if(session_is_registered("admin"))
  {
  function showBookingList($sb,$m,$p,$offs,$orderstate)
  {
  $offset = $offs;
  $querySelect = "select count(*) from  tblordermanage";
  $queryResult = query_select($querySelect,$nRows);
  $count = mysql_result($queryResult,0,0);
  $maxt = round($count/$offset,2);
  $last = ceil($maxt);
  
  if($p==1) 
  {
  $start = 0;
  $n = $p+1;
  $first = "<a href=\"viewQuoted.php?page=1&orderstate=$orderstate\"><span class='w_text'><u>First</u></span></a>";
  $next = "<a href=\"viewQuoted.php?page=$n&orderstate=$orderstate\"><span class='w_text'><u>Next</u></span></a>";
  $previous = "<span class='caption'>Previous</span>";
  $last = "<a href=\"viewQuoted.php?page=$last&orderstate=$orderstate\"><span class='w_text'><u>Last</u></span></a>";
  $stp = $start+1;
  
  if ($count==0)
  {
  $stp = 0;
  $ltp = 0;
  }
  else if ($count<=$offset) 
  {
  $ltp = $count;
  $next = "<span class='caption'>Next</span>";
  }
  else 
  {
  $ltp = $stp+$offset-1;
  }
  }
  else if($p==$last) 
  {
  $start = $p*$offset-$offset;
  $pr = $p-1;
  $first = "<a href=\"viewQuoted.php?page=1&orderstate=$orderstate\" class='caption'>First</a>";
  $next = "<span class='caption'>Next</span>";
  $previous = "<a href=\"viewQuoted.php?page=$pr&orderstate=$orderstate\" class='caption'>Previous</a>";
  $last = "<a href=\"viewQuoted.php?page=$last&orderstate=$orderstate\" class='caption'>Last</a>";
  $stp = $start+1;
  $ltp = $count;
  }
  else if($p>1 and $p<$last)
  {
  $start = $p*$offset-$offset;
  $n = $p+1;
  $pr = $p-1;
  $first = "<a href=\"viewQuoted.php?page=1&orderstate=$orderstate\" class='caption'>First</a>";
  $next = "<a href=\"viewQuoted.php?page=$n&orderstate=$orderstate\" class='caption'>Next</a>";
  $previous = "<a href=\"viewQuoted.php?page=$pr&orderstate=$orderstate\" class='caption'>Previous</a>";
  $last = "<a href=\"viewQuoted.php?page=$last&orderstate=$orderstate\" class='caption'>Last</a>";
  $stp = $start+1;
  $ltp = $stp+$offset-1;
  }
  
  
  if(empty($orderstate))
  {
  $orderstate='Q';
  }
  $query1Select = "select * from tblordermanage where orderstate='".$orderstate."' and processstate='".Q."' order By arrivedate limit ". $start .",".$offset;
  
  $query1Result = query_select($query1Select,$nRows);
  $nch = 0; 
  
  if(mysql_num_rows($query1Result)>=1)
  {
  $str.="<tr>
  
  <td align=\"right\">   $first    $previous    $next    $last</td>
  </tr>
  <tr>
  <td align='left' colspan='2'>
  <table border='0' width='100%'>
  <tr>
  <td width='22%' bgcolor='#FFFFFF' class='title' align='left'><font color='#000000'>Customer Name</font></td>
  <td width='15%' bgcolor='#FFFFFF' class='title' align='center'><font color='#000000'>Arrive date</font></td>
  <td width='10%' bgcolor='#FFFFFF' class='title' align='center'><font color='#000000'>Quoted</font></td>
  <td width='10%' bgcolor='#FFFFFF' class='title' align='center'><font color='#000000'>Process State</font></td>
  
  <td width='15%' bgcolor='#FFFFFF' class='title' align='center'><font color='#000000'>E-Mail</font></td>
  <td width='10%' bgcolor='#FFFFFF' class='title' align='center'><font color='#000000'>Arrive Station</font></td>
  
  </tr>";
  
  while($arr = mysql_fetch_array($query1Result))
  {
  $yquery="select * from tblyear ORDER BY yid";
  $yresult=query_select($yquery,$totalYearRecFound);
  
  $cId = $arr['id'];
  $name = $arr['name'];
  $ostate=$arr['orderstate'];
  $pstate=$arr['processstate'];
  
  if($ostate == 'B')
  {
  $ostate ="Booking";
  }
  if($ostate == 'Q')
  {
  $ostate ="Quoted";
  }
  //$pstate=$arr['processstate'];
  $arrivedate = $arr['arrivedate'];
  $datearr = split("-",$arrivedate);
  $year=$datearr[0];
  $month=$datearr[1];
  $day=$datearr[2];
  
  $yquery="select * from tblyear where yid = $year";
  $yresult=query_select($yquery,$totalYearRecFound);
  $yrow=mysql_fetch_array($yresult);
  $year=$yrow['caption'];
  $monquery="select * from tblmonth where mid = $month";
  $monresult=query_select($monquery,$totalMonRecFound);
  $monrow=mysql_fetch_array($monresult);
  $month=$monrow['caption'];
  $adate="$year-$month-$day";
  $email = $arr['email'];
  $contactno = $arr['contactnumber'];
  $arrivestation = $arr['arrivestation'];
  $cquery = "select * from tblcity where cityid = $arrivestation";
  $cresult=query_select($cquery,$totalMonRecFound);
  $crow=mysql_fetch_array($cresult);
  $city=$crow['caption'];
  
  $str.="<tr>
  
  <td class='w_text' align='center' valign='top'>$name</td>
  <td class='w_text' align='center' valign='top'>$adate</td>
  <td class='w_text' align='center' valign='top'>$ostate</td>
  <td class='w_text' align='center' valign='top'>$pstate</td>
  <td class='w_text' align='center' valign='top'><a href='mailto:$email'>
  <span class='w_text'><u>$email</u></span></a></td>
  <td class='w_text' align='center' valign='top'>$city</td>
  
  
  </tr>";
  }
  $str.="</table></td></tr>";
  }
  else
  {
  $str = "
  <tr>
  <td valign='top' class='w_text'>There are no records !</td>
  </tr>";
  }
  return $str;
  }
  if($message) 
  {
  $message="$message";
  }
 if($mode == "delete" and $cid)
  {
  $query2Delete = "delete from tblordermanage where id=$cid";
  $query2Result = query_delete($query2Delete);
  
  if ($query2Result)
  {
  $message = "Order deleted successfully.";
  }
  }
 if($page)
  {
  $page = $page; 
  }
  else
  {
  $page = 1;
  }
  $bookingList = showBookingList($sortby,$mode,$page,25,$_GET['orderstate']);
this function will be sort data in both mode and and up to 25 record from table and
delete and edit opetions you can add..
No comments:
Post a Comment