From 889896d2b3147fada30c71f42bb6203cf6556f66 Mon Sep 17 00:00:00 2001 From: Paul Thursby Date: Mon, 26 Feb 2018 17:45:45 +0000 Subject: [PATCH] MRPPlannedPurchasekOrders.php, MRPPlannedWorkOrders.php: PaulT: Add missing table cell to work orders to match recent change to planned purchase orders and replace 'where clause joins' with table join in both files. Paul B/PaulT: Apply consistent code formatting between both files. (Some consistency matters reported in forums: http://www.weberp.org/forum/showthread.php?tid=8061) --- MRPPlannedPurchaseOrders.php | 57 +++++++++---------- MRPPlannedWorkOrders.php | 107 ++++++++++++++++++++--------------- doc/Change.log | 13 +++-- 3 files changed, 96 insertions(+), 81 deletions(-) diff --git a/MRPPlannedPurchaseOrders.php b/MRPPlannedPurchaseOrders.php index 7cea737a4..06127aff7 100644 --- a/MRPPlannedPurchaseOrders.php +++ b/MRPPlannedPurchaseOrders.php @@ -5,19 +5,19 @@ include('includes/session.php'); -//Maybe not ANSI SQL?? $sql = "SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA = '" . $_SESSION['DatabaseName'] . "' AND TABLE_NAME = 'mrprequirements'"; - $result=DB_query($sql); + if (DB_num_rows($result)==0) { $Title=_('MRP error'); include('includes/header.php'); echo '
'; prnMsg( _('The MRP calculation must be run before you can run this report') . '
' . - _('To run the MRP calculation click').' ' . '' . _('here') . '', 'error'); + _('To run the MRP calculation click') . ' ' . '' . _('here') . '', 'error'); include('includes/footer.php'); exit; } + if ( isset($_POST['PrintPDF']) OR isset($_POST['Review']) ) { $WhereDate = ' '; @@ -25,8 +25,9 @@ if (Is_Date($_POST['cutoffdate'])) { $FormatDate = FormatDateForSQL($_POST['cutoffdate']); $WhereDate = " AND duedate <= '" . $FormatDate . "' "; - $ReportDate = _(' Through ') . Format_Date($_POST['cutoffdate']); + $ReportDate = ' ' . _('Through') . ' ' . $_POST['cutoffdate']; } + if ($_POST['Consolidation'] == 'None') { $sql = "SELECT mrpplannedorders.*, stockmaster.stockid, @@ -34,11 +35,11 @@ stockmaster.mbflag, stockmaster.decimalplaces, stockmaster.actualcost, - (stockmaster.materialcost + stockmaster.labourcost + - stockmaster.overheadcost ) as computedcost - FROM mrpplannedorders, stockmaster - WHERE mrpplannedorders.part = stockmaster.stockid " . $WhereDate . " - AND stockmaster.mbflag IN ('B','P') + (stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost ) as computedcost + FROM mrpplannedorders + INNER JOIN stockmaster + ON mrpplannedorders.part = stockmaster.stockid + WHERE stockmaster.mbflag IN ('B','P') " . $WhereDate . " ORDER BY mrpplannedorders.part,mrpplannedorders.duedate"; } elseif ($_POST['Consolidation'] == 'Weekly') { $sql = "SELECT mrpplannedorders.part, @@ -52,11 +53,11 @@ stockmaster.mbflag, stockmaster.decimalplaces, stockmaster.actualcost, - (stockmaster.materialcost + stockmaster.labourcost + - stockmaster.overheadcost ) as computedcost - FROM mrpplannedorders, stockmaster - WHERE mrpplannedorders.part = stockmaster.stockid " . $WhereDate . " - AND stockmaster.mbflag IN ('B','P') + (stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost ) as computedcost + FROM mrpplannedorders + INNER JOIN stockmaster + ON mrpplannedorders.part = stockmaster.stockid + WHERE stockmaster.mbflag IN ('B','P') " . $WhereDate . " GROUP BY mrpplannedorders.part, weekindex, stockmaster.stockid, @@ -81,11 +82,11 @@ stockmaster.mbflag, stockmaster.decimalplaces, stockmaster.actualcost, - (stockmaster.materialcost + stockmaster.labourcost + - stockmaster.overheadcost ) as computedcost - FROM mrpplannedorders, stockmaster - WHERE mrpplannedorders.part = stockmaster.stockid " . $WhereDate . " - AND stockmaster.mbflag IN ('B','P') + (stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost ) as computedcost + FROM mrpplannedorders + INNER JOIN stockmaster + ON mrpplannedorders.part = stockmaster.stockid + WHERE stockmaster.mbflag IN ('B','P') " . $WhereDate . " GROUP BY mrpplannedorders.part, yearmonth, stockmaster.stockid, @@ -97,7 +98,7 @@ stockmaster.labourcost, stockmaster.overheadcost, computedcost - ORDER BY mrpplannedorders.part,yearmonth "; + ORDER BY mrpplannedorders.part,yearmonth"; } $result = DB_query($sql,'','',false,true); @@ -125,12 +126,13 @@ if (isset($_POST['PrintPDF'])) { // Print planned purchase orders include('includes/PDFStarter.php'); + $pdf->addInfo('Title',_('MRP Planned Purchase Orders Report')); $pdf->addInfo('Subject',_('MRP Planned Purchase Orders')); + $FontSize=9; $PageNumber=1; $line_height=12; - $Xpos = $Left_Margin+1; PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin, @@ -188,16 +190,13 @@ } // Parameters for addTextWrap are defined in /includes/class.pdf.php - // 1) X position 2) Y position 3) Width - // 4) Height 5) Text 6) Alignment 7) Border 8) Fill - True to use SetFillColor - // and False to set to transparent $FormatedSupDueDate = ConvertSQLDate($myrow['duedate']); $FormatedSupMRPDate = ConvertSQLDate($myrow['mrpdate']); $extcost = $myrow['supplyquantity'] * $myrow['computedcost']; $pdf->addTextWrap($Left_Margin,$YPos,110,$FontSize,$myrow['part'],'',0,$fill); $pdf->addTextWrap(150,$YPos,50,$FontSize,$FormatedSupDueDate,'right',0,$fill); $pdf->addTextWrap(200,$YPos,60,$FontSize,$FormatedSupMRPDate,'right',0,$fill); - $pdf->addTextWrap(260,$YPos,50,$FontSize,locale_number_format($myrow['supplyquantity'],$myrow['decimalplaces']),'right',0,$fill); + $pdf->addTextWrap(260,$YPos,50,$FontSize,locale_number_format($myrow['supplyquantity'], $myrow['decimalplaces']),'right',0,$fill); $pdf->addTextWrap(310,$YPos,60,$FontSize,locale_number_format($extcost,$_SESSION['CompanyRecord']['decimalplaces']),'right',0,$fill); if ($_POST['Consolidation'] == 'None'){ @@ -285,7 +284,7 @@ -   + ' . _('Code') . ' ' . _('Description') . ' ' . _('MRP Date') . ' @@ -301,8 +300,8 @@ $Total_ExtCost = 0; $j=1; //row ID $k=0; //row colour counter - while ($myrow = DB_fetch_array($result)){ + while ($myrow = DB_fetch_array($result)){ // Alternate row color if ($k==1){ echo ''; @@ -327,7 +326,7 @@ echo '' . $myrow['consolidatedcount'] . ''; } else { - echo ' '; // Last cell blank when Consolidation is None. + echo ''; // Empty cell when Consolidation is None. } echo ''; @@ -383,7 +382,7 @@ ' . _('Cut Off Date') . ': - + diff --git a/MRPPlannedWorkOrders.php b/MRPPlannedWorkOrders.php index 768ff1b28..2c76d69ca 100755 --- a/MRPPlannedWorkOrders.php +++ b/MRPPlannedWorkOrders.php @@ -7,15 +7,17 @@ $sql = "SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA = '" . $_SESSION['DatabaseName'] . "' AND TABLE_NAME = 'mrprequirements'"; $result=DB_query($sql); + if (DB_num_rows($result)==0) { $Title=_('MRP error'); include('includes/header.php'); echo '
'; prnMsg( _('The MRP calculation must be run before you can run this report') . '
' . - _('To run the MRP calculation click').' ' . '' . _('here') . '', 'error'); + _('To run the MRP calculation click') . ' ' . '' . _('here') . '', 'error'); include('includes/footer.php'); exit; } + if ( isset($_POST['PrintPDF']) OR isset($_POST['Review']) ) { $WhereDate = ' '; @@ -33,11 +35,11 @@ stockmaster.mbflag, stockmaster.decimalplaces, stockmaster.actualcost, - (stockmaster.materialcost + stockmaster.labourcost + - stockmaster.overheadcost ) as computedcost - FROM mrpplannedorders, stockmaster - WHERE mrpplannedorders.part = stockmaster.stockid " . $WhereDate . " - AND stockmaster.mbflag = 'M' + (stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost ) as computedcost + FROM mrpplannedorders + INNER JOIN stockmaster + ON mrpplannedorders.part = stockmaster.stockid + WHERE stockmaster.mbflag = 'M' " . $WhereDate . " ORDER BY mrpplannedorders.part,mrpplannedorders.duedate"; } elseif ($_POST['Consolidation'] == 'Weekly') { $sql = "SELECT mrpplannedorders.part, @@ -51,11 +53,11 @@ stockmaster.mbflag, stockmaster.decimalplaces, stockmaster.actualcost, - (stockmaster.materialcost + stockmaster.labourcost + - stockmaster.overheadcost ) as computedcost - FROM mrpplannedorders, stockmaster - WHERE mrpplannedorders.part = stockmaster.stockid " . $WhereDate . " - AND stockmaster.mbflag = 'M' + (stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost ) as computedcost + FROM mrpplannedorders + INNER JOIN stockmaster + ON mrpplannedorders.part = stockmaster.stockid + WHERE stockmaster.mbflag = 'M' " . $WhereDate . " GROUP BY mrpplannedorders.part, weekindex, stockmaster.stockid, @@ -80,11 +82,11 @@ stockmaster.mbflag, stockmaster.decimalplaces, stockmaster.actualcost, - (stockmaster.materialcost + stockmaster.labourcost + - stockmaster.overheadcost ) as computedcost - FROM mrpplannedorders, stockmaster - WHERE mrpplannedorders.part = stockmaster.stockid " . $WhereDate . " - AND stockmaster.mbflag = 'M' + (stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost ) as computedcost + FROM mrpplannedorders + INNER JOIN stockmaster + ON mrpplannedorders.part = stockmaster.stockid + WHERE stockmaster.mbflag = 'M' " . $WhereDate . " GROUP BY mrpplannedorders.part, yearmonth, stockmaster.stockid, @@ -111,6 +113,7 @@ include('includes/footer.php'); exit; } + if (DB_num_rows($result)==0){ //then there is nothing to print $Title = _('MRP Planned Work Orders'); include('includes/header.php'); @@ -171,9 +174,6 @@ } // Parameters for addTextWrap are defined in /includes/class.pdf.php - // 1) X position 2) Y position 3) Width - // 4) Height 5) Text 6) Alignment 7) Border 8) Fill - True to use SetFillColor - // and False to set to transparent $FormatedSupDueDate = ConvertSQLDate($myrow['duedate']); $FormatedSupMRPDate = ConvertSQLDate($myrow['mrpdate']); $ExtCost = $myrow['supplyquantity'] * $myrow['computedcost']; @@ -204,7 +204,6 @@ if ($YPos < $Bottom_Margin + $line_height){ PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, $Right_Margin,$_POST['Consolidation'],$ReportDate); - // include('includes/MRPPlannedWorkOrdersPageHeader.inc'); } } /*end while loop */ @@ -223,7 +222,6 @@ if ($YPos < $Bottom_Margin + $line_height){ PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, $Right_Margin,$_POST['Consolidation'],$ReportDate); - // include('includes/MRPPlannedWorkOrdersPageHeader.inc'); } /*Print out the grand totals */ @@ -235,6 +233,7 @@ $pdf->OutputD($_SESSION['DatabaseName'] . '_MRP_Planned_Work_Orders_' . Date('Y-m-d') . '.pdf'); $pdf->__destruct(); + } else { // Review planned work orders $Title = _('Review/Convert MRP Planned Work Orders'); @@ -242,13 +241,17 @@ echo '

' . ' ' . $Title . '

'; - echo '
'; - echo '
'; - echo ''; - echo ''; - echo ''; - echo ' + echo ' +
+ +

' . _('Consolidation') . ': ' . $_POST['Consolidation'] . - "    " . _('Cutoff Date') . ': ' . $_POST['cutoffdate'] . '

+ + + + @@ -265,8 +268,8 @@ $Total_ExtCost = 0; $j=1; //row ID $k=0; //row colour counter - while ($myrow = DB_fetch_array($result)){ + while ($myrow = DB_fetch_array($result)){ // Alternate row color if ($k==1){ echo ''; @@ -276,8 +279,8 @@ $k++; } - echo ' - + echo ' + @@ -288,6 +291,9 @@ if ($_POST['Consolidation']!='None') { echo ''; } + else { + echo ''; // Empty cell when Consolidation is None. + } echo ''; $j++; @@ -297,18 +303,17 @@ // Print out the grand totals echo ' - + -
+

' . _('Consolidation') . ': ' . $_POST['Consolidation'] . '    ' + . _('Cutoff Date') . ': ' . $_POST['cutoffdate'] . '

+
' . _('Code') . ' ' . _('Description') . '
' . _('Convert') . '' . '' . $myrow['part'] . '' . '' . _('Convert') . '' . '' . $myrow['part'] . '' . ' ' . $myrow['description'] . ' ' . ConvertSQLDate($myrow['mrpdate']) . ' ' . ConvertSQLDate($myrow['duedate']) . '' . $myrow['consolidatedcount'] . '
' . _('Number of Work Orders') .': ' . ($j-1) . '' . _('Number of Work Orders') .': ' . ($j-1) . ' ' . _('Total Extended Cost') . ': ' . locale_number_format($Total_ExtCost,$_SESSION['CompanyRecord']['decimalplaces']) . '
'; - echo '
+ +
'; echo '
' . _('Back to the menu') . ''; include('includes/footer.php'); - } - + } // end Review planned work orders } else { /*The option to print PDF was not hit so display form */ $Title=_('MRP Planned Work Orders Reporting'); @@ -316,28 +321,35 @@ echo '

' . ' ' . $Title . '

'; - echo '

'; - echo '
'; - echo ''; - echo ''; - echo ' + echo '

+ +
+ +
+ - + + - + + - +
' . _('Consolidation') . ': +
' . _('Print Option') . ': +
' . _('Cut Off Date') . ': + +
@@ -370,6 +382,7 @@ function PrintHeader(&$pdf,&$YPos,&$PageNumber,$Page_Height,$Top_Margin,$Left_Ma $pdf->addTextWrap($Page_Width-$Right_Margin-150,$YPos,160,$FontSize,_('Printed') . ': ' . Date($_SESSION['DefaultDateFormat']) . ' ' . _('Page') . ' ' . $PageNumber,'left'); $YPos -= $line_height; + if ($consolidation == 'None') { $displayconsolidation = _('None'); } elseif ($consolidation == 'Weekly') { @@ -377,6 +390,7 @@ function PrintHeader(&$pdf,&$YPos,&$PageNumber,$Page_Height,$Top_Margin,$Left_Ma } else { $displayconsolidation = _('Monthly'); } + $pdf->addTextWrap($Left_Margin,$YPos,65,$FontSize,_('Consolidation').':'); $pdf->addTextWrap(110,$YPos,40,$FontSize,$displayconsolidation); @@ -390,6 +404,7 @@ function PrintHeader(&$pdf,&$YPos,&$PageNumber,$Page_Height,$Top_Margin,$Left_Ma $pdf->addTextWrap(200,$YPos,60,$FontSize,_('MRP Date'), 'right'); $pdf->addTextWrap(260,$YPos,50,$FontSize,_('Quantity'), 'right'); $pdf->addTextWrap(310,$YPos,60,$FontSize,_('Ext. Cost'), 'right'); + if ($consolidation == 'None') { $pdf->addTextWrap(370,$YPos,80,$FontSize,_('Source Type'), 'right'); $pdf->addTextWrap(450,$YPos,80,$FontSize,_('Source Order'), 'right'); diff --git a/doc/Change.log b/doc/Change.log index ec3cb5dcc..86edecffd 100644 --- a/doc/Change.log +++ b/doc/Change.log @@ -1,11 +1,12 @@ webERP Change Log -2/5/18 PaulT: SalesGraph.php: Rework previous 7908 implementation that caused graphing to break. (Reported broken in forums by Paul Becker: http://www.weberp.org/forum/showthread.php?tid=8071) -2/4/18 PaulT: InternalStockRequestInquiry.php: Restore ONE space to previous 7936 commit. -2/4/18 PaulT: Remove unused $db and $conn parameters from DB_Last_Insert_ID() and (where present) from DB_show_tables(), and DB_show_fields(). Also, remove any unused 'global $db' references across the code base. -2/4/18 Paul Becker (PaulT commit): MRPPlannedPurchaseOrders.php: Add capability to review planned purchase orders and add a new link to convert to a new PO. (Reported in forums: http://www.weberp.org/forum/showthread.php?tid=8061) -2/4/18 Paul Becker (PaulT commit): PrintCustOrder.php, PrintCustOrder_generic.php, PDFOrderPageHeader_generic.inc: Add units, volume, and weight info, date/signature lines, sales order details narrative, plus other minor PDF formatting. (Reported in forums: http://www.weberp.org/forum/showthread.php?tid=8048) -2/4/18 PaulT: Remove unused $db parameter from DB_fetch_array() and DB_Query() functions. Also, rename several DB_Query names to match function definition name: DB_query. +6/2/18 MRPPlannedPurchasekOrders.php, MRPPlannedWorkOrders.php: PaulT: Add missing table cell to work orders to match recent change to planned purchase orders and replace 'where clause joins' with table join in both files. Paul B/PaulT: Apply consistent code formatting between both files. (Some consistency matters reported in forums: http://www.weberp.org/forum/showthread.php?tid=8061) +5/2/18 PaulT: SalesGraph.php: Rework previous 7908 implementation that caused graphing to break. (Reported broken in forums by Paul Becker: http://www.weberp.org/forum/showthread.php?tid=8071) +4/2/18 PaulT: InternalStockRequestInquiry.php: Restore ONE space to previous 7936 commit. +4/2/18 PaulT: Remove unused $db and $conn parameters from DB_Last_Insert_ID() and (where present) from DB_show_tables(), and DB_show_fields(). Also, remove any unused 'global $db' references across the code base. +4/2/18 Paul Becker (PaulT commit): MRPPlannedPurchaseOrders.php: Add capability to review planned purchase orders and add a new link to convert to a new PO. (Reported in forums: http://www.weberp.org/forum/showthread.php?tid=8061) +4/2/18 Paul Becker (PaulT commit): PrintCustOrder.php, PrintCustOrder_generic.php, PDFOrderPageHeader_generic.inc: Add units, volume, and weight info, date/signature lines, sales order details narrative, plus other minor PDF formatting. (Reported in forums: http://www.weberp.org/forum/showthread.php?tid=8048) +4/2/18 PaulT: Remove unused $db parameter from DB_fetch_array() and DB_Query() functions. Also, rename several DB_Query names to match function definition name: DB_query. 2/2/18 PaulT: Dashboard.php: Replace due date handling with existing function. 2/2/18 PaulT: PrintCustTrans.php, PDFTransPageHeader.inc, PrintCustTransPortrait.php, PDFTransPageHeaderPortrait.inc: Add missing stock lot/serial info to landscape output to be consistent with portrait output (reported by HDeriauFF), add Due Date info to invoices (reported by Paul Becker), and (PaulT) add security checks to portrait file, layout improvements, change PDF initialization handling, and more. (A summary of all changes in this commit can be viewed here: http://www.weberp.org/forum/showthread.php?tid=8065&pid=14115#pid14115) 31/1/18 PaulT: Add a 'warning' case to getMsg(), as there is mixed use of 'warn' and 'warning' usage with prnMsg() calls. The 'warning' (before this change) defaults to an 'info' style message.