<?
# last update 18 july 2010
include_once('../hdr_general.php');
/* **************************************************************************************************** */
$pubmodule = $_REQUEST["module"];
$pubtask = $_REQUEST["task"];
$pubitemid = $_REQUEST["itemid"];
/* **************************************************************************************************** */
?>
<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>PMS-EVO</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');
  include_once('../models/supplierModel.php');
  $mymroModel=new mroModel;
  $mysupplierModel=new supplierModel;

  // 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);
  if ($mro_data['mro_status']=="9") {
    $mro_rejection = $mymroModel->getdata_lastapproval($pubitemid);
  }
  $supplier_data = $mysupplierModel->getdata_supplier($mro_data['mro_debitaccount']);
  ?>

  <table border=0 cellspacing=2 cellpadding=0 width=760>
  <tr valign=top>
  <td valign=top width=100>&nbsp;</td>
  <!--<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=560 class=rptzikayheader style="text-decoration: none; text-align: center;"><img src="../gfx/zikayheader.png" style="width: 226px; height: 82px;"><!-- 390/87 416/93 519/116 --><!--<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: right;">PU-SP-01-F1</td></tr>
    <tr valign=top><td valign=top width=100 class=rptzikayconfidential style="font-size: 10px; text-align: right; border-top: 0px;">Rev : 3</td></tr>
    </table>
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=760 colspan=3 class=rptzikayheader style="text-decoration: none; text-align: center;"><br><span style="font-size: 12px;"><u>MATERIAL REQUISITION 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=560 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=550>
      <tr valign=top>
      <td valign=top width=180 class=rptlistcontent>
      <b>Project Title</b>
      </td>
	  <?php if (strlen($myprojectname) >= 48){ 
	  $aku = "1";
	  $lol = 96;
	  $lola = $lol - strlen($myprojectname);
	  include 'nb.php';
	  
	  //$myprojectnameku = $myprojectname;
	  //$myprojectnameku = "<u>" .$myprojectname. "" .$nb. "</u>";
	  $myprojectnameku = $myprojectname;
	  //$myprojectnameku = strlen($myprojectname[48]);
	  } else { 
	  $aku ="1"; 
	  //$myprojectnameku = "<u>" .$myprojectname. "</u>";
	  $myprojectnameku = $myprojectname;
	  }
	  ?>
	  
      <td valign=top width=10 class=rptlistcontent>:</td>
      <td valign=top width=340 class=rptlistcontent style="border-bottom: 1px solid black;">
      
	
	  <?echo substr($myprojectnameku,0,48);?>
	 
      </td>
      <td valign=top width=20 class=rptlistcontent>&nbsp;</td>
      </tr>
      <tr valign=top>
      <td valign=top width=180t>&nbsp;</td>
      <td valign=top width=10>&nbsp;</td>
      <td valign=top width=340 class=rptlistcontent style="border-bottom: 1px solid black;">
	  <?echo substr($myprojectnameku,48);?>&nbsp;
	  </td>
      <td valign=top width=20 class=rptlistcontent>&nbsp;</td>
      </tr>
      <tr valign=top>
      <td valign=top width=180 class=rptlistcontent>
      <b>Date of Request</b>
      </td>
      <td valign=top width=10 class=rptlistcontent>:</td>
      <td valign=top width=340 class=rptlistcontent style="border-bottom: 1px solid black;">
      <?=unconverttounix($mro_data['mro_requestdate']);?>
      </td>
      <td valign=top width=20 class=rptlistcontent>&nbsp;</td>
      </tr>
      <tr valign=top>
      <td valign=top width=180 class=rptlistcontent>
      <b>Expected Date of Delivery</b>
      </td>
      <td valign=top width=10 class=rptlistcontent>:</td>
      <td valign=top width=340 class=rptlistcontent style="border-bottom: 1px solid black;">
      <?=unconverttounix($mro_data['mro_deliverydate']);?>
      </td>
      <td valign=top width=20 class=rptlistcontent>&nbsp;</td>
      </tr>
      <tr valign=top>
      <td valign=top width=180 class=rptlistcontent>
      <b>Backcharge / Debit Account</b>
      </td>
      <td valign=top width=10 class=rptlistcontent>:</td>
      <td valign=top width=340 class=rptlistcontent style="border-bottom: 1px solid black;">
      <? 
      if (($mro_data['mro_debitaccount']=="")&&($mro_data['mro_subcons']=="")) {
        echo "-NA-"; 
      } else if (strlen($mro_data['mro_subcons'])>32) {
        echo "Please Refer Remarks";
      } else {
       // echo "X" . $supplier_data['supplier_name']."&nbsp;"; 
	   //echo "pp" . $mro_data['supplier_name']."&nbsp;";
		$xx = $mro_data['mro_debitaccount'];
	    $sql1 = "SELECT * FROM `zikay_cmsv5`.`settings_subcontractors` WHERE `subconmasterpkey` = '$xx'";
		$sxx = mysql_query($sql1);
		while($data = mysql_fetch_assoc($sxx))
		{ echo $data['subconname'];}
      }
      ?>
      </td>
      <td valign=top width=20 class=rptlistcontent>&nbsp;</td>
      </tr>
      </table>
    </td>
    <td valign=top width=200 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=190>
      <tr valign=top>
      <td valign=top width=190 class=rptlistcontent>
      <br>
      <b>MRO No.</b> :&nbsp;&nbsp;&nbsp;&nbsp;<?=mroidstr($mro_data['mro_id'],$mro_data['mro_revno']);?>
      <br><br>
      </td>
      </tr>
      </table>
    </td>
    </tr>
    <tr valign=top>
    <td valign=top width=200 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=190>
      <tr valign=top>
      <td valign=top width=190 class=rptlistcontent>
      Sub-con PO/Ref : <?=$mro_data['mro_subconref'];?>
      </td>
      </tr>
      <tr valign=top>
      <td valign=top width=190 class=rptlistcontent>
      Client MRO NO : <?=$mro_data['mro_clientref'];?>
      </td>
      </tr>
      </table>
    </td>
    </tr>
    </table>
    <br>

  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=100% height=620 class=cboxcontent>

    <table border=0 cellspacing=0 cellpadding=0 width=760 style="border: 1px solid black; border-collapse: collapse; height: 100%;">
    <tr valign=top>
    <td valign=top width=40 class=rptlistheader style="text-transform: none; height: 20px;">Item</td>
    <td valign=top width=160 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=200 class=rptlistheader style="text-transform: none;">Purpose</td>
    <td valign=top width=200 class=rptlistheader style="text-transform: none;">Remarks</td>
    </tr>
    <tr valign=top>
    <td valign=top width=40 class=rptlistnumber style="height: 16px;">&nbsp;</td>
    <td valign=top width=160 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=200 class=rptlistcontent-left>&nbsp;</td>
    <td valign=top width=200 rowspan=500 class=rptlistcontent-left><br><center><?=richtext($mro_data['mro_remarks']);?></center>&nbsp;</td>
    </tr>

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

      <? if ($myitem['item_quantity']>0) { ?>
        <tr valign=top>
        <td valign=top width=40 class=rptlistnumber style="height: 16px;"><?=$myitem['item_no'];?>&nbsp;</td>
        <td valign=top width=160 class=rptlistcontent-left style="text-indent: 2px;"><? echo $myitem['item_code'];?>&nbsp;:&nbsp;<?=unescape($myitem['item_description']);?><? if ($myitem['item_remarks']!="") { echo "<br>".papar_break($myitem['item_remarks']); } ?><br>&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=200 class=rptlistcontent-left style="text-indent: 2px;"><?=$myitem['item_purpose'];?>&nbsp;</td>
        <!--<td valign=top width=200 class=rptlistcontent></td>-->
        </tr>

      <? } ?>

    <? } ?>

    <? if ($mro_data['mro_status']=="9") { ?>

      <tr valign=top>
      <td valign=top width=40 class=rptlistnumber style="height: 16px;">&nbsp;</td>
      <td valign=top width=160 class=rptlistcontent-left style="text-indent: 2px;"><b><? if ($mro_data['mro_cancel']=="1") { echo "CANCELLED: "; } else if ($mro_data['mro_cancel']=="2") { echo "<span style=\"color:#FE2E2E\">REJECTED: "; } ?><?=$mro_rejection['approval_remarks'];?> <?php echo "</span>"; ?></b>&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=200 class=rptlistcontent-left style="text-indent: 2px;">&nbsp;</td>
      </tr>

    <? } ?>

    <tr valign=top>
    <td valign=top width=40 class=rptlistnumber style="height: 100%;">&nbsp;</td>
    <td valign=top width=160 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=200 class=rptlistcontent-left>&nbsp;</td>
    </tr>

    <tr valign=top>
    <td valign=top width=40 class=rptlistnumber style="height: 16px;">&nbsp;</td>
    <td valign=top width=160 class=rptlistcontent-left><b>Note: Total Items <?=$myitem['item_no'];?> Only</b><br><br></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=200 class=rptlistcontent-left>&nbsp;</td>
    </tr>

    </table>

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

 <table width="760" border="0" cellspacing=2 cellpadding=0>
  <tr>
    <td width="250" class=rptlistcontent valign="top"><strong>Prepared  and Checked by :</strong></td>
    <td width="5">&nbsp;</td>
    <td width="250" class=rptlistcontent valign="top"><strong>Recommended by :<br><sup>(Non Budgeted Material)</sup></strong></td>
    <td width="5">&nbsp;</td>
    <td width="250" class=rptlistcontent valign="top"><strong>Approved  by :</strong></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td style="border-bottom: 1px solid black;" class=rptlistcontent>
    <?php
    if($mro_data['mro_requestor'] != '')
	 //echo "" .dottedstr($pubuserfullname,30). "";
      echo $mro_data['mro_requestor'];
	  //echo "ddd";
    else
      echo "&nbsp;";
     ?>
     </td>
    <td>&nbsp;</td>
    <td style="border-bottom: 1px solid black;" class=rptlistcontent>&nbsp;
	<!-- Recommended -->
	<?php
	echo $mro_data['mro_recommended'];
	?>
	</td>
    <td>&nbsp;</td>
    <td style="border-bottom: 1px solid black;" class=rptlistcontent>&nbsp;
	<?php 
    if($mro_data['mro_approver'] != '')
      echo $mro_data['mro_approver'];
    else 
     echo "&nbsp";
    ?>
    <?//=unconverttounixslash($mro_data['mro_requestdate']);?> 
    </td>
  </tr>
  <tr>
    <td class=rptlistcontent>Project QS / Quantity Surveyor</td>
    <td>&nbsp;</td>
    <td class=rptlistcontent>Project Manager </td>
    <td>&nbsp;</td>
    <td class=rptlistcontent>Project Manager / General Manager </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
   <tr>
    <td colspan="5" class=rptlistcontent style="text-align: center; border-top: 1px solid black;">THIS IS A COMPUTER GENERATED FORM AND IT DOES NOT REQUIRE ANY SIGNATURE</td>
  </tr>
</table>


<span class="noprint">
<br><br><br>
<button name="printreport" id="printreport" onClick="javascript:print_report();">&nbsp;Print&nbsp;</button>
</span>

</td>
</tr>
</table>
</body>
</html>

<!-- MeadCo ScriptX -->
<!-- For IE 7 only (not using MeadCo's scale-to-fit)
<object id="factory" viewastext style="display:none"
   classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
   codebase="http://[your_path]/smsx.cab#Version=6,4,438,06">
</object>
-->

<!-- MeadCo ScriptX -->
<object id="factory" viewastext style="display:none"
   classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
   codebase="../lib/smsx.cab#Version=6,4,438,06">
   <param name="template" value="MeadCo://IE7" />
</object>

<script type="text/javascript">
function print_report() {
	document.getElementById('printreport').visible = 'hidden'; /* myapit -- replace function */
  window.print();
  // save before meadco
  /* # myapit - comment to prevent exec
  var h=factory.printing.header;
  var f=factory.printing.footer;
  var o=factory.printing.portrait;
  var lm=factory.printing.leftMargin;
  var tm=factory.printing.topMargin;
  var rm=factory.printing.rightMargin;
  var bm=factory.printing.bottomMargin;
  // set and print (&b for tab)
 factory.printing.header = "";
  factory.printing.footer = "";
  factory.printing.portrait = true;
  factory.printing.leftMargin = 0.75;
  factory.printing.topMargin = 0.55;
  factory.printing.rightMargin = 0.75;
  factory.printing.bottomMargin = 0.55;
  factory.printing.Print(true);
  // restore..
  
  factory.printing.header=h;
  factory.printing.footer=f;
  factory.printing.portrait=o;
  factory.printing.leftMargin=lm;
  factory.printing.topMargin=tm;
  factory.printing.rightMargin=rm;
  factory.printing.bottomMargin=bm;
  */
}
</script>
