forked from timschofield/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPDFQALabel.php
118 lines (104 loc) · 5.83 KB
/
PDFQALabel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
include('includes/session.php');
if (isset($_GET['GRNNo'])) {
$GRNNo=$_GET['GRNNo'];
} else {
$GRNNo='';
}
$FormDesign = simplexml_load_file($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/QALabel.xml');
// Set the paper size/orintation
$PaperSize = $FormDesign->PaperSize;
$LineHeight=$FormDesign->LineHeight;
include('includes/PDFStarter.php');
$PageNumber=1;
$pdf->addInfo('Title', _('QA Label') );
if ($GRNNo == 'Preview'){
$MyRow['itemcode'] = str_pad('', 15,'x');
$MyRow['itemdescription'] = str_pad('', 30,'x');
$MyRow['serialno'] = str_pad('', 20,'x');
$MyRow['reslot'] = str_pad('', 20,'x');
$SuppRow['suppname'] = str_pad('', 30,'x');
$MyRow['deliverydate'] = '1000-01-01';
$MyRow['orderno'] = '0000000000';
$NoOfGRNs =1;
} else { //NOT PREVIEW
$SQL="SELECT grns.itemcode,
grns.grnno,
grns.deliverydate,
grns.itemdescription,
grns.supplierid,
purchorderdetails.orderno
FROM grns INNER JOIN purchorderdetails
ON grns.podetailitem=purchorderdetails.podetailitem
LEFT JOIN stockmaster
ON grns.itemcode=stockmaster.stockid
WHERE grnbatch='". $GRNNo ."'";
$GRNResult=DB_query($SQL);
$NoOfGRNs = DB_num_rows($GRNResult);
if($NoOfGRNs>0) { //there are GRNs to print
$SQL = "SELECT suppliers.suppname
FROM grns INNER JOIN suppliers
ON grns.supplierid=suppliers.supplierid
WHERE grnbatch='". $GRNNo ."'";
$SuppResult = DB_query($SQL,_('Could not get the supplier of the selected GRN'));
$SuppRow = DB_fetch_array($SuppResult);
}
} // get data to print
if ($NoOfGRNs >0){
for ($i=1;$i<=$NoOfGRNs;$i++) {
if ($GRNNo!='Preview'){
$MyRow = DB_fetch_array($GRNResult);
}
$DeliveryDate = ConvertSQLDate($MyRow['deliverydate']);
$SQL = "SELECT stockmaster.controlled
FROM stockmaster WHERE stockid ='" . $MyRow['itemcode'] . "'";
$CheckControlledResult = DB_query($SQL,'<br />' . _('Could not determine if the item was controlled or not because') . ' ');
$ControlledRow = DB_fetch_row($CheckControlledResult);
if ($ControlledRow[0]==1) { /*Then its a controlled item */
$SQL = "SELECT stockserialmoves.serialno
FROM stockmoves INNER JOIN stockserialmoves
ON stockmoves.stkmoveno= stockserialmoves.stockmoveno
WHERE stockmoves.stockid='" . $MyRow['itemcode'] . "'
AND stockmoves.type =25
AND stockmoves.transno='" . $GRNNo . "'";
$GetStockMoveResult = DB_query($SQL,_('Could not retrieve the stock movement reference number which is required in order to retrieve details of the serial items that came in with this GRN'));
while ($SerialStockMoves = DB_fetch_array($GetStockMoveResult)){
if ($PageNumber>1){
$pdf->newPage();
}
$pdf->addJpegFromFile($_SESSION['LogoFile'] ,$FormDesign->logo->x,$Page_Height-$FormDesign->logo->y,$FormDesign->logo->width,$FormDesign->logo->height);
$LeftOvers = $pdf->addText($FormDesign->ItemNbr->x,$Page_Height-$FormDesign->ItemNbr->y,$FormDesign->ItemNbr->FontSize,'Item: ' . $MyRow['itemcode']);
$LeftOvers = $pdf->addText($FormDesign->ItemDesc->x,$Page_Height-$FormDesign->ItemDesc->y,$FormDesign->ItemDesc->FontSize,'Description: ' . $MyRow['itemdescription']);
$LeftOvers = $pdf->addText($FormDesign->SupplierName->x,$Page_Height-$FormDesign->SupplierName->y,$FormDesign->SupplierName->FontSize,'Supplier: ' . $SuppRow['suppname']);
$LeftOvers = $pdf->addText($FormDesign->SupplierLot->x,$Page_Height-$FormDesign->SupplierLot->y,$FormDesign->SupplierLot->FontSize,'Supplier Lot: ' . $SerialStockMoves['serialno']);
$LeftOvers = $pdf->addText($FormDesign->Lot->x,$Page_Height-$FormDesign->Lot->y,$FormDesign->Lot->FontSize,'Lot: ' . $SerialStockMoves['serialno']);
$LeftOvers = $pdf->addText($FormDesign->ReceiptDate->x,$Page_Height-$FormDesign->ReceiptDate->y,$FormDesign->ReceiptDate->FontSize,'Receipt Date: ' . $MyRow['deliverydate']);
$LeftOvers = $pdf->addText($FormDesign->OrderNumber->x,$Page_Height-$FormDesign->OrderNumber->y,$FormDesign->OrderNumber->FontSize,'P/O: ' . $MyRow['orderno']);
$PageNumber++;
} //while SerialStockMoves
} //controlled item*/
else {
if ($PageNumber>1){
$pdf->newPage();
}
$pdf->addJpegFromFile($_SESSION['LogoFile'] ,$FormDesign->logo->x,$Page_Height-$FormDesign->logo->y,$FormDesign->logo->width,$FormDesign->logo->height);
$LeftOvers = $pdf->addText($FormDesign->ItemNbr->x,$Page_Height-$FormDesign->ItemNbr->y,$FormDesign->ItemNbr->FontSize,'Item: ' . $MyRow['itemcode']);
$LeftOvers = $pdf->addText($FormDesign->ItemDesc->x,$Page_Height-$FormDesign->ItemDesc->y,$FormDesign->ItemDesc->FontSize,'Description: ' . $MyRow['itemdescription']);
$LeftOvers = $pdf->addText($FormDesign->SupplierName->x,$Page_Height-$FormDesign->SupplierName->y,$FormDesign->SupplierName->FontSize,'Supplier: ' . $SuppRow['suppname']);
//$LeftOvers = $pdf->addText($FormDesign->SupplierLot->x,$Page_Height-$FormDesign->SupplierLot->y,$FormDesign->SupplierLot->FontSize,'Supplier Lot: ' . $MyRow['serialno']);
//$LeftOvers = $pdf->addText($FormDesign->Lot->x,$Page_Height-$FormDesign->Lot->y,$FormDesign->Lot->FontSize,'Lot: ' . $MyRow['serialno']);
$LeftOvers = $pdf->addText($FormDesign->ReceiptDate->x,$Page_Height-$FormDesign->ReceiptDate->y,$FormDesign->ReceiptDate->FontSize,'Receipt Date: ' . $MyRow['deliverydate']);
$LeftOvers = $pdf->addText($FormDesign->OrderNumber->x,$Page_Height-$FormDesign->OrderNumber->y,$FormDesign->OrderNumber->FontSize,'P/O: ' . $MyRow['orderno']);
$PageNumber++;
} //else not controlled
} //end of loop around GRNs to print
$pdf->OutputD($_SESSION['DatabaseName'] . '_QALabel_' . $GRNNo . '_' . date('Y-m-d').'.pdf');
$pdf->__destruct();
} else { //there were not GRNs to print
$Title = _('GRN Error');
include('includes/header.php');
prnMsg(_('There were no GRNs to print'),'warn');
echo '<br /><a href="'.$RootPath.'/index.php">' . _('Back to the menu') . '</a>';
include('includes/footer.php');
}
?>