<?php
require_once 'pe_part_inventory/inventory.jmd';
$printods = new inventory_pe();
$printmonth = $_REQUEST['printmonth'];
$printyear = $_REQUEST['printyear'];
$printdate = date('Y-m-d');
if($printmonth==1)
{
$startperiode = "January";
$endperiode = "April";
} else if($printmonth==2)
{
$startperiode = "May";
$endperiode = "Agustus";
} else if($printmonth==3)
{
$startperiode = "September";
$endperiode = "Desember";
}
$username = $_SESSION['EMcode'];
$judul = 'InventoryPartPe('.$printmonth.'-'.$printyear.').ods';
// get section dari data master order no section
$ressec = $printods->get_section_pe();
$numsec = mssql_num_rows($ressec);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: private");
header('Content-type: application/vnd.ms-excel');
header("Content-Disposition: attachment; filename= $judul");
function xlsBOF() {
echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
return;
}
// Function penanda akhir file (End Of File) Excel
function xlsEOF() {
echo pack("ss", 0x0A, 0x00);
return;
}
// Function untuk menulis data (angka) ke cell excel
function xlsWriteNumber($Row, $Col, $Value) {
echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
echo pack("d", $Value);
return;
}
// Function untuk menulis data (text) ke cell excel
function xlsWriteLabel($Row, $Col, $Value ) {
$L = strlen($Value);
echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
echo $Value;
return;
}
xlsBOF();
xlsWriteLabel(0,0,'PE Parts Inventory');
xlsWriteLabel(0,1,"Period : $startperiode - $endperiode $printyear");
if ($numsec > 0)
{
$noBarisCell = 1;
while ($rowsec = mssql_fetch_object($ressec))
{
//get data inventory per section
$cond = " and substring(riorderno,1,2) in (select PO_Name from jstpedb..tbmst_parentorder with(nolock)
left join jstpedb..tbmst_mfgrequester with(nolock) on po_mfgid = mfgr_id
where PO_OwnerSection = '$rowsec->po_ownersection')";
$q = $printods->inventory_data($printmonth,$printyear,$cond);
$res = mssql_query($q);
$num = mssql_num_rows($res);
if ($num > 0)
{
$noBarisCell++;
xlsWriteLabel($noBarisCell,0,$rowsec->po_ownersection);
xlsWriteLabel($noBarisCell,1,'Print Date :'.$printdate);
$noBarisCell=$noBarisCell+2;
xlsWriteLabel($noBarisCell,0,'No');
xlsWriteLabel($noBarisCell,1,'PartID');
xlsWriteLabel($noBarisCell,2,'Status');
xlsWriteLabel($noBarisCell,3,'Order No');
xlsWriteLabel($noBarisCell,4,'Equipment Code');
xlsWriteLabel($noBarisCell,5,'Drawing No');
xlsWriteLabel($noBarisCell,6,'PartNo');
xlsWriteLabel($noBarisCell,7,'PartName');
xlsWriteLabel($noBarisCell,8,'Balance Stock');
xlsWriteLabel($noBarisCell,9,'Actual Stock');
xlsWriteLabel($noBarisCell,10,'Remark');
$i = 0;
while ($row = mssql_fetch_object($res))
{
$i++;
$noBarisCell++;
xlsWriteLabel($noBarisCell,0,$i);
xlsWriteLabel($noBarisCell,1,$row->riidtc);
xlsWriteLabel($noBarisCell,2,$row->ristatus);
xlsWriteLabel($noBarisCell,3,$row->riorderno);
xlsWriteLabel($noBarisCell,4,$row->riequipcode);
xlsWriteLabel($noBarisCell,5,$row->ridrawno);
xlsWriteLabel($noBarisCell,6,$row->ripartno);
xlsWriteLabel($noBarisCell,7,$row->ripartname);
xlsWriteNumber($noBarisCell,8,$row->riendstock);
xlsWriteLabel($noBarisCell,9,'');
xlsWriteLabel($noBarisCell,10,'');
}
$noBarisCell++;
}
}
}
$noBarisCell++;
xlsWriteLabel($noBarisCell,0,'Noted : ');
xlsWriteLabel($noBarisCell,1,'Data yg ditampilkan ada data yg pada transaksi per period yg masih ada balance stock dan tidak ada stock');
xlsEOF();
exit();
?>
No comments:
Post a Comment