Fwd: [Web-erp-svn] SF.net SVN: web-erp:[7296] trunk

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Fwd: [Web-erp-svn] SF.net SVN: web-erp:[7296] trunk

Rafael Chacón
I uploaded two 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.

I tried to document inside the code (for programmers) and inside the manual (for users). Feel free to modify this documentación; specifically, for those who are English-GB native speakers, please review and fix (remember, I am not an english native speaker).

Best regards, Rafael.


---------- Forwarded message ----------
From: <[hidden email]>
Date: 2015-05-09 22:54 GMT-06:00
Subject: [Web-erp-svn] SF.net SVN: web-erp:[7296] trunk
To: [hidden email]


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   .  '&amp;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  . '&amp;NewRecurringOrder=Yes">' .  _('click here')  . '</a> '. _('to continue'),'info');
+       echo '<meta http-equiv="Refresh" content="0; url=' . $RootPath . '/RecurringSalesOrders.php?identifier='.$identifier  . '&amp;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 . '&amp;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 . '&amp;TransNo=' . $OrderNo . '">' .  _('Print packing slip') . ' (' . _('Preprinted stationery') . ')'  . '</a></td>
+                                               <td>' . ' ' . '<a target="_blank" href="' . $RootPath . '/PrintCustOrder.php?identifier='.$identifier . '&amp;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 . '&amp;TransNo=' . $OrderNo . '">' .  _('Print packing slip') . ' (' . _('Laser') . ')'  . '</a></td>
+                                       <td>' . ' ' . '<a target="_blank" href="' . $RootPath . '/PrintCustOrder_generic.php?identifier='.$identifier . '&amp;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 . '&amp;OrderNumber=' . $OrderNo .'">' .  _('Confirm Dispatch and Produce Invoice')  . '</a></td>
+                                       <td>' . ' ' . '<a href="' . $RootPath . '/ConfirmDispatch_Invoice.php?identifier='.$identifier . '&amp;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 . '&amp;QuotationNo=' . $OrderNo . '" target="_blank">' .  _('Print Quotation (Landscape)')  . '</a></td>
+                                               <td>' . ' ' . '<a href="' . $RootPath . '/PDFQuotation.php?identifier='.$identifier . '&amp;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">&nbsp;</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&amp;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'] : '&nbsp;'),// 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']), $db);
                $SQLTransferDate = FormatDateForSQL(Date($_SESSION['DefaultDateFormat']));

                $Result = DB_Txn_Begin();
@@ -201,21 +202,61 @@
                $DbgMsg =  _('The SQL that failed was');
                $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);

-               if (DB_num_rows($Result)==1){
+               if(DB_num_rows($Result)==1) {
                        $LocQtyRow = DB_fetch_row($Result);
                        $QtyOnHandPrior = $LocQtyRow[0];
                } else {
                        // There must actually be some error this should never happen
                        $QtyOnHandPrior = 0;
                }
-               if ($_SESSION['ProhibitNegativeStock']==1
+               if($_SESSION['ProhibitNegativeStock']==1
                        AND $QtyOnHandPrior<$_SESSION['Transfer']->TransferItem[0]->Quantity) {
                        prnMsg( _('There is insufficient stock to make this transfer and webERP is setup to prevent negative stock'), 'warn');
                        include('includes/footer.inc');
                        exit;
                }
+// BEGIN: **********************************************************************
+               // Insert outgoing inventory GL transaction if any of the locations has a GL account code:
+               if($_SESSION['Transfer']->StockLocationFromAccount !='' or $_SESSION['Transfer']->StockLocationToAccount !='') {
+                       // Get the account code:
+                       if($_SESSION['Transfer']->StockLocationToAccount !='') {
+                               $AccountCode = $_SESSION['Transfer']->StockLocationToAccount;
+                       } else {
+                               $StockGLCode = GetStockGLCode($_SESSION['Transfer']->TransferItem[0]->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 ='" . $_SESSION['Transfer']->TransferItem[0]->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,'" .
+                                       $TransferNumber . "','" .
+                                       $AccountCode . "','" .
+                                       $_SESSION['Transfer']->StockLocationFrom.' - '.$_SESSION['Transfer']->TransferItem[0]->StockID.' x '.$_SESSION['Transfer']->TransferItem[0]->Quantity.' @ '. $StandardCost . "','" .
+                                       -$_SESSION['Transfer']->TransferItem[0]->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 going out of the from location
-               $SQL = "INSERT INTO stockmoves (stockid,
+               $SQL = "INSERT INTO stockmoves(stockid,
                                                                                type,
                                                                                transno,
                                                                                loccode,
@@ -247,8 +288,8 @@

 /*Insert the StockSerialMovements and update the StockSerialItems  for controlled items*/

-               if ($_SESSION['Transfer']->TransferItem[0]->Controlled ==1){
-                       foreach($_SESSION['Transfer']->TransferItem[0]->SerialItems as $Item){
+               if($_SESSION['Transfer']->TransferItem[0]->Controlled ==1) {
+                       foreach($_SESSION['Transfer']->TransferItem[0]->SerialItems as $Item) {
                        /*We need to add or update the StockSerialItem record and
                        The StockSerialMoves as well */

@@ -264,7 +305,7 @@
                                $Result = DB_query($SQL,$ErrMsg);
                                $SerialItemExistsRow = DB_fetch_row($Result);

-                               if ($SerialItemExistsRow[0]==1){
+                               if($SerialItemExistsRow[0]==1) {

                                        $SQL = "UPDATE stockserialitems
                                                        SET quantity= quantity - '" . $Item->BundleQty . "',
@@ -324,14 +365,53 @@
                                AND loccode= '" . $_SESSION['Transfer']->StockLocationTo . "'";
                $ErrMsg = _('Could not retrieve QOH at the destination because');
                $Result = DB_query($SQL, $ErrMsg, $DbgMsg,true);
-               if (DB_num_rows($Result)==1){
+               if(DB_num_rows($Result)==1) {
                        $LocQtyRow = DB_fetch_row($Result);
                        $QtyOnHandPrior = $LocQtyRow[0];
                } else {
                        // There must actually be some error this should never happen
                        $QtyOnHandPrior = 0;
                }
-
+// BEGIN: **********************************************************************
+               // Insert incoming inventory GL transaction if any of the locations has a GL account code:
+               if($_SESSION['Transfer']->StockLocationFromAccount !='' or $_SESSION['Transfer']->StockLocationToAccount !='') {
+                       // Get the account code:
+                       if($_SESSION['Transfer']->StockLocationToAccount !='') {
+                               $AccountCode = $_SESSION['Transfer']->StockLocationToAccount;
+                       } else {
+                               $StockGLCode = GetStockGLCode($_SESSION['Transfer']->TransferItem[0]->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 ='" . $_SESSION['Transfer']->TransferItem[0]->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,'" .
+                                       $TransferNumber . "','" .
+                                       $AccountCode . "','" .
+                                       $_SESSION['Transfer']->StockLocationTo.' - '.$_SESSION['Transfer']->TransferItem[0]->StockID.' x '.$_SESSION['Transfer']->TransferItem[0]->Quantity.' @ '. $StandardCost . "','" .
+                                       $_SESSION['Transfer']->TransferItem[0]->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: ************************************************************************
                // Insert the stock movement for the stock coming into the to location
                $SQL = "INSERT INTO stockmoves (stockid,
                                                type,
@@ -363,8 +443,8 @@

 /*Insert the StockSerialMovements and update the StockSerialItems  for controlled items*/

-               if ($_SESSION['Transfer']->TransferItem[0]->Controlled ==1){
-                       foreach($_SESSION['Transfer']->TransferItem[0]->SerialItems as $Item){
+               if($_SESSION['Transfer']->TransferItem[0]->Controlled ==1) {
+                       foreach($_SESSION['Transfer']->TransferItem[0]->SerialItems as $Item) {
                        /*We need to add or update the StockSerialItem record and
                        The StockSerialMoves as well */

@@ -379,7 +459,7 @@
                                $Result = DB_query($SQL,$ErrMsg);
                                $SerialItemExistsRow = DB_fetch_row($Result);

-                               if ($SerialItemExistsRow[0]==1){
+                               if($SerialItemExistsRow[0]==1) {

                                        $SQL = "UPDATE stockserialitems
                                                        SET quantity= quantity + '" . $Item->BundleQty . "',
@@ -451,8 +531,8 @@

                prnMsg(_('An inventory transfer of').' ' . $_SESSION['Transfer']->TransferItem[0]->StockID . ' - ' . $_SESSION['Transfer']->TransferItem[0]->ItemDescription . ' '. _('has been created from').' ' . $_SESSION['Transfer']->StockLocationFrom . ' '. _('to') . ' ' . $_SESSION['Transfer']->StockLocationTo . ' '._('for a quantity of').' ' . $_SESSION['Transfer']->TransferItem[0]->Quantity,'success');
                echo '<br /><a href="PDFStockTransfer.php?TransferNo='.$TransferNumber.'">' . _('Print Transfer Note') . '</a>';
-               unset ($_SESSION['Transfer']);
-               include ('includes/footer.inc');
+               unset($_SESSION['Transfer']);
+               include('includes/footer.inc');
                exit;
        }

@@ -466,14 +546,14 @@
 echo '<div>';
 echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';

-if (!isset($_GET['Description'])) {
+if(!isset($_GET['Description'])) {
        $_GET['Description']='';
 }
 echo '<table class="selection">
                <tr>
                        <td>' .  _('Stock Code'). ':</td>
                        <td>';
-if (!isset($_POST['StockID'])) {
+if(!isset($_POST['StockID'])) {
        $_POST['StockID'] = '';
 }
        echo '<input type="text"  title="'._('The stock ID should not be blank or contains illegal characters, you can choose left this blank and only keyin')._('Partial Stock Code')._('or')._('Partial Description')._('then push')._('Check Part').'" name="StockID" size="21" value="' . $_POST['StockID'] . '" maxlength="20" /></td></tr>';
@@ -481,15 +561,15 @@
 echo '<tr><td>' .  _('Partial Description'). ':</td>
                <td><input type="text" name="StockText" title="'._('You can key in part of stock description or left this and ')._('Partial Stock Code')._('blank and click ')._('Check Part').' '._('to view the whole stock list').'" size="21" value="' . $_GET['Description'] .'" /></td>
                <td>' . _('Partial Stock Code'). ':</td><td>';
-if (isset($_POST['StockID'])) {
+if(isset($_POST['StockID'])) {
        echo '<input type="text" title="'._('You can key in partial of the stock code or just left this blank to click').' '._('Check Part').'" name="StockCode" size="21" value="' . $_POST['StockID'] .'" maxlength="20" />';
 } else {
        echo '<input type="text" title="'._('You can key in partial of the stock code or just left this blank to click').' '._('Check Part').'" name="StockCode" size="21" value="" maxlength="20" />';
 }
 echo '</td><td><input type="submit" name="CheckCode" value="'._('Check Part').'" /></td></tr>';

-if (isset($_SESSION['Transfer']->TransferItem[0]->ItemDescription)
-       AND mb_strlen($_SESSION['Transfer']->TransferItem[0]->ItemDescription)>1){
+if(isset($_SESSION['Transfer']->TransferItem[0]->ItemDescription)
+       AND mb_strlen($_SESSION['Transfer']->TransferItem[0]->ItemDescription)>1) {

        echo '<tr>
                        <td colspan="3"><font color="blue" size="3">' . $_SESSION['Transfer']->TransferItem[0]->ItemDescription . ' ('._('In Units of').' ' . $_SESSION['Transfer']->TransferItem[0]->PartUnit . ' )</font></td>
@@ -502,14 +582,14 @@

 $sql = "SELECT locations.loccode, locationname FROM locations INNER JOIN locationusers ON locationusers.loccode=locations.loccode AND locationusers.userid='" .  $_SESSION['UserID'] . "' AND locationusers.canupd=1";
 $resultStkLocs = DB_query($sql);
-while ($myrow=DB_fetch_array($resultStkLocs)){
-       if (isset($_SESSION['Transfer']->StockLocationFrom)){
-               if ($myrow['loccode'] == $_SESSION['Transfer']->StockLocationFrom){
+while($myrow=DB_fetch_array($resultStkLocs)) {
+       if(isset($_SESSION['Transfer']->StockLocationFrom)) {
+               if($myrow['loccode'] == $_SESSION['Transfer']->StockLocationFrom) {
                         echo '<option selected="selected" value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>';
                } else {
                         echo '<option value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>';
                }
-       } elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){
+       } elseif($myrow['loccode']==$_SESSION['UserStockLocation']) {
                echo '<option selected="selected" value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>';
                if(isset($_SESSION['Transfer']))
                 $_SESSION['Transfer']->StockLocationFrom=$myrow['loccode'];
@@ -527,14 +607,14 @@

 DB_data_seek($resultStkLocs,0);

-while ($myrow=DB_fetch_array($resultStkLocs)){
-       if (isset($_SESSION['Transfer']) AND isset($_SESSION['Transfer']->StockLocationTo)){
-               if ($myrow['loccode'] == $_SESSION['Transfer']->StockLocationTo){
+while($myrow=DB_fetch_array($resultStkLocs)) {
+       if(isset($_SESSION['Transfer']) AND isset($_SESSION['Transfer']->StockLocationTo)) {
+               if($myrow['loccode'] == $_SESSION['Transfer']->StockLocationTo) {
                         echo '<option selected="selected" value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>';
                } else {
                         echo '<option value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>';
                }
-       } elseif ($myrow['loccode']==$_SESSION['UserStockLocation'] AND isset($_SESSION['Transfer'])){
+       } elseif($myrow['loccode']==$_SESSION['UserStockLocation'] AND isset($_SESSION['Transfer'])) {
                echo '<option selected="selected" value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>';
                if(isset($_SESSION['Transfer']))
                 $_SESSION['Transfer']->StockLocationTo=$myrow['loccode'];
@@ -548,11 +628,11 @@
 echo '<tr>
                <td>' . _('Transfer Quantity').':</td>';

-if (isset($_SESSION['Transfer']->TransferItem[0]->Controlled)
-       AND $_SESSION['Transfer']->TransferItem[0]->Controlled==1){
+if(isset($_SESSION['Transfer']->TransferItem[0]->Controlled)
+       AND $_SESSION['Transfer']->TransferItem[0]->Controlled==1) {

        echo '<td class="number"><input type="hidden" name="Quantity" value="' . locale_number_format($_SESSION['Transfer']->TransferItem[0]->Quantity) . '" /><a href="' . $RootPath .'/StockTransferControlled.php?StockLocationFrom='.$_SESSION['Transfer']->StockLocationFrom.'">' . $_SESSION['Transfer']->TransferItem[0]->Quantity . '</a></td></tr>';
-} elseif (isset($_SESSION['Transfer']->TransferItem[0]->Controlled)){
+} elseif(isset($_SESSION['Transfer']->TransferItem[0]->Controlled)) {
        echo '<td><input type="text" class="number" name="Quantity" title="'._('The transfer quantity cannot be zero').'" size="12" maxlength="12" value="' . locale_number_format($_SESSION['Transfer']->TransferItem[0]->Quantity) . '" /></td></tr>';
 } else {
        echo '<td><input type="text" class="number"  title="'._('The transfer quantity cannot be zer0').'" name="Quantity" size="12" maxlength="12" value="0" /></td>
@@ -565,14 +645,14 @@
                <input type="submit" name="EnterTransfer" value="' . _('Enter Stock Transfer') . '" />
                <br />';

-if (empty($_SESSION['Transfer']->TransferItem[0]->StockID) and isset($_POST['StockID'])) {
+if(empty($_SESSION['Transfer']->TransferItem[0]->StockID) and isset($_POST['StockID'])) {
        $StockID=$_POST['StockID'];
-} else if (isset($_SESSION['Transfer']->TransferItem[0]->StockID)) {
+} elseif(isset($_SESSION['Transfer']->TransferItem[0]->StockID)) {
        $StockID=$_SESSION['Transfer']->TransferItem[0]->StockID;
 } else {
        $StockID='';
 }
-if (isset($_SESSION['Transfer'])) {
+if(isset($_SESSION['Transfer'])) {
        echo '<br />
                <a href="'.$RootPath.'/StockStatus.php?StockID=' . $StockID . '">' . _('Show Stock Status') . '</a>';
        echo '<br />

Modified: trunk/Z_ChangeGLAccountCode.php
===================================================================
--- trunk/Z_ChangeGLAccountCode.php     2015-05-10 01:01:51 UTC (rev 7295)
+++ trunk/Z_ChangeGLAccountCode.php     2015-05-10 04:54:12 UTC (rev 7296)
@@ -1,6 +1,6 @@
 <?php
 /* $Id: Z_ChangeGLAccountCode.php 6946 2014-10-27 07:30:11Z daintree $*/
-/* This script is an utility to change a GL account code in all webERP. */
+/* Utility to change a GL account code in all webERP. */

 include ('includes/session.inc');
 $Title = _('UTILITY PAGE Change A GL Account Code');// Screen identificator.
@@ -8,7 +8,7 @@
 $BookMark = 'Z_ChangeGLAccountCode'; // Anchor's id in the manual's html document.
 include('includes/header.inc');
 echo '<p class="page_title_text"><img alt="" src="'.$RootPath.'/css/'.$Theme.
-       '/images/gl.png" title="' .
+       '/images/gl.png" title="' .
        _('Change A GL Account Code') . '" /> ' .// Icon title.
        _('Change A GL Account Code') . '</p>';// Page title.

@@ -96,6 +96,10 @@
                ChangeFieldInTable("lastcostrollup", "stockact", $_POST['OldAccountCode'], $_POST['NewAccountCode'], $db);
                ChangeFieldInTable("lastcostrollup", "adjglact", $_POST['OldAccountCode'], $_POST['NewAccountCode'], $db);

+// BEGIN: **********************************************************************
+               ChangeFieldInTable("locations", "glaccountcode", $_POST['OldAccountCode'], $_POST['NewAccountCode'], $db);// Location's ledger account.
+// END: ************************************************************************
+
                ChangeFieldInTable("pcexpenses", "glaccount", $_POST['OldAccountCode'], $_POST['NewAccountCode'], $db);

                ChangeFieldInTable("pctabs", "glaccountassignment", $_POST['OldAccountCode'], $_POST['NewAccountCode'], $db);
@@ -156,6 +160,4 @@
        </form>';

 include('includes/footer.inc');
-
-
-?>
+?>
\ No newline at end of file

Modified: trunk/Z_ChangeLocationCode.php
===================================================================
--- trunk/Z_ChangeLocationCode.php      2015-05-10 01:01:51 UTC (rev 7295)
+++ trunk/Z_ChangeLocationCode.php      2015-05-10 04:54:12 UTC (rev 7296)
@@ -8,7 +8,7 @@
 $BookMark = 'Z_ChangeLocationCode'; // Anchor's id in the manual's html document.
 include('includes/header.inc');
 echo '<p class="page_title_text"><img alt="" src="'.$RootPath.'/css/'.$Theme.
-       '/images/maintenance.png" title="' .
+       '/images/maintenance.png" title="' .
        _('Change A Location Code') . '" /> ' .// Icon title.
        _('Change A Location Code') . '</p>';// Page title.

@@ -74,7 +74,12 @@
                                                                                taxprovinceid,
                                                                                managed,
                                                                                cashsalecustomer,
-                                                                               cashsalebranch)
+                                                                               cashsalebranch,
+                                                                               internalrequest,
+                                                                               usedforwo,
+                                                                               glaccountcode,
+                                                                               allowinvoicing
+                                                                               )
                                SELECT '" . $_POST['NewLocationID'] . "',
                                            '" . $_POST['NewLocationName'] . "',
                                                deladd1,
@@ -90,7 +95,11 @@
                                                taxprovinceid,
                                                managed,
                                                cashsalecustomer,
-                                               cashsalebranch
+                                               cashsalebranch,
+                                               internalrequest,
+                                               usedforwo,
+                                               glaccountcode,
+                                               allowinvoicing
                                FROM locations
                                WHERE loccode='" . $_POST['OldLocationID'] . "'";


Modified: trunk/doc/Change.log
===================================================================
--- trunk/doc/Change.log        2015-05-10 01:01:51 UTC (rev 7295)
+++ trunk/doc/Change.log        2015-05-10 04:54:12 UTC (rev 7296)
@@ -1,5 +1,6 @@
 webERP Change Log

+10/05/15 RChacon: 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.
 08/05/15 RChacon: In DeliveryDetails.php, add $ViewTopic and $BookMark to ManualSalesOrders.html.
 07/05/15 RChacon: In CustomerInquiry.php, hide submit button and 'More Info' columns when printing. Add thead tag to enable the table header to be printed at the top of each page.
 07/05/15 RChacon: In SupplierInquiry.php, hide submit button and 'More Info' columns when printing. Add thead tag to enable the table header to be printed at the top of each page.

Modified: trunk/doc/Manual/ManualAccountsReceivable.html
===================================================================
--- trunk/doc/Manual/ManualAccountsReceivable.html      2015-05-10 01:01:51 UTC (rev 7295)
+++ trunk/doc/Manual/ManualAccountsReceivable.html      2015-05-10 04:54:12 UTC (rev 7296)
@@ -120,7 +120,7 @@

 <p>A select box is available to enter the salesperson who services this branch.</p>

-<h3>Draw Stock From</h3>
+<h3><a id="DrawStockFrom">Draw Stock From</a></h3>

 <p>Branches local to a particular warehouse can be associated with the local warehouse by setting this field to the preferred stocking location (see <a href="ManualContents.php?ViewTopic=Inventory#Locations">Inventory Locations Maintenance</a>). This affects the entry of sales orders that default to the stock location entered here. It can be overridden at the time of order entry.</p>


Modified: trunk/doc/Manual/ManualInventory.html
===================================================================
--- trunk/doc/Manual/ManualInventory.html       2015-05-10 01:01:51 UTC (rev 7295)
+++ trunk/doc/Manual/ManualInventory.html       2015-05-10 04:54:12 UTC (rev 7296)
@@ -517,15 +517,55 @@
     <p>A table of locations is maintained which contains a location code of 5 characters and the location description (up to 20 characters).</p>
     <p>Inventory locations are the factories or warehouses where inventory is stored. When a sales order is created the location from which the inventory is to be picked is specified. Also, when a work order is created it is created on a specific location - in this case a manufacturing facility. Every transaction involving inventory must specify the location.</p>
     <p>To create or modify inventory locations go to the Main Menu -> Setup -> Inventory Setup tab and select Inventory Location Maintenance</p>
-       <p><img src="images/InventoryLocations.jpg" alt="Inventory Locations" /></p>
+       <p><img src="images/InventoryLocations.png" alt="Inventory Locations" /></p>
     <p>The description is the field used in lookups on invoicing and crediting. To keep the database as compact as possible it is the code which is stored against stock movement transactions. As many locations as required can be set up. When a new location is defined, location records for all items in the database are created. When a location is deleted, so too are all the item location records. However, a location record cannot be deleted if there are stock movements or stock held for any part in the location.</p>
     <p>When creating a purchase order, the inventory location that it is required for is specified. The inventory location address and contact details defined here are used as the default addresses available for delivery of goods ordered on purchase orders.</p>
-    <p>Since the location represents the physical location from where goods/services are supplied it is important for determining the tax applicable on a sale. The governing tax authority must specified with the location record. It is used in the calculation of the applicable rate of tax in conjunction with the tax authority of the customer branch being delivered to and the tax level of the item being sold.</p>
-       <p>The counter sales functionality looks at the default inventory location for a user and when that user enters a counter sale it uses the customer account and customer branch defined against the inventory location record. Consider a business with locations in Melbourne Australia and one in Anahaim USA - it is unlikely that a user based in Anaheim would be making a counter sale in Melbourne! Each location can have a customer account (and branch) defined for it's counter sales. These customers are expected to be cash only customers as the counter sales functionality expects the cash to be taken at the time of the sale. Not a substitute for proper Point of Sale - but suitable for occassional Counter Sales.</p>
-    <p>Some inventory locations are never going to be used as manufacturing facilities and to reduce the scope for errors it is possible to specify those inventory locations which can be used for work orders.</p>
+
+       <dl>
+       <!--dt><Location Code</dt>
+       <dd>.</dd>
+       <dt>Location Name</dt>
+       <dd>.</dd>
+       <dt>Contact for deliveries</dt>
+       <dd>.</dd>
+       <dt>Delivery Address 1 (Building)</dt>
+       <dd>.</dd>
+       <dt>Delivery Address 2 (Street):</dt>
+       <dd>.</dd>
+       <dt>Delivery Address 3 (Suburb):</dt>
+       <dd>.</dd>
+       <dt>Delivery Address 4 (City):</dt>
+       <dd>.</dd>
+       <dt>Delivery Address 5 (Zip Code):</dt>
+       <dd>.</dd>
+       <dt>Country</dt>
+       <dd>.</dd>
+       <dt>Telephone No:</dt>
+       <dd>.</dd>
+       <dt>Facsimile No:</dt>
+       <dd>.</dd>
+       <dt>Email:</dt>
+       <dd>.</dd-->
+       <dt>Tax Province:</dt>
+       <dd>Since the location represents the physical location from where goods/services are supplied it is important for determining the tax applicable on a sale. The governing tax authority must specified with the location record. It is used in the calculation of the applicable rate of tax in conjunction with the tax authority of the customer branch being delivered to and the tax level of the item being sold.</dd>
+       <dt><a id="DefaultCounterSalesCustomerCode">Default Counter Sales Customer Code</a></dt>
+               <dd>The counter sales functionality looks at the default inventory location for a user and when that user enters a counter sale it uses the customer account and customer branch defined against the inventory location record. Consider a business with locations in Melbourne Australia and one in Anahaim USA - it is unlikely that a user based in Anaheim would be making a counter sale in Melbourne! Each location can have a customer account (and branch) defined for it's counter sales. These customers are expected to be cash only customers as the counter sales functionality expects the cash to be taken at the time of the sale. Not a substitute for proper Point of Sale - but suitable for occassional Counter Sales.</dd>
+       <dt>Counter Sales Branch Code</dt>
+               <dd>See <a href="#DefaultCounterSalesCustomerCode">Default Counter Sales Customer Code</a>.</dd>
+       <!--dt>Allow internal requests?:</dt>
+       <dd>.</dd-->
+       <dt>Use for Work Order Productions?</dt>
+               <dd>Some inventory locations are never going to be used as manufacturing facilities and to reduce the scope for errors it is possible to specify those inventory locations which can be used for work orders.</dd>
+       <dt><a id="LocationAccountCode">Account Code</a></dt>
+               <dd>Sometimes it is needed to have general ledger transactions of inventory transfers to or from a location. For example, a location that is used for pledged inventory or a place with goods on consignment. In this case, the location should be related to a ledger account. To do this, enter the general ledger account code for this location in this field. This account code overwrites the account codes of <a href="#InventoryCategories">inventory categories</a> when a general ledger transaction related with this location is created. Each time you do an inventory transfer from or to a location with a non blank account code, the system will generate a general ledger transaction (a SysType 16 --Location Transfer-- transaction).<br />
+               If you do not need accounting entries for inventory transfers, nor locations with his own GL account, leave this field in blank.</dd>
+       <dt><a id="LocationAllowInvoicing">Allow Invoicing</a></dt>
+               <dd>This parameter is to allow or deny the invoicing of items in this location. For items on consignment, depending on the agreement, you can not sell or can sell them (if you notify the consignee). Also, for pledged items, depending on the agreement, you can not sell or can sell them (if you replace them with items with equal or greater value). For these cases, use this parameter to indicate whether these inventory locations allow or deny such transactions.<br />
+               This parameters hides locations from <a href="ManualContents.php?ViewTopic=AccountsReceivable#DrawStockFrom">Draw Stock From</a> in <em>Customer Branches</em> and in <a href="ManualContents.php?ViewTopic=SalesOrders#DeliveryDetails">Deliver from the warehouse at</a> in <em>Delivery Details</em>.<br />
+               For standard locations, leave this option in "<em>Yes</em>" (allow invoicing).</dd>
+       </dl>
     <p>Note: Location codes cannot be modified retrospectively. Neither can they be deleted if there are stock movements, users (default location) or customer branch records set up to receive stock from the location.</p>

-
 <!-- Help End: Inventory Locations Maintenance -->

 <!-- Help Begin: Inventory Location Authorised Users Maintenance -->

Modified: trunk/doc/Manual/ManualSalesOrders.html
===================================================================
--- trunk/doc/Manual/ManualSalesOrders.html     2015-05-10 01:01:51 UTC (rev 7295)
+++ trunk/doc/Manual/ManualSalesOrders.html     2015-05-10 04:54:12 UTC (rev 7296)
@@ -76,7 +76,7 @@

 <p>By default the delivery details are obtained from the physical address of the branch. However, any of the information in this screen can be over-ridden. This information prints on the dispatch/packing slip and on the invoice.</p>

-<p>The inventory location where the stock for the order is to be drawn from is defaulted from the customer branch record. However, it is possible to select an alternative inventory location if the order is to be picked from elsewhere.</p>
+<p>The inventory location where the stock for the order is to be drawn from is defaulted from the customer branch record. However, it is possible to select an alternative inventory location if the order is to be picked from elsewhere. Inventory locations are defined by system administrators in <i><u>Main Menu</u></i> &gt; <i><u>Setup</u></i> &gt; <i>Inventory Setup</i> &gt; <i><a href="ManualContents.php?ViewTopic=Inventory#Locations">Inventory Locations Maintenance</a></i>.</p>

 <p>The customer's order reference should be entered here and the most appropriate freight company should be selected. The system keeps track of the last freight company used to deliver to the branch and uses this as the default, if it is over-ridden then this new value is stored against the branch.</p>


Added: trunk/doc/Manual/images/InventoryLocations.png
===================================================================
(Binary files differ)

Index: trunk/doc/Manual/images/InventoryLocations.png
===================================================================
--- trunk/doc/Manual/images/InventoryLocations.png      2015-05-10 01:01:51 UTC (rev 7295)
+++ trunk/doc/Manual/images/InventoryLocations.png      2015-05-10 04:54:12 UTC (rev 7296)

Property changes on: trunk/doc/Manual/images/InventoryLocations.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Modified: trunk/includes/DefineStockTransfers.php
===================================================================
--- trunk/includes/DefineStockTransfers.php     2015-05-10 01:01:51 UTC (rev 7295)
+++ trunk/includes/DefineStockTransfers.php     2015-05-10 04:54:12 UTC (rev 7296)
@@ -8,23 +8,29 @@
        Var $TrfID;
        Var $StockLocationFrom;
        Var $StockLocationFromName;
+       Var $StockLocationFromAccount;
        Var $StockLocationTo;
        Var $StockLocationToName;
+       Var $StockLocationToAccount;
        Var $TranDate;
        Var $TransferItem; /*Array of LineItems */

        function StockTransfer($TrfID,
                                $StockLocationFrom,
                                $StockLocationFromName,
+                               $StockLocationFromAccount,
                                $StockLocationTo,
                                $StockLocationToName,
+                               $StockLocationToAccount,
                                $TranDate )     {

                $this->TrfID = $TrfID;
                $this->StockLocationFrom = $StockLocationFrom;
                $this->StockLocationFromName = $StockLocationFromName;
+               $this->StockLocationFromAccount = $StockLocationFromAccount;
                $this->StockLocationTo =$StockLocationTo;
                $this->StockLocationToName =$StockLocationToName;
+               $this->StockLocationToAccount =$StockLocationToAccount;
                $this->TranDate = $TranDate;
                $this->TransferItem=array(); /*Array of LineItem s */
        }

Modified: trunk/sql/mysql/upgrade4.12.2-4.13.sql
===================================================================
--- trunk/sql/mysql/upgrade4.12.2-4.13.sql      2015-05-10 01:01:51 UTC (rev 7295)
+++ trunk/sql/mysql/upgrade4.12.2-4.13.sql      2015-05-10 04:54:12 UTC (rev 7296)
@@ -2,6 +2,11 @@
 INSERT INTO `scripts` (`script`, `pagesecurity`, `description`) VALUES ('StockCategorySalesInquiry.php', '2', 'Sales inquiry by stock category showing top items');
 INSERT INTO `scripts` (`script`, `pagesecurity`, `description`) VALUES ('PcAnalysis.php', '15', 'Creates an Excel with details of PC expnese for 24 months');

+-- Add field to store location's GL account code:
+ALTER TABLE `locations` ADD `glaccountcode` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'GL account of the location';
+-- Add field to allow or deny the invoicing of items in this location:
+ALTER TABLE `locations` ADD `allowinvoicing` TINYINT(1) NOT NULL DEFAULT '1' COMMENT 'Allow invoicing of items at this location';
+---- QUESTION: Existing locations are (always) set to 1? ***********************

 -- Update version number:
 UPDATE config SET confvalue='4.13' WHERE confname='VersionNumber';


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Web-erp-svn mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/web-erp-svn


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Web-erp-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/web-erp-developers