|
From: <dai...@us...> - 2014-05-03 00:12:45
|
Revision: 6703
http://sourceforge.net/p/web-erp/reponame/6703
Author: daintree
Date: 2014-05-03 00:12:42 +0000 (Sat, 03 May 2014)
Log Message:
-----------
StockCost update now allows manufactured item cost updates
Modified Paths:
--------------
trunk/StockCostUpdate.php
trunk/doc/Change.log
trunk/includes/FreightCalculation.inc
trunk/sql/mysql/upgrade4.11-4.12.sql
Modified: trunk/StockCostUpdate.php
===================================================================
--- trunk/StockCostUpdate.php 2014-04-30 17:31:08 UTC (rev 6702)
+++ trunk/StockCostUpdate.php 2014-05-03 00:12:42 UTC (rev 6703)
@@ -117,17 +117,23 @@
$myrow = DB_fetch_array($result);
-echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">';
-echo '<div>';
-echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
+echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">
+ <div>
+ <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />
+ <table cellpadding="2" class="selection">
+ <tr>
+ <th colspan="2">' . _('Item Code') . ':<input type="text" name="StockID" value="' . $StockID . '" maxlength="20" /><input type="submit" name="Show" value="' . _('Show Cost Details') . '" /></th>
+ </tr>
+ <tr>
+ <th colspan="2">' . $StockID . ' - ' . $myrow['description'] . '</th>
+ </tr>
+ <tr>
+ <th colspan="2">' . _('Total Quantity On Hand') . ': ' . $myrow['totalqoh'] . ' ' . $myrow['units'] . '</th>
+ </tr>
+ <tr>
+ <th colspan="2">' . _('Last Cost update on') . ': ' . ConvertSQLDate($myrow['lastcostupdate']) . '</th>
+ </tr>';
-echo '<table cellpadding="2" class="selection">';
-echo '<tr><th colspan="2">' . _('Item Code') . ':<input type="text" name="StockID" value="' . $StockID . '" maxlength="20" />';
-echo '<input type="submit" name="Show" value="' . _('Show Cost Details') . '" /></th></tr>';
-echo '<tr><th colspan="2">' . $StockID . ' - ' . $myrow['description'] . '</th></tr>';
-echo '<tr><th colspan="2">' . _('Total Quantity On Hand') . ': ' . $myrow['totalqoh'] . ' ' . $myrow['units'] . '</th></tr>';
-echo '<tr><th colspan="2">' . _('Last Cost update on') . ': ' . ConvertSQLDate($myrow['lastcostupdate']) . '</th></tr>';
-
if (($myrow['mbflag']=='D' AND $myrow['stocktype'] != 'L')
OR $myrow['mbflag']=='A'
OR $myrow['mbflag']=='K'){
@@ -153,23 +159,24 @@
echo _('Last Cost') .':</td>
<td class="number">' . locale_number_format($myrow['lastcost'],$_SESSION['StandardCostDecimalPlaces']) . '</td></tr>';
-if (! in_array($UpdateSecurity,$_SESSION['AllowedPageSecurityTokens'])){
- echo '<tr><td>' . _('Cost') . ':</td>
+if (! in_array($_SESSION['PageSecurityArray']['CostUpdate'],$_SESSION['AllowedPageSecurityTokens'])){
+ echo '<tr>
+ <td>' . _('Cost') . ':</td>
<td class="number">' . locale_number_format($myrow['materialcost']+$myrow['labourcost']+$myrow['overheadcost'],$_SESSION['StandardCostDecimalPlaces']) . '</td>
</tr>
</table>';
} else {
if ($myrow['mbflag']=='M'){
- echo '<tr><td><input type="hidden" name="MaterialCost" value="' . $myrow['materialcost'] . '" />';
- echo _('Standard Material Cost Per Unit') .':</td>
- <td class="number">' . locale_number_format($myrow['materialcost'],$_SESSION['StandardCostDecimalPlaces']) . '</td>
- </tr>';
echo '<tr>
+ <td>' . _('Standard Material Cost Per Unit') .':</td>
+ <td class="number"><input type="text" class="number" name="MaterialCost" value="' . locale_number_format($myrow['materialcost'],$_SESSION['StandardCostDecimalPlaces']) . '" /></td>
+ </tr>
+ <tr>
<td>' . _('Standard Labour Cost Per Unit') . ':</td>
<td class="number"><input type="text" class="number" name="LabourCost" value="' . locale_number_format($myrow['labourcost'],$_SESSION['StandardCostDecimalPlaces']) . '" /></td>
- </tr>';
- echo '<tr>
+ </tr>
+ <tr>
<td>' . _('Standard Overhead Cost Per Unit') . ':</td>
<td class="number"><input type="text" class="number" name="OverheadCost" value="' . locale_number_format($myrow['overheadcost'],$_SESSION['StandardCostDecimalPlaces']) . '" /></td>
</tr>';
Modified: trunk/doc/Change.log
===================================================================
--- trunk/doc/Change.log 2014-04-30 17:31:08 UTC (rev 6702)
+++ trunk/doc/Change.log 2014-05-03 00:12:42 UTC (rev 6703)
@@ -1,5 +1,7 @@
webERP Change Log
-29/4/2014 Exson: Make price matrix workable including GetPrice.inc, MainMenuLinksArray.php,SelectOrderItems_IntoCart.inc,PriceMatrix.php, SelectProduct.php,StockDispatch.php.
+
+3/5/14 Phil: StockCostUpdate.php now allows updates to manufactured items.
+29/4/14 Exson: Make price matrix workable including GetPrice.inc, MainMenuLinksArray.php,SelectOrderItems_IntoCart.inc,PriceMatrix.php, SelectProduct.php,StockDispatch.php.
20/04/14 Exson: Fixed undefined variable bugs in PDFWOPageHeader.inc and PDFWOPrint.php and remove some redundant codes in PDFWOPrint.php
17/04/14 Exson: Update zh_CN.utf8 translation.
09/04/14 Tim: Fixed the table sort failure bugs in SelectSalesOrder.php reported by Andrew Agaluski.
Modified: trunk/includes/FreightCalculation.inc
===================================================================
--- trunk/includes/FreightCalculation.inc 2014-04-30 17:31:08 UTC (rev 6702)
+++ trunk/includes/FreightCalculation.inc 2014-05-03 00:12:42 UTC (rev 6703)
@@ -5,21 +5,28 @@
Function CalcFreightCost ($TotalValue,
- $BrAdd2,
- $BrAdd3,
- $BrAdd4,
- $BrAdd5,
- $BrAddCountry,
- $TotalVolume,
- $TotalWeight,
- $FromLocation,
- $Currency,
- $db){
-
+ $BrAdd2,
+ $BrAdd3,
+ $BrAdd4,
+ $BrAdd5,
+ $BrAddCountry,
+ $TotalVolume,
+ $TotalWeight,
+ $FromLocation,
+ $Currency,
+ $db){
+
+
$ParameterError = FALSE;
if ((!isset($BrAdd2)) AND (!isset($BrAdd3)) AND (!isset($BrAdd4)) AND (!isset($BrAdd5)) AND (!isset($BrAddCountry))){
// No address field to detect destination ==> ERROR
$ParameterError = TRUE;
+ //echo '<br />Branch address 2 : ' . $BrAdd2;
+ //echo '<br />Branch address 3 : ' . $BrAdd3;
+ //echo '<br />Branch address 4 : ' . $BrAdd4;
+ //echo '<br />Branch address 5 : ' . $BrAdd5;
+ //echo '<br />Branch address country : ' . $BrAddCountry;
+
}
if ((!isset($TotalVolume)) AND (!isset($TotalWeight))){
// No weight AND no volume ==> ERROR
@@ -27,19 +34,23 @@
}
if (!isset($FromLocation)){
// No location FROM ==> ERROR
+ //echo '<br />From Location : ' . $FromLocation;
+
$ParameterError = TRUE;
}
if (!isset($Currency)){
// No Currency ==> ERROR
+ //echo '<br />Currency : ' . $Currency;
+
$ParameterError = TRUE;
}
if($ParameterError){
- return array ("NOT AVAILABLE", "NOT AVAILABLE");
+ return array ("NOT AVAILABLE", "NOT AVAILABLE");
}
// All parameters are OK, so we move ahead...
// make an array of all the words that could be the name of the destination zone (city, state or ZIP)
- $FindCity = explode(' ', $BrAdd2 . ' ' . $BrAdd3 . ' ' . $BrAdd4 . ' ' . $BrAdd5);
+ $FindCity = array($BrAdd2, $BrAdd3, $BrAdd4, $BrAdd5);
$sql = "SELECT shipperid,
kgrate * " . $TotalWeight . " AS kgcost,
@@ -48,24 +59,25 @@
minimumchg
FROM freightcosts
WHERE locationfrom = '" . $FromLocation . "'
- AND destinationcountry = '" . $BrAddCountry . "'
+ AND destinationcountry = '" . strtoupper($BrAddCountry) . "'
AND maxkgs > " . $TotalWeight . "
- AND maxcub >" . $TotalVolume . " ";
- if (($BrAdd2 != '') OR ($BrAdd3 != '') OR ($BrAdd4 != '') OR ($BrAdd5 != '')){
- // if there is some details of the address besides the country
- $sql .= " AND (";
- foreach ($FindCity as $City) {
- if (ucwords($City) != ''){
- $sql = $sql . " destination LIKE '" . ucwords($City) . "%' OR";
- }
- }
- if ($BrAddCountry != $CountriesArray[$_SESSION['CountryOfOperation']]){
- /* For international shipments empty destination (ANY) is allowed */
- $sql = $sql . " destination = '' OR";
- }
- $sql = mb_substr($sql, 0, mb_strrpos($sql,' OR')) . ')';
- }
-// echo ($sql);
+ AND maxcub >" . $TotalVolume . " AND (";
+
+ //ALL suburbs and cities are compared in upper case - so data in freight tables must be in upper case too
+ foreach ($FindCity as $City) {
+ if ( strtoupper($City) != ''){
+ $sql .= " destination LIKE '" . strtoupper($City) . "%' OR";
+ }
+ }
+ if ($BrAddCountry != $CountriesArray[$_SESSION['CountryOfOperation']]){
+ /* For international shipments empty destination (ANY) is allowed */
+ $sql .= " destination = '' OR";
+ }
+ $sql = mb_substr($sql, 0, mb_strrpos($sql,' OR')) . ')';
+
+ //echo $sql;
+
+
$CalcFreightCostResult = DB_query($sql,$db);
if (DB_error_no($db) !=0) {
echo _('The freight calculation for the destination city cannot be performed because') . ' - ' . DB_error_msg($db) . ' - ' . $sql;
@@ -84,27 +96,31 @@
$CalcFreightCost=$myrow['fixedprice'];
$CalcBestShipper =$myrow['shipperid'];
}
- } elseif ($myrow['cubcost'] > $myrow['kgcost'] && $myrow['cubcost'] > $myrow['minimumchg'] && $myrow['cubcost'] < $CalcFreightCost) {
+ } elseif ($myrow['cubcost'] > $myrow['kgcost'] && $myrow['cubcost'] > $myrow['minimumchg'] && $myrow['cubcost'] <= $CalcFreightCost) {
$CalcFreightCost=$myrow['cubcost'];
$CalcBestShipper =$myrow['shipperid'];
- } elseif ($myrow['kgcost']>$myrow['cubcost'] && $myrow['kgcost'] > $myrow['minimumchg'] && $myrow['kgcost'] < $CalcFreightCost) {
+ } elseif ($myrow['kgcost']>$myrow['cubcost'] && $myrow['kgcost'] > $myrow['minimumchg'] && $myrow['kgcost'] <= $CalcFreightCost) {
$CalcFreightCost=$myrow['kgcost'];
$CalcBestShipper =$myrow['shipperid'];
- } elseif ($myrow['minimumchg']< $CalcFreightCost){
+ } elseif ($myrow['minimumchg'] < $CalcFreightCost){
$CalcFreightCost=$myrow['minimumchg'];
$CalcBestShipper =$myrow['shipperid'];
}
+ //echo '<br /> calculated freight cost = ' . $CalcFreightCost;
}
} else {
$CalcFreightCost = "NOT AVAILABLE";
}
- if ($TotalValue >= $_SESSION['FreightChargeAppliesIfLessThan']){
+ if ($TotalValue >= $_SESSION['FreightChargeAppliesIfLessThan'] AND $_SESSION['FreightChargeAppliesIfLessThan']!=0){
+
+ //echo '<br />Freight should be charged on orders less than ' . $_SESSION['FreightChargeAppliesIfLessThan'];
+
/*Even though the order is over the freight free threshold - still need to calculate the best shipper to ensure get best deal*/
$CalcFreightCost =0;
}
@@ -118,7 +134,7 @@
$ExRate =1;
}
if ($CalcFreightCost != "NOT AVAILABLE"){
- $CalcFreightCost = $CalcFreightCost * $ExRate;
+ $CalcFreightCost *= $ExRate;
}
}
Modified: trunk/sql/mysql/upgrade4.11-4.12.sql
===================================================================
--- trunk/sql/mysql/upgrade4.11-4.12.sql 2014-04-30 17:31:08 UTC (rev 6702)
+++ trunk/sql/mysql/upgrade4.11-4.12.sql 2014-05-03 00:12:42 UTC (rev 6703)
@@ -7,6 +7,7 @@
INSERT INTO `scripts` (`script` ,`pagesecurity` ,`description` ) VALUES ('CustItem.php', '11', 'Customer Items');
ALTER TABLE `woitems` ADD `comments` LONGBLOB NULL DEFAULT NULL ;
ALTER TABLE `www_users` CHANGE `modulesallowed` `modulesallowed` VARCHAR( 25 ) NOT NULL;
+INSERT INTO scripts VALUES ('CostUpdate','10','NB Not a script but allows users to maintain item costs from withing StockCostUpdate.php');
CREATE TABLE `custitem` (
`debtorno` char(10) NOT NULL DEFAULT '',
`stockid` varchar(20) NOT NULL DEFAULT '',
@@ -30,6 +31,7 @@
ALTER table pricematrix ADD KEY stockid(`stockid`);
ALTER TABLE `debtortrans` CHANGE `consignment` `consignment` VARCHAR( 20 ) NOT NULL DEFAULT '';
ALTER TABLE `workorders` ADD `closecomments` LONGBLOB NULL DEFAULT NULL ;
+
UPDATE config SET confvalue='4.12' WHERE confname='VersionNumber';
|