From: <tim...@us...> - 2010-07-10 11:43:43
|
Revision: 3601 http://web-erp.svn.sourceforge.net/web-erp/?rev=3601&view=rev Author: tim_schofield Date: 2010-07-10 11:43:37 +0000 (Sat, 10 Jul 2010) Log Message: ----------- Bug fixes, correctly round the decimal places, fix sql quoting errors and layout changes Modified Paths: -------------- trunk/StockLocTransfer.php trunk/StockLocTransferReceive.php trunk/doc/Change.log.html trunk/includes/DefineStockTransfers.php Modified: trunk/StockLocTransfer.php =================================================================== --- trunk/StockLocTransfer.php 2010-07-09 21:55:13 UTC (rev 3600) +++ trunk/StockLocTransfer.php 2010-07-10 11:43:37 UTC (rev 3601) @@ -8,7 +8,7 @@ include('includes/header.inc'); include('includes/SQL_CommonFunctions.inc'); -If (isset($_POST['Submit']) OR isset($_POST['EnterMoreItems'])){ +if (isset($_POST['Submit']) OR isset($_POST['EnterMoreItems'])){ /*Trap any errors in input */ $InputError = False; /*Start off hoping for the best */ @@ -65,7 +65,7 @@ } /*Ship location and Receive location are different */ - If ($_POST['FromStockLocation']==$_POST['ToStockLocation']){ + if ($_POST['FromStockLocation']==$_POST['ToStockLocation']){ $InputError=True; $ErrorMessage .= _('The transfer must have a different location to receive into and location sent from'); } @@ -78,6 +78,11 @@ for ($i=0;$i < $_POST['LinesCounter'];$i++){ if($_POST['StockID' . $i] != ""){ + $DecimalsSql = "SELECT decimalplaces + FROM stockmaster + WHERE stockid='" . $_POST['StockID' . $i] . "'"; + $DecimalResult = DB_Query($DecimalsSql, $db); + $DecimalRow = DB_fetch_array($DecimalResult); $sql = "INSERT INTO loctransfers (reference, stockid, shipqty, @@ -86,7 +91,7 @@ recloc) VALUES ('" . $_POST['Trf_ID'] . "', '" . $_POST['StockID' . $i] . "', - '" . $_POST['StockQTY' . $i] . "', + '" . round($_POST['StockQTY' . $i], $DecimalRow['decimalplaces']) . "', '" . Date('Y-m-d') . "', '" . $_POST['FromStockLocation'] ."', '" . $_POST['ToStockLocation'] . "')"; @@ -94,16 +99,16 @@ $resultLocShip = DB_query($sql,$db, $ErrMsg); } } - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('Unable to COMMIT Location Transfer transaction'); - DB_Txn_Commit($db); + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('Unable to COMMIT Location Transfer transaction'); + DB_Txn_Commit($db); prnMsg( _('The inventory transfer records have been created successfully'),'success'); echo '<p><a href="'.$rootpath.'/PDFStockLocTransfer.php?' . SID . 'TransferNo=' . $_POST['Trf_ID'] . '">'. _('Print the Transfer Docket'). '</a>'; unset($_SESSION['DispatchingTransfer']); unset($_SESSION['Transfer']); + include('includes/footer.inc'); - } else { //Get next Inventory Transfer Shipment Reference Number if (isset($_GET['Trf_ID'])){ @@ -116,7 +121,7 @@ $Trf_ID = GetNextTransNo(16,$db); } - If (isset($InputError) and $InputError==true){ + if (isset($InputError) and $InputError==true){ echo '<br>'; prnMsg($ErrorMessage, 'error'); @@ -124,13 +129,18 @@ } - echo '<hr><form action="' . $_SERVER['PHP_SELF'] . '?'. SID . '" method=post>'; + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Dispatch') . + '" alt="">' . ' ' . $title . ''; - echo '<div class="centre"><input type=hidden name="Trf_ID" VALUE="' . $Trf_ID . '"><h2>'. _('Inventory Location Transfer Shipment Reference').' # '. $Trf_ID. '</h2>'; + echo '<form action="' . $_SERVER['PHP_SELF'] . '?'. SID . '" method=post>'; + echo '<table class=selection>'; + echo '<tr><th colspan=4><input type=hidden name="Trf_ID" VALUE="' . $Trf_ID . '"><font size=3 color=blue>'. + _('Inventory Location Transfer Shipment Reference').' # '. $Trf_ID. '</font></th></tr>'; + $sql = 'SELECT loccode, locationname FROM locations'; $resultStkLocs = DB_query($sql,$db); - echo _('From Stock Location').':<select name="FromStockLocation">'; + echo '<tr><td>'._('From Stock Location').':</td><td><select name="FromStockLocation">'; while ($myrow=DB_fetch_array($resultStkLocs)){ if (isset($_POST['FromStockLocation'])){ if ($myrow['loccode'] == $_POST['FromStockLocation']){ @@ -145,10 +155,10 @@ echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; } } - echo '</select>'; + echo '</select></td>'; DB_data_seek($resultStkLocs,0); //go back to the start of the locations result - echo _('To Stock Location').':<select name="ToStockLocation">'; + echo '<td>'._('To Stock Location').':</td><td><select name="ToStockLocation">'; while ($myrow=DB_fetch_array($resultStkLocs)){ if (isset($_POST['ToStockLocation'])){ if ($myrow['loccode'] == $_POST['ToStockLocation']){ @@ -163,9 +173,9 @@ echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']; } } - echo '</select></div><br>'; + echo '</select></td></tr></table><p>'; - echo '<table>'; + echo '<table class=selection>'; $tableheader = '<tr><th>'. _('Item Code'). '</th><th>'. _('Quantity'). '</th></tr>'; echo $tableheader; @@ -205,7 +215,7 @@ } echo '</table><br><div class="centre"> - <input type=hidden name="LinesCounter" value='. $i .'><input type=submit name="EnterMoreItems" value="'. _('Add More Items'). '"><input type=submit name="Submit" value="'. _('Create Transfer Shipment'). '"><br><hr>'; + <input type=hidden name="LinesCounter" value='. $i .'><input type=submit name="EnterMoreItems" value="'. _('Add More Items'). '"><input type=submit name="Submit" value="'. _('Create Transfer Shipment'). '"><br>'; echo '<script type="text/javascript">defaultControl(document.forms[0].StockID0);</script>'; echo '</form></div>'; include('includes/footer.inc'); Modified: trunk/StockLocTransferReceive.php =================================================================== --- trunk/StockLocTransferReceive.php 2010-07-09 21:55:13 UTC (rev 3600) +++ trunk/StockLocTransferReceive.php 2010-07-10 11:43:37 UTC (rev 3601) @@ -93,13 +93,13 @@ VALUES ( '" . $TrfLine->StockID . "', 16, - " . $_SESSION['Transfer']->TrfID . ", + '" . $_SESSION['Transfer']->TrfID . "', '" . $_SESSION['Transfer']->StockLocationFrom . "', '" . $SQLTransferDate . "', - " . $PeriodNo . ", + '" . $PeriodNo . "', '" . _('To') . ' ' . $_SESSION['Transfer']->StockLocationToName . "', - " . -$TrfLine->Quantity . ", - " . ($QtyOnHandPrior - $TrfLine->Quantity) . " + '" . round(-$TrfLine->Quantity, $TrfLine->DecimalPlaces) . "', + '" . round($QtyOnHandPrior - $TrfLine->Quantity, $TrfLine->DecimalPlaces) . "' )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock movement record cannot be inserted because'); @@ -148,7 +148,7 @@ VALUES ('" . $TrfLine->StockID . "', '" . $_SESSION['Transfer']->StockLocationFrom . "', '" . $Item->BundleRef . "', - " . -$Item->BundleQty . ")"; + '" . -$Item->BundleQty . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock item for the stock being transferred out of the existing location could not be inserted because'); $DbgMsg = _('The following SQL to update the serial stock item record was used'); @@ -164,10 +164,10 @@ serialno, moveqty ) VALUES ( - " . $StkMoveNo . ", + '" . $StkMoveNo . "', '" . $TrfLine->StockID . "', '" . $Item->BundleRef . "', - " . -$Item->BundleQty . " + '" . -$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'); @@ -206,11 +206,13 @@ VALUES ( '" . $TrfLine->StockID . "', 16, - " . $_SESSION['Transfer']->TrfID . ", + '" . $_SESSION['Transfer']->TrfID . "', '" . $_SESSION['Transfer']->StockLocationTo . "', - '" . $SQLTransferDate . "'," . $PeriodNo . ", + '" . $SQLTransferDate . "', + '" . $PeriodNo . "', '" . _('From') . ' ' . $_SESSION['Transfer']->StockLocationFromName ."', - " . $TrfLine->Quantity . ", " . ($QtyOnHandPrior + $TrfLine->Quantity) . " + '" . round($TrfLine->Quantity, $TrfLine->DecimalPlaces) . "', + '" . round($QtyOnHandPrior + $TrfLine->Quantity, $TrfLine->DecimalPlaces) . "' )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock movement record for the incoming stock cannot be added because'); @@ -243,7 +245,7 @@ if ($SerialItemExistsRow[0]==1){ $SQL = "UPDATE stockserialitems SET - quantity= quantity + " . $Item->BundleQty . " + quantity= quantity + '" . $Item->BundleQty . "' WHERE stockid='" . $TrfLine->StockID . "' AND loccode='" . $_SESSION['Transfer']->StockLocationTo . "' @@ -261,7 +263,7 @@ VALUES ('" . $TrfLine->StockID . "', '" . $_SESSION['Transfer']->StockLocationTo . "', '" . $Item->BundleRef . "', - " . $Item->BundleQty . ")"; + '" . $Item->BundleQty . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock item record for the stock coming in could not be added because'); $DbgMsg = _('The following SQL to update the serial stock item record was used'); @@ -271,14 +273,15 @@ /* now insert the serial stock movement */ - $SQL = "INSERT INTO stockserialmoves (stockmoveno, + $SQL = "INSERT INTO stockserialmoves ( + stockmoveno, stockid, serialno, moveqty) VALUES (" . $StkMoveNo . ", '" . $TrfLine->StockID . "', '" . $Item->BundleRef . "', - " . $Item->BundleQty . ")"; + '" . $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); @@ -287,7 +290,7 @@ } /*end if the transfer item is a controlled item */ $SQL = "UPDATE locstock - SET quantity = quantity - " . $TrfLine->Quantity . " + SET quantity = quantity - '" . round($TrfLine->Quantity, $TrfLine->DecimalPlaces) . "' WHERE stockid='" . $TrfLine->StockID . "' AND loccode='" . $_SESSION['Transfer']->StockLocationFrom . "'"; @@ -296,7 +299,7 @@ $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); $SQL = "UPDATE locstock - SET quantity = quantity + " . $TrfLine->Quantity . " + SET quantity = quantity + '" . round($TrfLine->Quantity, $TrfLine->DecimalPlaces) . "' WHERE stockid='" . $TrfLine->StockID . "' AND loccode='" . $_SESSION['Transfer']->StockLocationTo . "'"; @@ -306,30 +309,30 @@ prnMsg(_('A stock transfer for item code'). ' - ' . $TrfLine->StockID . ' ' . $TrfLine->ItemDescription . ' '. _('has been created from').' ' . $_SESSION['Transfer']->StockLocationFromName . ' '. _('to'). ' ' . $_SESSION['Transfer']->StockLocationToName . ' ' . _('for a quantity of'). ' '. $TrfLine->Quantity,'success'); - if ($TrfLine->CancelBalance==1){ - $sql = "UPDATE loctransfers SET recqty = recqty + ". $TrfLine->Quantity . ", - shipqty = recqty + ". $TrfLine->Quantity . ", + if ($TrfLine->CancelBalance==1){ + $sql = "UPDATE loctransfers SET recqty = recqty + '". round($TrfLine->Quantity, $TrfLine->DecimalPlaces) . "', + shipqty = recqty + '". round($TrfLine->Quantity, $TrfLine->DecimalPlaces) . "', recdate = '".date('Y-m-d H:i:s'). "' WHERE reference = '". $_SESSION['Transfer']->TrfID . "' AND stockid = '". $TrfLine->StockID."'"; - } else { - $sql = "UPDATE loctransfers SET recqty = recqty + ". $TrfLine->Quantity . ", - recdate = '".date('Y-m-d H:i:s'). "' - WHERE reference = '". $_SESSION['Transfer']->TrfID . "' - AND stockid = '". $TrfLine->StockID."'"; - } + } else { + $sql = "UPDATE loctransfers SET recqty = recqty + '". round($TrfLine->Quantity, $TrfLine->DecimalPlaces) . "', + recdate = '".date('Y-m-d H:i:s'). "' + WHERE reference = '". $_SESSION['Transfer']->TrfID . "' + AND stockid = '". $TrfLine->StockID."'"; + } $ErrMsg = _('CRITICAL ERROR') . '! ' . _('Unable to update the Location Transfer Record'); $Result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true); unset ($_SESSION['Transfer']->LineItem[$i]); unset ($_POST['Qty' . $i]); } /*end if Quantity > 0 */ - if ($TrfLine->CancelBalance==1){ - $sql = "UPDATE loctransfers SET shipqty = recqty - WHERE reference = '". $_SESSION['Transfer']->TrfID . "' - AND stockid = '". $TrfLine->StockID."'"; - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('Unable to set the quantity received to the quantity shipped to cancel the balance on this transfer line'); + if ($TrfLine->CancelBalance==1){ + $sql = "UPDATE loctransfers SET shipqty = recqty + WHERE reference = '". $_SESSION['Transfer']->TrfID . "' + AND stockid = '". $TrfLine->StockID."'"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('Unable to set the quantity received to the quantity shipped to cancel the balance on this transfer line'); $Result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true); - } + } $i++; } /*end of foreach TransferItem */ @@ -364,7 +367,7 @@ ON loctransfers.recloc = reclocations.loccode INNER JOIN stockmaster ON loctransfers.stockid=stockmaster.stockid - WHERE reference =" . $_GET['Trf_ID'] . " ORDER BY loctransfers.stockid"; + WHERE reference ='" . $_GET['Trf_ID'] . "' ORDER BY loctransfers.stockid"; $ErrMsg = _('The details of transfer number') . ' ' . $_GET['Trf_ID'] . ' ' . _('could not be retrieved because') .' '; @@ -408,15 +411,19 @@ if (isset($_SESSION['Transfer'])){ //Begin Form for receiving shipment - echo '<hr><form action="' . $_SERVER['PHP_SELF'] . '?'. SID . '" method=post>'; - echo '<a href="'.$_SERVER['PHP_SELF']. '?' . SID . '&NewTransfer=true">'. _('Select A Different Transfer').'</a>'; - echo '<div class="centre"><H2>' . _('Location Transfer Reference'). ' #' . $_SESSION['Transfer']->TrfID . ' '. _('from').' ' . $_SESSION['Transfer']->StockLocationFromName . ' '. _('to'). ' ' . $_SESSION['Transfer']->StockLocationToName . '</H2></div>'; + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Dispatch') . + '" alt="">' . ' ' . $title . ''; + echo '<form action="' . $_SERVER['PHP_SELF'] . '?'. SID . '" method=post>'; + prnMsg(_('Please Verify Shipment Quantities Received'),'info'); $i = 0; //Line Item Array pointer - echo "<br><table border=1>"; + echo "<br><table class=selection>"; + echo '<tr><th colspan=7><font size=3 color=blue>' . _('Location Transfer Reference'). ' #' . $_SESSION['Transfer']->TrfID . + ' '. _('from').' ' . $_SESSION['Transfer']->StockLocationFromName . ' '. _('to'). ' ' . + $_SESSION['Transfer']->StockLocationToName . '</font></th></tr>'; $tableheader = '<tr> <th>'. _('Item Code') . '</th> @@ -425,15 +432,21 @@ <th>'. _('Quantity Received'). '</th> <th>'. _('Quantity To Receive'). '</th> <th>'. _('Units'). '</th> - <th>'. _('Cancel Balance') . '</th> + <th>'. _('Cancel Balance') . '</th> </tr>'; echo $tableheader; - + $k=0; foreach ($_SESSION['Transfer']->TransferItem AS $TrfLine) { + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k++; + } - echo '<tr> - <td>' . $TrfLine->StockID . '</td> + echo '<td>' . $TrfLine->StockID . '</td> <td>' . $TrfLine->ItemDescription . '</td>'; echo '<td class=number>' . number_format($TrfLine->ShipQty, $TrfLine->DecimalPlaces) . '</td>'; @@ -443,7 +456,7 @@ } else { $Qty = $TrfLine->Quantity; } - echo '<td>' . number_format($TrfLine->PrevRecvQty, $TrfLine->DecimalPlaces) . '</td>'; + echo '<td class=number>' . number_format($TrfLine->PrevRecvQty, $TrfLine->DecimalPlaces) . '</td>'; if ($TrfLine->Controlled==1){ echo '<td><input type=hidden name="Qty' . $i . '" VALUE="' . $Qty . '"><a href="' . $rootpath .'/StockTransferControlled.php?' . SID . '&TransferItem=' . $i . '">' . $Qty . '</a></td>'; @@ -472,14 +485,18 @@ echo '</table><br /> <div class="centre"><input type=submit name="ProcessTransfer" VALUE="'. _('Process Inventory Transfer'). '"><bR /> </form></div>'; + echo '<a href="'.$_SERVER['PHP_SELF']. '?' . SID . '&NewTransfer=true">'. _('Select A Different Transfer').'</a>'; } else { /*Not $_SESSION['Transfer'] set */ - echo '<hr><form action="' . $_SERVER['PHP_SELF'] . '?'. SID . '" method=post name=form1>'; + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Dispatch') . + '" alt="">' . ' ' . $title . ''; + echo '<form action="' . $_SERVER['PHP_SELF'] . '?'. SID . '" method=post name=form1>'; + $LocResult = DB_query("SELECT locationname, loccode FROM locations",$db); - echo '<table BORDER=0>'; + echo '<table class=selection>'; echo '<tr><td>'. _('Select Location Receiving Into'). ':</td><td>'; echo '<select NAME = "RecLocation" onChange=ReloadForm(form1.RefreshTransferList)>'; if (!isset($_POST['RecLocation'])){ @@ -504,17 +521,26 @@ $TrfResult = DB_query($sql,$db); if (DB_num_rows($TrfResult)>0){ - - echo '<table BORDER=0>'; - + $LocSql = "SELECT locationname FROM locations WHERE loccode='" . $_POST['RecLocation'] . "'"; + $LocResult = DB_query($LocSql,$db); + $LocRow = DB_fetch_array($LocResult); + echo '<table class=selection>'; + echo '<tr><th colspan=4><font size=3 color=blue>'._('Pending Transfers Into').' '.$LocRow['locationname'].'</font></th></tr>'; echo '<tr> <th>'. _('Transfer Ref'). '</th> <th>'. _('Transfer From'). '</th> <th>'. _('Dispatch Date'). '</th></tr>'; - + $k=0; while ($myrow=DB_fetch_array($TrfResult)){ - echo '<tr><td class=number>' . $myrow['reference'] . '</td> + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k++; + } + echo '<td class=number>' . $myrow['reference'] . '</td> <td>' . $myrow['trffromloc'] . '</td> <td>' . ConvertSQLDate($myrow['shipdate']) . '</td> <td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&Trf_ID=' . $myrow['reference'] . '">'. _('Receive'). '</a></td></tr>'; @@ -528,4 +554,4 @@ echo '</form>'; } include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-09 21:55:13 UTC (rev 3600) +++ trunk/doc/Change.log.html 2010-07-10 11:43:37 UTC (rev 3601) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>09/07/10 Tim: Bulk Transfers - Bug fixes, correctly round the decimal places, fix sql quoting errors and layout changes</p> <p>09/07/10 Tim: GLTrialBalance.php - Bug fixes, layout improvements changed period number to date and year and sql fixes</p> <p>09/07/10 Tim: GLTransInquiry.php - Layout improvements changed period number to date and year and sql fixes</p> <p>09/07/10 Tim: GLTags - Layout improvements and sql fixes</p> Modified: trunk/includes/DefineStockTransfers.php =================================================================== --- trunk/includes/DefineStockTransfers.php 2010-07-09 21:55:13 UTC (rev 3600) +++ trunk/includes/DefineStockTransfers.php 2010-07-10 11:43:37 UTC (rev 3601) @@ -55,6 +55,7 @@ $this->PartUnit = $PartUnit; $this->Controlled = $Controlled; $this->Serialised = $Serialised; + $this->DecimalPlaces = $DecimalPlaces; $this->ShipQty = $Quantity; if ($this->Controlled==1){ $this->Quantity = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |