Skip to content

Commit

Permalink
PaulT: Remove $db parameter from WoRealRequirements(), EnsureGLEntrie…
Browse files Browse the repository at this point in the history
…sBalance(), and CreateQASample() functions.
  • Loading branch information
TurboPT authored and timschofield committed Feb 27, 2018
1 parent 2ebcfda commit e6aa432
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 51 deletions.
2 changes: 1 addition & 1 deletion ConfirmDispatch_Invoice.php
Expand Up @@ -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
// *************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions CounterReturns.php
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */

Expand Down
6 changes: 3 additions & 3 deletions CounterSales.php
Expand Up @@ -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 .
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion Credit_Invoice.php
Expand Up @@ -1502,7 +1502,7 @@
}
}

EnsureGLEntriesBalance(11,$CreditNo,$db);
EnsureGLEntriesBalance(11,$CreditNo);

} /*end of if Sales and GL integrated */

Expand Down
2 changes: 1 addition & 1 deletion CustomerReceipt.php
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions DeliveryDetails.php
Expand Up @@ -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 .
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions GoodsReceived.php
Expand Up @@ -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
Expand Down Expand Up @@ -771,7 +771,7 @@
}

if ($_SESSION['PO'.$identifier]->GLLink==1) {
EnsureGLEntriesBalance(25, $GRN,$db);
EnsureGLEntriesBalance(25, $GRN);
}

$Result = DB_Txn_Commit();
Expand Down
2 changes: 1 addition & 1 deletion Payments.php
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion SelectCreditItems.php
Expand Up @@ -1984,7 +1984,7 @@
}
}

EnsureGLEntriesBalance(11,$CreditNo,$db);
EnsureGLEntriesBalance(11,$CreditNo);

} /*end of if Sales and GL integrated */

Expand Down
2 changes: 1 addition & 1 deletion SelectQASamples.php
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion StockAdjustments.php
Expand Up @@ -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:'';
Expand Down
4 changes: 2 additions & 2 deletions SupplierInvoice.php
Expand Up @@ -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();
Expand Down Expand Up @@ -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*/
Expand Down
4 changes: 2 additions & 2 deletions WorkOrderEntry.php
Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down
29 changes: 8 additions & 21 deletions WorkOrderEntry.php.orig
Expand Up @@ -821,17 +821,11 @@ echo '<tr><th>' . _('Output Item') . '</th>
<th>' . _('Balance Remaining') . '</th>
<th>' . _('Next Lot/SN Ref') . '</th>
</tr>';
$j=0;

if(isset($NumberOfOutputs)) {
for ($i=1;$i<=$NumberOfOutputs;$i++) {
if($j==1) {
echo '<tr class="OddTableRows">';
$j=0;
} else {
echo '<tr class="EvenTableRows">';
$j=1;
}
echo '<td><input type="hidden" name="OutputItem' . $i . '" value="' . $_POST['OutputItem' .$i] . '" />' .
echo '<tr class="striped_row">
<td><input type="hidden" name="OutputItem' . $i . '" value="' . $_POST['OutputItem' .$i] . '" />' .
$_POST['OutputItem' . $i] . ' - ' . $_POST['OutputItemDesc' .$i] . '
</td>';
echo'<td><textarea style="width:100%" rows="5" cols="20" name="WOComments' . $i . '" >' . $_POST['WOComments' . $i] . '</textarea>
Expand Down Expand Up @@ -973,7 +967,6 @@ if(isset($SearchResult)) {
<th class="ascending">' . _('Description') . '</th>
<th>' . _('Units') . '</th></tr>';
$j = 1;
$k=0; //row colour counter
$ItemCodes = array();
for ($i=1;$i<=$NumberOfOutputs;$i++) {
$ItemCodes[] =$_POST['OutputItem'.$i];
Expand All @@ -998,16 +991,10 @@ if(isset($SearchResult)) {
$ImageSource = _('No Image');
}

if($k==1) {
echo '<tr class="EvenTableRows">';
$k=0;
} else {
echo '<tr class="OddTableRows">';
$k=1;
}
if($myrow['controlled']==1 AND $_SESSION['DefineControlledOnWOEntry']==1) { //need to add serial nos or batches to determine quantity

printf('<td><font size="1">%s</font></td>
printf('<tr class="striped_row">
<td><font size="1">%s</font></td>
<td><font size="1">%s</font></td>
<td><font size="1">%s</font></td>
<td>%s</td>
Expand All @@ -1026,14 +1013,14 @@ if(isset($SearchResult)) {
if(!isset($myrow['quantity'])) {
$myrow['quantity'] = 0;
}
printf('<td><font size="1">%s</font></td>
printf('<tr class="striped_row">
<td><font size="1">%s</font></td>
<td><font size="1">%s</font></td>
<td><font size="1">%s</font></td>
<td>%s</td>
<td><font size="1"><a href="%s">'
. _('Add to Work Order') . '</a></font></td>
<td><input type="text" name="Qty_%s" value="%s" size="10" /><input type="hidden" value="%s" name="Item_%s" /></td>

</tr>',
$myrow['stockid'],
$myrow['description'],
Expand All @@ -1052,7 +1039,7 @@ if(isset($SearchResult)) {
}//end of while loop
} //end if more than 1 row to show
echo '</table>';
echo '<div class="center">
echo '<div class="centre">
<input type="submit" name="Add" value="' . _('Add To Work Order') . '" />
<input type="hidden" name="WO" value="' . $_POST['WO'] . '" />
</div>';
Expand Down
6 changes: 3 additions & 3 deletions WorkOrderReceive.php
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/api_debtortransactions.php
Expand Up @@ -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 */

Expand Down
2 changes: 1 addition & 1 deletion api/api_salesorders.php
Expand Up @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions 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.
Expand Down
2 changes: 1 addition & 1 deletion includes/PDFPaymentRun_PymtFooter.php
Expand Up @@ -224,7 +224,7 @@
exit;
}
}
EnsureGLEntriesBalance(22,$SuppPaymentNo,$db);
EnsureGLEntriesBalance(22,$SuppPaymentNo);
} /*end if GL linked to creditors */


Expand Down
8 changes: 4 additions & 4 deletions includes/SQL_CommonFunctions.inc
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'");
Expand Down

0 comments on commit e6aa432

Please sign in to comment.