  <?
  // Tab -----------------------------------------
  $tab_quantity=2;
  $tab_style=1;	// (single-row)
  $tab_name=array("&nbsp;&nbsp;<b>PO List</b>&nbsp;&nbsp;","&nbsp;<b>Completed PO</b>&nbsp;","&nbsp;<b>PO History</b>&nbsp;");
  if (isset($_REQUEST['tabid'])) $_SESSION['Xactivetab']=$_REQUEST['tabid'];
  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=po&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">
   <input name="tabid" id="tabid" type="hidden" value="0">
  <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=110 class=listheader>MRO No</td>
  <td valign=top width=110 class=listheader>RFQ No</td>
  <td valign=top width=250 class=listheader>Vendor Name</td>
  <td valign=top width=100 class=listheader>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) { ?>

    <? if (($mypo['recordno']>=$firstrec1)&&($mypo['recordno']<=$lastrec1)) { ?>

      <?
      // 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']);
      ?>

      <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=110 class=listcontent><?=mroidstr($mro_data['mro_id']);?>&nbsp;</td>
      <td valign=top width=110 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=100 class=listcontent>
      <?
      if ($mypo['po_cancel']=="0") {
        if ($mypo['po_status']=="0") {
          echo "Unknown";  
        } else if ($mypo['po_status']=="1") {
          echo "PO";
        } else if ($mypo['po_status']=="2") {
          echo "Partial";
        } else if ($mypo['po_status']=="3") {
          echo "Complete";
        }
      } else if ($mypo['po_cancel']=="1") {
        echo "Cancelled";
      } else if ($mypo['po_cancel']=="2") {
        echo "Rejected";
      }
      ?>
      </td>
      <td valign=top width=80 class=listcontent>
      <? if ($mypo['po_cancel']!=1) { ?>
	  <!--
        <a href="index.php?module=po&task=view&itemid=<?=$mypo['po_pkey'];?>"><img src="gfx/options/b_view.png" border=0 title="View" alt="View"></a>
		-->
		<a href="views/rpt_po.php?itemid=<?=$mypo['po_pkey'];?>" target="_blanks"><img src="gfx/options/b_view.png" border=0 title="View" alt="View"></a>
		
		<!-- tambahan -->
		
         <a href="index.php?module=po&task=view&itemid=<?=$mypo['po_pkey'];?>"><img src="gfx/options/file.png" border=0 title="View PO" alt="View PO"></a>	
      <? } else { ?>
        <a href="index.php?module=po&task=view&itemid=<?=$mypo['po_pkey'];?>"><img src="gfx/options/file.png" border=0 title="View" alt="View PO"></a>
        <? //if (($pubuseraccess['access_po_edit']==1)||($pubuserrole>=2)) { ?>
          <? //if ($mypo['po_status']=="0") { ?>
            <!--<a href="index.php?module=po&task=edit&itemid=<?=$mypo['po_pkey'];?>"><img src="gfx/options/b_edit.png" border=0 title="Edit" alt="Edit"></a>-->
            <!--<a href="index.php?module=po&task=delete&itemid=<?=$mypo['po_pkey'];?>"><img src="gfx/options/b_drop.png" border=0 title="Delete" alt="Delete"></a>-->
          <? //} ?>
        <? //} ?>
      <? } ?>
      </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>

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

  <!-- search form 2 -->
  <table border=1 cellspacing=1 cellpadding=2 width=928 style="border: 1px inset;">
  
  <form action="index.php?module=po&task=main" method="post" name="filterform1" id="filterform1">
  <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="pono1" id="pono1" value="<?=$filterpono1;?>" 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="podate1" id="podate1" value="<?=$filterpodate1;?>" 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="vendorname1" id="vendorname1" style="width: 235px;">
  <? $objsupplierpkey = $filtervendorname1; ?>
  <? include('object-selectsupplier.tpl'); ?>
  </select>
  </td>
  <td valign=top width=208 class=listcontent>
  <input name="pageno2" id="pageno2" type="hidden" value="1">
  <input name="tabid" id="tabid" type="hidden" value="1">
  <button name="filter1" id="filter1" 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>
  <!-- search fomr 2 end -->
  <!--
  <table border=1 cellspacing=1 cellpadding=2 width=928 style="border: 1px inset;">
  <form action="index.php?module=po&task=main" method="post" name="filterform2x" id="filterform2x">
  <input name="pageno2" id="pageno2" type="hidden" value="1">
  </form>
  </table>
-->
  <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=110 class=listheader>MRO No</td>
  <td valign=top width=110 class=listheader>RFQ No</td>
  <td valign=top width=350 class=listheader>Vendor Name</td>
  <td valign=top width=80 class=listheader>Options</td>
  </tr>

  <?
  $firstrec2 = (($pubpageno2-1)*20)+1;
  $lastrec2 = $firstrec2 + 19;
  $pagecount2 = 1;
  ?>

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

    <? if (($mypo['recordno']>=$firstrec2)&&($mypo['recordno']<=$lastrec2)) { ?>

      <?
      // 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']);
      ?>

      <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']);?>&nbsp;</td>
      <td valign=top width=120 class=listcontent><?=unconverttounixslash($mypo['po_date']);?>&nbsp;</td>
      <td valign=top width=110 class=listcontent><?=mroidstr($mro_data['mro_id']);?>&nbsp;</td>
      <td valign=top width=110 class=listcontent><?=itqidstr($itq_data['itq_rfqno']);?>&nbsp;</td>
      <td valign=top width=350 class=listcontent><?=$supplier_data['supplier_name'];?>&nbsp;</td>
      <td valign=top width=80 class=listcontent>
      <? if ($mypo['po_cancel']!=0) { ?>
        <a href="index.php?module=po&task=view&itemid=<?=$mypo['po_pkey'];?>"><img src="gfx/options/b_view.png" border=0 title="View" alt="View"></a>
      <? } else { ?>
        <a href="index.php?module=po&task=do&itemid=<?=$mypo['po_pkey'];?>"><img src="gfx/options/b_view.png" border=0 title="View DOs" alt="View DOs"></a>
        <a href="index.php?module=po&task=view&itemid=<?=$mypo['po_pkey'];?>"><img src="gfx/options/file.png" border=0 title="View PO" alt="View PO"></a>
        <? //if (($pubuseraccess['access_po_edit']==1)||($pubuserrole>=2)) { ?>
          <? //if ($mypo['po_status']=="0") { ?>
            <!--<a href="index.php?module=po&task=edit&itemid=<?=$mypo['po_pkey'];?>"><img src="gfx/options/b_edit.png" border=0 title="Edit" alt="Edit"></a>-->
            <!--<a href="index.php?module=po&task=delete&itemid=<?=$mypo['po_pkey'];?>"><img src="gfx/options/b_drop.png" border=0 title="Delete" alt="Delete"></a>-->
          <? //} ?>
        <? //} ?>
      <? } ?>
      </td>
      </tr>

    <? } ?>

  <? } ?>

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

  </table>

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

  </div>

 <?php 
 //print_r($_POST);
 
 //print_r(get_defined_functions());
 ?>

  <script type="text/javascript">

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

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

  function switchPage2(pageno) {
    document.filterform1.pageno2.value=pageno;
    document.filterform1.submit();
  }

  function switchPage3(pageno) {
    document.filterform3.pageno3.value=pageno;
    document.filterform3.submit();
  }

  </script>
