From: <tim...@us...> - 2012-05-21 16:56:07
|
Revision: 5375 http://web-erp.svn.sourceforge.net/web-erp/?rev=5375&view=rev Author: tim_schofield Date: 2012-05-21 16:56:00 +0000 (Mon, 21 May 2012) Log Message: ----------- Fix so that header entry remains while the items are being selected Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2012-05-19 23:55:14 UTC (rev 5374) +++ trunk/WorkOrderEntry.php 2012-05-21 16:56:00 UTC (rev 5375) @@ -12,16 +12,29 @@ </p>'; if (isset($_GET['ReqDate'])){ - $ReqDate = $_GET['ReqDate']; + $ReqDate = ConvertSQLDate($_GET['ReqDate']); } else { $ReqDate=Date('Y-m-d'); } + +if (isset($_GET['StartDate'])){ + $StartDate = ConvertSQLDate($_GET['StartDate']); +} else { + $StartDate=Date('Y-m-d'); +} + if (isset($_GET['loccode'])){ $LocCode = $_GET['loccode']; } else { $LocCode=$_SESSION['UserStockLocation']; } +foreach ($_POST as $key=>$value) { + if (substr($key, 0, 9)=='OutputQty' or substr($key, 0, 7)=='RecdQty') { + $_POST[$key] = filter_number_format($value); + } +} + // check for new or modify condition if (isset($_REQUEST['WO']) and $_REQUEST['WO']!=''){ // modify @@ -31,13 +44,14 @@ // new $_POST['WO'] = GetNextTransNo(40,$db); $sql = "INSERT INTO workorders (wo, - loccode, - requiredby, - startdate) - VALUES ('" . $_POST['WO'] . "', - '" . $LocCode . "', - '" . $ReqDate . "', - '" . Date('Y-m-d'). "')"; + loccode, + requiredby, + startdate) + VALUES ( + '" . $_POST['WO'] . "', + '" . $LocCode . "', + '" . $ReqDate . "', + '" . $StartDate. "')"; $InsWOResult = DB_query($sql,$db); } @@ -68,28 +82,30 @@ $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; if ($_POST['StockCat']=='All'){ - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.description " . LIKE . " '$SearchString' - AND stockmaster.discontinued=0 - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.description " . LIKE . " '$SearchString' + AND stockmaster.discontinued=0 + AND mbflag='M' + ORDER BY stockmaster.stockid"; } else { - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.discontinued=0 - AND stockmaster.description " . LIKE . " '" . $SearchString . "' - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.discontinued=0 + AND stockmaster.description " . LIKE . " '" . $SearchString . "' + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + AND mbflag='M' + ORDER BY stockmaster.stockid"; } } elseif (mb_strlen($_POST['StockCode'])>0){ @@ -98,55 +114,59 @@ $SearchString = '%' . $_POST['StockCode'] . '%'; if ($_POST['StockCat']=='All'){ - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' - AND stockmaster.discontinued=0 - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' + AND stockmaster.discontinued=0 + AND mbflag='M' + ORDER BY stockmaster.stockid"; } else { - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' - AND stockmaster.discontinued=0 - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' + AND stockmaster.discontinued=0 + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + AND mbflag='M' + ORDER BY stockmaster.stockid"; } } else { if ($_POST['StockCat']=='All'){ - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.discontinued=0 - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.discontinued=0 + AND mbflag='M' + ORDER BY stockmaster.stockid"; } else { - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.discontinued=0 - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.discontinued=0 + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + AND mbflag='M' + ORDER BY stockmaster.stockid"; } } - $SQL .= " LIMIT " . $_SESSION['DisplayRecordsMax']; + $SQL = $SQL . ' LIMIT ' . $_SESSION['DisplayRecordsMax']; $ErrMsg = _('There is a problem selecting the part records to display because'); $DbgMsg = _('The SQL used to get the part selection was'); @@ -168,16 +188,15 @@ } //end of if search if (isset($NewItem) AND isset($_POST['WO'])){ - - $InputError=false; - $CheckItemResult = DB_query("SELECT mbflag, - eoq, - controlled + $InputError=false; + $CheckItemResult = DB_query("SELECT mbflag, + eoq, + controlled FROM stockmaster WHERE stockid='" . $NewItem . "'", - $db); + $db); if (DB_num_rows($CheckItemResult)==1){ - $CheckItemRow = DB_fetch_array($CheckItemResult); + $CheckItemRow = DB_fetch_array($CheckItemResult); if ($CheckItemRow['controlled']==1 AND $_SESSION['DefineControlledOnWOEntry']==1){ //need to add serial nos or batches to determine quantity $EOQ = 0; } else { @@ -186,18 +205,18 @@ } $EOQ = $ReqQty; } - if ($CheckItemRow['mbflag']!='M'){ - prnMsg(_('The item selected cannot be added to a work order because it is not a manufactured item'),'warn'); - $InputError=true; - } + if ($CheckItemRow['mbflag']!='M'){ + prnMsg(_('The item selected cannot be added to a work order because it is not a manufactured item'),'warn'); + $InputError=true; + } } else { prnMsg(_('The item selected cannot be found in the database'),'error'); $InputError = true; } - $CheckItemResult = DB_query("SELECT stockid + $CheckItemResult = DB_query("SELECT stockid FROM woitems WHERE stockid='" . $NewItem . "' - AND wo='" .$_POST['WO'] . "'", + AND wo='" .$_POST['WO'] . "'", $db); if (DB_num_rows($CheckItemResult)==1){ prnMsg(_('This item is already on the work order and cannot be added again'),'warn'); @@ -207,63 +226,61 @@ if ($InputError==false){ $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*bom.quantity) AS cost - FROM stockmaster INNER JOIN bom - ON stockmaster.stockid=bom.component + FROM stockmaster + INNER JOIN bom + ON stockmaster.stockid=bom.component WHERE bom.parent='" . $NewItem . "' - AND bom.loccode='" . $_POST['StockLocation'] . "'", + AND bom.loccode='" . $_POST['StockLocation'] . "'", $db); - $CostRow = DB_fetch_row($CostResult); - if (is_null($CostRow[0]) OR $CostRow[0]==0){ - $Cost =0; - prnMsg(_('The cost of this item as accumulated from the sum of the component costs is nil. This could be because there is no bill of material set up ... you may wish to double check this'),'warn'); + $CostRow = DB_fetch_array($CostResult); + if (is_null($CostRow['cost']) OR $CostRow['cost']==0){ + $Cost =0; + prnMsg(_('The cost of this item as accumulated from the sum of the component costs is nil. This could be because there is no bill of material set up ... you may wish to double check this'),'warn'); } else { - $Cost = $CostRow[0]; + $Cost = $CostRow['cost']; } if (!isset($EOQ)){ $EOQ=1; } - + $Result = DB_Txn_Begin($db); - + // insert parent item info $sql = "INSERT INTO woitems (wo, stockid, qtyreqd, stdcost) - VALUES ( '" . $_POST['WO'] . "', - '" . $NewItem . "', - '" . $EOQ . "', - '" . $Cost . "' - )"; + VALUES ( + '" . $_POST['WO'] . "', + '" . $NewItem . "', + '" . $EOQ . "', + '" . $Cost . "' + )"; $ErrMsg = _('The work order item could not be added'); $result = DB_query($sql,$db,$ErrMsg); - + //Recursively insert real component requirements - see includes/SQL_CommonFunctions.in for function WoRealRequirements WoRealRequirements($db, $_POST['WO'], $_POST['StockLocation'], $NewItem); - + $result = DB_Txn_Commit($db); - + unset($NewItem); } //end if there were no input errors } //adding a new item to the work order -if (isset($_POST['submit'])) { //The update button has been clicked +if (isset($_POST['submit']) or isset($_POST['Search'])) { //The update button has been clicked - echo '<div class="centre"> - <a href="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') .'">' . _('Enter a new work order') . '</a> - <br /> - <a href="' . $rootpath . '/SelectWorkOrder.php">' . _('Select an existing work order') . '</a> - <br /> - <a href="'. $rootpath . '/WorkOrderCosting.php?WO=' . $_REQUEST['WO'] . '">' . _('Go to Costing'). '</a> - </div>'; + echo '<div class="centre"><a href="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') .'">' . _('Enter a new work order') . '</a>'; + echo '<br /><a href="' . $rootpath . '/SelectWorkOrder.php">' . _('Select an existing work order') . '</a>'; + echo '<br /><a href="'. $rootpath . '/WorkOrderCosting.php?WO=' . $_REQUEST['WO'] . '">' . _('Go to Costing'). '</a></div>'; $Input_Error = false; //hope for the best for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ - if (!is_numeric(filter_number_format($_POST['OutputQty'.$i]))){ + if (!is_numeric($_POST['OutputQty'.$i])){ prnMsg(_('The quantity entered must be numeric'),'error'); $Input_Error = true; - } elseif (filter_number_format($_POST['OutputQty'.$i])<=0){ + } elseif ($_POST['OutputQty'.$i]<=0){ prnMsg(_('The quantity entered must be a positive number greater than zero'),'error'); $Input_Error = true; } @@ -279,7 +296,7 @@ $QtyRecd=0; for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ - $QtyRecd += filter_number_format($_POST['RecdQty'.$i]); + $QtyRecd+=$_POST['RecdQty'.$i]; } unset($sql); @@ -287,46 +304,47 @@ $sql[] = "UPDATE workorders SET requiredby='" . $SQL_ReqDate . "', startdate='" . FormatDateForSQL($_POST['StartDate']) . "', loccode='" . $_POST['StockLocation'] . "' - WHERE wo='" . $_POST['WO'] . "'"; + WHERE wo='" . $_POST['WO'] . "'"; } else { prnMsg(_('The factory where this work order is made can only be updated if the quantity received on all output items is 0'),'warn'); $sql[] = "UPDATE workorders SET requiredby='" . $SQL_ReqDate . "', startdate='" . FormatDateForSQL($_POST['StartDate']) . "' - WHERE wo='" . $_POST['WO'] . "'"; + WHERE wo='" . $_POST['WO'] . "'"; } for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ if (!isset($_POST['NextLotSNRef'.$i])) { $_POST['NextLotSNRef'.$i]=''; } - if (isset($_POST['QtyRecd'.$i]) AND $_POST['QtyRecd'.$i]>filter_number_format($_POST['OutputQty'.$i])){ + if (isset($_POST['QtyRecd'.$i]) and $_POST['QtyRecd'.$i]>$_POST['OutputQty'.$i]){ $_POST['OutputQty'.$i]=$_POST['QtyRecd'.$i]; //OutputQty must be >= Qty already reced } - if ($_POST['RecdQty'.$i]==0 AND (!isset($_POST['HasWOSerialNos'.$i]) OR $_POST['HasWOSerialNos'.$i]==false)){ + if ($_POST['RecdQty'.$i]==0 AND (!isset($_POST['HasWOSerialNos'.$i]) or $_POST['HasWOSerialNos'.$i]==false)){ /* can only change location cost if QtyRecd=0 */ $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*bom.quantity) AS cost - FROM stockmaster INNER JOIN bom - ON stockmaster.stockid=bom.component - WHERE bom.parent='" . $_POST['OutputItem'.$i] . "' - AND bom.loccode='" . $_POST['StockLocation'] . "'", + FROM stockmaster + INNER JOIN bom + ON stockmaster.stockid=bom.component + WHERE bom.parent='" . $_POST['OutputItem'.$i] . "' + AND bom.loccode='" . $_POST['StockLocation'] . "'", $db); - $CostRow = DB_fetch_row($CostResult); - if (is_null($CostRow[0])){ + $CostRow = DB_fetch_array($CostResult); + if (is_null($CostRow['cost'])){ $Cost =0; prnMsg(_('The cost of this item as accumulated from the sum of the component costs is nil. This could be because there is no bill of material set up ... you may wish to double check this'),'warn'); } else { - $Cost = $CostRow[0]; + $Cost = $CostRow['cost']; } - $sql[] = "UPDATE woitems SET qtyreqd = '". filter_number_format($_POST['OutputQty' . $i]) . "', - nextlotsnref = '". $_POST['NextLotSNRef'.$i] ."', - stdcost ='" . $Cost . "' - WHERE wo='" . $_POST['WO'] . "' - AND stockid='" . $_POST['OutputItem'.$i] . "'"; + $sql[] = "UPDATE woitems SET qtyreqd = '". $_POST['OutputQty' . $i] . "', + nextlotsnref = '". $_POST['NextLotSNRef'.$i] ."', + stdcost ='" . $Cost . "' + WHERE wo='" . $_POST['WO'] . "' + AND stockid='" . $_POST['OutputItem'.$i] . "'"; } elseif (isset($_POST['HasWOSerialNos'.$i]) and $_POST['HasWOSerialNos'.$i]==false) { - $sql[] = "UPDATE woitems SET qtyreqd = '". filter_number_format($_POST['OutputQty' . $i]) . "', - nextlotsnref = '". $_POST['NextLotSNRef'.$i] ."' - WHERE wo='" . $_POST['WO'] . "' - AND stockid='" . $_POST['OutputItem'.$i] . "'"; + $sql[] = "UPDATE woitems SET qtyreqd = '". $_POST['OutputQty' . $i] . "', + nextlotsnref = '". $_POST['NextLotSNRef'.$i] ."' + WHERE wo='" . $_POST['WO'] . "' + AND stockid='" . $_POST['OutputItem'.$i] . "'"; } } @@ -335,16 +353,18 @@ foreach ($sql as $sql_stmt){ // echo '<br />' . $sql_stmt; $result = DB_query($sql_stmt,$db,$ErrMsg); + } + if (!isset($_POST['Search'])) { + prnMsg(_('The work order has been updated'),'success'); + } - prnMsg(_('The work order has been updated'),'success'); - for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ - unset($_POST['OutputItem'.$i]); - unset($_POST['OutputQty'.$i]); - unset($_POST['QtyRecd'.$i]); - unset($_POST['NetLotSNRef'.$i]); - unset($_POST['HasWOSerialNos'.$i]); + unset($_POST['OutputItem'.$i]); + unset($_POST['OutputQty'.$i]); + unset($_POST['QtyRecd'.$i]); + unset($_POST['NetLotSNRef'.$i]); + unset($_POST['HasWOSerialNos'.$i]); } } } elseif (isset($_POST['delete'])) { @@ -353,9 +373,10 @@ $CancelDelete=false; //always assume the best // can't delete it there are open work issues - $HasTransResult = DB_query("SELECT * FROM stockmoves - WHERE (stockmoves.type= 26 OR stockmoves.type=28) - AND reference " . LIKE . " '%" . $_POST['WO'] . "%'",$db); + $HasTransResult = DB_query("SELECT transno + FROM stockmoves + WHERE (stockmoves.type= 26 OR stockmoves.type=28) + AND reference " . LIKE . " '%" . $_POST['WO'] . "%'",$db); if (DB_num_rows($HasTransResult)>0){ prnMsg(_('This work order cannot be deleted because it has issues or receipts related to it'),'error'); $CancelDelete=true; @@ -363,8 +384,8 @@ if ($CancelDelete==false) { //ie all tests proved ok to delete DB_Txn_Begin($db); - $ErrMsg = _('Unable to delete the work order because'); - $DbgMsg = _('The SQL that failed to delete the work order was'); + $ErrMsg = _('The work order could not be deleted'); + $DbgMsg = _('The SQL used to delete the work order was'); //delete the worequirements $sql = "DELETE FROM worequirements WHERE wo='" . $_POST['WO'] . "'"; $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); @@ -381,27 +402,25 @@ $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); DB_Txn_Commit($db); - prnMsg(_('The work order has been deleted'),'success'); + prnMsg(_('The work order has been cancelled'),'success'); echo '<p><a href="' . $rootpath . '/SelectWorkOrder.php">' . _('Select an existing outstanding work order') . '</a></p>'; unset($_POST['WO']); for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ - unset($_POST['OutputItem'.$i]); - unset($_POST['OutputQty'.$i]); - unset($_POST['QtyRecd'.$i]); - unset($_POST['NetLotSNRef'.$i]); - unset($_POST['HasWOSerialNos'.$i]); + unset($_POST['OutputItem'.$i]); + unset($_POST['OutputQty'.$i]); + unset($_POST['QtyRecd'.$i]); + unset($_POST['NetLotSNRef'.$i]); + unset($_POST['HasWOSerialNos'.$i]); } include('includes/footer.inc'); exit; } } -echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">'; -echo '<div>'; +echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" name="form1">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; -echo '<input type="hidden" name="WO" value="' .$_POST['WO'] . '" />'; echo '<br /><table class="selection">'; @@ -410,12 +429,14 @@ startdate, costissued, closed - FROM workorders INNER JOIN locations - ON workorders.loccode=locations.loccode + FROM workorders + INNER JOIN locations + ON workorders.loccode=locations.loccode WHERE workorders.wo='" . $_POST['WO'] . "'"; $WOResult = DB_query($sql,$db); if (DB_num_rows($WOResult)==1){ + $myrow = DB_fetch_array($WOResult); $_POST['StartDate'] = ConvertSQLDate($myrow['startdate']); $_POST['CostIssued'] = $myrow['costissued']; @@ -423,18 +444,19 @@ $_POST['RequiredBy'] = ConvertSQLDate($myrow['requiredby']); $_POST['StockLocation'] = $myrow['loccode']; $ErrMsg =_('Could not get the work order items'); - $WOItemsResult = DB_query("SELECT woitems.stockid, - stockmaster.description, - qtyreqd, - qtyrecd, - stdcost, - nextlotsnref, - controlled, - serialised, - nextserialno, - decimalplaces - FROM woitems INNER JOIN stockmaster - ON woitems.stockid=stockmaster.stockid + $WOItemsResult = DB_query("SELECT woitems.stockid, + stockmaster.description, + qtyreqd, + qtyrecd, + stdcost, + nextlotsnref, + controlled, + serialised, + stockmaster.decimalplaces, + nextserialno + FROM woitems + INNER JOIN stockmaster + ON woitems.stockid=stockmaster.stockid WHERE wo='" .$_POST['WO'] . "'",$db,$ErrMsg); $NumberOfOutputs=DB_num_rows($WOItemsResult); @@ -452,7 +474,7 @@ } $_POST['Controlled'.$i] =$WOItem['controlled']; $_POST['Serialised'.$i] =$WOItem['serialised']; - $HasWOSerialNosResult = DB_query("SELECT * FROM woserialnos WHERE wo='" . $_POST['WO'] . "'",$db); + $HasWOSerialNosResult = DB_query("SELECT wo FROM woserialnos WHERE wo='" . $_POST['WO'] . "'",$db); if (DB_num_rows($HasWOSerialNosResult)>0){ $_POST['HasWOSerialNos']=true; } else { @@ -462,30 +484,26 @@ } } -echo '<tr> - <td class="label">' . _('Work Order Reference') . ':</td> - <td>' . $_POST['WO'] . '</td> - </tr>'; -echo '<tr> - <td class="label">' . _('Factory Location') .':</td> - <td><select name="StockLocation" onchange="ReloadForm(form1.submit)">'; +echo '<input type="hidden" name="WO" value="' .$_POST['WO'] . '" />'; +echo '<tr><td class="label">' . _('Work Order Reference') . ':</td><td>' . $_POST['WO'] . '</td></tr>'; +echo '<tr><td class="label">' . _('Factory Location') .':</td> + <td><select name="StockLocation" onChange="ReloadForm(form1.submit)">'; $LocResult = DB_query("SELECT loccode,locationname FROM locations",$db); while ($LocRow = DB_fetch_array($LocResult)){ if ($_POST['StockLocation']==$LocRow['loccode']){ - echo '<option selected="selected" value="' . $LocRow['loccode'] .'">' . $LocRow['locationname'] . '</option>'; + echo '<option selected="True" value="' . $LocRow['loccode'] .'">' . $LocRow['locationname'] . '</option>'; } else { echo '<option value="' . $LocRow['loccode'] .'">' . $LocRow['locationname'] . '</option>'; } } -echo '</select></td> - </tr>'; +echo '</select></td></tr>'; if (!isset($_POST['StartDate'])){ $_POST['StartDate'] = Date($_SESSION['DefaultDateFormat']); } echo '<tr> <td class="label">' . _('Start Date') . ':</td> - <td><input type="text" name="StartDate" size="12" maxlength="12" value="' . $_POST['StartDate'] . '" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" /></td> + <td><input type="text" name="StartDate" size="12" maxlength="12" value="' . $_POST['StartDate'] .'" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" /></td> </tr>'; if (!isset($_POST['RequiredBy'])){ @@ -494,25 +512,21 @@ echo '<tr> <td class="label">' . _('Required By') . ':</td> - <td><input type="text" name="RequiredBy" size="12" maxlength="12" value="' . $_POST['RequiredBy'] . '" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" /></td> + <td><input type="text" name="RequiredBy" size="12" maxlength="12" value="' . $_POST['RequiredBy'] .'" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" /></td> </tr>'; if (isset($WOResult)){ - echo '<tr> - <td class="label">' . _('Accumulated Costs') . ':</td> - <td class="number">' . locale_number_format($myrow['costissued'],$_SESSION['CompanyRecord']['decimalplaces']) . '</td> - </tr>'; + echo '<tr><td class="label">' . _('Accumulated Costs') . ':</td> + <td class="number">' . locale_number_format($myrow['costissued'],$_SESSION['CompanyRecord']['decimalplaces']) . '</td></tr>'; } echo '</table> <br /><table class="selection">'; -echo '<tr> - <th>' . _('Output Item') . '</th> - <th>' . _('Qty Required') . '</th> - <th>' . _('Qty Received') . '</th> - <th>' . _('Balance Remaining') . '</th> - <th>' . _('Next Lot/SN Ref') . '</th> - <th> </th> - </tr>'; +echo '<tr><th>' . _('Output Item') . '</th> + <th>' . _('Qty Required') . '</th> + <th>' . _('Qty Received') . '</th> + <th>' . _('Balance Remaining') . '</th> + <th>' . _('Next Lot/SN Ref') . '</th> + </tr>'; $j=0; if (isset($NumberOfOutputs)){ @@ -524,15 +538,16 @@ echo '<tr class="EvenTableRows">'; $j++; } - echo '<td><input type="hidden" name="OutputItem' . $i . '" value="' . $_POST['OutputItem' .$i] . '" />' . $_POST['OutputItem' . $i] . ' - ' . $_POST['OutputItemDesc' .$i] . '</td>'; + echo '<td><input type="hidden" name="OutputItem' . $i . '" value="' . $_POST['OutputItem' .$i] . '" />' . + $_POST['OutputItem' . $i] . ' - ' . $_POST['OutputItemDesc' .$i] . '</td>'; if ($_POST['Controlled'.$i]==1 AND $_SESSION['DefineControlledOnWOEntry']==1){ - echo '<td class="number">' . locale_number_format($_POST['OutputQty' . $i],$_POST['DecimalPlaces' . $i]); - echo '<input type="hidden" name="OutputQty' . $i .'" value="' . locale_number_format($_POST['OutputQty' . $i],$_POST['DecimalPlaces' . $i]) . '" /></td>'; + echo '<td class="number">' . locale_number_format($_POST['OutputQty' . $i], $_POST['DecimalPlaces' . $i]) . '</td>'; + echo '<input type="hidden" name="OutputQty' . $i .'" value="' . locale_number_format($_POST['OutputQty' . $i]-$_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" />'; } else { - echo'<td><input type="text" class="number" name="OutputQty' . $i . '" value="' . locale_number_format($_POST['OutputQty' . $i],$_POST['DecimalPlaces' . $i]) . '" size="10" maxlength="10" /></td>'; + echo'<td><input type="text" class="number" name="OutputQty' . $i . '" value="' . locale_number_format($_POST['OutputQty' . $i]-$_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" size="10" maxlength="10" /></td>'; } - echo '<td class="number"><input type="hidden" name="RecdQty' . $i . '" value="' . $_POST['RecdQty' .$i] . '" />' . $_POST['RecdQty' .$i] .'</td> - <td class="number">' . locale_number_format(($_POST['OutputQty' . $i] - $_POST['RecdQty' .$i]),$_POST['DecimalPlaces' . $i]) . '</td>'; + echo '<td class="number"><input type="hidden" name="RecdQty' . $i . '" value="' . locale_number_format($_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" />' . locale_number_format($_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) .'</td> + <td class="number">' . locale_number_format(($_POST['OutputQty' . $i] - $_POST['RecdQty' .$i]), $_POST['DecimalPlaces' . $i]) . '</td>'; if ($_POST['Controlled'.$i]==1){ echo '<td><input type="text" name="NextLotSNRef' .$i . '" value="' . $_POST['NextLotSNRef'.$i] . '" /></td>'; if ($_SESSION['DefineControlledOnWOEntry']==1){ @@ -541,11 +556,13 @@ } else { $LotOrSN = _('Batches'); } - echo '<td><a href="' . $rootpath . '/WOSerialNos.php?WO=' . $_POST['WO'] . '&StockID=' . $_POST['OutputItem' .$i] . '&Description=' . $_POST['OutputItemDesc' .$i] . '&Serialised=' . $_POST['Serialised' .$i] . '&NextSerialNo=' . $_POST['NextLotSNRef' .$i] . '">' . $LotOrSN . '</a></td>'; + echo '<td><a href="' . $rootpath . '/WOSerialNos.php?WO=' . $_POST['WO'] . '&StockID=' . $_POST['OutputItem' .$i] . '&Description=' . $_POST['OutputItemDesc' .$i] . '&Serialised=' . $_POST['Serialised' .$i] . '&NextSerialNo=' . $_POST['NextLotSNRef' .$i] . '">' . $LotOrSN . '</a></td>'; } } echo '<td>'; wikiLink('WorkOrder', $_POST['WO'] . $_POST['OutputItem' .$i]); + echo '</td>'; + echo '</tr>'; if (isset($_POST['Controlled' . $i])) { echo '<input type="hidden" name="Controlled' . $i .'" value="' . $_POST['Controlled' . $i] . '" />'; } @@ -555,22 +572,17 @@ if (isset($_POST['HasWOSerialNos' . $i])) { echo '<input type="hidden" name="HasWOSerialNos' . $i .'" value="' . $_POST['HasWOSerialNos' . $i] . '" />'; } - echo '</td> - </tr>'; } - echo '<tr><td><input type="hidden" name="NumberOfOutputs" value="' . ($i -1).'" /></td></tr>'; + echo '<input type="hidden" name="NumberOfOutputs" value="' . ($i -1).'" />'; } echo '</table>'; -echo '<div class="centre"> - <br /> - <input type="submit" name="submit" value="' . _('Update') . '" /> - <br /> - <br /> - <input type="submit" name="delete" value="' . _('Delete This Work Order') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');" /> - <br /> - </div>'; +echo '<br /><div class="centre"><button type="submit" name="submit">' . _('Update') . '</button></div>'; +echo '<br /><div class="centre"><button type="submit" name="delete" onclick="return confirm(\'' . _('Are You Sure?') . '\');">' . _('Cancel This Work Order') . '</button>'; + +echo '</div><br />'; + $SQL="SELECT categoryid, categorydescription FROM stockcategory @@ -578,12 +590,10 @@ ORDER BY categorydescription"; $result1 = DB_query($SQL,$db); -echo '<table class="selection"> - <tr> - <td>' . _('Select a stock category') . ':<select name="StockCat">'; +echo '<table class="selection"><tr><td>' . _('Select a stock category') . ':<select name="StockCat">'; if (!isset($_POST['StockCat'])){ - echo '<option selected="selected" value="All">' . _('All') . '</option>'; + echo '<option selected="True" value="All">' . _('All') . '</option>'; $_POST['StockCat'] ='All'; } else { echo '<option value="All">' . _('All') . '</option>'; @@ -592,40 +602,38 @@ while ($myrow1 = DB_fetch_array($result1)) { if ($_POST['StockCat']==$myrow1['categoryid']){ - echo '<option selected="selected" value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; + echo '<option selected="True" value=' . $myrow1['categoryid'] . '>' . $myrow1['categorydescription'] . '</option>'; } else { - echo '<option value="'. $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; + echo '<option value='. $myrow1['categoryid'] . '>' . $myrow1['categorydescription'] . '</option>'; } } -?> -</select></td> -<td><?php echo _('Enter text extracts in the'); ?> <b><?php echo _('description'); ?></b>:</td> -<td><input type="text" name="Keywords" size="20" maxlength="25" value="<?php if (isset($_POST['Keywords'])) echo $_POST['Keywords']; ?>" /></td> -</tr> -<tr><td></td> - <td><b><?php echo _('OR'); ?> </b><?php echo _('Enter extract of the'); ?> <b><?php echo _('Stock Code'); ?></b>:</td> - <td><input type="text" name="StockCode" size="15" maxlength="18" value="<?php if (isset($_POST['StockCode'])) echo $_POST['StockCode']; ?>" /></td> -</tr> -</table> -<br /><div class="centre"><input type="submit" name="Search" value="<?php echo _('Search Now'); ?>" /> +if (!isset($_POST['Keywords'])) { + $_POST['Keywords']=''; +} -<?php +if (!isset($_POST['StockCode'])) { + $_POST['StockCode']=''; +} -echo '</div>'; +echo '</select> + <td>' . _('Enter text extracts in the') . ' <b>' . _('description') . '</b>:</td> + <td><input type="text" name="Keywords" size="20" maxlength="25" value="' . $_POST['Keywords'] . '" /></td></tr> + <tr><td> </td> + <td><font size="3"><b>' . _('OR') . ' </b></font>' . _('Enter extract of the') . ' <b>' . _('Stock Code') . '</b>:</td> + <td><input type="text" name="StockCode" size="15" maxlength="18" value="' . $_POST['StockCode'] . '" /></td> + </tr> + </table> + <br /><div class="centre"><button type="submit" name="Search">' . _('Search Now') . '</button></div>'; if (isset($SearchResult)) { if (DB_num_rows($SearchResult)>1){ - echo '<table cellpadding="2" class="selection">'; - $TableHeader = '<tr> - <th>' . _('Code') . '</th> + echo '<br /><table cellpadding="2" class="selection">'; + $TableHeader = '<tr><th>' . _('Code') . '</th> <th>' . _('Description') . '</th> - <th>' . _('Units') . '</th> - <th> </th> - <th> </th> - </tr>'; + <th>' . _('Units') . '</th></tr>'; echo $TableHeader; $j = 1; $k=0; //row colour counter @@ -638,10 +646,10 @@ if (!in_array($myrow['stockid'],$ItemCodes)){ if (function_exists('imagecreatefrompng') ){ - $ImageSource = '<img src="GetStockImage.php?automake=1&textcolor=FFFFFF&bgcolor=CCCCCC&StockID=' . urlencode($myrow['stockid']). '&text=&width=64&height=64" alt="" />'; + $ImageSource = '<img src="GetStockImage.php?automake=1&textcolor=FFFFFF&bgcolor=CCCCCC&StockID=' . urlencode($myrow['stockid']). '&text=&width=64&height=64" />'; } else { if(file_exists($_SERVER['DOCUMENT_ROOT'] . $rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg')) { - $ImageSource = '<img src="' .$_SERVER['DOCUMENT_ROOT'] . $rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg" alt="" />'; + $ImageSource = '<img src="' .$_SERVER['DOCUMENT_ROOT'] . $rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg" />'; } else { $ImageSource = _('No Image'); } @@ -655,17 +663,18 @@ $k=1; } - printf('<td>%s</td> + printf('<td><font size="1">%s</font></td> + <td><font size="1">%s</font></td> + <td><font size="1">%s</font></td> <td>%s</td> - <td>%s</td> - <td>%s</td> - <td><a href="%s">' . _('Add to Work Order') . '</a></td> + <td><font size="1"><a href="%s">' + . _('Add to Work Order') . '</a></font></td> </tr>', $myrow['stockid'], $myrow['description'], $myrow['units'], $ImageSource, - htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?WO=' . $_POST['WO'] . '&NewItem=' . $myrow['stockid'].'&Line='.$i); + htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?WO=' . $_POST['WO'] . '&NewItem=' . $myrow['stockid'].'&Line='.$i); $j++; If ($j == 25){ @@ -681,12 +690,11 @@ if (!isset($_GET['NewItem']) or $_GET['NewItem']=='') { - echo '<script type="text/javascript">defaultControl(document.forms[0].StockCode);</script>'; + echo '<script>defaultControl(document.forms[0].StockCode);</script>'; } else { - echo '<script type="text/javascript">defaultControl(document.forms[0].OutputQty"'.$_GET['Line'].'");</script>'; + echo '<script>defaultControl(document.forms[0].OutputQty"'.$_GET['Line'].'");</script>'; } -echo '</div> - </form>'; +echo '</form>'; include('includes/footer.inc'); ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2012-05-21 16:56:11
|
Revision: 5375 http://web-erp.svn.sourceforge.net/web-erp/?rev=5375&view=rev Author: tim_schofield Date: 2012-05-21 16:56:00 +0000 (Mon, 21 May 2012) Log Message: ----------- Fix so that header entry remains while the items are being selected Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2012-05-19 23:55:14 UTC (rev 5374) +++ trunk/WorkOrderEntry.php 2012-05-21 16:56:00 UTC (rev 5375) @@ -12,16 +12,29 @@ </p>'; if (isset($_GET['ReqDate'])){ - $ReqDate = $_GET['ReqDate']; + $ReqDate = ConvertSQLDate($_GET['ReqDate']); } else { $ReqDate=Date('Y-m-d'); } + +if (isset($_GET['StartDate'])){ + $StartDate = ConvertSQLDate($_GET['StartDate']); +} else { + $StartDate=Date('Y-m-d'); +} + if (isset($_GET['loccode'])){ $LocCode = $_GET['loccode']; } else { $LocCode=$_SESSION['UserStockLocation']; } +foreach ($_POST as $key=>$value) { + if (substr($key, 0, 9)=='OutputQty' or substr($key, 0, 7)=='RecdQty') { + $_POST[$key] = filter_number_format($value); + } +} + // check for new or modify condition if (isset($_REQUEST['WO']) and $_REQUEST['WO']!=''){ // modify @@ -31,13 +44,14 @@ // new $_POST['WO'] = GetNextTransNo(40,$db); $sql = "INSERT INTO workorders (wo, - loccode, - requiredby, - startdate) - VALUES ('" . $_POST['WO'] . "', - '" . $LocCode . "', - '" . $ReqDate . "', - '" . Date('Y-m-d'). "')"; + loccode, + requiredby, + startdate) + VALUES ( + '" . $_POST['WO'] . "', + '" . $LocCode . "', + '" . $ReqDate . "', + '" . $StartDate. "')"; $InsWOResult = DB_query($sql,$db); } @@ -68,28 +82,30 @@ $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; if ($_POST['StockCat']=='All'){ - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.description " . LIKE . " '$SearchString' - AND stockmaster.discontinued=0 - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.description " . LIKE . " '$SearchString' + AND stockmaster.discontinued=0 + AND mbflag='M' + ORDER BY stockmaster.stockid"; } else { - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.discontinued=0 - AND stockmaster.description " . LIKE . " '" . $SearchString . "' - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.discontinued=0 + AND stockmaster.description " . LIKE . " '" . $SearchString . "' + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + AND mbflag='M' + ORDER BY stockmaster.stockid"; } } elseif (mb_strlen($_POST['StockCode'])>0){ @@ -98,55 +114,59 @@ $SearchString = '%' . $_POST['StockCode'] . '%'; if ($_POST['StockCat']=='All'){ - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' - AND stockmaster.discontinued=0 - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' + AND stockmaster.discontinued=0 + AND mbflag='M' + ORDER BY stockmaster.stockid"; } else { - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' - AND stockmaster.discontinued=0 - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' + AND stockmaster.discontinued=0 + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + AND mbflag='M' + ORDER BY stockmaster.stockid"; } } else { if ($_POST['StockCat']=='All'){ - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.discontinued=0 - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.discontinued=0 + AND mbflag='M' + ORDER BY stockmaster.stockid"; } else { - $SQL = "SELECT stockmaster.stockid, + $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.discontinued=0 - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - AND mbflag='M' - ORDER BY stockmaster.stockid"; + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.discontinued=0 + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + AND mbflag='M' + ORDER BY stockmaster.stockid"; } } - $SQL .= " LIMIT " . $_SESSION['DisplayRecordsMax']; + $SQL = $SQL . ' LIMIT ' . $_SESSION['DisplayRecordsMax']; $ErrMsg = _('There is a problem selecting the part records to display because'); $DbgMsg = _('The SQL used to get the part selection was'); @@ -168,16 +188,15 @@ } //end of if search if (isset($NewItem) AND isset($_POST['WO'])){ - - $InputError=false; - $CheckItemResult = DB_query("SELECT mbflag, - eoq, - controlled + $InputError=false; + $CheckItemResult = DB_query("SELECT mbflag, + eoq, + controlled FROM stockmaster WHERE stockid='" . $NewItem . "'", - $db); + $db); if (DB_num_rows($CheckItemResult)==1){ - $CheckItemRow = DB_fetch_array($CheckItemResult); + $CheckItemRow = DB_fetch_array($CheckItemResult); if ($CheckItemRow['controlled']==1 AND $_SESSION['DefineControlledOnWOEntry']==1){ //need to add serial nos or batches to determine quantity $EOQ = 0; } else { @@ -186,18 +205,18 @@ } $EOQ = $ReqQty; } - if ($CheckItemRow['mbflag']!='M'){ - prnMsg(_('The item selected cannot be added to a work order because it is not a manufactured item'),'warn'); - $InputError=true; - } + if ($CheckItemRow['mbflag']!='M'){ + prnMsg(_('The item selected cannot be added to a work order because it is not a manufactured item'),'warn'); + $InputError=true; + } } else { prnMsg(_('The item selected cannot be found in the database'),'error'); $InputError = true; } - $CheckItemResult = DB_query("SELECT stockid + $CheckItemResult = DB_query("SELECT stockid FROM woitems WHERE stockid='" . $NewItem . "' - AND wo='" .$_POST['WO'] . "'", + AND wo='" .$_POST['WO'] . "'", $db); if (DB_num_rows($CheckItemResult)==1){ prnMsg(_('This item is already on the work order and cannot be added again'),'warn'); @@ -207,63 +226,61 @@ if ($InputError==false){ $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*bom.quantity) AS cost - FROM stockmaster INNER JOIN bom - ON stockmaster.stockid=bom.component + FROM stockmaster + INNER JOIN bom + ON stockmaster.stockid=bom.component WHERE bom.parent='" . $NewItem . "' - AND bom.loccode='" . $_POST['StockLocation'] . "'", + AND bom.loccode='" . $_POST['StockLocation'] . "'", $db); - $CostRow = DB_fetch_row($CostResult); - if (is_null($CostRow[0]) OR $CostRow[0]==0){ - $Cost =0; - prnMsg(_('The cost of this item as accumulated from the sum of the component costs is nil. This could be because there is no bill of material set up ... you may wish to double check this'),'warn'); + $CostRow = DB_fetch_array($CostResult); + if (is_null($CostRow['cost']) OR $CostRow['cost']==0){ + $Cost =0; + prnMsg(_('The cost of this item as accumulated from the sum of the component costs is nil. This could be because there is no bill of material set up ... you may wish to double check this'),'warn'); } else { - $Cost = $CostRow[0]; + $Cost = $CostRow['cost']; } if (!isset($EOQ)){ $EOQ=1; } - + $Result = DB_Txn_Begin($db); - + // insert parent item info $sql = "INSERT INTO woitems (wo, stockid, qtyreqd, stdcost) - VALUES ( '" . $_POST['WO'] . "', - '" . $NewItem . "', - '" . $EOQ . "', - '" . $Cost . "' - )"; + VALUES ( + '" . $_POST['WO'] . "', + '" . $NewItem . "', + '" . $EOQ . "', + '" . $Cost . "' + )"; $ErrMsg = _('The work order item could not be added'); $result = DB_query($sql,$db,$ErrMsg); - + //Recursively insert real component requirements - see includes/SQL_CommonFunctions.in for function WoRealRequirements WoRealRequirements($db, $_POST['WO'], $_POST['StockLocation'], $NewItem); - + $result = DB_Txn_Commit($db); - + unset($NewItem); } //end if there were no input errors } //adding a new item to the work order -if (isset($_POST['submit'])) { //The update button has been clicked +if (isset($_POST['submit']) or isset($_POST['Search'])) { //The update button has been clicked - echo '<div class="centre"> - <a href="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') .'">' . _('Enter a new work order') . '</a> - <br /> - <a href="' . $rootpath . '/SelectWorkOrder.php">' . _('Select an existing work order') . '</a> - <br /> - <a href="'. $rootpath . '/WorkOrderCosting.php?WO=' . $_REQUEST['WO'] . '">' . _('Go to Costing'). '</a> - </div>'; + echo '<div class="centre"><a href="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') .'">' . _('Enter a new work order') . '</a>'; + echo '<br /><a href="' . $rootpath . '/SelectWorkOrder.php">' . _('Select an existing work order') . '</a>'; + echo '<br /><a href="'. $rootpath . '/WorkOrderCosting.php?WO=' . $_REQUEST['WO'] . '">' . _('Go to Costing'). '</a></div>'; $Input_Error = false; //hope for the best for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ - if (!is_numeric(filter_number_format($_POST['OutputQty'.$i]))){ + if (!is_numeric($_POST['OutputQty'.$i])){ prnMsg(_('The quantity entered must be numeric'),'error'); $Input_Error = true; - } elseif (filter_number_format($_POST['OutputQty'.$i])<=0){ + } elseif ($_POST['OutputQty'.$i]<=0){ prnMsg(_('The quantity entered must be a positive number greater than zero'),'error'); $Input_Error = true; } @@ -279,7 +296,7 @@ $QtyRecd=0; for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ - $QtyRecd += filter_number_format($_POST['RecdQty'.$i]); + $QtyRecd+=$_POST['RecdQty'.$i]; } unset($sql); @@ -287,46 +304,47 @@ $sql[] = "UPDATE workorders SET requiredby='" . $SQL_ReqDate . "', startdate='" . FormatDateForSQL($_POST['StartDate']) . "', loccode='" . $_POST['StockLocation'] . "' - WHERE wo='" . $_POST['WO'] . "'"; + WHERE wo='" . $_POST['WO'] . "'"; } else { prnMsg(_('The factory where this work order is made can only be updated if the quantity received on all output items is 0'),'warn'); $sql[] = "UPDATE workorders SET requiredby='" . $SQL_ReqDate . "', startdate='" . FormatDateForSQL($_POST['StartDate']) . "' - WHERE wo='" . $_POST['WO'] . "'"; + WHERE wo='" . $_POST['WO'] . "'"; } for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ if (!isset($_POST['NextLotSNRef'.$i])) { $_POST['NextLotSNRef'.$i]=''; } - if (isset($_POST['QtyRecd'.$i]) AND $_POST['QtyRecd'.$i]>filter_number_format($_POST['OutputQty'.$i])){ + if (isset($_POST['QtyRecd'.$i]) and $_POST['QtyRecd'.$i]>$_POST['OutputQty'.$i]){ $_POST['OutputQty'.$i]=$_POST['QtyRecd'.$i]; //OutputQty must be >= Qty already reced } - if ($_POST['RecdQty'.$i]==0 AND (!isset($_POST['HasWOSerialNos'.$i]) OR $_POST['HasWOSerialNos'.$i]==false)){ + if ($_POST['RecdQty'.$i]==0 AND (!isset($_POST['HasWOSerialNos'.$i]) or $_POST['HasWOSerialNos'.$i]==false)){ /* can only change location cost if QtyRecd=0 */ $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*bom.quantity) AS cost - FROM stockmaster INNER JOIN bom - ON stockmaster.stockid=bom.component - WHERE bom.parent='" . $_POST['OutputItem'.$i] . "' - AND bom.loccode='" . $_POST['StockLocation'] . "'", + FROM stockmaster + INNER JOIN bom + ON stockmaster.stockid=bom.component + WHERE bom.parent='" . $_POST['OutputItem'.$i] . "' + AND bom.loccode='" . $_POST['StockLocation'] . "'", $db); - $CostRow = DB_fetch_row($CostResult); - if (is_null($CostRow[0])){ + $CostRow = DB_fetch_array($CostResult); + if (is_null($CostRow['cost'])){ $Cost =0; prnMsg(_('The cost of this item as accumulated from the sum of the component costs is nil. This could be because there is no bill of material set up ... you may wish to double check this'),'warn'); } else { - $Cost = $CostRow[0]; + $Cost = $CostRow['cost']; } - $sql[] = "UPDATE woitems SET qtyreqd = '". filter_number_format($_POST['OutputQty' . $i]) . "', - nextlotsnref = '". $_POST['NextLotSNRef'.$i] ."', - stdcost ='" . $Cost . "' - WHERE wo='" . $_POST['WO'] . "' - AND stockid='" . $_POST['OutputItem'.$i] . "'"; + $sql[] = "UPDATE woitems SET qtyreqd = '". $_POST['OutputQty' . $i] . "', + nextlotsnref = '". $_POST['NextLotSNRef'.$i] ."', + stdcost ='" . $Cost . "' + WHERE wo='" . $_POST['WO'] . "' + AND stockid='" . $_POST['OutputItem'.$i] . "'"; } elseif (isset($_POST['HasWOSerialNos'.$i]) and $_POST['HasWOSerialNos'.$i]==false) { - $sql[] = "UPDATE woitems SET qtyreqd = '". filter_number_format($_POST['OutputQty' . $i]) . "', - nextlotsnref = '". $_POST['NextLotSNRef'.$i] ."' - WHERE wo='" . $_POST['WO'] . "' - AND stockid='" . $_POST['OutputItem'.$i] . "'"; + $sql[] = "UPDATE woitems SET qtyreqd = '". $_POST['OutputQty' . $i] . "', + nextlotsnref = '". $_POST['NextLotSNRef'.$i] ."' + WHERE wo='" . $_POST['WO'] . "' + AND stockid='" . $_POST['OutputItem'.$i] . "'"; } } @@ -335,16 +353,18 @@ foreach ($sql as $sql_stmt){ // echo '<br />' . $sql_stmt; $result = DB_query($sql_stmt,$db,$ErrMsg); + } + if (!isset($_POST['Search'])) { + prnMsg(_('The work order has been updated'),'success'); + } - prnMsg(_('The work order has been updated'),'success'); - for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ - unset($_POST['OutputItem'.$i]); - unset($_POST['OutputQty'.$i]); - unset($_POST['QtyRecd'.$i]); - unset($_POST['NetLotSNRef'.$i]); - unset($_POST['HasWOSerialNos'.$i]); + unset($_POST['OutputItem'.$i]); + unset($_POST['OutputQty'.$i]); + unset($_POST['QtyRecd'.$i]); + unset($_POST['NetLotSNRef'.$i]); + unset($_POST['HasWOSerialNos'.$i]); } } } elseif (isset($_POST['delete'])) { @@ -353,9 +373,10 @@ $CancelDelete=false; //always assume the best // can't delete it there are open work issues - $HasTransResult = DB_query("SELECT * FROM stockmoves - WHERE (stockmoves.type= 26 OR stockmoves.type=28) - AND reference " . LIKE . " '%" . $_POST['WO'] . "%'",$db); + $HasTransResult = DB_query("SELECT transno + FROM stockmoves + WHERE (stockmoves.type= 26 OR stockmoves.type=28) + AND reference " . LIKE . " '%" . $_POST['WO'] . "%'",$db); if (DB_num_rows($HasTransResult)>0){ prnMsg(_('This work order cannot be deleted because it has issues or receipts related to it'),'error'); $CancelDelete=true; @@ -363,8 +384,8 @@ if ($CancelDelete==false) { //ie all tests proved ok to delete DB_Txn_Begin($db); - $ErrMsg = _('Unable to delete the work order because'); - $DbgMsg = _('The SQL that failed to delete the work order was'); + $ErrMsg = _('The work order could not be deleted'); + $DbgMsg = _('The SQL used to delete the work order was'); //delete the worequirements $sql = "DELETE FROM worequirements WHERE wo='" . $_POST['WO'] . "'"; $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); @@ -381,27 +402,25 @@ $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); DB_Txn_Commit($db); - prnMsg(_('The work order has been deleted'),'success'); + prnMsg(_('The work order has been cancelled'),'success'); echo '<p><a href="' . $rootpath . '/SelectWorkOrder.php">' . _('Select an existing outstanding work order') . '</a></p>'; unset($_POST['WO']); for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ - unset($_POST['OutputItem'.$i]); - unset($_POST['OutputQty'.$i]); - unset($_POST['QtyRecd'.$i]); - unset($_POST['NetLotSNRef'.$i]); - unset($_POST['HasWOSerialNos'.$i]); + unset($_POST['OutputItem'.$i]); + unset($_POST['OutputQty'.$i]); + unset($_POST['QtyRecd'.$i]); + unset($_POST['NetLotSNRef'.$i]); + unset($_POST['HasWOSerialNos'.$i]); } include('includes/footer.inc'); exit; } } -echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">'; -echo '<div>'; +echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" name="form1">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; -echo '<input type="hidden" name="WO" value="' .$_POST['WO'] . '" />'; echo '<br /><table class="selection">'; @@ -410,12 +429,14 @@ startdate, costissued, closed - FROM workorders INNER JOIN locations - ON workorders.loccode=locations.loccode + FROM workorders + INNER JOIN locations + ON workorders.loccode=locations.loccode WHERE workorders.wo='" . $_POST['WO'] . "'"; $WOResult = DB_query($sql,$db); if (DB_num_rows($WOResult)==1){ + $myrow = DB_fetch_array($WOResult); $_POST['StartDate'] = ConvertSQLDate($myrow['startdate']); $_POST['CostIssued'] = $myrow['costissued']; @@ -423,18 +444,19 @@ $_POST['RequiredBy'] = ConvertSQLDate($myrow['requiredby']); $_POST['StockLocation'] = $myrow['loccode']; $ErrMsg =_('Could not get the work order items'); - $WOItemsResult = DB_query("SELECT woitems.stockid, - stockmaster.description, - qtyreqd, - qtyrecd, - stdcost, - nextlotsnref, - controlled, - serialised, - nextserialno, - decimalplaces - FROM woitems INNER JOIN stockmaster - ON woitems.stockid=stockmaster.stockid + $WOItemsResult = DB_query("SELECT woitems.stockid, + stockmaster.description, + qtyreqd, + qtyrecd, + stdcost, + nextlotsnref, + controlled, + serialised, + stockmaster.decimalplaces, + nextserialno + FROM woitems + INNER JOIN stockmaster + ON woitems.stockid=stockmaster.stockid WHERE wo='" .$_POST['WO'] . "'",$db,$ErrMsg); $NumberOfOutputs=DB_num_rows($WOItemsResult); @@ -452,7 +474,7 @@ } $_POST['Controlled'.$i] =$WOItem['controlled']; $_POST['Serialised'.$i] =$WOItem['serialised']; - $HasWOSerialNosResult = DB_query("SELECT * FROM woserialnos WHERE wo='" . $_POST['WO'] . "'",$db); + $HasWOSerialNosResult = DB_query("SELECT wo FROM woserialnos WHERE wo='" . $_POST['WO'] . "'",$db); if (DB_num_rows($HasWOSerialNosResult)>0){ $_POST['HasWOSerialNos']=true; } else { @@ -462,30 +484,26 @@ } } -echo '<tr> - <td class="label">' . _('Work Order Reference') . ':</td> - <td>' . $_POST['WO'] . '</td> - </tr>'; -echo '<tr> - <td class="label">' . _('Factory Location') .':</td> - <td><select name="StockLocation" onchange="ReloadForm(form1.submit)">'; +echo '<input type="hidden" name="WO" value="' .$_POST['WO'] . '" />'; +echo '<tr><td class="label">' . _('Work Order Reference') . ':</td><td>' . $_POST['WO'] . '</td></tr>'; +echo '<tr><td class="label">' . _('Factory Location') .':</td> + <td><select name="StockLocation" onChange="ReloadForm(form1.submit)">'; $LocResult = DB_query("SELECT loccode,locationname FROM locations",$db); while ($LocRow = DB_fetch_array($LocResult)){ if ($_POST['StockLocation']==$LocRow['loccode']){ - echo '<option selected="selected" value="' . $LocRow['loccode'] .'">' . $LocRow['locationname'] . '</option>'; + echo '<option selected="True" value="' . $LocRow['loccode'] .'">' . $LocRow['locationname'] . '</option>'; } else { echo '<option value="' . $LocRow['loccode'] .'">' . $LocRow['locationname'] . '</option>'; } } -echo '</select></td> - </tr>'; +echo '</select></td></tr>'; if (!isset($_POST['StartDate'])){ $_POST['StartDate'] = Date($_SESSION['DefaultDateFormat']); } echo '<tr> <td class="label">' . _('Start Date') . ':</td> - <td><input type="text" name="StartDate" size="12" maxlength="12" value="' . $_POST['StartDate'] . '" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" /></td> + <td><input type="text" name="StartDate" size="12" maxlength="12" value="' . $_POST['StartDate'] .'" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" /></td> </tr>'; if (!isset($_POST['RequiredBy'])){ @@ -494,25 +512,21 @@ echo '<tr> <td class="label">' . _('Required By') . ':</td> - <td><input type="text" name="RequiredBy" size="12" maxlength="12" value="' . $_POST['RequiredBy'] . '" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" /></td> + <td><input type="text" name="RequiredBy" size="12" maxlength="12" value="' . $_POST['RequiredBy'] .'" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" /></td> </tr>'; if (isset($WOResult)){ - echo '<tr> - <td class="label">' . _('Accumulated Costs') . ':</td> - <td class="number">' . locale_number_format($myrow['costissued'],$_SESSION['CompanyRecord']['decimalplaces']) . '</td> - </tr>'; + echo '<tr><td class="label">' . _('Accumulated Costs') . ':</td> + <td class="number">' . locale_number_format($myrow['costissued'],$_SESSION['CompanyRecord']['decimalplaces']) . '</td></tr>'; } echo '</table> <br /><table class="selection">'; -echo '<tr> - <th>' . _('Output Item') . '</th> - <th>' . _('Qty Required') . '</th> - <th>' . _('Qty Received') . '</th> - <th>' . _('Balance Remaining') . '</th> - <th>' . _('Next Lot/SN Ref') . '</th> - <th> </th> - </tr>'; +echo '<tr><th>' . _('Output Item') . '</th> + <th>' . _('Qty Required') . '</th> + <th>' . _('Qty Received') . '</th> + <th>' . _('Balance Remaining') . '</th> + <th>' . _('Next Lot/SN Ref') . '</th> + </tr>'; $j=0; if (isset($NumberOfOutputs)){ @@ -524,15 +538,16 @@ echo '<tr class="EvenTableRows">'; $j++; } - echo '<td><input type="hidden" name="OutputItem' . $i . '" value="' . $_POST['OutputItem' .$i] . '" />' . $_POST['OutputItem' . $i] . ' - ' . $_POST['OutputItemDesc' .$i] . '</td>'; + echo '<td><input type="hidden" name="OutputItem' . $i . '" value="' . $_POST['OutputItem' .$i] . '" />' . + $_POST['OutputItem' . $i] . ' - ' . $_POST['OutputItemDesc' .$i] . '</td>'; if ($_POST['Controlled'.$i]==1 AND $_SESSION['DefineControlledOnWOEntry']==1){ - echo '<td class="number">' . locale_number_format($_POST['OutputQty' . $i],$_POST['DecimalPlaces' . $i]); - echo '<input type="hidden" name="OutputQty' . $i .'" value="' . locale_number_format($_POST['OutputQty' . $i],$_POST['DecimalPlaces' . $i]) . '" /></td>'; + echo '<td class="number">' . locale_number_format($_POST['OutputQty' . $i], $_POST['DecimalPlaces' . $i]) . '</td>'; + echo '<input type="hidden" name="OutputQty' . $i .'" value="' . locale_number_format($_POST['OutputQty' . $i]-$_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" />'; } else { - echo'<td><input type="text" class="number" name="OutputQty' . $i . '" value="' . locale_number_format($_POST['OutputQty' . $i],$_POST['DecimalPlaces' . $i]) . '" size="10" maxlength="10" /></td>'; + echo'<td><input type="text" class="number" name="OutputQty' . $i . '" value="' . locale_number_format($_POST['OutputQty' . $i]-$_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" size="10" maxlength="10" /></td>'; } - echo '<td class="number"><input type="hidden" name="RecdQty' . $i . '" value="' . $_POST['RecdQty' .$i] . '" />' . $_POST['RecdQty' .$i] .'</td> - <td class="number">' . locale_number_format(($_POST['OutputQty' . $i] - $_POST['RecdQty' .$i]),$_POST['DecimalPlaces' . $i]) . '</td>'; + echo '<td class="number"><input type="hidden" name="RecdQty' . $i . '" value="' . locale_number_format($_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" />' . locale_number_format($_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) .'</td> + <td class="number">' . locale_number_format(($_POST['OutputQty' . $i] - $_POST['RecdQty' .$i]), $_POST['DecimalPlaces' . $i]) . '</td>'; if ($_POST['Controlled'.$i]==1){ echo '<td><input type="text" name="NextLotSNRef' .$i . '" value="' . $_POST['NextLotSNRef'.$i] . '" /></td>'; if ($_SESSION['DefineControlledOnWOEntry']==1){ @@ -541,11 +556,13 @@ } else { $LotOrSN = _('Batches'); } - echo '<td><a href="' . $rootpath . '/WOSerialNos.php?WO=' . $_POST['WO'] . '&StockID=' . $_POST['OutputItem' .$i] . '&Description=' . $_POST['OutputItemDesc' .$i] . '&Serialised=' . $_POST['Serialised' .$i] . '&NextSerialNo=' . $_POST['NextLotSNRef' .$i] . '">' . $LotOrSN . '</a></td>'; + echo '<td><a href="' . $rootpath . '/WOSerialNos.php?WO=' . $_POST['WO'] . '&StockID=' . $_POST['OutputItem' .$i] . '&Description=' . $_POST['OutputItemDesc' .$i] . '&Serialised=' . $_POST['Serialised' .$i] . '&NextSerialNo=' . $_POST['NextLotSNRef' .$i] . '">' . $LotOrSN . '</a></td>'; } } echo '<td>'; wikiLink('WorkOrder', $_POST['WO'] . $_POST['OutputItem' .$i]); + echo '</td>'; + echo '</tr>'; if (isset($_POST['Controlled' . $i])) { echo '<input type="hidden" name="Controlled' . $i .'" value="' . $_POST['Controlled' . $i] . '" />'; } @@ -555,22 +572,17 @@ if (isset($_POST['HasWOSerialNos' . $i])) { echo '<input type="hidden" name="HasWOSerialNos' . $i .'" value="' . $_POST['HasWOSerialNos' . $i] . '" />'; } - echo '</td> - </tr>'; } - echo '<tr><td><input type="hidden" name="NumberOfOutputs" value="' . ($i -1).'" /></td></tr>'; + echo '<input type="hidden" name="NumberOfOutputs" value="' . ($i -1).'" />'; } echo '</table>'; -echo '<div class="centre"> - <br /> - <input type="submit" name="submit" value="' . _('Update') . '" /> - <br /> - <br /> - <input type="submit" name="delete" value="' . _('Delete This Work Order') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');" /> - <br /> - </div>'; +echo '<br /><div class="centre"><button type="submit" name="submit">' . _('Update') . '</button></div>'; +echo '<br /><div class="centre"><button type="submit" name="delete" onclick="return confirm(\'' . _('Are You Sure?') . '\');">' . _('Cancel This Work Order') . '</button>'; + +echo '</div><br />'; + $SQL="SELECT categoryid, categorydescription FROM stockcategory @@ -578,12 +590,10 @@ ORDER BY categorydescription"; $result1 = DB_query($SQL,$db); -echo '<table class="selection"> - <tr> - <td>' . _('Select a stock category') . ':<select name="StockCat">'; +echo '<table class="selection"><tr><td>' . _('Select a stock category') . ':<select name="StockCat">'; if (!isset($_POST['StockCat'])){ - echo '<option selected="selected" value="All">' . _('All') . '</option>'; + echo '<option selected="True" value="All">' . _('All') . '</option>'; $_POST['StockCat'] ='All'; } else { echo '<option value="All">' . _('All') . '</option>'; @@ -592,40 +602,38 @@ while ($myrow1 = DB_fetch_array($result1)) { if ($_POST['StockCat']==$myrow1['categoryid']){ - echo '<option selected="selected" value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; + echo '<option selected="True" value=' . $myrow1['categoryid'] . '>' . $myrow1['categorydescription'] . '</option>'; } else { - echo '<option value="'. $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; + echo '<option value='. $myrow1['categoryid'] . '>' . $myrow1['categorydescription'] . '</option>'; } } -?> -</select></td> -<td><?php echo _('Enter text extracts in the'); ?> <b><?php echo _('description'); ?></b>:</td> -<td><input type="text" name="Keywords" size="20" maxlength="25" value="<?php if (isset($_POST['Keywords'])) echo $_POST['Keywords']; ?>" /></td> -</tr> -<tr><td></td> - <td><b><?php echo _('OR'); ?> </b><?php echo _('Enter extract of the'); ?> <b><?php echo _('Stock Code'); ?></b>:</td> - <td><input type="text" name="StockCode" size="15" maxlength="18" value="<?php if (isset($_POST['StockCode'])) echo $_POST['StockCode']; ?>" /></td> -</tr> -</table> -<br /><div class="centre"><input type="submit" name="Search" value="<?php echo _('Search Now'); ?>" /> +if (!isset($_POST['Keywords'])) { + $_POST['Keywords']=''; +} -<?php +if (!isset($_POST['StockCode'])) { + $_POST['StockCode']=''; +} -echo '</div>'; +echo '</select> + <td>' . _('Enter text extracts in the') . ' <b>' . _('description') . '</b>:</td> + <td><input type="text" name="Keywords" size="20" maxlength="25" value="' . $_POST['Keywords'] . '" /></td></tr> + <tr><td> </td> + <td><font size="3"><b>' . _('OR') . ' </b></font>' . _('Enter extract of the') . ' <b>' . _('Stock Code') . '</b>:</td> + <td><input type="text" name="StockCode" size="15" maxlength="18" value="' . $_POST['StockCode'] . '" /></td> + </tr> + </table> + <br /><div class="centre"><button type="submit" name="Search">' . _('Search Now') . '</button></div>'; if (isset($SearchResult)) { if (DB_num_rows($SearchResult)>1){ - echo '<table cellpadding="2" class="selection">'; - $TableHeader = '<tr> - <th>' . _('Code') . '</th> + echo '<br /><table cellpadding="2" class="selection">'; + $TableHeader = '<tr><th>' . _('Code') . '</th> <th>' . _('Description') . '</th> - <th>' . _('Units') . '</th> - <th> </th> - <th> </th> - </tr>'; + <th>' . _('Units') . '</th></tr>'; echo $TableHeader; $j = 1; $k=0; //row colour counter @@ -638,10 +646,10 @@ if (!in_array($myrow['stockid'],$ItemCodes)){ if (function_exists('imagecreatefrompng') ){ - $ImageSource = '<img src="GetStockImage.php?automake=1&textcolor=FFFFFF&bgcolor=CCCCCC&StockID=' . urlencode($myrow['stockid']). '&text=&width=64&height=64" alt="" />'; + $ImageSource = '<img src="GetStockImage.php?automake=1&textcolor=FFFFFF&bgcolor=CCCCCC&StockID=' . urlencode($myrow['stockid']). '&text=&width=64&height=64" />'; } else { if(file_exists($_SERVER['DOCUMENT_ROOT'] . $rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg')) { - $ImageSource = '<img src="' .$_SERVER['DOCUMENT_ROOT'] . $rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg" alt="" />'; + $ImageSource = '<img src="' .$_SERVER['DOCUMENT_ROOT'] . $rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg" />'; } else { $ImageSource = _('No Image'); } @@ -655,17 +663,18 @@ $k=1; } - printf('<td>%s</td> + printf('<td><font size="1">%s</font></td> + <td><font size="1">%s</font></td> + <td><font size="1">%s</font></td> <td>%s</td> - <td>%s</td> - <td>%s</td> - <td><a href="%s">' . _('Add to Work Order') . '</a></td> + <td><font size="1"><a href="%s">' + . _('Add to Work Order') . '</a></font></td> </tr>', $myrow['stockid'], $myrow['description'], $myrow['units'], $ImageSource, - htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?WO=' . $_POST['WO'] . '&NewItem=' . $myrow['stockid'].'&Line='.$i); + htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?WO=' . $_POST['WO'] . '&NewItem=' . $myrow['stockid'].'&Line='.$i); $j++; If ($j == 25){ @@ -681,12 +690,11 @@ if (!isset($_GET['NewItem']) or $_GET['NewItem']=='') { - echo '<script type="text/javascript">defaultControl(document.forms[0].StockCode);</script>'; + echo '<script>defaultControl(document.forms[0].StockCode);</script>'; } else { - echo '<script type="text/javascript">defaultControl(document.forms[0].OutputQty"'.$_GET['Line'].'");</script>'; + echo '<script>defaultControl(document.forms[0].OutputQty"'.$_GET['Line'].'");</script>'; } -echo '</div> - </form>'; +echo '</form>'; include('includes/footer.inc'); ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ex...@us...> - 2012-08-30 03:06:56
|
Revision: 5613 http://web-erp.svn.sourceforge.net/web-erp/?rev=5613&view=rev Author: ExsonQu Date: 2012-08-30 03:06:50 +0000 (Thu, 30 Aug 2012) Log Message: ----------- 30/8/2012 Exson: fixed sql problem reported bymodpr0be Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2012-08-30 02:51:49 UTC (rev 5612) +++ trunk/WorkOrderEntry.php 2012-08-30 03:06:50 UTC (rev 5613) @@ -38,7 +38,7 @@ // check for new or modify condition if (isset($_REQUEST['WO']) AND$_REQUEST['WO']!=''){ // modify - $_POST['WO'] = $_REQUEST['WO']; + $_POST['WO'] = (int)$_REQUEST['WO']; $EditingExisting = true; } else { // new @@ -696,4 +696,4 @@ echo '</form>'; include('includes/footer.inc'); -?> \ No newline at end of file +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ex...@us...> - 2012-08-30 03:06:56
|
Revision: 5613 http://web-erp.svn.sourceforge.net/web-erp/?rev=5613&view=rev Author: ExsonQu Date: 2012-08-30 03:06:50 +0000 (Thu, 30 Aug 2012) Log Message: ----------- 30/8/2012 Exson: fixed sql problem reported bymodpr0be Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2012-08-30 02:51:49 UTC (rev 5612) +++ trunk/WorkOrderEntry.php 2012-08-30 03:06:50 UTC (rev 5613) @@ -38,7 +38,7 @@ // check for new or modify condition if (isset($_REQUEST['WO']) AND$_REQUEST['WO']!=''){ // modify - $_POST['WO'] = $_REQUEST['WO']; + $_POST['WO'] = (int)$_REQUEST['WO']; $EditingExisting = true; } else { // new @@ -696,4 +696,4 @@ echo '</form>'; include('includes/footer.inc'); -?> \ No newline at end of file +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ex...@us...> - 2013-08-14 09:45:31
|
Revision: 6206 http://sourceforge.net/p/web-erp/reponame/6206 Author: exsonqu Date: 2013-08-14 09:45:26 +0000 (Wed, 14 Aug 2013) Log Message: ----------- 14/8/2013 Exson: HTML5 compatible for WorkOrderEntry.php. Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2013-08-14 09:23:23 UTC (rev 6205) +++ trunk/WorkOrderEntry.php 2013-08-14 09:45:26 UTC (rev 6206) @@ -552,7 +552,7 @@ echo '<td class="number">' . locale_number_format($_POST['OutputQty' . $i], $_POST['DecimalPlaces' . $i]) . '</td>'; echo '<input type="hidden" name="OutputQty' . $i .'" value="' . locale_number_format($_POST['OutputQty' . $i]-$_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" />'; } else { - echo'<td><input type="text" class="number" name="OutputQty' . $i . '" value="' . locale_number_format($_POST['OutputQty' . $i]-$_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" size="10" maxlength="10" /></td>'; + echo'<td><input type="text" required="required" class="number" name="OutputQty' . $i . '" value="' . locale_number_format($_POST['OutputQty' . $i]-$_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" size="10" maxlength="10" title="'._('The input format must be positive numeric').'" /></td>'; } echo '<td class="number"><input type="hidden" name="RecdQty' . $i . '" value="' . locale_number_format($_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" />' . locale_number_format($_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) .'</td> <td class="number">' . locale_number_format(($_POST['OutputQty' . $i] - $_POST['RecdQty' .$i]), $_POST['DecimalPlaces' . $i]) . '</td>'; |
From: <ex...@us...> - 2014-03-22 05:25:18
|
Revision: 6627 http://sourceforge.net/p/web-erp/reponame/6627 Author: exsonqu Date: 2014-03-22 05:25:14 +0000 (Sat, 22 Mar 2014) Log Message: ----------- 22/03/14 Exson: Fixed the stock searching function failure when items setup in system less than DisplayedRecordsMax in WorkOrderEntry.php. Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2014-03-21 11:27:25 UTC (rev 6626) +++ trunk/WorkOrderEntry.php 2014-03-22 05:25:14 UTC (rev 6627) @@ -196,8 +196,10 @@ if (!isset($Offset)) { $Offset=0; } - if($Offset<0)$Offset=0; - if($Offset>$ListPageMax)$Offset=$ListPageMax; + if($Offset<0){ + $Offset=0; + } + if($Offset>$ListPageMax AND $ListPageMax>0 )$Offset=$ListPageMax; $sql = $sql . ' LIMIT ' . $_SESSION['DisplayRecordsMax'].' OFFSET ' . strval($_SESSION['DisplayRecordsMax']*$Offset); @@ -737,4 +739,4 @@ echo '</form>'; include('includes/footer.inc'); -?> +?> \ No newline at end of file |
From: <te...@us...> - 2014-09-15 04:26:18
|
Revision: 6887 http://sourceforge.net/p/web-erp/reponame/6887 Author: tehonu Date: 2014-09-15 04:26:13 +0000 (Mon, 15 Sep 2014) Log Message: ----------- Fixed bug when converting a MRP suggested WO into a real WO, the filed "Required by" was always set to 0000-00-00 Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2014-09-14 02:51:55 UTC (rev 6886) +++ trunk/WorkOrderEntry.php 2014-09-15 04:26:13 UTC (rev 6887) @@ -11,7 +11,6 @@ <img src="'.$RootPath.'/css/'.$Theme.'/images/transactions.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title.' </p>'; - if (isset($_GET['WO'])) { $SelectedWO = $_GET['WO']; } elseif (isset($_POST['WO'])){ @@ -21,7 +20,7 @@ } if (isset($_GET['ReqDate'])){ - $ReqDate = ConvertSQLDate($_GET['ReqDate']); + $ReqDate = $_GET['ReqDate']; } else { $ReqDate=Date('Y-m-d'); } |
From: <ex...@us...> - 2014-09-15 05:10:30
|
Revision: 6888 http://sourceforge.net/p/web-erp/reponame/6888 Author: exsonqu Date: 2014-09-15 05:10:21 +0000 (Mon, 15 Sep 2014) Log Message: ----------- 15/09/14 Exson: fixed the date format errors in WorkOrderEntry.php. Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2014-09-15 04:26:13 UTC (rev 6887) +++ trunk/WorkOrderEntry.php 2014-09-15 05:10:21 UTC (rev 6888) @@ -22,13 +22,13 @@ if (isset($_GET['ReqDate'])){ $ReqDate = $_GET['ReqDate']; } else { - $ReqDate=Date('Y-m-d'); + $ReqDate=Date($_SESSION['DefaultDateFormat']); } if (isset($_GET['StartDate'])){ $StartDate = ConvertSQLDate($_GET['StartDate']); } else { - $StartDate=Date('Y-m-d'); + $StartDate=Date($_SESSION['DefaultDateFormat']); } if (isset($_GET['loccode'])){ |
From: <ex...@us...> - 2015-02-15 02:50:38
|
Revision: 7151 http://sourceforge.net/p/web-erp/reponame/7151 Author: exsonqu Date: 2015-02-15 02:50:35 +0000 (Sun, 15 Feb 2015) Log Message: ----------- 15/2/2015: Exson: Fixed date format error for request date and start date in WorkOrderEntry.php. Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2015-02-12 02:22:56 UTC (rev 7150) +++ trunk/WorkOrderEntry.php 2015-02-15 02:50:35 UTC (rev 7151) @@ -22,13 +22,13 @@ if (isset($_GET['ReqDate'])){ $ReqDate = $_GET['ReqDate']; } else { - $ReqDate=Date($_SESSION['DefaultDateFormat']); + $ReqDate=Date('Y-m-d'); } if (isset($_GET['StartDate'])){ $StartDate = $_GET['StartDate']; } else { - $StartDate=Date($_SESSION['DefaultDateFormat']); + $StartDate=Date('Y-m-d'); } if (isset($_GET['loccode'])){ |
From: <ex...@us...> - 2016-03-09 08:26:53
|
Revision: 7471 http://sourceforge.net/p/web-erp/reponame/7471 Author: exsonqu Date: 2016-03-09 08:26:50 +0000 (Wed, 09 Mar 2016) Log Message: ----------- 09/03/16 Exson: Fix the bug of wrong location selected when add items to the workorders in WorkOrderEntry.php. Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2016-03-09 08:09:37 UTC (rev 7470) +++ trunk/WorkOrderEntry.php 2016-03-09 08:26:50 UTC (rev 7471) @@ -284,7 +284,7 @@ INNER JOIN bom ON stockmaster.stockid=bom.component WHERE bom.parent='" . $NewItem . "' - AND bom.loccode='" . $_POST['StockLocation'] . "' + AND bom.loccode=(SELECT loccode FROM workorders WHERE wo='" . $_POST['WO'] . "') AND bom.effectiveafter<='" . Date('Y-m-d') . "' AND bom.effectiveto>='" . Date('Y-m-d') . "'"); $CostRow = DB_fetch_array($CostResult); |
From: <ex...@us...> - 2016-09-04 06:02:27
|
Revision: 7609 http://sourceforge.net/p/web-erp/reponame/7609 Author: exsonqu Date: 2016-09-04 06:02:25 +0000 (Sun, 04 Sep 2016) Log Message: ----------- 04/09/16 Exson: Fixed the bug that work order location will be wrong when user select location which is not user's default location. Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2016-09-04 01:37:10 UTC (rev 7608) +++ trunk/WorkOrderEntry.php 2016-09-04 06:02:25 UTC (rev 7609) @@ -279,7 +279,8 @@ if ($InputError==false){ - $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*bom.quantity) AS cost + $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*bom.quantity) AS cost, + bom.loccode FROM stockmaster INNER JOIN bom ON stockmaster.stockid=bom.component @@ -315,7 +316,7 @@ $result = DB_query($SQL,$ErrMsg); //Recursively insert real component requirements - see includes/SQL_CommonFunctions.in for function WoRealRequirements - WoRealRequirements($db, $_POST['WO'], $_POST['StockLocation'], $NewItem); + WoRealRequirements($db, $_POST['WO'], $CostRow['loccode'], $NewItem); $result = DB_Txn_Commit(); @@ -382,11 +383,11 @@ } if ($_POST['RecdQty'.$i]==0 AND (!isset($_POST['HasWOSerialNos'.$i]) OR $_POST['HasWOSerialNos'.$i]==false)){ /* can only change location cost if QtyRecd=0 */ - $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*bom.quantity) AS cost + $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*bom.quantity) AS cost,bom.loccode FROM stockmaster INNER JOIN bom ON stockmaster.stockid=bom.component WHERE bom.parent='" . $_POST['OutputItem'.$i] . "' - AND bom.loccode='" . $_POST['StockLocation'] . "' + AND bom.loccode=(SELECT loccode FROM workorders WHERE wo='" . $_POST['WO'] . "') AND bom.effectiveafter<='" . Date('Y-m-d') . "' AND bom.effectiveto>='" . Date('Y-m-d') . "'"); $CostRow = DB_fetch_array($CostResult); |
From: <ex...@us...> - 2016-09-04 08:14:29
|
Revision: 7613 http://sourceforge.net/p/web-erp/reponame/7613 Author: exsonqu Date: 2016-09-04 08:14:27 +0000 (Sun, 04 Sep 2016) Log Message: ----------- 04/09/16 Exson: Add delete Work orders Items feature in WorkOrderEntry.php. Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2016-09-04 06:13:37 UTC (rev 7612) +++ trunk/WorkOrderEntry.php 2016-09-04 08:14:27 UTC (rev 7613) @@ -482,7 +482,27 @@ exit; } } +if (isset($_GET['Delete'])) { + //delete items + DB_Txn_Begin(); + $ErrMsg = _('The work order could not be deleted'); + $DbgMsg = _('The SQL used to delete the work order was'); + //delete the worequirements + $SQL = "DELETE FROM worequirements WHERE wo='" . $_GET['WO'] . "' AND parentstockid='" . $_GET['StockID'] . "'"; + $result = DB_query($SQL,$ErrMsg,$DbgMsg,true); + //delete the item on the work order + $SQL = "DELETE FROM woitems WHERE wo='" . $_GET['WO'] . "' AND stockid='" . $_GET['StockID'] . "' "; + $result = DB_query($SQL,$ErrMsg,$DbgMsg,true); + //delete the controlled items defined in wip + $SQL="DELETE FROM woserialnos WHERE wo='" . $_GET['WO'] . "' AND stockid='" . $_GET['StockID'] . "' "; + $ErrMsg=_('The work order serial numbers could not be deleted'); + $result = DB_query($SQL,$ErrMsg,$DbgMsg,true); + DB_Txn_Commit(); + prnMsg(_('The item in this work order has been cancelled'),'success'); + header('Location: '. $_SERVER['PHP_SELF'] . '?WO=' . $_GET['WO']); +} + echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" name="form1">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; @@ -615,19 +635,25 @@ $j=0; } else { echo '<tr class="EvenTableRows">'; - $j++; + $j=1; } echo '<td><input type="hidden" name="OutputItem' . $i . '" value="' . $_POST['OutputItem' .$i] . '" />' . - $_POST['OutputItem' . $i] . ' - ' . $_POST['OutputItemDesc' .$i] . '</td>'; - echo'<td><textarea style="width:100%" rows="5" cols="20" name="WOComments' . $i . '" >' . $_POST['WOComments' . $i] . '</textarea></td>'; + $_POST['OutputItem' . $i] . ' - ' . $_POST['OutputItemDesc' .$i] . ' + </td>'; + echo'<td><textarea style="width:100%" rows="5" cols="20" name="WOComments' . $i . '" >' . $_POST['WOComments' . $i] . '</textarea> + </td>'; if ($_POST['Controlled'.$i]==1 AND $_SESSION['DefineControlledOnWOEntry']==1){ - echo '<td class="number">' . locale_number_format($_POST['OutputQty' . $i], $_POST['DecimalPlaces' . $i]) . '</td>'; + echo '<td class="number">' . locale_number_format($_POST['OutputQty' . $i], $_POST['DecimalPlaces' . $i]) . ' + </td>'; echo '<input type="hidden" name="OutputQty' . $i .'" value="' . locale_number_format($_POST['OutputQty' . $i]-$_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" />'; } else { - echo'<td><input type="text" required="required" class="number" name="OutputQty' . $i . '" value="' . locale_number_format($_POST['OutputQty' . $i]-$_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" size="10" maxlength="10" title="'._('The input format must be positive numeric').'" /></td>'; + echo'<td><input type="text" required="required" class="number" name="OutputQty' . $i . '" value="' . locale_number_format($_POST['OutputQty' . $i]-$_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" size="10" maxlength="10" title="'._('The input format must be positive numeric').'" /> + </td>'; } - echo '<td class="number"><input type="hidden" name="RecdQty' . $i . '" value="' . locale_number_format($_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" />' . locale_number_format($_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '</td> - <td class="number">' . locale_number_format(($_POST['OutputQty' . $i] - $_POST['RecdQty' .$i]), $_POST['DecimalPlaces' . $i]) . '</td>'; + echo '<td class="number"><input type="hidden" name="RecdQty' . $i . '" value="' . locale_number_format($_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . '" />' . locale_number_format($_POST['RecdQty' .$i], $_POST['DecimalPlaces' . $i]) . ' + </td> + <td class="number">' . locale_number_format(($_POST['OutputQty' . $i] - $_POST['RecdQty' .$i]), $_POST['DecimalPlaces' . $i]) . ' + </td>'; if ($_POST['Controlled'.$i]==1){ echo '<td><input type="text" name="NextLotSNRef' .$i . '" value="' . $_POST['NextLotSNRef'.$i] . '" /></td>'; if ($_SESSION['DefineControlledOnWOEntry']==1){ @@ -638,12 +664,17 @@ } echo '<td><a href="' . $RootPath . '/WOSerialNos.php?WO=' . $_POST['WO'] . '&StockID=' . $_POST['OutputItem' .$i] . '&Description=' . $_POST['OutputItemDesc' .$i] . '&Serialised=' . $_POST['Serialised' .$i] . '&NextSerialNo=' . $_POST['NextLotSNRef' .$i] . '">' . $LotOrSN . '</a></td>'; } + } else { + echo '<td></td>'; } - echo '<td>'; + echo '<td> + <a href="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?Delete=Yes&StockID=' . $_POST['OutputItem' . $i] . '&WO='.$_POST['WO'].'" onclick="return confirm(\''._('Are you sure').'?\');">' . _('Delete') . '</a></td>'; + if ($_SESSION['WikiApp']!=0){ + echo '<td>'; wikiLink('WorkOrder', $_POST['WO'] . $_POST['OutputItem' .$i]); + echo '</td>'; } - echo '</td>'; echo '</tr>'; if (isset($_POST['Controlled' . $i])) { echo '<input type="hidden" name="Controlled' . $i .'" value="' . $_POST['Controlled' . $i] . '" />'; |
From: <ex...@us...> - 2016-09-04 10:26:42
|
Revision: 7615 http://sourceforge.net/p/web-erp/reponame/7615 Author: exsonqu Date: 2016-09-04 10:26:40 +0000 (Sun, 04 Sep 2016) Log Message: ----------- 04/09/16 Exson: Add WO items delete constraint in WorkOrderEntry.php. Thanks for Phil's reminder. Modified Paths: -------------- trunk/WorkOrderEntry.php Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2016-09-04 08:15:04 UTC (rev 7614) +++ trunk/WorkOrderEntry.php 2016-09-04 10:26:40 UTC (rev 7615) @@ -483,7 +483,19 @@ } } if (isset($_GET['Delete'])) { + $CancelDelete=false; //always assume the best + + // can't delete it there are open work issues + $HasTransResult = DB_query("SELECT transno + FROM stockmoves + WHERE (stockmoves.type= 26 OR stockmoves.type=28) + AND reference " . LIKE . " '%" . $_POST['WO'] . "%'"); + if (DB_num_rows($HasTransResult)>0){ + prnMsg(_('This work order cannot be deleted because it has issues or receipts related to it'),'error'); + $CancelDelete=true; + } //delete items + if ($CancelDelete===false) { DB_Txn_Begin(); $ErrMsg = _('The work order could not be deleted'); $DbgMsg = _('The SQL used to delete the work order was'); @@ -500,6 +512,7 @@ DB_Txn_Commit(); prnMsg(_('The item in this work order has been cancelled'),'success'); header('Location: '. $_SERVER['PHP_SELF'] . '?WO=' . $_GET['WO']); + } } |