From: <rc...@us...> - 2015-05-10 04:54:14
|
Revision: 7296 http://sourceforge.net/p/web-erp/reponame/7296 Author: rchacon Date: 2015-05-10 04:54:12 +0000 (Sun, 10 May 2015) Log Message: ----------- New features: (1) GL account code for an inventory location, so that you can have general ledger transactions of inventory transfers to or from this location; useful for pledged inventory and goods on consignment. (2) Allow Invoicing parameter to allow or deny the availability of a location to be delivered; useful when a location stores compromised good that can not be sold. Modified Paths: -------------- trunk/CustomerBranches.php trunk/DeliveryDetails.php trunk/Locations.php trunk/StockLocTransferReceive.php trunk/StockTransfers.php trunk/Z_ChangeGLAccountCode.php trunk/Z_ChangeLocationCode.php trunk/doc/Change.log trunk/doc/Manual/ManualAccountsReceivable.html trunk/doc/Manual/ManualInventory.html trunk/doc/Manual/ManualSalesOrders.html trunk/includes/DefineStockTransfers.php trunk/sql/mysql/upgrade4.12.2-4.13.sql Added Paths: ----------- trunk/doc/Manual/images/InventoryLocations.png Modified: trunk/CustomerBranches.php =================================================================== --- trunk/CustomerBranches.php 2015-05-10 01:01:51 UTC (rev 7295) +++ trunk/CustomerBranches.php 2015-05-10 04:54:12 UTC (rev 7296) @@ -12,7 +12,7 @@ if(isset($_GET['DebtorNo'])) { $DebtorNo = mb_strtoupper($_GET['DebtorNo']); -} else if(isset($_POST['DebtorNo'])) { +} elseif(isset($_POST['DebtorNo'])) { $DebtorNo = mb_strtoupper($_POST['DebtorNo']); } @@ -26,7 +26,7 @@ if(isset($_GET['SelectedBranch'])) { $SelectedBranch = mb_strtoupper($_GET['SelectedBranch']); -} else if(isset($_POST['SelectedBranch'])) { +} elseif(isset($_POST['SelectedBranch'])) { $SelectedBranch = mb_strtoupper($_POST['SelectedBranch']); } @@ -177,7 +177,7 @@ $msg = $_POST['BrName'] . ' '._('branch has been updated.'); - } else if($InputError !=1) { + } elseif($InputError !=1) { /*Selected branch is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new Customer Branches form */ @@ -286,7 +286,7 @@ unset($_POST['DeliverBlind']); unset($SelectedBranch); } -} else if(isset($_GET['delete'])) { +} elseif(isset($_GET['delete'])) { //the link to delete a selected record was clicked instead of the submit button // PREVENT DELETES IF DEPENDENT RECORDS IN 'DebtorTrans' @@ -461,7 +461,7 @@ if($myrow[10]) { $TotalDisable++; - }else { + } else { $TotalEnable++; } } while ($myrow = DB_fetch_row($result)); @@ -698,7 +698,7 @@ foreach ($CountriesArray as $CountryEntry => $CountryName) { if(isset($_POST['BrAddress6']) AND ($_POST['BrAddress6'] == $CountryName)) { echo '<option selected="selected" value="' . $CountryName . '">' . $CountryName . '</option>'; - }elseif(!isset($_POST['BrAddress6']) AND $CountryName == "") { + } elseif(!isset($_POST['BrAddress6']) AND $CountryName == "") { echo '<option selected="selected" value="' . $CountryName . '">' . $CountryName . '</option>'; } else { echo '<option value="' . $CountryName . '">' . $CountryName . '</option>'; @@ -735,7 +735,7 @@ echo $_SESSION['UsersRealName']; echo '</td> </tr>'; - }else{ + } else { //SQL to poulate account selection boxes $SQL = "SELECT salesmanname, @@ -800,30 +800,38 @@ </tr>'; DB_data_seek($result,0); - $SQL = "SELECT locations.loccode, locationname FROM locations INNER JOIN locationusers ON locationusers.loccode=locations.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canupd=1"; +// BEGIN: ********************************************************************** + $SQL = "SELECT locations.loccode, locationname + FROM locations + INNER JOIN locationusers + ON locationusers.loccode=locations.loccode + AND locationusers.userid='" . $_SESSION['UserID'] . "' + AND locationusers.canupd=1 + WHERE locations.allowinvoicing='1'"; $result = DB_query($SQL); if(DB_num_rows($result)==0) { echo '</table>'; prnMsg(_('There are no stock locations defined as yet') . ' - ' . _('customer branches must refer to a default location where stock is normally drawn from') . '. ' . _('Please use the link below to define at least one stock location'),'error'); - echo '<br /><a href="' . $RootPath . '/Locations.php">' . _('Define Stock Locations') . '</a>'; + echo '<br /><a href="', $RootPath, '/Locations.php">', _('Define Stock Locations'), '</a>'; include('includes/footer.inc'); exit; } echo '<tr> - <td>' . _('Draw Stock From').':</td> - <td><select tabindex="15" name="DefaultLocation">'; + <td>', _('Draw Stock From'), ':</td> + <td><select name="DefaultLocation" tabindex="15">'; - while ($myrow = DB_fetch_array($result)) { + while($myrow = DB_fetch_array($result)) { if(isset($_POST['DefaultLocation']) AND $myrow['loccode']==$_POST['DefaultLocation']) { echo '<option selected="selected" value="'; } else { echo '<option value="'; } - echo $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; + echo $myrow['loccode'], '">', $myrow['locationname'], '</option>'; - } //end while loop + }// End while loop. +// END: ************************************************************************ echo '</select></td> </tr> @@ -910,7 +918,7 @@ while ($myrow=DB_fetch_array($ShipperResults)) { if(isset($_POST['DefaultShipVia'])and $myrow['shipper_id']==$_POST['DefaultShipVia']) { echo '<option selected="selected" value="' . $myrow['shipper_id'] . '">' . $myrow['shippername'] . '</option>'; - }else { + } else { echo '<option value="' . $myrow['shipper_id'] . '">' . $myrow['shippername'] . '</option>'; } } @@ -938,53 +946,53 @@ $_POST['BrPostAddr1']=''; } echo '<tr> - <td>' . _('Postal Address 1 (Street)').':</td> - <td><input tabindex="23" type="text" name="BrPostAddr1" size="41" maxlength="40" value="'. $_POST['BrPostAddr1'].'" /></td> + <td>', _('Postal Address 1 (Street)'), ':</td> + <td><input maxlength="40" name="BrPostAddr1" size="41" tabindex="23" type="text" value="', $_POST['BrPostAddr1'].'" /></td> </tr>'; if(!isset($_POST['BrPostAddr2'])) {// Postal address, line 2. Database: custbranch.brpostaddr2, varchar(40) $_POST['BrPostAddr2']=''; } echo '<tr> - <td>' . _('Postal Address 2 (Suburb/City)').':</td> - <td><input tabindex="24" type="text" name="BrPostAddr2" size="41" maxlength="40" value="'. $_POST['BrPostAddr2'].'" /></td> + <td>', _('Postal Address 2 (Suburb/City)'), ':</td> + <td><input maxlength="40" name="BrPostAddr2" size="41" tabindex="24" type="text" value="', $_POST['BrPostAddr2'].'" /></td> </tr>'; if(!isset($_POST['BrPostAddr3'])) {// Postal address, line 3. Database: custbranch.brpostaddr3, varchar(40) $_POST['BrPostAddr3']=''; } echo '<tr> - <td>' . _('Postal Address 3 (State)').':</td> - <td><input tabindex="25" type="text" name="BrPostAddr3" size="41" maxlength="40" value="'. $_POST['BrPostAddr3'].'" /></td> + <td>', _('Postal Address 3 (State)'), ':</td> + <td><input maxlength="40" name="BrPostAddr3" size="41" tabindex="25" type="text" value="', $_POST['BrPostAddr3'].'" /></td> </tr>'; if(!isset($_POST['BrPostAddr4'])) {// Postal address, line 4. Database: custbranch.brpostaddr4, varchar(40) $_POST['BrPostAddr4']=''; } echo '<tr> - <td>' . _('Postal Address 4 (Postal Code)').':</td> - <td><input tabindex="26" type="text" name="BrPostAddr4" size="41" maxlength="40" value="'. $_POST['BrPostAddr4'].'" /></td> + <td>', _('Postal Address 4 (Postal Code)'), ':</td> + <td><input maxlength="40" name="BrPostAddr4" size="41" tabindex="26" type="text" value="', $_POST['BrPostAddr4'].'" /></td> </tr>'; if(!isset($_POST['BrPostAddr5'])) {// Postal address, line 5. Database: custbranch.brpostaddr5, varchar(20) $_POST['BrPostAddr5']=''; } echo '<tr> - <td>' . _('Postal Address 5').':</td> - <td><input tabindex="27" type="text" name="BrPostAddr5" size="21" maxlength="20" value="'. $_POST['BrPostAddr5'].'" /></td> + <td>', _('Postal Address 5'), ':</td> + <td><input maxlength="20" name="BrPostAddr5" size="21" tabindex="27" type="text" value="', $_POST['BrPostAddr5'].'" /></td> </tr>'; if(!isset($_POST['CustBranchCode'])) { $_POST['CustBranchCode']=''; } echo '<tr> - <td>' . _('Customers Internal Branch Code (EDI)').':</td> - <td><input tabindex="28" type="text" name="CustBranchCode" size="31" maxlength="30" value="'. $_POST['CustBranchCode'].'" /></td> + <td>', _('Customers Internal Branch Code (EDI)'), ':</td> + <td><input maxlength="30" name="CustBranchCode" size="31" tabindex="28" type="text" value="', $_POST['CustBranchCode'], '" /></td> </tr> </table> <br /> <div class="centre"> - <input tabindex="28" type="submit" name="submit" value="' . _('Enter Or Update Branch') . '" /> + <input name="submit" tabindex="29" type="submit" value="', _('Enter Or Update Branch'), '" /> </div> </div> </form>'; Modified: trunk/DeliveryDetails.php =================================================================== --- trunk/DeliveryDetails.php 2015-05-10 01:01:51 UTC (rev 7295) +++ trunk/DeliveryDetails.php 2015-05-10 04:54:12 UTC (rev 7296) @@ -113,7 +113,7 @@ elseif(Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat'],$EarliestDispatch), $_POST['DeliveryDate'])) { $InputErrors =1; - echo '<br /><b>' . _('The delivery details cannot be updated because you are attempting to set the date the order is to be dispatched earlier than is possible. No dispatches are made on Saturday and Sunday. Also, the dispatch cut off time is') . $_SESSION['DispatchCutOffTime'] . _(':00 hrs. Orders placed after this time will be dispatched the following working day.'); + echo '<br /><b>' . _('The delivery details cannot be updated because you are attempting to set the date the order is to be dispatched earlier than is possible. No dispatches are made on Saturday and Sunday. Also, the dispatch cut off time is') . $_SESSION['DispatchCutOffTime'] . _(':00 hrs. Orders placed after this time will be dispatched the following working day.'); } */ @@ -236,7 +236,7 @@ - if shippers defined but the default shipper is bogus then use the first shipper defined */ if((isset($BestShipper) AND $BestShipper=='') AND ($_POST['ShipVia']=='' OR !isset($_POST['ShipVia']))) { - $sql = "SELECT shipper_id + $sql = "SELECT shipper_id FROM shippers WHERE shipper_id='" . $_SESSION['Default_Shipper']."'"; $ErrMsg = _('There was a problem testing for the default shipper'); @@ -258,7 +258,7 @@ $BestShipper = $ShipperReturned[0]; } else { prnMsg(_('We have a problem') . ' - ' . _('there are no shippers defined'). '. ' . _('Please use the link below to set up shipping or freight companies') . ', ' . _('the system expects the shipping company to be selected or a default freight company to be used'),'error'); - echo '<a href="' . $RootPath . 'Shippers.php">' . _('Enter') . '/' . _('Amend Freight Companies') . '</a>'; + echo '<a href="' . $RootPath . 'Shippers.php">' . _('Enter') . '/' . _('Amend Freight Companies') . '</a>'; } } if(isset($_SESSION['Items'.$identifier]->ShipVia) AND $_SESSION['Items'.$identifier]->ShipVia!='') { @@ -272,8 +272,8 @@ if(isset($_POST['MakeRecurringOrder']) AND ! $InputErrors) { - echo '<meta http-equiv="Refresh" content="0; url=' . $RootPath . '/RecurringSalesOrders.php?identifier='.$identifier . '&NewRecurringOrder=Yes">'; - prnMsg(_('You should automatically be forwarded to the entry of recurring order details page') . '. ' . _('If this does not happen') . '(' . _('if the browser does not support META Refresh') . ') ' . '<a href="' . $RootPath . '/RecurringOrders.php?identifier='.$identifier . '&NewRecurringOrder=Yes">' . _('click here') . '</a> '. _('to continue'),'info'); + echo '<meta http-equiv="Refresh" content="0; url=' . $RootPath . '/RecurringSalesOrders.php?identifier='.$identifier . '&NewRecurringOrder=Yes">'; + prnMsg(_('You should automatically be forwarded to the entry of recurring order details page') . '. ' . _('If this does not happen') . '(' . _('if the browser does not support META Refresh') . ') ' . '<a href="' . $RootPath . '/RecurringOrders.php?identifier='.$identifier . '&NewRecurringOrder=Yes">' . _('click here') . '</a> '. _('to continue'),'info'); include('includes/footer.inc'); exit; } @@ -281,8 +281,8 @@ if(isset($_POST['BackToLineDetails']) and $_POST['BackToLineDetails']==_('Modify Order Lines')) { - echo '<meta http-equiv="Refresh" content="0; url=' . $RootPath . '/SelectOrderItems.php?identifier='.$identifier . '">'; - prnMsg(_('You should automatically be forwarded to the entry of the order line details page') . '. ' . _('If this does not happen') . '(' . _('if the browser does not support META Refresh') . ') ' . '<a href="' . $RootPath . '/SelectOrderItems.php?identifier='.$identifier . '">' . _('click here') . '</a> '. _('to continue'),'info'); + echo '<meta http-equiv="Refresh" content="0; url=' . $RootPath . '/SelectOrderItems.php?identifier='.$identifier . '">'; + prnMsg(_('You should automatically be forwarded to the entry of the order line details page') . '. ' . _('If this does not happen') . '(' . _('if the browser does not support META Refresh') . ') ' . '<a href="' . $RootPath . '/SelectOrderItems.php?identifier='.$identifier . '">' . _('click here') . '</a> '. _('to continue'),'info'); include('includes/footer.inc'); exit; @@ -318,7 +318,7 @@ UNTIL ONLINE CREDIT CARD PROCESSING IS PERFORMED ASSUME OK TO PROCESS - NOT YET CODED */ + NOT YET CODED */ $OK_to_PROCESS =1; @@ -540,7 +540,7 @@ $FactoryManagerEmail = _('A new work order has been created for') . ":\n" . $StockItem->StockID . ' - ' . $StockItem->ItemDescription . ' x ' . $WOQuantity . ' ' . $StockItem->Units . - "\n" . _('These are for') . ' ' . $_SESSION['Items'.$identifier]->CustomerName . ' ' . _('there order ref') . ': ' . $_SESSION['Items'.$identifier]->CustRef . ' ' ._('our order number') . ': ' . $OrderNo; + "\n" . _('These are for') . ' ' . $_SESSION['Items'.$identifier]->CustomerName . ' ' . _('there order ref') . ': ' . $_SESSION['Items'.$identifier]->CustRef . ' ' ._('our order number') . ': ' . $OrderNo; if($StockItem->Serialised AND $StockItem->NextSerialNo>0) { //then we must create the serial numbers for the new WO also @@ -603,16 +603,16 @@ echo '<br /><table class="selection"> <tr> <td><img src="'.$RootPath.'/css/'.$Theme.'/images/printer.png" title="' . _('Print') . '" alt="" /></td> - <td>' . ' ' . '<a target="_blank" href="' . $RootPath . '/PrintCustOrder.php?identifier='.$identifier . '&TransNo=' . $OrderNo . '">' . _('Print packing slip') . ' (' . _('Preprinted stationery') . ')' . '</a></td> + <td>' . ' ' . '<a target="_blank" href="' . $RootPath . '/PrintCustOrder.php?identifier='.$identifier . '&TransNo=' . $OrderNo . '">' . _('Print packing slip') . ' (' . _('Preprinted stationery') . ')' . '</a></td> </tr>'; echo '<tr> <td><img src="'.$RootPath.'/css/'.$Theme.'/images/printer.png" title="' . _('Print') . '" alt="" /></td> - <td>' . ' ' . '<a target="_blank" href="' . $RootPath . '/PrintCustOrder_generic.php?identifier='.$identifier . '&TransNo=' . $OrderNo . '">' . _('Print packing slip') . ' (' . _('Laser') . ')' . '</a></td> + <td>' . ' ' . '<a target="_blank" href="' . $RootPath . '/PrintCustOrder_generic.php?identifier='.$identifier . '&TransNo=' . $OrderNo . '">' . _('Print packing slip') . ' (' . _('Laser') . ')' . '</a></td> </tr>'; echo '<tr> <td><img src="'.$RootPath.'/css/'.$Theme.'/images/reports.png" title="' . _('Invoice') . '" alt="" /></td> - <td>' . ' ' . '<a href="' . $RootPath . '/ConfirmDispatch_Invoice.php?identifier='.$identifier . '&OrderNumber=' . $OrderNo .'">' . _('Confirm Dispatch and Produce Invoice') . '</a></td> + <td>' . ' ' . '<a href="' . $RootPath . '/ConfirmDispatch_Invoice.php?identifier='.$identifier . '&OrderNumber=' . $OrderNo .'">' . _('Confirm Dispatch and Produce Invoice') . '</a></td> </tr>'; echo '</table>'; @@ -622,7 +622,7 @@ echo '<br /><table class="selection"> <tr> <td><img src="'.$RootPath.'/css/'.$Theme.'/images/printer.png" title="' . _('Order') . '" alt=""></td> - <td>' . ' ' . '<a href="' . $RootPath . '/PDFQuotation.php?identifier='.$identifier . '&QuotationNo=' . $OrderNo . '" target="_blank">' . _('Print Quotation (Landscape)') . '</a></td> + <td>' . ' ' . '<a href="' . $RootPath . '/PDFQuotation.php?identifier='.$identifier . '&QuotationNo=' . $OrderNo . '" target="_blank">' . _('Print Quotation (Landscape)') . '</a></td> </tr> </table>'; echo '<br /><table class="selection"> @@ -1007,29 +1007,30 @@ </tr>'; echo '<tr> - <td>' . _('Deliver from the warehouse at') .':</td> + <td>', _('Deliver from the warehouse at'), ':</td> <td><select name="Location">'; if($_SESSION['Items'.$identifier]->Location=='' OR !isset($_SESSION['Items'.$identifier]->Location)) { $_SESSION['Items'.$identifier]->Location = $DefaultStockLocation; } +// BEGIN: ********************************************************************** +$SQL = "SELECT locations.loccode, locationname + FROM locations + INNER JOIN locationusers + ON locationusers.loccode=locations.loccode + AND locationusers.userid='" . $_SESSION['UserID'] . "' + AND locationusers.canupd=1 + WHERE locations.allowinvoicing='1'"; $ErrMsg = _('The stock locations could not be retrieved'); $DbgMsg = _('SQL used to retrieve the stock locations was') . ':'; -$StkLocsResult = DB_query("SELECT locationname,locations.loccode - FROM locations INNER JOIN locationusers ON locationusers.loccode=locations.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canupd=1", - $ErrMsg, - $DbgMsg); - -while ($myrow=DB_fetch_array($StkLocsResult)) { - if($_SESSION['Items'.$identifier]->Location==$myrow['loccode']) { - echo '<option selected="selected" value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; - } else { - echo '<option value="'.$myrow['loccode'].'">' . $myrow['locationname'] . '</option>'; - } +$StkLocsResult = DB_query($SQL, $ErrMsg, $DbgMsg); +// COMMENT: What if there is no authorized locations available for this user? +while($myrow=DB_fetch_array($StkLocsResult)) { + echo '<option', ($_SESSION['Items'.$identifier]->Location==$myrow['loccode'] ? ' selected="selected"' : ''), ' value="', $myrow['loccode'], '">', $myrow['locationname'], '</option>'; } - echo '</select></td></tr>'; +// END: ************************************************************************ // Set the default date to earliest possible date if not set already if(!isset($_SESSION['Items'.$identifier]->DeliveryDate)) { Modified: trunk/Locations.php =================================================================== --- trunk/Locations.php 2015-05-10 01:01:51 UTC (rev 7295) +++ trunk/Locations.php 2015-05-10 04:54:12 UTC (rev 7296) @@ -77,7 +77,9 @@ cashsalebranch ='" . $_POST['CashSaleBranch'] . "', managed = '" . $_POST['Managed'] . "', internalrequest = '" . $_POST['InternalRequest'] . "', - usedforwo = '" . $_POST['UsedForWO'] . "' + usedforwo = '" . $_POST['UsedForWO'] . "', + glaccountcode = '" . $_POST['GLAccountCode'] . "', + allowinvoicing = '" . $_POST['AllowInvoicing'] . "' WHERE loccode = '" . $SelectedLocation . "'"; $ErrMsg = _('An error occurred updating the') . ' ' . $SelectedLocation . ' ' . _('location record because'); @@ -105,6 +107,8 @@ unset($_POST['Contact']); unset($_POST['InternalRequest']); unset($_POST['UsedForWO']); + unset($_POST['GLAccountCode']); + unset($_POST['AllowInvoicing']); } elseif($InputError !=1) { @@ -135,7 +139,9 @@ cashsalebranch, managed, internalrequest, - usedforwo) + usedforwo, + glaccountcode, + allowinvoicing) VALUES ('" . $_POST['LocCode'] . "', '" . $_POST['LocationName'] . "', '" . $_POST['DelAdd1'] ."', @@ -150,13 +156,15 @@ '" . $_POST['Contact'] . "', '" . $_POST['TaxProvince'] . "', '" . $_POST['CashSaleCustomer'] . "', - '" . $_POST['CashSaleBranch'] . "', + '" . $_POST['CashSaleBranch'] . "', '" . $_POST['Managed'] . "', - '" . $_POST['InternalRequest'] ."', - '" . $_POST['UsedForWO'] . "')"; + '" . $_POST['InternalRequest'] . "', + '" . $_POST['UsedForWO'] . "', + '" . $_POST['GLAccountCode'] . "', + '" . $_POST['AllowInvoicing'] . "')"; - $ErrMsg = _('An error occurred inserting the new location record because'); - $DbgMsg = _('The SQL used to insert the location record was'); + $ErrMsg = _('An error occurred inserting the new location record because'); + $DbgMsg = _('The SQL used to insert the location record was'); $result = DB_query($sql,$ErrMsg,$DbgMsg); prnMsg(_('The new location record has been added'),'success'); @@ -174,10 +182,10 @@ 0 FROM stockmaster"; - $ErrMsg = _('An error occurred inserting the new location stock records for all pre-existing parts because'); - $DbgMsg = _('The SQL used to insert the new stock location records was'); + $ErrMsg = _('An error occurred inserting the new location stock records for all pre-existing parts because'); + $DbgMsg = _('The SQL used to insert the new stock location records was'); $result = DB_query($sql,$ErrMsg, $DbgMsg); - prnMsg ('........ ' . _('and new stock locations inserted for all existing stock items for the new location'), 'success'); + prnMsg('........ ' . _('and new stock locations inserted for all existing stock items for the new location'), 'success'); /* Also need to add locationuser records for all existing users*/ $sql = "INSERT INTO locationusers (userid, loccode, canview, canupd) @@ -190,7 +198,7 @@ ON www_users.userid = locationusers.userid AND locations.loccode = locationusers.loccode WHERE locationusers.userid IS NULL - AND locations.loccode='". $_POST['LocCode'] . "';"; + AND locations.loccode='". $_POST['LocCode'] . "';"; $ErrMsg = _('The users/locations that need user location records created cannot be retrieved because'); $Result = DB_query($sql,$ErrMsg); @@ -215,7 +223,8 @@ unset($_POST['Contact']); unset($_POST['InternalRequest']); unset($_POST['UsedForWO']); - + unset($_POST['GLAccountCode']); + unset($_POST['AllowInvoicing']); } @@ -267,7 +276,7 @@ if($myrow[0]>0) { $CancelDelete = 1; prnMsg(_('Cannot delete this location because sales orders have been created delivering from this location'),'warn'); - echo _('There are') . ' ' . $myrow[0] . ' ' . _('sales orders with this Location code'); + echo _('There are') . ' ' . $myrow[0] . ' ' . _('sales orders with this Location code'); } else { $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockmoves.loccode='" . $SelectedLocation . "'"; $result = DB_query($sql); @@ -385,20 +394,24 @@ $sql = "SELECT loccode, locationname, taxprovinces.taxprovincename as description, + glaccountcode, + allowinvoicing, managed FROM locations INNER JOIN taxprovinces ON locations.taxprovinceid=taxprovinces.taxprovinceid"; $result = DB_query($sql); if(DB_num_rows($result)==0) { - prnMsg (_('There are no locations that match up with a tax province record to display. Check that tax provinces are set up for all dispatch locations'),'error'); + prnMsg(_('There are no locations that match up with a tax province record to display. Check that tax provinces are set up for all dispatch locations'),'error'); } - echo '<table class="selection">'; - echo '<tr> - <th class="ascending">' . _('Location Code') . '</th> - <th class="ascending">' . _('Location Name') . '</th> - <th class="ascending">' . _('Tax Province') . '</th> + echo '<table class="selection"> + <tr> + <th class="ascending">', _('Location Code'), '</th> + <th class="ascending">', _('Location Name'), '</th> + <th class="ascending">', _('Tax Province'), '</th> + <th class="ascending">', _('GL Account Code'), '</th> + <th class="ascending">', _('Allow Invoicing'), '</th> <th class="noprint" colspan="2"> </th> </tr>'; @@ -414,22 +427,25 @@ /* warehouse management not implemented ... yet if($myrow['managed'] == 1) { $myrow['managed'] = _('Yes'); - } else { + } else { $myrow['managed'] = _('No'); } */ printf('<td>%s</td> <td>%s</td> <td>%s</td> + <td class="number">%s</td> + <td class="centre">%s</td> <td class="noprint"><a href="%sSelectedLocation=%s">' . _('Edit') . '</a></td> <td class="noprint"><a href="%sSelectedLocation=%s&delete=1" onclick="return confirm(\'' . _('Are you sure you wish to delete this inventory location?') . '\');">' . _('Delete') . '</a></td> </tr>', $myrow['loccode'], $myrow['locationname'], $myrow['description'], + ($myrow['glaccountcode']!='' ? $myrow['glaccountcode'] : ' '),// Use a non-breaking space to avoid an empty cell in a HTML table. + ($myrow['allowinvoicing']==1 ? _('Yes') : _('No')), htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?', $myrow['loccode'], htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?', $myrow['loccode']); - } //END WHILE LIST LOOP echo '</table>'; @@ -446,7 +462,7 @@ if(!isset($_GET['delete'])) { echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">'; - echo '<div>'; + echo '<div>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; if(isset($SelectedLocation)) { @@ -469,7 +485,9 @@ cashsalebranch, managed, internalrequest, - usedforwo + usedforwo, + glaccountcode, + allowinvoicing FROM locations WHERE loccode='" . $SelectedLocation . "'"; @@ -477,7 +495,7 @@ $myrow = DB_fetch_array($result); $_POST['LocCode'] = $myrow['loccode']; - $_POST['LocationName'] = $myrow['locationname']; + $_POST['LocationName'] = $myrow['locationname']; $_POST['DelAdd1'] = $myrow['deladd1']; $_POST['DelAdd2'] = $myrow['deladd2']; $_POST['DelAdd3'] = $myrow['deladd3']; @@ -494,8 +512,9 @@ $_POST['Managed'] = $myrow['managed']; $_POST['InternalRequest'] = $myrow['internalrequest']; $_POST['UsedForWO'] = $myrow['usedforwo']; + $_POST['GLAccountCode'] = $myrow['glaccountcode']; + $_POST['AllowInvoicing'] = $myrow['allowinvoicing']; - echo '<input type="hidden" name="SelectedLocation" value="' . $SelectedLocation . '" />'; echo '<input type="hidden" name="LocCode" value="' . $_POST['LocCode'] . '" />'; echo '<table class="selection">'; @@ -561,9 +580,12 @@ if(!isset($_POST['Managed'])) { $_POST['Managed'] = 0; } + if(!isset($_POST['AllowInvoicing'])) { + $_POST['AllowInvoicing'] = 1;// If not set, set value to "Yes". + } echo '<tr> - <td>' . _('Location Name') . ':' . '</td> + <td>' . _('Location Name') . ':' . '</td> <td><input type="text" name="LocationName" required="required" value="'. $_POST['LocationName'] . '" title="' . _('Enter the inventory location name this could be either a warehouse or a factory') . '" namesize="51" maxlength="50" /></td> </tr> <tr> @@ -571,23 +593,23 @@ <td><input type="text" name="Contact" required="required" value="' . $_POST['Contact'] . '" title="' . _('Enter the name of the responsible person to contact for this inventory location') . '" size="31" maxlength="30" /></td> </tr> <tr> - <td>' . _('Delivery Address 1 (Building)') . ':' . '</td> + <td>' . _('Delivery Address 1 (Building)') . ':' . '</td> <td><input type="text" name="DelAdd1" value="' . $_POST['DelAdd1'] . '" size="41" maxlength="40" /></td> </tr> <tr> <td>' . _('Delivery Address 2 (Street)') . ':' . '</td> - <td><input type="text" name="DelAdd2" value="' . $_POST['DelAdd2'] . '" size="41" maxlength="40" /></td> + <td><input type="text" name="DelAdd2" value="' . $_POST['DelAdd2'] . '" size="41" maxlength="40" /></td> </tr> <tr> - <td>' . _('Delivery Address 3 (Suburb)') . ':' . '</td> - <td><input type="text" name="DelAdd3" value="' . $_POST['DelAdd3'] . '" size="41" maxlength="40" /></td> + <td>' . _('Delivery Address 3 (Suburb)') . ':' . '</td> + <td><input type="text" name="DelAdd3" value="' . $_POST['DelAdd3'] . '" size="41" maxlength="40" /></td> </tr> <tr> - <td>' . _('Delivery Address 4 (City)') . ':' . '</td> + <td>' . _('Delivery Address 4 (City)') . ':' . '</td> <td><input type="text" name="DelAdd4" value="' . $_POST['DelAdd4'] . '" size="41" maxlength="40" /></td> </tr> <tr> - <td>' . _('Delivery Address 5 (Zip Code)') . ':' . '</td> + <td>' . _('Delivery Address 5 (Zip Code)') . ':' . '</td> <td><input type="text" name="DelAdd5" value="' . $_POST['DelAdd5'] . '" size="21" maxlength="20" /></td> </tr> <tr> @@ -595,29 +617,29 @@ <td><select name="DelAdd6">'; foreach ($CountriesArray as $CountryEntry => $CountryName) { if(isset($_POST['DelAdd6']) AND (strtoupper($_POST['DelAdd6']) == strtoupper($CountryName))) { - echo '<option selected="selected" value="' . $CountryName . '">' . $CountryName . '</option>'; - }elseif(!isset($_POST['Address6']) AND $CountryName == "") { - echo '<option selected="selected" value="' . $CountryName . '">' . $CountryName . '</option>'; + echo '<option selected="selected" value="' . $CountryName . '">' . $CountryName . '</option>'; + } elseif(!isset($_POST['Address6']) AND $CountryName == "") { + echo '<option selected="selected" value="' . $CountryName . '">' . $CountryName . '</option>'; } else { - echo '<option value="' . $CountryName . '">' . $CountryName . '</option>'; + echo '<option value="' . $CountryName . '">' . $CountryName . '</option>'; } } echo '</select></td> </tr> <tr> - <td>' . _('Telephone No') . ':' . '</td> - <td><input type="tel" name="Tel" pattern="[0-9+\-\s()]*" value="' . $_POST['Tel'] . '" size="31" maxlength="30" title="' . _('The phone number should consist of numbers, spaces, parentheses, or the + character') . '" /></td> + <td>' . _('Telephone No') . ':' . '</td> + <td><input name="Tel" type="tel" pattern="[0-9+\-\s()]*" value="' . $_POST['Tel'] . '" size="31" maxlength="30" title="' . _('The phone number should consist of numbers, spaces, parentheses, or the + character') . '" /></td> </tr> <tr> - <td>' . _('Facsimile No') . ':' . '</td> - <td><input type="tel" name="Fax" pattern="[0-9+\-\s()]*" value="' . $_POST['Fax'] . '" size="31" maxlength="30" title="' . _('The fax number should consist of numbers, parentheses, spaces or the + character') . '"/></td> + <td>' . _('Facsimile No') . ':' . '</td> + <td><input name="Fax" type="tel" pattern="[0-9+\-\s()]*" value="' . $_POST['Fax'] . '" size="31" maxlength="30" title="' . _('The fax number should consist of numbers, parentheses, spaces or the + character') . '"/></td> </tr> <tr> - <td>' . _('Email') . ':' . '</td> - <td><input type="email" name="Email" value="' . $_POST['Email'] . '" size="31" maxlength="55" /></td> + <td>' . _('Email') . ':' . '</td> + <td><input name="Email" type="email" value="' . $_POST['Email'] . '" size="31" maxlength="55" /></td> </tr> <tr> - <td>' . _('Tax Province') . ':' . '</td> + <td>' . _('Tax Province') . ':' . '</td> <td><select name="TaxProvince">'; $TaxProvinceResult = DB_query("SELECT taxprovinceid, taxprovincename FROM taxprovinces"); @@ -668,6 +690,18 @@ echo '<option value="0">' . _('No') . '</option>'; } echo '</select></td></tr>'; + // Location's ledger account: + echo '<tr title="', _('Enter the GL account for this location, or leave it in blank if not needed'), '"> + <td><label for="GLAccountCode">', _('GL Account Code'), ':</label></td> + <td><input data-type="no-illegal-chars" id="GLAccountCode" maxlength="20" name="GLAccountCode" size="20" type="text" value="', $_POST['GLAccountCode'], '" /></td></tr>'; + // Allow or deny the invoicing of items in this location: + echo '<tr title="', _('Use this parameter to indicate whether these inventory location allows or denies the invoicing of its items.'), '"> + <td><label for="AllowInvoicing">', _('Allow Invoicing'), ':</label></td> + <td><select name="AllowInvoicing"> + <option', ($_POST['AllowInvoicing']==1 ? ' selected="selected"' : ''), ' value="1">', _('Yes'), '</option> + <option', ($_POST['AllowInvoicing']==0 ? ' selected="selected"' : ''), ' value="0">', _('No'), '</option> + </select></td> + </tr>'; /* This functionality is not written yet ... @@ -677,12 +711,12 @@ echo '</table> <br /> <div class="centre"> - <input type="submit" name="submit" value="' . _('Enter Information') . '" /> + <input type="submit" name="submit" value="' . _('Enter Information') . '" /> </div> - </div> + </div> </form>'; } //end if record deleted no point displaying form to add record include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/StockLocTransferReceive.php =================================================================== --- trunk/StockLocTransferReceive.php 2015-05-10 01:01:51 UTC (rev 7295) +++ trunk/StockLocTransferReceive.php 2015-05-10 04:54:12 UTC (rev 7296) @@ -6,21 +6,22 @@ include('includes/DefineStockTransfers.php'); include('includes/session.inc'); -$Title = _('Inventory Transfer') . ' - ' . _('Receiving'); -$BookMark = "LocationTransfers"; -$ViewTopic = "Inventory"; +$Title = _('Inventory Transfer') . ' - ' . _('Receiving');// Screen identification. +$ViewTopic = 'Inventory';// Filename's id in ManualContents.php's TOC. +$BookMark = 'LocationTransfers';// Anchor's id in the manual's html document. include('includes/header.inc'); + include('includes/SQL_CommonFunctions.inc'); -if (isset($_GET['NewTransfer'])){ +if(isset($_GET['NewTransfer'])) { unset($_SESSION['Transfer']); } -if ( isset($_SESSION['Transfer']) and $_SESSION['Transfer']->TrfID == ''){ +if(isset($_SESSION['Transfer']) and $_SESSION['Transfer']->TrfID == '') { unset($_SESSION['Transfer']); } -if(isset($_POST['ProcessTransfer'])){ +if(isset($_POST['ProcessTransfer'])) { /*Ok Time To Post transactions to Inventory Transfers, and Update Posted variable & received Qty's to LocTransfers */ $PeriodNo = GetPeriod ($_SESSION['Transfer']->TranDate, $db); @@ -30,24 +31,24 @@ $i=0; $TotalQuantity = 0; foreach ($_SESSION['Transfer']->TransferItem AS $TrfLine) { - if (is_numeric(filter_number_format($_POST['Qty' . $i]))){ + if(is_numeric(filter_number_format($_POST['Qty' . $i]))) { /*Update the quantity received from the inputs */ $_SESSION['Transfer']->TransferItem[$i]->Quantity= round(filter_number_format($_POST['Qty' . $i]),$_SESSION['Transfer']->TransferItem[$i]->DecimalPlaces); - } elseif ($_POST['Qty' . $i]=='') { + } elseif($_POST['Qty' . $i]=='') { $_SESSION['Transfer']->TransferItem[$i]->Quantity= 0; - } else { + } else { prnMsg(_('The quantity entered for'). ' ' . $TrfLine->StockID . ' '. _('is not numeric') . '. ' . _('All quantities must be numeric'),'error'); $InputError = True; } - if (filter_number_format($_POST['Qty' . $i])<0){ + if(filter_number_format($_POST['Qty' . $i])<0) { prnMsg(_('The quantity entered for'). ' ' . $TrfLine->StockID . ' '. _('is negative') . '. ' . _('All quantities must be for positive numbers greater than zero'),'error'); $InputError = True; } - if ($TrfLine->PrevRecvQty + $TrfLine->Quantity > $TrfLine->ShipQty){ + if($TrfLine->PrevRecvQty + $TrfLine->Quantity > $TrfLine->ShipQty) { prnMsg( _('The Quantity entered plus the Quantity Previously Received can not be greater than the Total Quantity shipped for').' '. $TrfLine->StockID , 'error'); $InputError = True; } - if (isset($_POST['CancelBalance' . $i]) and $_POST['CancelBalance' . $i]==1){ + if(isset($_POST['CancelBalance' . $i]) and $_POST['CancelBalance' . $i]==1) { $_SESSION['Transfer']->TransferItem[$i]->CancelBalance=1; } else { $_SESSION['Transfer']->TransferItem[$i]->CancelBalance=0; @@ -55,16 +56,16 @@ $TotalQuantity += $TrfLine->Quantity; $i++; } /*end loop to validate and update the SESSION['Transfer'] data */ - if ($TotalQuantity < 0){ + if($TotalQuantity < 0) { prnMsg( _('All quantities entered are less than zero') . '. ' . _('Please correct that and try again'), 'error' ); $InputError = True; } //exit; - if (!$InputError){ + if(!$InputError) { /*All inputs must be sensible so make the stock movement records and update the locations stocks */ foreach ($_SESSION['Transfer']->TransferItem AS $TrfLine) { - if ($TrfLine->Quantity >=0){ + if($TrfLine->Quantity >=0) { $Result = DB_Txn_Begin(); /* Need to get the current location quantity will need it later for the stock movement */ @@ -74,7 +75,7 @@ AND loccode= '" . $_SESSION['Transfer']->StockLocationFrom . "'"; $Result = DB_query($SQL, _('Could not retrieve the stock quantity at the dispatch stock location prior to this transfer being processed') ); - if (DB_num_rows($Result)==1){ + if(DB_num_rows($Result)==1) { $LocQtyRow = DB_fetch_row($Result); $QtyOnHandPrior = $LocQtyRow[0]; } else { @@ -115,8 +116,8 @@ /*Insert the StockSerialMovements and update the StockSerialItems for controlled items*/ - if ($TrfLine->Controlled ==1){ - foreach($TrfLine->SerialItems as $Item){ + if($TrfLine->Controlled ==1) { + foreach($TrfLine->SerialItems as $Item) { /*We need to add or update the StockSerialItem record and The StockSerialMoves as well */ @@ -131,7 +132,7 @@ $Result = DB_query($SQL,'<br />' . _('Could not determine if the serial item exists') ); $SerialItemExistsRow = DB_fetch_row($Result); - if ($SerialItemExistsRow[0]==1){ + if($SerialItemExistsRow[0]==1) { $SQL = "UPDATE stockserialitems SET quantity= quantity - " . $Item->BundleQty . " @@ -188,7 +189,7 @@ AND loccode= '" . $_SESSION['Transfer']->StockLocationTo . "'"; $Result = DB_query($SQL, _('Could not retrieve the quantity on hand at the location being transferred to') ); - if (DB_num_rows($Result)==1){ + if(DB_num_rows($Result)==1) { $LocQtyRow = DB_fetch_row($Result); $QtyOnHandPrior = $LocQtyRow[0]; } else { @@ -196,6 +197,49 @@ $QtyOnHandPrior = 0; } +// COMMENT: "if($TrfLine->Quantity !=0) {}" should be as a general condition to avoid transactions in zero. + +// BEGIN: ********************************************************************** + // Insert outgoing inventory GL transaction if any of the locations has a GL account code: + if(($_SESSION['Transfer']->StockLocationFromAccount !='' or $_SESSION['Transfer']->StockLocationToAccount !='') and $TrfLine->Quantity !=0) { + // Get the account code: + if($_SESSION['Transfer']->StockLocationFromAccount !='') { + $AccountCode = $_SESSION['Transfer']->StockLocationFromAccount; + } else { + $StockGLCode = GetStockGLCode($TrfLine->StockID, $db);// Get Category's account codes. + $AccountCode = $StockGLCode['stockact'];// Select account code for stock. + } + // Get the item cost: + $SQLstandardcost = "SELECT stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost AS standardcost + FROM stockmaster + WHERE stockmaster.stockid ='" . $TrfLine->StockID . "'"; + $ErrMsg = _('The standard cost of the item cannot be retrieved because'); + $DbgMsg = _('The SQL that failed was'); + $myrow = DB_fetch_array(DB_query($SQLstandardcost,$ErrMsg,$DbgMsg)); + $StandardCost = $myrow['standardcost'];// QUESTION: Standard cost for: Assembly (value="A") and Manufactured (value="M") items ? + // Insert record: + $SQL = "INSERT INTO gltrans ( + periodno, + trandate, + type, + typeno, + account, + narrative, + amount) + VALUES ('" . + $PeriodNo . "','" . + $SQLTransferDate . + "',16,'" . + $_SESSION['Transfer']->TrfID . "','" . + $AccountCode . "','" . + $_SESSION['Transfer']->StockLocationFrom.' - '.$TrfLine->StockID.' x '.$TrfLine->Quantity.' @ '. $StandardCost . "','" . + -$TrfLine->Quantity * $StandardCost . "')"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The outgoing inventory GL transacction record could not be inserted because'); + $DbgMsg = _('The following SQL to insert records was used'); + $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true); + } +// END: ************************************************************************ + // Insert the stock movement for the stock coming into the to location $SQL = "INSERT INTO stockmoves (stockid, type, @@ -228,13 +272,11 @@ /*Get the ID of the StockMove... */ $StkMoveNo = DB_Last_Insert_ID($db,'stockmoves','stkmoveno'); - /*Insert the StockSerialMovements and update the StockSerialItems for controlled items*/ + /*Insert the StockSerialMovements and update the StockSerialItems for controlled items*/ + if($TrfLine->Controlled ==1) { + foreach($TrfLine->SerialItems as $Item) { + /*We need to add or update the StockSerialItem record and the StockSerialMoves as well */ - if ($TrfLine->Controlled ==1){ - foreach($TrfLine->SerialItems as $Item){ - /*We need to add or update the StockSerialItem record and - The StockSerialMoves as well */ - /*First need to check if the serial items already exists or not in the location to */ $SQL = "SELECT COUNT(*) FROM stockserialitems @@ -247,7 +289,7 @@ $SerialItemExistsRow = DB_fetch_row($Result); - if ($SerialItemExistsRow[0]==1){ + if($SerialItemExistsRow[0]==1) { $SQL = "UPDATE stockserialitems SET quantity= quantity + '" . $Item->BundleQty . "' @@ -312,9 +354,50 @@ $DbgMsg = _('The following SQL to update the stock record was used'); $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true); +// BEGIN: ********************************************************************** + // Insert incoming inventory GL transaction if any of the locations has a GL account code: + if(($_SESSION['Transfer']->StockLocationFromAccount !='' or $_SESSION['Transfer']->StockLocationToAccount !='') and $TrfLine->Quantity !=0) { + // Get the account code: + if($_SESSION['Transfer']->StockLocationToAccount !='') { + $AccountCode = $_SESSION['Transfer']->StockLocationToAccount; + } else { + $StockGLCode = GetStockGLCode($TrfLine->StockID, $db);// Get Category's account codes. + $AccountCode = $StockGLCode['stockact'];// Select account code for stock. + } + // Get the item cost: + $SQLstandardcost = "SELECT stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost AS standardcost + FROM stockmaster + WHERE stockmaster.stockid ='" . $TrfLine->StockID . "'"; + $ErrMsg = _('The standard cost of the item cannot be retrieved because'); + $DbgMsg = _('The SQL that failed was'); + $myrow = DB_fetch_array(DB_query($SQLstandardcost,$ErrMsg,$DbgMsg)); + $StandardCost = $myrow['standardcost'];// QUESTION: Standard cost for: Assembly (value="A") and Manufactured (value="M") items ? + // Insert record: + $SQL = "INSERT INTO gltrans ( + periodno, + trandate, + type, + typeno, + account, + narrative, + amount) + VALUES ('" . + $PeriodNo . "','" . + $SQLTransferDate . "', + 16,'" . + $_SESSION['Transfer']->TrfID . "','" . + $AccountCode . "','" . + $_SESSION['Transfer']->StockLocationTo.' - '.$TrfLine->StockID.' x '.$TrfLine->Quantity.' @ '. $StandardCost . "','" . + $TrfLine->Quantity * $StandardCost . "')"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The incoming inventory GL transacction record could not be inserted because'); + $DbgMsg = _('The following SQL to insert records was used'); + $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true); + } +// END: ************************************************************************ + 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){ + 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'). "' @@ -323,22 +406,22 @@ } 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."'"; + WHERE reference = '". $_SESSION['Transfer']->TrfID . "' + AND stockid = '". $TrfLine->StockID."'"; } $ErrMsg = _('CRITICAL ERROR') . '! ' . _('Unable to update the Location Transfer Record'); $Result = DB_query($sql, $ErrMsg, $DbgMsg, true); unset ($_SESSION['Transfer']->LineItem[$i]); unset ($_POST['Qty' . $i]); } /*end if Quantity > 0 */ - if ($TrfLine->CancelBalance==1){ + 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, $ErrMsg, $DbgMsg, true); // send an email to the inventory manager about this cancellation (as can lead to employee fraud) - if ($_SESSION['InventoryManagerEmail']!=''){ + if($_SESSION['InventoryManagerEmail']!='') { $ConfirmationText = _('Cancelled balance of transfer'). ': ' . $_SESSION['Transfer']->TrfID . "\r\n" . _('From Location') . ': ' . $_SESSION['Transfer']->StockLocationFrom . "\r\n" . _('To Location') . ': ' . $_SESSION['Transfer']->StockLocationTo . @@ -347,7 +430,7 @@ "\r\n" . _('By user') . ': ' . $_SESSION['UserID'] . "\r\n" . _('At') . ': ' . Date('Y-m-d H:i:s'); $EmailSubject = _('Cancelled balance of transfer'). ' ' . $_SESSION['Transfer']->TrfID; - if($_SESSION['SmtpSetting']==0){ + if($_SESSION['SmtpSetting']==0) { mail($_SESSION['InventoryManagerEmail'],$EmailSubject,$ConfirmationText); }else{ include('includes/htmlMimeMail.php'); @@ -370,7 +453,7 @@ } /*end of PRocess Transfer */ -if(isset($_GET['Trf_ID'])){ +if(isset($_GET['Trf_ID'])) { unset($_SESSION['Transfer']); @@ -384,7 +467,9 @@ loctransfers.shipqty, loctransfers.recqty, locations.locationname as shiplocationname, + locations.glaccountcode as shipaccountcode, reclocations.locationname as reclocationname, + reclocations.glaccountcode as recaccountcode, loctransfers.shiploc, loctransfers.recloc FROM loctransfers INNER JOIN locations @@ -401,7 +486,7 @@ $DbgMsg = _('The SQL to retrieve the transfer was'); $result = DB_query($sql,$ErrMsg,$DbgMsg); - if(DB_num_rows($result) == 0){ + if(DB_num_rows($result) == 0) { echo '<h3>' . _('Transfer') . ' #' . $_GET['Trf_ID'] . ' '. _('Does Not Exist') . '</h3><br />'; include('includes/footer.inc'); exit; @@ -412,8 +497,10 @@ $_SESSION['Transfer']= new StockTransfer($_GET['Trf_ID'], $myrow['shiploc'], $myrow['shiplocationname'], + $myrow['shipaccountcode'], $myrow['recloc'], $myrow['reclocationname'], + $myrow['recaccountcode'], Date($_SESSION['DefaultDateFormat']) ); /*Populate the StockTransfer TransferItem s array with the lines to be transferred */ $i = 0; @@ -435,7 +522,7 @@ } /* $_GET['Trf_ID'] is set */ -if (isset($_SESSION['Transfer'])){ +if(isset($_SESSION['Transfer'])) { //Begin Form for receiving shipment echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/supplier.png" title="' . _('Dispatch') . @@ -467,7 +554,7 @@ echo $tableheader; $k=0; foreach ($_SESSION['Transfer']->TransferItem AS $TrfLine) { - if ($k==1){ + if($k==1) { echo '<tr class="EvenTableRows">'; $k=0; } else { @@ -479,14 +566,14 @@ <td>' . $TrfLine->ItemDescription . '</td>'; echo '<td class="number">' . locale_number_format($TrfLine->ShipQty, $TrfLine->DecimalPlaces) . '</td>'; - if (isset($_POST['Qty' . $i]) AND is_numeric(filter_number_format($_POST['Qty' . $i]))){ + if(isset($_POST['Qty' . $i]) AND is_numeric(filter_number_format($_POST['Qty' . $i]))) { $_SESSION['Transfer']->TransferItem[$i]->Quantity= round(filter_number_format($_POST['Qty' . $i]),$TrfLine->DecimalPlaces); $Qty = round(filter_number_format($_POST['Qty' . $i]),$TrfLine->DecimalPlaces); - } else if ($TrfLine->Controlled==1) { - if (sizeOf($TrfLine->SerialItems)==0) { + } else if($TrfLine->Controlled==1) { + if(sizeOf($TrfLine->SerialItems)==0) { $Qty = 0; } else { $Qty = $TrfLine->Quantity; @@ -496,7 +583,7 @@ } echo '<td class="number">' . locale_number_format($TrfLine->PrevRecvQty, $TrfLine->DecimalPlaces) . '</td>'; - if ($TrfLine->Controlled==1){ + if($TrfLine->Controlled==1) { echo '<td class="number"><input type="hidden" name="Qty' . $i . '" value="' . locale_number_format($Qty,$TrfLine->DecimalPlaces) . '" /><a href="' . $RootPath .'/StockTransferControlled.php?TransferItem=' . $i . '" />' . $Qty . '</a></td>'; } else { echo '<td><input type="text" class="number" name="Qty' . $i . '" maxlength="10" size="auto" value="' . locale_number_format($Qty,$TrfLine->DecimalPlaces) . '" /></td>'; @@ -507,8 +594,8 @@ echo '<td><input type="checkbox" name="CancelBalance' . $i . '" value="1" /></td>'; - if ($TrfLine->Controlled==1){ - if ($TrfLine->Serialised==1){ + if($TrfLine->Controlled==1) { + if($TrfLine->Serialised==1) { echo '<td><a href="' . $RootPath .'/StockTransferControlled.php?TransferItem=' . $i . '">' . _('Enter Serial Numbers') . '</a></td>'; } else { echo '<td><a href="' . $RootPath .'/StockTransferControlled.php?TransferItem=' . $i . '">' . _('Enter Batch Refs') . '</a></td>'; @@ -545,11 +632,11 @@ <td>' . _('Select Location Receiving Into'). ':</td> <td>'; echo '<select name="RecLocation" onchange="ReloadForm(form1.RefreshTransferList)">'; - if (!isset($_POST['RecLocation'])){ + if(!isset($_POST['RecLocation'])) { $_POST['RecLocation'] = $_SESSION['UserStockLocation']; } - while ($myrow=DB_fetch_array($LocResult)){ - if ($myrow['loccode'] == $_POST['RecLocation']){ + while ($myrow=DB_fetch_array($LocResult)) { + if($myrow['loccode'] == $_POST['RecLocation']) { echo '<option selected="selected" value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } else { echo '<option value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; @@ -570,7 +657,7 @@ AND recqty < shipqty"; $TrfResult = DB_query($sql); - if (DB_num_rows($TrfResult)>0){ + if(DB_num_rows($TrfResult)>0) { $LocSql = "SELECT locationname FROM locations WHERE loccode='" . $_POST['RecLocation'] . "'"; $LocResult = DB_query($LocSql); $LocRow = DB_fetch_array($LocResult); @@ -581,9 +668,9 @@ <th>' . _('Transfer From'). '</th> <th>' . _('Dispatch Date'). '</th></tr>'; $k=0; - while ($myrow=DB_fetch_array($TrfResult)){ + while ($myrow=DB_fetch_array($TrfResult)) { - if ($k==1){ + if($k==1) { echo '<tr class="EvenTableRows">'; $k=0; } else { @@ -597,7 +684,7 @@ </tr>'; } echo '</table>'; - } else if (!isset($_POST['ProcessTransfer'])) { + } else if(!isset($_POST['ProcessTransfer'])) { prnMsg(_('There are no incoming transfers to this location'), 'info'); } echo '</div> Modified: trunk/StockTransfers.php =================================================================== --- trunk/StockTransfers.php 2015-05-10 01:01:51 UTC (rev 7295) +++ trunk/StockTransfers.php 2015-05-10 04:54:12 UTC (rev 7296) @@ -1,35 +1,36 @@ <?php /* $Id$*/ -/* Inventory Transfer - Item Dispatch */ +/* Entry of point to point stock location transfers of a single part. */ include('includes/DefineSerialItems.php'); include('includes/DefineStockTransfers.php'); include('includes/session.inc'); -$Title = _('Stock Transfers'); -$BookMark = "LocationTransfers"; -$ViewTopic = "Inventory"; +$Title = _('Stock Transfers');// Screen identification. +$ViewTopic = "Inventory";// Filename's id in ManualContents.php's TOC. +$BookMark = "LocationTransfers";// Anchor's id in the manual's html document. include('includes/header.inc'); + include('includes/SQL_CommonFunctions.inc'); -if (isset($_GET['New'])) { +if(isset($_GET['New'])) { unset($_SESSION['Transfer']); } -if (isset($_GET['From'])) { +if(isset($_GET['From'])) { $_POST['StockLocationFrom']=$_GET['From']; $_POST['StockLocationTo']=$_GET['To']; $_POST['Quantity']=$_GET['Quantity']; } -if (isset($_POST['CheckCode'])) { +if(isset($_POST['CheckCode'])) { echo '<p class="page_title_text"> <img src="'.$RootPath.'/css/'.$Theme.'/images/magnifier.png" title="' . _('Dispatch') . '" alt="" /> ' . ' ' . _('Select Item to Transfer') . ' </p>'; - if (mb_strlen($_POST['StockText'])>0) { + if(mb_strlen($_POST['StockText'])>0) { $sql="SELECT stockid, description FROM stockmaster @@ -48,7 +49,7 @@ <th class="ascending">' . _('Stock Code') . '</th> <th class="ascending">' . _('Stock Description') . '</th> </tr>'; - while ($myrow = DB_fetch_array($result)) { + while($myrow = DB_fetch_array($result)) { echo '<tr> <td>' . $myrow['stockid'] . '</td> <td>' . $myrow['description'] . '</td> @@ -64,18 +65,18 @@ $NewTransfer = false; /*initialise this first then determine from form inputs */ -if (isset($_GET['NewTransfer'])){ +if(isset($_GET['NewTransfer'])) { unset($_SESSION['Transfer']); unset($_SESSION['TransferItem']); /*this is defined in bulk transfers but needs to be unset for individual transfers */ $NewTransfer=$_GET['NewTransfer']; } -if (isset($_GET['StockID'])){ /*carry the stockid through to the form for additional inputs */ +if(isset($_GET['StockID'])) { /*carry the stockid through to the form for additional inputs */ $_POST['StockID'] = trim(mb_strtoupper($_GET['StockID'])); -} elseif (isset($_POST['StockID'])){ /* initiate a new transfer only if the StockID is different to the previous entry */ - if (isset($_SESSION['Transfer']->TransferItem[0])) { - if ($_POST['StockID'] != $_SESSION['Transfer']->TransferItem[0]->StockID){ +} elseif(isset($_POST['StockID'])) { /* initiate a new transfer only if the StockID is different to the previous entry */ + if(isset($_SESSION['Transfer']->TransferItem[0])) { + if($_POST['StockID'] != $_SESSION['Transfer']->TransferItem[0]->StockID) { unset($_SESSION['Transfer']); $NewTransfer = true; } @@ -84,12 +85,12 @@ } } -if ($NewTransfer){ +if($NewTransfer) { - if(!isset($_POST['StockLocationFrom'])){ + if(!isset($_POST['StockLocationFrom'])) { $_POST['StockLocationFrom']=''; } - if(!isset($_POST['StockLocationTo'])){ + if(!isset($_POST['StockLocationTo'])) { $_POST['StockLocationTo']=''; } @@ -111,11 +112,11 @@ FROM stockmaster WHERE stockid='" . trim(mb_strtoupper($_POST['StockID'])) . "'"); - if (DB_num_rows($result) == 0){ + if(DB_num_rows($result) == 0) { prnMsg( _('Unable to locate Stock Code').' '.mb_strtoupper($_POST['StockID']), 'error' ); - } elseif (DB_num_rows($result)>0){ + } elseif(DB_num_rows($result)>0) { $myrow = DB_fetch_array($result); - $_SESSION['Transfer']->TransferItem[0] = new LineItem ( trim(mb_strtoupper($_POST['StockID'])), + $_SESSION['Transfer']->TransferItem[0] = new LineItem( trim(mb_strtoupper($_POST['StockID'])), $myrow['description'], filter_number_format($_POST['Quantity']), $myrow['units'], @@ -127,66 +128,66 @@ $_SESSION['Transfer']->TransferItem[0]->StandardCost = $myrow['standardcost']; - if ($myrow['mbflag']=='D' OR $myrow['mbflag']=='A' OR $myrow['mbflag']=='K'){ + if($myrow['mbflag']=='D' OR $myrow['mbflag']=='A' OR $myrow['mbflag']=='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?NewTransfer=Yes">' . _('Enter another Transfer') . '</a>'; - unset ($_SESSION['Transfer']); - include ('includes/footer.inc'); + unset($_SESSION['Transfer']); + include('includes/footer.inc'); exit; } } } -if (isset($_POST['Quantity']) +if(isset($_POST['Quantity']) AND isset($_SESSION['Transfer']->TransferItem[0]->Controlled) - AND $_SESSION['Transfer']->TransferItem[0]->Controlled==0){ + AND $_SESSION['Transfer']->TransferItem[0]->Controlled==0) { $_SESSION['Transfer']->TransferItem[0]->Quantity = filter_number_format($_POST['Quantity']); } -if ( isset($_POST['StockLocationFrom']) - AND $_POST['StockLocationFrom']!= $_SESSION['Transfer']->StockLocationFrom ){ +if(isset($_POST['StockLocationFrom']) + AND $_POST['StockLocationFrom']!= $_SESSION['Transfer']->StockLocationFrom ) { $_SESSION['Transfer']->StockLocationFrom = $_POST['StockLocationFrom']; $_SESSION['Transfer']->StockLocationTo = $_POST['StockLocationTo']; $_SESSION['Transfer']->TransferItem[0]->Quantity=filter_number_format($_POST['Quantity']); $_SESSION['Transfer']->TransferItem[0]->SerialItems=array(); } -if ( isset($_POST['StockLocationTo']) ){ +if(isset($_POST['StockLocationTo']) ) { $_SESSION['Transfer']->StockLocationTo = $_POST['StockLocationTo']; } -if ( isset($_POST['EnterTransfer']) ){ +if(isset($_POST['EnterTransfer']) ) { $result = DB_query("SELECT * FROM stockmaster WHERE stockid='" . $_SESSION['Transfer']->TransferItem[0]->StockID ."'"); $myrow = DB_fetch_row($result); $InputError = false; - if (DB_num_rows($result)==0) { + if(DB_num_rows($result)==0) { echo '<br />'; prnMsg(_('The entered item code does not exist'), 'error'); $InputError = true; - } elseif (!is_numeric($_SESSION['Transfer']->TransferItem[0]->Quantity)){ + } elseif(!is_numeric($_SESSION['Transfer']->TransferItem[0]->Quantity)) { echo '<br />'; prnMsg( _('The quantity entered must be numeric'), 'error' ); $InputError = true; - } elseif ($_SESSION['Transfer']->TransferItem[0]->Quantity <= 0){ + } elseif($_SESSION['Transfer']->TransferItem[0]->Quantity <= 0) { echo '<br />'; prnMsg( _('The quantity entered must be a positive number greater than zero'), 'error'); $InputError = true; } - if ($_SESSION['Transfer']->StockLocationFrom==$_SESSION['Transfer']->StockLocationTo){ + if($_SESSION['Transfer']->StockLocationFrom==$_SESSION['Transfer']->StockLocationTo) { echo '<br />'; prnMsg( _('The locations to transfer from and to must be different'), 'error'); $InputError = true; } - if ($InputError==False) { + if($InputError==False) { /*All inputs must be sensible so make the stock movement records and update the locations stocks */ $TransferNumber = GetNextTransNo(16,$db); - $PeriodNo = GetPeriod (Date($_SESSION['DefaultDateFormat']), $db); + $PeriodNo = GetPeriod(Date($_SESSION['DefaultDateFormat']), $... [truncated message content] |