|
From: <dai...@us...> - 2014-10-06 05:13:33
|
Revision: 6908
http://sourceforge.net/p/web-erp/reponame/6908
Author: daintree
Date: 2014-10-06 05:13:27 +0000 (Mon, 06 Oct 2014)
Log Message:
-----------
Remove db parameter from the new functions
Modified Paths:
--------------
trunk/CounterReturns.php
trunk/CounterSales.php
trunk/InventoryPlanning.php
trunk/InventoryPlanningPrefSupplier.php
trunk/SelectOrderItems.php
trunk/SelectProduct.php
trunk/StockLocStatus.php
trunk/StockStatus.php
trunk/TopItems.php
trunk/includes/SQL_CommonFunctions.inc
Modified: trunk/CounterReturns.php
===================================================================
--- trunk/CounterReturns.php 2014-10-05 13:14:49 UTC (rev 6907)
+++ trunk/CounterReturns.php 2014-10-06 05:13:27 UTC (rev 6908)
@@ -824,7 +824,7 @@
echo '</select></td></tr>';
$BankAccountsResult = DB_query("SELECT bankaccountname, accountcode FROM bankaccounts",$db);
-
+
echo '<tr>
<td style="color:red">' . _('Bank Account') . ':</td>
<td><select name="BankAccount">';
@@ -1725,9 +1725,9 @@
}
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO= GetQuantityOnOrderDueToPurchaseOrders($myrow['stockid'], "", $db);
+ $QOO= GetQuantityOnOrderDueToPurchaseOrders($myrow['stockid'], '');
// Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO += GetQuantityOnOrderDueToWorkOrders($myrow['stockid'], "", $db);
+ $QOO += GetQuantityOnOrderDueToWorkOrders($myrow['stockid'], '');
if ($k==1){
echo '<tr class="EvenTableRows">';
Modified: trunk/CounterSales.php
===================================================================
--- trunk/CounterSales.php 2014-10-05 13:14:49 UTC (rev 6907)
+++ trunk/CounterSales.php 2014-10-06 05:13:27 UTC (rev 6908)
@@ -1184,9 +1184,9 @@
$QuantityAssemblyDemand = $AssemblyDemandRow[0];
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QuantityPurchOrders= GetQuantityOnOrderDueToPurchaseOrders($StockItem->StockID, "", $db);
+ $QuantityPurchOrders= GetQuantityOnOrderDueToPurchaseOrders($StockItem->StockID, '');
// Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QuantityWorkOrders = GetQuantityOnOrderDueToWorkOrders($StockItem->StockID, "", $db);
+ $QuantityWorkOrders = GetQuantityOnOrderDueToWorkOrders($StockItem->StockID, '');
//Now we have the data - do we need to make any more?
$ShortfallQuantity = $QOH-$QuantityDemand-$QuantityAssemblyDemand+$QuantityPurchOrders+$QuantityWorkOrders;
@@ -1278,7 +1278,7 @@
//Send email to the Factory Manager
if($_SESSION['SmtpSetting']==0){
mail($_SESSION['FactoryManagerEmail'],$EmailSubject,$FactoryManagerEmail);
-
+
}else{
include('includes/htmlMimeMail.php');
$mail = new htmlMimeMail();
@@ -2137,9 +2137,9 @@
}
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO = GetQuantityOnOrderDueToPurchaseOrders($myrow['stockid'], "", $db);
- // Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO += GetQuantityOnOrderDueToWorkOrders($myrow['stockid'], "", $db);
+ $QOO = GetQuantityOnOrderDueToPurchaseOrders($myrow['stockid'], '');
+ // Get the QOO due to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
+ $QOO += GetQuantityOnOrderDueToWorkOrders($myrow['stockid'], '');
if ($k==1){
echo '<tr class="EvenTableRows">';
@@ -2288,9 +2288,9 @@
}
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO = GetQuantityOnOrderDueToPurchaseOrders($myrow['stockid'], "", $db);
+ $QOO = GetQuantityOnOrderDueToPurchaseOrders($myrow['stockid'], '');
// Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO += GetQuantityOnOrderDueToWorkOrders($myrow['stockid'], "", $db);
+ $QOO += GetQuantityOnOrderDueToWorkOrders($myrow['stockid'], '');
if ($k==1){
echo '<tr class="EvenTableRows">';
Modified: trunk/InventoryPlanning.php
===================================================================
--- trunk/InventoryPlanning.php 2014-10-05 13:14:49 UTC (rev 6907)
+++ trunk/InventoryPlanning.php 2014-10-06 05:13:27 UTC (rev 6908)
@@ -279,11 +279,11 @@
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
// Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
if ($_POST['Location']=='All'){
- $QOO = GetQuantityOnOrderDueToPurchaseOrders($InventoryPlan['stockid'], "", $db);
- $QOO += GetQuantityOnOrderDueToWorkOrders($InventoryPlan['stockid'], "", $db);
+ $QOO = GetQuantityOnOrderDueToPurchaseOrders($InventoryPlan['stockid'], '');
+ $QOO += GetQuantityOnOrderDueToWorkOrders($InventoryPlan['stockid'], '');
} else {
- $QOO = GetQuantityOnOrderDueToPurchaseOrders($InventoryPlan['stockid'], $_POST['Location'], $db);
- $QOO += GetQuantityOnOrderDueToWorkOrders($InventoryPlan['stockid'], $_POST['Location'], $db);
+ $QOO = GetQuantityOnOrderDueToPurchaseOrders($InventoryPlan['stockid'], $_POST['Location']);
+ $QOO += GetQuantityOnOrderDueToWorkOrders($InventoryPlan['stockid'], $_POST['Location']);
}
$DemandRow = DB_fetch_array($DemandResult);
Modified: trunk/InventoryPlanningPrefSupplier.php
===================================================================
--- trunk/InventoryPlanningPrefSupplier.php 2014-10-05 13:14:49 UTC (rev 6907)
+++ trunk/InventoryPlanningPrefSupplier.php 2014-10-06 05:13:27 UTC (rev 6908)
@@ -150,9 +150,9 @@
suppliers.suppname,
purchdata.leadtime/30 AS monthsleadtime,
SUM(locstock.quantity) AS qoh
- FROM locstock
- INNER JOIN locationusers
- ON locationusers.loccode=locstock.loccode
+ FROM locstock
+ INNER JOIN locationusers
+ ON locationusers.loccode=locstock.loccode
AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1,
stockmaster,
purchdata,
@@ -224,9 +224,9 @@
SUM(CASE WHEN prd='" . $Period_3 . "' THEN -qty ELSE 0 END) AS prd3,
SUM(CASE WHEN prd='" . $Period_4 . "' THEN -qty ELSE 0 END) AS prd4
FROM stockmoves
- INNER JOIN locationusers
- ON locationusers.loccode=stockmoves.loccode
- AND locationusers.userid='" . $_SESSION['UserID'] . "'
+ INNER JOIN locationusers
+ ON locationusers.loccode=stockmoves.loccode
+ AND locationusers.userid='" . $_SESSION['UserID'] . "'
AND locationusers.canview=1
WHERE stockid='" . $InventoryPlan['stockid'] . "'
AND (stockmoves.type=10 OR stockmoves.type=11)
@@ -312,11 +312,11 @@
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
// Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
if ($_POST['Location']=='All'){
- $QOO = GetQuantityOnOrderDueToPurchaseOrders($InventoryPlan['stockid'], "", $db);
- $QOO += GetQuantityOnOrderDueToWorkOrders($InventoryPlan['stockid'], "", $db);
+ $QOO = GetQuantityOnOrderDueToPurchaseOrders($InventoryPlan['stockid'], '');
+ $QOO += GetQuantityOnOrderDueToWorkOrders($InventoryPlan['stockid'], '');
} else {
- $QOO = GetQuantityOnOrderDueToPurchaseOrders($InventoryPlan['stockid'], $_POST['Location'], $db);
- $QOO += GetQuantityOnOrderDueToWorkOrders($InventoryPlan['stockid'], $_POST['Location'], $db);
+ $QOO = GetQuantityOnOrderDueToPurchaseOrders($InventoryPlan['stockid'], $_POST['Location']);
+ $QOO += GetQuantityOnOrderDueToWorkOrders($InventoryPlan['stockid'], $_POST['Location']);
}
$DemandRow = DB_fetch_array($DemandResult);
Modified: trunk/SelectOrderItems.php
===================================================================
--- trunk/SelectOrderItems.php 2014-10-05 13:14:49 UTC (rev 6907)
+++ trunk/SelectOrderItems.php 2014-10-06 05:13:27 UTC (rev 6908)
@@ -326,7 +326,7 @@
debtorsmaster.name
FROM custbranch
LEFT JOIN debtorsmaster
- ON custbranch.debtorno=debtorsmaster.debtorno
+ ON custbranch.debtorno=debtorsmaster.debtorno
WHERE custbranch.disabletrans=0 ";
if (($_POST['CustKeywords']=='') AND ($_POST['CustCode']=='') AND ($_POST['CustPhone']=='')) {
@@ -339,7 +339,7 @@
$SQL .= "AND custbranch.brname " . LIKE . " '%" . $SearchString . "%'
AND custbranch.branchcode " . LIKE . " '%" . mb_strtoupper(trim($_POST['CustCode'])) . "%'
AND custbranch.phoneno " . LIKE . " '%" . trim($_POST['CustPhone']) . "%'";
-
+
} /*one of keywords or custcode was more than a zero length string */
if ($_SESSION['SalesmanLogin']!=''){
$SQL .= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'";
@@ -573,9 +573,9 @@
<td>' . _('Part of the Branch Phone Number') . ':</td>
<td><input tabindex="3" type="text" name="CustPhone" size="15" maxlength="18" title="' . _('Enter a part of a customer\'s phone number that you wish to search for then click the Search Now button to find matching customers') . '"/></td>
</tr>
-
+
</table>
-
+
<div class="centre">
<input tabindex="4" type="submit" name="SearchCust" value="' . _('Search Now') . '" />
<input tabindex="5" type="submit" name="reset" value="' . _('Reset') . '" />
@@ -706,13 +706,13 @@
$RawMaterialSellable = '';
}
if(!empty($_POST['CustItemFlag'])){
- $IncludeCustItem = " INNER JOIN custitem ON custitem.stockid=stockmaster.stockid
+ $IncludeCustItem = " INNER JOIN custitem ON custitem.stockid=stockmaster.stockid
AND custitem.debtorno='" . $_SESSION['Items'.$identifier]->DebtorNo . "'";
}else{
- $IncludeCustItem = " LEFT OUTER JOIN custitem ON custitem.stockid=stockmaster.stockid
+ $IncludeCustItem = " LEFT OUTER JOIN custitem ON custitem.stockid=stockmaster.stockid
AND custitem.debtorno='" . $_SESSION['Items'.$identifier]->DebtorNo . "'";
}
-
+
if ($_POST['Keywords']!='' AND $_POST['StockCode']=='') {
$msg='<div class="page_help_text">' . _('Order Item description has been used in search') . '.</div>';
} elseif ($_POST['StockCode']!='' AND $_POST['Keywords']=='') {
@@ -1495,9 +1495,9 @@
$DemandQty = 0;
}
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
- $PurchQty = GetQuantityOnOrderDueToPurchaseOrders($myrow['stockid'], "", $db);
+ $PurchQty = GetQuantityOnOrderDueToPurchaseOrders($myrow['stockid'], '');
// Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
- $WoQty = GetQuantityOnOrderDueToWorkOrders($myrow['stockid'], "", $db);
+ $WoQty = GetQuantityOnOrderDueToWorkOrders($myrow['stockid'], '');
if ($k==1){
echo '<tr class="EvenTableRows">';
@@ -1584,7 +1584,7 @@
echo '" /></td>
<td><input type="checkbox" name="RawMaterialFlag" value="M" />'._('Raw material flag').' <br/><span class="dpTbl">'._('If checked, Raw material will be shown on search result').'</span> </td>
- <td><input type="checkbox" name="CustItemFlag" value="C" />'._('Customer Item flag').' <br/><span class="dpTbl">'._('If checked, only items for this customer will show').'</span> </td>
+ <td><input type="checkbox" name="CustItemFlag" value="C" />'._('Customer Item flag').' <br/><span class="dpTbl">'._('If checked, only items for this customer will show').'</span> </td>
</tr>';
echo '<tr>
@@ -1659,9 +1659,9 @@
}
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
- $PurchQty = GetQuantityOnOrderDueToPurchaseOrders($myrow['stockid'], "", $db);
+ $PurchQty = GetQuantityOnOrderDueToPurchaseOrders($myrow['stockid'], '');
// Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
- $WoQty = GetQuantityOnOrderDueToWorkOrders($myrow['stockid'], "", $db);
+ $WoQty = GetQuantityOnOrderDueToWorkOrders($myrow['stockid'], '');
if ($k==1){
echo '<tr class="EvenTableRows">';
@@ -1820,7 +1820,7 @@
ON custbranch.defaultlocation=locations.loccode
WHERE custbranch.branchcode='" . $_SESSION['Items'.$identifier]->Branch . "'
AND custbranch.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'";
-
+
$ErrMsg = _('The customer branch record of the customer selected') . ': ' . $_SESSION['Items'.$identifier]->DebtorNo . ' ' . _('cannot be retrieved because');
$DbgMsg = _('SQL used to retrieve the branch details was') . ':';
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg);
Modified: trunk/SelectProduct.php
===================================================================
--- trunk/SelectProduct.php 2014-10-05 13:14:49 UTC (rev 6907)
+++ trunk/SelectProduct.php 2014-10-06 05:13:27 UTC (rev 6908)
@@ -263,11 +263,11 @@
WHERE stockid = '" . $StockID . "'", $db);
$QOHRow = DB_fetch_row($QOHResult);
$QOH = locale_number_format($QOHRow[0], $myrow['decimalplaces']);
-
+
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO = GetQuantityOnOrderDueToPurchaseOrders($StockID, "", $db);
+ $QOO = GetQuantityOnOrderDueToPurchaseOrders($StockID, '');
// Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO += GetQuantityOnOrderDueToWorkOrders($StockID, "", $db);
+ $QOO += GetQuantityOnOrderDueToWorkOrders($StockID, '');
$QOO = locale_number_format($QOO, $myrow['decimalplaces']);
break;
Modified: trunk/StockLocStatus.php
===================================================================
--- trunk/StockLocStatus.php 2014-10-05 13:14:49 UTC (rev 6907)
+++ trunk/StockLocStatus.php 2014-10-06 05:13:27 UTC (rev 6908)
@@ -240,9 +240,9 @@
}
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO = GetQuantityOnOrderDueToPurchaseOrders($StockID, $myrow['loccode'], $db);
+ $QOO = GetQuantityOnOrderDueToPurchaseOrders($StockID, $myrow['loccode']);
// Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO += GetQuantityOnOrderDueToWorkOrders($StockID, $myrow['loccode'], $db);
+ $QOO += GetQuantityOnOrderDueToWorkOrders($StockID, $myrow['loccode']);
if (($_POST['BelowReorderQuantity']=='Below' AND ($myrow['quantity']-$myrow['reorderlevel']-$DemandQty)<0)
OR $_POST['BelowReorderQuantity']=='All' OR $_POST['BelowReorderQuantity']=='NotZero'
Modified: trunk/StockStatus.php
===================================================================
--- trunk/StockStatus.php 2014-10-05 13:14:49 UTC (rev 6907)
+++ trunk/StockStatus.php 2014-10-06 05:13:27 UTC (rev 6908)
@@ -177,9 +177,9 @@
if ($Its_A_KitSet_Assembly_Or_Dummy == False){
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO = GetQuantityOnOrderDueToPurchaseOrders($StockID, $myrow['loccode'], $db);
+ $QOO = GetQuantityOnOrderDueToPurchaseOrders($StockID, $myrow['loccode']);
// Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO += GetQuantityOnOrderDueToWorkOrders($StockID, $myrow['loccode'], $db);
+ $QOO += GetQuantityOnOrderDueToWorkOrders($StockID, $myrow['loccode']);
$InTransitSQL="SELECT SUM(shipqty-recqty) as intransit
FROM loctransfers
Modified: trunk/TopItems.php
===================================================================
--- trunk/TopItems.php 2014-10-05 13:14:49 UTC (rev 6907)
+++ trunk/TopItems.php 2014-10-06 05:13:27 UTC (rev 6908)
@@ -132,7 +132,7 @@
debtorsmaster.currcode,
fromstkloc,
stockmaster.decimalplaces
- FROM salesorderdetails, salesorders INNER JOIN locationusers ON locationusers.loccode=salesorders.fromstkloc AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1,
+ FROM salesorderdetails, salesorders INNER JOIN locationusers ON locationusers.loccode=salesorders.fromstkloc AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1,
debtorsmaster,stockmaster, currencies
WHERE salesorderdetails.orderno = salesorders.orderno
AND salesorderdetails.stkcode = stockmaster.stockid
@@ -202,9 +202,9 @@
$QOH = $QOHRow[0];
// Get the QOO due to Purchase orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO = GetQuantityOnOrderDueToPurchaseOrders($myrow['stkcode'], "", $db);
- // Get the QOO dues to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
- $QOO += GetQuantityOnOrderDueToWorkOrders($myrow['stkcode'], "", $db);
+ $QOO = GetQuantityOnOrderDueToPurchaseOrders($myrow['stkcode'], '');
+ // Get the QOO due to Work Orders for all locations. Function defined in SQL_CommonFunctions.inc
+ $QOO += GetQuantityOnOrderDueToWorkOrders($myrow['stkcode'], '');
break;
}
if(is_numeric($QOH) and is_numeric($QOO)){
Modified: trunk/includes/SQL_CommonFunctions.inc
===================================================================
--- trunk/includes/SQL_CommonFunctions.inc 2014-10-05 13:14:49 UTC (rev 6907)
+++ trunk/includes/SQL_CommonFunctions.inc 2014-10-06 05:13:27 UTC (rev 6908)
@@ -276,8 +276,8 @@
ON bom.component=stockmaster.stockid
WHERE bom.parent='" . $StockID . "'
AND bom.loccode ='" . $LocCode . "'
- AND bom.effectiveafter<='" . Date('Y-m-d') . "'
- AND bom.effectiveto>='" . Date('Y-m-d') . "'
+ AND bom.effectiveafter<='" . Date('Y-m-d') . "'
+ AND bom.effectiveto>='" . Date('Y-m-d') . "'
AND stockmaster.mbflag<>'G'
AND bom.component NOT IN (
SELECT stockid
@@ -373,7 +373,10 @@
If Location is empty, it returns the QOO for all locations
If location is NOT empty, returns the QOO for that specific location.
*/
-function GetQuantityOnOrderDueToPurchaseOrders($StockID, $Location, $db){
+function GetQuantityOnOrderDueToPurchaseOrders($StockID, $Location){
+
+ global $db;
+
if ($Location == ""){
// All locations to be considered
$WhereLocation = "";
@@ -385,12 +388,12 @@
}
$SQL="SELECT SUM(purchorderdetails.quantityord -purchorderdetails.quantityrecd) AS QtyOnOrder
- FROM purchorders
+ FROM purchorders
INNER JOIN purchorderdetails
ON purchorders.orderno=purchorderdetails.orderno
- INNER JOIN locationusers
- ON locationusers.loccode=purchorders.intostocklocation
- AND locationusers.userid='" . $_SESSION['UserID'] . "'
+ INNER JOIN locationusers
+ ON locationusers.loccode=purchorders.intostocklocation
+ AND locationusers.userid='" . $_SESSION['UserID'] . "'
AND locationusers.canview=1
WHERE purchorderdetails.itemcode='" . $StockID . "'
AND purchorderdetails.completed = 0
@@ -399,7 +402,7 @@
AND purchorders.status<>'Rejected'
AND purchorders.status<>'Completed'" .
$WhereLocation;
-
+
$QOOResult = DB_query($SQL, $db, $ErrMsg);
if (DB_num_rows($QOOResult) == 0) {
$QOO = 0;
@@ -415,29 +418,32 @@
If Location is empty, it returns the QOO for all locations
If location is NOT empty, returns the QOO for that specific location.
*/
-function GetQuantityOnOrderDueToWorkOrders($StockID, $Location, $db){
- if ($Location == ""){
+function GetQuantityOnOrderDueToWorkOrders($StockID, $Location){
+
+ global $db;
+
+ if ($Location == ''){
// All locations to be considered
- $WhereLocation = "";
+ $WhereLocation = '';
$ErrMsg = _('The quantity on order due to work orders for') . ' ' . $StockID . ' ' . _('to be received into all locations cannot be retrieved because');
}else{
// Just 1 location to consider
$WhereLocation = " AND workorders.loccode='" . $Location . "'";
$ErrMsg = _('The quantity on order due to work orders for') . ' ' . $StockID . ' ' . _('to be received into') . ' ' . $Location . ' ' . _('cannot be retrieved because');
}
-
+
$SQL="SELECT SUM(woitems.qtyreqd-woitems.qtyrecd) AS qtywo
- FROM woitems
+ FROM woitems
INNER JOIN workorders
ON woitems.wo=workorders.wo
- INNER JOIN locationusers
- ON locationusers.loccode=workorders.loccode
- AND locationusers.userid='" . $_SESSION['UserID'] . "'
+ INNER JOIN locationusers
+ ON locationusers.loccode=workorders.loccode
+ AND locationusers.userid='" . $_SESSION['UserID'] . "'
AND locationusers.canview=1
WHERE workorders.closed=0
AND woitems.stockid='" . $StockID . "'" .
$WhereLocation;
-
+
$QOOResult = DB_query($SQL, $db, $ErrMsg);
if (DB_num_rows($QOOResult) == 0) {
$QOO = 0;
|