From: <tim...@us...> - 2010-01-19 10:14:51
|
Revision: 3309 http://web-erp.svn.sourceforge.net/web-erp/?rev=3309&view=rev Author: tim_schofield Date: 2010-01-19 10:14:45 +0000 (Tue, 19 Jan 2010) Log Message: ----------- Missing gettext function for string Modified Paths: -------------- trunk/MRP.php trunk/doc/Change.log.html Modified: trunk/MRP.php =================================================================== --- trunk/MRP.php 2010-01-18 21:19:35 UTC (rev 3308) +++ trunk/MRP.php 2010-01-19 10:14:45 UTC (rev 3309) @@ -9,11 +9,11 @@ include('includes/header.inc'); if (isset($_POST['submit'])) { - + if (!$_POST['Leeway'] || !is_numeric($_POST['Leeway'])) { $_POST['Leeway'] = 0; } - + // MRP - Create levels table based on bom echo '</br>' ._('Start time') . ': ' . date('h:i:s') . '</br>'; echo '</br>' . _('Initialising tables .....') . '</br>'; @@ -23,15 +23,15 @@ $result = DB_query('DROP TABLE IF EXISTS passbom2',$db); $result = DB_query('DROP TABLE IF EXISTS bomlevels',$db); $result = DB_query('DROP TABLE IF EXISTS levels',$db); - + $sql = 'CREATE TEMPORARY TABLE passbom ( - part char(20), + part char(20), sortpart text)'; $ErrMsg = _('The SQL to to create passbom failed with the message'); $result = DB_query($sql,$db,$ErrMsg); - + $sql = 'CREATE TEMPORARY TABLE tempbom ( - parent char(20), + parent char(20), component char(20), sortpart text, level int)'; @@ -42,7 +42,7 @@ // Put those top level assemblies in passbom, use COMPONENT in passbom // to link to PARENT in bom to find next lower level and accumulate // those parts into tempbom - + prnMsg(_('Creating first level'),'info'); flush(); // This finds the top level @@ -52,8 +52,8 @@ FROM bom LEFT JOIN bom as bom2 ON bom.parent = bom2.component WHERE bom2.component IS NULL'; $result = DB_query($sql,$db); - - $lctr = 2; + + $lctr = 2; // $lctr is the level counter $sql = "INSERT INTO tempbom (parent, component, sortpart, level) SELECT bom.parent AS parent, bom.component AS component, @@ -77,46 +77,46 @@ $lctr as level FROM bom,passbom WHERE bom.parent = passbom.part"; $result = DB_query($sql,$db); - + $result = DB_query('DROP TABLE IF EXISTS passbom2',$db); $result = DB_query('ALTER TABLE passbom RENAME AS passbom2',$db); $result = DB_query('DROP TABLE IF EXISTS passbom',$db); - + $sql = 'CREATE TEMPORARY TABLE passbom ( - part char(20), + part char(20), sortpart text)'; $result = DB_query($sql,$db); - + $sql = "INSERT INTO passbom (part, sortpart) SELECT bom.component AS part, CONCAT(passbom2.sortpart,'%',bom.component) AS sortpart - FROM bom,passbom2 + FROM bom,passbom2 WHERE bom.parent = passbom2.part"; $result = DB_query($sql,$db); - - - $sql = 'SELECT COUNT(*) FROM bom + + + $sql = 'SELECT COUNT(*) FROM bom INNER JOIN passbom ON bom.parent = passbom.part GROUP BY bom.parent'; $result = DB_query($sql,$db); - + $myrow = DB_fetch_row($result); $compctr = $myrow[0]; - + } // End of while $compctr > 0 - + prnMsg(_('Creating bomlevels table'),'info'); flush(); $sql = 'CREATE TEMPORARY TABLE bomlevels ( - part char(20), + part char(20), level int)'; $result = DB_query($sql,$db); - + // Read tempbom and split sortpart into separate parts. For each separate part, calculate level as - // the sortpart level minus the position in the @parts array of the part. For example, the first + // the sortpart level minus the position in the @parts array of the part. For example, the first // part in the array for a level 4 sortpart would be created as a level 3 in levels, the fourth // and last part in sortpart would have a level code of zero, meaning it has no components - + $sql = 'SELECT * FROM tempbom'; $result = DB_query($sql,$db); while ($myrow=DB_fetch_array($result)) { @@ -128,15 +128,15 @@ $newlevel = $level - $ctr; $sql = "INSERT INTO bomlevels (part, level) VALUES('$part','$newlevel')"; $result2 = DB_query($sql,$db); - } // End of foreach + } // End of foreach } //end of while loop - + prnMsg(_('Creating levels table'),'info'); flush(); // Create levels from bomlevels using the highest level number found for a part $sql = 'CREATE TABLE levels ( - part char(20), + part char(20), level int, leadtime smallint(6) NOT NULL default "0", pansize double NOT NULL default "0", @@ -164,10 +164,10 @@ $result = DB_query($sql,$db); $sql = 'ALTER TABLE levels ADD INDEX part(part)'; $result = DB_query($sql,$db); - + // Create levels records with level of zero for all parts in stockmaster that // are not in bom - + $sql = 'INSERT INTO levels (part, level, leadtime, @@ -179,29 +179,29 @@ 0, stockmaster.pansize, stockmaster.shrinkfactor, - stockmaster.eoq - FROM stockmaster + stockmaster.eoq + FROM stockmaster LEFT JOIN levels ON stockmaster.stockid = levels.part WHERE levels.part IS NULL'; $result = DB_query($sql,$db); - + // Update leadtime in levels from purchdata. Do it twice so can make sure leadtime from preferred // vendor is used $sql = 'UPDATE levels,purchdata SET levels.leadtime = purchdata.leadtime - WHERE levels.part = purchdata.stockid + WHERE levels.part = purchdata.stockid AND purchdata.leadtime > 0'; $result = DB_query($sql,$db); $sql = 'UPDATE levels,purchdata SET levels.leadtime = purchdata.leadtime - WHERE levels.part = purchdata.stockid + WHERE levels.part = purchdata.stockid AND purchdata.preferred = 1 AND purchdata.leadtime > 0'; $result = DB_query($sql,$db); - + prnMsg(_('Levels table has been created'),'info'); flush(); - + // Get rid if temporary tables $sql = 'DROP TABLE IF EXISTS tempbom'; //$result = DB_query($sql,$db); @@ -211,7 +211,7 @@ //$result = DB_query($sql,$db); $sql = 'DROP TABLE IF EXISTS bomlevels'; //$result = DB_query($sql,$db); - + // In the following section, create mrprequirements from open sales orders and // mrpdemands prnMsg(_('Creating requirements table'),'info'); @@ -223,7 +223,7 @@ // CreateLowerLevelRequirement() function. Mostly do this so can distinguish the type // of requirements for the MRPShortageReport so don't show double requirements. $sql = 'CREATE TABLE mrprequirements ( - part char(20), + part char(20), daterequired date, quantity double, mrpdemandtype varchar(6), @@ -231,10 +231,10 @@ directdemand smallint, whererequired char(20))'; $result = DB_query($sql,$db,_('Create of mrprequirements failed because')); - + prnMsg(_('Loading requirements from sales orders'),'info'); flush(); - $sql = 'INSERT INTO mrprequirements + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, @@ -256,11 +256,11 @@ AND salesorders.quotation = 0'; $result = DB_query($sql,$db); - + prnMsg(_('Loading requirements from work orders'),'info'); - flush(); + flush(); // Definition of demand from SelectProduct.php - $sql = 'INSERT INTO mrprequirements + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, @@ -281,9 +281,9 @@ ON woitems.wo=workorders.wo AND woitems.wo=worequirements.wo WHERE workorders.closed=0'; - $result = DB_query($sql,$db); - - $sql = 'INSERT INTO mrprequirements + $result = DB_query($sql,$db); + + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, @@ -304,7 +304,7 @@ prnMsg(_('Loading requirements based on mrpdemands'),'info'); flush(); } - $sql = 'INSERT INTO mrprequirements + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, @@ -323,33 +323,33 @@ WHERE reorderlevel > quantity'; $result = DB_query($sql,$db); prnMsg(_('Loading requirements based on reorder level'),'info'); - flush(); - + flush(); + $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); - // updateflag is set to 1 in UpdateSupplies if change date when matching requirements to + // 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, - part char(20), + part char(20), duedate date, supplyquantity double, ordertype varchar(6), orderno int(11), mrpdate date, - updateflag smallint(6), + updateflag smallint(6), PRIMARY KEY (id))'; $result = DB_query($sql,$db,_('Create of mrpsupplies failed because')); - + prnMsg(_('Loading supplies from purchase orders'),'info'); flush(); - $sql = 'INSERT INTO mrpsupplies - (id, + $sql = 'INSERT INTO mrpsupplies + (id, part, duedate, supplyquantity, @@ -371,7 +371,7 @@ AND purchorders.status != "Cancelled" AND(quantityord - quantityrecd) > 0'; $result = DB_query($sql,$db); - + prnMsg(_('Loading supplies from inventory on hand'),'info'); flush(); // Set date for inventory already onhand to 0000-00-00 so it is first in sort @@ -409,14 +409,14 @@ "0000-00-00", 0 FROM locstock - WHERE quantity > 0 ' . + WHERE quantity > 0 ' . $whereloc . 'GROUP BY stockid'; $result = DB_query($sql,$db); - + prnMsg(_('Loading supplies from work orders'),'info'); flush(); - $sql = 'INSERT INTO mrpsupplies + $sql = 'INSERT INTO mrpsupplies (id, part, duedate, @@ -437,10 +437,10 @@ ON woitems.wo=workorders.wo WHERE workorders.closed=0'; $result = DB_query($sql,$db); - + $sql = 'ALTER TABLE mrpsupplies ADD INDEX part(part)'; $result = DB_query($sql,$db); - + // Create mrpplannedorders table to create a record for any unmet requirments // In the following section, create mrpsupplies from open purchase orders, // open work orders, and current quantity onhand from locstock @@ -449,33 +449,33 @@ $result = DB_query('DROP TABLE IF EXISTS mrpplannedorders',$db); $sql = 'CREATE TABLE mrpplannedorders ( id int(11) NOT NULL auto_increment, - part char(20), + part char(20), duedate date, supplyquantity double, ordertype varchar(6), orderno int(11), mrpdate date, - updateflag smallint(6), + updateflag smallint(6), PRIMARY KEY (id))'; $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'; $result = DB_query($sql,$db); - + $myrow = DB_fetch_row($result); $maxlevel = $myrow[0]; - $minlevel = $myrow[1]; - + $minlevel = $myrow[1]; + // At this point, have all requirements in mrprequirements and all supplies to satisfy // those requirements in mrpsupplies. Starting at the top level, will read all parts one // at a time, compare the requirements and supplies to see if have to re-schedule or create - // planned orders to satisfy requirements. If there is a net requirement from a higher level - // part, that serves as a gross requirement for a lower level part, so will read down through + // planned orders to satisfy requirements. If there is a net requirement from a higher level + // part, that serves as a gross requirement for a lower level part, so will read down through // the Bill of Materials to generate those requirements in function LevelNetting(). for ($level = $maxlevel; $level >= $minlevel; $level--) { $sql = 'SELECT * FROM levels WHERE level = ' . "$level " . ' LIMIT 50000'; //should cover most eventualities!! - + prnMsg('</br>------ ' . _('Processing level') .' ' . $level . ' ------','info'); flush(); $result = DB_query($sql,$db); @@ -489,7 +489,7 @@ $sql = 'DROP TABLE IF EXISTS mrpparameters'; $result = DB_query($sql,$db); $sql = 'CREATE TABLE mrpparameters ( - runtime datetime, + runtime datetime, location varchar(50), pansizeflag varchar(5), shrinkageflag varchar(5), @@ -522,21 +522,21 @@ '" . $_POST['usemrpdemands'] . "', '" . $_POST['Leeway'] . "')"; $result = DB_query($sql,$db); - -} else { // End of if submit isset + +} else { // End of if submit isset // Display form if submit has not been hit - + // Display parameters from last run $sql = 'SELECT * FROM mrpparameters'; $result = DB_query($sql,$db,'','',false,false); if (DB_error_no($db)==0){ - + $myrow = DB_fetch_array($result); - + $leeway = $myrow['leeway']; $usemrpdemands = _('No'); if ($myrow['usemrpdemands'] == 'y') { - $usemrpdemands = 'Yes'; + $usemrpdemands = _('Yes'); } $useeoq = _('No'); if ($myrow['eoqflag'] == 'y') { @@ -550,7 +550,7 @@ if ($myrow['shrinkageflag'] == 'y') { $useshrinkage = _('Yes'); } - + echo '<table><tr><td>     </td>'; echo '<td>' . _('Last Run Time') . ':  </td><td>' . $myrow['runtime'] . '</td></tr>'; echo '<td></td><td>' . _('Location') . ':  </td><td>' . $myrow['location'] . '</td></tr>'; @@ -579,7 +579,7 @@ if (!isset($leeway)){ $leeway =0; } - + echo '<tr><td>' . _('Days Leeway') . ':</td><td><input type="text" name="Leeway" size="4" value=' . $leeway . '>'; echo '<tr><td>' ._('Use MRP Demands?') . ':</td>'; echo '<td><input type="checkbox" name="usemrpdemands" value="y" checked></td></tr>'; @@ -600,13 +600,13 @@ // them seeing if all requirements are covered by supplies. Create a planned order // for any unmet requirements. Change dates if necessary for the supplies. //echo '</br>Part is ' . "$part" . '</br>'; - + // Get decimal places from stockmaster for rounding of shrinkage factor $sql = "SELECT decimalplaces FROM stockmaster WHERE stockid = '" . $part . "'"; $result = DB_query($sql,$db); $myrow=DB_fetch_row($result); $decimalplaces = $myrow[0]; - + // Load mrprequirements into $requirements array $sql = "SELECT * FROM mrprequirements WHERE part = '" . "$part" . "' ORDER BY daterequired"; $result = DB_query($sql,$db); @@ -630,7 +630,7 @@ // Go through all requirements and check if have supplies to cover them $requirementcount = count($requirements); $supplycount = count($supplies); - $reqi = 0; //Index for requirements + $reqi = 0; //Index for requirements $supi = 0; // index for supplies $totalrequirement = 0; $totalsupply = 0; @@ -646,10 +646,10 @@ $datediff = DateDiff($duedate,$reqdate,'d'); //if ($supplies[$supi]['duedate'] > $requirements[$reqi]['daterequired']) { if ($datediff > abs($_POST['Leeway'])) { - $sql = "UPDATE mrpsupplies SET mrpdate = '" . $requirements[$reqi]['daterequired'] . + $sql = "UPDATE mrpsupplies SET mrpdate = '" . $requirements[$reqi]['daterequired'] . "' WHERE id = '" . $supplies[$supi]['id'] . "' AND duedate = mrpdate"; $result = DB_query($sql,$db); - } + } if ($totalrequirement > $totalsupply) { $totalrequirement -= $totalsupply; @@ -669,10 +669,10 @@ if ($requirementcount > $reqi) { $totalrequirement += $requirements[$reqi]['quantity']; } - } // End of if $totalrequirement > $totalsupply + } // End of if $totalrequirement > $totalsupply } // End of while } // End of if - + // When get to this part of code, have gone through all requirements, If there is any // unmet requirements, create an mrpplannedorder to cover it. Also call the // CreateLowerLevelRequirement() function to create gross requirements for lower level parts. @@ -694,7 +694,7 @@ // Should the quantity be rounded? if ($_POST['shrinkageflag'] == 'y' and $shrinkfactor > 0) { $requirement['quantity'] = ($requirement['quantity'] * 100) / (100 - $shrinkfactor); - $requirement['quantity'] = round($requirement['quantity'],$decimalplaces); + $requirement['quantity'] = round($requirement['quantity'],$decimalplaces); } if ($excessqty >= $requirement['quantity']) { $plannedqty = 0; @@ -735,8 +735,8 @@ '0')"; $result = DB_query($sql,$db); // If part has lower level components, create requirements for them - $sql = "SELECT COUNT(*) FROM bom - WHERE parent ='" . $requirement['part'] . "' + $sql = "SELECT COUNT(*) FROM bom + WHERE parent ='" . $requirement['part'] . "' GROUP BY parent"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); @@ -747,10 +747,10 @@ } } // End of if $plannedqty > 0 } // End of foreach $requirements - + // If there are any supplies not used and updateflag is zero, those supplies are not // necessary, so change date - + foreach($supplies as $supply) { if ($supply['supplyquantity'] > 0 && $supply['updateflag'] == 0) { $id = $supply['id']; @@ -775,23 +775,23 @@ levels.leadtime, levels.eoq FROM bom - LEFT JOIN levels + LEFT JOIN levels ON bom.component = levels.part WHERE bom.parent = '$toppart' - AND effectiveafter <= now() + AND effectiveafter <= now() AND effectiveto >= now()"; $resultbom = DB_query($sql,$db); while ($myrow=DB_fetch_array($resultbom)) { // Calculate required date by subtracting leadtime from top part's required date $leadtime = $myrow['leadtime']; - - // Following sql finds daynumber for the top part's required date, subtracts leadtime, and finds + + // Following sql finds daynumber for the top part's required date, subtracts leadtime, and finds // a valid manufacturing date for the daynumber. There is only one valid manufacturing date - // for each daynumber, but there could be several non-manufacturing dates for the + // for each daynumber, but there could be several non-manufacturing dates for the // same daynumber. MRPCalendar.php maintains the manufacturing calendar. - $calendarsql = "SELECT COUNT(*),cal2.calendardate - FROM mrpcalendar - LEFT JOIN mrpcalendar as cal2 + $calendarsql = "SELECT COUNT(*),cal2.calendardate + FROM mrpcalendar + LEFT JOIN mrpcalendar as cal2 ON (mrpcalendar.daynumber - $leadtime) = cal2.daynumber WHERE mrpcalendar.calendardate = '$topdate' AND cal2.manufacturingflag='1' @@ -802,7 +802,7 @@ // If can't find date based on manufacturing calendar, use $topdate if ($myrowdate[0] == 0){ // Convert $topdate from mysql format to system date format, use that to subtract leadtime - // from it using DateAdd, convert that date back to mysql format + // from it using DateAdd, convert that date back to mysql format $convertdate = ConvertSQLDate($topdate); $dateadd = DateAdd($convertdate,"d",($leadtime * -1)); $newdate = FormatDateForSQL($dateadd); @@ -810,12 +810,12 @@ $component = $myrow['component']; $extendedquantity = $myrow['quantity'] * $topquantity; -// Commented out the following lines 8/15/09 because the eoq should be considered in the +// Commented out the following lines 8/15/09 because the eoq should be considered in the // LevelNetting() function where $excessqty is calculated // if ($myrow['eoq'] > $extendedquantity) { // $extendedquantity = $myrow['eoq']; // } - $sql = "INSERT INTO mrprequirements + $sql = "INSERT INTO mrprequirements (part, daterequired, quantity, Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-01-18 21:19:35 UTC (rev 3308) +++ trunk/doc/Change.log.html 2010-01-19 10:14:45 UTC (rev 3309) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>19/01/10 Tim: MRP.php - Missing gettext function for string</p> <p>18/01/10 Tim: MRPPlannedWorkOrders.php - Add default date and use the javascript date picker</p> <p>18/01/10 Tim: MRPPlannedPurchaseOrders.php - Add default date and use the javascript date picker</p> <p>17/01/10 Tim: index.php - Add entry for planned work orders</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |