From: <dai...@us...> - 2011-08-30 08:48:55
|
Revision: 4671 http://web-erp.svn.sourceforge.net/web-erp/?rev=4671&view=rev Author: daintree Date: 2011-08-30 08:48:48 +0000 (Tue, 30 Aug 2011) Log Message: ----------- Modified Paths: -------------- trunk/StockCostUpdate.php trunk/WorkOrderEntry.php trunk/WorkOrderReceive.php trunk/doc/Change.log trunk/includes/SQL_CommonFunctions.inc trunk/sql/mysql/upgrade4.05-4.06.sql Modified: trunk/StockCostUpdate.php =================================================================== --- trunk/StockCostUpdate.php 2011-08-28 09:25:31 UTC (rev 4670) +++ trunk/StockCostUpdate.php 2011-08-30 08:48:48 UTC (rev 4671) @@ -69,7 +69,8 @@ $SQL = "UPDATE stockmaster SET materialcost='" . $_POST['MaterialCost'] . "', labourcost='" . $_POST['LabourCost'] . "', overheadcost='" . $_POST['OverheadCost'] . "', - lastcost='" . $OldCost . "' + lastcost='" . $OldCost . "', + lastcostupdate ='" . Date('Y-m-d')."' WHERE stockid='" . $StockID . "'"; $ErrMsg = _('The cost details for the stock item could not be updated because'); @@ -94,6 +95,7 @@ overheadcost, mbflag, stocktype, + lastcostupdate, sum(quantity) as totalqoh FROM stockmaster INNER JOIN locstock ON stockmaster.stockid=locstock.stockid @@ -119,9 +121,10 @@ echo '<table cellpadding=2 class=selection>'; echo '<tr><th colspan=2>' . _('Item Code') . ':<input type="text" name="StockID" value="' . $StockID . '" 1 maxlength=20>'; -echo '<input type="submit" name="Show" VALUE="' . _('Show Cost Details') . '"></th></tr>'; +echo '<input type="submit" name="Show" value="' . _('Show Cost Details') . '"></th></tr>'; echo '<tr><th colspan=2><font color=navy size=2>' . $StockID . ' - ' . $myrow['description'] . '</font></th></tr>'; echo '<tr><th colspan=2><font color=navy size=2>'. _('Total Quantity On Hand') . ': ' . $myrow['totalqoh'] . ' ' . $myrow['units'] .'</font></th></tr>'; +echo '<tr><th colspan=2><font color=navy size=2>'. _('Last Cost update on') . ': ' . ConvertSQLDate($myrow['lastcostupdate']) .'</font></th></tr>'; if (($myrow['mbflag']=='D' AND $myrow['stocktype'] != 'L') OR $myrow['mbflag']=='A' @@ -139,28 +142,43 @@ exit; } -echo '<input type=hidden name=OldMaterialCost VALUE=' . $myrow['materialcost'] .'>'; -echo '<input type=hidden name=OldLabourCost VALUE=' . $myrow['labourcost'] .'>'; -echo '<input type=hidden name=OldOverheadCost VALUE=' . $myrow['overheadcost'] .">"; -echo '<input type=hidden name="QOH" VALUE=' . $myrow['totalqoh'] .'>'; +echo '<input type=hidden name="OldMaterialCost" value="' . $myrow['materialcost'] .'">'; +echo '<input type=hidden name="OldLabourCost" value="' . $myrow['labourcost'] .'">'; +echo '<input type=hidden name="OldOverheadCost" value="' . $myrow['overheadcost'] .'">'; +echo '<input type=hidden name="QOH" value="' . $myrow['totalqoh'] .'">'; -echo '<tr><td>' . _('Last Cost') .':</td><td class=number>' . number_format($myrow['lastcost'],2) . '</td></tr>'; +echo '<tr><td>' . _('Last Cost') .':</td> + <td class="number">' . number_format($myrow['lastcost'],$_SESSION['CompanyRecord']['decimalplaces']) . '</td></tr>'; if (! in_array($UpdateSecurity,$_SESSION['AllowedPageSecurityTokens'])){ - echo '<tr><td>' . _('Cost') . ':</td><td class=number>' . number_format($myrow['materialcost']+$myrow['labourcost']+$myrow['overheadcost'],2) . '</td></tr></table>'; + echo '<tr><td>' . _('Cost') . ':</td> + <td class="number">' . number_format($myrow['materialcost']+$myrow['labourcost']+$myrow['overheadcost'],$_SESSION['CompanyRecord']['decimalplaces']) . '</td> + </tr> + </table>'; } else { if ($myrow['mbflag']=='M'){ - echo '<input type=hidden name="MaterialCost" VALUE=' . $myrow['materialcost'] . '>'; - echo '<tr><td>' . _('Standard Material Cost Per Unit') .':</td><td class=number>' . number_format($myrow['materialcost'],4) . '</td></tr>'; - echo '<tr><td>' . _('Standard Labour Cost Per Unit') . ':</td><td class=number><input type="text" class="number" name="LabourCost" value=' . $myrow['labourcost'] . '></td></tr>'; - echo '<tr><td>' . _('Standard Overhead Cost Per Unit') . ':</td><td class=number><input type="text" class="number" name="OverheadCost" value=' . $myrow['overheadcost'] . '></td></tr>'; + echo '<input type=hidden name="MaterialCost" value=' . $myrow['materialcost'] . '>'; + echo '<tr><td>' . _('Standard Material Cost Per Unit') .':</td> + <td class="number">' . number_format($myrow['materialcost'],4) . '</td> + </tr>'; + echo '<tr> + <td>' . _('Standard Labour Cost Per Unit') . ':</td> + <td class="number"><input type="text" class="number" name="LabourCost" value=' . $myrow['labourcost'] . '></td> + </tr>'; + echo '<tr> + <td>' . _('Standard Overhead Cost Per Unit') . ':</td> + <td class="number"><input type="text" class="number" name="OverheadCost" value=' . $myrow['overheadcost'] . '></td> + </tr>'; } elseif ($myrow['mbflag']=='B' OR $myrow['mbflag']=='D') { - echo '<tr><td>' . _('Standard Cost') .':</td><td class=number><input type="text" class="number" name="MaterialCost" value=' . $myrow['materialcost'] . '></td></tr>'; + echo '<tr> + <td>' . _('Standard Cost') .':</td> + <td class="number"><input type="text" class="number" name="MaterialCost" value=' . $myrow['materialcost'] . '></td> + </tr>'; } else { - echo '<input type="hidden" name="LabourCost" VALUE=0>'; - echo '<input type="hidden" name="OverheadCost" VALUE=0>'; + echo '<input type="hidden" name="LabourCost" value=0>'; + echo '<input type="hidden" name="OverheadCost" value=0>'; } - echo '</table><br /><div class="centre"><input type="submit" name="UpdateData" VALUE="' . _('Update') . '"><br /><br />'; + echo '</table><br /><div class="centre"><input type="submit" name="UpdateData" value="' . _('Update') . '"><br /><br />'; } if ($myrow['mbflag']!='D'){ echo '<div class="centre"><a href="' . $rootpath . '/StockStatus.php?StockID=' . $StockID . '>' . _('Show Stock Status') . '</a>'; Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2011-08-28 09:25:31 UTC (rev 4670) +++ trunk/WorkOrderEntry.php 2011-08-30 08:48:48 UTC (rev 4671) @@ -173,76 +173,76 @@ $CheckItemResult = DB_query("SELECT mbflag, eoq, controlled - FROM stockmaster - WHERE stockid='" . $NewItem . "'", + FROM stockmaster + WHERE stockid='" . $NewItem . "'", $db); - if (DB_num_rows($CheckItemResult)==1){ - $CheckItemRow = DB_fetch_array($CheckItemResult); - if ($CheckItemRow['controlled']==1 AND $_SESSION['DefineControlledOnWOEntry']==1){ //need to add serial nos or batches to determine quantity - $EOQ = 0; - } else { - if (!isset($ReqQty)) { - $ReqQty=$CheckItemRow['eoq']; - } - $EOQ = $ReqQty; + if (DB_num_rows($CheckItemResult)==1){ + $CheckItemRow = DB_fetch_array($CheckItemResult); + if ($CheckItemRow['controlled']==1 AND $_SESSION['DefineControlledOnWOEntry']==1){ //need to add serial nos or batches to determine quantity + $EOQ = 0; + } else { + if (!isset($ReqQty)) { + $ReqQty=$CheckItemRow['eoq']; } - if ($CheckItemRow['mbflag']!='M'){ - prnMsg(_('The item selected cannot be added to a work order because it is not a manufactured item'),'warn'); - $InputError=true; - } - } else { - prnMsg(_('The item selected cannot be found in the database'),'error'); - $InputError = true; - } - $CheckItemResult = DB_query("SELECT stockid + $EOQ = $ReqQty; + } + if ($CheckItemRow['mbflag']!='M'){ + prnMsg(_('The item selected cannot be added to a work order because it is not a manufactured item'),'warn'); + $InputError=true; + } + } else { + prnMsg(_('The item selected cannot be found in the database'),'error'); + $InputError = true; + } + $CheckItemResult = DB_query("SELECT stockid FROM woitems WHERE stockid='" . $NewItem . "' AND wo='" .$_POST['WO'] . "'", $db); - if (DB_num_rows($CheckItemResult)==1){ - prnMsg(_('This item is already on the work order and cannot be added again'),'warn'); - $InputError=true; - } + if (DB_num_rows($CheckItemResult)==1){ + prnMsg(_('This item is already on the work order and cannot be added again'),'warn'); + $InputError=true; + } - if ($InputError==false){ + if ($InputError==false){ $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*bom.quantity) AS cost FROM stockmaster INNER JOIN bom ON stockmaster.stockid=bom.component WHERE bom.parent='" . $NewItem . "' AND bom.loccode='" . $_POST['StockLocation'] . "'", $db); - $CostRow = DB_fetch_row($CostResult); + $CostRow = DB_fetch_row($CostResult); if (is_null($CostRow[0]) OR $CostRow[0]==0){ - $Cost =0; - prnMsg(_('The cost of this item as accumulated from the sum of the component costs is nil. This could be because there is no bill of material set up ... you may wish to double check this'),'warn'); + $Cost =0; + prnMsg(_('The cost of this item as accumulated from the sum of the component costs is nil. This could be because there is no bill of material set up ... you may wish to double check this'),'warn'); } else { - $Cost = $CostRow[0]; + $Cost = $CostRow[0]; } if (!isset($EOQ)){ $EOQ=1; } - + $Result = DB_Txn_Begin($db); - + // insert parent item info $sql = "INSERT INTO woitems (wo, - stockid, - qtyreqd, - stdcost) - VALUES ( '" . $_POST['WO'] . "', - '" . $NewItem . "', - '" . $EOQ . "', - '" . $Cost . "' - )"; + stockid, + qtyreqd, + stdcost) + VALUES ( '" . $_POST['WO'] . "', + '" . $NewItem . "', + '" . $EOQ . "', + '" . $Cost . "' + )"; $ErrMsg = _('The work order item could not be added'); $result = DB_query($sql,$db,$ErrMsg); - + //Recursively insert real component requirements - see includes/SQL_CommonFunctions.in for function WoRealRequirements WoRealRequirements($db, $_POST['WO'], $_POST['StockLocation'], $NewItem); - + $result = DB_Txn_Commit($db); - + unset($NewItem); } //end if there were no input errors } //adding a new item to the work order @@ -331,17 +331,16 @@ foreach ($sql as $sql_stmt){ // echo '<br />' . $sql_stmt; $result = DB_query($sql_stmt,$db,$ErrMsg); - } prnMsg(_('The work order has been updated'),'success'); for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ - unset($_POST['OutputItem'.$i]); - unset($_POST['OutputQty'.$i]); - unset($_POST['QtyRecd'.$i]); - unset($_POST['NetLotSNRef'.$i]); - unset($_POST['HasWOSerialNos'.$i]); + unset($_POST['OutputItem'.$i]); + unset($_POST['OutputQty'.$i]); + unset($_POST['QtyRecd'.$i]); + unset($_POST['NetLotSNRef'.$i]); + unset($_POST['HasWOSerialNos'.$i]); } } } elseif (isset($_POST['delete'])) { @@ -382,12 +381,12 @@ echo '<p><a href="' . $rootpath . '/SelectWorkOrder.php">' . _('Select an existing outstanding work order') . '</a>'; unset($_POST['WO']); for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ - unset($_POST['OutputItem'.$i]); - unset($_POST['OutputQty'.$i]); - unset($_POST['QtyRecd'.$i]); - unset($_POST['NetLotSNRef'.$i]); - unset($_POST['HasWOSerialNos'.$i]); - } + unset($_POST['OutputItem'.$i]); + unset($_POST['OutputQty'.$i]); + unset($_POST['QtyRecd'.$i]); + unset($_POST['NetLotSNRef'.$i]); + unset($_POST['HasWOSerialNos'.$i]); + } include('includes/footer.inc'); exit; } @@ -399,13 +398,13 @@ echo '<br /><table class="selection">'; $sql="SELECT workorders.loccode, - requiredby, - startdate, - costissued, - closed - FROM workorders INNER JOIN locations - ON workorders.loccode=locations.loccode - WHERE workorders.wo='" . $_POST['WO'] . "'"; + requiredby, + startdate, + costissued, + closed + FROM workorders INNER JOIN locations + ON workorders.loccode=locations.loccode + WHERE workorders.wo='" . $_POST['WO'] . "'"; $WOResult = DB_query($sql,$db); if (DB_num_rows($WOResult)==1){ @@ -483,10 +482,10 @@ if (isset($WOResult)){ echo '<tr><td class="label">' . _('Accumulated Costs') . ':</td> - <td class=number>' . number_format($myrow['costissued'],2) . '</td></tr>'; + <td class="number">' . number_format($myrow['costissued'],2) . '</td></tr>'; } echo '</table> - <p><table class=selection>'; + <p><table class="selection">'; echo '<tr><th>' . _('Output Item') . '</th> <th>' . _('Qty Required') . '</th> <th>' . _('Qty Received') . '</th> @@ -507,13 +506,13 @@ echo '<td><input type="hidden" name="OutputItem' . $i . '" value="' . $_POST['OutputItem' .$i] . '">' . $_POST['OutputItem' . $i] . ' - ' . $_POST['OutputItemDesc' .$i] . '</td>'; if ($_POST['Controlled'.$i]==1 AND $_SESSION['DefineControlledOnWOEntry']==1){ - echo '<td style="text-align: right">' . $_POST['OutputQty' . $i] . '</td>'; - echo '<input type="hidden" name="OutputQty' . $i .'" value=' . $_POST['OutputQty' . $i] . '>'; + echo '<td class="number">' . $_POST['OutputQty' . $i] . '</td>'; + echo '<input type="hidden" name="OutputQty' . $i .'" value=' . $_POST['OutputQty' . $i] . ' />'; } else { - echo'<td><input type="text" class="number" name="OutputQty' . $i . '" value=' . $_POST['OutputQty' . $i] . ' size=10 maxlength=10></td>'; + echo'<td><input type="text" class="number" name="OutputQty' . $i . '" value=' . $_POST['OutputQty' . $i] . ' size="10" maxlength="10" /></td>'; } - echo '<td class=number><input type="hidden" name="RecdQty' . $i . '" value=' . $_POST['RecdQty' .$i] . '>' . $_POST['RecdQty' .$i] .'</td> - <td class=number>' . ($_POST['OutputQty' . $i] - $_POST['RecdQty' .$i]) . '</td>'; + echo '<td class="number"><input type="hidden" name="RecdQty' . $i . '" value=' . $_POST['RecdQty' .$i] . '>' . $_POST['RecdQty' .$i] .'</td> + <td class="number">' . ($_POST['OutputQty' . $i] - $_POST['RecdQty' .$i]) . '</td>'; if ($_POST['Controlled'.$i]==1){ echo '<td><input type="text" name="NextLotSNRef' .$i . '" value="' . $_POST['NextLotSNRef'.$i] . '"></td>'; if ($_SESSION['DefineControlledOnWOEntry']==1){ @@ -545,7 +544,7 @@ echo '<div class="centre"><br /><input type=submit name="submit" value="' . _('Update') . '">'; -echo '<br /><p><input type=submit name="delete" VALUE="' . _('Delete This Work Order') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');">'; +echo '<br /><p><input type=submit name="delete" value="' . _('Delete This Work Order') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');">'; echo '<br /></div>'; @@ -556,13 +555,14 @@ ORDER BY categorydescription"; $result1 = DB_query($SQL,$db); -echo '<table class=selection><tr><td>' . _('Select a stock category') . ':<select name="StockCat">'; +echo '<table class="selection"> + <tr><td>' . _('Select a stock category') . ':<select name="StockCat">'; if (!isset($_POST['StockCat'])){ - echo '<option selected VALUE="All">' . _('All') . '</option>'; + echo '<option selected value="All">' . _('All') . '</option>'; $_POST['StockCat'] ='All'; } else { - echo '<option VALUE="All">' . _('All') . '</option>'; + echo '<option value="All">' . _('All') . '</option>'; } while ($myrow1 = DB_fetch_array($result1)) { @@ -575,15 +575,16 @@ } ?> -</select> +</select></td> <td><?php echo _('Enter text extracts in the'); ?> <b><?php echo _('description'); ?></b>:</td> -<td><input type="Text" name="Keywords" size=20 maxlength=25 value="<?php if (isset($_POST['Keywords'])) echo $_POST['Keywords']; ?>"></td></tr> +<td><input type="Text" name="Keywords" size=20 maxlength=25 value="<?php if (isset($_POST['Keywords'])) echo $_POST['Keywords']; ?>"></td> +</tr> <tr><td></td> - <td><font SIZE 3><b><?php echo _('OR'); ?> </b></font><?php echo _('Enter extract of the'); ?> <b><?php echo _('Stock Code'); ?></b>:</td> - <td><input type="Text" name="StockCode" size=15 maxlength=18 value="<?php if (isset($_POST['StockCode'])) echo $_POST['StockCode']; ?>"></td> - </tr> - </table> - <br /><div class="centre"><input type=submit name="Search" value="<?php echo _('Search Now'); ?>"> + <td><font SIZE 3><b><?php echo _('OR'); ?> </b></font><?php echo _('Enter extract of the'); ?> <b><?php echo _('Stock Code'); ?></b>:</td> + <td><input type="text" name="StockCode" size="15" maxlength="18" value="<?php if (isset($_POST['StockCode'])) echo $_POST['StockCode']; ?>"></td> +</tr> +</table> +<br /><div class="centre"><input type="submit" name="Search" value="<?php echo _('Search Now'); ?>" /> <?php @@ -593,7 +594,7 @@ if (DB_num_rows($SearchResult)>1){ - echo '<table cellpadding=2 colspan=7 class=selection>'; + echo '<table cellpadding="2" colspan="7" class="selection">'; $TableHeader = '<tr><th>' . _('Code') . '</th> <th>' . _('Description') . '</th> <th>' . _('Units') . '</th></tr>'; @@ -609,7 +610,7 @@ if (!in_array($myrow['stockid'],$ItemCodes)){ if (function_exists('imagecreatefrompng') ){ - $ImageSource = '<img src="GetStockImage.php?SID&automake=1&textcolor=FFFFFF&bgcolor=CCCCCC&StockID=' . urlencode($myrow['stockid']). '&text=&width=64&height=64">'; + $ImageSource = '<img src="GetStockImage.php?automake=1&textcolor=FFFFFF&bgcolor=CCCCCC&StockID=' . urlencode($myrow['stockid']). '&text=&width=64&height=64">'; } else { if(file_exists($_SERVER['DOCUMENT_ROOT'] . $rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg')) { $ImageSource = '<img src="' .$_SERVER['DOCUMENT_ROOT'] . $rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg">'; Modified: trunk/WorkOrderReceive.php =================================================================== --- trunk/WorkOrderReceive.php 2011-08-28 09:25:31 UTC (rev 4670) +++ trunk/WorkOrderReceive.php 2011-08-30 08:48:48 UTC (rev 4671) @@ -133,19 +133,19 @@ if ($_SESSION['ProhibitNegativeStock']==1){ /*Now look for autoissue components that would go negative */ - $SQL = "SELECT worequirements.stockid, - stockmaster.description, - locstock.quantity-(" . $QuantityReceived . "*worequirements.qtypu) AS qtyleft - FROM worequirements - INNER JOIN stockmaster - ON worequirements.stockid=stockmaster.stockid - INNER JOIN locstock - ON worequirements.stockid=locstock.stockid - WHERE worequirements.wo='" . $_POST['WO'] . "' - AND worequirements.parentstockid='" .$_POST['StockID'] . "' - AND locstock.loccode='" . $WORow['loccode'] . "' - AND stockmaster.mbflag <>'D' - AND worequirements.autoissue=1"; + $SQL = "SELECT worequirements.stockid, + stockmaster.description, + locstock.quantity-(" . $QuantityReceived . "*worequirements.qtypu) AS qtyleft + FROM worequirements + INNER JOIN stockmaster + ON worequirements.stockid=stockmaster.stockid + INNER JOIN locstock + ON worequirements.stockid=locstock.stockid + WHERE worequirements.wo='" . $_POST['WO'] . "' + AND worequirements.parentstockid='" .$_POST['StockID'] . "' + AND locstock.loccode='" . $WORow['loccode'] . "' + AND stockmaster.mbflag <>'D' + AND worequirements.autoissue=1"; $ErrMsg = _('Could not retrieve the component quantity left at the location once the component items are issued to the work order (for the purposes of checking that stock will not go negative) because'); $Result = DB_query($SQL,$db,$ErrMsg); @@ -260,6 +260,7 @@ } $SQL = "UPDATE stockmaster SET + lastcostupdate='" . Date('Y-m-d') . "', materialcost='" . $Cost . "', labourcost='" . $ItemCostRow['labourcost'] . "', overheadcost='" . $ItemCostRow['overheadcost'] . "', Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2011-08-28 09:25:31 UTC (rev 4670) +++ trunk/doc/Change.log 2011-08-30 08:48:48 UTC (rev 4671) @@ -1,5 +1,7 @@ webERP Change Log +29/8/11 Ricard: Updated lastcostupdate in StockCostUpdate.php +29/8/11 Phil: Reinstated stockmaster.lastcostupdate field - added update to lastcostupdate in WorkOrderReceive.php 27/8/11 Phil: WorkOrderIssue.php now allows issue of 0 cost items to the work order - in the event that customer supplied product needs to be included in a work order and the quantities maintained for accountability to the customer 26/8/11 Pablo Martin: Fixed bugs in ConnectDB_mysql.inc in DB_Txn_Commit and DB_Txn_Begin was using msql functions not mysql functions!! 23/8/11 Phil: Added BuyerName to Delivery Details and the cart class Modified: trunk/includes/SQL_CommonFunctions.inc =================================================================== --- trunk/includes/SQL_CommonFunctions.inc 2011-08-28 09:25:31 UTC (rev 4670) +++ trunk/includes/SQL_CommonFunctions.inc 2011-08-30 08:48:48 UTC (rev 4671) @@ -252,7 +252,7 @@ // remember, 'G' is for ghost (phantom part type) // all components should be referenced to the initial parent - if ($ParentID == "") { + if ($ParentID == '') { $ParentID = $StockID; } Modified: trunk/sql/mysql/upgrade4.05-4.06.sql =================================================================== --- trunk/sql/mysql/upgrade4.05-4.06.sql 2011-08-28 09:25:31 UTC (rev 4670) +++ trunk/sql/mysql/upgrade4.05-4.06.sql 2011-08-30 08:48:48 UTC (rev 4671) @@ -1,2 +1,3 @@ ALTER TABLE stockmaster DROP lastcurcostdate; +ALTER TABLE stockmaster ADD lastcostupdate DATE NOT NULL; UPDATE config SET confvalue='4.05.1' WHERE confname='VersionNumber'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |