From e6aa432148c9718e196a991526c6e135091429e1 Mon Sep 17 00:00:00 2001 From: Paul Thursby Date: Tue, 27 Feb 2018 10:21:29 +0000 Subject: [PATCH] PaulT: Remove $db parameter from WoRealRequirements(), EnsureGLEntriesBalance(), and CreateQASample() functions. --- ConfirmDispatch_Invoice.php | 2 +- CounterReturns.php | 4 ++-- CounterSales.php | 6 +++--- Credit_Invoice.php | 2 +- CustomerReceipt.php | 2 +- DeliveryDetails.php | 4 ++-- GoodsReceived.php | 4 ++-- Payments.php | 2 +- SelectCreditItems.php | 2 +- SelectQASamples.php | 2 +- StockAdjustments.php | 2 +- SupplierInvoice.php | 4 ++-- WorkOrderEntry.php | 4 ++-- WorkOrderEntry.php.orig | 29 ++++++++------------------- WorkOrderReceive.php | 6 +++--- api/api_debtortransactions.php | 2 +- api/api_salesorders.php | 2 +- doc/Change.log | 1 + includes/PDFPaymentRun_PymtFooter.php | 2 +- includes/SQL_CommonFunctions.inc | 8 ++++---- 20 files changed, 39 insertions(+), 51 deletions(-) diff --git a/ConfirmDispatch_Invoice.php b/ConfirmDispatch_Invoice.php index c8a61a8cc..a5d3a2f37 100644 --- a/ConfirmDispatch_Invoice.php +++ b/ConfirmDispatch_Invoice.php @@ -1737,7 +1737,7 @@ DB_Txn_Commit(); - EnsureGLEntriesBalance(10, $InvoiceNo,$db); + EnsureGLEntriesBalance(10, $InvoiceNo); // ************************************************************************* // 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 // ************************************************************************* diff --git a/CounterReturns.php b/CounterReturns.php index 3aa0cda3f..c690bfb61 100644 --- a/CounterReturns.php +++ b/CounterReturns.php @@ -1431,7 +1431,7 @@ } } - EnsureGLEntriesBalance(11,$CreditNoteNo,$db); + EnsureGLEntriesBalance(11,$CreditNoteNo); /*Also if GL is linked to debtors need to process the debit to bank and credit to debtors for the payment */ /*Need to figure out the cross rate between customer currency and bank account currency */ @@ -1476,7 +1476,7 @@ $result = DB_query($SQL,$ErrMsg,$DbgMsg,true); }//amount paid was not zero - EnsureGLEntriesBalance(12,$PaymentNumber,$db); + EnsureGLEntriesBalance(12,$PaymentNumber); } /*end of if Sales and GL integrated */ diff --git a/CounterSales.php b/CounterSales.php index 6aedbfd21..e0dfcd70c 100644 --- a/CounterSales.php +++ b/CounterSales.php @@ -1241,7 +1241,7 @@ $result = DB_query($sql,$ErrMsg,$DbgMsg,true); //Recursively insert real component requirements - see includes/SQL_CommonFunctions.in for function WoRealRequirements - WoRealRequirements($db, $WONo, $_SESSION['DefaultFactoryLocation'], $StockItem->StockID); + WoRealRequirements($WONo, $_SESSION['DefaultFactoryLocation'], $StockItem->StockID); $FactoryManagerEmail = _('A new work order has been created for') . ":\n" . $StockItem->StockID . ' - ' . $StockItem->ItemDescription . ' x ' . $WOQuantity . ' ' . $StockItem->Units . @@ -1884,7 +1884,7 @@ } } - EnsureGLEntriesBalance(10,$InvoiceNo,$db); + EnsureGLEntriesBalance(10,$InvoiceNo); /*Also if GL is linked to debtors need to process the debit to bank and credit to debtors for the payment */ /*Need to figure out the cross rate between customer currency and bank account currency */ @@ -1929,7 +1929,7 @@ $result = DB_query($SQL,$ErrMsg,$DbgMsg,true); }//amount paid we not zero - EnsureGLEntriesBalance(12,$ReceiptNumber,$db); + EnsureGLEntriesBalance(12,$ReceiptNumber); } /*end of if Sales and GL integrated */ if ($_POST['AmountPaid']!=0){ diff --git a/Credit_Invoice.php b/Credit_Invoice.php index 17a79fd08..c63543a37 100644 --- a/Credit_Invoice.php +++ b/Credit_Invoice.php @@ -1502,7 +1502,7 @@ } } - EnsureGLEntriesBalance(11,$CreditNo,$db); + EnsureGLEntriesBalance(11,$CreditNo); } /*end of if Sales and GL integrated */ diff --git a/CustomerReceipt.php b/CustomerReceipt.php index 99e417393..5ac9f9109 100644 --- a/CustomerReceipt.php +++ b/CustomerReceipt.php @@ -587,7 +587,7 @@ functionalexrate, } //end if there is some discount } //end if there is GL work to be done - ie config is to link to GL - EnsureGLEntriesBalance(12,$_SESSION['ReceiptBatch' . $identifier]->BatchNo,$db); + EnsureGLEntriesBalance(12,$_SESSION['ReceiptBatch' . $identifier]->BatchNo); $ErrMsg = _('Cannot commit the changes'); $DbgMsg = _('The SQL that failed was'); diff --git a/DeliveryDetails.php b/DeliveryDetails.php index 1069c42bb..1ac452ee4 100644 --- a/DeliveryDetails.php +++ b/DeliveryDetails.php @@ -536,7 +536,7 @@ $result = DB_query($sql,$ErrMsg,$DbgMsg,true); //Recursively insert real component requirements - see includes/SQL_CommonFunctions.in for function WoRealRequirements - WoRealRequirements($db, $WONo, $_SESSION['DefaultFactoryLocation'], $StockItem->StockID); + WoRealRequirements($WONo, $_SESSION['DefaultFactoryLocation'], $StockItem->StockID); $FactoryManagerEmail = _('A new work order has been created for') . ":\n" . $StockItem->StockID . ' - ' . $StockItem->ItemDescription . ' x ' . $WOQuantity . ' ' . $StockItem->Units . @@ -738,7 +738,7 @@ $result = DB_query($sql,$ErrMsg,$DbgMsg,true); //Recursively insert real component requirements - see includes/SQL_CommonFunctions.in for function WoRealRequirements - WoRealRequirements($db, $WONo, $_SESSION['Items'.$identifier]->Location, $ContractRow['contractref']); + WoRealRequirements($WONo, $_SESSION['Items'.$identifier]->Location, $ContractRow['contractref']); }//end processing if the order was a contract quotation being changed to an order }//end test to see if the order was a contract quotation being changed to an order diff --git a/GoodsReceived.php b/GoodsReceived.php index 0a9925953..865f3241b 100644 --- a/GoodsReceived.php +++ b/GoodsReceived.php @@ -645,7 +645,7 @@ $DbgMsg = _('The following SQL to insert the serial stock movement records was used'); $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true); if ($_SESSION['QualityLogSamples']==1) { - CreateQASample($OrderLine->StockID,$Item->BundleRef, '', 'Created from Purchase Order', 0, 0,$db); + CreateQASample($OrderLine->StockID,$Item->BundleRef, '', 'Created from Purchase Order', 0, 0); } }//non blank BundleRef } //end foreach @@ -771,7 +771,7 @@ } if ($_SESSION['PO'.$identifier]->GLLink==1) { - EnsureGLEntriesBalance(25, $GRN,$db); + EnsureGLEntriesBalance(25, $GRN); } $Result = DB_Txn_Commit(); diff --git a/Payments.php b/Payments.php index 153887c5b..eda80ec23 100644 --- a/Payments.php +++ b/Payments.php @@ -720,7 +720,7 @@ functionalexrate, $ErrMsg = _('Cannot insert a GL transaction for the bank account credit because'); $DbgMsg = _('Cannot insert a GL transaction for the bank account credit using the SQL'); $result = DB_query($SQL,$ErrMsg,$DbgMsg,true); - EnsureGLEntriesBalance($TransType,$TransNo,$db); + EnsureGLEntriesBalance($TransType,$TransNo); } } diff --git a/SelectCreditItems.php b/SelectCreditItems.php index f723288a3..a5496ad1c 100644 --- a/SelectCreditItems.php +++ b/SelectCreditItems.php @@ -1984,7 +1984,7 @@ } } - EnsureGLEntriesBalance(11,$CreditNo,$db); + EnsureGLEntriesBalance(11,$CreditNo); } /*end of if Sales and GL integrated */ diff --git a/SelectQASamples.php b/SelectQASamples.php index eee660284..f523ec0aa 100644 --- a/SelectQASamples.php +++ b/SelectQASamples.php @@ -105,7 +105,7 @@ } } else { - CreateQASample($_POST['ProdSpecKey'],$_POST['LotKey'], $_POST['Identifier'], $_POST['Comments'], $_POST['Cert'], $_POST['DuplicateOK'],$db); + CreateQASample($_POST['ProdSpecKey'],$_POST['LotKey'], $_POST['Identifier'], $_POST['Comments'], $_POST['Cert'], $_POST['DuplicateOK']); $SelectedSampleID=DB_Last_Insert_ID('qasamples','sampleid'); if ($SelectedSampleID > '') { $msg = _('Created New Sample'); diff --git a/StockAdjustments.php b/StockAdjustments.php index a4f53f96b..300eba0b8 100644 --- a/StockAdjustments.php +++ b/StockAdjustments.php @@ -366,7 +366,7 @@ $Result = DB_query($SQL, $ErrMsg, $DbgMsg,true); } - EnsureGLEntriesBalance(17, $AdjustmentNumber,$db); + EnsureGLEntriesBalance(17, $AdjustmentNumber); $Result = DB_Txn_Commit(); $AdjustReason = $_SESSION['Adjustment' . $identifier]->Narrative? _('Narrative') . ' ' . $_SESSION['Adjustment' . $identifier]->Narrative:''; diff --git a/SupplierInvoice.php b/SupplierInvoice.php index c11757387..8d14330c8 100644 --- a/SupplierInvoice.php +++ b/SupplierInvoice.php @@ -434,7 +434,7 @@ $result=DB_query($sql); if ($_SESSION['PO'.$identifier]->GLLink==1) { - EnsureGLEntriesBalance(25, $GRN,$db); + EnsureGLEntriesBalance(25, $GRN); } $Result = DB_Txn_Commit(); @@ -1486,7 +1486,7 @@ $DbgMsg = _('The following SQL to insert the GL transaction was used'); $Result = DB_query($SQL, $ErrMsg, $DbgMsg, True); - EnsureGLEntriesBalance(20, $InvoiceNo, $db); + EnsureGLEntriesBalance(20, $InvoiceNo); } /*Thats the end of the GL postings */ /*Now insert the invoice into the SuppTrans table*/ diff --git a/WorkOrderEntry.php b/WorkOrderEntry.php index d00a1d0c9..bfe33c632 100644 --- a/WorkOrderEntry.php +++ b/WorkOrderEntry.php @@ -379,7 +379,7 @@ $result = DB_query($SQL,$ErrMsg); //Recursively insert real component requirements - see includes/SQL_CommonFunctions.in for function WoRealRequirements - WoRealRequirements($db, $_POST['WO'], $CostRow['loccode'], $NewItem); + WoRealRequirements($_POST['WO'], $CostRow['loccode'], $NewItem); $result = DB_Txn_Commit(); @@ -469,7 +469,7 @@ $ErrMsg = _('The work order item could not be added'); $result = DB_query($SQL,$ErrMsg); //Recursively insert real component requirements - see includes/SQL_CommonFunctions.in for function WoRealRequirements - WoRealRequirements($db, $_POST['WO'], $CostRow['loccode'], $Itm); + WoRealRequirements($_POST['WO'], $CostRow['loccode'], $Itm); } //end if there were no input errors else { DB_txn_rollback(); diff --git a/WorkOrderEntry.php.orig b/WorkOrderEntry.php.orig index ec6952a04..d00a1d0c9 100644 --- a/WorkOrderEntry.php.orig +++ b/WorkOrderEntry.php.orig @@ -821,17 +821,11 @@ echo '' . _('Output Item') . ' ' . _('Balance Remaining') . ' ' . _('Next Lot/SN Ref') . ' '; -$j=0; + if(isset($NumberOfOutputs)) { for ($i=1;$i<=$NumberOfOutputs;$i++) { - if($j==1) { - echo ''; - $j=0; - } else { - echo ''; - $j=1; - } - echo '' . + echo ' + ' . $_POST['OutputItem' . $i] . ' - ' . $_POST['OutputItemDesc' .$i] . ' '; echo' @@ -973,7 +967,6 @@ if(isset($SearchResult)) { ' . _('Description') . ' ' . _('Units') . ''; $j = 1; - $k=0; //row colour counter $ItemCodes = array(); for ($i=1;$i<=$NumberOfOutputs;$i++) { $ItemCodes[] =$_POST['OutputItem'.$i]; @@ -998,16 +991,10 @@ if(isset($SearchResult)) { $ImageSource = _('No Image'); } - if($k==1) { - echo ''; - $k=0; - } else { - echo ''; - $k=1; - } if($myrow['controlled']==1 AND $_SESSION['DefineControlledOnWOEntry']==1) { //need to add serial nos or batches to determine quantity - printf('%s + printf(' + %s %s %s %s @@ -1026,14 +1013,14 @@ if(isset($SearchResult)) { if(!isset($myrow['quantity'])) { $myrow['quantity'] = 0; } - printf('%s + printf(' + %s %s %s %s ' . _('Add to Work Order') . ' - ', $myrow['stockid'], $myrow['description'], @@ -1052,7 +1039,7 @@ if(isset($SearchResult)) { }//end of while loop } //end if more than 1 row to show echo ''; - echo '
+ echo '
'; diff --git a/WorkOrderReceive.php b/WorkOrderReceive.php index e20c983ce..dd5798e41 100644 --- a/WorkOrderReceive.php +++ b/WorkOrderReceive.php @@ -229,7 +229,7 @@ AND parentstockid='" . $_POST['StockID'] . "'"); //Recursively insert real component requirements - WoRealRequirements($db, $_POST['WO'], $WORow['loccode'], $_POST['StockID']); + WoRealRequirements($_POST['WO'], $WORow['loccode'], $_POST['StockID']); //Need to check this against the current standard cost and do a cost update if necessary $sql = "SELECT materialcost+labourcost+overheadcost AS cost, @@ -572,7 +572,7 @@ } }//end prefined controlled items or not if ($_SESSION['QualityLogSamples']==1) { - CreateQASample($_POST['StockID'],$_POST['SerialNo'.$i], '', 'Created from Work Order', 0, 0,$db); + CreateQASample($_POST['StockID'],$_POST['SerialNo'.$i], '', 'Created from Work Order', 0, 0); } } //non blank SerialNo } //end for all of the potential serialised fields received @@ -678,7 +678,7 @@ } */ } if ($_SESSION['QualityLogSamples']==1) { - CreateQASample($_POST['StockID'],$_POST['BatchRef'.$i], '', 'Created from Work Order', 0 ,0,$db); + CreateQASample($_POST['StockID'],$_POST['BatchRef'.$i], '', 'Created from Work Order', 0 ,0); } }//non blank BundleRef } //end for all of the potential batch/lot fields received diff --git a/api/api_debtortransactions.php b/api/api_debtortransactions.php index a7ba5c4d8..784dc7bc6 100644 --- a/api/api_debtortransactions.php +++ b/api/api_debtortransactions.php @@ -1050,7 +1050,7 @@ function CreateCreditNote($Header,$LineDetails, $User, $Password) { $Result = api_DB_query($SQL,'','',true); } - EnsureGLEntriesBalance(11,$CreditNoteNo,$db); + EnsureGLEntriesBalance(11,$CreditNoteNo); } /*end of if Sales and GL integrated */ diff --git a/api/api_salesorders.php b/api/api_salesorders.php index b60382b4d..f6757bdd5 100644 --- a/api/api_salesorders.php +++ b/api/api_salesorders.php @@ -1219,7 +1219,7 @@ function InvoiceSalesOrder($OrderNo, $User, $Password) { $Result = api_DB_query($SQL,'','',true); } - EnsureGLEntriesBalance(10,$InvoiceNo,$db); + EnsureGLEntriesBalance(10,$InvoiceNo); } /*end of if Sales and GL integrated */ diff --git a/doc/Change.log b/doc/Change.log index c5975e557..c880654fe 100644 --- a/doc/Change.log +++ b/doc/Change.log @@ -1,5 +1,6 @@ webERP Change Log +10/2/18 PaulT: Remove $db parameter from WoRealRequirements(), EnsureGLEntriesBalance(), and CreateQASample() functions. 10/2/18 PaulT: Remove $db parameter from BomMaterialCost(), GetTaxRate(), GetTaxes(), GetCreditAvailable(), ItemCostUpdateGL(), and UpdateCost() functions. 10/2/18 PaulT: Remove $db parameter from all GetStockGLCode() functions. 10/2/18 PaulT: Remove variables left behind from 7944 commit. diff --git a/includes/PDFPaymentRun_PymtFooter.php b/includes/PDFPaymentRun_PymtFooter.php index d09cd9599..598985263 100644 --- a/includes/PDFPaymentRun_PymtFooter.php +++ b/includes/PDFPaymentRun_PymtFooter.php @@ -224,7 +224,7 @@ exit; } } - EnsureGLEntriesBalance(22,$SuppPaymentNo,$db); + EnsureGLEntriesBalance(22,$SuppPaymentNo); } /*end if GL linked to creditors */ diff --git a/includes/SQL_CommonFunctions.inc b/includes/SQL_CommonFunctions.inc index fd5f04f1c..eb26f411a 100644 --- a/includes/SQL_CommonFunctions.inc +++ b/includes/SQL_CommonFunctions.inc @@ -247,7 +247,7 @@ function UpdateCost($Item) { } /* Accepts work order information and iterates through the bom, inserting real components (dissolving phantom assemblies) */ -function WoRealRequirements($db, $WO, $LocCode, $StockID, $Qty=1, $ParentID='') { +function WoRealRequirements($WO, $LocCode, $StockID, $Qty=1, $ParentID='') { // remember, 'G' is for ghost (phantom part type) @@ -330,13 +330,13 @@ function WoRealRequirements($db, $WO, $LocCode, $StockID, $Qty=1, $ParentID='') AND stockmaster.mbflag='G'"; $result = DB_query($sql); while ($MyRow=DB_fetch_array($result)) { - WoRealRequirements($db, $WO, $LocCode, $MyRow['component'], $MyRow['quantity'], $ParentID); + WoRealRequirements($WO, $LocCode, $MyRow['component'], $MyRow['quantity'], $ParentID); } } /*Ensures general ledger entries balance for a given transaction */ -function EnsureGLEntriesBalance ($TransType, $TransTypeNo, $db) { +function EnsureGLEntriesBalance ($TransType, $TransTypeNo) { $result = DB_query("SELECT SUM(amount) FROM gltrans @@ -444,7 +444,7 @@ function GetQuantityOnOrderDueToWorkOrders($StockID, $Location){ } /*Creates sample and testresults */ -function CreateQASample ($ProdSpecKey, $LotKey, $Identifier, $Comments, $Cert, $DuplicateOK, $db) { +function CreateQASample ($ProdSpecKey, $LotKey, $Identifier, $Comments, $Cert, $DuplicateOK) { $result = DB_query("SELECT COUNT(testid) FROM prodspecs WHERE keyval='" . $ProdSpecKey . "' AND active='1'");