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. |