From: <dai...@us...> - 2011-04-03 03:24:33
|
Revision: 4537 http://web-erp.svn.sourceforge.net/web-erp/?rev=4537&view=rev Author: daintree Date: 2011-04-03 03:24:25 +0000 (Sun, 03 Apr 2011) Log Message: ----------- SQL and xhtml fixes Modified Paths: -------------- trunk/SMTPServer.php trunk/SelectSalesOrder.php trunk/SelectWorkOrder.php trunk/ShipmentCosting.php trunk/StockAdjustments.php trunk/StockDispatch.php trunk/StockTransfers.php trunk/SuppFixedAssetChgs.php trunk/SupplierAllocations.php Modified: trunk/SMTPServer.php =================================================================== --- trunk/SMTPServer.php 2011-04-02 09:40:49 UTC (rev 4536) +++ trunk/SMTPServer.php 2011-04-03 03:24:25 UTC (rev 4537) @@ -1,7 +1,5 @@ <?php - -//$PageSecurity =15; - +/* $Id: SMTPServer.php 4469 2011-01-15 02:28:37Z daintree $*/ include('includes/session.inc'); $title = _('SMTP Server details'); @@ -25,17 +23,20 @@ } $sql='SELECT id, - host, - port, - heloaddress, - username, - password, - timeout, - auth - FROM emailsettings'; + host, + port, + heloaddress, + username, + password, + timeout, + auth + FROM emailsettings'; + $result=DB_query($sql, $db); + $myrow=DB_fetch_array($result); -echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . "?" . SID . ">"; + +echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<table class=selection>'; echo '<tr><td>'._('Server Host Name').'</td> Modified: trunk/SelectSalesOrder.php =================================================================== --- trunk/SelectSalesOrder.php 2011-04-02 09:40:49 UTC (rev 4536) +++ trunk/SelectSalesOrder.php 2011-04-03 03:24:25 UTC (rev 4537) @@ -14,9 +14,9 @@ for ($i=1;$i<count($_POST);$i++){ if (isset($_POST['PlacePO_' . $i])) { //checkboxes only set if they are checked if ($OrdersToPlacePOFor==''){ - $OrdersToPlacePOFor .= ' orderno=' . $_POST['OrderNo_PO_'.$i]; + $OrdersToPlacePOFor .= " orderno='" . $_POST['OrderNo_PO_'.$i] . "'"; } else { - $OrdersToPlacePOFor .= ' OR orderno=' . $_POST['OrderNo_PO_'.$i]; + $OrdersToPlacePOFor .= " OR orderno='" . $_POST['OrderNo_PO_'.$i] . "'"; } } } @@ -97,9 +97,9 @@ /* if an order is/has been created already and the supplier of this item has changed - so need to finish off the order */ //if the user has authority to authorise the PO then it should be created as authorised $AuthSQL ="SELECT authlevel - FROM purchorderauth - WHERE userid='".$_SESSION['UserID']."' - AND currabrev='".$SuppRow['currcode']."'"; + FROM purchorderauth + WHERE userid='".$_SESSION['UserID']."' + AND currabrev='".$SuppRow['currcode']."'"; $AuthResult=DB_query($AuthSQL,$db); $AuthRow=DB_fetch_array($AuthResult); @@ -280,8 +280,8 @@ $ErrMsg = _('Could not update purchase order status to Authorised'); $Debug = _('The SQL that failed was'); $result = DB_query("UPDATE purchorders SET allowprint=1, - status='Authorised', - stat_comment='" . $StatusComment . "' + status='Authorised', + stat_comment='" . $StatusComment . "' WHERE orderno='" . $PO_OrderNo . "'", $db,$ErrMsg,$DbgMsg,true); } else { // no authority to authorise this order Modified: trunk/SelectWorkOrder.php =================================================================== --- trunk/SelectWorkOrder.php 2011-04-02 09:40:49 UTC (rev 4536) +++ trunk/SelectWorkOrder.php 2011-04-03 03:24:25 UTC (rev 4537) @@ -2,14 +2,12 @@ /* $Id$*/ -//$PageSecurity = 2; - include('includes/session.inc'); $title = _('Search Work Orders'); include('includes/header.inc'); echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Search') . '" alt="" />' . ' ' . $title . '</p>'; -echo '<form action=' . $_SERVER['PHP_SELF'] .'?' .SID . ' method=post>'; +echo '<form action="' . $_SERVER['PHP_SELF'] . '" method=post>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; @@ -117,14 +115,14 @@ while ($myrow=DB_fetch_array($resultStkLocs)){ if (isset($_POST['StockLocation'])){ if ($myrow['loccode'] == $_POST['StockLocation']){ - echo "<option selected Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option selected value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } else { - echo "<option Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } } elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){ - echo "<option selected Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option selected value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } else { - echo "<option Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } } @@ -162,30 +160,30 @@ <select name='StockCat'>"; while ($myrow1 = DB_fetch_array($result1)) { - echo "<option value='". $myrow1['categoryid'] . "'>" . $myrow1['categorydescription']; + echo '<option value="'. $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; } echo '</select> - <td><font size=1>' . _('Enter text extract(s) in the description') . ":</font></td> - <td><input type='Text' name='Keywords' size=20 maxlength=25></td> + <td><font size=1>' . _('Enter text extract(s) in the description') . ':</font></td> + <td><input type="Text" name="Keywords" size="20" maxlength="25" /></td> </tr> <tr><td></td> - <td><font size=3><b>" . _('OR') . ' </b></font><font size=1>' . _('Enter extract of the Stock Code') . "</b>:</font></td> - <td><input type='Text' name='StockCode' size=15 maxlength=18></td> + <td><font size="3"><b>' . _('OR') . ' </b></font><font size=1>' . _('Enter extract of the Stock Code') . '</b>:</font></td> + <td><input type="Text" name="StockCode" size="15" maxlength="18"></td> </tr> - </table><br />"; - echo "<div class=centre><input type=submit name='SearchParts' value='" . _('Search Items Now') . "'> - <input type=submit name='ResetPart' value='" . _('Show All') . "'></div>"; + </table><br />'; + echo '<div class=centre><input type=submit name="SearchParts" value="' . _('Search Items Now') . '"> + <input type=submit name="ResetPart" value="' . _('Show All') . '"></div>'; if (isset($StockItemsResult)) { echo '<br /><table cellpadding=2 colspan=7 class=selection>'; - $TableHeader = "<tr> - <th>" . _('Code') . "</th> - <th>" . _('Description') . "</th> - <th>" . _('On Hand') . "</th> - <th>" . _('Units') . "</th> - </tr>"; + $TableHeader = '<tr> + <th>' . _('Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('On Hand') . '</th> + <th>' . _('Units') . '</th> + </tr>'; echo $TableHeader; $j = 1; @@ -249,7 +247,7 @@ WHERE workorders.closed='" . $ClosedOrOpen . "' AND workorders.wo='". $_REQUEST['WO'] ."' ORDER BY workorders.wo, - woitems.stockid"; + woitems.stockid"; } else { /* $DateAfterCriteria = FormatDateforSQL($OrdersAfterDate); */ @@ -293,18 +291,18 @@ echo '<br /><table cellpadding=2 colspan=7 width=95% class=selection>'; - $tableheader = "<tr> - <th>" . _('Modify') . "</th> - <th>" . _('Status') . "</th> - <th>" . _('Receive') . "</th> - <th>" . _('Issue To') . "</th> - <th>" . _('Costing') . "</th> - <th>" . _('Item') . "</th> - <th>" . _('Quantity Required') . "</th> - <th>" . _('Quantity Received') . "</th> - <th>" . _('Quantity Outstanding') . "</th> - <th>" . _('Required Date') . "</th> - </tr>"; + $tableheader = '<tr> + <th>' . _('Modify') . '</th> + <th>' . _('Status') . '</th> + <th>' . _('Receive') . '</th> + <th>' . _('Issue To') . '</th> + <th>' . _('Costing') . '</th> + <th>' . _('Item') . '</th> + <th>' . _('Quantity Required') . '</th> + <th>' . _('Quantity Received') . '</th> + <th>' . _('Quantity Outstanding') . '</th> + <th>' . _('Required Date') . '</th> + </tr>'; echo $tableheader; } @@ -320,11 +318,11 @@ $k++; } - $ModifyPage = $rootpath . "/WorkOrderEntry.php?" . SID . '&WO=' . $myrow['wo']; - $Status_WO = $rootpath . '/WorkOrderStatus.php?' . SID . '&WO=' .$myrow['wo'] . '&StockID=' . $myrow['stockid']; - $Receive_WO = $rootpath . '/WorkOrderReceive.php?' . SID . '&WO=' .$myrow['wo'] . '&StockID=' . $myrow['stockid']; - $Issue_WO = $rootpath . '/WorkOrderIssue.php?' . SID . '&WO=' .$myrow['wo'] . '&StockID=' . $myrow['stockid']; - $Costing_WO =$rootpath . '/WorkOrderCosting.php?' . SID . '&WO=' .$myrow['wo']; + $ModifyPage = $rootpath . '/WorkOrderEntry.php?WO=' . $myrow['wo']; + $Status_WO = $rootpath . '/WorkOrderStatus.php?WO=' .$myrow['wo'] . '&StockID=' . $myrow['stockid']; + $Receive_WO = $rootpath . '/WorkOrderReceive.php?WO=' .$myrow['wo'] . '&StockID=' . $myrow['stockid']; + $Issue_WO = $rootpath . '/WorkOrderIssue.php?WO=' .$myrow['wo'] . '&StockID=' . $myrow['stockid']; + $Costing_WO =$rootpath . '/WorkOrderCosting.php?WO=' .$myrow['wo']; $FormatedRequiredByDate = ConvertSQLDate($myrow['requiredby']); Modified: trunk/ShipmentCosting.php =================================================================== --- trunk/ShipmentCosting.php 2011-04-02 09:40:49 UTC (rev 4536) +++ trunk/ShipmentCosting.php 2011-04-03 03:24:25 UTC (rev 4537) @@ -2,8 +2,6 @@ /* $Id$*/ -//$PageSecurity = 11; - include('includes/session.inc'); $title = _('Shipment Costing'); /* Session started in header.inc for password checking and authorisation level check */ @@ -20,9 +18,9 @@ if (!isset($_GET['SelectedShipment'])){ - echo '<br>'; + echo '<br />'; prnMsg( _('This page is expected to be called with the shipment number to show the costing for'), 'error'); - include ("includes/footer.inc"); + include ('includes/footer.inc'); exit; } @@ -40,14 +38,14 @@ $ErrMsg = _('Shipment').' '. $_GET['SelectedShipment'] . ' ' . _('cannot be retrieved because a database error occurred'); $GetShiptHdrResult = DB_query($ShipmentHeaderSQL,$db, $ErrMsg); if (DB_num_rows($GetShiptHdrResult)==0) { - echo '<br>'; + echo '<br />'; prnMsg( _('Shipment') . ' ' . $_GET['SelectedShipment'] . ' ' . _('could not be located in the database') , 'error'); - include ("includes/footer.inc"); + include ('includes/footer.inc'); exit; } $HeaderData = DB_fetch_array($GetShiptHdrResult); -echo '<br>'; +echo '<br />'; echo '<table class=selection>'; echo '<tr><th colspan=4><font size=3 color=navy>'._('Shipment Details').'</font></th></tr>'; echo '<tr> @@ -73,7 +71,7 @@ $ErrMsg = _('Shipment') . ' ' . $_GET['SelectedShipment'] . ' ' . _('general costs cannot be retrieved from the database'); $GetShiptCostsResult = DB_query($sql,$db, $ErrMsg); if (DB_num_rows($GetShiptCostsResult)==0) { - echo '<br>'; + echo '<br />'; prnMsg ( _('No General Cost Records exist for Shipment') . ' ' . $_GET['SelectedShipment'] . ' ' . _('in the database'), 'error'); include ('includes/footer.inc'); exit; @@ -90,7 +88,7 @@ $ErrMsg = _('Shipment') . ' ' . $_GET['SelectedShipment'] . ' ' . _('Item costs cannot be retrieved from the database'); $GetShiptCostsResult = DB_query($sql,$db); if (DB_error_no($db) !=0 OR DB_num_rows($GetShiptCostsResult)==0) { - echo '<br>'; + echo '<br />'; prnMsg ( _('No Item Cost Records exist for Shipment') . ' ' . $_GET['SelectedShipment'] . ' ' . _('in the database'), 'error'); include ('includes/footer.inc'); exit; @@ -137,12 +135,12 @@ echo '<tr><th colspan=9><font color=navy size=3>' . _('Items on shipment'). '</font></th></tr>'; $TableHeader = '<tr> <th>'. _('Item'). '</th> - <th>'. _('Quantity'). '<br>'. _('Invoiced'). '</th> - <th>'. _('Quantity'). '<br>'. _('Received'). '</th> - <th>'. _('Invoiced'). '<br>'. _('Charges'). '</th> - <th>'. _('Shipment'). '<br>'. _('Charges'). '</th> - <th>'. _('Shipment'). '<br>'. _('Cost'). '</th> - <th>'. _('Standard'). '<br>'. _('Cost'). '</th> + <th>'. _('Quantity'). '<br />'. _('Invoiced'). '</th> + <th>'. _('Quantity'). '<br />'. _('Received'). '</th> + <th>'. _('Invoiced'). '<br />'. _('Charges'). '</th> + <th>'. _('Shipment'). '<br />'. _('Charges'). '</th> + <th>'. _('Shipment'). '<br />'. _('Cost'). '</th> + <th>'. _('Standard'). '<br />'. _('Cost'). '</th> <th>'. _('Variance'). '</th> <th>%</th></tr>'; echo $TableHeader; @@ -215,27 +213,27 @@ if ( isset($_POST['Close']) AND $Variance !=0){ - if ($_SESSION['CompanyRecord']['gllink_stock']==1){ - $StockGLCodes = GetStockGLCode($myrow['itemcode'],$db); - } + if ($_SESSION['CompanyRecord']['gllink_stock']==1){ + $StockGLCodes = GetStockGLCode($myrow['itemcode'],$db); + } - /*GL journals depend on the costing method used currently: - Standard cost - the price variance between the exisitng system cost and the shipment cost is taken as a variance - to the price varaince account - Weighted Average Cost - the price variance is taken to the stock account and the cost updated to ensure the GL - stock account ties up to the stock valuation - */ + /*GL journals depend on the costing method used currently: + Standard cost - the price variance between the exisitng system cost and the shipment cost is taken as a variance + to the price varaince account + Weighted Average Cost - the price variance is taken to the stock account and the cost updated to ensure the GL + stock account ties up to the stock valuation + */ - if ($_SESSION['WeightedAverageCosting'] == 1){ /* Do the WAvg journal and cost update */ - /* - First off figure out the new weighted average cost Need the following data: + if ($_SESSION['WeightedAverageCosting'] == 1){ /* Do the WAvg journal and cost update */ + /* + First off figure out the new weighted average cost Need the following data: - How many in stock now + How many in stock now The quantity being costed here - $myrow['qtyinvoiced'] The cost of these items - $ItemShipmentCost */ - $sql ='SELECT SUM(quantity) FROM locstock WHERE stockid="' . $myrow['itemcode'] . '"'; + $sql ="SELECT SUM(quantity) FROM locstock WHERE stockid='" . $myrow['itemcode'] . "'"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The quantity on hand could not be retrieved from the database'); $DbgMsg = _('The following SQL to retrieve the total stock quantity was used'); $Result = DB_query($sql, $db, $ErrMsg, $DbgMsg); @@ -247,68 +245,68 @@ But that's only provided that the total quantity in stock is > the quantity charged on this invoice */ - $WriteOffToVariances =0; + $WriteOffToVariances =0; - if ($myrow['totqtyinvoiced'] > $TotalQuantityOnHand){ + if ($myrow['totqtyinvoiced'] > $TotalQuantityOnHand){ - /*So we need to write off some of the variance to variances and - only the balance of the quantity in stock to go to stock value */ + /*So we need to write off some of the variance to variances and + only the balance of the quantity in stock to go to stock value */ - $WriteOffToVariances = ($myrow['totqtyinvoiced'] - $TotalQuantityOnHand) - * ($ItemShipmentCost - $StdCostUnit); - } + $WriteOffToVariances = ($myrow['totqtyinvoiced'] - $TotalQuantityOnHand) + * ($ItemShipmentCost - $StdCostUnit); + } - if ($_SESSION['CompanyRecord']['gllink_stock']==1){ + if ($_SESSION['CompanyRecord']['gllink_stock']==1){ /* If the quantity on hand is less the amount charged on this invoice then some must have been sold and the price variance on these must be written off to price variances*/ - if ($myrow['totqtyinvoiced'] > $TotalQuantityOnHand){ + if ($myrow['totqtyinvoiced'] > $TotalQuantityOnHand){ - $sql = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (31, - '" . $_GET['SelectedShipment'] . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $StockGLCodes['purchpricevaract'] . "', - '" . $myrow['itemcode'] . ' ' . _('shipment cost') . ' ' . number_format($ItemShipmentCost,2) . _('shipment quantity > stock held - variance write off') . "', - " . $WriteOffToVariances . ")"; + $sql = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (31, + '" . $_GET['SelectedShipment'] . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $StockGLCodes['purchpricevaract'] . "', + '" . $myrow['itemcode'] . ' ' . _('shipment cost') . ' ' . number_format($ItemShipmentCost,2) . _('shipment quantity > stock held - variance write off') . "', + " . $WriteOffToVariances . ")"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL entry for the shipment variance posting for'). ' ' . $myrow['itemcode'] . ' '. _('could not be inserted into the database because'); + $result = DB_query($sql,$db, $ErrMsg,'',TRUE); + + } + /*Now post any remaining price variance to stock rather than price variances */ + $sql = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (31, + '" . $_GET['SelectedShipment'] . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $StockGLCodes['stockact'] . "', + '" . $myrow['itemcode'] . ' ' . _('shipment avg cost adjt') . "', + '" . ($myrow['totqtyinvoiced'] *($ItemShipmentCost - $StdCostUnit) + - $WriteOffToVariances) . "')"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL entry for the shipment average cost adjustment for'). ' ' . $myrow['itemcode'] . ' '. _('could not be inserted into the database because'); + $result = DB_query($sql,$db, $ErrMsg,'',TRUE); - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL entry for the shipment variance posting for'). ' ' . $myrow['itemcode'] . ' '. _('could not be inserted into the database because'); - $result = DB_query($sql,$db, $ErrMsg,'',TRUE); + } /* end of average cost GL stuff */ - } - /*Now post any remaining price variance to stock rather than price variances */ - $sql = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (31, - '" . $_GET['SelectedShipment'] . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $StockGLCodes['stockact'] . "', - '" . $myrow['itemcode'] . ' ' . _('shipment avg cost adjt') . "', - '" . ($myrow['totqtyinvoiced'] *($ItemShipmentCost - $StdCostUnit) - - $WriteOffToVariances) . "')"; - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL entry for the shipment average cost adjustment for'). ' ' . $myrow['itemcode'] . ' '. _('could not be inserted into the database because'); - $result = DB_query($sql,$db, $ErrMsg,'',TRUE); - - } /* end of average cost GL stuff */ - - /*Now to update the stock cost with the new weighted average */ /*Need to consider what to do if the cost has been changed manually between receiving @@ -324,54 +322,54 @@ $CostIncrement = ($myrow['totqtyinvoiced'] *($ItemShipmentCost - $StdCostUnit) - $WriteOffToVariances) / $TotalQuantityOnHand; $sql = 'UPDATE stockmaster SET lastcost=materialcost+overheadcost+labourcost, - materialcost=materialcost+' . $CostIncrement . ' WHERE stockid="' . $myrow['itemcode'] . '"'; + materialcost=materialcost+' . $CostIncrement . " WHERE stockid='" . $myrow['itemcode'] . "'"; $Result = DB_query($sql, $db, $ErrMsg, $DbgMsg,'',TRUE); } else { $sql = "UPDATE stockmaster SET lastcost=materialcost+overheadcost+labourcost, materialcost='" . $ItemShipmentCost . "' WHERE stockid='" . $myrow['itemcode'] . "'"; $Result = DB_query($sql, $db, $ErrMsg, $DbgMsg,'',TRUE); - } + } /* End of Weighted Average Costing Code */ - } else { /*We must be using standard costing do the journals for standard costing then */ + } else { /*We must be using standard costing do the journals for standard costing then */ - if ($_SESSION['CompanyRecord']['gllink_stock']==1){ - $sql = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (31, - '" . $_GET['SelectedShipment'] . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $StockGLCodes['purchpricevaract'] . "', - '" . $myrow['itemcode'] . ' ' . _('shipment cost') . ' ' . number_format($ItemShipmentCost,2) . ' x ' . _('Qty recd') .' ' . $myrow['totqtyrecd'] . "', " . (-$Variance * $myrow['totqtyrecd']) . ")"; - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The Positive GL entry for the shipment variance posting for'). ' ' . $myrow['itemcode'] . ' '. _('could not be inserted into the database because'); - $result = DB_query($sql,$db, $ErrMsg,'',TRUE); - } - } /* end of the costing specific updates */ + if ($_SESSION['CompanyRecord']['gllink_stock']==1){ + $sql = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (31, + '" . $_GET['SelectedShipment'] . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $StockGLCodes['purchpricevaract'] . "', + '" . $myrow['itemcode'] . ' ' . _('shipment cost') . ' ' . number_format($ItemShipmentCost,2) . ' x ' . _('Qty recd') .' ' . $myrow['totqtyrecd'] . "', " . (-$Variance * $myrow['totqtyrecd']) . ")"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The Positive GL entry for the shipment variance posting for'). ' ' . $myrow['itemcode'] . ' '. _('could not be inserted into the database because'); + $result = DB_query($sql,$db, $ErrMsg,'',TRUE); + } + } /* end of the costing specific updates */ - if ($_SESSION['CompanyRecord']['gllink_stock']==1){ + if ($_SESSION['CompanyRecord']['gllink_stock']==1){ /*we always need to reverse entries relating to the GRN suspense during delivery and entry of shipment charges */ - $sql = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (31, - '" . $_GET['SelectedShipment'] . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $_SESSION['CompanyRecord']['grnact'] . "', - '" . $myrow['itemcode'] . ' ' ._('shipment cost') . ' ' . number_format($ItemShipmentCost,2) . ' x ' . _('Qty invoiced') . ' ' . $myrow['totqtyinvoiced'] . "', - " . ($Variance * $myrow['totqtyinvoiced']) . ")"; + $sql = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (31, + '" . $_GET['SelectedShipment'] . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $_SESSION['CompanyRecord']['grnact'] . "', + '" . $myrow['itemcode'] . ' ' ._('shipment cost') . ' ' . number_format($ItemShipmentCost,2) . ' x ' . _('Qty invoiced') . ' ' . $myrow['totqtyinvoiced'] . "', + " . ($Variance * $myrow['totqtyinvoiced']) . ")"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The credit GL entry for the shipment variance posting for') . ' ' . $myrow['itemcode'] . ' ' . _('could not be inserted because'); @@ -381,66 +379,66 @@ if ( $_POST['UpdateCost'] == 'Yes' ){ /*Only ever a standard costing option Weighted average costing implies cost updates taking place automatically */ - $QOHResult = DB_query("SELECT SUM(quantity) FROM locstock WHERE stockid ='" . $myrow['itemcode'] . "'",$db); - $QOHRow = DB_fetch_row($QOHResult); - $QOH=$QOHRow[0]; + $QOHResult = DB_query("SELECT SUM(quantity) FROM locstock WHERE stockid ='" . $myrow['itemcode'] . "'",$db); + $QOHRow = DB_fetch_row($QOHResult); + $QOH=$QOHRow[0]; - if ($_SESSION['CompanyRecord']['gllink_stock']==1){ - $CostUpdateNo = GetNextTransNo(35, $db); - $PeriodNo = GetPeriod(Date("d/m/Y"), $db); + if ($_SESSION['CompanyRecord']['gllink_stock']==1){ + $CostUpdateNo = GetNextTransNo(35, $db); + $PeriodNo = GetPeriod(Date("d/m/Y"), $db); - $ValueOfChange = $QOH * ($ItemShipmentCost - $StdCostUnit); + $ValueOfChange = $QOH * ($ItemShipmentCost - $StdCostUnit); - $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (35, - '" . $CostUpdateNo . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $StockGLCodes['adjglact'] . "', - '" . _('Shipment of') . ' ' . $myrow['itemcode'] . " " . _('cost was') . ' ' . $StdCostUnit . ' ' . _('changed to') . ' ' . number_format($ItemShipmentCost,2) . ' x ' . _('QOH of') . ' ' . $QOH . "', " . (-$ValueOfChange) . ")"; + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (35, + '" . $CostUpdateNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $StockGLCodes['adjglact'] . "', + '" . _('Shipment of') . ' ' . $myrow['itemcode'] . " " . _('cost was') . ' ' . $StdCostUnit . ' ' . _('changed to') . ' ' . number_format($ItemShipmentCost,2) . ' x ' . _('QOH of') . ' ' . $QOH . "', " . (-$ValueOfChange) . ")"; - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL credit for the shipment stock cost adjustment posting could not be inserted because'). ' ' . DB_error_msg($db); + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL credit for the shipment stock cost adjustment posting could not be inserted because'). ' ' . DB_error_msg($db); + + $Result = DB_query($SQL,$db, $ErrMsg,'',TRUE); + + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (35, + '" . $CostUpdateNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $StockGLCodes['stockact'] . "', + '" . _('Shipment of') . ' ' . $myrow['itemcode'] . ' ' . _('cost was') . ' ' . $StdCostUnit . ' ' . _('changed to') . ' ' . number_format($ItemShipmentCost,2) . ' x ' . _('QOH of') . ' ' . $QOH . "', + " . $ValueOfChange . ")"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL debit for stock cost adjustment posting could not be inserted because') .' '. DB_error_msg($db); + + $Result = DB_query($SQL,$db, $ErrMsg,'',TRUE); + + } /*end of GL entries for a standard cost update */ - $Result = DB_query($SQL,$db, $ErrMsg,'',TRUE); - - $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (35, - '" . $CostUpdateNo . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $StockGLCodes['stockact'] . "', - '" . _('Shipment of') . ' ' . $myrow['itemcode'] . ' ' . _('cost was') . ' ' . $StdCostUnit . ' ' . _('changed to') . ' ' . number_format($ItemShipmentCost,2) . ' x ' . _('QOH of') . ' ' . $QOH . "', - " . $ValueOfChange . ")"; - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL debit for stock cost adjustment posting could not be inserted because') .' '. DB_error_msg($db); - - $Result = DB_query($SQL,$db, $ErrMsg,'',TRUE); - - } /*end of GL entries for a standard cost update */ - /* Only the material cost is important for imported items */ - $sql = "UPDATE stockmaster SET materialcost=" . $ItemShipmentCost . ", - labourcost=0, - overheadcost=0, - lastcost='" . $StdCostUnit . "' - WHERE stockid='" . $myrow['itemcode'] . "'"; + $sql = "UPDATE stockmaster SET materialcost=" . $ItemShipmentCost . ", + labourcost=0, + overheadcost=0, + lastcost='" . $StdCostUnit . "' + WHERE stockid='" . $myrow['itemcode'] . "'"; - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The shipment cost details for the stock item could not be updated because'). ': ' . DB_error_msg($db); + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The shipment cost details for the stock item could not be updated because'). ': ' . DB_error_msg($db); - $result = DB_query($sql,$db, $ErrMsg,'',TRUE); + $result = DB_query($sql,$db, $ErrMsg,'',TRUE); - } // end of update cost code + } // end of update cost code } // end of Close shipment item updates @@ -502,7 +500,7 @@ <th>'. _('Ref'). '</th> <th>'. _('Date'). '</th> <th>'. _('Item'). '</th> - <th>'. _('Local Amount'). '<br>'. _('Charged'). '</th></tr>'; + <th>'. _('Local Amount'). '<br />'. _('Charged'). '</th></tr>'; echo $TableHeader; @@ -572,7 +570,7 @@ <th>'. _('Type'). '</th> <th>'. _('Ref'). '</th> <th>'. _('Date'). '</th> - <th>'. _('Local Amount'). '<br>'. _('Charged'). '</th></tr>'; + <th>'. _('Local Amount'). '<br />'. _('Charged'). '</th></tr>'; echo $TableHeader; @@ -613,16 +611,17 @@ if ( isset($_GET['Close'])) { /* Only an opportunity to confirm user wishes to close */ // if the page was called with Close=Yes then show options to confirm OK to c - echo '<div class+"centre"><form method="POST" action="' . $_SERVER['PHP_SELF'] .'?' . SID .'&SelectedShipment=' . $_GET['SelectedShipment'] . '">'; + echo '<div class+"centre"><form method="POST" action="' . $_SERVER['PHP_SELF'] .'?SelectedShipment=' . $_GET['SelectedShipment'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; if ($_SESSION['WeightedAverageCosting']==0){ /* We are standard costing - so show the option to update costs - under W. Avg cost updates are implicit */ echo _('Update Standard Costs') .':<select name="UpdateCost"> - <option selected VALUE="Yes">'. _('Yes') . ' - <option VALUE="No">'. _('No').'</select>'; + <option selected VALUE="Yes">'. _('Yes') . '</option> + <option VALUE="No">'. _('No') . '</option> + </select>'; } - echo '<br><br><input type=submit name="Close" VALUE="'. _('Confirm OK to Close'). '">'; + echo '<br /><br /><input type=submit name="Close" VALUE="'. _('Confirm OK to Close'). '">'; echo '</form></div>'; } @@ -651,14 +650,14 @@ $result = DB_query("UPDATE shipments SET closed=1 WHERE shiptref='" .$_GET['SelectedShipment']. "'",$db,_('Could not update the shipment to closed'),'',TRUE); $result = DB_Txn_Commit($db); - echo '<br><br>'; + echo '<br /><br />'; prnMsg( _('Shipment'). ' ' . $_GET['SelectedShipment'] . ' ' . _('has been closed') ); if ($_SESSION['CompanyRecord']['gllink_stock']==1) { - echo '<br>'; + echo '<br />'; prnMsg ( _('All variances were posted to the general ledger') ); } If ($_POST['UpdateCost']=='Yes'){ - echo '<br>'; + echo '<br />'; prnMsg ( _('All shipment items have had their standard costs updated') ); } } Modified: trunk/StockAdjustments.php =================================================================== --- trunk/StockAdjustments.php 2011-04-02 09:40:49 UTC (rev 4536) +++ trunk/StockAdjustments.php 2011-04-03 03:24:25 UTC (rev 4537) @@ -4,8 +4,6 @@ include('includes/DefineStockAdjustment.php'); include('includes/DefineSerialItems.php'); - -//$PageSecurity = 11; include('includes/session.inc'); $title = _('Stock Adjustments'); @@ -61,16 +59,18 @@ '" alt="" />' . ' ' . _('Select Item to Adjust') . '</p>'; if (strlen($_POST['StockText'])>0) { - $sql='SELECT stockid, description from stockmaster where description like "%'.$_POST['StockText'].'%"'; + $sql="SELECT stockid, description from stockmaster where description like '%" . $_POST['StockText'] ."%'"; } else { - $sql='SELECT stockid, description from stockmaster where stockid like "%'.$_POST['StockCode'].'%"'; + $sql="SELECT stockid, description from stockmaster where stockid like '%" . $_POST['StockCode'] ."%'"; } $ErrMsg=_('The stock information cannot be retrieved because'); $DbgMsg=_('The SQL to get the stock description was'); $result = DB_query($sql,$db,$ErrMsg,$DbgMsg); echo '<table class=selection><tr><th>'._('Stock Code').'</th><th>'._('Stock Description').'</th></tr>'; while ($myrow = DB_fetch_row($result)) { - echo '<tr><td>'.$myrow[0].'</td><td>'.$myrow[1].'</td><td><a href="StockAdjustments.php?StockID='.$myrow[0].'&Description='.$myrow[1].'">'._('Adjust').'</a></tr>'; + echo '<tr><td>'.$myrow[0].'</td> + <td>'.$myrow[1].'</td> + <td><a href="StockAdjustments.php?StockID='.$myrow[0].'&Description='.$myrow[1].'">'._('Adjust').'</a></tr>'; } echo '</table>'; include('includes/footer.inc'); @@ -132,27 +132,26 @@ $QtyOnHandPrior = 0; } - $SQL = "INSERT INTO stockmoves ( - stockid, - type, - transno, - loccode, - trandate, - prd, - reference, - qty, - newqoh) - VALUES ( - '" . $_SESSION['Adjustment']->StockID . "', - 17, - '" . $AdjustmentNumber . "', - '" . $_SESSION['Adjustment']->StockLocation . "', - '" . $SQLAdjustmentDate . "', - '" . $PeriodNo . "', - '" . $_SESSION['Adjustment']->Narrative ."', - '" . $_SESSION['Adjustment']->Quantity . "', - '" . ($QtyOnHandPrior + $_SESSION['Adjustment']->Quantity) . "' - )"; + $SQL = "INSERT INTO stockmoves ( stockid, + type, + transno, + loccode, + trandate, + prd, + reference, + qty, + newqoh) + VALUES ( + '" . $_SESSION['Adjustment']->StockID . "', + 17, + '" . $AdjustmentNumber . "', + '" . $_SESSION['Adjustment']->StockLocation . "', + '" . $SQLAdjustmentDate . "', + '" . $PeriodNo . "', + '" . $_SESSION['Adjustment']->Narrative ."', + '" . $_SESSION['Adjustment']->Quantity . "', + '" . ($QtyOnHandPrior + $_SESSION['Adjustment']->Quantity) . "' + )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock movement record cannot be inserted because'); @@ -172,23 +171,22 @@ /*First need to check if the serial items already exists or not */ $SQL = "SELECT COUNT(*) - FROM stockserialitems - WHERE - stockid='" . $_SESSION['Adjustment']->StockID . "' - AND loccode='" . $_SESSION['Adjustment']->StockLocation . "' - AND serialno='" . $Item->BundleRef . "'"; + FROM stockserialitems + WHERE + stockid='" . $_SESSION['Adjustment']->StockID . "' + AND loccode='" . $_SESSION['Adjustment']->StockLocation . "' + AND serialno='" . $Item->BundleRef . "'"; $ErrMsg = _('Unable to determine if the serial item exists'); $Result = DB_query($SQL,$db,$ErrMsg); $SerialItemExistsRow = DB_fetch_row($Result); if ($SerialItemExistsRow[0]==1){ - $SQL = "UPDATE stockserialitems SET - quantity= quantity + " . $Item->BundleQty . " - WHERE - stockid='" . $_SESSION['Adjustment']->StockID . "' - AND loccode='" . $_SESSION['Adjustment']->StockLocation . "' - AND serialno='" . $Item->BundleRef . "'"; + $SQL = "UPDATE stockserialitems SET quantity= quantity + " . $Item->BundleQty . " + WHERE + stockid='" . $_SESSION['Adjustment']->StockID . "' + AND loccode='" . $_SESSION['Adjustment']->StockLocation . "' + AND serialno='" . $Item->BundleRef . "'"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock item record could not be updated because'); $DbgMsg = _('The following SQL to update the serial stock item record was used'); @@ -196,16 +194,16 @@ } else { /*Need to insert a new serial item record */ $SQL = "INSERT INTO stockserialitems (stockid, - loccode, - serialno, - qualitytext, - quantity) - VALUES ('" . $_SESSION['Adjustment']->StockID . "', - '" . $_SESSION['Adjustment']->StockLocation . "', - '" . $Item->BundleRef . "', - '', - '" . $Item->BundleQty . "' - )"; + loccode, + serialno, + qualitytext, + quantity) + VALUES ('" . $_SESSION['Adjustment']->StockID . "', + '" . $_SESSION['Adjustment']->StockLocation . "', + '" . $Item->BundleRef . "', + '', + '" . $Item->BundleQty . "' + )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock item record could not be updated because'); $DbgMsg = _('The following SQL to update the serial stock item record was used'); @@ -216,13 +214,13 @@ /* now insert the serial stock movement */ $SQL = "INSERT INTO stockserialmoves (stockmoveno, - stockid, - serialno, - moveqty) - VALUES ('" . $StkMoveNo . "', - '" . $_SESSION['Adjustment']->StockID . "', - '" . $Item->BundleRef . "', - '" . $Item->BundleQty . "')"; + stockid, + serialno, + moveqty) + VALUES ('" . $StkMoveNo . "', + '" . $_SESSION['Adjustment']->StockID . "', + '" . $Item->BundleRef . "', + '" . $Item->BundleQty . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock movement record could not be inserted because'); $DbgMsg = _('The following SQL to insert the serial stock movement records was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); @@ -246,45 +244,45 @@ $StockGLCodes = GetStockGLCode($_SESSION['Adjustment']->StockID,$db); $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - amount, - narrative, - tag) - VALUES (17, - '" .$AdjustmentNumber . "', - '" . $SQLAdjustmentDate . "', - '" . $PeriodNo . "', - '" . $StockGLCodes['adjglact'] . "', - '" . $_SESSION['Adjustment']->StandardCost * -($_SESSION['Adjustment']->Quantity) . "', - '" . $_SESSION['Adjustment']->StockID . " x " . $_SESSION['Adjustment']->Quantity . " @ " . - $_SESSION['Adjustment']->StandardCost . " " . $_SESSION['Adjustment']->Narrative . "', - '" . $_SESSION['Adjustment']->tag . "' - )"; + typeno, + trandate, + periodno, + account, + amount, + narrative, + tag) + VALUES (17, + '" .$AdjustmentNumber . "', + '" . $SQLAdjustmentDate . "', + '" . $PeriodNo . "', + '" . $StockGLCodes['adjglact'] . "', + '" . $_SESSION['Adjustment']->StandardCost * -($_SESSION['Adjustment']->Quantity) . "', + '" . $_SESSION['Adjustment']->StockID . " x " . $_SESSION['Adjustment']->Quantity . " @ " . + $_SESSION['Adjustment']->StandardCost . " " . $_SESSION['Adjustment']->Narrative . "', + '" . $_SESSION['Adjustment']->tag . "' + )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction entries could not be added because'); $DbgMsg = _('The following SQL to insert the GL entries was used'); $Result = DB_query($SQL,$db, $ErrMsg, $DbgMsg, true); $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - amount, - narrative, - tag) - VALUES (17, - '" .$AdjustmentNumber . "', - '" . $SQLAdjustmentDate . "', - '" . $PeriodNo . "', - '" . $StockGLCodes['stockact'] . "', - '" . $_SESSION['Adjustment']->StandardCost * $_SESSION['Adjustment']->Quantity . "', - '" . $_SESSION['Adjustment']->StockID . " x " . $_SESSION['Adjustment']->Quantity . " @ " . $_SESSION['Adjustment']->StandardCost . " " . $_SESSION['Adjustment']->Narrative . "', - '" . $_SESSION['Adjustment']->tag . "' - )"; + typeno, + trandate, + periodno, + account, + amount, + narrative, + tag) + VALUES (17, + '" .$AdjustmentNumber . "', + '" . $SQLAdjustmentDate . "', + '" . $PeriodNo . "', + '" . $StockGLCodes['stockact'] . "', + '" . $_SESSION['Adjustment']->StandardCost * $_SESSION['Adjustment']->Quantity . "', + '" . $_SESSION['Adjustment']->StockID . " x " . $_SESSION['Adjustment']->Quantity . " @ " . $_SESSION['Adjustment']->StandardCost . " " . $_SESSION['Adjustment']->Narrative . "', + '" . $_SESSION['Adjustment']->tag . "' + )"; $Errmsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction entries could not be added because'); $DbgMsg = _('The following SQL to insert the GL entries was used'); @@ -388,18 +386,18 @@ //Select the tag echo '<tr><td>'._('Select Tag').'</td><td><select name="tag">'; -$SQL = "SELECT tagref, +$SQL = 'SELECT tagref, tagdescription FROM tags - ORDER BY tagref"; + ORDER BY tagref'; $result=DB_query($SQL,$db); echo '<option value=0>0 - None'; while ($myrow=DB_fetch_array($result)){ if (isset($_SESSION['Adjustment']->tag) and $_SESSION['Adjustment']->tag==$myrow['tagref']){ - echo '<option selected value=' . $myrow['tagref'] . '>' . $myrow['tagref'].' - ' .$myrow['tagdescription']; + echo '<option selected value=' . $myrow['tagref'] . '>' . $myrow['tagref'].' - ' .$myrow['tagdescription'] . '</option>'; } else { - echo '<option value=' . $myrow['tagref'] . '>' . $myrow['tagref'].' - ' .$myrow['tagdescription']; + echo '<option value=' . $myrow['tagref'] . '>' . $myrow['tagref'].' - ' .$myrow['tagdescription']. '</option>'; } } echo '</select></td>'; @@ -411,11 +409,11 @@ $_POST['StockLocation']=''; } -echo '<br><a href="'. $rootpath. '/StockStatus.php?' . SID . '&StockID='. $StockID . '">'._('Show Stock Status').'</a>'; -echo '<br><a href="'.$rootpath.'/StockMovements.php?' . SID . '&StockID=' . $StockID . '">'._('Show Movements').'</a>'; -echo '<br><a href="'.$rootpath.'/StockUsage.php?' . SID . '&StockID=' . $StockID . '&StockLocation=' . $_POST['StockLocation'] . '">'._('Show Stock Usage').'</a>'; -echo '<br><a href="'.$rootpath.'/SelectSalesOrder.php?' . SID . '&SelectedStockItem='. $StockID .'&StockLocation=' . $_POST['StockLocation'] . '">'. _('Search Outstanding Sales Orders').'</a>'; -echo '<br><a href="'.$rootpath.'/SelectCompletedOrder.php?' . SID . '&SelectedStockItem=' . $StockID .'">'._('Search Completed Sales Orders').'</a>'; +echo '<br><a href="'. $rootpath. '/StockStatus.php?StockID='. $StockID . '">'._('Show Stock Status').'</a>'; +echo '<br><a href="'.$rootpath.'/StockMovements.php?StockID=' . $StockID . '">'._('Show Movements').'</a>'; +echo '<br><a href="'.$rootpath.'/StockUsage.php?StockID=' . $StockID . '&StockLocation=' . $_POST['StockLocation'] . '">'._('Show Stock Usage').'</a>'; +echo '<br><a href="'.$rootpath.'/SelectSalesOrder.php?SelectedStockItem='. $StockID .'&StockLocation=' . $_POST['StockLocation'] . '">'. _('Search Outstanding Sales Orders').'</a>'; +echo '<br><a href="'.$rootpath.'/SelectCompletedOrder.php?SelectedStockItem=' . $StockID .'">'._('Search Completed Sales Orders').'</a>'; echo '</div></form>'; include('includes/footer.inc'); Modified: trunk/StockDispatch.php =================================================================== --- trunk/StockDispatch.php 2011-04-02 09:40:49 UTC (rev 4536) +++ trunk/StockDispatch.php 2011-04-03 03:24:25 UTC (rev 4537) @@ -1,11 +1,10 @@ <?php /* $Id$*/ + // StockDispatch.php - Report of parts with overstock at one location that can be transferred // to another location to cover shortage based on reorder level. Creates loctransfer records // that can be processed using Bulk Inventory Transfer - Receive. - -//$PageSecurity = 2; include('includes/session.inc'); include('includes/SQL_CommonFunctions.inc'); If (isset($_POST['PrintPDF'])) { @@ -49,9 +48,9 @@ // Creates WHERE clause for stock categories. StockCat is defined as an array so can choose // more than one category - $wherecategory = " "; + $WhereCategory = " "; if ($_POST['StockCat'] != 'All') { - $wherecategory = " AND stockmaster.categoryid ='" . $_POST['StockCat'] . "' "; + $WhereCategory = " AND stockmaster.categoryid ='" . $_POST['StockCat'] . "' "; } @@ -82,7 +81,7 @@ AND (fromlocstock.quantity - fromlocstock.reorderlevel) > 0 AND stockcategory.stocktype<>'A' AND (stockmaster.mbflag='B' OR stockmaster.mbflag='M') " . - $wherecategory . " ORDER BY locstock.loccode,locstock.stockid"; + $WhereCategory . " ORDER BY locstock.loccode,locstock.stockid"; $result = DB_query($sql,$db,'','',false,true); @@ -236,13 +235,13 @@ if (!isset($_POST['FromLocation'])) { $_POST['FromLocation']=$DefaultLocation; } - echo '<table class=selection><tr><td>' . _('Dispatch Percent') . ":</td><td><input type ='text' name='Percent' class=number size='8' value=0>"; + echo '<table class=selection><tr><td>' . _('Dispatch Percent') . ':</td><td><input type ="text" name="Percent" class="number" size="8" value=0>'; echo '<tr><td>' . _('From Stock Location') . ':</td><td><select name="FromLocation"> '; while ($myrow=DB_fetch_array($resultStkLocs)){ if ($myrow['loccode'] == $_POST['FromLocation']){ - echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } else { - echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } } echo '</select></td></tr>'; @@ -253,60 +252,60 @@ echo '<tr><td>' . _('To Stock Location') . ':</td><td><select name="ToLocation"> '; while ($myrow=DB_fetch_array($resultStkLocs)){ if ($myrow['loccode'] == $_POST['ToLocation']){ - echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } else { - echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } } echo '</select></td></tr>'; - $SQL='SELECT categoryid, categorydescription FROM stockcategory WHERE stocktype<>"A" ORDER BY categorydescription'; + $SQL='SELECT categoryid, categorydescription FROM stockcategory ORDER BY categorydescription'; $result1 = DB_query($SQL,$db); if (DB_num_rows($result1)==0){ echo '</table></td></tr> </table> <p>'; prnMsg(_('There are no stock categories currently defined please use the link below to set them up'),'warn'); - echo '<br><a href="' . $rootpath . '/StockCategories.php?' . SID .'">' . _('Define Stock Categories') . '</a>'; + echo '<br><a href="' . $rootpath . '/StockCategories.php">' . _('Define Stock Categories') . '</a>'; include ('includes/footer.inc'); exit; } // Define StockCat with 'name="StockCat[ ]" multiple' so can select more than one - // Also have to change way define $wherecategory for WHERE clause + // Also have to change way define $WhereCategory for WHERE clause echo '<tr><td>' . _('In Stock Category') . ':</td><td><select name="StockCat">'; if (!isset($_POST['StockCat'])){ $_POST['StockCat']='All'; } if ($_POST['StockCat']=='All'){ - echo '<option selected value="All">' . _('All'); + echo '<option selected value="All">' . _('All') . '</option>'; } else { - echo '<option value="All">' . _('All'); + echo '<option value="All">' . _('All') . '</option>'; } while ($myrow1 = DB_fetch_array($result1)) { if ($myrow1['categoryid']==$_POST['StockCat']){ - echo '<option selected value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription']; + echo '<option selected value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; } else { - echo '<option value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription']; + echo '<option value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; } } echo '</select></td></tr>'; echo '<tr></tr><tr></tr><tr><td>' . _('Report Type') . ':</td>'; - echo "<td><select name='ReportType'>"; - echo "<option selected value='Batch'>" . _('Create Batch'); - echo "<option value='Report'>" . _('Report Only'); + echo '<td><select name="ReportType">'; + echo '<option selected value="Batch">' . _('Create Batch') . '</option>'; + echo '<option value="Report">' . _('Report Only') . '</option>'; echo '</select></td><td> </td></tr>'; echo '<tr><td>' . _('Template') . ':</td>'; - echo "<td><select name='template'>"; - echo "<option selected value='standard'>" . _('Standard'); - echo "<option value='simple'>" . _('Simple'); + echo '<td><select name="template">'; + echo '<option selected value="standard">' . _('Standard') . '</option>'; + echo '<option value="simple">' . _('Simple') . '</option>'; echo '</select></td><td> </td></tr>'; - echo "</table><br/><div class='centre'><input type=submit name='PrintPDF' value='" . _('Print PDF') . "'></div>"; + echo '</table><br/><div class="centre"><input type="submit" name="PrintPDF" value="' . _('Print PDF') . '"></div>'; include('includes/footer.inc'); @@ -377,4 +376,4 @@ $FontSize=8; $PageNumber++; } // End of PrintHeader() function -?> +?> \ No newline at end of file Modified: trunk/StockTransfers.php =================================================================== --- trunk/StockTransfers.php 2011-04-02 09:40:49 UTC (rev 4536) +++ trunk/StockTransfers.php 2011-04-03 03:24:25 UTC (rev 4537) @@ -5,7 +5,6 @@ include('includes/DefineSerialItems.php'); include('includes/DefineStockTransfers.php'); -//$PageSecurity = 11; include('includes/session.inc'); $title = _('Stock Transfers'); @@ -18,16 +17,21 @@ '" alt="" />' . ' ' . _('Select Item to Transfer') . '</p>'; if (strlen($_POST['StockText'])>0) { - $sql='SELECT stockid, description from stockmaster where description like "%'.$_POST['StockText'].'%"'; + $sql="SELECT stockid, description from stockmaster where description like '%" . $_POST['StockText'] . "%'"; } else { - $sql='SELECT stockid, description from stockmaster where stockid like "%'.$_POST['StockCode'].'%"'; + $sql="SELECT stockid, description from stockmaster where stockid like '%" . $_POST['StockCode']."%'"; } $ErrMsg=_('The stock information cannot be retrieved because'); $DbgMsg=_('The SQL to get the stock description was'); $result = DB_query($sql,$db,$ErrMsg,$DbgMsg); - echo '<table class=selection><tr><th>'._('Stock Code').'</th><th>'._('Stock Description').'</th></tr>'; + echo '<table class=selection><tr><th>'._('Stock Code').'</th> + <th>'._('Stock Description').'</th> + </tr>'; while ($myrow = DB_fetch_row($result)) { - echo '<tr><td>'.$myrow[0].'</td><td>'.$myrow[1].'</td><td><a href="StockTransfers.php?StockID='.$myrow[0].'&Description='.$myrow[1].'">Transfer</a></tr>'; + echo '<tr><td>'.$myrow[0].'</td> + <td>'.$myrow[1].'</td> + <td><a href="StockTransfers.php?StockID='.$myrow[0].'&Description='.$myrow[1].'">Transfer</a></td> + </tr>'; } echo '</table>'; include('includes/footer.inc'); @@ -57,42 +61,42 @@ if ($NewTransfer){ $_SESSION['Transfer']= new StockTransfer(0, - $_POST['StockLocationFrom'], - '', - $_POST['StockLocationTo'], - '', - Date($_SESSION['DefaultDateFormat']) - ); + $_POST['StockLocationFrom'], + '', + $_POST['StockLocationTo'], + '', + Date($_SESSION['DefaultDateFormat']) + ); $result = DB_query("SELECT description, - units, - mbflag, - materialcost+labourcost+overheadcost as standardcost, - controlled, - serialised, - decimalplaces - FROM stockmaster - WHERE stockid='" . trim(strtoupper($_POST['StockID'])) . "'", - $db); + units, + mbflag, + materialcost+labourcost+overheadcost as standardcost, + controlled, + serialised, + decimalplaces + FROM stockmaster + WHERE stockid='" . trim(strtoupper($_POST['StockID'])) . "'", + $db); $myrow = DB_fetch_row($result); if (DB_num_rows($result) == 0){ prnMsg( _('Unable to locate Stock Code').' '.strtoupper($_POST['StockID']), 'error' ); } elseif (DB_num_rows($result)>0){ $_SESSION['Transfer']->TransferItem[0] = new LineItem ( trim(strtoupper($_POST['StockID'])), - $myrow[0], - $_POST['Quantity'], - $myrow[1], - $myrow[4], - $myrow[5], - $myrow[6]); + $myrow[0], + $_POST['Quantity'], + $myrow[1], + $myrow[4], + $myrow[5], + $myrow[6]); + - $_SESSION['Transfer']->TransferItem[0]->StandardCost = $myrow[3]; if ($myrow[2]=='D' OR $myrow[2]=='A' OR $myrow[2]=='K'){ prnMsg(_('The part entered is either or a dummy part or an assembly or a kit-set part') . '. ' . _('These parts are not physical parts and no stock holding is maintained for them') . '. ' . _('Stock Transfers are therefore not possible'),'warn'); echo '.<hr>'; - echo "<a href='" . $rootpath . '/StockTransfers.php?' . SID ."&NewTransfer=Yes'>" . _('Enter another Transfer') . '</a>'; + echo '<a href="' . $rootpath . '/StockTransfers.php?NewTransfer=Yes">' . _('Enter another Transfer') . '</a>'; unset ($_SESSION['Transfer']); include ('includes/footer.inc'); exit; @@ -373,8 +377,7 @@ } /*end if the transfer item is a controlled item */ - $SQL = "UPDATE locstock - SET quantity = quantity - '" . $_SESSION['Transfer']->TransferItem[0]->Quantity . "' + $SQL = "UPDATE locstock SET quantity = quantity - '" . $_SESSION['Transfer']->TransferItem[0]->Quantity . "' WHERE stockid='" . $_SESSION['Transfer']->TransferItem[0]->StockID . "' AND loccode='" . $_SESSION['Transfer']->StockLocationFrom . "'"; @@ -416,7 +419,7 @@ echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Dispatch') . '" alt="" />' . ' ' . $title . '</p>'; -echo '<form action="'. $_SERVER['PHP_SELF'] . '?' . SID . '" method=post>'; +echo '<form action="'. $_SERVER['PHP_SELF'] . '" method=post>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; //echo '<table> @@ -454,15 +457,15 @@ while ($myrow=DB_fetch_array($resultStkLocs)){ if (isset($_SESSION['Transfer']->StockLocationFrom)){ if ($myrow['loccode'] == $_SESSION['Transfer']->StockLocationFrom){ - echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } else { - echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } } elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){ - echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; - $_SESSION['Transfer']->StockLocationFrom=$myrow['loccode']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; + $_SESSION['Transfer']->StockLocationFrom=$myrow['loccode'] . '</option>'; } else { - echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } } @@ -475,15 +478,15 @@ while ($myrow=DB_fetch_array($resultStkLocs)){ if (isset($_SESSION['Transfer']->StockLocationTo)){ if ($myrow['loccode'] == $_SESSION['Transfer']->StockLocationTo){ - echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } else { - echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } } elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){ - echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; - $_SESSION['Transfer']->StockLocationTo=$myrow['loccode']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; + $_SESSION['Transfer']->StockLocationTo=$myrow['loccode'] . '</option>'; } else { - echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } } @@ -497,12 +500,12 @@ } if ($_SESSION['Transfer']->TransferItem[0]->Controlled==1){ - echo '<td class=number><input type=hidden name="Quantity" value=' . $_SESSION['Transfer']->TransferItem[0]->Quantity . '><a href="' . $rootpath .'/StockTransferControlled.php?' . SID . '">' . $_SESSION['Transfer']->TransferItem[0]->Quantity . '</a></td></tr>'; + echo '<td class=number><input type=hidden name="Quantity" value=' . $_SESSION['Transfer']->TransferItem[0]->Quantity . '><a href="' . $rootpath .'/StockTransferControlled.php">' . $_SESSION['Transfer']->TransferItem[0]->Quantity . '</a></td></tr>'; } else { - echo '<td><input type=text class="number" name="Quantity" size=12 maxlength=12 Value=' . $_SESSION['Transfer']->TransferItem[0]->Quantity . '></td></tr>'; + echo '<td><input type=text class="number" name="Quantity" size=12 maxlength=12 value=' . $_SESSION['Transfer']->TransferItem[0]->Quantity . '></td></tr>'; } -echo "</table><div class='centre'><br><input type=submit name='EnterTransfer' VALUE='" . _('Enter Stock Transfer') . "'><br>"; +echo '</table><div class="centre"><br /><input type="submit" name="EnterTransfer" value="' . _('Enter Stock Transfer') . '"><br />'; if (empty($_SESSION['Transfer']->TransferItem[0]->StockID) and isset($_POST['StockID'])) { $Stoc... [truncated message content] |