From: <tu...@us...> - 2018-01-26 23:55:59
|
Revision: 7924 http://sourceforge.net/p/web-erp/reponame/7924 Author: turbopt Date: 2018-01-26 23:55:55 +0000 (Fri, 26 Jan 2018) Log Message: ----------- Andrew Galuski/Tim (PaulT merge/commit): New picking list feature for regular and controlled/serialized stock. This feature improves (and replaces) the current pick list handling. (Reported in forums by HDeriauFF: http://www.weberp.org/forum/showthread.php?tid=7988) Modified Paths: -------------- trunk/AgedControlledInventory.php trunk/ConfirmDispatchControlled_Invoice.php trunk/ConfirmDispatch_Invoice.php trunk/PDFWOPrint.php trunk/PrintCustOrder_generic.php trunk/SelectSalesOrder.php trunk/SystemParameters.php trunk/Z_ChangeStockCode.php trunk/companies/weberpdemo/FormDesigns/PickingList.xml trunk/doc/Change.log trunk/includes/Add_SerialItems.php trunk/includes/InputSerialItems.php trunk/includes/InputSerialItemsExisting.php trunk/includes/MainMenuLinksArray.php trunk/sql/mysql/country_sql/default.sql trunk/sql/mysql/country_sql/demo.sql trunk/sql/mysql/upgrade4.14.1-4.14.2.sql Added Paths: ----------- trunk/GeneratePickingList.php trunk/PDFAck.php trunk/PDFShipLabel.php trunk/PickingLists.php trunk/PickingListsControlled.php trunk/SelectPickingLists.php trunk/companies/weberpdemo/FormDesigns/ShippingLabel.xml trunk/includes/GenPickingListHeader.inc trunk/includes/PDFAckPageHeader.php Modified: trunk/AgedControlledInventory.php =================================================================== --- trunk/AgedControlledInventory.php 2018-01-26 14:22:29 UTC (rev 7923) +++ trunk/AgedControlledInventory.php 2018-01-26 23:55:55 UTC (rev 7924) @@ -4,8 +4,10 @@ include('includes/session.php'); $PricesSecurity = 12;//don't show pricing info unless security token 12 available to user + $Today = time(); -$Title = _('Aged Controlled Inventory') . ' ' ._('as-of') .' ' . Date(($_SESSION['DefaultDateFormat']), strtotime($UpcomingDate . ' + 0 days')); +$Title = _('Aged Controlled Inventory') . ' ' . _('as-of') . ' ' . Date(($_SESSION['DefaultDateFormat']), $Today); + include('includes/header.php'); echo '<p class="page_title_text"> @@ -19,24 +21,30 @@ stockserialitems.quantity, stockmoves.trandate, stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost AS cost, + createdate, decimalplaces FROM stockserialitems - LEFT JOIN stockserialmoves ON stockserialitems.serialno=stockserialmoves.serialno - LEFT JOIN stockmoves ON stockserialmoves.stockmoveno=stockmoves.stkmoveno - INNER JOIN stockmaster ON stockmaster.stockid = stockserialitems.stockid - INNER JOIN locationusers ON locationusers.loccode=stockserialitems.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1 + LEFT JOIN stockserialmoves + ON stockserialitems.serialno=stockserialmoves.serialno + LEFT JOIN stockmoves + ON stockserialmoves.stockmoveno=stockmoves.stkmoveno + INNER JOIN stockmaster + ON stockmaster.stockid = stockserialitems.stockid + INNER JOIN locationusers + ON locationusers.loccode=stockserialitems.loccode + AND locationusers.userid='" . $_SESSION['UserID'] . "' + AND locationusers.canview=1 WHERE quantity > 0 - GROUP BY stockid, serialno - ORDER BY trandate"; + ORDER BY createdate, quantity"; $ErrMsg = _('The stock held could not be retrieved because'); $LocStockResult = DB_query($sql, $ErrMsg); -$NumRows = DB_num_rows($LocStockResult, $db); +$NumRows = DB_num_rows($LocStockResult); -$j = 1; $TotalQty=0; $TotalVal=0; $k=0; //row colour counter + echo '<table> <tr> <th class="ascending">' . _('Stock') . '</th> @@ -47,6 +55,7 @@ <th class="ascending">' . _('Date') . '</th> <th class="ascending">' . _('Days Old') . '</th> </tr>'; + while ($LocQtyRow=DB_fetch_array($LocStockResult)) { if ($k==1){ @@ -56,14 +65,16 @@ echo '<tr class="EvenTableRows">'; $k=1; } - $DaysOld=floor(($Today - strtotime($LocQtyRow['trandate']))/(60*60*24)); + + $DaysOld=floor(($Today - strtotime($LocQtyRow['createdate']))/(60*60*24)); $TotalQty +=$LocQtyRow['quantity']; - //$TotalVal +=($LocQtyRow['quantity'] *$LocQtyRow['cost']); $DispVal = '-----------'; + if (in_array($PricesSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PricesSecurity)) { $DispVal =locale_number_format(($LocQtyRow['quantity']*$LocQtyRow['cost']),$LocQtyRow['decimalplaces']); $TotalVal +=($LocQtyRow['quantity'] *$LocQtyRow['cost']); } + printf('<td>%s</td> <td>%s</td> <td>%s</td> @@ -70,17 +81,18 @@ <td class="number">%s</td> <td class="number">%s</td> <td>%s</td> - <td class="number">%s</td></tr>', + <td class="number">%s</td> + </tr>', mb_strtoupper($LocQtyRow['stockid']), $LocQtyRow['description'], $LocQtyRow['serialno'], locale_number_format($LocQtyRow['quantity'],$LocQtyRow['decimalplaces']), $DispVal, - ConvertSQLDate($LocQtyRow['trandate']), - $DaysOld); + ConvertSQLDate($LocQtyRow['createdate']), + $DaysOld + ); +} //while - -} //while if ($k==1){ echo '<tfoot><tr class="OddTableRows">'; $k=0; @@ -88,7 +100,12 @@ echo '<tfoot><tr class="EvenTableRows">'; $k=1; } -echo '<td colspan="3"><b>' . _('Total') . '</b></td><td class="number"><b>' . locale_number_format($TotalQty,2) . '</td><td class="number"><b>' . locale_number_format($TotalVal,2) . '</td><td colspan="2"></td>'; + +echo '<td colspan="3"><b>' . _('Total') . '</b></td> + <td class="number"><b>' . locale_number_format($TotalQty,2) . '</b></td> + <td class="number"><b>' . locale_number_format($TotalVal,2) . '</b></td> + <td colspan="2"></td> + </tr></tfoot>'; echo '</table>'; include('includes/footer.php'); Modified: trunk/ConfirmDispatchControlled_Invoice.php =================================================================== --- trunk/ConfirmDispatchControlled_Invoice.php 2018-01-26 14:22:29 UTC (rev 7923) +++ trunk/ConfirmDispatchControlled_Invoice.php 2018-01-26 23:55:55 UTC (rev 7924) @@ -72,6 +72,13 @@ $RecvQty = $LineItem->Quantity-$LineItem->QtyInv; $ItemMustExist = true; /*Can only invoice valid batches/serial numbered items that exist */ $LocationOut = $_SESSION['Items'.$identifier]->Location; + +if ($_SESSION['RequirePickingNote'] == 1) { + $OrderstoPick = $_SESSION['Items'.$identifier]->OrderNo; +} else { + unset($OrderstoPick); +} + $InOutModifier=1; $ShowExisting=true; Modified: trunk/ConfirmDispatch_Invoice.php =================================================================== --- trunk/ConfirmDispatch_Invoice.php 2018-01-26 14:22:29 UTC (rev 7923) +++ trunk/ConfirmDispatch_Invoice.php 2018-01-26 23:55:55 UTC (rev 7924) @@ -8,6 +8,8 @@ include('includes/session.php'); $Title = _('Confirm Dispatches and Invoice An Order'); + +/* Manual links before header.php */ $ViewTopic= 'ARTransactions'; $BookMark = 'ConfirmInvoice'; include('includes/header.php'); @@ -51,6 +53,7 @@ salesorders.branchcode, salesorders.customerref, salesorders.comments, + salesorders.internalcomment, salesorders.orddate, salesorders.ordertype, salesorders.shipvia, @@ -73,17 +76,26 @@ currencies.rate as currency_rate, currencies.decimalplaces, custbranch.defaultshipvia, - custbranch.specialinstructions - FROM salesorders INNER JOIN debtorsmaster - ON salesorders.debtorno = debtorsmaster.debtorno + custbranch.specialinstructions, + pickreq.consignment, + pickreq.packages + FROM salesorders + INNER JOIN debtorsmaster + ON salesorders.debtorno = debtorsmaster.debtorno INNER JOIN custbranch - ON salesorders.branchcode = custbranch.branchcode - AND salesorders.debtorno = custbranch.debtorno + ON salesorders.branchcode = custbranch.branchcode + AND salesorders.debtorno = custbranch.debtorno INNER JOIN currencies - ON debtorsmaster.currcode = currencies.currabrev + ON debtorsmaster.currcode = currencies.currabrev INNER JOIN locations - ON locations.loccode=salesorders.fromstkloc - INNER JOIN locationusers ON locationusers.loccode=salesorders.fromstkloc AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canupd=1 + ON locations.loccode=salesorders.fromstkloc + INNER JOIN locationusers + ON locationusers.loccode=salesorders.fromstkloc + AND locationusers.userid='" . $_SESSION['UserID'] . "' + AND locationusers.canupd=1 + LEFT OUTER JOIN pickreq + ON pickreq.orderno=salesorders.orderno + AND pickreq.closed=0 WHERE salesorders.orderno = '" . $_GET['OrderNumber']."'"; if($_SESSION['SalesmanLogin'] != '') { @@ -109,6 +121,9 @@ $_SESSION['Items'.$identifier]->CurrDecimalPlaces = $myrow['decimalplaces']; $BestShipper = $myrow['shipvia']; $_SESSION['Items'.$identifier]->ShipVia = $myrow['shipvia']; + $_SESSION['Items'.$identifier]->InternalComments = reverse_escape($myrow['internalcomment']); + $_SESSION['Items'.$identifier]->Consignment = $myrow['consignment']; + $_SESSION['Items'.$identifier]->Packages = $myrow['packages']; if(is_null($BestShipper)) { $BestShipper=0; @@ -175,6 +190,9 @@ if(DB_num_rows($LineItemsResult)>0) { while ($myrow=DB_fetch_array($LineItemsResult)) { + $QOHSQL = "SELECT quantity FROM locstock WHERE stockid='" . $myrow['stkcode'] . "' and loccode='" . $_SESSION['Items'.$identifier]->Location . "'"; + $QOHResult = DB_query($QOHSQL); + $QOHRow = DB_fetch_array($QOHResult); $_SESSION['Items'.$identifier]->add_to_cart($myrow['stkcode'], $myrow['quantity'], @@ -185,7 +203,7 @@ $myrow['units'], $myrow['volume'], $myrow['grossweight'], - 0, + $QOHRow['quantity'], $myrow['mbflag'], $myrow['actualdispatchdate'], $myrow['qtyinvoiced'], @@ -205,7 +223,35 @@ /*Calculate the taxes applicable to this line item from the customer branch Tax Group and Item Tax Category */ $_SESSION['Items'.$identifier]->GetTaxes($myrow['orderlineno']); + $SerialItemsSQL = "SELECT pickreqdetails.qtypicked, + pickserialdetails.stockid, + serialno, + moveqty + FROM pickreq + INNER JOIN pickreqdetails + ON pickreqdetails.prid=pickreq.prid + LEFT OUTER JOIN pickserialdetails + ON pickserialdetails.detailno=pickreqdetails.detailno + WHERE pickreq.orderno ='" . $_GET['OrderNumber'] . "' + AND pickreq.closed=0 + AND pickreqdetails.orderlineno='" . $myrow['orderlineno'] . "'"; + $ErrMsg = _('The serial items of the pick list cannot be retrieved because'); + $DbgMsg = _('The SQL that failed was'); + $SerialItemsResult = DB_query($SerialItemsSQL, $ErrMsg, $DbgMsg); + + if (DB_num_rows($SerialItemsResult) > 0) { + $InOutModifier = 1; + while ($MySerial = DB_fetch_array($SerialItemsResult)) { + if (isset($MySerial['serialno'])) { + $_SESSION['Items'.$identifier]->LineItems[$myrow['orderlineno']]->SerialItems[$MySerial['serialno']] = new SerialItem($MySerial['serialno'], ($InOutModifier > 0 ? 1 : 1) * filter_number_format($MySerial['moveqty'])); + } else { + if ($_SESSION['RequirePickingNote'] == 1) { + $_SESSION['Items'.$identifier]->LineItems[$myrow['orderlineno']]->QtyDispatched = $MySerial['qtypicked']; + } + } + } + } } /* line items from sales order details */ } else { /* there are no line items that have a quantity to deliver */ echo '<br />'; @@ -233,6 +279,9 @@ if(isset($_POST['ChargeFreightCost'])) { $_SESSION['Items'.$identifier]->FreightCost = filter_number_format($_POST['ChargeFreightCost']); } + if (isset($_POST['InternalComments'])) { + $_SESSION['Items'.$identifier]->InternalComments = $_POST['InternalComments']; + } $i=1; foreach ($_SESSION['Items'.$identifier]->FreightTaxes as $FreightTaxLine) { if(isset($_POST['FreightTaxRate' . $i])) { @@ -249,7 +298,7 @@ } //Preventing from dispatched more than ordered. Since it's controlled items, users must select the batch/lot again. if($_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyDispatched > ($_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyInv)) { - prnMsg(_('Dispathed Quantity should not be more than order balanced quantity').'. '._('To dispatch quantity is').' '.$_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyDispatched.' '._('And the order balance is ').' '.($_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyInv),'error'); + prnMsg(_('Dispatched Quantity should not be more than order balanced quantity').'. '._('To dispatch quantity is').' '.$_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyDispatched.' '._('And the order balance is ').' '.($_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyInv),'error'); include('includes/footer.php'); exit; } @@ -325,34 +374,52 @@ /*show the line items on the order with the quantity being dispatched available for modification */ $k=0; //row colour counter -$j=0; +$j=0; //used for tabindex + foreach ($_SESSION['Items'.$identifier]->LineItems as $LnItm) { $j++; - $LineTotal = $LnItm->QtyDispatched * $LnItm->Price * (1 - $LnItm->DiscountPercent); - $_SESSION['Items'.$identifier]->total += $LineTotal; - $_SESSION['Items'.$identifier]->totalVolume += ($LnItm->QtyDispatched * $LnItm->Volume); - $_SESSION['Items'.$identifier]->totalWeight += ($LnItm->QtyDispatched * $LnItm->Weight); - if($k==1) { - $RowStarter = '<tr class="EvenTableRows">'; + if ($LnItm->QOHatLoc < $LnItm->Quantity and ($LnItm->MBflag == 'B' or $LnItm->MBflag == 'M')) { + /*There is a stock deficiency in the stock location selected */ + $RowStarter = '<tr style="background:#FF0000;color:#FFC0CB">'; //rows show red where stock deficiency + } elseif ($k == 1) { + $RowStarter = '<tr class="OddTableRows">'; $k = 0; } else { - $RowStarter = '<tr class="OddTableRows">'; + $RowStarter = '<tr class="EvenTableRows">'; $k = 1; } - echo $RowStarter, ' - <td>', $LnItm->StockID, '</td> - <td class="text" title="', $LnItm->LongDescription, '">', $LnItm->ItemDescription, '</td> - <td class="number">', locale_number_format($LnItm->Quantity, $LnItm->DecimalPlaces), '</td> - <td class="text">', $LnItm->Units, '</td> - <td class="number">', locale_number_format($LnItm->QtyInv, $LnItm->DecimalPlaces), '</td>'; + if (sizeOf($LnItm->SerialItems) > 0) { + $_SESSION['Items'.$identifier]->LineItems[$LnItm->LineNumber]->QtyDispatched = 0; //initialise QtyDispatched + foreach ($LnItm->SerialItems as $SerialItem) { //calculate QtyDispatched from bundle quantities + $_SESSION['Items'.$identifier]->LineItems[$LnItm->LineNumber]->QtyDispatched += $SerialItem->BundleQty; + } + } else if (isset($_POST[$LnItm->LineNumber . '_QtyDispatched'])) { + if (is_numeric(filter_number_format($_POST[$LnItm->LineNumber . '_QtyDispatched'])) and filter_number_format($_POST[$LnItm->LineNumber . '_QtyDispatched']) <= ($_SESSION['Items'.$identifier]->LineItems[$LnItm->LineNumber]->Quantity - $_SESSION['Items'.$identifier]->LineItems[$LnItm->LineNumber]->QtyInv)) { + + $_SESSION['Items'.$identifier]->LineItems[$LnItm->LineNumber]->QtyDispatched = round(filter_number_format($_POST[$LnItm->LineNumber . '_QtyDispatched']), $LnItm->DecimalPlaces); + } + } + + $LineTotal = $LnItm->QtyDispatched * $LnItm->Price * (1 - $LnItm->DiscountPercent); + $_SESSION['Items'.$identifier]->total += $LineTotal; + $_SESSION['Items'.$identifier]->totalVolume += ($LnItm->QtyDispatched * $LnItm->Volume); + $_SESSION['Items'.$identifier]->totalWeight += ($LnItm->QtyDispatched * $LnItm->Weight); + + echo $RowStarter; + echo '<td>' . $LnItm->StockID . '</td> + <td class="text" title="' . $LnItm->LongDescription . '">' . $LnItm->ItemDescription . '</td> + <td class="number">' . locale_number_format($LnItm->Quantity, $LnItm->DecimalPlaces) . '</td> + <td class="text">' . $LnItm->Units . '</td> + <td class="number">' . locale_number_format($LnItm->QtyInv, $LnItm->DecimalPlaces) . '</td>'; + if($LnItm->Controlled==1) { if(isset($_POST['ProcessInvoice'])) { echo '<td class="number">' . locale_number_format($LnItm->QtyDispatched,$LnItm->DecimalPlaces) . '</td>'; } else { - echo '<td class="number"><input type="hidden" name="' . $LnItm->LineNumber . '_QtyDispatched" value="' . $LnItm->QtyDispatched . '" /><a href="' . $RootPath .'/ConfirmDispatchControlled_Invoice.php?identifier=' . $identifier . '&LineNo='. $LnItm->LineNumber.'">' .locale_number_format($LnItm->QtyDispatched,$LnItm->DecimalPlaces) . '</a></td>'; + echo '<td class="number"><input type="hidden" name="' . $LnItm->LineNumber . '_QtyDispatched" required="required" maxlength="11" value="' . $LnItm->QtyDispatched . '" /><a href="' . $RootPath .'/ConfirmDispatchControlled_Invoice.php?identifier=' . urlencode($identifier) . '&LineNo=' . urlencode($LnItm->LineNumber) . '">' .locale_number_format($LnItm->QtyDispatched,$LnItm->DecimalPlaces) . '</a></td>'; } } else { if(isset($_POST['ProcessInvoice'])) { @@ -420,7 +487,7 @@ if($LnItm->Controlled==1) { if(!isset($_POST['ProcessInvoice'])) { - echo '<td><a href="' . $RootPath . '/ConfirmDispatchControlled_Invoice.php?identifier=' . $identifier . '&LineNo='. $LnItm->LineNumber.'">'; + echo '<td><a href="' . $RootPath . '/ConfirmDispatchControlled_Invoice.php?identifier=' . urlencode($identifier) . '&LineNo=' . urlencode($LnItm->LineNumber) . '">'; if($LnItm->Serialised==1) { echo _('Enter Serial Numbers'); } else { /*Just batch/roll/lot control */ @@ -441,7 +508,7 @@ It seems unfair to charge the customer twice for freight if the order was not fully delivered the first time ?? */ -if(!isset($_SESSION['Items'.$identifier]->FreightCost)) { +if (!isset($_SESSION['Items'.$identifier]->FreightCost) or $_SESSION['Items'.$identifier]->FreightCost == 0) { if($_SESSION['DoFreightCalc']==True) { list ($FreightCost, $BestShipper) = CalcFreightCost($_SESSION['Items'.$identifier]->total, $_SESSION['Items'.$identifier]->BrAdd2, @@ -456,7 +523,7 @@ $db); $_SESSION['Items'.$identifier]->ShipVia = $BestShipper; } - if(is_numeric($FreightCost)) { + if (isset($FreightCost) and is_numeric($FreightCost)) { $FreightCost = $FreightCost / $_SESSION['CurrencyRate']; } else { $FreightCost =0; @@ -634,8 +701,8 @@ ON stockmaster.stockid=bom.component WHERE bom.parent='" . $OrderLine->StockID . "' AND locstock.loccode='" . $_SESSION['Items'.$identifier]->Location . "' - AND bom.effectiveafter <= '" . date('Y-m-d') . "' - AND bom.effectiveto > '" . date('Y-m-d') . "'"; + AND effectiveafter <= CURRENT_DATE + AND effectiveto > CURRENT_DATE"; $ErrMsg = _('Could not retrieve the component quantity left at the location once the assembly item on this order is invoiced (for the purposes of checking that stock will not go negative because)'); $Result = DB_query($SQL,$ErrMsg); @@ -768,7 +835,9 @@ /*Update order header for invoice charged on */ $SQL = "UPDATE salesorders - SET comments = CONCAT(comments,' Inv ','" . $InvoiceNo . "') + SET comments = CONCAT(comments,' Inv ','" . $InvoiceNo . "'), + internalcomment = '" . $_POST['InternalComments'] . "', + printedpackingslip=0 WHERE orderno= '" . $_SESSION['ProcessingOrder']."'"; $ErrMsg = _('CRITICAL ERROR') . ' ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales order header could not be updated with the invoice number'); @@ -804,7 +873,7 @@ '" . $DefaultDispatchDate . "', '" . date('Y-m-d H-i-s') . "', '" . $PeriodNo . "', - '', + '" . $_SESSION['Items'.$identifier]->CustRef . "', '" . $_SESSION['Items'.$identifier]->DefaultSalesType . "', '" . $_SESSION['ProcessingOrder'] . "', '" . $_SESSION['Items'.$identifier]->total . "', @@ -946,8 +1015,32 @@ $DbgMsg = _('The following SQL to update the sales order detail record was used'); $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); - /* Update location stock records if not a dummy stock item - need the MBFlag later too so save it to $MBFlag */ + /*update any open pickreqdetails*/ + $LineItemsSQL = "SELECT pickreqdetails.detailno + FROM pickreqdetails INNER JOIN pickreq ON pickreq.prid=pickreqdetails.prid + INNER JOIN salesorderdetails + ON salesorderdetails.orderno = pickreq.orderno + AND salesorderdetails.orderlineno=pickreqdetails.orderlineno + WHERE pickreq.orderno ='" . $_SESSION['ProcessingOrder'] . "' + AND pickreq.closed=0 + AND salesorderdetails.orderlineno='" . $OrderLine->LineNumber . "'"; + + $ErrMsg = _('The line items of the pick list cannot be retrieved because'); + $DbgMsg = _('The SQL that failed was'); + $LineItemsResult = DB_query($LineItemsSQL, $ErrMsg, $DbgMsg); + + $MyLine = DB_fetch_array($LineItemsResult); + $DetailNo = $MyLine['detailno']; + $SQL = "UPDATE pickreqdetails + SET invoicedqty='" . $OrderLine->QtyDispatched . "' + WHERE detailno='" . $DetailNo . "'"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The pickreqdetail record could not be inserted because'); + $DbgMsg = _('The following SQL to insert the pickreqdetail records was used'); + $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true); + + /* Update location stock records if not a dummy stock item + need the MBFlag later too so save it to $MBFlag */ $Result = DB_query("SELECT mbflag FROM stockmaster WHERE stockid = '" . $OrderLine->StockID . "'", @@ -996,8 +1089,8 @@ FROM bom INNER JOIN stockmaster ON bom.component=stockmaster.stockid WHERE bom.parent='" . $OrderLine->StockID . "' - AND bom.effectiveafter <= '" . date('Y-m-d') . "' - AND bom.effectiveto > '" . date('Y-m-d') . "'"; + AND bom.effectiveto > CURRENT_DATE + AND bom.effectiveafter <= CURRENT_DATE"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Could not retrieve assembly components from the database for'). ' '. $OrderLine->StockID . _('because').' '; $DbgMsg = _('The SQL that failed was'); @@ -1145,7 +1238,7 @@ '" . $_SESSION['Items'.$identifier]->Branch . "', '" . $LocalCurrencyPrice . "', '" . $PeriodNo . "', - '" . $_SESSION['ProcessingOrder'] . "', + '" . DB_escape_string($_SESSION['ProcessingOrder']) . "', '" . -$OrderLine->QtyDispatched . "', '" . $OrderLine->DiscountPercent . "', '" . $OrderLine->StandardCost . "', @@ -1228,7 +1321,8 @@ salesanalysis.periodno, salesanalysis.typeabbrev, salesanalysis.salesperson - FROM salesanalysis INNER JOIN custbranch + FROM salesanalysis + INNER JOIN custbranch ON salesanalysis.cust=custbranch.debtorno AND salesanalysis.custbranch=custbranch.branchcode AND salesanalysis.area=custbranch.area @@ -1235,12 +1329,12 @@ INNER JOIN stockmaster ON salesanalysis.stkcategory=stockmaster.categoryid WHERE salesanalysis.salesperson='" . $_SESSION['Items'.$identifier]->SalesPerson . "' - AND salesanalysis.typeabbrev ='" . $_SESSION['Items'.$identifier]->DefaultSalesType . "' - AND salesanalysis.periodno='" . $PeriodNo . "' - AND salesanalysis.cust='" . $_SESSION['Items'.$identifier]->DebtorNo . "' - AND salesanalysis.custbranch='" . $_SESSION['Items'.$identifier]->Branch . "' - AND salesanalysis.stockid='" . $OrderLine->StockID . "' - AND salesanalysis.budgetoractual=1 + AND salesanalysis.typeabbrev ='" . $_SESSION['Items'.$identifier]->DefaultSalesType . "' + AND salesanalysis.periodno='" . $PeriodNo . "' + AND salesanalysis.cust='" . $_SESSION['Items'.$identifier]->DebtorNo . "' + AND salesanalysis.custbranch='" . $_SESSION['Items'.$identifier]->Branch . "' + AND salesanalysis.stockid='" . $OrderLine->StockID . "' + AND salesanalysis.budgetoractual=1 GROUP BY salesanalysis.stockid, salesanalysis.stkcategory, salesanalysis.cust, @@ -1540,7 +1634,7 @@ 10, '" . $InvoiceNo . "', '" . $PeriodNo . "', - '" . Date('Y-m-d') . "', + CURRENT_DATE, 'disposal', '" . round(($OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . "', '" . $DefaultDispatchDate . "')"; @@ -1562,6 +1656,16 @@ } /*end of OrderLine loop */ + /*update any open pick list*/ + $SQL = "UPDATE pickreq + SET status = 'Invoiced', + closed='1' + WHERE orderno= '" . $_SESSION['ProcessingOrder'] . "' + AND closed=0"; + $ErrMsg = _('CRITICAL ERROR') . ' ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The pick list header could not be updated'); + $DbgMsg = _('The following SQL to update the pick list was used'); + $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true); + if($_SESSION['CompanyRecord']['gllink_debtors']==1) { /*Post debtors transaction to GL debit debtors, credit freight re-charged and credit sales */ @@ -1635,10 +1739,10 @@ } } } /*end of if Sales and GL integrated */ - EnsureGLEntriesBalance(10,$InvoiceNo,$db); DB_Txn_Commit(); + EnsureGLEntriesBalance(10, $InvoiceNo,$db); // ************************************************************************* // E N D O F I N V O I C E S Q L P R O C E S S I N G // ************************************************************************* @@ -1664,10 +1768,18 @@ } else { /*Process Invoice not set so allow input of invoice data */ if(!isset($_POST['Consignment'])) { - $_POST['Consignment']=''; + if ($_SESSION['Items'.$identifier]->Consignment != '') { + $_POST['Consignment'] = $_SESSION['Items'.$identifier]->Consignment; + } else { + $_POST['Consignment']=''; + } } if(!isset($_POST['Packages'])) { - $_POST['Packages']='1'; + if ($_SESSION['Items'.$identifier]->Packages) { + $_POST['Packages'] = $_SESSION['Items'.$identifier]->Packages; + } else { + $_POST['Packages']='1'; + } } if(!isset($_POST['InvoiceText'])) { $_POST['InvoiceText']=''; @@ -1676,7 +1788,7 @@ echo '<table class="selection"> <tr> <td>' ._('Date On Invoice'). ':</td> - <td><input tabindex="'.$j.'" type="text" maxlength="10" size="15" required="required" name="DispatchDate" value="' . $DefaultDispatchDate . '" id="datepicker" alt="' . $_SESSION['DefaultDateFormat'] . '" class="date" /></td> + <td><input tabindex="'.$j.'" type="text" required="required" maxlength="10" size="15" required="required" name="DispatchDate" value="' . $DefaultDispatchDate . '" id="datepicker" alt="' . $_SESSION['DefaultDateFormat'] . '" class="date" /></td> </tr>'; $j++; echo '<tr> @@ -1692,7 +1804,12 @@ $j++; echo '<tr> <td>' . _('Action For Balance'). ':</td> - <td><select tabindex="'.$j.'" name="BOPolicy"><option selected="selected" value="BO">' . _('Automatically put balance on back order') . '</option><option value="CAN">' . _('Cancel any quantities not delivered') . '</option></select></td> + <td> + <select required="required" tabindex="' . $j . '" name="BOPolicy"> + <option selected="selected" value="BO">' . _('Automatically put balance on back order') . '</option> + <option value="CAN">' . _('Cancel any quantities not delivered') . '</option> + </select> + </td> </tr>'; $j++; echo '<tr> @@ -1700,6 +1817,12 @@ <td><textarea tabindex="'.$j.'" name="InvoiceText" pattern=".{0,20}" cols="31" rows="5">' . reverse_escape($_POST['InvoiceText']) . '</textarea></td> </tr>'; + ++$j; + echo '<tr> + <td>' . _('Internal Comments') . ':</td> + <td><textarea tabindex="' . $j . '" name="InternalComments" pattern=".{0,20}" cols="31" rows="5">' . reverse_escape($_SESSION['Items'.$identifier]->InternalComments) . '</textarea></td> + </tr>'; + $j++; echo '</table> <br /> @@ -1709,7 +1832,7 @@ $j++; echo '<br /> - <input type="submit" tabindex="'.$j.'" name="ProcessInvoice" value="'._('Process Invoice').'" /> + <input type="submit" tabindex="'.$j.'" name="ProcessInvoice" value="'._('Process Invoice').'" /> </div> <input type="hidden" name="ShipVia" value="' . $_SESSION['Items'.$identifier]->ShipVia . '" />'; } @@ -1717,4 +1840,4 @@ echo '</form>'; include('includes/footer.php'); -?> +?> \ No newline at end of file Added: trunk/GeneratePickingList.php =================================================================== --- trunk/GeneratePickingList.php (rev 0) +++ trunk/GeneratePickingList.php 2018-01-26 23:55:55 UTC (rev 7924) @@ -0,0 +1,513 @@ +<?php + +/* $Id: GeneratePickingList.php 1 2014-08-26 11:54:03Z agaluski $*/ + +include('includes/session.php'); +include('includes/SQL_CommonFunctions.inc'); + +/* Check that the config variable is set for + * picking notes and get out if not. + */ +if ($_SESSION['RequirePickingNote'] == 0) { + $Title = _('Picking Lists Not Enabled'); + include('includes/header.php'); + echo '<br />'; + prnMsg(_('The system is not configured for picking lists. A configuration parameter is required where picking slips are required. Please consult your system administrator.'), 'info'); + include('includes/footer.php'); + exit; +} + +/* Show selection screen if we have no orders to work with */ +if ((!isset($_GET['TransNo']) or $_GET['TransNo'] == '') and !isset($_POST['TransDate'])) { + $Title = _('Select Picking Lists'); + include('includes/header.php'); + $SQL = "SELECT locations.loccode, + locationname + FROM locations + INNER JOIN locationusers ON locationusers.loccode=locations.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canupd=1"; + $Result = DB_query($SQL); + echo '<p class="page_title_text"><img src="' . $RootPath . '/css/' . $_SESSION['Theme'] . '/images/sales.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title . '</p><br />'; + echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post" name="form"> + <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" /> + <table class="selection"> + <tr> + <td>' . _('Create picking lists for all deliveries to be made on') . ' : ' . '</td> + <td><input type="text" required="required" autofocus="autofocus" class="date" name="TransDate" maxlength="10" size="11" value="' . date($_SESSION['DefaultDateFormat'], mktime(date('m'), date('Y'), date('d') + 1)) . '" /></td> + </tr> + <tr> + <td>' . _('From Warehouse') . ' : ' . '</td> + <td><select required="required" name="loccode">'; + while ($MyRow = DB_fetch_array($Result)) { + echo '<option value="' . $MyRow['loccode'] . '">' . $MyRow['locationname'] . '</option>'; + } + echo '</select></td> + </tr> + </table>'; + echo '<div class="centre"> + <input type="submit" name="Process" value="' . _('Print Picking Lists') . '" /> + </div> + </form>'; + include('includes/footer.php'); + exit(); +} + +/*retrieve the order details from the database to print */ +$ErrMsg = _('There was a problem retrieving the order header details from the database'); + +if (!isset($_POST['TransDate']) and $_GET['TransNo'] != 'Preview') { + /* If there is no transaction date set, then it must be for a single order */ + $SQL = "SELECT salesorders.debtorno, + salesorders.orderno, + salesorders.customerref, + salesorders.comments, + salesorders.orddate, + salesorders.deliverto, + salesorders.deladd1, + salesorders.deladd2, + salesorders.deladd3, + salesorders.deladd4, + salesorders.deladd5, + salesorders.deladd6, + salesorders.deliverblind, + salesorders.deliverydate, + debtorsmaster.name, + debtorsmaster.address1, + debtorsmaster.address2, + debtorsmaster.address3, + debtorsmaster.address4, + debtorsmaster.address5, + debtorsmaster.address6, + shippers.shippername, + salesorders.printedpackingslip, + salesorders.datepackingslipprinted, + locations.loccode, + locations.locationname + FROM salesorders INNER JOIN salesorderdetails on salesorderdetails.orderno=salesorders.orderno, + debtorsmaster, + shippers, + locations INNER JOIN locationusers ON locationusers.loccode=locations.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canupd=1 + WHERE salesorders.debtorno=debtorsmaster.debtorno + AND salesorders.shipvia=shippers.shipper_id + AND salesorders.fromstkloc=locations.loccode + AND salesorders.orderno='" . $_GET['TransNo'] . "' + AND salesorderdetails.completed=0 + GROUP BY salesorders.orderno"; +} else if (isset($_POST['TransDate']) or (isset($_GET['TransNo']) and $_GET['TransNo'] != 'Preview')) { + /* We are printing picking lists for all orders on a day */ + $SQL = "SELECT salesorders.debtorno, + salesorders.orderno, + salesorders.customerref, + salesorders.comments, + salesorders.orddate, + salesorders.deliverto, + salesorders.deladd1, + salesorders.deladd2, + salesorders.deladd3, + salesorders.deladd4, + salesorders.deladd5, + salesorders.deladd6, + salesorders.deliverblind, + salesorders.deliverydate, + debtorsmaster.name, + debtorsmaster.address1, + debtorsmaster.address2, + debtorsmaster.address3, + debtorsmaster.address4, + debtorsmaster.address5, + debtorsmaster.address6, + shippers.shippername, + salesorders.printedpackingslip, + salesorders.datepackingslipprinted, + locations.loccode, + locations.locationname + FROM salesorders INNER JOIN salesorderdetails on salesorderdetails.orderno=salesorders.orderno, + debtorsmaster, + shippers, + locations INNER JOIN locationusers ON locationusers.loccode=locations.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canupd=1 + WHERE salesorders.debtorno=debtorsmaster.debtorno + AND salesorders.shipvia=shippers.shipper_id + AND salesorders.fromstkloc=locations.loccode + AND salesorders.fromstkloc='" . $_POST['loccode'] . "' + AND salesorders.deliverydate<='" . FormatDateForSQL($_POST['TransDate']) . "' + AND salesorderdetails.completed=0 + GROUP BY salesorders.orderno + ORDER BY salesorders.deliverydate, salesorders.orderno"; +} + +if ($_SESSION['SalesmanLogin'] != '') { + $SQL .= " AND salesorders.salesperson='" . $_SESSION['SalesmanLogin'] . "'"; +} + +if (isset($_POST['TransDate']) or (isset($_GET['TransNo']) and $_GET['TransNo'] != 'Preview')) { + $Result = DB_query($SQL, $ErrMsg); + + /*if there are no rows, there's a problem. */ + if (DB_num_rows($Result) == 0) { + $Title = _('Print Picking List Error'); + include('includes/header.php'); + echo '<br />'; + prnMsg(_('Unable to Locate any orders for this criteria '), 'info'); + echo '<br /> + <table class="selection"> + <tr> + <td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">' . _('Enter Another Date') . '</a></td> + </tr> + </table> + <br />'; + include('includes/footer.php'); + exit(); + } + + /*retrieve the order details from the database and place them in an array */ + while ($MyRow = DB_fetch_array($Result)) { + $OrdersToPick[] = $MyRow; + } +} +else { + $OrdersToPick[0]['debtorno'] = str_pad('', 10, 'x'); + $OrdersToPick[0]['orderno'] = 'Preview'; + $OrdersToPick[0]['customerref'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['comments'] = str_pad('', 100, 'x'); + $OrdersToPick[0]['orddate'] = '1900-00-01'; + $OrdersToPick[0]['deliverto'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['deladd1'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['deladd2'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['deladd3'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['deladd4'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['deladd5'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['deladd6'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['deliverblind'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['deliverydate'] = '1900-00-01'; + $OrdersToPick[0]['name'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['address1'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['address2'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['address3'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['address4'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['address5'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['address6'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['shippername'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['printedpackingslip'] = str_pad('', 20, 'x'); + $OrdersToPick[0]['datepackingslipprinted'] = '1900-00-01'; + $OrdersToPick[0]['locationname'] = str_pad('', 15, 'x'); +} +/* Then there's an order to print and its not been printed already (or its been flagged for reprinting/ge_Width=807;) +LETS GO */ + +if ($OrdersToPick[0]['orderno'] == 'Preview') { + $FormDesign = simplexml_load_file(sys_get_temp_dir() . '/PickingList.xml'); +} else { + $FormDesign = simplexml_load_file($PathPrefix . 'companies/' . $_SESSION['DatabaseName'] . '/FormDesigns/PickingList.xml'); +} + +$PaperSize = $FormDesign->PaperSize; +include('includes/PDFStarter.php'); +$pdf->addInfo('Title', _('Picking List')); +$pdf->addInfo('Subject', _('Laser Picking List')); +$FontSize = 12; +$ListCount = 0; +$Copy = ''; + +$line_height = $FormDesign->LineHeight; +$TotalOrderCount = sizeof($OrdersToPick); + +for ( $i = 0; $i < $TotalOrderCount; $i++ ){ + /*Cycle through each of the orders to pick */ + if ($i > 0) { + $pdf->newPage(); + } + + /* Now ... Has the order got any line items still outstanding to be picked */ + + $PageNumber = 1; + + if (isset($_POST['TransDate']) or (isset($_GET['TransNo']) and $_GET['TransNo'] != 'Preview')) { + $ErrMsg = _('There was a problem retrieving the order line details for Order Number') . ' ' . $OrdersToPick[$i]['orderno'] . ' ' . _('from the database'); + + /* Are there any picking lists for this order already */ + $SQL = "SELECT COUNT(orderno), + prid, + comments + FROM pickreq + WHERE orderno='" . $OrdersToPick[$i]['orderno'] . "' + AND closed='0'"; + + $CountResult = DB_query($SQL); + $Count = DB_fetch_row($CountResult); + + if (!isset($Count[2]) or $Count[2] == '') { /* No comment was found in the query */ + $Count[2]='Please pick order. Generate packing slip. Apply shipment labels and ship in system.'; + } + + if ($Count[0] == 0) { + $SQL = "SELECT salesorderdetails.stkcode, + stockmaster.description, + stockmaster.controlled, + stockmaster.serialised, + salesorderdetails.orderlineno, + (salesorderdetails.quantity - salesorderdetails.qtyinvoiced) as qtyexpected, + salesorderdetails.quantity, + salesorderdetails.qtyinvoiced, + salesorderdetails.narrative, + stockmaster.decimalplaces, + custitem.cust_part, + custitem.cust_description, + locstock.quantity qtyavail, + bin + FROM salesorderdetails + INNER JOIN locstock + ON locstock.loccode='" . $OrdersToPick[$i]['loccode'] . "' + AND locstock.stockid=salesorderdetails.stkcode + INNER JOIN stockmaster + ON salesorderdetails.stkcode=stockmaster.stockid + LEFT OUTER JOIN custitem + ON custitem.debtorno='" . $OrdersToPick[$i]['debtorno'] . "' + AND custitem.stockid=stockmaster.stockid + WHERE salesorderdetails.orderno='" . $OrdersToPick[$i]['orderno'] . "' + AND salesorderdetails.completed=0"; + } else { + $SQL = "SELECT salesorderdetails.stkcode, + stockmaster.description, + stockmaster.controlled, + stockmaster.serialised, + salesorderdetails.orderlineno, + (salesorderdetails.quantity - salesorderdetails.qtyinvoiced) as qtyexpected, + salesorderdetails.quantity, + salesorderdetails.qtyinvoiced, + pickreqdetails.qtypicked, + pickreqdetails.shipqty, + salesorderdetails.narrative, + stockmaster.decimalplaces, + custitem.cust_part, + custitem.cust_description, + locstock.quantity qtyavail, + bin + FROM salesorderdetails + INNER JOIN locstock + ON locstock.loccode='" . $OrdersToPick[$i]['loccode'] . "' + AND locstock.stockid=salesorderdetails.stkcode + INNER JOIN stockmaster + ON salesorderdetails.stkcode=stockmaster.stockid + LEFT OUTER JOIN pickreq + ON pickreq.orderno=salesorderdetails.orderno + AND pickreq.closed=0 + LEFT OUTER JOIN pickreqdetails + ON pickreqdetails.stockid=salesorderdetails.stkcode + AND pickreqdetails.orderlineno=salesorderdetails.orderlineno + AND pickreqdetails.prid=pickreq.prid + LEFT OUTER JOIN custitem + ON custitem.debtorno='" . $OrdersToPick[$i]['debtorno'] . "' + AND custitem.stockid=stockmaster.stockid + WHERE salesorderdetails.orderno='" . $OrdersToPick[$i]['orderno'] . "' + AND salesorderdetails.completed=0"; + } + $LineResult = DB_query($SQL, $ErrMsg); + } + if ((isset($_GET['TransNo']) and $_GET['TransNo'] == 'Preview') or (isset($LineResult) and DB_num_rows($LineResult) > 0)) { + /*Yes there are line items to start the ball rolling with a page header */ + DB_Txn_Begin(); + + if (isset($_POST['TransDate']) or (isset($_GET['TransNo']) and $_GET['TransNo'] != 'Preview')) { + $LinesToShow = DB_num_rows($LineResult); + if ($Count[0] == 0) { + /*create picklist we have open lines and no pickreq yet*/ + + $SQL = "INSERT INTO pickreq + (prid, + initiator, + initdate, + requestdate, + status, + comments, + loccode, + orderno) + VALUES ( + 'NULL', + '" . $_SESSION['UserID'] . "', + '" . date('Y-m-d') . "', + '" . $OrdersToPick[$i]['deliverydate'] . "', + 'New', + 'Please pick order. Generate packing slip. Apply shipment labels and ship in system. Return all Paperwork to Mem...@re...', + '" . $OrdersToPick[$i]['loccode'] . "', + '" . $OrdersToPick[$i]['orderno'] . "');"; + $HeaderResult = DB_query($SQL); + $PickReqID = DB_Last_Insert_ID('pickreq', 'prid'); + $Count[1]=$PickReqID; + } //create pickreq + } + else { + $LinesToShow = 1; + } + + include('includes/GenPickingListHeader.inc'); + $YPos = $FormDesign->Data->y; + $Lines = 0; + + while ($Lines < $LinesToShow) { + if (isset($_GET['TransNo']) and $_GET['TransNo'] == 'Preview') { + $MyRow2['stkcode'] = str_pad('', 10, 'x'); + $MyRow2['decimalplaces'] = 2; + $DisplayQty = 'XXXX.XX'; + $DisplayPrevDel = 'XXXX.XX'; + $DisplayQtySupplied = 'XXXX.XX'; + $MyRow2['description'] = str_pad('', 18, 'x'); + $MyRow2['narrative'] = str_pad('', 18, 'x'); + } + else { + $MyRow2 = DB_fetch_array($LineResult); + + if ($Count[0] == 0) { + $SQL = "INSERT INTO pickreqdetails + (detailno, + prid, + orderlineno, + stockid, + qtyexpected) + VALUES ( + 'NULL', + '" . $PickReqID . "', + '" . $MyRow2['orderlineno'] . "', + '" . $MyRow2['stkcode'] . "', + '" . $MyRow2['qtyexpected'] . "');"; + + $InsLineResult = DB_query($SQL); + $MyRow2['qtyexpected'] = 0; + $MyRow2['qtypicked'] = 0; + } //create pickreqdetail + + $DisplayQty = locale_number_format($MyRow2['quantity'], $MyRow2['decimalplaces']); + $DisplayQtySupplied = locale_number_format($MyRow2['quantity'] - $MyRow2['qtyinvoiced'], $MyRow2['decimalplaces']); + $DisplayPrevDel = locale_number_format($MyRow2['qtyinvoiced'], $MyRow2['decimalplaces']); + $DisplayQtyAvail = locale_number_format($MyRow2['qtyavail'], $MyRow2['decimalplaces']); + + if ($MyRow2['qtypicked'] > 0) { + $DisplayPicked = locale_number_format($MyRow2['qtypicked'], $MyRow2['decimalplaces']); + } else { + $DisplayPicked = '____________'; + } + } + ++$ListCount; + + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column1->x, $Page_Height - $YPos, $FormDesign->Headings->Column1->Length, $FormDesign->Headings->Column1->FontSize, $MyRow2['stkcode'], 'left'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column2->x, $Page_Height - $YPos, $FormDesign->Headings->Column2->Length, $FormDesign->Headings->Column2->FontSize, $MyRow2['description']); + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column3->x, $Page_Height - $YPos, $FormDesign->Headings->Column3->Length, $FormDesign->Headings->Column3->FontSize, $MyRow2['bin'], 'right'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column4->x, $Page_Height - $YPos, $FormDesign->Headings->Column4->Length, $FormDesign->Headings->Column4->FontSize, $DisplayQtySupplied, 'right'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column5->x, $Page_Height - $YPos, $FormDesign->Headings->Column5->Length, $FormDesign->Headings->Column5->FontSize, $DisplayQtyAvail, 'right'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column6->x, $Page_Height - $YPos, $FormDesign->Headings->Column6->Length, $FormDesign->Headings->Column6->FontSize, $DisplayPicked, 'right'); + + if ($Page_Height - $YPos - $line_height <= 60) { + /* We reached the end of the page so finish off the page and start a new */ + $PageNumber++; + include ('includes/GenPickingListHeader.inc'); + } //end if need a new page headed up + else { + /*increment a line down for the next line item */ + $YPos += ($line_height); + } + + if ($MyRow2['cust_part'] > '') { + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column2->x, $Page_Height - $YPos, $FormDesign->Headings->Column2->Length, $FormDesign->Headings->Column2->FontSize, $MyRow2['cust_part'] . ' ' . $MyRow2['cust_description']); + + if ($Page_Height - $YPos - $line_height <= 60) { + /* We reached the end of the page so finish off the page and start a new */ + $PageNumber++; + include ('includes/GenPickingListHeader.inc'); + } //end if need a new page headed up + else { + /*increment a line down for the next line item */ + $YPos += ($line_height); + } + } + + if ($MyRow2['narrative'] > '') { + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column2->x, $Page_Height - $YPos, $FormDesign->Headings->Column2->Length, $FormDesign->Headings->Column2->FontSize, $MyRow2['narrative']); + if ($Page_Height - $YPos - $line_height <= 60) { + /* We reached the end of the page so finish off the page and start a new */ + $PageNumber++; + include ('includes/GenPickingListHeader.inc'); + } //end if need a new page headed up + else { + /*increment a line down for the next line item */ + $YPos += ($line_height); + } + } + + if ($MyRow2['controlled'] == 1) { + if ($MyRow2['serialised'] == 1) { + $BundleLabel = _('Serial#:'); + } + else { + $BundleLabel = _('Lot#:'); + } + $SQL = "SELECT serialno, + quantity, + (SELECT SUM(moveqty) + FROM pickserialdetails + INNER JOIN pickreqdetails on pickreqdetails.detailno=pickserialdetails.detailno + INNER JOIN pickreq on pickreq.prid=pickreqdetails.prid + AND pickreq.closed=0 + WHERE pickserialdetails.serialno=stockserialitems.serialno + AND pickserialdetails.stockid=stockserialitems.stockid) as qtypickedtotal, + (SELECT SUM(moveqty) + FROM pickserialdetails + INNER JOIN pickreqdetails on pickreqdetails.detailno=pickserialdetails.detailno + INNER JOIN pickreq on pickreq.prid=pickreqdetails.prid + AND pickreq.orderno='" . $OrdersToPick[$i]['orderno'] . "' + AND pickreq.closed=0 + WHERE pickserialdetails.serialno=stockserialitems.serialno + AND pickserialdetails.stockid=stockserialitems.stockid) as qtypickedthisorder + FROM stockserialitems + WHERE stockid='" . $MyRow2['stkcode'] . "' + AND stockserialitems.loccode ='" . $OrdersToPick[$i]['loccode'] . "' + AND quantity > 0 + ORDER BY createdate, quantity"; + + $ErrMsg = '<br />' . _('Could not retrieve the items for') . ' ' . $MyRow2['stkcode']; + $Bundles = DB_query($SQL, $ErrMsg); + $YPos += ($line_height); + + while ($mybundles = DB_fetch_array($Bundles)) { + if ($mybundles['qtypickedthisorder'] == 0 or is_null($mybundles['qtypickedthisorder'])) { + $mybundles['qtypickedthisorder'] = '____________'; + } + + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column3->x, $Page_Height - $YPos, $FormDesign->Headings->Column3->Length, $FormDesign->Headings->Column3->FontSize, $BundleLabel, 'right'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column4->x, $Page_Height - $YPos, $FormDesign->Headings->Column4->Length, $FormDesign->Headings->Column4->FontSize, $mybundles['serialno'], 'left'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column5->x, $Page_Height - $YPos, $FormDesign->Headings->Column5->Length, $FormDesign->Headings->Column5->FontSize, $mybundles['quantity'] - $mybundles['qtypickedtotal'], 'right'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column6->x, $Page_Height - $YPos, $FormDesign->Headings->Column6->Length, $FormDesign->Headings->Column6->FontSize, $mybundles['qtypickedthisorder'], 'right'); + + if ($Page_Height - $YPos - $line_height <= 60) { + /* We reached the end of the page so finish off the page and start a new */ + $PageNumber++; + include ('includes/GenPickingListHeader.inc'); + } //end if need a new page headed up + else { + /*increment a line down for the next line item */ + $YPos += ($line_height); + } + } //while + } //controlled + + ++$Lines; + $YPos += ($line_height); + } //end while there are line items to print out + + $YPos = $Page_Height - 45; + $pdf->setFont('', 'B'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column2->x, $Page_Height - $YPos, $FormDesign->Headings->Column2->Length, $FormDesign->Headings->Column2->FontSize, _('Signed for: ') . '______________________________'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column3->x, $Page_Height - $YPos, $FormDesign->Headings->Column3->Length, $FormDesign->Headings->Column3->FontSize, _('Date : ') . '__________'); + $pdf->setFont('', ''); + } /*end if there are order details to show on the order*/ +} /*end for loop to print the whole lot twice */ + +if ($ListCount == 0) { + $Title = _('Print Picking List Error'); + include('includes/header.php'); + prnMsg( _('There are no picking lists to print'), 'error'); + include('includes/footer.php'); + exit; +} else { + $pdf->OutputD($_SESSION['DatabaseName'] . '_PickingLists_' . date('Y-m-d') . '.pdf'); + $pdf->__destruct(); + DB_Txn_Commit(); +} +?> \ No newline at end of file Added: trunk/PDFAck.php =================================================================== --- trunk/PDFAck.php (rev 0) +++ trunk/PDFAck.php 2018-01-26 23:55:55 UTC (rev 7924) @@ -0,0 +1,283 @@ +<?php + +/* $Id: PDFAcknowledgementPortrait.php 4491 2011-02-15 06:31:08Z daintree $ */ + +include('includes/session.php'); +include('includes/SQL_CommonFunctions.inc'); + +//Get Out if we have no order number to work with +If (!isset($_GET['AcknowledgementNo']) || $_GET['AcknowledgementNo'] == "") { + $Title = _('Select Acknowledgement To Print'); + include('includes/header.php'); + prnMsg(_('Select a Acknowledgement to Print before calling this page'), 'error'); + echo '<table class="table_index"> + <tr> + <td class="menu_group_item"> + <ul><li><a href="' . $RootPath . '/SelectSalesOrder.php?Acknowledgements=Quotes_Only">' . _('Acknowledgements') . '</a></li> + </ul> + </td> + </tr> + </table>'; + include('includes/footer.php'); + exit(); +} + +/*retrieve the order details from the database to print */ +$ErrMsg = _('There was a problem retrieving the Acknowledgement header details for Order Number') . ' ' . $_GET['AcknowledgementNo'] . ' ' . _('from the database'); + +$SQL = "SELECT salesorders.customerref, + salesorders.comments, + salesorders.orddate, + salesorders.deliverto, + salesorders.deladd1, + salesorders.deladd2, + salesorders.deladd3, + salesorders.deladd4, + salesorders.deladd5, + salesorders.deladd6, + salesorders.freightcost, + debtorsmaster.debtorno, + debtorsmaster.name, + debtorsmaster.currcode, + debtorsmaster.address1, + debtorsmaster.address2, + debtorsmaster.address3, + debtorsmaster.address4, + debtorsmaster.address5, + debtorsmaster.address6, + shippers.shippername, + salesorders.printedpackingslip, + salesorders.datepackingslipprinted, + salesorders.branchcode, + locations.taxprovinceid, + locations.locationname, + currencies.decimalplaces AS currdecimalplaces + FROM salesorders + INNER JOIN debtorsmaster + ON salesorders.debtorno=debtorsmaster.debtorno + INNER JOIN shippers + ON salesorders.shipvia=shippers.shipper_id + INNER JOIN locations + ON salesorders.fromstkloc=locations.loccode + INNER JOIN currencies + ON debtorsmaster.currcode=currencies.currabrev + AND salesorders.orderno='" . $_GET['AcknowledgementNo'] . "'"; + +$Result = DB_query($SQL, $ErrMsg); + +//If there are no rows, there's a problem. +if (DB_num_rows($Result) == 0) { + $Title = _('Print Acknowledgement Error'); + include('includes/header.php'); + prnMsg(_('Unable to Locate Acknowledgement Number') . ' : ' . $_GET['AcknowledgementNo'] . ' ', 'error'); + echo '<table class="table_index"> + <tr> + <td class="menu_group_item"> + <ul><li><a href="' . $RootPath . '/SelectSalesOrder.php?Acknowledgements=Quotes_Only">' . _('Outstanding Acknowledgements') . '</a></li></ul> + </td> + </tr> + </table>'; + include('includes/footer.php'); + exit; +} elseif (DB_num_rows($Result) == 1) { + /*There is only one order header returned - thats good! */ + $MyRow = DB_fetch_array($Result); +} + +/*retrieve the order details from the database to print */ + +/* Then there's an order to print and its not been printed already (or its been flagged for reprinting/ge_Width=807; +) +LETS GO */ +$Terms = $_SESSION['TermsAndConditions']; + +$PaperSize = 'Letter'; + +include('includes/PDFStarter.php'); +$pdf->addInfo('Title', _('Customer Acknowledgement')); +$pdf->addInfo('Subject', _('Acknowledgement') . ' ' . $_GET['AcknowledgementNo']); +$FontSize = 12; +$PageNumber = 1; +$line_height = $FontSize * 1.25; + +/* Now ... Has the order got any line items still outstanding to be invoiced */ + +$ErrMsg = _('There was a problem retrieving the Acknowledgement line details for Acknowledgement Number') . ' ' . $_GET['AcknowledgementNo'] . ' ' . _('from the database'); + +$SQL = "SELECT salesorderdetails.stkcode, + stockmaster.description, + salesorderdetails.quantity, + salesorderdetails.qtyinvoiced, + salesorderdetails.unitprice, + salesorderdetails.itemdue, + salesorderdetails.narrative, + stockmaster.taxcatid, + salesorderdetails.narrative, + stockmaster.decimalplaces, + custitem.cust_part, + custitem.cust_description + FROM salesorderdetails + INNER JOIN stockmaster + ON salesorderdetails.stkcode=stockmaster.stockid + LEFT OUTER JOIN custitem + ON custitem.debtorno='" . $MyRow['debtorno'] . "' + AND custitem.stockid=stockmaster.stockid + WHERE salesorderdetails.orderno='" . $_GET['AcknowledgementNo'] . "'"; + +$Result = DB_query($SQL, $ErrMsg); + +$ListCount = 0; + +if (DB_num_rows($Result) > 0) { + /*Yes there are line items to start the ball rolling with a page header */ + include('includes/PDFAckPageHeader.php'); + + $AcknowledgementTotal = $MyRow['freightcost']; + $AcknowledgementTotalEx = 0; + $TaxTotal = 0; + + while ($MyRow2 = DB_fetch_array($Result)) { + + $ListCount++; + + if ((mb_strlen($MyRow2['narrative']) > 200 AND $YPos - $line_height <= 75) OR (mb_strlen($MyRow2['narrative']) > 1 AND $YPos - $line_height <= 62) OR $YPos - $line_height <= 50) { + /* We reached the end of the page so finsih off the page and start a newy */ + $PageNumber++; + include('includes/PDFAckPageHeader.php'); + + } //end if need a new page headed up + + $DisplayQty = locale_number_format($MyRow2['quantity'], $MyRow2['decimalplaces']); + $DisplayPrevDel = locale_number_format($MyRow2['qtyinvoiced'], $MyRow2['decimalplaces']); + //$DisplayPrice = locale_number_format($MyRow2['unitprice'],$MyRow['currdecimalplaces']); + $DisplayPrice = locale_number_format($MyRow2['unitprice'], 4); + $SubTot = $MyRow2['unitprice'] * $MyRow2['quantity'] * (1 - $MyRow2['discountpercent']); + $TaxProv = $MyRow['taxprovinceid']; + $TaxCat = $MyRow2['taxcatid']; + $Branch = $MyRow['branchcode']; + $SQL3 = " SELECT taxgrouptaxes.taxauthid + FROM taxgrouptaxes + INNER JOIN custbranch + ON taxgrouptaxes.taxgroupid=custbranch.taxgroupid + WHERE custbranch.branchcode='" . $Branch . "'"; + $Result3 = DB_query($SQL3, $ErrMsg); + while ($MyRow3 = DB_fetch_array($Result3)) { + $TaxAuth = $MyRow3['taxauthid']; + } + + $SQL4 = "SELECT taxrate + FROM taxauthrates + WHERE dispatchtaxprovince='" . $TaxProv . "' + AND taxcatid='" . $TaxCat . "' + AND taxauthority='" . $TaxAuth . "'"; + $Result4 = DB_query($SQL4, $ErrMsg); + while ($MyRow4 = DB_fetch_array($Result4)) { + $TaxClass = 100 * $MyRow4['taxrate']; + } + + $DisplayTaxClass = $TaxClass . "%"; + $TaxAmount = (($SubTot / 100) * (100 + $TaxClass)) - $SubTot; + $DisplayTaxAmount = locale_number_format($TaxAmount, $MyRow['currdecimalplaces']); + + $LineTotal = $SubTot + $TaxAmount; + $DisplayTotal = locale_number_format($LineTotal, $MyRow['currdecimalplaces']); + + $FontSize = 10; + + $LeftOvers = $pdf->addTextWrap($XPos + 1, $YPos, 100, $FontSize, $MyRow2['stkcode']); + $LeftOvers = $pdf->addTextWrap(120, $YPos, 295, $FontSize, $MyRow2['description']); + $LeftOvers = $pdf->addTextWrap(270, $YPos, 85, $FontSize, ConvertSQLDate($MyRow2['itemdue']), right); + $LeftOvers = $pdf->addTextWrap(350, $YPos, 85, $FontSize, $DisplayQty, 'right'); + $LeftOvers = $pdf->addTextWrap(400, $YPos, 85, $FontSize, $DisplayPrice, 'right'); + $LeftOvers = $pdf->addTextWrap($Page_Width - $Right_Margin - 90, $YPos, 90, $FontSize, $DisplayTotal, 'right'); + + if ($MyRow2['cust_part'] > '') { + $YPos -= $line_height; + $LeftOvers = $pdf->addTextWrap($XPos + 10, $YPos, 300, $FontSize, _('Customer Part') . ': ' . $MyRow2['cust_part'] . ' ' . $MyRow2['cust_description']); + //$LeftOvers = $pdf->addTextWrap(190,$YPos,186,$FontSize,$MyRow2['cust_description']); + } + + // Prints salesorderdetails.narrative + $Split = explode("\r\n", wordwrap($MyRow2['narrative'], 130, "\r\n")); + foreach ($Split as $TextLine) { + $YPos -= $line_height; // rchacon's suggestion: $YPos -= $FontSize; + if ($YPos < ($Bottom_Margin + $line_height)) { // Begins new page + $PageNumber++; + include('includes/PDFAckPageHeader.php'); + } + $LeftOvers = $pdf->addTextWrap($XPos + 1, $YPos, 750, 10, $TextLine); + } + $YPos -= $line_height; + + $AcknowledgementTotal += $LineTotal; + $AcknowledgementTotalEx += $SubTot; + $TaxTotal += $TaxAmount; + + /*increment a line down for the next line item */ + $YPos -= ($line_height); + + } //end while there are line items to print out + if ((mb_strlen($MyRow['comments']) > 200 AND $YPos - $line_height <= 75) OR (mb_strlen($MyRow['comments']) > 1 AND $YPos - $line_height <= 62) OR $YPos - $line_height <= 50) { + /* We reached the end of the page so finsih off the page and start a newy */ + $PageNumber++; + include('includes/PDFAckPageHeader.php'); + } //end if need a new page headed up + + $LeftOvers = $pdf->addTextWrap($XPos, $YPos - 80, 30, 10, _('Notes:')); + $LeftOvers = $pdf->addText($XPos, $YPos - 95, 10, $MyRow['comments']); + + if (mb_strlen($LeftOvers) > 1) { + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos, $YPos, 700, 10, $LeftOvers); + if (mb_strlen($LeftOve... [truncated message content] |