From: <dai...@us...> - 2014-04-08 08:27:10
|
Revision: 6680 http://sourceforge.net/p/web-erp/reponame/6680 Author: daintree Date: 2014-04-08 08:27:07 +0000 (Tue, 08 Apr 2014) Log Message: ----------- Andrew Galuski missing files from QA label and WO labels work Modified Paths: -------------- trunk/Z_MakeNewCompany.php Added Paths: ----------- trunk/PDFFGLabel.php trunk/PDFQALabel.php Added: trunk/PDFFGLabel.php =================================================================== --- trunk/PDFFGLabel.php (rev 0) +++ trunk/PDFFGLabel.php 2014-04-08 08:27:07 UTC (rev 6680) @@ -0,0 +1,220 @@ +<?php + +/* $Id: PDFFGLabel.php agaluski $*/ + +include('includes/session.inc'); + +if (isset($_GET['WO'])) { + $SelectedWO = $_GET['WO']; +} elseif (isset($_POST['WO'])){ + $SelectedWO = $_POST['WO']; +} else { + unset($SelectedWO); +} +if (isset($_GET['StockID'])) { + $StockID = $_GET['StockID']; +} elseif (isset($_POST['StockID'])){ + $StockID = $_POST['StockID']; +} else { + unset($StockID); +} + + +if (isset($_GET['LabelItem'])) { + $LabelItem = $_GET['LabelItem']; +} elseif (isset($_POST['LabelItem'])){ + $LabelItem = $_POST['LabelItem']; +} else { + unset($LabelItem); +} +if (isset($_GET['LabelDesc'])) { + $LabelDesc = $_GET['LabelDesc']; +} elseif (isset($_POST['LabelDesc'])){ + $LabelDesc = $_POST['LabelDesc']; +} else { + unset($LabelDesc); +} +if (isset($_GET['LabelLot'])) { + $LabelLot = $_GET['LabelLot']; +} elseif (isset($_POST['LabelLot'])){ + $LabelLot = $_POST['LabelLot']; +} else { + unset($LabelLot); +} +if (isset($_GET['NoOfBoxes'])) { + $NoOfBoxes = $_GET['NoOfBoxes']; +} elseif (isset($_POST['NoOfBoxes'])){ + $NoOfBoxes = $_POST['NoOfBoxes']; +} else { + unset($NoOfBoxes); +} +if (isset($_GET['LabelsPerBox'])) { + $LabelsPerBox = $_GET['LabelsPerBox']; +} elseif (isset($_POST['LabelsPerBox'])){ + $LabelsPerBox = $_POST['LabelsPerBox']; +} else { + unset($LabelsPerBox); +} +if (isset($_GET['QtyPerBox'])) { + $QtyPerBox = $_GET['QtyPerBox']; +} elseif (isset($_POST['QtyPerBox'])){ + $QtyPerBox = $_POST['QtyPerBox']; +} else { + unset($QtyPerBox); +} +if (isset($_GET['LeftOverQty'])) { + $LeftOverQty = $_GET['LeftOverQty']; +} elseif (isset($_POST['LeftOverQty'])){ + $LeftOverQty = $_POST['LeftOverQty']; +} else { + unset($LeftOverQty); +} + +/* If we are previewing the order then we dont want to email it */ +if ($SelectedWO == 'Preview') { //WO is set to 'Preview' when just looking at the format of the printed order + $_POST['PrintOrEmail'] = 'Print'; + $MakePDFThenDisplayIt = True; +} //$SelectedWO == 'Preview' + +if (isset($_POST['DoIt']) AND ($_POST['PrintOrEmail'] == 'Print' OR $ViewingOnly == 1)) { + $MakePDFThenDisplayIt = True; + $MakePDFThenEmailIt = False; +} elseif (isset($_POST['DoIt']) AND $_POST['PrintOrEmail'] == 'Email' AND isset($_POST['EmailTo'])) { + $MakePDFThenEmailIt = True; + $MakePDFThenDisplayIt = False; +} + +$FormDesign = simplexml_load_file($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/FGLabel.xml'); + +// Set the paper size/orintation +$PaperSize = $FormDesign->PaperSize; +$line_height=$FormDesign->LineHeight; +include('includes/PDFStarter.php'); +$PageNumber=1; +$pdf->addInfo('Title', _('FG Label') ); + +if ($SelectedWO == 'Preview'){ + $myrow['itemcode'] = str_pad('', 15,'x'); + $myrow['itemdescription'] = str_pad('', 25,'x'); + $myrow['serialno'] = str_pad('', 20,'x'); + $myrow['weight'] = '99999999'; + $ControlledRow['1'] = 'lbs'; + $ControlledRow['controlled']=1; + $NoOfLabels =1; +} else { //NOT PREVIEW + $i=1; + $NoOfLabels=$NoOfBoxes*$LabelsPerBox; + $BoxNumber=1; + while($i<=$NoOfLabels){ + $myarray[$i]['itemcode']=$LabelItem; + $myarray[$i]['itemdescription']=$LabelDesc; + $myarray[$i]['serialno']=$LabelLot; + $myarray[$i]['weight']=$QtyPerBox; + $myarray[$i]['box']=$BoxNumber; + if ($i % $LabelsPerBox == 0) { + $BoxNumber+=1; + } + $i++; + } + if ($LeftOverQty>0) { + $j=1; + while($j<=$LabelsPerBox){ + $myarray[$i]['itemcode']=$LabelItem; + $myarray[$i]['itemdescription']=$LabelDesc; + $myarray[$i]['serialno']=$LabelLot; + $myarray[$i]['weight']=$LeftOverQty; + $myarray[$i]['box']=$BoxNumber; + if ($i % $LabelsPerBox == 0) { + $BoxNumber+=1; + } + $i++; + $j++; + $NoOfLabels++; + } + } +} // get data to print +if ($NoOfLabels >0){ + + for ($i=1;$i<=$NoOfLabels;$i++) { + if ($SelectedWO!='Preview'){ + $myrow = $myarray[$i]; + //echo $myrow['itemcode'] ; + $SQL = "SELECT stockmaster.controlled, + stockmaster.units + FROM stockmaster WHERE stockid ='" . $myrow['itemcode'] . "'"; + //echo $SQL; + $CheckControlledResult = DB_query($SQL,$db,'<br />' . _('Could not determine if the item was controlled or not because') . ' '); + $ControlledRow = DB_fetch_row($CheckControlledResult); + //var_dump($ControlledRow); + } + if ($PageNumber>1){ + $pdf->newPage(); + } + $PageNumber++; + $pdf->addJpegFromFile($_SESSION['LogoFile'] ,$FormDesign->logo->x,$Page_Height-$FormDesign->logo->y,$FormDesign->logo->width,$FormDesign->logo->height); + $pdf->addText($FormDesign->CompanyAddress->Line1->x,$Page_Height - $FormDesign->CompanyAddress->Line1->y, $FormDesign->CompanyAddress->Line1->FontSize, $_SESSION['CompanyRecord']['regoffice1']); + $pdf->addText($FormDesign->CompanyAddress->Line2->x,$Page_Height - $FormDesign->CompanyAddress->Line2->y, $FormDesign->CompanyAddress->Line2->FontSize, $_SESSION['CompanyRecord']['regoffice2']); + $pdf->addText($FormDesign->CompanyAddress->Line3->x,$Page_Height - $FormDesign->CompanyAddress->Line3->y, $FormDesign->CompanyAddress->Line3->FontSize, $_SESSION['CompanyRecord']['regoffice3']); + $pdf->addText($FormDesign->CompanyAddress->phone->x,$Page_Height - $FormDesign->CompanyAddress->phone->y, $FormDesign->CompanyAddress->phone->FontSize, _('Tel'). ': ' . $_SESSION['CompanyRecord']['telephone']); + $pdf->addText($FormDesign->CompanyAddress->www->x,$Page_Height - $FormDesign->CompanyAddress->www->y, $FormDesign->CompanyAddress->www->FontSize, $_SESSION['CompanyRecord']['regoffice4']); + $pdf->Line($FormDesign->LabelLine->startx, $Page_Height - $FormDesign->LabelLine->starty, $FormDesign->LabelLine->endx,$Page_Height - $FormDesign->LabelLine->endy); + $pdf->addText($FormDesign->ItemNbr->x,$Page_Height-$FormDesign->ItemNbr->y,$FormDesign->ItemNbr->FontSize,'Item: ' . $myrow['itemcode']); + $pdf->addText($FormDesign->ItemDesc->x,$Page_Height-$FormDesign->ItemDesc->y,$FormDesign->ItemDesc->FontSize,'Description: ' . $myrow['itemdescription']); + $pdf->addText($FormDesign->Weight->x,$Page_Height-$FormDesign->Weight->y,$FormDesign->Weight->FontSize,'Weight' . '(' . $ControlledRow['1'] . '): ' . $myrow['weight']); + $pdf->addText($FormDesign->Box->x,$Page_Height-$FormDesign->Box->y,$FormDesign->Box->FontSize,'Box' . ': ' . $myrow['box']); + + if ($ControlledRow[0]==1) { /*Then its a controlled item */ + $pdf->addText($FormDesign->ResMartLot->x,$Page_Height-$FormDesign->ResMartLot->y,$FormDesign->ResMartLot->FontSize,'Lot: ' . $myrow['serialno']); + } //controlled item*/ + } //end of loop around GRNs to print + + $Success = 1; //assume the best and email goes - has to be set to 1 to allow update status + if ($MakePDFThenDisplayIt) { + $pdf->OutputD($_SESSION['DatabaseName'] . '_FGLABEL_' . $SelectedWO . '_' . date('Y-m-d') . '.pdf'); + $pdf->__destruct(); + } else { + $PdfFileName = $_SESSION['DatabaseName'] . '__FGLABEL_' . $SelectedWO . '_' . date('Y-m-d') . '.pdf'; + $pdf->Output($_SESSION['reports_dir'] . '/' . $PdfFileName, 'F'); + $pdf->__destruct(); + include('includes/htmlMimeMail.php'); + $mail = new htmlMimeMail(); + $attachment = $mail->getFile($_SESSION['reports_dir'] . '/' . $PdfFileName); + $mail->setText(_('Please Process this Work order number') . ' ' . $SelectedWO); + $mail->setSubject(_('Work Order Number') . ' ' . $SelectedWO); + $mail->addAttachment($attachment, $PdfFileName, 'application/pdf'); + //since sometime the mail server required to verify the users, so must set this information. + if($_SESSION['SmtpSetting'] == 0){//use the mail service provice by the server. + $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); + $Success = $mail->send(array($_POST['EmailTo'])); + }else if($_SESSION['SmtpSetting'] == 1) { + $Success = SendmailBySmtp($mail,array($_POST['EmailTo'])); + + }else{ + prnMsg(_('The SMTP settings are wrong, please ask administrator for help'),'error'); + exit; + include('includes/footer.inc'); + } + + if ($Success == 1) { + $Title = _('Email a Work Order'); + include('includes/header.inc'); + echo '<div class="centre"><br /><br /><br />'; + prnMsg(_('Work Order') . ' ' . $SelectedWO . ' ' . _('has been emailed to') . ' ' . $_POST['EmailTo'] . ' ' . _('as directed'), 'success'); + + } else { //email failed + $Title = _('Email a Work Order'); + include('includes/header.inc'); + echo '<div class="centre"><br /><br /><br />'; + prnMsg(_('Emailing Work order') . ' ' . $SelectedWO . ' ' . _('to') . ' ' . $_POST['EmailTo'] . ' ' . _('failed'), 'error'); + } + } + include('includes/footer.inc'); + +} else { //there were not labels to print + $Title = _('Label Error'); + include('includes/header.inc'); + prnMsg(_('There were no labels to print'),'warn'); + echo '<br /><a href="'.$RootPath.'/index.php">' . _('Back to the menu') . '</a>'; + include('includes/footer.inc'); +} +?> Added: trunk/PDFQALabel.php =================================================================== --- trunk/PDFQALabel.php (rev 0) +++ trunk/PDFQALabel.php 2014-04-08 08:27:07 UTC (rev 6680) @@ -0,0 +1,119 @@ +<?php + +/* $Id: PDFQALabel.php agaluski $*/ + +include('includes/session.inc'); + +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; +$line_height=$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'] = '0000-00-00'; + $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, $db); + $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,$db,_('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,$db,'<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,$db,_('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->ResMartLot->x,$Page_Height-$FormDesign->ResMartLot->y,$FormDesign->ResMartLot->FontSize,'ResMart 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 { + $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->ResMartLot->x,$Page_Height-$FormDesign->ResMartLot->y,$FormDesign->ResMartLot->FontSize,'ResMart 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']); + if ($PageNumber>1){ + $pdf->newPage(); + } + $PageNumber++; + } //else not controlled + } //end of loop around GRNs to print + + + $pdf->OutputD($_SESSION['DatabaseName'] . '_GRN_' . $GRNNo . '_' . date('Y-m-d').'.pdf'); + $pdf->__destruct(); +} else { //there were not GRNs to print + $Title = _('GRN Error'); + include('includes/header.inc'); + prnMsg(_('There were no GRNs to print'),'warn'); + echo '<br /><a href="'.$RootPath.'/index.php">' . _('Back to the menu') . '</a>'; + include('includes/footer.inc'); +} +?> Modified: trunk/Z_MakeNewCompany.php =================================================================== --- trunk/Z_MakeNewCompany.php 2014-04-07 14:26:40 UTC (rev 6679) +++ trunk/Z_MakeNewCompany.php 2014-04-08 08:27:07 UTC (rev 6680) @@ -138,6 +138,9 @@ copy ('./companies/' . $_SESSION['DatabaseName'] . '/FormDesigns/GoodsReceived.xml', './companies/' .$_POST['NewDatabase'] . '/FormDesigns/GoodsReceived.xml'); copy ('./companies/' . $_SESSION['DatabaseName'] . '/FormDesigns/PickingList.xml', './companies/' .$_POST['NewDatabase'] . '/FormDesigns/PickingList.xml'); copy ('./companies/' . $_SESSION['DatabaseName'] . '/FormDesigns/PurchaseOrder.xml', './companies/' .$_POST['NewDatabase'] . '/FormDesigns/PurchaseOrder.xml'); + copy ('./companies/' . $_SESSION['DatabaseName'] . '/FormDesigns/FGLabel.xml', './companies/' . $_POST['NewDatabase'] . '/FormDesigns/FGLabel.xml'); + copy ('./companies/' . $_SESSION['DatabaseName'] . '/FormDesigns/WOPaperwork.xml', './companies/' . $_POST['NewDatabase'] . '/FormDesigns/WOPaperwork.xml'); + copy ('./companies/' . $_SESSION['DatabaseName'] . '/FormDesigns/QALabel.xml', './companies/' . $_POST['NewDatabase'] . '/FormDesigns/QALabel.xml'); /*OK Now upload the logo */ if ($UploadTheLogo=='Yes'){ |