|
From: <dai...@us...> - 2011-05-15 07:53:49
|
Revision: 4569
http://web-erp.svn.sourceforge.net/web-erp/?rev=4569&view=rev
Author: daintree
Date: 2011-05-15 07:53:42 +0000 (Sun, 15 May 2011)
Log Message:
-----------
Change Stock Code fix
Modified Paths:
--------------
trunk/MRP.php
trunk/Z_ChangeStockCode.php
trunk/build/make_release.sh
trunk/doc/Change.log
Modified: trunk/MRP.php
===================================================================
--- trunk/MRP.php 2011-05-15 07:12:43 UTC (rev 4568)
+++ trunk/MRP.php 2011-05-15 07:53:42 UTC (rev 4569)
@@ -314,16 +314,16 @@
prnMsg(_('Loading requirements based on reorder level'),'info');
flush();
- $result = DB_query('ALTER TABLE mrprequirements ADD INDEX part(part)',$db);
+ $result = DB_query("ALTER TABLE mrprequirements ADD INDEX part(part)",$db);
// In the following section, create mrpsupplies from open purchase orders,
// open work orders, and current quantity onhand from locstock
prnMsg(_('Creating supplies table'),'info');
flush();
- $result = DB_query('DROP TABLE IF EXISTS mrpsupplies',$db);
+ $result = DB_query("DROP TABLE IF EXISTS mrpsupplies",$db);
// updateflag is set to 1 in UpdateSupplies if change date when matching requirements to
// supplies. Actually only change update flag in the array created from mrpsupplies
- $sql = 'CREATE TABLE mrpsupplies ( id int(11) NOT NULL auto_increment,
+ $sql = "CREATE TABLE mrpsupplies ( id int(11) NOT NULL auto_increment,
part char(20),
duedate date,
supplyquantity double,
@@ -331,7 +331,7 @@
orderno int(11),
mrpdate date,
updateflag smallint(6),
- PRIMARY KEY (id)) DEFAULT CHARSET=utf8';
+ PRIMARY KEY (id)) DEFAULT CHARSET=utf8";
$result = DB_query($sql,$db,_('Create of mrpsupplies failed because'));
prnMsg(_('Loading supplies from purchase orders'),'info');
@@ -424,7 +424,7 @@
WHERE workorders.closed=0";
$result = DB_query($sql,$db);
- $sql = 'ALTER TABLE mrpsupplies ADD INDEX part(part)';
+ $sql = "ALTER TABLE mrpsupplies ADD INDEX part(part)";
$result = DB_query($sql,$db);
// Create mrpplannedorders table to create a record for any unmet requirments
@@ -432,8 +432,8 @@
// open work orders, and current quantity onhand from locstock
prnMsg(_('Creating planned orders table'),'info');
flush();
- $result = DB_query('DROP TABLE IF EXISTS mrpplannedorders',$db);
- $sql = 'CREATE TABLE mrpplannedorders (id int(11) NOT NULL auto_increment,
+ $result = DB_query("DROP TABLE IF EXISTS mrpplannedorders",$db);
+ $sql = "CREATE TABLE mrpplannedorders (id int(11) NOT NULL auto_increment,
part char(20),
duedate date,
supplyquantity double,
@@ -441,11 +441,11 @@
orderno int(11),
mrpdate date,
updateflag smallint(6),
- PRIMARY KEY (id)) DEFAULT CHARSET=utf8';
+ PRIMARY KEY (id)) DEFAULT CHARSET=utf8";
$result = DB_query($sql,$db,_('Create of mrpplannedorders failed because'));
// Find the highest and lowest level number
- $sql = 'SELECT MAX(level),MIN(level) from levels';
+ $sql = "SELECT MAX(level),MIN(level) from levels";
$result = DB_query($sql,$db);
$myrow = DB_fetch_row($result);
@@ -471,16 +471,16 @@
echo '</br>' . _('End time') . ': ' . date('h:i:s') . '</br>';
// Create mrpparameters table
- $sql = 'DROP TABLE IF EXISTS mrpparameters';
+ $sql = "DROP TABLE IF EXISTS mrpparameters";
$result = DB_query($sql,$db);
- $sql = 'CREATE TABLE mrpparameters (
+ $sql = "CREATE TABLE mrpparameters (
runtime datetime,
location varchar(50),
pansizeflag varchar(5),
shrinkageflag varchar(5),
eoqflag varchar(5),
usemrpdemands varchar(5),
- leeway smallint) DEFAULT CHARSET=utf8';
+ 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
@@ -515,7 +515,7 @@
_('Inventory') . '" alt="" />' . ' ' . $title . '</p>';
// Display parameters from last run
- $sql = 'SELECT * FROM mrpparameters';
+ $sql = "SELECT * FROM mrpparameters";
$result = DB_query($sql,$db,'','',false,false);
if (DB_error_no($db)==0){
@@ -551,7 +551,7 @@
echo '<td>' . _('Use Shrinkage') . ':  </td><td>' . $useshrinkage . '</td></tr>';
echo '</table></td>';
}
- echo "<p><form method='post' action='" . $_SERVER['PHP_SELF'] . "'>";
+ echo '<p><form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<table class=selection>';
// Generate selections for Location
@@ -560,9 +560,9 @@
<td>' . _('Location') . '</td>
<td><select name="location[]" multiple>
<option value="All" selected>' . _('All') . '</option>';
- $sql = 'SELECT loccode,
+ $sql = "SELECT loccode,
locationname
- FROM locations';
+ FROM locations";
$result = DB_query($sql,$db);
while ($myrow = DB_fetch_array($result)) {
echo '<option value="';
Modified: trunk/Z_ChangeStockCode.php
===================================================================
--- trunk/Z_ChangeStockCode.php 2011-05-15 07:12:43 UTC (rev 4568)
+++ trunk/Z_ChangeStockCode.php 2011-05-15 07:53:42 UTC (rev 4569)
@@ -1,53 +1,72 @@
<?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'])){
-
+
+ $InputError =0;
+
$_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;
+ $InputError =1;
}
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;
+ $InputError =1;
}
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;
+ $InputError =1;
}
/*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>';
+ 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;
+ $InputError =1;
}
-
- $result = DB_Txn_Begin($db);
-
- echo '<br>' . _('Adding the new stock master record');
- $sql = "INSERT INTO stockmaster (stockid,
+ if ($InputError ==0){ // no input errors
+ $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,
@@ -67,256 +86,238 @@
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');
+ 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 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 '<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 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 '<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');
+
+ //check if MRP tables exist before assuming
+
+ $result = DB_query("SELECT COUNT(*) FROM mrpplannedorders",$db);
+ if ($DB_error_no==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');
+ }
+
+ $result = DB_query("SELECT * FROM mrprequirements" , $db);
+ if (DB_error_no($db)==0){
+ 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');
+ }
+ $result = DB_query("SELECT * FROM mrpsupplies" , $db);
+ if (DB_error_no($db)==0){
+ 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'];
+ } //only do the stuff above if $InputError==0
+
}
-echo "<form action='" . $_SERVER['PHP_SELF'] . "?=" . $SID . "' method=post>";
+echo '<form action="' . $_SERVER['PHP_SELF'] . '" 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>";
+ <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 '<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 '<div class="centre"><input type="submit" name="ProcessStockChange" value="' . _('Process') . '"></div>';
echo '</form>';
Modified: trunk/build/make_release.sh
===================================================================
--- trunk/build/make_release.sh 2011-05-15 07:12:43 UTC (rev 4568)
+++ trunk/build/make_release.sh 2011-05-15 07:53:42 UTC (rev 4569)
@@ -69,7 +69,7 @@
echo "SET FOREIGN_KEY_CHECKS = 0;" > $BASE_DIR/sql/mysql/weberp-new.sql
-mysqldump -u$MYSQL_USER -p$MYSQL_PWD --skip-opt --create-options --skip-set-charset --no-data weberpdemo >> $BASE_DIR/sql/mysql/weberp-new.sql
+mysqldump -u$MYSQL_USER -p$MYSQL_PWD --skip-opt --create-options --skip-set-charset --ignore-table=weberpdemo.mrpsupplies --ignore-table=weberpdemo.mrpplanedorders --ignore-table=weberpdemo.mrpparameters --ignore-table=weberpdemo.levels --ignore-table=weberpdemo.mrprequirements --ignore-table=weberpdemo.audittrail --no-data weberpdemo >> $BASE_DIR/sql/mysql/weberp-new.sql
mysqldump -u$MYSQL_USER -p$MYSQL_PWD --skip-opt --skip-set-charset --quick --no-create-info weberpdemo \
accountgroups \
@@ -101,10 +101,10 @@
accountsection \
> $BASE_DIR/sql/mysql/weberp-base.sql
-mysqldump -u$MYSQL_USER -p$MYSQL_PWD --skip-opt --skip-set-charset --quick --no-create-info weberpdemo > $BASE_DIR/sql/mysql/weberp-demo_data.sql
+mysqldump -u$MYSQL_USER -p$MYSQL_PWD --skip-opt --skip-set-charset --quick --ignore-table=weberpdemo.mrpsupplies --ignore-table=weberpdemo.mrpplanedorders --ignore-table=weberpdemo.mrpparameters --ignore-table=weberpdemo.levels --ignore-table=weberpdemo.mrprequirements --no-create-info weberpdemo > $BASE_DIR/sql/mysql/weberp-demo_data.sql
rm $BASE_DIR/sql/mysql/weberp-demo.sql
-echo "CREATE DATABASE weberpdemo;" > $BASE_DIR/sql/mysql/weberp-demo.sql
+echo "CREATE DATABASE IF NOT EXISTS weberpdemo;" > $BASE_DIR/sql/mysql/weberp-demo.sql
echo "USE weberpdemo;" >> $BASE_DIR/sql/mysql/weberp-demo.sql
cat $BASE_DIR/sql/mysql/weberp-new.sql >> $BASE_DIR/sql/mysql/weberp-demo.sql
Modified: trunk/doc/Change.log
===================================================================
--- trunk/doc/Change.log 2011-05-15 07:12:43 UTC (rev 4568)
+++ trunk/doc/Change.log 2011-05-15 07:53:42 UTC (rev 4569)
@@ -1,6 +1,6 @@
webERP Change Log
-
+15/5/11 Z_ChangeStockCode.php modified to test if MRP tables exist before doing the updates
15/5/11 Tim: FixedAssetCategories prior to deletion of a category check for existing assets in the category failed due to typo in SQL - fixed
14/5/11 Tim: StockTransfer now checks for negative stock before allowing transfer - launchpad changes to 4691
14/5/11 CustomerInquiry.php now shows the currency decimal places
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|