|
From: <dai...@us...> - 2011-03-15 09:33:16
|
Revision: 4511
http://web-erp.svn.sourceforge.net/web-erp/?rev=4511&view=rev
Author: daintree
Date: 2011-03-15 09:33:07 +0000 (Tue, 15 Mar 2011)
Log Message:
-----------
various
Modified Paths:
--------------
trunk/CounterSales.php
trunk/Locations.php
trunk/PricesByCost.php
trunk/SelectOrderItems.php
trunk/SelectSalesOrder.php
trunk/doc/Change.log.html
trunk/sql/mysql/upgrade3.11.1-4.00.sql
Removed Paths:
-------------
trunk/PrintSalesOrder_generic.php
Modified: trunk/CounterSales.php
===================================================================
--- trunk/CounterSales.php 2011-03-14 09:11:21 UTC (rev 4510)
+++ trunk/CounterSales.php 2011-03-15 09:33:07 UTC (rev 4511)
@@ -66,10 +66,11 @@
$_SESSION['PrintedPackingSlip'] = 0; /*Of course 'cos the order ain't even started !!*/
/*Get the default customer-branch combo from the user's default location record */
$sql = "SELECT cashsalecustomer,
- locationname,
- taxprovinceid
- FROM locations
- WHERE loccode='" . $_SESSION['UserStockLocation'] ."'";
+ cashsalebranch,
+ locationname,
+ taxprovinceid
+ FROM locations
+ WHERE loccode='" . $_SESSION['UserStockLocation'] ."'";
$result = DB_query($sql,$db);
if (DB_num_rows($result)==0) {
prnMsg(_('Your user account does not have a valid default inventory location set up. Please see the system administrator to modify your user account.'),'error');
@@ -78,36 +79,34 @@
} else {
$myrow = DB_fetch_array($result); //get the only row returned
- if ($myrow['cashsalecustomer']==''){
- prnMsg(_('To use this script it is first necessary to define a cash sales customer for the location that is your default location. The default cash sale customer is defined under set up ->Inventory Locations Maintenance. The customer should be entered using the customer code a hypen then the branch code of the customer to use.'),'error');
+ if ($myrow['cashsalecustomer']=='' OR $myrow['cashsalebranch']==''){
+ prnMsg(_('To use this script it is first necessary to define a cash sales customer for the location that is your default location. The default cash sale customer is defined under set up ->Inventory Locations Maintenance. The customer should be entered using the customer code and a valid branch code of the customer entered.'),'error');
include('includes/footer.inc');
exit;
}
- $CashSaleCustomer = explode('-',$myrow['cashsalecustomer']);
-
- $_SESSION['Items'.$identifier]->Branch = $CashSaleCustomer[1];
- $_SESSION['Items'.$identifier]->DebtorNo = $CashSaleCustomer[0];
+ $_SESSION['Items'.$identifier]->Branch = $myrow['cashsalebranch'];
+ $_SESSION['Items'.$identifier]->DebtorNo = $myrow['cashsalecustomer'];
$_SESSION['Items'.$identifier]->LocationName = $myrow['locationname'];
$_SESSION['Items'.$identifier]->Location = $_SESSION['UserStockLocation'];
$_SESSION['Items'.$identifier]->DispatchTaxProvince = $myrow['taxprovinceid'];
// Now check to ensure this account exists and set defaults */
$sql = "SELECT debtorsmaster.name,
- holdreasons.dissallowinvoices,
- debtorsmaster.salestype,
- salestypes.sales_type,
- debtorsmaster.currcode,
- debtorsmaster.customerpoline,
- paymentterms.terms
- FROM debtorsmaster,
- holdreasons,
- salestypes,
- paymentterms
- WHERE debtorsmaster.salestype=salestypes.typeabbrev
- AND debtorsmaster.holdreason=holdreasons.reasoncode
- AND debtorsmaster.paymentterms=paymentterms.termsindicator
- AND debtorsmaster.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'";
+ holdreasons.dissallowinvoices,
+ debtorsmaster.salestype,
+ salestypes.sales_type,
+ debtorsmaster.currcode,
+ debtorsmaster.customerpoline,
+ paymentterms.terms
+ FROM debtorsmaster,
+ holdreasons,
+ salestypes,
+ paymentterms
+ WHERE debtorsmaster.salestype=salestypes.typeabbrev
+ AND debtorsmaster.holdreason=holdreasons.reasoncode
+ AND debtorsmaster.paymentterms=paymentterms.termsindicator
+ AND debtorsmaster.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'";
$ErrMsg = _('The details of the customer selected') . ': ' . $_SESSION['Items'.$identifier]->DebtorNo . ' ' . _('cannot be retrieved because');
$DbgMsg = _('The SQL used to retrieve the customer details and failed was') . ':';
@@ -132,19 +131,18 @@
/* now get the branch defaults from the customer branches table CustBranch. */
$sql = "SELECT custbranch.brname,
- custbranch.braddress1,
- custbranch.defaultshipvia,
- custbranch.deliverblind,
- custbranch.specialinstructions,
- custbranch.estdeliverydays,
- custbranch.salesman,
- custbranch.taxgroupid,
- custbranch.defaultshipvia
- FROM custbranch
- WHERE custbranch.branchcode='" . $_SESSION['Items'.$identifier]->Branch . "'
- AND custbranch.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'";
-
- $ErrMsg = _('The customer branch record of the customer selected') . ': ' . $_SESSION['Items'.$identifier]->Branch . ' ' . _('cannot be retrieved because');
+ custbranch.braddress1,
+ custbranch.defaultshipvia,
+ custbranch.deliverblind,
+ custbranch.specialinstructions,
+ custbranch.estdeliverydays,
+ custbranch.salesman,
+ custbranch.taxgroupid,
+ custbranch.defaultshipvia
+ FROM custbranch
+ WHERE custbranch.branchcode='" . $_SESSION['Items'.$identifier]->Branch . "'
+ AND custbranch.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'";
+ $ErrMsg = _('The customer branch record of the customer selected') . ': ' . $_SESSION['Items'.$identifier]->Branch . ' ' . _('cannot be retrieved because');
$DbgMsg = _('SQL used to retrieve the branch details was') . ':';
$result =DB_query($sql,$db,$ErrMsg,$DbgMsg);
@@ -210,7 +208,6 @@
} else { /*Not cancelling the order */
echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/inventory.png" title="' . _('Counter Sales') . '" alt="" />' . ' ';
-
echo _('Counter Sale') . ' - ' . $_SESSION['Items'.$identifier]->LocationName . ' (' . _('all amounts in') . ' ' . $_SESSION['Items'.$identifier]->DefaultCurrency . ')';
echo '</p>';
}
@@ -231,30 +228,30 @@
if ($_POST['StockCat']=='All'){
$SQL = "SELECT stockmaster.stockid,
- stockmaster.description,
- stockmaster.units
- FROM stockmaster,
- stockcategory
- WHERE stockmaster.categoryid=stockcategory.categoryid
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
- AND stockmaster.mbflag <>'G'
- AND stockmaster.controlled <> 1
- AND stockmaster.description " . LIKE . " '" . $SearchString . "'
- AND stockmaster.discontinued=0
- ORDER BY stockmaster.stockid";
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster,
+ stockcategory
+ WHERE stockmaster.categoryid=stockcategory.categoryid
+ AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
+ AND stockmaster.mbflag <>'G'
+ AND stockmaster.controlled <> 1
+ AND stockmaster.description " . LIKE . " '" . $SearchString . "'
+ AND stockmaster.discontinued=0
+ ORDER BY stockmaster.stockid";
} else {
$SQL = "SELECT stockmaster.stockid,
- stockmaster.description,
- stockmaster.units
- FROM stockmaster, stockcategory
- WHERE stockmaster.categoryid=stockcategory.categoryid
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
- AND stockmaster.mbflag <>'G'
- AND stockmaster.controlled <> 1
- AND stockmaster.discontinued=0
- AND stockmaster.description " . LIKE . " '" . $SearchString . "'
- AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
- ORDER BY stockmaster.stockid";
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster, stockcategory
+ WHERE stockmaster.categoryid=stockcategory.categoryid
+ AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
+ AND stockmaster.mbflag <>'G'
+ AND stockmaster.controlled <> 1
+ AND stockmaster.discontinued=0
+ AND stockmaster.description " . LIKE . " '" . $SearchString . "'
+ AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
+ ORDER BY stockmaster.stockid";
}
} else if (strlen($_POST['StockCode'])>0){
@@ -264,55 +261,55 @@
if ($_POST['StockCat']=='All'){
$SQL = "SELECT stockmaster.stockid,
- stockmaster.description,
- stockmaster.units
- FROM stockmaster, stockcategory
- WHERE stockmaster.categoryid=stockcategory.categoryid
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
- AND stockmaster.stockid " . LIKE . " '" . $SearchString . "'
- AND stockmaster.mbflag <>'G'
- AND stockmaster.controlled <> 1
- AND stockmaster.discontinued=0
- ORDER BY stockmaster.stockid";
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster, stockcategory
+ WHERE stockmaster.categoryid=stockcategory.categoryid
+ AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
+ AND stockmaster.stockid " . LIKE . " '" . $SearchString . "'
+ AND stockmaster.mbflag <>'G'
+ AND stockmaster.controlled <> 1
+ AND stockmaster.discontinued=0
+ ORDER BY stockmaster.stockid";
} else {
$SQL = "SELECT stockmaster.stockid,
- stockmaster.description,
- stockmaster.units
- FROM stockmaster, stockcategory
- WHERE stockmaster.categoryid=stockcategory.categoryid
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
- AND stockmaster.stockid " . LIKE . " '" . $SearchString . "'
- AND stockmaster.mbflag <>'G'
- AND stockmaster.controlled <> 1
- AND stockmaster.discontinued=0
- AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
- ORDER BY stockmaster.stockid";
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster, stockcategory
+ WHERE stockmaster.categoryid=stockcategory.categoryid
+ AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
+ AND stockmaster.stockid " . LIKE . " '" . $SearchString . "'
+ AND stockmaster.mbflag <>'G'
+ AND stockmaster.controlled <> 1
+ AND stockmaster.discontinued=0
+ AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
+ ORDER BY stockmaster.stockid";
}
} else {
if ($_POST['StockCat']=='All'){
$SQL = "SELECT stockmaster.stockid,
- stockmaster.description,
- stockmaster.units
- FROM stockmaster, stockcategory
- WHERE stockmaster.categoryid=stockcategory.categoryid
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
- AND stockmaster.mbflag <>'G'
- AND stockmaster.controlled <> 1
- AND stockmaster.discontinued=0
- ORDER BY stockmaster.stockid";
- } else {
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster, stockcategory
+ WHERE stockmaster.categoryid=stockcategory.categoryid
+ AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
+ AND stockmaster.mbflag <>'G'
+ AND stockmaster.controlled <> 1
+ AND stockmaster.discontinued=0
+ ORDER BY stockmaster.stockid";
+ } else {
$SQL = "SELECT stockmaster.stockid,
- stockmaster.description,
- stockmaster.units
- FROM stockmaster, stockcategory
- WHERE stockmaster.categoryid=stockcategory.categoryid
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
- AND stockmaster.mbflag <>'G'
- AND stockmaster.controlled <> 1
- AND stockmaster.discontinued=0
- AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
- ORDER BY stockmaster.stockid";
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster, stockcategory
+ WHERE stockmaster.categoryid=stockcategory.categoryid
+ AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
+ AND stockmaster.mbflag <>'G'
+ AND stockmaster.controlled <> 1
+ AND stockmaster.discontinued=0
+ AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
+ ORDER BY stockmaster.stockid";
}
}
@@ -426,11 +423,11 @@
} elseif ($myrow=DB_fetch_array($KitResult)){
if ($myrow['mbflag']=='K'){ /*It is a kit set item */
$sql = "SELECT bom.component,
- bom.quantity
- FROM bom
- WHERE bom.parent='" . $NewItem . "'
- AND bom.effectiveto > '" . Date('Y-m-d') . "'
- AND bom.effectiveafter < '" . Date('Y-m-d') . "'";
+ bom.quantity
+ FROM bom
+ WHERE bom.parent='" . $NewItem . "'
+ AND bom.effectiveto > '" . Date('Y-m-d') . "'
+ AND bom.effectiveafter < '" . Date('Y-m-d') . "'";
$ErrMsg = _('Could not retrieve kitset components from the database because') . ' ';
$KitResult = DB_query($sql,$db,$ErrMsg,$DbgMsg);
@@ -441,6 +438,7 @@
$NewItemQty = $KitParts['quantity'] * $ParentQty;
$NewPOLine = 0;
include('includes/SelectOrderItems_IntoCart.inc');
+ $_SESSION['Items'.$identifier]->GetTaxes(($_SESSION['Items'.$identifier]->LineCounter - 1));
}
} else if ($myrow['mbflag']=='G'){
@@ -449,6 +447,7 @@
prnMsg(_('The system does not currently cater for counter sales of lot controlled or serialised items'),'warn');
} else { /*Its not a kit set item*/
include('includes/SelectOrderItems_IntoCart.inc');
+ $_SESSION['Items'.$identifier]->GetTaxes(($_SESSION['Items'.$identifier]->LineCounter - 1));
}
}
}
@@ -515,9 +514,10 @@
if (isset($_POST['Recalculate'])) {
foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) {
$NewItem=$OrderLine->StockID;
- $sql = "SELECT stockmaster.mbflag, stockmaster.controlled
- FROM stockmaster
- WHERE stockmaster.stockid='". $OrderLine->StockID."'";
+ $sql = "SELECT stockmaster.mbflag,
+ stockmaster.controlled
+ FROM stockmaster
+ WHERE stockmaster.stockid='". $OrderLine->StockID."'";
$ErrMsg = _('Could not determine if the part being ordered was a kitset or not because');
$DbgMsg = _('The sql that was used to determine if the part being ordered was a kitset or not was ');
@@ -525,11 +525,11 @@
if ($myrow=DB_fetch_array($KitResult)){
if ($myrow['mbflag']=='K'){ /*It is a kit set item */
$sql = "SELECT bom.component,
- bom.quantity
- FROM bom
- WHERE bom.parent='" . $OrderLine->StockID. "'
- AND bom.effectiveto > '" . Date('Y-m-d') . "'
- AND bom.effectiveafter < '" . Date('Y-m-d') . "'";
+ bom.quantity
+ FROM bom
+ WHERE bom.parent='" . $OrderLine->StockID. "'
+ AND bom.effectiveto > '" . Date('Y-m-d') . "'
+ AND bom.effectiveafter < '" . Date('Y-m-d') . "'";
$ErrMsg = _('Could not retrieve kitset components from the database because');
$KitResult = DB_query($sql,$db,$ErrMsg);
@@ -559,9 +559,9 @@
* controlled items and ghost/phantom items cannot be selected because the SQL to show items to select doesn't show 'em
* */
$sql = "SELECT stockmaster.mbflag,
- stockmaster.taxcatid
- FROM stockmaster
- WHERE stockmaster.stockid='". $NewItem ."'";
+ stockmaster.taxcatid
+ FROM stockmaster
+ WHERE stockmaster.stockid='". $NewItem ."'";
$ErrMsg = _('Could not determine if the part being ordered was a kitset or not because');
@@ -573,11 +573,11 @@
if ($myrow=DB_fetch_array($KitResult)){
if ($myrow['mbflag']=='K'){ /*It is a kit set item */
$sql = "SELECT bom.component,
- bom.quantity
- FROM bom
- WHERE bom.parent='" . $NewItem . "'
- AND bom.effectiveto > '" . Date('Y-m-d') . "'
- AND bom.effectiveafter < '" . Date('Y-m-d') . "'";
+ bom.quantity
+ FROM bom
+ WHERE bom.parent='" . $NewItem . "'
+ AND bom.effectiveto > '" . Date('Y-m-d') . "'
+ AND bom.effectiveafter < '" . Date('Y-m-d') . "'";
$ErrMsg = _('Could not retrieve kitset components from the database because');
$KitResult = DB_query($sql,$db,$ErrMsg);
@@ -610,8 +610,8 @@
foreach($NewItemArray as $NewItem => $NewItemQty) {
if($NewItemQty > 0) {
$sql = "SELECT stockmaster.mbflag
- FROM stockmaster
- WHERE stockmaster.stockid='". $NewItem ."'";
+ FROM stockmaster
+ WHERE stockmaster.stockid='". $NewItem ."'";
$ErrMsg = _('Could not determine if the part being ordered was a kitset or not because');
@@ -623,11 +623,11 @@
if ($myrow=DB_fetch_array($KitResult)){
if ($myrow['mbflag']=='K'){ /*It is a kit set item */
$sql = "SELECT bom.component,
- bom.quantity
- FROM bom
- WHERE bom.parent='" . $NewItem . "'
- AND bom.effectiveto > '" . Date('Y-m-d') . "'
- AND bom.effectiveafter < '" . Date('Y-m-d') . "'";
+ bom.quantity
+ FROM bom
+ WHERE bom.parent='" . $NewItem . "'
+ AND bom.effectiveto > '" . Date('Y-m-d') . "'
+ AND bom.effectiveafter < '" . Date('Y-m-d') . "'";
$ErrMsg = _('Could not retrieve kitset components from the database because');
$KitResult = DB_query($sql,$db,$ErrMsg);
@@ -670,10 +670,10 @@
}
}
$result = DB_query("SELECT MAX(discountrate) AS discount
- FROM discountmatrix
- WHERE salestype='" . $_SESSION['Items'.$identifier]->DefaultSalesType . "'
- AND discountcategory ='" . $OrderLine->DiscCat . "'
- AND quantitybreak <'" . $QuantityOfDiscCat . "'",$db);
+ FROM discountmatrix
+ WHERE salestype='" . $_SESSION['Items'.$identifier]->DefaultSalesType . "'
+ AND discountcategory ='" . $OrderLine->DiscCat . "'
+ AND quantitybreak <'" . $QuantityOfDiscCat . "'",$db);
$myrow = DB_fetch_row($result);
if ($myrow[0]!=0){ /* need to update the lines affected */
foreach ($_SESSION['Items'.$identifier]->LineItems as $StkItems_2) {
@@ -697,17 +697,17 @@
<table width="90%" cellpadding="2" colspan="7">
<tr bgcolor="#800000">';
echo '<th>' . _('Item Code') . '</th>
- <th>' . _('Item Description') . '</th>
- <th>' . _('Quantity') . '</th>
- <th>' . _('QOH') . '</th>
- <th>' . _('Unit') . '</th>
- <th>' . _('Price') . '</th>
- <th>' . _('Discount') . '</th>
- <th>' . _('GP %') . '</th>
- <th>' . _('Net') . '</th>
- <th>' . _('Tax') . '</th>
- <th>' . _('Total') . '<br />' . _('Incl Tax') . '</th>
- </tr>';
+ <th>' . _('Item Description') . '</th>
+ <th>' . _('Quantity') . '</th>
+ <th>' . _('QOH') . '</th>
+ <th>' . _('Unit') . '</th>
+ <th>' . _('Price') . '</th>
+ <th>' . _('Discount') . '</th>
+ <th>' . _('GP %') . '</th>
+ <th>' . _('Net') . '</th>
+ <th>' . _('Tax') . '</th>
+ <th>' . _('Total') . '<br />' . _('Incl Tax') . '</th>
+ </tr>';
$_SESSION['Items'.$identifier]->total = 0;
$_SESSION['Items'.$identifier]->totalVolume = 0;
@@ -744,8 +744,8 @@
echo '<td><input class="number" tabindex="2" type="text" name="Quantity_' . $OrderLine->LineNumber . '" size="6" maxlength="6" value="' . $OrderLine->Quantity . '" />';
echo '</td>
- <td class="number">' . $OrderLine->QOHatLoc . '</td>
- <td>' . $OrderLine->Units . '</td>';
+ <td class="number">' . $OrderLine->QOHatLoc . '</td>
+ <td>' . $OrderLine->Units . '</td>';
echo '<td><input class="number" type="text" name="Price_' . $OrderLine->LineNumber . '" size="16" maxlength="16" value="' . $OrderLine->Price . '" /></td>
<td><input class="number" type="text" name="Discount_' . $OrderLine->LineNumber . '" size="5" maxlength="4" value="' . ($OrderLine->DiscountPercent * 100) . '" /></td>
Modified: trunk/Locations.php
===================================================================
--- trunk/Locations.php 2011-03-14 09:11:21 UTC (rev 4510)
+++ trunk/Locations.php 2011-03-15 09:33:07 UTC (rev 4511)
@@ -31,27 +31,22 @@
prnMsg( _('The location code may not be empty'), 'error');
}
if ($_POST['CashSaleCustomer']!=''){
- if (!strstr($_POST['CashSaleCustomer'],'-')){
- $InputError =1;
- prnMsg(_('The cash sale customers '.$_POST['CashSaleCustomer'].' account must be a valid customer account separated by " - " then the branch code of the customer entered'), 'error');
- } else {
- // $Branch = substr($_POST['CashSaleCustomer'],strpos($_POST['CashSaleCustomer'],' - ')+3);
- // $DebtorNo = substr($_POST['CashSaleCustomer'],0,strpos($_POST['CashSaleCustomer'],' - '));
- $arr = explode('-',$_POST['CashSaleCustomer']);
- $DebtorNo = $arr[0];
- $Branch = $arr[1];
- $sql = "SELECT * FROM custbranch
- WHERE debtorno='" . $DebtorNo . "'
- AND branchcode='" . $Branch . "'";
+ if ($_POST['CashSaleBranch']==''){
+ prnMsg(_('A cash sale customer and branch are necessary to fully setup the counter sales functionality'),'error');
+ $InputError =1;
+ } else { //customer branch is set too ... check it ties up with a valid customer
+ $sql = "SELECT * FROM custbranch
+ WHERE debtorno='" . $_POST['CashSaleCustomer'] . "'
+ AND branchcode='" . $_POST['CashSaleBranch'] . "'";
- // echo $sql;
- $result = DB_query($sql,$db);
- if (DB_num_rows($result)==0){
- $InputError = 1;
- prnMsg(_('The cash sale customer for this location must be a valid customer code separated by " - " then a valid branch code for this customer'),'error');
- }
- }
+ // echo $sql;
+ $result = DB_query($sql,$db);
+ if (DB_num_rows($result)==0){
+ $InputError = 1;
+ prnMsg(_('The cash sale customer for this location must be defined with both a valid customer code and a valid branch code for this customer'),'error');
+ }
+ }
} //end of checking the customer - branch code entered
@@ -79,6 +74,7 @@
contact='" . $_POST['Contact'] . "',
taxprovinceid = '" . $_POST['TaxProvince'] . "',
cashsalecustomer ='" . $_POST['CashSaleCustomer'] . "',
+ cashsalebranch ='" . $_POST['CashSaleBranch'] . "',
managed = '" . $_POST['Managed'] . "'
WHERE loccode = '" . $SelectedLocation . "'";
@@ -102,6 +98,7 @@
unset($_POST['TaxProvince']);
unset($_POST['Managed']);
unset($_POST['CashSaleCustomer']);
+ unset($_POST['CashSaleBranch']);
unset($SelectedLocation);
unset($_POST['Contact']);
@@ -132,6 +129,7 @@
contact,
taxprovinceid,
cashsalecustomer,
+ cashsalebranch,
managed
)
VALUES (
@@ -149,6 +147,7 @@
'" . $_POST['Contact'] . "',
'" . $_POST['TaxProvince'] . "',
'" . $_POST['CashSaleCustomer'] . "',
+ '" . $_POST['CashSaleBranch'] . "',
'" . $_POST['Managed'] . "'
)";
@@ -189,6 +188,7 @@
unset($_POST['Email']);
unset($_POST['TaxProvince']);
unset($_POST['CashSaleCustomer']);
+ unset($_POST['CashSaleBranch']);
unset($_POST['Managed']);
unset($SelectedLocation);
unset($_POST['Contact']);
@@ -356,7 +356,6 @@
echo '<tr><th>' . _('Location Code') . '</th>
<th>' . _('Location Name') . '</th>
<th>' . _('Tax Province') . '</th>
- <th>' . _('Managed') . '</th>
</tr>';
$k=0; //row colour counter
@@ -368,24 +367,22 @@
echo '<tr class="OddTableRows">';
$k=1;
}
-
+/* warehouse management not implemented ... yet
if($myrow['managed'] == 1) {
$myrow['managed'] = _('Yes');
} else {
$myrow['managed'] = _('No');
}
-
+*/
printf("<td>%s</td>
<td>%s</td>
<td>%s</td>
- <td>%s</td>
<td><a href='%sSelectedLocation=%s'>" . _('Edit') . "</td>
<td><a href='%sSelectedLocation=%s&delete=1'>" . _('Delete') . '</td>
</tr>',
$myrow['loccode'],
$myrow['locationname'],
$myrow['description'],
- $myrow['managed'],
$_SERVER['PHP_SELF'] . '?' . SID . '&',
$myrow['loccode'],
$_SERVER['PHP_SELF'] . '?' . SID . '&',
@@ -428,6 +425,7 @@
email,
taxprovinceid,
cashsalecustomer,
+ cashsalebranch,
managed
FROM locations
WHERE loccode='" . $SelectedLocation . "'";
@@ -449,6 +447,7 @@
$_POST['Email'] = $myrow['email'];
$_POST['TaxProvince'] = $myrow['taxprovinceid'];
$_POST['CashSaleCustomer'] = $myrow['cashsalecustomer'];
+ $_POST['CashSaleBranch'] = $myrow['cashsalebranch'];
$_POST['Managed'] = $myrow['managed'];
@@ -501,6 +500,9 @@
if (!isset($_POST['CashSaleCustomer'])) {
$_POST['CashSaleCustomer'] = '';
}
+ if (!isset($_POST['CashSaleBranch'])) {
+ $_POST['CashSaleBranch'] = '';
+ }
if (!isset($_POST['Managed'])) {
$_POST['Managed'] = 0;
}
@@ -540,9 +542,12 @@
}
echo '</select></td></tr>';
- echo '<tr><td>' . _('Default Counter Sales Customer') . ':' . '</td>';
+ echo '<tr><td>' . _('Default Counter Sales Customer Code') . ':' . '</td>';
echo '<td><input type="Text" name="CashSaleCustomer" value="' . $_POST['CashSaleCustomer'] .
- '" size=25 maxlength=23></td></tr>';
+ '" size=11 maxlength=10></td></tr>';
+ echo '<tr><td>' . _('Counter Sales Branch Code') . ':' . '</td>';
+ echo '<td><input type="Text" name="CashSaleBranch" value="' . $_POST['CashSaleBranch'] .
+ '" size=11 maxlength=10></td></tr>';
/*
This functionality is not written yet ...
<tr><td><?php echo _('Enable Warehouse Management') . ':'; ?></td>
Modified: trunk/PricesByCost.php
===================================================================
--- trunk/PricesByCost.php 2011-03-14 09:11:21 UTC (rev 4510)
+++ trunk/PricesByCost.php 2011-03-15 09:33:07 UTC (rev 4511)
@@ -24,20 +24,20 @@
}/*end of else StockCat */
$sql = "SELECT stockmaster.stockid,
- stockmaster.description,
- prices.debtorno,
- prices.branchcode,
- (stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost) as cost,
- prices.price as price, prices.debtorno as customer, prices.branchcode as branch,
- prices.startdate,
- prices.enddate
- FROM stockmaster, prices
- WHERE stockmaster.stockid=prices.stockid" . $Category . "
- AND stockmaster.discontinued = 0
- AND prices.price" . $Comparator . "(stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost) * '" . $_POST['Margin'] . "'
- AND prices.typeabbrev ='" . $_POST['SalesType'] . "'
- AND prices.currabrev ='" . $_POST['CurrCode'] . "'
- AND (prices.enddate>='" . Date('Y-m-d') . "' OR prices.enddate='0000-00-00')";
+ stockmaster.description,
+ prices.debtorno,
+ prices.branchcode,
+ (stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost) as cost,
+ prices.price as price, prices.debtorno as customer, prices.branchcode as branch,
+ prices.startdate,
+ prices.enddate
+ FROM stockmaster, prices
+ WHERE stockmaster.stockid=prices.stockid" . $Category . "
+ AND stockmaster.discontinued = 0
+ AND prices.price" . $Comparator . "(stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost) * '" . $_POST['Margin'] . "'
+ AND prices.typeabbrev ='" . $_POST['SalesType'] . "'
+ AND prices.currabrev ='" . $_POST['CurrCode'] . "'
+ AND (prices.enddate>='" . Date('Y-m-d') . "' OR prices.enddate='0000-00-00')";
$result = DB_query($sql, $db);
$numrow = DB_num_rows($result);
@@ -45,25 +45,36 @@
//Update Prices
$PriceCounter =0;
while ($myrow = DB_fetch_array($result)) {
- //update database if update pressed
- $SQLUpdate = "UPDATE prices SET price = '" . $_POST['Price_' . $PriceCounter] . "'
- WHERE stockid = '" . $_POST['StockID_' . $PriceCounter] . "'
- AND prices.typeabbrev ='" . $_POST['SalesType'] . "'
- AND prices.currabrev ='" . $_POST['CurrCode'] . "'
- AND prices.debtorno ='" . $_POST['DebtorNo_' . $PriceCounter] . "'
- AND prices.branchcode ='" . $_POST['BranchCode_' . $PriceCounter] . "'
- AND prices.startdate ='" . $_POST['StartDate_' . $PriceCounter] . "'
- AND prices.enddate ='" . $_POST['EndDate_' . $PriceCounter] . "'";
- $ResultUpdate = DB_query($SQLUpdate, $db);
- $SQLInsert = "INSERT INTO prices (
+
+ $SQLTestExists = "SELECT price FROM prices
+ WHERE stockid = '" . $_POST['StockID_' . $PriceCounter] . "'
+ AND prices.typeabbrev ='" . $_POST['SalesType'] . "'
+ AND prices.currabrev ='" . $_POST['CurrCode'] . "'
+ AND prices.debtorno ='" . $_POST['DebtorNo_' . $PriceCounter] . "'
+ AND prices.branchcode ='" . $_POST['BranchCode_' . $PriceCounter] . "'
+ AND prices.startdate ='" . date('Y-m-d') . "'";
+ $TestExistsResult = DB_query($SQLTestExists,$db);
+ if (DB_num_rows($TestExistsResult)==1){
+ //then we are updating
+ $SQLUpdate = "UPDATE prices SET price = '" . $_POST['Price_' . $PriceCounter] . "'
+ WHERE stockid = '" . $_POST['StockID_' . $PriceCounter] . "'
+ AND prices.typeabbrev ='" . $_POST['SalesType'] . "'
+ AND prices.currabrev ='" . $_POST['CurrCode'] . "'
+ AND prices.debtorno ='" . $_POST['DebtorNo_' . $PriceCounter] . "'
+ AND prices.branchcode ='" . $_POST['BranchCode_' . $PriceCounter] . "'
+ AND prices.startdate ='" . date('Y-m-d') . "'
+ AND prices.enddate ='" . $_POST['EndDate_' . $PriceCounter] . "'";
+ $ResultUpdate = DB_query($SQLUpdate, $db);
+ } else {
+ //we need to add a new price from today
+ $SQLInsert = "INSERT INTO prices (
stockid,
price,
typeabbrev,
currabrev,
debtorno,
branchcode,
- startdate,
- enddate
+ startdate
) VALUES (
'" . $_POST['StockID_' . $PriceCounter] . "',
'" . $_POST['Price_' . $PriceCounter] . "',
@@ -71,10 +82,10 @@
'" . $_POST['CurrCode'] . "',
'" . $_POST['DebtorNo_' . $PriceCounter] . "',
'" . $_POST['BranchCode_' . $PriceCounter] . "',
- '" . date('Y-m-d') . "',
- '2030-12-31'
+ '" . date('Y-m-d') . "'
)";
- $ResultInsert = DB_query($SQLInsert, $db);
+ $ResultInsert = DB_query($SQLInsert, $db);
+ }
$PriceCounter++;
}
DB_free_result($result); //clear the old result
Deleted: trunk/PrintSalesOrder_generic.php
===================================================================
--- trunk/PrintSalesOrder_generic.php 2011-03-14 09:11:21 UTC (rev 4510)
+++ trunk/PrintSalesOrder_generic.php 2011-03-15 09:33:07 UTC (rev 4511)
@@ -1,194 +0,0 @@
-<?php
-
-/* $Revision: 1.2 $ */
-
-/* $Id$*/
-
-//$PageSecurity = 2;
-
-include('includes/session.inc');
-include('includes/SQL_CommonFunctions.inc');
-
-//Get Out if we have no order number to work with
-If (!isset($_GET['TransNo']) OR $_GET['TransNo']==""){
- $title = _('Select Order To Print');
- include('includes/header.inc');
- echo '<div class=centre><br><br><br>';
- prnMsg( _('Select an Order Number to Print before calling this page') , 'error');
- echo '<br><br><br><table class="table_index"><tr><td class="menu_group_item">
- <li><a href="'. $rootpath . '/SelectSalesOrder.php?'. SID .'">' . _('Outstanding Sales Orders') . '</a></li>
- <li><a href="'. $rootpath . '/SelectCompletedOrder.php?'. SID .'">' . _('Completed Sales Orders') . '</a></li>
- </td></tr></table></div><br><br><br>';
- include('includes/footer.inc');
- exit();
-}
-
-/*retrieve the order details from the database to print */
-$ErrMsg = _('There was a problem retrieving the order header details for Order Number') . ' ' . $_GET['TransNo'] . ' ' . _('from the database');
-
-$sql = "SELECT salesorders.debtorno,
- salesorders.customerref,
- salesorders.comments,
- salesorders.orddate,
- salesorders.deliverto,
- salesorders.deladd1,
- salesorders.deladd2,
- salesorders.deladd3,
- salesorders.deladd4,
- salesorders.deladd5,
- salesorders.deladd6,
- salesorders.deliverblind,
- debtorsmaster.name,
- debtorsmaster.address1,
- debtorsmaster.address2,
- debtorsmaster.address3,
- debtorsmaster.address4,
- debtorsmaster.address5,
- debtorsmaster.address6,
- shippers.shippername,
- salesorders.printedpackingslip,
- salesorders.datepackingslipprinted,
- locations.locationname
- FROM salesorders,
- debtorsmaster,
- shippers,
- locations
- WHERE salesorders.debtorno=debtorsmaster.debtorno
- AND salesorders.shipvia=shippers.shipper_id
- AND salesorders.fromstkloc=locations.loccode
- AND salesorders.orderno='" . $_GET['TransNo'] . "'";
-
-$result=DB_query($sql,$db, $ErrMsg);
-
-//If there are no rows, there's a problem.
-if (DB_num_rows($result)==0){
- $title = _('Print Packing Slip Error');
- include('includes/header.inc');
- echo '<div class=centre><br><br><br>';
- prnMsg( _('Unable to Locate Order Number') . ' : ' . $_GET['TransNo'] . ' ', 'error');
- echo '<br><br><br><table class="table_index"><tr><td class="menu_group_item">
- <li><a href="'. $rootpath . '/SelectSalesOrder.php?'. SID .'">' . _('Outstanding Sales Orders') . '</a></li>
- <li><a href="'. $rootpath . '/SelectCompletedOrder.php?'. SID .'">' . _('Completed Sales Orders') . '</a></li>
- </td></tr></table></div><br><br><br>';
- include('includes/footer.inc');
- exit();
-} elseif (DB_num_rows($result)==1){ /*There is only one order header returned - thats good! */
-
- $myrow = DB_fetch_array($result);
- /* Place the deliver blind variable into a hold variable to used when
- producing the packlist */
- $DeliverBlind = $myrow['deliverblind'];
- if ($myrow['printedpackingslip']==1 AND ($_GET['Reprint']!='OK' OR !isset($_GET['Reprint']))){
- $title = _('Print Packing Slip Error');
- include('includes/header.inc');
- echo '<p>';
- prnMsg( _('The packing slip for order number') . ' ' . $_GET['TransNo'] . ' ' .
- _('has previously been printed') . '. ' . _('It was printed on'). ' ' . ConvertSQLDate($myrow['datepackingslipprinted']) .
- '<br>' . _('This check is there to ensure that duplicate packing slips are not produced and dispatched more than once to the customer'), 'warn' );
- echo '<p><a href="' . $rootpath . '/PrintCustOrder.php?' . SID . '&TransNo=' . $_GET['TransNo'] . '&Reprint=OK">'
- . _('Do a Re-Print') . ' (' . _('On Pre-Printed Stationery') . ') ' . _('Even Though Previously Printed') . '</a><p>' .
- '<a href="' . $rootpath. '/PrintCustOrder_generic.php?' . SID . '&TransNo=' . $_GET['TransNo'] . '&Reprint=OK">'. _('Do a Re-Print') . ' (' . _('Plain paper') . ' - ' . _('A4') . ' ' . _('landscape') . ') ' . _('Even Though Previously Printed'). '</a>';
-
- echo '<br><br><br>';
- echo _('Or select another Order Number to Print');
- echo '<table class="table_index"><tr><td class="menu_group_item">
- <li><a href="'. $rootpath . '/SelectSalesOrder.php?'. SID .'">' . _('Outstanding Sales Orders') . '</a></li>
- <li><a href="'. $rootpath . '/SelectCompletedOrder.php?'. SID .'">' . _('Completed Sales Orders') . '</a></li>
- </td></tr></table></div><br><br><br>';
-
- include('includes/footer.inc');
- exit;
- }//packing slip has been printed.
-}
-
-/*retrieve the order details from the database to print */
-
-/* Then there's an order to print and its not been printed already (or its been flagged for reprinting/ge_Width=807;
-)
-LETS GO */
-$PaperSize = 'A4_Landscape';
-include('includes/PDFStarter.php');
-$pdf->addInfo('Title', _('Customer Laser Packing Slip') );
-$pdf->addInfo('Subject', _('Laser Packing slip for order') . ' ' . $_GET['TransNo']);
-$FontSize=12;
-
-$ListCount = 0; // UldisN
-$Copy='';
-
-for ($i=1;$i<=2;$i++){ /*Print it out twice one copy for customer and one for office */
- if ($i==2){
- $pdf->newPage();
- }
-
- $line_height=24;
-
- /* Now ... Has the order got any line items still outstanding to be invoiced */
-
- $PageNumber = 1;
-
- $ErrMsg = _('There was a problem retrieving the order header details for Order Number') . ' ' .
- $_GET['TransNo'] . ' ' . _('from the database');
-
- $sql = "SELECT salesorderdetails.stkcode,
- stockmaster.description,
- salesorderdetails.quantity,
- salesorderdetails.qtyinvoiced,
- salesorderdetails.unitprice,
- salesorderdetails.narrative
- FROM salesorderdetails INNER JOIN stockmaster
- ON salesorderdetails.stkcode=stockmaster.stockid
- WHERE salesorderdetails.orderno='" . $_GET['TransNo'] . "'";
- $result=DB_query($sql,$db, $ErrMsg);
-
- if (DB_num_rows($result)>0){
- /*Yes there are line items to start the ball rolling with a page header */
- include('includes/PDFSalesOrder_generic.inc');
-
- while ($myrow2=DB_fetch_array($result)){
-
- $ListCount ++;
-
- $DisplayQty = number_format($myrow2['quantity'],2);
- $DisplayPrevDel = number_format($myrow2['qtyinvoiced'],2);
- $DisplayQtySupplied = number_format($myrow2['quantity'] - $myrow2['qtyinvoiced'],2);
- $itemdesc = $myrow2['description'] . ' - ' . $myrow2['narrative'];
- $LeftOvers = $pdf->addTextWrap($XPos,$YPos,127,$FontSize,$myrow2['stkcode']);
- $LeftOvers = $pdf->addTextWrap(147,$YPos,355,$FontSize,$itemdesc);
- $LeftOvers = $pdf->addTextWrap(400,$YPos,85,$FontSize,$DisplayQty,'right');
- $LeftOvers = $pdf->addTextWrap(503,$YPos,85,$FontSize,$DisplayQtySupplied,'right');
- $LeftOvers = $pdf->addTextWrap(602,$YPos,85,$FontSize,$DisplayPrevDel,'right');
-
- if ($YPos-$line_height <= 50){
- /* We reached the end of the page so finsih off the page and start a newy */
- $PageNumber++;
- include ('includes/PDFSalesOrder_generic.inc');
- } //end if need a new page headed up
- else{
- /*increment a line down for the next line item */
- $YPos -= ($line_height);
- }
- } //end while there are line items to print out
-
- } /*end if there are order details to show on the order*/
-
- $Copy='Customer';
-
-} /*end for loop to print the whole lot twice */
-
-if ($ListCount == 0){
- $title = _('Print Packing Slip Error');
- include('includes/header.inc');
- echo '<p>'. _('There were no outstanding items on the order to deliver. A packing slip cannot be printed').
- '<br><a href="' . $rootpath . '/SelectSalesOrder.php?' . SID . '">'. _('Print Another Packing Slip/Order').
- '</a>' . '<br>'. '<a href="' . $rootpath . '/index.php?' . SID . '">' . _('Back to the menu') . '</a>';
- include('includes/footer.inc');
- exit;
-} else {
- $pdf->OutputD($_SESSION['DatabaseName'] . '_SalesOrder_' . date('Y-m-d') . '.pdf');//UldisN
- $pdf->__destruct(); //UldisN
-
- $sql = "UPDATE salesorders SET printedpackingslip=1, datepackingslipprinted='" . Date('Y-m-d') . "' WHERE salesorders.orderno='" .$_GET['TransNo'] . "'";
- $result = DB_query($sql,$db);
-}
-
-?>
\ No newline at end of file
Modified: trunk/SelectOrderItems.php
===================================================================
--- trunk/SelectOrderItems.php 2011-03-14 09:11:21 UTC (rev 4510)
+++ trunk/SelectOrderItems.php 2011-03-15 09:33:07 UTC (rev 4511)
@@ -35,7 +35,7 @@
}
-if (empty($_GET['identifier'])) {
+if (empty($_GET['identifier'])) {
/*unique session identifier to ensure that there is no conflict with other order entry sessions on the same machine */
$identifier=date('U');
} else {
@@ -79,51 +79,50 @@
/*read in all the guff from the selected order into the Items cart */
$OrderHeaderSQL = "SELECT salesorders.debtorno,
- debtorsmaster.name,
- salesorders.branchcode,
- salesorders.customerref,
- salesorders.comments,
- salesorders.orddate,
- salesorders.ordertype,
- salestypes.sales_type,
- salesorders.shipvia,
- salesorders.deliverto,
- salesorders.deladd1,
- salesorders.deladd2,
- salesorders.deladd3,
- salesorders.deladd4,
- salesorders.deladd5,
- salesorders.deladd6,
- salesorders.contactphone,
- salesorders.contactemail,
- salesorders.freightcost,
- salesorders.deliverydate,
- debtorsmaster.currcode,
- paymentterms.terms,
- salesorders.fromstkloc,
- salesorders.printedpackingslip,
- salesorders.datepackingslipprinted,
- salesorders.quotation,
- salesorders.deliverblind,
- debtorsmaster.customerpoline,
- locations.locationname,
- custbranch.estdeliverydays,
- custbranch.salesman
- FROM salesorders,
- debtorsmaster,
- salestypes,
- custbranch,
- paymentterms,
- locations
- WHERE salesorders.ordertype=salestypes.typeabbrev
- AND salesorders.debtorno = debtorsmaster.debtorno
- AND salesorders.debtorno = custbranch.debtorno
- AND salesorders.branchcode = custbranch.branchcode
- AND debtorsmaster.paymentterms=paymentterms.termsindicator
- AND locations.loccode=salesorders.fromstkloc
- AND salesorders.orderno = '" . $_GET['ModifyOrderNumber'] . "'";
+ debtorsmaster.name,
+ salesorders.branchcode,
+ salesorders.customerref,
+ salesorders.comments,
+ salesorders.orddate,
+ salesorders.ordertype,
+ salestypes.sales_type,
+ salesorders.shipvia,
+ salesorders.deliverto,
+ salesorders.deladd1,
+ salesorders.deladd2,
+ salesorders.deladd3,
+ salesorders.deladd4,
+ salesorders.deladd5,
+ salesorders.deladd6,
+ salesorders.contactphone,
+ salesorders.contactemail,
+ salesorders.freightcost,
+ salesorders.deliverydate,
+ debtorsmaster.currcode,
+ paymentterms.terms,
+ salesorders.fromstkloc,
+ salesorders.printedpackingslip,
+ salesorders.datepackingslipprinted,
+ salesorders.quotation,
+ salesorders.deliverblind,
+ debtorsmaster.customerpoline,
+ locations.locationname,
+ custbranch.estdeliverydays,
+ custbranch.salesman
+ FROM salesorders,
+ debtorsmaster,
+ salestypes,
+ custbranch,
+ paymentterms,
+ locations
+ WHERE salesorders.ordertype=salestypes.typeabbrev
+ AND salesorders.debtorno = debtorsmaster.debtorno
+ AND salesorders.debtorno = custbranch.debtorno
+ AND salesorders.branchcode = custbranch.branchcode
+ AND debtorsmaster.paymentterms=paymentterms.termsindicator
+ AND locations.loccode=salesorders.fromstkloc
+ AND salesorders.orderno = '" . $_GET['ModifyOrderNumber'] . "'";
-
$ErrMsg = _('The order cannot be retrieved because');
$GetOrdHdrResult = DB_query($OrderHeaderSQL,$db,$ErrMsg);
@@ -338,7 +337,7 @@
LEFT JOIN debtorsmaster
ON custbranch.debtorno=debtorsmaster.debtorno
WHERE custbranch.debtorno " . LIKE . " '%" . $_POST['CustCode'] . "%' OR custbranch.branchcode " . LIKE . " '%" . $_POST['CustCode'] . "%'";
-
+
if ($_SESSION['SalesmanLogin']!=''){
$SQL .= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'";
}
@@ -346,16 +345,16 @@
ORDER BY custbranch.debtorno';
} elseif (strlen($_POST['CustPhone'])>0){
$SQL = "SELECT custbranch.brname,
- custbranch.contactname,
- custbranch.phoneno,
- custbranch.faxno,
- custbranch.branchcode,
- custbranch.debtorno,
- debtorsmaster.name
- FROM custbranch
- LEFT JOIN debtorsmaster
- ON custbranch.debtorno=debtorsmaster.debtorno
- WHERE custbranch.phoneno " . LIKE . " '%" . $_POST['CustPhone'] . "%'";
+ custbranch.contactname,
+ custbranch.phoneno,
+ custbranch.faxno,
+ custbranch.branchcode,
+ custbranch.debtorno,
+ debtorsmaster.name
+ FROM custbranch
+ INNER JOIN debtorsmaster
+ ON custbranch.debtorno=debtorsmaster.debtorno
+ WHERE custbranch.phoneno " . LIKE . " '%" . $_POST['CustPhone'] . "%'";
if ($_SESSION['SalesmanLogin']!=''){
$SQL .= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'";
@@ -370,7 +369,8 @@
if (DB_num_rows($result_CustSelect)==1){
$myrow=DB_fetch_array($result_CustSelect);
- $SelectedCustomer= $myrow['debtorno'] . ' - ' . $myrow['branchcode'];
+ $SelectedCustomer = $myrow['debtorno'];
+ $SelectedBranch = $myrow['branchcode'];
} elseif (DB_num_rows($result_CustSelect)==0){
prnMsg(_('No Customer Branch records contain the search criteria') . ' - ' . _('please try again') . ' - ' . _('Note a Customer Branch Name may be different to the Customer Name'),'info');
}
@@ -388,16 +388,16 @@
prnMsg(_('Unable to identify the selected customer'),'error');
} else {
$SelectedCustomer = $_POST['SelectedCustomer'.$i];
+ $SelectedBranch = $_POST['SelectedBranch'.$i];
}
}
/* will only be true if page called from customer selection form or set because only one customer
record returned from a search so parse the $SelectCustomer string into customer code and branch code */
if (isset($SelectedCustomer)) {
-
- $CustomerBranchArray = explode('-',$SelectedCustomer);
- $_SESSION['Items'.$identifier]->DebtorNo = trim($CustomerBranchArray[0]);
- $_SESSION['Items'.$identifier]->Branch = trim($CustomerBranchArray[1]);
+ $_SESSION['Items'.$identifier]->DebtorNo = trim($SelectedCustomer);
+ $_SESSION['Items'.$identifier]->Branch = trim($SelectedBranch);
+
// Now check to ensure this account is not on hold */
$sql = "SELECT debtorsmaster.name,
holdreasons.dissallowinvoices,
@@ -661,7 +661,7 @@
echo '<td></td>';
}
echo '<td><input tabindex='.($j+5).' type=submit name="SubmitCustomerSelection' . $j .'" value="' . htmlentities($myrow['brname'], ENT_QUOTES,'UTF-8'). '"></td>
- <input type="hidden" name="SelectedCustomer' . $j .'" value="'.$myrow['debtorno'] .' - '.$myrow['branchcode'].'">
+ <input type="hidden" name="SelectedCustomer' . $j .'" value="'.$myrow['debtorno'].'"><input type="hidden" name="SelectedBranch' . $j .'" value="'. $myrow['branchcode'].'">
<td>'.$myrow['contactname'].'</td>
<td>'.$myrow['phoneno'].'</td>
<td>'.$myrow['faxno'].'</td>
@@ -1418,7 +1418,7 @@
$SQL="SELECT stockmaster.units,
stockmaster.description,
stockmaster.stockid,
- salesorderdetails.stkcode,
+ salesorderdetails.stkcode,
SUM(qtyinvoiced) salesqty
FROM `salesorderdetails`INNER JOIN `stockmaster`
ON salesorderdetails.stkcode = stockmaster.stockid
@@ -1580,7 +1580,7 @@
echo '</select></td>
<td><b>' . _('Enter partial Description') . ':</b><input tabindex=2 type="Text" name="Keywords" size=20 maxlength=25 value="' ;
-
+
if (isset($_POST['Keywords'])) {
echo$_POST['Keywords'] ;
}
Modified: trunk/SelectSalesOrder.php
===================================================================
--- trunk/SelectSalesOrder.php 2011-03-14 09:11:21 UTC (rev 4510)
+++ trunk/SelectSalesOrder.php 2011-03-15 09:33:07 UTC (rev 4511)
@@ -5,10 +5,10 @@
include('includes/session.inc');
$title = _('Search Outstanding Sales Orders');
include('includes/header.inc');
+include('includes/SQL_CommonFunctions.inc');
+if (isset($_POST['PlacePO'])){ /*user hit button to place PO for selected orders */
-if (isset($_POST['PlacePO'])){ /*user hit button to place PO for selected orders */
-
/*Note the button would not have been displayed if the user had no authority to create purchase orders */
$OrdersToPlacePOFor = '';
for ($i=1;$i<count($_POST);$i++){
@@ -25,235 +25,279 @@
} else {
/* Now build SQL of items to purchase with purchasing data and preferred suppliers - sorted by preferred supplier */
$sql = "SELECT purchdata.supplierno,
- purchdata.stockid,
- purchdata.price,
- purchdata.suppliers_partno,
- purchdata.supplierdescription,
- purchdata.conversionfactor,
- purchdata.leadtime,
- purchdata.suppliersuom,
- stockmaster.kgs,
- stockmaster.volume,
- stockcategory.stockact,
- SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS orderqty
- FROM purchdata INNER JOIN salesorderdetails ON
- purchdata.stockid = salesorderdetails.stkcode
- INNER JOIN stockmaster ON
- purchdata.stockid = stockmaster.stockid
- INNER JOIN stockcategory ON
- stockmaster.categoryid = stockcategory.categoryid
- WHERE purchdata.preferred=1
- AND purchdata.effectivefrom <='" . Date('Y-m-d') . "'
- AND (" . $OrdersToPlacePOFor . ")
- GROUP BY purchdata.supplierno,
- purchdata.stockid,
- purchdata.price,
- purchdata.suppliers_partno,
- purchdata.supplierdescription,
- purchdata.conversionfactor,
- purchdata.leadtime,
- purchdata.suppliersuom,
- stockmaster.kgs,
- stockmaster.volume,
- stockcategory.stockact
- ORDER BY purchdata.supplierno,
- purchdata.stockid";
+ purchdata.stockid,
+ purchdata.price,
+ purchdata.suppliers_partno,
+ purchdata.supplierdescription,
+ purchdata.conversionfactor,
+ purchdata.leadtime,
+ purchdata.suppliersuom,
+ stockmaster.kgs,
+ stockmaster.volume,
+ stockcategory.stockact,
+ SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS orderqty
+ FROM purchdata INNER JOIN salesorderdetails ON
+ purchdata.stockid = salesorderdetails.stkcode
+ INNER JOIN stockmaster ON
+ purchdata.stockid = stockmaster.stockid
+ INNER JOIN stockcategory ON
+ stockmaster.categoryid = stockcategory.categoryid
+ WHERE purchdata.preferred=1
+ AND purchdata.effectivefrom <='" . Date('Y-m-d') . "'
+ AND (" . $OrdersToPlacePOFor . ")
+ GROUP BY purchdata.supplierno,
+ purchdata.stockid,
+ purchdata.price,
+ purchdata.suppliers_partno,
+ purchdata.supplierdescription,
+ purchdata.conversionfactor,
+ purchdata.leadtime,
+ purchdata.suppliersuom,
+ stockmaster.kgs,
+ stockmaster.volume,
+ stockcategory.stockact
+ ORDER BY purchdata.supplierno,
+ purchdata.stockid";
$ErrMsg = _('Unable to retrieve the items on the selected orders for creating purchase orders for');
$ItemResult = DB_query($sql,$db,$ErrMsg);
-
+
if (DB_num_rows($ItemResult)==0){
prnMsg(_('There might be no supplier purchasing data set up for any items on the selected sales order(s). No purchase orders have been created'),'warn');
} else {
/*Now get the default delivery address details from the users default stock location */
$sql = "SELECT locationname,
- deladd1,
- deladd2,
- deladd3,
- deladd4,
- deladd5,
- deladd6,
- tel,
- contact
- FROM locations
- WHERE loccode = '" .$_SESSION['UserStockLocation'] . "'";
+ deladd1,
+ deladd2,
+ deladd3,
+ deladd4,
+ deladd5,
+ deladd6,
+ tel,
+ contact
+ FROM locations
+ WHERE loccode = '" .$_SESSION['UserStockLocation'] . "'";
$ErrMsg = _('The delivery address for the order could not be obtained from the user default stock location');
$DelAddResult = DB_query($sql, $db,$ErrMsg);
$DelAddRow = DB_fetch_array($DelAddResult);
-
+
$SupplierID = '';
+
if (IsEmailAddress($_SESSION['UserEmail'])){
$UserDetails = ' <a href="mailto:' . $_SESSION['UserEmail'] . '">' . $_SESSION['UsersRealName']. '</a>';
} else {
$UserDetails = ' ' . $_SESSION['UsersRealName'] . ' ';
}
-
+
while ($ItemRow = DB_fetch_array($ItemResult)){
-
- if ($SupplierID != $ItemRow['supplierno']){
- /* This order item is purchased from a different supplier so need to finish off the authorisation of the previous order and start a new order */
-
- if ($SupplierID !='' AND $_SESSION['AutoAuthorisePO']==1) {
+
+ if ($SupplierID != $ItemRow['supplierno']){
+ /* This order item is purchased from a different supplier so need to finish off the authorisation of the previous order and start a new order */
+
+ if ($SupplierID !='' AND $_SESSION['AutoAuthorisePO']==1) {
+ /* if an order is/has been created already and the supplier of this item has changed - so need to finish off the order */
//if the user has authority to authorise the PO then it should be created as authorised
$AuthSQL ="SELECT authlevel
- FROM purchorderauth
- WHERE userid='".$_SESSION['UserID']."'
- AND currabrev='".$SuppRow['currcode']."'";
-
+ FROM purchorderauth
+ WHERE userid='".$_SESSION['UserID']."'
+ AND currabrev='".$SuppRow['currcode']."'";
+
$AuthResult=DB_query($AuthSQL,$db);
$AuthRow=DB_fetch_array($AuthResult);
-
+ if ($AuthRow['authlevel']=''){
+ $AuthRow['authlevel'] = 0;
+ }
+
if (DB_num_rows($AuthResult) > 0 AND $AuthRow['authlevel'] > $Order_Value) { //user has authority to authrorise as well as create the order
- $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created and Authorised by') . $UserDetails . ' - '._('Auto created from sales orders') .'<br />';
- $result = DB_query("UPDATE purchorders SET allowprint=1,
- status='Authorised',
- stat_comment='" . $StatusComment . "'
- WHERE orderno='" . $OrderNo . "'",
- $db);
+ $StatusComment = date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created and Authorised by') . ' ' . $UserDetails . ' - '._('Auto created from sales orders') .'<br />';
+ $ErrMsg = _('Could not update purchase order status to Authorised');
+ $Debug = _('The SQL that failed was');
+ $result = DB_query("UPDATE purchorders SET allowprint=1,
+ status='Authorised',
+ stat_comment='" . $StatusComment . "'
+ WHERE orderno='" . $PO_OrderNo . "'",
+ $db,$ErrMsg,$DbgMsg,true);
} else { // no authority to authorise this order
if (DB_num_rows($AuthResult) ==0){
$AuthMessage = _('Your authority to approve purchase orders in') . ' ' .$SuppRow['currcode'] . ' ' . _('has not yet been set up') . '<br />';
} else {
$AuthMessage = _('You can only authorise up to').' '.$SuppRow['currcode'].' '.$AuthRow['authlevel'].'.<br />';
}
-
+
prnMsg( _('You do not have permission to authorise this purchase order').'.<br />'. _('This order is for').' '.
$SuppRow['currcode'] . ' '. $Order_Value .'. '.
$AuthMessage . _('If you think this is a mistake please contact the systems administrator') . '<br />'.
_('The order has been created with a status of pending and will require authorisation'), 'warn');
}
} //end of authorisation status settings
-
+
if ($SupplierID !=''){ //then we have just added a purchase order
- echo '<p>';
- prnMsg(_('Purchase Order') . ' ' . $PO_OrderNo . ' ' . _('on') . ' ' . $ItemRow['supplierno'] . ' ' . _('has been created'),'success');
+ echo '<p />';
+ prnMsg(_('Purchase Order') . ' ' . $PO_OrderNo . ' ' . _('on') . ' ' . $SupplierID . ' ' . _('has been created'),'success');
DB_Txn_Commit($db);
}
- /*Starting a new purchase order with a different supplier */
+
+ /*Starting a new purchase order with a different supplier */
$result = DB_Txn_Begin($db);
- include('includes/SQL_CommonFunctions.inc');
+
$PO_OrderNo = GetNextTransNo(18, $db); //get the next PO number
-
+
$SupplierID = $ItemRow['supplierno'];
$Order_Value =0;
/*Now get all the required details for the supplier */
$sql = "SELECT address1,
- address2,
- address3,
- address4,
- address5,
- address6,
- telephone,
- paymentterms,
- currcode,
- rate
- FROM suppliers INNER JOIN currencies
- ON suppliers.currcode = currencies.currabrev
- WHERE supplierid='" . $SupplierID . "'";
-
+ address2,
+ address3,
+ address4,
+ address5,
+ address6,
+ telephone,
+ paymentterms,
+ currcode,
+ rate
+ FROM suppliers INNER JOIN currencies
+ ON suppliers.currcode = currencies.currabrev
+ WHERE supplierid='" . $SupplierID . "'";
+
$ErrMsg = _('Could not get the supplier information for the order');
$SuppResult = DB_query($sql, $db, $ErrMsg);
$SuppRow = DB_fetch_array($SuppResult);
-
+
$StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . ' ' . $UserDetails . ' - '._('Auto created from sales orders') .'<br />';
/*Insert to purchase order header record */
- $sql = "INSERT INTO purchorders ( orderno,
- supplierno,
- orddate,
- rate,
- initiator,
- intostocklocation,
- deladd1,
- deladd2,
- deladd3,
- deladd4,
- deladd5,
- deladd6,
- tel,
- suppdeladdress1,
- suppdeladdress2,
- suppdeladdress3,
- suppdeladdress4,
- suppdeladdress5,
- suppdeladdress6,
- supptel,
- version,
- revised,
- deliveryby,
- status,
- stat_comment,
- deliverydate,
- paymentterms,
- allowprint)
- VALUES( '" . $PO_OrderNo . "',
- '" . $SupplierID . "',
- '" . Date('Y-m-d') . "',
- '" . $SuppRow['rate'] . "',
- '" . $_SESSION['UsersRealName'] . "',
- '" . $_SESSION['UserStockLocation'] . "',
- '" . $DelAddRow['locationname'] . "',
- '" . $DelAddRow['deladd1'] . "',
- '" . $DelAddRow['deladd2'] . "',
- '" . $DelAddRow['deladd3'] . "',
- '" . $DelAddRow['deladd4'] . "',
- '" . $DelAddRow['deladd5'] . ' ' . $DelAddRow['deladd6'] . "',
- '" . $DelAddRow['tel'] . "',
- '" . $SuppRow['address1'] . "',
- '" . $SuppRow['address2'] . "',
- '" . $SuppRow['address3'] . "',
- '" . $SuppRow['address4'] . "',
- '" . $SuppRow['address5'] . "',
- '" . $SuppRow['address6'] . "',
- '" . $SuppRow['telephone'] . "',
- '1.0',
- '" . Date('Y-m-d') . "',
- '" . $_SESSION['Default_Shipper'] . "',
- 'Pending',
- '" . $StatusComment . "',
- '" . Date('Y-m-d') . "',
- '" . $SuppRow['paymentterms'] . "',
- 0)";
-
+ $sql = "INSERT INTO purchorders ( orderno,
+ supplierno,
+ orddate,
+ rate,
+ initiator,
+ intostocklocation,
+ deladd1,
+ deladd2,
+ deladd3,
+ deladd4,
+ deladd5,
+ deladd6,
+ tel,
+ suppdeladdress1,
+ suppdeladdress2,
+ suppdeladdress3,
+ suppdeladdress4,
+ suppdeladdress5,
+ suppdeladdress6,
+ supptel,
+ version,
+ revised,
+ deliveryby,
+ status,
+ stat_comment,
+ deliverydate,
+ paymentterms,
+ allowprint)
+ VALUES( '" . $PO_OrderNo . "',
+ '" . $SupplierID . "',
+ '" . Date('Y-m-d') . "',
+ '" . $SuppRow['rate'] . "',
+ '" . $_SESSION['UsersRealName'] . "',
+ ...
[truncated message content] |