  <?
  // Tab -----------------------------------------
  $tab_quantity=2;
  $tab_style=1;	// (single-row)
  $tab_name=array("&nbsp;&nbsp;<b>MRO List</b>&nbsp;&nbsp;","&nbsp;<b>MRO History</b>&nbsp;");
  //$tab_name=array("&nbsp;&nbsp;<b>MRO List</b>&nbsp;&nbsp;","&nbsp;<b>MRO History</b>&nbsp;","&nbsp;&nbsp;<b>New MRO</b>&nbsp;&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;'"; } ?>>

  <table border=1 cellspacing=1 cellpadding=2 width=928 style="border: 1px inset;">
  <form action="index.php?module=mro&task=list" 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=60 class=listcontent>MRO No :</td>
  <td valign=top width=120 class=listcontent><input name="mrono1" id="mrono1" value="<?=$filtermrono1;?>" style="width: 115px;" onKeypress="integerOnly();"></td>
  <td valign=top width=70 class=listcontent>MRO Date:</td>
  <td valign=top width=120 class=listcontent><input name="mrodate1" id="mrodate1" value="<?=$filtermrodate1;?>" maxlength=10 style="width: 115px;" onKeypress="dateOnly();"></td>
  <td valign=top width=350 class=listcontent>&nbsp;</td>
  <td valign=top width=208 class=listcontent>
  <input name="tabid" id="tabid" type="hidden" value="0">
  <input name="pageno1" id="pageno1" 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="showall1" id="showall1" style="width: 90px;" onClick="unFilter1();">&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=42 class=listheader>No.</td>
  <td valign=top width=70 class=listheader>MRO No</td>
  <td valign=top width=173 class=listheader>MRO Type</td>
  <td valign=top width=116 class=listheader>Type of Trade</td>
  <td valign=top width=108 class=listheader>Request Date</td>
  <td valign=top width=100 class=listheader>Delivery Date</td>
  <td valign=top width=111 class=listheader>Requestor</td>
  <td valign=top width=78 class=listheader>Status</td>  
  <td valign=top width=64 class=listheader>Options</td>
  </tr>

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

  <? foreach ($mro_submitted as $mymro) { ?>

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

      <tr valign=top>
      <td valign=top width=42 class=listnumber><?=$mymro['recordno'];?></td>
      <td valign=top width=70 class=listcontent><?=mroidstr($mymro['mro_id']);//,$mymro['mro_revno']);?>&nbsp;</td>
      <td valign=top width=173 class=listcontent>
      <?
      if ($mymro['mro_type']=="1") {
        echo "Budgeted Material";
      } else if ($mymro['mro_type']=="2") {
        echo "Budgeted Material Exceeded";
      } else if ($mymro['mro_type']=="3") {
        echo "Non Budgeted Material - VO";
      } else if ($mymro['mro_type']=="4") {
        echo "Non Budgeted Material - Subcon";
      } else {
        echo "Unknown";
      }
      ?>      </td>
	
	  <td valign=top width=116 class=listcontent>
		<?php
		 //arie add 
		  	$varItemID = $mymro['tradedescription'];
	  		if ($varItemID=='')
				{echo "-";}
			else
				{echo $varItemID;}
	  ?>	  
       </td>
      <td valign=top width=108 class=listcontent><?=unconverttounixslash($mymro['mro_requestdate']);?>&nbsp;</td>
      <td valign=top width=100 class=listcontent><?=unconverttounixslash($mymro['mro_deliverydate']);?>&nbsp;</td>
      <td valign=top width=111 class=listcontent><?=$mymro['mro_requestor'];?>&nbsp;</td>
      <td valign=top width=78 class=listcontent>
      <?
      if ($mymro['mro_cancel']=="1") {
        echo "Cancelled";
      } else {
        if (($mymro['mro_status']=="0")||($mymro['mro_status']=="9")) {
          if ($mymro['mro_cancel']=="2") {
            echo "Rejected";
          } else {
            echo "New";	//"Not Submitted";  
          }
        } else if ($mymro['mro_status']=="1") {
		        if ($mymro['mro_type']=="1") {
					echo "To Approved";
					} else { echo "To Recommend";}
				
		} else if ($mymro['mro_status']=="2") {
          //echo "Recommended";
		  echo "To Approved";
        } else if ($mymro['mro_status']=="3") {
          echo "Approved";
        } else if ($mymro['mro_status']=="4") {
          echo "ITQ";
        } else if ($mymro['mro_status']=="5") {
          echo "PO";
        }
      }
	  
      ?>      </td>
      
      <td valign=top width=64 class=listcontent>
      <? if ($mymro['mro_cancel']==1) { ?>
        <? if (($pubuseraccess['access_mro_view']==1)||($pubuserrole>=2)) { ?>
          <a href="index.php?module=mro&task=view&itemid=<?=$mymro['mro_pkey'];?>"><img src="gfx/options/b_edit.png" border=0 title="Edit" alt="Edit"></a>
		  <a href="views/rpt_mro.php?itemid=<?=$mymro['mro_pkey'];?><?php if ($mymro['mro_cancel']=="2") { echo "&y=reject"; }?>" target="_blanks"><img src="gfx/options/b_view.png" border=0 title="View" alt="View"></a>
       
	   <? } ?>
      <? } else { ?>
        <? if (($pubuseraccess['access_mro_view']==1)||($pubuserrole>=2)) { ?>
          
		  <!-- yusr bg nampak butang kanta jer -->
		  <? if (($pubuseraccess['access_mro_edit']==1)||($pubuserrole>=2)) {?>
		  <a href="index.php?module=mro&task=view&itemid=<?=$mymro['mro_pkey'];?>"><img src="gfx/options/b_edit.png" border=0 title="Edit" alt="Edit"></a> 
          
           		  
		  <?php } else {} ?>
		   <!-- end bg nampak butang kanta je -->
		   
		  <a href="views/rpt_mro.php?itemid=<?=$mymro['mro_pkey'];?><?php if ($mymro['mro_cancel']=="2") { echo "&y=reject"; }?>" target="_blanks"><img src="gfx/options/b_view.png" border=0 title="View" alt="View"></a>
        <? } ?>
        <? 
        if ($mymro['mro_type']==1) {
          if (($pubuseraccess['access_mro_approvenormal']==1)||($pubuserrole>=2)) {
            //if ($mymro['mro_status']==1) {
              echo "<a href=\"index.php?module=mro&task=approvenormal&itemid=".$mymro['mro_pkey']."\"><img src=\"gfx/options/b_approve2.png\" border=0 title=\"View and Approve/Reject/Cancel\" alt=\"View and Approve/Reject/Cancel\"></a>";
            //}
          }
        } else {
          if (($pubuseraccess['access_mro_recommendvariance']==1)||($pubuserrole>=2)) {
            if ($mymro['mro_status']==1) {
              echo "<a href=\"index.php?module=mro&task=recommend&itemid=".$mymro['mro_pkey']."\"><img src=\"gfx/options/b_approve2.png\" border=0 title=\"Recommend/Reject/Cancel\" alt=\"Recommend/Reject/Cancel\"></a>";
            }
          }
          if (($pubuseraccess['access_mro_approvevariance']==1)||($pubuserrole>=2)) {
            if ($mymro['mro_status']==2) {
              echo "<a href=\"index.php?module=mro&task=approvevariance&itemid=".$mymro['mro_pkey']."\"><img src=\"gfx/options/b_approve2.png\" border=0 title=\"View and Approve/Reject/Cancel\" alt=\"View and Approve/Reject/Cancel\"></a>";
            }
          }
        }
        ?>
        <? //if (($pubuseraccess['access_mro_edit']==1)||($pubuserrole>=2)) { ?>
          <? //if ($mymro['mro_status']=="0") { ?>
            <!--<a href="index.php?module=mro&task=edit&itemid=<?=$mymro['mro_pkey'];?>"><img src="gfx/options/b_edit.png" border=0 title="Edit" alt="Edit"></a>-->
            <!--<a href="index.php?module=mro&task=delete&itemid=<?=$mymro['mro_pkey'];?>"><img src="gfx/options/b_drop.png" border=0 title="Delete" alt="Delete"></a>-->
          <? //} ?>
        <? //} ?>
      <? } ?>      </td>
      </tr>

    <? } ?>

  <? } ?>

  <?
  $pagecount1 = intval($mymro['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;'"; } ?>>

  <table border=1 cellspacing=1 cellpadding=2 width=928 style="border: 1px inset;">
  <form action="index.php?module=mro&task=list" method="post" name="filterform2" id="filterform2">
  <tr valign=top>
  <td valign=top width=928 colspan=9 class=listfilterheader>Filters</td>
  </tr>
  <tr valign=top>
  <td valign=top width=60 class=listcontent>MRO No :</td>
  <td valign=top width=120 class=listcontent><input name="mrono2" id="mrono2" value="<?=$filtermrono2;?>" style="width: 115px;" onKeypress="integerOnly();"></td>
  <td valign=top width=70 class=listcontent>MRO Date:</td>
  <td valign=top width=120 class=listcontent><input name="mrodate2" id="mrodate2" value="<?=$filtermrodate2;?>" maxlength=10 style="width: 115px;" onKeypress="dateOnly();"></td>
  <td valign=top width=350 class=listcontent>&nbsp;</td>
  <td valign=top width=208 class=listcontent>
  <input name="tabid" id="tabid" type="hidden" value="1">
  <input name="pageno2" id="pageno2" type="hidden" value="1">
  <button name="filter2" id="filter2" type="submit" style="width: 80px;">&nbsp;<img src='gfx/options/b_find.png' class='actionbutton'>&nbsp;Search&nbsp;</button>&nbsp;
  <button name="showall2" id="showall2" style="width: 90px;" onClick="unFilter2();">&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=80 class=listheader>MRO No</td>
  <td valign=top width=110 class=listheader>Request Date</td>
  <td valign=top width=110 class=listheader>Delivery Date</td>
  <td valign=top width=200 class=listheader>Requestor</td>
  <td valign=top width=200 class=listheader>AUTHORIZED/Cancel By <!-- Approved By --></td>
  <td valign=top width=100 class=listheader>Status</td>
  <td valign=top width=80 class=listheader>Options</td>
  </tr>

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

  <? foreach ($mro_approved as $mymro) { ?>

    <? if (($mymro['recordno']>=$firstrec2)&&($mymro['recordno']<=$lastrec2)) { ?>
	
		<? //if (($mymro['mro_status']=="0")||($mymro['mro_status']=="9")) { 
		       if ($mymro['mro_cancel']=="2") { } else { // utk filter reject
		
		 ?>

      <tr valign=top>
      <td valign=top width=48 class=listnumber><?=$mymro['recordno'];?></td>
      <td valign=top width=80 class=listcontent><?=mroidstr($mymro['mro_id']);//,$mymro['mro_revno']);?>&nbsp;</td>
      <td valign=top width=110 class=listcontent><?=unconverttounixslash($mymro['mro_requestdate']);?>&nbsp;</td>
      <td valign=top width=110 class=listcontent><?=unconverttounixslash($mymro['mro_deliverydate']);?>&nbsp;</td>
      <td valign=top width=200 class=listcontent><?=$mymro['mro_requestor'];?>&nbsp;</td>
      <td valign=top width=200 class=listcontent><?=$mymro['mro_approver'];?>&nbsp;</td>
      <td valign=top width=100 class=listcontent>
      <?
      if ($mymro['mro_cancel']=="1") {
        echo "Cancelled";
      } else {
        if (($mymro['mro_status']=="0")||($mymro['mro_status']=="9")) {
          if ($mymro['mro_cancel']=="2") {
            echo "Rejected";
          } else {
            echo "New";	//"Not Submitted";  
          }
        } else if ($mymro['mro_status']=="1") {
          echo "Submitted";
        } else if ($mymro['mro_status']=="2") {
          echo "Recommended";
        } else if ($mymro['mro_status']=="3") {
          echo "Approved";
        } else if ($mymro['mro_status']=="4") {
          echo "ITQ";
        } else if ($mymro['mro_status']=="5") {
          echo "PO";
        }
      }
      ?>
      </td>
      <td valign=top width=80 class=listcontent>
      <!--<a href="index.php?module=mro&task=view&itemid=<?=$mymro['mro_pkey'];?>"><img src="gfx/options/b_view.png" border=0 title="View" alt="View"></a>-->
      <? if (($pubuseraccess['access_mro_view']==1)||($pubuserrole>=2)) { ?>
        <!--<img src="gfx/options/b_view.png" border=0 title="View" alt="View" style="cursor: pointer;" onClick="mro_button_print('<?=$mymro['mro_pkey'];?>');"></a>
		-->
		<a href="views/rpt_mro.php?itemid=<?=$mymro['mro_pkey'];?>" target="_blanks"><img src="gfx/options/b_view.png" border=0 title="View" alt="View"></a>
      <? } ?>
      <? if (($mymro['mro_status']=="3")&&($mymro['mro_cancel']!="1")) { ?>
        <? // aritu status != 5.. ikut nafsu dorang jer la buat masa ni ; ?>
        <? if (($pubuseraccess['access_itq_edit']==1)||($pubuserrole>=2)) { ?>
          <a href="index.php?module=itq&task=generate&itemid=<?=$mymro['mro_pkey'];?>"><img src="gfx/options/file.png" border=0 title="Create ITQ" alt="Create ITQ"></a>
        <? } ?>
      <? } ?>
      </td>
      </tr>

    <? } ?>

  <?  }} // ?>

  <?
  $pagecount2 = intval($mymro['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>

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

  <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=120 class=listheader>MRO No</td>
  <td valign=top width=140 class=listheader>Request Date</td>
  <td valign=top width=140 class=listheader>Delivery Date</td>
  <td valign=top width=300 class=listheader>Requestor</td>
  <td valign=top width=100 class=listheader>Status</td>
  <td valign=top width=80 class=listheader>Options</td>
  </tr>

  <? foreach ($mro_new as $mymro) { ?>

    <tr valign=top>
    <td valign=top width=48 class=listnumber><?=$mymro['recordno'];?></td>
    <td valign=top width=120 class=listcontent><?=mroidstr($mymro['mro_id']);//,$mymro['mro_revno']);?>&nbsp;</td>
    <td valign=top width=140 class=listcontent><?=unconverttounixslash($mymro['mro_requestdate']);?>&nbsp;</td>
    <td valign=top width=140 class=listcontent><?=unconverttounixslash($mymro['mro_deliverydate']);?>&nbsp;</td>
    <td valign=top width=300 class=listcontent><?=$mymro['mro_requestor'];?>&nbsp;</td>
    <td valign=top width=100 class=listcontent>
    <?
    if ($mymro['mro_cancel']=="1") {
      echo "Cancelled";
    } else if ($mymro['mro_cancel']=="2") {
      echo "Rejected";
    } else {
      if ($mymro['mro_status']=="0") {
        echo "New";  
      } else if ($mymro['mro_status']=="1") {
        echo "Submitted";
      } else if ($mymro['mro_status']=="2") {
        echo "Recommended";
      } else if ($mymro['mro_status']=="3") {
        echo "Approved";
      } else if ($mymro['mro_status']=="4") {
        echo "ITQ";
      } else if ($mymro['mro_status']=="5") {
        echo "PO";
      }
    }
    ?>
    </td>
    <td valign=top width=80 class=listcontent>
    <? if (($pubuseraccess['access_mro_edit']==1)||($pubuserrole>=2)) { ?>
      <a href="index.php?module=mro&task=view&itemid=<?=$mymro['mro_pkey'];?>"><img src="gfx/options/b_view.png" border=0 title="View" alt="View"></a>
    <? } ?>
    <? //if (($pubuseraccess['access_mro_edit']==1)||($pubuserrole>=2)) { ?>
      <? //if ($mymro['mro_status']=="0") { ?>
        <!--<a href="index.php?module=mro&task=edit&itemid=<?=$mymro['mro_pkey'];?>"><img src="gfx/options/b_edit.png" border=0 title="Edit" alt="Edit"></a>-->
        <!--<a href="index.php?module=mro&task=delete&itemid=<?=$mymro['mro_pkey'];?>"><img src="gfx/options/b_drop.png" border=0 title="Delete" alt="Delete"></a>-->
      <? //} ?>
    <? //} ?>
    </td>
    </tr>

  <? } ?>

  </table>

  </div>

  <script type="text/javascript">

  function unFilter1() {
    document.filterform1.mrono1.value="";
    document.filterform1.mrodate1.value="";
    document.filterform1.submit();
  }

  function unFilter2() {
    document.filterform2.mrono2.value="";
    document.filterform2.mrodate2.value="";
    document.filterform2.submit();
  }

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

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

  </script>
