Skip to content

Commit

Permalink
Remove unused $db and $conn parameters from DB_Last_Insert_ID() and (…
Browse files Browse the repository at this point in the history
…where present) from DB_show_tables(), and DB_show_fields(). Also, remove any unused 'global $db' references across the code base.
  • Loading branch information
TurboPT authored and timschofield committed Feb 26, 2018
1 parent ffa090f commit 7f3464c
Show file tree
Hide file tree
Showing 59 changed files with 108 additions and 205 deletions.
2 changes: 1 addition & 1 deletion AuditTrail.php
Expand Up @@ -29,7 +29,7 @@
}

// Get list of tables
$TableResult = DB_show_tables($db);
$TableResult = DB_show_tables();

// Get list of users
$UserResult = DB_query("SELECT userid FROM www_users ORDER BY userid");
Expand Down
1 change: 0 additions & 1 deletion BOMs.php
Expand Up @@ -11,7 +11,6 @@

function display_children($Parent, $Level, &$BOMTree) {

global $db;
global $i;

// retrive all children of parent
Expand Down
1 change: 0 additions & 1 deletion BOMs_SingleLevel.php
Expand Up @@ -11,7 +11,6 @@

function display_children($Parent, $Level, &$BOMTree) {

global $db;
global $i;

// retrive all children of parent
Expand Down
4 changes: 2 additions & 2 deletions ConfirmDispatch_Invoice.php
Expand Up @@ -890,7 +890,7 @@
$DbgMsg = _('The following SQL to insert the debtor transaction record was used');
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

$DebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id');
$DebtorTransID = DB_Last_Insert_ID('debtortrans','id');

/* Insert the tax totals for each tax authority where tax was charged on the invoice */
foreach ($TaxTotals AS $TaxAuthID => $TaxAmount) {
Expand Down Expand Up @@ -1251,7 +1251,7 @@
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

/*Insert the taxes that applied to this line */
foreach ($OrderLine->Taxes as $Tax) {
Expand Down
2 changes: 1 addition & 1 deletion ContractCosting.php
Expand Up @@ -370,7 +370,7 @@
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);

/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

/* If GLLink_Stock then insert GLTrans to debit the GL Code and credit GRN Suspense account at standard cost*/
if ($_SESSION['CompanyRecord']['gllink_stock']==1 AND ($OtherReqtsBudget+$ContractBOMBudget)!=0){
Expand Down
6 changes: 3 additions & 3 deletions CounterReturns.php
Expand Up @@ -948,7 +948,7 @@
$DbgMsg = _('The following SQL to insert the debtor transaction record was used');
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

$DebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id');
$DebtorTransID = DB_Last_Insert_ID('debtortrans','id');

/* Insert the tax totals for each tax authority where tax was charged on the invoice */
foreach ($_SESSION['Items' . $identifier]->TaxTotals AS $TaxAuthID => $TaxAmount) {
Expand Down Expand Up @@ -1172,7 +1172,7 @@
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

/*Insert the taxes that applied to this line */
foreach ($ReturnItemLine->Taxes as $Tax) {
Expand Down Expand Up @@ -1569,7 +1569,7 @@ functionalexrate,
$ErrMsg = _('Cannot insert a receipt transaction against the customer because') ;
$result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

$ReceiptDebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id');
$ReceiptDebtorTransID = DB_Last_Insert_ID('debtortrans','id');


//and finally add the allocation record between receipt and invoice
Expand Down
6 changes: 3 additions & 3 deletions CounterSales.php
Expand Up @@ -1359,7 +1359,7 @@
$DbgMsg = _('The following SQL to insert the debtor transaction record was used');
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

$DebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id');
$DebtorTransID = DB_Last_Insert_ID('debtortrans','id');

/* Insert the tax totals for each tax authority where tax was charged on the invoice */
foreach ($_SESSION['Items'.$identifier]->TaxTotals AS $TaxAuthID => $TaxAmount) {
Expand Down Expand Up @@ -1584,7 +1584,7 @@
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

/*Insert the taxes that applied to this line */
foreach ($OrderLine->Taxes as $Tax) {
Expand Down Expand Up @@ -2021,7 +2021,7 @@ functionalexrate,
$ErrMsg = _('Cannot insert a receipt transaction against the customer because') ;
$result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

$ReceiptDebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id');
$ReceiptDebtorTransID = DB_Last_Insert_ID('debtortrans','id');

$SQL = "UPDATE debtorsmaster SET lastpaiddate = '" . $DefaultDispatchDate . "',
lastpaid='" . filter_number_format($_POST['AmountPaid']) . "'
Expand Down
8 changes: 4 additions & 4 deletions Credit_Invoice.php
Expand Up @@ -658,7 +658,7 @@
$DbgMsg = _('The following SQL to insert the customer credit note was used');
$Result = DB_query($SQL,$ErrMsg, $DbgMsg, true);

$CreditTransID = DB_Last_Insert_ID($db,'debtortrans','id');
$CreditTransID = DB_Last_Insert_ID('debtortrans','id');

/* Insert the tax totals for each tax authority where tax was charged on the invoice */
foreach($TaxTotals AS $TaxAuthID => $TaxAmount) {
Expand Down Expand Up @@ -958,7 +958,7 @@
$DbgMsg = _('The following SQL to insert the stock movement records was used');
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');
/*Insert the StockSerialMovements and update the StockSerialItems for controlled items*/
//echo "<div align="left"><pre>"; var_dump($CreditLine); echo "</pre> </div>";
if($CreditLine->Controlled ==1) {
Expand Down Expand Up @@ -1060,7 +1060,7 @@
$DbgMsg = _('The following SQL to insert the stock movement records was used');
$Result = DB_query($SQL,$ErrMsg, $DbgMsg, true);
/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

$SQL = "INSERT INTO stockmoves(stockid,
type,
Expand Down Expand Up @@ -1145,7 +1145,7 @@

$Result = DB_query($SQL,$ErrMsg, $DbgMsg, true);
/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');
}

/*Insert the taxes that applied to this line */
Expand Down
2 changes: 1 addition & 1 deletion FixedAssetItems.php
Expand Up @@ -277,7 +277,7 @@
$result = DB_query($sql, $ErrMsg, $DbgMsg);

if (DB_error_no() ==0) {
$NewAssetID = DB_Last_Insert_ID($db,'fixedassets', 'assetid');
$NewAssetID = DB_Last_Insert_ID('fixedassets', 'assetid');
prnMsg( _('The new asset has been added to the database with an asset code of:') . ' ' . $NewAssetID,'success');
unset($_POST['LongDescription']);
unset($_POST['Description']);
Expand Down
2 changes: 1 addition & 1 deletion GLProfit_Loss.php
Expand Up @@ -93,7 +93,7 @@

$RetResult = DB_data_seek($Periods,0);

while ($myrow=DB_fetch_array($Periods,$db)){
while ($myrow=DB_fetch_array($Periods)){

if($myrow['periodno']==$DefaultToPeriod){
echo '<option selected="selected" value="' . $myrow['periodno'] . '">' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']) . '</option>';
Expand Down
2 changes: 1 addition & 1 deletion GoodsReceived.php
Expand Up @@ -591,7 +591,7 @@
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);

/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');
/* Do the Controlled Item INSERTS HERE */

if ($OrderLine->Controlled ==1){
Expand Down
2 changes: 1 addition & 1 deletion InternalStockRequestFulfill.php
Expand Up @@ -91,7 +91,7 @@


/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

$SQL="UPDATE stockrequestitems
SET qtydelivered=qtydelivered+" . $Quantity . "
Expand Down
20 changes: 3 additions & 17 deletions InternalStockRequestInquiry.php
Expand Up @@ -164,9 +164,7 @@
<td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="FromDate" maxlength="10" size="11" vaue="' . $_POST['FromDate'] .'" /></td>
<td>' . _('Date To') . '</td>
<td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="ToDate" maxlength="10" size="11" value="' . $_POST['ToDate'] . '" /></td>
<td><input type="submit" name="Search" value="' ._('Search') . '" /></td></tr></table>
';
<td><input type="submit" name="Search" value="' ._('Search') . '" /></td></tr></table>';
if (!isset($_POST['ShowDetails'])) {
$_POST['ShowDetails'] = 1;
}
Expand Down Expand Up @@ -324,8 +322,7 @@
FROM stockrequest INNER JOIN stockrequestitems ON stockrequest.dispatchid=stockrequestitems.dispatchid
INNER JOIN departments ON stockrequest.departmentid=departments.departmentid
INNER JOIN locations ON locations.loccode=stockrequest.loccode
INNER JOIN stockmaster ON stockrequestitems.stockid=stockmaster.stockid
";
INNER JOIN stockmaster ON stockrequestitems.stockid=stockmaster.stockid";
} else {
$SQL = "SELECT stockrequest.dispatchid,
stockrequest.loccode,
Expand All @@ -338,7 +335,7 @@
narrative,
initiator
FROM stockrequest INNER JOIN departments ON stockrequest.departmentid=departments.departmentid
INNER JOIN locations ON locations.loccode=stockrequest.loccode ";
INNER JOIN locations ON locations.loccode=stockrequest.loccode";
}
//lets add the condition selected by users
if (isset($_POST['RequestNo']) AND $_POST['RequestNo'] !== '') {
Expand Down Expand Up @@ -489,23 +486,12 @@
} else {
prnMsg(_('There are no stock request available'),'warn');
}










}

include('includes/footer.php');
exit;

function GetSearchItems ($SQLConstraint='') {
global $db;
if ($_POST['Keywords'] AND $_POST['StockCode']) {
echo _('Stock description keywords have been used in preference to the Stock code extract entered');
}
Expand Down
8 changes: 0 additions & 8 deletions MailingGroupMaintenance.php
Expand Up @@ -153,15 +153,8 @@
?>








<?php
function GetMailGroup () {
global $db;
//GET the mailing group data if there are any
$sql = "SELECT groupname, id FROM mailgroups ORDER BY groupname";
$ErrMsg = _('Failed to retrieve mail groups information');
Expand All @@ -188,7 +181,6 @@ function GetMailGroup () {
}

function GetUsers ($GroupId,$GroupName) {
global $db;
$sql = "SELECT userid FROM mailgroups INNER JOIN mailgroupdetails ON mailgroups.groupname=mailgroupdetails.groupname WHERE mailgroups.id = '".$GroupId."'";
$ErrMsg = _('Failed to retrieve userid');
$result = DB_query($sql,$ErrMsg);
Expand Down
2 changes: 1 addition & 1 deletion PcClaimExpensesFromTab.php
Expand Up @@ -165,7 +165,7 @@
)";
$Msg = _('The expense claim on tab') . ' ' . $_POST['SelectedTabs'] . ' ' . _('has been created');
$Result = DB_query($SQL);
$SelectedIndex = DB_Last_Insert_ID($db, 'pcashdetails', 'counterindex');
$SelectedIndex = DB_Last_Insert_ID('pcashdetails', 'counterindex');
foreach ($_POST as $Index => $Value) {
if (substr($Index, 0, 5) == 'index') {
$Index = $Value;
Expand Down
2 changes: 1 addition & 1 deletion RecurringSalesOrders.php
Expand Up @@ -267,7 +267,7 @@
$DbgMsg = _('The SQL that failed was');
$InsertQryResult = DB_query($HeaderSQL,$ErrMsg,$DbgMsg,true);

$RecurrOrderNo = DB_Last_Insert_ID($db,'recurringsalesorders','recurrorderno');
$RecurrOrderNo = DB_Last_Insert_ID('recurringsalesorders','recurrorderno');
echo 'xxx'.$RecurrOrderNo;
$StartOf_LineItemsSQL = "INSERT INTO recurrsalesorderdetails (recurrorderno,
stkcode,
Expand Down
4 changes: 2 additions & 2 deletions RecurringSalesOrdersProcess.php
Expand Up @@ -367,7 +367,7 @@
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

/*Insert the taxes that applied to this line */
foreach ($LineTaxes[$LineCounter] as $Tax) {
Expand Down Expand Up @@ -683,7 +683,7 @@
$DbgMsg = _('The following SQL to insert the debtor transaction record was used');
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

$DebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id');
$DebtorTransID = DB_Last_Insert_ID('debtortrans','id');


$SQL = "INSERT INTO debtortranstaxes (debtortransid,
Expand Down
2 changes: 1 addition & 1 deletion ReverseGRN.php
Expand Up @@ -257,7 +257,7 @@
$DbgMsg = _('The following SQL to insert the stock movement records was used');
$Result=DB_query($SQL,$ErrMsg,$DbgMsg,true);

$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

if ($Controlled==true){
while ($SerialStockMoves = DB_fetch_array($GetStockMoveResult)){
Expand Down
6 changes: 3 additions & 3 deletions SelectCreditItems.php
Expand Up @@ -1171,7 +1171,7 @@
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);


$CreditTransID = DB_Last_Insert_ID($db,'debtortrans','id');
$CreditTransID = DB_Last_Insert_ID('debtortrans','id');

/* Insert the tax totals for each tax authority where tax was charged on the invoice */
foreach ($TaxTotals AS $TaxAuthID => $TaxAmount) {
Expand Down Expand Up @@ -1332,7 +1332,7 @@
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);

/*Get the stockmoveno from above - need to ref StockMoveTaxes and possibly SerialStockMoves */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

/*Insert the taxes that applied to this line */
foreach ($CreditLine->Taxes as $Tax) {
Expand Down Expand Up @@ -1613,7 +1613,7 @@
/*Its a write off too still so need to process the serial items
written off */

$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

foreach($CreditLine->SerialItems as $Item){
/*no need to check StockSerialItems record exists
Expand Down
1 change: 0 additions & 1 deletion SelectOrderItems.php
Expand Up @@ -1888,7 +1888,6 @@
include('includes/footer.php');

function GetCustBranchDetails($identifier) {
global $db;
$sql = "SELECT custbranch.brname,
custbranch.branchcode,
custbranch.braddress1,
Expand Down
2 changes: 1 addition & 1 deletion SelectQASamples.php
Expand Up @@ -106,7 +106,7 @@

} else {
CreateQASample($_POST['ProdSpecKey'],$_POST['LotKey'], $_POST['Identifier'], $_POST['Comments'], $_POST['Cert'], $_POST['DuplicateOK'],$db);
$SelectedSampleID=DB_Last_Insert_ID($db,'qasamples','sampleid');
$SelectedSampleID=DB_Last_Insert_ID('qasamples','sampleid');
if ($SelectedSampleID > '') {
$msg = _('Created New Sample');
prnMsg($msg , 'success');
Expand Down
2 changes: 1 addition & 1 deletion StockAdjustments.php
Expand Up @@ -240,7 +240,7 @@
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);

/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

/*Insert the StockSerialMovements and update the StockSerialItems for controlled items*/

Expand Down
4 changes: 2 additions & 2 deletions StockLocTransferReceive.php
Expand Up @@ -113,7 +113,7 @@
$Result = DB_query($SQL,$ErrMsg, $DbgMsg, true);

/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

/*Insert the StockSerialMovements and update the StockSerialItems for controlled items*/

Expand Down Expand Up @@ -267,7 +267,7 @@


/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

/*Insert the StockSerialMovements and update the StockSerialItems for controlled items*/
if($TrfLine->Controlled ==1) {
Expand Down
4 changes: 2 additions & 2 deletions StockTransfers.php
Expand Up @@ -283,7 +283,7 @@
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

/*Insert the StockSerialMovements and update the StockSerialItems for controlled items*/

Expand Down Expand Up @@ -437,7 +437,7 @@
$Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);

/*Get the ID of the StockMove... */
$StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno');
$StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno');

/*Insert the StockSerialMovements and update the StockSerialItems for controlled items*/

Expand Down
2 changes: 1 addition & 1 deletion SupplierCredit.php
Expand Up @@ -1145,7 +1145,7 @@
$DbgMsg = _('The following SQL to insert the supplier credit note was used');
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, True);

$SuppTransID = DB_Last_Insert_ID($db,'supptrans','id');
$SuppTransID = DB_Last_Insert_ID('supptrans','id');

/* Insert the tax totals for each tax authority where tax was charged on the invoice */
foreach ($_SESSION['SuppTrans']->Taxes AS $TaxTotals) {
Expand Down

0 comments on commit 7f3464c

Please sign in to comment.