|
From: <dai...@us...> - 2012-11-02 23:45:44
|
Revision: 5732
http://sourceforge.net/p/web-erp/reponame/5732
Author: daintree
Date: 2012-11-02 23:45:41 +0000 (Fri, 02 Nov 2012)
Log Message:
-----------
Modifiable salesman on order entry and counter sales
Modified Paths:
--------------
trunk/ConfirmDispatch_Invoice.php
trunk/CounterSales.php
trunk/DeliveryDetails.php
trunk/SelectOrderItems.php
trunk/includes/DefineCartClass.php
trunk/sql/mysql/upgrade4.09-4.10.sql
Modified: trunk/ConfirmDispatch_Invoice.php
===================================================================
--- trunk/ConfirmDispatch_Invoice.php 2012-10-29 02:00:22 UTC (rev 5731)
+++ trunk/ConfirmDispatch_Invoice.php 2012-11-02 23:45:41 UTC (rev 5732)
@@ -60,6 +60,7 @@
salesorders.deladd6,
salesorders.contactphone,
salesorders.contactemail,
+ salesorders.salesperson,
salesorders.freightcost,
salesorders.deliverydate,
debtorsmaster.currcode,
@@ -114,6 +115,8 @@
$_SESSION['Items'.$identifier]->BrAdd6 = $myrow['deladd6'];
$_SESSION['Items'.$identifier]->PhoneNo = $myrow['contactphone'];
$_SESSION['Items'.$identifier]->Email = $myrow['contactemail'];
+ $_SESSION['Items'.$identifier]->SalesPerson = $myrow['salesperson'];
+
$_SESSION['Items'.$identifier]->Location = $myrow['fromstkloc'];
$_SESSION['Items'.$identifier]->FreightCost = $myrow['freightcost'];
$_SESSION['Old_FreightCost'] = $myrow['freightcost'];
@@ -740,7 +743,7 @@
$SQL = "UPDATE custbranch
SET defaultshipvia ='" . $_SESSION['Items'.$identifier]->ShipVia . "'
WHERE debtorno='" . $_SESSION['Items'.$identifier]->DebtorNo . "'
- AND branchcode='" . $_SESSION['Items'.$identifier]->Branch . "'";
+ AND branchcode='" . $_SESSION['Items'.$identifier]->Branch . "'";
$ErrMsg = _('Could not update the default shipping carrier for this branch because');
$DbgMsg = _('The SQL used to update the branch default carrier was');
$result = DB_query($SQL,$db, $ErrMsg, $DbgMsg, true);
@@ -1201,7 +1204,7 @@
AND salesanalysis.cust=custbranch.debtorno
AND salesanalysis.custbranch=custbranch.branchcode
AND salesanalysis.area=custbranch.area
- AND salesanalysis.salesperson=custbranch.salesman
+ AND salesanalysis.salesperson='" . $_SESSION['Items'.$identifier]->SalesPerson . "'
AND salesanalysis.typeabbrev ='" . $_SESSION['Items'.$identifier]->DefaultSalesType . "'
AND salesanalysis.periodno='" . $PeriodNo . "'
AND salesanalysis.cust " . LIKE . " '" . $_SESSION['Items'.$identifier]->DebtorNo . "'
@@ -1265,10 +1268,9 @@
'" . $OrderLine->StockID . "',
custbranch.area,
1,
- custbranch.salesman,
+ '" . $_SESSION['Items'.$identifier]->SalesPerson . "',
stockmaster.categoryid
- FROM stockmaster,
- custbranch
+ FROM stockmaster, custbranch
WHERE stockmaster.stockid = '" . $OrderLine->StockID . "'
AND custbranch.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'
AND custbranch.branchcode='" . $_SESSION['Items'.$identifier]->Branch . "'";
Modified: trunk/CounterSales.php
===================================================================
--- trunk/CounterSales.php 2012-10-29 02:00:22 UTC (rev 5731)
+++ trunk/CounterSales.php 2012-11-02 23:45:41 UTC (rev 5732)
@@ -32,6 +32,7 @@
$_SESSION['Items'.$identifier]->DeliverTo = $_POST['DeliverTo'];
$_SESSION['Items'.$identifier]->PhoneNo = $_POST['PhoneNo'];
$_SESSION['Items'.$identifier]->Email = $_POST['Email'];
+ $_SESSION['Items'.$identifier]->SalesPerson = $_POST['SalesPerson'];
}
if (isset($_POST['QuickEntry'])){
@@ -178,8 +179,9 @@
$_SESSION['Items'.$identifier]->DeliverBlind = $myrow['deliverblind'];
$_SESSION['Items'.$identifier]->SpecialInstructions = $myrow['specialinstructions'];
$_SESSION['Items'.$identifier]->DeliveryDays = $myrow['estdeliverydays'];
- $_SESSION['Items'.$identifier]->TaxGroup = $myrow['taxgroupid'];
-
+ $_SESSION['Items'.$identifier]->TaxGroup = $myrow['taxgroupid'];
+ $_SESSION['Items'.$identifier]->SalesPerson = $myrow['salesman'];
+
if ($_SESSION['Items'.$identifier]->SpecialInstructions) {
prnMsg($_SESSION['Items'.$identifier]->SpecialInstructions,'warn');
}
@@ -875,9 +877,27 @@
</tr>';
echo '<tr>
- <td>'. _('Comments') .':</td>
- <td><textarea name="Comments" cols="23" rows="5">' . stripcslashes($_SESSION['Items'.$identifier]->Comments) .'</textarea></td>
- </tr>';
+ <td>' . _('Sales person'). ':</td>
+ <td><select name="SalesPerson">';
+ $SalesPeopleResult = DB_query("SELECT salesmancode, salesmanname FROM salesman WHERE current=1",$db);
+ if (!isset($_POST['SalesPerson']) AND $_SESSION['SalesmanLogin']!=NULL ){
+ $_SESSION['Items'.$identifier]->SalesPerson = $_SESSION['SalesmanLogin'];
+ }
+
+ while ($SalesPersonRow = DB_fetch_array($SalesPeopleResult)){
+ if ($SalesPersonRow['salesmancode']==$_SESSION['Items'.$identifier]->SalesPerson){
+ echo '<option selected="selected" value="' . $SalesPersonRow['salesmancode'] . '">' . $SalesPersonRow['salesmanname'] . '</option>';
+ } else {
+ echo '<option value="' . $SalesPersonRow['salesmancode'] . '">' . $SalesPersonRow['salesmanname'] . '</option>';
+ }
+ }
+
+ echo '</select></td>
+ </tr>';
+ echo '<tr>
+ <td>'. _('Comments') .':</td>
+ <td><textarea name="Comments" cols="23" rows="5">' . stripcslashes($_SESSION['Items'.$identifier]->Comments) .'</textarea></td>
+ </tr>';
echo '</table>'; //end the sub table in the first column of master table
echo '</td><th valign="bottom">'; //for the master table
echo '<table class="selection">'; // a new nested table in the second column of master table
@@ -1052,7 +1072,8 @@
fromstkloc,
deliverydate,
confirmeddate,
- deliverblind)
+ deliverblind,
+ salesperson)
VALUES (
'" . $OrderNo . "',
'" . $_SESSION['Items'.$identifier]->DebtorNo . "',
@@ -1069,7 +1090,8 @@
'" . $_SESSION['Items'.$identifier]->Location ."',
'" . Date('Y-m-d') . "',
'" . Date('Y-m-d') . "',
- 0)";
+ 0,
+ '" . $_SESSION['Items'.$identifier]->SalesPerson . "')";
$ErrMsg = _('The order cannot be added because');
$InsertQryResult = DB_query($HeaderSQL,$db,$ErrMsg);
@@ -1129,39 +1151,39 @@
$QuantityDemand = $DemandRow[0];
$SQL = "SELECT SUM((salesorderdetails.quantity-salesorderdetails.qtyinvoiced)*bom.quantity) AS dem
- FROM salesorderdetails INNER JOIN salesorders
- ON salesorderdetails.orderno=salesorders.orderno
- INNER JOIN bom
- ON salesorderdetails.stkcode=bom.parent
- INNER JOIN stockmaster
- ON stockmaster.stockid=bom.parent
- WHERE salesorderdetails.quantity-salesorderdetails.qtyinvoiced > 0
- AND bom.component='" . $StockItem->StockID . "'
- AND salesorderdetails.completed=0
- AND salesorders.quotation=0";
+ FROM salesorderdetails INNER JOIN salesorders
+ ON salesorderdetails.orderno=salesorders.orderno
+ INNER JOIN bom
+ ON salesorderdetails.stkcode=bom.parent
+ INNER JOIN stockmaster
+ ON stockmaster.stockid=bom.parent
+ WHERE salesorderdetails.quantity-salesorderdetails.qtyinvoiced > 0
+ AND bom.component='" . $StockItem->StockID . "'
+ AND salesorderdetails.completed=0
+ AND salesorders.quotation=0";
$AssemblyDemandResult = DB_query($SQL,$db);
$AssemblyDemandRow = DB_fetch_row($AssemblyDemandResult);
$QuantityAssemblyDemand = $AssemblyDemandRow[0];
$SQL = "SELECT SUM(purchorderdetails.quantityord - purchorderdetails.quantityrecd) as qtyonorder
- FROM purchorderdetails INNER JOIN purchorders
- ON purchorderdetails.orderno = purchorders.orderno
- WHERE purchorderdetails.itemcode = '" . $StockItem->StockID . "'
- AND purchorderdetails.completed = 0
- AND purchorders.status<>'Cancelled'
- AND purchorders.status<>'Rejected'
- AND purchorders.status<>'Pending'
- AND purchorders.status<>'Completed'";
+ FROM purchorderdetails INNER JOIN purchorders
+ ON purchorderdetails.orderno = purchorders.orderno
+ WHERE purchorderdetails.itemcode = '" . $StockItem->StockID . "'
+ AND purchorderdetails.completed = 0
+ AND purchorders.status<>'Cancelled'
+ AND purchorders.status<>'Rejected'
+ AND purchorders.status<>'Pending'
+ AND purchorders.status<>'Completed'";
$PurchOrdersResult = DB_query($SQL,$db);
$PurchOrdersRow = DB_fetch_row($PurchOrdersResult);
$QuantityPurchOrders = $PurchOrdersRow[0];
$SQL = "SELECT SUM(woitems.qtyreqd - woitems.qtyrecd) as qtyonorder
- FROM woitems INNER JOIN workorders
- ON woitems.wo=workorders.wo
- WHERE woitems.stockid = '" . $StockItem->StockID . "'
- AND woitems.qtyreqd > woitems.qtyrecd
- AND workorders.closed = 0";
+ FROM woitems INNER JOIN workorders
+ ON woitems.wo=workorders.wo
+ WHERE woitems.stockid = '" . $StockItem->StockID . "'
+ AND woitems.qtyreqd > woitems.qtyrecd
+ AND workorders.closed = 0";
$WorkOrdersResult = DB_query($SQL,$db);
$WorkOrdersRow = DB_fetch_row($WorkOrdersResult);
$QuantityWorkOrders = $WorkOrdersRow[0];
@@ -1619,7 +1641,7 @@
AND salesanalysis.cust=custbranch.debtorno
AND salesanalysis.custbranch=custbranch.branchcode
AND salesanalysis.area=custbranch.area
- AND salesanalysis.salesperson=custbranch.salesman
+ AND salesanalysis.sales |