  <?
  error_reporting(0);
  // Tab -----------------------------------------
  $tab_quantity=1;
  $tab_style=1;	// (single-row)
  $tab_name=array("&nbsp;<b>Update Received</b>&nbsp;");
  include_once('tab.php');
  //----------------------------------------------
  ?>
  <table width="99%" border="0" cellspacing="0" cellpadding="0">
  <tr valign=top>
  <td valign=top>

  <div id='tab-body:0' class='tab-body' <? if ($_SESSION['Xactivetab']=="0") { echo "style='border: none; display: block;'"; } else { echo "style='border: none; display: none;'"; } ?>>

  <!--
  Boleh search by MRO no, date request (OR)			
  boleh search by rfq no, mro no, vendor name (OR)			
  boleh search by po no, po date, vendor name (OR)			
  -->

  <table border=1 cellspacing=1 cellpadding=2 width=928 style="border: 1px inset;">
  <form action="index.php?module=do&task=main" method="post" name="filterform" id="filterform">
  <tr valign=top>
  <td valign=top width=928 colspan=9 class=listfilterheader>Filters</td>
  </tr>
  <tr valign=top>
  <td valign=top width=50 class=listcontent>PO No :</td>
  <td valign=top width=120 class=listcontent><input name="pono" id="pono" value="<?=$filterpono;?>" style="width: 115px;" onKeypress="integerOnly();"></td>
  <td valign=top width=70 class=listcontent>PO Date:</td>
  <td valign=top width=120 class=listcontent><input name="podate" id="podate" value="<?=$filterpodate;?>" maxlength=10 style="width: 115px;" onKeypress="dateOnly();"></td>
  <td valign=top width=120 class=listcontent>Vendor Name :</td>
  <td valign=top width=240 class=listcontent>
  <select name="vendorname" id="vendorname" style="width: 235px;">
  <? $objsupplierpkey = $filtervendorname; ?>
  <? include('object-selectsupplier.tpl'); ?>
  </select>
  </td>
  <td valign=top width=208 class=listcontent>
  <input name="pageno1" id="pageno1" type="hidden" value="1">
  <button name="filter" id="filter" type="submit" style="width: 80px;">&nbsp;<img src='gfx/options/b_find.png' class='actionbutton'>&nbsp;Search&nbsp;</button>&nbsp;
  <button name="showall" id="showall" style="width: 90px;" onClick="unFilter();">&nbsp;<img src='gfx/options/b_clear.png' class='actionbutton'>&nbsp;Show All&nbsp;</button>&nbsp;
  </td>
  </tr>
  </form>
  </table>
  <br>

  <table border=1 cellspacing=1 cellpadding=2 width=928 style="border: 1px inset;">

  <tr valign=top>
  <td valign=top width=48 class=listheader>No.</td>
  <td valign=top width=110 class=listheader>PO No</td>
  <td valign=top width=120 class=listheader>PO Date</td>
  <td valign=top width=100 class=listheader>MRO No</td>
  <td valign=top width=100 class=listheader>RFQ No</td>
  <td valign=top width=250 class=listheader>Vendor Name</td>
  <td valign=top width=120 class=listheader>Exp. Delivery</td>
  <td valign=top width=120 class=listheader>Delivery Status</td>
  <td valign=top width=80 class=listheader>Options</td>
  </tr>

  <?
  $firstrec1 = (($pubpageno1-1)*20)+1;
  $lastrec1 = $firstrec1 + 19;
  $pagecount1 = 1;
  ?>

  <? foreach ($po_list as $mypo) { ?>

     <?php 
	 //filtering for po cancel
	 //$heh = "SELECT po_cancel FROM po_details WHERE po_pkey = '".$mypo['po_pkey']."'";
	 //$heh2 = mysql_query($heh);
	 //$heh3 = mysql_fetch_assoc($heh2);
	 //$heh4 = $heh3['po_cancel'];
	 
	?>
    <? if (($mypo['recordno']>=$firstrec1)&&($mypo['recordno']<=$lastrec1) && ($mypo['po_cancel'] == 0)) { ?>

		
      <?
      // get po total and do totals

      include_once('models/supplierModel.php');
      include_once('models/mroModel.php');
      include_once('models/itqModel.php');
      $mysupplierModel=new supplierModel;
      $mymroModel=new mroModel;
      $myitqModel=new itqModel;

      $supplier_data = $mysupplierModel->getdata_supplier($mypo['po_supplierpkey']);
      $mro_data = $mymroModel->getdata_mro($mypo['po_mropkey']);
      $itq_data = $myitqModel->getdata_itq($mypo['po_itqpkey']);
      ?>
      <?php //echo $mypo['po_pkey']."-".$mypo['po_cancel'];?>
      <tr valign=top>
      <td valign=top width=48 class=listnumber><?=$mypo['recordno'];?></td>
      <td valign=top width=110 class=listcontent>
	  
	  <?//=poidstr($mypo['po_no'],$mypo['po_revno']);?>
	  <?=poidstr($mypo['po_no']);?>
	  &nbsp;</td>
      <td valign=top width=120 class=listcontent><?=unconverttounixslash($mypo['po_date']);?>&nbsp;</td>
      <td valign=top width=100 class=listcontent><?=mroidstr($mro_data['mro_id']);?>&nbsp;</td>
      <td valign=top width=100 class=listcontent><?=itqidstr($itq_data['itq_rfqno']);?>&nbsp;</td>
      <td valign=top width=250 class=listcontent><?=$supplier_data['supplier_name'];?>&nbsp;</td>
      <td valign=top width=120 class=listcontent><?=unconverttounixslash($mro_data['mro_deliverydate']);?>&nbsp;</td>
      <td valign=top width=120 class=listcontent> 
	  <!-- 
	 
	  -->
	 <?php 
	 
	  $w1 = "SELECT * FROM do_items WHERE item_popkey = '".$mypo['po_pkey']."'";
	  $w2 = mysql_query($w1);
	  $w3 = mysql_num_rows($w2);
	  //echo $w3;
	  if ($w3 == 0) { echo "<span style=\"color: red; font-weight:bold\">NEW</span>"; }else{echo "<span style=\"color:blue; font-weight:bold;\">PARTIAL</span>"; }
	  echo "<br />DO : ".$w3;
	  
	  $x1 = "SELECT * FROM po_items WHERE item_popkey = '".$mypo['po_pkey']."'";
	  $x2 = mysql_query($x1);
	  $x3 = mysql_num_rows($x2);
	  
	  echo "<br />Item : ".$x3;
	 ?>
	  
	  </td>
	  <td valign=top width=80 class=listcontent>
      <? if (($pubuseraccess['access_do_edit']==1)||($pubuserrole>=2)) { ?>
        <button name="adddo" id="adddo" type="button" style="width: 76px;" onClick="addDO('<?=$mypo['po_pkey'];?>');">&nbsp;<img src='gfx/options/b_edit.png' class='actionbutton'>&nbsp;Edit DO&nbsp;</button>
      <? } ?>&nbsp;
      </td>
      </tr>

    <? } ?>

  <? } ?>

  <?
  $pagecount1 = intval($mypo['recordno']/20) + 1;
  ?>

  </table>

  <br>
  <?
  echo "<b>Page : </b>";
  for ($i=1;$i<=$pagecount1;$i++) {
    if ($i==$pubpageno1) {
      echo "[<u>".$i."</u>]&nbsp;";	//-&nbsp;";
    } else {
      echo "<span style='cursor: hand;' onClick='switchPage1(".$i.");'><b>".$i."</b></span>&nbsp;";	//-&nbsp;";
    }
    if (($i % 25)==0) echo "<br>";
  }
  ?>

  </div>

  <script type="text/javascript">

  function unFilter() {
    document.filterform.pono.value="";
    document.filterform.podate.value="";
    document.filterform.vendorname.value="";
    document.filterform.submit();
  }

  function switchPage1(pageno) {
    document.filterform.pageno1.value=pageno;
    document.filterform.submit();
  }

  function addDO(popkey) {
    document.location='index.php?module=do&task=add&itemid='+popkey;
  }

  </script>
