From: <tim...@us...> - 2010-11-05 11:08:05
|
Revision: 4142 http://web-erp.svn.sourceforge.net/web-erp/?rev=4142&view=rev Author: tim_schofield Date: 2010-11-05 11:07:59 +0000 (Fri, 05 Nov 2010) Log Message: ----------- Converted field name to lower case for consistency Modified Paths: -------------- trunk/PurchData.php trunk/doc/Change.log.html Modified: trunk/PurchData.php =================================================================== --- trunk/PurchData.php 2010-11-05 11:03:04 UTC (rev 4141) +++ trunk/PurchData.php 2010-11-05 11:07:59 UTC (rev 4142) @@ -80,7 +80,7 @@ supplierdescription, suppliers_partno, leadtime, - MinOrderQty, + minorderqty, preferred) VALUES ('" . $SupplierID . "', '" . $StockID . "', @@ -107,7 +107,7 @@ supplierdescription='" . $_POST['SupplierDescription'] . "', suppliers_partno='" . $_POST['SupplierCode'] . "', leadtime='" . $_POST['LeadTime'] . "', - MinOrderQty='" . $_POST['MinOrderQty'] . "', + minorderqty='" . $_POST['MinOrderQty'] . "', preferred='" . $_POST['Preferred'] . "' WHERE purchdata.stockid='".$StockID."' AND purchdata.supplierno='".$SupplierID."' @@ -156,7 +156,7 @@ purchdata.supplierdescription, purchdata.leadtime, purchdata.suppliers_partno, - purchdata.MinOrderQty, + purchdata.minorderqty, purchdata.preferred FROM purchdata INNER JOIN suppliers ON purchdata.supplierno=suppliers.supplierid @@ -176,7 +176,7 @@ <th>' . _('Currency') . '</th> <th>' . _('Effective From') . '</th> <th>' . _('Supplier Unit') . '</th> - <th>' . _('Min Order Qty') . '</th> + <th>' . _('Min Order Qty') . '</th> <th>' . _('Lead Time') . '</th> <th>' . _('Preferred') . '</th> </tr>'; @@ -209,7 +209,7 @@ <td>%s</td> <td><a href='%s?%s&StockID=%s&SupplierID=%s&Edit=1&EffectiveFrom=%s'>" . _('Edit') . "</a></td> <td><a href='%s?%s&StockID=%s&SupplierID=%s&Delete=1&EffectiveFrom=%s' onclick=\"return confirm('" . _('Are you sure you wish to delete this suppliers price?') . "');\">" . _('Delete') . "</a></td> - </tr>", $myrow['suppname'], number_format($myrow['price'], 3), $myrow['currcode'], ConvertSQLDate($myrow['effectivefrom']), $myrow['unitname'],$myrow['MinOrderQty'], $myrow['leadtime'], $DisplayPreferred, $_SERVER['PHP_SELF'], SID, $StockID, $myrow['supplierno'], $myrow['effectivefrom'], $_SERVER['PHP_SELF'], SID, $StockID, $myrow['supplierno'], $myrow['effectivefrom']); + </tr>", $myrow['suppname'], number_format($myrow['price'], 3), $myrow['currcode'], ConvertSQLDate($myrow['effectivefrom']), $myrow['unitname'],$myrow['minorderqty'], $myrow['leadtime'], $DisplayPreferred, $_SERVER['PHP_SELF'], SID, $StockID, $myrow['supplierno'], $myrow['effectivefrom'], $_SERVER['PHP_SELF'], SID, $StockID, $myrow['supplierno'], $myrow['effectivefrom']); } //end of while loop echo '</table><br/>'; if ($CountPreferreds > 1) { @@ -364,7 +364,7 @@ purchdata.leadtime, purchdata.conversionfactor, purchdata.suppliers_partno, - purchdata.MinOrderQty, + purchdata.minorderqty, purchdata.preferred, stockmaster.units FROM purchdata INNER JOIN suppliers @@ -386,7 +386,7 @@ $_POST['LeadTime'] = $myrow['leadtime']; $_POST['ConversionFactor'] = $myrow['conversionfactor']; $_POST['Preferred'] = $myrow['preferred']; - $_POST['MinOrderQty'] = $myrow['MinOrderQty']; + $_POST['MinOrderQty'] = $myrow['minorderqty']; $_POST['SupplierCode'] = $myrow['suppliers_partno']; $stockuom=$myrow['units']; } Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-05 11:03:04 UTC (rev 4141) +++ trunk/doc/Change.log.html 2010-11-05 11:07:59 UTC (rev 4142) @@ -1,8 +1,9 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> -<p>02/11/10 Tim: SelectProduct.php. Change the standard order quantities to agree with Minimum order qty</p> -<p>02/11/10 Tim: PurchData.php. Make the Minimum order quantity field numeric only</p> -<p>02/11/10 Poul Bjerre-Jensen: SelectProduct.php,PurchData.php. Add in Minimum order quantity to Purchasing data</p> +<p>05/11/10 Tim: PurchData.php. Converted field name to lower case for consistency</p> +<p>05/11/10 Tim: SelectProduct.php. Change the standard order quantities to agree with Minimum order qty</p> +<p>05/11/10 Tim: PurchData.php. Make the Minimum order quantity field numeric only</p> +<p>05/11/10 Poul Bjerre-Jensen: SelectProduct.php,PurchData.php. Add in Minimum order quantity to Purchasing data</p> <p>02/11/10 Tim: SelectCustomer.php. Correction to work with debtors that have a - in the code</p> <p>31/10/10 Tim: SuppTransGLAnalysis.php. Minor bug fixes</p> <p>31/10/10 Tim: SuppTransGLAnalysis.php. Force the user to select a GL account code instaed of defaulting to first on the list</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-06 04:12:44
|
Revision: 4143 http://web-erp.svn.sourceforge.net/web-erp/?rev=4143&view=rev Author: daintree Date: 2010-11-06 04:12:36 +0000 (Sat, 06 Nov 2010) Log Message: ----------- added validation for item category properties Modified Paths: -------------- trunk/FixedAssetCategories.php trunk/FixedAssetItems.php trunk/PricesByCost.php trunk/StockCategories.php trunk/Stocks.php trunk/Z_ChangeStockCode.php trunk/doc/Change.log.html trunk/includes/PDFStarter.php trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/FixedAssetCategories.php =================================================================== --- trunk/FixedAssetCategories.php 2010-11-05 11:07:59 UTC (rev 4142) +++ trunk/FixedAssetCategories.php 2010-11-06 04:12:36 UTC (rev 4143) @@ -99,6 +99,9 @@ '"._('Depreciation Type')."', '1', '"._('Straight Line').","._('Reducing Balance')."', + '', + '', + '0', '0')"; $result=DB_query($sql,$db); $sql="INSERT INTO stockcatproperties @@ -108,6 +111,9 @@ '"._('Annual Depreciation Percentage')."', '0', '5', + '100', + '0', + '1', '0')"; $result=DB_query($sql,$db); } @@ -331,7 +337,7 @@ } else { echo '<option value='; } - echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; + echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')</option>'; } //end while loop DB_data_seek($PnLAccountsResult,0); Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-11-05 11:07:59 UTC (rev 4142) +++ trunk/FixedAssetItems.php 2010-11-06 04:12:36 UTC (rev 4143) @@ -241,9 +241,9 @@ /*now check that if the item is being changed to a kitset, there are no items on sales orders or purchase orders*/ if ($_POST['MBFlag']=='K') { $sql = "SELECT quantity-qtyinvoiced - FROM salesorderdetails - WHERE stkcode = '" . $StockID . "' - AND completed=0"; + FROM salesorderdetails + WHERE stkcode = '" . $StockID . "' + AND completed=0"; $result = DB_query($sql,$db); $ChkSalesOrds = DB_fetch_row($result); @@ -256,9 +256,9 @@ if ($_POST['MBFlag']=='K' OR $_POST['MBFlag']=='A' OR $_POST['MBFlag']=='D') { $sql = "SELECT quantityord-quantityrecd - FROM purchorderdetails - WHERE itemcode = '" . $StockID . "' - AND completed=0"; + FROM purchorderdetails + WHERE itemcode = '" . $StockID . "' + AND completed=0"; $result = DB_query($sql,$db); $ChkPurchOrds = DB_fetch_row($result); @@ -366,47 +366,47 @@ exit; } else { $sql = "INSERT INTO stockmaster ( - stockid, - description, - longdescription, - categoryid, - units, - mbflag, - eoq, - discontinued, - controlled, - serialised, - perishable, - volume, - kgs, - barcode, - discountcategory, - taxcatid, - decimalplaces, - appendfile, - shrinkfactor, - pansize) - VALUES ('" . $StockID . "', - '" . $_POST['Description'] . "', - '" . $_POST['LongDescription'] . "', - '" . $_POST['CategoryID'] . "', - '" . $_POST['Units'] . "', - '" . $_POST['MBFlag'] . "', - '" . $_POST['EOQ'] . "', - '" . $_POST['Discontinued'] . "', - '" . $_POST['Controlled'] . "', - '" . $_POST['Serialised']. "', - '" . $_POST['Perishable']. "', - '" . $_POST['Volume'] . "', - '" . $_POST['KGS'] . "', - '" . $_POST['BarCode'] . "', - '" . $_POST['DiscountCategory'] . "', - '" . $_POST['TaxCat'] . "', - '" . $_POST['DecimalPlaces']. "', - '" . $_POST['ItemPDF']. "', - '" . $_POST['ShrinkFactor'] . "', - '" . $_POST['Pansize'] . "' - )"; + stockid, + description, + longdescription, + categoryid, + units, + mbflag, + eoq, + discontinued, + controlled, + serialised, + perishable, + volume, + kgs, + barcode, + discountcategory, + taxcatid, + decimalplaces, + appendfile, + shrinkfactor, + pansize) + VALUES ('" . $StockID . "', + '" . $_POST['Description'] . "', + '" . $_POST['LongDescription'] . "', + '" . $_POST['CategoryID'] . "', + '" . $_POST['Units'] . "', + '" . $_POST['MBFlag'] . "', + '" . $_POST['EOQ'] . "', + '" . $_POST['Discontinued'] . "', + '" . $_POST['Controlled'] . "', + '" . $_POST['Serialised']. "', + '" . $_POST['Perishable']. "', + '" . $_POST['Volume'] . "', + '" . $_POST['KGS'] . "', + '" . $_POST['BarCode'] . "', + '" . $_POST['DiscountCategory'] . "', + '" . $_POST['TaxCat'] . "', + '" . $_POST['DecimalPlaces']. "', + '" . $_POST['ItemPDF']. "', + '" . $_POST['ShrinkFactor'] . "', + '" . $_POST['Pansize'] . "' + )"; $ErrMsg = _('The item could not be added because'); $DbgMsg = _('The SQL that was used to add the item failed was'); @@ -534,7 +534,6 @@ } } } - } if ($CancelDelete==0) { $result = DB_Txn_Begin($db); @@ -687,8 +686,7 @@ } else { $curr_val .= 'none'; } - while (false !== ($file = readdir($handle))) - { + while (false !== ($file = readdir($handle))) { $files[] = $file; } closedir($handle); @@ -867,13 +865,16 @@ } echo '<br><table class=selection><tr><th colspan="2">' . _('Depreciation Properties') . '</th></tr>'; $sql = "SELECT stkcatpropid, - label, - controltype, - defaultvalue - FROM stockcatproperties - WHERE categoryid ='" . $_POST['CategoryID'] . "' - AND reqatsalesorder =0 - ORDER BY stkcatpropid"; + label, + controltype, + defaultvalue, + maximumvalue, + minimumvalue, + numericvalue + FROM stockcatproperties + WHERE categoryid ='" . $_POST['CategoryID'] . "' + AND reqatsalesorder =0 + ORDER BY stkcatpropid"; $PropertiesResult = DB_query($sql,$db); $PropertyCounter = 0; @@ -882,10 +883,10 @@ while ($PropertyRow=DB_fetch_array($PropertiesResult)){ $PropValResult = DB_query("SELECT value FROM - stockitemproperties - WHERE stockid='" . $StockID . "' - AND stkcatpropid ='" . $PropertyRow['stkcatpropid'] . "'", - $db); + stockitemproperties + WHERE stockid='" . $StockID . "' + AND stkcatpropid ='" . $PropertyRow['stkcatpropid'] . "'", + $db); $PropValRow = DB_fetch_row($PropValResult); $PropertyValue = $PropValRow[0]; @@ -895,7 +896,12 @@ <td>'; switch ($PropertyRow['controltype']) { case 0; //textbox - echo '<input type="textbox" name="PropValue' . $PropertyCounter . '" size="20" maxlength="100" value="' . $PropertyValue . '">'; + if ($PropertyRow['numericvalue']==1) { + echo '<input type="textbox" class="number" name="PropValue' . $PropertyCounter . '" size="20" maxlength="100" value="' . $PropertyValue . '">'; + echo _('A number between') . ' ' . $PropertyRow['minimumvalue'] . ' ' . _('and') . ' ' . $PropertyRow['maximumvalue'] . ' ' . _('is expected'); + } else { + echo '<input type="textbox" name="PropValue' . $PropertyCounter . '" size="20" maxlength="100" value="' . $PropertyValue . '">'; + } break; case 1; //select box $OptionValues = explode(',',$PropertyRow['defaultvalue']); Modified: trunk/PricesByCost.php =================================================================== --- trunk/PricesByCost.php 2010-11-05 11:07:59 UTC (rev 4142) +++ trunk/PricesByCost.php 2010-11-06 04:12:36 UTC (rev 4143) @@ -1,5 +1,5 @@ <?php -/* $Id: PricesByCost.php 3566 2010-07-05 13:06:08Z tim_schofield $ */ +/* $Id$ */ // PricesByCost.php - $PageSecurity = 11; include ('includes/session.inc'); Modified: trunk/StockCategories.php =================================================================== --- trunk/StockCategories.php 2010-11-05 11:07:59 UTC (rev 4142) +++ trunk/StockCategories.php 2010-11-06 04:12:36 UTC (rev 4143) @@ -53,6 +53,18 @@ $InputError = 1; prnMsg(_('The stock type selected must be one of') . ' "D" - ' . _('Dummy item') . ', "L" - ' . _('Labour stock item') . ', "F" - ' . _('Finished product') . ' ' . _('or') . ' "M" - ' . _('Raw Materials'),'error'); } + for ($i=0;$i<=$_POST['PropertyCounter'];$i++){ + if (isset($_POST['PropNumeric' .$i]) and $_POST['PropNumeric' .$i] == true){ + if (!is_numeric($_POST['PropMinimum' .$i])){ + $InputError = 1; + prnMsg(_('The minimum value is expected to be a numeric value'),'error'); + } + if (!is_numeric($_POST['PropMaximum' .$i])){ + $InputError = 1; + prnMsg(_('The maximum value is expected to be a numeric value'),'error'); + } + } + } //check the properties are sensible if ($SelectedCategory AND $InputError !=1) { @@ -79,24 +91,38 @@ } else { $_POST['PropReqSO' .$i] =0; } + if (isset($_POST['PropNumeric' .$i]) and $_POST['PropNumeric' .$i] == true){ + $_POST['PropNumeric' .$i] =1; + } else { + $_POST['PropNumeric' .$i] =0; + } if ($_POST['PropID' .$i] =='NewProperty' AND strlen($_POST['PropLabel'.$i])>0){ $sql = "INSERT INTO stockcatproperties (categoryid, label, controltype, defaultvalue, + minimumvalue, + maximumvalue, + numericvalue, reqatsalesorder) VALUES ('" . $SelectedCategory . "', '" . $_POST['PropLabel' . $i] . "', " . $_POST['PropControlType' . $i] . ", '" . $_POST['PropDefault' .$i] . "', + '" . $_POST['PropMinimum' .$i] . "', + '" . $_POST['PropMaximum' .$i] . "', + '" . $_POST['PropNumeric' .$i] . "', " . $_POST['PropReqSO' .$i] . ')'; $ErrMsg = _('Could not insert a new category property for') . $_POST['PropLabel' . $i]; $result = DB_query($sql,$db,$ErrMsg); } elseif ($_POST['PropID' .$i] !='NewProperty') { //we could be amending existing properties $sql = "UPDATE stockcatproperties SET label ='" . $_POST['PropLabel' . $i] . "', - controltype = " . $_POST['PropControlType' . $i] . ", - defaultvalue = '" . $_POST['PropDefault' .$i] . "', - reqatsalesorder = " . $_POST['PropReqSO' .$i] . " + controltype = " . $_POST['PropControlType' . $i] . ", + defaultvalue = '" . $_POST['PropDefault' .$i] . "', + minimumvalue = '" . $_POST['PropMinimum' .$i] . "', + maximumvalue = '" . $_POST['PropMaximum' .$i] . "', + numericvalue = '" . $_POST['PropNumeric' .$i] . "', + reqatsalesorder = " . $_POST['PropReqSO' .$i] . " WHERE stkcatpropid =" . $_POST['PropID' .$i]; $ErrMsg = _('Updated the stock category property for') . ' ' . $_POST['PropLabel' . $i]; $result = DB_query($sql,$db,$ErrMsg); @@ -457,6 +483,9 @@ $TableHeader = '<tr><th>' . _('Property Label') . '</th> <th>' . _('Control Type') . '</th> <th>' . _('Default Value') . '</th> + <th>' . _('Numeric Value') . '</th> + <th>' . _('Minimum Value') . '</th> + <th>' . _('Maximum Value') . '</th> <th>' . _('Require in SO') . '</th> </tr>'; echo $TableHeader; @@ -490,7 +519,15 @@ echo '</select></td> <td><input type="textbox" name="PropDefault' . $PropertyCounter . '" value="' . $myrow['defaultvalue'] . '"></td> - <td align="center"><input type="checkbox" name="PropReqSO' . $PropertyCounter .'"'; + <td><input type="checkbox" name="PropNumeric' . $PropertyCounter . '"'; + + if ($myrow['numericvalue'] ==1){ + echo 'checked'; + } + echo '"></td> + <td><input type="textbox" "name="PropMinimum' . $PropertyCounter . '" value="' . $myrow['minimumvalue'] . '"></td> + <td><input type="textbox" name="PropMaximum' . $PropertyCounter . '" value="' . $myrow['maximumvalue'] . '"></td>'; + echo '<td align="center"><input type="checkbox" name="PropReqSO' . $PropertyCounter .'"'; if ($myrow['reqatsalesorder']==1){ echo 'checked'; @@ -511,6 +548,9 @@ echo '<option value=2>' . _('Check Box') . '</option>'; echo '</select></td> <td><input type="textbox" name="PropDefault' . $PropertyCounter . '"></td> + <td><input type="checkbox" name="PropNumeric' . $PropertyCounter . '"></td> + <td><input type="textbox" "name="PropMinimum' . $PropertyCounter . '"></td> + <td><input type="textbox" name="PropMaximum' . $PropertyCounter . '"></td> <td align="center"><input type="checkbox" name="PropReqSO' . $PropertyCounter .'"></td></tr>'; echo '</table>'; echo '<input type=hidden name="PropertyCounter" value=' . $PropertyCounter . '>'; Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2010-11-05 11:07:59 UTC (rev 4142) +++ trunk/Stocks.php 2010-11-06 04:12:36 UTC (rev 4143) @@ -942,7 +942,10 @@ $sql = "SELECT stkcatpropid, label, controltype, - defaultvalue + defaultvalue, + numericvalue, + minimumvalue, + maximumvalue FROM stockcatproperties WHERE categoryid ='" . $_POST['CategoryID'] . "' AND reqatsalesorder =0 @@ -976,7 +979,12 @@ <td>'; switch ($PropertyRow['controltype']) { case 0; //textbox - echo '<input type="textbox" name="PropValue' . $PropertyCounter . '" size="20" maxlength="100" value="' . $PropertyValue . '">'; + if ($PropertyRow['numericvalue']==1) { + echo '<input type="textbox" class="number" name="PropValue' . $PropertyCounter . '" size="20" maxlength="100" value="' . $PropertyValue . '">'; + echo _('A number between') . ' ' . $PropertyRow['minimumvalue'] . ' ' . _('and') . ' ' . $PropertyRow['maximumvalue'] . ' ' . _('is expected'); + } else { + echo '<input type="textbox" name="PropValue' . $PropertyCounter . '" size="20" maxlength="100" value="' . $PropertyValue . '">'; + } break; case 1; //select box $OptionValues = explode(',',$PropertyRow['defaultvalue']); Modified: trunk/Z_ChangeStockCode.php =================================================================== --- trunk/Z_ChangeStockCode.php 2010-11-05 11:07:59 UTC (rev 4142) +++ trunk/Z_ChangeStockCode.php 2010-11-06 04:12:36 UTC (rev 4143) @@ -1,324 +1,324 @@ -<?php -/* $Id: Z_ChangeStockCode.php 3293 2010-01-12 11:02:25Z tim_schofield $*/ -/*Script to Delete all sales transactions*/ - -$PageSecurity=15; -include ('includes/session.inc'); -$title = _('UTILITY PAGE Change A Stock Code'); -include('includes/header.inc'); -include('includes/SQL_CommonFunctions.inc'); - -if (isset($_POST['ProcessStockChange'])){ - - $_POST['NewStockID'] = strtoupper($_POST['NewStockID']); - -/*First check the stock code exists */ - $result=DB_query("SELECT stockid FROM stockmaster WHERE stockid='" . $_POST['OldStockID'] . "'",$db); - if (DB_num_rows($result)==0){ - prnMsg(_('The stock code') . ': ' . $_POST['OldStockID'] . ' ' . _('does not currently exist as a stock code in the system'),'error'); - include('includes/footer.inc'); - exit; - } - - if (ContainsIllegalCharacters($_POST['NewStockID'])){ - prnMsg(_('The new stock code to change the old code to contains illegal characters - no changes will be made'),'error'); - include('includes/footer.inc'); - exit; - } - - if ($_POST['NewStockID']==''){ - prnMsg(_('The new stock code to change the old code to must be entered as well'),'error'); - include('includes/footer.inc'); - exit; - } - - -/*Now check that the new code doesn't already exist */ - $result=DB_query("SELECT stockid FROM stockmaster WHERE stockid='" . $_POST['NewStockID'] . "'",$db); - if (DB_num_rows($result)!=0){ - echo '<br><br>'; - prnMsg(_('The replacement stock code') . ': ' . $_POST['NewStockID'] . ' ' . _('already exists as a stock code in the system') . ' - ' . _('a unique stock code must be entered for the new code'),'error'); - include('includes/footer.inc'); - exit; - } - - - - $result = DB_Txn_Begin($db); - - echo '<br>' . _('Adding the new stock master record'); - $sql = "INSERT INTO stockmaster (stockid, - categoryid, - description, - longdescription, - units, - mbflag, - lastcurcostdate, - actualcost, - lastcost, - materialcost, - labourcost, - overheadcost, - lowestlevel, - discontinued, - controlled, - eoq, - volume, - kgs, - barcode, - discountcategory, - taxcatid) - SELECT '" . $_POST['NewStockID'] . "', - categoryid, - description, - longdescription, - units, - mbflag, - lastcurcostdate, - actualcost, - lastcost, - materialcost, - labourcost, - overheadcost, - lowestlevel, - discontinued, - controlled, - eoq, - volume, - kgs, - barcode, - discountcategory, - taxcatid - FROM stockmaster - WHERE stockid='" . $_POST['OldStockID'] . "'"; - - $DbgMsg = _('The SQL statement that failed was'); - $ErrMsg =_('The SQL to insert the new stock master record failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - echo '<br>' . _('Changing stock location records'); - $sql = "UPDATE locstock SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update stock location records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - echo '<br>' . _('Changing stock movement records'); - $sql = "UPDATE stockmoves SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update stock movement transaction records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - echo '<BR>' . _('Changing location transfer information'); - - $sql = "UPDATE loctransfers SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the loctransfers records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - echo '<BR>' . _('Changing MRP demands information'); - - $sql = "UPDATE mrpdemands SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the mrpdemands records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - $sql="select count(table_name) from information_schema.tables where table_schema='".$_SESSION['DatabaseName']."' and table_name='mrpplannedorders'"; - $result = DB_query($sql,$db); - $row=DB_fetch_row($result); - if ($row[0]>0) { - echo '<BR>' . _('Changing MRP planned orders information'); - - $sql = "UPDATE mrpplannedorders SET part='" . $_POST['NewStockID'] . "' WHERE part='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the mrpplannedorders records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - } - - echo '<BR>' . _('Changing MRP requirements information'); - - $sql = "UPDATE mrprequirements SET part='" . $_POST['NewStockID'] . "' WHERE part='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the mrprequirements records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - echo '<BR>' . _('Changing MRP supplies information'); - - $sql = "UPDATE mrpsupplies SET part='" . $_POST['NewStockID'] . "' WHERE part='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the mrpsupplies records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - - echo '<br>' . _('Changing sales analysis records'); - $sql = "UPDATE salesanalysis SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update Sales Analysis records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - echo '<br>' . _('Changing order delivery differences records'); - $sql = "UPDATE orderdeliverydifferenceslog SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update order delivery differences records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - echo '<br>' . _('Changing pricing records'); - $sql = "UPDATE prices SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the pricing records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - echo '<br>' . _('Changing sales orders detail records'); - $sql = "UPDATE salesorderdetails SET stkcode='" . $_POST['NewStockID'] . "' WHERE stkcode='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the sales order header records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - echo '<br>' . _('Changing purchase order details records'); - $sql = "UPDATE purchorderdetails SET itemcode='" . $_POST['NewStockID'] . "' WHERE itemcode='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the purchase order detail records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - echo '<br>' . _('Changing purchasing data records'); - $sql = "UPDATE purchdata SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the purchasing data records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - echo '<br>' . _('Changing the stock code in shipment charges records'); - $sql = "UPDATE shipmentcharges SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update Shipment Charges records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - echo '<br>' . _('Changing the stock check freeze file records'); - $sql = "UPDATE stockcheckfreeze SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update stock check freeze records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - echo '<br>' . _('Changing the stock counts table records'); - $sql = "UPDATE stockcounts SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update stock counts records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - echo '<br>' . _('Changing the GRNs table records'); - $sql = "UPDATE grns SET itemcode='" . $_POST['NewStockID'] . "' WHERE itemcode='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update GRN records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - echo '<br>' . _('Changing the contract BOM table records'); - $sql = "UPDATE contractbom SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to contract BOM records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - echo '<br>' . _('Changing the BOM table records') . ' - ' . _('components'); - $sql = "UPDATE bom SET component='" . $_POST['NewStockID'] . "' WHERE component='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the BOM records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - echo '<br>' . _('Changing the BOM table records') . ' - ' . _('parents'); - $sql = "UPDATE bom SET parent='" . $_POST['NewStockID'] . "' WHERE parent='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the BOM parent records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - echo '<br>' . _('Changing any image files'); - if (file_exists($_SESSION['part_pics_dir'] . '/' .$_POST['OldStockID'].'.jpg')) { - if (rename($_SESSION['part_pics_dir'] . '/' .$_POST['OldStockID'].'.jpg', - $_SESSION['part_pics_dir'] . '/' .$_POST['NewStockID'].'.jpg')) { - echo ' ... ' . _('completed'); - } else { - echo ' ... ' . _('failed'); - } - } else { - echo ' ... ' . _('completed'); - } - - echo '<br>' . _('Changing the item properties table records') . ' - ' . _('parents'); - $sql = "UPDATE stockitemproperties SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the item properties records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - $sql = 'SET FOREIGN_KEY_CHECKS=0'; - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - - echo '<BR>' . _('Changing work order requirements information'); - - $sql = "UPDATE worequirements SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the stockid worequirements records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - $sql = "UPDATE worequirements SET parentstockid='" . $_POST['NewStockID'] . "' WHERE parentstockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the parent stockid worequirements records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - echo '<BR>' . _('Changing work order information'); - - $sql = "UPDATE woitems SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the woitem records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - echo '<br>' . _('Changing any serialised item information'); - - - $sql = "UPDATE stockserialitems SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the stockserialitem records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - $sql = "UPDATE stockserialmoves SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to update the stockserialitem records failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - $sql = 'SET FOREIGN_KEY_CHECKS=1'; - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - - $result = DB_Txn_Commit($db); - - echo '<br>' . _('Deleting the old stock master record'); - $sql = "DELETE FROM stockmaster WHERE stockid='" . $_POST['OldStockID'] . "'"; - $ErrMsg = _('The SQL to delete the old stock master record failed'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - echo ' ... ' . _('completed'); - - - echo '<p>' . _('Stock Code') . ': ' . $_POST['OldStockID'] . ' ' . _('was successfully changed to') . ' : ' . $_POST['NewStockID']; - -} - -echo "<form action='" . $_SERVER['PHP_SELF'] . "?=" . $SID . "' method=post>"; -echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - -echo '<p><table> - <tr><td>' . _('Existing Inventory Code') . ":</td> - <td><input type=Text name='OldStockID' size=20 maxlength=20></td></tr>"; - -echo '<tr><td>' . _('New Inventory Code') . ":</td><td><input type=Text name='NewStockID' size=20 maxlength=20></td></tr>"; -echo '</table>'; - -echo "<div class=centre><input type=submit name='ProcessStockChange' VALUE='" . _('Process') . "'></div>"; - -echo '</form>'; - -include('includes/footer.inc'); +<?php +/* $Id$*/ +/*Script to Delete all sales transactions*/ + +$PageSecurity=15; +include ('includes/session.inc'); +$title = _('UTILITY PAGE Change A Stock Code'); +include('includes/header.inc'); +include('includes/SQL_CommonFunctions.inc'); + +if (isset($_POST['ProcessStockChange'])){ + + $_POST['NewStockID'] = strtoupper($_POST['NewStockID']); + +/*First check the stock code exists */ + $result=DB_query("SELECT stockid FROM stockmaster WHERE stockid='" . $_POST['OldStockID'] . "'",$db); + if (DB_num_rows($result)==0){ + prnMsg(_('The stock code') . ': ' . $_POST['OldStockID'] . ' ' . _('does not currently exist as a stock code in the system'),'error'); + include('includes/footer.inc'); + exit; + } + + if (ContainsIllegalCharacters($_POST['NewStockID'])){ + prnMsg(_('The new stock code to change the old code to contains illegal characters - no changes will be made'),'error'); + include('includes/footer.inc'); + exit; + } + + if ($_POST['NewStockID']==''){ + prnMsg(_('The new stock code to change the old code to must be entered as well'),'error'); + include('includes/footer.inc'); + exit; + } + + +/*Now check that the new code doesn't already exist */ + $result=DB_query("SELECT stockid FROM stockmaster WHERE stockid='" . $_POST['NewStockID'] . "'",$db); + if (DB_num_rows($result)!=0){ + echo '<br><br>'; + prnMsg(_('The replacement stock code') . ': ' . $_POST['NewStockID'] . ' ' . _('already exists as a stock code in the system') . ' - ' . _('a unique stock code must be entered for the new code'),'error'); + include('includes/footer.inc'); + exit; + } + + + + $result = DB_Txn_Begin($db); + + echo '<br>' . _('Adding the new stock master record'); + $sql = "INSERT INTO stockmaster (stockid, + categoryid, + description, + longdescription, + units, + mbflag, + lastcurcostdate, + actualcost, + lastcost, + materialcost, + labourcost, + overheadcost, + lowestlevel, + discontinued, + controlled, + eoq, + volume, + kgs, + barcode, + discountcategory, + taxcatid) + SELECT '" . $_POST['NewStockID'] . "', + categoryid, + description, + longdescription, + units, + mbflag, + lastcurcostdate, + actualcost, + lastcost, + materialcost, + labourcost, + overheadcost, + lowestlevel, + discontinued, + controlled, + eoq, + volume, + kgs, + barcode, + discountcategory, + taxcatid + FROM stockmaster + WHERE stockid='" . $_POST['OldStockID'] . "'"; + + $DbgMsg = _('The SQL statement that failed was'); + $ErrMsg =_('The SQL to insert the new stock master record failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + echo '<br>' . _('Changing stock location records'); + $sql = "UPDATE locstock SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update stock location records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + echo '<br>' . _('Changing stock movement records'); + $sql = "UPDATE stockmoves SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update stock movement transaction records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + echo '<BR>' . _('Changing location transfer information'); + + $sql = "UPDATE loctransfers SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the loctransfers records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + echo '<BR>' . _('Changing MRP demands information'); + + $sql = "UPDATE mrpdemands SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the mrpdemands records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + $sql="select count(table_name) from information_schema.tables where table_schema='".$_SESSION['DatabaseName']."' and table_name='mrpplannedorders'"; + $result = DB_query($sql,$db); + $row=DB_fetch_row($result); + if ($row[0]>0) { + echo '<BR>' . _('Changing MRP planned orders information'); + + $sql = "UPDATE mrpplannedorders SET part='" . $_POST['NewStockID'] . "' WHERE part='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the mrpplannedorders records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + } + + echo '<BR>' . _('Changing MRP requirements information'); + + $sql = "UPDATE mrprequirements SET part='" . $_POST['NewStockID'] . "' WHERE part='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the mrprequirements records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + echo '<BR>' . _('Changing MRP supplies information'); + + $sql = "UPDATE mrpsupplies SET part='" . $_POST['NewStockID'] . "' WHERE part='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the mrpsupplies records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + + echo '<br>' . _('Changing sales analysis records'); + $sql = "UPDATE salesanalysis SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update Sales Analysis records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + echo '<br>' . _('Changing order delivery differences records'); + $sql = "UPDATE orderdeliverydifferenceslog SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update order delivery differences records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + echo '<br>' . _('Changing pricing records'); + $sql = "UPDATE prices SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the pricing records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + echo '<br>' . _('Changing sales orders detail records'); + $sql = "UPDATE salesorderdetails SET stkcode='" . $_POST['NewStockID'] . "' WHERE stkcode='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the sales order header records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + echo '<br>' . _('Changing purchase order details records'); + $sql = "UPDATE purchorderdetails SET itemcode='" . $_POST['NewStockID'] . "' WHERE itemcode='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the purchase order detail records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + echo '<br>' . _('Changing purchasing data records'); + $sql = "UPDATE purchdata SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the purchasing data records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + echo '<br>' . _('Changing the stock code in shipment charges records'); + $sql = "UPDATE shipmentcharges SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update Shipment Charges records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + echo '<br>' . _('Changing the stock check freeze file records'); + $sql = "UPDATE stockcheckfreeze SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update stock check freeze records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + echo '<br>' . _('Changing the stock counts table records'); + $sql = "UPDATE stockcounts SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update stock counts records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + echo '<br>' . _('Changing the GRNs table records'); + $sql = "UPDATE grns SET itemcode='" . $_POST['NewStockID'] . "' WHERE itemcode='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update GRN records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + echo '<br>' . _('Changing the contract BOM table records'); + $sql = "UPDATE contractbom SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to contract BOM records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + echo '<br>' . _('Changing the BOM table records') . ' - ' . _('components'); + $sql = "UPDATE bom SET component='" . $_POST['NewStockID'] . "' WHERE component='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the BOM records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + echo '<br>' . _('Changing the BOM table records') . ' - ' . _('parents'); + $sql = "UPDATE bom SET parent='" . $_POST['NewStockID'] . "' WHERE parent='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the BOM parent records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + echo '<br>' . _('Changing any image files'); + if (file_exists($_SESSION['part_pics_dir'] . '/' .$_POST['OldStockID'].'.jpg')) { + if (rename($_SESSION['part_pics_dir'] . '/' .$_POST['OldStockID'].'.jpg', + $_SESSION['part_pics_dir'] . '/' .$_POST['NewStockID'].'.jpg')) { + echo ' ... ' . _('completed'); + } else { + echo ' ... ' . _('failed'); + } + } else { + echo ' ... ' . _('completed'); + } + + echo '<br>' . _('Changing the item properties table records') . ' - ' . _('parents'); + $sql = "UPDATE stockitemproperties SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the item properties records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + $sql = 'SET FOREIGN_KEY_CHECKS=0'; + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + + echo '<BR>' . _('Changing work order requirements information'); + + $sql = "UPDATE worequirements SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the stockid worequirements records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + $sql = "UPDATE worequirements SET parentstockid='" . $_POST['NewStockID'] . "' WHERE parentstockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the parent stockid worequirements records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + echo '<BR>' . _('Changing work order information'); + + $sql = "UPDATE woitems SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the woitem records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + echo '<br>' . _('Changing any serialised item information'); + + + $sql = "UPDATE stockserialitems SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the stockserialitem records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + $sql = "UPDATE stockserialmoves SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the stockserialitem records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + $sql = 'SET FOREIGN_KEY_CHECKS=1'; + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + + $result = DB_Txn_Commit($db); + + echo '<br>' . _('Deleting the old stock master record'); + $sql = "DELETE FROM stockmaster WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to delete the old stock master record failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + + + echo '<p>' . _('Stock Code') . ': ' . $_POST['OldStockID'] . ' ' . _('was successfully changed to') . ' : ' . $_POST['NewStockID']; + +} + +echo "<form action='" . $_SERVER['PHP_SELF'] . "?=" . $SID . "' method=post>"; +echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + +echo '<p><table> + <tr><td>' . _('Existing Inventory Code') . ":</td> + <td><input type=Text name='OldStockID' size=20 maxlength=20></td></tr>"; + +echo '<tr><td>' . _('New Inventory Code') . ":</td><td><input type=Text name='NewStockID' size=20 maxlength=20></td></tr>"; +echo '</table>'; + +echo "<div class=centre><input type=submit name='ProcessStockChange' VALUE='" . _('Process') . "'></div>"; + +echo '</form>'; + +include('includes/footer.inc'); ?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-05 11:07:59 UTC (rev 4142) +++ trunk/doc/Change.log.html 2010-11-06 04:12:36 UTC (rev 4143) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>06/11/10 Phil: StockCategory.php FixedAssetCategory.php attempt to add validation to depreciation rates by extending the stock category property logic with new fields for numericvalue, minimumvalue and maximumvalue. Then adding the depreciation rate percentage property to expect numeric values with a minimum of 0 and maximum of 100. Not really happy with the fixed asset stuff - feels like a bit like a hack :-( <p>05/11/10 Tim: PurchData.php. Converted field name to lower case for consistency</p> <p>05/11/10 Tim: SelectProduct.php. Change the standard order quantities to agree with Minimum order qty</p> <p>05/11/10 Tim: PurchData.php. Make the Minimum order quantity field numeric only</p> Modified: trunk/includes/PDFStarter.php =================================================================== --- trunk/includes/PDFStarter.php 2010-11-05 11:07:59 UTC (rev 4142) +++ trunk/includes/PDFStarter.php 2010-11-06 04:12:36 UTC (rev 4143) @@ -1,173 +1,173 @@ -<?php - -/* $Id: PDFStarter.php 3526 2010-06-26 08:05:36Z tim_schofield $ */ - -/* ------------------------------------------------------------------------------------- - November 2009. Moving from FPDF to TCPDF. - This file is included by most of the scripts (47 from 54 at now) that creates a pdf. - This file creates a new instance of the PDF object defined in class.pdf.php - The changes applied to the PDF class affected this file that needed some changes too. - Javier de Lorenzo-Cáceres <in...@ci...> - ------------------------------------------------------------------------------------- */ - - -require_once (dirname(__FILE__).'/class.pdf.php'); - -/* -// Changes to move from FPDF to TCPDF to support UTF-8 by Javier de Lorenzo-Cáceres <in...@ci...> -*/ - -if (!isset($PaperSize)){ // Javier: Results True, it's not set. - $PaperSize = $_SESSION['DefaultPageSize']; // Javier: DefaultPageSize is taken from DB, www_users, pagesize = A4 -} - -/* Javier: TCPDF supports 45 standard ISO (DIN) paper formats and 4 american common formats and does this cordinates calculation. - However, reports use this units */ - -switch ($PaperSize) { - - case 'A4': - -// Javier: Now I use the native TCPDF constructor to which I send these values in each case, -// this should have been done whith FPDF which use the same values in its constructor. - - $DocumentPaper = 'A4'; $DocumentOrientation ='P'; - -// Javier: DIN-A4 is 210 mm width, i.e., 595'2756 points (inches * 72 ppi) - $Page_Width=595; - $Page_Height=842; - $Top_Margin=30; - $Bottom_Margin=30; - $Left_Margin=40; - $Right_Margin=30; - break; - - case 'A4_Landscape': - - $DocumentPaper = 'A4'; $DocumentOrientation ='L'; - - $Page_Width=842; - $Page_Height=595; - $Top_Margin=30; - $Bottom_Margin=30; - $Left_Margin=40; - $Right_Margin=30; - break; - - case 'A5': - - $DocumentPaper = 'A5'; $DocumentOrientation ='P'; - - $Page_Width=421; - $Page_Height=595; - $Top_Margin=30; - $Bottom_Margin=30; - $Left_Margin=40; - $Right_Margin=30; - break; - - case 'A5_Landscape': - - $DocumentPaper = 'A5'; $DocumentOrientation ='L'; - - $Page_Width=595; - $Page_Height=421; - $Top_Margin=30; - $Bottom_Margin=30; - $Left_Margin=40; - $Right_Margin=30; - break; - - case 'A3': - - $DocumentPaper = 'A3'; $DocumentOrientation ='P'; - - $Page_Width=842; - $Page_Height=1190; - $Top_Margin=50; - $Bottom_Margin=50; - $Left_Margin=50; - $Right_Margin=40; - break; - - case 'A3_landscape': - - $DocumentPaper = 'A3'; $DocumentOrientation ='L'; - - $Page_Width=1190; - $Page_Height=842; - $Top_Margin=50; - $Bottom_Margin=50; - $Left_Margin=50; - $Right_Margin=40; - break; - - case 'letter': - - $DocumentPaper = 'LETTER'; $DocumentOrientation ='P'; - - $Page_Width=612; - $Page_Height=792; - $Top_Margin=30; - $Bottom_Margin=30; - $Left_Margin=30; - $Right_Margin=25; - break; - - case 'letter_landscape': - - $DocumentPaper = 'LETTER'; $DocumentOrientation ='L'; - - $Page_Width=792; - $Page_Height=612; - $Top_Margin=30; - $Bottom_Margin=30; - $Left_Margin=30; - $Right_Margin=25; - break; - - case 'legal': - - $DocumentPaper = 'LEGAL'; $DocumentOrientation ='P'; - - $Page_Width=612; - $Page_Height=1008; - $Top_Margin=50; - $Bottom_Margin=40; - $Left_Margin=30; - $Right_Margin=25; - break; - - case 'legal_landscape': - - $DocumentPaper = 'LEGAL'; $DocumentOrientation ='L'; - - $Page_Width=1008; - $Page_Height=612; - $Top_Margin=50; - $Bottom_Margin=40; - $Left_Margin=30; - $Right_Margin=25; - break; -} - -// Javier: I correct the call to the constructor to match TCPDF (and FPDF ;-) -// $PageSize = array(0,0,$Page_Width,$Page_Height); -// $pdf = new Cpdf($PageSize); -$pdf = new Cpdf($DocumentOrientation, 'pt', $DocumentPaper); - -$pdf->addInfo('Creator', 'WebERP http://www.weberp.org'); -$pdf->addInfo('Author', 'WebERP ' . $Version); - - -/* Javier: I have brought this piece from the pdf class constructor to get it closer to the admin/user, - I corrected it to match TCPDF, but it still needs check, after which, - I think it should be moved to each report to provide flexible Document Header and Margins in a per-report basis. */ - $pdf->SetAutoPageBreak(true, 0); // Javier: needs check. - $pdf->SetPrintHeader(false); // Javier: I added this must be called before Add Page - $pdf->AddPage(); -// $this->SetLineWidth(1); Javier: It was ok for FPDF but now is too gross with TCPDF. TCPDF defaults to 0'57 pt (0'2 mm) which is ok. - $pdf->cMargin = 0; // Javier: needs check. -/* END Brought from class.pdf.php constructor */ - -?> +<?php + +/* $Id$ */ + +/* ------------------------------------------------------------------------------------- + November 2009. Moving from FPDF to TCPDF. + This file is included by most of the scripts (47 from 54 at now) that creates a pdf. + This file creates a new instance of the PDF object defined in class.pdf.php + The changes applied to the PDF class affected this file that needed some changes too. + Javier de Lorenzo-Cáceres <in...@ci...> + ------------------------------------------------------------------------------------- */ + + +require_once (dirname(__FILE__).'/class.pdf.php'); + +/* +// Changes to move from FPDF to TCPDF to support UTF-8 by Javier de Lorenzo-Cáceres <in...@ci...> +*/ + +if (!isset($PaperSize)){ // Javier: Results True, it's not set. + $PaperSize = $_SESSION['DefaultPageSize']; // Javier: DefaultPageSize is taken from DB, www_users, pagesize = A4 +} + +/* Javier: TCPDF supports 45 standard ISO (DIN) paper formats and 4 american common formats and does this cordinates calculation. + However, reports use this units */ + +switch ($PaperSize) { + + case 'A4': + +// Javier: Now I use the native TCPDF constructor to which I send these values in each case, +// this should have been done whith FPDF which use the same values in its constructor. + + $DocumentPaper = 'A4'; $DocumentOrientation ='P'; + +// Javier: DIN-A4 is 210 mm width, i.e., 595'2756 points (inches * 72 ppi) + $Page_Width=595; + $Page_Height=842; + $Top_Margin=30; + $Bottom_Margin=30; + $Left_Margin=40; + $Right_Margin=30; + break; + + case 'A4_Landscape': + + $DocumentPaper = 'A4'; $DocumentOrientation ='L'; + + $Page_Width=842; + $Page_Height=595; + $Top_Margin=30; + $Bottom_Margin=30; + $Left_Margin=40; + $Right_Margin=30; + break; + + case 'A5': + + $DocumentPaper = 'A5'; $DocumentOrientation ='P'; + + $Page_Width=421; + $Page_Height=595; + $Top_Margin=30; + $Bottom_Margin=30; + $Left_Margin=40; + $Right_Margin=30; + break; + + case 'A5_Landscape': + + $DocumentPaper = 'A5'; $DocumentOrientation ='L'; + + $Page_Width=595; + $Page_Height=421; + $Top_Margin=30; + $Bottom_Margin=30; + $Left_Margin=40; + $Right_Margin=30; + break; + + case 'A3': + + $DocumentPaper = 'A3'; $DocumentOrientation ='P'; + + $Page_Width=842; + $Page_Height=1190; + $Top_Margin=50; + $Bottom_Margin=50; + $Left_Margin=50; + $Right_Margin=40; + break; + + case 'A3_landscape': + + $DocumentPaper = 'A3'; $DocumentOrientation ='L'; + + $Page_Width=1190; + $Page_Height=842; + $Top_Margin=50; + $Bottom_Margin=50; + $Left_Margin=50; + $Right_Margin=40; + break; + + case 'letter': + + $DocumentPaper = 'LETTER'; $DocumentOrientation ='P'; + + $Page_Width=612; + $Page_Height=792; + $Top_Margin=30; + $Bottom_Margin=30; + $Left_Margin=30; + $Right_Margin=25; + break; + + case 'letter_landscape': + + $DocumentPaper = 'LETTER'; $DocumentOrientation ='L'; + + $Page_Width=792; + $Page_Height=612; + $Top_Margin=30; + $Bottom_Margin=30; + $Left_Margin=30; + $Right_Margin=25; + break; + + case 'legal': + + $DocumentPaper = 'LEGAL'; $DocumentOrientation ='P'; + + $Page_Width=612; + $Page_Height=1008; + $Top_Margin=50; + $Bottom_Margin=40; + $Left_Margin=30; + $Right_Margin=25; + break; + + case 'legal_landscape': + + $DocumentPaper = 'LEGAL'; $DocumentOrientation ='L'; + + $Page_Width=1008; + $Page_Height=612; + $Top_Margin=50; + $Bottom_Margin=40; + $Left_Margin=30; + $Right_Margin=25; + break; +} + +// Javier: I correct the call to the constructor to match TCPDF (and FPDF ;-) +// $PageSize = array(0,0,$Page_Width,$Page_Height); +// $pdf = new Cpdf($PageSize); +$pdf = new Cpdf($DocumentOrientation, 'pt', $DocumentPaper); + +$pdf->addInfo('Creator', 'WebERP http://www.weberp.org'); +$pdf->addInfo('Author', 'WebERP ' . $Version); + + +/* Javier: I have brought this piece from the pdf class constructor to get it closer to the admin/user, + I corrected it to match TCPDF, but it still needs check, after which, + I think it should be moved to each report to provide flexible Document Header and Margins in a per-report basis. */ + $pdf->SetAutoPageBreak(true, 0); // Javier: needs check. + $pdf->SetPrintHeader(false); // Javier: I added this must be called before Add Page + $pdf->AddPage(); +// $this->SetLineWidth(1); Javier: It was ok for FPDF but now is too gross with TCPDF. TCPDF defaults to 0'57 pt (0'2 mm) which is ok. + $pdf->cMargin = 0; // Javier: needs check. +/* END Brought from class.pdf.php constructor */ + +?> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-05 11:07:59 UTC (rev 4142) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-06 04:12:36 UTC (rev 4143) @@ -433,3 +433,7 @@ ALTER TABLE `reports` ADD `col20width` INT( 3 ) NOT NULL DEFAULT '25' AFTER `col19width` ; ALTER TABLE `reportfields` CHANGE `fieldname` `fieldname` VARCHAR( 80) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT ''; + +ALTER TABLE `stockcatproperties` ADD `maximumvalue` DOUBLE NOT NULL DEFAULT 999999999 AFTER `defaultvalue` , +ADD `minimumvalue` DOUBLE NOT NULL DEFAULT -999999999 AFTER `maximumvalue` , +ADD `numericvalue` TINYINT NOT NULL AFTER `minumumvalue` This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-06 09:16:36
|
Revision: 4145 http://web-erp.svn.sourceforge.net/web-erp/?rev=4145&view=rev Author: tim_schofield Date: 2010-11-06 09:16:30 +0000 (Sat, 06 Nov 2010) Log Message: ----------- Fixed typo preventing Item code being shown Modified Paths: -------------- trunk/FixedAssetItems.php trunk/doc/Change.log.html Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-11-06 09:09:58 UTC (rev 4144) +++ trunk/FixedAssetItems.php 2010-11-06 09:16:30 UTC (rev 4145) @@ -596,7 +596,7 @@ /*If the page was called without $StockID passed to page then assume a new stock item is to be entered show a form with a part Code field other wise the form showing the fields with the existing entries against the part will show for editing with only a hidden StockID field. New is set to flag that the page may have called itself and still be entering a new part, in which case the page needs to know not to go looking up details for an existing part*/ $New = true; - echo '<input type="hidden" name="New" value=">'. "\n"; + echo '<input type="hidden" name="New" value="">'. "\n"; // echo '<input type="hidden" name="StockID" value="'.$StockID.'">'. "\n"; echo '<tr><td>'. _('Asset Code'). ':</td><td><input ' . (in_array('StockID',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="StockID" size=21 maxlength=20></td></tr>'. "\n"; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-06 09:09:58 UTC (rev 4144) +++ trunk/doc/Change.log.html 2010-11-06 09:16:30 UTC (rev 4145) @@ -1,6 +1,7 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> -<p>06/11/10 Phil: StockCategory.php FixedAssetCategory.php attempt to add validation to depreciation rates by extending the stock category property logic with new fields for numericvalue, minimumvalue and maximumvalue. Then adding the depreciation rate percentage property to expect numeric values with a minimum of 0 and maximum of 100. Not really happy with the fixed asset stuff - feels like a bit like a hack :-( +<p>06/11/10 Tim: FixedAssetItems.php - Fixed typo preventing Item code being shown</p> +<p>06/11/10 Phil: StockCategory.php FixedAssetCategory.php attempt to add validation to depreciation rates by extending the stock category property logic with new fields for numericvalue, minimumvalue and maximumvalue. Then adding the depreciation rate percentage property to expect numeric values with a minimum of 0 and maximum of 100. Not really happy with the fixed asset stuff - feels like a bit like a hack :-(</p> <p>05/11/10 Tim: PurchData.php. Converted field name to lower case for consistency</p> <p>05/11/10 Tim: SelectProduct.php. Change the standard order quantities to agree with Minimum order qty</p> <p>05/11/10 Tim: PurchData.php. Make the Minimum order quantity field numeric only</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-06 09:34:17
|
Revision: 4146 http://web-erp.svn.sourceforge.net/web-erp/?rev=4146&view=rev Author: tim_schofield Date: 2010-11-06 09:34:11 +0000 (Sat, 06 Nov 2010) Log Message: ----------- Ensure fixed assets dont get shown in valuation report Modified Paths: -------------- trunk/InventoryValuation.php trunk/doc/Change.log.html Modified: trunk/InventoryValuation.php =================================================================== --- trunk/InventoryValuation.php 2010-11-06 09:16:30 UTC (rev 4145) +++ trunk/InventoryValuation.php 2010-11-06 09:34:11 UTC (rev 4146) @@ -35,6 +35,7 @@ locstock WHERE stockmaster.stockid=locstock.stockid AND stockmaster.categoryid=stockcategory.categoryid + AND stockcategory.stocktype<>'A' GROUP BY stockmaster.categoryid, stockcategory.categorydescription, unitcost, @@ -67,6 +68,7 @@ AND stockmaster.categoryid >= '" . $_POST['FromCriteria'] . "' AND stockmaster.categoryid <= '" . $_POST['ToCriteria'] . "' AND locstock.loccode = '" . $_POST['Location'] . "' + AND stockcategory.stocktype<>'A' ORDER BY stockmaster.categoryid, stockmaster.stockid"; } @@ -206,7 +208,7 @@ echo '<tr><td>' . _('From Inventory Category Code') . ':</font></td><td><select name=FromCriteria>'; - $sql='SELECT categoryid, categorydescription FROM stockcategory ORDER BY categoryid'; + $sql='SELECT categoryid, categorydescription FROM stockcategory WHERE stocktype<>"A" ORDER BY categoryid'; $CatResult= DB_query($sql,$db); While ($myrow = DB_fetch_array($CatResult)){ echo "<option value='" . $myrow['categoryid'] . "'>" . $myrow['categoryid'] . ' - ' . $myrow['categorydescription']; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-06 09:16:30 UTC (rev 4145) +++ trunk/doc/Change.log.html 2010-11-06 09:34:11 UTC (rev 4146) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>06/11/10 Tim: InventoryValuation.php - Ensure fixed assets dont get shown in valuation report</p> <p>06/11/10 Tim: FixedAssetItems.php - Fixed typo preventing Item code being shown</p> <p>06/11/10 Phil: StockCategory.php FixedAssetCategory.php attempt to add validation to depreciation rates by extending the stock category property logic with new fields for numericvalue, minimumvalue and maximumvalue. Then adding the depreciation rate percentage property to expect numeric values with a minimum of 0 and maximum of 100. Not really happy with the fixed asset stuff - feels like a bit like a hack :-(</p> <p>05/11/10 Tim: PurchData.php. Converted field name to lower case for consistency</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-06 12:18:31
|
Revision: 4147 http://web-erp.svn.sourceforge.net/web-erp/?rev=4147&view=rev Author: tim_schofield Date: 2010-11-06 12:18:25 +0000 (Sat, 06 Nov 2010) Log Message: ----------- Remove fixed assets from selections Modified Paths: -------------- trunk/SelectProduct.php trunk/doc/Change.log.html Modified: trunk/SelectProduct.php =================================================================== --- trunk/SelectProduct.php 2010-11-06 09:34:11 UTC (rev 4146) +++ trunk/SelectProduct.php 2010-11-06 12:18:25 UTC (rev 4147) @@ -28,10 +28,11 @@ $_POST['StockCode'] = trim(strtoupper($_POST['StockCode'])); } // Always show the search facilities -$SQL = 'SELECT categoryid, +$SQL = "SELECT categoryid, categorydescription FROM stockcategory - ORDER BY categorydescription'; + WHERE stocktype<>'A' + ORDER BY categorydescription"; $result1 = DB_query($SQL, $db); if (DB_num_rows($result1) == 0) { echo '<p><font size=4 color=red>' . _('Problem Report') . ':</font><br>' . _('There are no stock categories currently defined please use the link below to set them up'); @@ -523,10 +524,13 @@ stockmaster.units, stockmaster.mbflag, stockmaster.decimalplaces - FROM stockmaster, + FROM stockmaster + LEFT JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid, locstock WHERE stockmaster.stockid=locstock.stockid AND stockmaster.description " . LIKE . " '$SearchString' + AND stockcategory.stocktype<>'A' GROUP BY stockmaster.stockid, stockmaster.description, stockmaster.units, @@ -561,10 +565,13 @@ SUM(locstock.quantity) AS qoh, stockmaster.units, stockmaster.decimalplaces - FROM stockmaster, + FROM stockmaster + LEFT JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid, locstock WHERE stockmaster.stockid=locstock.stockid AND stockmaster.stockid " . LIKE . " '%" . $_POST['StockCode'] . "%' + AND stockcategory.stocktype<>'A' GROUP BY stockmaster.stockid, stockmaster.description, stockmaster.units, @@ -598,9 +605,12 @@ SUM(locstock.quantity) AS qoh, stockmaster.units, stockmaster.decimalplaces - FROM stockmaster, + FROM stockmaster + LEFT JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid, locstock WHERE stockmaster.stockid=locstock.stockid + AND stockcategory.stocktype<>'A' GROUP BY stockmaster.stockid, stockmaster.description, stockmaster.units, Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-06 09:34:11 UTC (rev 4146) +++ trunk/doc/Change.log.html 2010-11-06 12:18:25 UTC (rev 4147) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>06/11/10 Tim: Selectproduct.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: InventoryValuation.php - Ensure fixed assets dont get shown in valuation report</p> <p>06/11/10 Tim: FixedAssetItems.php - Fixed typo preventing Item code being shown</p> <p>06/11/10 Phil: StockCategory.php FixedAssetCategory.php attempt to add validation to depreciation rates by extending the stock category property logic with new fields for numericvalue, minimumvalue and maximumvalue. Then adding the depreciation rate percentage property to expect numeric values with a minimum of 0 and maximum of 100. Not really happy with the fixed asset stuff - feels like a bit like a hack :-(</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-06 12:35:12
|
Revision: 4148 http://web-erp.svn.sourceforge.net/web-erp/?rev=4148&view=rev Author: tim_schofield Date: 2010-11-06 12:35:06 +0000 (Sat, 06 Nov 2010) Log Message: ----------- Remove fixed assets from selections Modified Paths: -------------- trunk/InventoryQuantities.php trunk/doc/Change.log.html Modified: trunk/InventoryQuantities.php =================================================================== --- trunk/InventoryQuantities.php 2010-11-06 12:18:25 UTC (rev 4147) +++ trunk/InventoryQuantities.php 2010-11-06 12:35:06 UTC (rev 4148) @@ -154,7 +154,7 @@ echo "<option value='Multiple'>" . _('Only Parts With Multiple Locations'); echo '</select></td></tr>'; - $SQL="SELECT categoryid, categorydescription FROM stockcategory ORDER BY categorydescription"; + $SQL="SELECT categoryid, categorydescription FROM stockcategory where stocktype<>'A' ORDER BY categorydescription"; $result1 = DB_query($SQL,$db); if (DB_num_rows($result1)==0){ echo '</table></td></tr> Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-06 12:18:25 UTC (rev 4147) +++ trunk/doc/Change.log.html 2010-11-06 12:35:06 UTC (rev 4148) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>06/11/10 Tim: InventoryQuantities.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: Selectproduct.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: InventoryValuation.php - Ensure fixed assets dont get shown in valuation report</p> <p>06/11/10 Tim: FixedAssetItems.php - Fixed typo preventing Item code being shown</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-06 15:33:37
|
Revision: 4149 http://web-erp.svn.sourceforge.net/web-erp/?rev=4149&view=rev Author: tim_schofield Date: 2010-11-06 15:33:31 +0000 (Sat, 06 Nov 2010) Log Message: ----------- Remove fixed assets from selections Modified Paths: -------------- trunk/InventoryQuantities.php trunk/ReorderLevel.php trunk/doc/Change.log.html Modified: trunk/InventoryQuantities.php =================================================================== --- trunk/InventoryQuantities.php 2010-11-06 12:35:06 UTC (rev 4148) +++ trunk/InventoryQuantities.php 2010-11-06 15:33:31 UTC (rev 4149) @@ -21,7 +21,7 @@ $wherecategory = " "; $catdescription = " "; if ($_POST['StockCat'] != 'All') { - $wherecategory = " AND stockmaster.categoryid='" . $_POST['StockCat'] . "' "; + $wherecategory = " AND stockmaster.categoryid='" . $_POST['StockCat'] . "' AND stockcategory.stocktype<>'A'"; $sql= "SELECT categoryid, categorydescription FROM stockcategory WHERE categoryid='" . $_POST['StockCat'] . "' "; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); @@ -39,7 +39,9 @@ stockmaster.serialised, stockmaster.controlled FROM locstock, - stockmaster, + stockmaster + LEFT JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid, locations WHERE locstock.stockid=stockmaster.stockid AND locstock.loccode=locations.loccode Modified: trunk/ReorderLevel.php =================================================================== --- trunk/ReorderLevel.php 2010-11-06 12:35:06 UTC (rev 4148) +++ trunk/ReorderLevel.php 2010-11-06 15:33:31 UTC (rev 4149) @@ -21,7 +21,7 @@ $wherecategory = " "; $catdescription = " "; if ($_POST['StockCat'] != 'All') { - $wherecategory = " AND stockmaster.categoryid='" . $_POST['StockCat'] . "' "; + $wherecategory = " AND stockmaster.categoryid='" . $_POST['StockCat'] . "' AND stockcategory.stocktype<>'A'"; $sql= "SELECT categoryid, categorydescription FROM stockcategory WHERE categoryid='" . $_POST['StockCat'] . "' "; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); @@ -42,7 +42,9 @@ stockmaster.serialised, stockmaster.controlled FROM locstock, - stockmaster, + stockmaster + LEFT JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid, locations WHERE locstock.stockid=stockmaster.stockid " . $wherelocation . @@ -195,7 +197,7 @@ } echo '</select></td></tr>'; - $SQL="SELECT categoryid, categorydescription FROM stockcategory ORDER BY categorydescription"; + $SQL="SELECT categoryid, categorydescription FROM stockcategory WHERE stocktype<>'A' ORDER BY categorydescription"; $result1 = DB_query($SQL,$db); if (DB_num_rows($result1)==0){ echo '</table></td></tr> Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-06 12:35:06 UTC (rev 4148) +++ trunk/doc/Change.log.html 2010-11-06 15:33:31 UTC (rev 4149) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>06/11/10 Tim: ReorderLevel.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: InventoryQuantities.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: Selectproduct.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: InventoryValuation.php - Ensure fixed assets dont get shown in valuation report</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-06 17:08:14
|
Revision: 4150 http://web-erp.svn.sourceforge.net/web-erp/?rev=4150&view=rev Author: tim_schofield Date: 2010-11-06 15:50:51 +0000 (Sat, 06 Nov 2010) Log Message: ----------- Remove fixed assets from selections Modified Paths: -------------- trunk/ReorderLevelLocation.php trunk/doc/Change.log.html Modified: trunk/ReorderLevelLocation.php =================================================================== --- trunk/ReorderLevelLocation.php 2010-11-06 15:33:31 UTC (rev 4149) +++ trunk/ReorderLevelLocation.php 2010-11-06 15:50:51 UTC (rev 4150) @@ -181,8 +181,9 @@ echo '</select></td></tr>'; $SQL="SELECT categoryid, categorydescription - FROM stockcategory - ORDER BY categorydescription"; + FROM stockcategory + WHERE stocktype<>'A' + ORDER BY categorydescription"; $result1 = DB_query($SQL,$db); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-06 15:33:31 UTC (rev 4149) +++ trunk/doc/Change.log.html 2010-11-06 15:50:51 UTC (rev 4150) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>06/11/10 Tim: ReorderLevelLocation.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: ReorderLevel.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: InventoryQuantities.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: Selectproduct.php - Remove fixed assets from selections</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2010-11-07 02:24:44
|
Revision: 4151 http://web-erp.svn.sourceforge.net/web-erp/?rev=4151&view=rev Author: turbopt Date: 2010-11-07 02:24:38 +0000 (Sun, 07 Nov 2010) Log Message: ----------- 06/11/10 Paul T: InputSerialItemsSequential.php - Bug# 3080130 - Add new FormID to form. (and minor cleanup) Modified Paths: -------------- trunk/doc/Change.log.html trunk/includes/InputSerialItemsSequential.php Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-06 15:50:51 UTC (rev 4150) +++ trunk/doc/Change.log.html 2010-11-07 02:24:38 UTC (rev 4151) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>06/11/10 Paul T: InputSerialItemsSequential.php - Bug# 3080130 - Add new FormID to form. (and minor cleanup)</p> <p>06/11/10 Tim: ReorderLevelLocation.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: ReorderLevel.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: InventoryQuantities.php - Remove fixed assets from selections</p> Modified: trunk/includes/InputSerialItemsSequential.php =================================================================== --- trunk/includes/InputSerialItemsSequential.php 2010-11-06 15:50:51 UTC (rev 4150) +++ trunk/includes/InputSerialItemsSequential.php 2010-11-07 02:24:38 UTC (rev 4151) @@ -19,32 +19,33 @@ $LineNo = $_POST['LineNo']; } -echo '<TD valign=top>'; +echo '<td valign="top">'; /*Start a new table for the Serial/Batch ref input in one column (as a sub table then the multi select box for selection of existing bundle/serial nos for dispatch if applicable*/ -//echo '<TABLE><TR><TD valign=TOP>'; +//echo '<table><tr><td valign="top">'; /*in the first column add a table for the input of newies */ -echo '<TABLE>'; +echo '<table>'; echo $tableheader; -echo '<FORM ACTION="' . $_SERVER['PHP_SELF'] . '?=' . $SID . '" METHOD="POST"> - <input type=hidden name=LineNo value="' . $LineNo . '"> - <input type=hidden name=StockID value="' . $StockID . '"> - <input type=hidden name=EntryType value="SEQUENCE">'; +echo '<form action="' . $_SERVER['PHP_SELF'] . '?=' . $SID . '" method="post"> + <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" /> + <input type="hidden" name="LineNo" value="' . $LineNo . '"> + <input type="hidden" name="StockID" value="' . $StockID . '"> + <input type="hidden" name="EntryType" value="SEQUENCE">'; if ( isset($_GET['EditControlled']) ) { $EditControlled = isset($_GET['EditControlled'])?$_GET['EditControlled']:false; } elseif ( isset($_POST['EditControlled']) ){ $EditControlled = isset($_POST['EditControlled'])?$_POST['EditControlled']:false; } -echo '<TR><TD valign=top>'. _('Begin:') . '</td><td> <input type=text name="BeginNo" size=21 maxlength=20 value="'. $_POST['BeginNo']. '"></td></tr>'; -echo '<TR><TD valign=top>'. _('End:') . '</td><td> <input type=text name="EndNo" size=21 maxlength=20 value="'. $_POST['EndNo']. '"></td></tr>'; +echo '<tr><td valign="top">'. _('Begin:') . '</td><td> <input type="text" name="BeginNo" size="21" maxlength="20" value="'. $_POST['BeginNo']. '"></td></tr>'; +echo '<tr><td valign="top">'. _('End:') . '</td><td> <input type="text" name="EndNo" size="21" maxlength="20" value="'. $_POST['EndNo']. '"></td></tr>'; echo '</table>'; -echo '<br><center><INPUT TYPE=SUBMIT NAME="AddSequence" VALUE="'. _('Enter'). '"></center><BR>'; -echo '</FORM></TD><TD valign=top>'; -//echo '</TD></TR></TABLE>'; /*end of nested table */ +echo '<br><center><input type="submit" name="AddSequence" value="'. _('Enter'). '"></center><br>'; +echo '</form></td><td valign="top">'; +//echo '</td></tr></table>'; /*end of nested table */ ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-07 02:59:06
|
Revision: 4152 http://web-erp.svn.sourceforge.net/web-erp/?rev=4152&view=rev Author: daintree Date: 2010-11-07 02:59:00 +0000 (Sun, 07 Nov 2010) Log Message: ----------- API getprices method needs to refer to start and end dates - set method not modified but needs work! Modified Paths: -------------- trunk/SuppShiptChgs.php trunk/api/api_stock.php trunk/api/api_xml-rpc.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/SuppShiptChgs.php =================================================================== --- trunk/SuppShiptChgs.php 2010-11-07 02:24:38 UTC (rev 4151) +++ trunk/SuppShiptChgs.php 2010-11-07 02:59:00 UTC (rev 4152) @@ -39,12 +39,14 @@ $InputError = False; if ($_POST['ShiptRef'] == ""){ $_POST['ShiptRef'] = $_POST['ShiptSelection']; + } else { + $result = DB_query("SELECT shiptref FROM shipments WHERE shiptref='". $_POST['ShiptRef'] . "'",$db); + if (DB_num_rows($result)==0) { + prnMsg(_('The shipment entered manually is not a valid shipment reference. If you do not know the shipment reference, select it from the list'),'error'); + $InputError = True; + } } - if (!is_numeric($_POST['ShiptRef'])){ - prnMsg(_('The shipment reference must be numeric') . '. ' . _('This shipment charge cannot be added to the invoice'),'error'); - $InputError = True; - } - + if (!is_numeric($_POST['Amount'])){ prnMsg(_('The amount entered is not numeric') . '. ' . _('This shipment charge cannot be added to the invoice'),'error'); $InputError = True; Modified: trunk/api/api_stock.php =================================================================== --- trunk/api/api_stock.php 2010-11-07 02:24:38 UTC (rev 4151) +++ trunk/api/api_stock.php 2010-11-07 02:59:00 UTC (rev 4152) @@ -715,19 +715,24 @@ if (sizeof($Errors)!=0) { return $Errors; } - $sql = 'SELECT COUNT(*) FROM prices - WHERE stockid="'.$StockID.'" - and typeabbrev="'.$SalesType.'" - and currabrev="'.$Currency.'"'; + $sql = "SELECT COUNT(*) FROM prices + WHERE stockid='" .$StockID. "' + AND typeabbrev='" .$SalesType. "' + AND currabrev='".$Currency. "' + AND startdate>='". Date('Y-m-d') . "' + (AND enddate<='" . Date('Y-m-d') . "' OR enddate='0000-00-00')"; $result = DB_Query($sql, $db); $myrow = DB_fetch_row($result); if ($myrow[0]==0) { $Errors[0] = NoPricesSetup; return $Errors; } else { - $sql='SELECT price FROM prices WHERE stockid="'.$StockID.'" - and typeabbrev="'.$SalesType.'" - and currabrev="'.$Currency.'"'; + $sql="SELECT price FROM prices + WHERE stockid='" .$StockID. "' + AND typeabbrev='" .$SalesType. "' + AND currabrev='".$Currency. "' + AND startdate>='". Date('Y-m-d') . "' + (AND enddate<='" . Date('Y-m-d') . "' OR enddate='0000-00-00')"; } $result = DB_Query($sql, $db); $myrow = DB_fetch_row($result); Modified: trunk/api/api_xml-rpc.php =================================================================== --- trunk/api/api_xml-rpc.php 2010-11-07 02:24:38 UTC (rev 4151) +++ trunk/api/api_xml-rpc.php 2010-11-07 02:59:00 UTC (rev 4152) @@ -29,8 +29,8 @@ function xmlrpc_Login($xmlrpcmsg) { ob_start('ob_file_callback'); $rtn = new xmlrpcresp(php_xmlrpc_encode(LoginAPI($xmlrpcmsg->getParam(0)->scalarval(), - $xmlrpcmsg->getParam(1)->scalarval(), - $xmlrpcmsg->getParam(2)->scalarval()))); + $xmlrpcmsg->getParam(1)->scalarval(), + $xmlrpcmsg->getParam(2)->scalarval()))); ob_end_flush(); return $rtn; } Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-07 02:24:38 UTC (rev 4151) +++ trunk/doc/Change.log.html 2010-11-07 02:59:00 UTC (rev 4152) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>06/11/10 Phil: ShiptChgs.php - made a check to ensure a shipment reference entered manully actually exists before it is added - otherwise a nasty error occurs on commital of the invoice <p>06/11/10 Paul T: InputSerialItemsSequential.php - Bug# 3080130 - Add new FormID to form. (and minor cleanup)</p> <p>06/11/10 Tim: ReorderLevelLocation.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: ReorderLevel.php - Remove fixed assets from selections</p> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-07 02:24:38 UTC (rev 4151) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-07 02:59:00 UTC (rev 4152) @@ -435,5 +435,5 @@ ALTER TABLE `reportfields` CHANGE `fieldname` `fieldname` VARCHAR( 80) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT ''; ALTER TABLE `stockcatproperties` ADD `maximumvalue` DOUBLE NOT NULL DEFAULT 999999999 AFTER `defaultvalue` , -ADD `minimumvalue` DOUBLE NOT NULL DEFAULT -999999999 AFTER `maximumvalue` , -ADD `numericvalue` TINYINT NOT NULL AFTER `minimumvalue`; +ADD `minimumvalue` DOUBLE NOT NULL DEFAULT -999999999, +ADD `numericvalue` TINYINT NOT NULL DEFAULT 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-08 12:06:21
|
Revision: 4153 http://web-erp.svn.sourceforge.net/web-erp/?rev=4153&view=rev Author: tim_schofield Date: 2010-11-08 12:06:15 +0000 (Mon, 08 Nov 2010) Log Message: ----------- Exson: Z_ImportStocks.php - Bug fixes. Modified Paths: -------------- trunk/Z_ImportStocks.php trunk/doc/Change.log.html Modified: trunk/Z_ImportStocks.php =================================================================== --- trunk/Z_ImportStocks.php 2010-11-07 02:59:00 UTC (rev 4152) +++ trunk/Z_ImportStocks.php 2010-11-08 12:06:15 UTC (rev 4153) @@ -1,309 +1,308 @@ -<?php -/* $Id$*/ -/* Script to make stock locations for all parts that do not have stock location records set up*/ - -$PageSecurity = 15; -include('includes/session.inc'); -$title = _('Import Items'); -include('includes/header.inc'); - -// If this script is called with a file object, then the file contents are imported -// If this script is called with the gettemplate flag, then a template file is served -// Otherwise, a file upload form is displayed - -$headers = array( - 'StockID', // 0 'STOCKID', - 'Description', // 1 'DESCRIPTION', - 'LongDescription', // 2 'LONGDESCRIPTION', - 'CategoryID', // 3 'CATEGORYID', - 'Units', // 4 'UNITS', - 'MBFlag', // 5 'MBFLAG', - 'EOQ', // 6 'EOQ', - 'Discontinued', // 7 'DISCONTINUED', - 'Controlled', // 8 'CONTROLLED', - 'Serialised', // 9 'SERIALISED', - 'Perishable', // 10 'PERISHABLE', - 'Volume', // 11 'VOLUME', - 'KGS', // 12 'KGS', - 'BarCode', // 13 'BARCODE', - 'DiscountCategory', // 14 'DISCOUNTCATEGORY', - 'TaxCat', // 15 'TAXCAT', - 'DecimalPlaces', // 16 'DECIMALPLACES', - 'ItemPDF' // 17 'ITEMPDF' -); - -if ($_FILES['userfile']['name']) { //start file processing - - //initialize - $allowType='text/csv'; - $fieldTarget = 18; - $InputError = 0; - - //check file info - $fileName = $_FILES['userfile']['name']; - $tmpName = $_FILES['userfile']['tmp_name']; - $fileSize = $_FILES['userfile']['size']; - $fileType = $_FILES['userfile']['type']; - if ($fileType != $allowType) { - prnMsg (_('File has type '. $fileType. ', but only '. $allowType. ' is allowed.'),'error'); - include('includes/footer.inc'); - exit; - } - - //get file handle - $handle = fopen($tmpName, 'r'); - - //get the header row - $headRow = fgetcsv($handle, 10000, ","); - - //check for correct number of fields - if ( count($headRow) != count($headers) ) { - prnMsg (_('File contains '. count($headRow). ' columns, expected '. count($headers). '. Try downloading a new template.'),'error'); - fclose($handle); - include('includes/footer.inc'); - exit; - } - - //test header row field name and sequence - $head = 0; - foreach ($headRow as $headField) { - if ( strtoupper($headField) != strtoupper($headers[$head]) ) { - prnMsg (_('File contains incorrect headers ('. strtoupper($headField). ' != '. strtoupper($header[$head]). '. Try downloading a new template.'),'error'); - fclose($handle); - include('includes/footer.inc'); - exit; - } - $head++; - } - - //start database transaction - DB_Txn_Begin($db); - - //loop through file rows - $row = 1; - while ( ($myrow = fgetcsv($handle, 10000, ",")) !== FALSE ) { - - //check for correct number of fields - $fieldCount = count($myrow); - if ($fieldCount != $fieldTarget){ - prnMsg (_($fieldTarget. ' fields required, '. $fieldCount. ' fields received'),'error'); - fclose($handle); - include('includes/footer.inc'); - exit; - } - - // cleanup the data (csv files often import with empty strings and such) - $StockID = strtoupper($myrow[0]); - foreach ($myrow as &$value) { - $value = trim($value); - } - - //first off check if the item already exists - $sql = "SELECT COUNT(stockid) FROM stockmaster WHERE stockid='".$StockID."'"; - $result = DB_query($sql,$db); - $testrow = DB_fetch_row($result); - if ($testrow[0] != 0) { - $InputError = 1; - prnMsg (_('Stock item "'. $StockID. '" already exists'),'error'); - } - - //next validate inputs are sensible - if (!$myrow[1] or strlen($myrow[1]) > 50 OR strlen($myrow[1])==0) { - $InputError = 1; - prnMsg (_('The stock item description must be entered and be fifty characters or less long') . '. ' . _('It cannot be a zero length string either') . ' - ' . _('a description is required'). ' ("'. implode('","',$myrow). $stockid. '") ','error'); - } - if (strlen($myrow[2])==0) { - $InputError = 1; - prnMsg (_('The stock item description cannot be a zero length string') . ' - ' . _('a long description is required'),'error'); - } - if (strlen($StockID) ==0) { - $InputError = 1; - prnMsg (_('The Stock Item code cannot be empty'),'error'); - } - if (strstr($StockID,' ') OR strstr($StockID,"'") OR strstr($StockID,'+') OR strstr($StockID,"\\") OR strstr($StockID,"\"") OR strstr($StockID,'&') OR strstr($StockID,'"')) { - $InputError = 1; - prnMsg(_('The stock item code cannot contain any of the following characters') . " ' & + \" \\ " . _('or a space'). " (". $StockID. ")",'error'); - $StockID=''; - } - if (strlen($myrow[4]) >20) { - $InputError = 1; - prnMsg(_('The unit of measure must be 20 characters or less long'),'error'); - } - if (strlen($myrow[13]) >20) { - $InputError = 1; - prnMsg(_('The barcode must be 20 characters or less long'),'error'); - } - if ($myrow[10]!=0 AND $myrow[10]!=1) { - $InputError = 1; - prnMsg (_('Values in the Perishable field must be either 0 (No) or 1 (Yes)') ,'error'); - } - if (!is_numeric($myrow[11])) { - $InputError = 1; - prnMsg (_('The volume of the packaged item in cubic metres must be numeric') ,'error'); - } - if ($myrow[11] <0) { - $InputError = 1; - prnMsg(_('The volume of the packaged item must be a positive number'),'error'); - } - if (!is_numeric($myrow[12])) { - $InputError = 1; - prnMsg(_('The weight of the packaged item in KGs must be numeric'),'error'); - } - if ($myrow[12]<0) { - $InputError = 1; - prnMsg(_('The weight of the packaged item must be a positive number'),'error'); - } - if (!is_numeric($myrow[6])) { - $InputError = 1; - prnMsg(_('The economic order quantity must be numeric'),'error'); - } - if ($$myrow[6] <0) { - $InputError = 1; - prnMsg (_('The economic order quantity must be a positive number'),'error'); - } - if ($myrow[8]==0 AND $myrow[9]==1){ - $InputError = 1; - prnMsg(_('The item can only be serialised if there is lot control enabled already') . '. ' . _('Batch control') . ' - ' . _('with any number of items in a lot/bundle/roll is enabled when controlled is enabled') . '. ' . _('Serialised control requires that only one item is in the batch') . '. ' . _('For serialised control') . ', ' . _('both controlled and serialised must be enabled'),'error'); - } - - $mbflag = $myrow[5]; - if ($mbflag!='M' and $mbflag!='K' and $mbflag!='A' and $mbflag!='B' and $mbflag!='D' and $mbflag!='G') { - $InputError = 1; - prnMsg(_('Items must be of MBFlag type Manufactured(M), Assembly(A), Kit-Set(K), Purchased(B), Dummy(D) or Phantom(G)'),'error'); - } - if (($mbflag=='A' OR $mbflag=='K' OR $mbflag=='D' OR $mbflag=='G') AND $myrow[8]==1){ - $InputError = 1; - prnMsg(_('Assembly/Kitset/Phantom/Service items cannot also be controlled items') . '. ' . _('Assemblies, Dummies and Kitsets are not physical items and batch/serial control is therefore not appropriate'),'error'); - } - if ($myrow[3]==''){ - $InputError = 1; - prnMsg(_('There are no inventory categories defined. All inventory items must belong to a valid inventory category,'),'error'); - } - if ($myrow[17]==''){ - $InputError = 1; - prnMsg(_('ItemPDF must contain either a filename, or the keyword `none`'),'error'); - } - - if ($InputError !=1){ - if ($myrow[9]==1){ /*Not appropriate to have several dp on serial items */ - $myrow[16]=0; - } - - //attempt to insert the stock item - $sql = " - INSERT INTO stockmaster ( - stockid, - description, - longdescription, - categoryid, - units, - mbflag, - eoq, - discontinued, - controlled, - serialised, - perishable, - volume, - kgs, - barcode, - discountcategory, - taxcatid, - decimalplaces, - appendfile) - VALUES ( - '$StockID', - '" . $myrow[1] . "', - '" . $myrow[2] . "', - '" . $myrow[3] . "', - '" . $myrow[4] . "', - '" . $myrow[5] . "', - " . $myrow[6] . ", - " . $myrow[7] . ", - " . $myrow[8] . ", - " . $myrow[9] . ", - " . $myrow[10] . ", - " . $myrow[11] . ", - " . $myrow[12] . ", - '" . $myrow[13] . "', - '" . $myrow[14] . "', - " . $myrow[15] . ", - " . $myrow[16] . ", - '" . $myrow[17] . "' - ); - "; - - $ErrMsg = _('The item could not be added because'); - $DbgMsg = _('The SQL that was used to add the item failed was'); - $result = DB_query($sql,$db, $ErrMsg, $DbgMsg); - - if (DB_error_no($db) ==0) { //the insert of the new code worked so bang in the stock location records too - - $sql = "INSERT INTO locstock (loccode, - stockid) - SELECT locations.loccode, - '" . $StockID . "' - FROM locations"; - - $ErrMsg = _('The locations for the item') . ' ' . $StockID . ' ' . _('could not be added because'); - $DbgMsg = _('NB Locations records can be added by opening the utility page') . ' <i>Z_MakeStockLocns.php</i> ' . _('The SQL that was used to add the location records that failed was'); - $InsResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); - - if (DB_error_no($db) ==0) { - prnMsg( _('New Item') .' ' . $StockID . ' '. _('has been added to the transaction'),'info'); - } else { //location insert failed so set some useful error info - $InputError = 1; - prnMsg(_($InsResult),'error'); - } - - } else { //item insert failed so set some useful error info - $InputError = 1; - prnMsg(_($InsResult),'error'); - } - - } - - if ($InputError == 1) { //this row failed so exit loop - break; - } - - $row++; - - } - - if ($InputError == 1) { //exited loop with errors so rollback - prnMsg(_('Failed on row '. $row. '. Batch import has been rolled back.'),'error'); - DB_Txn_Rollback($db); - } else { //all good so commit data transaction - DB_Txn_Commit($db); - prnMsg( _('Batch Import of') .' ' . $fileName . ' '. _('has been completed. All transactions committed to the database.'),'success'); - } - - fclose($handle); - -} elseif ( isset($_POST['gettemplate']) || isset($_GET['gettemplate']) ) { //download an import template - - echo '<br /><br /><br />"'. implode('","',$headers). '"<br /><br /><br />'; - -} else { //show file upload form - - echo ' - <br /> - <a href="Z_ImportStocks.php?gettemplate=1">Get Import Template</a> - <br /> - <br /> - '; - - echo "<form ENCtype='multipart/form-data' action='Z_ImportStocks.php' method=post>" - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - - echo "<input type='hidden' name='MAX_FILE_SIZE' value='1000000'>" . - _('Upload file') . ": <input name='userfile' type='file'> - <input type='submit' VALUE='" . _('Send File') . "'> - </form> - "; - -} - - -include('includes/footer.inc'); -?> +<?php +/* $Id: Z_ImportStocks.php 4043 2010-09-30 16:17:53Z tim_schofield $*/ +/* Script to make stock locations for all parts that do not have stock location records set up*/ + +$PageSecurity = 15; +include('includes/session.inc'); +$title = _('Import Items'); +include('includes/header.inc'); + +// If this script is called with a file object, then the file contents are imported +// If this script is called with the gettemplate flag, then a template file is served +// Otherwise, a file upload form is displayed + +$headers = array( + 'StockID', // 0 'STOCKID', + 'Description', // 1 'DESCRIPTION', + 'LongDescription', // 2 'LONGDESCRIPTION', + 'CategoryID', // 3 'CATEGORYID', + 'Units', // 4 'UNITS', + 'MBFlag', // 5 'MBFLAG', + 'EOQ', // 6 'EOQ', + 'Discontinued', // 7 'DISCONTINUED', + 'Controlled', // 8 'CONTROLLED', + 'Serialised', // 9 'SERIALISED', + 'Perishable', // 10 'PERISHABLE', + 'Volume', // 11 'VOLUME', + 'KGS', // 12 'KGS', + 'BarCode', // 13 'BARCODE', + 'DiscountCategory', // 14 'DISCOUNTCATEGORY', + 'TaxCat', // 15 'TAXCAT', + 'DecimalPlaces', // 16 'DECIMALPLACES', + 'ItemPDF' // 17 'ITEMPDF' +); + +if ($_FILES['userfile']['name']) { //start file processing + + //initialize + $allowType='text/csv'; + $fieldTarget = 18; + $InputError = 0; + + //check file info + $fileName = $_FILES['userfile']['name']; + $tmpName = $_FILES['userfile']['tmp_name']; + $fileSize = $_FILES['userfile']['size']; + $fileType = $_FILES['userfile']['type']; + if ($fileType != $allowType) { + prnMsg (_('File has type '. $fileType. ', but only '. $allowType. ' is allowed.'),'error'); + include('includes/footer.inc'); + exit; + } + + //get file handle + $handle = fopen($tmpName, 'r'); + + //get the header row + $headRow = fgetcsv($handle, 10000, ","); + + //check for correct number of fields + if ( count($headRow) != count($headers) ) { + prnMsg (_('File contains '. count($headRow). ' columns, expected '. count($headers). '. Try downloading a new template.'),'error'); + fclose($handle); + include('includes/footer.inc'); + exit; + } + + //test header row field name and sequence + $head = 0; + foreach ($headRow as $headField) { + if ( strtoupper($headField) != strtoupper($headers[$head]) ) { + prnMsg (_('File contains incorrect headers ('. strtoupper($headField). ' != '. strtoupper($header[$head]). '. Try downloading a new template.'),'error'); + fclose($handle); + include('includes/footer.inc'); + exit; + } + $head++; + } + + //start database transaction + DB_Txn_Begin($db); + + //loop through file rows + $row = 1; + while ( ($myrow = fgetcsv($handle, 10000, ",")) !== FALSE ) { + + //check for correct number of fields + $fieldCount = count($myrow); + if ($fieldCount != $fieldTarget){ + prnMsg (_($fieldTarget. ' fields required, '. $fieldCount. ' fields received'),'error'); + fclose($handle); + include('includes/footer.inc'); + exit; + } + + // cleanup the data (csv files often import with empty strings and such) + $StockID = strtoupper($myrow[0]); + foreach ($myrow as &$value) { + $value = trim($value); + } + + //first off check if the item already exists + $sql = "SELECT COUNT(stockid) FROM stockmaster WHERE stockid='".$StockID."'"; + $result = DB_query($sql,$db); + $testrow = DB_fetch_row($result); + if ($testrow[0] != 0) { + $InputError = 1; + prnMsg (_('Stock item "'. $StockID. '" already exists'),'error'); + } + + //next validate inputs are sensible + if (!$myrow[1] or strlen($myrow[1]) > 50 OR strlen($myrow[1])==0) { + $InputError = 1; + prnMsg (_('The stock item description must be entered and be fifty characters or less long') . '. ' . _('It cannot be a zero length string either') . ' - ' . _('a description is required'). ' ("'. implode('","',$myrow). $stockid. '") ','error'); + } + if (strlen($myrow[2])==0) { + $InputError = 1; + prnMsg (_('The stock item description cannot be a zero length string') . ' - ' . _('a long description is required'),'error'); + } + if (strlen($StockID) ==0) { + $InputError = 1; + prnMsg (_('The Stock Item code cannot be empty'),'error'); + } + if (strstr($StockID,' ') OR strstr($StockID,"'") OR strstr($StockID,'+') OR strstr($StockID,"\\") OR strstr($StockID,"\"") OR strstr($StockID,'&') OR strstr($StockID,'"')) { + $InputError = 1; + prnMsg(_('The stock item code cannot contain any of the following characters') . " ' & + \" \\ " . _('or a space'). " (". $StockID. ")",'error'); + $StockID=''; + } + if (strlen($myrow[4]) >20) { + $InputError = 1; + prnMsg(_('The unit of measure must be 20 characters or less long'),'error'); + } + if (strlen($myrow[13]) >20) { + $InputError = 1; + prnMsg(_('The barcode must be 20 characters or less long'),'error'); + } + if ($myrow[10]!=0 AND $myrow[10]!=1) { + $InputError = 1; + prnMsg (_('Values in the Perishable field must be either 0 (No) or 1 (Yes)') ,'error'); + } + if (!is_numeric($myrow[11])) { + $InputError = 1; + prnMsg (_('The volume of the packaged item in cubic metres must be numeric') ,'error'); + } + if ($myrow[11] <0) { + $InputError = 1; + prnMsg(_('The volume of the packaged item must be a positive number'),'error'); + } + if (!is_numeric($myrow[12])) { + $InputError = 1; + prnMsg(_('The weight of the packaged item in KGs must be numeric'),'error'); + } + if ($myrow[12]<0) { + $InputError = 1; + prnMsg(_('The weight of the packaged item must be a positive number'),'error'); + } + if (!is_numeric($myrow[6])) { + $InputError = 1; + prnMsg(_('The economic order quantity must be numeric'),'error'); + } + if ($$myrow[6] <0) { + $InputError = 1; + prnMsg (_('The economic order quantity must be a positive number'),'error'); + } + if ($myrow[8]==0 AND $myrow[9]==1){ + $InputError = 1; + prnMsg(_('The item can only be serialised if there is lot control enabled already') . '. ' . _('Batch control') . ' - ' . _('with any number of items in a lot/bundle/roll is enabled when controlled is enabled') . '. ' . _('Serialised control requires that only one item is in the batch') . '. ' . _('For serialised control') . ', ' . _('both controlled and serialised must be enabled'),'error'); + } + + $mbflag = $myrow[5]; + if ($mbflag!='M' and $mbflag!='K' and $mbflag!='A' and $mbflag!='B' and $mbflag!='D' and $mbflag!='G') { + $InputError = 1; + prnMsg(_('Items must be of MBFlag type Manufactured(M), Assembly(A), Kit-Set(K), Purchased(B), Dummy(D) or Phantom(G)'),'error'); + } + if (($mbflag=='A' OR $mbflag=='K' OR $mbflag=='D' OR $mbflag=='G') AND $myrow[8]==1){ + $InputError = 1; + prnMsg(_('Assembly/Kitset/Phantom/Service items cannot also be controlled items') . '. ' . _('Assemblies, Dummies and Kitsets are not physical items and batch/serial control is therefore not appropriate'),'error'); + } + if ($myrow[3]==''){ + $InputError = 1; + prnMsg(_('There are no inventory categories defined. All inventory items must belong to a valid inventory category,'),'error'); + } + if ($myrow[17]==''){ + $InputError = 1; + prnMsg(_('ItemPDF must contain either a filename, or the keyword `none`'),'error'); + } + + if ($InputError !=1){ + if ($myrow[9]==1){ /*Not appropriate to have several dp on serial items */ + $myrow[16]=0; + } + + //attempt to insert the stock item + $sql = " + INSERT INTO stockmaster ( + stockid, + description, + longdescription, + categoryid, + units, + mbflag, + eoq, + discontinued, + controlled, + serialised, + perishable, + volume, + kgs, + barcode, + discountcategory, + taxcatid, + decimalplaces, + appendfile) + VALUES ( + '$StockID', + '" . $myrow[1] . "', + '" . $myrow[2] . "', + '" . $myrow[3] . "', + '" . $myrow[4] . "', + '" . $myrow[5] . "', + " . $myrow[6] . ", + " . $myrow[7] . ", + " . $myrow[8] . ", + " . $myrow[9] . ", + " . $myrow[10] . ", + " . $myrow[11] . ", + " . $myrow[12] . ", + '" . $myrow[13] . "', + '" . $myrow[14] . "', + " . $myrow[15] . ", + " . $myrow[16] . ", + '" . $myrow[17] . "' + ); + "; + + $ErrMsg = _('The item could not be added because'); + $DbgMsg = _('The SQL that was used to add the item failed was'); + $result = DB_query($sql,$db, $ErrMsg, $DbgMsg); + + if (DB_error_no($db) ==0) { //the insert of the new code worked so bang in the stock location records too + + $sql = "INSERT INTO locstock (loccode, + stockid) + SELECT locations.loccode, + '" . $StockID . "' + FROM locations"; + + $ErrMsg = _('The locations for the item') . ' ' . $StockID . ' ' . _('could not be added because'); + $DbgMsg = _('NB Locations records can be added by opening the utility page') . ' <i>Z_MakeStockLocns.php</i> ' . _('The SQL that was used to add the location records that failed was'); + $InsResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); + + if (DB_error_no($db) ==0) { + prnMsg( _('New Item') .' ' . $StockID . ' '. _('has been added to the transaction'),'info'); + } else { //location insert failed so set some useful error info + $InputError = 1; + prnMsg(_($InsResult),'error'); + } + + } else { //item insert failed so set some useful error info + $InputError = 1; + prnMsg(_($InsResult),'error'); + } + + } + + if ($InputError == 1) { //this row failed so exit loop + break; + } + + $row++; + + } + + if ($InputError == 1) { //exited loop with errors so rollback + prnMsg(_('Failed on row '. $row. '. Batch import has been rolled back.'),'error'); + DB_Txn_Rollback($db); + } else { //all good so commit data transaction + DB_Txn_Commit($db); + prnMsg( _('Batch Import of') .' ' . $fileName . ' '. _('has been completed. All transactions committed to the database.'),'success'); + } + + fclose($handle); + +} elseif ( isset($_POST['gettemplate']) || isset($_GET['gettemplate']) ) { //download an import template + + echo '<br /><br /><br />"'. implode('","',$headers). '"<br /><br /><br />'; + +} else { //show file upload form + + echo ' + <br /> + <a href="Z_ImportStocks.php?gettemplate=1">Get Import Template</a> + <br /> + <br /> + '; + echo "<form ENCtype='multipart/form-data' action='Z_ImportStocks.php' method=post>"; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '">'; + + echo "<input type='hidden' name='MAX_FILE_SIZE' value='1000000'>" . + _('Upload file') . ": <input name='userfile' type='file'> + <input type='submit' VALUE='" . _('Send File') . "'> + </form> + "; + +} + + +include('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-07 02:59:00 UTC (rev 4152) +++ trunk/doc/Change.log.html 2010-11-08 12:06:15 UTC (rev 4153) @@ -1,6 +1,7 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> -<p>06/11/10 Phil: ShiptChgs.php - made a check to ensure a shipment reference entered manully actually exists before it is added - otherwise a nasty error occurs on commital of the invoice +<p>08/11/10 Exson: Z_ImportStocks.php - Bug fixes.</p> +<p>06/11/10 Phil: ShiptChgs.php - made a check to ensure a shipment reference entered manully actually exists before it is added - otherwise a nasty error occurs on commital of the invoice</p> <p>06/11/10 Paul T: InputSerialItemsSequential.php - Bug# 3080130 - Add new FormID to form. (and minor cleanup)</p> <p>06/11/10 Tim: ReorderLevelLocation.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: ReorderLevel.php - Remove fixed assets from selections</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-13 22:21:05
|
Revision: 4155 http://web-erp.svn.sourceforge.net/web-erp/?rev=4155&view=rev Author: daintree Date: 2010-11-13 22:20:58 +0000 (Sat, 13 Nov 2010) Log Message: ----------- Reviewed and amended/rewrote SelectAssetType.php script Modified Paths: -------------- trunk/FixedAssetItems.php Added Paths: ----------- trunk/SelectAsset.php Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-11-13 20:56:25 UTC (rev 4154) +++ trunk/FixedAssetItems.php 2010-11-13 22:20:58 UTC (rev 4155) @@ -5,29 +5,31 @@ $PageSecurity = 11; +/*The fixed asset module follows the same logic to a large extent as stock - this script was a copy of the Stocks.php script */ + include('includes/session.inc'); $title = _('Fixed Asset Item Maintenance'); include('includes/header.inc'); -echo '<a href="' . $rootpath . '/SelectAssetType.php?' . SID . '">' . _('Back to Select') . '</a><br>' . "\n"; +echo '<a href="' . $rootpath . '/SelectAsset.php?' . SID . '">' . _('Back to Select') . '</a><br>' . "\n"; echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . _('Fixed Asset Items') . '" alt="">' . ' ' . $title . '</p>'; -/*If this form is called with the StockID then it is assumed that the stock item is to be modified */ +/*If this form is called with the AssetID then it is assumed that the asset is to be modified */ -if (isset($_GET['StockID'])){ - $StockID =trim(strtoupper($_GET['StockID'])); -} elseif (isset($_POST['StockID'])){ - $StockID =trim(strtoupper($_POST['StockID'])); +if (isset($_GET['AssetID'])){ + $AssetID =trim(strtoupper($_GET['AssetID'])); +} elseif (isset($_POST['AssetID'])){ + $AssetID =trim(strtoupper($_POST['AssetID'])); } elseif (isset($_POST['Select'])){ - $StockID =trim(strtoupper($_POST['Select'])); + $AssetID =trim(strtoupper($_POST['Select'])); } else { - $StockID = ''; + $AssetID = ''; } -if (isset($StockID)) { - $sql = "SELECT COUNT(stockid) FROM assetmanager WHERE stockid='".$StockID."'"; +if (isset($AssetID)) { + $sql = "SELECT COUNT(stockid) FROM assetmanager WHERE stockid='".$AssetID."'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]==0) { @@ -41,7 +43,7 @@ $result = $_FILES['ItemPicture']['error']; $UploadTheFile = 'Yes'; //Assume all is well to start off with - $filename = $_SESSION['part_pics_dir'] . '/' . $StockID . '.jpg'; + $filename = $_SESSION['part_pics_dir'] . '/' . $AssetID . '.jpg'; //But check for the worst if (strtoupper(substr(trim($_FILES['ItemPicture']['name']),strlen($_FILES['ItemPicture']['name'])-3))!='JPG'){ @@ -98,18 +100,18 @@ $Errors[$i] = 'LongDescription'; $i++; } - if (strlen($StockID) ==0) { + if (strlen($AssetID) ==0) { $InputError = 1; prnMsg (_('The Stock Item code cannot be empty'),'error'); - $Errors[$i] = 'StockID'; + $Errors[$i] = 'AssetID'; $i++; } - if (strstr($StockID,' ') OR strstr($StockID,"'") OR strstr($StockID,'+') OR strstr($StockID,"\\") OR strstr($StockID,"\"") OR strstr($StockID,'&') OR strstr($StockID,'.') OR strstr($StockID,'"')) { + if (strstr($AssetID,' ') OR strstr($AssetID,"'") OR strstr($AssetID,'+') OR strstr($AssetID,"\\") OR strstr($AssetID,"\"") OR strstr($AssetID,'&') OR strstr($AssetID,'.') OR strstr($AssetID,'"')) { $InputError = 1; prnMsg(_('The stock item code cannot contain any of the following characters') . " - ' & + \" \\ " . _('or a space'),'error'); - $Errors[$i] = 'StockID'; + $Errors[$i] = 'AssetID'; $i++; - $StockID=''; + $AssetID=''; } if (strlen($_POST['Units']) >20) { $InputError = 1; @@ -214,14 +216,14 @@ $sql = "SELECT mbflag, controlled, serialised - FROM stockmaster WHERE stockid = '" . $StockID . "'"; + FROM stockmaster WHERE stockid = '" . $AssetID . "'"; $MBFlagResult = DB_query($sql,$db); $myrow = DB_fetch_row($MBFlagResult); $OldMBFlag = $myrow[0]; $OldControlled = $myrow[1]; $OldSerialised = $myrow[2]; - $sql = "SELECT SUM(locstock.quantity) FROM locstock WHERE stockid='" . $StockID . "'"; + $sql = "SELECT SUM(locstock.quantity) FROM locstock WHERE stockid='" . $AssetID . "'"; $result = DB_query($sql,$db); $stkqtychk = DB_fetch_row($result); @@ -242,7 +244,7 @@ if ($_POST['MBFlag']=='K') { $sql = "SELECT quantity-qtyinvoiced FROM salesorderdetails - WHERE stkcode = '" . $StockID . "' + WHERE stkcode = '" . $AssetID . "' AND completed=0"; $result = DB_query($sql,$db); @@ -257,7 +259,7 @@ $sql = "SELECT quantityord-quantityrecd FROM purchorderdetails - WHERE itemcode = '" . $StockID . "' + WHERE itemcode = '" . $AssetID . "' AND completed=0"; $result = DB_query($sql,$db); @@ -270,7 +272,7 @@ /*now check that if it was a Manufactured, Kitset, Phantom or Assembly and is being changed to a purchased or dummy - that no BOM exists */ if (($OldMBFlag=='M' OR $OldMBFlag =='K' OR $OldMBFlag=='A' OR $OldMBFlag=='G') AND ($_POST['MBFlag']=='B' OR $_POST['MBFlag']=='D')) { - $sql = "SELECT COUNT(*) FROM bom WHERE parent = '" . $StockID . "'"; + $sql = "SELECT COUNT(*) FROM bom WHERE parent = '" . $AssetID . "'"; $result = DB_query($sql,$db); $ChkBOM = DB_fetch_row($result); if ($ChkBOM[0]!=0){ @@ -281,7 +283,7 @@ /*now check that if it was Manufac, Phantom or Purchased and is being changed to assembly or kitset, it is not a component on an existing BOM */ if (($OldMBFlag=='M' OR $OldMBFlag =='B' OR $OldMBFlag=='D' OR $OldMBFlag=='G') AND ($_POST['MBFlag']=='A' OR $_POST['MBFlag']=='K')) { - $sql = "SELECT COUNT(*) FROM bom WHERE component = '" . $StockID . "'"; + $sql = "SELECT COUNT(*) FROM bom WHERE component = '" . $AssetID . "'"; $result = DB_query($sql,$db); $ChkBOM = DB_fetch_row($result); if ($ChkBOM[0]!=0){ @@ -325,7 +327,7 @@ shrinkfactor='" . $_POST['ShrinkFactor'] . "', pansize='" . $_POST['Pansize'] . "', nextserialno='" . $_POST['NextSerialNo'] . "' - WHERE stockid='" . $StockID . "'"; + WHERE stockid='" . $AssetID . "'"; $ErrMsg = _('The stock item could not be updated because'); $DbgMsg = _('The SQL that was used to update the stock item and failed was'); @@ -333,7 +335,7 @@ //delete any properties for the item no longer relevant with the change of category $result = DB_query("DELETE FROM stockitemproperties - WHERE stockid ='" . $StockID . "'", + WHERE stockid ='" . $AssetID . "'", $db); //now insert any item properties @@ -349,18 +351,18 @@ $result = DB_query("INSERT INTO stockitemproperties (stockid, stkcatpropid, value) - VALUES ('" . $StockID . "', + VALUES ('" . $AssetID . "', '" . $_POST['PropID' . $i] . "', '" . $_POST['PropValue' . $i] . "')", $db); } //end of loop around properties defined for the category - prnMsg( _('Stock Item') . ' ' . $StockID . ' ' . _('has been updated'), 'success'); + prnMsg( _('Stock Item') . ' ' . $AssetID . ' ' . _('has been updated'), 'success'); echo '<br>'; } } else { //it is a NEW part //but lets be really sure here - $result = DB_query("SELECT stockid FROM stockmaster WHERE stockid='" . $StockID ."'",$db); + $result = DB_query("SELECT stockid FROM stockmaster WHERE stockid='" . $AssetID ."'",$db); if (DB_num_rows($result)==1){ prnMsg(_('The stock code entered is actually already in the database - duplicate stock codes are prohibited by the system. Try choosing an alternative stock code'),'error'); exit; @@ -386,7 +388,7 @@ appendfile, shrinkfactor, pansize) - VALUES ('" . $StockID . "', + VALUES ('" . $AssetID . "', '" . $_POST['Description'] . "', '" . $_POST['LongDescription'] . "', '" . $_POST['CategoryID'] . "', @@ -424,7 +426,7 @@ $sql="INSERT INTO stockitemproperties (stockid, stkcatpropid, value) - VALUES ('" . $StockID . "', + VALUES ('" . $AssetID . "', '" . $_POST['PropID' . $i] . "', '" . $_POST['PropValue' . $i] . "')"; $result = DB_query($sql,$db); @@ -434,16 +436,16 @@ $sql = "INSERT INTO locstock (loccode, stockid) SELECT locations.loccode, - '" . $StockID . "' + '" . $AssetID . "' FROM locations"; - $ErrMsg = _('The locations for the item') . ' ' . $StockID . ' ' . _('could not be added because'); + $ErrMsg = _('The locations for the item') . ' ' . $AssetID . ' ' . _('could not be added because'); $DbgMsg = _('NB Locations records can be added by opening the utility page') . ' <i>Z_MakeStockLocns.php</i> ' . _('The SQL that was used to add the location records that failed was'); $InsResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); if (DB_error_no($db) ==0) { prnMsg( _('New Item') .' ' . "<a - href='SelectProduct.php?StockID=$StockID'>$StockID</a>" . ' '. _('has been added to the database'),'success'); unset($_POST['LongDescription']); + href='SelectProduct.php?StockID=$AssetID'>$AssetID</a>" . ' '. _('has been added to the database'),'success'); unset($_POST['LongDescription']); unset($_POST['Description']); unset($_POST['EOQ']); // Leave Category ID set for ease of batch entry @@ -463,7 +465,7 @@ unset($_POST['ItemPDF']); unset($_POST['ShrinkFactor']); unset($_POST['Pansize']); - unset($StockID); + unset($AssetID); }//ALL WORKED SO RESET THE FORM VARIABLES }//THE INSERT OF THE NEW CODE WORKED SO BANG IN THE STOCK LOCATION RECORDS TOO }//END CHECK FOR ALREADY EXISTING ITEM OF THE SAME CODE @@ -481,7 +483,7 @@ // PREVENT DELETES IF DEPENDENT RECORDS IN 'StockMoves' - $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockid='" . $StockID . "'"; + $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockid='" . $AssetID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -490,7 +492,7 @@ echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('stock movements that refer to this item'); } else { - $sql= "SELECT COUNT(*) FROM bom WHERE component='" . $StockID . "'"; + $sql= "SELECT COUNT(*) FROM bom WHERE component='" . $AssetID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -498,7 +500,7 @@ prnMsg( _('Cannot delete this item record because there are bills of material that require this part as a component'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('bills of material that require this part as a component'); } else { - $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='" . $StockID . "'"; + $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='" . $AssetID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -506,7 +508,7 @@ prnMsg( _('Cannot delete this item record because there are existing sales orders for this part'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales order items against this part'); } else { - $sql= "SELECT COUNT(*) FROM salesanalysis WHERE stockid='" . $StockID . "'"; + $sql= "SELECT COUNT(*) FROM salesanalysis WHERE stockid='" . $AssetID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -514,7 +516,7 @@ prnMsg(_('Cannot delete this item because sales analysis records exist for it'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales analysis records against this part'); } else { - $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='" . $StockID . "'"; + $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='" . $AssetID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -522,7 +524,7 @@ prnMsg(_('Cannot delete this item because there are existing purchase order items for it'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('purchase order item record relating to this part'); } else { - $sql = "SELECT SUM(quantity) AS qoh FROM locstock WHERE stockid='" . $StockID . "'"; + $sql = "SELECT SUM(quantity) AS qoh FROM locstock WHERE stockid='" . $AssetID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]!=0) { @@ -539,23 +541,23 @@ $result = DB_Txn_Begin($db); /*Deletes LocStock records*/ - $sql ="DELETE FROM locstock WHERE stockid='" . $StockID . "'"; + $sql ="DELETE FROM locstock WHERE stockid='" . $AssetID . "'"; $result=DB_query($sql,$db,_('Could not delete the location stock records because'),'',true); /*Deletes Price records*/ - $sql ="DELETE FROM prices WHERE stockid='" . $StockID . "'"; + $sql ="DELETE FROM prices WHERE stockid='" . $AssetID . "'"; $result=DB_query($sql,$db,_('Could not delete the prices for this stock record because'),'',true); /*and cascade deletes in PurchData */ - $sql ="DELETE FROM purchdata WHERE stockid='" . $StockID . "'"; + $sql ="DELETE FROM purchdata WHERE stockid='" . $AssetID . "'"; $result=DB_query($sql,$db,_('Could not delete the purchasing data because'),'',true); /*and cascade delete the bill of material if any */ - $sql = "DELETE FROM bom WHERE parent='" . $StockID . "'"; + $sql = "DELETE FROM bom WHERE parent='" . $AssetID . "'"; $result=DB_query($sql,$db,_('Could not delete the bill of material because'),'',true); - $sql="DELETE FROM stockmaster WHERE stockid='" . $StockID . "'"; + $sql="DELETE FROM stockmaster WHERE stockid='" . $AssetID . "'"; $result=DB_query($sql,$db, _('Could not delete the item record'),'',true); $result = DB_Txn_Commit($db); - prnMsg(_('Deleted the stock master record for') . ' ' . $StockID . '....' . + prnMsg(_('Deleted the stock master record for') . ' ' . $AssetID . '....' . '<br>. . ' . _('and all the location stock records set up for the part') . '<br>. . .' . _('and any bill of material that may have been set up for the part') . '<br> . . . .' . _('and any purchasing data that may have been set up for the part') . @@ -578,7 +580,7 @@ unset($_POST['TaxCat']); unset($_POST['DecimalPlaces']); unset($_POST['ItemPDF']); - unset($StockID); + unset($AssetID); unset($_SESSION['SelectedStockItem']); //echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/SelectProduct.php?' . SID ."'>"; @@ -591,15 +593,15 @@ '"><table class=selection>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; -if (!isset($StockID) or $StockID=='') { +if (!isset($AssetID) or $AssetID=='') { -/*If the page was called without $StockID passed to page then assume a new stock item is to be entered show a form with a part Code field other wise the form showing the fields with the existing entries against the part will show for editing with only a hidden StockID field. New is set to flag that the page may have called itself and still be entering a new part, in which case the page needs to know not to go looking up details for an existing part*/ +/*If the page was called without $AssetID passed to page then assume a new stock item is to be entered show a form with a part Code field other wise the form showing the fields with the existing entries against the part will show for editing with only a hidden AssetID field. New is set to flag that the page may have called itself and still be entering a new part, in which case the page needs to know not to go looking up details for an existing part*/ $New = true; echo '<input type="hidden" name="New" value="">'. "\n"; -// echo '<input type="hidden" name="StockID" value="'.$StockID.'">'. "\n"; +// echo '<input type="hidden" name="AssetID" value="'.$AssetID.'">'. "\n"; - echo '<tr><td>'. _('Asset Code'). ':</td><td><input ' . (in_array('StockID',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="StockID" size=21 maxlength=20></td></tr>'. "\n"; + echo '<tr><td>'. _('Asset Code'). ':</td><td><input ' . (in_array('AssetID',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="AssetID" size=21 maxlength=20></td></tr>'. "\n"; } elseif (!isset($_POST['UpdateCategories']) and $InputError!=1) { // Must be modifying an existing item and no changes made yet @@ -623,7 +625,7 @@ appendfile, nextserialno FROM stockmaster - WHERE stockid ='" . $StockID . "'"; + WHERE stockid ='" . $AssetID . "'"; $result = DB_query($sql, $db); $myrow = DB_fetch_array($result); @@ -647,13 +649,13 @@ $_POST['ItemPDF'] = $myrow['appendfile']; $_POST['NextSerialNo'] = $myrow['nextserialno']; - echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$StockID.'</td></tr>'. "\n"; - echo '<input type="Hidden" name="StockID" value='.$StockID.'>'. "\n"; + echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$AssetID.'</td></tr>'. "\n"; + echo '<input type="Hidden" name="AssetID" value='.$AssetID.'>'. "\n"; echo '<input type="Hidden" name="NextSerialNo" value='.$_POST['NextSerialNo'].'>'. "\n"; } else { // some changes were made to the data so don't re-set form variables to DB ie the code above - echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$StockID.'</td></tr>'; - echo "<input type='Hidden' name='StockID' value='$StockID'>"; + echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$AssetID.'</td></tr>'; + echo "<input type='Hidden' name='AssetID' value='$AssetID'>"; } if (isset($_POST['Description'])) { @@ -715,14 +717,14 @@ if (function_exists('imagecreatefromjpg')){ $StockImgLink = '<img src="GetStockImage.php?SID&automake=1&textcolor=FFFFFF&bgcolor=CCCCCC'. - '&StockID='.urlencode($StockID). + '&AssetID='.urlencode($AssetID). '&text='. '&width=64'. '&height=64'. '" >'; } else { - if( isset($StockID) and file_exists($_SESSION['part_pics_dir'] . '/' .$StockID.'.jpg') ) { - $StockImgLink = '<img src="' . $_SESSION['part_pics_dir'] . '/' .$StockID.'.jpg" >'; + if( isset($AssetID) and file_exists($_SESSION['part_pics_dir'] . '/' .$AssetID.'.jpg') ) { + $StockImgLink = '<img src="' . $_SESSION['part_pics_dir'] . '/' .$AssetID.'.jpg" >'; } else { $StockImgLink = _('No Image'); } @@ -884,7 +886,7 @@ $PropValResult = DB_query("SELECT value FROM stockitemproperties - WHERE stockid='" . $StockID . "' + WHERE stockid='" . $AssetID . "' AND stkcatpropid ='" . $PropertyRow['stkcatpropid'] . "'", $db); $PropValRow = DB_fetch_row($PropValResult); Added: trunk/SelectAsset.php =================================================================== --- trunk/SelectAsset.php (rev 0) +++ trunk/SelectAsset.php 2010-11-13 22:20:58 UTC (rev 4155) @@ -0,0 +1,236 @@ +<?php +/* $Id$*/ +$PageSecurity = 2; +$PricesSecurity = 9; +include ('includes/session.inc'); +$title = _('Select an Asset'); +include ('includes/header.inc'); + +if (isset($_GET['AssetID'])) { + //The page is called with a AssetID + $_GET['AssetID'] = trim(strtoupper($_GET['AssetID'])); + $_POST['Select'] = trim(strtoupper($_GET['AssetID'])); +} + +if (isset($_GET['NewSearch']) or isset($_POST['Next']) or isset($_POST['Previous']) or isset($_POST['Go'])) { + unset($AssetID); + unset($_SESSION['SelectedAsset']); + unset($_POST['Select']); +} +if (!isset($_POST['PageOffset'])) { + $_POST['PageOffset'] = 1; +} else { + if ($_POST['PageOffset'] == 0) { + $_POST['PageOffset'] = 1; + } +} +if (isset($_POST['AssetCode'])) { + $_POST['AssetCode'] = trim(strtoupper($_POST['AssetCode'])); +} +// Always show the search facilities +$SQL = 'SELECT categoryid, + categorydescription + FROM stockcategory + WHERE stocktype="A" + ORDER BY categorydescription'; +$result1 = DB_query($SQL, $db); +if (DB_num_rows($result1) == 0) { + echo '<p><font size=4 color=red>' . _('Problem Report') . ':</font><br>' . _('There are no asset categories currently defined please use the link below to set them up'); + echo '<br><a href="' . $rootpath . '/FixedAssetCategories.php?' . SID . '">' . _('Define Asset Categories') . '</a>'; + exit; +} +// end of showing search facilities + +echo '<form action="SelectAsset.php?' . SID . '" method=post>'; +echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; +echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'</p>'; +echo '<table class=selection><tr>'; +echo '<td>' . _('In Asset Category') . ':'; +echo '<select name="AssetCat">'; +if (!isset($_POST['AssetCat'])) { + $_POST['AssetCat'] = ""; +} + +while ($myrow1 = DB_fetch_array($result1)) { + if ($myrow1['categoryid'] == $_POST['AssetCat']) { + echo '<option selected VALUE="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription']; + } else { + echo '<option value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription']; + } +} +echo '</select>'; +echo '<td>' . _('Enter partial') . '<b> ' . _('Description') . '</b>:</td><td>'; +if (isset($_POST['Keywords'])) { + echo '<input type="text" name="Keywords" value="' . $_POST['Keywords'] . '" size=20 maxlength=25>'; +} else { + echo '<input type="text" name="Keywords" size=20 maxlength=25>'; +} +echo '</td></tr><tr><td></td>'; +echo '<td><font size 3><b>' . _('OR') . ' ' . '</b></font>' . _('Enter partial') . ' <b>' . _('Stock Code') . '</b>:</td>'; +echo '<td>'; +if (isset($_POST['AssetCode'])) { + echo '<input type="text" name="AssetCode" value="' . $_POST['AssetCode'] . '" size=15 maxlength=18>'; +} else { + echo '<input type="text" name="AssetCode" size=15 maxlength=18>'; +} +echo '</td></tr></table><br>'; +echo '<div class="centre"><input type=submit name="Search" value="' . _('Search Now') . '"></div><br></form>'; +echo '<script type="text/javascript">defaultControl(document.forms[0].AssetCode);</script>'; +echo '</form>'; +// query for list of record(s) +if(isset($_POST['Go']) OR isset($_POST['Next']) OR isset($_POST['Previous'])) { + $_POST['Search']='Search'; +} +if (isset($_POST['Search']) OR isset($_POST['Go']) OR isset($_POST['Next']) OR isset($_POST['Previous'])) { + if (!isset($_POST['Go']) AND !isset($_POST['Next']) AND !isset($_POST['Previous'])) { + // if Search then set to first page + $_POST['PageOffset'] = 1; + } + if ($_POST['Keywords'] AND $_POST['AssetCode']) { + prnMsg( _('Asset description keywords have been used in preference to the asset code extract entered'), 'info' ); + } + if ($_POST['Keywords']) { + //insert wildcard characters in spaces + $_POST['Keywords'] = strtoupper($_POST['Keywords']); + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + if ($_POST['AssetCat'] == 'All') { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster + WHERE stockmaster.description " . LIKE . " '$SearchString' + ORDER BY stockmaster.stockid"; + } else { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster + WHERE description " . LIKE . " '$SearchString' + AND categoryid='" . $_POST['AssetCat'] . "' + ORDER BY stockmaster.stockid"; + } + } elseif (isset($_POST['AssetCode'])) { + $_POST['AssetCode'] = strtoupper($_POST['AssetCode']); + if ($_POST['AssetCat'] == 'All') { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster + WHERE stockmaster.stockid " . LIKE . " '%" . $_POST['AssetCode'] . "%' + ORDER BY stockmaster.stockid"; + } else { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster + WHERE stockmaster.stockid " . LIKE . " '%" . $_POST['AssetCode'] . "%' + AND categoryid='" . $_POST['AssetCat'] . "' + ORDER BY stockmaster.stockid"; + } + } elseif (!isset($_POST['AssetCode']) AND !isset($_POST['Keywords'])) { + if ($_POST['AssetCat'] == 'All') { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster + ORDER BY stockmaster.stockid"; + } else { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster + WHERE categoryid='" . $_POST['AssetCat'] . "' + ORDER BY stockmaster.stockid"; + } + } + $ErrMsg = _('No assets were returned by the SQL because'); + $DbgMsg = _('The SQL that returned an error was'); + $searchresult = DB_query($SQL, $db, $ErrMsg, $DbgMsg); + if (DB_num_rows($searchresult) == 0) { + prnMsg(_('No assets were returned by this search please re-enter alternative criteria to try again'), 'info'); + } + unset($_POST['Search']); +} +/* end query for list of records */ +/* display list if there is more than one record */ +if (isset($searchresult) AND !isset($_POST['Select'])) { + echo '<form action="FixedAssetItems.php?' . SID . '" method=post>'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + $ListCount = DB_num_rows($searchresult); + if ($ListCount > 0) { + // If the user hit the search button and there is more than one item to show + $ListPageMax = ceil($ListCount / $_SESSION['DisplayRecordsMax']); + if (isset($_POST['Next'])) { + if ($_POST['PageOffset'] < $ListPageMax) { + $_POST['PageOffset'] = $_POST['PageOffset'] + 1; + } + } + if (isset($_POST['Previous'])) { + if ($_POST['PageOffset'] > 1) { + $_POST['PageOffset'] = $_POST['PageOffset'] - 1; + } + } + if ($_POST['PageOffset'] > $ListPageMax) { + $_POST['PageOffset'] = $ListPageMax; + } + if ($ListPageMax > 1) { + echo "<div class='centre'><p> " . $_POST['PageOffset'] . ' ' . _('of') . ' ' . $ListPageMax . ' ' . _('pages') . '. ' . _('Go to Page') . ': '; + echo '<select name="PageOffset">'; + $ListPage = 1; + while ($ListPage <= $ListPageMax) { + if ($ListPage == $_POST['PageOffset']) { + echo '<option value=' . $ListPage . ' selected>' . $ListPage . '</option>'; + } else { + echo '<option value=' . $ListPage . '>' . $ListPage . '</option>'; + } + $ListPage++; + } + echo '</select> + <input type=submit name="Go" value="' . _('Go') . '"> + <input type=submit name="Previous" value="' . _('Previous') . '"> + <input type=submit name="Next" value="' . _('Next') . '">'; + echo '<input type=hidden name=Keywords value="'.$_POST['Keywords'].'">'; + echo '<input type=hidden name=AssetCat value="'.$_POST['AssetCat'].'">'; + echo '<input type=hidden name=AssetCode value="'.$_POST['AssetCode'].'">'; + echo '<p></div>'; + } + echo '<table cellpadding=2 colspan=7 class=selection>'; + $tableheader = '<tr> + <th>' . _('Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Units') . '</th> + </tr>'; + echo $tableheader; + $j = 1; + $k = 0; //row counter to determine background colour + $RowIndex = 0; + if (DB_num_rows($searchresult) <> 0) { + DB_data_seek($searchresult, ($_POST['PageOffset'] - 1) * $_SESSION['DisplayRecordsMax']); + } + while (($myrow = DB_fetch_array($searchresult)) AND ($RowIndex <> $_SESSION['DisplayRecordsMax'])) { + if ($k == 1) { + echo '<tr class="EvenTableRows">'; + $k = 0; + } else { + echo '<tr class="OddTableRows">'; + $k++; + } + echo "<td><input type=submit name='Select' value='".$myrow['stockid']."'></td> + <td>".$myrow['description']."</td> + <td>".$myrow['units']."</td> + </tr>"; + $j++; + if ($j == 20 AND ($RowIndex + 1 != $_SESSION['DisplayRecordsMax'])) { + $j = 1; + echo $tableheader; + } + $RowIndex = $RowIndex + 1; + //end of page full new headings if + } + //end of while loop + echo '</table></form><br>'; + } +} +/* end display list if there is more than one record */ +include ('includes/footer.inc'); +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-13 22:22:15
|
Revision: 4156 http://web-erp.svn.sourceforge.net/web-erp/?rev=4156&view=rev Author: daintree Date: 2010-11-13 22:22:09 +0000 (Sat, 13 Nov 2010) Log Message: ----------- Removed SelectAssetType.php Modified Paths: -------------- trunk/doc/Change.log.html Removed Paths: ------------- trunk/SelectAssetType.php Deleted: trunk/SelectAssetType.php =================================================================== --- trunk/SelectAssetType.php 2010-11-13 22:20:58 UTC (rev 4155) +++ trunk/SelectAssetType.php 2010-11-13 22:22:09 UTC (rev 4156) @@ -1,313 +0,0 @@ -<?php -/* $Id$*/ -$PageSecurity = 2; -$PricesSecurity = 9; -include ('includes/session.inc'); -$title = _('Select an Asset Type'); -include ('includes/header.inc'); - -if (isset($_GET['StockID'])) { - //The page is called with a StockID - $_GET['StockID'] = trim(strtoupper($_GET['StockID'])); - $_POST['Select'] = trim(strtoupper($_GET['StockID'])); -} - -if (isset($_GET['NewSearch']) or isset($_POST['Next']) or isset($_POST['Previous']) or isset($_POST['Go'])) { - unset($StockID); - unset($_SESSION['SelectedStockItem']); - unset($_POST['Select']); -} -if (!isset($_POST['PageOffset'])) { - $_POST['PageOffset'] = 1; -} else { - if ($_POST['PageOffset'] == 0) { - $_POST['PageOffset'] = 1; - } -} -if (isset($_POST['StockCode'])) { - $_POST['StockCode'] = trim(strtoupper($_POST['StockCode'])); -} -// Always show the search facilities -$SQL = 'SELECT categoryid, - categorydescription - FROM stockcategory - WHERE stocktype="A" - ORDER BY categorydescription'; -$result1 = DB_query($SQL, $db); -if (DB_num_rows($result1) == 0) { - echo '<p><font size=4 color=red>' . _('Problem Report') . ':</font><br>' . _('There are no stock categories currently defined please use the link below to set them up'); - echo '<br><a href="' . $rootpath . '/StockCategories.php?' . SID . '">' . _('Define Stock Categories') . '</a>'; - exit; -} -// end of showing search facilities -/* displays item options if there is one and only one selected */ -if (!isset($_POST['Search']) AND (isset($_POST['Select']) OR isset($_SESSION['SelectedStockItem']))) { - if (isset($_POST['Select'])) { - $_SESSION['SelectedStockItem'] = $_POST['Select']; - $StockID = $_POST['Select']; - unset($_POST['Select']); - } else { - $StockID = $_SESSION['SelectedStockItem']; - } - $sql="SELECT stockmaster.description, - stockmaster.mbflag, - stockcategory.stocktype, - stockmaster.units, - stockmaster.decimalplaces, - stockmaster.controlled, - stockmaster.serialised, - stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost AS cost, - stockmaster.discontinued, - stockmaster.eoq, - stockmaster.volume, - stockmaster.kgs - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE stockid='" . $StockID . "'"; - $result = DB_query($sql, $db); - $myrow = DB_fetch_array($result); - $Its_A_Kitset_Assembly_Or_Dummy = false; - $Its_A_Dummy = false; - $Its_A_Kitset = false; - $Its_A_Labour_Item = false; -} else { - // options (links) to pages. This requires stock id also to be passed. -} // end displaying item options if there is one and only one record -echo '<form action="SelectAssetType.php?' . SID . '" method=post>'; -echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; -echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'</p>'; -echo '<table class=selection><tr>'; -echo '<td>' . _('In Stock Category') . ':'; -echo '<select name="StockCat">'; -if (!isset($_POST['StockCat'])) { - $_POST['StockCat'] = ""; -} - -while ($myrow1 = DB_fetch_array($result1)) { - if ($myrow1['categoryid'] == $_POST['StockCat']) { - echo '<option selected VALUE="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription']; - } else { - echo '<option value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription']; - } -} -echo '</select>'; -echo '<td>' . _('Enter partial') . '<b> ' . _('Description') . '</b>:</td><td>'; -if (isset($_POST['Keywords'])) { - echo '<input type="text" name="Keywords" value="' . $_POST['Keywords'] . '" size=20 maxlength=25>'; -} else { - echo '<input type="text" name="Keywords" size=20 maxlength=25>'; -} -echo '</td></tr><tr><td></td>'; -echo '<td><font size 3><b>' . _('OR') . ' ' . '</b></font>' . _('Enter partial') . ' <b>' . _('Stock Code') . '</b>:</td>'; -echo '<td>'; -if (isset($_POST['StockCode'])) { - echo '<input type="text" name="StockCode" value="' . $_POST['StockCode'] . '" size=15 maxlength=18>'; -} else { - echo '<input type="text" name="StockCode" size=15 maxlength=18>'; -} -echo '</td></tr></table><br>'; -echo '<div class="centre"><input type=submit name="Search" value="' . _('Search Now') . '"></div><br></form>'; -echo '<script type="text/javascript">defaultControl(document.forms[0].StockCode);</script>'; -echo '</form>'; -// query for list of record(s) -if(isset($_POST['Go']) OR isset($_POST['Next']) OR isset($_POST['Previous'])) { - $_POST['Search']='Search'; -} -if (isset($_POST['Search']) OR isset($_POST['Go']) OR isset($_POST['Next']) OR isset($_POST['Previous'])) { - if (!isset($_POST['Go']) AND !isset($_POST['Next']) AND !isset($_POST['Previous'])) { - // if Search then set to first page - $_POST['PageOffset'] = 1; - } - if ($_POST['Keywords'] AND $_POST['StockCode']) { - prnMsg( _('Stock description keywords have been used in preference to the Stock code extract entered'), 'info' ); - } - if ($_POST['Keywords']) { - //insert wildcard characters in spaces - $_POST['Keywords'] = strtoupper($_POST['Keywords']); - $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; - if ($_POST['StockCat'] == 'All') { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.mbflag, - stockmaster.decimalplaces - FROM stockmaster - WHERE stockmaster.description " . LIKE . " '$SearchString' - GROUP BY stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.mbflag, - stockmaster.decimalplaces - ORDER BY stockmaster.stockid"; - } else { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.mbflag, - stockmaster.decimalplaces - FROM stockmaster - WHERE description " . LIKE . " '$SearchString' - AND categoryid='" . $_POST['StockCat'] . "' - GROUP BY stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.mbflag, - stockmaster.decimalplaces - ORDER BY stockmaster.stockid"; - } - } elseif (isset($_POST['StockCode'])) { - $_POST['StockCode'] = strtoupper($_POST['StockCode']); - if ($_POST['StockCat'] == 'All') { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.mbflag, - stockmaster.units, - stockmaster.decimalplaces - FROM stockmaster - WHERE stockmaster.stockid " . LIKE . " '%" . $_POST['StockCode'] . "%' - GROUP BY stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.mbflag, - stockmaster.decimalplaces - ORDER BY stockmaster.stockid"; - } else { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.mbflag, - stockmaster.units, - stockmaster.decimalplaces - FROM stockmaster - WHERE stockmaster.stockid " . LIKE . " '%" . $_POST['StockCode'] . "%' - AND categoryid='" . $_POST['StockCat'] . "' - GROUP BY stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.mbflag, - stockmaster.decimalplaces - ORDER BY stockmaster.stockid"; - } - } elseif (!isset($_POST['StockCode']) AND !isset($_POST['Keywords'])) { - if ($_POST['StockCat'] == 'All') { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.mbflag, - stockmaster.units, - stockmaster.decimalplaces - FROM stockmaster - GROUP BY stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.mbflag, - stockmaster.decimalplaces - ORDER BY stockmaster.stockid"; - } else { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.mbflag, - stockmaster.units, - stockmaster.decimalplaces - FROM stockmaster - WHERE categoryid='" . $_POST['StockCat'] . "' - GROUP BY stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.mbflag, - stockmaster.decimalplaces - ORDER BY stockmaster.stockid"; - } - } - $ErrMsg = _('No stock items were returned by the SQL because'); - $DbgMsg = _('The SQL that returned an error was'); - $searchresult = DB_query($SQL, $db, $ErrMsg, $DbgMsg); - if (DB_num_rows($searchresult) == 0) { - prnMsg(_('No stock items were returned by this search please re-enter alternative criteria to try again'), 'info'); - } - unset($_POST['Search']); -} -/* end query for list of records */ -/* display list if there is more than one record */ -if (isset($searchresult) AND !isset($_POST['Select'])) { - echo '<form action="FixedAssetItems.php?' . SID . '" method=post>'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - $ListCount = DB_num_rows($searchresult); - if ($ListCount > 0) { - // If the user hit the search button and there is more than one item to show - $ListPageMax = ceil($ListCount / $_SESSION['DisplayRecordsMax']); - if (isset($_POST['Next'])) { - if ($_POST['PageOffset'] < $ListPageMax) { - $_POST['PageOffset'] = $_POST['PageOffset'] + 1; - } - } - if (isset($_POST['Previous'])) { - if ($_POST['PageOffset'] > 1) { - $_POST['PageOffset'] = $_POST['PageOffset'] - 1; - } - } - if ($_POST['PageOffset'] > $ListPageMax) { - $_POST['PageOffset'] = $ListPageMax; - } - if ($ListPageMax > 1) { - echo "<div class='centre'><p> " . $_POST['PageOffset'] . ' ' . _('of') . ' ' . $ListPageMax . ' ' . _('pages') . '. ' . _('Go to Page') . ': '; - echo '<select name="PageOffset">'; - $ListPage = 1; - while ($ListPage <= $ListPageMax) { - if ($ListPage == $_POST['PageOffset']) { - echo '<option value=' . $ListPage . ' selected>' . $ListPage . '</option>'; - } else { - echo '<option value=' . $ListPage . '>' . $ListPage . '</option>'; - } - $ListPage++; - } - echo '</select> - <input type=submit name="Go" value="' . _('Go') . '"> - <input type=submit name="Previous" value="' . _('Previous') . '"> - <input type=submit name="Next" value="' . _('Next') . '">'; - echo '<input type=hidden name=Keywords value="'.$_POST['Keywords'].'">'; - echo '<input type=hidden name=StockCat value="'.$_POST['StockCat'].'">'; - echo '<input type=hidden name=StockCode value="'.$_POST['StockCode'].'">'; -// echo '<input type=hidden name=Search value="Search">'; - echo '<p></div>'; - } - echo '<table cellpadding=2 colspan=7 class=selection>'; - $tableheader = '<tr> - <th>' . _('Code') . '</th> - <th>' . _('Description') . '</th> - <th>' . _('Units') . '</th> - <th>' . _('Stock Status') . '</th> - </tr>'; - echo $tableheader; - $j = 1; - $k = 0; //row counter to determine background colour - $RowIndex = 0; - if (DB_num_rows($searchresult) <> 0) { - DB_data_seek($searchresult, ($_POST['PageOffset'] - 1) * $_SESSION['DisplayRecordsMax']); - } - while (($myrow = DB_fetch_array($searchresult)) AND ($RowIndex <> $_SESSION['DisplayRecordsMax'])) { - if ($k == 1) { - echo '<tr class="EvenTableRows">'; - $k = 0; - } else { - echo '<tr class="OddTableRows">'; - $k++; - } - echo "<td><input type=submit name='Select' value='".$myrow['stockid']."'></td> - <td>".$myrow['description']."</td> - <td>".$myrow['units']."</td> - <td><a target='_blank' href='" . $rootpath . "/StockStatus.php?" . SID . "&StockID=".$myrow['stockid']."'>" . _('View') . "</a></td> - </tr>"; - $j++; - if ($j == 20 AND ($RowIndex + 1 != $_SESSION['DisplayRecordsMax'])) { - $j = 1; - echo $tableheader; - } - $RowIndex = $RowIndex + 1; - //end of page full new headings if - } - //end of while loop - echo '</table></form><br>'; - } -} -/* end display list if there is more than one record */ -include ('includes/footer.inc'); -?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-13 22:20:58 UTC (rev 4155) +++ trunk/doc/Change.log.html 2010-11-13 22:22:09 UTC (rev 4156) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>14/11/10 Phil: SelectAsset.php script reworked SelectAssetType.php script now deleted</p> <p>08/11/10 Exson: Z_ImportStocks.php - Bug fixes.</p> <p>06/11/10 Phil: ShiptChgs.php - made a check to ensure a shipment reference entered manully actually exists before it is added - otherwise a nasty error occurs on commital of the invoice</p> <p>06/11/10 Paul T: InputSerialItemsSequential.php - Bug# 3080130 - Add new FormID to form. (and minor cleanup)</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-13 23:04:00
|
Revision: 4157 http://web-erp.svn.sourceforge.net/web-erp/?rev=4157&view=rev Author: daintree Date: 2010-11-13 23:03:50 +0000 (Sat, 13 Nov 2010) Log Message: ----------- Rework of FixedAssetItems.php - category properties not updating Modified Paths: -------------- trunk/FixedAssetItems.php trunk/index.php Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-11-13 22:22:09 UTC (rev 4156) +++ trunk/FixedAssetItems.php 2010-11-13 23:03:50 UTC (rev 4157) @@ -90,25 +90,25 @@ if (!isset($_POST['Description']) or strlen($_POST['Description']) > 50 OR strlen($_POST['Description'])==0) { $InputError = 1; - prnMsg (_('The stock item description must be entered and be fifty characters or less long') . '. ' . _('It cannot be a zero length string either') . ' - ' . _('a description is required'),'error'); + prnMsg (_('The asset description must be entered and be fifty characters or less long. It cannot be a zero length string either, a description is required'),'error'); $Errors[$i] = 'Description'; $i++; } if (strlen($_POST['LongDescription'])==0) { $InputError = 1; - prnMsg (_('The stock item description cannot be a zero length string') . ' - ' . _('a long description is required'),'error'); + prnMsg (_('The asset long description cannot be a zero length string, a long description is required'),'error'); $Errors[$i] = 'LongDescription'; $i++; } if (strlen($AssetID) ==0) { $InputError = 1; - prnMsg (_('The Stock Item code cannot be empty'),'error'); + prnMsg (_('The asset code cannot be empty'),'error'); $Errors[$i] = 'AssetID'; $i++; } - if (strstr($AssetID,' ') OR strstr($AssetID,"'") OR strstr($AssetID,'+') OR strstr($AssetID,"\\") OR strstr($AssetID,"\"") OR strstr($AssetID,'&') OR strstr($AssetID,'.') OR strstr($AssetID,'"')) { + if (ContainsIllegalCharacters($AssetID)) { $InputError = 1; - prnMsg(_('The stock item code cannot contain any of the following characters') . " - ' & + \" \\ " . _('or a space'),'error'); + prnMsg(_('The asset code cannot contain any of the following characters') . " - ' & + \" \\ " . _('or a space'),'error'); $Errors[$i] = 'AssetID'; $i++; $AssetID=''; @@ -125,85 +125,21 @@ $Errors[$i] = 'BarCode'; $i++; } - if (!is_numeric($_POST['Volume'])) { - $InputError = 1; - prnMsg (_('The volume of the packaged item in cubic metres must be numeric') ,'error'); - $Errors[$i] = 'Volume'; - $i++; - } - if ($_POST['Volume'] <0) { - $InputError = 1; - prnMsg(_('The volume of the packaged item must be a positive number'),'error'); - $Errors[$i] = 'Volume'; - $i++; - } - if (!is_numeric($_POST['KGS'])) { - $InputError = 1; - prnMsg(_('The weight of the packaged item in KGs must be numeric'),'error'); - $Errors[$i] = 'KGS'; - $i++; - } - if ($_POST['KGS']<0) { - $InputError = 1; - prnMsg(_('The weight of the packaged item must be a positive number'),'error'); - $Errors[$i] = 'KGS'; - $i++; - } - if (!is_numeric($_POST['EOQ'])) { - $InputError = 1; - prnMsg(_('The economic order quantity must be numeric'),'error'); - $Errors[$i] = 'EOQ'; - $i++; - } - if ($_POST['EOQ'] <0) { - $InputError = 1; - prnMsg (_('The economic order quantity must be a positive number'),'error'); - $Errors[$i] = 'EOQ'; - $i++; - } + if ($_POST['Controlled']==0 AND $_POST['Serialised']==1){ $InputError = 1; prnMsg(_('The item can only be serialised if there is lot control enabled already') . '. ' . _('Batch control') . ' - ' . _('with any number of items in a lot/bundle/roll is enabled when controlled is enabled') . '. ' . _('Serialised control requires that only one item is in the batch') . '. ' . _('For serialised control') . ', ' . _('both controlled and serialised must be enabled'),'error'); $Errors[$i] = 'Serialised'; $i++; } - if ($_POST['NextSerialNo']!=0 AND $_POST['Serialised']==0){ + + if (trim($_POST['AssetCategoryID'])==''){ $InputError = 1; - prnMsg(_('The item can only have automatically generated serial numbers if it is a serialised item'),'error'); - $Errors[$i] = 'NextSerialNo'; + prnMsg(_('There are no asset categories defined. All assets must belong to a valid category,'),'error'); + $Errors[$i] = 'AssetCategoryID'; $i++; } - if ($_POST['NextSerialNo']!=0 AND $_POST['MBFlag']!='M'){ - $InputError = 1; - prnMsg(_('The item can only have automatically generated serial numbers if it is a manufactured item'),'error'); - $Errors[$i] = 'NextSerialNo'; - $i++; - } - if (($_POST['MBFlag']=='A' OR $_POST['MBFlag']=='K' OR $_POST['MBFlag']=='D' OR $_POST['MBFlag']=='G') AND $_POST['Controlled']==1){ - $InputError = 1; - prnMsg(_('Assembly/Kitset/Phantom/Service/Labour items cannot also be controlled items') . '. ' . _('Assemblies/Dummies/Phantom and Kitsets are not physical items and batch/serial control is therefore not appropriate'),'error'); - $Errors[$i] = 'Controlled'; - $i++; - } - if (trim($_POST['CategoryID'])==''){ - $InputError = 1; - prnMsg(_('There are no inventory categories defined. All inventory items must belong to a valid inventory category,'),'error'); - $Errors[$i] = 'CategoryID'; - $i++; - } - if (!is_numeric($_POST['Pansize'])) { - $InputError = 1; - prnMsg(_('Pansize quantity must be numeric'),'error'); - $Errors[$i] = 'Pansize'; - $i++; - } - if (!is_numeric($_POST['ShrinkFactor'])) { - $InputError = 1; - prnMsg(_('Shrinkage factor quantity must be numeric'),'error'); - $Errors[$i] = 'ShrinkFactor'; - $i++; - } - + if ($InputError !=1){ if ($_POST['Serialised']==1){ /*Not appropriate to have several dp on serial items */ $_POST['DecimalPlaces']=0; @@ -211,7 +147,7 @@ if ($_POST['submit']==_('Update')) { /*so its an existing one */ /*first check on the changes being made we must disallow: - - changes from manufactured or purchased to Service, Assembly or Kitset if there is stock - changes from manufactured, kitset or assembly where a BOM exists + - changes from manufactured or purchased to Service, Assembly or Kitset if there is stock - changes from manufactured, kitset or assembly where a BOM exists */ $sql = "SELECT mbflag, controlled, @@ -227,72 +163,6 @@ $result = DB_query($sql,$db); $stkqtychk = DB_fetch_row($result); - if ($OldMBFlag != $_POST['MBFlag']){ - if (($OldMBFlag == 'M' OR $OldMBFlag=='B') AND ($_POST['MBFlag']=='A' OR $_POST['MBFlag']=='K' OR $_POST['MBFlag']=='D' OR $_POST['MBFlag']=='G')){ /*then need to check that there is no stock holding first */ - /* stock holding OK for phantom (ghost) items */ - if ($stkqtychk[0]!=0 AND $OldMBFlag!='G'){ - $InputError=1; - prnMsg( _('The make or buy flag cannot be changed from') . ' ' . $OldMBFlag . ' ' . _('to') . ' ' . $_POST['MBFlag'] . ' ' . _('where there is a quantity of stock on hand at any location') . '. ' . _('Currently there are') . ' ' . $stkqtychk[0] . ' ' . _('on hand') , 'errror'); - } - /* don't allow controlled/serialized */ - if ($_POST['Controlled']==1){ - $InputError=1; - prnMsg( _('The make or buy flag cannot be changed from') . ' ' . $OldMBFlag . ' ' . _('to') . ' ' . $_POST['MBFlag'] . ' ' . _('where the item is to be lot controlled') . '. ' . _('Kitset, phantom, dummy and assembly items cannot be lot controlled'), 'error'); - } - } - /*now check that if the item is being changed to a kitset, there are no items on sales orders or purchase orders*/ - if ($_POST['MBFlag']=='K') { - $sql = "SELECT quantity-qtyinvoiced - FROM salesorderdetails - WHERE stkcode = '" . $AssetID . "' - AND completed=0"; - - $result = DB_query($sql,$db); - $ChkSalesOrds = DB_fetch_row($result); - if ($ChkSalesOrds[0]!=0){ - $InputError = 1; - prnMsg( _('The make or buy flag cannot be changed to a kitset where there is a quantity outstanding to be delivered on sales orders') . '. ' . _('Currently there are') .' ' . $ChkSalesOrds[0] . ' '. _('outstanding'), 'error'); - } - } - /*now check that if it is to be a kitset or assembly or dummy there is no quantity on purchase orders outstanding*/ - if ($_POST['MBFlag']=='K' OR $_POST['MBFlag']=='A' OR $_POST['MBFlag']=='D') { - - $sql = "SELECT quantityord-quantityrecd - FROM purchorderdetails - WHERE itemcode = '" . $AssetID . "' - AND completed=0"; - - $result = DB_query($sql,$db); - $ChkPurchOrds = DB_fetch_row($result); - if ($ChkPurchOrds[0]!=0){ - $InputError = 1; - prnMsg( _('The make or buy flag cannot be changed to'). ' ' . $_POST['MBFlag'] . ' '. _('where there is a quantity outstanding to be received on purchase orders') . '. ' . _('Currently there are'). ' ' . $ChkPurchOrds[0] . ' '. _('yet to be received'). 'error'); - } - } - - /*now check that if it was a Manufactured, Kitset, Phantom or Assembly and is being changed to a purchased or dummy - that no BOM exists */ - if (($OldMBFlag=='M' OR $OldMBFlag =='K' OR $OldMBFlag=='A' OR $OldMBFlag=='G') AND ($_POST['MBFlag']=='B' OR $_POST['MBFlag']=='D')) { - $sql = "SELECT COUNT(*) FROM bom WHERE parent = '" . $AssetID . "'"; - $result = DB_query($sql,$db); - $ChkBOM = DB_fetch_row($result); - if ($ChkBOM[0]!=0){ - $InputError = 1; - prnMsg( _('The make or buy flag cannot be changed from manufactured, kitset or assembly to'). ' ' . $_POST['MBFlag'] . ' '. _('where there is a bill of material set up for the item') . '. ' . _('Bills of material are not appropriate for purchased or dummy items'), 'error'); - } - } - - /*now check that if it was Manufac, Phantom or Purchased and is being changed to assembly or kitset, it is not a component on an existing BOM */ - if (($OldMBFlag=='M' OR $OldMBFlag =='B' OR $OldMBFlag=='D' OR $OldMBFlag=='G') AND ($_POST['MBFlag']=='A' OR $_POST['MBFlag']=='K')) { - $sql = "SELECT COUNT(*) FROM bom WHERE component = '" . $AssetID . "'"; - $result = DB_query($sql,$db); - $ChkBOM = DB_fetch_row($result); - if ($ChkBOM[0]!=0){ - $InputError = 1; - prnMsg( _('The make or buy flag cannot be changed from manufactured, purchased or dummy to a kitset or assembly where the item is a component in a bill of material') . '. ' . _('Assembly and kitset items are not appropriate as components in a bill of materials'), 'error'); - } - } - } - /* Do some checks for changes in the Serial & Controlled setups */ if ($OldControlled != $_POST['Controlled'] AND $stkqtychk[0]!=0){ $InputError=1; @@ -309,28 +179,19 @@ $sql = "UPDATE stockmaster SET longdescription='" . $_POST['LongDescription'] . "', description='" . $_POST['Description'] . "', - discontinued='" . $_POST['Discontinued'] . "', controlled='" . $_POST['Controlled'] . "', serialised='" . $_POST['Serialised']."', - perishable='" . $_POST['Perishable']."', - categoryid='" . $_POST['CategoryID'] . "', + categoryid='" . $_POST['AssetCategoryID'] . "', units='" . $_POST['Units'] . "', mbflag='" . $_POST['MBFlag'] . "', - eoq='" . $_POST['EOQ'] . "', - volume='" . $_POST['Volume'] . "', - kgs='" . $_POST['KGS'] . "', barcode='" . $_POST['BarCode'] . "', - discountcategory='" . $_POST['DiscountCategory'] . "', taxcatid='" . $_POST['TaxCat'] . "', decimalplaces='" . $_POST['DecimalPlaces'] . "', appendfile='" . $_POST['ItemPDF'] . "', - shrinkfactor='" . $_POST['ShrinkFactor'] . "', - pansize='" . $_POST['Pansize'] . "', - nextserialno='" . $_POST['NextSerialNo'] . "' - WHERE stockid='" . $AssetID . "'"; + WHERE stockid='" . $AssetID . "'"; - $ErrMsg = _('The stock item could not be updated because'); - $DbgMsg = _('The SQL that was used to update the stock item and failed was'); + $ErrMsg = _('The asset could not be updated because'); + $DbgMsg = _('The SQL that was used to update the asset and failed was'); $result = DB_query($sql,$db,$ErrMsg,$DbgMsg); //delete any properties for the item no longer relevant with the change of category @@ -356,7 +217,7 @@ '" . $_POST['PropValue' . $i] . "')", $db); } //end of loop around properties defined for the category - prnMsg( _('Stock Item') . ' ' . $AssetID . ' ' . _('has been updated'), 'success'); + prnMsg( _('Asset') . ' ' . $AssetID . ' ' . _('has been updated'), 'success'); echo '<br>'; } @@ -364,7 +225,7 @@ //but lets be really sure here $result = DB_query("SELECT stockid FROM stockmaster WHERE stockid='" . $AssetID ."'",$db); if (DB_num_rows($result)==1){ - prnMsg(_('The stock code entered is actually already in the database - duplicate stock codes are prohibited by the system. Try choosing an alternative stock code'),'error'); + prnMsg(_('The asset code entered is actually already in the database - duplicate asset codes are prohibited by the system. Try choosing an alternative asset code'),'error'); exit; } else { $sql = "INSERT INTO stockmaster ( @@ -374,44 +235,28 @@ categoryid, units, mbflag, - eoq, - discontinued, controlled, serialised, - perishable, - volume, - kgs, barcode, - discountcategory, taxcatid, decimalplaces, - appendfile, - shrinkfactor, - pansize) + appendfile) VALUES ('" . $AssetID . "', '" . $_POST['Description'] . "', '" . $_POST['LongDescription'] . "', - '" . $_POST['CategoryID'] . "', + '" . $_POST['AssetCategoryID'] . "', '" . $_POST['Units'] . "', '" . $_POST['MBFlag'] . "', - '" . $_POST['EOQ'] . "', - '" . $_POST['Discontinued'] . "', '" . $_POST['Controlled'] . "', '" . $_POST['Serialised']. "', - '" . $_POST['Perishable']. "', - '" . $_POST['Volume'] . "', - '" . $_POST['KGS'] . "', '" . $_POST['BarCode'] . "', - '" . $_POST['DiscountCategory'] . "', '" . $_POST['TaxCat'] . "', '" . $_POST['DecimalPlaces']. "', - '" . $_POST['ItemPDF']. "', - '" . $_POST['ShrinkFactor'] . "', - '" . $_POST['Pansize'] . "' + '" . $_POST['ItemPDF']. "' )"; - $ErrMsg = _('The item could not be added because'); - $DbgMsg = _('The SQL that was used to add the item failed was'); + $ErrMsg = _('The asset could not be added because'); + $DbgMsg = _('The SQL that was used to add the asset failed was'); $result = DB_query($sql,$db, $ErrMsg, $DbgMsg); //now insert any item properties for ($i=0;$i<=$_POST['PropertyCounter'];$i++){ @@ -439,32 +284,23 @@ '" . $AssetID . "' FROM locations"; - $ErrMsg = _('The locations for the item') . ' ' . $AssetID . ' ' . _('could not be added because'); + $ErrMsg = _('The locations for the asset') . ' ' . $AssetID . ' ' . _('could not be added because'); $DbgMsg = _('NB Locations records can be added by opening the utility page') . ' <i>Z_MakeStockLocns.php</i> ' . _('The SQL that was used to add the location records that failed was'); $InsResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); if (DB_error_no($db) ==0) { - prnMsg( _('New Item') .' ' . "<a - href='SelectProduct.php?StockID=$AssetID'>$AssetID</a>" . ' '. _('has been added to the database'),'success'); unset($_POST['LongDescription']); + prnMsg( _('New Item') .' ' . $AssetID . ' '. _('has been added to the database'),'success'); unset($_POST['LongDescription']); unset($_POST['Description']); - unset($_POST['EOQ']); + // Leave Category ID set for ease of batch entry -// unset($_POST['CategoryID']); +// unset($_POST['AssetCategoryID']); unset($_POST['Units']); unset($_POST['MBFlag']); - unset($_POST['Discontinued']); unset($_POST['Controlled']); unset($_POST['Serialised']); - unset($_POST['Perishable']); - unset($_POST['Volume']); - unset($_POST['KGS']); unset($_POST['BarCode']); - unset($_POST['ReorderLevel']); - unset($_POST['DiscountCategory']); unset($_POST['DecimalPlaces']); unset($_POST['ItemPDF']); - unset($_POST['ShrinkFactor']); - unset($_POST['Pansize']); unset($AssetID); }//ALL WORKED SO RESET THE FORM VARIABLES }//THE INSERT OF THE NEW CODE WORKED SO BANG IN THE STOCK LOCATION RECORDS TOO @@ -545,7 +381,7 @@ $result=DB_query($sql,$db,_('Could not delete the location stock records because'),'',true); /*Deletes Price records*/ $sql ="DELETE FROM prices WHERE stockid='" . $AssetID . "'"; - $result=DB_query($sql,$db,_('Could not delete the prices for this stock record because'),'',true); + $result=DB_query($sql,$db,_('Could not delete the prices for this asset record because'),'',true); /*and cascade deletes in PurchData */ $sql ="DELETE FROM purchdata WHERE stockid='" . $AssetID . "'"; $result=DB_query($sql,$db,_('Could not delete the purchasing data because'),'',true); @@ -553,43 +389,33 @@ $sql = "DELETE FROM bom WHERE parent='" . $AssetID . "'"; $result=DB_query($sql,$db,_('Could not delete the bill of material because'),'',true); $sql="DELETE FROM stockmaster WHERE stockid='" . $AssetID . "'"; - $result=DB_query($sql,$db, _('Could not delete the item record'),'',true); + $result=DB_query($sql,$db, _('Could not delete the asset record'),'',true); $result = DB_Txn_Commit($db); - prnMsg(_('Deleted the stock master record for') . ' ' . $AssetID . '....' . - '<br>. . ' . _('and all the location stock records set up for the part') . - '<br>. . .' . _('and any bill of material that may have been set up for the part') . - '<br> . . . .' . _('and any purchasing data that may have been set up for the part') . - '<br> . . . . .' . _('and any prices that may have been set up for the part'),'success'); + prnMsg(_('Deleted the asset master record for') . ' ' . $AssetID . '....' . + '<br>. . ' . _('and all the location stock records set up for the asset') . + '<br>. . .' . _('and any bill of material that may have been set up for the asset') . + '<br> . . . .' . _('and any purchasing data that may have been set up for the asset') . + '<br> . . . . .' . _('and any prices that may have been set up for the asset'),'success'); unset($_POST['LongDescription']); unset($_POST['Description']); - unset($_POST['EOQ']); - unset($_POST['CategoryID']); + unset($_POST['AssetCategoryID']); unset($_POST['Units']); unset($_POST['MBFlag']); - unset($_POST['Discontinued']); unset($_POST['Controlled']); unset($_POST['Serialised']); - unset($_POST['Perishable']); - unset($_POST['Volume']); - unset($_POST['KGS']); unset($_POST['BarCode']); - unset($_POST['ReorderLevel']); - unset($_POST['DiscountCategory']); unset($_POST['TaxCat']); unset($_POST['DecimalPlaces']); - unset($_POST['ItemPDF']); unset($AssetID); - unset($_SESSION['SelectedStockItem']); - //echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/SelectProduct.php?' . SID ."'>"; + unset($_SESSION['SelectedAsset']); - - } //end if Delete Part + } //end if Delete Asset } -echo '<form name="ItemForm" enctype="multipart/form-data" method="post" action="' . $_SERVER['PHP_SELF'] . '?' .SID . +echo '<form name="AssetForm" enctype="multipart/form-data" method="post" action="' . $_SERVER['PHP_SELF'] . '?' .SID . '"><table class=selection>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; @@ -611,19 +437,11 @@ categoryid, units, mbflag, - discontinued, controlled, serialised, - perishable, - eoq, - volume, - kgs, barcode, - discountcategory, taxcatid, - decimalplaces, - appendfile, - nextserialno + decimalplaces FROM stockmaster WHERE stockid ='" . $AssetID . "'"; @@ -632,30 +450,23 @@ $_POST['LongDescription'] = $myrow['longdescription']; $_POST['Description'] = $myrow['description']; - $_POST['EOQ'] = $myrow['eoq']; - $_POST['CategoryID'] = $myrow['categoryid']; + $_POST['AssetCategoryID'] = $myrow['categoryid']; $_POST['Units'] = $myrow['units']; $_POST['MBFlag'] = $myrow['mbflag']; - $_POST['Discontinued'] = $myrow['discontinued']; $_POST['Controlled'] = $myrow['controlled']; $_POST['Serialised'] = $myrow['serialised']; - $_POST['Perishable'] = $myrow['perishable']; - $_POST['Volume'] = $myrow['volume']; - $_POST['KGS'] = $myrow['kgs']; $_POST['BarCode'] = $myrow['barcode']; $_POST['DiscountCategory'] = $myrow['discountcategory']; $_POST['TaxCat'] = $myrow['taxcatid']; $_POST['DecimalPlaces'] = $myrow['decimalplaces']; - $_POST['ItemPDF'] = $myrow['appendfile']; - $_POST['NextSerialNo'] = $myrow['nextserialno']; - + echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$AssetID.'</td></tr>'. "\n"; echo '<input type="Hidden" name="AssetID" value='.$AssetID.'>'. "\n"; echo '<input type="Hidden" name="NextSerialNo" value='.$_POST['NextSerialNo'].'>'. "\n"; } else { // some changes were made to the data so don't re-set form variables to DB ie the code above echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$AssetID.'</td></tr>'; - echo "<input type='Hidden' name='AssetID' value='$AssetID'>"; + echo '<input type="Hidden" name="AssetID" value="' . $AssetID . '">'; } if (isset($_POST['Description'])) { @@ -672,45 +483,6 @@ } echo '<tr><td>' . _('Asset Description') . ' (' . _('long') . '):</td><td><textarea ' . (in_array('LongDescription',$Errors) ? 'class="texterror"' : '' ) .' name="LongDescription" cols=40 rows=4>' . stripslashes($LongDescription) . '</textarea></td></tr>'."\n"; -// Generate selection drop down from pdf_append directory - by emdx, -// developed with examples from http://au2.php.net/manual/en/function.opendir.php -function select_files($dir, $label = '', $select_name = 'ItemPDF', $curr_val = '', $char_length = 60) { - $teller = 0; - if (!file_exists($dir)) { - mkdir($dir); - chmod($dir, 0777); - } - if ($handle = opendir($dir)) { - $mydir = "<select name=".$select_name.">\n"; - $mydir .= '<option VALUE=0>none'; - if (isset($_POST['ItemPDF'])) { - $curr_val = $_POST['ItemPDF']; - } else { - $curr_val .= 'none'; - } - while (false !== ($file = readdir($handle))) { - $files[] = $file; - } - closedir($handle); - sort($files); - foreach ($files as $val) { - if (is_file($dir.$val)) { - $mydir .= '<option VALUE='.$val; - $mydir .= ($val == $curr_val) ? ' selected>' : '>'; - $mydir .= $val."\n"; - $teller++; - } - } - $mydir .= ""; - } - return $mydir; -} -if (!isset($_POST['ItemPDF'])) { - $_POST['ItemPDF'] = ''; -} -echo '<tr><td>' . _('PDF attachment (.pdf)') . ':' . "\n</td><td>" . select_files('companies/' . $_SESSION['DatabaseName'] . - '/pdf_append//','' , 'ItemPDF', $_POST['ItemPDF'], '60') . '</td></tr>'. "\n"; - // Add image upload for New Item - by Ori echo '<tr><td>'. _('Image File (.jpg)') . ':</td><td><input type="file" id="ItemPicture" name="ItemPicture"></td>'; // EOR Add Image upload for New Item - by Ori @@ -738,15 +510,15 @@ // EOR Add Image upload for New Item - by Ori -echo '<tr><td>' . _('Category') . ':</td><td><select name="CategoryID" onChange="ReloadForm(ItemForm.UpdateCategories)">'; +echo '<tr><td>' . _('Category') . ':</td><td><select name="AssetCategoryID" onChange="ReloadForm(AssetForm.UpdateCategories)">'; $sql = 'SELECT categoryid, categorydescription FROM stockcategory WHERE stocktype="A"'; -$ErrMsg = _('The stock categories could not be retrieved because'); +$ErrMsg = _('The asset categories could not be retrieved because'); $DbgMsg = _('The SQL used to retrieve stock categories and failed was'); $result = DB_query($sql,$db,$ErrMsg,$DbgMsg); while ($myrow=DB_fetch_array($result)){ - if (!isset($_POST['CategoryID']) or $myrow['categoryid']==$_POST['CategoryID']){ + if (!isset($_POST['AssetCategoryID']) or $myrow['categoryid']==$_POST['AssetCategoryID']){ echo '<option selected VALUE="'. $myrow['categoryid'] . '">' . $myrow['categorydescription']; } else { echo '<option VALUE="'. $myrow['categoryid'] . '">' . $myrow['categorydescription']; @@ -754,20 +526,10 @@ $category=$myrow['categoryid']; } echo '</select><a target="_blank" href="'. $rootpath . '/FixedAssetCategories.php?' . SID . '">'.' ' . _('Add or Modify Asset Categories') . '</a></td></tr>'; -if (!isset($_POST['CategoryID'])) { - $_POST['CategoryID']=$category; +if (!isset($_POST['AssetCategoryID'])) { + $_POST['AssetCategoryID']=$category; } -if (!isset($_POST['EOQ']) or $_POST['EOQ']==''){ - $_POST['EOQ']=0; -} - -if (!isset($_POST['Volume']) or $_POST['Volume']==''){ - $_POST['Volume']=0; -} -if (!isset($_POST['KGS']) or $_POST['KGS']==''){ - $_POST['KGS']=0; -} if (!isset($_POST['Controlled']) or $_POST['Controlled']==''){ $_POST['Controlled']=0; } @@ -777,26 +539,7 @@ if (!isset($_POST['DecimalPlaces']) or $_POST['DecimalPlaces']==''){ $_POST['DecimalPlaces']=0; } -if (!isset($_POST['Discontinued']) or $_POST['Discontinued']==''){ - $_POST['Discontinued']=0; -} -if (!isset($_POST['Pansize'])) { - $_POST['Pansize']=0; -} -if (!isset($_POST['ShrinkFactor'])) { - $_POST['ShrinkFactor']=0; -} -if (!isset($_POST['NextSerialNo'])) { - $_POST['NextSerialNo']=0; -} - -echo '<input type="hidden" class="number" name="EOQ" size=12 maxlength=10 value="0">'; - -echo '<tr><td>' . _('Packaged Volume (metres cubed)') . ':</td><td><input ' . (in_array('Volume',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" class="number" name="Volume" size=12 maxlength=10 value="' . $_POST['Volume'] . '"></td></tr>'; - -echo '<tr><td>' . _('Packaged Weight (KGs)') . ':</td><td><input ' . (in_array('KGS',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" class="number" name="KGS" size=12 maxlength=10 value="' . $_POST['KGS'] . '"></td></tr>'; - if (!isset($_POST['Units'])) { $UOMrow['unitname']=_('each'); } @@ -817,13 +560,6 @@ echo '</select></td></tr>'; -echo '<input type=hidden name=Discontinued value="0">'; -echo '<input type=hidden name=Controlled value="1">'; -echo '<input type=hidden name=Serialised value="1">'; - - -echo '<input type=hidden name=Perishable value="0">'; - echo '<input type="hidden" class="number" name="DecimalPlaces" size=1 maxlength=1 value="0">'; if (isset($_POST['BarCode'])) { @@ -833,13 +569,6 @@ } echo '<tr><td>' . _('Bar Code') . ':</td><td><input ' . (in_array('BarCode',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="BarCode" size=22 maxlength=20 value="' . $BarCode . '"></td></tr>'; -if (isset($_POST['DiscountCategory'])) { - $DiscountCategory = $_POST['DiscountCategory']; -} else { - $DiscountCategory=''; -} -echo '<input type="hidden" name="DiscountCategory" size=2 maxlength=2 value="' . $DiscountCategory . '">'; - echo '<tr><td>' . _('Tax Category') . ':</td><td><select name="TaxCat">'; $sql = 'SELECT taxcatid, taxcatname FROM taxcategories ORDER BY taxcatname'; $result = DB_query($sql, $db); @@ -858,12 +587,9 @@ echo '</select></td></tr></table>'; -echo '<input type="hidden" class="number" name="Pansize" size="6" maxlength="6" value=' . $_POST['Pansize'] . '>'; -echo '<input type="hidden" class="number" name="ShrinkFactor" size="6" maxlength="6" value=' . $_POST['ShrinkFactor'] . '>'; - -if (!isset($_POST['CategoryID'])) { - $_POST['CategoryID'] = ''; +if (!isset($_POST['AssetCategoryID'])) { + $_POST['AssetCategoryID'] = ''; } echo '<br><table class=selection><tr><th colspan="2">' . _('Depreciation Properties') . '</th></tr>'; $sql = "SELECT stkcatpropid, @@ -874,7 +600,7 @@ minimumvalue, numericvalue FROM stockcatproperties - WHERE categoryid ='" . $_POST['CategoryID'] . "' + WHERE categoryid ='" . $_POST['AssetCategoryID'] . "' AND reqatsalesorder =0 ORDER BY stkcatpropid"; @@ -940,8 +666,8 @@ // Now the form to enter the item properties echo '<br><div class=centre><input type="submit" name="submit" value="' . _('Update') . '"></div>'; echo '<input type="submit" name="UpdateCategories" style="visibility:hidden;width:1px" value="' . _('Categories') . '">'; - prnMsg( _('Only click the Delete button if you are sure you wish to delete the item!') . _('Checks will be made to ensure that there are no stock movements, sales analysis records, sales order items or purchase order items for the item') . '. ' . _('No deletions will be allowed if they exist'), 'warn', _('WARNING')); - echo '<br><div class=centre><input type="Submit" name="delete" value="' . _('Delete This Item') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');"></div>'; + prnMsg( _('Only click the Delete button if you are sure you wish to delete the asset.'), 'warn', _('WARNING')); + echo '<br><div class=centre><input type="Submit" name="delete" value="' . _('Delete This Asset') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');"></div>'; } echo '</form></div>'; Modified: trunk/index.php =================================================================== --- trunk/index.php 2010-11-13 22:22:09 UTC (rev 4156) +++ trunk/index.php 2010-11-13 23:03:50 UTC (rev 4157) @@ -1230,7 +1230,7 @@ </tr> <tr> <td class="menu_group_item"> - <?php echo '<p>• <a href="' . $rootpath . "/GLProfit_Loss.php?" . SID . '">' . _('Profit and Loss Statement') . '</a></p>'; ?> + <?php echo '<p>• <a href="' . $rootpath . '/GLProfit_Loss.php?' . SID . '">' . _('Profit and Loss Statement') . '</a></p>'; ?> </td> </tr> <tr> @@ -1310,7 +1310,7 @@ </tr> <tr> <td class="menu_group_item"> - <?php echo '<p>• <a href="' . $rootpath . '/SelectAssetType.php?' . SID . '">' . _('Select an Asset') . '</a></p>'; ?> + <?php echo '<p>• <a href="' . $rootpath . '/SelectAsset.php?' . SID . '">' . _('Select an Asset') . '</a></p>'; ?> </td> </tr> <tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-16 08:57:36
|
Revision: 4158 http://web-erp.svn.sourceforge.net/web-erp/?rev=4158&view=rev Author: daintree Date: 2010-11-16 08:57:29 +0000 (Tue, 16 Nov 2010) Log Message: ----------- start on rework of fixed assets Modified Paths: -------------- trunk/FixedAssetItems.php trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-11-13 23:03:50 UTC (rev 4157) +++ trunk/FixedAssetItems.php 2010-11-16 08:57:29 UTC (rev 4158) @@ -5,10 +5,8 @@ $PageSecurity = 11; -/*The fixed asset module follows the same logic to a large extent as stock - this script was a copy of the Stocks.php script */ - include('includes/session.inc'); -$title = _('Fixed Asset Item Maintenance'); +$title = _('Fixed Assets'); include('includes/header.inc'); echo '<a href="' . $rootpath . '/SelectAsset.php?' . SID . '">' . _('Back to Select') . '</a><br>' . "\n"; @@ -16,20 +14,20 @@ echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . _('Fixed Asset Items') . '" alt="">' . ' ' . $title . '</p>'; -/*If this form is called with the AssetID then it is assumed that the asset is to be modified */ +/* If this form is called with the AssetID then it is assumed that the asset is to be modified */ if (isset($_GET['AssetID'])){ - $AssetID =trim(strtoupper($_GET['AssetID'])); + $AssetID =$_GET['AssetID']; } elseif (isset($_POST['AssetID'])){ - $AssetID =trim(strtoupper($_POST['AssetID'])); + $AssetID =$_POST['AssetID']; } elseif (isset($_POST['Select'])){ - $AssetID =trim(strtoupper($_POST['Select'])); + $AssetID =$_POST['Select']; } else { $AssetID = ''; } if (isset($AssetID)) { - $sql = "SELECT COUNT(stockid) FROM assetmanager WHERE stockid='".$AssetID."'"; + $sql = "SELECT COUNT(assetid) FROM fixedassets WHERE assetid='".$AssetID."'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]==0) { @@ -43,7 +41,7 @@ $result = $_FILES['ItemPicture']['error']; $UploadTheFile = 'Yes'; //Assume all is well to start off with - $filename = $_SESSION['part_pics_dir'] . '/' . $AssetID . '.jpg'; + $filename = $_SESSION['part_pics_dir'] . '/ASSET_' . $AssetID . '.jpg'; //But check for the worst if (strtoupper(substr(trim($_FILES['ItemPicture']['name']),strlen($_FILES['ItemPicture']['name'])-3))!='JPG'){ @@ -100,25 +98,7 @@ $Errors[$i] = 'LongDescription'; $i++; } - if (strlen($AssetID) ==0) { - $InputError = 1; - prnMsg (_('The asset code cannot be empty'),'error'); - $Errors[$i] = 'AssetID'; - $i++; - } - if (ContainsIllegalCharacters($AssetID)) { - $InputError = 1; - prnMsg(_('The asset code cannot contain any of the following characters') . " - ' & + \" \\ " . _('or a space'),'error'); - $Errors[$i] = 'AssetID'; - $i++; - $AssetID=''; - } - if (strlen($_POST['Units']) >20) { - $InputError = 1; - prnMsg(_('The unit of measure must be 20 characters or less long'),'error'); - $Errors[$i] = 'Units'; - $i++; - } + if (strlen($_POST['BarCode']) >20) { $InputError = 1; prnMsg(_('The barcode must be 20 characters or less long'),'error'); @@ -126,13 +106,6 @@ $i++; } - if ($_POST['Controlled']==0 AND $_POST['Serialised']==1){ - $InputError = 1; - prnMsg(_('The item can only be serialised if there is lot control enabled already') . '. ' . _('Batch control') . ' - ' . _('with any number of items in a lot/bundle/roll is enabled when controlled is enabled') . '. ' . _('Serialised control requires that only one item is in the batch') . '. ' . _('For serialised control') . ', ' . _('both controlled and serialised must be enabled'),'error'); - $Errors[$i] = 'Serialised'; - $i++; - } - if (trim($_POST['AssetCategoryID'])==''){ $InputError = 1; prnMsg(_('There are no asset categories defined. All assets must belong to a valid category,'),'error'); @@ -141,172 +114,66 @@ } if ($InputError !=1){ - if ($_POST['Serialised']==1){ /*Not appropriate to have several dp on serial items */ - $_POST['DecimalPlaces']=0; - } + if ($_POST['submit']==_('Update')) { /*so its an existing one */ - /*first check on the changes being made we must disallow: - - changes from manufactured or purchased to Service, Assembly or Kitset if there is stock - changes from manufactured, kitset or assembly where a BOM exists - */ - $sql = "SELECT mbflag, - controlled, - serialised - FROM stockmaster WHERE stockid = '" . $AssetID . "'"; - $MBFlagResult = DB_query($sql,$db); - $myrow = DB_fetch_row($MBFlagResult); - $OldMBFlag = $myrow[0]; - $OldControlled = $myrow[1]; - $OldSerialised = $myrow[2]; + $sql = "UPDATE fixedassets + SET longdescription='" . $_POST['LongDescription'] . "', + description='" . $_POST['Description'] . "', + categoryid='" . $_POST['AssetCategoryID'] . "', + assetlocation='" . $_POST['AssetLocation'] . "', + datepurchased='" . $_POST['DatePurchased'] . "', + depntype='" . $_POST['DepnType'] . "', + depnrate='" . $_POST['DepnRate'] . "', + barcode='" . $_POST['BarCode'] . "', + serialno='" . $_POST['SerialNo'] . "' + WHERE assetid='" . $AssetID . "'"; - $sql = "SELECT SUM(locstock.quantity) FROM locstock WHERE stockid='" . $AssetID . "'"; - $result = DB_query($sql,$db); - $stkqtychk = DB_fetch_row($result); - - /* Do some checks for changes in the Serial & Controlled setups */ - if ($OldControlled != $_POST['Controlled'] AND $stkqtychk[0]!=0){ - $InputError=1; - prnMsg( _('You can not change a Non-Controlled Item to Controlled (or back from Controlled to non-controlled when there is currently stock on hand for the item') , 'error'); - - } - if ($OldSerialised != $_POST['Serialised'] AND $stkqtychk[0]!=0){ - $InputError=1; - prnMsg( _('You can not change a Serialised Item to Non-Serialised (or vice-versa) when there is a quantity on hand for the item') , 'error'); - } - - - if ($InputError == 0){ - $sql = "UPDATE stockmaster - SET longdescription='" . $_POST['LongDescription'] . "', - description='" . $_POST['Description'] . "', - controlled='" . $_POST['Controlled'] . "', - serialised='" . $_POST['Serialised']."', - categoryid='" . $_POST['AssetCategoryID'] . "', - units='" . $_POST['Units'] . "', - mbflag='" . $_POST['MBFlag'] . "', - barcode='" . $_POST['BarCode'] . "', - taxcatid='" . $_POST['TaxCat'] . "', - decimalplaces='" . $_POST['DecimalPlaces'] . "', - appendfile='" . $_POST['ItemPDF'] . "', - WHERE stockid='" . $AssetID . "'"; - $ErrMsg = _('The asset could not be updated because'); $DbgMsg = _('The SQL that was used to update the asset and failed was'); $result = DB_query($sql,$db,$ErrMsg,$DbgMsg); - //delete any properties for the item no longer relevant with the change of category - $result = DB_query("DELETE FROM stockitemproperties - WHERE stockid ='" . $AssetID . "'", - $db); - - //now insert any item properties - for ($i=0;$i<=$_POST['PropertyCounter'];$i++){ - - if ($_POST['PropType' . $i] ==2){ - if ($_POST['PropValue' . $i]=='on'){ - $_POST['PropValue' . $i]=1; - } else { - $_POST['PropValue' . $i]=0; - } - } - $result = DB_query("INSERT INTO stockitemproperties (stockid, - stkcatpropid, - value) - VALUES ('" . $AssetID . "', - '" . $_POST['PropID' . $i] . "', - '" . $_POST['PropValue' . $i] . "')", - $db); - } //end of loop around properties defined for the category prnMsg( _('Asset') . ' ' . $AssetID . ' ' . _('has been updated'), 'success'); echo '<br>'; - } - } else { //it is a NEW part - //but lets be really sure here - $result = DB_query("SELECT stockid FROM stockmaster WHERE stockid='" . $AssetID ."'",$db); - if (DB_num_rows($result)==1){ - prnMsg(_('The asset code entered is actually already in the database - duplicate asset codes are prohibited by the system. Try choosing an alternative asset code'),'error'); - exit; - } else { - $sql = "INSERT INTO stockmaster ( - stockid, - description, - longdescription, - categoryid, - units, - mbflag, - controlled, - serialised, - barcode, - taxcatid, - decimalplaces, - appendfile) - VALUES ('" . $AssetID . "', - '" . $_POST['Description'] . "', - '" . $_POST['LongDescription'] . "', - '" . $_POST['AssetCategoryID'] . "', - '" . $_POST['Units'] . "', - '" . $_POST['MBFlag'] . "', - '" . $_POST['Controlled'] . "', - '" . $_POST['Serialised']. "', - '" . $_POST['BarCode'] . "', - '" . $_POST['TaxCat'] . "', - '" . $_POST['DecimalPlaces']. "', - '" . $_POST['ItemPDF']. "' - )"; - - $ErrMsg = _('The asset could not be added because'); - $DbgMsg = _('The SQL that was used to add the asset failed was'); - $result = DB_query($sql,$db, $ErrMsg, $DbgMsg); - //now insert any item properties - for ($i=0;$i<=$_POST['PropertyCounter'];$i++){ - - if ($_POST['PropType' . $i] ==2){ - if ($_POST['PropValue' . $i]=='on'){ - $_POST['PropValue' . $i]=1; - } else { - $_POST['PropValue' . $i]=0; - } - } - $sql="INSERT INTO stockitemproperties (stockid, - stkcatpropid, - value) - VALUES ('" . $AssetID . "', - '" . $_POST['PropID' . $i] . "', - '" . $_POST['PropValue' . $i] . "')"; - $result = DB_query($sql,$db); - } //end of loop around properties defined for the category - if (DB_error_no($db) ==0) { - - $sql = "INSERT INTO locstock (loccode, - stockid) - SELECT locations.loccode, - '" . $AssetID . "' - FROM locations"; - - $ErrMsg = _('The locations for the asset') . ' ' . $AssetID . ' ' . _('could not be added because'); - $DbgMsg = _('NB Locations records can be added by opening the utility page') . ' <i>Z_MakeStockLocns.php</i> ' . _('The SQL that was used to add the location records that failed was'); - $InsResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); - - if (DB_error_no($db) ==0) { - prnMsg( _('New Item') .' ' . $AssetID . ' '. _('has been added to the database'),'success'); unset($_POST['LongDescription']); - unset($_POST['Description']); - -// Leave Category ID set for ease of batch entry -// unset($_POST['AssetCategoryID']); - unset($_POST['Units']); - unset($_POST['MBFlag']); - unset($_POST['Controlled']); - unset($_POST['Serialised']); - unset($_POST['BarCode']); - unset($_POST['DecimalPlaces']); - unset($_POST['ItemPDF']); - unset($AssetID); - }//ALL WORKED SO RESET THE FORM VARIABLES - }//THE INSERT OF THE NEW CODE WORKED SO BANG IN THE STOCK LOCATION RECORDS TOO - }//END CHECK FOR ALREADY EXISTING ITEM OF THE SAME CODE + $sql = "INSERT INTO fixedassets ( + description, + longdescription, + assetcategoryid, + assetlocation, + datepurchased, + depntype, + depnrate, + barcode, + serialno) + VALUES ('" . $AssetID . "', + '" . $_POST['Description'] . "', + '" . $_POST['LongDescription'] . "', + '" . $_POST['AssetCategoryID'] . "', + '" . $_POST['AssetLocation'] . "', + '" . $_POST['DatePurchased'] . "', + '" . $_POST['DepnType'] . "', + '" . $_POST['DepnRate']. "', + '" . $_POST['BarCode'] . "', + '" . $_POST['SerialNo'] . "' + )"; + $ErrMsg = _('The asset could not be added because'); + $DbgMsg = _('The SQL that was used to add the asset failed was'); + $result = DB_query($sql,$db, $ErrMsg, $DbgMsg); + + if (DB_error_no($db) ==0) { + prnMsg( _('New Item') .' ' . $AssetID . ' '. _('has been added to the database'),'success'); + unset($_POST['LongDescription']); + unset($_POST['Description']); +// unset($_POST['AssetCategoryID']); +// unset($_POST['AssetLocation']); + unset($_POST['DatePurchased']); +// unset($_POST['DepnType']); +// unset($_POST['DepnRate']); + unset($_POST['BarCode']); + unset($_POST['SerialNo']); + }//ALL WORKED SO RESET THE FORM VARIABLES } - } else { echo '<br>'. "\n"; prnMsg( _('Validation failed, no updates or deletes took place'), 'error'); @@ -316,153 +183,76 @@ //the button to delete a selected record was clicked instead of the submit button $CancelDelete = 0; - -// PREVENT DELETES IF DEPENDENT RECORDS IN 'StockMoves' - - $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockid='" . $AssetID . "'"; - $result = DB_query($sql,$db); - $myrow = DB_fetch_row($result); - if ($myrow[0]>0) { - $CancelDelete = 1; - prnMsg( _('Cannot delete this stock item because there are stock movements that refer to this item'),'warn'); - echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('stock movements that refer to this item'); - - } else { - $sql= "SELECT COUNT(*) FROM bom WHERE component='" . $AssetID . "'"; - $result = DB_query($sql,$db); - $myrow = DB_fetch_row($result); - if ($myrow[0]>0) { - $CancelDelete = 1; - prnMsg( _('Cannot delete this item record because there are bills of material that require this part as a component'),'warn'); - echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('bills of material that require this part as a component'); - } else { - $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='" . $AssetID . "'"; - $result = DB_query($sql,$db); - $myrow = DB_fetch_row($result); - if ($myrow[0]>0) { - $CancelDelete = 1; - prnMsg( _('Cannot delete this item record because there are existing sales orders for this part'),'warn'); - echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales order items against this part'); - } else { - $sql= "SELECT COUNT(*) FROM salesanalysis WHERE stockid='" . $AssetID . "'"; - $result = DB_query($sql,$db); - $myrow = DB_fetch_row($result); - if ($myrow[0]>0) { - $CancelDelete = 1; - prnMsg(_('Cannot delete this item because sales analysis records exist for it'),'warn'); - echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales analysis records against this part'); - } else { - $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='" . $AssetID . "'"; - $result = DB_query($sql,$db); - $myrow = DB_fetch_row($result); - if ($myrow[0]>0) { - $CancelDelete = 1; - prnMsg(_('Cannot delete this item because there are existing purchase order items for it'),'warn'); - echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('purchase order item record relating to this part'); - } else { - $sql = "SELECT SUM(quantity) AS qoh FROM locstock WHERE stockid='" . $AssetID . "'"; - $result = DB_query($sql,$db); - $myrow = DB_fetch_row($result); - if ($myrow[0]!=0) { - $CancelDelete = 1; - prnMsg( _('Cannot delete this item because there is currently some stock on hand'),'warn'); - echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('on hand for this part'); - } - } - } - } - } + //what validation is required before allowing deletion of assets .... maybe there should be no deletion option? + $result = DB_query('SELECT cost-depn AS netbookvalue FROM fixedassets WHERE assetid="' . $AssetID . '"', $db); + $AssetRow = DB_fetch_row($result); + if ($AssetRow[0] !=0) { + $CancelDelete =1; //cannot delete assets where NBV is not 0 } if ($CancelDelete==0) { $result = DB_Txn_Begin($db); - /*Deletes LocStock records*/ - $sql ="DELETE FROM locstock WHERE stockid='" . $AssetID . "'"; - $result=DB_query($sql,$db,_('Could not delete the location stock records because'),'',true); - /*Deletes Price records*/ - $sql ="DELETE FROM prices WHERE stockid='" . $AssetID . "'"; - $result=DB_query($sql,$db,_('Could not delete the prices for this asset record because'),'',true); - /*and cascade deletes in PurchData */ - $sql ="DELETE FROM purchdata WHERE stockid='" . $AssetID . "'"; - $result=DB_query($sql,$db,_('Could not delete the purchasing data because'),'',true); - /*and cascade delete the bill of material if any */ - $sql = "DELETE FROM bom WHERE parent='" . $AssetID . "'"; - $result=DB_query($sql,$db,_('Could not delete the bill of material because'),'',true); - $sql="DELETE FROM stockmaster WHERE stockid='" . $AssetID . "'"; + $sql="DELETE FROM fixedassets WHERE assetid='" . $AssetID . "'"; $result=DB_query($sql,$db, _('Could not delete the asset record'),'',true); $result = DB_Txn_Commit($db); - prnMsg(_('Deleted the asset master record for') . ' ' . $AssetID . '....' . - '<br>. . ' . _('and all the location stock records set up for the asset') . - '<br>. . .' . _('and any bill of material that may have been set up for the asset') . - '<br> . . . .' . _('and any purchasing data that may have been set up for the asset') . - '<br> . . . . .' . _('and any prices that may have been set up for the asset'),'success'); + prnMsg(_('Deleted the asset record for asset number' ) . ' ' . $AssetID ); unset($_POST['LongDescription']); unset($_POST['Description']); unset($_POST['AssetCategoryID']); - unset($_POST['Units']); - unset($_POST['MBFlag']); - unset($_POST['Controlled']); - unset($_POST['Serialised']); + unset($_POST['AssetLocation']); + unset($_POST['DatePurchased']); + unset($_POST['DepnType']); + unset($_POST['DepnRate']); unset($_POST['BarCode']); - unset($_POST['TaxCat']); - unset($_POST['DecimalPlaces']); + unset($_POST['SerialNo']); unset($AssetID); unset($_SESSION['SelectedAsset']); } //end if Delete Asset } - echo '<form name="AssetForm" enctype="multipart/form-data" method="post" action="' . $_SERVER['PHP_SELF'] . '?' .SID . '"><table class=selection>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; if (!isset($AssetID) or $AssetID=='') { -/*If the page was called without $AssetID passed to page then assume a new stock item is to be entered show a form with a part Code field other wise the form showing the fields with the existing entries against the part will show for editing with only a hidden AssetID field. New is set to flag that the page may have called itself and still be entering a new part, in which case the page needs to know not to go looking up details for an existing part*/ +/*If the page was called without $AssetID passed to page then assume a new asset is to be entered other wise the form showing the fields with the existing entries against the asset will show for editing with a hidden AssetID field. New is set to flag that the page may have called itself and still be entering a new asset, in which case the page needs to know not to go looking up details for an existing asset*/ $New = true; echo '<input type="hidden" name="New" value="">'. "\n"; -// echo '<input type="hidden" name="AssetID" value="'.$AssetID.'">'. "\n"; + +} elseif ($InputError!=1) { // Must be modifying an existing item and no changes made yet - need to lookup the details - echo '<tr><td>'. _('Asset Code'). ':</td><td><input ' . (in_array('AssetID',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="AssetID" size=21 maxlength=20></td></tr>'. "\n"; - -} elseif (!isset($_POST['UpdateCategories']) and $InputError!=1) { // Must be modifying an existing item and no changes made yet - - $sql = "SELECT stockid, + $sql = "SELECT assetid, description, longdescription, - categoryid, - units, - mbflag, - controlled, - serialised, - barcode, - taxcatid, - decimalplaces - FROM stockmaster - WHERE stockid ='" . $AssetID . "'"; + assetcategoryid, + serialno, + assetlocation, + datepurchased, + depntype, + depnrate + FROM fixedassets + WHERE assetid ='" . $AssetID . "'"; $result = DB_query($sql, $db); $myrow = DB_fetch_array($result); $_POST['LongDescription'] = $myrow['longdescription']; $_POST['Description'] = $myrow['description']; - $_POST['AssetCategoryID'] = $myrow['categoryid']; - $_POST['Units'] = $myrow['units']; - $_POST['MBFlag'] = $myrow['mbflag']; - $_POST['Controlled'] = $myrow['controlled']; - $_POST['Serialised'] = $myrow['serialised']; + $_POST['AssetCategoryID'] = $myrow['assetcategoryid']; + $_POST['SerialNo'] = $myrow['serialno']; + $_POST['AssetLocation'] = $myrow['assetlocation']; + $_POST['DatePurchased'] = ConvertSQLDate($myrow['DatePurchased']); + $_POST['DepnType'] = $myrow['depntype']; $_POST['BarCode'] = $myrow['barcode']; - $_POST['DiscountCategory'] = $myrow['discountcategory']; - $_POST['TaxCat'] = $myrow['taxcatid']; - $_POST['DecimalPlaces'] = $myrow['decimalplaces']; - + $_POST['DepnRate'] = $myrow['depnrate']; + echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$AssetID.'</td></tr>'. "\n"; echo '<input type="Hidden" name="AssetID" value='.$AssetID.'>'. "\n"; - echo '<input type="Hidden" name="NextSerialNo" value='.$_POST['NextSerialNo'].'>'. "\n"; } else { // some changes were made to the data so don't re-set form variables to DB ie the code above echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$AssetID.'</td></tr>'; @@ -495,24 +285,24 @@ '&height=64'. '" >'; } else { - if( isset($AssetID) and file_exists($_SESSION['part_pics_dir'] . '/' .$AssetID.'.jpg') ) { - $StockImgLink = '<img src="' . $_SESSION['part_pics_dir'] . '/' .$AssetID.'.jpg" >'; + if( isset($AssetID) and file_exists($_SESSION['part_pics_dir'] . '/ASSET_' .$AssetID.'.jpg') ) { + $AssetImgLink = '<img src="' . $_SESSION['part_pics_dir'] . '/ASSET_' .$AssetID.'.jpg" >'; } else { - $StockImgLink = _('No Image'); + $AssetImgLink = _('No Image'); } } -if ($StockImgLink!=_('No Image')) { - echo '<td>' . _('Image') . '<br>'.$StockImgLink . '</td></tr>'; +if ($AssetImgLink!=_('No Image')) { + echo '<td>' . _('Image') . '<br>'.$AssetImgLink . '</td></tr>'; } else { echo '</td></tr>'; } // EOR Add Image upload for New Item - by Ori -echo '<tr><td>' . _('Category') . ':</td><td><select name="AssetCategoryID" onChange="ReloadForm(AssetForm.UpdateCategories)">'; +echo '<tr><td>' . _('Asset Category') . ':</td><td><select name="AssetCategoryID">'; -$sql = 'SELECT categoryid, categorydescription FROM stockcategory WHERE stocktype="A"'; +$sql = 'SELECT categoryid, categorydescription FROM fixedassetcategories'; $ErrMsg = _('The asset categories could not be retrieved because'); $DbgMsg = _('The SQL used to retrieve stock categories and failed was'); $result = DB_query($sql,$db,$ErrMsg,$DbgMsg); @@ -530,37 +320,21 @@ $_POST['AssetCategoryID']=$category; } -if (!isset($_POST['Controlled']) or $_POST['Controlled']==''){ - $_POST['Controlled']=0; -} -if (!isset($_POST['Serialised']) or $_POST['Serialised']=='' || $_POST['Controlled']==0){ - $_POST['Serialised']=0; -} -if (!isset($_POST['DecimalPlaces']) or $_POST['DecimalPlaces']==''){ - $_POST['DecimalPlaces']=0; -} +$sql = 'SELECT locationid, locationdescription FROM fixedassetlocations'; +$ErrMsg = _('The asset locations could not be retrieved because'); +$DbgMsg = _('The SQL used to retrieve asset locations and failed was'); +$result = DB_query($sql,$db,$ErrMsg,$DbgMsg); -if (!isset($_POST['Units'])) { - $UOMrow['unitname']=_('each'); +echo '<tr><td>' . _('Asset Location') . ':</td><td><select name="AssetLocation">'; +while ($myrow=DB_fetch_array($result)){ + if ($_POST['AssetLocation']==$myrow['locationid']){ + echo '<option selected value="' . $myrow['locationid'] .'">' . $myrow['locationdescription'] . '</option>'; + } else { + echo '<option value="' . $myrow['locationid'] .'">' . $myrow['locationdescription'] . '</option>'; + } } - -echo '<input type=hidden name=Units value="each">'; - -echo '<tr><td>' . _('Manufactured or Purchased') . ':</td><td><select name="MBFlag">'; -if (!isset($_POST['MBFlag']) or $_POST['MBFlag']=='M'){ - echo '<option selected value="M">' . _('Manufactured') . '</option>'; -} else { - echo '<option value="M">' . _('Manufactured') . '</option>'; -} -if (!isset($_POST['MBFlag']) or $_POST['MBFlag']=='B' OR !isset($_POST['MBFlag']) OR $_POST['MBFlag']==''){ - echo '<option selected value="B">' . _('Purchased') . '</option>'; -} else { - echo '<option value="B">' . _('Purchased') . '</option>'; -} - echo '</select></td></tr>'; -echo '<input type="hidden" class="number" name="DecimalPlaces" size=1 maxlength=1 value="0">'; if (isset($_POST['BarCode'])) { $BarCode = $_POST['BarCode']; @@ -612,7 +386,7 @@ $PropValResult = DB_query("SELECT value FROM stockitemproperties - WHERE stockid='" . $AssetID . "' + WHERE assetid='" . $AssetID . "' AND stkcatpropid ='" . $PropertyRow['stkcatpropid'] . "'", $db); $PropValRow = DB_fetch_row($PropValResult); Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-13 23:03:50 UTC (rev 4157) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-16 08:57:29 UTC (rev 4158) @@ -437,3 +437,36 @@ ALTER TABLE `stockcatproperties` ADD `maximumvalue` DOUBLE NOT NULL DEFAULT 999999999 AFTER `defaultvalue` , ADD `minimumvalue` DOUBLE NOT NULL DEFAULT -999999999, ADD `numericvalue` TINYINT NOT NULL DEFAULT 0 + +RENAME TABLE assetmanager to fixedassets; +ALTER TABLE fixedassets ADD COLUMN `assetcategoryid` varchar(6) NOT NULL DEFAULT ''; +ALTER TABLE fixedassets ADD COLUMN `description` varchar(50) NOT NULL DEFAULT ''; +ALTER TABLE fixedassets ADD COLUMN `longdescription` text NOT NULL; +ALTER TABLE fixedassets ADD COLUMN `depntype` int NOT NULL DEFAULT 1; +ALTER TABLE fixedassets ADD COLUMN `depnrate` double NOT NULL; + +UPDATE fixedassets INNER JOIN stockmaster ON fixedassets.stockid=stockmaster.stockid SET assetcategoryid=stockmaster.categoryid, fixedassets.description=stockmaster.description, fixedassets.longdescription=stockmaster.longdescription; + +CREATE TABLE IF NOT EXISTS `fixedassetcategories` ( + `categoryid` char(6) NOT NULL DEFAULT '', + `categorydescription` char(20) NOT NULL DEFAULT '', + `costact` int(11) NOT NULL DEFAULT '0', + `depnact` int(11) NOT NULL DEFAULT '0', + `disposalact` int(11) NOT NULL DEFAULT '80000', + `accumdepnact` int(11) NOT NULL DEFAULT '0', + defaultdepnrate double NOT NULL DEFAULT '.2', + defaultdepntype int NOT NULL DEFAULT '1' + PRIMARY KEY (`categoryid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO fixedassetcategories SELECT categoryid, categorydescription, stockact, adjglact, materialuseagevarac, wipact FROM stockcategory WHERE stocktype='A'; + +DELETE locstock.* FROM locstock INNER JOIN stockmaster ON locstock.stockid=stockmaster.stockid INNER JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid WHERE stockcategory.stocktype='A'; + +DELETE stockitemproperties.* FROM stockitemproperties INNER JOIN stockmaster ON stockitemproperties.stockid=stockmaster.stockid INNER JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid WHERE stockcategory.stocktype='A'; + +DELETE stockmaster.* FROM stockmaster INNER JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid WHERE stockcategory.stocktype='A'; + +ALTER TABLE `fixedassets` CHANGE `id` `assetid` INT( 11 ) NOT NULL AUTO_INCREMENT ; +DELETE FROM stockcategory WHERE stocktype='A'; +ALTER TABLE `fixedassets` DROP `stockid`; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-18 10:01:03
|
Revision: 4159 http://web-erp.svn.sourceforge.net/web-erp/?rev=4159&view=rev Author: tim_schofield Date: 2010-11-18 10:00:57 +0000 (Thu, 18 Nov 2010) Log Message: ----------- Fix sql syntax errors brought in on recent changes. Modified Paths: -------------- trunk/StockDispatch.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/StockDispatch.php =================================================================== --- trunk/StockDispatch.php 2010-11-16 08:57:29 UTC (rev 4158) +++ trunk/StockDispatch.php 2010-11-18 10:00:57 UTC (rev 4159) @@ -55,7 +55,7 @@ } - $sql = 'SELECT locstock.stockid, + $sql = "SELECT locstock.stockid, stockmaster.description, locstock.loccode, locstock.quantity, @@ -64,22 +64,25 @@ stockmaster.serialised, stockmaster.controlled, ROUND((locstock.reorderlevel - locstock.quantity) * - (1 + (' . $_POST['Percent'] . '/100))) + (1 + (" . $_POST['Percent'] . "/100))) as neededqty, (fromlocstock.quantity - fromlocstock.reorderlevel) as available, fromlocstock.reorderlevel as fromreorderlevel, fromlocstock.quantity as fromquantity - FROM stockmaster, - locstock + FROM stockmaster + LEFT JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid, + locstock LEFT JOIN locstock AS fromlocstock ON locstock.stockid = fromlocstock.stockid - AND fromlocstock.loccode = "' . $_POST['FromLocation'] . '" + AND fromlocstock.loccode = '" . $_POST['FromLocation'] . "' WHERE locstock.stockid=stockmaster.stockid - AND locstock.loccode ="' . $_POST['ToLocation'] . '" + AND locstock.loccode ='" . $_POST['ToLocation'] . "' AND locstock.reorderlevel > locstock.quantity AND (fromlocstock.quantity - fromlocstock.reorderlevel) > 0 - AND (stockmaster.mbflag="B" OR stockmaster.mbflag="M") ' . - $wherecategory . ' ORDER BY locstock.loccode,locstock.stockid'; + AND stockcategory.stocktype<>'A' + AND (stockmaster.mbflag='B' OR stockmaster.mbflag='M') " . + $wherecategory . " ORDER BY locstock.loccode,locstock.stockid"; $result = DB_query($sql,$db,'','',false,true); @@ -257,7 +260,7 @@ } echo '</select></td></tr>'; - $SQL='SELECT categoryid, categorydescription FROM stockcategory ORDER BY categorydescription'; + $SQL='SELECT categoryid, categorydescription FROM stockcategory WHERE stocktype<>"A" ORDER BY categorydescription'; $result1 = DB_query($SQL,$db); if (DB_num_rows($result1)==0){ echo '</table></td></tr> Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-16 08:57:29 UTC (rev 4158) +++ trunk/doc/Change.log.html 2010-11-18 10:00:57 UTC (rev 4159) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>18/11/10 Tim: upgrade3.11.1-4.00.sql - Fix sql syntax errors brought in on recent changes.</p> <p>14/11/10 Phil: SelectAsset.php script reworked SelectAssetType.php script now deleted</p> <p>08/11/10 Exson: Z_ImportStocks.php - Bug fixes.</p> <p>06/11/10 Phil: ShiptChgs.php - made a check to ensure a shipment reference entered manully actually exists before it is added - otherwise a nasty error occurs on commital of the invoice</p> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-16 08:57:29 UTC (rev 4158) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-18 10:00:57 UTC (rev 4159) @@ -147,7 +147,7 @@ ALTER TABLE `purchorders` ADD COLUMN `tel` varchar(15) NOT NULL DEFAULT '' AFTER deladd6; ALTER TABLE `purchorders` ADD COLUMN `port` varchar(40) NOT NULL DEFAULT '' ; -ALTER TABLE `suppliers` DROP KEY `suppliers_ibfk_4`; +ALTER TABLE `suppliers` DROP FOREIGN KEY `suppliers_ibfk_4`; UPDATE `suppliers` SET `factorcompanyid`=0 WHERE `factorcompanyid`=1; DELETE FROM `factorcompanies` WHERE `coyname`='None'; @@ -436,7 +436,7 @@ ALTER TABLE `stockcatproperties` ADD `maximumvalue` DOUBLE NOT NULL DEFAULT 999999999 AFTER `defaultvalue` , ADD `minimumvalue` DOUBLE NOT NULL DEFAULT -999999999, -ADD `numericvalue` TINYINT NOT NULL DEFAULT 0 +ADD `numericvalue` TINYINT NOT NULL DEFAULT 0 ; RENAME TABLE assetmanager to fixedassets; ALTER TABLE fixedassets ADD COLUMN `assetcategoryid` varchar(6) NOT NULL DEFAULT ''; @@ -455,11 +455,11 @@ `disposalact` int(11) NOT NULL DEFAULT '80000', `accumdepnact` int(11) NOT NULL DEFAULT '0', defaultdepnrate double NOT NULL DEFAULT '.2', - defaultdepntype int NOT NULL DEFAULT '1' + defaultdepntype int NOT NULL DEFAULT '1', PRIMARY KEY (`categoryid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO fixedassetcategories SELECT categoryid, categorydescription, stockact, adjglact, materialuseagevarac, wipact FROM stockcategory WHERE stocktype='A'; +INSERT INTO fixedassetcategories (categoryid, categorydescription, costact, depnact, disposalact, accumdepnact) SELECT categoryid, categorydescription, stockact, adjglact, materialuseagevarac, wipact FROM stockcategory WHERE stocktype='A'; DELETE locstock.* FROM locstock INNER JOIN stockmaster ON locstock.stockid=stockmaster.stockid INNER JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid WHERE stockcategory.stocktype='A'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-20 08:13:55
|
Revision: 4160 http://web-erp.svn.sourceforge.net/web-erp/?rev=4160&view=rev Author: daintree Date: 2010-11-20 08:13:47 +0000 (Sat, 20 Nov 2010) Log Message: ----------- Fixed Asset module development Modified Paths: -------------- trunk/FixedAssetCategories.php trunk/FixedAssetItems.php trunk/FixedAssetLocations.php trunk/SelectAsset.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/FixedAssetCategories.php =================================================================== --- trunk/FixedAssetCategories.php 2010-11-18 10:00:57 UTC (rev 4159) +++ trunk/FixedAssetCategories.php 2010-11-20 08:13:47 UTC (rev 4160) @@ -18,16 +18,6 @@ $SelectedCategory = strtoupper($_POST['SelectedCategory']); } -if (isset($_GET['DeleteProperty'])){ - - $ErrMsg = _('Could not delete the property') . ' ' . $_GET['DeleteProperty'] . ' ' . _('because'); - $sql = "DELETE FROM stockitemproperties WHERE stkcatpropid='" . $_GET['DeleteProperty'] . "'"; - $result = DB_query($sql,$db,$ErrMsg); - $sql = "DELETE FROM stockcatproperties WHERE stkcatpropid='" . $_GET['DeleteProperty'] . "'"; - $result = DB_query($sql,$db,$ErrMsg); - prnMsg(_('Deleted the property') . ' ' . $_GET['DeleteProperty'],'success'); -} - if (isset($_POST['submit'])) { //initialise no input errors assumed initially before we test @@ -57,14 +47,13 @@ would not run in this case cos submit is false of course see the delete code below*/ - $sql = "UPDATE stockcategory SET - stocktype = '" . $_POST['StockType'] . "', - categorydescription = '" . $_POST['CategoryDescription'] . "', - stockact = '" . $_POST['StockAct'] . "', - adjglact = '" . $_POST['AdjGLAct'] . "', - materialuseagevarac = '" . $_POST['MaterialUseageVarAc'] . "', - wipact = '" . $_POST['WIPAct'] . "' - WHERE categoryid = '".$SelectedCategory . "'"; + $sql = "UPDATE fixedassetcategories SET + categorydescription = '" . $_POST['CategoryDescription'] . "', + costact = '" . $_POST['CostAct'] . "', + depnact = '" . $_POST['DepnAct'] . "', + disposalact = '" . $_POST['DisposalAct'] . "', + accumdepnact = '" . $_POST['AccumDepnAct'] . "' + WHERE categoryid = '".$SelectedCategory . "'"; $ErrMsg = _('Could not update the fixed asset category') . $_POST['CategoryDescription'] . _('because'); $result = DB_query($sql,$db,$ErrMsg); @@ -72,94 +61,50 @@ } elseif ($InputError !=1) { - /*Selected category is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new stock category form */ - - $sql = "INSERT INTO stockcategory (categoryid, - stocktype, - categorydescription, - stockact, - adjglact, - materialuseagevarac, - wipact) - VALUES ( - '" . $_POST['CategoryID'] . "', - '" . $_POST['StockType'] . "', - '" . $_POST['CategoryDescription'] . "', - '" . $_POST['StockAct'] . "', - '" . $_POST['AdjGLAct'] . "', - '" . $_POST['MaterialUseageVarAc'] . "', - '" . $_POST['WIPAct'] . "')"; - $ErrMsg = _('Could not insert the new stock category') . $_POST['CategoryDescription'] . _('because'); + $sql = "INSERT INTO fixedassetcategories (categoryid, + categorydescription, + costact, + depnact, + disposalact, + accumdepnact) + VALUES ( + '" . $_POST['CategoryID'] . "', + '" . $_POST['CategoryDescription'] . "', + '" . $_POST['CostAct'] . "', + '" . $_POST['DepnAct'] . "', + '" . $_POST['DisposalAct'] . "', + '" . $_POST['AccumDepnAct'] . "')"; + $ErrMsg = _('Could not insert the new fixed asset category') . $_POST['CategoryDescription'] . _('because'); $result = DB_query($sql,$db,$ErrMsg); - prnMsg(_('A new stock category record has been added for') . ' ' . $_POST['CategoryDescription'],'success'); - $sql="INSERT INTO stockcatproperties - VALUES( - NULL, - '".$_POST['CategoryID']."', - '"._('Depreciation Type')."', - '1', - '"._('Straight Line').","._('Reducing Balance')."', - '', - '', - '0', - '0')"; - $result=DB_query($sql,$db); - $sql="INSERT INTO stockcatproperties - VALUES( - NULL, - '".$_POST['CategoryID']."', - '"._('Annual Depreciation Percentage')."', - '0', - '5', - '100', - '0', - '1', - '0')"; - $result=DB_query($sql,$db); + prnMsg(_('A new fixed asset category record has been added for') . ' ' . $_POST['CategoryDescription'],'success'); + } //run the SQL from either of the above possibilites unset($_POST['CategoryID']); - unset($_POST['StockType']); unset($_POST['CategoryDescription']); - unset($_POST['StockAct']); - unset($_POST['AdjGLAct']); - unset($_POST['PurchPriceVarAct']); - unset($_POST['MaterialUseageVarAc']); - unset($_POST['WIPAct']); + unset($_POST['CostAct']); + unset($_POST['DepnAct']); + unset($_POST['DisposalAct']); + unset($_POST['AccumDepnAct']); - } elseif (isset($_GET['delete'])) { //the link to delete a selected record was clicked instead of the submit button -// PREVENT DELETES IF DEPENDENT RECORDS IN 'StockMaster' +// PREVENT DELETES IF DEPENDENT RECORDS IN 'fixedassets' - $sql= "SELECT COUNT(*) FROM stockmaster WHERE stockmaster.categoryid='" . $SelectedCategory . "'"; + $sql= "SELECT COUNT(*) FROM fixedasset WHERE fixedassets.assetcategoryid='" . $SelectedCategory . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { - prnMsg(_('Cannot delete this stock category because stock items have been created using this stock category') . - '<br> ' . _('There are') . ' ' . $myrow[0] . ' ' . _('items referring to this stock category code'),'warn'); + prnMsg(_('Cannot delete this fixed asset category because fixed assets have been created using this category') . + '<br> ' . _('There are') . ' ' . $myrow[0] . ' ' . _('fixed assets referring to this category code'),'warn'); } else { - $sql = "SELECT COUNT(*) FROM salesglpostings WHERE stkcat='" . $SelectedCategory . "'"; + $sql="DELETE FROM fixedassetcategories WHERE categoryid='" . $SelectedCategory . "'"; $result = DB_query($sql,$db); - $myrow = DB_fetch_row($result); - if ($myrow[0]>0) { - prnMsg(_('Cannot delete this stock category because it is used by the sales') . ' - ' . _('GL posting interface') . '. ' . _('Delete any records in the Sales GL Interface set up using this stock category first'),'warn'); - } else { - $sql = "SELECT COUNT(*) FROM cogsglpostings WHERE stkcat='" . $SelectedCategory . "'"; - $result = DB_query($sql,$db); - $myrow = DB_fetch_row($result); - if ($myrow[0]>0) { - prnMsg(_('Cannot delete this stock category because it is used by the cost of sales') . ' - ' . _('GL posting interface') . '. ' . _('Delete any records in the Cost of Sales GL Interface set up using this stock category first'),'warn'); - } else { - $sql="DELETE FROM stockcategory WHERE categoryid='" . $SelectedCategory . "'"; - $result = DB_query($sql,$db); - prnMsg(_('The stock category') . ' ' . $SelectedCategory . ' ' . _('has been deleted') . ' !','success'); - unset ($SelectedCategory); - } - } + prnMsg(_('The fixed asset category') . ' ' . $SelectedCategory . ' ' . _('has been deleted'),'success'); + unset ($SelectedCategory); } //end if stock category used in debtor transactions } @@ -170,21 +115,26 @@ links to delete or edit each. These will call the same page again and allow update/input or deletion of the records*/ - $sql = "SELECT * FROM stockcategory WHERE stocktype='A'"; + $sql = 'SELECT categoryid, + categorydescription, + costact, + depnact, + disposalact, + accumdepnact + FROM fixedassetcategories'; $result = DB_query($sql,$db); echo "<br><table class=selection>\n"; echo '<tr><th>' . _('Cat Code') . '</th> <th>' . _('Description') . '</th> - <th>' . _('Type') . '</th> - <th>' . _('Asset GL') . '</th> + <th>' . _('Cost GL') . '</th> <th>' . _('P & L Depn GL') . '</th> - <th>' . _('Sale of Asset account') . '</th> - <th>' . _('BS Depn GL') . '</th></tr>'; + <th>' . _('Disposal GL') . '</th> + <th>' . _('Accum Depn GL') . '</th></tr>'; $k=0; //row colour counter - while ($myrow = DB_fetch_row($result)) { + while ($myrow = DB_fetch_array($result)) { if ($k==1){ echo '<tr class="EvenTableRows">'; $k=0; @@ -194,26 +144,23 @@ } printf("<td>%s</td> <td>%s</td> - <td>%s</td> - <td align=right>%s</td> - <td align=right>%s</td> - <td align=right>%s</td> - <td align=right>%s</td> + <td class=\"number\">%s</td> + <td class=\"number\">%s</td> + <td class=\"number\">%s</td> + <td class=\"number\">%s</td> <td><a href=\"%sSelectedCategory=%s\">" . _('Edit') . "</td> - <td><a href=\"%sSelectedCategory=%s&delete=yes\" onclick=\"return confirm('" . _('Are you sure you wish to delete this stock category? Additional checks will be performed before actual deletion to ensure data integrity is not compromised.') . "');\">" . _('Delete') . "</td> + <td><a href=\"%sSelectedCategory=%s&delete=yes\" onclick=\"return confirm('" . _('Are you sure you wish to delete this fixed asset category? Additional checks will be performed before actual deletion to ensure data integrity is not compromised.') . "');\">" . _('Delete') . "</td> </tr>", - $myrow[0], - $myrow[1], - $myrow[2], - $myrow[3], - $myrow[4], -// $myrow[5], - $myrow[6], - $myrow[7], + $myrow['categoryid'], + $myrow['categorydescription'], + $myrow['costact'], + $myrow['depnact'], + $myrow['disposalact'], + $myrow['accumdepnact'], $_SERVER['PHP_SELF'] . '?' . SID, - $myrow[0], + $myrow['categoryid'], $_SERVER['PHP_SELF'] . '?' . SID, - $myrow[0]); + $myrow['categoryid']); } //END WHILE LIST LOOP echo '</table>'; @@ -222,38 +169,33 @@ //end of ifs and buts! if (isset($SelectedCategory)) { - echo "<br><div class='centre'><a href='" . $_SERVER['PHP_SELF'] . '?' . SID . ">" ._('Show All Stock Categories') . "</a></div>"; + echo "<br><div class='centre'><a href='" . $_SERVER['PHP_SELF'] . '?' . SID . ">" ._('Show All Fixed Asset Categories') . "</a></div>"; } echo '<form name="CategoryForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; if (isset($SelectedCategory) and !isset($_POST['submit'])) { - //editing an existing stock category - if (!isset($_POST['UpdateTypes'])) { + //editing an existing fixed asset category $sql = "SELECT categoryid, - stocktype, categorydescription, - stockact, - adjglact, - purchpricevaract, - materialuseagevarac, - wipact - FROM stockcategory + costact, + depnact, + disposalact, + accumdepnact + FROM fixedassetcategories WHERE categoryid='" . $SelectedCategory . "'"; $result = DB_query($sql, $db); $myrow = DB_fetch_array($result); - $_POST['CategoryID'] = $myrow['categoryid']; - $_POST['StockType'] = $myrow['stocktype']; - $_POST['CategoryDescription'] = $myrow['categorydescription']; - $_POST['StockAct'] = $myrow['stockact']; - $_POST['AdjGLAct'] = $myrow['adjglact']; - $_POST['PurchPriceVarAct'] = $myrow['purchpricevaract']; - $_POST['MaterialUseageVarAc'] = $myrow['materialuseagevarac']; - $_POST['WIPAct'] = $myrow['wipact']; - } + $_POST['CategoryID'] = $myrow['categoryid']; + $_POST['CategoryDescription'] = $myrow['categorydescription']; + $_POST['CostAct'] = $myrow['costact']; + $_POST['DepnAct'] = $myrow['depnact']; + $_POST['DisposalAct'] = $myrow['disposalact']; + $_POST['AccumDepnAct'] = $myrow['accumdepnact']; + echo '<input type=hidden name="SelectedCategory" value="' . $SelectedCategory . '">'; echo '<input type=hidden name="CategoryID" value="' . $_POST['CategoryID'] . '">'; echo '<table class=selection><tr><td>' . _('Category Code') . ':</td><td>' . $_POST['CategoryID'] . '</td></tr>'; @@ -263,7 +205,7 @@ $_POST['CategoryID'] = ''; } echo '<table class=selection><tr><td>' . _('Category Code') . ':</td> - <td><input type="Text" name="CategoryID" size=7 maxlength=6 value="' . $_POST['CategoryID'] . '"></td></tr>'; + <td><input type="Text" name="CategoryID" size=7 maxlength=6 value="' . $_POST['CategoryID'] . '"></td></tr>'; } //SQL to poulate account selection boxes @@ -294,81 +236,64 @@ echo '<tr><td>' . _('Category Description') . ':</td> <td><input type="Text" name="CategoryDescription" size=22 maxlength=20 value="' . $_POST['CategoryDescription'] . '"></td></tr>'; -echo '<input type=hidden name="StockType" value="A">'; -echo '<input type="submit" name="UpdateTypes" style="visibility:hidden;width:1px" value="Not Seen">'; -echo '<tr><td>' . _('Fixed Asset GL Code'); +echo '<tr><td>' . _('Fixed Asset Cost GL Code'); -echo ':</td><td><select name="StockAct">'; +echo ':</td><td><select name="CostAct">'; while ($myrow = DB_fetch_array($BSAccountsResult)){ - if (isset($_POST['StockAct']) and $myrow['accountcode']==$_POST['StockAct']) { + if (isset($_POST['CostAct']) and $myrow['accountcode']==$_POST['CostAct']) { echo '<option selected value='; } else { echo '<option value='; } echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; } //end while loop -DB_data_seek($PnLAccountsResult,0); -DB_data_seek($BSAccountsResult,0); echo '</select></td></tr>'; -echo '<tr><td>' . _('Balance Sheet Depreciation GL Code') . ':</td><td><select name="WIPAct">'; +echo '<tr><td>' . _('Profit and Loss Depreciation GL Code') . ':</td> + <td><select name="DepnAct">'; -while ($myrow = DB_fetch_array($BSAccountsResult)) { - - if (isset($_POST['WIPAct']) and $myrow['accountcode']==$_POST['WIPAct']) { +while ($myrow = DB_fetch_array($PnLAccountsResult)) { + if (isset($_POST['DepnAct']) and $myrow['accountcode']==$_POST['DepnAct']) { echo '<option selected value='; } else { echo '<option value='; } - echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; - + echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')</option>'; } //end while loop echo '</select></td></tr>'; -DB_data_seek($BSAccountsResult,0); -echo '<tr><td>' . _('Profit and Loss Depreciation GL Code') . ':</td> - <td><select name="AdjGLAct">'; - +DB_data_seek($PnLAccountsResult,0); +echo '<tr><td>' . _('Profit or Loss on Disposal GL Code:') . '</td><td><select name="DisposalAct">'; while ($myrow = DB_fetch_array($PnLAccountsResult)) { - if (isset($_POST['AdjGLAct']) and $myrow['accountcode']==$_POST['AdjGLAct']) { + if (isset($_POST['DisposalAct']) and $myrow['accountcode']==$_POST['DisposalAct']) { echo '<option selected value='; } else { echo '<option value='; } - echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')</option>'; - + echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')' . '</option>'; } //end while loop -DB_data_seek($PnLAccountsResult,0); echo '</select></td></tr>'; -echo '<tr><td>'; -if (isset($_POST['StockType']) and $_POST['StockType']=='L') { - echo _('Labour Efficiency Variance GL Code'); -} else { - echo _('Sale of Asset account'); -} -echo ':</td><td><select name="MaterialUseageVarAc">'; -while ($myrow = DB_fetch_array($PnLAccountsResult)) { - if (isset($_POST['MaterialUseageVarAc']) and $myrow['accountcode']==$_POST['MaterialUseageVarAc']) { +DB_data_seek($BSAccountsResult,0); +echo '<tr><td>' . _('Balance Sheet Accumulated Depreciation GL Code') . ':</td><td><select name="AccumDepnAct">'; + +while ($myrow = DB_fetch_array($BSAccountsResult)) { + + if (isset($_POST['AccumDepnAct']) and $myrow['accountcode']==$_POST['AccumDepnAct']) { echo '<option selected value='; } else { echo '<option value='; } - echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; + echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')' . '</option>'; } //end while loop -DB_free_result($PnLAccountsResult); -echo '</select></td></tr></table><br>'; -$sql='SELECT COUNT(categoryid) - FROM stockcatproperties - WHERE categoryid="dpntyp"'; -$result=DB_query($sql,$db); -$row=DB_fetch_array($result); +echo '</select></td></tr></table><br>'; + echo '<div class="centre"><input type="Submit" name="submit" value="' . _('Enter Information') . '"></div>'; echo '</form>'; Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-11-18 10:00:57 UTC (rev 4159) +++ trunk/FixedAssetItems.php 2010-11-20 08:13:47 UTC (rev 4160) @@ -8,6 +8,7 @@ include('includes/session.inc'); $title = _('Fixed Assets'); include('includes/header.inc'); +include('includes/SQL_CommonFunctions.inc'); echo '<a href="' . $rootpath . '/SelectAsset.php?' . SID . '">' . _('Back to Select') . '</a><br>' . "\n"; @@ -15,7 +16,6 @@ _('Fixed Asset Items') . '" alt="">' . ' ' . $title . '</p>'; /* If this form is called with the AssetID then it is assumed that the asset is to be modified */ - if (isset($_GET['AssetID'])){ $AssetID =$_GET['AssetID']; } elseif (isset($_POST['AssetID'])){ @@ -26,17 +26,6 @@ $AssetID = ''; } -if (isset($AssetID)) { - $sql = "SELECT COUNT(assetid) FROM fixedassets WHERE assetid='".$AssetID."'"; - $result = DB_query($sql,$db); - $myrow = DB_fetch_row($result); - if ($myrow[0]==0) { - $New=0; - } else { - $New=1; - } -} - if (isset($_FILES['ItemPicture']) AND $_FILES['ItemPicture']['name'] !='') { $result = $_FILES['ItemPicture']['error']; @@ -112,15 +101,123 @@ $Errors[$i] = 'AssetCategoryID'; $i++; } + if (!is_numeric($_POST['DepnRate']) OR $_POST['DepnRate']>100 OR $_POST['DepnRate']<0){ + $InputError = 1; + prnMsg(_('The depreciation rate is expected to be a number between 0 and 100'),'error'); + $Errors[$i] = 'DepnRate'; + $i++; + } + if (!Is_Date($_POST['DatePurchased'])){ + $InputError = 1; + prnMsg(_('The date that the asset was purchased must be entered in the format') . ' ' . $SESSION['DefaultDateFormat'],'error'); + $Errors[$i] = 'DatePurchased'; + $i++; + } if ($InputError !=1){ if ($_POST['submit']==_('Update')) { /*so its an existing one */ - $sql = "UPDATE fixedassets + /*Start a transaction to do the whole lot inside */ + $result = DB_Txn_Begin($db); + + /*Need to check if changing the balance sheet codes - as will need to do journals for the cost and accum depn of the asset to the new category */ + $result = DB_query("SELECT assetcategoryid, cost, accumdepn, costact, accumdepnact FROM fixedassets INNER JOIN fixedassetcategories WHERE assetid='" . $AssetID . "'",$db); + $OldDetails = DB_fetch_array($result); + if ($OldDetails['assetcategoryid'] !=$_POST['AssetCategoryID'] AND $OldDetails['cost']!=0){ + + $PeriodNo = GetPeriod(Date($_SESSION['DefaultDateFormat']),$db); + /* Get the new account codes for the new asset category */ + $result = DB_query("SELECT costact, accumdepnact FROM fixedassetcategories WHERE categoryid='" . $_POST['AssetCategoryID'] . "'",$db); + $NewAccounts = DB_fetch_array($result); + + $TransNo = GetNextTransNo( 42, $db); /* transaction type is asset category change */ + + //credit cost for the old category + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) "; + $SQL= $SQL . "VALUES (42, + '" . $TransNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $OldDetails['costact'] . "', + '" . $AssetID . ' ' . _('change category') . ' ' . $OldDetails['assetcategoryid'] . ' - ' . $_POST['AssetCategoryID'] . "', + '" . -$OldDetails['cost']. "' + )"; + $ErrMsg = _('Cannot insert a GL entry for the change of asset category because'); + $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + //debit cost for the new category + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) "; + $SQL= $SQL . "VALUES (42, + '" . $TransNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $NewAccounts['costact'] . "', + '" . $AssetID . ' ' . _('change category') . ' ' . $OldDetails['assetcategoryid'] . ' - ' . $_POST['AssetCategoryID'] . "', + '" . $OldDetails['cost']. "' + )"; + $ErrMsg = _('Cannot insert a GL entry for the change of asset category because'); + $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + if ($OldDetails['accumdepn']!=0) { + //debit accumdepn for the old category + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) "; + $SQL= $SQL . "VALUES (42, + '" . $TransNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $OldDetails['accumdepnact'] . "', + '" . $AssetID . ' ' . _('change category') . ' ' . $OldDetails['assetcategoryid'] . ' - ' . $_POST['AssetCategoryID'] . "', + '" . $OldDetails['accumdepn']. "' + )"; + $ErrMsg = _('Cannot insert a GL entry for the change of asset category because'); + $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + //credit accum depn for the new category + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) "; + $SQL= $SQL . "VALUES (42, + '" . $TransNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $NewAccounts['accumdepnact'] . "', + '" . $AssetID . ' ' . _('change category') . ' ' . $OldDetails['assetcategoryid'] . ' - ' . $_POST['AssetCategoryID'] . "', + '" . $OldDetails['accumdepn']. "' + )"; + $ErrMsg = _('Cannot insert a GL entry for the change of asset category because'); + $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + } /*end if there was accumulated depreciation for the asset */ + } /* end if there is a change in asset category */ + $sql = "UPDATE fixedassets SET longdescription='" . $_POST['LongDescription'] . "', description='" . $_POST['Description'] . "', - categoryid='" . $_POST['AssetCategoryID'] . "', + assetcategoryid='" . $_POST['AssetCategoryID'] . "', assetlocation='" . $_POST['AssetLocation'] . "', datepurchased='" . $_POST['DatePurchased'] . "', depntype='" . $_POST['DepnType'] . "', @@ -129,12 +226,12 @@ serialno='" . $_POST['SerialNo'] . "' WHERE assetid='" . $AssetID . "'"; - $ErrMsg = _('The asset could not be updated because'); - $DbgMsg = _('The SQL that was used to update the asset and failed was'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg); + $ErrMsg = _('The asset could not be updated because'); + $DbgMsg = _('The SQL that was used to update the asset and failed was'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg); - prnMsg( _('Asset') . ' ' . $AssetID . ' ' . _('has been updated'), 'success'); - echo '<br>'; + prnMsg( _('Asset') . ' ' . $AssetID . ' ' . _('has been updated'), 'success'); + echo '<br>'; } else { //it is a NEW part $sql = "INSERT INTO fixedassets ( description, @@ -146,7 +243,7 @@ depnrate, barcode, serialno) - VALUES ('" . $AssetID . "', + VALUES ( '" . $_POST['Description'] . "', '" . $_POST['LongDescription'] . "', '" . $_POST['AssetCategoryID'] . "', @@ -162,7 +259,7 @@ $result = DB_query($sql,$db, $ErrMsg, $DbgMsg); if (DB_error_no($db) ==0) { - prnMsg( _('New Item') .' ' . $AssetID . ' '. _('has been added to the database'),'success'); + prnMsg( _('The new asset has been added to the database'),'success'); unset($_POST['LongDescription']); unset($_POST['Description']); // unset($_POST['AssetCategoryID']); @@ -173,6 +270,7 @@ unset($_POST['BarCode']); unset($_POST['SerialNo']); }//ALL WORKED SO RESET THE FORM VARIABLES + $result = DB_Txn_Commit($db); } } else { echo '<br>'. "\n"; @@ -184,17 +282,70 @@ $CancelDelete = 0; //what validation is required before allowing deletion of assets .... maybe there should be no deletion option? - $result = DB_query('SELECT cost-depn AS netbookvalue FROM fixedassets WHERE assetid="' . $AssetID . '"', $db); - $AssetRow = DB_fetch_row($result); - if ($AssetRow[0] !=0) { + $result = DB_query('SELECT cost, accumdepn, accumdepnact, costact FROM fixedassets INNER JOIN fixedassetcategories ON fixedassets.assetcategoryid=fixedassetcategories.categoryid WHERE assetid="' . $AssetID . '"', $db); + $AssetRow = DB_fetch_array($result); + $NBV = $AssetRow['cost'] -$AssetRow['accumdepn']; + if ($NBV!=0) { $CancelDelete =1; //cannot delete assets where NBV is not 0 } + $result = DB_query('SELECT * FROM fixedassettrans WHERE assetid="' . $AssetID . '"',$db); + if (DB_num_rows($result) > 0){ + $CancelDelete =1; /*cannot delete assets with transactions */ + } + if ($CancelDelete==0) { $result = DB_Txn_Begin($db); + + /*Need to remove cost and accumulate depreciation from cost and accumdepn accounts */ + $PeriodNo = GetPeriod(Date($_SESSION['DefaultDateFormat']),$db); + $TransNo = GetNextTransNo( 43, $db); /* transaction type is asset deletion - (and remove cost/accumdepn from GL) */ + if ($AssetRow['cost'] > 0){ + //credit cost for the asset deleted + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) "; + $SQL= $SQL . "VALUES (43, + '" . $TransNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $AssetRow['costact'] . "', + '" . _('Delete asset') . ' ' . $AssetID . "', + '" . -$AssetRow['cost']. "' + )"; + $ErrMsg = _('Cannot insert a GL entry for the deletion of the asset because'); + $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + //debit accumdepn for the depreciation removed on deletion of this asset + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) "; + $SQL= $SQL . "VALUES (43, + '" . $TransNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $AssetRow['accumdepnact'] . "', + '" . _('Delete asset') . ' ' . $AssetID . "', + '" . $Asset['accumdepn']. "' + )"; + $ErrMsg = _('Cannot insert a GL entry for the reversal of accumulated depreciation on deletion of the asset because'); + $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + } //end if cost > 0 + + + $sql="DELETE FROM fixedassets WHERE assetid='" . $AssetID . "'"; + $result=DB_query($sql,$db, _('Could not delete the asset record'),'',true); - $sql="DELETE FROM fixedassets WHERE assetid='" . $AssetID . "'"; - $result=DB_query($sql,$db, _('Could not delete the asset record'),'',true); - $result = DB_Txn_Commit($db); prnMsg(_('Deleted the asset record for asset number' ) . ' ' . $AssetID ); @@ -210,18 +361,19 @@ unset($AssetID); unset($_SESSION['SelectedAsset']); - } //end if Delete Asset -} + } //end if OK Delete Asset +} /* end if delete asset */ echo '<form name="AssetForm" enctype="multipart/form-data" method="post" action="' . $_SERVER['PHP_SELF'] . '?' .SID . '"><table class=selection>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + if (!isset($AssetID) or $AssetID=='') { /*If the page was called without $AssetID passed to page then assume a new asset is to be entered other wise the form showing the fields with the existing entries against the asset will show for editing with a hidden AssetID field. New is set to flag that the page may have called itself and still be entering a new asset, in which case the page needs to know not to go looking up details for an existing asset*/ - $New = true; + $New = 1; echo '<input type="hidden" name="New" value="">'. "\n"; } elseif ($InputError!=1) { // Must be modifying an existing item and no changes made yet - need to lookup the details @@ -255,7 +407,7 @@ echo '<input type="Hidden" name="AssetID" value='.$AssetID.'>'. "\n"; } else { // some changes were made to the data so don't re-set form variables to DB ie the code above - echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$AssetID.'</td></tr>'; + echo '<tr><td>' . _('Asset Code') . ':</td><td>' . $AssetID . '</td></tr>'; echo '<input type="Hidden" name="AssetID" value="' . $AssetID . '">'; } @@ -264,7 +416,8 @@ } else { $Description =''; } -echo '<tr><td>' . _('Asset Description') . ' (' . _('short') . '):</td><td><input ' . (in_array('Description',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="Description" size=52 maxlength=50 value="' . $Description . '"></td></tr>'."\n"; +echo '<tr><td>' . _('Asset Description') . ' (' . _('short') . '):</td> + <td><input ' . (in_array('Description',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="Description" size=52 maxlength=50 value="' . $Description . '"></td></tr>'."\n"; if (isset($_POST['LongDescription'])) { $LongDescription = AddCarriageReturns($_POST['LongDescription']); @@ -273,33 +426,35 @@ } echo '<tr><td>' . _('Asset Description') . ' (' . _('long') . '):</td><td><textarea ' . (in_array('LongDescription',$Errors) ? 'class="texterror"' : '' ) .' name="LongDescription" cols=40 rows=4>' . stripslashes($LongDescription) . '</textarea></td></tr>'."\n"; -// Add image upload for New Item - by Ori -echo '<tr><td>'. _('Image File (.jpg)') . ':</td><td><input type="file" id="ItemPicture" name="ItemPicture"></td>'; -// EOR Add Image upload for New Item - by Ori +if ($New == 0) { //ie not new at all! + // Add image upload for New Item - by Ori + echo '<tr><td>'. _('Image File (.jpg)') . ':</td><td><input type="file" id="ItemPicture" name="ItemPicture"></td>'; + // EOR Add Image upload for New Item - by Ori -if (function_exists('imagecreatefromjpg')){ - $StockImgLink = '<img src="GetStockImage.php?SID&automake=1&textcolor=FFFFFF&bgcolor=CCCCCC'. - '&AssetID='.urlencode($AssetID). - '&text='. - '&width=64'. - '&height=64'. - '" >'; -} else { - if( isset($AssetID) and file_exists($_SESSION['part_pics_dir'] . '/ASSET_' .$AssetID.'.jpg') ) { - $AssetImgLink = '<img src="' . $_SESSION['part_pics_dir'] . '/ASSET_' .$AssetID.'.jpg" >'; + if (function_exists('imagecreatefromjpg')){ + $StockImgLink = '<img src="GetStockImage.php?SID&automake=1&textcolor=FFFFFF&bgcolor=CCCCCC'. + '&AssetID='.urlencode($AssetID). + '&text='. + '&width=64'. + '&height=64'. + '" >'; } else { - $AssetImgLink = _('No Image'); + if( isset($AssetID) and file_exists($_SESSION['part_pics_dir'] . '/ASSET_' .$AssetID.'.jpg') ) { + $AssetImgLink = '<img src="' . $_SESSION['part_pics_dir'] . '/ASSET_' .$AssetID.'.jpg" >'; + } else { + $AssetImgLink = _('No Image'); + } } -} + + if ($AssetImgLink!=_('No Image')) { + echo '<td>' . _('Image') . '<br>'.$AssetImgLink . '</td></tr>'; + } else { + echo '</td></tr>'; + } + + // EOR Add Image upload for New Item - by Ori +} //only show the add image if the asset already exists - otherwise AssetID will not be set - and the image needs the AssetID to save -if ($AssetImgLink!=_('No Image')) { - echo '<td>' . _('Image') . '<br>'.$AssetImgLink . '</td></tr>'; -} else { - echo '</td></tr>'; -} - -// EOR Add Image upload for New Item - by Ori - echo '<tr><td>' . _('Asset Category') . ':</td><td><select name="AssetCategoryID">'; $sql = 'SELECT categoryid, categorydescription FROM fixedassetcategories'; @@ -320,6 +475,13 @@ $_POST['AssetCategoryID']=$category; } +if ($_POST['DatePurchased']==''){ + $_POST['DatePurchased'] = Date($_SESSION['DefaultDateFormat'],mktime(0,0,0,date('m'),0,date('Y'))); +} + +echo '<tr><td>' . _('Date Purchased') . ':</td><td><input ' . (in_array('DatePurchased',$Errors) ? 'class="inputerror"' : 'class="date"' ) . ' alt="' .$_SESSION['DefaultDateFormat'] . '" type="Text" name="DatePurchased" size=12 maxlength=10 value="' . $_POST['DatePurchased '] . '"></td></tr>'; + + $sql = 'SELECT locationid, locationdescription FROM fixedassetlocations'; $ErrMsg = _('The asset locations could not be retrieved because'); $DbgMsg = _('The SQL used to retrieve asset locations and failed was'); @@ -335,113 +497,38 @@ } echo '</select></td></tr>'; - -if (isset($_POST['BarCode'])) { - $BarCode = $_POST['BarCode']; -} else { - $BarCode=''; -} echo '<tr><td>' . _('Bar Code') . ':</td><td><input ' . (in_array('BarCode',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="BarCode" size=22 maxlength=20 value="' . $BarCode . '"></td></tr>'; -echo '<tr><td>' . _('Tax Category') . ':</td><td><select name="TaxCat">'; -$sql = 'SELECT taxcatid, taxcatname FROM taxcategories ORDER BY taxcatname'; -$result = DB_query($sql, $db); +echo '<tr><td>' . _('Serial Number') . ':</td><td><input ' . (in_array('SerialNo',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="SerialNo" size=32 maxlength=30 value="' . $_POST['SerialNo'] . '"></td></tr>'; -if (!isset($_POST['TaxCat'])){ - $_POST['TaxCat'] = $_SESSION['DefaultTaxCategory']; -} -while ($myrow = DB_fetch_array($result)) { - if ($_POST['TaxCat'] == $myrow['taxcatid']){ - echo '<option selected value=' . $myrow['taxcatid'] . '>' . $myrow['taxcatname'] . '</option>'; - } else { - echo '<option value=' . $myrow['taxcatid'] . '>' . $myrow['taxcatname'] . '</option>'; - } -} //end while loop +echo '<tr><td>' . _('Depreciation Type') . ':</td><td><select name="DepnType">'; -echo '</select></td></tr></table>'; - - -if (!isset($_POST['AssetCategoryID'])) { - $_POST['AssetCategoryID'] = ''; +if (!isset($_POST['DepnType'])){ + $_POST['DepnType'] = 0; //0 = Straight line - 1 = Diminishing Value } -echo '<br><table class=selection><tr><th colspan="2">' . _('Depreciation Properties') . '</th></tr>'; -$sql = "SELECT stkcatpropid, - label, - controltype, - defaultvalue, - maximumvalue, - minimumvalue, - numericvalue - FROM stockcatproperties - WHERE categoryid ='" . $_POST['AssetCategoryID'] . "' - AND reqatsalesorder =0 - ORDER BY stkcatpropid"; +if ($_POST['DepnType']==0){ //straight line + echo '<option selected value="0">' . _('Straight Line') . '</option>'; + echo '<option value="1">' . _('Diminishing Value') . '</option>'; +} else { + echo '<option value="0">' . _('Straight Line') . '</option>'; + echo '<option selected value="1">' . _('Diminishing Value') . '</option>'; +} -$PropertiesResult = DB_query($sql,$db); -$PropertyCounter = 0; -$PropertyWidth = array(); +echo '</select></td></tr>'; -while ($PropertyRow=DB_fetch_array($PropertiesResult)){ +echo '<tr><td>' . _('Depreciation Rate') . ':</td><td><input ' . (in_array('DepnRate',$Errors) ? 'class="inputerror"' : 'class="number"' ) .' type="Text" name="DepnRate" size=3 maxlength=3 value="' . $_POST['DepnRate'] . '"></td></tr>'; - $PropValResult = DB_query("SELECT value FROM - stockitemproperties - WHERE assetid='" . $AssetID . "' - AND stkcatpropid ='" . $PropertyRow['stkcatpropid'] . "'", - $db); - $PropValRow = DB_fetch_row($PropValResult); - $PropertyValue = $PropValRow[0]; - - echo '<input type="hidden" name="PropID' . $PropertyCounter . '" value=' .$PropertyRow['stkcatpropid'] .'>'; - - echo '<tr><td>' . $PropertyRow['label'] . '</td> - <td>'; - switch ($PropertyRow['controltype']) { - case 0; //textbox - if ($PropertyRow['numericvalue']==1) { - echo '<input type="textbox" class="number" name="PropValue' . $PropertyCounter . '" size="20" maxlength="100" value="' . $PropertyValue . '">'; - echo _('A number between') . ' ' . $PropertyRow['minimumvalue'] . ' ' . _('and') . ' ' . $PropertyRow['maximumvalue'] . ' ' . _('is expected'); - } else { - echo '<input type="textbox" name="PropValue' . $PropertyCounter . '" size="20" maxlength="100" value="' . $PropertyValue . '">'; - } - break; - case 1; //select box - $OptionValues = explode(',',$PropertyRow['defaultvalue']); - echo '<select name="PropValue' . $PropertyCounter . '">'; - foreach ($OptionValues as $PropertyOptionValue){ - if ($PropertyOptionValue == $PropertyValue){ - echo '<option selected value="' . $PropertyOptionValue . '">' . $PropertyOptionValue . '</option>'; - } else { - echo '<option value="' . $PropertyOptionValue . '">' . $PropertyOptionValue . '</option>'; - } - } - echo '</select>'; - break; - case 2; //checkbox - echo '<input type="checkbox" name="PropValue' . $PropertyCounter . '"'; - if ($PropertyValue==1){ - echo '"checked"'; - } - echo '>'; - break; - } //end switch - echo '<input type="hidden" name="PropType' . $PropertyCounter .'" value=' . $PropertyRow['controltype'] . '>'; - echo '</td></tr>'; - $PropertyCounter++; -} //end loop round properties for the item category echo '</table>'; -echo '<input type="hidden" name="PropertyCounter" value=1>'; if ($New==1) { - echo '<div class=centre><br><input type="Submit" name="submit" value="' . _('Insert New Item') . '">'; + echo '<div class=centre><br><input type="Submit" name="submit" value="' . _('Insert New Fixed Asset') . '">'; } else { - - // Now the form to enter the item properties + echo '<br><div class=centre><input type="submit" name="submit" value="' . _('Update') . '"></div>'; - echo '<input type="submit" name="UpdateCategories" style="visibility:hidden;width:1px" value="' . _('Categories') . '">'; - prnMsg( _('Only click the Delete button if you are sure you wish to delete the asset.'), 'warn', _('WARNING')); - echo '<br><div class=centre><input type="Submit" name="delete" value="' . _('Delete This Asset') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');"></div>'; + prnMsg( _('Only click the Delete button if you are sure you wish to delete the asset. Only assets with a zero book value can be deleted'), 'warn', _('WARNING')); + echo '<br><div class=centre><input type="Submit" name="delete" value="' . _('Delete This Asset') . '" onclick="return confirm(\'' . _('Are You Sure? Only assets with a zero book value can be deleted.') . '\');"></div>'; } echo '</form></div>'; Modified: trunk/FixedAssetLocations.php =================================================================== --- trunk/FixedAssetLocations.php 2010-11-18 10:00:57 UTC (rev 4159) +++ trunk/FixedAssetLocations.php 2010-11-20 08:13:47 UTC (rev 4160) @@ -10,83 +10,73 @@ if (isset($_POST['submit']) and !isset($_POST['delete'])) { $InputError=0; - if (!isset($_POST['locationid']) or strlen($_POST['locationid'])<1) { + if (!isset($_POST['LocationID']) or strlen($_POST['LocationID'])<1) { prnMsg(_('You must enter at least one character in the location ID'),'error'); $InputError=1; } - if (!isset($_POST['locdesc']) or strlen($_POST['locdesc'])<1) { + if (!isset($_POST['LocationDescription']) or strlen($_POST['LocationDescription'])<1) { prnMsg(_('You must enter at least one character in the location description'),'error'); $InputError=1; } if ($InputError==0) { $sql='INSERT INTO fixedassetlocations - VALUES ( - "'.$_POST['locationid'].'", - "'.$_POST['locdesc'].'", - "'.$_POST['parentlocationid'].'")'; + VALUES ( + "'.$_POST['LocationID'].'", + "'.$_POST['LocationDescription'].'", + "'.$_POST['ParentLocationID'].'")'; $result=DB_query($sql, $db); } } if (isset($_GET['SelectedLocation'])) { $sql='SELECT * FROM fixedassetlocations WHERE locationid="'.$_GET['SelectedLocation'].'"'; - $result=DB_query($sql, $db); - $myrow=DB_fetch_array($result); - $locationid=$myrow['locationid']; - $locdesc=$myrow['locationdescription']; - $parentlocationid=$myrow['parentlocationid']; + $result = DB_query($sql, $db); + $myrow = DB_fetch_array($result); + $LocationID = $myrow['locationid']; + $LocationDescription = $myrow['locationdescription']; + $ParentLocationID = $myrow['parentlocationid']; } else { - $locationid=''; - $locdesc=''; + $LocationID = ''; + $LocationDescription = ''; } -//Batman: Attempting to update fields +//Attempting to update fields + if (isset($_POST['update']) and !isset($_POST['delete'])) { $InputError=0; - /*Batman: Removing the ID - if (!isset($_POST['locationid']) or strlen($_POST['locationid'])<1) { - prnMsg(_('You must enter at least one character in the location ID'),'error'); - $InputError=1; - }*/ - if (!isset($_POST['locdesc']) or strlen($_POST['locdesc'])<1) { + if (!isset($_POST['LocationDescription']) or strlen($_POST['LocationDescription'])<1) { prnMsg(_('You must enter at least one character in the location description'),'error'); $InputError=1; } if ($InputError==0) { - $sql='UPDATE fixedassetlocations SET - locationdescription="'.$_POST['locdesc'].'", - parentlocationid="'.$_POST['parentlocationid'].'" - WHERE locationid ="'.$_POST['locationid'].'"'; - $result=DB_query($sql,$db); -//Batman: Testing leaking sql echo $sql; - echo '<meta http-equiv="Refresh" content="0; url="'.$_SERVER['PHP_SELF'].'">'; - } + $sql='UPDATE fixedassetlocations SET + locationdescription="'.$_POST['LocationDescription'].'", + parentlocationid="'.$_POST['ParentLocationID'].'" + WHERE locationid ="'.$_POST['LocationID'].'"'; + $result=DB_query($sql,$db); + echo '<meta http-equiv="Refresh" content="0; url="'.$_SERVER['PHP_SELF'].'">'; + } } else { // if you are not updating then you want to delete but lets be sure first. if (isset($_POST['delete'])) { $InputError=0; - - if (!isset($_POST['locdesc']) or strlen($_POST['locdesc'])<1) { - prnMsg(_('You must enter at least one character in the location description'),'error'); - $InputError=1; - } - - $sql="SELECT COUNT(locationid) FROM fixedassetlocations WHERE parentlocationid='" . $_POST['locationid']."'"; + + $sql="SELECT COUNT(locationid) FROM fixedassetlocations WHERE parentlocationid='" . $_POST['LocationID']."'"; $result = DB_query($sql,$db); $myrow=DB_fetch_row($result); if ($myrow[0]>0) { prnMsg(_('This location has child locations so cannot be removed'), 'warning'); $InputError=1; } - $sql="SELECT COUNT(id) FROM assetmanager WHERE location='" . $_POST['locationid']."'"; + $sql="SELECT COUNT(assetid) FROM fixedassets WHERE assetlocation='" . $_POST['LocationID']."'"; $result = DB_query($sql,$db); $myrow=DB_fetch_row($result); if ($myrow[0]>0) { - prnMsg(_('You have assets in this location location so cannot be removed'), 'warning'); + prnMsg(_('You have assets in this location location so it cannot be removed'), 'warn'); $InputError=1; } if ($InputError==0) { - $sql = "DELETE FROM fixedassetlocations WHERE locationid = '".$_POST['locationid']."'"; + $sql = "DELETE FROM fixedassetlocations WHERE locationid = '".$_POST['LocationID']."'"; $result = DB_query($sql,$db); prnMsg(_('The location has been deleted successfully'), 'success'); } @@ -99,61 +89,55 @@ if (DB_num_rows($result) > 0) { echo '<table class=selection><tr>'; echo '<th>'._('Location ID').'</th> - <th>'._('Location Description').'</th> - <th>'._('Parent Location').'</th></tr>'; + <th>'._('Location Description').'</th> + <th>'._('Parent Location').'</th></tr>'; } while ($myrow=DB_fetch_array($result)) { - - $parentsql="select locationdescription from fixedassetlocations where locationid='".$myrow['parentlocationid']."'"; + echo '<tr><td>'.$myrow['locationid'].'</td> + <td>'.$myrow['locationdescription'].'</td>'; + $parentsql="SELECT locationdescription FROM fixedassetlocations WHERE locationid='".$myrow['parentlocationid']."'"; $parentresult=DB_query($parentsql, $db); $parentrow=DB_fetch_array($parentresult); - echo '<tr><td>'.$myrow['locationid'].'</td>'; - echo '<td>'.$myrow['locationdescription'].'</td>'; echo '<td>'.$parentrow['locationdescription'].'</td>'; - echo '<td><a href="'.$_SERVER['PHP_SELF'] . '?' . SID.'SelectedLocation='.$myrow['locationid'].'">' . - _('Edit') . '</td>'; //Batman: added '; and duplicated line as below -//Batman: Just hashed this out</tr>'; + echo '<td><a href="'.$_SERVER['PHP_SELF'] . '?' . SID.'SelectedLocation='.$myrow['locationid'].'">' . _('Edit') . '</td>'; } -//Batman: Capturing the location ID before the update process -//echo $loc = "'.$_POST['locationid'].'"; echo '</table><br>'; echo '<form name="LocationForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><table class=selection>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<tr><th style="text-align:left">'._('Location ID').'</th>'; if (isset($_GET['SelectedLocation'])) { - echo '<input type=hidden name=locationid value="'.$locationid.'">'; - echo '<td>'.$locationid.'</td>'; + echo '<input type=hidden name=LocationID value="'.$LocationID.'">'; + echo '<td>'.$LocationID.'</td>'; } else { - echo '<td><input type=text name=locationid size=6 value="'.$locationid.'"></td></tr>'; + echo '<td><input type=text name=LocationID size=6 value="'.$LocationID.'"></td></tr>'; } echo '<tr><th style="text-align:left">'._('Location Description').'</th>'; -echo '<td><input type=text name=locdesc size=20 value="'.$locdesc.'"></td></tr>'; +echo '<td><input type=text name=LocationDescription size=20 value="'.$LocationDescription.'"></td></tr>'; echo '<tr><th style="text-align:left">'._('Parent Location').'</th>'; -echo '<td><select name=parentlocationid>'; +echo '<td><select name=ParentLocationID>'; $sql='SELECT * FROM fixedassetlocations'; $result=DB_query($sql, $db); echo '<option value=""></option>'; while ($row=DB_fetch_array($result)) { - if ($row['locationid']==$parentlocationid) { + if ($row['locationid']==$ParentLocationID) { echo '<option selected value="'.$row['locationid'].'">'.$row['locationdescription'].'</option>'; } else { echo '<option value="'.$row['locationid'].'">'.$row['locationdescription'].'</option>'; } } echo '</select>'; -//Batman: Collecting all ParentLocations echo '</td></tr>'; echo '</table><br>'; -//Batman: parentlocationid checking the location ID -//echo $locationid; +//Batman: ParentLocationID checking the location ID +//echo $LocationID; echo '<div class="centre">'; if (isset($_GET['SelectedLocation'])) { Modified: trunk/SelectAsset.php =================================================================== --- trunk/SelectAsset.php 2010-11-18 10:00:57 UTC (rev 4159) +++ trunk/SelectAsset.php 2010-11-20 08:13:47 UTC (rev 4160) @@ -8,8 +8,7 @@ if (isset($_GET['AssetID'])) { //The page is called with a AssetID - $_GET['AssetID'] = trim(strtoupper($_GET['AssetID'])); - $_POST['Select'] = trim(strtoupper($_GET['AssetID'])); + $_POST['Select'] = $_GET['AssetID']; } if (isset($_GET['NewSearch']) or isset($_POST['Next']) or isset($_POST['Previous']) or isset($_POST['Go'])) { @@ -30,11 +29,10 @@ // Always show the search facilities $SQL = 'SELECT categoryid, categorydescription - FROM stockcategory - WHERE stocktype="A" + FROM fixedassetcategories ORDER BY categorydescription'; -$result1 = DB_query($SQL, $db); -if (DB_num_rows($result1) == 0) { +$result = DB_query($SQL, $db); +if (DB_num_rows($result) == 0) { echo '<p><font size=4 color=red>' . _('Problem Report') . ':</font><br>' . _('There are no asset categories currently defined please use the link below to set them up'); echo '<br><a href="' . $rootpath . '/FixedAssetCategories.php?' . SID . '">' . _('Define Asset Categories') . '</a>'; exit; @@ -45,37 +43,63 @@ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'</p>'; echo '<table class=selection><tr>'; -echo '<td>' . _('In Asset Category') . ':'; -echo '<select name="AssetCat">'; -if (!isset($_POST['AssetCat'])) { - $_POST['AssetCat'] = ""; +echo '<td>' . _('In Asset Category') . ':</td><td>'; +echo '<select name="AssetCategory">'; + +if (!isset($_POST['AssetCategory'])) { + $_POST['AssetCategory'] = ""; } +if ($_POST['AssetCategory']=='ALL'){ + echo '<option selected value="ALL">' . _('Any asset category') . '</option>'; +} else { + echo '<option value="ALL">' . _('Any asset category') . '</option>'; +} -while ($myrow1 = DB_fetch_array($result1)) { - if ($myrow1['categoryid'] == $_POST['AssetCat']) { - echo '<option selected VALUE="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription']; +while ($myrow = DB_fetch_array($result)) { + if ($myrow['categoryid'] == $_POST['AssetCategory']) { + echo '<option selected VALUE="' . $myrow['categoryid'] . '">' . $myrow['categorydescription']; } else { - echo '<option value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription']; + echo '<option value="' . $myrow['categoryid'] . '">' . $myrow['categorydescription']; } } echo '</select>'; -echo '<td>' . _('Enter partial') . '<b> ' . _('Description') . '</b>:</td><td>'; + +echo '<td>' . _('Enter partial description') . '</b>:</td><td>'; if (isset($_POST['Keywords'])) { echo '<input type="text" name="Keywords" value="' . $_POST['Keywords'] . '" size=20 maxlength=25>'; } else { echo '<input type="text" name="Keywords" size=20 maxlength=25>'; } -echo '</td></tr><tr><td></td>'; -echo '<td><font size 3><b>' . _('OR') . ' ' . '</b></font>' . _('Enter partial') . ' <b>' . _('Stock Code') . '</b>:</td>'; +echo '</td></tr><tr><td>' . _('Asset Location') . ':</td><td><select name="AssetLocation">'; +if (!isset($_POST['AssetLocation'])) { + $_POST['AssetLocation'] = 'ALL'; +} +if ($_POST['AssetLocation']=='ALL'){ + echo '<option selected value="ALL">' . _('Any asset location') . '</option>'; +} else { + echo '<option value="ALL">' . _('Any asset location') . '</option>'; +} +$result = DB_query('SELECT locationid, locationdescription FROM fixedassetlocations',$db); + +while ($myrow = DB_fetch_array($result)) { + if ($myrow['locationid'] == $_POST['AssetLocation']) { + echo '<option selected VALUE="' . $myrow['locationid'] . '">' . $myrow['locationdescription']; + } else { + echo '<option value="' . $myrow['locationid'] . '">' . $myrow['locationdescription']; + } +} +echo '</select>'; + +echo ' </td><td><b>' . _('OR') . ' ' . '</b>' . _('Enter partial asset code') . '</b>:</td>'; echo '<td>'; if (isset($_POST['AssetCode'])) { - echo '<input type="text" name="AssetCode" value="' . $_POST['AssetCode'] . '" size=15 maxlength=18>'; + echo '<input type="text" class="number" name="AssetCode" value="' . $_POST['AssetCode'] . '" size=15 maxlength=13>'; } else { - echo '<input type="text" name="AssetCode" size=15 maxlength=18>'; + echo '<input type="text" name="AssetCode" size=15 maxlength=13>'; } echo '</td></tr></table><br>'; echo '<div class="centre"><input type=submit name="Search" value="' . _('Search Now') . '"></div><br></form>'; -echo '<script type="text/javascript">defaultControl(document.forms[0].AssetCode);</script>'; +echo '<script type="text/javascript">defaultControl(document.forms[0].Keywords);</script>'; echo '</form>'; // query for list of record(s) if(isset($_POST['Go']) OR isset($_POST['Next']) OR isset($_POST['Previous'])) { @@ -89,58 +113,59 @@ if ($_POST['Keywords'] AND $_POST['AssetCode']) { prnMsg( _('Asset description keywords have been used in preference to the asset code extract entered'), 'info' ); } + $SQL = 'SELECT assetid, + description, + datepurchased, + fixedassetlocations.locationdescription + FROM fixedassets INNER JOIN fixedassetlocations + ON fixedassets.assetlocation=fixedassetlocations.locationid '; + if ($_POST['Keywords']) { //insert wildcard characters in spaces $_POST['Keywords'] = strtoupper($_POST['Keywords']); $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; - if ($_POST['AssetCat'] == 'All') { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster - WHERE stockmaster.description " . LIKE . " '$SearchString' - ORDER BY stockmaster.stockid"; + if ($_POST['AssetCategory'] == 'All') { + if ($_POST['AssetLocation']=='ALL'){ + $SQL .= 'WHERE description ' . LIKE . "'" . $SearchString . "' ORDER BY fixedassets.assetid"; + } else { + $SQL .= "WHERE fixedassets.assetlocation='" . $_POST['AssetLocation'] . "' AND description " . LIKE . "'" . $SearchString . "' ORDER BY fixedassets.assetid"; + } } else { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster - WHERE description " . LIKE . " '$SearchString' - AND categoryid='" . $_POST['AssetCat'] . "' - ORDER BY stockmaster.stockid"; + if ($_POST['AssetLocation']=='ALL'){ + $SQL .= 'WHERE description ' . LIKE . "'" . $SearchString . "' AND assetcategoryid='" . $_POST['AssetCategory'] . "' ORDER BY fixedassets.assetid"; + } else { + $SQL .= "WHERE fixedassets.assetlocation='" . $_POST['AssetLocation'] . "' AND description " . LIKE . "'" . $SearchString . "' AND assetcategoryid='" . $_POST['AssetCategory'] . "' + ORDER BY fixedassets.assetid"; + } } } elseif (isset($_POST['AssetCode'])) { - $_POST['AssetCode'] = strtoupper($_POST['AssetCode']); - if ($_POST['AssetCat'] == 'All') { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster - WHERE stockmaster.stockid " . LIKE . " '%" . $_POST['AssetCode'] . "%' - ORDER BY stockmaster.stockid"; + if ($_POST['AssetCategory'] == 'ALL') { + if ($_POST['AssetLocation']=='ALL'){ + $SQL .= 'WHERE fixedassets.assetid ' . LIKE . " '%" . $_POST['AssetCode'] . "%' ORDER BY fixedassets.assetid"; + } else { + $SQL .= "WHERE fixedassets.assetlocation='" . $_POST['AssetLocation'] . "' AND fixedassets.assetid " . LIKE . " '%" . $_POST['AssetCode'] . "%' ORDER BY fixedassets.assetid"; + } } else { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster - WHERE stockmaster.stockid " . LIKE . " '%" . $_POST['AssetCode'] . "%' - AND categoryid='" . $_POST['AssetCat'] . "' - ORDER BY stockmaster.stockid"; + if ($_POST['AssetLocation']=='ALL'){ + $SQL .= 'WHERE fixedassets.assetid ' . LIKE . " '%" . $_POST['AssetCode'] . "%' AND assetcategoryid='" . $_POST['AssetCategory'] . "' + ORDER BY fixedassets.assetid"; + } else { + $SQL .= "WHERE fixedassets.assetlocation='" . $_POST['AssetLocation'] . "' AND fixedassets.assetid " . LIKE . " '%" . $_POST['AssetCode'] . "%' AND assetcategoryid='" . $_POST['AssetCategory'] . "' ORDER BY fixedassets.assetid"; + } } } elseif (!isset($_POST['AssetCode']) AND !isset($_POST['Keywords'])) { - if ($_POST['AssetCat'] == 'All') { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster - ORDER BY stockmaster.stockid"; + if ($_POST['AssetCategory'] == 'All') { + if ($_POST['AssetLocation']=='ALL'){ + $SQL .= 'ORDER BY fixedassets.assetid'; + } else { + $SQL .= "WHERE fixedassets.assetlocation='" . $_POST['AssetLocation'] . "' ORDER BY fixedassets.assetid"; + } } else { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster - WHERE categoryid='" . $_POST['AssetCat'] . "' - ORDER BY stockmaster.stockid"; + if ($_POST['AssetLocation']=='ALL'){ + $SQL .= "WHERE assetcategoryid='" . $_POST['AssetCategory'] . "' ORDER BY fixedassets.assetid"; + } else { + $SQL .= "WHERE assetcategoryid='" . $_POST['AssetCategory'] . "' AND fixedassets.assetlocation='" . $_POST['AssetLocation'] . "' ORDER BY fixedassets.assetid"; + } } } $ErrMsg = _('No assets were returned by the SQL because'); @@ -189,16 +214,15 @@ <input type=submit name="Go" value="' . _('Go') . '"> <input type=submit name="Previous" value="' . _('Previous') . '"> <input type=submit name="Next" value="' . _('Next') . '">'; - echo '<input type=hidden name=Keywords value="'.$_POST['Keywords'].'">'; - echo '<input type=hidden name=AssetCat value="'.$_POST['AssetCat'].'">'; - echo '<input type=hidden name=AssetCode value="'.$_POST['AssetCode'].'">'; + echo '<p></div>'; } echo '<table cellpadding=2 colspan=7 class=selection>'; $tableheader = '<tr> - <th>' . _('Code') . '</th> + <th>' . _('Asset Code') . '</th> <th>' . _('Description') . '</th> - <th>' . _('Units') . '</th> + <th>' . _('Date Purchased') . '</th> + <th>' . _('Asset Location') . '</th> </tr>'; echo $tableheader; $j = 1; @@ -215,10 +239,11 @@ echo '<tr class="OddTableRows">'; $k++; } - echo "<td><input type=submit name='Select' value='".$myrow['stockid']."'></td> - <td>".$myrow['description']."</td> - <td>".$myrow['units']."</td> - </tr>"; + echo '<td><input type="submit" name="Select" value="' . $myrow['assetid'] .'"></td> + <td>' . $myrow['description'] . '</td> + <td>' . $myrow['locationdescription'] . '</td> + <td>' . ConvertSQLDate($myrow['datepurchased']) . '</td> + </tr>'; $j++; if ($j == 20 AND ($RowIndex + 1 != $_SESSION['DisplayRecordsMax'])) { $j = 1; @@ -228,8 +253,8 @@ //end of page full new headings if } //end of while loop - echo '</table></form><br>'; - } + echo '</table></form>'; + } // there were records to list } /* end display list if there is more than one record */ include ('includes/footer.inc'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-18 10:00:57 UTC (rev 4159) +++ trunk/doc/Change.log.html 2010-11-20 08:13:47 UTC (rev 4160) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>20/11/10 Phil:Rewritten FixedAssetItems.php FixedAssetCategories.php and modified FixedAssetLocations.php to use the new structure <p>18/11/10 Tim: upgrade3.11.1-4.00.sql - Fix sql syntax errors brought in on recent changes.</p> <p>14/11/10 Phil: SelectAsset.php script reworked SelectAssetType.php script now deleted</p> <p>08/11/10 Exson: Z_ImportStocks.php - Bug fixes.</p> @@ -11,7 +12,7 @@ <p>06/11/10 Tim: Selectproduct.php - Remove fixed assets from selections</p> <p>06/11/10 Tim: InventoryValuation.php - Ensure fixed assets dont get shown in valuation report</p> <p>06/11/10 Tim: FixedAssetItems.php - Fixed typo preventing Item code being shown</p> -<p>06/11/10 Phil: StockCategory.php FixedAssetCategory.php attempt to add validation to depreciation rates by extending the stock category property logic with new fields for numericvalue, minimumvalue and maximumvalue. Then adding the depreciation rate percentage property to expect numeric values with a minimum of 0 and maximum of 100. Not re... [truncated message content] |
From: <dai...@us...> - 2010-11-21 00:25:59
|
Revision: 4161 http://web-erp.svn.sourceforge.net/web-erp/?rev=4161&view=rev Author: daintree Date: 2010-11-21 00:25:51 +0000 (Sun, 21 Nov 2010) Log Message: ----------- Fixed Asset Module - deprn journal Modified Paths: -------------- trunk/FixedAssetCategories.php trunk/FixedAssetItems.php trunk/FixedAssetJournal.php trunk/GoodsReceived.php trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/FixedAssetCategories.php =================================================================== --- trunk/FixedAssetCategories.php 2010-11-20 08:13:47 UTC (rev 4160) +++ trunk/FixedAssetCategories.php 2010-11-21 00:25:51 UTC (rev 4161) @@ -41,6 +41,37 @@ prnMsg(_('The Fixed Asset Category description must be twenty characters or less long'),'error'); } + if ($_POST['CostAct'] == $_SESSION['CompanyRecord']['debtorsact'] + OR $_POST['CostAct'] == $_SESSION['CompanyRecord']['creditorsact'] + OR $_POST['AccumDepnAct'] == $_SESSION['CompanyRecord']['debtorsact'] + OR $_POST['AccumDepnAct'] == $_SESSION['CompanyRecord']['creditorsact'] + OR $_POST['CostAct'] == $_SESSION['CompanyRecord']['grnact'] + OR $_POST['AccumDepnAct'] == $_SESSION['CompanyRecord']['grnact']){ + prnMsg(_('The accounts selected to post cost or accumulated depreciation to cannot be either of the debtors control account, creditors control account or GRN suspense accounts'),'error'); + $InputError =1; + } + /*Make an array of the defined bank accounts */ + $SQL = 'SELECT bankaccounts.accountcode + FROM bankaccounts, + chartmaster + WHERE bankaccounts.accountcode=chartmaster.accountcode'; + $result = DB_query($SQL,$db); + $BankAccounts = array(); + $i=0; + + while ($Act = DB_fetch_row($result)){ + $BankAccounts[$i]= $Act[0]; + $i++; + } + if (in_array($_POST['CostAct'], $BankAccounts)) { + prnMsg( _('The asset cost account selected is a bank account - bank accounts are protected from having any other postings made to them. Select another balance sheet account for the asset cost'),'error'); + $InputError =1; + } + if (in_array($_POST['AccumDepnAct'], $BankAccounts)) { + prnMsg( _('The accumulated depreciation account selected is a bank account - bank accounts are protected from having any other postings made to them. Select another balance sheet account for the asset accumulated depreciation'),'error'); + $InputError =1; + } + if (isset($SelectedCategory) AND $InputError !=1) { /*SelectedCategory could also exist if submit had not been clicked this code Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-11-20 08:13:47 UTC (rev 4160) +++ trunk/FixedAssetItems.php 2010-11-21 00:25:51 UTC (rev 4161) @@ -219,7 +219,7 @@ description='" . $_POST['Description'] . "', assetcategoryid='" . $_POST['AssetCategoryID'] . "', assetlocation='" . $_POST['AssetLocation'] . "', - datepurchased='" . $_POST['DatePurchased'] . "', + datepurchased='" . FormatDateForSQL($_POST['DatePurchased']) . "', depntype='" . $_POST['DepnType'] . "', depnrate='" . $_POST['DepnRate'] . "', barcode='" . $_POST['BarCode'] . "', @@ -248,7 +248,7 @@ '" . $_POST['LongDescription'] . "', '" . $_POST['AssetCategoryID'] . "', '" . $_POST['AssetLocation'] . "', - '" . $_POST['DatePurchased'] . "', + '" . FormatDateForSQL($_POST['DatePurchased']) . "', '" . $_POST['DepnType'] . "', '" . $_POST['DepnRate']. "', '" . $_POST['BarCode'] . "', Modified: trunk/FixedAssetJournal.php =================================================================== --- trunk/FixedAssetJournal.php 2010-11-20 08:13:47 UTC (rev 4160) +++ trunk/FixedAssetJournal.php 2010-11-21 00:25:51 UTC (rev 4161) @@ -11,396 +11,220 @@ include('includes/header.inc'); include('includes/SQL_CommonFunctions.inc'); -if (isset($_GET['NewJournal']) and $_GET['NewJournal'] == 'Yes' AND isset($_SESSION['JournalDetail'])){ - unset($_SESSION['JournalDetail']->GLEntries); - unset($_SESSION['JournalDetail']); -} -if (!isset($_SESSION['JournalDetail']) or isset($_POST['update'])){ - $_SESSION['JournalDetail'] = new Journal; +/*Get the last period depreciation (depn is transtype =44) was posted for */ +$result = DB_query('SELECT periods.lastdate_in_period, max(fixedassettrans.periodno) FROM fixedassettrans INNER JOIN periods ON fixedassettrans.periodno=periods.periodno WHERE transtype=44 GROUP BY periods.lastdate_in_period',$db); - /* Make an array of the defined bank accounts - better to make it now than do it each time a line is added - Journals cannot be entered against bank accounts GL postings involving bank accounts must be done using - a receipt or a payment transaction to ensure a bank trans is available for matching off vs statements */ +$LastDepnRun = DB_fetch_row($result); - $SQL = 'SELECT accountcode FROM bankaccounts'; - $result = DB_query($SQL,$db); - $i=0; - while ($Act = DB_fetch_row($result)){ - $_SESSION['JournalDetail']->BankAccounts[$i]= $Act[0]; - $i++; - } +//echo '<BR>LastRun period = ' . $LastDepnRun[1] . ' Last date in period = ' . $LastDepnRun[0]; - /* Get list of assets for journal */ - $sql='SELECT assetmanager.*, - stockcategory.wipact as bsdepn, - stockcategory.adjglact as pldepn, - fixedassetlocations.locationdescription - FROM assetmanager - LEFT JOIN stockmaster - ON assetmanager.stockid=stockmaster.stockid - LEFT JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - LEFT JOIN fixedassetlocations - ON fixedassetlocations.locationid=assetmanager.location'; - $result=DB_query($sql, $db); - $i=0; - while ($myrow=DB_fetch_array($result)) { - $assetarray[$i]=$myrow; - // Find depreciation type - $typesql='SELECT stockitemproperties.value - FROM stockitemproperties - LEFT JOIN stockcatproperties - ON stockcatproperties.stkcatpropid=stockitemproperties.stkcatpropid - WHERE stockitemproperties.stockid="'.$myrow['stockid'].'" - AND stockcatproperties.label="'._('Depreciation Type').'"'; - $typeresult=DB_query($typesql,$db); - $typerow=DB_fetch_array($typeresult); - $assetarray[$i]['DepreciationType']=$typerow['value']; +$AllowUserEnteredProcessDate = true; - // Find the depreciation rate - $ratesql='SELECT stockitemproperties.value - FROM stockitemproperties - LEFT JOIN stockcatproperties - ON stockcatproperties.stkcatpropid=stockitemproperties.stkcatpropid - WHERE stockitemproperties.stockid="'.$myrow['stockid'].'" - AND stockcatproperties.label="'._('Annual Depreciation Percentage').'"'; - $rateresult=DB_query($ratesql, $db); - $raterow=DB_fetch_array($rateresult); - $assetarray[$i]['DepreciationRate']=$raterow['value']; - - - $bsnamesql='SELECT accountname FROM chartmaster WHERE accountcode="'.$assetarray[$i]['bsdepn'].'"'; - $bsnameresult=DB_query($bsnamesql, $db); - $bsnamerow=DB_fetch_array($bsnameresult); - $assetarray[$i]['bsdepnaccount']=$bsnamerow['accountname']; - $plnamesql='SELECT accountname FROM chartmaster WHERE accountcode="'.$assetarray[$i]['pldepn'].'"'; - $plnameresult=DB_query($plnamesql, $db); - $plnamerow=DB_fetch_array($plnameresult); - $assetarray[$i]['pldepnaccount']=$plnamerow['accountname']; - - /* Need a method to correctly enter the journal date, - * and for it to be available to the depn calculation - Tim - */ - - if (isset($_POST['JournalProcessDate'])) { - $_SESSION['JournalDetail']->JnlDate=$_POST['JournalProcessDate']; - } - if (!Is_Date($_SESSION['JournalDetail']->JnlDate)){ - // Default the date to the last day of the previous month - $_SESSION['JournalDetail']->JnlDate = Date($_SESSION['DefaultDateFormat'],mktime(0,0,0,date('m'),0,date('Y'))); - } - - $NoOfMonths=DateDiff($_SESSION['JournalDetail']->JnlDate,ConvertSQLDate($assetarray[$i]['datepurchased']), 'm'); - if ($assetarray[$i]['DepreciationType']==_('Straight Line')) { - $TotalDepnAmount=round(($NoOfMonths/12)*($assetarray[$i]['DepreciationRate']/100)*$assetarray[$i]['cost'],2); - } else { - $TotalDepnAmount=round(($NoOfMonths/12)*($assetarray[$i]['DepreciationRate']/100)* - ($assetarray[$i]['cost']-$assetarray[$i]['depn']),2); - } - - if (($TotalDepnAmount+$assetarray[$i]['disposalvalue'])>$assetarray[$i]['cost']) { - $TotalDepnAmount=$assetarray[$i]['cost']-$assetarray[$i]['disposalvalue']; - } - $assetarray[$i]['narrative']='Depreciation Journal - '.$assetarray[$i]['stockid']. - ' - '.$assetarray[$i]['serialno'].' - '.$assetarray[$i]['locationdescription']; - - $_SESSION['JournalDetail']->Add_To_GLAnalysis( - -($TotalDepnAmount-$assetarray[$i]['depn']), - $assetarray[$i]['narrative'], - $assetarray[$i]['bsdepn'], - $assetarray[$i]['bsdepnaccount'], - 0, - $assetarray[$i]['id']); - - $_SESSION['JournalDetail']->Add_To_GLAnalysis( - $TotalDepnAmount-$assetarray[$i]['depn'], - $assetarray[$i]['narrative'], - $assetarray[$i]['pldepn'], - $assetarray[$i]['pldepnaccount'], - 0, - $assetarray[$i]['id']); - $i++; +if ($LastDepnRun[1]==0 AND $LastDepnRun[0]==NULL) { //then depn has never been run yet? + + /*in this case default depreciation calc to the last day of last month - and allow user to select a period */ + if (!isset($_POST['ProcessDate'])) { + $_POST['ProcessDate'] = Date($_SESSION['DefaultDateFormat'],mktime(0,0,0,date('m'),0,date('Y'))); } + +} else { //depn calc has been run previously + $AllowUserEnteredProcessDate = false; + $_POST['ProcessDate'] = DateAdd(ConvertSQLDate($LastDepnRun[0]),'m',1); } +$PeriodNo = GetPeriod($_POST['ProcessDate'],$db); -if (isset($_POST['JournalProcessDate'])){ - $_SESSION['JournalDetail']->JnlDate=$_POST['JournalProcessDate']; +/* Get list of assets for journal */ +$sql='SELECT fixedassets.assetid, + fixedassets.description, + fixedassets.cost, + fixedassets.accumdepn, + fixedassets.depntype, + fixedassets.depnrate, + fixedassetcategories.accumdepnact AS bsdepn, + fixedassetcategories.depnact AS pldepn, + fixedassetcategories.categorydescription + FROM fixedassets + INNER JOIN fixedassetcategories + ON fixedassets.assetcategoryid=fixedassetcategories.categoryid + ORDER BY assetcategoryid, assetid'; +$result=DB_query($sql, $db); - if (!Is_Date($_POST['JournalProcessDate'])){ - prnMsg(_('The date entered was not valid please enter the date to process the journal in the format'). $_SESSION['DefaultDateFormat'],'warn'); - $_POST['CommitBatch']='Do not do it the date is wrong'; - } +if (isset($_POST['CommitDepreciation'])){ + $result = DB_Txn_Begin($db); + $TransNo = GetNextTransNo(44, $db); + } -if (isset($_POST['JournalType'])){ - $_SESSION['JournalDetail']->JournalType = $_POST['JournalType']; -} -if (isset($_POST['CommitBatch']) and $_POST['CommitBatch']==_('Accept and Process Journal')){ +echo '<p></p><table>'; +$Heading = '<tr><th>' . _('Asset ID') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Cost') . '</th> + <th>' . _('Accum Depn') . '</th> + <th>' . _('B/fwd Book Value') . '</th> + <th>'. _('Depn Type') . '</th> + <th>'. _('Depn Rate') . '</th> + <th>' . _('New Depn') . '</th> + </tr>'; +echo $Heading; - /* once the GL analysis of the journal is entered - process all the data in the session cookie into the DB - A GL entry is created for each GL entry -*/ +$AssetCategoryDescription ='0'; - $PeriodNo = GetPeriod($_SESSION['JournalDetail']->JnlDate,$db); +$TotalCost =0; +$TotalAccumDepn=0; +$TotalDepn = 0; +$RowCounter = 0; +$k=0; - /*Start a transaction to do the whole lot inside */ - $result = DB_Txn_Begin($db); - - $TransNo = GetNextTransNo( 0, $db); - $BSorPL=1; // Balance sheet or P&L indicator - - foreach ($_SESSION['JournalDetail']->GLEntries as $JournalItem) { - $odd=$BSorPL%2; - if ($odd==0) { - $sql='UPDATE assetmanager SET depn=depn+"'.$JournalItem->Amount.'" WHERE id="'.$JournalItem->assetid.'"'; - $ErrMsg = _('Cannot update the asset manager for this amount because'); - $DbgMsg = _('The SQL that failed to update the asset manger record was'); - $result=DB_query($sql, $db,$ErrMsg,$DbgMsg,true); +while ($myrow=DB_fetch_array($result)) { + if ($AssetCategoryDescription != $myrow['categorydescription'] OR $AssetCategoryDescription =='0'){ + if ($AssetCategoryDescription !='0'){ //then print totals + echo '<tr><th colspan=2 align="right">' . _('Total for') . ' ' . $AssetCategoryDescription . ' </th> + <th class="number">' . number_format($TotalCategoryCost,2) . '</th> + <th class="number">' . number_format($TotalCategoryAccumDepn,2) . '</th> + <th class="number">' . number_format(($TotalCategoryCost-$TotalCategoryAccumDepn),2) . '</th> + <th colspan=2></th> + <th class="number">' . number_format($TotalCategoryDepn,2) . '</th> + </tr>'; } - $BSorPL++; + echo '<tr><th colspan=8 align="left">' . $myrow['categorydescription'] . '</th></tr>'; + $AssetCategoryDescription = $myrow['categorydescription']; + $TotalCategoryCost = 0; + $TotalCategoryAccumDepn =0; + $TotalCategoryDepn = 0; } - - foreach ($_SESSION['JournalDetail']->GLEntries as $JournalItem) { + $BookValueBfwd = $myrow['cost'] - $myrow['accumdepn']; + if ($myrow['depntype']==0){ //striaght line depreciation + $DepreciationType = _('SL'); + $NewDepreciation = $myrow['cost'] * $myrow['depnrate']/100/12; + if ($NewDepreciation > $BookValueBfwd){ + $NewDepreciation = $BookValueBfwd; + } + } else { //Diminishing value depreciation + $DepreciationType = _('DV'); + $NewDepreciation = $BookValueBfwd * $myrow['depnrate']/100/12; + } + $RowCounter++; + if ($RowCounter ==15){ + echo $Heading; + $RowCounter =0; + } + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k++; + } + echo '<td>' . $myrow['assetid'] . '</td> + <td>' . $myrow['description'] . '</td> + <td class="number">' . number_format($myrow['cost'],2) . '</td> + <td class="number">' . number_format($myrow['accumdepn'],2) . '</td> + <td class="number">' . number_format($myrow['cost']-$myrow['accumdepn'],2) . '</td> + <td align="center">' . $DepreciationType . '</td> + <td class="number">' . $myrow['depnrate'] . '</td> + <td class="number">' . $NewDepreciation . '</td> + </tr>'; + $TotalCategoryCost +=$myrow['cost']; + $TotalCategoryAccumDepn +=$myrow['accumdepn']; + $TotalCategoryDepn +=$NewDepreciation; + $TotalCost +=$myrow['cost']; + $TotalAccumDepn +=$myrow['accumdepn']; + $TotalDepn +=$NewDepreciation; + + if (isset($_POST['CommitDepreciation']) AND $NewDepreciation !=0){ + //debit depreciation expense $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount, - tag) "; - $SQL= $SQL . "VALUES (0, - '" . $TransNo . "', - '" . FormatDateForSQL($_SESSION['JournalDetail']->JnlDate) . "', - '" . $PeriodNo . "', - '" . $JournalItem->GLCode . "', - '" . $JournalItem->Narrative . "', - '" . $JournalItem->Amount ."', - '" . $JournalItem->tag."' - )"; - $ErrMsg = _('Cannot insert a GL entry for the journal line because'); + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (44, + '" . $TransNo . "', + '" . FormatDateForSQL($_POST['ProcessDate']) . "', + '" . $PeriodNo . "', + '" . $myrow['depnact'] . "', + '" . $myrow['assetid'] . "', + '" . $NewDepreciation ."')"; + $ErrMsg = _('Cannot insert a depreciation GL entry for the depreciation because'); $DbgMsg = _('The SQL that failed to insert the GL Trans record was'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - } + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (44, + '" . $TransNo . "', + '" . FormatDateForSQL($_POST['ProcessDate']) . "', + '" . $PeriodNo . "', + '" . $myrow['accumdepnact'] . "', + '" . $myrow['assetid'] . "', + '" . -$NewDepreciation ."')"; + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + //insert the fixedassettrans record + $SQL = "INSERT INTO fixedassettrans (assetid, + transtype, + transno, + transdate, + periodno, + inputdate, + cost, + depn) + VALUES ('" . $myrow['assetid'] . "', + '44', + '" . $TransNo . "', + '" . FormatDateForSQL($_POST['ProcessDate']) . "', + '" . $PeriodNo . "', + '" . Date('Y-m-d') . "', + '0', + '" . $NewDepreciation . "')"; + $ErrMsg = _('Cannot insert a fixed asset transaction entry for the depreciation because'); + $DbgMsg = _('The SQL that failed to insert the fixed asset transaction record was'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + } //end if Committing the depreciation to DB +} //end loop around the assets to calculate depreciation for +echo '<tr><th colspan=2 align="right">' . _('Total for') . ' ' . $AssetCategoryDescription . ' </th> + <th class="number">' . number_format($TotalCategoryCost,2) . '</th> + <th class="number">' . number_format($TotalCategoryAccumDepn,2) . '</th> + <th class="number">' . number_format(($TotalCategoryCost-$TotalCategoryAccumDepn),2) . '</th> + <th colspan=2></th> + <th class="number">' . number_format($TotalCategoryDepn,2) . '</th> + </tr>'; +echo '<tr><th colspan=2 align="right">' . _('GRAND Total') . ' </th> + <th class="number">' . number_format($TotalCost,2) . '</th> + <th class="number">' . number_format($TotalAccumDepn,2) . '</th> + <th class="number">' . number_format(($TotalCost-$TotalAccumDepn),2) . '</th> + <th colspan=2></th> + <th class="number">' . number_format($TotalDepn,2) . '</th> + </tr>'; +echo '</table><hr><p></p>'; - $ErrMsg = _('Cannot commit the changes'); - $result= DB_Txn_Begin($db); - - prnMsg(_('Journal').' ' . $TransNo . ' '._('has been successfully entered'),'success'); - - unset($_POST['JournalProcessDate']); - unset($_POST['JournalType']); - unset($_SESSION['JournalDetail']->GLEntries); - unset($_SESSION['JournalDetail']); - - /*Set up a newy in case user wishes to enter another */ - echo "<br><a href='index.php" . '?' . SID . "'>"._('Return to main menu').'</a>'; +if (isset($_POST['CommitDepreciation'])){ + $result = DB_Txn_Commit($db); + prnMsg(_('Depreciation') . ' ' . $TransNo . ' ' . _('has been successfully entered'),'success'); + unset($_POST['ProcessDate']); + echo '<br><a href="index.php' . '?' . SID . '">' ._('Return to main menu').'</a>'; /*And post the journal too */ include ('includes/GLPostings.inc'); - include ('includes/footer.inc'); - exit; - -} elseif (isset($_GET['Delete'])){ - - /* User hit delete the line from the journal */ - $_SESSION['JournalDetail']->Remove_GLEntry($_GET['Delete']); - -} elseif (isset($_POST['Process']) and $_POST['Process']==_('Accept')){ //user hit submit a new GL Analysis line into the journal - if($_POST['GLCode']!='') - { - $extract = explode(' - ',$_POST['GLCode']); - $_POST['GLCode'] = $extract[0]; +} else { + echo '<form action=' . $_SERVER['PHP_SELF'] . '?' . SID . ' method=post name="form">'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + echo '<p></p>'; + echo '<table class=selection width=30%><tr></tr><tr>'; + if (AllowUserEnteredProcessDate){ + echo '<td>'._('Date to Process Depreciation'). ':</td> + <td><input type="text" class="date" alt="' .$_SESSION['DefaultDateFormat']. '" name="ProcessDate" maxlength=10 size=11 value="' . $_POST['ProcessDate'] . '"></td>'; } - if($_POST['Debit']>0) - { - $_POST['GLAmount'] = $_POST['Debit']; - } - elseif($_POST['Credit']>0) - { - $_POST['GLAmount'] = '-' . $_POST['Credit']; - } - if ($_POST['GLManualCode'] != '' AND is_numeric($_POST['GLManualCode'])){ - // If a manual code was entered need to check it exists and isnt a bank account - $AllowThisPosting = true; //by default - if ($_SESSION['ProhibitJournalsToControlAccounts'] == 1){ - if ($_SESSION['CompanyRecord']['gllink_debtors'] == '1' AND $_POST['GLManualCode'] == $_SESSION['CompanyRecord']['debtorsact']){ - prnMsg(_('GL Journals involving the debtors control account cannot be entered. The general ledger debtors ledger (AR) integration is enabled so control accounts are automatically maintained by webERP. This setting can be disabled in System Configuration'),'warn'); - $AllowThisPosting = false; - } - if ($_SESSION['CompanyRecord']['gllink_creditors'] == '1' AND $_POST['GLManualCode'] == $_SESSION['CompanyRecord']['creditorsact']){ - prnMsg(_('GL Journals involving the creditors control account cannot be entered. The general ledger creditors ledger (AP) integration is enabled so control accounts are automatically maintained by webERP. This setting can be disabled in System Configuration'),'warn'); - $AllowThisPosting = false; - } - } - if (in_array($_POST['GLManualCode'], $_SESSION['JournalDetail']->BankAccounts)) { - prnMsg(_('GL Journals involving a bank account cannot be entered') . '. ' . _('Bank account general ledger entries must be entered by either a bank account receipt or a bank account payment'),'info'); - $AllowThisPosting = false; - } - - if ($AllowThisPosting) { - $SQL = 'SELECT accountname - FROM chartmaster - WHERE accountcode=' . $_POST['GLManualCode']; - $Result=DB_query($SQL,$db); - - if (DB_num_rows($Result)==0){ - prnMsg(_('The manual GL code entered does not exist in the database') . ' - ' . _('so this GL analysis item could not be added'),'warn'); - unset($_POST['GLManualCode']); - } else { - $myrow = DB_fetch_array($Result); - $_SESSION['JournalDetail']->add_to_glanalysis($_POST['GLAmount'], $_POST['GLNarrative'], $_POST['GLManualCode'], $myrow['accountname'], $_POST['tag']); - } - } - } else { - $AllowThisPosting =true; //by default - if ($_SESSION['ProhibitJournalsToControlAccounts'] == 1){ - if ($_SESSION['CompanyRecord']['gllink_debtors'] == '1' AND $_POST['GLCode'] == $_SESSION['CompanyRecord']['debtorsact']){ - prnMsg(_('GL Journals involving the debtors control account cannot be entered. The general ledger debtors ledger (AR) integration is enabled so control accounts are automatically maintained by webERP. This setting can be disabled in System Configuration'),'warn'); - $AllowThisPosting = false; - } - if ($_SESSION['CompanyRecord']['gllink_creditors'] == '1' AND $_POST['GLCode'] == $_SESSION['CompanyRecord']['creditorsact']){ - prnMsg(_('GL Journals involving the creditors control account cannot be entered. The general ledger creditors ledger (AP) integration is enabled so control accounts are automatically maintained by webERP. This setting can be disabled in System Configuration'),'warn'); - $AllowThisPosting = false; - } - } - - if (in_array($_POST['GLCode'], $_SESSION['JournalDetail']->BankAccounts)) { - prnMsg(_('GL Journals involving a bank account cannot be entered') . '. ' . _('Bank account general ledger entries must be entered by either a bank account receipt or a bank account payment'),'warn'); - $AllowThisPosting = false; - } - - if ($AllowThisPosting){ - if (!isset($_POST['GLAmount'])) { - $_POST['GLAmount']=0; - } - $SQL = 'SELECT accountname FROM chartmaster WHERE accountcode=' . $_POST['GLCode']; - $Result=DB_query($SQL,$db); - $myrow=DB_fetch_array($Result); - $_SESSION['JournalDetail']->add_to_glanalysis($_POST['GLAmount'], $_POST['GLNarrative'], $_POST['GLCode'], $myrow['accountname'], $_POST['tag']); - } - } - - /*Make sure the same receipt is not double processed by a page refresh */ - $Cancel = 1; - unset($_POST['Credit']); - unset($_POST['Debit']); - unset($_POST['tag']); - unset($_POST['GLManualCode']); - unset($_POST['GLNarrative']); + echo '<td><input type="submit" name="CommitDepreciation" value="'._('Commit Depreciation').'">'; + echo '</tr></table><br>'; + echo '</form>'; } - -if (isset($Cancel)){ - unset($_POST['Credit']); - unset($_POST['Debit']); - unset($_POST['GLAmount']); - unset($_POST['GLCode']); - unset($_POST['tag']); - unset($_POST['GLManualCode']); -} - -// set up the form whatever -/* -if (!isset($_SESSION['JournalDetail']->JnlDate)){ - $_POST['JournalProcessDate']= Date($_SESSION['DefaultDateFormat']); - $_SESSION['JournalDetail']->JnlDate = $_POST['JournalProcessDate']; -} -*/ - -echo '<form action=' . $_SERVER['PHP_SELF'] . '?' . SID . ' method=post name="form">'; -echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - -echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'</p>'; - -// A new table in the first column of the main table - -echo '<table class=selection width=30%><tr><td>'._('Date to Process Journal').":</td> - <td><input type='text' class='date' alt='".$_SESSION['DefaultDateFormat']. - "' name='JournalProcessDate' maxlength=10 size=11 value='" . - $_SESSION['JournalDetail']->JnlDate . "'></td>"; -echo '<td><input type="submit" name="update" value="'._('Update Journal').'">'; -echo '<input type=hidden name=JournalType value=Normal>'; -echo '</tr> - </table><br>'; -/* close off the table in the first column */ - - -echo "<table class=selection width=85%> - <tr> - <th>"._('GL Tag')."</th> - <th>"._('GL Account')."</th> - <th>"._('Debit')."</th> - <th>"._('Credit')."</th> - <th>"._('Narrative').'</th></tr>'; - -$debittotal=0; -$credittotal=0; -$j=0; - -foreach ($_SESSION['JournalDetail']->GLEntries as $JournalItem) { - if ($j==1) { - echo '<tr class="OddTableRows">'; - $j=0; - } else { - echo '<tr class="EvenTableRows">'; - $j++; - } - $sql='SELECT tagdescription - FROM tags - WHERE tagref='.$JournalItem->tag; - $result=DB_query($sql, $db); - $myrow=DB_fetch_row($result); - if ($JournalItem->tag==0) { - $tagdescription='None'; - } else { - $tagdescription=$myrow[0]; - } - echo "<td>" . $JournalItem->tag . ' - ' . $tagdescription . "</td>"; - echo "<td>" . $JournalItem->GLCode . ' - ' . $JournalItem->GLActName . "</td>"; - if($JournalItem->Amount>0) { - echo "<td class='number'>" . number_format($JournalItem->Amount,2) . '</td><td></td>'; - $debittotal=$debittotal+$JournalItem->Amount; - } elseif($JournalItem->Amount<0) { - $credit=(-1 * $JournalItem->Amount); - echo "<td></td><td class='number'>" . number_format($credit,2) . '</td>'; - $credittotal=$credittotal+$credit; - } - - echo '<td>' . $JournalItem->Narrative . "</td> - <td><a href='" . $_SERVER['PHP_SELF'] . '?' . SID . '&Delete=' . $JournalItem->ID . "'>"._('Delete').'</a></td></tr>'; -} - -echo '<tr class="EvenTableRows"><td></td> - <td align=right><b> Total </b></td> - <td align=right class="number"><b>' . number_format($debittotal,2) . '</b></td> - <td align=right class="number"><b>' . number_format($credittotal,2) . '</b></td>'; -if ($debittotal!=$credittotal) { - echo '<td align=center style="background-color: #fddbdb"><b>Required to balance - ' . - number_format(abs($debittotal-$credittotal),2); -} -if ($debittotal>$credittotal) { - echo ' Credit'; -} else if ($debittotal<$credittotal) { - echo ' Debit'; -} - -echo '</b></td></tr></table>'; - -if (ABS($_SESSION['JournalDetail']->JournalTotal)<0.001 AND $_SESSION['JournalDetail']->GLItemCounter > 0){ - echo "<br><br><div class='centre'><input type=submit name='CommitBatch' value='"._('Accept and Process Journal')."'></div>"; -} elseif(count($_SESSION['JournalDetail']->GLEntries)>0) { - echo '<br><br>'; - prnMsg(_('The journal must balance ie debits equal to credits before it can be processed'),'warn'); -} - -if (!isset($_GET['NewJournal']) or $_GET['NewJournal']=='') { - echo "<script>defaultControl(document.form.GLManualCode);</script>"; -} else { - echo "<script>defaultControl(document.form.JournalProcessDate);</script>"; -} - -echo '</form>'; include('includes/footer.inc'); ?> \ No newline at end of file Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2010-11-20 08:13:47 UTC (rev 4160) +++ trunk/GoodsReceived.php 2010-11-21 00:25:51 UTC (rev 4161) @@ -23,7 +23,7 @@ /* This page can only be called with a purchase order number for invoicing*/ echo '<div class="centre"><a href= "' . $rootpath . '/PO_SelectOSPurchOrder.php?' . SID . '">'. _('Select a purchase order to receive').'</a></div>'; - echo '<br>'. _('This page can only be opened if a purchase order has been selected') . '. ' . _('Please select a purchase order first'); + echo '<br>'. _('This page can only be opened if a purchase order has been selected. Please select a purchase order first'); include ('includes/footer.inc'); exit; } elseif (isset($_GET['PONumber']) AND !isset($_POST['Update'])) { @@ -45,10 +45,10 @@ } } -$statussql="SELECT status FROM purchorders WHERE orderno='".$_SESSION['PO']->OrderNo . "'"; -$statusresult=DB_query($statussql, $db); -$mystatusrow=DB_fetch_array($statusresult); -$Status=$mystatusrow['status']; +$StatusSQL="SELECT status FROM purchorders WHERE orderno='".$_SESSION['PO']->OrderNo . "'"; +$StatusResult=DB_query($StatusSQL, $db); +$StatusRow=DB_fetch_array($StatusResult); +$Status=$StatusRow['status']; if ($Status != PurchOrder::STATUS_PRINTED) { prnMsg( _('Purchase orders must have a status of Printed before they can be received').'.<br>'. @@ -79,11 +79,11 @@ echo '<table cellpadding=2 class=selection> <tr><th>' . _('Item Code') . '</th> - <th>' . _('Description') . '</th> - <th>' . _('Quantity') . '<br>' . _('Ordered') . '</th> - <th>' . _('Units') . '</th> - <th>' . _('Already Received') . '</th> - <th>' . _('This Delivery') . '<br>' . _('Quantity') . '</th>'; + <th>' . _('Description') . '</th> + <th>' . _('Quantity') . '<br>' . _('Ordered') . '</th> + <th>' . _('Units') . '</th> + <th>' . _('Already Received') . '</th> + <th>' . _('This Delivery') . '<br>' . _('Quantity') . '</th>'; if ($_SESSION['ShowValueOnGRN']==1) { echo '<th>' . _('Price') . '</th><th>' . _('Total Value') . '<br>' . _('Received') . '</th>'; @@ -126,29 +126,29 @@ $DisplayLineTotal = number_format($LineTotal,2); $DisplayPrice = number_format($LnItm->Price,2); - $uomsql="SELECT unitsofmeasure.unitname, - conversionfactor, - suppliersuom, - max(effectivefrom) - FROM purchdata - LEFT JOIN unitsofmeasure - ON purchdata.suppliersuom=unitsofmeasure.unitid - WHERE supplierno='".$_SESSION['PO']->SupplierID."' - AND stockid='".$LnItm->StockID."' - GROUP BY unitsofmeasure.unitname"; - - $uomresult=DB_query($uomsql, $db); - if (DB_num_rows($uomresult)>0) { - $uomrow=DB_fetch_array($uomresult); - if (strlen($uomrow['unitname'])>0) { - $uom=$uomrow['unitname']; + $UomSQL="SELECT unitsofmeasure.unitname, + conversionfactor, + suppliersuom, + max(effectivefrom) + FROM purchdata + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid + WHERE supplierno='".$_SESSION['PO']->SupplierID."' + AND stockid='".$LnItm->StockID."' + GROUP BY unitsofmeasure.unitname"; + + $UomResult=DB_query($UomSQL, $db); + if (DB_num_rows($UomResult)>0) { + $UomRow=DB_fetch_array($UomResult); + if (strlen($UomRow['unitname'])>0) { + $Uom=$UomRow['unitname']; } else { - $uom=$LnItm->Units; + $Uom=$LnItm->Units; } - $conversionfactor=$uomrow['conversionfactor']; + $ConversionFactor=$UomRow['conversionfactor']; } else { - $uom=$LnItm->Units; - $conversionfactor=1; + $Uom=$LnItm->Units; + $ConversionFactor=1; } //Now Display LineItem @@ -188,14 +188,13 @@ $DisplayTotal = number_format($_SESSION['PO']->total,2); if ($_SESSION['ShowValueOnGRN']==1) { echo '<tr><td colspan=7 class=number><b>' . _('Total value of goods received'). '</b></td> - <td class=number><b>'. $DisplayTotal. '</b></td> - </tr></table>'; + <td class=number><b>'. $DisplayTotal. '</b></td> + </tr></table>'; } else { echo '</table>'; } }//If count(LineItems) > 0 - $SomethingReceived = 0; if (count($_SESSION['PO']->LineItems)>0){ foreach ($_SESSION['PO']->LineItems as $OrderLine) { @@ -225,19 +224,18 @@ if ($OrderLine->ReceiveQty < 0 AND $_SESSION['ProhibitNegativeStock']==1){ $SQL = "SELECT locstock.quantity FROM - locstock WHERE locstock.stockid='" . $OrderLine->StockID . "' - AND loccode= '" . $_SESSION['PO']->Location . "'"; + locstock WHERE locstock.stockid='" . $OrderLine->StockID . "' + AND loccode= '" . $_SESSION['PO']->Location . "'"; $CheckNegResult = DB_query($SQL,$db); $CheckNegRow = DB_fetch_row($CheckNegResult); if ($CheckNegRow[0]+$OrderLine->ReceiveQty<0){ $NegativesFound=true; prnMsg(_('Receiving a negative quantity that results in negative stock is prohibited by the parameter settings. This delivery of stock cannot be processed until the stock of the item is corrected.'),'error',$OrderLine->StockID . ' Cannot Go Negative'); } - } + } /*end if ReceiveQty negative and not allowed negative stock */ + } /* end loop around the items received */ +} /* end if there are lines received */ - } -} - if ($SomethingReceived==0 AND isset($_POST['ProcessGoodsReceived'])){ /*Then dont bother proceeding cos nothing to do ! */ prnMsg(_('There is nothing to process') . '. ' . _('Please enter valid quantities greater than zero'),'warn'); @@ -272,16 +270,16 @@ /*Now need to check that the order details are the same as they were when they were read into the Items array. If they've changed then someone else must have altered them */ // Otherwise if you try to fullfill item quantities separately will give error. $SQL = "SELECT itemcode, - glcode, - quantityord, - quantityrecd, - qtyinvoiced, - shiptref, - jobref - FROM purchorderdetails - WHERE orderno='" . (int) $_SESSION['PO']->OrderNo . "' - AND completed=0 - ORDER BY podetailitem"; + glcode, + quantityord, + quantityrecd, + qtyinvoiced, + shiptref, + jobref + FROM purchorderdetails + WHERE orderno='" . (int) $_SESSION['PO']->OrderNo . "' + AND completed=0 + ORDER BY podetailitem"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Could not check that the details of the purchase order had not been changed by another user because'). ':'; $DbgMsg = _('The following SQL to retrieve the purchase order details was used'); @@ -422,22 +420,22 @@ /*Need to insert a GRN item */ $SQL = "INSERT INTO grns (grnbatch, - podetailitem, - itemcode, - itemdescription, - deliverydate, - qtyrecd, - supplierid, - stdcostunit) - VALUES ('" . $GRN . "', - '" . $OrderLine->PODetailRec . "', - '" . $OrderLine->StockID . "', - '" . $OrderLine->ItemDescription . "', - '" . $_POST['DefaultReceivedDate'] . "', - '" . $OrderLine->ReceiveQty . "', - '" . $_SESSION['PO']->SupplierID . "', - '" . $CurrentStandardCost *$OrderLine->ConversionFactor. "')"; - + podetailitem, + itemcode, + itemdescription, + deliverydate, + qtyrecd, + supplierid, + stdcostunit) + VALUES ('" . $GRN . "', + '" . $OrderLine->PODetailRec . "', + '" . $OrderLine->StockID . "', + '" . $OrderLine->ItemDescription . "', + '" . $_POST['DefaultReceivedDate'] . "', + '" . $OrderLine->ReceiveQty . "', + '" . $_SESSION['PO']->SupplierID . "', + '" . $CurrentStandardCost *$OrderLine->ConversionFactor. "')"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('A GRN record could not be inserted') . '. ' . _('This receipt of goods has not been processed because'); $DbgMsg = _('The following SQL to insert the GRN record was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); @@ -448,10 +446,10 @@ /* Need to get the current location quantity will need it later for the stock movement */ $SQL="SELECT locstock.quantity - FROM locstock - WHERE locstock.stockid='" . $OrderLine->StockID . "' - AND loccode= '" . $_SESSION['PO']->Location . "'"; - + FROM locstock + WHERE locstock.stockid='" . $OrderLine->StockID . "' + AND loccode= '" . $_SESSION['PO']->Location . "'"; + $Result = DB_query($SQL, $db); if (DB_num_rows($Result)==1){ $LocQtyRow = DB_fetch_row($Result); @@ -462,23 +460,23 @@ } $sql="SELECT conversionfactor - FROM purchdata - WHERE supplierno='".$_SESSION['PO']->SupplierID."' - AND stockid='".$OrderLine->StockID."'"; + FROM purchdata + WHERE supplierno='".$_SESSION['PO']->SupplierID."' + AND stockid='".$OrderLine->StockID."'"; $result=DB_query($sql, $db); if (DB_num_rows($result)>0) { $myrow=DB_fetch_array($result); - $conversionfactor=$myrow['conversionfactor']; + $ConversionFactor=$myrow['conversionfactor']; } else { - $conversionfactor=1; + $ConversionFactor=1; } - $OrderLine->ReceiveQty=$OrderLine->ReceiveQty*$conversionfactor; + $OrderLine->ReceiveQty=$OrderLine->ReceiveQty*$ConversionFactor; $SQL = "UPDATE locstock - SET quantity = locstock.quantity + '" . $OrderLine->ReceiveQty . "' - WHERE locstock.stockid = '" . $OrderLine->StockID . "' - AND loccode = '" . $_SESSION['PO']->Location . "'"; - + SET quantity = locstock.quantity + '" . $OrderLine->ReceiveQty . "' + WHERE locstock.stockid = '" . $OrderLine->StockID . "' + AND loccode = '" . $_SESSION['PO']->Location . "'"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The location stock record could not be updated because'); $DbgMsg = _('The following SQL to update the location stock record was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); @@ -487,30 +485,30 @@ /* If its a stock item still .... Insert stock movements - with unit cost */ $SQL = "INSERT INTO stockmoves (stockid, - type, - transno, - loccode, - trandate, - price, - prd, - reference, - qty, - standardcost, - newqoh) - VALUES ( - '" . $OrderLine->StockID . "', - 25, - '" . $GRN . "', - '" . $_SESSION['PO']->Location . "', - '" . $_POST['DefaultReceivedDate'] . "', - '" . $LocalCurrencyPrice / $conversionfactor . "', - '" . $PeriodNo . "', - '" . $_SESSION['PO']->SupplierID . " (" . $_SESSION['PO']->SupplierName . ") - " .$_SESSION['PO']->OrderNo . "', - '" . $OrderLine->ReceiveQty . "', - '" . $_SESSION['PO']->LineItems[$OrderLine->LineNo]->StandardCost . "', - '" . ($QtyOnHandPrior + $OrderLine->ReceiveQty) . "' - )"; - + type, + transno, + loccode, + trandate, + price, + prd, + reference, + qty, + standardcost, + newqoh) + VALUES ( + '" . $OrderLine->StockID . "', + 25, + '" . $GRN . "', + '" . $_SESSION['PO']->Location . "', + '" . $_POST['DefaultReceivedDate'] . "', + '" . $LocalCurrencyPrice / $ConversionFactor . "', + '" . $PeriodNo . "', + '" . $_SESSION['PO']->SupplierID . " (" . $_SESSION['PO']->SupplierName . ") - " .$_SESSION['PO']->OrderNo . "', + '" . $OrderLine->ReceiveQty . "', + '" . $_SESSION['PO']->LineItems[$OrderLine->LineNo]->StandardCost . "', + '" . ($QtyOnHandPrior + $OrderLine->ReceiveQty) . "' + )"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('stock movement records could not be inserted because'); $DbgMsg = _('The following SQL to insert the stock movement records was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); @@ -526,9 +524,9 @@ The StockSerialMoves as well */ //need to test if the controlled item exists first already $SQL = "SELECT COUNT(*) FROM stockserialitems - WHERE stockid='" . $OrderLine->StockID . "' - AND loccode = '" . $_SESSION['PO']->Location . "' - AND serialno = '" . $Item->BundleRef . "'"; + WHERE stockid='" . $OrderLine->StockID . "' + AND loccode = '" . $_SESSION['PO']->Location . "' + AND serialno = '" . $Item->BundleRef . "'"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Could not check if a batch or lot stock item already exists because'); $DbgMsg = _('The following SQL to test for an already existing controlled but not serialised stock item was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); @@ -545,47 +543,23 @@ AND serialno = '" . $Item->BundleRef . "'"; } else { $SQL = "INSERT INTO stockserialitems (stockid, - loccode, - serialno, - qualitytext, - quantity) - VALUES ('" . $OrderLine->StockID . "', - '" . $_SESSION['PO']->Location . "', - '" . $Item->BundleRef . "', - '', - '" . $Item->BundleQty . "')"; + loccode, + serialno, + qualitytext, + quantity) + VALUES ('" . $OrderLine->StockID . "', + '" . $_SESSION['PO']->Location . "', + '" . $Item->BundleRef . "', + '', + '" . $Item->BundleQty . "')"; } $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock item record could not be inserted because'); $DbgMsg = _('The following SQL to insert the serial stock item records was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); - /*Update fixed asset details */ - $sql="SELECT stocktype - FROM stockcategory - LEFT JOIN stockmaster - ON stockcategory.categoryid=stockmaster.categoryid - WHERE stockmaster.stockid='".$OrderLine->StockID."'"; - $result=DB_query($sql, $db); - $myrow=DB_fetch_array($result); - if ($myrow['stocktype']=='A') { - $SQL = "INSERT INTO assetmanager - VALUES ( - NULL, - '" . $OrderLine->StockID . "', - '" . $Item->BundleRef . "', - '', - '".$Item->BundleQty*$OrderLine->Price."', - 0, - '". $_POST['DefaultReceivedDate']."', - 0)"; - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock item record could not be inserted because'); - $DbgMsg = _('The following SQL to insert the serial stock item records was used'); - $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); - } + /* end of handle stockserialitems records */ - /** end of handle stockserialitems records */ - /** now insert the serial stock movement **/ $SQL = "INSERT INTO stockserialmoves (stockmoveno, stockid, @@ -611,23 +585,23 @@ /*first the debit using the GLCode in the PO detail record entry*/ $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES ( - 25, - '" . $GRN . "', - '" . $_POST['DefaultReceivedDate'] . "', - '" . $PeriodNo . "', - '" . $OrderLine->GLCode . "', - 'PO: " . $_SESSION['PO']->OrderNo . " " . $_SESSION['PO']->SupplierID . " - " . $OrderLine->StockID - . " - " . $OrderLine->ItemDescription . " x " . $OrderLine->ReceiveQty . " @ " . - number_format($CurrentStandardCost,2) . "', - '" . $CurrentStandardCost * $OrderLine->ReceiveQty . "' - )"; + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ( + 25, + '" . $GRN . "', + '" . $_POST['DefaultReceivedDate'] . "', + '" . $PeriodNo . "', + '" . $OrderLine->GLCode . "', + 'PO: " . $_SESSION['PO']->OrderNo . " " . $_SESSION['PO']->SupplierID . " - " . $OrderLine->StockID + . " - " . $OrderLine->ItemDescription . " x " . $OrderLine->ReceiveQty . " @ " . + number_format($CurrentStandardCost,2) . "', + '" . $CurrentStandardCost * $OrderLine->ReceiveQty . "' + )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The purchase GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the purchase GLTrans record was used'); @@ -635,25 +609,24 @@ /* If the CurrentStandardCost != UnitCost (the standard at the time the first delivery was booked in, and its a stock item, then the difference needs to be booked in against the purchase price variance account */ - /*now the GRN suspense entry*/ $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (25, - '" . $GRN . "', - '" . $_POST['DefaultReceivedDate'] . "', - '" . $PeriodNo . "', - '" . $_SESSION['CompanyRecord']['grnact'] . "', - '" . _('PO') . ': ' . $_SESSION['PO']->OrderNo . ' ' . $_SESSION['PO']->SupplierID . ' - ' . - $OrderLine->StockID . ' - ' . $OrderLine->ItemDescription . ' x ' . - $OrderLine->ReceiveQty . ' @ ' . number_format($UnitCost,2) . "', - '" . -$UnitCost * $OrderLine->ReceiveQty . "' - )"; + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (25, + '" . $GRN . "', + '" . $_POST['DefaultReceivedDate'] . "', + '" . $PeriodNo . "', + '" . $_SESSION['CompanyRecord']['grnact'] . "', + '" . _('PO') . ': ' . $_SESSION['PO']->OrderNo . ' ' . $_SESSION['PO']->SupplierID . ' - ' . + $OrderLine->StockID . ' - ' . $OrderLine->ItemDescription . ' x ' . + $OrderLine->ReceiveQty . ' @ ' . number_format($UnitCost,2) . "', + '" . -$UnitCost * $OrderLine->ReceiveQty . "' + )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GRN suspense side of the GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GRN Suspense GLTrans record was used'); @@ -662,27 +635,27 @@ } /* end of if GL and stock integrated and standard cost !=0 */ } /*Quantity received is != 0 */ } /*end of OrderLine loop */ - $completedsql="SELECT SUM(completed) as completedlines, - COUNT(podetailitem) as alllines - FROM purchorderdetails - WHERE orderno='".$_SESSION['PO']->OrderNo . "'"; - $completedresult=DB_query($completedsql,$db); - $mycompletedrow=DB_fetch_array($completedresult); - $status=$mycompletedrow['alllines']-$mycompletedrow['completedlines']; + $CompletedSQL="SELECT SUM(completed) as completedlines, + COUNT(podetailitem) as alllines + FROM purchorderdetails + WHERE orderno='".$_SESSION['PO']->OrderNo . "'"; + $CompletedResult=DB_query($CompletedSQL,$db); + $MyCompletedRow=DB_fetch_array($CompletedResult); + $Status=$MyCompletedRow['alllines']-$MyCompletedRow['completedlines']; - if ($status==0) { + if ($Status==0) { $sql="SELECT stat_comment - FROM purchorders - WHERE orderno='".$_SESSION['PO']->OrderNo . "'"; + FROM purchorders + WHERE orderno='".$_SESSION['PO']->OrderNo . "'"; $result=DB_query($sql,$db); $myrow=DB_fetch_array($result); $comment=$myrow['stat_comment']; $date = date($_SESSION['DefaultDateFormat']); $StatusComment=$date.' - Order Completed'.'<br>'.$comment; $sql="UPDATE purchorders - SET status='" . PurchOrder::STATUS_COMPLITED . "', - stat_comment='".$StatusComment."' - WHERE orderno='".$_SESSION['PO']->OrderNo . "'"; + SET status='" . PurchOrder::STATUS_COMPLITED . "', + stat_comment='".$StatusComment."' + WHERE orderno='".$_SESSION['PO']->OrderNo . "'"; $result=DB_query($sql,$db); } @@ -695,7 +668,7 @@ echo '<br><div class=centre>'. _('GRN number'). ' '. $GRN .' '. _('has been processed').'<br>'; echo '<br><a href=PDFGrn.php?GRNNo='.$GRN .'&PONo='.$PONo.'>'. _('Print this Goods Received Note (GRN)').'</a><br><br>'; - echo "<a href='" . $rootpath . "/PO_SelectOSPurchOrder.php?" . SID . "'>" . + echo '<a href="' . $rootpath . '/PO_SelectOSPurchOrder.php?' . SID . '">' . _('Select a different purchase order for receiving goods against'). '</a></div>'; /*end of process goods received entry */ include('includes/footer.inc'); @@ -703,13 +676,12 @@ } else { /*Process Goods received not set so show a link to allow mod of line items on order and allow input of date goods received*/ - echo "<br><div class='centre'><a href='" . $rootpath . "/PO_Items.php?=" . SID . "'>" . _('Modify Order Items'). '</a></div>'; + echo '<br><div class='centre'><a href="' . $rootpath . '/PO_Items.php?=' . SID . '">' . _('Modify Order Items'). '</a></div>'; echo '<br><div class="centre"><input type=submit name=Update Value=' . _('Update') . '><p>'; echo '<input type=submit name="ProcessGoodsReceived" Value="' . _('Process Goods Received') . '"></div>'; } echo '</form>'; - include('includes/footer.inc'); ?> \ No newline at end of file Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-20 08:13:47 UTC (rev 4160) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-21 00:25:51 UTC (rev 4161) @@ -473,14 +473,17 @@ DELETE FROM stockcategory WHERE stocktype='A'; ALTER TABLE `fixedassets` DROP `stockid`; +INSERT INTO `systypes` (`typeid`, `typename`, `typeno`) VALUES ('41', 'Asset Addition', '1'); INSERT INTO `systypes` (`typeid`, `typename`, `typeno`) VALUES ('42', 'Asset Category Change', '1'); INSERT INTO `systypes` (`typeid`, `typename`, `typeno`) VALUES ('43', 'Delete w/down asset', '1'); +INSERT INTO `systypes` (`typeid`, `typename`, `typeno`) VALUES ('44', 'Depreciation', '1'); CREATE TABLE `fixedassettrans` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `assetid` INT NOT NULL , `transtype` TINYINT NOT NULL , `transno` INT NOT NULL , +`periodno` SMALLINT( 4 ) NOT NULL, `inputdate` DATE NOT, `cost` DOUBLE NOT NULL , `depn` DOUBLE NOT NULL , This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-21 03:28:38
|
Revision: 4162 http://web-erp.svn.sourceforge.net/web-erp/?rev=4162&view=rev Author: daintree Date: 2010-11-21 03:28:30 +0000 (Sun, 21 Nov 2010) Log Message: ----------- Fixed assets Modified Paths: -------------- trunk/PO_Items.php trunk/doc/Change.log.html trunk/index.php Added Paths: ----------- trunk/FixedAssetDepreciation.php Removed Paths: ------------- trunk/FixedAssetJournal.php Added: trunk/FixedAssetDepreciation.php =================================================================== --- trunk/FixedAssetDepreciation.php (rev 0) +++ trunk/FixedAssetDepreciation.php 2010-11-21 03:28:30 UTC (rev 4162) @@ -0,0 +1,230 @@ +<?php + +/* $Revision: 1.1 $ */ + +include('includes/DefineJournalClass.php'); + +$PageSecurity = 10; +include('includes/session.inc'); +$title = _('Depreciation Journal Entry'); + +include('includes/header.inc'); +include('includes/SQL_CommonFunctions.inc'); + + +/*Get the last period depreciation (depn is transtype =44) was posted for */ +$result = DB_query('SELECT periods.lastdate_in_period, max(fixedassettrans.periodno) FROM fixedassettrans INNER JOIN periods ON fixedassettrans.periodno=periods.periodno WHERE transtype=44 GROUP BY periods.lastdate_in_period',$db); + +$LastDepnRun = DB_fetch_row($result); + +//echo '<BR>LastRun period = ' . $LastDepnRun[1] . ' Last date in period = ' . $LastDepnRun[0]; + +$AllowUserEnteredProcessDate = true; + +if ($LastDepnRun[1]==0 AND $LastDepnRun[0]==NULL) { //then depn has never been run yet? + + /*in this case default depreciation calc to the last day of last month - and allow user to select a period */ + if (!isset($_POST['ProcessDate'])) { + $_POST['ProcessDate'] = Date($_SESSION['DefaultDateFormat'],mktime(0,0,0,date('m'),0,date('Y'))); + } + +} else { //depn calc has been run previously + $AllowUserEnteredProcessDate = false; + $_POST['ProcessDate'] = DateAdd(ConvertSQLDate($LastDepnRun[0]),'m',1); +} +$PeriodNo = GetPeriod($_POST['ProcessDate'],$db); + +/* Get list of assets for journal */ +$sql='SELECT fixedassets.assetid, + fixedassets.description, + fixedassets.cost, + fixedassets.accumdepn, + fixedassets.depntype, + fixedassets.depnrate, + fixedassetcategories.accumdepnact AS bsdepn, + fixedassetcategories.depnact AS pldepn, + fixedassetcategories.categorydescription + FROM fixedassets + INNER JOIN fixedassetcategories + ON fixedassets.assetcategoryid=fixedassetcategories.categoryid + ORDER BY assetcategoryid, assetid'; +$result=DB_query($sql, $db); + +if (isset($_POST['CommitDepreciation'])){ + $result = DB_Txn_Begin($db); + $TransNo = GetNextTransNo(44, $db); + +} + +echo '<p></p><table>'; +$Heading = '<tr><th>' . _('Asset ID') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Cost') . '</th> + <th>' . _('Accum Depn') . '</th> + <th>' . _('B/fwd Book Value') . '</th> + <th>'. _('Depn Type') . '</th> + <th>'. _('Depn Rate') . '</th> + <th>' . _('New Depn') . '</th> + </tr>'; +echo $Heading; + +$AssetCategoryDescription ='0'; + +$TotalCost =0; +$TotalAccumDepn=0; +$TotalDepn = 0; +$RowCounter = 0; +$k=0; + +while ($myrow=DB_fetch_array($result)) { + if ($AssetCategoryDescription != $myrow['categorydescription'] OR $AssetCategoryDescription =='0'){ + if ($AssetCategoryDescription !='0'){ //then print totals + echo '<tr><th colspan=2 align="right">' . _('Total for') . ' ' . $AssetCategoryDescription . ' </th> + <th class="number">' . number_format($TotalCategoryCost,2) . '</th> + <th class="number">' . number_format($TotalCategoryAccumDepn,2) . '</th> + <th class="number">' . number_format(($TotalCategoryCost-$TotalCategoryAccumDepn),2) . '</th> + <th colspan=2></th> + <th class="number">' . number_format($TotalCategoryDepn,2) . '</th> + </tr>'; + } + echo '<tr><th colspan=8 align="left">' . $myrow['categorydescription'] . '</th></tr>'; + $AssetCategoryDescription = $myrow['categorydescription']; + $TotalCategoryCost = 0; + $TotalCategoryAccumDepn =0; + $TotalCategoryDepn = 0; + } + $BookValueBfwd = $myrow['cost'] - $myrow['accumdepn']; + if ($myrow['depntype']==0){ //striaght line depreciation + $DepreciationType = _('SL'); + $NewDepreciation = $myrow['cost'] * $myrow['depnrate']/100/12; + if ($NewDepreciation > $BookValueBfwd){ + $NewDepreciation = $BookValueBfwd; + } + } else { //Diminishing value depreciation + $DepreciationType = _('DV'); + $NewDepreciation = $BookValueBfwd * $myrow['depnrate']/100/12; + } + $RowCounter++; + if ($RowCounter ==15){ + echo $Heading; + $RowCounter =0; + } + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k++; + } + echo '<td>' . $myrow['assetid'] . '</td> + <td>' . $myrow['description'] . '</td> + <td class="number">' . number_format($myrow['cost'],2) . '</td> + <td class="number">' . number_format($myrow['accumdepn'],2) . '</td> + <td class="number">' . number_format($myrow['cost']-$myrow['accumdepn'],2) . '</td> + <td align="center">' . $DepreciationType . '</td> + <td class="number">' . $myrow['depnrate'] . '</td> + <td class="number">' . $NewDepreciation . '</td> + </tr>'; + $TotalCategoryCost +=$myrow['cost']; + $TotalCategoryAccumDepn +=$myrow['accumdepn']; + $TotalCategoryDepn +=$NewDepreciation; + $TotalCost +=$myrow['cost']; + $TotalAccumDepn +=$myrow['accumdepn']; + $TotalDepn +=$NewDepreciation; + + if (isset($_POST['CommitDepreciation']) AND $NewDepreciation !=0){ + //debit depreciation expense + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (44, + '" . $TransNo . "', + '" . FormatDateForSQL($_POST['ProcessDate']) . "', + '" . $PeriodNo . "', + '" . $myrow['depnact'] . "', + '" . $myrow['assetid'] . "', + '" . $NewDepreciation ."')"; + $ErrMsg = _('Cannot insert a depreciation GL entry for the depreciation because'); + $DbgMsg = _('The SQL that failed to insert the GL Trans record was'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (44, + '" . $TransNo . "', + '" . FormatDateForSQL($_POST['ProcessDate']) . "', + '" . $PeriodNo . "', + '" . $myrow['accumdepnact'] . "', + '" . $myrow['assetid'] . "', + '" . -$NewDepreciation ."')"; + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + //insert the fixedassettrans record + $SQL = "INSERT INTO fixedassettrans (assetid, + transtype, + transno, + transdate, + periodno, + inputdate, + cost, + depn) + VALUES ('" . $myrow['assetid'] . "', + '44', + '" . $TransNo . "', + '" . FormatDateForSQL($_POST['ProcessDate']) . "', + '" . $PeriodNo . "', + '" . Date('Y-m-d') . "', + '0', + '" . $NewDepreciation . "')"; + $ErrMsg = _('Cannot insert a fixed asset transaction entry for the depreciation because'); + $DbgMsg = _('The SQL that failed to insert the fixed asset transaction record was'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + } //end if Committing the depreciation to DB +} //end loop around the assets to calculate depreciation for +echo '<tr><th colspan=2 align="right">' . _('Total for') . ' ' . $AssetCategoryDescription . ' </th> + <th class="number">' . number_format($TotalCategoryCost,2) . '</th> + <th class="number">' . number_format($TotalCategoryAccumDepn,2) . '</th> + <th class="number">' . number_format(($TotalCategoryCost-$TotalCategoryAccumDepn),2) . '</th> + <th colspan=2></th> + <th class="number">' . number_format($TotalCategoryDepn,2) . '</th> + </tr>'; +echo '<tr><th colspan=2 align="right">' . _('GRAND Total') . ' </th> + <th class="number">' . number_format($TotalCost,2) . '</th> + <th class="number">' . number_format($TotalAccumDepn,2) . '</th> + <th class="number">' . number_format(($TotalCost-$TotalAccumDepn),2) . '</th> + <th colspan=2></th> + <th class="number">' . number_format($TotalDepn,2) . '</th> + </tr>'; + +echo '</table><hr><p></p>'; + +if (isset($_POST['CommitDepreciation'])){ + $result = DB_Txn_Commit($db); + prnMsg(_('Depreciation') . ' ' . $TransNo . ' ' . _('has been successfully entered'),'success'); + unset($_POST['ProcessDate']); + echo '<br><a href="index.php' . '?' . SID . '">' ._('Return to main menu').'</a>'; + /*And post the journal too */ + include ('includes/GLPostings.inc'); +} else { + echo '<form action=' . $_SERVER['PHP_SELF'] . '?' . SID . ' method=post name="form">'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + echo '<p></p>'; + echo '<table class=selection width=30%><tr></tr><tr>'; + if (AllowUserEnteredProcessDate){ + echo '<td>'._('Date to Process Depreciation'). ':</td> + <td><input type="text" class="date" alt="' .$_SESSION['DefaultDateFormat']. '" name="ProcessDate" maxlength=10 size=11 value="' . $_POST['ProcessDate'] . '"></td>'; + } + echo '<td><input type="submit" name="CommitDepreciation" value="'._('Commit Depreciation').'">'; + echo '</tr></table><br>'; + echo '</form>'; +} +include('includes/footer.inc'); +?> \ No newline at end of file Deleted: trunk/FixedAssetJournal.php =================================================================== --- trunk/FixedAssetJournal.php 2010-11-21 00:25:51 UTC (rev 4161) +++ trunk/FixedAssetJournal.php 2010-11-21 03:28:30 UTC (rev 4162) @@ -1,230 +0,0 @@ -<?php - -/* $Revision: 1.1 $ */ - -include('includes/DefineJournalClass.php'); - -$PageSecurity = 10; -include('includes/session.inc'); -$title = _('Depreciation Journal Entry'); - -include('includes/header.inc'); -include('includes/SQL_CommonFunctions.inc'); - - -/*Get the last period depreciation (depn is transtype =44) was posted for */ -$result = DB_query('SELECT periods.lastdate_in_period, max(fixedassettrans.periodno) FROM fixedassettrans INNER JOIN periods ON fixedassettrans.periodno=periods.periodno WHERE transtype=44 GROUP BY periods.lastdate_in_period',$db); - -$LastDepnRun = DB_fetch_row($result); - -//echo '<BR>LastRun period = ' . $LastDepnRun[1] . ' Last date in period = ' . $LastDepnRun[0]; - -$AllowUserEnteredProcessDate = true; - -if ($LastDepnRun[1]==0 AND $LastDepnRun[0]==NULL) { //then depn has never been run yet? - - /*in this case default depreciation calc to the last day of last month - and allow user to select a period */ - if (!isset($_POST['ProcessDate'])) { - $_POST['ProcessDate'] = Date($_SESSION['DefaultDateFormat'],mktime(0,0,0,date('m'),0,date('Y'))); - } - -} else { //depn calc has been run previously - $AllowUserEnteredProcessDate = false; - $_POST['ProcessDate'] = DateAdd(ConvertSQLDate($LastDepnRun[0]),'m',1); -} -$PeriodNo = GetPeriod($_POST['ProcessDate'],$db); - -/* Get list of assets for journal */ -$sql='SELECT fixedassets.assetid, - fixedassets.description, - fixedassets.cost, - fixedassets.accumdepn, - fixedassets.depntype, - fixedassets.depnrate, - fixedassetcategories.accumdepnact AS bsdepn, - fixedassetcategories.depnact AS pldepn, - fixedassetcategories.categorydescription - FROM fixedassets - INNER JOIN fixedassetcategories - ON fixedassets.assetcategoryid=fixedassetcategories.categoryid - ORDER BY assetcategoryid, assetid'; -$result=DB_query($sql, $db); - -if (isset($_POST['CommitDepreciation'])){ - $result = DB_Txn_Begin($db); - $TransNo = GetNextTransNo(44, $db); - -} - -echo '<p></p><table>'; -$Heading = '<tr><th>' . _('Asset ID') . '</th> - <th>' . _('Description') . '</th> - <th>' . _('Cost') . '</th> - <th>' . _('Accum Depn') . '</th> - <th>' . _('B/fwd Book Value') . '</th> - <th>'. _('Depn Type') . '</th> - <th>'. _('Depn Rate') . '</th> - <th>' . _('New Depn') . '</th> - </tr>'; -echo $Heading; - -$AssetCategoryDescription ='0'; - -$TotalCost =0; -$TotalAccumDepn=0; -$TotalDepn = 0; -$RowCounter = 0; -$k=0; - -while ($myrow=DB_fetch_array($result)) { - if ($AssetCategoryDescription != $myrow['categorydescription'] OR $AssetCategoryDescription =='0'){ - if ($AssetCategoryDescription !='0'){ //then print totals - echo '<tr><th colspan=2 align="right">' . _('Total for') . ' ' . $AssetCategoryDescription . ' </th> - <th class="number">' . number_format($TotalCategoryCost,2) . '</th> - <th class="number">' . number_format($TotalCategoryAccumDepn,2) . '</th> - <th class="number">' . number_format(($TotalCategoryCost-$TotalCategoryAccumDepn),2) . '</th> - <th colspan=2></th> - <th class="number">' . number_format($TotalCategoryDepn,2) . '</th> - </tr>'; - } - echo '<tr><th colspan=8 align="left">' . $myrow['categorydescription'] . '</th></tr>'; - $AssetCategoryDescription = $myrow['categorydescription']; - $TotalCategoryCost = 0; - $TotalCategoryAccumDepn =0; - $TotalCategoryDepn = 0; - } - $BookValueBfwd = $myrow['cost'] - $myrow['accumdepn']; - if ($myrow['depntype']==0){ //striaght line depreciation - $DepreciationType = _('SL'); - $NewDepreciation = $myrow['cost'] * $myrow['depnrate']/100/12; - if ($NewDepreciation > $BookValueBfwd){ - $NewDepreciation = $BookValueBfwd; - } - } else { //Diminishing value depreciation - $DepreciationType = _('DV'); - $NewDepreciation = $BookValueBfwd * $myrow['depnrate']/100/12; - } - $RowCounter++; - if ($RowCounter ==15){ - echo $Heading; - $RowCounter =0; - } - if ($k==1){ - echo '<tr class="EvenTableRows">'; - $k=0; - } else { - echo '<tr class="OddTableRows">'; - $k++; - } - echo '<td>' . $myrow['assetid'] . '</td> - <td>' . $myrow['description'] . '</td> - <td class="number">' . number_format($myrow['cost'],2) . '</td> - <td class="number">' . number_format($myrow['accumdepn'],2) . '</td> - <td class="number">' . number_format($myrow['cost']-$myrow['accumdepn'],2) . '</td> - <td align="center">' . $DepreciationType . '</td> - <td class="number">' . $myrow['depnrate'] . '</td> - <td class="number">' . $NewDepreciation . '</td> - </tr>'; - $TotalCategoryCost +=$myrow['cost']; - $TotalCategoryAccumDepn +=$myrow['accumdepn']; - $TotalCategoryDepn +=$NewDepreciation; - $TotalCost +=$myrow['cost']; - $TotalAccumDepn +=$myrow['accumdepn']; - $TotalDepn +=$NewDepreciation; - - if (isset($_POST['CommitDepreciation']) AND $NewDepreciation !=0){ - //debit depreciation expense - $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (44, - '" . $TransNo . "', - '" . FormatDateForSQL($_POST['ProcessDate']) . "', - '" . $PeriodNo . "', - '" . $myrow['depnact'] . "', - '" . $myrow['assetid'] . "', - '" . $NewDepreciation ."')"; - $ErrMsg = _('Cannot insert a depreciation GL entry for the depreciation because'); - $DbgMsg = _('The SQL that failed to insert the GL Trans record was'); - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (44, - '" . $TransNo . "', - '" . FormatDateForSQL($_POST['ProcessDate']) . "', - '" . $PeriodNo . "', - '" . $myrow['accumdepnact'] . "', - '" . $myrow['assetid'] . "', - '" . -$NewDepreciation ."')"; - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - - //insert the fixedassettrans record - $SQL = "INSERT INTO fixedassettrans (assetid, - transtype, - transno, - transdate, - periodno, - inputdate, - cost, - depn) - VALUES ('" . $myrow['assetid'] . "', - '44', - '" . $TransNo . "', - '" . FormatDateForSQL($_POST['ProcessDate']) . "', - '" . $PeriodNo . "', - '" . Date('Y-m-d') . "', - '0', - '" . $NewDepreciation . "')"; - $ErrMsg = _('Cannot insert a fixed asset transaction entry for the depreciation because'); - $DbgMsg = _('The SQL that failed to insert the fixed asset transaction record was'); - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - } //end if Committing the depreciation to DB -} //end loop around the assets to calculate depreciation for -echo '<tr><th colspan=2 align="right">' . _('Total for') . ' ' . $AssetCategoryDescription . ' </th> - <th class="number">' . number_format($TotalCategoryCost,2) . '</th> - <th class="number">' . number_format($TotalCategoryAccumDepn,2) . '</th> - <th class="number">' . number_format(($TotalCategoryCost-$TotalCategoryAccumDepn),2) . '</th> - <th colspan=2></th> - <th class="number">' . number_format($TotalCategoryDepn,2) . '</th> - </tr>'; -echo '<tr><th colspan=2 align="right">' . _('GRAND Total') . ' </th> - <th class="number">' . number_format($TotalCost,2) . '</th> - <th class="number">' . number_format($TotalAccumDepn,2) . '</th> - <th class="number">' . number_format(($TotalCost-$TotalAccumDepn),2) . '</th> - <th colspan=2></th> - <th class="number">' . number_format($TotalDepn,2) . '</th> - </tr>'; - -echo '</table><hr><p></p>'; - -if (isset($_POST['CommitDepreciation'])){ - $result = DB_Txn_Commit($db); - prnMsg(_('Depreciation') . ' ' . $TransNo . ' ' . _('has been successfully entered'),'success'); - unset($_POST['ProcessDate']); - echo '<br><a href="index.php' . '?' . SID . '">' ._('Return to main menu').'</a>'; - /*And post the journal too */ - include ('includes/GLPostings.inc'); -} else { - echo '<form action=' . $_SERVER['PHP_SELF'] . '?' . SID . ' method=post name="form">'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo '<p></p>'; - echo '<table class=selection width=30%><tr></tr><tr>'; - if (AllowUserEnteredProcessDate){ - echo '<td>'._('Date to Process Depreciation'). ':</td> - <td><input type="text" class="date" alt="' .$_SESSION['DefaultDateFormat']. '" name="ProcessDate" maxlength=10 size=11 value="' . $_POST['ProcessDate'] . '"></td>'; - } - echo '<td><input type="submit" name="CommitDepreciation" value="'._('Commit Depreciation').'">'; - echo '</tr></table><br>'; - echo '</form>'; -} -include('includes/footer.inc'); -?> \ No newline at end of file Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2010-11-21 00:25:51 UTC (rev 4161) +++ trunk/PO_Items.php 2010-11-21 03:28:30 UTC (rev 4162) @@ -37,18 +37,17 @@ /* If a stock item is selected and a purchdata record * exists for it then find that record. */ - $sql = "SELECT - stockmaster.description, - purchdata.suppliers_partno, - stockmaster.pkg_type, - stockmaster.units, - stockmaster.netweight, - stockmaster.kgs, - stockmaster.volume - FROM purchdata INNER JOIN stockmaster - ON purchdata.stockid=stockmaster.stockid - WHERE purchdata.stockid='" . $_POST['StockID2'] . "' AND - purchdata.supplierno='".$_SESSION['PO'.$identifier]->SupplierID."'"; + $sql = "SELECT stockmaster.description, + purchdata.suppliers_partno, + stockmaster.pkg_type, + stockmaster.units, + stockmaster.netweight, + stockmaster.kgs, + stockmaster.volume + FROM purchdata INNER JOIN stockmaster + ON purchdata.stockid=stockmaster.stockid + WHERE purchdata.stockid='" . $_POST['StockID2'] . "' AND + purchdata.supplierno='".$_SESSION['PO'.$identifier]->SupplierID."'"; $ErrMsg = _('The stock record of the stock selected') . ': ' . $_POST['Stock'] . ' ' . _('cannot be retrieved because'); @@ -111,70 +110,69 @@ $_SESSION['PO'.$identifier]->OrderNo = GetNextTransNo(18, $db); /*Insert to purchase order header record */ - $sql = "INSERT INTO purchorders ( - orderno, - supplierno, - comments, - orddate, - rate, - initiator, - requisitionno, - intostocklocation, - deladd1, - deladd2, - deladd3, - deladd4, - deladd5, - deladd6, - tel, - suppdeladdress1, - suppdeladdress2, - suppdeladdress3, - suppdeladdress4, - suppdeladdress5, - suppdeladdress6, - suppliercontact, - supptel, - contact, - version, - revised, - deliveryby, - status, - stat_comment, - deliverydate, - paymentterms) - VALUES( '" . $_SESSION['PO'.$identifier]->OrderNo . "', - '" . $_SESSION['PO'.$identifier]->SupplierID . "', - '" . $_SESSION['PO'.$identifier]->Comments . "', - '" . Date('Y-m-d') . "', - '" . $_SESSION['PO'.$identifier]->ExRate . "', - '" . $_SESSION['PO'.$identifier]->Initiator . "', - '" . $_SESSION['PO'.$identifier]->RequisitionNo . "', - '" . $_SESSION['PO'.$identifier]->Location . "', - '" . $_SESSION['PO'.$identifier]->DelAdd1 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd2 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd3 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd4 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd5 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd6 . "', - '" . $_SESSION['PO'.$identifier]->tel . "', - '" . $_SESSION['PO'.$identifier]->suppDelAdd1 . "', - '" . $_SESSION['PO'.$identifier]->suppDelAdd2 . "', - '" . $_SESSION['PO'.$identifier]->suppDelAdd3 . "', - '" . $_SESSION['PO'.$identifier]->suppDelAdd4 . "', - '" . $_SESSION['PO'.$identifier]->suppDelAdd5 . "', - '" . $_SESSION['PO'.$identifier]->suppDelAdd6 . "', - '" . $_SESSION['PO'.$identifier]->SupplierContact . "', - '" . $_SESSION['PO'.$identifier]->supptel. "', - '" . $_SESSION['PO'.$identifier]->contact . "', - '" . $_SESSION['PO'.$identifier]->version . "', - '" . FormatDateForSQL($date) . "', - '" . $_SESSION['PO'.$identifier]->deliveryby . "', - '" . 'Pending' . "', - '" . $StatusComment . "', - '" . FormatDateForSQL($_SESSION['PO'.$identifier]->deliverydate) . "', - '" . $_SESSION['PO'.$identifier]->paymentterms. "' - )"; + $sql = "INSERT INTO purchorders ( orderno, + supplierno, + comments, + orddate, + rate, + initiator, + requisitionno, + intostocklocation, + deladd1, + deladd2, + deladd3, + deladd4, + deladd5, + deladd6, + tel, + suppdeladdress1, + suppdeladdress2, + suppdeladdress3, + suppdeladdress4, + suppdeladdress5, + suppdeladdress6, + suppliercontact, + supptel, + contact, + version, + revised, + deliveryby, + status, + stat_comment, + deliverydate, + paymentterms) + VALUES( '" . $_SESSION['PO'.$identifier]->OrderNo . "', + '" . $_SESSION['PO'.$identifier]->SupplierID . "', + '" . $_SESSION['PO'.$identifier]->Comments . "', + '" . Date('Y-m-d') . "', + '" . $_SESSION['PO'.$identifier]->ExRate . "', + '" . $_SESSION['PO'.$identifier]->Initiator . "', + '" . $_SESSION['PO'.$identifier]->RequisitionNo . "', + '" . $_SESSION['PO'.$identifier]->Location . "', + '" . $_SESSION['PO'.$identifier]->DelAdd1 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd2 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd3 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd4 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd5 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd6 . "', + '" . $_SESSION['PO'.$identifier]->tel . "', + '" . $_SESSION['PO'.$identifier]->suppDelAdd1 . "', + '" . $_SESSION['PO'.$identifier]->suppDelAdd2 . "', + '" . $_SESSION['PO'.$identifier]->suppDelAdd3 . "', + '" . $_SESSION['PO'.$identifier]->suppDelAdd4 . "', + '" . $_SESSION['PO'.$identifier]->suppDelAdd5 . "', + '" . $_SESSION['PO'.$identifier]->suppDelAdd6 . "', + '" . $_SESSION['PO'.$identifier]->SupplierContact . "', + '" . $_SESSION['PO'.$identifier]->supptel. "', + '" . $_SESSION['PO'.$identifier]->contact . "', + '" . $_SESSION['PO'.$identifier]->version . "', + '" . FormatDateForSQL($date) . "', + '" . $_SESSION['PO'.$identifier]->deliveryby . "', + '" . 'Pending' . "', + '" . $StatusComment . "', + '" . FormatDateForSQL($_SESSION['PO'.$identifier]->deliverydate) . "', + '" . $_SESSION['PO'.$identifier]->paymentterms. "' + )"; $ErrMsg = _('The purchase order header record could not be inserted into the database because'); $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); @@ -183,49 +181,48 @@ /*Insert the purchase order detail records */ foreach ($_SESSION['PO'.$identifier]->LineItems as $POLine) { if ($POLine->Deleted==False) { - $sql = "INSERT INTO purchorderdetails ( - orderno, - itemcode, - deliverydate, - itemdescription, - glcode, - unitprice, - quantityord, - shiptref, - jobref, - itemno, - uom, - suppliers_partno, - subtotal_amount, - package, - pcunit, - nw, - gw, - cuft, - total_quantity, - total_amount ) - VALUES ( - '" . $_SESSION['PO'.$identifier]->OrderNo . "', - '" . $POLine->StockID . "', - '" . FormatDateForSQL($POLine->ReqDelDate) . "', - '" . $POLine->ItemDescription . "', - '" . $POLine->GLCode . "', - '" . $POLine->Price . "', - '" . $POLine->Quantity . "', - '" . $POLine->ShiptRef . "', - '" . $POLine->JobRef . "', - '" . $POLine->itemno . "', - '" . $POLine->uom . "', - '" . $POLine->suppliers_partno . "', - '" . $POLine->subtotal_amount . "', - '" . $POLine->package . "', - '" . $POLine->pcunit . "', - '" . $POLine->nw . "', - '" . $POLine->gw . "', - '" . $POLine->cuft . "', - '" . $POLine->total_quantity . "', - '" . $POLine->total_amount . "' - )"; + $sql = "INSERT INTO purchorderdetails ( orderno, + itemcode, + deliverydate, + itemdescription, + glcode, + unitprice, + quantityord, + shiptref, + jobref, + itemno, + uom, + suppliers_partno, + subtotal_amount, + package, + pcunit, + nw, + gw, + cuft, + total_quantity, + total_amount ) + VALUES ( + '" . $_SESSION['PO'.$identifier]->OrderNo . "', + '" . $POLine->StockID . "', + '" . FormatDateForSQL($POLine->ReqDelDate) . "', + '" . $POLine->ItemDescription . "', + '" . $POLine->GLCode . "', + '" . $POLine->Price . "', + '" . $POLine->Quantity . "', + '" . $POLine->ShiptRef . "', + '" . $POLine->JobRef . "', + '" . $POLine->itemno . "', + '" . $POLine->uom . "', + '" . $POLine->suppliers_partno . "', + '" . $POLine->subtotal_amount . "', + '" . $POLine->package . "', + '" . $POLine->pcunit . "', + '" . $POLine->nw . "', + '" . $POLine->gw . "', + '" . $POLine->cuft . "', + '" . $POLine->total_quantity . "', + '" . $POLine->total_amount . "' + )"; $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); @@ -239,37 +236,36 @@ $date = date($_SESSION['DefaultDateFormat']); /*Update the purchase order header with any changes */ - $sql = "UPDATE purchorders SET - supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' , - comments='" . $_SESSION['PO'.$identifier]->Comments . "', - rate='" . $_SESSION['PO'.$identifier]->ExRate . "', - initiator='" . $_SESSION['PO'.$identifier]->Initiator . "', - requisitionno= '" . $_SESSION['PO'.$identifier]->RequisitionNo . "', - version= '" . $_SESSION['PO'.$identifier]->version . "', - deliveryby='" . $_SESSION['PO'.$identifier]->deliveryby . "', - deliverydate='" . FormatDateForSQL($_SESSION['PO'.$identifier]->deliverydate) . "', - revised= '" . FormatDateForSQL($date) . "', - intostocklocation='" . $_SESSION['PO'.$identifier]->Location . "', - deladd1='" . $_SESSION['PO'.$identifier]->DelAdd1 . "', - deladd2='" . $_SESSION['PO'.$identifier]->DelAdd2 . "', - deladd3='" . $_SESSION['PO'.$identifier]->DelAdd3 . "', - deladd4='" . $_SESSION['PO'.$identifier]->DelAdd4 . "', - deladd5='" . $_SESSION['PO'.$identifier]->DelAdd5 . "', - deladd6='" . $_SESSION['PO'.$identifier]->DelAdd6 . "', - deladd6='" . $_SESSION['PO'.$identifier]->tel . "', - suppdeladdress1='" . $_SESSION['PO'.$identifier]->suppDelAdd1 . "', - suppdeladdress2='" . $_SESSION['PO'.$identifier]->suppDelAdd2 . "', - suppdeladdress3='" . $_SESSION['PO'.$identifier]->suppDelAdd3 . "', - suppdeladdress4='" . $_SESSION['PO'.$identifier]->suppDelAdd4 . "', - suppdeladdress5='" . $_SESSION['PO'.$identifier]->suppDelAdd5 . "', - suppdeladdress6='" . $_SESSION['PO'.$identifier]->suppDelAdd6 . "', - suppliercontact='" . $_SESSION['PO'.$identifier]->SupplierContact . "', - supptel='" . $_SESSION['PO'.$identifier]->supptel . "', - contact='" . $_SESSION['PO'.$identifier]->contact . "', - paymentterms='" . $_SESSION['PO'.$identifier]->paymentterms . "', - allowprint='" . $_SESSION['PO'.$identifier]->AllowPrintPO . "', - status = '" . PurchOrder::STATUS_PENDING . "' - WHERE orderno = '" . $_SESSION['PO'.$identifier]->OrderNo ."'"; + $sql = "UPDATE purchorders SET supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' , + comments='" . $_SESSION['PO'.$identifier]->Comments . "', + rate='" . $_SESSION['PO'.$identifier]->ExRate . "', + initiator='" . $_SESSION['PO'.$identifier]->Initiator . "', + requisitionno= '" . $_SESSION['PO'.$identifier]->RequisitionNo . "', + version= '" . $_SESSION['PO'.$identifier]->version . "', + deliveryby='" . $_SESSION['PO'.$identifier]->deliveryby . "', + deliverydate='" . FormatDateForSQL($_SESSION['PO'.$identifier]->deliverydate) . "', + revised= '" . FormatDateForSQL($date) . "', + intostocklocation='" . $_SESSION['PO'.$identifier]->Location . "', + deladd1='" . $_SESSION['PO'.$identifier]->DelAdd1 . "', + deladd2='" . $_SESSION['PO'.$identifier]->DelAdd2 . "', + deladd3='" . $_SESSION['PO'.$identifier]->DelAdd3 . "', + deladd4='" . $_SESSION['PO'.$identifier]->DelAdd4 . "', + deladd5='" . $_SESSION['PO'.$identifier]->DelAdd5 . "', + deladd6='" . $_SESSION['PO'.$identifier]->DelAdd6 . "', + deladd6='" . $_SESSION['PO'.$identifier]->tel . "', + suppdeladdress1='" . $_SESSION['PO'.$identifier]->suppDelAdd1 . "', + suppdeladdress2='" . $_SESSION['PO'.$identifier]->suppDelAdd2 . "', + suppdeladdress3='" . $_SESSION['PO'.$identifier]->suppDelAdd3 . "', + suppdeladdress4='" . $_SESSION['PO'.$identifier]->suppDelAdd4 . "', + suppdeladdress5='" . $_SESSION['PO'.$identifier]->suppDelAdd5 . "', + suppdeladdress6='" . $_SESSION['PO'.$identifier]->suppDelAdd6 . "', + suppliercontact='" . $_SESSION['PO'.$identifier]->SupplierContact . "', + supptel='" . $_SESSION['PO'.$identifier]->supptel . "', + contact='" . $_SESSION['PO'.$identifier]->contact . "', + paymentterms='" . $_SESSION['PO'.$identifier]->paymentterms . "', + allowprint='" . $_SESSION['PO'.$identifier]->AllowPrintPO . "', + status = '" . PurchOrder::STATUS_PENDING . "' + WHERE orderno = '" . $_SESSION['PO'.$identifier]->OrderNo ."'"; $ErrMsg = _('The purchase order could not be updated because'); $DbgMsg = _('The SQL statement used to update the purchase order header record, that failed was'); @@ -287,97 +283,94 @@ } } else if ($POLine->PODetailRec=='') { - $sql = "INSERT INTO purchorderdetails ( - orderno, - itemcode, - deliverydate, - itemdescription, - glcode, - unitprice, - quantityord, - shiptref, - jobref, - itemno, - uom, - suppliers_partno, - subtotal_amount, - package, - pcunit, - nw, - gw, - cuft, - total_quantity, - total_amount - ) - VALUES ( - '" . $_SESSION['PO'.$identifier]->OrderNo . "', - '" . $POLine->StockID . "', - '" . FormatDateForSQL($POLine->ReqDelDate) . "', - '" . $POLine->ItemDescription . "', - '" . $POLine->GLCode . "', - '" . $POLine->Price . "', - '" . $POLine->Quantity . "', - '" . $POLine->ShiptRef . "', - '" . $POLine->JobRef . "', - '" . $POLine->itemno . "', - '" . $POLine->uom . "', - '" . $POLine->suppliers_partno . "', - '" . $POLine->subtotal_amount . "', - '" . $POLine->package . "', - '" . $POLine->pcunit . "', - '" . $POLine->nw . "', - '" . $POLine->gw . "', - '" . $POLine->cuft . "', - '" . $POLine->total_quantity . "', - '" . $POLine->total_amount . "' - )"; + $sql = "INSERT INTO purchorderdetails ( orderno, + itemcode, + deliverydate, + itemdescription, + glcode, + unitprice, + quantityord, + shiptref, + jobref, + itemno, + uom, + suppliers_partno, + subtotal_amount, + package, + pcunit, + nw, + gw, + cuft, + total_quantity, + total_amount + ) + VALUES ( + '" . $_SESSION['PO'.$identifier]->OrderNo . "', + '" . $POLine->StockID . "', + '" . FormatDateForSQL($POLine->ReqDelDate) . "', + '" . $POLine->ItemDescription . "', + '" . $POLine->GLCode . "', + '" . $POLine->Price . "', + '" . $POLine->Quantity . "', + '" . $POLine->ShiptRef . "', + '" . $POLine->JobRef . "', + '" . $POLine->itemno . "', + '" . $POLine->uom . "', + '" . $POLine->suppliers_partno . "', + '" . $POLine->subtotal_amount . "', + '" . $POLine->package . "', + '" . $POLine->pcunit . "', + '" . $POLine->nw . "', + '" . $POLine->gw . "', + '" . $POLine->cuft . "', + '" . $POLine->total_quantity . "', + '" . $POLine->total_amount . "' + )"; } else { if ($POLine->Quantity==$POLine->QtyReceived){ - $sql = "UPDATE purchorderdetails SET - itemcode='" . $POLine->StockID . "', - deliverydate ='" . FormatDateForSQL($POLine->ReqDelDate) . "', - itemdescription='" . $POLine->ItemDescription . "', - glcode='" . $POLine->GLCode . "', - unitprice='" . $POLine->Price . "', - quantityord='" . $POLine->Quantity . "', - shiptref='" . $POLine->ShiptRef . "', - jobref='" . $POLine->JobRef . "', - itemno='" . $POLine->itemno . "', - uom='" . $POLine->uom . "', - suppliers_partno='" . $POLine->suppliers_partno . "', - subtotal_amount='" . $POLine->subtotal_amount . "', - package='" . $POLine->package . "', - pcunit='" . $POLine->pcunit . "', - nw='" . $POLine->nw . "', - gw='" . $POLine->gw . "', - cuft='" . $POLine->cuft . "', - total_quantity='" . $POLine->total_quantity . "', - total_amount='" . $POLine->total_amount . "', - completed=1 - WHERE podetailitem='" . $POLine->PODetailRec . "'"; + $sql = "UPDATE purchorderdetails SET itemcode='" . $POLine->StockID . "', + deliverydate ='" . FormatDateForSQL($POLine->ReqDelDate) . "', + itemdescription='" . $POLine->ItemDescription . "', + glcode='" . $POLine->GLCode . "', + unitprice='" . $POLine->Price . "', + quantityord='" . $POLine->Quantity . "', + shiptref='" . $POLine->ShiptRef . "', + jobref='" . $POLine->JobRef . "', + itemno='" . $POLine->itemno . "', + uom='" . $POLine->uom . "', + suppliers_partno='" . $POLine->suppliers_partno . "', + subtotal_amount='" . $POLine->subtotal_amount . "', + package='" . $POLine->package . "', + pcunit='" . $POLine->pcunit . "', + nw='" . $POLine->nw . "', + gw='" . $POLine->gw . "', + cuft='" . $POLine->cuft . "', + total_quantity='" . $POLine->total_quantity . "', + total_amount='" . $POLine->total_amount . "', + completed=1 + WHERE podetailitem='" . $POLine->PODetailRec . "'"; } else { - $sql = "UPDATE purchorderdetails SET - itemcode='" . $POLine->StockID . "', - deliverydate ='" . FormatDateForSQL($POLine->ReqDelDate) . "', - itemdescription='" . $POLine->ItemDescription . "', - glcode='" . $POLine->GLCode . "', - unitprice='" . $POLine->Price . "', - quantityord='" . $POLine->Quantity . "', - shiptref='" . $POLine->ShiptRef . "', - jobref='" . $POLine->JobRef . "', - itemno='" . $POLine->itemno . "', - uom='" . $POLine->uom . "', - suppliers_partno='" . $POLine->suppliers_partno . "', - subtotal_amount='" . $POLine->subtotal_amount . "', - package='" . $POLine->package . "', - pcunit='" . $POLine->pcunit . "', - nw='" . $POLine->nw . "', - gw='" . $POLine->gw . "', - cuft='" . $POLine->cuft . "', - total_quantity='" . $POLine->total_quantity . "', - total_amount='" . $POLine->total_amount . "' - WHERE podetailitem='" . $POLine->PODetailRec . "'"; + $sql = "UPDATE purchorderdetails SET itemcode='" . $POLine->StockID . "', + deliverydate ='" . FormatDateForSQL($POLine->ReqDelDate) . "', + itemdescription='" . $POLine->ItemDescription . "', + glcode='" . $POLine->GLCode . "', + unitprice='" . $POLine->Price . "', + quantityord='" . $POLine->Quantity . "', + shiptref='" . $POLine->ShiptRef . "', + jobref='" . $POLine->JobRef . "', + itemno='" . $POLine->itemno . "', + uom='" . $POLine->uom . "', + suppliers_partno='" . $POLine->suppliers_partno . "', + subtotal_amount='" . $POLine->subtotal_amount . "', + package='" . $POLine->package . "', + pcunit='" . $POLine->pcunit . "', + nw='" . $POLine->nw . "', + gw='" . $POLine->gw . "', + cuft='" . $POLine->cuft . "', + total_quantity='" . $POLine->total_quantity . "', + total_amount='" . $POLine->total_amount . "' + WHERE podetailitem='" . $POLine->PODetailRec . "'"; } } @@ -414,31 +407,31 @@ if ($_POST['StockCat']=='All'){ $sql = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE stockmaster.mbflag!='D' - AND stockmaster.mbflag!='A' - AND stockmaster.mbflag!='K' - and stockmaster.discontinued!=1 - AND stockmaster.description LIKE '" . $SearchString ."' - ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + AND stockmaster.description LIKE '" . $SearchString ."' + ORDER BY stockmaster.stockid + LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; } else { $sql = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE stockmaster.mbflag!='D' - AND stockmaster.mbflag!='A' - AND stockmaster.mbflag!='K' - and stockmaster.discontinued!=1 - AND stockmaster.description LIKE '". $SearchString ."' - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + AND stockmaster.description LIKE '". $SearchString ."' + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid + LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; } } elseif ($_POST['StockCode']){ @@ -447,59 +440,59 @@ if ($_POST['StockCat']=='All'){ $sql = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE stockmaster.mbflag!='D' - AND stockmaster.mbflag!='A' - AND stockmaster.mbflag!='K' - and stockmaster.discontinued!=1 - AND stockmaster.stockid LIKE '" . $_POST['StockCode'] . "' - ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + AND stockmaster.stockid LIKE '" . $_POST['StockCode'] . "' + ORDER BY stockmaster.stockid + LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; } else { $sql = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE stockmaster.mbflag!='D' - AND stockmaster.mbflag!='A' - AND stockmaster.mbflag!='K' - and stockmaster.discontinued!=1 - AND stockmaster.stockid LIKE '" . $_POST['StockCode'] . "' - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + AND stockmaster.stockid LIKE '" . $_POST['StockCode'] . "' + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid + LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; } } else { if ($_POST['StockCat']=='All'){ $sql = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE stockmaster.mbflag!='D' - AND stockmaster.mbflag!='A' - AND stockmaster.mbflag!='K' - and stockmaster.discontinued!=1 - ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + ORDER BY stockmaster.stockid + LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; } else { $sql = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE stockmaster.mbflag!='D' - AND stockmaster.mbflag!='A' - AND stockmaster.mbflag!='K' - and stockmaster.discontinued!=1 - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid + LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; } } @@ -533,12 +526,12 @@ if (isset($_POST['LookupPrice']) and isset($_POST['StockID2'])){ $sql = "SELECT purchdata.price, - purchdata.conversionfactor, - purchdata.supplierdescription - FROM purchdata - WHERE purchdata.supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' - AND purchdata.stockid = '". strtoupper($_POST['StockID2']) . "'"; - + purchdata.conversionfactor, + purchdata.supplierdescription + FROM purchdata + WHERE purchdata.supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' + AND purchdata.stockid = '". strtoupper($_POST['StockID2']) . "'"; + $ErrMsg = _('The supplier pricing details for') . ' ' . strtoupper($_POST['StockID']) . ' ' . _('could not be retrieved because'); $DbgMsg = _('The SQL used to retrieve the pricing details but failed was'); $LookupResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); @@ -567,8 +560,8 @@ if ($_SESSION['PO'.$identifier]->GLLink==1) { /*Check for existance of GL Code selected */ $sql = "SELECT accountname - FROM chartmaster - WHERE accountcode ='" . $_SESSION['PO'.$identifier]->LineItems[$_POST['LineNo']]->GLCode ."'"; + FROM chartmaster + WHERE accountcode ='" . $_SESSION['PO'.$identifier]->LineItems[$_POST['LineNo']]->GLCode ."'"; $ErrMsg = _('The account name for') . ' ' . $_POST['GLCode'] . ' ' . _('could not be retrieved because'); $DbgMsg = _('The SQL used to retrieve the account details but failed was'); $GLActResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); @@ -589,28 +582,27 @@ if ($AllowUpdate == true) { - $_SESSION['PO'.$identifier]->update_order_item( - $_POST['LineNo'], - $_POST['Qty'], - $_POST['Price'], - $_POST['ItemDescription'], - $_POST['GLCode'], - $GLAccountName, - $_POST['ReqDelDate'], - $_POST['ShiptRef'], - $_POST['JobRef'], - $_POST['itemno'], - $_SESSION['PO'.$identifier]->LineItems[$_POST['LineNo']]->uom, - $_POST['suppliers_partno'], - $_POST['Qty']*$_POST['Price'], - $_POST['package'], - $_POST['pcunit'], - $_POST['nw'], - $_POST['gw'], - $_POST['cuft'], - $_POST['Qty'], - $_POST['Qty']*$_POST['Price'] - ); + $_SESSION['PO'.$identifier]->update_order_item($_POST['LineNo'], + $_POST['Qty'], + $_POST['Price'], + $_POST['ItemDescription'], + $_POST['GLCode'], + $GLAccountName, + $_POST['ReqDelDate'], + $_POST['ShiptRef'], + $_POST['JobRef'], + $_POST['itemno'], + $_SESSION['PO'.$identifier]->LineItems[$_POST['LineNo']]->uom, + $_POST['suppliers_partno'], + $_POST['Qty']*$_POST['Price'], + $_POST['package'], + $_POST['pcunit'], + $_POST['nw'], + $_POST['gw'], + $_POST['cuft'], + $_POST['Qty'], + $_POST['Qty']*$_POST['Price'] + ); include ('includes/PO_UnsetFormVbls.php'); @@ -680,34 +672,34 @@ if ($AllowUpdate == true){ $_SESSION['PO'.$identifier]->add_to_order ($_SESSION['PO'.$identifier]->LinesOnOrder+1, - '', - 0, /*Serialised */ - 0, /*Controlled */ - $_POST['Qty'], - $_POST['ItemDescription'], - $_POST['Price'], - _('each'), - $_POST['GLCode'], - $_POST['ReqDelDate'], - $_POST['ShiptRef'], - $_POST['JobRef'], - 0, - 0, - $GLAccountName, - 2, - $_POST['itemno'], - $_POST['uom'], - $_POST['suppliers_partno'], - 1, - $_POST['subtotal_amount'], - $_POST['package'], - $_POST['pcunit'], - $_POST['nw'], - $_POST['gw'], - $_POST['cuft'], - $_POST['total_quantity'], - $_POST['total_amount'] - ); + '', + 0, /*Serialised */ + 0, /*Controlled */ + $_POST['Qty'], + $_POST['ItemDescription'], + $_POST['Price'], + _('each'), + $_POST['GLCode'], + $_POST['ReqDelDate'], + $_POST['ShiptRef'], + $_POST['JobRef'], + 0, + 0, + $GLAccountName, + 2, + $_POST['itemno'], + $_POST['uom'], + $_POST['suppliers_partno'], + 1, + $_POST['subtotal_amount'], + $_POST['package'], + $_POST['pcunit'], + $_POST['nw'], + $_POST['gw'], + $_POST['cuft'], + $_POST['total_quantity'], + $_POST['total_amount'] + ); include ('includes/PO_UnsetFormVbls.php'); } } @@ -737,58 +729,58 @@ } } if ($AlreadyOnThisOrder!=1 and $Quantity>0){ - $purchdatasql="SELECT COUNT(supplierno) - FROM purchdata - WHERE purchdata.supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' - AND purchdata.stockid='". $ItemCode . "'"; - $purchdataresult=DB_query($purchdatasql, $db); - $myrow=DB_fetch_row($purchdataresult); + $PurchDataSQL="SELECT COUNT(supplierno) + FROM purchdata + WHERE purchdata.supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' + AND purchdata.stockid='". $ItemCode . "'"; + $PurchDataResult=DB_query($PurchDataSQL, $db); + $myrow=DB_fetch_row($PurchDataResult); if ($myrow[0]>0) { $sql = "SELECT stockmaster.description, - stockmaster.stockid, - stockmaster.units, - stockmaster.decimalplaces, - stockmaster.kgs, - stockmaster.netweight, - stockcategory.stockact, - chartmaster.accountname, - purchdata.price, - purchdata.conversionfactor, - purchdata.supplierdescription, - purchdata.suppliersuom, - unitsofmeasure.unitname, - purchdata.suppliers_partno, - purchdata.leadtime - FROM stockcategory, - chartmaster, - stockmaster LEFT JOIN purchdata - ON stockmaster.stockid = purchdata.stockid - LEFT JOIN unitsofmeasure - ON purchdata.suppliersuom=unitsofmeasure.unitid - AND purchdata.supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' - WHERE chartmaster.accountcode = stockcategory.stockact - AND stockcategory.categoryid = stockmaster.categoryid - AND stockmaster.stockid = '". $ItemCode . "' - AND purchdata.effectivefrom = - (SELECT max(effectivefrom) - FROM purchdata - WHERE purchdata.stockid='". $ItemCode . "' - AND purchdata.supplierno='" . $_SESSION['PO'.$identifier]->SupplierID . "')"; + stockmaster.stockid, + stockmaster.units, + stockmaster.decimalplaces, + stockmaster.kgs, + stockmaster.netweight, + stockcategory.stockact, + chartmaster.accountname, + purchdata.price, + purchdata.conversionfactor, + purchdata.supplierdescription, + purchdata.suppliersuom, + unitsofmeasure.unitname, + purchdata.suppliers_partno, + purchdata.leadtime + FROM stockcategory, + chartmaster, + stockmaster LEFT JOIN purchdata + ON stockmaster.stockid = purchdata.stockid + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid + AND purchdata.supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' + WHERE chartmaster.accountcode = stockcategory.stockact + AND stockcategory.categoryid = stockmaster.categoryid + AND stockmaster.stockid = '". $ItemCode . "' + AND purchdata.effectivefrom = + (SELECT max(effectivefrom) + FROM purchdata + WHERE purchdata.stockid='". $ItemCode . "' + AND purchdata.supplierno='" . $_SESSION['PO'.$identifier]->SupplierID . "')"; } else { $sql="SELECT stockmaster.description, - stockmaster.stockid, - stockmaster.units, - stockmaster.decimalplaces, - stockmaster.kgs, - stockmaster.netweight, - stockcategory.stockact, - chartmaster.accountname - FROM stockcategory, - chartmaster, - stockmaster - WHERE chartmaster.accountcode = stockcategory.stockact - AND stockcategory.categoryid = stockmaster.categoryid - AND stockmaster.stockid = '". $ItemCode . "'"; + stockmaster.stockid, + stockmaster.units, + stockmaster.decimalplaces, + stockmaster.kgs, + stockmaster.netweight, + stockcategory.stockact, + chartmaster.accountname + FROM stockcategory, + chartmaster, + stockmaster + WHERE chartmaster.accountcode = stockcategory.stockact + AND stockcategory.categoryid = stockmaster.categoryid + AND stockmaster.stockid = '". $ItemCode . "'"; } $ErrMsg = _('The supplier pricing details for') . ' ' . $ItemCode . ' ' . _('could not be retrieved because'); @@ -799,69 +791,69 @@ if (isset($myrow['price']) and is_numeric($myrow['price'])){ $_SESSION['PO'.$identifier]->add_to_order ($_SESSION['PO'.$identifier]->LinesOnOrder+1, - $ItemCode, - 0, /*Serialised */ - 0, /*Controlled */ - $Quantity, /* Qty */ - $myrow['description'], - $myrow['price'], - $myrow['units'], - $myrow['stockact'], - $_SESSION['PO'.$identifier]->deliverydate, - 0, - 0, - 0, - 0, - 0, - $myrow['accountname'], - $myrow['decimalplaces'], - $ItemCode, - $myrow['unitname'], - $myrow['conversionfactor'], - $myrow['suppliers_partno'], - $Quantity*$myrow['price'], - $myrow['leadtime'], - '', - 0, - $myrow['netweight'], - $myrow['kgs'], - '', - $Quantity, - $Quantity*$myrow['price'] - ); + $ItemCode, + 0, /*Serialised */ + 0, /*Controlled */ + $Quantity, /* Qty */ + $myrow['description'], + $myrow['price'], + $myrow['units'], + $myrow['stockact'], + $_SESSION['PO'.$identifier]->deliverydate, + 0, + 0, + 0, + 0, + 0, + $myrow['accountname'], + $myrow['decimalplaces'], + $ItemCode, + $myrow['unitname'], + $myrow['conversionfactor'], + $myrow['suppliers_partno'], + $Quantity*$myrow['price'], + $myrow['leadtime'], + '', + 0, + $myrow['netweight'], + $myrow['kgs'], + ... [truncated message content] |
From: <dai...@us...> - 2010-11-21 09:20:15
|
Revision: 4163 http://web-erp.svn.sourceforge.net/web-erp/?rev=4163&view=rev Author: daintree Date: 2010-11-21 09:20:08 +0000 (Sun, 21 Nov 2010) Log Message: ----------- Fixed assets and coding standards Modified Paths: -------------- trunk/GoodsReceived.php trunk/PO_Items.php trunk/SelectOrderItems.php trunk/includes/DefinePOClass.php trunk/includes/PO_ReadInOrder.inc trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2010-11-21 03:28:30 UTC (rev 4162) +++ trunk/GoodsReceived.php 2010-11-21 09:20:08 UTC (rev 4163) @@ -334,7 +334,7 @@ unset($_SESSION['PO']->LineItems); unset($_SESSION['PO']); unset($_POST['ProcessGoodsReceived']); - include ("includes/footer.inc"); + include ('includes/footer.inc'); exit; } $LineNo++; @@ -654,8 +654,8 @@ $StatusComment=$date.' - Order Completed'.'<br>'.$comment; $sql="UPDATE purchorders SET status='" . PurchOrder::STATUS_COMPLITED . "', - stat_comment='".$StatusComment."' - WHERE orderno='".$_SESSION['PO']->OrderNo . "'"; + stat_comment='" . $StatusComment . "' + WHERE orderno='" . $_SESSION['PO']->OrderNo . "'"; $result=DB_query($sql,$db); } @@ -676,7 +676,7 @@ } else { /*Process Goods received not set so show a link to allow mod of line items on order and allow input of date goods received*/ - echo '<br><div class='centre'><a href="' . $rootpath . '/PO_Items.php?=' . SID . '">' . _('Modify Order Items'). '</a></div>'; + echo '<br><div class="centre"><a href="' . $rootpath . '/PO_Items.php?=' . SID . '">' . _('Modify Order Items'). '</a></div>'; echo '<br><div class="centre"><input type=submit name=Update Value=' . _('Update') . '><p>'; echo '<input type=submit name="ProcessGoodsReceived" Value="' . _('Process Goods Received') . '"></div>'; Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2010-11-21 03:28:30 UTC (rev 4162) +++ trunk/PO_Items.php 2010-11-21 09:20:08 UTC (rev 4163) @@ -639,8 +639,8 @@ if ($_SESSION['PO'.$identifier]->GLLink==1){ $sql = "SELECT accountname - FROM chartmaster - WHERE accountcode ='" . (int) $_POST['GLCode'] . "'"; + FROM chartmaster + WHERE accountcode ='" . (int) $_POST['GLCode'] . "'"; $ErrMsg = _('The account details for') . ' ' . $_POST['GLCode'] . ' ' . _('could not be retrieved because'); $DbgMsg = _('The SQL used to retrieve the details of the account, but failed was'); $GLValidResult = DB_query($sql,$db,$ErrMsg,$DbgMsg,false,false); @@ -664,6 +664,17 @@ else { $_POST['GLCode']=0; } + if (strlen($_POST['AssetID'])>0){ + if (!is_numeric($_POST['AssetID'])){ + $AllowUpdate = false; + prnMsg(_('An asset code was entered but it is not numeric. A numeric asset code that exists must be entered when ordering a fixed asset'),'error'); + } + $ValidAssetResult = DB_query('SELECT assetid FROM fixedassets WHERE assetid="' . $_POST['AssetID'] . '"',$db); + if (DB_num_rows($ValidAssetResult)==0){ // then the asset id entered doesn't exist + $AllowUpdate = false; + prnMsg(_('An asset code was entered but it does not yet exist. Only pre-existing asset ids can be entered when ordering a fixed asset'),'error'); + } + } //end if an AssetID is entered if (strlen($_POST['ItemDescription'])<=3){ $AllowUpdate = false; prnMsg(_('Cannot enter this order line') . ':<br>' . _('The description of the item being purchase is required where a non-stock item is being ordered'),'warn'); @@ -698,8 +709,7 @@ $_POST['gw'], $_POST['cuft'], $_POST['total_quantity'], - $_POST['total_amount'] - ); + $_POST['total_amount'] ); include ('includes/PO_UnsetFormVbls.php'); } } @@ -925,7 +935,7 @@ echo '<tr class="OddTableRows">'; $k=1; } - $uomsql="SELECT conversionfactor, + $UomSQL="SELECT conversionfactor, suppliersuom, unitsofmeasure. unitname @@ -935,27 +945,27 @@ WHERE supplierno='".$_SESSION['PO'.$identifier]->SupplierID."' AND stockid='".$POLine->StockID."'"; - $uomresult=DB_query($uomsql, $db); - if (DB_num_rows($uomresult)>0) { - $uomrow=DB_fetch_array($uomresult); - if (strlen($uomrow['suppliersuom'])>0) { - $uom=$uomrow['unitname']; + $UomResult=DB_query($UomSQL, $db); + if (DB_num_rows($UomResult)>0) { + $UomRow=DB_fetch_array($UomResult); + if (strlen($UomRow['suppliersuom'])>0) { + $Uom=$UomRow['unitname']; } else { - $uom=$POLine->Units; + $Uom=$POLine->Units; } } else { - $uom=$POLine->Units; + $Uom=$POLine->Units; } // echo "<td>$POLine->StockID</td><td>$POLine->ItemDescription</td>td> class=number>$DisplayQuantity</td><td>$POLine->Units</td><td>$POLine->ReqDelDate</td>td> class=number>$DisplayPrice</td>td> class=number>$DisplayLineTotal</font></td><td><a href='" . $_SERVER['PHP_SELF'] . "?" . SID . "&Edit=" . $POLine->LineNo . "'>" . _('Select') . "</a></td></tr>"; - echo "<td>".$POLine->StockID ."</td> - <td>".$POLine->ItemDescription."</td> - <td><input type=text class=number name=Qty".$POLine->LineNo ." size=11 value=".$DisplayQuantity."></td> - <td>".$uom."</td> - <td><input type=text class=number name=nw".$POLine->LineNo." size=11 value=".$POLine->nw."></td> - <td><input type=text class=number name=Price".$POLine->LineNo." size=11 value=".$DisplayPrice."></td> - <td class=number>".$DisplayLineTotal."</td> - <td><input type=text class=date alt='".$_SESSION['DefaultDateFormat']."' name=ReqDelDate".$POLine->LineNo." size=11 value=".$POLine->ReqDelDate."></td> - <td><a href='" . $_SERVER['PHP_SELF'] . "?" . SID . "identifier=".$identifier. "&Delete=" . $POLine->LineNo . "'>" . _('Delete') . "</a></td></tr>"; + echo '<td>' . $POLine->StockID . '</td> + <td>' . $POLine->ItemDescription . '</td> + <td><input type="text" class="number" name="Qty' . $POLine->LineNo .'" size="11" value="' . $DisplayQuantity . '"></td> + <td>' . $Uom . '</td> + <td><input type="text" class="number" name="nw' . $POLine->LineNo . '" size="11" value="' . $POLine->nw . '"></td> + <td><input type="text" class="number" name="Price' . $POLine->LineNo . '" size="11" value="' .$DisplayPrice.'"></td> + <td class="number">' . $DisplayLineTotal . '</td> + <td><input type="text" class="date" alt="' .$_SESSION['DefaultDateFormat'].'" name="ReqDelDate' . $POLine->LineNo.'" size="11" value="' .$POLine->ReqDelDate .'"></td> + <td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . 'identifier='.$identifier. '&Delete=' . $POLine->LineNo . '">' . _('Delete') . '</a></td></tr>'; $_SESSION['PO'.$identifier]->total = $_SESSION['PO'.$identifier]->total + $LineTotal; } } @@ -967,7 +977,6 @@ if (!isset($_POST['NewItem']) and isset($_GET['Edit'])) { /*show a form for putting in a new line item with or without a stock entry */ - } } /*Only display the order line items if there are any !! */ @@ -977,23 +986,25 @@ echo '<td><input type=text name=ItemDescription size=40></td></tr>'; echo '<tr><td>'._('General Ledger Code').'</td>'; echo '<td><select name="GLCode">'; - $sql="SELECT - accountcode, - accountname - FROM chartmaster - ORDER BY accountcode ASC"; + $sql='SELECT accountcode, + accountname + FROM chartmaster + ORDER BY accountcode ASC'; + $result=DB_query($sql, $db); while ($myrow=DB_fetch_array($result)) { echo '<option value="'.$myrow['accountcode'].'">'.$myrow['accountcode'].' - '.$myrow['accountname'].'</option>'; } echo '</td></tr>'; - echo '<tr><td>'._('Quantity to purchase').'</td>'; - echo '<td><input type=text class=number name=Qty size=10></td></tr>'; - echo '<tr><td>'._('Price per item').'</td>'; - echo '<td><input type=text class=number name=Price size=10></td></tr>'; - echo '<tr><td>'._('Delivery Date').'</td>'; - echo '<td><input type=text class=date alt="'.$_SESSION['DefaultDateFormat'].'" name=ReqDelDate size=11 - value="'.$_SESSION['PO'.$identifier]->deliverydate .'"></td></tr>'; + echo '<tr><td>'._('OR Asset ID'). '</td> + <td><input type="text" class="number" name="AssetID" size="10" maxlength=12> + <a href="FixedAssetItems.php" target=_blank>'. _('New Fixed Asset') . '</a></td> + <tr><td>'._('Quantity to purchase').'</td> + <td><input type="text" class="number" name="Qty" size=10></td></tr> + <tr><td>'._('Price per item').'</td> + <td><input type="text" class="number" name="Price" size=10></td></tr> + <tr><td>'._('Delivery Date').'</td> + <td><input type="text" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" name="ReqDelDate" size=11 value="'.$_SESSION['PO'.$identifier]->deliverydate .'"></td></tr>'; echo '</table>'; echo '<div class=centre><input type=submit name="EnterLine" value="Enter Item"></div>'; } @@ -1001,26 +1012,26 @@ /* Now show the stock item selection search stuff below */ if (!isset($_GET['Edit'])) { - $sql="SELECT categoryid, - categorydescription - FROM stockcategory - WHERE stocktype<>'L' - AND stocktype<>'D' - ORDER BY categorydescription"; + $sql='SELECT categoryid, + categorydescription + FROM stockcategory + WHERE stocktype<>"L" + AND stocktype<>"D" + ORDER BY categorydescription'; $ErrMsg = _('The supplier category details could not be retrieved because'); $DbgMsg = _('The SQL used to retrieve the category details but failed was'); $result1 = DB_query($sql,$db,$ErrMsg,$DbgMsg); echo '<table class=selection><tr><th colspan=3><font size=3 color=blue>'. _('Search For Stock Items') . '</th>'; - echo ":</font></tr><tr><td><select name='StockCat'>"; + echo ':</font></tr><tr><td><select name="StockCat">'; - echo "<option selected value='All'>" . _('All'); + echo '<option selected value="All">' . _('All'); while ($myrow1 = DB_fetch_array($result1)) { if (isset($_POST['StockCat']) and $_POST['StockCat']==$myrow1['categoryid']){ - echo "<option selected value=". $myrow1['categoryid'] . '>' . $myrow1['categorydescription']; + echo '<option selected value="'. $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; } else { - echo "<option value=". $myrow1['categoryid'] . '>' . $myrow1['categorydescription']; + echo '<option value="'. $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; } } @@ -1059,13 +1070,13 @@ echo "<table cellpadding=1 colspan=7 class=selection>"; - $tableheader = "<tr> - <th>" . _('Code') . "</th> - <th>" . _('Description') . "</th> - <th>" . _('Units') . "</th> - <th colspan=2><a href='#end'>"._('Go to end of list')."</a></th> - </tr>"; - echo $tableheader; + $TableHeader = '<tr> + <th>' . _('Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Units') . '</th> + <th colspan=2><a href="#end">'._('Go to end of list').'</a></th> + </tr>'; + echo $TableHeader; $j = 1; $k=0; //row colour counter @@ -1090,32 +1101,32 @@ $ImageSource = '<i>'._('No Image').'</i>'; } - $uomsql="SELECT conversionfactor, - suppliersuom, - unitsofmeasure.unitname - FROM purchdata - LEFT JOIN unitsofmeasure - ON purchdata.suppliersuom=unitsofmeasure.unitid - WHERE supplierno='".$_SESSION['PO'.$identifier]->SupplierID."' - AND stockid='".$myrow['stockid']."'"; + $UomSQL="SELECT conversionfactor, + suppliersuom, + unitsofmeasure.unitname + FROM purchdata + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid + WHERE supplierno='".$_SESSION['PO'.$identifier]->SupplierID."' + AND stockid='".$myrow['stockid']."'"; - $uomresult=DB_query($uomsql, $db); - if (DB_num_rows($uomresult)>0) { - $uomrow=DB_fetch_array($uomresult); - if (strlen($uomrow['suppliersuom'])>0) { - $uom=$uomrow['unitname']; + $UomResult=DB_query($UomSQL, $db); + if (DB_num_rows($UomResult)>0) { + $UomRow=DB_fetch_array($UomResult); + if (strlen($UomRow['suppliersuom'])>0) { + $Uom=$UomRow['unitname']; } else { - $uom=$myrow['units']; + $Uom=$myrow['units']; } } else { - $uom=$myrow['units']; + $Uom=$myrow['units']; } echo "<td>".$myrow['stockid']."</td> <td>".$myrow['description']."</td> - <td>".$uom."</td> + <td>".$Uom."</td> <td>".$ImageSource."</td> <td><input class='number' type='text' size=6 value=0 name='qty".$myrow['stockid']."'></td> - <input type='hidden' size=6 value=".$uom." name=uom> + <input type='hidden' size=6 value=".$Uom." name=uom> </tr>"; $PartsDisplayed++; Modified: trunk/SelectOrderItems.php =================================================================== --- trunk/SelectOrderItems.php 2010-11-21 03:28:30 UTC (rev 4162) +++ trunk/SelectOrderItems.php 2010-11-21 09:20:08 UTC (rev 4163) @@ -1112,7 +1112,7 @@ } /*end of if its a new item */ - if (isset($NewItem_array) && isset($_POST['order_items'])){ + if (isset($NewItem_array) AND isset($_POST['order_items'])){ /* get the item details from the database and hold them in the cart object make the quantity 1 by default then add it to the cart */ /*Now figure out if the item is a kit set - the field MBFlag='K'*/ foreach($NewItem_array as $NewItem => $NewItemQty) { @@ -1302,11 +1302,11 @@ $DisplayTotal = number_format($_SESSION['Items'.$identifier]->total,2); if (in_array(2,$_SESSION['AllowedPageSecurityTokens'])){ - $ColSpanNumber = 7; + $ColSpanNumber = 3; } else { - $ColSpanNumber = 5; + $ColSpanNumber = 1; } - echo '<tr class="EvenTableRows"><td></td><td><b>' . _('TOTAL Excl Tax/Freight') . '</b></td> + echo '<tr class="EvenTableRows"><td class="number" colspan=7><b>' . _('TOTAL Excl Tax/Freight') . '</b></td> <td colspan="' . $ColSpanNumber . '" class=number>' . $DisplayTotal . '</td></tr></table>'; $DisplayVolume = number_format($_SESSION['Items'.$identifier]->totalVolume,2); Modified: trunk/includes/DefinePOClass.php =================================================================== --- trunk/includes/DefinePOClass.php 2010-11-21 03:28:30 UTC (rev 4162) +++ trunk/includes/DefinePOClass.php 2010-11-21 09:20:08 UTC (rev 4163) @@ -85,49 +85,51 @@ $itemno, $uom, $ConversionFactor=1, - $leadtime=1, - $suppliers_partno='', - $subtotal_amount=0, - $package=0, - $pcunit=0, + $LeadTime=1, + $Suppliers_PartNo='', + $SubTotal_Amount=0, + $Package=0, + $PcUnit=0, $nw=0, $gw=0, - $cuft=0, - $total_quantity=0, - $total_amount=0){ + $CuFt=0, + $Total_Quantity=0, + $Total_Amount=0, + $AssetID=''){ if ($Qty!=0 && isset($Qty)){ $this->LineItems[$LineNo] = new LineDetails($LineNo, - $StockID, - $Serialised, - $Controlled, - $Qty, - $ItemDescr, - $Price, - $UOM, - $GLCode, - $ReqDelDate, - $ShiptRef, - 0, - $JobRef, - $QtyInv, - $QtyRecd, - $GLActName, - $DecimalPlaces, - $itemno, - $uom, - $ConversionFactor, - $leadtime, - $suppliers_partno, - $subtotal_amount, - $package, - $pcunit, - $nw, - $gw, - $cuft, - $total_quantity, - $total_amount); + $StockID, + $Serialised, + $Controlled, + $Qty, + $ItemDescr, + $Price, + $UOM, + $GLCode, + $ReqDelDate, + $ShiptRef, + 0, + $JobRef, + $QtyInv, + $QtyRecd, + $GLActName, + $DecimalPlaces, + $itemno, + $uom, + $ConversionFactor, + $LeadTime, + $Suppliers_PartNo, + $SubTotal_Amount, + $Package, + $PcUnit, + $nw, + $gw, + $CuFt, + $Total_Quantity, + $Total_Amount, + $AssetID); $this->LinesOnOrder++; Return 1; } @@ -135,26 +137,26 @@ } function update_order_item($LineNo, - $Qty, - $Price, - $ItemDescription, - $GLCode, - $GLAccountName, - $ReqDelDate, - $ShiptRef, - $JobRef , - $itemno, - $uom, - $ConversionFactor, - $suppliers_partno, - $subtotal_amount, - $package, - $pcunit, - $nw, - $gw, - $cuft, - $total_quantity, - $total_amount){ + $Qty, + $Price, + $ItemDescription, + $GLCode, + $GLAccountName, + $ReqDelDate, + $ShiptRef, + $JobRef , + $itemno, + $uom, + $ConversionFactor, + $Suppliers_PartNo, + $SubTotal_Amount, + $Package, + $PcUnit, + $nw, + $gw, + $CuFt, + $Total_Quantity, + $Total_Amount){ $this->LineItems[$LineNo]->ItemDescription = $ItemDescription; $this->LineItems[$LineNo]->Quantity = $Qty; @@ -164,18 +166,18 @@ $this->LineItems[$LineNo]->ReqDelDate = $ReqDelDate; $this->LineItems[$LineNo]->ShiptRef = $ShiptRef; $this->LineItems[$LineNo]->JobRef = $JobRef; - $this->LineItems[$LineNo]->itemno = $itemno; + $this->LineItems[$LineNo]->ItemNo = $ItemNo; $this->LineItems[$LineNo]->uom = $uom; $this->LineItems[$LineNo]->ConversionFactor = $ConversionFactor; - $this->LineItems[$LineNo]->suppliers_partno = $suppliers_partno; - $this->LineItems[$LineNo]->subtotal_amount = $subtotal_amount; - $this->LineItems[$LineNo]->package = $package; - $this->LineItems[$LineNo]->pcunit = $pcunit; + $this->LineItems[$LineNo]->Suppliers_PartNo = $Suppliers_PartNo; + $this->LineItems[$LineNo]->Subtotal_Amount = $SubTotal_Amount; + $this->LineItems[$LineNo]->Package = $Package; + $this->LineItems[$LineNo]->PcUnit = $PcUnit; $this->LineItems[$LineNo]->nw = $nw; $this->LineItems[$LineNo]->gw = $gw; - $this->LineItems[$LineNo]->cuft = $cuft; - $this->LineItems[$LineNo]->total_quantity = $total_quantity; - $this->LineItems[$LineNo]->total_amount = $total_amount; + $this->LineItems[$LineNo]->CuFt = $CuFt; + $this->LineItems[$LineNo]->Total_Quantity = $Total_Quantity; + $this->LineItems[$LineNo]->Total_Amount = $Total_Amount; $this->LineItems[$LineNo]->Price = $Price; } @@ -188,7 +190,7 @@ /* Checks if there have been deliveries or invoiced entered against any of the line items */ if (count($this->LineItems)>0){ foreach ($this->LineItems as $OrderedItems) { - if ($OrderedItems->QtyReceived !=0 || $OrderedItems->QtyInvoiced !=0){ + if ($OrderedItems->QtyReceived !=0 OR $OrderedItems->QtyInvoiced !=0){ return 1; } } @@ -234,57 +236,57 @@ var $ShiptRef; var $completed; Var $JobRef; - Var $itemno; + Var $ItemNo; Var $uom; var $ConversionFactor; - Var $suppliers_partno; - Var $subtotal_amount; - Var $leadtime; - Var $package; - Var $pcunit; + Var $Suppliers_PartNo; + Var $SubTotal_Amount; + Var $LeadTime; + Var $Package; + Var $PcUnit; Var $nw; Var $gw; - Var $cuft; - Var $total_quantity; - Var $total_amount; + Var $CuFt; + Var $Total_Quantity; + Var $Total_Amount; Var $ReceiveQty; Var $Deleted; Var $Controlled; Var $Serialised; Var $SerialItems; /*An array holding the batch/serial numbers and quantities in each batch*/ + Var $AssetID; - function LineDetails ( - $LineNo, - $StockItem, - $Serialised, - $Controlled, - $Qty, - $ItemDescr, - $Prc, - $UOM, - $GLCode, - $ReqDelDate, - $ShiptRef =0, - $Completed, - $JobRef, - $QtyInv, - $QtyRecd, - $GLActName, - $DecimalPlaces, - $itemno, - $uom, - $ConversionFactor, - $suppliers_partno, - $subtotal_amount, - $leadtime, - $package, - $pcunit, - $nw, - $gw, - $cuft, - $total_quantity, - $total_amount) - { + function LineDetails ( $LineNo, + $StockItem, + $Serialised, + $Controlled, + $Qty, + $ItemDescr, + $Prc, + $UOM, + $GLCode, + $ReqDelDate, + $ShiptRef =0, + $Completed, + $JobRef, + $QtyInv, + $QtyRecd, + $GLActName, + $DecimalPlaces, + $ItemNo, + $uom, + $ConversionFactor, + $Suppliers_PartNo, + $SubTotal_Amount, + $LeadTime, + $Package, + $PcUnit, + $nw, + $gw, + $CuFt, + $Total_Quantity, + $Total_Amount, + $AssetID) { /* Constructor function to add a new LineDetail object with passed params */ $this->LineNo = $LineNo; @@ -301,18 +303,18 @@ $this->QtyInv = $QtyInv; $this->GLCode = $GLCode; $this->JobRef = $JobRef; - $this->itemno = $itemno; + $this->ItemNo = $itemno; $this->uom = $uom; $this->ConversionFactor = $ConversionFactor; - $this->suppliers_partno = $suppliers_partno; - $this->subtotal_amount = $subtotal_amount; - $this->leadtime = $leadtime; - $this->pcunit = $pcunit; + $this->Suppliers_PartNo = $Suppliers_PartNo; + $this->Subtotal_Amount = $SubTotal_Amount; + $this->LeadTime = $LeadTime; + $this->PcUnit = $PcUnit; $this->nw = $nw; $this->gw = $gw; - $this->cuft = $cuft; - $this->total_quantity = $total_quantity; - $this->total_amount = $total_amount; + $this->CuFt = $CuFt; + $this->Total_Quantity = $Total_Quantity; + $this->Total_Amount = $Total_Amount; if (is_numeric($ShiptRef)){ $this->ShiptRef = $ShiptRef; } else { @@ -325,6 +327,7 @@ $this->Deleted=False; $this->SerialItems = array(); /*if Controlled then need to populate this later */ $this->SerialItemsValid=false; + $this->AssetID= $AssetID; } } Modified: trunk/includes/PO_ReadInOrder.inc =================================================================== --- trunk/includes/PO_ReadInOrder.inc 2010-11-21 03:28:30 UTC (rev 4162) +++ trunk/includes/PO_ReadInOrder.inc 2010-11-21 09:20:08 UTC (rev 4163) @@ -100,17 +100,17 @@ $_SESSION['PO'.$identifier]->paymentterms= $myrow['paymentterms']; $supplierSQL = "SELECT suppliers.supplierid, - suppliers.suppname, - suppliers.address1, - suppliers.address2, - suppliers.address3, - suppliers.address4, - suppliers.address5, - suppliers.address6, - suppliers.currcode - FROM suppliers - WHERE suppliers.supplierid='" . $_SESSION['PO'.$identifier]->SupplierID."' - ORDER BY suppliers.supplierid"; + suppliers.suppname, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.currcode + FROM suppliers + WHERE suppliers.supplierid='" . $_SESSION['PO'.$identifier]->SupplierID."' + ORDER BY suppliers.supplierid"; $ErrMsg = _('The searched supplier records requested cannot be retrieved because'); $result_SuppSelect = DB_query($supplierSQL,$db,$ErrMsg); @@ -126,43 +126,44 @@ /*now populate the line PO array with the purchase order details records */ $LineItemsSQL = "SELECT podetailitem, - itemcode, - stockmaster.description, - purchorderdetails.deliverydate, - itemdescription, - glcode, - accountname, - qtyinvoiced, - unitprice, - units, - quantityord, - quantityrecd, - shiptref, - completed, - jobref, - stdcostunit, - itemno, - stockmaster.controlled, - stockmaster.serialised, - stockmaster.decimalplaces, - subtotal_amount, - package, - pcunit, - nw, - gw, - cuft, - total_quantity, - total_amount - FROM purchorderdetails - LEFT JOIN stockmaster - ON purchorderdetails.itemcode=stockmaster.stockid - LEFT JOIN purchorders - ON purchorders.orderno=purchorderdetails.orderno - LEFT JOIN chartmaster - ON purchorderdetails.glcode=chartmaster.accountcode - WHERE purchorderdetails.completed=0 - AND purchorderdetails.orderno =" . $_GET['ModifyOrderNumber'] . ' - ORDER BY podetailitem'; + itemcode, + stockmaster.description, + purchorderdetails.deliverydate, + itemdescription, + glcode, + accountname, + qtyinvoiced, + unitprice, + units, + quantityord, + quantityrecd, + shiptref, + completed, + jobref, + stdcostunit, + itemno, + stockmaster.controlled, + stockmaster.serialised, + stockmaster.decimalplaces, + subtotal_amount, + package, + pcunit, + nw, + gw, + cuft, + total_quantity, + total_amount, + assetid + FROM purchorderdetails + LEFT JOIN stockmaster + ON purchorderdetails.itemcode=stockmaster.stockid + LEFT JOIN purchorders + ON purchorders.orderno=purchorderdetails.orderno + LEFT JOIN chartmaster + ON purchorderdetails.glcode=chartmaster.accountcode + WHERE purchorderdetails.completed=0 + AND purchorderdetails.orderno ='" . $_GET['ModifyOrderNumber'] . "' + ORDER BY podetailitem"; $ErrMsg = _('The lines on the purchase order cannot be retrieved because'); $DbgMsg = _('The SQL statement that was used to retrieve the purchase order lines was'); @@ -187,63 +188,63 @@ } else { $StockID = $myrow['itemcode']; } - $datesql='SELECT max(effectivefrom) - FROM purchdata - WHERE supplierno="'.$_SESSION['PO'.$identifier]->SupplierID.'" - AND stockid="'.$StockID.'" - AND effectivefrom<="'.$_SESSION['PO'.$identifier]->Orig_OrderDate.'"'; - $dateresult=DB_query($datesql, $db); - $date=DB_fetch_row($dateresult); - if ($date[0]!='') { + $DateSQL='SELECT max(effectivefrom) + FROM purchdata + WHERE supplierno="'.$_SESSION['PO'.$identifier]->SupplierID.'" + AND stockid="'.$StockID.'" + AND effectivefrom<="'.$_SESSION['PO'.$identifier]->Orig_OrderDate.'"'; + $DateResult=DB_query($DateSQL, $db); + $Date=DB_fetch_row($DateResult); + if ($Date[0]!='') { $sql='SELECT unitsofmeasure.unitname, - suppliers_partno, - conversionfactor - FROM purchdata - LEFT JOIN unitsofmeasure - ON purchdata.suppliersuom=unitsofmeasure.unitid - WHERE supplierno="'.$_SESSION['PO'.$identifier]->SupplierID.'" - AND stockid="'.$StockID.'" - AND effectivefrom="'.$date[0].'"'; - $purchdataresult=DB_query($sql, $db); - $myrow2=DB_fetch_array($purchdataresult); + suppliers_partno, + conversionfactor + FROM purchdata + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid + WHERE supplierno="'.$_SESSION['PO'.$identifier]->SupplierID.'" + AND stockid="'.$StockID.'" + AND effectivefrom="'.$Date[0].'"'; + $PurchDataResult=DB_query($sql, $db); + $myrow2=DB_fetch_array($PurchDataResult); } else { $sql='SELECT units as unitname, stockid as suppliers_partno FROM stockmaster WHERE stockid="'.$StockID.'"'; - $purchdataresult=DB_query($sql, $db); - $myrow2=DB_fetch_array($purchdataresult); + $PurchDataResult=DB_query($sql, $db); + $myrow2=DB_fetch_array($PurchDataResult); $myrow2['conversionfactor']=1; } $_SESSION['PO'.$identifier]->add_to_order($_SESSION['PO'.$identifier]->LinesOnOrder+1, - $StockID, - $myrow['serialised'], - $myrow['controlled'], - $myrow['quantityord'], - stripslashes($myrow['itemdescription']), - $myrow['unitprice'], - $Units, - $GLCode, - ConvertSQLDate($myrow['deliverydate']), - $myrow['shiptref'], - $myrow['completed'], - $myrow['jobref'], - $myrow['qtyinvoiced'], - $myrow['quantityrecd'], - $myrow['accountname'], - $myrow['decimalplaces'], - $myrow['itemno'], - $myrow2['unitname'], - $myrow2['conversionfactor'], - $myrow2['suppliers_partno'], - $myrow['subtotal_amount'], - 0, - $myrow['package'], - $myrow['pcunit'], - $myrow['nw'], - $myrow['gw'], - $myrow['cuft'], - $myrow['total_quantity'], - $myrow['total_amount']); - + $StockID, + $myrow['serialised'], + $myrow['controlled'], + $myrow['quantityord'], + stripslashes($myrow['itemdescription']), + $myrow['unitprice'], + $Units, + $GLCode, + ConvertSQLDate($myrow['deliverydate']), + $myrow['shiptref'], + $myrow['completed'], + $myrow['jobref'], + $myrow['qtyinvoiced'], + $myrow['quantityrecd'], + $myrow['accountname'], + $myrow['decimalplaces'], + $myrow['itemno'], + $myrow2['unitname'], + $myrow2['conversionfactor'], + $myrow2['suppliers_partno'], + $myrow['subtotal_amount'], + 0, + $myrow['package'], + $myrow['pcunit'], + $myrow['nw'], + $myrow['gw'], + $myrow['cuft'], + $myrow['total_quantity'], + $myrow['total_amount']); + $_SESSION['PO'.$identifier]->LineItems[$_SESSION['PO'.$identifier]->LinesOnOrder]->PODetailRec = $myrow['podetailitem']; $_SESSION['PO'.$identifier]->LineItems[$_SESSION['PO'.$identifier]->LinesOnOrder]->StandardCost = $myrow['stdcostunit']; /*Needed for receiving goods and GL interface */ } /* line PO from purchase order details */ Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-21 03:28:30 UTC (rev 4162) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-21 09:20:08 UTC (rev 4163) @@ -444,8 +444,9 @@ ALTER TABLE fixedassets ADD COLUMN `longdescription` text NOT NULL; ALTER TABLE fixedassets ADD COLUMN `depntype` int NOT NULL DEFAULT 1; ALTER TABLE fixedassets ADD COLUMN `depnrate` double NOT NULL; -ALTER TABLE `fixedassets` CHANGE `depn` `accumdepn` DOUBLE NOT NULL DEFAULT '0' -ALTER TABLE `fixedassets` CHANGE `location` `assetlocation` VARCHAR( 6 ) NOT NULL DEFAULT '' +ALTER TABLE fixedassets ADD COLUMN `barcode` VARCHAR( 30 ) NOT NULL; +ALTER TABLE `fixedassets` CHANGE `depn` `accumdepn` DOUBLE NOT NULL DEFAULT '0'; +ALTER TABLE `fixedassets` CHANGE `location` `assetlocation` VARCHAR( 6 ) NOT NULL DEFAULT ''; UPDATE fixedassets INNER JOIN stockmaster ON fixedassets.stockid=stockmaster.stockid SET assetcategoryid=stockmaster.categoryid, fixedassets.description=stockmaster.description, fixedassets.longdescription=stockmaster.longdescription; @@ -491,5 +492,4 @@ INDEX ( inputdate ) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; - UPDATE config SET confvalue='4.0-RC2' WHERE confname='VersionName'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-23 07:05:41
|
Revision: 4164 http://web-erp.svn.sourceforge.net/web-erp/?rev=4164&view=rev Author: daintree Date: 2010-11-23 07:05:34 +0000 (Tue, 23 Nov 2010) Log Message: ----------- Pak Ricard - fix for MRP with utf-8 temporary tables Modified Paths: -------------- trunk/MRP.php trunk/MRPShortages.php trunk/SupplierAllocations.php trunk/doc/Change.log.html Modified: trunk/MRP.php =================================================================== --- trunk/MRP.php 2010-11-21 09:20:08 UTC (rev 4163) +++ trunk/MRP.php 2010-11-23 07:05:34 UTC (rev 4164) @@ -26,7 +26,7 @@ $sql = 'CREATE TEMPORARY TABLE passbom ( part char(20), - sortpart text)'; + sortpart text) DEFAULT CHARSET=utf8'; $ErrMsg = _('The SQL to to create passbom failed with the message'); $result = DB_query($sql,$db,$ErrMsg); @@ -34,7 +34,7 @@ parent char(20), component char(20), sortpart text, - level int)'; + level int) DEFAULT CHARSET=utf8'; $result = DB_query($sql,$db,_('Create of tempbom failed because')); // To create levels, first, find parts in bom that are top level assemblies. // Do this by doing a LEFT JOIN from bom to bom (as bom2), linking @@ -84,7 +84,7 @@ $sql = 'CREATE TEMPORARY TABLE passbom ( part char(20), - sortpart text)'; + sortpart text) DEFAULT CHARSET=utf8'; $result = DB_query($sql,$db); $sql = "INSERT INTO passbom (part, sortpart) @@ -109,7 +109,7 @@ flush(); $sql = 'CREATE TEMPORARY TABLE bomlevels ( part char(20), - level int)'; + level int) DEFAULT CHARSET=utf8'; $result = DB_query($sql,$db); // Read tempbom and split sortpart into separate parts. For each separate part, calculate level as @@ -141,7 +141,7 @@ leadtime smallint(6) NOT NULL default "0", pansize double NOT NULL default "0", shrinkfactor double NOT NULL default "0", - eoq double NOT NULL default "0")'; + eoq double NOT NULL default "0") DEFAULT CHARSET=utf8'; $result = DB_query($sql,$db); $sql = 'INSERT INTO levels (part, level, @@ -229,7 +229,7 @@ mrpdemandtype varchar(6), orderno int(11), directdemand smallint, - whererequired char(20))'; + whererequired char(20)) DEFAULT CHARSET=utf8'; $result = DB_query($sql,$db,_('Create of mrprequirements failed because')); prnMsg(_('Loading requirements from sales orders'),'info'); @@ -343,7 +343,7 @@ orderno int(11), mrpdate date, updateflag smallint(6), - PRIMARY KEY (id))'; + PRIMARY KEY (id)) DEFAULT CHARSET=utf8'; $result = DB_query($sql,$db,_('Create of mrpsupplies failed because')); prnMsg(_('Loading supplies from purchase orders'),'info'); @@ -495,7 +495,7 @@ shrinkageflag varchar(5), eoqflag varchar(5), usemrpdemands varchar(5), - leeway smallint)'; + leeway smallint) DEFAULT CHARSET=utf8'; $result = DB_query($sql,$db); // Create entry for location field from $_POST['location'], which is an array // since multiple locations can be selected Modified: trunk/MRPShortages.php =================================================================== --- trunk/MRPShortages.php 2010-11-21 09:20:08 UTC (rev 4163) +++ trunk/MRPShortages.php 2010-11-23 07:05:34 UTC (rev 4164) @@ -35,7 +35,7 @@ $sql = 'CREATE TEMPORARY TABLE demandtotal ( part char(20), demand double, - KEY `PART` (`part`))'; + KEY `PART` (`part`)) DEFAULT CHARSET=utf8'; $result = DB_query($sql,$db,_('Create of demandtotal failed because')); $sql = 'INSERT INTO demandtotal @@ -50,7 +50,7 @@ $sql = 'CREATE TEMPORARY TABLE supplytotal ( part char(20), supply double, - KEY `PART` (`part`))'; + KEY `PART` (`part`)) DEFAULT CHARSET=utf8'; $result = DB_query($sql,$db,_('Create of supplytotal failed because')); /* 21/03/2010: Ricard modification to allow items with total supply = 0 be included in the report */ Modified: trunk/SupplierAllocations.php =================================================================== --- trunk/SupplierAllocations.php 2010-11-21 09:20:08 UTC (rev 4163) +++ trunk/SupplierAllocations.php 2010-11-23 07:05:34 UTC (rev 4164) @@ -203,19 +203,19 @@ $_SESSION['Alloc']->TransDate = FormatDateForSQL($_SESSION['Alloc']->TransDate); $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES ('" . $_SESSION['Alloc']->TransType . "', - '" . $_SESSION['Alloc']->TransNo . "', - '" . $_SESSION['Alloc']->TransDate . "', - '" . $PeriodNo . "', - '" . $_SESSION['CompanyRecord']['purchasesexchangediffact'] . "', - '". _('Exch diff') . "', - '" . $MovtInDiffOnExch . "')"; + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ('" . $_SESSION['Alloc']->TransType . "', + '" . $_SESSION['Alloc']->TransNo . "', + '" . $_SESSION['Alloc']->TransDate . "', + '" . $PeriodNo . "', + '" . $_SESSION['CompanyRecord']['purchasesexchangediffact'] . "', + '". _('Exch diff') . "', + '" . $MovtInDiffOnExch . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL entry for the difference on exchange arising out of this allocation could not be inserted because'); @@ -225,20 +225,20 @@ $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES ('" . $_SESSION['Alloc']->TransType . "', - '" . $_SESSION['Alloc']->TransNo . "', - '" . $_SESSION['Alloc']->TransDate . "', - '" . $PeriodNo . "', - '" . $_SESSION['CompanyRecord']['creditorsact'] . "', - '" . _('Exch Diff') . "', - '" . -$MovtInDiffOnExch . "')"; - + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ('" . $_SESSION['Alloc']->TransType . "', + '" . $_SESSION['Alloc']->TransNo . "', + '" . $_SESSION['Alloc']->TransDate . "', + '" . $PeriodNo . "', + '" . $_SESSION['CompanyRecord']['creditorsact'] . "', + '" . _('Exch Diff') . "', + '" . -$MovtInDiffOnExch . "')"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ' : ' . _('The GL entry for the difference on exchange arising out of this allocation could not be inserted because'); @@ -309,22 +309,22 @@ $SQL= "SELECT systypes.typename, - supptrans.type, - supptrans.transno, - supptrans.trandate, - supptrans.supplierno, - suppliers.suppname, - rate, - (supptrans.ovamount+supptrans.ovgst) AS total, - supptrans.diffonexch, - supptrans.alloc - FROM supptrans, - systypes, - suppliers - WHERE supptrans.type = systypes.typeid - AND supptrans.supplierno = suppliers.supplierid - AND supptrans.id='" . $_SESSION['AllocTrans'] . "'"; - + supptrans.type, + supptrans.transno, + supptrans.trandate, + supptrans.supplierno, + suppliers.suppname, + rate, + (supptrans.ovamount+supptrans.ovgst) AS total, + supptrans.diffonexch, + supptrans.alloc + FROM supptrans, + systypes, + suppliers + WHERE supptrans.type = systypes.typeid + AND supptrans.supplierno = suppliers.supplierid + AND supptrans.id='" . $_SESSION['AllocTrans'] . "'"; + $Result = DB_query($SQL, $db); if (DB_num_rows($Result) != 1){ echo _('There was a problem retrieving the information relating the transaction selected') . '. ' . _('Allocations are unable to proceed'); @@ -351,20 +351,20 @@ /*First get the transactions that have outstanding balances ie Total-Alloc >0 */ $SQL= "SELECT supptrans.id, - typename, - transno, - trandate, - suppreference, - rate, - ovamount+ovgst AS total, - diffonexch, - alloc - FROM supptrans, - systypes - WHERE supptrans.type = systypes.typeid - AND supptrans.settled=0 - AND abs(ovamount+ovgst-alloc)>0.009 - AND supplierno='" . $_SESSION['Alloc']->SupplierID . "'"; + typename, + transno, + trandate, + suppreference, + rate, + ovamount+ovgst AS total, + diffonexch, + alloc + FROM supptrans, + systypes + WHERE supptrans.type = systypes.typeid + AND supptrans.settled=0 + AND abs(ovamount+ovgst-alloc)>0.009 + AND supplierno='" . $_SESSION['Alloc']->SupplierID . "'"; $ErrMsg = _('There was a problem retrieving the transactions available to allocate to'); @@ -392,23 +392,23 @@ above logic will be overwritten with the prev alloc detail below */ $SQL = "SELECT supptrans.id, - typename, - transno, - trandate, - suppreference, - rate, - ovamount+ovgst AS total, - diffonexch, - supptrans.alloc-suppallocs.amt AS prevallocs, - amt, - suppallocs.id AS allocid - FROM supptrans, - systypes, - suppallocs - WHERE supptrans.type = systypes.typeid - AND supptrans.id=suppallocs.transid_allocto - AND suppallocs.transid_allocfrom='" . $_SESSION['AllocTrans'] . - "' AND supplierno='" . $_SESSION['Alloc']->SupplierID . "'"; + typename, + transno, + trandate, + suppreference, + rate, + ovamount+ovgst AS total, + diffonexch, + supptrans.alloc-suppallocs.amt AS prevallocs, + amt, + suppallocs.id AS allocid + FROM supptrans, + systypes, + suppallocs + WHERE supptrans.type = systypes.typeid + AND supptrans.id=suppallocs.transid_allocto + AND suppallocs.transid_allocfrom='" . $_SESSION['AllocTrans'] . + "' AND supplierno='" . $_SESSION['Alloc']->SupplierID . "'"; $ErrMsg = _('There was a problem retrieving the previously allocated transactions for modification'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-21 09:20:08 UTC (rev 4163) +++ trunk/doc/Change.log.html 2010-11-23 07:05:34 UTC (rev 4164) @@ -1,7 +1,8 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> -<p>21/11/10 Phil:Rewritten FixedAssetJournal.php - renamed FixedAssetDepreciation.php -<p>20/11/10 Phil: Rewritten FixedAssetItems.php FixedAssetCategories.php and modified FixedAssetLocations.php to use the new structure +<p>23/11/10 Pak Ricard: MRP.php and MRPShortages.php fixed temporary tables to use utf-8 - code failed without probably depends on mysql server settings</p> +<p>21/11/10 Phil:Rewritten FixedAssetJournal.php - renamed FixedAssetDepreciation.php</p> +<p>20/11/10 Phil: Rewritten FixedAssetItems.php FixedAssetCategories.php and modified FixedAssetLocations.php to use the new structure</p> <p>18/11/10 Tim: upgrade3.11.1-4.00.sql - Fix sql syntax errors brought in on recent changes.</p> <p>14/11/10 Phil: SelectAsset.php script reworked SelectAssetType.php script now deleted</p> <p>08/11/10 Exson: Z_ImportStocks.php - Bug fixes.</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-24 09:05:50
|
Revision: 4165 http://web-erp.svn.sourceforge.net/web-erp/?rev=4165&view=rev Author: daintree Date: 2010-11-24 09:05:42 +0000 (Wed, 24 Nov 2010) Log Message: ----------- receiving fixed asset nominal order lines postings to fixedassettrans and GL Modified Paths: -------------- trunk/GoodsReceived.php trunk/doc/Change.log.html trunk/includes/PO_ReadInOrder.inc trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2010-11-23 07:05:34 UTC (rev 4164) +++ trunk/GoodsReceived.php 2010-11-24 09:05:42 UTC (rev 4165) @@ -78,12 +78,12 @@ '"></td></tr></table><br>'; echo '<table cellpadding=2 class=selection> - <tr><th>' . _('Item Code') . '</th> - <th>' . _('Description') . '</th> - <th>' . _('Quantity') . '<br>' . _('Ordered') . '</th> - <th>' . _('Units') . '</th> - <th>' . _('Already Received') . '</th> - <th>' . _('This Delivery') . '<br>' . _('Quantity') . '</th>'; + <tr><th>' . _('Item Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Quantity') . '<br>' . _('Ordered') . '</th> + <th>' . _('Units') . '</th> + <th>' . _('Already Received') . '</th> + <th>' . _('This Delivery') . '<br>' . _('Quantity') . '</th>'; if ($_SESSION['ShowValueOnGRN']==1) { echo '<th>' . _('Price') . '</th><th>' . _('Total Value') . '<br>' . _('Received') . '</th>'; @@ -362,8 +362,8 @@ if ($OrderLine->StockID!='') { /*Its a stock item line */ /*Need to get the current standard cost as it is now so we can process GL jorunals later*/ $SQL = "SELECT materialcost + labourcost + overheadcost as stdcost - FROM stockmaster - WHERE stockid='" . $OrderLine->StockID . "'"; + FROM stockmaster + WHERE stockid='" . $OrderLine->StockID . "'"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The standard cost of the item being received cannot be retrieved because'); $DbgMsg = _('The following SQL to retrieve the standard cost was used'); $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); @@ -482,7 +482,7 @@ $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); - /* If its a stock item still .... Insert stock movements - with unit cost */ + /* ... Insert stock movements - with unit cost */ $SQL = "INSERT INTO stockmoves (stockid, type, @@ -579,6 +579,40 @@ } } /*end of its a stock item - updates to locations and insert movements*/ + /* Check to see if the line item was flagged as the purchase of an asset */ + if ($OrderLine->AssetID !=''){ //then it is an asset + + /*first validate the AssetID and if it doesn't exist treat it like a normal nominal item */ + $CheckAssetExistsResult = DB_query("SELECT assetid, costact + FROM fixedassets INNER JOIN fixedassetcategories + ON fixedassets.assetcategoryid=fixedassetcategories.categoryid + WHERE assetid='" . $OrderLine->AssetID . "'",$db); + if (DB_num_rows($CheckAssetExistsResult)==1){ //then work with the assetid provided + + /*Need to add a fixedassettrans for the cost of the asset being received */ + $SQL = "INSERT INTO fixedassettrans (assetid, + transtype, + typeno, + transdate, + periodno, + inputdate, + cost) + VALUES (25, + '" . $GRN . "', + '" . $_POST['DefaultReceivedDate'] . "', + '" . $PeriodNo . "', + '" . Date('Y-m-d') . "', + '" . $CurrentStandardCost * $OrderLine->ReceiveQty . "')"; + $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE The fixed asset transaction could not be inserted because'); + $DbgMsg = _('The following SQL to insert the fixed asset transaction record was used'); + $Result = DB_query($SQL,$db,$ErrMsg, $DbgMsg, true); + + /*Now get the correct cost GL account from the asset category */ + $AssetRow = DB_fetch_array($CheckAssetExistsResult); + /*Over-ride any GL account specified in the order with the asset category cost account */ + $_SESSION['PO']->LineItems[$OrderLine->LineNo]->GLCode = $AssetRow['costact']; + } //assetid provided doesn't exist so ignore it and treat as a normal nominal item + } //assetid is set so the nominal item is an asset /* If GLLink_Stock then insert GLTrans to debit the GL Code and credit GRN Suspense account at standard cost*/ if ($_SESSION['PO']->GLLink==1 AND $OrderLine->GLCode !=0){ /*GLCode is set to 0 when the GLLink is not activated this covers a situation where the GLLink is now active but it wasn't when this PO was entered */ Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-23 07:05:34 UTC (rev 4164) +++ trunk/doc/Change.log.html 2010-11-24 09:05:42 UTC (rev 4165) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>24/11/10 Phil: GoodsReceived.php - modified to insert fixedassettrans and to post nominal POs to fixed asset cost account from fixedassetcategories.costact <p>23/11/10 Pak Ricard: MRP.php and MRPShortages.php fixed temporary tables to use utf-8 - code failed without probably depends on mysql server settings</p> <p>21/11/10 Phil:Rewritten FixedAssetJournal.php - renamed FixedAssetDepreciation.php</p> <p>20/11/10 Phil: Rewritten FixedAssetItems.php FixedAssetCategories.php and modified FixedAssetLocations.php to use the new structure</p> Modified: trunk/includes/PO_ReadInOrder.inc =================================================================== --- trunk/includes/PO_ReadInOrder.inc 2010-11-23 07:05:34 UTC (rev 4164) +++ trunk/includes/PO_ReadInOrder.inc 2010-11-24 09:05:42 UTC (rev 4165) @@ -16,45 +16,45 @@ /*read in all the guff from the selected order into the PO PurchOrder Class variable */ $OrderHeaderSQL = 'SELECT purchorders.supplierno, - suppliers.suppname, - purchorders.comments, - purchorders.orddate, - purchorders.rate, - purchorders.dateprinted, - purchorders.deladd1, - purchorders.deladd2, - purchorders.deladd3, - purchorders.deladd4, - purchorders.deladd5, - purchorders.deladd6, - purchorders.tel, - purchorders.suppdeladdress1, - purchorders.suppdeladdress2, - purchorders.suppdeladdress3, - purchorders.suppdeladdress4, - purchorders.suppdeladdress5, - purchorders.suppdeladdress6, - purchorders.suppliercontact, - purchorders.supptel, - purchorders.contact, - purchorders.allowprint, - purchorders.requisitionno, - purchorders.intostocklocation, - purchorders.initiator, - purchorders.version, - purchorders.status, - purchorders.stat_comment, - purchorders.deliverydate, - purchorders.port, - suppliers.currcode, - locations.managed , - purchorders.paymentterms - FROM purchorders - LEFT JOIN locations ON purchorders.intostocklocation=locations.loccode, - suppliers - WHERE purchorders.supplierno = suppliers.supplierid - AND purchorders.orderno = ' . $_GET['ModifyOrderNumber']; - + suppliers.suppname, + purchorders.comments, + purchorders.orddate, + purchorders.rate, + purchorders.dateprinted, + purchorders.deladd1, + purchorders.deladd2, + purchorders.deladd3, + purchorders.deladd4, + purchorders.deladd5, + purchorders.deladd6, + purchorders.tel, + purchorders.suppdeladdress1, + purchorders.suppdeladdress2, + purchorders.suppdeladdress3, + purchorders.suppdeladdress4, + purchorders.suppdeladdress5, + purchorders.suppdeladdress6, + purchorders.suppliercontact, + purchorders.supptel, + purchorders.contact, + purchorders.allowprint, + purchorders.requisitionno, + purchorders.intostocklocation, + purchorders.initiator, + purchorders.version, + purchorders.status, + purchorders.stat_comment, + purchorders.deliverydate, + purchorders.port, + suppliers.currcode, + locations.managed , + purchorders.paymentterms + FROM purchorders + LEFT JOIN locations ON purchorders.intostocklocation=locations.loccode, + suppliers + WHERE purchorders.supplierno = suppliers.supplierid + AND purchorders.orderno = ' . $_GET['ModifyOrderNumber']; + $ErrMsg = _('The order cannot be retrieved because'); $DbgMsg = _('The SQL statement that was used and failed was'); $GetOrdHdrResult = DB_query($OrderHeaderSQL,$db,$ErrMsg,$DbgMsg); @@ -243,7 +243,8 @@ $myrow['gw'], $myrow['cuft'], $myrow['total_quantity'], - $myrow['total_amount']); + $myrow['total_amount'], + $myrow['assetid'] ); $_SESSION['PO'.$identifier]->LineItems[$_SESSION['PO'.$identifier]->LinesOnOrder]->PODetailRec = $myrow['podetailitem']; $_SESSION['PO'.$identifier]->LineItems[$_SESSION['PO'.$identifier]->LinesOnOrder]->StandardCost = $myrow['stdcostunit']; /*Needed for receiving goods and GL interface */ Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-23 07:05:34 UTC (rev 4164) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-24 09:05:42 UTC (rev 4165) @@ -479,17 +479,18 @@ INSERT INTO `systypes` (`typeid`, `typename`, `typeno`) VALUES ('43', 'Delete w/down asset', '1'); INSERT INTO `systypes` (`typeid`, `typename`, `typeno`) VALUES ('44', 'Depreciation', '1'); -CREATE TABLE `fixedassettrans` ( -`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , -`assetid` INT NOT NULL , -`transtype` TINYINT NOT NULL , -`transno` INT NOT NULL , -`periodno` SMALLINT( 4 ) NOT NULL, -`inputdate` DATE NOT, -`cost` DOUBLE NOT NULL , -`depn` DOUBLE NOT NULL , -INDEX ( `assetid` , `transtype` , `transno` ), +CREATE TABLE fixedassettrans( +id INT( 11 ) NOT NULL AUTO_INCREMENT , +assetid INT( 11 ) NOT NULL , +transtype TINYINT( 4 ) NOT NULL , +transno INT NOT NULL , +periodno SMALLINT( 6 ) NOT NULL , +inputdate DATE NOT NULL , +cost DOUBLE NOT NULL , +depn DOUBLE NOT NULL , +PRIMARY KEY ( id ) , +INDEX ( assetid, transtype, transno ) , INDEX ( inputdate ) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; UPDATE config SET confvalue='4.0-RC2' WHERE confname='VersionName'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-26 08:43:37
|
Revision: 4166 http://web-erp.svn.sourceforge.net/web-erp/?rev=4166&view=rev Author: tim_schofield Date: 2010-11-26 08:43:31 +0000 (Fri, 26 Nov 2010) Log Message: ----------- Otandeka: CounterSales.php - Fix bug in counter sales script. Modified Paths: -------------- trunk/CounterSales.php trunk/doc/Change.log.html Modified: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php 2010-11-24 09:05:42 UTC (rev 4165) +++ trunk/CounterSales.php 2010-11-26 08:43:31 UTC (rev 4166) @@ -83,11 +83,11 @@ include('includes/footer.inc'); exit; } - + $CashSaleCustomer = explode('-',$myrow['cashsalecustomer']); - $_SESSION['Items'.$identifier]->Branch = $CashSaleCustomer[0]; - $_SESSION['Items'.$identifier]->DebtorNo = $CashSaleCustomer[1]; + $_SESSION['Items'.$identifier]->Branch = $CashSaleCustomer[1]; + $_SESSION['Items'.$identifier]->DebtorNo = $CashSaleCustomer[0]; $_SESSION['Items'.$identifier]->LocationName = $myrow['locationname']; $_SESSION['Items'.$identifier]->Location = $_SESSION['UserStockLocation']; $_SESSION['Items'.$identifier]->DispatchTaxProvince = $myrow['taxprovinceid']; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-24 09:05:42 UTC (rev 4165) +++ trunk/doc/Change.log.html 2010-11-26 08:43:31 UTC (rev 4166) @@ -1,6 +1,7 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> -<p>24/11/10 Phil: GoodsReceived.php - modified to insert fixedassettrans and to post nominal POs to fixed asset cost account from fixedassetcategories.costact +<p>26/11/10 Otandeka: CounterSales.php - Fix bug in counter sales script.</p> +<p>24/11/10 Phil: GoodsReceived.php - modified to insert fixedassettrans and to post nominal POs to fixed asset cost account from fixedassetcategories.costact</p> <p>23/11/10 Pak Ricard: MRP.php and MRPShortages.php fixed temporary tables to use utf-8 - code failed without probably depends on mysql server settings</p> <p>21/11/10 Phil:Rewritten FixedAssetJournal.php - renamed FixedAssetDepreciation.php</p> <p>20/11/10 Phil: Rewritten FixedAssetItems.php FixedAssetCategories.php and modified FixedAssetLocations.php to use the new structure</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-26 09:44:02
|
Revision: 4167 http://web-erp.svn.sourceforge.net/web-erp/?rev=4167&view=rev Author: daintree Date: 2010-11-26 09:43:55 +0000 (Fri, 26 Nov 2010) Log Message: ----------- bug fixes - style corrections Modified Paths: -------------- trunk/PDFBankingSummary.php trunk/StockCostUpdate.php trunk/includes/SQL_CommonFunctions.inc Modified: trunk/PDFBankingSummary.php =================================================================== --- trunk/PDFBankingSummary.php 2010-11-26 08:43:31 UTC (rev 4166) +++ trunk/PDFBankingSummary.php 2010-11-26 09:43:55 UTC (rev 4167) @@ -43,19 +43,19 @@ if (isset($_POST['BatchNo']) and $_POST['BatchNo']!='') { $SQL= 'SELECT bankaccountname, - bankaccountnumber, - ref, - transdate, - banktranstype, - bankact, - banktrans.exrate, - banktrans.functionalexrate, - banktrans.currcode - FROM bankaccounts, - banktrans - WHERE bankaccounts.accountcode=banktrans.bankact - AND banktrans.transno="' . $_POST['BatchNo'] . '" - AND banktrans.type=12'; + bankaccountnumber, + ref, + transdate, + banktranstype, + bankact, + banktrans.exrate, + banktrans.functionalexrate, + banktrans.currcode + FROM bankaccounts, + banktrans + WHERE bankaccounts.accountcode=banktrans.bankact + AND banktrans.transno="' . $_POST['BatchNo'] . '" + AND banktrans.type=12'; $ErrMsg = _('An error occurred getting the header information about the receipt batch number') . ' ' . $_POST['BatchNo']; $DbgMsg = _('The SQL used to get the receipt header information that failed was'); @@ -81,15 +81,14 @@ $SQL = "SELECT debtorsmaster.name, - ovamount, - invtext, - reference - FROM debtorsmaster, - debtortrans - WHERE debtorsmaster.debtorno=debtortrans.debtorno - AND debtortrans.transno='" . $_POST['BatchNo'] . "' - AND debtortrans.type=12"; - + ovamount, + invtext, + reference + FROM debtorsmaster INNER JOIN debtortrans + ON debtorsmaster.debtorno=debtortrans.debtorno + WHERE debtortrans.transno='" . $_POST['BatchNo'] . "' + AND debtortrans.type=12"; + $CustRecs=DB_query($SQL,$db,'','',false,false); if (DB_error_no($db)!=0){ $title = _('Create PDF Print-out For A Batch Of Receipts'); @@ -102,12 +101,12 @@ exit; } $SQL = "SELECT narrative, - amount - FROM gltrans - WHERE gltrans.typeno=" . $_POST['BatchNo'] . " - AND gltrans.type=12 and gltrans.amount <0 - AND gltrans.account !='" . $myrow['bankact'] . "' - AND gltrans.account !='" . $_SESSION['CompanyRecord']['debtorsact'] . "'"; + amount + FROM gltrans + WHERE gltrans.typeno='" . $_POST['BatchNo'] . "' + AND gltrans.type=12 and gltrans.amount <0 + AND gltrans.account !='" . $myrow['bankact'] . "' + AND gltrans.account !='" . $_SESSION['CompanyRecord']['debtorsact'] . "'"; $GLRecs=DB_query($SQL,$db,'','',false,false); if (DB_error_no($db)!=0){ @@ -121,16 +120,6 @@ exit; } -if (DB_num_rows($GLRecs) == 0){ - $title = _('Create PDF Print-out For A Batch Of Receipts'); - include ('includes/header.inc'); - prnMsg(_('No GL receipts retrieved for batch number') . ' ' . $_POST['BatchNo'], 'warn'); - if ($debug==1){ - prnMsg(_('The SQL used to get the GL receipt information that no any record retrieved') . ':<br>' . $SQL,'error'); - } - include('includes/footer.inc'); - exit; -} include('includes/PDFStarter.php'); @@ -152,7 +141,7 @@ $LeftOvers = $pdf->addTextWrap($Left_Margin+315,$YPos,100,$FontSize,$myrow['reference'], 'left'); $YPos -= ($line_height); - $TotalBanked = $TotalBanked - $myrow['ovamount']; + $TotalBanked -= $myrow['ovamount']; if ($YPos - (2 *$line_height) < $Bottom_Margin){ /*Then set up a new page */ @@ -162,11 +151,11 @@ /* Right now print out the GL receipt entries in the batch */ while ($myrow=DB_fetch_array($GLRecs)){ - + $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,60,$FontSize,number_format((-$myrow['amount']*$ExRate*$FunctionalExRate),2), 'right'); $LeftOvers = $pdf->addTextWrap($Left_Margin+65,$YPos,300,$FontSize,$myrow['narrative'], 'left'); $YPos -= ($line_height); - $TotalBanked = $TotalBanked + (-$myrow['amount']*$ExRate); + $TotalBanked += (-$myrow['amount']*$ExRate); if ($YPos - (2 *$line_height) < $Bottom_Margin){ /*Then set up a new page */ @@ -174,21 +163,11 @@ } /*end of new page header */ } /* end of while there are GL receipts in the batch to print */ + $YPos-=$line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,60,$FontSize,number_format($TotalBanked,2), 'right'); $LeftOvers = $pdf->addTextWrap($Left_Margin+65,$YPos,300,$FontSize,_('TOTAL') . ' ' . $Currency . ' ' . _('BANKED'), 'left'); -/* UldisN -$buf = $pdf->output(); -$len = strlen($buf); -header('Content-type: application/pdf'); -header('Content-Length: ' . $len); -header('Content-Disposition: inline; filename=BankingSummary.pdf'); -header('Expires: 0'); -header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); -header('Pragma: public'); -$pdf->stream(); -*/ $pdf->OutputD($_SESSION['DatabaseName'] . '_BankingSummary_' . date('Y-m-d').'.pdf');//UldisN $pdf->__destruct(); //UldisN } Modified: trunk/StockCostUpdate.php =================================================================== --- trunk/StockCostUpdate.php 2010-11-26 08:43:31 UTC (rev 4166) +++ trunk/StockCostUpdate.php 2010-11-26 09:43:55 UTC (rev 4167) @@ -17,127 +17,125 @@ $StockID =trim(strtoupper($_POST['StockID'])); } -echo "<a href='" . $rootpath . '/SelectProduct.php?' . SID . "'>" . _('Back to Items') . '</a><br>'; +echo '<a href="' . $rootpath . '/SelectProduct.php?' . SID . '">' . _('Back to Items') . '</a><br>'; echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Inventory Adjustment') . '" alt="">' . ' ' . $title . '</p>'; if (isset($_POST['UpdateData'])){ - - $sql = "SELECT materialcost, - labourcost, - overheadcost, - mbflag, - sum(quantity) as totalqoh - FROM stockmaster INNER JOIN locstock - ON stockmaster.stockid=locstock.stockid - WHERE stockmaster.stockid='".$StockID."' - GROUP BY description, - units, - lastcost, - actualcost, - materialcost, - labourcost, - overheadcost, - mbflag"; - $ErrMsg = _('The entered item code does not exist'); - $oldresult = DB_query($sql,$db,$ErrMsg); - $oldrow = DB_fetch_array($oldresult); - $_POST['QOH'] = $oldrow['totalqoh']; - $_POST['OldMaterialCost'] = $oldrow['materialcost']; - if ($oldrow['mbflag']=='M') { - $_POST['OldLabourCost'] = $oldrow['labourcost']; - $_POST['OldOverheadCost'] = $oldrow['overheadcost']; + $sql = "SELECT materialcost, + labourcost, + overheadcost, + mbflag, + sum(quantity) as totalqoh + FROM stockmaster INNER JOIN locstock + ON stockmaster.stockid=locstock.stockid + WHERE stockmaster.stockid='".$StockID."' + GROUP BY description, + units, + lastcost, + actualcost, + materialcost, + labourcost, + overheadcost, + mbflag"; + $ErrMsg = _('The entered item code does not exist'); + $OldResult = DB_query($sql,$db,$ErrMsg); + $OldRow = DB_fetch_array($OldResult); + $_POST['QOH'] = $OldRow['totalqoh']; + $_POST['OldMaterialCost'] = $OldRow['materialcost']; + if ($OldRow['mbflag']=='M') { + $_POST['OldLabourCost'] = $OldRow['labourcost']; + $_POST['OldOverheadCost'] = $OldRow['overheadcost']; } else { $_POST['OldLabourCost'] = 0; $_POST['OldOverheadCost'] = 0; $_POST['LabourCost'] = 0; $_POST['OverheadCost'] = 0; } - DB_free_result($oldresult); + DB_free_result($OldResult); - $OldCost =$_POST['OldMaterialCost'] + $_POST['OldLabourCost'] + $_POST['OldOverheadCost']; + $OldCost = $_POST['OldMaterialCost'] + $_POST['OldLabourCost'] + $_POST['OldOverheadCost']; $NewCost =$_POST['MaterialCost'] + $_POST['LabourCost'] + $_POST['OverheadCost']; - $result = DB_query("SELECT * FROM stockmaster WHERE stockid='".$StockID."'",$db); + $result = DB_query("SELECT * FROM stockmaster WHERE stockid='" . $StockID . "'",$db); $myrow = DB_fetch_row($result); if (DB_num_rows($result)==0) { prnMsg (_('The entered item code does not exist'),'error',_('Non-existent Item')); } elseif ($OldCost != $NewCost){ - $Result = DB_Txn_Begin($db); - ItemCostUpdateGL($db, $StockID, $NewCost, $OldCost, $_POST['QOH']); - - + $Result = DB_Txn_Begin($db); + ItemCostUpdateGL($db, $StockID, $NewCost, $OldCost, $_POST['QOH']); + $SQL = "UPDATE stockmaster SET - materialcost='" . $_POST['MaterialCost'] . "', - labourcost='" . $_POST['LabourCost'] . "', - overheadcost='" . $_POST['OverheadCost'] . "', - lastcost='" . $OldCost . "' - WHERE stockid='" . $StockID . "'"; - + materialcost='" . $_POST['MaterialCost'] . "', + labourcost='" . $_POST['LabourCost'] . "', + overheadcost='" . $_POST['OverheadCost'] . "', + lastcost='" . $OldCost . "' + WHERE stockid='" . $StockID . "'"; + $ErrMsg = _('The cost details for the stock item could not be updated because'); $DbgMsg = _('The SQL that failed was'); $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - + $Result = DB_Txn_Commit($db); UpdateCost($db, $StockID); //Update any affected BOMs - } + } } $ErrMsg = _('The cost details for the stock item could not be retrieved because'); $DbgMsg = _('The SQL that failed was'); $result = DB_query("SELECT description, - units, - lastcost, - actualcost, - materialcost, - labourcost, - overheadcost, - mbflag, - stocktype, - sum(quantity) as totalqoh - FROM stockmaster INNER JOIN locstock - ON stockmaster.stockid=locstock.stockid - INNER JOIN stockcategory - ON stockmaster.categoryid = stockcategory.categoryid - WHERE stockmaster.stockid='" . $StockID . "' - GROUP BY description, - units, - lastcost, - actualcost, - materialcost, - labourcost, - overheadcost, - mbflag, - stocktype", - $db,$ErrMsg,$DbgMsg); + units, + lastcost, + actualcost, + materialcost, + labourcost, + overheadcost, + mbflag, + stocktype, + sum(quantity) as totalqoh + FROM stockmaster INNER JOIN locstock + ON stockmaster.stockid=locstock.stockid + INNER JOIN stockcategory + ON stockmaster.categoryid = stockcategory.categoryid + WHERE stockmaster.stockid='" . $StockID . "' + GROUP BY description, + units, + lastcost, + actualcost, + materialcost, + labourcost, + overheadcost, + mbflag, + stocktype", + $db,$ErrMsg,$DbgMsg); + - $myrow = DB_fetch_array($result); -echo "<form action='" . $_SERVER['PHP_SELF'] . "?". SID ."' method=post>"; +echo '<form action="' . $_SERVER['PHP_SELF'] . '?'. SID .'" method=post>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; 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 "<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>' . _('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 '<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>'; if (($myrow['mbflag']=='D' AND $myrow['stocktype'] != 'L') - OR $myrow['mbflag']=='A' - OR $myrow['mbflag']=='K'){ + OR $myrow['mbflag']=='A' + OR $myrow['mbflag']=='K'){ echo '</form>'; // Close the form if ($myrow['mbflag']=='D'){ - echo "<br>$StockID " . _('is a service item'); + echo '<br>' . $StockID .' ' . _('is a service item'); } else if ($myrow['mbflag']=='A'){ - echo "<br>$StockID " . _('is an assembly part'); + echo '<br>' . $StockID .' ' . _('is an assembly part'); } else if ($myrow['mbflag']=='K'){ - echo "<br>$StockID " . _('is a kit set part'); + echo '<br>' . $StockID . ' ' . _('is a kit set part'); } prnMsg(_('Cost information cannot be modified for kits assemblies or service items') . '. ' . _('Please select a different part'),'warn'); include('includes/footer.inc'); @@ -147,7 +145,7 @@ 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="QOH" VALUE=' . $myrow['totalqoh'] .'>'; echo '<tr><td>' . _('Last Cost') .':</td><td class=number>' . number_format($myrow['lastcost'],2) . '</td></tr>'; if (! in_array($UpdateSecurity,$_SESSION['AllowedPageSecurityTokens']) OR !isset($UpdateSecurity)){ @@ -165,14 +163,14 @@ 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 "<a href='$rootpath/StockStatus.php?" . SID . "&StockID=$StockID'>" . _('Show Stock Status') . '</a>'; - echo "<br><a href='$rootpath/StockMovements.php?" . SID . "&StockID=$StockID'>" . _('Show Stock Movements') . '</a>'; - echo "<br><a href='$rootpath/StockUsage.php?" . SID . "&StockID=$StockID'>" . _('Show Stock Usage') .'</a>'; - echo "<br><a href='$rootpath/SelectSalesOrder.php?" . SID . "&SelectedStockItem=$StockID'>" . _('Search Outstanding Sales Orders') . '</a>'; - echo "<br><a href='$rootpath/SelectCompletedOrder.php?" . SID . "&SelectedStockItem=$StockID'>" . _('Search Completed Sales Orders') . '</a>'; + echo '<a href="' . $rootpath . '/StockStatus.php?' . SID . '&StockID=' . $StockID . '>' . _('Show Stock Status') . '</a>'; + echo '<br><a href="' . $rootpath . '/StockMovements.php?' . SID . '&StockID=' . $StockID . '">' . _('Show Stock Movements') . '</a>'; + echo '<br><a href="' . $rootpath . '/StockUsage.php?' . SID . '&StockID=' . $StockID . '">' . _('Show Stock Usage') .'</a>'; + echo '<br><a href="' . $rootpath . '/SelectSalesOrder.php?' . SID . '&SelectedStockItem=' . $StockID . '">' . _('Search Outstanding Sales Orders') . '</a>'; + echo '<br><a href="' . $rootpath . '/SelectCompletedOrder.php?' . SID . '&SelectedStockItem=' . $StockID . '">' . _('Search Completed Sales Orders') . '</a>'; } echo '</form></div>'; include('includes/footer.inc'); Modified: trunk/includes/SQL_CommonFunctions.inc =================================================================== --- trunk/includes/SQL_CommonFunctions.inc 2010-11-26 08:43:31 UTC (rev 4166) +++ trunk/includes/SQL_CommonFunctions.inc 2010-11-26 09:43:55 UTC (rev 4167) @@ -16,9 +16,9 @@ */ - DB_query("LOCK TABLES systypes WRITE",$db); + DB_query('LOCK TABLES systypes WRITE',$db); - $SQL = "SELECT typeno FROM systypes WHERE typeid = " . $TransType; + $SQL = 'SELECT typeno FROM systypes WHERE typeid = ' . $TransType; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': <BR>' . _('The next transaction number could not be retrieved from the database because'); $DbgMsg = _('The following SQL to retrieve the transaction number was used'); @@ -63,9 +63,9 @@ $QuerySQL = "SELECT taxrate FROM taxauthrates - WHERE taxauthority=" . $TaxAuthority . " - AND dispatchtaxprovince=" . $DispatchTaxProvince . " - AND taxcatid = " . $TaxCategory; + WHERE taxauthority='" . $TaxAuthority . "' + AND dispatchtaxprovince='" . $DispatchTaxProvince . "' + AND taxcatid = '" . $TaxCategory . "'"; $ErrMsg = _('The tax rate for this item could not be retrieved because'); $GetTaxRateResult = DB_query($QuerySQL,$db,$ErrMsg); @@ -92,9 +92,9 @@ taxauthrates.taxauthority=taxgrouptaxes.taxauthid INNER JOIN taxauthorities ON taxauthrates.taxauthority=taxauthorities.taxid - WHERE taxgrouptaxes.taxgroupid=" . $TaxGroup . " - AND taxauthrates.dispatchtaxprovince=" . $DispatchTaxProvince . " - AND taxauthrates.taxcatid = " . $TaxCategory . " + WHERE taxgrouptaxes.taxgroupid='" . $TaxGroup . "' + AND taxauthrates.dispatchtaxprovince='" . $DispatchTaxProvince . "' + AND taxauthrates.taxcatid = '" . $TaxCategory . "' ORDER BY taxgrouptaxes.calculationorder"; @@ -162,7 +162,7 @@ if ($_SESSION['CompanyRecord']['gllink_stock']==1 AND $QOH!=0){ $CostUpdateNo = GetNextTransNo(35, $db); - $PeriodNo = GetPeriod(Date('d/m/Y'), $db); + $PeriodNo = GetPeriod($_SESSION['DefaultDateFormat'], $db); $StockGLCode = GetStockGLCode($StockID,$db); $ValueOfChange = $QOH * ($NewCost - $OldCost); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-26 11:23:59
|
Revision: 4168 http://web-erp.svn.sourceforge.net/web-erp/?rev=4168&view=rev Author: tim_schofield Date: 2010-11-26 11:23:53 +0000 (Fri, 26 Nov 2010) Log Message: ----------- Add default date for stockcheckdate field in stockcheckfreeze table Modified Paths: -------------- trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-26 09:43:55 UTC (rev 4167) +++ trunk/doc/Change.log.html 2010-11-26 11:23:53 UTC (rev 4168) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>26/11/10 Tim: upgrade3.11.1-4.00.sql - Add default date for stockcheckdate field in stockcheckfreeze table</p> <p>26/11/10 Otandeka: CounterSales.php - Fix bug in counter sales script.</p> <p>24/11/10 Phil: GoodsReceived.php - modified to insert fixedassettrans and to post nominal POs to fixed asset cost account from fixedassetcategories.costact</p> <p>23/11/10 Pak Ricard: MRP.php and MRPShortages.php fixed temporary tables to use utf-8 - code failed without probably depends on mysql server settings</p> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-26 09:43:55 UTC (rev 4167) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-26 11:23:53 UTC (rev 4168) @@ -493,4 +493,6 @@ INDEX ( inputdate ) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; +ALTER TABLE stockcheckfreeze CHANGE stockcheckdate stockcheckdate date NOT NULL DEFAULT '0000-00-00'; + UPDATE config SET confvalue='4.0-RC2' WHERE confname='VersionName'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |