|
From: <dai...@us...> - 2014-06-02 03:40:54
|
Revision: 6743
http://sourceforge.net/p/web-erp/reponame/6743
Author: daintree
Date: 2014-06-02 03:40:49 +0000 (Mon, 02 Jun 2014)
Log Message:
-----------
fix WO entry costing calculations to take into account BOM effectivity dates
Modified Paths:
--------------
trunk/SystemParameters.php
trunk/WorkOrderEntry.php
trunk/includes/SQL_CommonFunctions.inc
Modified: trunk/SystemParameters.php
===================================================================
--- trunk/SystemParameters.php 2014-06-02 03:25:01 UTC (rev 6742)
+++ trunk/SystemParameters.php 2014-06-02 03:40:49 UTC (rev 6743)
@@ -905,7 +905,7 @@
echo '<tr style="outline: 1px solid"><td>' . _('Wiki application') . ':</td>
<td><select name="X_WikiApp">';
for ($i=0; $i < sizeof($WikiApplications); $i++ ) {
- echo '<option '.($_SESSION['WikiApp'] == $WikiApplications[$i] ? 'selected="selected" ' : '').'value="'.$WikiApplications[$i].'">' . $WikiApplications[$i] . '</option>';
+ echo '<option '.($_SESSION['WikiApp'] == $i ? 'selected="selected" ' : '').'value="'. $i .'">' . $WikiApplications[$i] . '</option>';
}
echo '</select></td>
<td>' . _('This feature makes webERP show links to a free form company knowledge base using a wiki. This allows sharing of important company information - about customers, suppliers and products and the set up of work flow menus and/or company procedures documentation') . '</td></tr>';
Modified: trunk/WorkOrderEntry.php
===================================================================
--- trunk/WorkOrderEntry.php 2014-06-02 03:25:01 UTC (rev 6742)
+++ trunk/WorkOrderEntry.php 2014-06-02 03:40:49 UTC (rev 6743)
@@ -271,7 +271,7 @@
ON stockmaster.stockid=bom.component
WHERE bom.parent='" . $NewItem . "'
AND bom.loccode='" . $_POST['StockLocation'] . "'
- AND bom.effectivefrom<='" . Date('Y-m-d') . "'
+ AND bom.effectiveafter<='" . Date('Y-m-d') . "'
AND bom.effectiveto>='" . Date('Y-m-d') . "'",
$db);
$CostRow = DB_fetch_array($CostResult);
@@ -374,7 +374,7 @@
INNER JOIN bom ON stockmaster.stockid=bom.component
WHERE bom.parent='" . $_POST['OutputItem'.$i] . "'
AND bom.loccode='" . $_POST['StockLocation'] . "'
- AND bom.effectivefrom<='" . Date('Y-m-d') . "'
+ AND bom.effectiveafter<='" . Date('Y-m-d') . "'
AND bom.effectiveto>='" . Date('Y-m-d') . "'",
$db);
$CostRow = DB_fetch_array($CostResult);
@@ -612,7 +612,9 @@
}
}
echo '<td>';
- wikiLink('WorkOrder', $_POST['WO'] . $_POST['OutputItem' .$i]);
+ if ($_SESSION['WikiApp']!=0){
+ wikiLink('WorkOrder', $_POST['WO'] . $_POST['OutputItem' .$i]);
+ }
echo '</td>';
echo '</tr>';
if (isset($_POST['Controlled' . $i])) {
Modified: trunk/includes/SQL_CommonFunctions.inc
===================================================================
--- trunk/includes/SQL_CommonFunctions.inc 2014-06-02 03:25:01 UTC (rev 6742)
+++ trunk/includes/SQL_CommonFunctions.inc 2014-06-02 03:40:49 UTC (rev 6743)
@@ -209,18 +209,20 @@
/* Calculates the material cost of a bill of materials, given parent code*/
function BomMaterialCost($Parent, $db) {
- $SQL = "SELECT materialcost from stockmaster where stockid='".$Parent."'";
+ $SQL = "SELECT materialcost FROM stockmaster WHERE stockid='" . $Parent . "'";
$result1 = DB_query($SQL,$db);
$MyRow1 = DB_fetch_row($result1);
$OldCost = $MyRow1[0];
- $SQL = "SELECT sum(quantity) as qoh from locstock where stockid='".$Parent."'";
+ $SQL = "SELECT sum(quantity) as qoh from locstock where stockid='" . $Parent . "'";
$result1 = DB_query($SQL,$db);
$MyRow1 = DB_fetch_row($result1);
$QOH = $MyRow1[0];
$SQL = "SELECT Sum(stockmaster.materialcost*bom.quantity) AS SumOfmaterialcost
FROM bom LEFT JOIN stockmaster
- ON bom.component = stockmaster.stockid
- WHERE bom.parent='". $Parent . "'";
+ ON bom.component = stockmaster.stockid
+ WHERE bom.parent='". $Parent . "'
+ AND bom.effectiveafter<='" . Date('Y-m-d') . "'
+ AND bom.effectiveto>='" . Date('Y-m-d') . "'";
$result = DB_query($SQL,$db);
$MyRow = DB_fetch_row($result);
$MaterialCost = $MyRow[0];
@@ -274,6 +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 stockmaster.mbflag<>'G'
AND bom.component NOT IN (
SELECT stockid
@@ -300,6 +304,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 stockmaster.mbflag<>'G'
AND bom.component IN (
SELECT stockid
@@ -322,6 +328,8 @@
ON bom.component=stockmaster.stockid
WHERE parent='" . $StockID . "'
AND loccode ='" . $LocCode . "'
+ AND bom.effectiveafter<='" . Date('Y-m-d') . "'
+ AND bom.effectiveto>='" . Date('Y-m-d') . "'
AND stockmaster.mbflag='G'";
$result = DB_query($sql, $db);
while ($MyRow=DB_fetch_array($result)) {
|