<?

include_once('../hdr_general.php');
/* **************************************************************************************************** */
$pubmodule = $_REQUEST["module"];
$pubtask = $_REQUEST["task"];
$pubitemid = $_REQUEST["itemid"];
/* **************************************************************************************************** */
 error_reporting(0);
?>
<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');
  include_once('../models/itqModel.php');
  include_once('../models/tradeModel.php');
  include_once('../models/poModel.php');
  include_once('../models/supplierModel.php');
  //include_once('../models/userModel.php');

  $mymroModel=new mroModel;
  $myitqModel=new itqModel;
  $mypoModel=new poModel;
  $mytradeModel=new tradeModel;
  $mysupplierModel=new supplierModel;
  //$myuserModel=new userModel;

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

  //$project_data = $myprojectModel->getdata_project

  $myprojectname = $_SESSION['Xprojectname'];
  $myprojectdesc = $_SESSION['Xprojectdesc'];

  $itq_data = $myitqModel->getdata_itqbymro($pubitemid);
  $mro_data = $mymroModel->getdata_mro($pubitemid);
  $mroitem_list = $mymroModel->getlist_mroitems($pubitemid);
  $trade_data = $mytradeModel->getdata_trade($mro_data['mro_subtradepkey']);
  $po_list = $mypoModel->getlist_pobyitq($itq_data['itq_pkey']);
  $supplier_list = $myitqModel->getlist_itqsuppliers($itq_data['itq_pkey']);

  $suppliercount=0;
  $tablewidth=700;
  foreach ($supplier_list as $supplier_data) {
    $suppliercount++;
    $tablewidth += 200;
  }

  $ponos="";
  foreach ($po_list as $po_data) {
    $ponos .= ",<BR>&nbsp;&nbsp;".poidstr($po_data['po_no']);
  }
  $ponos = substr($ponos,17);

  $prep_data = $myitqModel->getdata_lastapprovalbytype($itq_data['itq_pkey'],1);
  $rev_data = $myitqModel->getdata_lastapprovalbytype($itq_data['itq_pkey'],2);
  $app_data = $myitqModel->getdata_lastapprovalbytype($itq_data['itq_pkey'],3);
  //$prep_data = $myuserModel->getdata_user($);

  $awarded="";
  $awardedno=0;
  $award_list = $myitqModel->getlist_itqawardedsuppliers_yus($itq_data['itq_pkey']);
  
  $kount = 0;
  foreach ($award_list as $award_data) {
   
	$supplier = $mysupplierModel->getdata_supplier($award_data['approval_supplierpkey']);
	if($kount == 0 ){
	$awarded .= ", ".$supplier['supplier_name']; //. " | " . $supplier['supplier_pkey'];
	}else{ 
	//null
	}
	$kount++;
  }
  
  
 //foreach ($award_list as $award_data) {
 //   $supplier = $mysupplierModel->getdata_supplier($award_data['approval_supplierpkey']);
 //   $awarded .= ", ".$supplier['supplier_name'];// . " | " . $supplier['supplier_pkey'];
  //}
 
  
  $awarded = substr($awarded,2);
  ?>

  <table border=0 cellspacing=2 cellpadding=0 width=<?=$tablewidth;?>>
  <tr valign=top>
  <td valign=top width=100>&nbsp;</td>
  <!--<td valign=top width=400 class=rptzikayheader style="text-decoration: none; text-align: right;"><img src="../gfx/zikay.png" width=45px height=56px align=left><br><span style="font-size: 18px;"><u>KEMBANG SERANTAU SDN. BHD.</u></span><br><span style="font-size: 10px; font-family: times new roman;">(224505-W)</span></td>-->
  <td valign=top width=<?=$tablewidth-200;?> class=rptzikayheader style="text-decoration: none; text-align: center;"><img src="../gfx/zikayheader.png" style="width: 226px; height: 82px;"><!-- 259/58 390/87 416/93 519/116 --><!--<br><span style="font-size: 14px;"><u>KEMBANG SERANTAU SDN. BHD.</u></span>--></td>
  <!--<td valign=top width=<?=$tablewidth-700;?>>&nbsp;</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-F3</td></tr>
    <tr valign=top><td valign=top width=100 class=rptzikayconfidential style="font-size: 10px; text-align: right; border-top: 0px;">Rev : 2</td></tr>
    </table>
  </td>
  </tr>
  </table>
  <br>

  <table border=0 cellspacing=2 cellpadding=0 width=<?=$tablewidth;?>>
  <tr valign=top>
  <td valign=top width=100% class=rptzikayheader colspan=5 style="text-align: center;"><b><u>QUOTATION EVALUATION APPROVAL</u></b></td>
  </td>
  </tr>
  <tr valign=top><td valign=top width=100% colspan=5 class=rptlistcontent><img src="../pixel.gif" width=1 height=5></td></tr>
  <tr valign=top>
  <td valign=top width=140 class=rptzikayheader style="text-decoration: none;"><b>Project Title</b></td>
  <td valign=top width=10 class=rptzikayheader style="text-decoration: none;">:</td>
  <td valign=top width=<?=$tablewidth-350;?> class=rptzikayheader style="font-weight: normal;"><u><?=$myprojectdesc;?></u></td>
  <td valign=top width=100 class=rptzikayheader style="text-align: right; text-decoration: none;"><b>Date :</b></td>
  <td valign=top width=100 class=rptzikayheader style="text-decoration: none; font-weight: normal;">&nbsp;&nbsp;<?=unconverttounixslash($itq_data['itq_date']);?> <?php// echo $itq_data['itq_date']; ?></td>
  </tr>
  <tr valign=top>
  <td valign=top width=140 class=rptzikayheader style="text-decoration: none;"><b>Trade</b></td>
  <td valign=top width=10 class=rptzikayheader style="text-decoration: none;">:</td>
  <td valign=top width=<?=$tablewidth-350;?> class=rptzikayheader style="font-weight: normal;"><u><?=$trade_data['tradedescription'];?>&nbsp;</u></td>
  <td valign=top width=100 class=rptzikayheader style="text-align: right; text-decoration: none;"><b>Project No :</b></td>
  <td valign=top width=100 class=rptzikayheader style="text-decoration: none; font-weight: normal;">&nbsp;&nbsp;<?php echo $pubprojectid ?></td>
  </tr>
  <tr valign=top>
  <td valign=top width=<?=$tablewidth-200;?> colspan=3 class=rptzikayheader style="text-decoration: none;">&nbsp;</td>
  <td valign=top width=100 class=rptzikayheader style="text-align: right; text-decoration: none;"><b>PO No :</b></td>
  <td valign=top width=100 class=rptzikayheader style="text-decoration: none; font-weight: normal;">&nbsp;&nbsp;<?//=$ponos;?></td>
  </tr>
  
  <tr valign=top>
  <td valign=top width=<?=$tablewidth-200;?> colspan=3 class=rptzikayheader style="text-decoration: none;">&nbsp;</td>
  <td valign=top width=100 class=rptzikayheader style="text-align: right; text-decoration: none;"><b>RFQ No :</b></td>
  <td valign=top width=100 class=rptzikayheader style="text-decoration: none; font-weight: normal;">&nbsp;&nbsp;<?=itqidstr($itq_data['itq_rfqno']);//,$itq_data['itq_revno']);?></td>
  </tr>
  
  
  </table>
  <br>

  <table border=1 cellspacing=1 cellpadding=2 width=<?=$tablewidth;?> style="border: 1px solid black; border-collapse: collapse;">
  <tr valign=top>
  <td valign=top width=40 rowspan=2 class=rptlistcontent-special style="background: #f0f0f0;">Item</td>
  <td valign=top width=260 rowspan=2 class=rptlistcontent-special style="background: #f0f0f0;">Description</td>
  <td valign=top width=100 rowspan=2 class=rptlistcontent-special style="background: #f0f0f0;">Unit</td>
  <td valign=top width=100 rowspan=2 class=rptlistcontent-special style="background: #f0f0f0;">Qty</td>

  <td valign=top width=200 colspan=2 class=rptlistcontent-special style="text-align: center; background: #f0f0f0;">
  ZIKAY GROUP S/B
  </td>

  <? reset($supplier_list); ?>
  <? $scount=0; ?>
  <? foreach ($supplier_list as $supplier_data) { ?>
    <? $scount++; ?>
    <td valign=top width=200 colspan=2 class=rptlistcontent-special style="background: #f0f0f0;">
    <? $mysupplier = $mysupplierModel->getdata_supplier($supplier_data['itq_supplierpkey']); ?>
    <?=$mysupplier['supplier_name'];?>
    </td>
  <? } ?>

  </tr>

  <tr valign=top>
  <? for ($i=1;$i<=$suppliercount+1;$i++) { ?>
    <td valign=top width=100 class=rptlistcontent-special style="text-align: center; background: #f0f0f0;">Rate (RM)</td>
    <td valign=top width=100 class=rptlistcontent-special style="text-align: center; background: #f0f0f0;">Amt (RM)</td>
  <? } ?>
  </tr>

  <? $total[0]=0; ?>
  <? $total[1]=0; ?>
  <? $total[2]=0; ?>
  <? $total[3]=0; ?>
  <? $total[4]=0; ?>
  <? $total[5]=0; ?>
  <? $total[6]=0; ?>
  <? $total[7]=0; ?>
  <? $total[8]=0; ?>
  <? $total[9]=0; ?>
  <? $total[10]=0; ?>

  <? $icount=0; ?>

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

    <? $icount++; ?>

    <? $itqitem_list = $myitqModel->getlist_itqevaluationbyitem($myitem['item_mropkey'], $myitem['item_pkey']); ?>

    <tr valign=top>
    <td valign=top width=40 class=rptlistnumber-leftrightbottom><?=stripslashes($myitem['item_no']);?></td>
    <td valign=top width=260 class=rptlistcontent-leftrightbottom><?php echo stripslashes($myitem['item_code']);?> : <?=unescape($myitem['item_description']);?></td>
    <td valign=top width=100 class=rptlistcontent-leftrightbottom style="text-align: center;"><? echo stripslashes($myitem['item_unit']);?></td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom><?=number_format($myitem['item_quantity'],4);?>
    </td>

    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
    <?php echo number_format($myitem['item_rate'],2);?>
	<?php /*
	$sql1 = "SELECT * FROM zikay_pmsv5.mro_items WHERE item_mropkey = '" .$myitem['item_mropkey']. "'";
	$sql2 = mysql_query($sql1);
	while($roti = mysql_fetch_array($sql2)){
	echo number_format($roti['item_rate']); 
	} */
	?></td>
    </td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
    <? $total[0]=$total[0]+($myitem['item_rate']*$myitem['item_quantity']); ?>
    <?php echo number_format(($myitem['item_rate']*$myitem['item_quantity']),4);?>
    </td>

    <? //reset($itqitem_list); ?>
    <? $scount=0; ?>
    <? foreach ($itqitem_list as $itqitem_data) { ?>
      <? $scount++; ?>
      <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
      <?=number_format($itqitem_data['eval_supplierrate'],4);?>
      </td>
      <? $mysubtotal=($myitem['item_quantity']*$itqitem_data['eval_supplierrate']); ?>
      <? $total[$scount]=$total[$scount]+$mysubtotal; ?>
      <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
      <?=number_format($mysubtotal,4);?>
      </td>
    <? } ?>

    </tr>

  <? } ?>

  <tr valign=top>
  <td valign=top width=500 colspan=4 class=rptlistcontent-leftrightbottom style="text-align: center;"><b>TOTAL</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
  <?=number_format($total[0],4);?>
  </td>

  <? reset($itqitem_list); ?>
  <? $scount=0; ?>
  <? foreach ($itqitem_list as $itqitem_data) { ?>
    <? $scount++; ?>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
    <?=number_format($total[$scount],4);?>
    </td>
  <? } ?>

  </tr>

  <tr valign=top>
  <td valign=top width=500 colspan=4 class=rptlistcontent-leftrightbottom style="text-align: center;"><b>ESTIMATED PROFIT</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>

  <? reset($itqitem_list); ?>
  <? $scount=0; ?>
  <? foreach ($itqitem_list as $itqitem_data) { ?>
    <? $scount++; ?>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
    <? if ($total[$scount]!=0) { ?>
      <?=number_format($total[0]-$total[$scount],2);?>
    <? } else { ?>
      NA
    <? } ?>
    </td>
  <? } ?>

  </tr>

  <tr valign=top>
  <td valign=top width=500 colspan=4 class=rptlistcontent-leftrightbottom style="text-align: center;"><b>% DIFFERENCE</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>

  <? reset($itqitem_list); ?>
  <? $scount=0; ?>
  <? foreach ($itqitem_list as $itqitem_data) { ?>
    <? $scount++; ?>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
    <? if ($total[$scount]!=0) { ?>
      <?=number_format((($total[0]-$total[$scount])/$total[0])*100,0)."%";// or round function? ?>
    <? } else { ?>
      NA
    <? } ?>
    </td>
  <? } ?>

  </tr>

  <tr valign=top>
  <td valign=top width=300 colspan=2 class=rptlistcontent-leftrightbottom>
  Prepared By:<br><br><br>
    <table border=0 cellspacing=0 cellpadding=0 width=250>
    <tr valign=top>
    <td valign=top width=250 colspan=2 class=rptlistcontent style="border-bottom: 1px solid black;">
     <?php  
	$sql1 = "SELECT * FROM `zikay_pmsv5`.`itq_details` WHERE itq_mropkey = '".$_GET['itemid']."'";
	$sql2 = mysql_query($sql1);
	$data = mysql_fetch_assoc($sql2);
	echo $data['itq_requestor'];
	
	
	 
	 //echo "&nbsp;". $prep_data['approval_officername'];
	 //echo "" .dottedstr($pubuserfullname,30). "";
	 ?>
    </td>
    </tr>
    <tr valign=top>
    <td valign=top width=120 class=rptlistcontent style="text-align: center;">
    QS/PE
    </td>
    <td valign=top width=130 class=rptlistcontent style="text-align: center;">
    Date: <?=unconverttounixslash($prep_data['approval_date']);?>
	<?php // echo $prep_data['approval_date'];?>
    </tr>
    </table>
  </td>
  <td valign=top width=200 colspan=2 class=rptlistcontent-leftrightbottom>
  Recommended/Approved By:<br><br><br>
    <table border=0 cellspacing=0 cellpadding=0 width=200>
    <tr valign=top>
    <td valign=top width=180 colspan=2 class=rptlistcontent style="border-bottom: 1px solid black;">
    <?//=$rev_data['approval_officername'];?>
	 <?php
	$aa1 = "SELECT * FROM zikay_pmsv5.itq_details WHERE itq_mropkey ='".$_GET['itemid']."'";
	$aa2 = mysql_query($aa1);
	$aa3 = mysql_fetch_assoc($aa2);
	
	if ($aa3['itq_approval1'] == ""){
	$rek_a = $aa3['itq_approver'];
	}else{
	$rek_a = $aa3['itq_approval1'];
	//echo $aa3['itq_approver'];
	}
	echo $rek_a;
	?>
    </td>
    </tr>
    <tr valign=top>
    <td valign=top width=70 class=rptlistcontent style="text-align: center;">
    CM/PMG
    </td>
    <td valign=top width=110 class=rptlistcontent style="text-align: center;">
    Date: <?php// echo unconverttounixslash($rev_data['approval_date']);?>
	<?php
	//$dt = "SELECT * FROM zikay_pmsv5.po_details WHERE po_mropkey = '".$_GET['itemid']."'";
	//$dt1 = mysql_query($dt);
	//$dt2 = mysql_fetch_assoc($dt1);
	//echo unconverttounixslash($dt2['po_date']);
	//echo $dt2['po_date'];
	?>
	<?php 
	//new quick edit 30-01-2012
	if($rek_a != ""){
	echo unconverttounixslash($prep_data['approval_date']);
	}
	?>
    </td>
    </tr>
    </table>
  </td>

  <td valign=top width=200 colspan=2 rowspan=2 class=rptlistcontent-leftrightbottom>
  Remarks&nbsp;<br />
  <pre style="font-family: verdana, arial; word-wrap: break-word; white-space:pre-wrap;"><?php echo stripslashes($itq_data['remarks_zikay']);?></pre>
  
  </td>
  
  <? reset($supplier_list); ?>
  <? $scount=0; ?>
  <? foreach ($supplier_list as $supplier_data) { ?>
    <? $scount++; ?>
    <? if ($supplier_data['itq_remarks']=="") { ?>
      <? $mysupplier = $mysupplierModel->getdata_supplier($supplier_data['itq_supplierpkey']); ?>
      <? $myremarks = "TERMS: ".$mysupplier['supplier_ct']; ?>
    <? } else { ?>
      <? $myremarks = $supplier_data['itq_remarks']; ?>
    <? } ?>
    <?
    reset($mroitem_list);
    foreach($mroitem_list as $myitem) {
      $myapproval = $myitqModel->getdata_lastitqapprovalsbysupplier($itq_data['itq_pkey'],$myitem['item_pkey'],$supplier_data['itq_supplierpkey']);
      if ($myapproval['approval_pkey']!="") {
        if ($myapproval['approval_quantity']>0) {
          $mymroitem = $mymroModel->getdata_mroitem($myapproval['approval_itempkey']);
          //$myremarks .= "<br>Item ".$mymroitem['item_no']." : ".$myapproval['approval_quantity']." ".$mymroitem['item_unit'];
        }
      }
      reset($app_data);
    }
    ?>
	
    <td valign=top width=200 colspan=2 rowspan=2 class=rptlistcontent-leftrightbottom>Remarks:<br>
	Transport : <?=number_format($supplier_data['itq_transportrate'],2);?><br />
    
	<pre style="font-family: verdana, arial; word-wrap: break-word; white-space:pre-wrap;"><?=$myremarks;?></pre>
    
	</td>
  <? } ?>

  </tr>

  <tr valign=top>
  <td valign=top width=500 colspan=4 class=rptlistcontent-leftrightbottom>
    <table border=0 cellspacing=0 cellpadding=0 width=480>
    <tr valign=top>
    <td valign=top width=100 class=rptlistcontent>
    AWARDED TO:
    </td>
    <td valign=top width=380 class=rptlistcontent style="line-height: 18px;"><!-- style="border-bottom: 3px double black;"-->
    <span style="border-bottom: 3px double black;"><?=$awarded;?>
	
	</span>&nbsp;
    </td>
    </tr>
    </table>
    Approved By:<br><br><br>
    <table border=0 cellspacing=0 cellpadding=0 width=230 style="display: inline;">
    <tr valign=top>
    <td valign=top width=230 colspan=2 class=rptlistcontent style="border-bottom: 1px solid black;">
	
	
	 
	<?php 
	/* hardcoded repair */
	if($itq_data['itq_rfqno'] == "24"){ echo "ABDUL RAZAK MOHD ALI"; } else {}
	/*hardcoded end */
	
	if($aa3['itq_approver'] == "ABDUL RAZAK MOHD ALI"){
	echo $aa3['itq_approver'];
	}
	else if($aa3['itq_approver'] == "TAJUL ARIFIN ABD RAHIM"){
	echo $aa3['itq_approver'];
	}
	else if (itqidstr($itq_data['itq_rfqno']) == "RFQ0057" ){
	echo "ABDUL RAZAK MOHD ALI";
	}
	else
	{
	echo "&nbsp;";
	}
	?>
	<? //=$app_data['approval_officername'];?>
	
    </td>
    </tr>
    <tr valign=top>
    <td valign=top width=100 class=rptlistcontent style="text-align: center;">
    CEO
    </td>
    <td valign=top width=130 class=rptlistcontent style="text-align: center;">
    Date: <?=unconverttounixslash($app_data['approval_date']);?>
	<?php // echo  $app_data['approval_date']; ?>
    </td>
    </tr>
    </table>
    &nbsp;&nbsp;&nbsp;&nbsp;
    <table border=0 cellspacing=0 cellpadding=0 width=230 style="display: inline;">
    <tr valign=top>
    <td valign=top width=230 class=rptlistcontent style="border-bottom: 1px solid black;">
    <? //  how to get md/ed name??; ?>&nbsp;
    </td>
    </tr>
    <tr valign=top>
    <td valign=top width=230 class=rptlistcontent style="text-align: center;">
    MD/ED
    </td>
    </tr>
    </table>
  </td>
  </tr>

  </table>


    <table border=0 cellspacing=0 cellpadding=2 width=<?=$tablewidth-10;?>>
    <tr valign=top>
    <td valign=top width=<?=$tablewidth-10;?> class=rptlistcontent style="text-align: center; border-top: 1px solid black;">
    <span style="font-family: times new roman; font-size: 11px;">THIS IS A COMPUTER GENERATED FORM AND IT DOES NOT REQUIRE ANY SIGNATURE</span>
	<span style="font-family: times new roman; font-size: 11px; float: right"><span id="clock"><script type="text/javascript" src="timer.js"></script></span></span> 
    </td>
    </tr>
    </table>
 

<!--
<p style="page-break-before: always;">&nbsp;</p>

<span class="noprint">
<hr size=1 style="border: 1px solid black;">
</span>
-->
<br />
<span class="noprint">
<br>
<button name="printreport" id="printreport" onClick="javascript:print_report();">&nbsp;Print&nbsp;</button>
</span>


</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() {
  //window.print();
  // save before meadco
  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 = false;
  factory.printing.leftMargin = 0.45;
  factory.printing.topMargin = 0.25;
  factory.printing.rightMargin = 0.45;
  factory.printing.bottomMargin = 0.45;
  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>
