<?
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>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/supplierModel.php');
  $mysupplierModel=new supplierModel;


  $supplier_list = $mysupplierModel->getlist_suppliers("supplier_regdate","ASC","","","","");
  $cindex=0;
  foreach ($supplier_list as $mysupp) {
    $approval_list[$cindex] = $mysupplierModel->getlist_approvals($mysupp['supplier_pkey']);
    $bg_list[$cindex] = $mysupplierModel->getlist_bankguarantees($mysupp['supplier_pkey']);
    $expfound=false;
    $bgtotal[$cindex]['bg_banktotal']=0;
    foreach ($bg_list[$cindex] as $mybg) {
      $bgtotal[$cindex]['bg_expired']=false;
      $bgtotal[$cindex]['bg_banktotal']=$bgtotal[$cindex]['bg_banktotal']+$mybg['bg_bankamount'];
      if (($mybg['bg_enddate']-5184000)<=getdatestamp()) {
        $expfound=true;
        $bgtotal[$cindex]['bg_expired']=true;
        if ($mybg['bg_enddate']<=getdatestamp()) {
          $bgtotal[$cindex]['bg_fullremarks']=$bgtotal[$cindex]['bg_fullremarks']."".unconverttounixslash($mybg['bg_startdate'])." - ".unconverttounixslash($mybg['bg_enddate'])." ".$mybg['bg_projectname']." ".($mybg['bg_bankamount']/1000)."K&nbsp;, ";
        } else {
          $bgtotal[$cindex]['bg_fullremarks']=$bgtotal[$cindex]['bg_fullremarks']."".unconverttounixslash($mybg['bg_startdate'])." - ".unconverttounixslash($mybg['bg_enddate'])." ".$mybg['bg_projectname']." ".($mybg['bg_bankamount']/1000)."K&nbsp;, ";
        }
      } else {
        $bgtotal[$cindex]['bg_expired']=false;
        $bgtotal[$cindex]['bg_fullremarks']=$bgtotal[$cindex]['bg_fullremarks'].unconverttounixslash($mybg['bg_startdate'])." - ".unconverttounixslash($mybg['bg_enddate'])." ".$mybg['bg_projectname']." ".($mybg['bg_bankamount']/1000)."K, ";
      }
    }
    $bgtotal[$cindex]['bg_fulltotal']=($bgtotal[$cindex]['bg_banktotal']*$mysupp['supplier_bgratio'])+$mysupp['supplier_personalamount'];
    if ($expfound==true_) {
      $bgtotal[$cindex]['bg_fullremarks']=substr($bgtotal[$cindex]['bg_fullremarks'],0,strlen($bgtotal[$cindex]['bg_fullremarks'])-2);
    } else {
      $bgtotal[$cindex]['bg_fullremarks']=substr($bgtotal[$cindex]['bg_fullremarks'],0,strlen($bgtotal[$cindex]['bg_fullremarks'])-2);
    }
    $cindex++;
  }
  ?>

  <table border=0 cellspacing=2 cellpadding=0 width=1350>
  <tr valign=top>
  <!--<td valign=top width=1250 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=1350 class=rptzikayheader style="text-decoration: none; text-align: center;"><img src="../gfx/zikayheader.png" style="width: 311px; height: 69px;"></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;">NA</td></tr>
    <tr valign=top><td valign=top width=100 class=rptzikayconfidential style="font-size: 10px; text-align: left; border-top: 0px;">Rev : 0</td></tr>
    </table>
  </td>
  -->
  </tr>
  <tr valign=top>
  <td valign=top width=1350 class=rptzikayheader style="text-decoration: none; text-align: center;"><br><span style="font-size: 12px;"><u>SUPPLIER REGISTERED LIST</u></span></td>
  </tr>
  </table>
  <br>

  <table border=1 cellspacing=0 cellpadding=2 width=1350 style="border: 1px solid black; border-collapse: collapse;">

  <tr valign=top>
  <td valign=top width=30 rowspan=2 class=rptlistheader style="text-transform: none;">No</td>
  <td valign=top width=70 rowspan=2 class=rptlistheader style="text-transform: none;">Register Date</td>
  <td valign=top width=70 rowspan=2 class=rptlistheader style="text-transform: none;">Approved Date</td>
  <td valign=top width=60 rowspan=2 class=rptlistheader style="text-transform: none;">Supplier Reg No</td>
  <td valign=top width=200 rowspan=2 class=rptlistheader style="text-transform: none; text-align: center;">Supplier Name<br>Address/Tel/Fax/Email</td>
  <td valign=top width=100 rowspan=2 class=rptlistheader style="text-transform: none;">Contact Person</td>
  <td valign=top width=100 rowspan=2 class=rptlistheader style="text-transform: none;">Contact Number (PIC)</td>
  <td valign=top width=60 rowspan=2 class=rptlistheader style="text-transform: none;">Credit Terms</td>
  <td valign=top width=100 rowspan=2 class=rptlistheader style="text-transform: none;">Nature of Business</td>
  <td valign=top width=100 rowspan=2 class=rptlistheader style="text-transform: none;">Products</td>
  <td valign=top width=60 rowspan=2 class=rptlistheader style="text-transform: none;">Status</td>
  <td valign=top width=400 colspan=4 class=rptlistheader style="text-transform: none;">Credit Facilities</td>
  </tr>
  <tr valign=top>
  <td valign=top width=100 class=rptlistheader style="text-transform: none;">Bank Guarantee</td>
  <td valign=top width=100 class=rptlistheader style="text-transform: none;">Personal Guarantee</td>
  <td valign=top width=100 class=rptlistheader style="text-transform: none;">Grand Total</td>
  <td valign=top width=100 class=rptlistheader style="text-transform: none;">Remarks</td>
  </tr>

  <? $cindex=0; ?>

  <? foreach ($supplier_list as $mysupplier) { ?>

    <? $aindex=0; ?>
    <? unset($myapproval); ?>

    <? foreach ($approval_list[$cindex] as $myapprovalitem) { ?>
      <? $myapproval = $myapprovalitem; ?>
      <? $aindex++; ?>
    <? } ?>

    <tr valign=top>
    <td valign=top width=30 class=rptlistnumber-leftrightbottom><?=$mysupplier['recordno'];?></td>
    <td valign=top width=70 class=rptlistcontent-leftrightbottom><?=unconverttounixslash($mysupplier['supplier_regdate']);?>&nbsp;</td>
    <td valign=top width=70 class=rptlistcontent-leftrightbottom><? if ($mysupplier['supplier_approved']==1) { ?><?=unconverttounixslash($myapproval['approval_date']);?>&nbsp;<? } ?>&nbsp;</td>
    <td valign=top width=60 class=rptlistcontent-leftrightbottom><? if ($mysupplier['supplier_regid']!=0) { ?><?=idstr($mysupplier['supplier_regid']);?><? } ?>&nbsp;</td>
    <td valign=top width=200 class=rptlistcontent-leftrightbottom><?=$mysupplier['supplier_name'];?><br><?=$mysupplier['supplier_address'];?><br>Tel: <?=$mysupplier['supplier_phone'];?><br>Fax: <?=$mysupplier['supplier_fax'];?><br>Email: <?=$mysupplier['supplier_email'];?>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontent-leftrightbottom><?=$mysupplier['supplier_pic'];?>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontent-leftrightbottom><?=$mysupplier['supplier_picphone'];?>&nbsp;</td>
    <td valign=top width=60 class=rptlistcontent-leftrightbottom><?=$mysupplier['supplier_ct'];?>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontent-leftrightbottom><?=$mysupplier['supplier_nob'];?>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontent-leftrightbottom><?=$mysupplier['supplier_products'];?>&nbsp;</td>
    <td valign=top width=60 class=rptlistcontent-leftrightbottom><? if ($mysupplier['supplier_status']==1) { echo "Active"; } else { echo "Inactive"; } ?>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom style="font-size: 11px;"><?=number_format($bgtotal[$cindex]['bg_banktotal'],2);?>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom style="font-size: 11px;"><?=number_format($mysupplier['supplier_personalamount'],2);?>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom style="font-size: 11px;"><?=number_format($bgtotal[$cindex]['bg_fulltotal'],2);?>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontent-leftrightbottom><? if ($bgtotal[$cindex]['bg_fullremarks']!="") { ?><?=$bgtotal[$cindex]['bg_fullremarks'];?><? } else { ?><? } ?>&nbsp;</td>
    </tr>

    <? $cindex++; ?>

  <? } ?>

  </table>

<span class="noprint">
<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() {
  //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>
