<?
include_once('../hdr_general.php');
/* **************************************************************************************************** */
$pubmodule = $_REQUEST["module"];
$pubtask = $_REQUEST["task"];
$pubitemid = $_REQUEST["itemid"];
$pubtype = $_REQUEST["type"];
/* **************************************************************************************************** */
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../css/<?=$_SESSION['Xcssfile'];?>" type="text/css" media=all>
<link rel="stylesheet" href="../css/print.css" type="text/css" media="print">
<title>Purchasing Online (ZIKAY)</title>
</head>
<body leftmargin=5 topmargin=5 bgcolor="#ffffff">
<table border=0 cellspacing=0 cellpadding=0 width=760>
<tr valign=top>
<td valign=top width=760px>

  <?
  include_once('../models/mroModel.php');
  $mymroModel=new mroModel;

  // get project info
  // get mro details and items

  //$project_data = $myprojectModel->getdata_project

  $myprojectname = $_SESSION['Xprojectname'];
  $mro_data = $mymroModel->getdata_mro($pubitemid);
  $mro_items = $mymroModel->getlist_mroitems($pubitemid);
  ?>

  <table border=0 cellspacing=2 cellpadding=0 width=760>
  <tr valign=top>
  <td valign=top width=660 class=rptzikayheader style="text-decoration: none;"><img src="../gfx/zikay.png" width=45px height=56px align=left><br><span style="font-size: 14px;"><u>KEMBANG SERANTAU SDN BHD</u></span></td>
  <td valign=top width=100>
    <table border=0 cellspacing=0 cellpadding=2 width=100>
    <tr valign=top><td valign=top width=100 class=rptzikayconfidential style="font-size: 10px; text-align: left;">PU-SP-01-F1</td></tr>
    <tr valign=top><td valign=top width=100 class=rptzikayconfidential style="font-size: 10px; text-align: left; border-top: 0px;">Rev : 1</td></tr>
    </table>
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=760 colspan=2 class=rptzikayheader style="text-decoration: none; text-align: center;"><span style="font-size: 12px;"><u>MATERIAL REQUEST ORDER</u></span></td>
  </tr>
  </table>
  <br>

  <table border=0 cellspacing=2 cellpadding=0 width=760>
  <tr valign=top>
  <td valign=top width=100% class=cboxcontent>
    <table border=1 cellspacing=0 cellpadding=2 width=760 style="border: 1px solid black; border-collapse: collapse;">
    <tr valign=top>
    <td valign=top width=500 rowspan=2 class=listcontent style="border-left: 1px solid black; border-top: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black;">
      <table border=0 cellspacing=0 cellpadding=2 width=490>
      <tr valign=top>
      <td valign=top width=180 class=rptlistcontent>
      <b>Project Title</b>
      </td>
      <td valign=top width=310 class=rptlistcontent>
      : <u><?=$myprojectname;?></u>
      </td>
      </tr>
      <tr valign=top>
      <td valign=top width=180 class=rptlistcontent>
      <b>Date of Request</b>
      </td>
      <td valign=top width=310 class=rptlistcontent style="text-transform: uppercase;">
      : <u><?=unconverttounix($mro_data['mro_requestdate']);?></u>
      </td>
      </tr>
      <tr valign=top>
      <td valign=top width=180 class=rptlistcontent>
      <b>Expected Date of Delivery</b>
      </td>
      <td valign=top width=310 class=rptlistcontent>
      : <u><?=unconverttounix($mro_data['mro_deliverydate']);?></u>
      </td>
      </tr>
      <tr valign=top>
      <td valign=top width=180 class=rptlistcontent>
      <b>Backcharge / Debit Account</b>
      </td>
      <td valign=top width=310 class=rptlistcontent>
      : <u><?=$supplier_data['suppliername'];?></u>
      </td>
      </tr>
      </table>
    </td>
    <td valign=top width=260 class=listcontent style="border-left: 1px solid black; border-top: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black;">
      <table border=0 cellspacing=0 cellpadding=2 width=250>
      <tr valign=top>
      <td valign=top width=250 colspan=3 class=rptlistcontent>
      <br>
      MRO No. :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=mroidstr($mro_data['mro_id']);?>
      <br><br>
      </td>
      </tr>
      </table>
    </td>
    </tr>
    <tr valign=top>
    <td valign=top width=260 class=listcontent style="border-left: 1px solid black; border-top: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black;">
      <table border=0 cellspacing=0 cellpadding=2 width=250>
      <tr valign=top>
      <td valign=top width=250 class=rptlistcontent>
      Sub-con PO/Ref : <?=$mro_data['mro_subconref'];?>
      </td>
      </tr>
      <tr valign=top>
      <td valign=top width=250 class=rptlistcontent>
      Client MRO NO : <?=$mro_data['mro_clientref'];?>
      </td>
      </tr>
      </table>
    </td>
    </tr>
    </table>
    <br>

    <table border=0 cellspacing=0 cellpadding=2 width=760 style="border: 1px solid black; border-collapse: collapse;">
    <tr valign=top>
    <td valign=top width=40 class=rptlistheader style="text-transform: none;">Item</td>
    <td valign=top width=260 class=rptlistheader style="text-transform: none;">Description</td>
    <td valign=top width=80 class=rptlistheader style="text-transform: none;">Unit</td>
    <td valign=top width=80 class=rptlistheader style="text-transform: none;">Qty</td>
    <td valign=top width=150 class=rptlistheader style="text-transform: none;">Purpose</td>
    <td valign=top width=150 class=rptlistheader style="text-transform: none;">Remarks</td>
    </tr>
    <tr valign=top>
    <td valign=top width=40 class=rptlistnumber>&nbsp;</td>
    <td valign=top width=260 class=rptlistcontent-left>&nbsp;</td>
    <td valign=top width=80 class=rptlistcontent-left style="text-align: center;">&nbsp;</td>
    <td valign=top width=80 class=rptlistcontentnumeric-left>&nbsp;</td>
    <td valign=top width=150 class=rptlistcontent-left>&nbsp;</td>
    <td valign=top width=150 rowspan=500 class=rptlistcontent-left><br><?=richtext($mro_data['mro_remarks']);?>&nbsp;</td>
    </tr>

    <? foreach($mro_items as $myitem) { ?>

      <tr valign=top>
      <td valign=top width=40 class=rptlistnumber><?=$myitem['item_no'];?>&nbsp;</td>
      <td valign=top width=260 class=rptlistcontent-left><?=unescape($myitem['item_description']);?>&nbsp;</td>
      <td valign=top width=80 class=rptlistcontent-left style="text-align: center;"><?=$myitem['item_unit'];?>&nbsp;</td>
      <td valign=top width=80 class=rptlistcontentnumeric-left><?=number_format($myitem['item_quantity'],4);?>&nbsp;</td>
      <td valign=top width=150 class=rptlistcontent-left><?=$myitem['item_purpose'];?>&nbsp;</td>
      <!--<td valign=top width=150 class=rptlistcontent></td>-->
      </tr>

    <? } ?>

    <tr valign=top>
    <td valign=top width=40 height=500 class=rptlistnumber>&nbsp;</td>
    <td valign=top width=260 class=rptlistcontent-left>&nbsp;</td>
    <td valign=top width=80 class=rptlistcontent-left style="text-align: center;">&nbsp;</td>
    <td valign=top width=80 class=rptlistcontentnumeric-left>&nbsp;</td>
    <td valign=top width=150 class=rptlistcontent-left>&nbsp;</td>
    </tr>

    </table>

  </td>
  </tr>
  </table>
  <br>

  <table border=0 cellspacing=2 cellpadding=0 width=760>
  <tr valign=top>
  <td valign=top width=460 class=rptlistcontent>
  <b>Requested by Project Manager:</b><br><br><br><br>
  <u>Project Manager</u><br>
  Date: <?=unconverttounixslash(getdatestamp());?>
  </td>
  <td valign=top width=300 class=rptlistcontent>
  <b>Acknowledged by Purchasing Executive:</b><br><br><br><br>
  <u>Purchasing Executive</u><br>
  Date: <?=unconverttounixslash(getdatestamp());?>
  </td>
  </tr>
  </table>

</td>
</tr>

<tr valign=top>
<td valign=top width=760px style="background: #808080;">
<form action="../controllers/inputController.php" method="post" name="mroform" id="mroform">

  <table border=1 cellspacing=2 cellpadding=0 width=760>
  <tr valign=top>
  <td valign=top width=100 class=cboxcontent>Date</td>
  <td valign=top width=360 class=cboxcontent>Remarks</td>
  <td valign=top width=300 class=cboxcontent>Status</td>
  </tr>
  <tr valign=top>
  <td valign=top width=100 class=cboxcontent><input name="date" id="date" type="text" value="<?=unconverttounixslash(gettimestamp());?>" style="width: 90px;"></td>
  <td valign=top width=360 class=cboxcontent><input name="remarks" id="remarks" type="text" value="" style="width: 450px;"></td>
  <td valign=top width=300 class=cboxcontent>
  <button name="accept" id="accept" onClick="approveDocument();" style="width: 90px;"><img src='../gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Approve MRO</button>&nbsp;
  <button name="reject" id="reject" onClick="rejectDocument();" style="width: 90px;"><img src='../gfx/options/b_stop.png' class='actionbutton'>&nbsp;&nbsp;Reject MRO</button>&nbsp;
  <button name="cancel" id="cancel" onClick="cancelAction();" style="width: 90px;"><img src='../gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;
  </td>
  </tr>
  <input name="mropkey" id="mropkey" type="hidden" value="<?=$pubitemid;?>">
  <input name="type" id="type" type="hidden" value="<?=$pubtype;?>">
  <input name="userpkey" id="userpkey" type="hidden" value="<?=$_SESSION['Xuserpkey'];?>">
  <input name="officername" id="officername" type="hidden" value="<?=$user_data['staff_name'];?>">
  <input name="status" id="status" type="hidden" value="">
  <input name="job" id="job" type="hidden" value="mro_approve">

</form>
</td>
</tr>

</table>
</body>
</html>

<script type="text/javascript">

function approveDocument() {
  document.mroform.status.value='1'; document.mroform.submit();
  self.close;
}

function rejectDocument() {
  document.mroform.status.value='2'; document.mroform.submit();
  self.close;
}

function cancelAction() {
  self.close;
}

</script>
