From: <tu...@us...> - 2018-02-13 04:05:02
|
Revision: 7959 http://sourceforge.net/p/web-erp/reponame/7959 Author: turbopt Date: 2018-02-13 04:04:59 +0000 (Tue, 13 Feb 2018) Log Message: ----------- PaulT: Remove $db parameter from PeriodExists(), CreatePeriod(), CalcFreightCost(), CheckForRecursiveBOM(), DisplayBOMItems() and a few other functions. Modified Paths: -------------- trunk/AccountGroups.php trunk/BOMs.php trunk/ConfirmDispatch_Invoice.php trunk/DeliveryDetails.php trunk/MRP.php trunk/MRPCalendar.php trunk/MRPDemands.php trunk/MRPReport.php trunk/POReport.php trunk/PcAnalysis.php trunk/PcTabExpensesList.php trunk/PriceMatrix.php trunk/Prices_Customer.php trunk/SalesInquiry.php trunk/WOCanBeProducedNow.php trunk/api/api_login.php trunk/api/api_salesorders.php trunk/doc/Change.log trunk/includes/DateFunctions.inc trunk/includes/FreightCalculation.inc trunk/includes/UserLogin.php trunk/includes/session.php Modified: trunk/AccountGroups.php =================================================================== --- trunk/AccountGroups.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/AccountGroups.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -11,7 +11,7 @@ include('includes/SQL_CommonFunctions.inc'); -function CheckForRecursiveGroup($ParentGroupName, $GroupName, $db) { +function CheckForRecursiveGroup($ParentGroupName, $GroupName) { /* returns true ie 1 if the group contains the parent group as a child group ie the parent group results in a recursive group structure otherwise false ie 0 */ @@ -90,7 +90,7 @@ $i++; } if($_POST['ParentGroupName'] !='') { - if(CheckForRecursiveGroup($_POST['GroupName'],$_POST['ParentGroupName'],$db)) { + if(CheckForRecursiveGroup($_POST['GroupName'],$_POST['ParentGroupName'])) { $InputError =1; prnMsg(_('The parent account group selected appears to result in a recursive account structure - select an alternative parent account group or make this group a top level account group'),'error'); $Errors[$i] = 'ParentGroupName'; Modified: trunk/BOMs.php =================================================================== --- trunk/BOMs.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/BOMs.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -49,7 +49,7 @@ } -function CheckForRecursiveBOM ($UltimateParent, $ComponentToCheck, $db) { +function CheckForRecursiveBOM ($UltimateParent, $ComponentToCheck) { /* returns true ie 1 if the BOM contains the parent part as a component ie the BOM is recursive otherwise false ie 0 */ @@ -64,7 +64,7 @@ if ($myrow['component']==$UltimateParent){ return 1; } - if (CheckForRecursiveBOM($UltimateParent, $myrow['component'],$db)){ + if (CheckForRecursiveBOM($UltimateParent, $myrow['component'])){ return 1; } } //(while loop) @@ -74,7 +74,7 @@ } //end of function CheckForRecursiveBOM -function DisplayBOMItems($UltimateParent, $Parent, $Component,$Level, $db) { +function DisplayBOMItems($UltimateParent, $Parent, $Component,$Level) { global $ParentMBflag; $sql = "SELECT bom.sequence, @@ -377,7 +377,7 @@ //need to check not recursive BOM component of itself! - if (!CheckForRecursiveBOM ($SelectedParent, $_POST['Component'], $db)) { + if (!CheckForRecursiveBOM ($SelectedParent, $_POST['Component'])) { /*Now check to see that the component is not already on the BOM */ $sql = "SELECT component @@ -685,7 +685,7 @@ echo '<tr class="striped_row">'; - DisplayBOMItems($UltimateParent, $Parent, $Component, $Level, $db); + DisplayBOMItems($UltimateParent, $Parent, $Component, $Level); } } echo '</table> Modified: trunk/ConfirmDispatch_Invoice.php =================================================================== --- trunk/ConfirmDispatch_Invoice.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/ConfirmDispatch_Invoice.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -514,8 +514,7 @@ $_SESSION['Items'.$identifier]->totalVolume, $_SESSION['Items'.$identifier]->totalWeight, $_SESSION['Items'.$identifier]->Location, - $_SESSION['Items'.$identifier]->DefaultCurrency, - $db); + $_SESSION['Items'.$identifier]->DefaultCurrency); $_SESSION['Items'.$identifier]->ShipVia = $BestShipper; } if (isset($FreightCost) and is_numeric($FreightCost)) { Modified: trunk/DeliveryDetails.php =================================================================== --- trunk/DeliveryDetails.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/DeliveryDetails.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -130,8 +130,7 @@ $_SESSION['Items'.$identifier]->totalVolume, $_SESSION['Items'.$identifier]->totalWeight, $_SESSION['Items'.$identifier]->Location, - $_SESSION['Items'.$identifier]->DefaultCurrency, - $db); + $_SESSION['Items'.$identifier]->DefaultCurrency); if( !empty($BestShipper) ) { $_POST['FreightCost'] = round($_POST['FreightCost'],2); $_POST['ShipVia'] = $BestShipper; Modified: trunk/MRP.php =================================================================== --- trunk/MRP.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/MRP.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -489,7 +489,7 @@ flush(); $result = DB_query($sql); while ($myrow=DB_fetch_array($result)) { - LevelNetting($db,$myrow['part'],$myrow['eoq'],$myrow['pansize'],$myrow['shrinkfactor'], $myrow['leadtime']); + LevelNetting($myrow['part'],$myrow['eoq'],$myrow['pansize'],$myrow['shrinkfactor'], $myrow['leadtime']); } //end of while loop } // end of for echo '<br />' . _('End time') . ': ' . date('h:i:s') . '<br />'; @@ -666,7 +666,7 @@ -function LevelNetting(&$db,$Part,$eoq,$PanSize,$ShrinkFactor,$LeadTime) { +function LevelNetting($Part,$eoq,$PanSize,$ShrinkFactor,$LeadTime) { // Create an array of mrprequirements and an array of mrpsupplies, then read through // them seeing if all requirements are covered by supplies. Create a planned order // for any unmet requirements. Change dates if necessary for the supplies. @@ -860,7 +860,7 @@ $result = DB_query($sql); $myrow = DB_fetch_row($result); if ($myrow[0] > 0) { - CreateLowerLevelRequirement($db,$Requirement['part'],$NewDate, + CreateLowerLevelRequirement($Requirement['part'],$NewDate, $PlannedQty,$Requirement['mrpdemandtype'],$Requirement['orderno'], $Requirement['whererequired']); } @@ -881,8 +881,7 @@ } // End of LevelNetting ------------------------------------------------------- -function CreateLowerLevelRequirement(&$db, - $TopPart, +function CreateLowerLevelRequirement($TopPart, $TopDate, $TopQuantity, $TopMRPDemandType, @@ -930,4 +929,4 @@ } // End of CreateLowerLevelRequirement include('includes/footer.php'); -?> +?> \ No newline at end of file Modified: trunk/MRPCalendar.php =================================================================== --- trunk/MRPCalendar.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/MRPCalendar.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -22,16 +22,16 @@ </p>'; if (isset($_POST['submit'])) { - submit($db,$ChangeDate); + submit($ChangeDate); } elseif (isset($_POST['update'])) { - update($db,$ChangeDate); + update($ChangeDate); } elseif (isset($_POST['ListAll'])) { - ShowDays($db); + ShowDays(); } else { - ShowInputForm($db,$ChangeDate); + ShowInputForm($ChangeDate); } -function submit(&$db,&$ChangeDate) //####SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT#### +function submit(&$ChangeDate) //####SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT#### { //initialize no input errors @@ -70,7 +70,7 @@ } if ($InputError == 1) { - ShowInputForm($db,$ChangeDate); + ShowInputForm($ChangeDate); return; } @@ -135,12 +135,12 @@ $resultupdate = DB_query($sql,$ErrMsg); } prnMsg(_('The MRP Calendar has been created'),'success'); - ShowInputForm($db,$ChangeDate); + ShowInputForm($ChangeDate); } // End of function submit() -function update(&$db,&$ChangeDate) //####UPDATE_UPDATE_UPDATE_UPDATE_UPDATE_UPDATE_UPDATE_#### +function update(&$ChangeDate) //####UPDATE_UPDATE_UPDATE_UPDATE_UPDATE_UPDATE_UPDATE_#### { // Change manufacturing flag for a date. The value "1" means the date is a manufacturing date. // After change the flag, re-calculate the daynumber for all dates. @@ -158,7 +158,7 @@ } if ($InputError == 1) { - ShowInputForm($db,$ChangeDate); + ShowInputForm($ChangeDate); return; } @@ -175,7 +175,7 @@ $resultupdate = DB_query($sql,$ErrMsg); prnMsg(_('The MRP calendar record for') . ' ' . $ChangeDate . ' ' . _('has been updated'),'success'); unset ($ChangeDate); - ShowInputForm($db,$ChangeDate); + ShowInputForm($ChangeDate); // Have to update daynumber any time change a date from or to a manufacturing date // Update daynumber. Set it so non-manufacturing days will have the same daynumber as a valid @@ -197,7 +197,7 @@ } // End of function update() -function ShowDays(&$db) {//####LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_#### +function ShowDays() {//####LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_#### // List all records in date range $FromDate = FormatDateForSQL($_POST['FromDate']); @@ -238,12 +238,12 @@ echo '</table>'; echo '<br /><br />'; unset ($ChangeDate); - ShowInputForm($db,$ChangeDate); + ShowInputForm($ChangeDate); } // End of function ShowDays() -function ShowInputForm(&$db,&$ChangeDate) {//####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### +function ShowInputForm(&$ChangeDate) {//####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### // Display form fields. This function is called the first time // the page is called, and is also invoked at the end of all of the other functions. @@ -323,4 +323,4 @@ } // End of function ShowInputForm() include('includes/footer.php'); -?> +?> \ No newline at end of file Modified: trunk/MRPDemands.php =================================================================== --- trunk/MRPDemands.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/MRPDemands.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -3,9 +3,8 @@ /* $Id$*/ // Add, Edit, Delete, and List MRP demand records. Table is mrpdemands. -// Have separate functions for each routine. Use pass-by-reference - (&$db,&$StockID) - -// to pass values of $db and $StockID to functions. - when just used $db as variable, -// got error: Catchable fatal error: Object of class mysqli could not be converted to string +// Have separate functions for each routine. Use pass-by-reference - (&$StockID) - +// to pass value of $StockID to functions. include('includes/session.php'); $Title = _('MRP Demands'); @@ -27,22 +26,22 @@ _('Inventory') . '" alt="" />' . ' ' . $Title . '</p>'; if (isset($_POST['Search'])) { - search($db,$StockID); + search($StockID); } elseif (isset($_POST['submit'])) { - submit($db,$StockID,$DemandID); + submit($StockID,$DemandID); } elseif (isset($_GET['delete'])) { - delete($db,$DemandID,'',$StockID); + delete($DemandID,'',$StockID); } elseif (isset($_POST['deletesome'])) { - delete($db,'',$_POST['MRPDemandtype'],$StockID); + delete('',$_POST['MRPDemandtype'],$StockID); } elseif (isset($_GET['listall'])) { - listall($db,'',''); + listall('',''); } elseif (isset($_POST['listsome'])) { - listall($db,$StockID,$_POST['MRPDemandtype']); + listall($StockID,$_POST['MRPDemandtype']); } else { - display($db,$StockID,$DemandID); + display($StockID,$DemandID); } -function search(&$db,&$StockID) { //####SEARCH_SEARCH_SEARCH_SEARCH_SEARCH_SEARCH_SEARCH_##### +function search(&$StockID) { //####SEARCH_SEARCH_SEARCH_SEARCH_SEARCH_SEARCH_SEARCH_##### // Search by partial part number or description. Display the part number and description from // the stockmaster so user can select one. If the user clicks on a part number @@ -111,7 +110,7 @@ } else { prnMsg(_('No record found in search'),'error'); unset ($StockID); - display($db,$StockID,$DemandID); + display($StockID,$DemandID); } @@ -118,7 +117,7 @@ } // End of function search() -function submit(&$db,&$StockID,&$DemandID) //####SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT#### +function submit(&$StockID,&$DemandID) //####SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT#### { // In this section if hit submit button. Do edit checks. If all checks pass, see if record already // exists for StockID/Duedate/MRPDemandtype combo; that means do an Update, otherwise, do INSERT. @@ -218,11 +217,11 @@ unset ($DemandID); } // End of else where DB_num_rows showed there was a valid stockmaster record - display($db,$StockID,$DemandID); + display($StockID,$DemandID); } // End of function submit() -function delete(&$db,$DemandID,$DemandType,$StockID) { //####DELETE_DELETE_DELETE_DELETE_DELETE_DELETE_#### +function delete($DemandID,$DemandType,$StockID) { //####DELETE_DELETE_DELETE_DELETE_DELETE_DELETE_#### // If wanted to have a Confirm routine before did actually deletion, could check if // deletion = "yes"; if it did, display link that redirects back to this page @@ -247,12 +246,12 @@ } unset ($DemandID); unset ($StockID); - display($db,$stockID,$DemandID); + display($stockID,$DemandID); } // End of function delete() -function listall(&$db,$part,$DemandType) {//####LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_#### +function listall($part,$DemandType) {//####LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_LISTALL_#### // List all mrpdemands records, with anchors to Edit or Delete records if hit List All anchor // Lists some in hit List Selection submit button, and uses part number if it is entered or @@ -312,12 +311,12 @@ echo '</div>'; echo '</form><br/><br/><br/><br/>'; unset ($StockID); - display($db,$StockID,$DemandID); + display($StockID,$DemandID); } // End of function listall() -function display(&$db,&$StockID,&$DemandID) { //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### +function display(&$StockID,&$DemandID) { //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### // Display Seach fields at top and Entry form below that. This function is called the first time // the page is called, and is also invoked at the end of all of the other functions. Modified: trunk/MRPReport.php =================================================================== --- trunk/MRPReport.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/MRPReport.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -31,7 +31,6 @@ $result = DB_query($sql,'','',False,False); if (DB_error_no() !=0) { $errors = 1; - $holddb = $db; $Title = _('Print MRP Report Error'); include('includes/header.php'); prnMsg(_('The MRP calculation must be run before this report will have any output. MRP requires set up of many parameters, including, EOQ, lead times, minimums, bills of materials, demand types, master schedule etc'),'error'); @@ -42,7 +41,6 @@ if (DB_num_rows($result) == 0) { $errors = 1; - $holddb = $db; $Title = _('Print MRP Report Warning'); include('includes/header.php'); prnMsg(_('The MRP calculation must be run before this report will have any output. MRP requires set up of many parameters, including, EOQ, lead times, minimums, bills of materials, demand types, master schedule, etc'), 'warn'); @@ -82,7 +80,6 @@ $result = DB_query($sql,'','',false,true); if (DB_error_no() !=0) { $errors = 1; - $holddb = $db; } $Supplies = array(); $WeeklySup = array(); @@ -116,7 +113,6 @@ $result = DB_query($sql,'','',false,true); if (DB_error_no() !=0) { $errors = 1; - $holddb = $db; } // Fields for Order Due weekly buckets based on planned orders @@ -145,7 +141,7 @@ if (isset($errors)) { $Title = _('MRP Report') . ' - ' . _('Problem Report'); include('includes/header.php'); - prnMsg( _('The MRP Report could not be retrieved by the SQL because') . ' ' . DB_error_msg($holddb),'error'); + prnMsg( _('The MRP Report could not be retrieved by the SQL because') . ' ' . DB_error_msg(),'error'); echo '<br /><a href="' .$RootPath .'/index.php">' . _('Back to the menu') . '</a>'; if ($debug==1){ echo '<br />' . $sql; Modified: trunk/POReport.php =================================================================== --- trunk/POReport.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/POReport.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -59,20 +59,20 @@ if (isset($_POST['submit'])) { echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/maintenance.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title . '</p>'; - submit($db,$PartNumber,$PartNumberOp,$SupplierId,$SupplierIdOp,$SupplierName,$SupplierNameOp,$SaveSummaryType); + submit($PartNumber,$PartNumberOp,$SupplierId,$SupplierIdOp,$SupplierName,$SupplierNameOp,$SaveSummaryType); } else if (isset($_POST['submitcsv'])) { echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/maintenance.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title . '</p>'; - submitcsv($db,$PartNumber,$PartNumberOp,$SupplierId,$SupplierIdOp,$SupplierName,$SupplierNameOp,$SaveSummaryType); + submitcsv($PartNumber,$PartNumberOp,$SupplierId,$SupplierIdOp,$SupplierName,$SupplierNameOp,$SaveSummaryType); } else { echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/maintenance.png" title="' . _('Search') . '" alt="" />' . $Title . '</p>'; - display($db); + display(); } //####_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT#### -function submit(&$db,$PartNumber,$PartNumberOp,$SupplierId,$SupplierIdOp,$SupplierName,$SupplierNameOp,$SaveSummaryType) { +function submit($PartNumber,$PartNumberOp,$SupplierId,$SupplierIdOp,$SupplierName,$SupplierNameOp,$SaveSummaryType) { global $RootPath; //initialize no input errors @@ -834,8 +834,7 @@ } // End of function submit() //####_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT#### -function submitcsv(&$db, - $PartNumber, +function submitcsv( $PartNumber, $PartNumberOp, $SupplierId, $SupplierIdOp, @@ -1490,7 +1489,7 @@ } // End of function submitcvs() -function display(&$db) //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### +function display() //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### { // Display form fields. This function is called the first time // the page is called. Modified: trunk/PcAnalysis.php =================================================================== --- trunk/PcAnalysis.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/PcAnalysis.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -7,13 +7,13 @@ include('includes/SQL_CommonFunctions.inc'); if (isset($_POST['submit'])) { - submit($db, $_POST['Tabs']); + submit($_POST['Tabs']); } else { - display($db); + display(); } //####_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT#### -function submit(&$db, $TabToShow) { +function submit($TabToShow) { //initialise no input errors $InputError = 0; @@ -194,7 +194,7 @@ } // End of function submit() -function display(&$db) //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### +function display() //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### { // Display form fields. This function is called the first time // the page is called. Modified: trunk/PcTabExpensesList.php =================================================================== --- trunk/PcTabExpensesList.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/PcTabExpensesList.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -7,13 +7,13 @@ include('includes/SQL_CommonFunctions.inc'); if (isset($_POST['submit'])) { - submit($db, $_POST['Tabs'], $_POST['FromDate'], $_POST['ToDate']); + submit($_POST['Tabs'], $_POST['FromDate'], $_POST['ToDate']); } else { - display($db); + display(); } //####_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT#### -function submit(&$db, $TabToShow, $FromDate, $ToDate) { +function submit($TabToShow, $FromDate, $ToDate) { //initialise no input errors $InputError = 0; @@ -56,10 +56,10 @@ WHERE pcashdetails.tabcode = '" . $TabToShow . "' AND pcashdetails.date >= '" . FormatDateForSQL($FromDate) . "' AND pcashdetails.date <= '" . FormatDateForSQL($ToDate) . "' - ORDER BY pcashdetails.date, + ORDER BY pcashdetails.date, pcashdetails.counterindex"; $Result = DB_query($SQL); - + if (DB_num_rows($Result) != 0){ // Create new PHPExcel object @@ -73,9 +73,9 @@ ->setDescription("PC Tab Expenses List") ->setKeywords("") ->setCategory(""); - + // Formatting - + $objPHPExcel->getActiveSheet()->getStyle('A')->getAlignment()->setWrapText(true); $objPHPExcel->getActiveSheet()->getStyle('A')->getNumberFormat()->setFormatCode('dd/mm/yyyy'); $objPHPExcel->getActiveSheet()->getStyle('B5')->getNumberFormat()->setFormatCode('#,##0.00'); @@ -110,7 +110,7 @@ $objPHPExcel->getActiveSheet()->setCellValue('E1', $FromDate); $objPHPExcel->getActiveSheet()->setCellValue('D2', 'To'); $objPHPExcel->getActiveSheet()->setCellValue('E2', $ToDate); - + $objPHPExcel->getActiveSheet()->setCellValue('A10', 'Date'); $objPHPExcel->getActiveSheet()->setCellValue('B10', 'Expense Code'); $objPHPExcel->getActiveSheet()->setCellValue('C10', 'Gross Amount'); @@ -123,11 +123,11 @@ $objPHPExcel->getActiveSheet()->setCellValue('B11', 'Previous Balance'); $objPHPExcel->getActiveSheet()->setCellValue('D11', $MyPreviousBalance['previous']); - + // Add data $i = 12; while ($MyRow = DB_fetch_array($Result)) { - + $SQLDes = "SELECT description FROM pcexpenses WHERE codeexpense = '" . $MyRow['codeexpense'] . "'"; @@ -138,7 +138,7 @@ } else { $ExpenseCodeDes = $MyRow['codeexpense'] . ' - ' . $Description[0]; } - + $TagSQL = "SELECT tagdescription FROM tags WHERE tagref='" . $MyRow['tag'] . "'"; $TagResult = DB_query($TagSQL); $TagRow = DB_fetch_array($TagResult); @@ -147,7 +147,7 @@ } $TagTo = $MyRow['tag']; $TagDescription = $TagTo . ' - ' . $TagRow['tagdescription']; - + $TaxesDescription = ''; $TaxesTaxAmount = ''; $TaxSQL = "SELECT counterindex, @@ -166,7 +166,7 @@ $TaxesDescription .= $MyTaxRow['description']; $TaxesTaxAmount .= locale_number_format($MyTaxRow['amount'], $CurrDecimalPlaces); } - + //Generate download link for expense receipt, or show text if no receipt file is found. $ReceiptSupportedExt = array('png','jpg','jpeg','pdf','doc','docx','xls','xlsx'); //Supported file extensions $ReceiptFileDir = $PathPrefix . 'companies/' . $_SESSION['DatabaseName'] . '/expenses_receipts/' . mb_strtolower($TabToShow); //Receipts upload directory @@ -176,12 +176,12 @@ } else { $ReceiptText = '<a href="' . $ReceiptFilePath . '" download="ExpenseReceipt-' . mb_strtolower($TabToShow) . '-[' . $MyRow['date'] . ']-[' . $MyRow['counterindex'] . ']">' . _('Download attachment') . '</a>'; } - + if ($MyRow['authorized'] == '0000-00-00') { $AuthorisedDate = _('Unauthorised'); } else { $AuthorisedDate = ConvertSQLDate($MyRow['authorized']); - } + } $objPHPExcel->getActiveSheet()->setCellValue('A'.$i, ConvertSQLDate($MyRow['date'])); $objPHPExcel->getActiveSheet()->setCellValue('B'.$i, $ExpenseCodeDes); @@ -198,13 +198,13 @@ // Freeze panes $objPHPExcel->getActiveSheet()->freezePane('A11'); - + // Auto Size columns foreach(range('A','I') as $columnID) { $objPHPExcel->getActiveSheet()->getColumnDimension($columnID) ->setAutoSize(true); } - + // Rename worksheet $objPHPExcel->getActiveSheet()->setTitle($TabToShow); // Set active sheet index to the first sheet, so Excel opens this as the first sheet @@ -237,7 +237,7 @@ } // End of function submit() -function display(&$db) //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### +function display() //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### { // Display form fields. This function is called the first time // the page is called. @@ -270,7 +270,7 @@ <td><select name="Tabs">'; $SQL = "SELECT tabcode - FROM pctabs + FROM pctabs ORDER BY tabcode"; $CatResult = DB_query($SQL); @@ -303,7 +303,7 @@ function beginning_of_month($Date){ $Date2 = explode("-",$Date); - $M = $Date2[1]; + $M = $Date2[1]; $Y = $Date2[0]; $FirstOfMonth = $Y . '-' . $M . '-01'; return $FirstOfMonth; Modified: trunk/PriceMatrix.php =================================================================== --- trunk/PriceMatrix.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/PriceMatrix.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -90,7 +90,7 @@ $ErrMsg = _('Could not be update the existing prices'); $result = DB_query($sql,$ErrMsg); - ReSequenceEffectiveDates ($StockID, $_POST['SalesType'],$_POST['CurrAbrev'],$_POST['QuantityBreak'],$db); + ReSequenceEffectiveDates ($StockID, $_POST['SalesType'],$_POST['CurrAbrev'],$_POST['QuantityBreak']); prnMsg(_('The price has been updated'),'success'); } elseif ($InputError != 1) { @@ -332,7 +332,7 @@ return '9999/12/31'; } } -function ReSequenceEffectiveDates ($Item, $PriceList, $CurrAbbrev, $QuantityBreak,$db) { +function ReSequenceEffectiveDates ($Item, $PriceList, $CurrAbbrev, $QuantityBreak) { /*This is quite complicated - the idea is that prices set up should be unique and there is no way two prices could be returned as valid - when getting a price in includes/GetPrice.inc the logic is to first look for a price of the salestype/currency within the effective start and end dates - then if not get the price with a start date prior but a blank end date (the default price). We would not want two prices where one price falls inside another effective date range except in the case of a blank end date - ie no end date - the default price for the currency/salestype. I first thought that we would need to update the previous default price (blank end date), when a new default price is entered, to have an end date of the startdate of this new default price less 1 day - but this is converting a default price into a special price which could result in having two special prices over the same date range - best to leave it unchanged and use logic in the GetPrice.inc to ensure the correct default price is returned Modified: trunk/Prices_Customer.php =================================================================== --- trunk/Prices_Customer.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/Prices_Customer.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -158,7 +158,7 @@ $msg = _('The price could not be added because') . ' - ' . DB_error_msg(); } }else { - ReSequenceEffectiveDates ($Item, $SalesType, $CurrCode, $_SESSION['CustomerID'], $db); + ReSequenceEffectiveDates ($Item, $SalesType, $CurrCode, $_SESSION['CustomerID']); unset($_POST['EndDate']); unset($_POST['StartDate']); unset($_POST['Price']); @@ -375,7 +375,7 @@ include('includes/footer.php'); exit; -function ReSequenceEffectiveDates ($Item, $PriceList, $CurrAbbrev, $CustomerID, $db) { +function ReSequenceEffectiveDates ($Item, $PriceList, $CurrAbbrev, $CustomerID) { /*This is quite complicated - the idea is that prices set up should be unique and there is no way two prices could be returned as valid - when getting a price in includes/GetPrice.inc the logic is to first look for a price of the salestype/currency within the effective start and end dates - then if not get the price with a start date prior but a blank end date (the default price). We would not want two prices where the effective dates fall between an existing price so it is necessary to update enddates of prices - with me - I am just hanging on here myself Modified: trunk/SalesInquiry.php =================================================================== --- trunk/SalesInquiry.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/SalesInquiry.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -61,13 +61,13 @@ } if(isset($_POST['submit'])) { - submit($db,$PartNumber,$PartNumberOp,$DebtorNo,$DebtorNoOp,$DebtorName,$DebtorNameOp,$SaveSummaryType); + submit($PartNumber,$PartNumberOp,$DebtorNo,$DebtorNoOp,$DebtorName,$DebtorNameOp,$SaveSummaryType); } else { - display($db); + display(); } //####_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT#### -function submit(&$db,$PartNumber,$PartNumberOp,$DebtorNo,$DebtorNoOp,$DebtorName,$DebtorNameOp,$SaveSummaryType) { +function submit($PartNumber,$PartNumberOp,$DebtorNo,$DebtorNoOp,$DebtorName,$DebtorNameOp,$SaveSummaryType) { //initialise no input errors $InputError = 0; @@ -101,7 +101,7 @@ // TempStockmoves function creates a temporary table of stockmoves that is used when the DateType // is Invoice Date if($_POST['DateType'] == 'Invoice') { - TempStockmoves($db); + TempStockmoves(); } # Add more to WHERE statement, if user entered something for the part number,debtorno, name @@ -1050,7 +1050,7 @@ } // End of function submit() -function display(&$db) //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### +function display() //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### { // Display form fields. This function is called the first time // the page is called. @@ -1253,7 +1253,7 @@ } // End of function display() -function TempStockmoves(&$db) { +function TempStockmoves() { // When report based on Invoice Date, use stockmoves as the main file, but credit // notes, which are type 11 in stockmoves, do not have the order number in the // reference field; instead they have "Ex Inv - " and then the transno from the @@ -1289,4 +1289,4 @@ } // End of function TempStockmoves include('includes/footer.php'); -?> +?> \ No newline at end of file Modified: trunk/WOCanBeProducedNow.php =================================================================== --- trunk/WOCanBeProducedNow.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/WOCanBeProducedNow.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -5,16 +5,16 @@ include('includes/header.php'); if (isset($_POST['submit'])) { - submit($db, $RootPath, $_POST['Location']); + submit($RootPath, $_POST['Location']); } else { - display($db); + display(); } //####_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT#### -function submit(&$db, $RootPath, $Location) { +function submit($RootPath, $Location) { $WhereLocation = " AND workorders.loccode = '". $Location ."' "; - + $sql = "SELECT woitems.wo, woitems.stockid, woitems.qtyreqd, @@ -23,17 +23,17 @@ stockmaster.units FROM workorders, woitems, stockmaster WHERE workorders.wo = woitems.wo - AND stockmaster.stockid = woitems.stockid + AND stockmaster.stockid = woitems.stockid AND workorders.closed = 0 AND woitems.qtyreqd > woitems.qtyrecd ". $WhereLocation . "ORDER BY woitems.wo, woitems.stockid" ; - + $ErrMsg = _('The SQL to find the WO items to produce '); $resultItems = DB_query($sql,$ErrMsg); if (DB_num_rows($resultItems) != 0){ - + echo '<p class="page_title_text" align="center"><strong>' . "Items in WO to be produced now in " . $Location . " with available stock" . '</strong></p>'; echo '<div>'; echo '<table class="selection">'; @@ -56,13 +56,13 @@ while ($myItem = DB_fetch_array($resultItems)) { echo $TableHeader; - + $QtyPending = $myItem['qtyreqd'] - $myItem['qtyrecd']; $QtyCanBeProduced = $QtyPending; $WOLink = '<a href="' . $RootPath . '/WorkOrderEntry.php?WO=' . $myItem['wo'] . '">' . $myItem['wo'] . '</a>'; $CodeLink = '<a href="' . $RootPath . '/SelectProduct.php?StockID=' . $myItem['stockid'] . '">' . $myItem['stockid'] . '</a>'; - + printf('<td class="number">%s</td> <td>%s</td> <td class="number">%s</td> @@ -76,13 +76,13 @@ <td>%s</td> <td>%s</td> <td>%s</td> - </tr>', + </tr>', $WOLink, - $CodeLink, + $CodeLink, locale_number_format($myItem['qtyreqd'],$myItem['decimalplaces']), locale_number_format($myItem['qtyrecd'],$myItem['decimalplaces']), locale_number_format($QtyPending,$myItem['decimalplaces']), - $myItem['units'], + $myItem['units'], '', '', '', @@ -107,11 +107,11 @@ AND bom.parent = '" . $myItem['stockid'] . "' AND bom.effectiveafter <= '" . date('Y-m-d') . "' AND bom.effectiveto > '" . date('Y-m-d') . "'"; - + $ErrMsg = _('The bill of material could not be retrieved because'); $BOMResult = DB_query ($sqlBOM,$ErrMsg); $ItemCanBeproduced = TRUE; - + while ($myComponent = DB_fetch_array($BOMResult)) { $ComponentNeeded = $myComponent['bomqty'] * $QtyPending; @@ -125,7 +125,7 @@ } $ComponentLink = '<a href="' . $RootPath . '/SelectProduct.php?StockID=' . $myComponent['component'] . '">' . $myComponent['component'] . '</a>'; - + printf('<td class="number">%s</td> <td>%s</td> <td class="number">%s</td> @@ -139,7 +139,7 @@ <td>%s</td> <td>%s</td> <td>%s</td> - </tr>', + </tr>', '', '', '', @@ -146,11 +146,11 @@ '', '', '', - $ComponentLink, + $ComponentLink, locale_number_format($myComponent['qoh'],$myComponent['decimalplaces']), locale_number_format($ComponentNeeded,$myComponent['decimalplaces']), locale_number_format($PrevisionShrinkage,$myComponent['decimalplaces']), - $myComponent['units'], + $myComponent['units'], $Available, '' ); @@ -174,7 +174,7 @@ <td>%s</td> <td>%s</td> <td>%s</td> - </tr>', + </tr>', '', '', '', @@ -196,11 +196,11 @@ }else{ prnMsg('No items waiting to be produced in ' . $Location); } - + } // End of function submit() -function display(&$db) //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### +function display() //####DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_DISPLAY_##### { // Display form fields. This function is called the first time // the page is called. Modified: trunk/api/api_login.php =================================================================== --- trunk/api/api_login.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/api/api_login.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -25,7 +25,7 @@ } $_SESSION['db'] = $db; // Set in above include } - $rc = userLogin($user, $password, $SysAdminEmail, $_SESSION['db']); + $rc = userLogin($user, $password, $SysAdminEmail); switch ($rc) { case UL_OK: $RetCode[0] = 0; // All is well Modified: trunk/api/api_salesorders.php =================================================================== --- trunk/api/api_salesorders.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/api/api_salesorders.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -1316,7 +1316,7 @@ $FirstPeriod = $myrow[1]; /* If the period number doesn't exist */ - if (!PeriodExists($TransDate, $db)) { + if (!PeriodExists($TransDate)) { /* if the transaction is after the last period */ if ($TransDate > $LastPeriodEnd) { @@ -1329,7 +1329,7 @@ $LastPeriodEnd = mktime(0,0,0,2, 0, Date('Y', $LastPeriodEnd)+1); } $LastPeriod++; - CreatePeriod($LastPeriod, $LastPeriodEnd, $db); + CreatePeriod($LastPeriod, $LastPeriodEnd); } } else { /* The transaction is before the first period */ @@ -1336,7 +1336,7 @@ $PeriodEnd = mktime(0,0,0,Date('m', $TransDate), 0, Date('Y', $TransDate)); $Period = $FirstPeriod - 1; while ($FirstPeriodEnd > $PeriodEnd) { - CreatePeriod($Period, $FirstPeriodEnd, $db); + CreatePeriod($Period, $FirstPeriodEnd); $Period--; if (Date('m', $FirstPeriodEnd)>0) { $FirstPeriodEnd = mktime(0,0,0,Date('m', $FirstPeriodEnd), 0, Date('Y', $FirstPeriodEnd)); @@ -1345,7 +1345,7 @@ } } } - } else if (!PeriodExists(mktime(0,0,0,Date('m',$TransDate)+1,Date('d',$TransDate),Date('Y',$TransDate)), $db)) { + } else if (!PeriodExists(mktime(0,0,0,Date('m',$TransDate)+1,Date('d',$TransDate),Date('Y',$TransDate)))) { /* Make sure the following months period exists */ $sql = "SELECT MAX(lastdate_in_period), MAX(periodno) from periods"; $result = DB_query($sql); @@ -1353,7 +1353,7 @@ $Date_Array = explode('-', $myrow[0]); $LastPeriodEnd = mktime(0,0,0,$Date_Array[1]+2,0,(int)$Date_Array[0]); $LastPeriod = $myrow[1]; - CreatePeriod($LastPeriod+1, $LastPeriodEnd, $db); + CreatePeriod($LastPeriod+1, $LastPeriodEnd); } /* Now return the period number of the transaction */ Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/doc/Change.log 2018-02-13 04:04:59 UTC (rev 7959) @@ -1,5 +1,6 @@ webERP Change Log +12/2/18 PaulT: Remove $db parameter from PeriodExists(), CreatePeriod(), CalcFreightCost(), CheckForRecursiveBOM(), DisplayBOMItems() and a few other functions. 12/2/18 PaulT: InternalStockRequest.php: Address a few issues reported by Paul B: Fix Previous/Next handling, table sorting, wrong on-order quantities, and apply the user's display records max. Change also removes unused code and other minor improvements. (Reported in forums: http://www.weberp.org/forum/showthread.php?tid=8089) 12/2/18 Tim (PaulT commit): StockMovements.php, StockLocMovements.php: Correct stock movements that have more than one serial number as part of it, then the item will appear multiple times in the movements script with the total quantity in each line. For example, if I enter a quantity adjustment for a controlled item, and assign 3 serial numbers to this movement and then run the inquiries, there will be 3 separate lines with a quantity of 3 against each one. 11/2/18 PaulT: SellThroughSupport.php: Remove (another) redundant hidden FormID input. (there were two, overlooked the 2nd one earlier) Modified: trunk/includes/DateFunctions.inc =================================================================== --- trunk/includes/DateFunctions.inc 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/includes/DateFunctions.inc 2018-02-13 04:04:59 UTC (rev 7959) @@ -977,7 +977,7 @@ return $EarliestDispatch; } -function CreatePeriod($PeriodNo, $PeriodEnd, &$db) { +function CreatePeriod($PeriodNo, $PeriodEnd) { $GetPrdSQL = "INSERT INTO periods (periodno, lastdate_in_period) VALUES ( @@ -988,7 +988,7 @@ } -function PeriodExists($TransDate, &$db) { +function PeriodExists($TransDate) { /* Find the date a month on */ $MonthAfterTransDate = Mktime(0,0,0,Date('m',$TransDate)+1,Date('d',$TransDate),Date('Y',$TransDate)); @@ -1059,7 +1059,7 @@ $FirstPeriod = $myrow[1]; /* If the period number doesn't exist */ - if (!PeriodExists($TransDate, $db)) { + if (!PeriodExists($TransDate)) { /* if the transaction is after the last period */ if ($TransDate > $LastPeriodEnd) { @@ -1073,7 +1073,7 @@ $LastPeriodEnd = mktime(0,0,0,2, 0, Date('Y', $LastPeriodEnd)+1); } $LastPeriod++; - CreatePeriod($LastPeriod, $LastPeriodEnd, $db); + CreatePeriod($LastPeriod, $LastPeriodEnd); } } else { /* The transaction is before the first period */ @@ -1080,7 +1080,7 @@ $PeriodEnd = mktime(0,0,0,Date('m', $TransDate), 0, Date('Y', $TransDate)); $Period = $FirstPeriod - 1; while ($FirstPeriodEnd > $PeriodEnd) { - CreatePeriod($Period, $FirstPeriodEnd, $db); + CreatePeriod($Period, $FirstPeriodEnd); $Period--; if (Date('m', $FirstPeriodEnd)>0) { $FirstPeriodEnd = mktime(0,0,0,Date('m', $FirstPeriodEnd), 0, Date('Y', $FirstPeriodEnd)); @@ -1089,7 +1089,7 @@ } } } - } else if (!PeriodExists(mktime(0,0,0,Date('m',$TransDate)+1,Date('d',$TransDate),Date('Y',$TransDate)), $db)) { + } else if (!PeriodExists(mktime(0,0,0,Date('m',$TransDate)+1,Date('d',$TransDate),Date('Y',$TransDate)))) { /* Make sure the following months period exists */ $sql = "SELECT MAX(lastdate_in_period), MAX(periodno) from periods"; $result = DB_query($sql); @@ -1097,7 +1097,7 @@ $Date_Array = explode('-', $myrow[0]); $LastPeriodEnd = mktime(0,0,0,$Date_Array[1]+2,0,(int)$Date_Array[0]); $LastPeriod = $myrow[1]; - CreatePeriod($LastPeriod+1, $LastPeriodEnd, $db); + CreatePeriod($LastPeriod+1, $LastPeriodEnd); } /* Now return the period number of the transaction */ @@ -1114,4 +1114,4 @@ return $myrow[0]; } -?> +?> \ No newline at end of file Modified: trunk/includes/FreightCalculation.inc =================================================================== --- trunk/includes/FreightCalculation.inc 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/includes/FreightCalculation.inc 2018-02-13 04:04:59 UTC (rev 7959) @@ -13,8 +13,7 @@ $TotalVolume, $TotalWeight, $FromLocation, - $Currency, - $db){ + $Currency){ $CalcFreightCost =9999999999; $CalcBestShipper =''; Modified: trunk/includes/UserLogin.php =================================================================== --- trunk/includes/UserLogin.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/includes/UserLogin.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -17,7 +17,7 @@ * See define() statements above. */ -function userLogin($Name, $Password, $SysAdminEmail = '', $db) { +function userLogin($Name, $Password, $SysAdminEmail = '') { global $debug; global $PathPrefix; @@ -273,4 +273,4 @@ return UL_OK; /* All is well */ } -?> +?> \ No newline at end of file Modified: trunk/includes/session.php =================================================================== --- trunk/includes/session.php 2018-02-13 00:20:44 UTC (rev 7958) +++ trunk/includes/session.php 2018-02-13 04:04:59 UTC (rev 7959) @@ -146,7 +146,7 @@ include $PathPrefix . 'includes/UserLogin.php'; /* Login checking and setup */ if (isset($_POST['UserNameEntryField']) AND isset($_POST['Password'])) { - $rc = userLogin($_POST['UserNameEntryField'], $_POST['Password'], $SysAdminEmail, $db); + $rc = userLogin($_POST['UserNameEntryField'], $_POST['Password'], $SysAdminEmail); $FirstLogin = true; } elseif (empty($_SESSION['DatabaseName'])) { $rc = UL_SHOWLOGIN; |