From: <tim...@us...> - 2012-02-21 15:56:20
|
Revision: 4947 http://web-erp.svn.sourceforge.net/web-erp/?rev=4947&view=rev Author: tim_schofield Date: 2012-02-21 15:56:08 +0000 (Tue, 21 Feb 2012) Log Message: ----------- Move CopyBOM.php from utilities to the main menu Modified Paths: -------------- trunk/UpgradeDatabase.php trunk/includes/ConnectDB.inc trunk/includes/IndexArray.php trunk/sql/mysql/upgrade4.07-4.08.sql Added Paths: ----------- trunk/CopyBOM.php Removed Paths: ------------- trunk/Z_CopyBOM.php Copied: trunk/CopyBOM.php (from rev 4937, trunk/Z_CopyBOM.php) =================================================================== --- trunk/CopyBOM.php (rev 0) +++ trunk/CopyBOM.php 2012-02-21 15:56:08 UTC (rev 4947) @@ -0,0 +1,168 @@ +<?php +/** + * Author: Ashish Shukla <gmail.com!wahjava> + * + * Script to duplicate BoMs. + */ +/* $Id$*/ + +$title = _('Copy a BOM to New Item Code'); + +include('includes/session.inc'); + +include('includes/header.inc'); + +include('includes/SQL_CommonFunctions.inc'); + +if(isset($_POST['Submit'])) { + $stkid = $_POST['stkid']; + $type = $_POST['type']; + $newstkid = ''; + + if($type == 'N') { + $newstkid = $_POST['tostkid']; + } else { + $newstkid = $_POST['exstkid']; + } + + $result = DB_query("begin", $db); + + if($type == 'N') { + /* duplicate rows into stockmaster */ + $sql = "INSERT INTO stockmaster + SELECT '".$newstkid."' AS stockid, + categoryid, + description, + longdescription, + units, + mbflag, + lastcurcostdate, + actualcost, + lastcost, + materialcost, + labourcost, + overheadcost, + lowestlevel, + discontinued, + controlled, + eoq, + volume, + kgs, + barcode, + discountcategory, + taxcatid, + serialised, + appendfile, + perishable, + decimalplaces, + nextserialno, + pansize, + shrinkfactor, + netweight + FROM stockmaster + WHERE stockid='".$stkid."';"; + $result = DB_query($sql, $db); + } else { + $sql = "SELECT lastcurcostdate, + actualcost, + lastcost, + materialcost, + labourcost, + overheadcost, + lowestlevel + FROM stockmaster + WHERE stockid='".$stkid."';"; + $result = DB_query($sql, $db); + + $row = DB_fetch_row($result); + + $sql = "UPDATE stockmaster set + lastcurcostdate = '".$row[0]."', + actualcost = ".$row[1].", + lastcost = ".$row[2].", + materialcost = ".$row[3].", + labourcost = ".$row[4].", + overheadcost = ".$row[5].", + lowestlevel = ".$row[6]." + WHERE stockid='".$newstkid."';"; + $result = DB_query($sql, $db); + } + + $sql = "INSERT INTO bom + SELECT '".$newstkid."' AS parent, + component, + workcentreadded, + loccode, + effectiveafter, + effectiveto, + quantity, + autoissue + FROM bom + WHERE parent='".$stkid."';"; + $result = DB_query($sql, $db); + + if($type == 'N') { + $sql = "INSERT INTO locstock + SELECT loccode, + '".$newstkid."' AS stockid, + 0 AS quantity, + reorderlevel + FROM locstock + WHERE stockid='".$stkid."';"; + $result = DB_query($sql, $db); + } + + $result = DB_query('commit', $db); + + UpdateCost($db, $newstkid); + + header('Location: BOMs.php?Select='.$newstkid); +} else { + + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/inventory.png" title="' . _('Contract') . '" alt="" />' . ' ' . $title . '</p>'; + + echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + + $sql = "SELECT stockid, + description + FROM stockmaster + WHERE stockid IN (SELECT DISTINCT parent FROM bom) + AND mbflag IN ('M', 'A', 'K');"; + $result = DB_query($sql, $db); + + echo '<table class="selection"> + <tr> + <td>' . _('From Stock ID') . '</td>'; + echo '<td><select name="stkid">'; + while($row = DB_fetch_row($result)) { + echo '<option value="'.$row[0].'">'.$row[0].' -- '.$row[1].'</option>'; + } + echo '</select></td> + </tr>'; + echo '<tr> + <td><input type="radio" name="type" value="N" checked="" />' . _(' To New Stock ID') . '</td></td><td>'; + echo '<input type="text" maxlength="20" name="tostkid" /></td></tr>'; + + $sql = "SELECT stockid, + description + FROM stockmaster + WHERE stockid NOT IN (SELECT DISTINCT parent FROM bom) + AND mbflag IN ('M', 'A', 'K');"; + $result = DB_query($sql, $db); + + if (DB_num_rows($result) > 0) { + echo '<tr> + <td><input type="radio" name="type" value="E" />'._('To Existing Stock ID') . '</td><td>'; + echo '<select name="exstkid">'; + while($row = DB_fetch_row($result)) { + echo '<option value="'.$row[0].'">'.$row[0].' -- '.$row[1].'</option>'; + } + echo '</select>'; + } + echo '</table>'; + echo '<br /><div class="centre"><input type="submit" name="Submit" value="Submit" /></div></form>'; + + include('includes/footer.inc'); +} +?> \ No newline at end of file Modified: trunk/UpgradeDatabase.php =================================================================== --- trunk/UpgradeDatabase.php 2012-02-21 11:13:54 UTC (rev 4946) +++ trunk/UpgradeDatabase.php 2012-02-21 15:56:08 UTC (rev 4947) @@ -135,7 +135,8 @@ $SQLScripts[] = './sql/mysql/upgrade4.06-4.07.sql'; case '4.07.0': $SQLScripts[] = './sql/mysql/upgrade4.07-4.08.sql'; - case '4.08': + case '4.08.0': + $SQLScripts[] = './sql/mysql/upgrade4.07-4.08.sql'; break; } //end switch } Deleted: trunk/Z_CopyBOM.php =================================================================== --- trunk/Z_CopyBOM.php 2012-02-21 11:13:54 UTC (rev 4946) +++ trunk/Z_CopyBOM.php 2012-02-21 15:56:08 UTC (rev 4947) @@ -1,147 +0,0 @@ -<?php -/** - * Author: Ashish Shukla <gmail.com!wahjava> - * - * Script to duplicate BoMs. - */ -/* $Id$*/ - -include('includes/session.inc'); -include('includes/SQL_CommonFunctions.inc'); - -if(isset($_POST['Submit'])) { - $StkID = $_POST['StkID']; - $type = $_POST['type']; - $newStkID = ''; - - if($type == 'N') { - $newStkID = $_POST['toStkID']; - } else { - $newStkID = $_POST['exStkID']; - } - DB_Txn_Begin($db); - - if($type == 'N') { - /* duplicate rows into stockmaster */ - $sql = "INSERT INTO stockmaster - select '" . $newStkID . "' as stockid, - categoryid, - description, - longdescription, - units, - mbflag, - actualcost, - lastcost, - materialcost, - labourcost, - overheadcost, - lowestlevel, - discontinued, - controlled, - eoq, - volume, - kgs, - barcode, - discountcategory, - taxcatid, - serialised, - appendfile, - perishable, - decimalplaces - FROM stockmaster - WHERE stockid='".$StkID."';"; - $result = DB_query($sql, $db); - } - else - { - $sql = "SELECT actualcost, lastcost, materialcost, labourcost, overheadcost, lowestlevel - FROM stockmaster WHERE stockid='".$StkID."';"; - $result = DB_query($sql, $db); - - $row = DB_fetch_row($result); - - $sql = "UPDATE stockmaster SET - actualcost = ".$row[0].", - lastcost = ".$row[1].", - materialcost = ".$row[2].", - labourcost = ".$row[3].", - overheadcost = ".$row[4].", - lowestlevel = ".$row[5]." - WHERE stockid='".$newStkID."';"; - $result = DB_query($sql, $db); - } - - $sql = "INSERT INTO bom - SELECT '".$newStkID."' as parent, - component, - workcentreadded, - loccode, - effectiveafter, - effectiveto, - quantity, - autoissue - FROM bom - WHERE parent='".$StkID."';"; - $result = DB_query($sql, $db); - - if($type == 'N') - { - $sql = "INSERT INTO locstock - SELECT loccode, '".$newStkID."' as stockid,0 as quantity, - reorderlevel - FROM locstock - WHERE stockid='".$StkID."';"; - $result = DB_query($sql, $db); - } - - DB_Txn_Commit($db); - - UpdateCost($db, $newStkID); - - header('Location: BOMs.php?Select='.$newStkID); - } - - else - { - $title = _('UTILITY PAGE To Copy a BOM'); - include('includes/header.inc'); - - echo '<form method="post" action="Z_CopyBOM.php">'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - - $sql = "SELECT stockid, description FROM stockmaster WHERE stockid IN (SELECT DISTINCT parent FROM bom) AND mbflag IN ('M', 'A', 'K');"; - $result = DB_query($sql, $db); - - echo '<br /> - <br />' . _('From Stock ID') . ': <select name="StkID">'; - while($row = DB_fetch_row($result)) { - echo '<option value="' . $row[0] . '">' . $row[0]. ' -- ' . $row[1] . '</option>'; - } - echo '</select> - <br/> - <input type="radio" name="type" value="N" checked="" />' ._('To New Stock ID') .': - <input type="text" maxlength="20" name="toStkID" />'; - - $sql = "SELECT stockid, - description - FROM stockmaster - WHERE stockid NOT IN (SELECT DISTINCT parent FROM bom) - AND mbflag IN ('M', 'A', 'K');"; - $result = DB_query($sql, $db); - - if(DB_num_rows($result) > 0) { - echo '<br/> - <input type="radio" name="type" value="E" />' . _('To Existing Stock ID') . ': - <select name="exStkID">'; - while($row = DB_fetch_row($result)){ - echo '<option value="' . $row[0] .'">' . $row[0] . ' -- ' . $row[1] . '</option>'; - } - echo '</select>'; - } - - echo '<br /> - <input type="submit" name="Submit" value="' . _('Submit') . '" />'; - - include('includes/footer.inc'); -} -?> Modified: trunk/includes/ConnectDB.inc =================================================================== --- trunk/includes/ConnectDB.inc 2012-02-21 11:13:54 UTC (rev 4946) +++ trunk/includes/ConnectDB.inc 2012-02-21 15:56:08 UTC (rev 4947) @@ -4,7 +4,7 @@ * this value is saved in the $_SESSION['Versionumber'] when includes/GetConfig.php is run * if VersionNumber is < $Version then the DB update script is run */ -$Version='4.07.1'; //must update manually every time there is a DB change +$Version='4.08.1'; //must update manually every time there is a DB change require_once ($PathPrefix .'includes/MiscFunctions.php'); Modified: trunk/includes/IndexArray.php =================================================================== --- trunk/includes/IndexArray.php 2012-02-21 11:13:54 UTC (rev 4946) +++ trunk/includes/IndexArray.php 2012-02-21 15:56:08 UTC (rev 4947) @@ -303,6 +303,7 @@ $MenuItems['manuf']['Maintenance']['Caption'] = array (_('Work Centre'), _('Bills Of Material'), + _('Copy a Bill Of Materials Between Items'), _('Master Schedule'), _('Auto Create Master Schedule'), _('MRP Calculation') @@ -310,6 +311,7 @@ $MenuItems['manuf']['Maintenance']['URL'] = array ('/WorkCentres.php', '/BOMs.php', + '/CopyBOM.php', '/MRPDemands.php', '/MRPCreateDemands.php', '/MRP.php' Modified: trunk/sql/mysql/upgrade4.07-4.08.sql =================================================================== --- trunk/sql/mysql/upgrade4.07-4.08.sql 2012-02-21 11:13:54 UTC (rev 4946) +++ trunk/sql/mysql/upgrade4.07-4.08.sql 2012-02-21 15:56:08 UTC (rev 4947) @@ -4,4 +4,6 @@ INSERT INTO `scripts` (`script` ,`pagesecurity` ,`description`) VALUES ('reportwriter/admin/ReportCreator.php', '15', 'Report Writer'); INSERT INTO `scripts` (`script` ,`pagesecurity` ,`description`) VALUES ('RecurringSalesOrdersProcess.php', '1', 'Process Recurring Sales Orders'); -UPDATE config SET confvalue='4.08.0' WHERE confname='VersionNumber'; \ No newline at end of file +UPDATE `scripts` SET `script`='CopyBOM.php' WHERE `script`='Z_CopyBOM.php'; + +UPDATE config SET confvalue='4.08.1' WHERE confname='VersionNumber'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |