This list is closed, nobody may subscribe to it.
2011 |
Jan
(14) |
Feb
(42) |
Mar
(56) |
Apr
(60) |
May
(54) |
Jun
(48) |
Jul
(74) |
Aug
(52) |
Sep
(68) |
Oct
(64) |
Nov
(42) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2012 |
Jan
(142) |
Feb
(270) |
Mar
(374) |
Apr
(230) |
May
(214) |
Jun
(116) |
Jul
(234) |
Aug
(66) |
Sep
(120) |
Oct
(16) |
Nov
(17) |
Dec
(41) |
2013 |
Jan
(19) |
Feb
(18) |
Mar
(8) |
Apr
(40) |
May
(121) |
Jun
(42) |
Jul
(127) |
Aug
(145) |
Sep
(27) |
Oct
(38) |
Nov
(83) |
Dec
(61) |
2014 |
Jan
(33) |
Feb
(35) |
Mar
(59) |
Apr
(41) |
May
(38) |
Jun
(45) |
Jul
(17) |
Aug
(58) |
Sep
(46) |
Oct
(51) |
Nov
(55) |
Dec
(36) |
2015 |
Jan
(57) |
Feb
(67) |
Mar
(70) |
Apr
(34) |
May
(32) |
Jun
(11) |
Jul
(3) |
Aug
(17) |
Sep
(16) |
Oct
(13) |
Nov
(30) |
Dec
(30) |
2016 |
Jan
(17) |
Feb
(12) |
Mar
(17) |
Apr
(20) |
May
(47) |
Jun
(15) |
Jul
(13) |
Aug
(30) |
Sep
(32) |
Oct
(20) |
Nov
(32) |
Dec
(24) |
2017 |
Jan
(16) |
Feb
|
Mar
(11) |
Apr
(11) |
May
(5) |
Jun
(42) |
Jul
(9) |
Aug
(10) |
Sep
(14) |
Oct
(15) |
Nov
(2) |
Dec
(29) |
2018 |
Jan
(28) |
Feb
(49) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dai...@us...> - 2011-03-18 05:45:28
|
Revision: 4512 http://web-erp.svn.sourceforge.net/web-erp/?rev=4512&view=rev Author: daintree Date: 2011-03-18 05:45:21 +0000 (Fri, 18 Mar 2011) Log Message: ----------- Marcos Change Supplier code Modified Paths: -------------- trunk/CustomerBranches.php trunk/Customers.php trunk/DailyBankTransactions.php trunk/Stocks.php trunk/UserSettings.php trunk/Z_index.php trunk/doc/Change.log.html trunk/includes/ConnectDB.inc trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/CustomerBranches.php =================================================================== --- trunk/CustomerBranches.php 2011-03-15 09:33:07 UTC (rev 4511) +++ trunk/CustomerBranches.php 2011-03-18 05:45:21 UTC (rev 4512) @@ -52,7 +52,7 @@ $_POST['BranchCode'] = strtoupper($_POST['BranchCode']); - if (strstr($_POST['BranchCode'],"'") OR strstr($_POST['BranchCode'],'"') OR strstr($_POST['BranchCode'],'&')) { + if (ContainsIllegalCharacters($_POST['BranchCode']) OR strstr($_POST['BranchCode'],' ')) { $InputError = 1; prnMsg(_('The Branch code cannot contain any of the following characters')." - & \'",'error'); $Errors[$i] = 'BranchCode'; Modified: trunk/Customers.php =================================================================== --- trunk/Customers.php 2011-03-15 09:33:07 UTC (rev 4511) +++ trunk/Customers.php 2011-03-18 05:45:21 UTC (rev 4512) @@ -41,7 +41,7 @@ prnMsg( _('The customer number already exists in the database'),'error'); $Errors[$i] = 'DebtorNo'; $i++; - } elseif (strlen($_POST['CustName']) > 40 OR strlen($_POST['CustName'])==0) { + }elseif (strlen($_POST['CustName']) > 40 OR strlen($_POST['CustName'])==0) { $InputError = 1; prnMsg( _('The customer name must be entered and be forty characters or less long'),'error'); $Errors[$i] = 'CustName'; @@ -51,7 +51,7 @@ prnMsg( _('The debtor code cannot be empty'),'error'); $Errors[$i] = 'DebtorNo'; $i++; - } elseif ($_SESSION['AutoDebtorNo']==0 AND ContainsIllegalCharacters($_POST['DebtorNo'])) { + } elseif ($_SESSION['AutoDebtorNo']==0 AND (ContainsIllegalCharacters($_POST['DebtorNo']) OR strpos($_POST['DebtorNo'], ' '))) { $InputError = 1; prnMsg( _('The customer code cannot contain any of the following characters') . " . - ' & + \" " . _('or a space'),'error'); $Errors[$i] = 'DebtorNo'; Modified: trunk/DailyBankTransactions.php =================================================================== --- trunk/DailyBankTransactions.php 2011-03-15 09:33:07 UTC (rev 4511) +++ trunk/DailyBankTransactions.php 2011-03-18 05:45:21 UTC (rev 4512) @@ -82,7 +82,8 @@ ON banktrans.type=systypes.typeid WHERE bankact='".$_POST['BankAccount']."' AND transdate>='" . FormatDateForSQL($_POST['FromTransDate']) . "' - AND transdate<='" . FormatDateForSQL($_POST['ToTransDate']) . "'"; + AND transdate<='" . FormatDateForSQL($_POST['ToTransDate']) . "' + ORDER BY banktrans.transdate"; $result = DB_query($sql, $db); if (DB_num_rows($result)==0) { prnMsg(_('There are no transactions for this account in the date range selected'), 'info'); Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2011-03-15 09:33:07 UTC (rev 4511) +++ trunk/Stocks.php 2011-03-18 05:45:21 UTC (rev 4512) @@ -100,7 +100,7 @@ $Errors[$i] = 'StockID'; $i++; } - if (ContainsIllegalCharacters($StockID)) { + if (ContainsIllegalCharacters($StockID) OR strstr($StockID,' ')) { $InputError = 1; prnMsg(_('The stock item code cannot contain any of the following characters') . " - ' & + \" \\ " . _('or a space'),'error'); $Errors[$i] = 'StockID'; Modified: trunk/UserSettings.php =================================================================== --- trunk/UserSettings.php 2011-03-15 09:33:07 UTC (rev 4511) +++ trunk/UserSettings.php 2011-03-18 05:45:21 UTC (rev 4512) @@ -10,8 +10,8 @@ _('User Settings') . '" alt="" />' . ' ' . _('User Settings') . '</p>'; $PDFLanguages = array(_('Latin Western Languages'), - _('Eastern European Russian Japanese Korean Hebrew Arabic Thai'), - _('Chinese')); + _('Eastern European Russian Japanese Korean Hebrew Arabic Thai'), + _('Chinese')); if (isset($_POST['Modify'])) { Modified: trunk/Z_index.php =================================================================== --- trunk/Z_index.php 2011-03-15 09:33:07 UTC (rev 4511) +++ trunk/Z_index.php 2011-03-18 05:45:21 UTC (rev 4512) @@ -13,6 +13,7 @@ echo "<p><a href='$rootpath/Z_ChangeCustomerCode.php?" . SID . "'>". _('Change A Customer Code') . '</a>'; echo "<p><a href='$rootpath/Z_ChangeBranchCode.php?" . SID . "'>" . _('Change A Customer Branch Code') . '</a>'; echo "<p><a href='$rootpath/Z_ChangeStockCode.php?" . SID . "'>" . _('Change An Inventory Item Code') . '</a>'; + echo "<p><a href='$rootpath/Z_ChangeSupplierCode.php?" . SID . "'>" . _('Change A Supplier Code') . '</a>'; echo "<p><a href='$rootpath/Z_PriceChanges.php?" . SID . "'>" . _('Bulk Change Customer Pricing') . '</a>'; echo "<p><a href='$rootpath/Z_BottomUpCosts.php?" . SID . "'>" . _('Update costs for all BOM items, from the bottom up') . '</a>'; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-15 09:33:07 UTC (rev 4511) +++ trunk/doc/Change.log.html 2011-03-18 05:45:21 UTC (rev 4512) @@ -1,5 +1,8 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>18/3/11: Marcos Garcia Trejo Added Z_ChangeSupplierCode.php +<p>18/3/11: Ricard add orderby transdate to DailyBankTransactions.php +<p>18/3/11: Phil check for Customers.php CustomerBranches.php and Stocks.php now traps codes containing spaces - as well as other illegal characters</p> <p>15/3/11: Phil PricesByCost.php - made it update prices where there is already a price starting on today's date</p> <p>15/3/11: Phil SelectOrderItems.php customer selection now done using a hidden $_POST rather than parsing debtorno hyphen branchcode.</p> <p>15/3/11: Phil Locations.php new field for CounterSales branch code - instead of parsing it from a single field with a hyphen in it. CounterSales.php now uses the new field for customer branch</p> Modified: trunk/includes/ConnectDB.inc =================================================================== --- trunk/includes/ConnectDB.inc 2011-03-15 09:33:07 UTC (rev 4511) +++ trunk/includes/ConnectDB.inc 2011-03-18 05:45:21 UTC (rev 4512) @@ -4,7 +4,7 @@ * this value is saved in the $_SESSION['Versionumber'] when includes/GetConfig.php is run * if VersionNumber is < $Version then the DB update script is run */ -$Version='4.03.2'; //must update manually every time there is a DB change +$Version='4.03.4'; //must update manually every time there is a DB change require_once ($PathPrefix .'includes/MiscFunctions.php'); Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2011-03-15 09:33:07 UTC (rev 4511) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2011-03-18 05:45:21 UTC (rev 4512) @@ -833,4 +833,6 @@ UPDATE config SET confvalue='4.03.2' WHERE confname='VersionNumber'; ALTER TABLE locations ADD cashsalebranch varchar(10) DEFAULT ''; ALTER TABLE `locations` CHANGE `cashsalecustomer` `cashsalecustomer` VARCHAR( 10 ) DEFAULT ''; -UPDATE config SET confvalue='4.03.3' WHERE confname='VersionNumber'; \ No newline at end of file +UPDATE config SET confvalue='4.03.3' WHERE confname='VersionNumber'; +INSERT INTO `weberpdemo`.`scripts` (`script`, `pagesecurity`, `description`) VALUES ('Z_ChangeSupplierCode.php', '15', 'Script to change a supplier code accross all tables necessary'); +UPDATE config SET confvalue='4.03.4' WHERE confname='VersionNumber'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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] |
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] |
From: <dai...@us...> - 2011-03-14 09:11:28
|
Revision: 4510 http://web-erp.svn.sourceforge.net/web-erp/?rev=4510&view=rev Author: daintree Date: 2011-03-14 09:11:21 +0000 (Mon, 14 Mar 2011) Log Message: ----------- Show outstanding sales order value in functional currency Modified Paths: -------------- trunk/SelectSalesOrder.php trunk/UpgradeDatabase.php trunk/doc/Change.log.html trunk/includes/LanguageSetup.php trunk/includes/session.inc Modified: trunk/SelectSalesOrder.php =================================================================== --- trunk/SelectSalesOrder.php 2011-03-13 08:28:44 UTC (rev 4509) +++ trunk/SelectSalesOrder.php 2011-03-14 09:11:21 UTC (rev 4510) @@ -106,7 +106,7 @@ $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', - statuscomment='" . $StatusComment . "' + stat_comment='" . $StatusComment . "' WHERE orderno='" . $OrderNo . "'", $db); } else { // no authority to authorise this order @@ -514,16 +514,17 @@ salesorders.deliverto, salesorders.printedpackingslip, salesorders.poplaced, - SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue - FROM salesorders, - salesorderdetails, - debtorsmaster, - custbranch - WHERE salesorders.orderno = salesorderdetails.orderno - AND salesorders.branchcode = custbranch.branchcode - AND salesorders.debtorno = debtorsmaster.debtorno - AND debtorsmaster.debtorno = custbranch.debtorno - AND salesorderdetails.completed=0 + SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate) AS ordervalue + FROM salesorders INNER JOIN salesorderdetails + ON salesorders.orderno = salesorderdetails.orderno + INNER JOIN debtorsmaster + ON salesorders.debtorno = debtorsmaster.debtorno + INNER JOIN custbranch + ON debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.branchcode = custbranch.branchcode + INNER JOIN currencies + ON debtorsmaster.currcode = currencies.currabrev + WHERE salesorderdetails.completed=0 AND salesorders.orderno=". $_REQUEST['OrderNumber'] ." AND salesorders.quotation =" .$Quotations . " GROUP BY salesorders.orderno, @@ -533,7 +534,8 @@ salesorders.orddate, salesorders.deliverydate, salesorders.deliverto, - salesorders.printedpackingslip + salesorders.printedpackingslip, + salesorders.poplaced ORDER BY salesorders.orderno"; } else { /* $DateAfterCriteria = FormatDateforSQL($OrdersAfterDate); */ @@ -550,16 +552,17 @@ salesorders.deliverto, salesorders.printedpackingslip, salesorders.poplaced, - salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent) AS ordervalue - FROM salesorders, - salesorderdetails, - debtorsmaster, - custbranch - WHERE salesorders.orderno = salesorderdetails.orderno - AND salesorders.debtorno = debtorsmaster.debtorno - AND debtorsmaster.debtorno = custbranch.debtorno - AND salesorders.branchcode = custbranch.branchcode - AND salesorderdetails.completed=0 + salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate AS ordervalue + FROM salesorders INNER JOIN salesorderdetails + ON salesorders.orderno = salesorderdetails.orderno + INNER JOIN debtorsmaster + ON salesorders.debtorno = debtorsmaster.debtorno + INNER JOIN custbranch + ON debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.branchcode = custbranch.branchcode + INNER JOIN currencies + ON debtorsmaster.currcode = currencies.currabrev + WHERE salesorderdetails.completed=0 AND salesorders.quotation =" .$Quotations . " AND salesorderdetails.stkcode='". $_REQUEST['SelectedStockItem'] ."' AND salesorders.debtorno='" . $_REQUEST['SelectedCustomer'] ."' @@ -576,16 +579,18 @@ salesorders.deliverto, salesorders.printedpackingslip, salesorders.poplaced, - salesorders.deliverydate, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue - FROM salesorders, - salesorderdetails, - debtorsmaster, - custbranch - WHERE salesorders.orderno = salesorderdetails.orderno - AND salesorders.debtorno = debtorsmaster.debtorno - AND debtorsmaster.debtorno = custbranch.debtorno - AND salesorders.branchcode = custbranch.branchcode - AND salesorders.quotation =" .$Quotations . " + salesorders.deliverydate, + SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate) AS ordervalue + FROM salesorders INNER JOIN salesorderdetails + ON salesorders.orderno = salesorderdetails.orderno + INNER JOIN debtorsmaster + ON salesorders.debtorno = debtorsmaster.debtorno + INNER JOIN custbranch + ON debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.branchcode = custbranch.branchcode + INNER JOIN currencies + ON debtorsmaster.currcode = currencies.currabrev + WHERE salesorders.quotation =" .$Quotations . " AND salesorderdetails.completed=0 AND salesorders.debtorno='" . $_REQUEST['SelectedCustomer'] . "' AND salesorders.fromstkloc = '". $_POST['StockLocation'] . "' @@ -596,7 +601,8 @@ salesorders.customerref, salesorders.orddate, salesorders.deliverto, - salesorders.deliverydate + salesorders.deliverydate, + salesorders.poplaced ORDER BY salesorders.orderno"; } @@ -610,16 +616,18 @@ salesorders.deliverto, salesorders.printedpackingslip, salesorders.poplaced, - salesorders.deliverydate, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue - FROM salesorders, - salesorderdetails, - debtorsmaster, - custbranch - WHERE salesorders.orderno = salesorderdetails.orderno - AND salesorders.debtorno = debtorsmaster.debtorno - AND debtorsmaster.debtorno = custbranch.debtorno - AND salesorders.branchcode = custbranch.branchcode - AND salesorderdetails.completed=0 + salesorders.deliverydate, + SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate) AS ordervalue + FROM salesorders INNER JOIN salesorderdetails + ON salesorders.orderno = salesorderdetails.orderno + INNER JOIN debtorsmaster + ON salesorders.debtorno = debtorsmaster.debtorno + INNER JOIN custbranch + ON debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.branchcode = custbranch.branchcode + INNER JOIN currencies + ON debtorsmaster.currcode = currencies.currabrev + WHERE salesorderdetails.completed=0 AND salesorders.quotation =" .$Quotations . " AND salesorderdetails.stkcode='". $_REQUEST['SelectedStockItem'] . "' AND salesorders.fromstkloc = '". $_POST['StockLocation'] . "' @@ -629,6 +637,7 @@ salesorders.customerref, salesorders.orddate, salesorders.deliverto, + salesorders.poplaced, salesorders.deliverydate, salesorders.printedpackingslip ORDER BY salesorders.orderno"; @@ -642,16 +651,17 @@ salesorders.deliverydate, salesorders.printedpackingslip, salesorders.poplaced, - SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue - FROM salesorders, - salesorderdetails, - debtorsmaster, - custbranch - WHERE salesorders.orderno = salesorderdetails.orderno - AND salesorders.debtorno = debtorsmaster.debtorno - AND debtorsmaster.debtorno = custbranch.debtorno - AND salesorders.branchcode = custbranch.branchcode - AND salesorderdetails.completed=0 + SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate) AS ordervalue + FROM salesorders INNER JOIN salesorderdetails + ON salesorders.orderno = salesorderdetails.orderno + INNER JOIN debtorsmaster + ON salesorders.debtorno = debtorsmaster.debtorno + INNER JOIN custbranch + ON debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.branchcode = custbranch.branchcode + INNER JOIN currencies + ON debtorsmaster.currcode = currencies.currabrev + WHERE salesorderdetails.completed=0 AND salesorders.quotation =" .$Quotations . " AND salesorders.fromstkloc = '". $_POST['StockLocation'] . "' GROUP BY salesorders.orderno, @@ -661,7 +671,8 @@ salesorders.orddate, salesorders.deliverto, salesorders.deliverydate, - salesorders.printedpackingslip + salesorders.printedpackingslip, + salesorders.poplaced ORDER BY salesorders.orderno"; } @@ -685,7 +696,7 @@ echo '<table cellpadding=2 colspan=7 width=95% class=selection>'; - if (isset($_POST['Quotations']) and $_POST['Quotations']=='Orders_Only'){ + if (isset($_POST['Quotations']) AND $_POST['Quotations']=='Orders_Only'){ $tableheader = '<tr> <th>' . _('Modify') . '</th> <th>' . _('Invoice') . '</th> @@ -697,7 +708,7 @@ <th>' . _('Order Date') . '</th> <th>' . _('Req Del Date') . '</th> <th>' . _('Delivery To') . '</th> - <th>' . _('Order Total') . '</th>'; + <th>' . _('Order Total') . '<br />' . $_SESSION['CompanyRecord']['currencydefault'] . '</th>'; if ($AuthRow['cancreate']==0){ //If cancreate==0 then this means the user can create orders hmmm!! $tableheader .= '<th>' . _('Place PO') . '</th></tr>'; } else { @@ -713,7 +724,7 @@ <th>' . _('Quote Date') . '</th> <th>' . _('Req Del Date') . '</th> <th>' . _('Delivery To') . '</th> - <th>' . _('Quote Total') . '</th></tr>'; + <th>' . _('Quote Total') . '<br />' . $_SESSION['CompanyRecord']['currencydefault'] . '</th></tr>'; } echo $tableheader; @@ -721,6 +732,8 @@ $i = 1; $j = 1; $k=0; //row colour counter + $OrdersTotal =0; + while ($myrow=DB_fetch_array($SalesOrdersResult)) { @@ -732,16 +745,16 @@ $k++; } - $ModifyPage = $rootpath . "/SelectOrderItems.php?" . SID . '&ModifyOrderNumber=' . $myrow['orderno']; - $Confirm_Invoice = $rootpath . '/ConfirmDispatch_Invoice.php?' . SID . '&OrderNumber=' .$myrow['orderno']; + $ModifyPage = $rootpath . '/SelectOrderItems.php?ModifyOrderNumber=' . $myrow['orderno']; + $Confirm_Invoice = $rootpath . '/ConfirmDispatch_Invoice.php?OrderNumber=' .$myrow['orderno']; if ($_SESSION['PackNoteFormat']==1){ /*Laser printed A4 default */ - $PrintDispatchNote = $rootpath . '/PrintCustOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; + $PrintDispatchNote = $rootpath . '/PrintCustOrder_generic.php?TransNo=' . $myrow['orderno']; } else { /*pre-printed stationery default */ - $PrintDispatchNote = $rootpath . '/PrintCustOrder.php?' . SID . '&TransNo=' . $myrow['orderno']; + $PrintDispatchNote = $rootpath . '/PrintCustOrder.php?TransNo=' . $myrow['orderno']; } - $PrintSalesOrder = $rootpath . '/PrintSalesOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; - $PrintQuotation = $rootpath . '/PDFQuotation.php?' . SID . '&QuotationNo=' . $myrow['orderno']; + $PrintSalesOrder = $rootpath . '/PrintSalesOrder_generic.php?TransNo=' . $myrow['orderno']; + $PrintQuotation = $rootpath . '/PDFQuotation.php?QuotationNo=' . $myrow['orderno']; $FormatedDelDate = ConvertSQLDate($myrow['deliverydate']); $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); $FormatedOrderValue = number_format($myrow['ordervalue'],2); @@ -835,6 +848,7 @@ } $i++; $j++; + $TotalOrders += $myrow['ordervalue']; if ($j == 12){ $j=1; echo $tableheader; @@ -842,9 +856,16 @@ //end of page full new headings if }//end while loop through orders to display if ($_POST['Quotations']=='Orders_Only' AND $AuthRow['cancreate']==0){ //cancreate==0 means can create POs - echo '<tr><td colspan="10"><td><td colspan="2"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; + echo '<tr><td colspan="9"><td><td colspan="2" class="number"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; } - echo '</table>'; + echo '<tr><td colspan="10" class="number">'; + if ($_POST['Quotations']=='Orders_Only'){ + echo _('Total Order(s) Value in'); + } else { + echo _('Total Quotation(s) Value in'); + } + echo ' ' . $_SESSION['CompanyRecord']['currencydefault'] . ' :</td><td colspan="1" class="number">' . number_format($TotalOrders,2) . '</td></tr> + </table>'; } //end if there are some orders to show } Modified: trunk/UpgradeDatabase.php =================================================================== --- trunk/UpgradeDatabase.php 2011-03-13 08:28:44 UTC (rev 4509) +++ trunk/UpgradeDatabase.php 2011-03-14 09:11:21 UTC (rev 4510) @@ -97,7 +97,7 @@ $SQLScripts[] = './sql/mysql/upgrade3.11.1-4.00.sql'; break; } //end switch - if(isset($_SESSION['VersionNumber']) AND $_SESSION['VersionNumber']< '4.03') { /* VersionNumber is set to '4.03' when upgrade3.11.1-4.00.sql is run */ + if(isset($_SESSION['VersionNumber']) AND strcmp($_SESSION['VersionNumber'],'4.04')<0) { /* VersionNumber is set to '4.04' when upgrade3.11.1-4.00.sql is run */ $SQLScripts[] = './sql/mysql/upgrade3.11.1-4.00.sql'; } } Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-13 08:28:44 UTC (rev 4509) +++ trunk/doc/Change.log.html 2011-03-14 09:11:21 UTC (rev 4510) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>14/3/11: SelectSalesOrder.php now lists with sales order value denominated in functional currency with total of listed outstadning sales orders (or quotations) shown at the bottom of the listing</p> <p>12/3/11: Tim Now allow space in codes </p> <p>12/3/11: SelectSalesOrder.php now allows any number of sales orders to be selected and purchase orders placed for the aggregate of items on the selected sales orders</p> <p>12/3/11: SuppPriceList.php removed a round trip to DB to get currency - fixed function to get pdf to new TCPDF Output </p> Modified: trunk/includes/LanguageSetup.php =================================================================== --- trunk/includes/LanguageSetup.php 2011-03-13 08:28:44 UTC (rev 4509) +++ trunk/includes/LanguageSetup.php 2011-03-14 09:11:21 UTC (rev 4510) @@ -75,8 +75,8 @@ } } //if (substr($_SESSION['Language'],0,2) == 'en'){ - $locale_info['thousands_sep'] = ','; - $locale_info['decimal_point'] = '.'; + $locale_info['thousands_sep'] = ','; + $locale_info['decimal_point'] = '.'; /* } else { $locale_info['thousands_sep'] = '.'; Modified: trunk/includes/session.inc =================================================================== --- trunk/includes/session.inc 2011-03-13 08:28:44 UTC (rev 4509) +++ trunk/includes/session.inc 2011-03-14 09:11:21 UTC (rev 4510) @@ -124,7 +124,7 @@ } /*If the Code $Version - held in ConnectDB.inc is > than the Database VersionNumber held in config table then do upgrades */ -if (($Version>$_SESSION['VersionNumber']) and (basename($_SERVER['SCRIPT_NAME'])!='UpgradeDatabase.php')) { +if (strcmp($Version,$_SESSION['VersionNumber'])>0 AND (basename($_SERVER['SCRIPT_NAME'])!='UpgradeDatabase.php')) { header('Location: UpgradeDatabase.php'); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-14 09:11:27
|
Revision: 4510 http://web-erp.svn.sourceforge.net/web-erp/?rev=4510&view=rev Author: daintree Date: 2011-03-14 09:11:21 +0000 (Mon, 14 Mar 2011) Log Message: ----------- Show outstanding sales order value in functional currency Modified Paths: -------------- trunk/SelectSalesOrder.php trunk/UpgradeDatabase.php trunk/doc/Change.log.html trunk/includes/LanguageSetup.php trunk/includes/session.inc Modified: trunk/SelectSalesOrder.php =================================================================== --- trunk/SelectSalesOrder.php 2011-03-13 08:28:44 UTC (rev 4509) +++ trunk/SelectSalesOrder.php 2011-03-14 09:11:21 UTC (rev 4510) @@ -106,7 +106,7 @@ $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', - statuscomment='" . $StatusComment . "' + stat_comment='" . $StatusComment . "' WHERE orderno='" . $OrderNo . "'", $db); } else { // no authority to authorise this order @@ -514,16 +514,17 @@ salesorders.deliverto, salesorders.printedpackingslip, salesorders.poplaced, - SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue - FROM salesorders, - salesorderdetails, - debtorsmaster, - custbranch - WHERE salesorders.orderno = salesorderdetails.orderno - AND salesorders.branchcode = custbranch.branchcode - AND salesorders.debtorno = debtorsmaster.debtorno - AND debtorsmaster.debtorno = custbranch.debtorno - AND salesorderdetails.completed=0 + SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate) AS ordervalue + FROM salesorders INNER JOIN salesorderdetails + ON salesorders.orderno = salesorderdetails.orderno + INNER JOIN debtorsmaster + ON salesorders.debtorno = debtorsmaster.debtorno + INNER JOIN custbranch + ON debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.branchcode = custbranch.branchcode + INNER JOIN currencies + ON debtorsmaster.currcode = currencies.currabrev + WHERE salesorderdetails.completed=0 AND salesorders.orderno=". $_REQUEST['OrderNumber'] ." AND salesorders.quotation =" .$Quotations . " GROUP BY salesorders.orderno, @@ -533,7 +534,8 @@ salesorders.orddate, salesorders.deliverydate, salesorders.deliverto, - salesorders.printedpackingslip + salesorders.printedpackingslip, + salesorders.poplaced ORDER BY salesorders.orderno"; } else { /* $DateAfterCriteria = FormatDateforSQL($OrdersAfterDate); */ @@ -550,16 +552,17 @@ salesorders.deliverto, salesorders.printedpackingslip, salesorders.poplaced, - salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent) AS ordervalue - FROM salesorders, - salesorderdetails, - debtorsmaster, - custbranch - WHERE salesorders.orderno = salesorderdetails.orderno - AND salesorders.debtorno = debtorsmaster.debtorno - AND debtorsmaster.debtorno = custbranch.debtorno - AND salesorders.branchcode = custbranch.branchcode - AND salesorderdetails.completed=0 + salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate AS ordervalue + FROM salesorders INNER JOIN salesorderdetails + ON salesorders.orderno = salesorderdetails.orderno + INNER JOIN debtorsmaster + ON salesorders.debtorno = debtorsmaster.debtorno + INNER JOIN custbranch + ON debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.branchcode = custbranch.branchcode + INNER JOIN currencies + ON debtorsmaster.currcode = currencies.currabrev + WHERE salesorderdetails.completed=0 AND salesorders.quotation =" .$Quotations . " AND salesorderdetails.stkcode='". $_REQUEST['SelectedStockItem'] ."' AND salesorders.debtorno='" . $_REQUEST['SelectedCustomer'] ."' @@ -576,16 +579,18 @@ salesorders.deliverto, salesorders.printedpackingslip, salesorders.poplaced, - salesorders.deliverydate, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue - FROM salesorders, - salesorderdetails, - debtorsmaster, - custbranch - WHERE salesorders.orderno = salesorderdetails.orderno - AND salesorders.debtorno = debtorsmaster.debtorno - AND debtorsmaster.debtorno = custbranch.debtorno - AND salesorders.branchcode = custbranch.branchcode - AND salesorders.quotation =" .$Quotations . " + salesorders.deliverydate, + SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate) AS ordervalue + FROM salesorders INNER JOIN salesorderdetails + ON salesorders.orderno = salesorderdetails.orderno + INNER JOIN debtorsmaster + ON salesorders.debtorno = debtorsmaster.debtorno + INNER JOIN custbranch + ON debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.branchcode = custbranch.branchcode + INNER JOIN currencies + ON debtorsmaster.currcode = currencies.currabrev + WHERE salesorders.quotation =" .$Quotations . " AND salesorderdetails.completed=0 AND salesorders.debtorno='" . $_REQUEST['SelectedCustomer'] . "' AND salesorders.fromstkloc = '". $_POST['StockLocation'] . "' @@ -596,7 +601,8 @@ salesorders.customerref, salesorders.orddate, salesorders.deliverto, - salesorders.deliverydate + salesorders.deliverydate, + salesorders.poplaced ORDER BY salesorders.orderno"; } @@ -610,16 +616,18 @@ salesorders.deliverto, salesorders.printedpackingslip, salesorders.poplaced, - salesorders.deliverydate, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue - FROM salesorders, - salesorderdetails, - debtorsmaster, - custbranch - WHERE salesorders.orderno = salesorderdetails.orderno - AND salesorders.debtorno = debtorsmaster.debtorno - AND debtorsmaster.debtorno = custbranch.debtorno - AND salesorders.branchcode = custbranch.branchcode - AND salesorderdetails.completed=0 + salesorders.deliverydate, + SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate) AS ordervalue + FROM salesorders INNER JOIN salesorderdetails + ON salesorders.orderno = salesorderdetails.orderno + INNER JOIN debtorsmaster + ON salesorders.debtorno = debtorsmaster.debtorno + INNER JOIN custbranch + ON debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.branchcode = custbranch.branchcode + INNER JOIN currencies + ON debtorsmaster.currcode = currencies.currabrev + WHERE salesorderdetails.completed=0 AND salesorders.quotation =" .$Quotations . " AND salesorderdetails.stkcode='". $_REQUEST['SelectedStockItem'] . "' AND salesorders.fromstkloc = '". $_POST['StockLocation'] . "' @@ -629,6 +637,7 @@ salesorders.customerref, salesorders.orddate, salesorders.deliverto, + salesorders.poplaced, salesorders.deliverydate, salesorders.printedpackingslip ORDER BY salesorders.orderno"; @@ -642,16 +651,17 @@ salesorders.deliverydate, salesorders.printedpackingslip, salesorders.poplaced, - SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue - FROM salesorders, - salesorderdetails, - debtorsmaster, - custbranch - WHERE salesorders.orderno = salesorderdetails.orderno - AND salesorders.debtorno = debtorsmaster.debtorno - AND debtorsmaster.debtorno = custbranch.debtorno - AND salesorders.branchcode = custbranch.branchcode - AND salesorderdetails.completed=0 + SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate) AS ordervalue + FROM salesorders INNER JOIN salesorderdetails + ON salesorders.orderno = salesorderdetails.orderno + INNER JOIN debtorsmaster + ON salesorders.debtorno = debtorsmaster.debtorno + INNER JOIN custbranch + ON debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.branchcode = custbranch.branchcode + INNER JOIN currencies + ON debtorsmaster.currcode = currencies.currabrev + WHERE salesorderdetails.completed=0 AND salesorders.quotation =" .$Quotations . " AND salesorders.fromstkloc = '". $_POST['StockLocation'] . "' GROUP BY salesorders.orderno, @@ -661,7 +671,8 @@ salesorders.orddate, salesorders.deliverto, salesorders.deliverydate, - salesorders.printedpackingslip + salesorders.printedpackingslip, + salesorders.poplaced ORDER BY salesorders.orderno"; } @@ -685,7 +696,7 @@ echo '<table cellpadding=2 colspan=7 width=95% class=selection>'; - if (isset($_POST['Quotations']) and $_POST['Quotations']=='Orders_Only'){ + if (isset($_POST['Quotations']) AND $_POST['Quotations']=='Orders_Only'){ $tableheader = '<tr> <th>' . _('Modify') . '</th> <th>' . _('Invoice') . '</th> @@ -697,7 +708,7 @@ <th>' . _('Order Date') . '</th> <th>' . _('Req Del Date') . '</th> <th>' . _('Delivery To') . '</th> - <th>' . _('Order Total') . '</th>'; + <th>' . _('Order Total') . '<br />' . $_SESSION['CompanyRecord']['currencydefault'] . '</th>'; if ($AuthRow['cancreate']==0){ //If cancreate==0 then this means the user can create orders hmmm!! $tableheader .= '<th>' . _('Place PO') . '</th></tr>'; } else { @@ -713,7 +724,7 @@ <th>' . _('Quote Date') . '</th> <th>' . _('Req Del Date') . '</th> <th>' . _('Delivery To') . '</th> - <th>' . _('Quote Total') . '</th></tr>'; + <th>' . _('Quote Total') . '<br />' . $_SESSION['CompanyRecord']['currencydefault'] . '</th></tr>'; } echo $tableheader; @@ -721,6 +732,8 @@ $i = 1; $j = 1; $k=0; //row colour counter + $OrdersTotal =0; + while ($myrow=DB_fetch_array($SalesOrdersResult)) { @@ -732,16 +745,16 @@ $k++; } - $ModifyPage = $rootpath . "/SelectOrderItems.php?" . SID . '&ModifyOrderNumber=' . $myrow['orderno']; - $Confirm_Invoice = $rootpath . '/ConfirmDispatch_Invoice.php?' . SID . '&OrderNumber=' .$myrow['orderno']; + $ModifyPage = $rootpath . '/SelectOrderItems.php?ModifyOrderNumber=' . $myrow['orderno']; + $Confirm_Invoice = $rootpath . '/ConfirmDispatch_Invoice.php?OrderNumber=' .$myrow['orderno']; if ($_SESSION['PackNoteFormat']==1){ /*Laser printed A4 default */ - $PrintDispatchNote = $rootpath . '/PrintCustOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; + $PrintDispatchNote = $rootpath . '/PrintCustOrder_generic.php?TransNo=' . $myrow['orderno']; } else { /*pre-printed stationery default */ - $PrintDispatchNote = $rootpath . '/PrintCustOrder.php?' . SID . '&TransNo=' . $myrow['orderno']; + $PrintDispatchNote = $rootpath . '/PrintCustOrder.php?TransNo=' . $myrow['orderno']; } - $PrintSalesOrder = $rootpath . '/PrintSalesOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; - $PrintQuotation = $rootpath . '/PDFQuotation.php?' . SID . '&QuotationNo=' . $myrow['orderno']; + $PrintSalesOrder = $rootpath . '/PrintSalesOrder_generic.php?TransNo=' . $myrow['orderno']; + $PrintQuotation = $rootpath . '/PDFQuotation.php?QuotationNo=' . $myrow['orderno']; $FormatedDelDate = ConvertSQLDate($myrow['deliverydate']); $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); $FormatedOrderValue = number_format($myrow['ordervalue'],2); @@ -835,6 +848,7 @@ } $i++; $j++; + $TotalOrders += $myrow['ordervalue']; if ($j == 12){ $j=1; echo $tableheader; @@ -842,9 +856,16 @@ //end of page full new headings if }//end while loop through orders to display if ($_POST['Quotations']=='Orders_Only' AND $AuthRow['cancreate']==0){ //cancreate==0 means can create POs - echo '<tr><td colspan="10"><td><td colspan="2"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; + echo '<tr><td colspan="9"><td><td colspan="2" class="number"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; } - echo '</table>'; + echo '<tr><td colspan="10" class="number">'; + if ($_POST['Quotations']=='Orders_Only'){ + echo _('Total Order(s) Value in'); + } else { + echo _('Total Quotation(s) Value in'); + } + echo ' ' . $_SESSION['CompanyRecord']['currencydefault'] . ' :</td><td colspan="1" class="number">' . number_format($TotalOrders,2) . '</td></tr> + </table>'; } //end if there are some orders to show } Modified: trunk/UpgradeDatabase.php =================================================================== --- trunk/UpgradeDatabase.php 2011-03-13 08:28:44 UTC (rev 4509) +++ trunk/UpgradeDatabase.php 2011-03-14 09:11:21 UTC (rev 4510) @@ -97,7 +97,7 @@ $SQLScripts[] = './sql/mysql/upgrade3.11.1-4.00.sql'; break; } //end switch - if(isset($_SESSION['VersionNumber']) AND $_SESSION['VersionNumber']< '4.03') { /* VersionNumber is set to '4.03' when upgrade3.11.1-4.00.sql is run */ + if(isset($_SESSION['VersionNumber']) AND strcmp($_SESSION['VersionNumber'],'4.04')<0) { /* VersionNumber is set to '4.04' when upgrade3.11.1-4.00.sql is run */ $SQLScripts[] = './sql/mysql/upgrade3.11.1-4.00.sql'; } } Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-13 08:28:44 UTC (rev 4509) +++ trunk/doc/Change.log.html 2011-03-14 09:11:21 UTC (rev 4510) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>14/3/11: SelectSalesOrder.php now lists with sales order value denominated in functional currency with total of listed outstadning sales orders (or quotations) shown at the bottom of the listing</p> <p>12/3/11: Tim Now allow space in codes </p> <p>12/3/11: SelectSalesOrder.php now allows any number of sales orders to be selected and purchase orders placed for the aggregate of items on the selected sales orders</p> <p>12/3/11: SuppPriceList.php removed a round trip to DB to get currency - fixed function to get pdf to new TCPDF Output </p> Modified: trunk/includes/LanguageSetup.php =================================================================== --- trunk/includes/LanguageSetup.php 2011-03-13 08:28:44 UTC (rev 4509) +++ trunk/includes/LanguageSetup.php 2011-03-14 09:11:21 UTC (rev 4510) @@ -75,8 +75,8 @@ } } //if (substr($_SESSION['Language'],0,2) == 'en'){ - $locale_info['thousands_sep'] = ','; - $locale_info['decimal_point'] = '.'; + $locale_info['thousands_sep'] = ','; + $locale_info['decimal_point'] = '.'; /* } else { $locale_info['thousands_sep'] = '.'; Modified: trunk/includes/session.inc =================================================================== --- trunk/includes/session.inc 2011-03-13 08:28:44 UTC (rev 4509) +++ trunk/includes/session.inc 2011-03-14 09:11:21 UTC (rev 4510) @@ -124,7 +124,7 @@ } /*If the Code $Version - held in ConnectDB.inc is > than the Database VersionNumber held in config table then do upgrades */ -if (($Version>$_SESSION['VersionNumber']) and (basename($_SERVER['SCRIPT_NAME'])!='UpgradeDatabase.php')) { +if (strcmp($Version,$_SESSION['VersionNumber'])>0 AND (basename($_SERVER['SCRIPT_NAME'])!='UpgradeDatabase.php')) { header('Location: UpgradeDatabase.php'); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-13 08:28:51
|
Revision: 4509 http://web-erp.svn.sourceforge.net/web-erp/?rev=4509&view=rev Author: daintree Date: 2011-03-13 08:28:44 +0000 (Sun, 13 Mar 2011) Log Message: ----------- add to contract manual Modified Paths: -------------- trunk/doc/Change.log.html trunk/doc/Manual/ManualContracts.html Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-13 04:55:32 UTC (rev 4508) +++ trunk/doc/Change.log.html 2011-03-13 08:28:44 UTC (rev 4509) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>12/3/11: Tim Now allow space in codes </p> <p>12/3/11: SelectSalesOrder.php now allows any number of sales orders to be selected and purchase orders placed for the aggregate of items on the selected sales orders</p> <p>12/3/11: SuppPriceList.php removed a round trip to DB to get currency - fixed function to get pdf to new TCPDF Output </p> <p>12/3/11: Exson fix all htmlentities to use ENTQUOTES, 'UTF-8' option so other character sets work with it</p> Modified: trunk/doc/Manual/ManualContracts.html =================================================================== --- trunk/doc/Manual/ManualContracts.html 2011-03-13 04:55:32 UTC (rev 4508) +++ trunk/doc/Manual/ManualContracts.html 2011-03-13 08:28:44 UTC (rev 4509) @@ -1,43 +1,43 @@ <!-- Help Begin: Contracts --> -<br><br> +<br /><br /> <a name="Contracts"><font size="+3"><b>Contract Costing</b></font></a> -<br><br> +<br /><br /> <font size="+1"><b>Overview</b></font> -<br><br> +<br /><br /> The Contracts module allows for construction of costings for specific customer projects where a bill of materials to be taken from inventory for the contract can be defined, together with a costed list of other requirements. By entering a gross profit percentage figure a price can then be arrived at to charge the customer. The contract can then be converted to a quotation. While the contract is at the quotation stage it is possible to modify the stock components and other requirements - the quotation will be updated with the new costing on commital. The quotation can then be resubmitted to the customer. -<br><br> +<br /><br /> When a contract is converted to a quotation the system actually creates a manuafactured inventory item with the name of the contract refence and with the description from the contract description. -<br><br> +<br /><br /> When (if) the quotation is accepted by the customer, the quotation can be converted to an order in the usual way by modifying the quotation flag from quotation to order. Committing this change then changes the status of the contract to ordered so that changes are no longer allowed. This process also creates a work order so that stock required for the contract can be issued to it. By using the work order issue functionality the stock is reduced and work in progress is increased. -<br><br> +<br /><br /> When supplier invoices (accounts payable) are entered there is the option to specify the contract that is to be charged with the cost. The cost of contract charges also goes to the work in progress account (as determined from the stock category record of the contract). Any number of contract charges can be entered against a supplier invoice (or credit note). In entering contract charges there is also the possibility of flagging whether or not the charge was orignially envisaged and costed into the contract or not. Contract charges records are created for each entry. -<br><br> +<br /><br /> The original contract costing can be compared against the actual charges against the contract, to see how much was made on the contract. When all charges are entered against the contract it needs the status of the contract to be changed to complete. This process closes the work order and compares the original contract cost against actual costs and takes the value not charged to cost of sales to the usage variances account (based on the stock category of the contract item) and clears the balance that would otherwise be left in work in progress. -<br><br> +<br /><br /> <font size="+1"><b>Creating a New Contract</b></font> -<br><br> +<br /><br /> From the contract tab of the main menu, select Create Contract. The first step is to select the customer for whom the contract is for. -<br><br> +<br /><br /> The contract requires a reference up to 20 characters - without spaces, slashes or inverted commas - that will be used for the contract code. It must be unique from other contracts and also from any existing inventory item codes already in the system. A description of the contract is also required. The description can be any length and is a text field but will be truncated in the stockmaster to X characters when the contract is converted to a quotation. The description in the contract record is retained. -<br><br> +<br /><br /> Each contract must also specify the category - the existing inventory categories are displayed to select from but new categories can be created. It is important to realise that the posting for the general ledger is performed based on the general ledger codes set up against the inventory category selected. e.g. charges against the contract will be posted to the work in progress account against this inventory category and the usage variance account of this category will be used for any difference between the contract total cost and the original costing. -<br><br> +<br /><br /> The gross profit percentage entered is the factor used based on the cost to arrive at the contract price. -<br><br> +<br /><br /> The date that the customer requires the contract to be completed is also specified in the contract. This propogates through to the quotation and order. -<br><br> +<br /><br /> If the contract is for a customer that is invoiced in a foriegn currency the currency exchange rate can also be specified - it is defaulted based on the current table of exchange rates at the time the contract is created. -<br><br> +<br /><br /> There are two buttons on the contract setup page that allow the stock required for the contract to be specified and the requirments that are not stock items to be recorded. -<br><br> +<br /><br /> Entering the bill of materials for the contract is done from a screen that shows a stock selection options - it is possible to choose by stock category or search for individual items by code or description. The list of items matching the criteria entered displays and the quantity of each item required should be entered in the box next to the item. There is no limit to how many items can be selected. Once all the items from stock have been selected there is a button that brings back the contract details (Back to Contract Header). The contract screen will now show the bill of materials as selected and the cost of each together with the quantity of each required extending to the total value of all stock items required for the contract. -<br><br> +<br /><br /> Entering the other requirements is more straightforward as a new screen allows entry of descriptions of the other items required, the quantity of the item and the cost per unit of the items. Again, a button to go back to the contract header allows the user to switch back to the contract definition screen which will now show the other requirements listed and extended to arrive at the total cost. -<br><br> +<br /><br /> The sum of the cost of the bill of materials together with the total cost of the other requirements is shown as the total contract cost. This cost is used together with the GP % entered to work out the total contract cost. The GP% is the % of the total contract price that is profit - so 1 minus the GP% is % of the total contract price that is the cost. The calculation is therefore - contract total cost divided by (1 - the GP%). -<br><br> +<br /><br /> <font size="+1"><b>Selecting A Contract</b></font> -<br><br> +<br /><br /> From the Contracts tab of the main menu, Select Contract allows contracts for a specific customer to be selected, or contracts of a specific status. Contracts can have a status of: <ul> <li>Setup and defining requirements</li> @@ -46,24 +46,63 @@ <li>Closed - the contract has been completed and finished - the contract work order is closed so no more stock can be issued to it and no more charges can be made to it. through accounts payable</li> </ul> The contracts meeting the criteria specified are displayed with links to perform actions depending on its status. If the contract is quoted already there is a link to select the quotation for printing. If the quotation is ordered then there is a link to issue items to the contract work order. In all cases a link to open the contract definition is available. However, the option to modify the contract definition is disabled once the contract has been ordered by the customer. The contract definition can be modified until the contract quotation is converted to an order. This is done in the ususal way - selecting the quotation then changing the quotation flag from quote to order. When the changes are committed the contract work order is created and the requirements for the work order from the contract bill of materials are copied to a normal manufacturing bill of materials. It is not necessary to venture into the manufacturing functionality of webERP as all this is handled within the contract. Only the work order issues screen which comes up directly from the link on the contract selection screen once the contract is converted to a sales order. -<br><br> +<br /><br /> When the contract has been ordered by the customer a link is available to show the actual contract cost in comparison to the originally estimated costs. This screen shows the originally costed components and the other requirements costed into the total contract cost on the left side of the screen. On the right the actual inventory issued to the contract and the actual other costs entered through the supplier invoice entry screen. -<br><br> +<br /><br /> <font size="+1"><b>Entering Contract Costs</b></font> -<br><br> +<br /><br /> The act of issuing stock items to the contract work order, puts the cost of those items as contract costs. Issues to contract work orders is the same as issuing stock to any other work order. See work orders/manufacturing manual. A link to enter the inventory issued against the contract is provided from the contract selection screen. The general ledger entries created when stock is issued to a contract work order are to debit the work in progress account (from the stock category record of the contract item) and credit stock (from the stock account of the stock category record of the item being issued). -<br><br> +<br /><br /> Other contract costs are entered at the time of entering AP invoices or credit notes. There is an option on this screen to enter against a contract - in a similar way to entry against a shipment. It is possible to enter a supplier invoice against any number of contracts. The amount of the supplier invoice (or credit note) that is entered against contracts is posted in the general ledger to work in progress. Contract charges records are also created referring to the supplier invoice. To reverse contract charges, supplier credit notes have the exact opposite entries to supplier invoices. -<br><br> +<br /><br /> <font size="+1"><b>Closing Contracts</b></font> -<br><br> +<br /><br /> Open contracts continue to show on the contract selection screen until they are closed. When entering supplier invoices and credits they show in the drop down list as options for issuing costs against until they are closed. Open contracts also have entries created in the general ledger for work in progress for all the stock issued to them and other requirements charged against them through accounts payable. When the contract item is invoiced to the customer the stock is reduced by the costed amount of the contract and cost of sales is charged with this amount. This value may not actually be the final cost of the contract and the difference between the actual contract cost and the costed contract cost needs to be processed to usage variances in the general ledger, this is what closing the contract does. -<br><br> +<br /><br /> The process of closing the contract, compares the cost of the contract as invoiced to the customer against the costs issued to the contract (in work in progress) and creates a general ledger journal to the usage variance account (from the stock category record of the contract item). If the contract item is already invoiced to the customer and the contract work order as showing that the contract item has not yet been received against the work order then the work order receipt is processed. This receives a finished contract items against the contract work order. This process creates the general ledger postings to Debit the stock account (from the stock category record of the contract item) and credit the work in progress account. The amount of this journal is based on the original contract cost. -<br><br> +<br /><br /> At the end of the contract closing process, the contract work order has the contract item received against it and the work order is then closed. In addition the work in progress account is cleared so that all entries for issues of stock and other costs to the contract are contra'd by the receipt of the contract item and any variance posting. -<br><br> +<br /><br /> Using the contract closing option from the Contract Costing screen thus avoids any requirement to venture into the manufacturing module at all. Since, (if it has not been done through the manufacturing module - which is checked first) the finished contract item is received against the work order and the contract work order is closed. The status of the contract is also updated to closed. -<br><br> +<br /><br /> Once a contract is closed it is no longer possible to issue costs against it either in the form of inventory or other charges. However, it is still possible to inspect the original contract costing and the actual costs that were issued against it. This is done from the contract selection screen - where completed contracts can be specified - the link to the contract costing will show. +<br /><br /> +<font size="+1"><b>Contract Process Flow Summary</b></font> +<br /><br /> +The process with contracts is as follows: +<ul> +<li>1. Discussion with customer</li> +<li>2. Create contract costing - with all requirements, both external costs and stock required</li> +<li>3. Produce the quotation for customer based on the contract costing created</li> +<li>4. If the quotation is accepted by the customer turn the quotation to a sales order - this initates the contract costing</li> +<li>5. Issue stock to the contract</li> +<li>6. Enter supplier invoices against the contract</li> +<li>7. When the contract has been delivered to the customer, recieve the contract item against the contract work order. If the contract is closed through the contract costing screen, this step happens automatically.</li> +<li>8. Invoice the contract item to the customer</li> +<li>9. Complete the contract costing - to take any variances and clear the work in progress account where the variances sit until the contract is closed</li> +</ul> +<br /><br /> +<font size="+1"><b>Contract Costing General Ledger Impact Summary</b></font> +<br /><br /> +When cost is allocated from a supplier invoice, the cost is debited to the work in progress account of the stock category of the contract - credit to creditors control. +<br /><br /> +When the contract item is received against the contract works order, the entry is : +DR stock +<br />CR WIP +<br />based on the stock category of the contract. +<br /><br /> +When the contract item is sold then it is like selling any other item +DR cost of sales - from the COGS GL posting table +<br />CR stock - from the stock category of the contract item +<br /><br /> +When you issue stock to a contract the entries are: +<br /><br /> +DR WIP - from the stock category of the contract item +<br />CR stock - from the stock category of the issued items +<br /><br /> +When you close a contract the variance against the consted contract is taken to account - the entries are: +<br /><br /> +DR/CR WIP of the stock category of the contract item - to clear WIP in relation to the +<br />DR/CR usage variance of the stock category of the contract item + <!-- Help End: Contracts --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-13 08:28:51
|
Revision: 4509 http://web-erp.svn.sourceforge.net/web-erp/?rev=4509&view=rev Author: daintree Date: 2011-03-13 08:28:44 +0000 (Sun, 13 Mar 2011) Log Message: ----------- add to contract manual Modified Paths: -------------- trunk/doc/Change.log.html trunk/doc/Manual/ManualContracts.html Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-13 04:55:32 UTC (rev 4508) +++ trunk/doc/Change.log.html 2011-03-13 08:28:44 UTC (rev 4509) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>12/3/11: Tim Now allow space in codes </p> <p>12/3/11: SelectSalesOrder.php now allows any number of sales orders to be selected and purchase orders placed for the aggregate of items on the selected sales orders</p> <p>12/3/11: SuppPriceList.php removed a round trip to DB to get currency - fixed function to get pdf to new TCPDF Output </p> <p>12/3/11: Exson fix all htmlentities to use ENTQUOTES, 'UTF-8' option so other character sets work with it</p> Modified: trunk/doc/Manual/ManualContracts.html =================================================================== --- trunk/doc/Manual/ManualContracts.html 2011-03-13 04:55:32 UTC (rev 4508) +++ trunk/doc/Manual/ManualContracts.html 2011-03-13 08:28:44 UTC (rev 4509) @@ -1,43 +1,43 @@ <!-- Help Begin: Contracts --> -<br><br> +<br /><br /> <a name="Contracts"><font size="+3"><b>Contract Costing</b></font></a> -<br><br> +<br /><br /> <font size="+1"><b>Overview</b></font> -<br><br> +<br /><br /> The Contracts module allows for construction of costings for specific customer projects where a bill of materials to be taken from inventory for the contract can be defined, together with a costed list of other requirements. By entering a gross profit percentage figure a price can then be arrived at to charge the customer. The contract can then be converted to a quotation. While the contract is at the quotation stage it is possible to modify the stock components and other requirements - the quotation will be updated with the new costing on commital. The quotation can then be resubmitted to the customer. -<br><br> +<br /><br /> When a contract is converted to a quotation the system actually creates a manuafactured inventory item with the name of the contract refence and with the description from the contract description. -<br><br> +<br /><br /> When (if) the quotation is accepted by the customer, the quotation can be converted to an order in the usual way by modifying the quotation flag from quotation to order. Committing this change then changes the status of the contract to ordered so that changes are no longer allowed. This process also creates a work order so that stock required for the contract can be issued to it. By using the work order issue functionality the stock is reduced and work in progress is increased. -<br><br> +<br /><br /> When supplier invoices (accounts payable) are entered there is the option to specify the contract that is to be charged with the cost. The cost of contract charges also goes to the work in progress account (as determined from the stock category record of the contract). Any number of contract charges can be entered against a supplier invoice (or credit note). In entering contract charges there is also the possibility of flagging whether or not the charge was orignially envisaged and costed into the contract or not. Contract charges records are created for each entry. -<br><br> +<br /><br /> The original contract costing can be compared against the actual charges against the contract, to see how much was made on the contract. When all charges are entered against the contract it needs the status of the contract to be changed to complete. This process closes the work order and compares the original contract cost against actual costs and takes the value not charged to cost of sales to the usage variances account (based on the stock category of the contract item) and clears the balance that would otherwise be left in work in progress. -<br><br> +<br /><br /> <font size="+1"><b>Creating a New Contract</b></font> -<br><br> +<br /><br /> From the contract tab of the main menu, select Create Contract. The first step is to select the customer for whom the contract is for. -<br><br> +<br /><br /> The contract requires a reference up to 20 characters - without spaces, slashes or inverted commas - that will be used for the contract code. It must be unique from other contracts and also from any existing inventory item codes already in the system. A description of the contract is also required. The description can be any length and is a text field but will be truncated in the stockmaster to X characters when the contract is converted to a quotation. The description in the contract record is retained. -<br><br> +<br /><br /> Each contract must also specify the category - the existing inventory categories are displayed to select from but new categories can be created. It is important to realise that the posting for the general ledger is performed based on the general ledger codes set up against the inventory category selected. e.g. charges against the contract will be posted to the work in progress account against this inventory category and the usage variance account of this category will be used for any difference between the contract total cost and the original costing. -<br><br> +<br /><br /> The gross profit percentage entered is the factor used based on the cost to arrive at the contract price. -<br><br> +<br /><br /> The date that the customer requires the contract to be completed is also specified in the contract. This propogates through to the quotation and order. -<br><br> +<br /><br /> If the contract is for a customer that is invoiced in a foriegn currency the currency exchange rate can also be specified - it is defaulted based on the current table of exchange rates at the time the contract is created. -<br><br> +<br /><br /> There are two buttons on the contract setup page that allow the stock required for the contract to be specified and the requirments that are not stock items to be recorded. -<br><br> +<br /><br /> Entering the bill of materials for the contract is done from a screen that shows a stock selection options - it is possible to choose by stock category or search for individual items by code or description. The list of items matching the criteria entered displays and the quantity of each item required should be entered in the box next to the item. There is no limit to how many items can be selected. Once all the items from stock have been selected there is a button that brings back the contract details (Back to Contract Header). The contract screen will now show the bill of materials as selected and the cost of each together with the quantity of each required extending to the total value of all stock items required for the contract. -<br><br> +<br /><br /> Entering the other requirements is more straightforward as a new screen allows entry of descriptions of the other items required, the quantity of the item and the cost per unit of the items. Again, a button to go back to the contract header allows the user to switch back to the contract definition screen which will now show the other requirements listed and extended to arrive at the total cost. -<br><br> +<br /><br /> The sum of the cost of the bill of materials together with the total cost of the other requirements is shown as the total contract cost. This cost is used together with the GP % entered to work out the total contract cost. The GP% is the % of the total contract price that is profit - so 1 minus the GP% is % of the total contract price that is the cost. The calculation is therefore - contract total cost divided by (1 - the GP%). -<br><br> +<br /><br /> <font size="+1"><b>Selecting A Contract</b></font> -<br><br> +<br /><br /> From the Contracts tab of the main menu, Select Contract allows contracts for a specific customer to be selected, or contracts of a specific status. Contracts can have a status of: <ul> <li>Setup and defining requirements</li> @@ -46,24 +46,63 @@ <li>Closed - the contract has been completed and finished - the contract work order is closed so no more stock can be issued to it and no more charges can be made to it. through accounts payable</li> </ul> The contracts meeting the criteria specified are displayed with links to perform actions depending on its status. If the contract is quoted already there is a link to select the quotation for printing. If the quotation is ordered then there is a link to issue items to the contract work order. In all cases a link to open the contract definition is available. However, the option to modify the contract definition is disabled once the contract has been ordered by the customer. The contract definition can be modified until the contract quotation is converted to an order. This is done in the ususal way - selecting the quotation then changing the quotation flag from quote to order. When the changes are committed the contract work order is created and the requirements for the work order from the contract bill of materials are copied to a normal manufacturing bill of materials. It is not necessary to venture into the manufacturing functionality of webERP as all this is handled within the contract. Only the work order issues screen which comes up directly from the link on the contract selection screen once the contract is converted to a sales order. -<br><br> +<br /><br /> When the contract has been ordered by the customer a link is available to show the actual contract cost in comparison to the originally estimated costs. This screen shows the originally costed components and the other requirements costed into the total contract cost on the left side of the screen. On the right the actual inventory issued to the contract and the actual other costs entered through the supplier invoice entry screen. -<br><br> +<br /><br /> <font size="+1"><b>Entering Contract Costs</b></font> -<br><br> +<br /><br /> The act of issuing stock items to the contract work order, puts the cost of those items as contract costs. Issues to contract work orders is the same as issuing stock to any other work order. See work orders/manufacturing manual. A link to enter the inventory issued against the contract is provided from the contract selection screen. The general ledger entries created when stock is issued to a contract work order are to debit the work in progress account (from the stock category record of the contract item) and credit stock (from the stock account of the stock category record of the item being issued). -<br><br> +<br /><br /> Other contract costs are entered at the time of entering AP invoices or credit notes. There is an option on this screen to enter against a contract - in a similar way to entry against a shipment. It is possible to enter a supplier invoice against any number of contracts. The amount of the supplier invoice (or credit note) that is entered against contracts is posted in the general ledger to work in progress. Contract charges records are also created referring to the supplier invoice. To reverse contract charges, supplier credit notes have the exact opposite entries to supplier invoices. -<br><br> +<br /><br /> <font size="+1"><b>Closing Contracts</b></font> -<br><br> +<br /><br /> Open contracts continue to show on the contract selection screen until they are closed. When entering supplier invoices and credits they show in the drop down list as options for issuing costs against until they are closed. Open contracts also have entries created in the general ledger for work in progress for all the stock issued to them and other requirements charged against them through accounts payable. When the contract item is invoiced to the customer the stock is reduced by the costed amount of the contract and cost of sales is charged with this amount. This value may not actually be the final cost of the contract and the difference between the actual contract cost and the costed contract cost needs to be processed to usage variances in the general ledger, this is what closing the contract does. -<br><br> +<br /><br /> The process of closing the contract, compares the cost of the contract as invoiced to the customer against the costs issued to the contract (in work in progress) and creates a general ledger journal to the usage variance account (from the stock category record of the contract item). If the contract item is already invoiced to the customer and the contract work order as showing that the contract item has not yet been received against the work order then the work order receipt is processed. This receives a finished contract items against the contract work order. This process creates the general ledger postings to Debit the stock account (from the stock category record of the contract item) and credit the work in progress account. The amount of this journal is based on the original contract cost. -<br><br> +<br /><br /> At the end of the contract closing process, the contract work order has the contract item received against it and the work order is then closed. In addition the work in progress account is cleared so that all entries for issues of stock and other costs to the contract are contra'd by the receipt of the contract item and any variance posting. -<br><br> +<br /><br /> Using the contract closing option from the Contract Costing screen thus avoids any requirement to venture into the manufacturing module at all. Since, (if it has not been done through the manufacturing module - which is checked first) the finished contract item is received against the work order and the contract work order is closed. The status of the contract is also updated to closed. -<br><br> +<br /><br /> Once a contract is closed it is no longer possible to issue costs against it either in the form of inventory or other charges. However, it is still possible to inspect the original contract costing and the actual costs that were issued against it. This is done from the contract selection screen - where completed contracts can be specified - the link to the contract costing will show. +<br /><br /> +<font size="+1"><b>Contract Process Flow Summary</b></font> +<br /><br /> +The process with contracts is as follows: +<ul> +<li>1. Discussion with customer</li> +<li>2. Create contract costing - with all requirements, both external costs and stock required</li> +<li>3. Produce the quotation for customer based on the contract costing created</li> +<li>4. If the quotation is accepted by the customer turn the quotation to a sales order - this initates the contract costing</li> +<li>5. Issue stock to the contract</li> +<li>6. Enter supplier invoices against the contract</li> +<li>7. When the contract has been delivered to the customer, recieve the contract item against the contract work order. If the contract is closed through the contract costing screen, this step happens automatically.</li> +<li>8. Invoice the contract item to the customer</li> +<li>9. Complete the contract costing - to take any variances and clear the work in progress account where the variances sit until the contract is closed</li> +</ul> +<br /><br /> +<font size="+1"><b>Contract Costing General Ledger Impact Summary</b></font> +<br /><br /> +When cost is allocated from a supplier invoice, the cost is debited to the work in progress account of the stock category of the contract - credit to creditors control. +<br /><br /> +When the contract item is received against the contract works order, the entry is : +DR stock +<br />CR WIP +<br />based on the stock category of the contract. +<br /><br /> +When the contract item is sold then it is like selling any other item +DR cost of sales - from the COGS GL posting table +<br />CR stock - from the stock category of the contract item +<br /><br /> +When you issue stock to a contract the entries are: +<br /><br /> +DR WIP - from the stock category of the contract item +<br />CR stock - from the stock category of the issued items +<br /><br /> +When you close a contract the variance against the consted contract is taken to account - the entries are: +<br /><br /> +DR/CR WIP of the stock category of the contract item - to clear WIP in relation to the +<br />DR/CR usage variance of the stock category of the contract item + <!-- Help End: Contracts --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-13 04:55:40
|
Revision: 4508 http://web-erp.svn.sourceforge.net/web-erp/?rev=4508&view=rev Author: daintree Date: 2011-03-13 04:55:32 +0000 (Sun, 13 Mar 2011) Log Message: ----------- various Modified Paths: -------------- trunk/SelectSalesOrder.php trunk/Stocks.php trunk/SuppPriceList.php trunk/doc/Change.log.html trunk/includes/ConnectDB.inc trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/SelectSalesOrder.php =================================================================== --- trunk/SelectSalesOrder.php 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/SelectSalesOrder.php 2011-03-13 04:55:32 UTC (rev 4508) @@ -8,10 +8,11 @@ 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++){ - if ($_POST['PlacePO_' . $i]== 'on') { + if (isset($_POST['PlacePO_' . $i])) { //checkboxes only set if they are checked if ($OrdersToPlacePOFor==''){ $OrdersToPlacePOFor .= ' orderno=' . $_POST['OrderNo_PO_'.$i]; } else { @@ -30,13 +31,17 @@ purchdata.supplierdescription, purchdata.conversionfactor, purchdata.leadtime, + purchdata.suppliersuom, stockmaster.kgs, - stockmaster.cuft - SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS OrderQty + 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 . ") @@ -47,223 +52,213 @@ purchdata.supplierdescription, purchdata.conversionfactor, purchdata.leadtime, + purchdata.suppliersuom, stockmaster.kgs, - stockmaster.cuft + 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); - /*Now get the default delivery address details from the users default stock location */ - $sql = "SELECT locationame, - 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>'; + 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 { - $UserDetails = ' ' . $_SESSION['UsersRealName'] . ' '; - } - - while ($ItemRow = DB_fetch_array($ItemResult)){ + /*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'] . "'"; + $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); - 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 */ + $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 !='' AND $_SESSION['AutoAuthorisePO']==1) { - //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']."'"; - - $AuthResult=DB_query($AuthSQL,$db); - $AuthRow=DB_fetch_array($AuthResult); - - 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', - statuscomment='" . $StatusComment . "' - WHERE orderno='" . $OrderNo . "'", - $db); - } 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 />'; + 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 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']."'"; + + $AuthResult=DB_query($AuthSQL,$db); + $AuthRow=DB_fetch_array($AuthResult); + + 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', + statuscomment='" . $StatusComment . "' + WHERE orderno='" . $OrderNo . "'", + $db); + } 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 - 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'); + if ($SupplierID !=''){ //then we have just added a purchase order + echo '<p>'; + prnMsg(_('Purchase Order') . ' ' . $PO_OrderNo . ' ' . _('on') . ' ' . $ItemRow['supplierno'] . ' ' . _('has been created'),'success'); + DB_Txn_Commit($db); } - } //end of authorisation status settings + /*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 . "'"; + + $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)"; + + $ErrMsg = _('The purchase order header record could not be inserted into the database because'); + $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + } //end if it's a new supplier and PO to create - if ($SupplierID !=''){ //then we have just added a purchase order - DB_Txn_Commit($db); - } - /*Starting a new purchase order with a different supplier */ - $result = DB_Txn_Begin($db); - $OrderNo = GetNextTransNo(18, $db); //get the next PO number + /*reminder we are in a loop of the total of each item to place a purchase order for based on a selection of sales orders */ + $DeliveryDate = DateAdd(Date($_SESSION['DefaultDateFormat']),'d',$ItemRow['leadtime']); + $sql = "INSERT INTO purchorderdetails ( orderno, + itemcode, + deliverydate, + itemdescription, + glcode, + unitprice, + quantityord, + suppliersunit, + suppliers_partno, + kgs, + cuft, + conversionfactor ) + VALUES ( + '" . $PO_OrderNo . "', + '" . $ItemRow['stockid'] . "', + '" . FormatDateForSQL($DeliveryDate) . "', + '" . $ItemRow['suppliers_partno'] . ' ' . $ItemRow['supplierdescription'] . "', + '" . $ItemRow['stockact'] . "', + '" . $ItemRow['price'] . "', + '" . $ItemRow['orderqty'] . "', + '" . $ItemRow['suppliersuom'] . "', + '" . $ItemRow['suppliers_partno'] . "', + '" . $ItemRow['kgs'] . "', + '" . $ItemRow['volume'] . "', + '" . $ItemRow['conversionfactor'] . "')"; + $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); + $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); - $SupplierID = $ItemRow['supplierno']; - $Order_Value =0; - /*Now get all the required details for the supplier */ - $sql = "SELECT address1, - address2, - address3, - address4, - address5, - address6, - suppliercontact, - telephone, - paymentterms, - currcode, - rate - FROM suppliers INNER JOIN currencies - ON suppliers.currcode = currencies.currabrev - WHERE supplierno='" . $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( '" . $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)"; - - $ErrMsg = _('The purchase order header record could not be inserted into the database because'); - $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - - /*Insert the purchase order detail records */ - foreach ($_SESSION['PO'.$identifier]->LineItems as $POLine) { - if ($POLine->Deleted==False) { - $sql = "INSERT INTO purchorderdetails ( orderno, - itemcode, - deliverydate, - itemdescription, - glcode, - unitprice, - quantityord, - shiptref, - jobref, - itemno, - suppliersunit, - suppliers_partno, - subtotal_amount, - package, - pcunit, - netweight, - kgs, - cuft, - total_quantity, - total_amount, - assetid, - conversionfactor ) - VALUES ( - '" . $_SESSION['PO'.$identifier]->OrderNo . "', - '" . $POLine->StockID . "', - '" . FormatDateForSQL($POLine->ReqDelDate) . "', - '" . $POLine->ItemDescription . "', - '" . $POLine->GLCode . "', - '" . $POLine->Price . "', - '" . $POLine->Quantity . "', - '" . $POLine->ShiptRef . "', - '" . $POLine->JobRef . "', - '" . $POLine->ItemNo . "', - '" . $POLine->SuppliersUnit . "', - '" . $POLine->Suppliers_PartNo . "', - '" . $POLine->SubTotal_Amount . "', - '" . $POLine->Package . "', - '" . $POLine->PcUnit . "', - '" . $POLine->NetWeight . "', - '" . $POLine->KGs . "', - '" . $POLine->CuFt . "', - '" . $POLine->Total_Quantity . "', - '" . $POLine->Total_Amount . "', - '" . $POLine->AssetID . "', - '" . $POLine->ConversionFactor . "')"; - $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); - $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); - - $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - } - } /* end of the loop round the detail line items on the order */ + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + $Order_Value += ($ItemRow['price']*$ItemRow['orderqty']); + } /* end of the loop round the items on the sales order that we wish to place purchase orders for */ + if ($SupplierID !=''){ //then we have just added a purchase order echo '<p>'; - prnMsg(_('Purchase Order') . ' ' . $_SESSION['PO'.$identifier]->OrderNo . ' ' . _('on') . ' ' . - $_SESSION['PO'.$identifier]->SupplierName . ' ' . _('has been created'),'success'); - } - } + prnMsg(_('Purchase Order') . ' ' . $PO_OrderNo . ' ' . _('on') . ' ' . $ItemRow['supplierno'] . ' ' . _('has been created'),'success'); + DB_Txn_Commit($db); + } + $result = DB_query("UPDATE salesorders SET poplaced=1 WHERE " . $OrdersToPlacePOFor,$db); + }/*There were items that had purchasing data set up to create POs for */ + } /* there were sales orders checked to place POs for */ }/*end of purchase order creation code */ /* ******************************************************************************************* */ @@ -389,14 +384,14 @@ while ($myrow=DB_fetch_array($resultStkLocs)){ if (isset($_POST['StockLocation'])){ if ($myrow['loccode'] == $_POST['StockLocation']){ - echo "<option selected Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } else { - echo "<option Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']. '</option>'; } } elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){ - echo "<option selected Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname']. '</option>'; } else { - echo "<option Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']. '</option>'; } } @@ -416,7 +411,7 @@ } echo '</select> </td><td>'; - echo "<input type=submit name='SearchOrders' VALUE='" . _('Search') . "'></td>"; + echo '<input type=submit name="SearchOrders" VALUE="' . _('Search') . '"></td>'; echo ' <td><a href="' . $rootpath . '/SelectOrderItems.php?' . SID . '&NewOrder=Yes">' . _('Add Sales Order') . '</a></td></tr></table>'; } @@ -428,16 +423,15 @@ $result1 = DB_query($SQL,$db); - echo "</font>"; - echo "<br /><table class=selection>"; + echo '<br /><table class="selection">'; echo '<tr><th colspan=6><font size=3 color=navy>' . _('To search for sales orders for a specific part use the part selection facilities below'); echo '</th></tr>'; - echo "<tr> - <td><font size=1>" . _('Select a stock category') . ":</font> - <select name='StockCat'>"; + echo '<tr> + <td><font size="1">' . _('Select a stock category') . ':</font> + <select name="StockCat">'; while ($myrow1 = DB_fetch_array($result1)) { - echo "<option VALUE='". $myrow1['categoryid'] . "'>" . $myrow1['categorydescription']; + echo '<option value="'. $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; } echo '</select> @@ -455,12 +449,12 @@ if (isset($StockItemsResult) and DB_num_rows($StockItemsResult)>0) { echo '<table cellpadding=2 colspan=7 class=selection>'; - $TableHeader = "<tr> - <th>" . _('Code') . "</th> - <th>" . _('Description') . "</th> - <th>" . _('On Hand') . "</th> - <th>" . _('Units') . "</th> - </tr>"; + $TableHeader = '<tr> + <th>' . _('Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('On Hand') . '</th> + <th>' . _('Units') . '</th> + </tr>'; echo $TableHeader; $j = 1; @@ -502,7 +496,7 @@ else { //figure out the SQL required from the inputs available - if (isset($_POST['Quotations']) and $_POST['Quotations']=='Orders_Only'){ + if (isset($_POST['Quotations']) AND $_POST['Quotations']=='Orders_Only'){ $Quotations = 0; } else { $Quotations =1; @@ -519,6 +513,7 @@ salesorders.deliverydate, salesorders.deliverto, salesorders.printedpackingslip, + salesorders.poplaced, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -553,7 +548,8 @@ salesorders.orddate, salesorders.deliverydate, salesorders.deliverto, - salesorders.printedpackingslip, + salesorders.printedpackingslip, + salesorders.poplaced, salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent) AS ordervalue FROM salesorders, salesorderdetails, @@ -578,7 +574,8 @@ salesorders.customerref, salesorders.orddate, salesorders.deliverto, - salesorders.printedpackingslip, + salesorders.printedpackingslip, + salesorders.poplaced, salesorders.deliverydate, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -612,6 +609,7 @@ salesorders.orddate, salesorders.deliverto, salesorders.printedpackingslip, + salesorders.poplaced, salesorders.deliverydate, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -642,7 +640,8 @@ salesorders.orddate, salesorders.deliverto, salesorders.deliverydate, - salesorders.printedpackingslip, + salesorders.printedpackingslip, + salesorders.poplaced, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -676,9 +675,9 @@ if (DB_num_rows($SalesOrdersResult)>0) { /* Get users authority to place POs */ - $AuthSql="SELECT cancreate - FROM purchorderauth - WHERE userid='". $_SESSION['UserID'] . "'"; + $AuthSQL="SELECT cancreate + FROM purchorderauth + WHERE userid='". $_SESSION['UserID'] . "'"; /*we don't know what currency these orders might be in but if no authority at all then don't show option*/ $AuthResult=DB_query($AuthSQL,$db); @@ -718,7 +717,7 @@ } echo $tableheader; - } + $i = 1; $j = 1; $k=0; //row colour counter @@ -733,120 +732,120 @@ $k++; } - $ModifyPage = $rootpath . "/SelectOrderItems.php?" . SID . '&ModifyOrderNumber=' . $myrow['orderno']; - $Confirm_Invoice = $rootpath . '/ConfirmDispatch_Invoice.php?' . SID . '&OrderNumber=' .$myrow['orderno']; - - if ($_SESSION['PackNoteFormat']==1){ /*Laser printed A4 default */ - $PrintDispatchNote = $rootpath . '/PrintCustOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; - } else { /*pre-printed stationery default */ - $PrintDispatchNote = $rootpath . '/PrintCustOrder.php?' . SID . '&TransNo=' . $myrow['orderno']; + $ModifyPage = $rootpath . "/SelectOrderItems.php?" . SID . '&ModifyOrderNumber=' . $myrow['orderno']; + $Confirm_Invoice = $rootpath . '/ConfirmDispatch_Invoice.php?' . SID . '&OrderNumber=' .$myrow['orderno']; + + if ($_SESSION['PackNoteFormat']==1){ /*Laser printed A4 default */ + $PrintDispatchNote = $rootpath . '/PrintCustOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; + } else { /*pre-printed stationery default */ + $PrintDispatchNote = $rootpath . '/PrintCustOrder.php?' . SID . '&TransNo=' . $myrow['orderno']; + } + $PrintSalesOrder = $rootpath . '/PrintSalesOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; + $PrintQuotation = $rootpath . '/PDFQuotation.php?' . SID . '&QuotationNo=' . $myrow['orderno']; + $FormatedDelDate = ConvertSQLDate($myrow['deliverydate']); + $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); + $FormatedOrderValue = number_format($myrow['ordervalue'],2); + + if ($myrow['printedpackingslip']==0) { + $PrintText = _('Print'); + } else { + $PrintText = _('Reprint'); + } + + if ($_POST['Quotations']=='Orders_Only'){ + + /*Check authority to create POs if user has authority then show the check boxes to select sales orders to place POs for otherwise don't provide this option */ + if ($AuthRow['cancreate']==0 AND $myrow['poplaced']==0){ //cancreate==0 if the user can create POs and not already placed + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . _('Invoice') . "</a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + <td><input type=checkbox name=PlacePO_%s value><input type=hidden name=OrderNo_PO_%s value=%s></td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $Confirm_Invoice, + $PrintDispatchNote, + $PrintSalesOrder, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue, + $i, + $i, + $myrow['orderno']); + } else { /*User is not authorised to create POs so don't even show the option */ + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . _('Invoice') . "</a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $Confirm_Invoice, + $PrintDispatchNote, + $PrintSalesOrder, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue); + } + + } else { /*must be quotes only */ + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . $PrintText . "</a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $PrintQuotation, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue); + } + $i++; + $j++; + if ($j == 12){ + $j=1; + echo $tableheader; + } + //end of page full new headings if + }//end while loop through orders to display + if ($_POST['Quotations']=='Orders_Only' AND $AuthRow['cancreate']==0){ //cancreate==0 means can create POs + echo '<tr><td colspan="10"><td><td colspan="2"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; } - $PrintSalesOrder = $rootpath . '/PrintSalesOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; - $PrintQuotation = $rootpath . '/PDFQuotation.php?' . SID . '&QuotationNo=' . $myrow['orderno']; - $FormatedDelDate = ConvertSQLDate($myrow['deliverydate']); - $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); - $FormatedOrderValue = number_format($myrow['ordervalue'],2); - - if ($myrow['printedpackingslip']==0) { - $PrintText = _('Print'); - } else { - $PrintText = _('Reprint'); - } - - if ($_POST['Quotations']=='Orders_Only'){ - - /*Check authority to create POs if user has authority then show the check boxes to select sales orders to place POs for otherwise don't provide this option */ - if ($AuthRow['cancreate']==0){ //cancreate==0 if the user can create POs - printf("<td><a href='%s'>%s</a></td> - <td><a href='%s'>" . _('Invoice') . "</a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - <td><input type=checkbox name=PlacePO_%s><input type=hidden name=OrderNo_PO_%s value=%s></td> - </tr>", - $ModifyPage, - $myrow['orderno'], - $Confirm_Invoice, - $PrintDispatchNote, - $PrintSalesOrder, - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $FormatedOrderDate, - $FormatedDelDate, - $myrow['deliverto'], - $FormatedOrderValue, - $i, - $i, - $myrow['orderno']); - } else { /*User is not authorised to create POs so don't even show the option */ - printf("<td><a href='%s'>%s</a></td> - <td><a href='%s'>" . _('Invoice') . "</a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - </tr>", - $ModifyPage, - $myrow['orderno'], - $Confirm_Invoice, - $PrintDispatchNote, - $PrintSalesOrder, - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $FormatedOrderDate, - $FormatedDelDate, - $myrow['deliverto'], - $FormatedOrderValue); - } - - } else { /*must be quotes only */ - printf("<td><a href='%s'>%s</a></td> - <td><a href='%s'>" . $PrintText . "</a></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - </tr>", - $ModifyPage, - $myrow['orderno'], - $PrintQuotation, - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $FormatedOrderDate, - $FormatedDelDate, - $myrow['deliverto'], - $FormatedOrderValue); - } - $i++; - $j++; - if ($j == 12){ - $j=1; - echo $tableheader; - } - //end of page full new headings if - } - //end of while loop - if ($_POST['Quotations']=='Orders_Only' AND $AuthRow['cancreate']==0){ //cancreate==0 means can create POs - echo '<tr><td colspan="10"><td><td colspan="2"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; - } - echo '</table>'; + echo '</table>'; + } //end if there are some orders to show } ?> Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/Stocks.php 2011-03-13 04:55:32 UTC (rev 4508) @@ -477,7 +477,7 @@ prnMsg( _('Cannot delete this item record because there are bills of material that require this part as a component'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('bills of material that require this part as a component'); } else { - $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."' GROUP BY stockid"; + $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."' GROUP BY stkcode"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -493,7 +493,7 @@ prnMsg(_('Cannot delete this item because sales analysis records exist for it'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales analysis records against this part'); } else { - $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."' GROUP BY stockid"; + $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."' GROUP BY itemcode"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { Modified: trunk/SuppPriceList.php =================================================================== --- trunk/SuppPriceList.php 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/SuppPriceList.php 2011-03-13 04:55:32 UTC (rev 4508) @@ -21,10 +21,11 @@ $line_height=12; //get supplier - $sqlsup = "SELECT suppname FROM suppliers where supplierid='" . $_POST['supplier'] . "'"; + $sqlsup = "SELECT suppname, currcode FROM suppliers where supplierid='" . $_POST['supplier'] . "'"; $resultsup = db_query($sqlsup,$db); - $RowSup = db_fetch_row($resultsup); - $Supp=$RowSup['0']; + $RowSup = db_fetch_array($resultsup); + $SupplierName=$RowSup['suppname']; + $CurrCode =$RowSup['currcode']; //get category if ($_POST['category']!="all"){ @@ -36,26 +37,22 @@ $Categoryname="ALL"; } - //get currency - $sqlcur="SELECT currcode FROM `suppliers` where supplierid='" . $_POST['supplier'] . "'"; - $resultcur = db_query($sqlcur,$db); - $RowCur = db_fetch_row($resultcur); - $Currency=$RowCur['0']; - + //get date price - if ($_POST['price']=="all"){ - $DatePrice=_('All Price'); + if ($_POST['price']=='all'){ + $DatePrice=_('All Prices'); } else { $DatePrice=_('Current Price'); } //price and category = all - if (($_POST['price']=="all")and($_POST['category']=="all")){ + if (($_POST['price']=='all')and($_POST['category']=='all')){ $sql = "SELECT purchdata.stockid, stockmaster.description, purchdata.price, (purchdata.effectivefrom)as dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata,stockmaster WHERE supplierno='" . $_POST['supplier'] . "' AND stockmaster.stockid=purchdata.stockid @@ -72,7 +69,8 @@ WHERE purchdata.stockid = stockmaster.stockid ORDER BY effectivefrom DESC LIMIT 0,1) AS dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata, stockmaster WHERE supplierno = '" . $_POST['supplier'] . "' AND stockmaster.stockid = purchdata.stockid @@ -86,7 +84,8 @@ stockmaster.description, purchdata.price, (purchdata.effectivefrom)as dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata,stockmaster WHERE supplierno='" . $_POST['supplier'] . "' AND stockmaster.stockid=purchdata.stockid @@ -102,7 +101,8 @@ WHERE purchdata.stockid = stockmaster.stockid ORDER BY effectivefrom DESC LIMIT 0,1) AS dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata,stockmaster WHERE supplierno='" . $_POST['supplier'] . "' AND stockmaster.stockid=purchdata.stockid @@ -127,7 +127,7 @@ } PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin, - $Page_Width,$Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice); + $Page_Width,$Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice); $FontSize=8; $code=''; @@ -148,26 +148,26 @@ $dateprice=date($_SESSION['DefaultDateFormat'], mktime(0,0,0,$DateArray[1],$DateArray[2],$DateArray[0])); //if item has more than 1 price, write only price, date and supplier code for the old ones - if ($code==$myrow[0]){ + if ($code==$myrow['stockid']){ - $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow[2],2),'right'); + $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow['price'],2),'right'); $pdf->addTextWrap(430,$YPos,50,$FontSize,$dateprice,'left'); - $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow[4],'left'); - $code=$myrow[0]; + $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow['suppliers_partno'],'left'); + $code=$myrow['stockid']; } else { - $code=$myrow[0]; - $pdf->addTextWrap(50,$YPos,90,$FontSize,$myrow[0],'left'); - $pdf->addTextWrap(145,$YPos,215,$FontSize,$myrow[1],'left'); - $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow[2],2),'right'); + $code=$myrow['stockid']; + $pdf->addTextWrap(50,$YPos,90,$FontSize,$myrow['stockid'],'left'); + $pdf->addTextWrap(145,$YPos,215,$FontSize,$myrow['description'],'left'); + $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow['price'],2),'right'); $pdf->addTextWrap(430,$YPos,50,$FontSize,$dateprice,'left'); - $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow[4],'left'); + $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow['suppliers_partno'],'left'); } if ($YPos < $Bottom_Margin + $line_height){ PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, - $Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice); + $Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice); } @@ -176,22 +176,13 @@ if ($YPos < $Bottom_Margin + $line_height){ PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, - $Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice); + $Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice); } + + $pdf->OutputD( $_SESSION['DatabaseName'] . '_SupplierPriceList_' . Date('Y-m-d') . '.pdf'); + - $pdfcode = $pdf->output(); - - header('Content-type: application/pdf'); - header("Content-Length: " . $len); - header('Content-Disposition: inline; filename=Supplier Price List.pdf'); - header('Expires: 0'); - header('Cache-Control: private, post-check=0, pre-check=0'); - header('Pragma: public'); - $pdf->Output('SuppPriceList.pdf', 'I'); - - - } else { /*The option to print PDF was not hit so display form */ $title=_('Supplier Price List'); @@ -229,8 +220,8 @@ echo '</select></td></tr>'; echo '<tr><td>' . _('Price List') . ':</td><td><select name="price"> '; - echo '<option Value="all">' ._('All Prices').''; - echo '<option Value="current">' ._('Only Current Price').''; + echo '<option Value="all">' ._('All Prices').'</option>'; + echo '<option Value="current">' ._('Only Current Price').'</option>'; echo '</select></td></tr>'; @@ -243,7 +234,7 @@ function PrintHeader(&$pdf,&$YPos,&$PageNumber,$Page_Height,$Top_Margin,$Left_Margin, - $Page_Width,$Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice) { + $Page_Width,$Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice) { /*PDF page header for Supplier price list */ @@ -264,7 +255,7 @@ Date($_SESSION['DefaultDateFormat']) . ' ' . _('Page') . ' ' . $PageNumber,'left'); $YPos -= $line_height; $pdf->addTextWrap($Left_Margin,$YPos,50,$FontSize,_('Supplier').' '); - $pdf->addTextWrap(95,$YPos,150,$FontSize,_(': ').$Supp); + $pdf->addTextWrap(95,$YPos,150,$FontSize,_(': ').$SupplierName); $YPos -= $line_height; $pdf->addTextWrap($Left_Margin,$YPos,50,$FontSize,_('Category').' '); @@ -272,7 +263,7 @@ $pdf->addTextWrap(95,$YPos,150,$FontSize,_(': ').$Categoryname); $YPos -= $line_height; $pdf->addTextWrap($Left_Margin,$YPos,50,$FontSize,_('Currency').' '); - $pdf->addTextWrap(95,$YPos,50,$FontSize,_(': ').$Currency); + $pdf->addTextWrap(95,$YPos,50,$FontSize,_(': ').$CurrCode); $YPos -=(2*$line_height); /*set up the headings */ Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/doc/Change.log.html 2011-03-13 04:55:32 UTC (rev 4508) @@ -1,5 +1,7 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>12/3/11: SelectSalesOrder.php now allows any number of sales orders to be selected and purchase orders placed for the aggregate of items on the selected sales orders</p> +<p>12/3/11: SuppPriceList.php removed a round trip to DB to get currency - fixed function to get pdf to new TCPDF Output </p> <p>12/3/11: Exson fix all htmlentities to use ENTQUOTES, 'UTF-8' option so other character sets work with it</p> <p>10/3/11: Phil fix pagination of PrintCustOrder_generic.php - second copy was not restarting page numbers</p> <p>10/3/11: Tims launchpad fixes brought in MRP.php fix for table charset utf8 so joins work correctly; typeo in PO_Header preventing purchasing data being retrieved ($result not $Result); correct sql on searching for customer in SelectCreditItems.php; StockStatus.php pricing history bug resolved (4450); StockQuantityByDate.php now allowed to show for all categories - enclosed 'All' in gettext</p> Modified: trunk/includes/ConnectDB.inc =================================================================== --- trunk/includes/ConnectDB.inc 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/includes/ConnectDB.inc 2011-03-13 04:55:32 UTC (rev 4508) @@ -4,7 +4,7 @@ * this value is saved in the $_SESSION['Versionumber'] when includes/GetConfig.php is run * if VersionNumber is < $Version then the DB update script is run */ -$Version='4.03'; //must update manually every time there is a DB change +$Version='4.03.2'; //must update manually every time there is a DB change require_once ($PathPrefix .'includes/MiscFunctions.php'); Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2011-03-13 04:55:32 UTC (rev 4508) @@ -816,4 +816,18 @@ UPDATE config SET confvalue='3.12.31' WHERE confname='VersionNumber'; INSERT INTO config (`confname`, `confvalue`) VALUES ('AutoAuthorisePO', '1'); UPDATE config SET confvalue='4.03' WHERE confname='VersionNumber'; +ALTER TABLE `salesorders` ADD `poplaced` TINYINT NOT NULL DEFAULT '0', +ADD INDEX ( `poplaced` ); +UPDATE config SET confvalue='4.03.1' WHERE confname='VersionNumber'; +CREATE TABLE IF NOT EXISTS `fixedassetlocations` ( + `locationid` char(6) NOT NULL DEFAULT '', + `locationdescription` char(20) NOT NULL DEFAULT '', + `parentlocationid` char(6) DEFAULT '', + PRIMARY KEY (`locationid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +INSERT INTO `fixedassetlocations` (`locationid`, `locationdescription`, `parentlocationid`) VALUES +('HEADOF', 'Head Office', ''); +UPDATE config SET confvalue='4.03.2' WHERE confname='VersionNumber'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-13 04:55:39
|
Revision: 4508 http://web-erp.svn.sourceforge.net/web-erp/?rev=4508&view=rev Author: daintree Date: 2011-03-13 04:55:32 +0000 (Sun, 13 Mar 2011) Log Message: ----------- various Modified Paths: -------------- trunk/SelectSalesOrder.php trunk/Stocks.php trunk/SuppPriceList.php trunk/doc/Change.log.html trunk/includes/ConnectDB.inc trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/SelectSalesOrder.php =================================================================== --- trunk/SelectSalesOrder.php 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/SelectSalesOrder.php 2011-03-13 04:55:32 UTC (rev 4508) @@ -8,10 +8,11 @@ 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++){ - if ($_POST['PlacePO_' . $i]== 'on') { + if (isset($_POST['PlacePO_' . $i])) { //checkboxes only set if they are checked if ($OrdersToPlacePOFor==''){ $OrdersToPlacePOFor .= ' orderno=' . $_POST['OrderNo_PO_'.$i]; } else { @@ -30,13 +31,17 @@ purchdata.supplierdescription, purchdata.conversionfactor, purchdata.leadtime, + purchdata.suppliersuom, stockmaster.kgs, - stockmaster.cuft - SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS OrderQty + 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 . ") @@ -47,223 +52,213 @@ purchdata.supplierdescription, purchdata.conversionfactor, purchdata.leadtime, + purchdata.suppliersuom, stockmaster.kgs, - stockmaster.cuft + 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); - /*Now get the default delivery address details from the users default stock location */ - $sql = "SELECT locationame, - 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>'; + 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 { - $UserDetails = ' ' . $_SESSION['UsersRealName'] . ' '; - } - - while ($ItemRow = DB_fetch_array($ItemResult)){ + /*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'] . "'"; + $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); - 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 */ + $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 !='' AND $_SESSION['AutoAuthorisePO']==1) { - //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']."'"; - - $AuthResult=DB_query($AuthSQL,$db); - $AuthRow=DB_fetch_array($AuthResult); - - 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', - statuscomment='" . $StatusComment . "' - WHERE orderno='" . $OrderNo . "'", - $db); - } 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 />'; + 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 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']."'"; + + $AuthResult=DB_query($AuthSQL,$db); + $AuthRow=DB_fetch_array($AuthResult); + + 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', + statuscomment='" . $StatusComment . "' + WHERE orderno='" . $OrderNo . "'", + $db); + } 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 - 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'); + if ($SupplierID !=''){ //then we have just added a purchase order + echo '<p>'; + prnMsg(_('Purchase Order') . ' ' . $PO_OrderNo . ' ' . _('on') . ' ' . $ItemRow['supplierno'] . ' ' . _('has been created'),'success'); + DB_Txn_Commit($db); } - } //end of authorisation status settings + /*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 . "'"; + + $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)"; + + $ErrMsg = _('The purchase order header record could not be inserted into the database because'); + $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + } //end if it's a new supplier and PO to create - if ($SupplierID !=''){ //then we have just added a purchase order - DB_Txn_Commit($db); - } - /*Starting a new purchase order with a different supplier */ - $result = DB_Txn_Begin($db); - $OrderNo = GetNextTransNo(18, $db); //get the next PO number + /*reminder we are in a loop of the total of each item to place a purchase order for based on a selection of sales orders */ + $DeliveryDate = DateAdd(Date($_SESSION['DefaultDateFormat']),'d',$ItemRow['leadtime']); + $sql = "INSERT INTO purchorderdetails ( orderno, + itemcode, + deliverydate, + itemdescription, + glcode, + unitprice, + quantityord, + suppliersunit, + suppliers_partno, + kgs, + cuft, + conversionfactor ) + VALUES ( + '" . $PO_OrderNo . "', + '" . $ItemRow['stockid'] . "', + '" . FormatDateForSQL($DeliveryDate) . "', + '" . $ItemRow['suppliers_partno'] . ' ' . $ItemRow['supplierdescription'] . "', + '" . $ItemRow['stockact'] . "', + '" . $ItemRow['price'] . "', + '" . $ItemRow['orderqty'] . "', + '" . $ItemRow['suppliersuom'] . "', + '" . $ItemRow['suppliers_partno'] . "', + '" . $ItemRow['kgs'] . "', + '" . $ItemRow['volume'] . "', + '" . $ItemRow['conversionfactor'] . "')"; + $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); + $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); - $SupplierID = $ItemRow['supplierno']; - $Order_Value =0; - /*Now get all the required details for the supplier */ - $sql = "SELECT address1, - address2, - address3, - address4, - address5, - address6, - suppliercontact, - telephone, - paymentterms, - currcode, - rate - FROM suppliers INNER JOIN currencies - ON suppliers.currcode = currencies.currabrev - WHERE supplierno='" . $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( '" . $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)"; - - $ErrMsg = _('The purchase order header record could not be inserted into the database because'); - $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - - /*Insert the purchase order detail records */ - foreach ($_SESSION['PO'.$identifier]->LineItems as $POLine) { - if ($POLine->Deleted==False) { - $sql = "INSERT INTO purchorderdetails ( orderno, - itemcode, - deliverydate, - itemdescription, - glcode, - unitprice, - quantityord, - shiptref, - jobref, - itemno, - suppliersunit, - suppliers_partno, - subtotal_amount, - package, - pcunit, - netweight, - kgs, - cuft, - total_quantity, - total_amount, - assetid, - conversionfactor ) - VALUES ( - '" . $_SESSION['PO'.$identifier]->OrderNo . "', - '" . $POLine->StockID . "', - '" . FormatDateForSQL($POLine->ReqDelDate) . "', - '" . $POLine->ItemDescription . "', - '" . $POLine->GLCode . "', - '" . $POLine->Price . "', - '" . $POLine->Quantity . "', - '" . $POLine->ShiptRef . "', - '" . $POLine->JobRef . "', - '" . $POLine->ItemNo . "', - '" . $POLine->SuppliersUnit . "', - '" . $POLine->Suppliers_PartNo . "', - '" . $POLine->SubTotal_Amount . "', - '" . $POLine->Package . "', - '" . $POLine->PcUnit . "', - '" . $POLine->NetWeight . "', - '" . $POLine->KGs . "', - '" . $POLine->CuFt . "', - '" . $POLine->Total_Quantity . "', - '" . $POLine->Total_Amount . "', - '" . $POLine->AssetID . "', - '" . $POLine->ConversionFactor . "')"; - $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); - $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); - - $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - } - } /* end of the loop round the detail line items on the order */ + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + $Order_Value += ($ItemRow['price']*$ItemRow['orderqty']); + } /* end of the loop round the items on the sales order that we wish to place purchase orders for */ + if ($SupplierID !=''){ //then we have just added a purchase order echo '<p>'; - prnMsg(_('Purchase Order') . ' ' . $_SESSION['PO'.$identifier]->OrderNo . ' ' . _('on') . ' ' . - $_SESSION['PO'.$identifier]->SupplierName . ' ' . _('has been created'),'success'); - } - } + prnMsg(_('Purchase Order') . ' ' . $PO_OrderNo . ' ' . _('on') . ' ' . $ItemRow['supplierno'] . ' ' . _('has been created'),'success'); + DB_Txn_Commit($db); + } + $result = DB_query("UPDATE salesorders SET poplaced=1 WHERE " . $OrdersToPlacePOFor,$db); + }/*There were items that had purchasing data set up to create POs for */ + } /* there were sales orders checked to place POs for */ }/*end of purchase order creation code */ /* ******************************************************************************************* */ @@ -389,14 +384,14 @@ while ($myrow=DB_fetch_array($resultStkLocs)){ if (isset($_POST['StockLocation'])){ if ($myrow['loccode'] == $_POST['StockLocation']){ - echo "<option selected Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } else { - echo "<option Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']. '</option>'; } } elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){ - echo "<option selected Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname']. '</option>'; } else { - echo "<option Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']. '</option>'; } } @@ -416,7 +411,7 @@ } echo '</select> </td><td>'; - echo "<input type=submit name='SearchOrders' VALUE='" . _('Search') . "'></td>"; + echo '<input type=submit name="SearchOrders" VALUE="' . _('Search') . '"></td>'; echo ' <td><a href="' . $rootpath . '/SelectOrderItems.php?' . SID . '&NewOrder=Yes">' . _('Add Sales Order') . '</a></td></tr></table>'; } @@ -428,16 +423,15 @@ $result1 = DB_query($SQL,$db); - echo "</font>"; - echo "<br /><table class=selection>"; + echo '<br /><table class="selection">'; echo '<tr><th colspan=6><font size=3 color=navy>' . _('To search for sales orders for a specific part use the part selection facilities below'); echo '</th></tr>'; - echo "<tr> - <td><font size=1>" . _('Select a stock category') . ":</font> - <select name='StockCat'>"; + echo '<tr> + <td><font size="1">' . _('Select a stock category') . ':</font> + <select name="StockCat">'; while ($myrow1 = DB_fetch_array($result1)) { - echo "<option VALUE='". $myrow1['categoryid'] . "'>" . $myrow1['categorydescription']; + echo '<option value="'. $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; } echo '</select> @@ -455,12 +449,12 @@ if (isset($StockItemsResult) and DB_num_rows($StockItemsResult)>0) { echo '<table cellpadding=2 colspan=7 class=selection>'; - $TableHeader = "<tr> - <th>" . _('Code') . "</th> - <th>" . _('Description') . "</th> - <th>" . _('On Hand') . "</th> - <th>" . _('Units') . "</th> - </tr>"; + $TableHeader = '<tr> + <th>' . _('Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('On Hand') . '</th> + <th>' . _('Units') . '</th> + </tr>'; echo $TableHeader; $j = 1; @@ -502,7 +496,7 @@ else { //figure out the SQL required from the inputs available - if (isset($_POST['Quotations']) and $_POST['Quotations']=='Orders_Only'){ + if (isset($_POST['Quotations']) AND $_POST['Quotations']=='Orders_Only'){ $Quotations = 0; } else { $Quotations =1; @@ -519,6 +513,7 @@ salesorders.deliverydate, salesorders.deliverto, salesorders.printedpackingslip, + salesorders.poplaced, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -553,7 +548,8 @@ salesorders.orddate, salesorders.deliverydate, salesorders.deliverto, - salesorders.printedpackingslip, + salesorders.printedpackingslip, + salesorders.poplaced, salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent) AS ordervalue FROM salesorders, salesorderdetails, @@ -578,7 +574,8 @@ salesorders.customerref, salesorders.orddate, salesorders.deliverto, - salesorders.printedpackingslip, + salesorders.printedpackingslip, + salesorders.poplaced, salesorders.deliverydate, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -612,6 +609,7 @@ salesorders.orddate, salesorders.deliverto, salesorders.printedpackingslip, + salesorders.poplaced, salesorders.deliverydate, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -642,7 +640,8 @@ salesorders.orddate, salesorders.deliverto, salesorders.deliverydate, - salesorders.printedpackingslip, + salesorders.printedpackingslip, + salesorders.poplaced, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -676,9 +675,9 @@ if (DB_num_rows($SalesOrdersResult)>0) { /* Get users authority to place POs */ - $AuthSql="SELECT cancreate - FROM purchorderauth - WHERE userid='". $_SESSION['UserID'] . "'"; + $AuthSQL="SELECT cancreate + FROM purchorderauth + WHERE userid='". $_SESSION['UserID'] . "'"; /*we don't know what currency these orders might be in but if no authority at all then don't show option*/ $AuthResult=DB_query($AuthSQL,$db); @@ -718,7 +717,7 @@ } echo $tableheader; - } + $i = 1; $j = 1; $k=0; //row colour counter @@ -733,120 +732,120 @@ $k++; } - $ModifyPage = $rootpath . "/SelectOrderItems.php?" . SID . '&ModifyOrderNumber=' . $myrow['orderno']; - $Confirm_Invoice = $rootpath . '/ConfirmDispatch_Invoice.php?' . SID . '&OrderNumber=' .$myrow['orderno']; - - if ($_SESSION['PackNoteFormat']==1){ /*Laser printed A4 default */ - $PrintDispatchNote = $rootpath . '/PrintCustOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; - } else { /*pre-printed stationery default */ - $PrintDispatchNote = $rootpath . '/PrintCustOrder.php?' . SID . '&TransNo=' . $myrow['orderno']; + $ModifyPage = $rootpath . "/SelectOrderItems.php?" . SID . '&ModifyOrderNumber=' . $myrow['orderno']; + $Confirm_Invoice = $rootpath . '/ConfirmDispatch_Invoice.php?' . SID . '&OrderNumber=' .$myrow['orderno']; + + if ($_SESSION['PackNoteFormat']==1){ /*Laser printed A4 default */ + $PrintDispatchNote = $rootpath . '/PrintCustOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; + } else { /*pre-printed stationery default */ + $PrintDispatchNote = $rootpath . '/PrintCustOrder.php?' . SID . '&TransNo=' . $myrow['orderno']; + } + $PrintSalesOrder = $rootpath . '/PrintSalesOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; + $PrintQuotation = $rootpath . '/PDFQuotation.php?' . SID . '&QuotationNo=' . $myrow['orderno']; + $FormatedDelDate = ConvertSQLDate($myrow['deliverydate']); + $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); + $FormatedOrderValue = number_format($myrow['ordervalue'],2); + + if ($myrow['printedpackingslip']==0) { + $PrintText = _('Print'); + } else { + $PrintText = _('Reprint'); + } + + if ($_POST['Quotations']=='Orders_Only'){ + + /*Check authority to create POs if user has authority then show the check boxes to select sales orders to place POs for otherwise don't provide this option */ + if ($AuthRow['cancreate']==0 AND $myrow['poplaced']==0){ //cancreate==0 if the user can create POs and not already placed + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . _('Invoice') . "</a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + <td><input type=checkbox name=PlacePO_%s value><input type=hidden name=OrderNo_PO_%s value=%s></td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $Confirm_Invoice, + $PrintDispatchNote, + $PrintSalesOrder, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue, + $i, + $i, + $myrow['orderno']); + } else { /*User is not authorised to create POs so don't even show the option */ + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . _('Invoice') . "</a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $Confirm_Invoice, + $PrintDispatchNote, + $PrintSalesOrder, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue); + } + + } else { /*must be quotes only */ + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . $PrintText . "</a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $PrintQuotation, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue); + } + $i++; + $j++; + if ($j == 12){ + $j=1; + echo $tableheader; + } + //end of page full new headings if + }//end while loop through orders to display + if ($_POST['Quotations']=='Orders_Only' AND $AuthRow['cancreate']==0){ //cancreate==0 means can create POs + echo '<tr><td colspan="10"><td><td colspan="2"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; } - $PrintSalesOrder = $rootpath . '/PrintSalesOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; - $PrintQuotation = $rootpath . '/PDFQuotation.php?' . SID . '&QuotationNo=' . $myrow['orderno']; - $FormatedDelDate = ConvertSQLDate($myrow['deliverydate']); - $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); - $FormatedOrderValue = number_format($myrow['ordervalue'],2); - - if ($myrow['printedpackingslip']==0) { - $PrintText = _('Print'); - } else { - $PrintText = _('Reprint'); - } - - if ($_POST['Quotations']=='Orders_Only'){ - - /*Check authority to create POs if user has authority then show the check boxes to select sales orders to place POs for otherwise don't provide this option */ - if ($AuthRow['cancreate']==0){ //cancreate==0 if the user can create POs - printf("<td><a href='%s'>%s</a></td> - <td><a href='%s'>" . _('Invoice') . "</a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - <td><input type=checkbox name=PlacePO_%s><input type=hidden name=OrderNo_PO_%s value=%s></td> - </tr>", - $ModifyPage, - $myrow['orderno'], - $Confirm_Invoice, - $PrintDispatchNote, - $PrintSalesOrder, - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $FormatedOrderDate, - $FormatedDelDate, - $myrow['deliverto'], - $FormatedOrderValue, - $i, - $i, - $myrow['orderno']); - } else { /*User is not authorised to create POs so don't even show the option */ - printf("<td><a href='%s'>%s</a></td> - <td><a href='%s'>" . _('Invoice') . "</a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - </tr>", - $ModifyPage, - $myrow['orderno'], - $Confirm_Invoice, - $PrintDispatchNote, - $PrintSalesOrder, - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $FormatedOrderDate, - $FormatedDelDate, - $myrow['deliverto'], - $FormatedOrderValue); - } - - } else { /*must be quotes only */ - printf("<td><a href='%s'>%s</a></td> - <td><a href='%s'>" . $PrintText . "</a></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - </tr>", - $ModifyPage, - $myrow['orderno'], - $PrintQuotation, - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $FormatedOrderDate, - $FormatedDelDate, - $myrow['deliverto'], - $FormatedOrderValue); - } - $i++; - $j++; - if ($j == 12){ - $j=1; - echo $tableheader; - } - //end of page full new headings if - } - //end of while loop - if ($_POST['Quotations']=='Orders_Only' AND $AuthRow['cancreate']==0){ //cancreate==0 means can create POs - echo '<tr><td colspan="10"><td><td colspan="2"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; - } - echo '</table>'; + echo '</table>'; + } //end if there are some orders to show } ?> Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/Stocks.php 2011-03-13 04:55:32 UTC (rev 4508) @@ -477,7 +477,7 @@ prnMsg( _('Cannot delete this item record because there are bills of material that require this part as a component'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('bills of material that require this part as a component'); } else { - $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."' GROUP BY stockid"; + $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."' GROUP BY stkcode"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -493,7 +493,7 @@ prnMsg(_('Cannot delete this item because sales analysis records exist for it'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales analysis records against this part'); } else { - $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."' GROUP BY stockid"; + $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."' GROUP BY itemcode"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { Modified: trunk/SuppPriceList.php =================================================================== --- trunk/SuppPriceList.php 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/SuppPriceList.php 2011-03-13 04:55:32 UTC (rev 4508) @@ -21,10 +21,11 @@ $line_height=12; //get supplier - $sqlsup = "SELECT suppname FROM suppliers where supplierid='" . $_POST['supplier'] . "'"; + $sqlsup = "SELECT suppname, currcode FROM suppliers where supplierid='" . $_POST['supplier'] . "'"; $resultsup = db_query($sqlsup,$db); - $RowSup = db_fetch_row($resultsup); - $Supp=$RowSup['0']; + $RowSup = db_fetch_array($resultsup); + $SupplierName=$RowSup['suppname']; + $CurrCode =$RowSup['currcode']; //get category if ($_POST['category']!="all"){ @@ -36,26 +37,22 @@ $Categoryname="ALL"; } - //get currency - $sqlcur="SELECT currcode FROM `suppliers` where supplierid='" . $_POST['supplier'] . "'"; - $resultcur = db_query($sqlcur,$db); - $RowCur = db_fetch_row($resultcur); - $Currency=$RowCur['0']; - + //get date price - if ($_POST['price']=="all"){ - $DatePrice=_('All Price'); + if ($_POST['price']=='all'){ + $DatePrice=_('All Prices'); } else { $DatePrice=_('Current Price'); } //price and category = all - if (($_POST['price']=="all")and($_POST['category']=="all")){ + if (($_POST['price']=='all')and($_POST['category']=='all')){ $sql = "SELECT purchdata.stockid, stockmaster.description, purchdata.price, (purchdata.effectivefrom)as dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata,stockmaster WHERE supplierno='" . $_POST['supplier'] . "' AND stockmaster.stockid=purchdata.stockid @@ -72,7 +69,8 @@ WHERE purchdata.stockid = stockmaster.stockid ORDER BY effectivefrom DESC LIMIT 0,1) AS dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata, stockmaster WHERE supplierno = '" . $_POST['supplier'] . "' AND stockmaster.stockid = purchdata.stockid @@ -86,7 +84,8 @@ stockmaster.description, purchdata.price, (purchdata.effectivefrom)as dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata,stockmaster WHERE supplierno='" . $_POST['supplier'] . "' AND stockmaster.stockid=purchdata.stockid @@ -102,7 +101,8 @@ WHERE purchdata.stockid = stockmaster.stockid ORDER BY effectivefrom DESC LIMIT 0,1) AS dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata,stockmaster WHERE supplierno='" . $_POST['supplier'] . "' AND stockmaster.stockid=purchdata.stockid @@ -127,7 +127,7 @@ } PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin, - $Page_Width,$Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice); + $Page_Width,$Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice); $FontSize=8; $code=''; @@ -148,26 +148,26 @@ $dateprice=date($_SESSION['DefaultDateFormat'], mktime(0,0,0,$DateArray[1],$DateArray[2],$DateArray[0])); //if item has more than 1 price, write only price, date and supplier code for the old ones - if ($code==$myrow[0]){ + if ($code==$myrow['stockid']){ - $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow[2],2),'right'); + $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow['price'],2),'right'); $pdf->addTextWrap(430,$YPos,50,$FontSize,$dateprice,'left'); - $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow[4],'left'); - $code=$myrow[0]; + $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow['suppliers_partno'],'left'); + $code=$myrow['stockid']; } else { - $code=$myrow[0]; - $pdf->addTextWrap(50,$YPos,90,$FontSize,$myrow[0],'left'); - $pdf->addTextWrap(145,$YPos,215,$FontSize,$myrow[1],'left'); - $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow[2],2),'right'); + $code=$myrow['stockid']; + $pdf->addTextWrap(50,$YPos,90,$FontSize,$myrow['stockid'],'left'); + $pdf->addTextWrap(145,$YPos,215,$FontSize,$myrow['description'],'left'); + $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow['price'],2),'right'); $pdf->addTextWrap(430,$YPos,50,$FontSize,$dateprice,'left'); - $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow[4],'left'); + $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow['suppliers_partno'],'left'); } if ($YPos < $Bottom_Margin + $line_height){ PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, - $Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice); + $Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice); } @@ -176,22 +176,13 @@ if ($YPos < $Bottom_Margin + $line_height){ PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, - $Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice); + $Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice); } + + $pdf->OutputD( $_SESSION['DatabaseName'] . '_SupplierPriceList_' . Date('Y-m-d') . '.pdf'); + - $pdfcode = $pdf->output(); - - header('Content-type: application/pdf'); - header("Content-Length: " . $len); - header('Content-Disposition: inline; filename=Supplier Price List.pdf'); - header('Expires: 0'); - header('Cache-Control: private, post-check=0, pre-check=0'); - header('Pragma: public'); - $pdf->Output('SuppPriceList.pdf', 'I'); - - - } else { /*The option to print PDF was not hit so display form */ $title=_('Supplier Price List'); @@ -229,8 +220,8 @@ echo '</select></td></tr>'; echo '<tr><td>' . _('Price List') . ':</td><td><select name="price"> '; - echo '<option Value="all">' ._('All Prices').''; - echo '<option Value="current">' ._('Only Current Price').''; + echo '<option Value="all">' ._('All Prices').'</option>'; + echo '<option Value="current">' ._('Only Current Price').'</option>'; echo '</select></td></tr>'; @@ -243,7 +234,7 @@ function PrintHeader(&$pdf,&$YPos,&$PageNumber,$Page_Height,$Top_Margin,$Left_Margin, - $Page_Width,$Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice) { + $Page_Width,$Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice) { /*PDF page header for Supplier price list */ @@ -264,7 +255,7 @@ Date($_SESSION['DefaultDateFormat']) . ' ' . _('Page') . ' ' . $PageNumber,'left'); $YPos -= $line_height; $pdf->addTextWrap($Left_Margin,$YPos,50,$FontSize,_('Supplier').' '); - $pdf->addTextWrap(95,$YPos,150,$FontSize,_(': ').$Supp); + $pdf->addTextWrap(95,$YPos,150,$FontSize,_(': ').$SupplierName); $YPos -= $line_height; $pdf->addTextWrap($Left_Margin,$YPos,50,$FontSize,_('Category').' '); @@ -272,7 +263,7 @@ $pdf->addTextWrap(95,$YPos,150,$FontSize,_(': ').$Categoryname); $YPos -= $line_height; $pdf->addTextWrap($Left_Margin,$YPos,50,$FontSize,_('Currency').' '); - $pdf->addTextWrap(95,$YPos,50,$FontSize,_(': ').$Currency); + $pdf->addTextWrap(95,$YPos,50,$FontSize,_(': ').$CurrCode); $YPos -=(2*$line_height); /*set up the headings */ Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/doc/Change.log.html 2011-03-13 04:55:32 UTC (rev 4508) @@ -1,5 +1,7 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>12/3/11: SelectSalesOrder.php now allows any number of sales orders to be selected and purchase orders placed for the aggregate of items on the selected sales orders</p> +<p>12/3/11: SuppPriceList.php removed a round trip to DB to get currency - fixed function to get pdf to new TCPDF Output </p> <p>12/3/11: Exson fix all htmlentities to use ENTQUOTES, 'UTF-8' option so other character sets work with it</p> <p>10/3/11: Phil fix pagination of PrintCustOrder_generic.php - second copy was not restarting page numbers</p> <p>10/3/11: Tims launchpad fixes brought in MRP.php fix for table charset utf8 so joins work correctly; typeo in PO_Header preventing purchasing data being retrieved ($result not $Result); correct sql on searching for customer in SelectCreditItems.php; StockStatus.php pricing history bug resolved (4450); StockQuantityByDate.php now allowed to show for all categories - enclosed 'All' in gettext</p> Modified: trunk/includes/ConnectDB.inc =================================================================== --- trunk/includes/ConnectDB.inc 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/includes/ConnectDB.inc 2011-03-13 04:55:32 UTC (rev 4508) @@ -4,7 +4,7 @@ * this value is saved in the $_SESSION['Versionumber'] when includes/GetConfig.php is run * if VersionNumber is < $Version then the DB update script is run */ -$Version='4.03'; //must update manually every time there is a DB change +$Version='4.03.2'; //must update manually every time there is a DB change require_once ($PathPrefix .'includes/MiscFunctions.php'); Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2011-03-13 04:55:32 UTC (rev 4508) @@ -816,4 +816,18 @@ UPDATE config SET confvalue='3.12.31' WHERE confname='VersionNumber'; INSERT INTO config (`confname`, `confvalue`) VALUES ('AutoAuthorisePO', '1'); UPDATE config SET confvalue='4.03' WHERE confname='VersionNumber'; +ALTER TABLE `salesorders` ADD `poplaced` TINYINT NOT NULL DEFAULT '0', +ADD INDEX ( `poplaced` ); +UPDATE config SET confvalue='4.03.1' WHERE confname='VersionNumber'; +CREATE TABLE IF NOT EXISTS `fixedassetlocations` ( + `locationid` char(6) NOT NULL DEFAULT '', + `locationdescription` char(20) NOT NULL DEFAULT '', + `parentlocationid` char(6) DEFAULT '', + PRIMARY KEY (`locationid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +INSERT INTO `fixedassetlocations` (`locationid`, `locationdescription`, `parentlocationid`) VALUES +('HEADOF', 'Head Office', ''); +UPDATE config SET confvalue='4.03.2' WHERE confname='VersionNumber'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-11 20:24:10
|
Revision: 4507 http://web-erp.svn.sourceforge.net/web-erp/?rev=4507&view=rev Author: daintree Date: 2011-03-11 20:24:03 +0000 (Fri, 11 Mar 2011) Log Message: ----------- Exson fix all htmlentities to use ENTQUOTES, UTF-8 option Modified Paths: -------------- trunk/AccountGroups.php trunk/Contracts.php trunk/GLJournal.php trunk/PO_SelectPurchOrder.php trunk/PageSecurity.php trunk/SelectCreditItems.php trunk/SelectOrderItems.php trunk/SelectSalesOrder.php trunk/doc/Change.log.html trunk/includes/MiscFunctions.php Modified: trunk/AccountGroups.php =================================================================== --- trunk/AccountGroups.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/AccountGroups.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -68,7 +68,7 @@ } if (ContainsIllegalCharacters($_POST['GroupName'])) { $InputError = 1; - prnMsg( _('The account group name cannot contain the character') . " '&' " . _('or the character') ." '",'error'); + prnMsg( _('The account group name cannot contain the character') . " '&' " . _('or the character') ."' '",'error'); $Errors[$i] = 'GroupName'; $i++; } @@ -257,13 +257,13 @@ break; } //end of switch statement - echo '<td>' . htmlentities($myrow[0]) . '</td> + echo '<td>' . htmlentities($myrow[0], ENT_QUOTES,'UTF-8') . '</td> <td>' . $myrow[1] . '</td> <td>' . $myrow[2] . '</td> <td>' . $PandLText . '</td> <td>' . $myrow[4] . '</td>'; - echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&SelectedAccountGroup=' . htmlentities($myrow[0]) . '">' . _('Edit') . '</a></td>'; - echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&SelectedAccountGroup=' . htmlentities($myrow[0]) . '&delete=1">' . _('Delete') .'</a></td></tr>'; + echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&SelectedAccountGroup=' . htmlentities($myrow[0], ENT_QUOTES,'UTF-8') . '">' . _('Edit') . '</a></td>'; + echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&SelectedAccountGroup=' . htmlentities($myrow[0], ENT_QUOTES,'UTF-8') . '&delete=1">' . _('Delete') .'</a></td></tr>'; } //END WHILE LIST LOOP echo '</table>'; @@ -353,9 +353,9 @@ while ( $grouprow = DB_fetch_array($groupresult) ) { if (isset($_POST['ParentGroupName']) and $_POST['ParentGroupName']==$grouprow['groupname']) { - echo '<option selected="selected" value="'.htmlentities($grouprow['groupname']).'">' .htmlentities($grouprow['groupname']).'</option>'; + echo '<option selected="selected" value="'.htmlentities($grouprow['groupname'], ENT_QUOTES,'UTF-8').'">' .htmlentities($grouprow['groupname'], ENT_QUOTES,'UTF-8').'</option>'; } else { - echo '<option value="'.htmlentities($grouprow['groupname']).'">' .htmlentities($grouprow['groupname']).'</option>'; + echo '<option value="'.htmlentities($grouprow['groupname'], ENT_QUOTES,'UTF-8').'">' .htmlentities($grouprow['groupname'], ENT_QUOTES,'UTF-8').'</option>'; } } echo '</select>'; Modified: trunk/Contracts.php =================================================================== --- trunk/Contracts.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/Contracts.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -792,13 +792,13 @@ $k=1; } if ($LastCustomer != $myrow['name']) { - echo '<td>'.htmlentities($myrow['name']).'</td>'; + echo '<td>'.htmlentities($myrow['name'], ENT_QUOTES,'UTF-8').'</td>'; } else { echo '<td></td>'; } - echo '<td><input tabindex="'.($j+5).'" type="submit" name="SubmitCustomerSelection' . $j .'" value="'.htmlentities($myrow['brname']).'" /></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'].'" /> - <td>'.htmlentities($myrow['contactname']).'</td> + <td>'.htmlentities($myrow['contactname'], ENT_QUOTES,'UTF-8') .'</td> <td>'.$myrow['phoneno'].'</td> <td>'.$myrow['faxno'].'</td> </tr>'; Modified: trunk/GLJournal.php =================================================================== --- trunk/GLJournal.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/GLJournal.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -249,175 +249,173 @@ $_SESSION['JournalDetail']->JnlDate = Date($_SESSION['DefaultDateFormat'],mktime(0,0,0,date('m'),0,date('Y'))); } - echo '<table><tr> - <td colspan="5"><table class="selection"><tr><td>'._('Date to Process Journal').":</td> - <td><input type='text' class='date' alt='".$_SESSION['DefaultDateFormat']."' name='JournalProcessDate' maxlength='10' size='11' value='" . - $_SESSION['JournalDetail']->JnlDate . "' /></td>"; - echo '<td>' . _('Type') . ':</td> - <td><select name="JournalType">'; +echo '<table><tr> + <td colspan="5"><table class="selection"><tr><td>'._('Date to Process Journal').":</td> + <td><input type='text' class='date' alt='".$_SESSION['DefaultDateFormat']."' name='JournalProcessDate' maxlength='10' size='11' value='" . + $_SESSION['JournalDetail']->JnlDate . "' /></td>"; +echo '<td>' . _('Type') . ':</td> + <td><select name="JournalType">'; - if ($_POST['JournalType'] == 'Reversing'){ - echo "<option selected='True' value = 'Reversing'>" . _('Reversing')."</option>"; - echo "<option value = 'Normal'>" . _('Normal')."</option>"; - } else { - echo "<option value = 'Reversing'>" . _('Reversing')."</option>"; - echo "<option selected='True' value = 'Normal'>" . _('Normal')."</option>"; - } +if ($_POST['JournalType'] == 'Reversing'){ + echo '<option selected="True" value = "Reversing">' . _('Reversing').'</option>'; + echo '<option value = "Normal">' . _('Normal').'</option>'; +} else { + echo '<option value = "Reversing">' . _('Reversing').'</option>'; + echo '<option selected="True" value = "Normal">' . _('Normal') . '</option>'; +} - echo '</select></td> - </tr> - </table>'; - /* close off the table in the first column */ +echo '</select></td> + </tr> + </table>'; +/* close off the table in the first column */ - echo '<br />'; - echo '<table class="selection" width="70%">'; - /* Set upthe form for the transaction entry for a GL Payment Analysis item */ +echo '<br />'; +echo '<table class="selection" width="70%">'; +/* Set upthe form for the transaction entry for a GL Payment Analysis item */ - echo '<tr><th colspan="3"><div class="centre"><font size="3" color="blue"><b>' . _('Journal Line Entry') . '</b></font></div></th></tr>'; +echo '<tr><th colspan="3"><div class="centre"><font size="3" color="blue"><b>' . _('Journal Line Entry') . '</b></font></div></th></tr>'; - /*now set up a GLCode field to select from avaialble GL accounts */ - echo '<tr><th>' . _('GL Tag') . '</th>'; - echo '<th>' . _('GL Account Code') . '</th>'; - echo '<th>' . _('Select GL Account') . '</th></tr>'; +/*now set up a GLCode field to select from avaialble GL accounts */ +echo '<tr><th>' . _('GL Tag') . '</th>'; +echo '<th>' . _('GL Account Code') . '</th>'; +echo '<th>' . _('Select GL Account') . '</th></tr>'; /* Set upthe form for the transaction entry for a GL Payment Analysis item */ - //Select the tag - echo '<tr><td><select name="tag">'; +//Select the tag +echo '<tr><td><select name="tag">'; - $SQL = "SELECT tagref, - tagdescription - FROM tags - ORDER BY tagref"; +$SQL = 'SELECT tagref, + tagdescription + FROM tags + ORDER BY tagref'; - $result=DB_query($SQL,$db); - echo '<option value="0">0 - None</option>'; - while ($myrow=DB_fetch_array($result)){ - if (isset($_POST['tag']) and $_POST['tag']==$myrow['tagref']){ - echo '<option selected value="' . $myrow['tagref'] . '">' . $myrow['tagref'].' - ' .$myrow['tagdescription']."</option>"; - } else { - echo '<option value="' . $myrow['tagref'] . '">' . $myrow['tagref'].' - ' .$myrow['tagdescription']."</option>"; - } +$result=DB_query($SQL,$db); +echo '<option value="0">0 - None</option>'; +while ($myrow=DB_fetch_array($result)){ + if (isset($_POST['tag']) and $_POST['tag']==$myrow['tagref']){ + echo '<option selected value="' . $myrow['tagref'] . '">' . $myrow['tagref'].' - ' .$myrow['tagdescription'].'</option>'; + } else { + echo '<option value="' . $myrow['tagref'] . '">' . $myrow['tagref'].' - ' .$myrow['tagdescription'] . '</option>'; } - echo '</select></td>'; +} +echo '</select></td>'; // End select tag - if (!isset($_POST['GLManualCode'])) { - $_POST['GLManualCode']=''; - } - echo '<td><input class="number" type="text" Name="GLManualCode" Maxlength="12" size="12" onChange="inArray(this.value, GLCode.options,'. - "'".'The account code '."'".'+ this.value+ '."'".' doesnt exist'."'".')"' . - ' value="'. $_POST['GLManualCode'] .'" /></td>'; +if (!isset($_POST['GLManualCode'])) { + $_POST['GLManualCode']=''; +} +echo '<td><input class="number" type="text" Name="GLManualCode" Maxlength="12" size="12" onChange="inArray(this.value, GLCode.options,'. + "'".'The account code '."'".'+ this.value+ '."'".' doesnt exist'."'".')"' . + ' value="'. $_POST['GLManualCode'] .'" /></td>'; - $sql="SELECT accountcode, - accountname - FROM chartmaster - ORDER BY accountcode"; +$sql="SELECT accountcode, + accountname + FROM chartmaster + ORDER BY accountcode"; - $result=DB_query($sql, $db); - echo '<td><select name="GLCode" onChange="return assignComboToInput(this,'.'GLManualCode'.')">'; - echo '<option value="">' . _('Select a general ledger account code') . '</option>'; - while ($myrow=DB_fetch_array($result)){ - if (isset($_POST['tag']) and $_POST['tag']==$myrow['accountcode']){ - echo '<option selected value="' . $myrow['accountcode'] . '">' . $myrow['accountcode'].' - ' .htmlentities($myrow['accountname'])."</option>"; - } else { - echo '<option value="' . $myrow['accountcode'] . '">' . $myrow['accountcode'].' - ' .htmlentities($myrow['accountname'])."</option>"; - } +$result=DB_query($sql, $db); +echo '<td><select name="GLCode" onChange="return assignComboToInput(this,'.'GLManualCode'.')">'; +echo '<option value="">' . _('Select a general ledger account code') . '</option>'; +while ($myrow=DB_fetch_array($result)){ + if (isset($_POST['tag']) and $_POST['tag']==$myrow['accountcode']){ + echo '<option selected value="' . $myrow['accountcode'] . '">' . $myrow['accountcode'].' - ' .htmlentities($myrow['accountname'], ENT_QUOTES,'UTF-8') . '</option>'; + } else { + echo '<option value="' . $myrow['accountcode'] . '">' . $myrow['accountcode'].' - ' .htmlentities($myrow['accountname'], ENT_QUOTES,'UTF-8') .'</option>'; } - echo '</select></td>'; +} +echo '</select></td>'; - if (!isset($_POST['GLNarrative'])) { - $_POST['GLNarrative'] = ''; - } - if (!isset($_POST['Credit'])) { - $_POST['Credit'] = ''; - } - if (!isset($_POST['Debit'])) { - $_POST['Debit'] = ''; - } +if (!isset($_POST['GLNarrative'])) { + $_POST['GLNarrative'] = ''; +} +if (!isset($_POST['Credit'])) { + $_POST['Credit'] = ''; +} +if (!isset($_POST['Debit'])) { + $_POST['Debit'] = ''; +} - echo '</tr><tr><th>' . _('Debit') . "</th>".'<td><input type="text" class="number" Name = "Debit" ' . - 'onChange="eitherOr(this, '.'Credit'.')"'. - ' Maxlength="12" size="10" value="' . $_POST['Debit'] . '" /></td>'; - echo '</tr><tr><th>' . _('Credit') . "</th>".'<td><input type="text" class="number" Name = "Credit" ' . - 'onChange="eitherOr(this, '.'Debit'.')"'. - ' Maxlength="12" size="10" value="' . $_POST['Credit'] . '" /></td>'; - echo '</tr><tr><td></td><td></td><th>'. _('Narrative'). '</th>'; - echo '</tr><tr><th></th><th>' . _('GL Narrative') . "</th>"; +echo '</tr><tr><th>' . _('Debit') . '</th>'.'<td><input type="text" class="number" Name = "Debit" ' . + 'onChange="eitherOr(this, '.'Credit'.')"'. + ' Maxlength="12" size="10" value="' . $_POST['Debit'] . '" /></td>'; +echo '</tr><tr><th>' . _('Credit') . "</th>".'<td><input type="text" class="number" Name = "Credit" ' . + 'onChange="eitherOr(this, '.'Debit'.')"'. + ' Maxlength="12" size="10" value="' . $_POST['Credit'] . '" /></td>'; +echo '</tr><tr><td></td><td></td><th>'. _('Narrative'). '</th>'; +echo '</tr><tr><th></th><th>' . _('GL Narrative') . "</th>"; - echo '<td><input type="text" name="GLNarrative" maxlength="100" size="100" value="' . $_POST['GLNarrative'] . '" /></td>'; +echo '<td><input type="text" name="GLNarrative" maxlength="100" size="100" value="' . $_POST['GLNarrative'] . '" /></td>'; - echo '</tr></table><br />'; /*Close the main table */ - echo "<div class='centre'><input type='submit' name='Process' value='" . _('Accept') . "' /></div><br /><br />"; +echo '</tr></table><br />'; /*Close the main table */ +echo "<div class='centre'><input type='submit' name='Process' value='" . _('Accept') . "' /></div><br /><br />"; - echo "<table class='selection' width='85%'>"; +echo '<table class="selection" width="85%">'; - echo '<tr><th colspan="6"><div class="centre"><font size="3" color="blue"><b>' . _('Journal Summary') . '</b></font></div></th></tr>'; - echo "<tr> - <th>"._('GL Tag')."</th> - <th>"._('GL Account')."</th> - <th>"._('Debit')."</th> - <th>"._('Credit')."</th> - <th>"._('Narrative').'</th></tr>'; +echo '<tr><th colspan="6"><div class="centre"><font size="3" color="blue"><b>' . _('Journal Summary') . '</b></font></div></th></tr>'; +echo '<tr> + <th>'._('GL Tag').'</th> + <th>'._('GL Account').'</th> + <th>'._('Debit').'</th> + <th>'._('Credit').'</th> + <th>'._('Narrative').'</th></tr>'; - $debittotal=0; - $credittotal=0; - $j=0; +$debittotal=0; +$credittotal=0; +$j=0; - foreach ($_SESSION['JournalDetail']->GLEntries as $JournalItem) { - if ($j==1) { - echo '<tr class="OddTableRows">'; - $j=0; - } else { - echo '<tr class="EvenTableRows">'; - $j++; - } - $sql="SELECT tagdescription - FROM tags - WHERE tagref='".$JournalItem->tag . "'"; - $result=DB_query($sql, $db); - $myrow=DB_fetch_row($result); - if ($JournalItem->tag==0) { - $tagdescription='None'; - } else { - $tagdescription=$myrow[0]; - } - echo "<td>" . $JournalItem->tag . ' - ' . $tagdescription . "</td>"; - echo "<td>" . $JournalItem->GLCode . ' - ' . $JournalItem->GLActName . "</td>"; - if($JournalItem->Amount>0) - { - echo "<td class='number'>" . number_format($JournalItem->Amount,2) . '</td><td></td>'; - $debittotal=$debittotal+$JournalItem->Amount; - } - elseif($JournalItem->Amount<0) - { - $credit=(-1 * $JournalItem->Amount); - echo "<td></td> - <td class='number'>" . number_format($credit,2) . '</td>'; - $credittotal=$credittotal+$credit; - } +foreach ($_SESSION['JournalDetail']->GLEntries as $JournalItem) { + if ($j==1) { + echo '<tr class="OddTableRows">'; + $j=0; + } else { + echo '<tr class="EvenTableRows">'; + $j++; + } + $sql="SELECT tagdescription + FROM tags + WHERE tagref='".$JournalItem->tag . "'"; + $result=DB_query($sql, $db); + $myrow=DB_fetch_row($result); + if ($JournalItem->tag==0) { + $tagdescription='None'; + } else { + $tagdescription=$myrow[0]; + } + echo '<td>' . $JournalItem->tag . ' - ' . $tagdescription . '</td>'; + echo '<td>' . $JournalItem->GLCode . ' - ' . $JournalItem->GLActName . '</td>'; + if ($JournalItem->Amount>0) { + echo '<td class="number">' . number_format($JournalItem->Amount,2) . '</td><td></td>'; + $debittotal=$debittotal+$JournalItem->Amount; + + } elseif($JournalItem->Amount<0) { + $credit=(-1 * $JournalItem->Amount); + echo '<td></td> + <td class="number">' . number_format($credit,2) . '</td>'; + $credittotal=$credittotal+$credit; + } - echo '<td>' . $JournalItem->Narrative . "</td> - <td><a href='" . $_SERVER['PHP_SELF'] . '?' . SID . '&Delete=' . $JournalItem->ID . "'>"._('Delete').'</a></td> - </tr>'; - } + echo '<td>' . $JournalItem->Narrative . "</td> + <td><a href='" . $_SERVER['PHP_SELF'] . '?' . SID . '&Delete=' . $JournalItem->ID . "'>"._('Delete').'</a></td> + </tr>'; +} - echo '<tr class="EvenTableRows"><td></td> - <td class="number"><b> Total </b></td> - <td class="number"><b>' . number_format($debittotal,2) . '</b></td> - <td class="number"><b>' . number_format($credittotal,2) . '</b></td></tr>'; - if ($debittotal!=$credittotal) { - echo '<td align="center" style="background-color: #fddbdb"><b>Required to balance - </b>' . - number_format(abs($debittotal-$credittotal),2); - } - if ($debittotal>$credittotal) { - echo ' Credit</td></tr>'; - } else if ($debittotal<$credittotal) { - echo ' Debit</td></tr>'; - } - echo '</table>'; +echo '<tr class="EvenTableRows"><td></td> + <td class="number"><b> Total </b></td> + <td class="number"><b>' . number_format($debittotal,2) . '</b></td> + <td class="number"><b>' . number_format($credittotal,2) . '</b></td></tr>'; +if ($debittotal!=$credittotal) { + echo '<td align="center" style="background-color: #fddbdb"><b>Required to balance - </b>' . + number_format(abs($debittotal-$credittotal),2); +} +if ($debittotal>$credittotal) { + echo ' Credit</td></tr>'; +} else if ($debittotal<$credittotal) { + echo ' Debit</td></tr>'; +} +echo '</table>'; if (ABS($_SESSION['JournalDetail']->JournalTotal)<0.001 AND $_SESSION['JournalDetail']->GLItemCounter > 0){ echo "<br /><br /><div class='centre'><input type='submit' name='CommitBatch' value='"._('Accept and Process Journal')."' /></div>"; Modified: trunk/PO_SelectPurchOrder.php =================================================================== --- trunk/PO_SelectPurchOrder.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/PO_SelectPurchOrder.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -121,10 +121,10 @@ } } echo '</select> ' . _('Order Status:') .' <select name="Status">'; - if (!isset($_POST['Status']) OR $_POST['Status']=='Pending_Authorised'){ - echo '<option selected value="Pending_Authorised">' . _('Pending and Authorised') . '</option>'; + if (!isset($_POST['Status']) OR $_POST['Status']=='Pending_Authorised_Completed'){ + echo '<option selected value="Pending_Authorised_Completed">' . _('Pending/Authorised/Completed') . '</option>'; } else { - echo '<option value="Pending_Authorised">' . _('Pending and Authorised') . '</option>'; + echo '<option value="Pending_Authorised_Completed">' . _('Pending/Authorised/Completed') . '</option>'; } if ($_POST['Status']=='Pending'){ echo '<option selected value="Pending">' . _('Pending') . '</option>'; @@ -136,6 +136,11 @@ } else { echo '<option value="Authorised">' . _('Authorised') . '</option>'; } + if ($_POST['Status']=='Completed'){ + echo '<option selected value="Completed">' . _('Completed') . '</option>'; + } else { + echo '<option value="Completed">' . _('Completed') . '</option>'; + } if ($_POST['Status']=='Cancelled'){ echo '<option selected value="Cancelled">' . _('Cancelled') . '</option>'; } else { @@ -207,8 +212,8 @@ else { //figure out the SQL required from the inputs available - if (!isset($_POST['Status']) OR $_POST['Status']=='Pending_Authorised'){ - $StatusCriteria = " AND (purchorders.status='Pending' OR purchorders.status='Authorised' OR purchorders.status='Printed') "; + if (!isset($_POST['Status']) OR $_POST['Status']=='Pending_Authorised_Completed'){ + $StatusCriteria = " AND (purchorders.status='Pending' OR purchorders.status='Authorised' OR purchorders.status='Printed' OR purchorders.status='Completed') "; }elseif ($_POST['Status']=='Authorised'){ $StatusCriteria = " AND (purchorders.status='Authorised' OR purchorders.status='Printed')"; }elseif ($_POST['Status']=='Pending'){ @@ -217,25 +222,26 @@ $StatusCriteria = " AND purchorders.status='Rejected' "; }elseif ($_POST['Status']=='Cancelled'){ $StatusCriteria = " AND purchorders.status='Cancelled' "; + } elseif($_POST['Status']=='Completed'){ + $StatusCriteria = " AND purchorders.status='Completed' "; } - if (isset($OrderNumber) && $OrderNumber != "") { $SQL = "SELECT purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - purchorders.status, - suppliers.currcode, - SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue - FROM purchorders, - purchorderdetails, - suppliers - WHERE purchorders.orderno = purchorderdetails.orderno - AND purchorders.supplierno = suppliers.supplierid - AND purchorders.orderno='" . $OrderNumber . "' - GROUP BY purchorders.orderno"; + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + purchorders.status, + suppliers.currcode, + SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue + FROM purchorders, + purchorderdetails, + suppliers + WHERE purchorders.orderno = purchorderdetails.orderno + AND purchorders.supplierno = suppliers.supplierid + AND purchorders.orderno='" . $OrderNumber . "' + GROUP BY purchorders.orderno"; } else { /* $DateAfterCriteria = FormatDateforSQL($OrdersAfterDate); */ if (empty($_POST['StockLocation'])) { @@ -244,106 +250,106 @@ if (isset($SelectedSupplier)) { if (isset($SelectedStockItem)) { $SQL = "SELECT purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - purchorders.status, - suppliers.currcode, - SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue - FROM purchorders, - purchorderdetails, - suppliers - WHERE purchorders.orderno = purchorderdetails.orderno - AND purchorders.supplierno = suppliers.supplierid - AND purchorderdetails.itemcode='" . $SelectedStockItem . "' - AND purchorders.supplierno='" . $SelectedSupplier . "' - AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' - " . $StatusCriteria . " - GROUP BY purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - suppliers.currcode"; + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + purchorders.status, + suppliers.currcode, + SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue + FROM purchorders, + purchorderdetails, + suppliers + WHERE purchorders.orderno = purchorderdetails.orderno + AND purchorders.supplierno = suppliers.supplierid + AND purchorderdetails.itemcode='" . $SelectedStockItem . "' + AND purchorders.supplierno='" . $SelectedSupplier . "' + AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' + " . $StatusCriteria . " + GROUP BY purchorders.orderno, + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + suppliers.currcode"; } else { $SQL = "SELECT purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - purchorders.status, - suppliers.currcode, - SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue - FROM purchorders, - purchorderdetails, - suppliers - WHERE purchorders.orderno = purchorderdetails.orderno - AND purchorders.supplierno = suppliers.supplierid - AND purchorders.supplierno='" . $SelectedSupplier . "' - AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' - " . $StatusCriteria . " - GROUP BY purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - suppliers.currcode"; + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + purchorders.status, + suppliers.currcode, + SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue + FROM purchorders, + purchorderdetails, + suppliers + WHERE purchorders.orderno = purchorderdetails.orderno + AND purchorders.supplierno = suppliers.supplierid + AND purchorders.supplierno='" . $SelectedSupplier . "' + AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' + " . $StatusCriteria . " + GROUP BY purchorders.orderno, + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + suppliers.currcode"; } } else { //no supplier selected if (isset($SelectedStockItem)) { $SQL = "SELECT purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - purchorders.status, - suppliers.currcode, - SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue - FROM purchorders, - purchorderdetails, - suppliers - WHERE purchorders.orderno = purchorderdetails.orderno - AND purchorders.supplierno = suppliers.supplierid - AND purchorderdetails.itemcode='" . $SelectedStockItem . "' - AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' - " . $StatusCriteria . " - GROUP BY purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - suppliers.currcode"; + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + purchorders.status, + suppliers.currcode, + SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue + FROM purchorders, + purchorderdetails, + suppliers + WHERE purchorders.orderno = purchorderdetails.orderno + AND purchorders.supplierno = suppliers.supplierid + AND purchorderdetails.itemcode='" . $SelectedStockItem . "' + AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' + " . $StatusCriteria . " + GROUP BY purchorders.orderno, + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + suppliers.currcode"; } else { $SQL = "SELECT purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - purchorders.status, - suppliers.currcode, - sum(purchorderdetails.unitprice*purchorderdetails.quantityord) as ordervalue - FROM purchorders, - purchorderdetails, - suppliers - WHERE purchorders.orderno = purchorderdetails.orderno - AND purchorders.supplierno = suppliers.supplierid - AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' - " . $StatusCriteria . " - GROUP BY purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - suppliers.currcode"; + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + purchorders.status, + suppliers.currcode, + sum(purchorderdetails.unitprice*purchorderdetails.quantityord) as ordervalue + FROM purchorders, + purchorderdetails, + suppliers + WHERE purchorders.orderno = purchorderdetails.orderno + AND purchorders.supplierno = suppliers.supplierid + AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' + " . $StatusCriteria . " + GROUP BY purchorders.orderno, + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + suppliers.currcode"; } } //end selected supplier @@ -377,17 +383,17 @@ $ViewPurchOrder = $rootpath . '/PO_OrderDetails.php?' . SID . 'OrderNo=' . $myrow['orderno']; $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); $FormatedOrderValue = number_format($myrow['ordervalue'], 2); - /* View Supplier Currency Requisition Order Date Initiator Order Total + /* View Supplier Currency Requisition Order Date Initiator Order Total ModifyPage, $myrow["orderno"], $myrow["suppname"], $myrow["currcode"], $myrow["requisitionno"] $FormatedOrderDate, $myrow["initiator"] $FormatedOrderValue Order Status*/ - echo "<td><a href='" . $ViewPurchOrder . "'>" . $myrow['orderno'] . "</a></td> - <td>" . $myrow['suppname'] . "</td> - <td>" . $myrow['currcode'] . "</td> - <td>" . $myrow['requisitionno'] . "</td> - <td>" . $FormatedOrderDate . "</td> - <td>" . $myrow['initiator'] . "</td> - <td class=number>" . $FormatedOrderValue . "</td> - <td>" . _($myrow['status']) . "</td> - </tr>"; + echo '<td><a href="' . $ViewPurchOrder . '">' . $myrow['orderno'] . '</a></td> + <td>' . $myrow['suppname'] . '</td> + <td>' . $myrow['currcode'] . '</td> + <td>' . $myrow['requisitionno'] . '</td> + <td>' . $FormatedOrderDate . '</td> + <td>' . $myrow['initiator'] . '</td> + <td class=number>' . $FormatedOrderValue . '</td> + <td>' . _($myrow['status']) . '</td> + </tr>'; //$myrow['status'] is a string which has gettext translations from PO_Header.php script $j++; Modified: trunk/PageSecurity.php =================================================================== --- trunk/PageSecurity.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/PageSecurity.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -40,9 +40,9 @@ echo '<td><select name="'.$myrow['script'].'">'; while ($mytokenrow=DB_fetch_array($TokenResult)) { if ($mytokenrow['tokenid']==$myrow['pagesecurity']) { - echo '<option selected="True" value="'.$mytokenrow['tokenid'].'">'.htmlentities($mytokenrow['tokenname']).'</option>'; + echo '<option selected="True" value="'.$mytokenrow['tokenid'].'">'.htmlentities($mytokenrow['tokenname'], ENT_QUOTES,'UTF-8') .'</option>'; } else { - echo '<option value="'.$mytokenrow['tokenid'].'">'.htmlentities($mytokenrow['tokenname']).'</option>'; + echo '<option value="'.$mytokenrow['tokenid'].'">'.htmlentities($mytokenrow['tokenname'], ENT_QUOTES,'UTF-8') .'</option>'; } } echo '</select></td></tr>'; Modified: trunk/SelectCreditItems.php =================================================================== --- trunk/SelectCreditItems.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/SelectCreditItems.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -5,8 +5,6 @@ /*The credit selection screen uses the Cart class used for the making up orders some of the variable names refer to order - please think credit when you read order */ -//$PageSecurity = 3; - include('includes/DefineCartClass.php'); include('includes/DefineSerialItems.php'); /* Session started in session.inc for password checking and authorisation level check */ Modified: trunk/SelectOrderItems.php =================================================================== --- trunk/SelectOrderItems.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/SelectOrderItems.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -660,7 +660,7 @@ } else { echo '<td></td>'; } - echo '<td><input tabindex='.($j+5).' type=submit name="SubmitCustomerSelection' . $j .'" value="' . htmlentities($myrow['brname']) . '"></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'].'"> <td>'.$myrow['contactname'].'</td> <td>'.$myrow['phoneno'].'</td> Modified: trunk/SelectSalesOrder.php =================================================================== --- trunk/SelectSalesOrder.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/SelectSalesOrder.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -53,135 +53,153 @@ purchdata.stockid"; $ErrMsg = _('Unable to retrieve the items on the selected orders for creating purchase orders for'); $ItemResult = DB_query($sql,$db,$ErrMsg); + /*Now get the default delivery address details from the users default stock location */ + $sql = "SELECT locationame, + 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)){ - $SupplierID = $ItemRow['supplierno']; - /*Now get all the required details for the supplier */ - - - - - - - - $result = DB_Txn_Begin($db); - - /*figure out what status to set the order to */ - if (IsEmailAddress($_SESSION['UserEmail'])){ - $UserDetails = ' <a href="mailto:' . $_SESSION['UserEmail'] . '">' . $_SESSION['UsersRealName']. '</a>'; - } else { - $UserDetails = ' ' . $_SESSION['UsersRealName'] . ' '; - } - if ($_SESSION['AutoAuthorisePO']==1) { //if the user has authority to authorise the PO then it will automatically be authorised - $AuthSQL ="SELECT authlevel - FROM purchorderauth - WHERE userid='".$_SESSION['UserID']."' - AND currabrev='".$_SESSION['PO'.$identifier]->CurrCode."'"; - - $AuthResult=DB_query($AuthSQL,$db); - $AuthRow=DB_fetch_array($AuthResult); + 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 (DB_num_rows($AuthResult) > 0 AND $AuthRow['authlevel'] > $_SESSION['PO'.$identifier]->Order_Value()) { //user has authority to authrorise as well as create the order - $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created and Authorised by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; - $_SESSION['PO'.$identifier]->AllowPrintPO=1; - $_SESSION['PO'.$identifier]->Status = 'Authorised'; - } else { // no authority to authorise this order - if (DB_num_rows($AuthResult) ==0){ - $AuthMessage = _('Your authority to approve purchase orders in') . ' ' . $_SESSION['PO'.$identifier]->CurrCode . ' ' . _('has not yet been set up') . '<br />'; - } else { - $AuthMessage = _('You can only authorise up to').' '.$_SESSION['PO'.$identifier]->CurrCode.' '.$AuthorityLevel.'.<br />'; + if ($SupplierID !='' AND $_SESSION['AutoAuthorisePO']==1) { + //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']."'"; + + $AuthResult=DB_query($AuthSQL,$db); + $AuthRow=DB_fetch_array($AuthResult); + + 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', + statuscomment='" . $StatusComment . "' + WHERE orderno='" . $OrderNo . "'", + $db); + } 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'); } - - prnMsg( _('You do not have permission to authorise this purchase order').'.<br />'. _('This order is for').' '. - $_SESSION['PO'.$identifier]->CurrCode . ' '. $_SESSION['PO'.$identifier]->Order_Value() .'. '. - $AuthMessage . - _('If you think this is a mistake please contact the systems administrator') . '<br />'. - _('The order will be created with a status of pending and will require authorisation'), 'warn'); - - $_SESSION['PO'.$identifier]->AllowPrintPO=0; - $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; - $_SESSION['PO'.$identifier]->Status = 'Pending'; + } //end of authorisation status settings + + if ($SupplierID !=''){ //then we have just added a purchase order + DB_Txn_Commit($db); } - } else { //auto authorise is set to off - $_SESSION['PO'.$identifier]->AllowPrintPO=0; - $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; - $_SESSION['PO'.$identifier]->Status = 'Pending'; - } - - if ($_SESSION['ExistingOrder']==0){ /*its a new order to be inserted */ - - //Do we need to check authorisation to create - no because already trapped when new PO session started + /*Starting a new purchase order with a different supplier */ + $result = DB_Txn_Begin($db); + $OrderNo = GetNextTransNo(18, $db); //get the next PO number - /*Get the order number */ - $_SESSION['PO'.$identifier]->OrderNo = GetNextTransNo(18, $db); - + $SupplierID = $ItemRow['supplierno']; + $Order_Value =0; + /*Now get all the required details for the supplier */ + $sql = "SELECT address1, + address2, + address3, + address4, + address5, + address6, + suppliercontact, + telephone, + paymentterms, + currcode, + rate + FROM suppliers INNER JOIN currencies + ON suppliers.currcode = currencies.currabrev + WHERE supplierno='" . $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, - comments, - orddate, - rate, - initiator, - requisitionno, - intostocklocation, - deladd1, - deladd2, - deladd3, - deladd4, - deladd5, - deladd6, - tel, - suppdeladdress1, - suppdeladdress2, - suppdeladdress3, - suppdeladdress4, - suppdeladdress5, - suppdeladdress6, - suppliercontact, - supptel, - contact, - version, - revised, - deliveryby, - status, - stat_comment, - deliverydate, - paymentterms, - allowprint) - VALUES( '" . $_SESSION['PO'.$identifier]->OrderNo . "', - '" . $_SESSION['PO'.$identifier]->SupplierID . "', - '" . $_SESSION['PO'.$identifier]->Comments . "', - '" . Date('Y-m-d') . "', - '" . $_SESSION['PO'.$identifier]->ExRate . "', - '" . $_SESSION['PO'.$identifier]->Initiator . "', - '" . $_SESSION['PO'.$identifier]->RequisitionNo . "', - '" . $_SESSION['PO'.$identifier]->Location . "', - '" . $_SESSION['PO'.$identifier]->DelAdd1 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd2 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd3 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd4 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd5 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd6 . "', - '" . $_SESSION['PO'.$identifier]->Tel . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd1 . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd2 . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd3 . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd4 . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd5 . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd6 . "', - '" . $_SESSION['PO'.$identifier]->SupplierContact . "', - '" . $_SESSION['PO'.$identifier]->SuppTel. "', - '" . $_SESSION['PO'.$identifier]->Contact . "', - '" . $_SESSION['PO'.$identifier]->Version . "', - '" . Date('Y-m-d') . "', - '" . $_SESSION['PO'.$identifier]->DeliveryBy . "', - '" . $_SESSION['PO'.$identifier]->Status . "', - '" . $StatusComment . "', - '" . FormatDateForSQL($_SESSION['PO'.$identifier]->DeliveryDate) . "', - '" . $_SESSION['PO'.$identifier]->PaymentTerms. "', - '" . $_SESSION['PO'.$identifier]->AllowPrintPO . "' - )"; + 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( '" . $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)"; $ErrMsg = _('The purchase order header record could not be inserted into the database because'); $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); @@ -191,50 +209,50 @@ foreach ($_SESSION['PO'.$identifier]->LineItems as $POLine) { if ($POLine->Deleted==False) { $sql = "INSERT INTO purchorderdetails ( orderno, - itemcode, - deliverydate, - itemdescription, - glcode, - unitprice, - quantityord, - shiptref, - jobref, - itemno, - suppliersunit, - suppliers_partno, - subtotal_amount, - package, - pcunit, - netweight, - kgs, - cuft, - total_quantity, - total_amount, - assetid, - conversionfactor ) - VALUES ( - '" . $_SESSION['PO'.$identifier]->OrderNo . "', - '" . $POLine->StockID . "', - '" . FormatDateForSQL($POLine->ReqDelDate) . "', - '" . $POLine->ItemDescription . "', - '" . $POLine->GLCode . "', - '" . $POLine->Price . "', - '" . $POLine->Quantity . "', - '" . $POLine->ShiptRef . "', - '" . $POLine->JobRef . "', - '" . $POLine->ItemNo . "', - '" . $POLine->SuppliersUnit . "', - '" . $POLine->Suppliers_PartNo . "', - '" . $POLine->SubTotal_Amount . "', - '" . $POLine->Package . "', - '" . $POLine->PcUnit . "', - '" . $POLine->NetWeight . "', - '" . $POLine->KGs . "', - '" . $POLine->CuFt . "', - '" . $POLine->Total_Quantity . "', - '" . $POLine->Total_Amount . "', - '" . $POLine->AssetID . "', - '" . $POLine->ConversionFactor . "')"; + itemcode, + deliverydate, + itemdescription, + glcode, + unitprice, + quantityord, + shiptref, + jobref, + itemno, + suppliersunit, + suppliers_partno, + subtotal_amount, + package, + pcunit, + netweight, + kgs, + cuft, + total_quantity, + total_amount, + assetid, + conversionfactor ) + VALUES ( + '" . $_SESSION['PO'.$identifier]->OrderNo . "', + '" . $POLine->StockID . "', + '" . FormatDateForSQL($POLine->ReqDelDate) . "', + '" . $POLine->ItemDescription . "', + '" . $POLine->GLCode . "', + '" . $POLine->Price . "', + '" . $POLine->Quantity . "', + '" . $POLine->ShiptRef . "', + '" . $POLine->JobRef . "', + '" . $POLine->ItemNo . "', + '" . $POLine->SuppliersUnit . "', + '" . $POLine->Suppliers_PartNo . "', + '" . $POLine->SubTotal_Amount . "', + '" . $POLine->Package . "', + '" . $POLine->PcUnit . "', + '" . $POLine->NetWeight . "', + '" . $POLine->KGs . "', + '" . $POLine->CuFt . "', + '" . $POLine->Total_Quantity . "', + '" . $POLine->Total_Amount . "', + '" . $POLine->AssetID . "', + '" . $POLine->ConversionFactor . "')"; $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/doc/Change.log.html 2011-03-11 20:24:03 UTC (rev 4507) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>12/3/11: Exson fix all htmlentities to use ENTQUOTES, 'UTF-8' option so other character sets work with it</p> <p>10/3/11: Phil fix pagination of PrintCustOrder_generic.php - second copy was not restarting page numbers</p> <p>10/3/11: Tims launchpad fixes brought in MRP.php fix for table charset utf8 so joins work correctly; typeo in PO_Header preventing purchasing data being retrieved ($result not $Result); correct sql on searching for customer in SelectCreditItems.php; StockStatus.php pricing history bug resolved (4450); StockQuantityByDate.php now allowed to show for all categories - enclosed 'All' in gettext</p> <p>8/3/11: Tim/Phil PO_Items.php in committing an order detail the assetid of 'Not an Asset' was being inserted to an integer field. Modified $_POST['AssetID'] to = 0 if it was 'Not an Asset' as advised by Tim</p> Modified: trunk/includes/MiscFunctions.php =================================================================== --- trunk/includes/MiscFunctions.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/includes/MiscFunctions.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -114,8 +114,7 @@ OR strstr($CheckVariable,"\"") OR strstr($CheckVariable,'&') OR strstr($CheckVariable,"\\") - OR strstr($CheckVariable,'"') - OR strstr($CheckVariable,' ')){ + OR strstr($CheckVariable,'"')){ return true; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-11 20:24:10
|
Revision: 4507 http://web-erp.svn.sourceforge.net/web-erp/?rev=4507&view=rev Author: daintree Date: 2011-03-11 20:24:03 +0000 (Fri, 11 Mar 2011) Log Message: ----------- Exson fix all htmlentities to use ENTQUOTES, UTF-8 option Modified Paths: -------------- trunk/AccountGroups.php trunk/Contracts.php trunk/GLJournal.php trunk/PO_SelectPurchOrder.php trunk/PageSecurity.php trunk/SelectCreditItems.php trunk/SelectOrderItems.php trunk/SelectSalesOrder.php trunk/doc/Change.log.html trunk/includes/MiscFunctions.php Modified: trunk/AccountGroups.php =================================================================== --- trunk/AccountGroups.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/AccountGroups.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -68,7 +68,7 @@ } if (ContainsIllegalCharacters($_POST['GroupName'])) { $InputError = 1; - prnMsg( _('The account group name cannot contain the character') . " '&' " . _('or the character') ." '",'error'); + prnMsg( _('The account group name cannot contain the character') . " '&' " . _('or the character') ."' '",'error'); $Errors[$i] = 'GroupName'; $i++; } @@ -257,13 +257,13 @@ break; } //end of switch statement - echo '<td>' . htmlentities($myrow[0]) . '</td> + echo '<td>' . htmlentities($myrow[0], ENT_QUOTES,'UTF-8') . '</td> <td>' . $myrow[1] . '</td> <td>' . $myrow[2] . '</td> <td>' . $PandLText . '</td> <td>' . $myrow[4] . '</td>'; - echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&SelectedAccountGroup=' . htmlentities($myrow[0]) . '">' . _('Edit') . '</a></td>'; - echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&SelectedAccountGroup=' . htmlentities($myrow[0]) . '&delete=1">' . _('Delete') .'</a></td></tr>'; + echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&SelectedAccountGroup=' . htmlentities($myrow[0], ENT_QUOTES,'UTF-8') . '">' . _('Edit') . '</a></td>'; + echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&SelectedAccountGroup=' . htmlentities($myrow[0], ENT_QUOTES,'UTF-8') . '&delete=1">' . _('Delete') .'</a></td></tr>'; } //END WHILE LIST LOOP echo '</table>'; @@ -353,9 +353,9 @@ while ( $grouprow = DB_fetch_array($groupresult) ) { if (isset($_POST['ParentGroupName']) and $_POST['ParentGroupName']==$grouprow['groupname']) { - echo '<option selected="selected" value="'.htmlentities($grouprow['groupname']).'">' .htmlentities($grouprow['groupname']).'</option>'; + echo '<option selected="selected" value="'.htmlentities($grouprow['groupname'], ENT_QUOTES,'UTF-8').'">' .htmlentities($grouprow['groupname'], ENT_QUOTES,'UTF-8').'</option>'; } else { - echo '<option value="'.htmlentities($grouprow['groupname']).'">' .htmlentities($grouprow['groupname']).'</option>'; + echo '<option value="'.htmlentities($grouprow['groupname'], ENT_QUOTES,'UTF-8').'">' .htmlentities($grouprow['groupname'], ENT_QUOTES,'UTF-8').'</option>'; } } echo '</select>'; Modified: trunk/Contracts.php =================================================================== --- trunk/Contracts.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/Contracts.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -792,13 +792,13 @@ $k=1; } if ($LastCustomer != $myrow['name']) { - echo '<td>'.htmlentities($myrow['name']).'</td>'; + echo '<td>'.htmlentities($myrow['name'], ENT_QUOTES,'UTF-8').'</td>'; } else { echo '<td></td>'; } - echo '<td><input tabindex="'.($j+5).'" type="submit" name="SubmitCustomerSelection' . $j .'" value="'.htmlentities($myrow['brname']).'" /></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'].'" /> - <td>'.htmlentities($myrow['contactname']).'</td> + <td>'.htmlentities($myrow['contactname'], ENT_QUOTES,'UTF-8') .'</td> <td>'.$myrow['phoneno'].'</td> <td>'.$myrow['faxno'].'</td> </tr>'; Modified: trunk/GLJournal.php =================================================================== --- trunk/GLJournal.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/GLJournal.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -249,175 +249,173 @@ $_SESSION['JournalDetail']->JnlDate = Date($_SESSION['DefaultDateFormat'],mktime(0,0,0,date('m'),0,date('Y'))); } - echo '<table><tr> - <td colspan="5"><table class="selection"><tr><td>'._('Date to Process Journal').":</td> - <td><input type='text' class='date' alt='".$_SESSION['DefaultDateFormat']."' name='JournalProcessDate' maxlength='10' size='11' value='" . - $_SESSION['JournalDetail']->JnlDate . "' /></td>"; - echo '<td>' . _('Type') . ':</td> - <td><select name="JournalType">'; +echo '<table><tr> + <td colspan="5"><table class="selection"><tr><td>'._('Date to Process Journal').":</td> + <td><input type='text' class='date' alt='".$_SESSION['DefaultDateFormat']."' name='JournalProcessDate' maxlength='10' size='11' value='" . + $_SESSION['JournalDetail']->JnlDate . "' /></td>"; +echo '<td>' . _('Type') . ':</td> + <td><select name="JournalType">'; - if ($_POST['JournalType'] == 'Reversing'){ - echo "<option selected='True' value = 'Reversing'>" . _('Reversing')."</option>"; - echo "<option value = 'Normal'>" . _('Normal')."</option>"; - } else { - echo "<option value = 'Reversing'>" . _('Reversing')."</option>"; - echo "<option selected='True' value = 'Normal'>" . _('Normal')."</option>"; - } +if ($_POST['JournalType'] == 'Reversing'){ + echo '<option selected="True" value = "Reversing">' . _('Reversing').'</option>'; + echo '<option value = "Normal">' . _('Normal').'</option>'; +} else { + echo '<option value = "Reversing">' . _('Reversing').'</option>'; + echo '<option selected="True" value = "Normal">' . _('Normal') . '</option>'; +} - echo '</select></td> - </tr> - </table>'; - /* close off the table in the first column */ +echo '</select></td> + </tr> + </table>'; +/* close off the table in the first column */ - echo '<br />'; - echo '<table class="selection" width="70%">'; - /* Set upthe form for the transaction entry for a GL Payment Analysis item */ +echo '<br />'; +echo '<table class="selection" width="70%">'; +/* Set upthe form for the transaction entry for a GL Payment Analysis item */ - echo '<tr><th colspan="3"><div class="centre"><font size="3" color="blue"><b>' . _('Journal Line Entry') . '</b></font></div></th></tr>'; +echo '<tr><th colspan="3"><div class="centre"><font size="3" color="blue"><b>' . _('Journal Line Entry') . '</b></font></div></th></tr>'; - /*now set up a GLCode field to select from avaialble GL accounts */ - echo '<tr><th>' . _('GL Tag') . '</th>'; - echo '<th>' . _('GL Account Code') . '</th>'; - echo '<th>' . _('Select GL Account') . '</th></tr>'; +/*now set up a GLCode field to select from avaialble GL accounts */ +echo '<tr><th>' . _('GL Tag') . '</th>'; +echo '<th>' . _('GL Account Code') . '</th>'; +echo '<th>' . _('Select GL Account') . '</th></tr>'; /* Set upthe form for the transaction entry for a GL Payment Analysis item */ - //Select the tag - echo '<tr><td><select name="tag">'; +//Select the tag +echo '<tr><td><select name="tag">'; - $SQL = "SELECT tagref, - tagdescription - FROM tags - ORDER BY tagref"; +$SQL = 'SELECT tagref, + tagdescription + FROM tags + ORDER BY tagref'; - $result=DB_query($SQL,$db); - echo '<option value="0">0 - None</option>'; - while ($myrow=DB_fetch_array($result)){ - if (isset($_POST['tag']) and $_POST['tag']==$myrow['tagref']){ - echo '<option selected value="' . $myrow['tagref'] . '">' . $myrow['tagref'].' - ' .$myrow['tagdescription']."</option>"; - } else { - echo '<option value="' . $myrow['tagref'] . '">' . $myrow['tagref'].' - ' .$myrow['tagdescription']."</option>"; - } +$result=DB_query($SQL,$db); +echo '<option value="0">0 - None</option>'; +while ($myrow=DB_fetch_array($result)){ + if (isset($_POST['tag']) and $_POST['tag']==$myrow['tagref']){ + echo '<option selected value="' . $myrow['tagref'] . '">' . $myrow['tagref'].' - ' .$myrow['tagdescription'].'</option>'; + } else { + echo '<option value="' . $myrow['tagref'] . '">' . $myrow['tagref'].' - ' .$myrow['tagdescription'] . '</option>'; } - echo '</select></td>'; +} +echo '</select></td>'; // End select tag - if (!isset($_POST['GLManualCode'])) { - $_POST['GLManualCode']=''; - } - echo '<td><input class="number" type="text" Name="GLManualCode" Maxlength="12" size="12" onChange="inArray(this.value, GLCode.options,'. - "'".'The account code '."'".'+ this.value+ '."'".' doesnt exist'."'".')"' . - ' value="'. $_POST['GLManualCode'] .'" /></td>'; +if (!isset($_POST['GLManualCode'])) { + $_POST['GLManualCode']=''; +} +echo '<td><input class="number" type="text" Name="GLManualCode" Maxlength="12" size="12" onChange="inArray(this.value, GLCode.options,'. + "'".'The account code '."'".'+ this.value+ '."'".' doesnt exist'."'".')"' . + ' value="'. $_POST['GLManualCode'] .'" /></td>'; - $sql="SELECT accountcode, - accountname - FROM chartmaster - ORDER BY accountcode"; +$sql="SELECT accountcode, + accountname + FROM chartmaster + ORDER BY accountcode"; - $result=DB_query($sql, $db); - echo '<td><select name="GLCode" onChange="return assignComboToInput(this,'.'GLManualCode'.')">'; - echo '<option value="">' . _('Select a general ledger account code') . '</option>'; - while ($myrow=DB_fetch_array($result)){ - if (isset($_POST['tag']) and $_POST['tag']==$myrow['accountcode']){ - echo '<option selected value="' . $myrow['accountcode'] . '">' . $myrow['accountcode'].' - ' .htmlentities($myrow['accountname'])."</option>"; - } else { - echo '<option value="' . $myrow['accountcode'] . '">' . $myrow['accountcode'].' - ' .htmlentities($myrow['accountname'])."</option>"; - } +$result=DB_query($sql, $db); +echo '<td><select name="GLCode" onChange="return assignComboToInput(this,'.'GLManualCode'.')">'; +echo '<option value="">' . _('Select a general ledger account code') . '</option>'; +while ($myrow=DB_fetch_array($result)){ + if (isset($_POST['tag']) and $_POST['tag']==$myrow['accountcode']){ + echo '<option selected value="' . $myrow['accountcode'] . '">' . $myrow['accountcode'].' - ' .htmlentities($myrow['accountname'], ENT_QUOTES,'UTF-8') . '</option>'; + } else { + echo '<option value="' . $myrow['accountcode'] . '">' . $myrow['accountcode'].' - ' .htmlentities($myrow['accountname'], ENT_QUOTES,'UTF-8') .'</option>'; } - echo '</select></td>'; +} +echo '</select></td>'; - if (!isset($_POST['GLNarrative'])) { - $_POST['GLNarrative'] = ''; - } - if (!isset($_POST['Credit'])) { - $_POST['Credit'] = ''; - } - if (!isset($_POST['Debit'])) { - $_POST['Debit'] = ''; - } +if (!isset($_POST['GLNarrative'])) { + $_POST['GLNarrative'] = ''; +} +if (!isset($_POST['Credit'])) { + $_POST['Credit'] = ''; +} +if (!isset($_POST['Debit'])) { + $_POST['Debit'] = ''; +} - echo '</tr><tr><th>' . _('Debit') . "</th>".'<td><input type="text" class="number" Name = "Debit" ' . - 'onChange="eitherOr(this, '.'Credit'.')"'. - ' Maxlength="12" size="10" value="' . $_POST['Debit'] . '" /></td>'; - echo '</tr><tr><th>' . _('Credit') . "</th>".'<td><input type="text" class="number" Name = "Credit" ' . - 'onChange="eitherOr(this, '.'Debit'.')"'. - ' Maxlength="12" size="10" value="' . $_POST['Credit'] . '" /></td>'; - echo '</tr><tr><td></td><td></td><th>'. _('Narrative'). '</th>'; - echo '</tr><tr><th></th><th>' . _('GL Narrative') . "</th>"; +echo '</tr><tr><th>' . _('Debit') . '</th>'.'<td><input type="text" class="number" Name = "Debit" ' . + 'onChange="eitherOr(this, '.'Credit'.')"'. + ' Maxlength="12" size="10" value="' . $_POST['Debit'] . '" /></td>'; +echo '</tr><tr><th>' . _('Credit') . "</th>".'<td><input type="text" class="number" Name = "Credit" ' . + 'onChange="eitherOr(this, '.'Debit'.')"'. + ' Maxlength="12" size="10" value="' . $_POST['Credit'] . '" /></td>'; +echo '</tr><tr><td></td><td></td><th>'. _('Narrative'). '</th>'; +echo '</tr><tr><th></th><th>' . _('GL Narrative') . "</th>"; - echo '<td><input type="text" name="GLNarrative" maxlength="100" size="100" value="' . $_POST['GLNarrative'] . '" /></td>'; +echo '<td><input type="text" name="GLNarrative" maxlength="100" size="100" value="' . $_POST['GLNarrative'] . '" /></td>'; - echo '</tr></table><br />'; /*Close the main table */ - echo "<div class='centre'><input type='submit' name='Process' value='" . _('Accept') . "' /></div><br /><br />"; +echo '</tr></table><br />'; /*Close the main table */ +echo "<div class='centre'><input type='submit' name='Process' value='" . _('Accept') . "' /></div><br /><br />"; - echo "<table class='selection' width='85%'>"; +echo '<table class="selection" width="85%">'; - echo '<tr><th colspan="6"><div class="centre"><font size="3" color="blue"><b>' . _('Journal Summary') . '</b></font></div></th></tr>'; - echo "<tr> - <th>"._('GL Tag')."</th> - <th>"._('GL Account')."</th> - <th>"._('Debit')."</th> - <th>"._('Credit')."</th> - <th>"._('Narrative').'</th></tr>'; +echo '<tr><th colspan="6"><div class="centre"><font size="3" color="blue"><b>' . _('Journal Summary') . '</b></font></div></th></tr>'; +echo '<tr> + <th>'._('GL Tag').'</th> + <th>'._('GL Account').'</th> + <th>'._('Debit').'</th> + <th>'._('Credit').'</th> + <th>'._('Narrative').'</th></tr>'; - $debittotal=0; - $credittotal=0; - $j=0; +$debittotal=0; +$credittotal=0; +$j=0; - foreach ($_SESSION['JournalDetail']->GLEntries as $JournalItem) { - if ($j==1) { - echo '<tr class="OddTableRows">'; - $j=0; - } else { - echo '<tr class="EvenTableRows">'; - $j++; - } - $sql="SELECT tagdescription - FROM tags - WHERE tagref='".$JournalItem->tag . "'"; - $result=DB_query($sql, $db); - $myrow=DB_fetch_row($result); - if ($JournalItem->tag==0) { - $tagdescription='None'; - } else { - $tagdescription=$myrow[0]; - } - echo "<td>" . $JournalItem->tag . ' - ' . $tagdescription . "</td>"; - echo "<td>" . $JournalItem->GLCode . ' - ' . $JournalItem->GLActName . "</td>"; - if($JournalItem->Amount>0) - { - echo "<td class='number'>" . number_format($JournalItem->Amount,2) . '</td><td></td>'; - $debittotal=$debittotal+$JournalItem->Amount; - } - elseif($JournalItem->Amount<0) - { - $credit=(-1 * $JournalItem->Amount); - echo "<td></td> - <td class='number'>" . number_format($credit,2) . '</td>'; - $credittotal=$credittotal+$credit; - } +foreach ($_SESSION['JournalDetail']->GLEntries as $JournalItem) { + if ($j==1) { + echo '<tr class="OddTableRows">'; + $j=0; + } else { + echo '<tr class="EvenTableRows">'; + $j++; + } + $sql="SELECT tagdescription + FROM tags + WHERE tagref='".$JournalItem->tag . "'"; + $result=DB_query($sql, $db); + $myrow=DB_fetch_row($result); + if ($JournalItem->tag==0) { + $tagdescription='None'; + } else { + $tagdescription=$myrow[0]; + } + echo '<td>' . $JournalItem->tag . ' - ' . $tagdescription . '</td>'; + echo '<td>' . $JournalItem->GLCode . ' - ' . $JournalItem->GLActName . '</td>'; + if ($JournalItem->Amount>0) { + echo '<td class="number">' . number_format($JournalItem->Amount,2) . '</td><td></td>'; + $debittotal=$debittotal+$JournalItem->Amount; + + } elseif($JournalItem->Amount<0) { + $credit=(-1 * $JournalItem->Amount); + echo '<td></td> + <td class="number">' . number_format($credit,2) . '</td>'; + $credittotal=$credittotal+$credit; + } - echo '<td>' . $JournalItem->Narrative . "</td> - <td><a href='" . $_SERVER['PHP_SELF'] . '?' . SID . '&Delete=' . $JournalItem->ID . "'>"._('Delete').'</a></td> - </tr>'; - } + echo '<td>' . $JournalItem->Narrative . "</td> + <td><a href='" . $_SERVER['PHP_SELF'] . '?' . SID . '&Delete=' . $JournalItem->ID . "'>"._('Delete').'</a></td> + </tr>'; +} - echo '<tr class="EvenTableRows"><td></td> - <td class="number"><b> Total </b></td> - <td class="number"><b>' . number_format($debittotal,2) . '</b></td> - <td class="number"><b>' . number_format($credittotal,2) . '</b></td></tr>'; - if ($debittotal!=$credittotal) { - echo '<td align="center" style="background-color: #fddbdb"><b>Required to balance - </b>' . - number_format(abs($debittotal-$credittotal),2); - } - if ($debittotal>$credittotal) { - echo ' Credit</td></tr>'; - } else if ($debittotal<$credittotal) { - echo ' Debit</td></tr>'; - } - echo '</table>'; +echo '<tr class="EvenTableRows"><td></td> + <td class="number"><b> Total </b></td> + <td class="number"><b>' . number_format($debittotal,2) . '</b></td> + <td class="number"><b>' . number_format($credittotal,2) . '</b></td></tr>'; +if ($debittotal!=$credittotal) { + echo '<td align="center" style="background-color: #fddbdb"><b>Required to balance - </b>' . + number_format(abs($debittotal-$credittotal),2); +} +if ($debittotal>$credittotal) { + echo ' Credit</td></tr>'; +} else if ($debittotal<$credittotal) { + echo ' Debit</td></tr>'; +} +echo '</table>'; if (ABS($_SESSION['JournalDetail']->JournalTotal)<0.001 AND $_SESSION['JournalDetail']->GLItemCounter > 0){ echo "<br /><br /><div class='centre'><input type='submit' name='CommitBatch' value='"._('Accept and Process Journal')."' /></div>"; Modified: trunk/PO_SelectPurchOrder.php =================================================================== --- trunk/PO_SelectPurchOrder.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/PO_SelectPurchOrder.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -121,10 +121,10 @@ } } echo '</select> ' . _('Order Status:') .' <select name="Status">'; - if (!isset($_POST['Status']) OR $_POST['Status']=='Pending_Authorised'){ - echo '<option selected value="Pending_Authorised">' . _('Pending and Authorised') . '</option>'; + if (!isset($_POST['Status']) OR $_POST['Status']=='Pending_Authorised_Completed'){ + echo '<option selected value="Pending_Authorised_Completed">' . _('Pending/Authorised/Completed') . '</option>'; } else { - echo '<option value="Pending_Authorised">' . _('Pending and Authorised') . '</option>'; + echo '<option value="Pending_Authorised_Completed">' . _('Pending/Authorised/Completed') . '</option>'; } if ($_POST['Status']=='Pending'){ echo '<option selected value="Pending">' . _('Pending') . '</option>'; @@ -136,6 +136,11 @@ } else { echo '<option value="Authorised">' . _('Authorised') . '</option>'; } + if ($_POST['Status']=='Completed'){ + echo '<option selected value="Completed">' . _('Completed') . '</option>'; + } else { + echo '<option value="Completed">' . _('Completed') . '</option>'; + } if ($_POST['Status']=='Cancelled'){ echo '<option selected value="Cancelled">' . _('Cancelled') . '</option>'; } else { @@ -207,8 +212,8 @@ else { //figure out the SQL required from the inputs available - if (!isset($_POST['Status']) OR $_POST['Status']=='Pending_Authorised'){ - $StatusCriteria = " AND (purchorders.status='Pending' OR purchorders.status='Authorised' OR purchorders.status='Printed') "; + if (!isset($_POST['Status']) OR $_POST['Status']=='Pending_Authorised_Completed'){ + $StatusCriteria = " AND (purchorders.status='Pending' OR purchorders.status='Authorised' OR purchorders.status='Printed' OR purchorders.status='Completed') "; }elseif ($_POST['Status']=='Authorised'){ $StatusCriteria = " AND (purchorders.status='Authorised' OR purchorders.status='Printed')"; }elseif ($_POST['Status']=='Pending'){ @@ -217,25 +222,26 @@ $StatusCriteria = " AND purchorders.status='Rejected' "; }elseif ($_POST['Status']=='Cancelled'){ $StatusCriteria = " AND purchorders.status='Cancelled' "; + } elseif($_POST['Status']=='Completed'){ + $StatusCriteria = " AND purchorders.status='Completed' "; } - if (isset($OrderNumber) && $OrderNumber != "") { $SQL = "SELECT purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - purchorders.status, - suppliers.currcode, - SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue - FROM purchorders, - purchorderdetails, - suppliers - WHERE purchorders.orderno = purchorderdetails.orderno - AND purchorders.supplierno = suppliers.supplierid - AND purchorders.orderno='" . $OrderNumber . "' - GROUP BY purchorders.orderno"; + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + purchorders.status, + suppliers.currcode, + SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue + FROM purchorders, + purchorderdetails, + suppliers + WHERE purchorders.orderno = purchorderdetails.orderno + AND purchorders.supplierno = suppliers.supplierid + AND purchorders.orderno='" . $OrderNumber . "' + GROUP BY purchorders.orderno"; } else { /* $DateAfterCriteria = FormatDateforSQL($OrdersAfterDate); */ if (empty($_POST['StockLocation'])) { @@ -244,106 +250,106 @@ if (isset($SelectedSupplier)) { if (isset($SelectedStockItem)) { $SQL = "SELECT purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - purchorders.status, - suppliers.currcode, - SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue - FROM purchorders, - purchorderdetails, - suppliers - WHERE purchorders.orderno = purchorderdetails.orderno - AND purchorders.supplierno = suppliers.supplierid - AND purchorderdetails.itemcode='" . $SelectedStockItem . "' - AND purchorders.supplierno='" . $SelectedSupplier . "' - AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' - " . $StatusCriteria . " - GROUP BY purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - suppliers.currcode"; + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + purchorders.status, + suppliers.currcode, + SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue + FROM purchorders, + purchorderdetails, + suppliers + WHERE purchorders.orderno = purchorderdetails.orderno + AND purchorders.supplierno = suppliers.supplierid + AND purchorderdetails.itemcode='" . $SelectedStockItem . "' + AND purchorders.supplierno='" . $SelectedSupplier . "' + AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' + " . $StatusCriteria . " + GROUP BY purchorders.orderno, + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + suppliers.currcode"; } else { $SQL = "SELECT purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - purchorders.status, - suppliers.currcode, - SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue - FROM purchorders, - purchorderdetails, - suppliers - WHERE purchorders.orderno = purchorderdetails.orderno - AND purchorders.supplierno = suppliers.supplierid - AND purchorders.supplierno='" . $SelectedSupplier . "' - AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' - " . $StatusCriteria . " - GROUP BY purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - suppliers.currcode"; + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + purchorders.status, + suppliers.currcode, + SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue + FROM purchorders, + purchorderdetails, + suppliers + WHERE purchorders.orderno = purchorderdetails.orderno + AND purchorders.supplierno = suppliers.supplierid + AND purchorders.supplierno='" . $SelectedSupplier . "' + AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' + " . $StatusCriteria . " + GROUP BY purchorders.orderno, + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + suppliers.currcode"; } } else { //no supplier selected if (isset($SelectedStockItem)) { $SQL = "SELECT purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - purchorders.status, - suppliers.currcode, - SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue - FROM purchorders, - purchorderdetails, - suppliers - WHERE purchorders.orderno = purchorderdetails.orderno - AND purchorders.supplierno = suppliers.supplierid - AND purchorderdetails.itemcode='" . $SelectedStockItem . "' - AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' - " . $StatusCriteria . " - GROUP BY purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - suppliers.currcode"; + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + purchorders.status, + suppliers.currcode, + SUM(purchorderdetails.unitprice*purchorderdetails.quantityord) AS ordervalue + FROM purchorders, + purchorderdetails, + suppliers + WHERE purchorders.orderno = purchorderdetails.orderno + AND purchorders.supplierno = suppliers.supplierid + AND purchorderdetails.itemcode='" . $SelectedStockItem . "' + AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' + " . $StatusCriteria . " + GROUP BY purchorders.orderno, + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + suppliers.currcode"; } else { $SQL = "SELECT purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - purchorders.status, - suppliers.currcode, - sum(purchorderdetails.unitprice*purchorderdetails.quantityord) as ordervalue - FROM purchorders, - purchorderdetails, - suppliers - WHERE purchorders.orderno = purchorderdetails.orderno - AND purchorders.supplierno = suppliers.supplierid - AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' - " . $StatusCriteria . " - GROUP BY purchorders.orderno, - suppliers.suppname, - purchorders.orddate, - purchorders.initiator, - purchorders.requisitionno, - purchorders.allowprint, - suppliers.currcode"; + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + purchorders.status, + suppliers.currcode, + sum(purchorderdetails.unitprice*purchorderdetails.quantityord) as ordervalue + FROM purchorders, + purchorderdetails, + suppliers + WHERE purchorders.orderno = purchorderdetails.orderno + AND purchorders.supplierno = suppliers.supplierid + AND purchorders.intostocklocation = '" . $_POST['StockLocation'] . "' + " . $StatusCriteria . " + GROUP BY purchorders.orderno, + suppliers.suppname, + purchorders.orddate, + purchorders.initiator, + purchorders.requisitionno, + purchorders.allowprint, + suppliers.currcode"; } } //end selected supplier @@ -377,17 +383,17 @@ $ViewPurchOrder = $rootpath . '/PO_OrderDetails.php?' . SID . 'OrderNo=' . $myrow['orderno']; $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); $FormatedOrderValue = number_format($myrow['ordervalue'], 2); - /* View Supplier Currency Requisition Order Date Initiator Order Total + /* View Supplier Currency Requisition Order Date Initiator Order Total ModifyPage, $myrow["orderno"], $myrow["suppname"], $myrow["currcode"], $myrow["requisitionno"] $FormatedOrderDate, $myrow["initiator"] $FormatedOrderValue Order Status*/ - echo "<td><a href='" . $ViewPurchOrder . "'>" . $myrow['orderno'] . "</a></td> - <td>" . $myrow['suppname'] . "</td> - <td>" . $myrow['currcode'] . "</td> - <td>" . $myrow['requisitionno'] . "</td> - <td>" . $FormatedOrderDate . "</td> - <td>" . $myrow['initiator'] . "</td> - <td class=number>" . $FormatedOrderValue . "</td> - <td>" . _($myrow['status']) . "</td> - </tr>"; + echo '<td><a href="' . $ViewPurchOrder . '">' . $myrow['orderno'] . '</a></td> + <td>' . $myrow['suppname'] . '</td> + <td>' . $myrow['currcode'] . '</td> + <td>' . $myrow['requisitionno'] . '</td> + <td>' . $FormatedOrderDate . '</td> + <td>' . $myrow['initiator'] . '</td> + <td class=number>' . $FormatedOrderValue . '</td> + <td>' . _($myrow['status']) . '</td> + </tr>'; //$myrow['status'] is a string which has gettext translations from PO_Header.php script $j++; Modified: trunk/PageSecurity.php =================================================================== --- trunk/PageSecurity.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/PageSecurity.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -40,9 +40,9 @@ echo '<td><select name="'.$myrow['script'].'">'; while ($mytokenrow=DB_fetch_array($TokenResult)) { if ($mytokenrow['tokenid']==$myrow['pagesecurity']) { - echo '<option selected="True" value="'.$mytokenrow['tokenid'].'">'.htmlentities($mytokenrow['tokenname']).'</option>'; + echo '<option selected="True" value="'.$mytokenrow['tokenid'].'">'.htmlentities($mytokenrow['tokenname'], ENT_QUOTES,'UTF-8') .'</option>'; } else { - echo '<option value="'.$mytokenrow['tokenid'].'">'.htmlentities($mytokenrow['tokenname']).'</option>'; + echo '<option value="'.$mytokenrow['tokenid'].'">'.htmlentities($mytokenrow['tokenname'], ENT_QUOTES,'UTF-8') .'</option>'; } } echo '</select></td></tr>'; Modified: trunk/SelectCreditItems.php =================================================================== --- trunk/SelectCreditItems.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/SelectCreditItems.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -5,8 +5,6 @@ /*The credit selection screen uses the Cart class used for the making up orders some of the variable names refer to order - please think credit when you read order */ -//$PageSecurity = 3; - include('includes/DefineCartClass.php'); include('includes/DefineSerialItems.php'); /* Session started in session.inc for password checking and authorisation level check */ Modified: trunk/SelectOrderItems.php =================================================================== --- trunk/SelectOrderItems.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/SelectOrderItems.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -660,7 +660,7 @@ } else { echo '<td></td>'; } - echo '<td><input tabindex='.($j+5).' type=submit name="SubmitCustomerSelection' . $j .'" value="' . htmlentities($myrow['brname']) . '"></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'].'"> <td>'.$myrow['contactname'].'</td> <td>'.$myrow['phoneno'].'</td> Modified: trunk/SelectSalesOrder.php =================================================================== --- trunk/SelectSalesOrder.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/SelectSalesOrder.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -53,135 +53,153 @@ purchdata.stockid"; $ErrMsg = _('Unable to retrieve the items on the selected orders for creating purchase orders for'); $ItemResult = DB_query($sql,$db,$ErrMsg); + /*Now get the default delivery address details from the users default stock location */ + $sql = "SELECT locationame, + 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)){ - $SupplierID = $ItemRow['supplierno']; - /*Now get all the required details for the supplier */ - - - - - - - - $result = DB_Txn_Begin($db); - - /*figure out what status to set the order to */ - if (IsEmailAddress($_SESSION['UserEmail'])){ - $UserDetails = ' <a href="mailto:' . $_SESSION['UserEmail'] . '">' . $_SESSION['UsersRealName']. '</a>'; - } else { - $UserDetails = ' ' . $_SESSION['UsersRealName'] . ' '; - } - if ($_SESSION['AutoAuthorisePO']==1) { //if the user has authority to authorise the PO then it will automatically be authorised - $AuthSQL ="SELECT authlevel - FROM purchorderauth - WHERE userid='".$_SESSION['UserID']."' - AND currabrev='".$_SESSION['PO'.$identifier]->CurrCode."'"; - - $AuthResult=DB_query($AuthSQL,$db); - $AuthRow=DB_fetch_array($AuthResult); + 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 (DB_num_rows($AuthResult) > 0 AND $AuthRow['authlevel'] > $_SESSION['PO'.$identifier]->Order_Value()) { //user has authority to authrorise as well as create the order - $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created and Authorised by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; - $_SESSION['PO'.$identifier]->AllowPrintPO=1; - $_SESSION['PO'.$identifier]->Status = 'Authorised'; - } else { // no authority to authorise this order - if (DB_num_rows($AuthResult) ==0){ - $AuthMessage = _('Your authority to approve purchase orders in') . ' ' . $_SESSION['PO'.$identifier]->CurrCode . ' ' . _('has not yet been set up') . '<br />'; - } else { - $AuthMessage = _('You can only authorise up to').' '.$_SESSION['PO'.$identifier]->CurrCode.' '.$AuthorityLevel.'.<br />'; + if ($SupplierID !='' AND $_SESSION['AutoAuthorisePO']==1) { + //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']."'"; + + $AuthResult=DB_query($AuthSQL,$db); + $AuthRow=DB_fetch_array($AuthResult); + + 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', + statuscomment='" . $StatusComment . "' + WHERE orderno='" . $OrderNo . "'", + $db); + } 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'); } - - prnMsg( _('You do not have permission to authorise this purchase order').'.<br />'. _('This order is for').' '. - $_SESSION['PO'.$identifier]->CurrCode . ' '. $_SESSION['PO'.$identifier]->Order_Value() .'. '. - $AuthMessage . - _('If you think this is a mistake please contact the systems administrator') . '<br />'. - _('The order will be created with a status of pending and will require authorisation'), 'warn'); - - $_SESSION['PO'.$identifier]->AllowPrintPO=0; - $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; - $_SESSION['PO'.$identifier]->Status = 'Pending'; + } //end of authorisation status settings + + if ($SupplierID !=''){ //then we have just added a purchase order + DB_Txn_Commit($db); } - } else { //auto authorise is set to off - $_SESSION['PO'.$identifier]->AllowPrintPO=0; - $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; - $_SESSION['PO'.$identifier]->Status = 'Pending'; - } - - if ($_SESSION['ExistingOrder']==0){ /*its a new order to be inserted */ - - //Do we need to check authorisation to create - no because already trapped when new PO session started + /*Starting a new purchase order with a different supplier */ + $result = DB_Txn_Begin($db); + $OrderNo = GetNextTransNo(18, $db); //get the next PO number - /*Get the order number */ - $_SESSION['PO'.$identifier]->OrderNo = GetNextTransNo(18, $db); - + $SupplierID = $ItemRow['supplierno']; + $Order_Value =0; + /*Now get all the required details for the supplier */ + $sql = "SELECT address1, + address2, + address3, + address4, + address5, + address6, + suppliercontact, + telephone, + paymentterms, + currcode, + rate + FROM suppliers INNER JOIN currencies + ON suppliers.currcode = currencies.currabrev + WHERE supplierno='" . $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, - comments, - orddate, - rate, - initiator, - requisitionno, - intostocklocation, - deladd1, - deladd2, - deladd3, - deladd4, - deladd5, - deladd6, - tel, - suppdeladdress1, - suppdeladdress2, - suppdeladdress3, - suppdeladdress4, - suppdeladdress5, - suppdeladdress6, - suppliercontact, - supptel, - contact, - version, - revised, - deliveryby, - status, - stat_comment, - deliverydate, - paymentterms, - allowprint) - VALUES( '" . $_SESSION['PO'.$identifier]->OrderNo . "', - '" . $_SESSION['PO'.$identifier]->SupplierID . "', - '" . $_SESSION['PO'.$identifier]->Comments . "', - '" . Date('Y-m-d') . "', - '" . $_SESSION['PO'.$identifier]->ExRate . "', - '" . $_SESSION['PO'.$identifier]->Initiator . "', - '" . $_SESSION['PO'.$identifier]->RequisitionNo . "', - '" . $_SESSION['PO'.$identifier]->Location . "', - '" . $_SESSION['PO'.$identifier]->DelAdd1 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd2 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd3 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd4 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd5 . "', - '" . $_SESSION['PO'.$identifier]->DelAdd6 . "', - '" . $_SESSION['PO'.$identifier]->Tel . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd1 . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd2 . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd3 . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd4 . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd5 . "', - '" . $_SESSION['PO'.$identifier]->SuppDelAdd6 . "', - '" . $_SESSION['PO'.$identifier]->SupplierContact . "', - '" . $_SESSION['PO'.$identifier]->SuppTel. "', - '" . $_SESSION['PO'.$identifier]->Contact . "', - '" . $_SESSION['PO'.$identifier]->Version . "', - '" . Date('Y-m-d') . "', - '" . $_SESSION['PO'.$identifier]->DeliveryBy . "', - '" . $_SESSION['PO'.$identifier]->Status . "', - '" . $StatusComment . "', - '" . FormatDateForSQL($_SESSION['PO'.$identifier]->DeliveryDate) . "', - '" . $_SESSION['PO'.$identifier]->PaymentTerms. "', - '" . $_SESSION['PO'.$identifier]->AllowPrintPO . "' - )"; + 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( '" . $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)"; $ErrMsg = _('The purchase order header record could not be inserted into the database because'); $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); @@ -191,50 +209,50 @@ foreach ($_SESSION['PO'.$identifier]->LineItems as $POLine) { if ($POLine->Deleted==False) { $sql = "INSERT INTO purchorderdetails ( orderno, - itemcode, - deliverydate, - itemdescription, - glcode, - unitprice, - quantityord, - shiptref, - jobref, - itemno, - suppliersunit, - suppliers_partno, - subtotal_amount, - package, - pcunit, - netweight, - kgs, - cuft, - total_quantity, - total_amount, - assetid, - conversionfactor ) - VALUES ( - '" . $_SESSION['PO'.$identifier]->OrderNo . "', - '" . $POLine->StockID . "', - '" . FormatDateForSQL($POLine->ReqDelDate) . "', - '" . $POLine->ItemDescription . "', - '" . $POLine->GLCode . "', - '" . $POLine->Price . "', - '" . $POLine->Quantity . "', - '" . $POLine->ShiptRef . "', - '" . $POLine->JobRef . "', - '" . $POLine->ItemNo . "', - '" . $POLine->SuppliersUnit . "', - '" . $POLine->Suppliers_PartNo . "', - '" . $POLine->SubTotal_Amount . "', - '" . $POLine->Package . "', - '" . $POLine->PcUnit . "', - '" . $POLine->NetWeight . "', - '" . $POLine->KGs . "', - '" . $POLine->CuFt . "', - '" . $POLine->Total_Quantity . "', - '" . $POLine->Total_Amount . "', - '" . $POLine->AssetID . "', - '" . $POLine->ConversionFactor . "')"; + itemcode, + deliverydate, + itemdescription, + glcode, + unitprice, + quantityord, + shiptref, + jobref, + itemno, + suppliersunit, + suppliers_partno, + subtotal_amount, + package, + pcunit, + netweight, + kgs, + cuft, + total_quantity, + total_amount, + assetid, + conversionfactor ) + VALUES ( + '" . $_SESSION['PO'.$identifier]->OrderNo . "', + '" . $POLine->StockID . "', + '" . FormatDateForSQL($POLine->ReqDelDate) . "', + '" . $POLine->ItemDescription . "', + '" . $POLine->GLCode . "', + '" . $POLine->Price . "', + '" . $POLine->Quantity . "', + '" . $POLine->ShiptRef . "', + '" . $POLine->JobRef . "', + '" . $POLine->ItemNo . "', + '" . $POLine->SuppliersUnit . "', + '" . $POLine->Suppliers_PartNo . "', + '" . $POLine->SubTotal_Amount . "', + '" . $POLine->Package . "', + '" . $POLine->PcUnit . "', + '" . $POLine->NetWeight . "', + '" . $POLine->KGs . "', + '" . $POLine->CuFt . "', + '" . $POLine->Total_Quantity . "', + '" . $POLine->Total_Amount . "', + '" . $POLine->AssetID . "', + '" . $POLine->ConversionFactor . "')"; $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/doc/Change.log.html 2011-03-11 20:24:03 UTC (rev 4507) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>12/3/11: Exson fix all htmlentities to use ENTQUOTES, 'UTF-8' option so other character sets work with it</p> <p>10/3/11: Phil fix pagination of PrintCustOrder_generic.php - second copy was not restarting page numbers</p> <p>10/3/11: Tims launchpad fixes brought in MRP.php fix for table charset utf8 so joins work correctly; typeo in PO_Header preventing purchasing data being retrieved ($result not $Result); correct sql on searching for customer in SelectCreditItems.php; StockStatus.php pricing history bug resolved (4450); StockQuantityByDate.php now allowed to show for all categories - enclosed 'All' in gettext</p> <p>8/3/11: Tim/Phil PO_Items.php in committing an order detail the assetid of 'Not an Asset' was being inserted to an integer field. Modified $_POST['AssetID'] to = 0 if it was 'Not an Asset' as advised by Tim</p> Modified: trunk/includes/MiscFunctions.php =================================================================== --- trunk/includes/MiscFunctions.php 2011-03-10 06:24:48 UTC (rev 4506) +++ trunk/includes/MiscFunctions.php 2011-03-11 20:24:03 UTC (rev 4507) @@ -114,8 +114,7 @@ OR strstr($CheckVariable,"\"") OR strstr($CheckVariable,'&') OR strstr($CheckVariable,"\\") - OR strstr($CheckVariable,'"') - OR strstr($CheckVariable,' ')){ + OR strstr($CheckVariable,'"')){ return true; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-10 06:24:56
|
Revision: 4506 http://web-erp.svn.sourceforge.net/web-erp/?rev=4506&view=rev Author: daintree Date: 2011-03-10 06:24:48 +0000 (Thu, 10 Mar 2011) Log Message: ----------- launchpad changes and pagination of PrintCustOrder_generic.php Modified Paths: -------------- trunk/MRP.php trunk/PO_Header.php trunk/PrintCustOrder_generic.php trunk/SelectCreditItems.php trunk/SelectSalesOrder.php trunk/SelectSupplier.php trunk/StockQuantityByDate.php trunk/StockStatus.php trunk/SupplierCredit.php trunk/doc/Change.log.html trunk/doc/README.txt trunk/doc/UPGRADING.txt Modified: trunk/MRP.php =================================================================== --- trunk/MRP.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/MRP.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -44,11 +44,11 @@ prnMsg(_('Creating first level'),'info'); flush(); // This finds the top level - $sql = "INSERT INTO passbom (part, sortpart) + $sql = 'INSERT INTO passbom (part, sortpart) SELECT bom.component AS part, - CONCAT(bom.parent,'%',bom.component) AS sortpart + CONCAT(bom.parent,"%",bom.component) AS sortpart FROM bom LEFT JOIN bom as bom2 ON bom.parent = bom2.component - WHERE bom2.component IS NULL"; + WHERE bom2.component IS NULL'; $result = DB_query($sql,$db); $lctr = 2; @@ -201,7 +201,7 @@ // Get rid if temporary tables $sql = 'DROP TABLE IF EXISTS tempbom'; -- //$result = DB_query($sql,$db); + //$result = DB_query($sql,$db); $sql = 'DROP TABLE IF EXISTS passbom'; //$result = DB_query($sql,$db); $sql = 'DROP TABLE IF EXISTS passbom2'; @@ -230,7 +230,7 @@ prnMsg(_('Loading requirements from sales orders'),'info'); flush(); - $sql = "INSERT INTO mrprequirements (part, + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, mrpdemandtype, @@ -240,22 +240,22 @@ SELECT stkcode, deliverydate, (quantity - qtyinvoiced) AS netqty, - 'SO', + "SO", salesorderdetails.orderno, - '1', + "1", stkcode FROM salesorders, salesorderdetails WHERE salesorders.orderno = salesorderdetails.orderno AND (quantity - qtyinvoiced) > 0 AND salesorderdetails.completed = 0 - AND salesorders.quotation = 0"; + AND salesorders.quotation = 0'; $result = DB_query($sql,$db); prnMsg(_('Loading requirements from work orders'),'info'); flush(); // Definition of demand from SelectProduct.php - $sql = "INSERT INTO mrprequirements (part, + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, mrpdemandtype, @@ -265,19 +265,19 @@ SELECT worequirements.stockid, workorders.requiredby, qtypu*(woitems.qtyreqd - woitems.qtyrecd) AS netqty, - 'WO', + "WO", woitems.wo, - '1', + "1", parentstockid FROM woitems INNER JOIN worequirements ON woitems.stockid=worequirements.parentstockid INNER JOIN workorders ON woitems.wo=workorders.wo AND woitems.wo=worequirements.wo - WHERE workorders.closed=0"; + WHERE workorders.closed=0'; $result = DB_query($sql,$db); - $sql = "INSERT INTO mrprequirements (part, + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, mrpdemandtype, @@ -289,15 +289,15 @@ quantity, mrpdemandtype, demandid, - '1', + "1", stockid - FROM mrpdemands"; + FROM mrpdemands'; if ($_POST['usemrpdemands'] == 'y') { $result = DB_query($sql,$db); prnMsg(_('Loading requirements based on mrpdemands'),'info'); flush(); } - $sql = "INSERT INTO mrprequirements (part, + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, mrpdemandtype, @@ -307,12 +307,12 @@ SELECT stockid, NOW(), (reorderlevel - quantity) AS reordqty, - 'REORD', - '1', - '1', + "REORD", + "1", + "1", stockid FROM locstock - WHERE reorderlevel > quantity"; + WHERE reorderlevel > quantity'; $result = DB_query($sql,$db); prnMsg(_('Loading requirements based on reorder level'),'info'); flush(); @@ -339,7 +339,7 @@ prnMsg(_('Loading supplies from purchase orders'),'info'); flush(); - $sql = "INSERT INTO mrpsupplies (id, + $sql = 'INSERT INTO mrpsupplies (id, part, duedate, supplyquantity, @@ -351,16 +351,16 @@ purchorderdetails.itemcode, purchorderdetails.deliverydate, (quantityord - quantityrecd) AS netqty, - 'PO', + "PO", purchorderdetails.orderno, purchorderdetails.deliverydate, 0 FROM purchorderdetails, purchorders WHERE purchorderdetails.orderno = purchorders.orderno - AND purchorders.status != 'Cancelled' - AND purchorders.status != 'Rejected' - AND(quantityord - quantityrecd) > 0"; + AND purchorders.status != "Cancelled" + AND purchorders.status != "Rejected" + AND(quantityord - quantityrecd) > 0'; $result = DB_query($sql,$db); prnMsg(_('Loading supplies from inventory on hand'),'info'); @@ -382,7 +382,7 @@ } // End of foreach $WhereLocation .= ')'; } - $sql = "INSERT INTO mrpsupplies (id, + $sql = 'INSERT INTO mrpsupplies (id, part, duedate, supplyquantity, @@ -392,21 +392,21 @@ updateflag) SELECT Null, stockid, - '0000-00-00', + "0000-00-00", SUM(quantity), - 'QOH', + "QOH", 1, - '0000-00-00', + "0000-00-00", 0 FROM locstock - WHERE quantity > 0 ". + WHERE quantity > 0 ' . $WhereLocation . - "GROUP BY stockid"; + 'GROUP BY stockid'; $result = DB_query($sql,$db); prnMsg(_('Loading supplies from work orders'),'info'); flush(); - $sql = "INSERT INTO mrpsupplies (id, + $sql = 'INSERT INTO mrpsupplies (id, part, duedate, supplyquantity, @@ -418,13 +418,13 @@ stockid, workorders.requiredby, (woitems.qtyreqd-woitems.qtyrecd) AS netqty, - 'WO', + "WO", woitems.wo, workorders.requiredby, 0 FROM woitems INNER JOIN workorders ON woitems.wo=workorders.wo - WHERE workorders.closed=0"; + WHERE workorders.closed=0'; $result = DB_query($sql,$db); $sql = 'ALTER TABLE mrpsupplies ADD INDEX part(part)'; @@ -436,15 +436,15 @@ prnMsg(_('Creating planned orders table'),'info'); flush(); $result = DB_query('DROP TABLE IF EXISTS mrpplannedorders',$db); - $sql = 'CREATE TABLE mrpplannedorders (id int(11) NOT NULL auto_increment, - part char(20), - duedate date, - supplyquantity double, - ordertype varchar(6), - orderno int(11), - mrpdate date, - updateflag smallint(6), - PRIMARY KEY (id))'; + $sql = 'CREATE TABLE mrpplannedorders (id int(11) NOT NULL auto_increment, + part char(20), + duedate date, + supplyquantity double, + ordertype varchar(6), + orderno int(11), + mrpdate date, + updateflag smallint(6), + PRIMARY KEY (id)) DEFAULT CHARSET=utf8'; $result = DB_query($sql,$db,_('Create of mrpplannedorders failed because')); // Find the highest and lowest level number Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/PO_Header.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -618,7 +618,7 @@ ON stockmaster.stockid = purchdata.stockid WHERE stockmaster.stockid='".$Purch_Item. "' AND purchdata.supplierno ='" . $_GET['SelectedSupplier'] . "'"; - $Result=DB_query($sql, $db); + $result=DB_query($sql, $db); $PurchItemRow=DB_fetch_array($result); if (!isset($PurchItemRow['conversionfactor'])) { Modified: trunk/PrintCustOrder_generic.php =================================================================== --- trunk/PrintCustOrder_generic.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/PrintCustOrder_generic.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -9,6 +9,7 @@ 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'); @@ -119,6 +120,7 @@ for ($i=1;$i<=2;$i++){ /*Print it out twice one copy for customer and one for office */ if ($i==2){ + $PageNumber = 1; $pdf->newPage(); } /* Now ... Has the order got any line items still outstanding to be invoiced */ Modified: trunk/SelectCreditItems.php =================================================================== --- trunk/SelectCreditItems.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/SelectCreditItems.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -72,7 +72,7 @@ //insert wildcard characters in spaces $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; - $SQL = "SELECT + $SQL = 'SELECT custbranch.debtorno, custbranch.brname, custbranch.contactname, @@ -80,7 +80,7 @@ custbranch.faxno, custbranch.branchcode FROM custbranch - WHERE custbranch.brname " . LIKE . "'" . $SearchString . "' + WHERE custbranch.brname ' . LIKE . " '" . $SearchString . "' AND custbranch.disabletrans=0"; } elseif (strlen($_POST['CustCode'])>0){ @@ -1102,12 +1102,12 @@ /* Insert the tax totals for each tax authority where tax was charged on the invoice */ foreach ($TaxTotals AS $TaxAuthID => $TaxAmount) { - $SQL = "INSERT INTO debtortranstaxes (debtortransid, + $SQL = 'INSERT INTO debtortranstaxes (debtortransid, taxauthid, taxamount) - VALUES ('" . $CreditTransID . "', - '" . $TaxAuthID . "', - '" . -($TaxAmount)/$_SESSION['CurrencyRate'] . "')"; + VALUES (' . $CreditTransID . ', + ' . $TaxAuthID . ', + ' . -($TaxAmount)/$_SESSION['CurrencyRate'] . ')'; $ErrMsg =_('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction taxes records could not be inserted because'); $DbgMsg = _('The following SQL to insert the debtor transaction taxes record was used'); Modified: trunk/SelectSalesOrder.php =================================================================== --- trunk/SelectSalesOrder.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/SelectSalesOrder.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -2,12 +2,258 @@ /* $Id$*/ -//$PageSecurity = 2; - include('includes/session.inc'); $title = _('Search Outstanding Sales Orders'); include('includes/header.inc'); + +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++){ + if ($_POST['PlacePO_' . $i]== 'on') { + if ($OrdersToPlacePOFor==''){ + $OrdersToPlacePOFor .= ' orderno=' . $_POST['OrderNo_PO_'.$i]; + } else { + $OrdersToPlacePOFor .= ' OR orderno=' . $_POST['OrderNo_PO_'.$i]; + } + } + } + if (strlen($OrdersToPlacePOFor)==''){ + prnMsg(_('There were no sales orders checked to place purchase orders for. No purchase orders will be created.'),'info'); + } 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, + stockmaster.kgs, + stockmaster.cuft + 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 + 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, + stockmaster.kgs, + stockmaster.cuft + 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); + $SupplierID = ''; + while ($ItemRow = DB_fetch_array($ItemResult)){ + $SupplierID = $ItemRow['supplierno']; + /*Now get all the required details for the supplier */ + + + + + + + + + $result = DB_Txn_Begin($db); + + /*figure out what status to set the order to */ + if (IsEmailAddress($_SESSION['UserEmail'])){ + $UserDetails = ' <a href="mailto:' . $_SESSION['UserEmail'] . '">' . $_SESSION['UsersRealName']. '</a>'; + } else { + $UserDetails = ' ' . $_SESSION['UsersRealName'] . ' '; + } + if ($_SESSION['AutoAuthorisePO']==1) { //if the user has authority to authorise the PO then it will automatically be authorised + $AuthSQL ="SELECT authlevel + FROM purchorderauth + WHERE userid='".$_SESSION['UserID']."' + AND currabrev='".$_SESSION['PO'.$identifier]->CurrCode."'"; + + $AuthResult=DB_query($AuthSQL,$db); + $AuthRow=DB_fetch_array($AuthResult); + + if (DB_num_rows($AuthResult) > 0 AND $AuthRow['authlevel'] > $_SESSION['PO'.$identifier]->Order_Value()) { //user has authority to authrorise as well as create the order + $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created and Authorised by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; + $_SESSION['PO'.$identifier]->AllowPrintPO=1; + $_SESSION['PO'.$identifier]->Status = 'Authorised'; + } else { // no authority to authorise this order + if (DB_num_rows($AuthResult) ==0){ + $AuthMessage = _('Your authority to approve purchase orders in') . ' ' . $_SESSION['PO'.$identifier]->CurrCode . ' ' . _('has not yet been set up') . '<br />'; + } else { + $AuthMessage = _('You can only authorise up to').' '.$_SESSION['PO'.$identifier]->CurrCode.' '.$AuthorityLevel.'.<br />'; + } + + prnMsg( _('You do not have permission to authorise this purchase order').'.<br />'. _('This order is for').' '. + $_SESSION['PO'.$identifier]->CurrCode . ' '. $_SESSION['PO'.$identifier]->Order_Value() .'. '. + $AuthMessage . + _('If you think this is a mistake please contact the systems administrator') . '<br />'. + _('The order will be created with a status of pending and will require authorisation'), 'warn'); + + $_SESSION['PO'.$identifier]->AllowPrintPO=0; + $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; + $_SESSION['PO'.$identifier]->Status = 'Pending'; + } + } else { //auto authorise is set to off + $_SESSION['PO'.$identifier]->AllowPrintPO=0; + $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; + $_SESSION['PO'.$identifier]->Status = 'Pending'; + } + + if ($_SESSION['ExistingOrder']==0){ /*its a new order to be inserted */ + + //Do we need to check authorisation to create - no because already trapped when new PO session started + + /*Get the order number */ + $_SESSION['PO'.$identifier]->OrderNo = GetNextTransNo(18, $db); + + /*Insert to purchase order header record */ + $sql = "INSERT INTO purchorders ( orderno, + supplierno, + comments, + orddate, + rate, + initiator, + requisitionno, + intostocklocation, + deladd1, + deladd2, + deladd3, + deladd4, + deladd5, + deladd6, + tel, + suppdeladdress1, + suppdeladdress2, + suppdeladdress3, + suppdeladdress4, + suppdeladdress5, + suppdeladdress6, + suppliercontact, + supptel, + contact, + version, + revised, + deliveryby, + status, + stat_comment, + deliverydate, + paymentterms, + allowprint) + VALUES( '" . $_SESSION['PO'.$identifier]->OrderNo . "', + '" . $_SESSION['PO'.$identifier]->SupplierID . "', + '" . $_SESSION['PO'.$identifier]->Comments . "', + '" . Date('Y-m-d') . "', + '" . $_SESSION['PO'.$identifier]->ExRate . "', + '" . $_SESSION['PO'.$identifier]->Initiator . "', + '" . $_SESSION['PO'.$identifier]->RequisitionNo . "', + '" . $_SESSION['PO'.$identifier]->Location . "', + '" . $_SESSION['PO'.$identifier]->DelAdd1 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd2 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd3 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd4 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd5 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd6 . "', + '" . $_SESSION['PO'.$identifier]->Tel . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd1 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd2 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd3 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd4 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd5 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd6 . "', + '" . $_SESSION['PO'.$identifier]->SupplierContact . "', + '" . $_SESSION['PO'.$identifier]->SuppTel. "', + '" . $_SESSION['PO'.$identifier]->Contact . "', + '" . $_SESSION['PO'.$identifier]->Version . "', + '" . Date('Y-m-d') . "', + '" . $_SESSION['PO'.$identifier]->DeliveryBy . "', + '" . $_SESSION['PO'.$identifier]->Status . "', + '" . $StatusComment . "', + '" . FormatDateForSQL($_SESSION['PO'.$identifier]->DeliveryDate) . "', + '" . $_SESSION['PO'.$identifier]->PaymentTerms. "', + '" . $_SESSION['PO'.$identifier]->AllowPrintPO . "' + )"; + + $ErrMsg = _('The purchase order header record could not be inserted into the database because'); + $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + + /*Insert the purchase order detail records */ + foreach ($_SESSION['PO'.$identifier]->LineItems as $POLine) { + if ($POLine->Deleted==False) { + $sql = "INSERT INTO purchorderdetails ( orderno, + itemcode, + deliverydate, + itemdescription, + glcode, + unitprice, + quantityord, + shiptref, + jobref, + itemno, + suppliersunit, + suppliers_partno, + subtotal_amount, + package, + pcunit, + netweight, + kgs, + cuft, + total_quantity, + total_amount, + assetid, + conversionfactor ) + VALUES ( + '" . $_SESSION['PO'.$identifier]->OrderNo . "', + '" . $POLine->StockID . "', + '" . FormatDateForSQL($POLine->ReqDelDate) . "', + '" . $POLine->ItemDescription . "', + '" . $POLine->GLCode . "', + '" . $POLine->Price . "', + '" . $POLine->Quantity . "', + '" . $POLine->ShiptRef . "', + '" . $POLine->JobRef . "', + '" . $POLine->ItemNo . "', + '" . $POLine->SuppliersUnit . "', + '" . $POLine->Suppliers_PartNo . "', + '" . $POLine->SubTotal_Amount . "', + '" . $POLine->Package . "', + '" . $POLine->PcUnit . "', + '" . $POLine->NetWeight . "', + '" . $POLine->KGs . "', + '" . $POLine->CuFt . "', + '" . $POLine->Total_Quantity . "', + '" . $POLine->Total_Amount . "', + '" . $POLine->AssetID . "', + '" . $POLine->ConversionFactor . "')"; + $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); + $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); + + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + } + } /* end of the loop round the detail line items on the order */ + echo '<p>'; + prnMsg(_('Purchase Order') . ' ' . $_SESSION['PO'.$identifier]->OrderNo . ' ' . _('on') . ' ' . + $_SESSION['PO'.$identifier]->SupplierName . ' ' . _('has been created'),'success'); + } + } +}/*end of purchase order creation code */ +/* ******************************************************************************************* */ + + + + +/*To the sales order selection form */ + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/sales.png" title="' . _('Sales') . '" alt="" />' . ' ' . _('Outstanding Sales Orders') . '</p> '; echo '<form action=' . $_SERVER['PHP_SELF'] .'?' .SID . ' method=post>'; @@ -410,37 +656,53 @@ /*show a table of the orders returned by the SQL */ if (DB_num_rows($SalesOrdersResult)>0) { - echo '<table cellpadding=2 colspan=7 width=95% class=selection>'; + + /* Get users authority to place POs */ + $AuthSql="SELECT cancreate + FROM purchorderauth + WHERE userid='". $_SESSION['UserID'] . "'"; + + /*we don't know what currency these orders might be in but if no authority at all then don't show option*/ + $AuthResult=DB_query($AuthSQL,$db); + $AuthRow=DB_fetch_array($AuthResult); + echo '<table cellpadding=2 colspan=7 width=95% class=selection>'; + if (isset($_POST['Quotations']) and $_POST['Quotations']=='Orders_Only'){ - $tableheader = "<tr> - <th>" . _('Modify') . "</th> - <th>" . _('Invoice') . "</th> - <th>" . _('Dispatch Note') . "</th> - <th>" . _('Sales Order') . "</th> - <th>" . _('Customer') . "</th> - <th>" . _('Branch') . "</th> - <th>" . _('Cust Order') . " #</th> - <th>" . _('Order Date') . "</th> - <th>" . _('Req Del Date') . "</th> - <th>" . _('Delivery To') . "</th> - <th>" . _('Order Total') . "</th></tr>"; - } else { - $tableheader = "<tr> - <th>" . _('Modify') . "</th> - <th>" . _('Print Quote') . "</th> - <th>" . _('Customer') . "</th> - <th>" . _('Branch') . "</th> - <th>" . _('Cust Ref') . " #</th> - <th>" . _('Quote Date') . "</th> - <th>" . _('Req Del Date') . "</th> - <th>" . _('Delivery To') . "</th> - <th>" . _('Quote Total') . "</th></tr>"; + $tableheader = '<tr> + <th>' . _('Modify') . '</th> + <th>' . _('Invoice') . '</th> + <th>' . _('Dispatch Note') . '</th> + <th>' . _('Sales Order') . '</th> + <th>' . _('Customer') . '</th> + <th>' . _('Branch') . '</th> + <th>' . _('Cust Order') . ' #</th> + <th>' . _('Order Date') . '</th> + <th>' . _('Req Del Date') . '</th> + <th>' . _('Delivery To') . '</th> + <th>' . _('Order Total') . '</th>'; + if ($AuthRow['cancreate']==0){ //If cancreate==0 then this means the user can create orders hmmm!! + $tableheader .= '<th>' . _('Place PO') . '</th></tr>'; + } else { + $tableheader .= '</tr>'; + } + } else { /* displaying only quotations */ + $tableheader = '<tr> + <th>' . _('Modify') . '</th> + <th>' . _('Print Quote') . '</th> + <th>' . _('Customer') . '</th> + <th>' . _('Branch') . '</th> + <th>' . _('Cust Ref') . ' #</th> + <th>' . _('Quote Date') . '</th> + <th>' . _('Req Del Date') . '</th> + <th>' . _('Delivery To') . '</th> + <th>' . _('Quote Total') . '</th></tr>'; } echo $tableheader; } - $j = 1; + $i = 1; + $j = 1; $k=0; //row colour counter while ($myrow=DB_fetch_array($SalesOrdersResult)) { @@ -474,30 +736,64 @@ } if ($_POST['Quotations']=='Orders_Only'){ - printf("<td><a href='%s'>%s</a></td> - <td><a href='%s'>" . _('Invoice') . "</a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - </tr>", - $ModifyPage, - $myrow['orderno'], - $Confirm_Invoice, - $PrintDispatchNote, - $PrintSalesOrder, - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $FormatedOrderDate, - $FormatedDelDate, - $myrow['deliverto'], - $FormatedOrderValue); + + /*Check authority to create POs if user has authority then show the check boxes to select sales orders to place POs for otherwise don't provide this option */ + if ($AuthRow['cancreate']==0){ //cancreate==0 if the user can create POs + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . _('Invoice') . "</a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + <td><input type=checkbox name=PlacePO_%s><input type=hidden name=OrderNo_PO_%s value=%s></td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $Confirm_Invoice, + $PrintDispatchNote, + $PrintSalesOrder, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue, + $i, + $i, + $myrow['orderno']); + } else { /*User is not authorised to create POs so don't even show the option */ + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . _('Invoice') . "</a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $Confirm_Invoice, + $PrintDispatchNote, + $PrintSalesOrder, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue); + } + } else { /*must be quotes only */ printf("<td><a href='%s'>%s</a></td> <td><a href='%s'>" . $PrintText . "</a></td> @@ -520,7 +816,7 @@ $myrow['deliverto'], $FormatedOrderValue); } - + $i++; $j++; if ($j == 12){ $j=1; @@ -529,7 +825,9 @@ //end of page full new headings if } //end of while loop - + if ($_POST['Quotations']=='Orders_Only' AND $AuthRow['cancreate']==0){ //cancreate==0 means can create POs + echo '<tr><td colspan="10"><td><td colspan="2"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; + } echo '</table>'; } Modified: trunk/SelectSupplier.php =================================================================== --- trunk/SelectSupplier.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/SelectSupplier.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -155,28 +155,28 @@ <th width=33%>" . _('Supplier Maintenance') . "</th> </tr>"; echo '<tr><td valign=top class="select">'; /* Inquiry Options */ - echo "<a href=\"$rootpath/SupplierInquiry.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Supplier Account Inquiry') . '</a><br>'; + echo "<a href=\"$rootpath/SupplierInquiry.php?SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Supplier Account Inquiry') . '</a><br>'; echo '<br>'; - echo "<br><a href='$rootpath/PO_SelectOSPurchOrder.php?" . SID . '&SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('Add / Receive / View Outstanding Purchase Orders') . '</a>'; - echo "<br><a href='$rootpath/PO_SelectPurchOrder.php?" . SID . '&SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('View All Purchase Orders') . '</a><br>'; + echo "<br><a href='$rootpath/PO_SelectOSPurchOrder.php?SelectedSupplier=" . $_SESSION['SupplierID'] . "'>" . _('Add / Receive / View Outstanding Purchase Orders') . '</a>'; + echo "<br><a href='$rootpath/PO_SelectPurchOrder.php?SelectedSupplier=" . $_SESSION['SupplierID'] . "'>" . _('View All Purchase Orders') . '</a><br>'; wikiLink('Supplier', $_SESSION['SupplierID']); - echo "<br><a href='$rootpath/ShiptsList.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "&SupplierName=".urlencode($SupplierName)."'>" . _('List all open shipments for') .' '.$SupplierName. '</a>'; - echo "<br><a href='$rootpath/Shipt_Select.php?" . SID . '&SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('Search / Modify / Close Shipments') . '</a>'; - echo "<br><a href='$rootpath/SuppPriceList.php?" . SID . '&SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('Supplier Price List') . '</a>'; + echo "<br><a href='$rootpath/ShiptsList.php?SupplierID=" . $_SESSION['SupplierID'] . "&SupplierName=".urlencode($SupplierName)."'>" . _('List all open shipments for') .' '.$SupplierName. '</a>'; + echo "<br><a href='" . $rootpath . '/Shipt_Select.php?SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('Search / Modify / Close Shipments') . '</a>'; + echo "<br><a href='" . $rootpath . '/SuppPriceList.php?SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('Supplier Price List') . '</a>'; echo '</td><td valign=top class="select">'; /* Supplier Transactions */ - echo "<a href=\"$rootpath/PO_Header.php?" . SID . '&NewOrder=Yes&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Purchase Order for This Supplier') . '</a><br>'; - echo "<a href=\"$rootpath/SupplierInvoice.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Suppliers Invoice') . '</a><br>'; - echo "<a href=\"$rootpath/SupplierCredit.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . '&New=True' . "\">" . _('Enter a Suppliers Credit Note') . '</a><br>'; - echo "<a href=\"$rootpath/Payments.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Payment to, or Receipt from the Supplier') . '</a><br>'; + echo "<a href=\"$rootpath/PO_Header.php?NewOrder=Yes&SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Enter a Purchase Order for This Supplier') . '</a><br>'; + echo "<a href=\"$rootpath/SupplierInvoice.php?SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Enter a Suppliers Invoice') . '</a><br>'; + echo "<a href=\"$rootpath/SupplierCredit.php?New=true&SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Enter a Suppliers Credit Note') . '</a><br>'; + echo "<a href=\"$rootpath/Payments.php?SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Enter a Payment to, or Receipt from the Supplier') . '</a><br>'; echo '<br>'; - echo "<br><a href='$rootpath/ReverseGRN.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "'>" . _('Reverse an Outstanding Goods Received Note (GRN)') . '</a>'; + echo "<br><a href='$rootpath/ReverseGRN.php?&SupplierID=" . $_SESSION['SupplierID'] . "'>" . _('Reverse an Outstanding Goods Received Note (GRN)') . '</a>'; echo '</td><td valign=top class="select">'; /* Supplier Maintenance */ echo '<a href="' . $rootpath . '/Suppliers.php?">' . _('Add a New Supplier') . '</a><br>'; - echo "<a href=\"$rootpath/Suppliers.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Modify Or Delete Supplier Details') . '</a>'; - echo "<br><a href=\"$rootpath/SupplierContacts.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Add/Modify/Delete Supplier Contacts') . '</a>'; + echo "<a href=\"$rootpath/Suppliers.php?SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Modify Or Delete Supplier Details') . '</a>'; + echo "<br><a href=\"$rootpath/SupplierContacts.php?&SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Add/Modify/Delete Supplier Contacts') . '</a>'; echo '<br>'; - echo "<br><a href='$rootpath/Shipments.php?" . SID . "&NewShipment=Yes'>" . _('Set Up A New Shipment') . '</a>'; - echo "<br><a href='$rootpath/SuppLoginSetup.php?" . SID . "'>" . _('Supplier Login Configuration') . '</a>'; + echo "<br><a href='$rootpath/Shipments.php?NewShipment=Yes'>" . _('Set Up A New Shipment') . '</a>'; + echo "<br><a href='$rootpath/SuppLoginSetup.php'>" . _('Supplier Login Configuration') . '</a>'; echo '</td></tr></table>'; } else { // Supplier is not selected yet Modified: trunk/StockQuantityByDate.php =================================================================== --- trunk/StockQuantityByDate.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/StockQuantityByDate.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -22,16 +22,17 @@ echo '<table class=selection><tr>'; echo '<td>' . _('For Stock Category') . ":</td> <td><select name='StockCategory'> "; +echo '<option value="All">' . _('All') . '</option>'; while ($myrow=DB_fetch_array($resultStkLocs)){ if (isset($_POST['StockCategory']) AND $_POST['StockCategory']!='All'){ if ($myrow['categoryid'] == $_POST['StockCategory']){ - echo "<option selected VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription']; + echo "<option selected VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription'] . '</option>'; } else { - echo "<option VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription']; + echo "<option VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription'] . '</option>'; } }else { - echo "<option VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription']; + echo "<option VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription'] . '</option>'; } } echo '</select></td>'; @@ -69,14 +70,21 @@ $TotalQuantity = 0; -if(isset($_POST['ShowStatus']) AND Is_Date($_POST['OnHandDate'])) -{ - $sql = "SELECT stockid, - description, - decimalplaces - FROM stockmaster - WHERE categoryid = '" . $_POST['StockCategory'] . "' - AND (mbflag='M' OR mbflag='B')"; +if(isset($_POST['ShowStatus']) AND Is_Date($_POST['OnHandDate'])) { + if ($_POST['StockCategory']='All') { + $sql = "SELECT stockid, + description, + decimalplaces + FROM stockmaster + WHERE (mbflag='M' OR mbflag='B')"; + } else { + $sql = "SELECT stockid, + description, + decimalplaces + FROM stockmaster + WHERE categoryid = '" . $_POST['StockCategory'] . "' + AND (mbflag='M' OR mbflag='B')"; + } $ErrMsg = _('The stock items in the category selected cannot be retrieved because'); $DbgMsg = _('The SQL that failed was'); Modified: trunk/StockStatus.php =================================================================== --- trunk/StockStatus.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/StockStatus.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -274,22 +274,25 @@ $k=1; while ($myrow=DB_fetch_array($MovtsResult)) { - if ($LastPrice != $myrow['price'] or $LastDiscount != $myrow['discount']) { /* consolidate price history for records with same price/discount */ - if ($qty) { + if ($LastPrice != $myrow['price'] OR $LastDiscount != $myrow['discount']) { /* consolidate price history for records with same price/discount */ + if (isset($qty)) { $DateRange=ConvertSQLDate($FromDate); if ($FromDate != $ToDate) { $DateRange .= ' - ' . ConvertSQLDate($ToDate); } $PriceHistory[] = array($DateRange, $qty, $LastPrice, $LastDiscount); $k++; - if ($k > 9) break; /* 10 price records is enough to display */ - if ($myrow['trandate'] < FormatDateForSQL(time() - 366*86400)) + if ($k > 9) { + break; /* 10 price records is enough to display */ + } + if ($myrow['trandate'] < FormatDateForSQL(DateAdd(date($_SESSION['DefaultDateFormat']),'y', -1))) { break; /* stop displaying pirce history more than a year old once we have at least one to display */ + } } - $LastPrice = $myrow['price']; - $LastDiscount = $myrow['discount']; + $LastPrice = $myrow['price']; + $LastDiscount = $myrow['discountpercent']; $ToDate = $myrow['trandate']; - $qty = 0; + $qty = 0; } $qty += $myrow['qty']; $FromDate = $myrow['trandate']; @@ -302,8 +305,8 @@ $PriceHistory[] = array($DateRange, $qty, $LastPrice, $LastDiscount); } if (isset($PriceHistory)) { - echo '<p>' . _('Pricing history for sales of') . ' ' . $StockID . ' ' . _('to') . ' ' . $DebtorNo; - echo '<table cellpadding="2" class="selection">'; + echo '<br /><table cellpadding="4" class="selection">'; + echo '<tr><th colspan=4><font color=navy size=2>' . _('Pricing history for sales of') . ' ' . $StockID . ' ' . _('to') . ' ' . $DebtorNo . '</font></th></tr>'; $tableheader = "<tr> <th>" . _('Date Range') . "</th> <th>" . _('Quantity') . "</th> Modified: trunk/SupplierCredit.php =================================================================== --- trunk/SupplierCredit.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/SupplierCredit.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -36,7 +36,7 @@ //echo "<a href='" . $rootpath . '/SelectSupplier.php?' . SID . "'>" . _('Back to Suppliers') . '</a><br>'; if (isset($_GET['New'])) { - unset($_SESSION['SuppTrans']); + unset($_SESSION['SuppTrans']); } if (!isset($_SESSION['SuppTrans']->SupplierName)) { @@ -615,8 +615,8 @@ }elseif ($_SESSION['SuppTrans']->ExRate <= 0){ $InputError = True; prnMsg(_('The credit note as entered cannot be processed because the exchange rate for the credit note has been entered as a negative or zero number') . '. ' . _('The exchange rate is expected to show how many of the suppliers currency there are in 1 of the local currency'),'warn'); - }elseif ($_SESSION['SuppTrans']->OvAmount < round($TotalGRNValue + $TotalGLValue + $TotalAssetValue + $TotalShiptValue + $TotalContractsValue,2)){ - prnMsg(_('The credit note total as entered is less than the sum of the shipment charges, the general ledger entries (if any) and the charges for goods received, contracts and fixed assets. There must be a mistake somewhere, the credit note as entered will not be processed'),'error'); + }elseif ($_SESSION['SuppTrans']->OvAmount < round($TotalShiptValue + $TotalGLValue + $TotalAssetValue + $TotalGRNValue,2)){ + prnMsg(_('The credit note total as entered is less than the sum of the shipment charges') . ', ' . _('the general ledger entries (if any) and the charges for goods received') . '. ' . _('There must be a mistake somewhere') . ', ' . _('the credit note as entered will not be processed'),'error'); $InputError = True; } else { @@ -722,15 +722,15 @@ foreach ($_SESSION['SuppTrans']->Assets as $AssetAddition){ /* only the GL entries if the creditors->GL integration is enabled */ - $SQL = "INSERT INTO gltrans (type, + $SQL = 'INSERT INTO gltrans (type, typeno, trandate, periodno, account, narrative, amount) - VALUES (21, '" . - $CreditNoteNo . "', + VALUES (21, ' . + $CreditNoteNo . ", '" . $SQLCreditNoteDate . "', '" . $PeriodNo . "', '". $AssetAddition->CostAct . "', Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/doc/Change.log.html 2011-03-10 06:24:48 UTC (rev 4506) @@ -1,8 +1,11 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>10/3/11: Phil fix pagination of PrintCustOrder_generic.php - second copy was not restarting page numbers</p> +<p>10/3/11: Tims launchpad fixes brought in MRP.php fix for table charset utf8 so joins work correctly; typeo in PO_Header preventing purchasing data being retrieved ($result not $Result); correct sql on searching for customer in SelectCreditItems.php; StockStatus.php pricing history bug resolved (4450); StockQuantityByDate.php now allowed to show for all categories - enclosed 'All' in gettext</p> +<p>8/3/11: Tim/Phil PO_Items.php in committing an order detail the assetid of 'Not an Asset' was being inserted to an integer field. Modified $_POST['AssetID'] to = 0 if it was 'Not an Asset' as advised by Tim</p> <p>8/3/11:Phil fix SalesAnalysis reports for TCPDF as reported by Joe Zhou</p> <p>5/3/11: Kovács Attila fix to Stocks.php to use ANSI GROUP BY for aggregate functions SQL</p> -<p>5/3/11: Kovács Attila fix to LanguageSetup.php to use utf-8 not ISO-8859-1. Phil hardcoded UTF- now as no dynamic changing of character set required all translations are utf-8</p> +<p>5/3/11: Kovács Attila fix to LanguageSetup.php to use utf-8 not ISO-8859-1. Phil hardcoded UTF-8 now as no dynamic changing of character set required all translations are utf-8</p> <p>3/3/11: Exson/Baran/Phil fix to customer login to ensure that other customers orders are not displayed when searching by customer ref or order no</p> <p>3/3/11: Tim launchpad mods to revision 4441 including change to allow supplier currency to be changed if there are no transactions already against the supplier. Ensure credit note session variable is unset before attempting to create a new credit note from the supplier form. Tim's work to add perisable expiry dates to the serial items logic - affects quite a few scripts. Headings to stock check script even if no quantity is shown. Portrait quotations. Not included change to default delivery date to the date the customer requested - left to be the current day's date. Not included Tim's unit pricing work .. yet launchpad revisions 4442-4447 inclusive</p> <p>27/2/11: Phil/Tim/Peter launchpad added category option for MRPShortages.php links with matching quotes in WorkOrderEntry</p> Modified: trunk/doc/README.txt =================================================================== --- trunk/doc/README.txt 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/doc/README.txt 2011-03-10 06:24:48 UTC (rev 4506) @@ -4,29 +4,27 @@ Thankyou for using webERP. -Installation instructions are in the file INSTALL.txt in the doc directory. It is important to read the INSTALL.txt file in its entirety before proceeding. In fact a printout is not a bad idea. +Installation instructions are in the file INSTALL.txt in the doc directory. It is important to read the INSTALL.txt file in its entirety before proceeding. A printout is recommended. The user documentation contains a wealth of information and is installed under the doc/Manual directory in html format. Links to it are available from the application itself. SUPPORT -The primary means of support queries is through the user mailing list. +The primary means of support queries is through the user mailing list. Please join the list at: http://lists.sourceforge.net/lists/listinfo/web-erp-users if you have queries. The archives of the mailing lists on sourceforge and the FAQ (see http://www.weberp.org/wikidocs/FrequentlyAskedQuestionsInstallation) contain the most common issues with respect to installation. -Feedback, wants and gripes are encouraged in the interests of improving this applicaton. +Feedback, wants and gripes are encouraged in the interests of improving the applicaton. -DEVELOPING +DEVELOPING -All contributions of code are needed and encouraged. -Guidelines for contributing code are in the document at http://www.weberp.org/wikidocs/ContributingtowebERP developers should read this document carefully and follow the guidelines therein. Standards and conventions used in the code are rigorously applied in the interests of consistency and readability. Code submitted that does not conform to these standards will be changed so it does where possible. +Contributions of code are documents including HOW-TOs with screen-shots etc are encouraged. Contributions in the form of bug reports or other feedback through the mainling lists above are also encouraged. +Guidelines for contributing code are in the document at http://www.weberp.org/wikidocs/ContributingtowebERP developers should read this document carefully and follow the guidelines therein. Standards and conventions used in the code are rigorously applied in the interests of consistency and readability. Code submitted that does not conform to these standards will be changed so it does where possible. If the job to make the code conform to webERP standards is too large then the code will not be included. TRANSLATIONS -Translations that have been contributed are distributed as separate language archives. These must be downloaded separately from: +All available translations are now included in the archive downloaded. -http://sourceforge.net/project/showfiles.php?group_id=70949 - Translators should read the document http://www.weberp.org/HowToTranslate which describes how to translate webERP. Translations must be installed under the webERP/locale directory and the locale must be available on the web-server. @@ -42,4 +40,4 @@ A copy of the GNU General Public License is included in the doc directory along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Copyright weberp.org 2010 - Contact: in...@we... \ No newline at end of file +Copyright weberp.org 2011 - Contact: in...@we... \ No newline at end of file Modified: trunk/doc/UPGRADING.txt =================================================================== --- trunk/doc/UPGRADING.txt 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/doc/UPGRADING.txt 2011-03-10 06:24:48 UTC (rev 4506) @@ -2,6 +2,8 @@ /* $Id$*/ +From version 4.01 database upgrades are now automatically processed if the version number of the code is different to the version number of the database. The first login will require the system administrator to allow the system to upgrade it's own database. A backup of the database prior to the running the upgrade is advisable. The new upgrade system will not be able to identify versions prior to 3.11 so it is necessary to select the version being upgraded from manaully. It can process database upgrades from version 3.00 onwards. + From version 3.05 an upgrade script will be provided that applies the database modifications automatically and does any data conversions required for the new scripts to work. The upgrade script to convert a 3.05 database to work with 3.06 scripts is: @@ -13,7 +15,7 @@ Previous to version 3.05, the database conversion had to be done manually - the instructions to complete upgrades from older versions are provided below: -CONVERTING THE DATABASE +CONVERTING THE DATABASE MANUALY - THE DETAIL As each new version is released the new php scripts will use new database fields or changed field names. A a consequence, the new scripts will most likely not work unless the database structure has been converted to the new database structure. Normally the changes to the database between versions are small. However, between 2.9b and 3.0 the changes were significant and the upgrade script may take some time to run. It should not be run from a phpMyAdmin window since PHP will time out long before the upgrade script will have finished. @@ -26,9 +28,9 @@ where XX.XX is the old version number and YY.YY is the new version number. No other users should be using the database. The upgrade script will need to be edited to use the name of the database that your webERP installation was created with - by default this is weberp. If the default has not been changed then the following line will need to be added to the upgrade script - right at the beginning: - + use weberp; - + A similar line will be required but substituting the name of the database that your installation uses where the default database name has been changed. @@ -58,7 +60,7 @@ There are extensive changes to the database and the upgrade2.9b-3.0.sql may take some time to run depending on how much data there is in the system. A backup of the 2.9b database dump should be taken prior to attempting to run the upgrade script. -IMPORTANT: Note that version of mysql 4.1.8 or greater is required because from the mysql change log: +IMPORTANT: Note that version of mysql 4.1.8 or greater is required because from the mysql change log: "Fix two hangs: FOREIGN KEY constraints treated table and database names as case-insensitive. RENAME TABLE t TO T would hang in an endless loop if t had a foreign key constraint defined on it. Fix also a hang over the dictionary mutex that would occur if one tried in ALTER TABLE or RENAME TABLE to create a foreign key constraint name that collided with another existing name. (Bug #3478)" @@ -71,6 +73,6 @@ 3.05 now has Dave Premo's report writer scripts included in the distribution - additional tables are required for this functionality. Also, 3.05 allows for weighted average stock valuation - using the existing data fields and retaining integrated general ledger stock values. This requires cost information to be copied over into the grns table. The upgrade script Z_Upgrade_3.04-3.05.php applies all the additional tables to the database and does the data conversions required wihtout any manual intervention. -NOTES ON UPGRADING FROM 3.11 to 3.12 +NOTES ON UPGRADING FROM 3.11 to 4.x -PHP 5 is now required because of the simpleXML module of PHP only comes with PHP 5. This is used on the new XML definition of report formats. \ No newline at end of file +PHP 5 is now required because of the simpleXML module of PHP only comes with PHP 5+. This is used on the new XML definition of report formats. \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-10 06:24:56
|
Revision: 4506 http://web-erp.svn.sourceforge.net/web-erp/?rev=4506&view=rev Author: daintree Date: 2011-03-10 06:24:48 +0000 (Thu, 10 Mar 2011) Log Message: ----------- launchpad changes and pagination of PrintCustOrder_generic.php Modified Paths: -------------- trunk/MRP.php trunk/PO_Header.php trunk/PrintCustOrder_generic.php trunk/SelectCreditItems.php trunk/SelectSalesOrder.php trunk/SelectSupplier.php trunk/StockQuantityByDate.php trunk/StockStatus.php trunk/SupplierCredit.php trunk/doc/Change.log.html trunk/doc/README.txt trunk/doc/UPGRADING.txt Modified: trunk/MRP.php =================================================================== --- trunk/MRP.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/MRP.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -44,11 +44,11 @@ prnMsg(_('Creating first level'),'info'); flush(); // This finds the top level - $sql = "INSERT INTO passbom (part, sortpart) + $sql = 'INSERT INTO passbom (part, sortpart) SELECT bom.component AS part, - CONCAT(bom.parent,'%',bom.component) AS sortpart + CONCAT(bom.parent,"%",bom.component) AS sortpart FROM bom LEFT JOIN bom as bom2 ON bom.parent = bom2.component - WHERE bom2.component IS NULL"; + WHERE bom2.component IS NULL'; $result = DB_query($sql,$db); $lctr = 2; @@ -201,7 +201,7 @@ // Get rid if temporary tables $sql = 'DROP TABLE IF EXISTS tempbom'; -- //$result = DB_query($sql,$db); + //$result = DB_query($sql,$db); $sql = 'DROP TABLE IF EXISTS passbom'; //$result = DB_query($sql,$db); $sql = 'DROP TABLE IF EXISTS passbom2'; @@ -230,7 +230,7 @@ prnMsg(_('Loading requirements from sales orders'),'info'); flush(); - $sql = "INSERT INTO mrprequirements (part, + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, mrpdemandtype, @@ -240,22 +240,22 @@ SELECT stkcode, deliverydate, (quantity - qtyinvoiced) AS netqty, - 'SO', + "SO", salesorderdetails.orderno, - '1', + "1", stkcode FROM salesorders, salesorderdetails WHERE salesorders.orderno = salesorderdetails.orderno AND (quantity - qtyinvoiced) > 0 AND salesorderdetails.completed = 0 - AND salesorders.quotation = 0"; + AND salesorders.quotation = 0'; $result = DB_query($sql,$db); prnMsg(_('Loading requirements from work orders'),'info'); flush(); // Definition of demand from SelectProduct.php - $sql = "INSERT INTO mrprequirements (part, + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, mrpdemandtype, @@ -265,19 +265,19 @@ SELECT worequirements.stockid, workorders.requiredby, qtypu*(woitems.qtyreqd - woitems.qtyrecd) AS netqty, - 'WO', + "WO", woitems.wo, - '1', + "1", parentstockid FROM woitems INNER JOIN worequirements ON woitems.stockid=worequirements.parentstockid INNER JOIN workorders ON woitems.wo=workorders.wo AND woitems.wo=worequirements.wo - WHERE workorders.closed=0"; + WHERE workorders.closed=0'; $result = DB_query($sql,$db); - $sql = "INSERT INTO mrprequirements (part, + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, mrpdemandtype, @@ -289,15 +289,15 @@ quantity, mrpdemandtype, demandid, - '1', + "1", stockid - FROM mrpdemands"; + FROM mrpdemands'; if ($_POST['usemrpdemands'] == 'y') { $result = DB_query($sql,$db); prnMsg(_('Loading requirements based on mrpdemands'),'info'); flush(); } - $sql = "INSERT INTO mrprequirements (part, + $sql = 'INSERT INTO mrprequirements (part, daterequired, quantity, mrpdemandtype, @@ -307,12 +307,12 @@ SELECT stockid, NOW(), (reorderlevel - quantity) AS reordqty, - 'REORD', - '1', - '1', + "REORD", + "1", + "1", stockid FROM locstock - WHERE reorderlevel > quantity"; + WHERE reorderlevel > quantity'; $result = DB_query($sql,$db); prnMsg(_('Loading requirements based on reorder level'),'info'); flush(); @@ -339,7 +339,7 @@ prnMsg(_('Loading supplies from purchase orders'),'info'); flush(); - $sql = "INSERT INTO mrpsupplies (id, + $sql = 'INSERT INTO mrpsupplies (id, part, duedate, supplyquantity, @@ -351,16 +351,16 @@ purchorderdetails.itemcode, purchorderdetails.deliverydate, (quantityord - quantityrecd) AS netqty, - 'PO', + "PO", purchorderdetails.orderno, purchorderdetails.deliverydate, 0 FROM purchorderdetails, purchorders WHERE purchorderdetails.orderno = purchorders.orderno - AND purchorders.status != 'Cancelled' - AND purchorders.status != 'Rejected' - AND(quantityord - quantityrecd) > 0"; + AND purchorders.status != "Cancelled" + AND purchorders.status != "Rejected" + AND(quantityord - quantityrecd) > 0'; $result = DB_query($sql,$db); prnMsg(_('Loading supplies from inventory on hand'),'info'); @@ -382,7 +382,7 @@ } // End of foreach $WhereLocation .= ')'; } - $sql = "INSERT INTO mrpsupplies (id, + $sql = 'INSERT INTO mrpsupplies (id, part, duedate, supplyquantity, @@ -392,21 +392,21 @@ updateflag) SELECT Null, stockid, - '0000-00-00', + "0000-00-00", SUM(quantity), - 'QOH', + "QOH", 1, - '0000-00-00', + "0000-00-00", 0 FROM locstock - WHERE quantity > 0 ". + WHERE quantity > 0 ' . $WhereLocation . - "GROUP BY stockid"; + 'GROUP BY stockid'; $result = DB_query($sql,$db); prnMsg(_('Loading supplies from work orders'),'info'); flush(); - $sql = "INSERT INTO mrpsupplies (id, + $sql = 'INSERT INTO mrpsupplies (id, part, duedate, supplyquantity, @@ -418,13 +418,13 @@ stockid, workorders.requiredby, (woitems.qtyreqd-woitems.qtyrecd) AS netqty, - 'WO', + "WO", woitems.wo, workorders.requiredby, 0 FROM woitems INNER JOIN workorders ON woitems.wo=workorders.wo - WHERE workorders.closed=0"; + WHERE workorders.closed=0'; $result = DB_query($sql,$db); $sql = 'ALTER TABLE mrpsupplies ADD INDEX part(part)'; @@ -436,15 +436,15 @@ prnMsg(_('Creating planned orders table'),'info'); flush(); $result = DB_query('DROP TABLE IF EXISTS mrpplannedorders',$db); - $sql = 'CREATE TABLE mrpplannedorders (id int(11) NOT NULL auto_increment, - part char(20), - duedate date, - supplyquantity double, - ordertype varchar(6), - orderno int(11), - mrpdate date, - updateflag smallint(6), - PRIMARY KEY (id))'; + $sql = 'CREATE TABLE mrpplannedorders (id int(11) NOT NULL auto_increment, + part char(20), + duedate date, + supplyquantity double, + ordertype varchar(6), + orderno int(11), + mrpdate date, + updateflag smallint(6), + PRIMARY KEY (id)) DEFAULT CHARSET=utf8'; $result = DB_query($sql,$db,_('Create of mrpplannedorders failed because')); // Find the highest and lowest level number Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/PO_Header.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -618,7 +618,7 @@ ON stockmaster.stockid = purchdata.stockid WHERE stockmaster.stockid='".$Purch_Item. "' AND purchdata.supplierno ='" . $_GET['SelectedSupplier'] . "'"; - $Result=DB_query($sql, $db); + $result=DB_query($sql, $db); $PurchItemRow=DB_fetch_array($result); if (!isset($PurchItemRow['conversionfactor'])) { Modified: trunk/PrintCustOrder_generic.php =================================================================== --- trunk/PrintCustOrder_generic.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/PrintCustOrder_generic.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -9,6 +9,7 @@ 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'); @@ -119,6 +120,7 @@ for ($i=1;$i<=2;$i++){ /*Print it out twice one copy for customer and one for office */ if ($i==2){ + $PageNumber = 1; $pdf->newPage(); } /* Now ... Has the order got any line items still outstanding to be invoiced */ Modified: trunk/SelectCreditItems.php =================================================================== --- trunk/SelectCreditItems.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/SelectCreditItems.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -72,7 +72,7 @@ //insert wildcard characters in spaces $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; - $SQL = "SELECT + $SQL = 'SELECT custbranch.debtorno, custbranch.brname, custbranch.contactname, @@ -80,7 +80,7 @@ custbranch.faxno, custbranch.branchcode FROM custbranch - WHERE custbranch.brname " . LIKE . "'" . $SearchString . "' + WHERE custbranch.brname ' . LIKE . " '" . $SearchString . "' AND custbranch.disabletrans=0"; } elseif (strlen($_POST['CustCode'])>0){ @@ -1102,12 +1102,12 @@ /* Insert the tax totals for each tax authority where tax was charged on the invoice */ foreach ($TaxTotals AS $TaxAuthID => $TaxAmount) { - $SQL = "INSERT INTO debtortranstaxes (debtortransid, + $SQL = 'INSERT INTO debtortranstaxes (debtortransid, taxauthid, taxamount) - VALUES ('" . $CreditTransID . "', - '" . $TaxAuthID . "', - '" . -($TaxAmount)/$_SESSION['CurrencyRate'] . "')"; + VALUES (' . $CreditTransID . ', + ' . $TaxAuthID . ', + ' . -($TaxAmount)/$_SESSION['CurrencyRate'] . ')'; $ErrMsg =_('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction taxes records could not be inserted because'); $DbgMsg = _('The following SQL to insert the debtor transaction taxes record was used'); Modified: trunk/SelectSalesOrder.php =================================================================== --- trunk/SelectSalesOrder.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/SelectSalesOrder.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -2,12 +2,258 @@ /* $Id$*/ -//$PageSecurity = 2; - include('includes/session.inc'); $title = _('Search Outstanding Sales Orders'); include('includes/header.inc'); + +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++){ + if ($_POST['PlacePO_' . $i]== 'on') { + if ($OrdersToPlacePOFor==''){ + $OrdersToPlacePOFor .= ' orderno=' . $_POST['OrderNo_PO_'.$i]; + } else { + $OrdersToPlacePOFor .= ' OR orderno=' . $_POST['OrderNo_PO_'.$i]; + } + } + } + if (strlen($OrdersToPlacePOFor)==''){ + prnMsg(_('There were no sales orders checked to place purchase orders for. No purchase orders will be created.'),'info'); + } 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, + stockmaster.kgs, + stockmaster.cuft + 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 + 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, + stockmaster.kgs, + stockmaster.cuft + 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); + $SupplierID = ''; + while ($ItemRow = DB_fetch_array($ItemResult)){ + $SupplierID = $ItemRow['supplierno']; + /*Now get all the required details for the supplier */ + + + + + + + + + $result = DB_Txn_Begin($db); + + /*figure out what status to set the order to */ + if (IsEmailAddress($_SESSION['UserEmail'])){ + $UserDetails = ' <a href="mailto:' . $_SESSION['UserEmail'] . '">' . $_SESSION['UsersRealName']. '</a>'; + } else { + $UserDetails = ' ' . $_SESSION['UsersRealName'] . ' '; + } + if ($_SESSION['AutoAuthorisePO']==1) { //if the user has authority to authorise the PO then it will automatically be authorised + $AuthSQL ="SELECT authlevel + FROM purchorderauth + WHERE userid='".$_SESSION['UserID']."' + AND currabrev='".$_SESSION['PO'.$identifier]->CurrCode."'"; + + $AuthResult=DB_query($AuthSQL,$db); + $AuthRow=DB_fetch_array($AuthResult); + + if (DB_num_rows($AuthResult) > 0 AND $AuthRow['authlevel'] > $_SESSION['PO'.$identifier]->Order_Value()) { //user has authority to authrorise as well as create the order + $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created and Authorised by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; + $_SESSION['PO'.$identifier]->AllowPrintPO=1; + $_SESSION['PO'.$identifier]->Status = 'Authorised'; + } else { // no authority to authorise this order + if (DB_num_rows($AuthResult) ==0){ + $AuthMessage = _('Your authority to approve purchase orders in') . ' ' . $_SESSION['PO'.$identifier]->CurrCode . ' ' . _('has not yet been set up') . '<br />'; + } else { + $AuthMessage = _('You can only authorise up to').' '.$_SESSION['PO'.$identifier]->CurrCode.' '.$AuthorityLevel.'.<br />'; + } + + prnMsg( _('You do not have permission to authorise this purchase order').'.<br />'. _('This order is for').' '. + $_SESSION['PO'.$identifier]->CurrCode . ' '. $_SESSION['PO'.$identifier]->Order_Value() .'. '. + $AuthMessage . + _('If you think this is a mistake please contact the systems administrator') . '<br />'. + _('The order will be created with a status of pending and will require authorisation'), 'warn'); + + $_SESSION['PO'.$identifier]->AllowPrintPO=0; + $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; + $_SESSION['PO'.$identifier]->Status = 'Pending'; + } + } else { //auto authorise is set to off + $_SESSION['PO'.$identifier]->AllowPrintPO=0; + $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . $UserDetails . ' - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br />'; + $_SESSION['PO'.$identifier]->Status = 'Pending'; + } + + if ($_SESSION['ExistingOrder']==0){ /*its a new order to be inserted */ + + //Do we need to check authorisation to create - no because already trapped when new PO session started + + /*Get the order number */ + $_SESSION['PO'.$identifier]->OrderNo = GetNextTransNo(18, $db); + + /*Insert to purchase order header record */ + $sql = "INSERT INTO purchorders ( orderno, + supplierno, + comments, + orddate, + rate, + initiator, + requisitionno, + intostocklocation, + deladd1, + deladd2, + deladd3, + deladd4, + deladd5, + deladd6, + tel, + suppdeladdress1, + suppdeladdress2, + suppdeladdress3, + suppdeladdress4, + suppdeladdress5, + suppdeladdress6, + suppliercontact, + supptel, + contact, + version, + revised, + deliveryby, + status, + stat_comment, + deliverydate, + paymentterms, + allowprint) + VALUES( '" . $_SESSION['PO'.$identifier]->OrderNo . "', + '" . $_SESSION['PO'.$identifier]->SupplierID . "', + '" . $_SESSION['PO'.$identifier]->Comments . "', + '" . Date('Y-m-d') . "', + '" . $_SESSION['PO'.$identifier]->ExRate . "', + '" . $_SESSION['PO'.$identifier]->Initiator . "', + '" . $_SESSION['PO'.$identifier]->RequisitionNo . "', + '" . $_SESSION['PO'.$identifier]->Location . "', + '" . $_SESSION['PO'.$identifier]->DelAdd1 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd2 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd3 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd4 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd5 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd6 . "', + '" . $_SESSION['PO'.$identifier]->Tel . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd1 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd2 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd3 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd4 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd5 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd6 . "', + '" . $_SESSION['PO'.$identifier]->SupplierContact . "', + '" . $_SESSION['PO'.$identifier]->SuppTel. "', + '" . $_SESSION['PO'.$identifier]->Contact . "', + '" . $_SESSION['PO'.$identifier]->Version . "', + '" . Date('Y-m-d') . "', + '" . $_SESSION['PO'.$identifier]->DeliveryBy . "', + '" . $_SESSION['PO'.$identifier]->Status . "', + '" . $StatusComment . "', + '" . FormatDateForSQL($_SESSION['PO'.$identifier]->DeliveryDate) . "', + '" . $_SESSION['PO'.$identifier]->PaymentTerms. "', + '" . $_SESSION['PO'.$identifier]->AllowPrintPO . "' + )"; + + $ErrMsg = _('The purchase order header record could not be inserted into the database because'); + $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + + /*Insert the purchase order detail records */ + foreach ($_SESSION['PO'.$identifier]->LineItems as $POLine) { + if ($POLine->Deleted==False) { + $sql = "INSERT INTO purchorderdetails ( orderno, + itemcode, + deliverydate, + itemdescription, + glcode, + unitprice, + quantityord, + shiptref, + jobref, + itemno, + suppliersunit, + suppliers_partno, + subtotal_amount, + package, + pcunit, + netweight, + kgs, + cuft, + total_quantity, + total_amount, + assetid, + conversionfactor ) + VALUES ( + '" . $_SESSION['PO'.$identifier]->OrderNo . "', + '" . $POLine->StockID . "', + '" . FormatDateForSQL($POLine->ReqDelDate) . "', + '" . $POLine->ItemDescription . "', + '" . $POLine->GLCode . "', + '" . $POLine->Price . "', + '" . $POLine->Quantity . "', + '" . $POLine->ShiptRef . "', + '" . $POLine->JobRef . "', + '" . $POLine->ItemNo . "', + '" . $POLine->SuppliersUnit . "', + '" . $POLine->Suppliers_PartNo . "', + '" . $POLine->SubTotal_Amount . "', + '" . $POLine->Package . "', + '" . $POLine->PcUnit . "', + '" . $POLine->NetWeight . "', + '" . $POLine->KGs . "', + '" . $POLine->CuFt . "', + '" . $POLine->Total_Quantity . "', + '" . $POLine->Total_Amount . "', + '" . $POLine->AssetID . "', + '" . $POLine->ConversionFactor . "')"; + $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); + $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); + + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + } + } /* end of the loop round the detail line items on the order */ + echo '<p>'; + prnMsg(_('Purchase Order') . ' ' . $_SESSION['PO'.$identifier]->OrderNo . ' ' . _('on') . ' ' . + $_SESSION['PO'.$identifier]->SupplierName . ' ' . _('has been created'),'success'); + } + } +}/*end of purchase order creation code */ +/* ******************************************************************************************* */ + + + + +/*To the sales order selection form */ + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/sales.png" title="' . _('Sales') . '" alt="" />' . ' ' . _('Outstanding Sales Orders') . '</p> '; echo '<form action=' . $_SERVER['PHP_SELF'] .'?' .SID . ' method=post>'; @@ -410,37 +656,53 @@ /*show a table of the orders returned by the SQL */ if (DB_num_rows($SalesOrdersResult)>0) { - echo '<table cellpadding=2 colspan=7 width=95% class=selection>'; + + /* Get users authority to place POs */ + $AuthSql="SELECT cancreate + FROM purchorderauth + WHERE userid='". $_SESSION['UserID'] . "'"; + + /*we don't know what currency these orders might be in but if no authority at all then don't show option*/ + $AuthResult=DB_query($AuthSQL,$db); + $AuthRow=DB_fetch_array($AuthResult); + echo '<table cellpadding=2 colspan=7 width=95% class=selection>'; + if (isset($_POST['Quotations']) and $_POST['Quotations']=='Orders_Only'){ - $tableheader = "<tr> - <th>" . _('Modify') . "</th> - <th>" . _('Invoice') . "</th> - <th>" . _('Dispatch Note') . "</th> - <th>" . _('Sales Order') . "</th> - <th>" . _('Customer') . "</th> - <th>" . _('Branch') . "</th> - <th>" . _('Cust Order') . " #</th> - <th>" . _('Order Date') . "</th> - <th>" . _('Req Del Date') . "</th> - <th>" . _('Delivery To') . "</th> - <th>" . _('Order Total') . "</th></tr>"; - } else { - $tableheader = "<tr> - <th>" . _('Modify') . "</th> - <th>" . _('Print Quote') . "</th> - <th>" . _('Customer') . "</th> - <th>" . _('Branch') . "</th> - <th>" . _('Cust Ref') . " #</th> - <th>" . _('Quote Date') . "</th> - <th>" . _('Req Del Date') . "</th> - <th>" . _('Delivery To') . "</th> - <th>" . _('Quote Total') . "</th></tr>"; + $tableheader = '<tr> + <th>' . _('Modify') . '</th> + <th>' . _('Invoice') . '</th> + <th>' . _('Dispatch Note') . '</th> + <th>' . _('Sales Order') . '</th> + <th>' . _('Customer') . '</th> + <th>' . _('Branch') . '</th> + <th>' . _('Cust Order') . ' #</th> + <th>' . _('Order Date') . '</th> + <th>' . _('Req Del Date') . '</th> + <th>' . _('Delivery To') . '</th> + <th>' . _('Order Total') . '</th>'; + if ($AuthRow['cancreate']==0){ //If cancreate==0 then this means the user can create orders hmmm!! + $tableheader .= '<th>' . _('Place PO') . '</th></tr>'; + } else { + $tableheader .= '</tr>'; + } + } else { /* displaying only quotations */ + $tableheader = '<tr> + <th>' . _('Modify') . '</th> + <th>' . _('Print Quote') . '</th> + <th>' . _('Customer') . '</th> + <th>' . _('Branch') . '</th> + <th>' . _('Cust Ref') . ' #</th> + <th>' . _('Quote Date') . '</th> + <th>' . _('Req Del Date') . '</th> + <th>' . _('Delivery To') . '</th> + <th>' . _('Quote Total') . '</th></tr>'; } echo $tableheader; } - $j = 1; + $i = 1; + $j = 1; $k=0; //row colour counter while ($myrow=DB_fetch_array($SalesOrdersResult)) { @@ -474,30 +736,64 @@ } if ($_POST['Quotations']=='Orders_Only'){ - printf("<td><a href='%s'>%s</a></td> - <td><a href='%s'>" . _('Invoice') . "</a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - </tr>", - $ModifyPage, - $myrow['orderno'], - $Confirm_Invoice, - $PrintDispatchNote, - $PrintSalesOrder, - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $FormatedOrderDate, - $FormatedDelDate, - $myrow['deliverto'], - $FormatedOrderValue); + + /*Check authority to create POs if user has authority then show the check boxes to select sales orders to place POs for otherwise don't provide this option */ + if ($AuthRow['cancreate']==0){ //cancreate==0 if the user can create POs + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . _('Invoice') . "</a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + <td><input type=checkbox name=PlacePO_%s><input type=hidden name=OrderNo_PO_%s value=%s></td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $Confirm_Invoice, + $PrintDispatchNote, + $PrintSalesOrder, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue, + $i, + $i, + $myrow['orderno']); + } else { /*User is not authorised to create POs so don't even show the option */ + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . _('Invoice') . "</a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $Confirm_Invoice, + $PrintDispatchNote, + $PrintSalesOrder, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue); + } + } else { /*must be quotes only */ printf("<td><a href='%s'>%s</a></td> <td><a href='%s'>" . $PrintText . "</a></td> @@ -520,7 +816,7 @@ $myrow['deliverto'], $FormatedOrderValue); } - + $i++; $j++; if ($j == 12){ $j=1; @@ -529,7 +825,9 @@ //end of page full new headings if } //end of while loop - + if ($_POST['Quotations']=='Orders_Only' AND $AuthRow['cancreate']==0){ //cancreate==0 means can create POs + echo '<tr><td colspan="10"><td><td colspan="2"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; + } echo '</table>'; } Modified: trunk/SelectSupplier.php =================================================================== --- trunk/SelectSupplier.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/SelectSupplier.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -155,28 +155,28 @@ <th width=33%>" . _('Supplier Maintenance') . "</th> </tr>"; echo '<tr><td valign=top class="select">'; /* Inquiry Options */ - echo "<a href=\"$rootpath/SupplierInquiry.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Supplier Account Inquiry') . '</a><br>'; + echo "<a href=\"$rootpath/SupplierInquiry.php?SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Supplier Account Inquiry') . '</a><br>'; echo '<br>'; - echo "<br><a href='$rootpath/PO_SelectOSPurchOrder.php?" . SID . '&SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('Add / Receive / View Outstanding Purchase Orders') . '</a>'; - echo "<br><a href='$rootpath/PO_SelectPurchOrder.php?" . SID . '&SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('View All Purchase Orders') . '</a><br>'; + echo "<br><a href='$rootpath/PO_SelectOSPurchOrder.php?SelectedSupplier=" . $_SESSION['SupplierID'] . "'>" . _('Add / Receive / View Outstanding Purchase Orders') . '</a>'; + echo "<br><a href='$rootpath/PO_SelectPurchOrder.php?SelectedSupplier=" . $_SESSION['SupplierID'] . "'>" . _('View All Purchase Orders') . '</a><br>'; wikiLink('Supplier', $_SESSION['SupplierID']); - echo "<br><a href='$rootpath/ShiptsList.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "&SupplierName=".urlencode($SupplierName)."'>" . _('List all open shipments for') .' '.$SupplierName. '</a>'; - echo "<br><a href='$rootpath/Shipt_Select.php?" . SID . '&SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('Search / Modify / Close Shipments') . '</a>'; - echo "<br><a href='$rootpath/SuppPriceList.php?" . SID . '&SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('Supplier Price List') . '</a>'; + echo "<br><a href='$rootpath/ShiptsList.php?SupplierID=" . $_SESSION['SupplierID'] . "&SupplierName=".urlencode($SupplierName)."'>" . _('List all open shipments for') .' '.$SupplierName. '</a>'; + echo "<br><a href='" . $rootpath . '/Shipt_Select.php?SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('Search / Modify / Close Shipments') . '</a>'; + echo "<br><a href='" . $rootpath . '/SuppPriceList.php?SelectedSupplier=' . $_SESSION['SupplierID'] . "'>" . _('Supplier Price List') . '</a>'; echo '</td><td valign=top class="select">'; /* Supplier Transactions */ - echo "<a href=\"$rootpath/PO_Header.php?" . SID . '&NewOrder=Yes&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Purchase Order for This Supplier') . '</a><br>'; - echo "<a href=\"$rootpath/SupplierInvoice.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Suppliers Invoice') . '</a><br>'; - echo "<a href=\"$rootpath/SupplierCredit.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . '&New=True' . "\">" . _('Enter a Suppliers Credit Note') . '</a><br>'; - echo "<a href=\"$rootpath/Payments.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Payment to, or Receipt from the Supplier') . '</a><br>'; + echo "<a href=\"$rootpath/PO_Header.php?NewOrder=Yes&SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Enter a Purchase Order for This Supplier') . '</a><br>'; + echo "<a href=\"$rootpath/SupplierInvoice.php?SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Enter a Suppliers Invoice') . '</a><br>'; + echo "<a href=\"$rootpath/SupplierCredit.php?New=true&SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Enter a Suppliers Credit Note') . '</a><br>'; + echo "<a href=\"$rootpath/Payments.php?SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Enter a Payment to, or Receipt from the Supplier') . '</a><br>'; echo '<br>'; - echo "<br><a href='$rootpath/ReverseGRN.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "'>" . _('Reverse an Outstanding Goods Received Note (GRN)') . '</a>'; + echo "<br><a href='$rootpath/ReverseGRN.php?&SupplierID=" . $_SESSION['SupplierID'] . "'>" . _('Reverse an Outstanding Goods Received Note (GRN)') . '</a>'; echo '</td><td valign=top class="select">'; /* Supplier Maintenance */ echo '<a href="' . $rootpath . '/Suppliers.php?">' . _('Add a New Supplier') . '</a><br>'; - echo "<a href=\"$rootpath/Suppliers.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Modify Or Delete Supplier Details') . '</a>'; - echo "<br><a href=\"$rootpath/SupplierContacts.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Add/Modify/Delete Supplier Contacts') . '</a>'; + echo "<a href=\"$rootpath/Suppliers.php?SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Modify Or Delete Supplier Details') . '</a>'; + echo "<br><a href=\"$rootpath/SupplierContacts.php?&SupplierID=" . $_SESSION['SupplierID'] . "\">" . _('Add/Modify/Delete Supplier Contacts') . '</a>'; echo '<br>'; - echo "<br><a href='$rootpath/Shipments.php?" . SID . "&NewShipment=Yes'>" . _('Set Up A New Shipment') . '</a>'; - echo "<br><a href='$rootpath/SuppLoginSetup.php?" . SID . "'>" . _('Supplier Login Configuration') . '</a>'; + echo "<br><a href='$rootpath/Shipments.php?NewShipment=Yes'>" . _('Set Up A New Shipment') . '</a>'; + echo "<br><a href='$rootpath/SuppLoginSetup.php'>" . _('Supplier Login Configuration') . '</a>'; echo '</td></tr></table>'; } else { // Supplier is not selected yet Modified: trunk/StockQuantityByDate.php =================================================================== --- trunk/StockQuantityByDate.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/StockQuantityByDate.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -22,16 +22,17 @@ echo '<table class=selection><tr>'; echo '<td>' . _('For Stock Category') . ":</td> <td><select name='StockCategory'> "; +echo '<option value="All">' . _('All') . '</option>'; while ($myrow=DB_fetch_array($resultStkLocs)){ if (isset($_POST['StockCategory']) AND $_POST['StockCategory']!='All'){ if ($myrow['categoryid'] == $_POST['StockCategory']){ - echo "<option selected VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription']; + echo "<option selected VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription'] . '</option>'; } else { - echo "<option VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription']; + echo "<option VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription'] . '</option>'; } }else { - echo "<option VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription']; + echo "<option VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categorydescription'] . '</option>'; } } echo '</select></td>'; @@ -69,14 +70,21 @@ $TotalQuantity = 0; -if(isset($_POST['ShowStatus']) AND Is_Date($_POST['OnHandDate'])) -{ - $sql = "SELECT stockid, - description, - decimalplaces - FROM stockmaster - WHERE categoryid = '" . $_POST['StockCategory'] . "' - AND (mbflag='M' OR mbflag='B')"; +if(isset($_POST['ShowStatus']) AND Is_Date($_POST['OnHandDate'])) { + if ($_POST['StockCategory']='All') { + $sql = "SELECT stockid, + description, + decimalplaces + FROM stockmaster + WHERE (mbflag='M' OR mbflag='B')"; + } else { + $sql = "SELECT stockid, + description, + decimalplaces + FROM stockmaster + WHERE categoryid = '" . $_POST['StockCategory'] . "' + AND (mbflag='M' OR mbflag='B')"; + } $ErrMsg = _('The stock items in the category selected cannot be retrieved because'); $DbgMsg = _('The SQL that failed was'); Modified: trunk/StockStatus.php =================================================================== --- trunk/StockStatus.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/StockStatus.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -274,22 +274,25 @@ $k=1; while ($myrow=DB_fetch_array($MovtsResult)) { - if ($LastPrice != $myrow['price'] or $LastDiscount != $myrow['discount']) { /* consolidate price history for records with same price/discount */ - if ($qty) { + if ($LastPrice != $myrow['price'] OR $LastDiscount != $myrow['discount']) { /* consolidate price history for records with same price/discount */ + if (isset($qty)) { $DateRange=ConvertSQLDate($FromDate); if ($FromDate != $ToDate) { $DateRange .= ' - ' . ConvertSQLDate($ToDate); } $PriceHistory[] = array($DateRange, $qty, $LastPrice, $LastDiscount); $k++; - if ($k > 9) break; /* 10 price records is enough to display */ - if ($myrow['trandate'] < FormatDateForSQL(time() - 366*86400)) + if ($k > 9) { + break; /* 10 price records is enough to display */ + } + if ($myrow['trandate'] < FormatDateForSQL(DateAdd(date($_SESSION['DefaultDateFormat']),'y', -1))) { break; /* stop displaying pirce history more than a year old once we have at least one to display */ + } } - $LastPrice = $myrow['price']; - $LastDiscount = $myrow['discount']; + $LastPrice = $myrow['price']; + $LastDiscount = $myrow['discountpercent']; $ToDate = $myrow['trandate']; - $qty = 0; + $qty = 0; } $qty += $myrow['qty']; $FromDate = $myrow['trandate']; @@ -302,8 +305,8 @@ $PriceHistory[] = array($DateRange, $qty, $LastPrice, $LastDiscount); } if (isset($PriceHistory)) { - echo '<p>' . _('Pricing history for sales of') . ' ' . $StockID . ' ' . _('to') . ' ' . $DebtorNo; - echo '<table cellpadding="2" class="selection">'; + echo '<br /><table cellpadding="4" class="selection">'; + echo '<tr><th colspan=4><font color=navy size=2>' . _('Pricing history for sales of') . ' ' . $StockID . ' ' . _('to') . ' ' . $DebtorNo . '</font></th></tr>'; $tableheader = "<tr> <th>" . _('Date Range') . "</th> <th>" . _('Quantity') . "</th> Modified: trunk/SupplierCredit.php =================================================================== --- trunk/SupplierCredit.php 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/SupplierCredit.php 2011-03-10 06:24:48 UTC (rev 4506) @@ -36,7 +36,7 @@ //echo "<a href='" . $rootpath . '/SelectSupplier.php?' . SID . "'>" . _('Back to Suppliers') . '</a><br>'; if (isset($_GET['New'])) { - unset($_SESSION['SuppTrans']); + unset($_SESSION['SuppTrans']); } if (!isset($_SESSION['SuppTrans']->SupplierName)) { @@ -615,8 +615,8 @@ }elseif ($_SESSION['SuppTrans']->ExRate <= 0){ $InputError = True; prnMsg(_('The credit note as entered cannot be processed because the exchange rate for the credit note has been entered as a negative or zero number') . '. ' . _('The exchange rate is expected to show how many of the suppliers currency there are in 1 of the local currency'),'warn'); - }elseif ($_SESSION['SuppTrans']->OvAmount < round($TotalGRNValue + $TotalGLValue + $TotalAssetValue + $TotalShiptValue + $TotalContractsValue,2)){ - prnMsg(_('The credit note total as entered is less than the sum of the shipment charges, the general ledger entries (if any) and the charges for goods received, contracts and fixed assets. There must be a mistake somewhere, the credit note as entered will not be processed'),'error'); + }elseif ($_SESSION['SuppTrans']->OvAmount < round($TotalShiptValue + $TotalGLValue + $TotalAssetValue + $TotalGRNValue,2)){ + prnMsg(_('The credit note total as entered is less than the sum of the shipment charges') . ', ' . _('the general ledger entries (if any) and the charges for goods received') . '. ' . _('There must be a mistake somewhere') . ', ' . _('the credit note as entered will not be processed'),'error'); $InputError = True; } else { @@ -722,15 +722,15 @@ foreach ($_SESSION['SuppTrans']->Assets as $AssetAddition){ /* only the GL entries if the creditors->GL integration is enabled */ - $SQL = "INSERT INTO gltrans (type, + $SQL = 'INSERT INTO gltrans (type, typeno, trandate, periodno, account, narrative, amount) - VALUES (21, '" . - $CreditNoteNo . "', + VALUES (21, ' . + $CreditNoteNo . ", '" . $SQLCreditNoteDate . "', '" . $PeriodNo . "', '". $AssetAddition->CostAct . "', Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/doc/Change.log.html 2011-03-10 06:24:48 UTC (rev 4506) @@ -1,8 +1,11 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>10/3/11: Phil fix pagination of PrintCustOrder_generic.php - second copy was not restarting page numbers</p> +<p>10/3/11: Tims launchpad fixes brought in MRP.php fix for table charset utf8 so joins work correctly; typeo in PO_Header preventing purchasing data being retrieved ($result not $Result); correct sql on searching for customer in SelectCreditItems.php; StockStatus.php pricing history bug resolved (4450); StockQuantityByDate.php now allowed to show for all categories - enclosed 'All' in gettext</p> +<p>8/3/11: Tim/Phil PO_Items.php in committing an order detail the assetid of 'Not an Asset' was being inserted to an integer field. Modified $_POST['AssetID'] to = 0 if it was 'Not an Asset' as advised by Tim</p> <p>8/3/11:Phil fix SalesAnalysis reports for TCPDF as reported by Joe Zhou</p> <p>5/3/11: Kovács Attila fix to Stocks.php to use ANSI GROUP BY for aggregate functions SQL</p> -<p>5/3/11: Kovács Attila fix to LanguageSetup.php to use utf-8 not ISO-8859-1. Phil hardcoded UTF- now as no dynamic changing of character set required all translations are utf-8</p> +<p>5/3/11: Kovács Attila fix to LanguageSetup.php to use utf-8 not ISO-8859-1. Phil hardcoded UTF-8 now as no dynamic changing of character set required all translations are utf-8</p> <p>3/3/11: Exson/Baran/Phil fix to customer login to ensure that other customers orders are not displayed when searching by customer ref or order no</p> <p>3/3/11: Tim launchpad mods to revision 4441 including change to allow supplier currency to be changed if there are no transactions already against the supplier. Ensure credit note session variable is unset before attempting to create a new credit note from the supplier form. Tim's work to add perisable expiry dates to the serial items logic - affects quite a few scripts. Headings to stock check script even if no quantity is shown. Portrait quotations. Not included change to default delivery date to the date the customer requested - left to be the current day's date. Not included Tim's unit pricing work .. yet launchpad revisions 4442-4447 inclusive</p> <p>27/2/11: Phil/Tim/Peter launchpad added category option for MRPShortages.php links with matching quotes in WorkOrderEntry</p> Modified: trunk/doc/README.txt =================================================================== --- trunk/doc/README.txt 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/doc/README.txt 2011-03-10 06:24:48 UTC (rev 4506) @@ -4,29 +4,27 @@ Thankyou for using webERP. -Installation instructions are in the file INSTALL.txt in the doc directory. It is important to read the INSTALL.txt file in its entirety before proceeding. In fact a printout is not a bad idea. +Installation instructions are in the file INSTALL.txt in the doc directory. It is important to read the INSTALL.txt file in its entirety before proceeding. A printout is recommended. The user documentation contains a wealth of information and is installed under the doc/Manual directory in html format. Links to it are available from the application itself. SUPPORT -The primary means of support queries is through the user mailing list. +The primary means of support queries is through the user mailing list. Please join the list at: http://lists.sourceforge.net/lists/listinfo/web-erp-users if you have queries. The archives of the mailing lists on sourceforge and the FAQ (see http://www.weberp.org/wikidocs/FrequentlyAskedQuestionsInstallation) contain the most common issues with respect to installation. -Feedback, wants and gripes are encouraged in the interests of improving this applicaton. +Feedback, wants and gripes are encouraged in the interests of improving the applicaton. -DEVELOPING +DEVELOPING -All contributions of code are needed and encouraged. -Guidelines for contributing code are in the document at http://www.weberp.org/wikidocs/ContributingtowebERP developers should read this document carefully and follow the guidelines therein. Standards and conventions used in the code are rigorously applied in the interests of consistency and readability. Code submitted that does not conform to these standards will be changed so it does where possible. +Contributions of code are documents including HOW-TOs with screen-shots etc are encouraged. Contributions in the form of bug reports or other feedback through the mainling lists above are also encouraged. +Guidelines for contributing code are in the document at http://www.weberp.org/wikidocs/ContributingtowebERP developers should read this document carefully and follow the guidelines therein. Standards and conventions used in the code are rigorously applied in the interests of consistency and readability. Code submitted that does not conform to these standards will be changed so it does where possible. If the job to make the code conform to webERP standards is too large then the code will not be included. TRANSLATIONS -Translations that have been contributed are distributed as separate language archives. These must be downloaded separately from: +All available translations are now included in the archive downloaded. -http://sourceforge.net/project/showfiles.php?group_id=70949 - Translators should read the document http://www.weberp.org/HowToTranslate which describes how to translate webERP. Translations must be installed under the webERP/locale directory and the locale must be available on the web-server. @@ -42,4 +40,4 @@ A copy of the GNU General Public License is included in the doc directory along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Copyright weberp.org 2010 - Contact: in...@we... \ No newline at end of file +Copyright weberp.org 2011 - Contact: in...@we... \ No newline at end of file Modified: trunk/doc/UPGRADING.txt =================================================================== --- trunk/doc/UPGRADING.txt 2011-03-08 09:32:48 UTC (rev 4505) +++ trunk/doc/UPGRADING.txt 2011-03-10 06:24:48 UTC (rev 4506) @@ -2,6 +2,8 @@ /* $Id$*/ +From version 4.01 database upgrades are now automatically processed if the version number of the code is different to the version number of the database. The first login will require the system administrator to allow the system to upgrade it's own database. A backup of the database prior to the running the upgrade is advisable. The new upgrade system will not be able to identify versions prior to 3.11 so it is necessary to select the version being upgraded from manaully. It can process database upgrades from version 3.00 onwards. + From version 3.05 an upgrade script will be provided that applies the database modifications automatically and does any data conversions required for the new scripts to work. The upgrade script to convert a 3.05 database to work with 3.06 scripts is: @@ -13,7 +15,7 @@ Previous to version 3.05, the database conversion had to be done manually - the instructions to complete upgrades from older versions are provided below: -CONVERTING THE DATABASE +CONVERTING THE DATABASE MANUALY - THE DETAIL As each new version is released the new php scripts will use new database fields or changed field names. A a consequence, the new scripts will most likely not work unless the database structure has been converted to the new database structure. Normally the changes to the database between versions are small. However, between 2.9b and 3.0 the changes were significant and the upgrade script may take some time to run. It should not be run from a phpMyAdmin window since PHP will time out long before the upgrade script will have finished. @@ -26,9 +28,9 @@ where XX.XX is the old version number and YY.YY is the new version number. No other users should be using the database. The upgrade script will need to be edited to use the name of the database that your webERP installation was created with - by default this is weberp. If the default has not been changed then the following line will need to be added to the upgrade script - right at the beginning: - + use weberp; - + A similar line will be required but substituting the name of the database that your installation uses where the default database name has been changed. @@ -58,7 +60,7 @@ There are extensive changes to the database and the upgrade2.9b-3.0.sql may take some time to run depending on how much data there is in the system. A backup of the 2.9b database dump should be taken prior to attempting to run the upgrade script. -IMPORTANT: Note that version of mysql 4.1.8 or greater is required because from the mysql change log: +IMPORTANT: Note that version of mysql 4.1.8 or greater is required because from the mysql change log: "Fix two hangs: FOREIGN KEY constraints treated table and database names as case-insensitive. RENAME TABLE t TO T would hang in an endless loop if t had a foreign key constraint defined on it. Fix also a hang over the dictionary mutex that would occur if one tried in ALTER TABLE or RENAME TABLE to create a foreign key constraint name that collided with another existing name. (Bug #3478)" @@ -71,6 +73,6 @@ 3.05 now has Dave Premo's report writer scripts included in the distribution - additional tables are required for this functionality. Also, 3.05 allows for weighted average stock valuation - using the existing data fields and retaining integrated general ledger stock values. This requires cost information to be copied over into the grns table. The upgrade script Z_Upgrade_3.04-3.05.php applies all the additional tables to the database and does the data conversions required wihtout any manual intervention. -NOTES ON UPGRADING FROM 3.11 to 3.12 +NOTES ON UPGRADING FROM 3.11 to 4.x -PHP 5 is now required because of the simpleXML module of PHP only comes with PHP 5. This is used on the new XML definition of report formats. \ No newline at end of file +PHP 5 is now required because of the simpleXML module of PHP only comes with PHP 5+. This is used on the new XML definition of report formats. \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-08 09:32:55
|
Revision: 4505 http://web-erp.svn.sourceforge.net/web-erp/?rev=4505&view=rev Author: daintree Date: 2011-03-08 09:32:48 +0000 (Tue, 08 Mar 2011) Log Message: ----------- PO Not an Asset SQL fix Modified Paths: -------------- trunk/PO_Items.php Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2011-03-08 07:38:45 UTC (rev 4504) +++ trunk/PO_Items.php 2011-03-08 09:32:48 UTC (rev 4505) @@ -195,7 +195,7 @@ '" . $_SESSION['PO'.$identifier]->PaymentTerms. "', '" . $_SESSION['PO'.$identifier]->AllowPrintPO . "' )"; - + $ErrMsg = _('The purchase order header record could not be inserted into the database because'); $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); @@ -250,6 +250,7 @@ '" . $POLine->ConversionFactor . "')"; $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); } } /* end of the loop round the detail line items on the order */ @@ -510,7 +511,10 @@ $_POST['ItemDescription'] = $AssetRow['description']; } } - } //end if an AssetID is entered + } /*end if an AssetID is entered */ + else { + $_POST['AssetID'] = 0; // cannot commit a string to an integer field so make it 0 if AssetID = 'Not an Asset' + } if (strlen($_POST['ItemDescription'])<=3){ $AllowUpdate = false; prnMsg(_('Cannot enter this order line') . ':<br />' . _('The description of the item being purchased is required where a non-stock item is being ordered'),'warn'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-08 09:32:55
|
Revision: 4505 http://web-erp.svn.sourceforge.net/web-erp/?rev=4505&view=rev Author: daintree Date: 2011-03-08 09:32:48 +0000 (Tue, 08 Mar 2011) Log Message: ----------- PO Not an Asset SQL fix Modified Paths: -------------- trunk/PO_Items.php Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2011-03-08 07:38:45 UTC (rev 4504) +++ trunk/PO_Items.php 2011-03-08 09:32:48 UTC (rev 4505) @@ -195,7 +195,7 @@ '" . $_SESSION['PO'.$identifier]->PaymentTerms. "', '" . $_SESSION['PO'.$identifier]->AllowPrintPO . "' )"; - + $ErrMsg = _('The purchase order header record could not be inserted into the database because'); $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); @@ -250,6 +250,7 @@ '" . $POLine->ConversionFactor . "')"; $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); } } /* end of the loop round the detail line items on the order */ @@ -510,7 +511,10 @@ $_POST['ItemDescription'] = $AssetRow['description']; } } - } //end if an AssetID is entered + } /*end if an AssetID is entered */ + else { + $_POST['AssetID'] = 0; // cannot commit a string to an integer field so make it 0 if AssetID = 'Not an Asset' + } if (strlen($_POST['ItemDescription'])<=3){ $AllowUpdate = false; prnMsg(_('Cannot enter this order line') . ':<br />' . _('The description of the item being purchased is required where a non-stock item is being ordered'),'warn'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-08 07:38:52
|
Revision: 4504 http://web-erp.svn.sourceforge.net/web-erp/?rev=4504&view=rev Author: daintree Date: 2011-03-08 07:38:45 +0000 (Tue, 08 Mar 2011) Log Message: ----------- Sales Analysis fix Modified Paths: -------------- trunk/SalesAnalysis_UserDefined.php trunk/doc/Change.log.html trunk/includes/PDFSalesAnalysis.inc Modified: trunk/SalesAnalysis_UserDefined.php =================================================================== --- trunk/SalesAnalysis_UserDefined.php 2011-03-04 19:40:47 UTC (rev 4503) +++ trunk/SalesAnalysis_UserDefined.php 2011-03-08 07:38:45 UTC (rev 4504) @@ -2,7 +2,7 @@ /* $Id$ */ -//$PageSecurity = 2; + include('includes/session.inc'); if (!in_array($PageSecurity,$_SESSION['AllowedPageSecurityTokens'])){ @@ -18,9 +18,9 @@ if ($Counter >0) { $pdf->OutputD('SalesAnalysis_' . date('Y-m-d') . '.pdf'); - $pdf-> __destruct(); + $pdf->__destruct(); } else { - $pdf-> __destruct(); + $pdf->__destruct(); $title = _('User Defined Sales Analysis Problem'); include('includes/header.inc'); echo '<p>' . _('The report did not have any none zero lines of information to show and so it has not been created'); @@ -46,5 +46,4 @@ echo '<p>' . _('You should automatically be forwarded to the CSV Sales Analysis file when it is ready') . '. ' . _('If this does not happen') . ' <a href="' . $rootpath . '/' . $_SESSION['reports_dir'] . '/SalesAnalysis.csv">' . _('click here') . '</a> ' . _('to continue') . '<br />'; include('includes/footer.inc'); } - -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-04 19:40:47 UTC (rev 4503) +++ trunk/doc/Change.log.html 2011-03-08 07:38:45 UTC (rev 4504) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>8/3/11:Phil fix SalesAnalysis reports for TCPDF as reported by Joe Zhou</p> <p>5/3/11: Kovács Attila fix to Stocks.php to use ANSI GROUP BY for aggregate functions SQL</p> <p>5/3/11: Kovács Attila fix to LanguageSetup.php to use utf-8 not ISO-8859-1. Phil hardcoded UTF- now as no dynamic changing of character set required all translations are utf-8</p> <p>3/3/11: Exson/Baran/Phil fix to customer login to ensure that other customers orders are not displayed when searching by customer ref or order no</p> Modified: trunk/includes/PDFSalesAnalysis.inc =================================================================== --- trunk/includes/PDFSalesAnalysis.inc 2011-03-04 19:40:47 UTC (rev 4503) +++ trunk/includes/PDFSalesAnalysis.inc 2011-03-08 07:38:45 UTC (rev 4504) @@ -4,23 +4,23 @@ include ('includes/class.pdf.php'); -/* A4_Landscape */ +/* A4_Landscape */ +$DocumentPaper = 'A4'; +$DocumentOrientation ='L'; $Page_Width=842; $Page_Height=595; -$Top_Margin=20; -$Bottom_Margin=20; -$Left_Margin=25; -$Right_Margin=22; +$Top_Margin=30; +$Bottom_Margin=30; +$Left_Margin=40; +$Right_Margin=30; -// Javier: now I use the native constructor -// $PageSize = array(0,0,$Page_Width,$Page_Height); +$pdf = new Cpdf($DocumentOrientation, 'pt', $DocumentPaper); +$pdf->SetAutoPageBreak(true, 0); +$pdf->SetPrintHeader(false); +$pdf->AddPage(); +$pdf->cMargin = 0; -// Javier: better to not use references -// $pdf = & new Cpdf($PageSize); - $pdf = new Cpdf('L', 'pt', 'A4'); - - /* Standard PDF file creation header stuff */ $pdf->addInfo('Author','webERP ' . $Version); @@ -41,278 +41,269 @@ /*Make an array to hold accumulators for */ $AccumLvl1 = array(); +$AccumLvl2 = array(); +$AccumLvl3 = array(); +$AccumLvl4 = array(); + for ($i=0;$i<=10;$i++){ -$AccumLvl1[$i]=0; + $AccumLvl1[$i]=0; + $AccumLvl2[$i]=0; + $AccumLvl3[$i]=0; + $AccumLvl4[$i]=0; } -$AccumLvl2= array(); -for ($i=0;$i<=10;$i++){ -$AccumLvl2[$i]=0; -} -$AccumLvl3=array(); -for ($i=0;$i<=10;$i++){ -$AccumLvl3[$i]=0; -} -$AccumLvl4=array(); -for ($i=0;$i<=10;$i++){ -$AccumLvl4[$i]=0; -} While ($myrow = DB_fetch_array($result)){ /*First off check that at least one of the columns of data has some none zero amounts */ -DB_data_seek($ColsResult,0); /*go back to the beginning */ -$ThisLineHasOutput=False; /*assume no output to start with */ -while ($Cols = DB_fetch_array($ColsResult)){ - $ColumnNo ='col' . ((int) $Cols['colno'] + 8); - if (abs($myrow[$ColumnNo])>0.5){ - $ThisLineHasOutput = True; + DB_data_seek($ColsResult,0); /*go back to the beginning */ + $ThisLineHasOutput=False; /*assume no output to start with */ + while ($Cols = DB_fetch_array($ColsResult)){ + $ColumnNo ='col' . ((int) $Cols['colno'] + 8); + if (abs($myrow[$ColumnNo])>0.5){ + $ThisLineHasOutput = True; + } } -} -if ($ThisLineHasOutput==True){ + if ($ThisLineHasOutput==True){ - if ($myrow['col5']!=$GrpData3 && $myrow['col5']!='0' && $myrow['col7']!='0'){ - /*Totals only relevant to GrpByLevel 3 if GrpByLevel 4 also used */ - if ($Counter > 0){ /*Dont want to print totals if this is the first record */ - $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col5'] . ' - ' . $LastLine['col6'],0,33); - $LeftOvers = $pdf->addTextWrap(40,$Ypos,180,$FontSize,$TotalText); + if ($myrow['col5']!=$GrpData3 && $myrow['col5']!='0' && $myrow['col7']!='0'){ + /*Totals only relevant to GrpByLevel 3 if GrpByLevel 4 also used */ + if ($Counter > 0){ /*Dont want to print totals if this is the first record */ + $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col5'] . ' - ' . $LastLine['col6'],0,33); + $LeftOvers = $pdf->addTextWrap(40,$Ypos,180,$FontSize,$TotalText); - DB_data_seek($ColsResult,0); - while ($Cols = DB_fetch_array($ColsResult)){ - $Xpos = 160 + $Cols['colno']*60; - if ($Cols['calculation']==0){ - $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, number_format($AccumLvl3[$Cols['colno']]),'right'); - } else { /* its a calculation need to re-perform on the totals*/ + DB_data_seek($ColsResult,0); + while ($Cols = DB_fetch_array($ColsResult)){ + $Xpos = 160 + $Cols['colno']*60; + if ($Cols['calculation']==0){ + $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, number_format($AccumLvl3[$Cols['colno']]),'right'); + } else { /* its a calculation need to re-perform on the totals*/ - switch ($Cols['calcoperator']) { - case '/': - if ($AccumLvl3[$Cols['coldenominator']]==0){ - $TotalCalculation = 0; + switch ($Cols['calcoperator']) { + case '/': + if ($AccumLvl3[$Cols['coldenominator']]==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] / $AccumLvl3[$Cols['coldenominator']]; + } + break; + case '+': + $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] + $AccumLvl3[$Cols['coldenominator']]; + break; + case '-': + $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] + $AccumLvl3[$Cols['coldenominator']]; + break; + case '*': + $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] * $Cols['constant']; + break; + case 'C': + if ($Cols['constant']==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] / $Cols['constant']; + } + break; + } /*end of switch stmt block*/ + if ($Cols['valformat']=='P'){ + $TotalCalculation = number_format($TotalCalculation * 100) . '%'; } else { - $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] / $AccumLvl3[$Cols['coldenominator']]; + $TotalCalculation = number_format($TotalCalculation); } - break; - case '+': - $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] + $AccumLvl3[$Cols['coldenominator']]; - break; - case '-': - $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] + $AccumLvl3[$Cols['coldenominator']]; - break; - case '*': - $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] * $Cols['constant']; - break; - case 'C': - if ($Cols['constant']==0){ - $TotalCalculation = 0; - } else { - $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] / $Cols['constant']; - } - break; - } /*end of switch stmt block*/ - if ($Cols['valformat']=='P'){ - $TotalCalculation = number_format($TotalCalculation * 100) . '%'; - } else { - $TotalCalculation = number_format($TotalCalculation); + $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); } - $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); } + $Ypos -=(2*$line_height); + /*reset the accumulators to 0 */ + for ($i=0;$i<=10;$i++){ + $AccumLvl3[$i]=0; + } } - $Ypos -=(2*$line_height); - /*reset the accumulators to 0 */ - for ($i=0;$i<=10;$i++){ - $AccumLvl3[$i]=0; - } } - } - - if ($myrow['col3']!=$GrpData2 && $myrow['col3']!='0' && $myrow['col5']!='0'){ + if ($myrow['col3']!=$GrpData2 && $myrow['col3']!='0' && $myrow['col5']!='0'){ /*Totals only relevant to GrpByLevel 2 if GrpByLevel 3 also used */ - if ($Counter > 0){ /*Dont want to print totals if this is the first record */ - $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col3'] . ' - ' . $LastLine['col4'],0,43); - $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$TotalText); - DB_data_seek($ColsResult,0); - while ($Cols = DB_fetch_array($ColsResult)){ - $Xpos = 160 + $Cols['colno']*60; - if ($Cols['calculation']==0){ - $LeftOvers = $pdf->addTextWrap($Xpos, $Ypos,60,$FontSize, number_format($AccumLvl2[$Cols['colno']]),'right'); - } else { /* its a calculation need to re-perform on the totals*/ + if ($Counter > 0){ /*Dont want to print totals if this is the first record */ + $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col3'] . ' - ' . $LastLine['col4'],0,43); + $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$TotalText); + DB_data_seek($ColsResult,0); + while ($Cols = DB_fetch_array($ColsResult)){ + $Xpos = 160 + $Cols['colno']*60; + if ($Cols['calculation']==0){ + $LeftOvers = $pdf->addTextWrap($Xpos, $Ypos,60,$FontSize, number_format($AccumLvl2[$Cols['colno']]),'right'); + } else { /* its a calculation need to re-perform on the totals*/ - switch ($Cols['calcoperator']) { - case '/': - if ($AccumLvl2[$Cols['coldenominator']]==0){ - $TotalCalculation = 0; + switch ($Cols['calcoperator']) { + case '/': + if ($AccumLvl2[$Cols['coldenominator']]==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] / $AccumLvl2[$Cols['coldenominator']]; + } + break; + case '+': + $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] + $AccumLvl2[$Cols['coldenominator']]; + break; + case '-': + $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] + $AccumLvl2[$Cols['coldenominator']]; + break; + case '*': + $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] * $Cols['constant']; + break; + case 'C': + if ($Cols['constant']==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] / $Cols['constant']; + } + break; + } /*end of switch stmt block*/ + if ($Cols['valformat']=='P'){ + $TotalCalculation = number_format($TotalCalculation * 100) . '%'; } else { - $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] / $AccumLvl2[$Cols['coldenominator']]; + $TotalCalculation = number_format($TotalCalculation); } - break; - case '+': - $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] + $AccumLvl2[$Cols['coldenominator']]; - break; - case '-': - $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] + $AccumLvl2[$Cols['coldenominator']]; - break; - case '*': - $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] * $Cols['constant']; - break; - case 'C': - if ($Cols['constant']==0){ - $TotalCalculation = 0; - } else { - $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] / $Cols['constant']; - } - break; - } /*end of switch stmt block*/ - if ($Cols['valformat']=='P'){ - $TotalCalculation = number_format($TotalCalculation * 100) . '%'; - } else { - $TotalCalculation = number_format($TotalCalculation); - } - $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); + $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); + }/*end if not a calculation column*/ + }/*end while loop through column definitions */ + $Ypos -=(2*$line_height); + /*reset the accumulators to 0 */ + for ($i=0;$i<=10;$i++){ + $AccumLvl2[$i]=0; } - - } - $Ypos -=(2*$line_height); - /*reset the accumulators to 0 */ - for ($i=0;$i<=10;$i++){ - $AccumLvl2[$i]=0; - } + }/*end if Counter > 0 */ } - } - if ($myrow['col1']!=$GrpData1 && $myrow['col3']!='0'){ - /*Totals only relevant to GrpByLevel 1 if GrpByLevel 2 also used */ - if ($Counter > 0){ /*Dont want to print totals if this is the first record */ - $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col1'] . ' - ' . $LastLine['col2'],0,46); - $LeftOvers = $pdf->addTextWrap(15,$Ypos,205,$FontSize,$TotalText); - DB_data_seek($ColsResult,0); - while ($Cols = DB_fetch_array($ColsResult)){ - $Xpos = 160 + $Cols['colno']*60; - if ($Cols['calculation']==0){ - $LeftOvers = $pdf->addTextWrap($Xpos, $Ypos,60,$FontSize, number_format($AccumLvl1[$Cols['colno']]),'right'); - } else { /* its a calculation need to re-perform on the totals*/ - - switch ($Cols['calcoperator']) { - Case '/': - if ($AccumLvl1[$Cols['coldenominator']]==0){ - $TotalCalculation = 0; + if ($myrow['col1']!=$GrpData1 && $myrow['col3']!='0'){ + /*Totals only relevant to GrpByLevel 1 if GrpByLevel 2 also used */ + if ($Counter > 0){ /*Dont want to print totals if this is the first record */ + $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col1'] . ' - ' . $LastLine['col2'],0,46); + $LeftOvers = $pdf->addTextWrap(15,$Ypos,205,$FontSize,$TotalText); + DB_data_seek($ColsResult,0); + while ($Cols = DB_fetch_array($ColsResult)){ + $Xpos = 160 + $Cols['colno']*60; + if ($Cols['calculation']==0){ + $LeftOvers = $pdf->addTextWrap($Xpos, $Ypos,60,$FontSize, number_format($AccumLvl1[$Cols['colno']]),'right'); + } else { /* its a calculation need to re-perform on the totals*/ + + switch ($Cols['calcoperator']) { + Case '/': + if ($AccumLvl1[$Cols['coldenominator']]==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] / $AccumLvl1[$Cols['coldenominator']]; + } + break; + Case '+': + $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] + $AccumLvl1[$Cols['coldenominator']]; + break; + Case '-': + $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] + $AccumLvl1[$Cols['coldenominator']]; + break; + Case '*': + $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] * $Cols['constant']; + break; + Case 'C': + if ($Cols['constant']==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] / $Cols['constant']; + } + break; + } /*end of switch stmt block*/ + if ($Cols['valformat']=='P'){ + $TotalCalculation = number_format($TotalCalculation * 100) . '%'; } else { - $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] / $AccumLvl1[$Cols['coldenominator']]; + $TotalCalculation = number_format($TotalCalculation); } - break; - Case '+': - $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] + $AccumLvl1[$Cols['coldenominator']]; - break; - Case '-': - $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] + $AccumLvl1[$Cols['coldenominator']]; - break; - Case '*': - $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] * $Cols['constant']; - break; - Case 'C': - if ($Cols['constant']==0){ - $TotalCalculation = 0; - } else { - $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] / $Cols['constant']; - } - break; - } /*end of switch stmt block*/ - if ($Cols['valformat']=='P'){ - $TotalCalculation = number_format($TotalCalculation * 100) . '%'; - } else { - $TotalCalculation = number_format($TotalCalculation); - } - $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); + $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); + }/*end if its not a calculation */ + } /* end loop around column defintions */ + $Ypos -=(2*$line_height); + + /*reset the accumulators to 0 */ + for ($i=0;$i<=10;$i++){ + $AccumLvl1[$i]=0; } + }/* end if counter>0 */ + } + + $NewHeading =0; + if ($myrow['col1']!=$GrpData1){ /*Need a new heading for Level 1 */ + $NewHeading = 1; + if ($ReportSpec['newpageafter1']==1){ + include ('includes/PDFSalesAnalPageHeader.inc'); } - $Ypos -=(2*$line_height); + $GroupHeadingText = substr($myrow['col1'] . ' - ' . $myrow['col2'],0,50); + $LeftOvers = $pdf->addTextWrap(15,$Ypos,205,$FontSize,$GroupHeadingText); - /*reset the accumulators to 0 */ - for ($i=0;$i<=10;$i++){ - $AccumLvl1[$i]=0; + if ($myrow['col3']!='0'){ + $Ypos-=$line_height; } } - } - $NewHeading =0; + if (($myrow['col3']!=$GrpData2 OR $NewHeading ==1) AND $myrow['col3']!='0'){ + /*Need a new heading for Level 2 */ + $NewHeading = 1; + if ($ReportSpec['newpageafter2']==1){ + include ('includes/PDFSalesAnalPageHeader.inc'); + } + $GroupHeadingText = substr($myrow['col3'] . ' - ' . $myrow['col4'],0,46); + $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$GroupHeadingText); - if ($myrow['col1']!=$GrpData1){ /*Need a new heading for Level 1 */ - $NewHeading = 1; - if ($ReportSpec['newpageafter1']==1){ - include ('includes/PDFSalesAnalPageHeader.inc'); - } - $GroupHeadingText = substr($myrow['col1'] . ' - ' . $myrow['col2'],0,50); - $LeftOvers = $pdf->addTextWrap(15,$Ypos,205,$FontSize,$GroupHeadingText); - - if ($myrow['col3']!='0'){ + if ($myrow['col5']!='0'){ $Ypos-=$line_height; + } } - } + if (($myrow['col5']!=$GrpData3 OR $NewHeading ==1) AND $myrow['col5']!='0'){ + /*Need a new heading for Level 3 */ - if (($myrow['col3']!=$GrpData2 OR $NewHeading ==1) AND $myrow['col3']!='0'){ - /*Need a new heading for Level 2 */ - $NewHeading = 1; - if ($ReportSpec['newpageafter2']==1){ - include ('includes/PDFSalesAnalPageHeader.inc'); - } - $GroupHeadingText = substr($myrow['col3'] . ' - ' . $myrow['col4'],0,46); - $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$GroupHeadingText); + if ($ReportSpec['newpageafter3']==1){ + include ('includes/PDFSalesAnalPageHeader.inc'); + } + $GroupHeadingText = substr($myrow['col5'] . ' - ' . $myrow['col6'],0,46); + $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$GroupHeadingText); - if ($myrow['col5']!='0'){ - $Ypos-=$line_height; + if ($myrow['col7']!='0'){ + $Ypos-=$line_height; + } } - } - if (($myrow['col5']!=$GrpData3 OR $NewHeading ==1) AND $myrow['col5']!='0'){ - /*Need a new heading for Level 3 */ - if ($ReportSpec['newpageafter3']==1){ - include ('includes/PDFSalesAnalPageHeader.inc'); - } - $GroupHeadingText = substr($myrow['col5'] . ' - ' . $myrow['col6'],0,46); - $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$GroupHeadingText); - if ($myrow['col7']!='0'){ - $Ypos-=$line_height; + /*show titles */ + $GroupHeadingText = substr($myrow['col7'] . ' - ' . $myrow['col8'], 0, 40); + $LeftOvers = $pdf->addTextWrap(55,$Ypos,135,$FontSize,$GroupHeadingText); + } - } - if ($myrow['col7']!='0'){ - /*show titles */ - $GroupHeadingText = substr($myrow['col7'] . ' - ' . $myrow['col8'], 0, 40); - $LeftOvers = $pdf->addTextWrap(55,$Ypos,135,$FontSize,$GroupHeadingText); + /*NOW SHOW THE LINE OF DATA */ + DB_data_seek($ColsResult,0); + while ($Cols = DB_fetch_array($ColsResult)){ + $Xpos = 160 + ($Cols['colno']*60); + $ColumnNo = 'col' . (string) (($Cols['colno']) +8); + if ($Cols['valformat']=='P'){ + $DisplayValue = number_format($myrow[$ColumnNo] *100) . '%'; + } else { + $DisplayValue = number_format($myrow[$ColumnNo]); + } + $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize,$DisplayValue, 'right'); - } - - /*NOW SHOW THE LINE OF DATA */ - DB_data_seek($ColsResult,0); - while ($Cols = DB_fetch_array($ColsResult)){ - $Xpos = 160 + ($Cols['colno']*60); - $ColumnNo = 'col' . (string) (($Cols['colno']) +8); - if ($Cols['valformat']=='P'){ - $DisplayValue = number_format($myrow[$ColumnNo] *100) . '%'; - } else { - $DisplayValue = number_format($myrow[$ColumnNo]); + $AccumLvl1[$Cols['colno']] += $myrow[$ColumnNo]; + $AccumLvl2[$Cols['colno']] += $myrow[$ColumnNo]; + $AccumLvl3[$Cols['colno']] += $myrow[$ColumnNo]; + $AccumLvl4[$Cols['colno']] += $myrow[$ColumnNo]; } - $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize,$DisplayValue, 'right'); - $AccumLvl1[$Cols['colno']] += $myrow[$ColumnNo]; - $AccumLvl2[$Cols['colno']] += $myrow[$ColumnNo]; - $AccumLvl3[$Cols['colno']] += $myrow[$ColumnNo]; - $AccumLvl4[$Cols['colno']] += $myrow[$ColumnNo]; - } + $Ypos -=$line_height; - $Ypos -=$line_height; - - if ($Ypos - (2*$line_height) < $Bottom_Margin){ - include ('includes/PDFSalesAnalPageHeader.inc'); - }//end if need a new page headed up - $GrpData1 = $myrow['col1']; - $GrpData2 = $myrow['col3']; - $GrpData3 = $myrow['col5']; - $Counter++; - $LastLine = $myrow; /*remember the last line that had some output in an array called last line*/ + if ($Ypos - (2*$line_height) < $Bottom_Margin){ + include ('includes/PDFSalesAnalPageHeader.inc'); + }//end if need a new page headed up + $GrpData1 = $myrow['col1']; + $GrpData2 = $myrow['col3']; + $GrpData3 = $myrow['col5']; + $Counter++; + $LastLine = $myrow; /*remember the last line that had some output in an array called last line*/ } /*The line has some positive amount on it */ - } /*end of the data loop to print lines */ if ($LastLine['col5']!='0' && $LastLine['col7']!='0'){ @@ -514,8 +505,6 @@ } - - if ($_GET['ProduceCVSFile']==True){ function stripcomma($str) { //because we're using comma as a delimiter This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-08 07:38:52
|
Revision: 4504 http://web-erp.svn.sourceforge.net/web-erp/?rev=4504&view=rev Author: daintree Date: 2011-03-08 07:38:45 +0000 (Tue, 08 Mar 2011) Log Message: ----------- Sales Analysis fix Modified Paths: -------------- trunk/SalesAnalysis_UserDefined.php trunk/doc/Change.log.html trunk/includes/PDFSalesAnalysis.inc Modified: trunk/SalesAnalysis_UserDefined.php =================================================================== --- trunk/SalesAnalysis_UserDefined.php 2011-03-04 19:40:47 UTC (rev 4503) +++ trunk/SalesAnalysis_UserDefined.php 2011-03-08 07:38:45 UTC (rev 4504) @@ -2,7 +2,7 @@ /* $Id$ */ -//$PageSecurity = 2; + include('includes/session.inc'); if (!in_array($PageSecurity,$_SESSION['AllowedPageSecurityTokens'])){ @@ -18,9 +18,9 @@ if ($Counter >0) { $pdf->OutputD('SalesAnalysis_' . date('Y-m-d') . '.pdf'); - $pdf-> __destruct(); + $pdf->__destruct(); } else { - $pdf-> __destruct(); + $pdf->__destruct(); $title = _('User Defined Sales Analysis Problem'); include('includes/header.inc'); echo '<p>' . _('The report did not have any none zero lines of information to show and so it has not been created'); @@ -46,5 +46,4 @@ echo '<p>' . _('You should automatically be forwarded to the CSV Sales Analysis file when it is ready') . '. ' . _('If this does not happen') . ' <a href="' . $rootpath . '/' . $_SESSION['reports_dir'] . '/SalesAnalysis.csv">' . _('click here') . '</a> ' . _('to continue') . '<br />'; include('includes/footer.inc'); } - -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-04 19:40:47 UTC (rev 4503) +++ trunk/doc/Change.log.html 2011-03-08 07:38:45 UTC (rev 4504) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>8/3/11:Phil fix SalesAnalysis reports for TCPDF as reported by Joe Zhou</p> <p>5/3/11: Kovács Attila fix to Stocks.php to use ANSI GROUP BY for aggregate functions SQL</p> <p>5/3/11: Kovács Attila fix to LanguageSetup.php to use utf-8 not ISO-8859-1. Phil hardcoded UTF- now as no dynamic changing of character set required all translations are utf-8</p> <p>3/3/11: Exson/Baran/Phil fix to customer login to ensure that other customers orders are not displayed when searching by customer ref or order no</p> Modified: trunk/includes/PDFSalesAnalysis.inc =================================================================== --- trunk/includes/PDFSalesAnalysis.inc 2011-03-04 19:40:47 UTC (rev 4503) +++ trunk/includes/PDFSalesAnalysis.inc 2011-03-08 07:38:45 UTC (rev 4504) @@ -4,23 +4,23 @@ include ('includes/class.pdf.php'); -/* A4_Landscape */ +/* A4_Landscape */ +$DocumentPaper = 'A4'; +$DocumentOrientation ='L'; $Page_Width=842; $Page_Height=595; -$Top_Margin=20; -$Bottom_Margin=20; -$Left_Margin=25; -$Right_Margin=22; +$Top_Margin=30; +$Bottom_Margin=30; +$Left_Margin=40; +$Right_Margin=30; -// Javier: now I use the native constructor -// $PageSize = array(0,0,$Page_Width,$Page_Height); +$pdf = new Cpdf($DocumentOrientation, 'pt', $DocumentPaper); +$pdf->SetAutoPageBreak(true, 0); +$pdf->SetPrintHeader(false); +$pdf->AddPage(); +$pdf->cMargin = 0; -// Javier: better to not use references -// $pdf = & new Cpdf($PageSize); - $pdf = new Cpdf('L', 'pt', 'A4'); - - /* Standard PDF file creation header stuff */ $pdf->addInfo('Author','webERP ' . $Version); @@ -41,278 +41,269 @@ /*Make an array to hold accumulators for */ $AccumLvl1 = array(); +$AccumLvl2 = array(); +$AccumLvl3 = array(); +$AccumLvl4 = array(); + for ($i=0;$i<=10;$i++){ -$AccumLvl1[$i]=0; + $AccumLvl1[$i]=0; + $AccumLvl2[$i]=0; + $AccumLvl3[$i]=0; + $AccumLvl4[$i]=0; } -$AccumLvl2= array(); -for ($i=0;$i<=10;$i++){ -$AccumLvl2[$i]=0; -} -$AccumLvl3=array(); -for ($i=0;$i<=10;$i++){ -$AccumLvl3[$i]=0; -} -$AccumLvl4=array(); -for ($i=0;$i<=10;$i++){ -$AccumLvl4[$i]=0; -} While ($myrow = DB_fetch_array($result)){ /*First off check that at least one of the columns of data has some none zero amounts */ -DB_data_seek($ColsResult,0); /*go back to the beginning */ -$ThisLineHasOutput=False; /*assume no output to start with */ -while ($Cols = DB_fetch_array($ColsResult)){ - $ColumnNo ='col' . ((int) $Cols['colno'] + 8); - if (abs($myrow[$ColumnNo])>0.5){ - $ThisLineHasOutput = True; + DB_data_seek($ColsResult,0); /*go back to the beginning */ + $ThisLineHasOutput=False; /*assume no output to start with */ + while ($Cols = DB_fetch_array($ColsResult)){ + $ColumnNo ='col' . ((int) $Cols['colno'] + 8); + if (abs($myrow[$ColumnNo])>0.5){ + $ThisLineHasOutput = True; + } } -} -if ($ThisLineHasOutput==True){ + if ($ThisLineHasOutput==True){ - if ($myrow['col5']!=$GrpData3 && $myrow['col5']!='0' && $myrow['col7']!='0'){ - /*Totals only relevant to GrpByLevel 3 if GrpByLevel 4 also used */ - if ($Counter > 0){ /*Dont want to print totals if this is the first record */ - $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col5'] . ' - ' . $LastLine['col6'],0,33); - $LeftOvers = $pdf->addTextWrap(40,$Ypos,180,$FontSize,$TotalText); + if ($myrow['col5']!=$GrpData3 && $myrow['col5']!='0' && $myrow['col7']!='0'){ + /*Totals only relevant to GrpByLevel 3 if GrpByLevel 4 also used */ + if ($Counter > 0){ /*Dont want to print totals if this is the first record */ + $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col5'] . ' - ' . $LastLine['col6'],0,33); + $LeftOvers = $pdf->addTextWrap(40,$Ypos,180,$FontSize,$TotalText); - DB_data_seek($ColsResult,0); - while ($Cols = DB_fetch_array($ColsResult)){ - $Xpos = 160 + $Cols['colno']*60; - if ($Cols['calculation']==0){ - $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, number_format($AccumLvl3[$Cols['colno']]),'right'); - } else { /* its a calculation need to re-perform on the totals*/ + DB_data_seek($ColsResult,0); + while ($Cols = DB_fetch_array($ColsResult)){ + $Xpos = 160 + $Cols['colno']*60; + if ($Cols['calculation']==0){ + $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, number_format($AccumLvl3[$Cols['colno']]),'right'); + } else { /* its a calculation need to re-perform on the totals*/ - switch ($Cols['calcoperator']) { - case '/': - if ($AccumLvl3[$Cols['coldenominator']]==0){ - $TotalCalculation = 0; + switch ($Cols['calcoperator']) { + case '/': + if ($AccumLvl3[$Cols['coldenominator']]==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] / $AccumLvl3[$Cols['coldenominator']]; + } + break; + case '+': + $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] + $AccumLvl3[$Cols['coldenominator']]; + break; + case '-': + $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] + $AccumLvl3[$Cols['coldenominator']]; + break; + case '*': + $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] * $Cols['constant']; + break; + case 'C': + if ($Cols['constant']==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] / $Cols['constant']; + } + break; + } /*end of switch stmt block*/ + if ($Cols['valformat']=='P'){ + $TotalCalculation = number_format($TotalCalculation * 100) . '%'; } else { - $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] / $AccumLvl3[$Cols['coldenominator']]; + $TotalCalculation = number_format($TotalCalculation); } - break; - case '+': - $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] + $AccumLvl3[$Cols['coldenominator']]; - break; - case '-': - $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] + $AccumLvl3[$Cols['coldenominator']]; - break; - case '*': - $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] * $Cols['constant']; - break; - case 'C': - if ($Cols['constant']==0){ - $TotalCalculation = 0; - } else { - $TotalCalculation = $AccumLvl3[$Cols['colnumerator']] / $Cols['constant']; - } - break; - } /*end of switch stmt block*/ - if ($Cols['valformat']=='P'){ - $TotalCalculation = number_format($TotalCalculation * 100) . '%'; - } else { - $TotalCalculation = number_format($TotalCalculation); + $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); } - $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); } + $Ypos -=(2*$line_height); + /*reset the accumulators to 0 */ + for ($i=0;$i<=10;$i++){ + $AccumLvl3[$i]=0; + } } - $Ypos -=(2*$line_height); - /*reset the accumulators to 0 */ - for ($i=0;$i<=10;$i++){ - $AccumLvl3[$i]=0; - } } - } - - if ($myrow['col3']!=$GrpData2 && $myrow['col3']!='0' && $myrow['col5']!='0'){ + if ($myrow['col3']!=$GrpData2 && $myrow['col3']!='0' && $myrow['col5']!='0'){ /*Totals only relevant to GrpByLevel 2 if GrpByLevel 3 also used */ - if ($Counter > 0){ /*Dont want to print totals if this is the first record */ - $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col3'] . ' - ' . $LastLine['col4'],0,43); - $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$TotalText); - DB_data_seek($ColsResult,0); - while ($Cols = DB_fetch_array($ColsResult)){ - $Xpos = 160 + $Cols['colno']*60; - if ($Cols['calculation']==0){ - $LeftOvers = $pdf->addTextWrap($Xpos, $Ypos,60,$FontSize, number_format($AccumLvl2[$Cols['colno']]),'right'); - } else { /* its a calculation need to re-perform on the totals*/ + if ($Counter > 0){ /*Dont want to print totals if this is the first record */ + $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col3'] . ' - ' . $LastLine['col4'],0,43); + $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$TotalText); + DB_data_seek($ColsResult,0); + while ($Cols = DB_fetch_array($ColsResult)){ + $Xpos = 160 + $Cols['colno']*60; + if ($Cols['calculation']==0){ + $LeftOvers = $pdf->addTextWrap($Xpos, $Ypos,60,$FontSize, number_format($AccumLvl2[$Cols['colno']]),'right'); + } else { /* its a calculation need to re-perform on the totals*/ - switch ($Cols['calcoperator']) { - case '/': - if ($AccumLvl2[$Cols['coldenominator']]==0){ - $TotalCalculation = 0; + switch ($Cols['calcoperator']) { + case '/': + if ($AccumLvl2[$Cols['coldenominator']]==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] / $AccumLvl2[$Cols['coldenominator']]; + } + break; + case '+': + $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] + $AccumLvl2[$Cols['coldenominator']]; + break; + case '-': + $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] + $AccumLvl2[$Cols['coldenominator']]; + break; + case '*': + $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] * $Cols['constant']; + break; + case 'C': + if ($Cols['constant']==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] / $Cols['constant']; + } + break; + } /*end of switch stmt block*/ + if ($Cols['valformat']=='P'){ + $TotalCalculation = number_format($TotalCalculation * 100) . '%'; } else { - $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] / $AccumLvl2[$Cols['coldenominator']]; + $TotalCalculation = number_format($TotalCalculation); } - break; - case '+': - $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] + $AccumLvl2[$Cols['coldenominator']]; - break; - case '-': - $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] + $AccumLvl2[$Cols['coldenominator']]; - break; - case '*': - $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] * $Cols['constant']; - break; - case 'C': - if ($Cols['constant']==0){ - $TotalCalculation = 0; - } else { - $TotalCalculation = $AccumLvl2[$Cols['colnumerator']] / $Cols['constant']; - } - break; - } /*end of switch stmt block*/ - if ($Cols['valformat']=='P'){ - $TotalCalculation = number_format($TotalCalculation * 100) . '%'; - } else { - $TotalCalculation = number_format($TotalCalculation); - } - $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); + $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); + }/*end if not a calculation column*/ + }/*end while loop through column definitions */ + $Ypos -=(2*$line_height); + /*reset the accumulators to 0 */ + for ($i=0;$i<=10;$i++){ + $AccumLvl2[$i]=0; } - - } - $Ypos -=(2*$line_height); - /*reset the accumulators to 0 */ - for ($i=0;$i<=10;$i++){ - $AccumLvl2[$i]=0; - } + }/*end if Counter > 0 */ } - } - if ($myrow['col1']!=$GrpData1 && $myrow['col3']!='0'){ - /*Totals only relevant to GrpByLevel 1 if GrpByLevel 2 also used */ - if ($Counter > 0){ /*Dont want to print totals if this is the first record */ - $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col1'] . ' - ' . $LastLine['col2'],0,46); - $LeftOvers = $pdf->addTextWrap(15,$Ypos,205,$FontSize,$TotalText); - DB_data_seek($ColsResult,0); - while ($Cols = DB_fetch_array($ColsResult)){ - $Xpos = 160 + $Cols['colno']*60; - if ($Cols['calculation']==0){ - $LeftOvers = $pdf->addTextWrap($Xpos, $Ypos,60,$FontSize, number_format($AccumLvl1[$Cols['colno']]),'right'); - } else { /* its a calculation need to re-perform on the totals*/ - - switch ($Cols['calcoperator']) { - Case '/': - if ($AccumLvl1[$Cols['coldenominator']]==0){ - $TotalCalculation = 0; + if ($myrow['col1']!=$GrpData1 && $myrow['col3']!='0'){ + /*Totals only relevant to GrpByLevel 1 if GrpByLevel 2 also used */ + if ($Counter > 0){ /*Dont want to print totals if this is the first record */ + $TotalText = substr(_('TOTAL') . ' ' . $LastLine['col1'] . ' - ' . $LastLine['col2'],0,46); + $LeftOvers = $pdf->addTextWrap(15,$Ypos,205,$FontSize,$TotalText); + DB_data_seek($ColsResult,0); + while ($Cols = DB_fetch_array($ColsResult)){ + $Xpos = 160 + $Cols['colno']*60; + if ($Cols['calculation']==0){ + $LeftOvers = $pdf->addTextWrap($Xpos, $Ypos,60,$FontSize, number_format($AccumLvl1[$Cols['colno']]),'right'); + } else { /* its a calculation need to re-perform on the totals*/ + + switch ($Cols['calcoperator']) { + Case '/': + if ($AccumLvl1[$Cols['coldenominator']]==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] / $AccumLvl1[$Cols['coldenominator']]; + } + break; + Case '+': + $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] + $AccumLvl1[$Cols['coldenominator']]; + break; + Case '-': + $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] + $AccumLvl1[$Cols['coldenominator']]; + break; + Case '*': + $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] * $Cols['constant']; + break; + Case 'C': + if ($Cols['constant']==0){ + $TotalCalculation = 0; + } else { + $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] / $Cols['constant']; + } + break; + } /*end of switch stmt block*/ + if ($Cols['valformat']=='P'){ + $TotalCalculation = number_format($TotalCalculation * 100) . '%'; } else { - $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] / $AccumLvl1[$Cols['coldenominator']]; + $TotalCalculation = number_format($TotalCalculation); } - break; - Case '+': - $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] + $AccumLvl1[$Cols['coldenominator']]; - break; - Case '-': - $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] + $AccumLvl1[$Cols['coldenominator']]; - break; - Case '*': - $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] * $Cols['constant']; - break; - Case 'C': - if ($Cols['constant']==0){ - $TotalCalculation = 0; - } else { - $TotalCalculation = $AccumLvl1[$Cols['colnumerator']] / $Cols['constant']; - } - break; - } /*end of switch stmt block*/ - if ($Cols['valformat']=='P'){ - $TotalCalculation = number_format($TotalCalculation * 100) . '%'; - } else { - $TotalCalculation = number_format($TotalCalculation); - } - $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); + $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize, $TotalCalculation,'right'); + }/*end if its not a calculation */ + } /* end loop around column defintions */ + $Ypos -=(2*$line_height); + + /*reset the accumulators to 0 */ + for ($i=0;$i<=10;$i++){ + $AccumLvl1[$i]=0; } + }/* end if counter>0 */ + } + + $NewHeading =0; + if ($myrow['col1']!=$GrpData1){ /*Need a new heading for Level 1 */ + $NewHeading = 1; + if ($ReportSpec['newpageafter1']==1){ + include ('includes/PDFSalesAnalPageHeader.inc'); } - $Ypos -=(2*$line_height); + $GroupHeadingText = substr($myrow['col1'] . ' - ' . $myrow['col2'],0,50); + $LeftOvers = $pdf->addTextWrap(15,$Ypos,205,$FontSize,$GroupHeadingText); - /*reset the accumulators to 0 */ - for ($i=0;$i<=10;$i++){ - $AccumLvl1[$i]=0; + if ($myrow['col3']!='0'){ + $Ypos-=$line_height; } } - } - $NewHeading =0; + if (($myrow['col3']!=$GrpData2 OR $NewHeading ==1) AND $myrow['col3']!='0'){ + /*Need a new heading for Level 2 */ + $NewHeading = 1; + if ($ReportSpec['newpageafter2']==1){ + include ('includes/PDFSalesAnalPageHeader.inc'); + } + $GroupHeadingText = substr($myrow['col3'] . ' - ' . $myrow['col4'],0,46); + $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$GroupHeadingText); - if ($myrow['col1']!=$GrpData1){ /*Need a new heading for Level 1 */ - $NewHeading = 1; - if ($ReportSpec['newpageafter1']==1){ - include ('includes/PDFSalesAnalPageHeader.inc'); - } - $GroupHeadingText = substr($myrow['col1'] . ' - ' . $myrow['col2'],0,50); - $LeftOvers = $pdf->addTextWrap(15,$Ypos,205,$FontSize,$GroupHeadingText); - - if ($myrow['col3']!='0'){ + if ($myrow['col5']!='0'){ $Ypos-=$line_height; + } } - } + if (($myrow['col5']!=$GrpData3 OR $NewHeading ==1) AND $myrow['col5']!='0'){ + /*Need a new heading for Level 3 */ - if (($myrow['col3']!=$GrpData2 OR $NewHeading ==1) AND $myrow['col3']!='0'){ - /*Need a new heading for Level 2 */ - $NewHeading = 1; - if ($ReportSpec['newpageafter2']==1){ - include ('includes/PDFSalesAnalPageHeader.inc'); - } - $GroupHeadingText = substr($myrow['col3'] . ' - ' . $myrow['col4'],0,46); - $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$GroupHeadingText); + if ($ReportSpec['newpageafter3']==1){ + include ('includes/PDFSalesAnalPageHeader.inc'); + } + $GroupHeadingText = substr($myrow['col5'] . ' - ' . $myrow['col6'],0,46); + $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$GroupHeadingText); - if ($myrow['col5']!='0'){ - $Ypos-=$line_height; + if ($myrow['col7']!='0'){ + $Ypos-=$line_height; + } } - } - if (($myrow['col5']!=$GrpData3 OR $NewHeading ==1) AND $myrow['col5']!='0'){ - /*Need a new heading for Level 3 */ - if ($ReportSpec['newpageafter3']==1){ - include ('includes/PDFSalesAnalPageHeader.inc'); - } - $GroupHeadingText = substr($myrow['col5'] . ' - ' . $myrow['col6'],0,46); - $LeftOvers = $pdf->addTextWrap(30,$Ypos,190,$FontSize,$GroupHeadingText); - if ($myrow['col7']!='0'){ - $Ypos-=$line_height; + /*show titles */ + $GroupHeadingText = substr($myrow['col7'] . ' - ' . $myrow['col8'], 0, 40); + $LeftOvers = $pdf->addTextWrap(55,$Ypos,135,$FontSize,$GroupHeadingText); + } - } - if ($myrow['col7']!='0'){ - /*show titles */ - $GroupHeadingText = substr($myrow['col7'] . ' - ' . $myrow['col8'], 0, 40); - $LeftOvers = $pdf->addTextWrap(55,$Ypos,135,$FontSize,$GroupHeadingText); + /*NOW SHOW THE LINE OF DATA */ + DB_data_seek($ColsResult,0); + while ($Cols = DB_fetch_array($ColsResult)){ + $Xpos = 160 + ($Cols['colno']*60); + $ColumnNo = 'col' . (string) (($Cols['colno']) +8); + if ($Cols['valformat']=='P'){ + $DisplayValue = number_format($myrow[$ColumnNo] *100) . '%'; + } else { + $DisplayValue = number_format($myrow[$ColumnNo]); + } + $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize,$DisplayValue, 'right'); - } - - /*NOW SHOW THE LINE OF DATA */ - DB_data_seek($ColsResult,0); - while ($Cols = DB_fetch_array($ColsResult)){ - $Xpos = 160 + ($Cols['colno']*60); - $ColumnNo = 'col' . (string) (($Cols['colno']) +8); - if ($Cols['valformat']=='P'){ - $DisplayValue = number_format($myrow[$ColumnNo] *100) . '%'; - } else { - $DisplayValue = number_format($myrow[$ColumnNo]); + $AccumLvl1[$Cols['colno']] += $myrow[$ColumnNo]; + $AccumLvl2[$Cols['colno']] += $myrow[$ColumnNo]; + $AccumLvl3[$Cols['colno']] += $myrow[$ColumnNo]; + $AccumLvl4[$Cols['colno']] += $myrow[$ColumnNo]; } - $LeftOvers = $pdf->addTextWrap($Xpos,$Ypos,60,$FontSize,$DisplayValue, 'right'); - $AccumLvl1[$Cols['colno']] += $myrow[$ColumnNo]; - $AccumLvl2[$Cols['colno']] += $myrow[$ColumnNo]; - $AccumLvl3[$Cols['colno']] += $myrow[$ColumnNo]; - $AccumLvl4[$Cols['colno']] += $myrow[$ColumnNo]; - } + $Ypos -=$line_height; - $Ypos -=$line_height; - - if ($Ypos - (2*$line_height) < $Bottom_Margin){ - include ('includes/PDFSalesAnalPageHeader.inc'); - }//end if need a new page headed up - $GrpData1 = $myrow['col1']; - $GrpData2 = $myrow['col3']; - $GrpData3 = $myrow['col5']; - $Counter++; - $LastLine = $myrow; /*remember the last line that had some output in an array called last line*/ + if ($Ypos - (2*$line_height) < $Bottom_Margin){ + include ('includes/PDFSalesAnalPageHeader.inc'); + }//end if need a new page headed up + $GrpData1 = $myrow['col1']; + $GrpData2 = $myrow['col3']; + $GrpData3 = $myrow['col5']; + $Counter++; + $LastLine = $myrow; /*remember the last line that had some output in an array called last line*/ } /*The line has some positive amount on it */ - } /*end of the data loop to print lines */ if ($LastLine['col5']!='0' && $LastLine['col7']!='0'){ @@ -514,8 +505,6 @@ } - - if ($_GET['ProduceCVSFile']==True){ function stripcomma($str) { //because we're using comma as a delimiter This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-04 19:40:54
|
Revision: 4503 http://web-erp.svn.sourceforge.net/web-erp/?rev=4503&view=rev Author: daintree Date: 2011-03-04 19:40:47 +0000 (Fri, 04 Mar 2011) Log Message: ----------- Kovacs Attila fixes GROUP BY clauses in SQL and laguage binding always UTF-8 Modified Paths: -------------- trunk/Stocks.php trunk/doc/Change.log.html trunk/includes/LanguageSetup.php Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2011-03-03 09:14:45 UTC (rev 4502) +++ trunk/Stocks.php 2011-03-04 19:40:47 UTC (rev 4503) @@ -2,8 +2,6 @@ /* $Id$ */ -//$PageSecurity = 11; - include('includes/session.inc'); $title = _('Item Maintenance'); include('includes/header.inc'); @@ -19,7 +17,7 @@ } if (isset($StockID) and !isset($_POST['UpdateCategories'])) { - $sql = "SELECT COUNT(stockid) FROM stockmaster WHERE stockid='".$StockID."'"; + $sql = "SELECT COUNT(stockid) FROM stockmaster WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]==0) { @@ -48,7 +46,7 @@ } elseif ( $_FILES['ItemPicture']['size'] > ($_SESSION['MaxImageSize']*1024)) { //File Size Check prnMsg(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $_SESSION['MaxImageSize'],'warn'); $UploadTheFile ='No'; - } elseif ( $_FILES['ItemPicture']['type'] == "text/plain" ) { //File Type Check + } elseif ( $_FILES['ItemPicture']['type'] == 'text/plain' ) { //File Type Check prnMsg( _('Only graphics files can be uploaded'),'warn'); $UploadTheFile ='No'; } elseif (file_exists($filename)){ @@ -219,7 +217,7 @@ $OldControlled = $myrow[1]; $OldSerialised = $myrow[2]; - $sql = "SELECT SUM(locstock.quantity) FROM locstock WHERE stockid='".$StockID."'"; + $sql = "SELECT SUM(locstock.quantity) FROM locstock WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $stkqtychk = DB_fetch_row($result); @@ -268,7 +266,7 @@ /*now check that if it was a Manufactured, Kitset, Phantom or Assembly and is being changed to a purchased or dummy - that no BOM exists */ if (($OldMBFlag=='M' OR $OldMBFlag =='K' OR $OldMBFlag=='A' OR $OldMBFlag=='G') AND ($_POST['MBFlag']=='B' OR $_POST['MBFlag']=='D')) { - $sql = "SELECT COUNT(*) FROM bom WHERE parent = '".$StockID."'"; + $sql = "SELECT COUNT(*) FROM bom WHERE parent = '".$StockID."' GROUP BY parent"; $result = DB_query($sql,$db); $ChkBOM = DB_fetch_row($result); if ($ChkBOM[0]!=0){ @@ -279,7 +277,7 @@ /*now check that if it was Manufac, Phantom or Purchased and is being changed to assembly or kitset, it is not a component on an existing BOM */ if (($OldMBFlag=='M' OR $OldMBFlag =='B' OR $OldMBFlag=='D' OR $OldMBFlag=='G') AND ($_POST['MBFlag']=='A' OR $_POST['MBFlag']=='K')) { - $sql = "SELECT COUNT(*) FROM bom WHERE component = '".$StockID."'"; + $sql = "SELECT COUNT(*) FROM bom WHERE component = '".$StockID."' GROUP BY component"; $result = DB_query($sql,$db); $ChkBOM = DB_fetch_row($result); if ($ChkBOM[0]!=0){ @@ -462,7 +460,7 @@ // PREVENT DELETES IF DEPENDENT RECORDS IN 'StockMoves' - $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockid='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -471,7 +469,7 @@ echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('stock movements that refer to this item'); } else { - $sql= "SELECT COUNT(*) FROM bom WHERE component='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM bom WHERE component='".$StockID."' GROUP BY component"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -479,7 +477,7 @@ prnMsg( _('Cannot delete this item record because there are bills of material that require this part as a component'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('bills of material that require this part as a component'); } else { - $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -487,7 +485,7 @@ prnMsg( _('Cannot delete this item record because there are existing sales orders for this part'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales order items against this part'); } else { - $sql= "SELECT COUNT(*) FROM salesanalysis WHERE stockid='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM salesanalysis WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -495,7 +493,7 @@ prnMsg(_('Cannot delete this item because sales analysis records exist for it'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales analysis records against this part'); } else { - $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -503,7 +501,7 @@ prnMsg(_('Cannot delete this item because there are existing purchase order items for it'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('purchase order item record relating to this part'); } else { - $sql = "SELECT SUM(quantity) AS qoh FROM locstock WHERE stockid='".$StockID."'"; + $sql = "SELECT SUM(quantity) AS qoh FROM locstock WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]!=0) { Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-03 09:14:45 UTC (rev 4502) +++ trunk/doc/Change.log.html 2011-03-04 19:40:47 UTC (rev 4503) @@ -1,5 +1,7 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>5/3/11: Kovács Attila fix to Stocks.php to use ANSI GROUP BY for aggregate functions SQL</p> +<p>5/3/11: Kovács Attila fix to LanguageSetup.php to use utf-8 not ISO-8859-1. Phil hardcoded UTF- now as no dynamic changing of character set required all translations are utf-8</p> <p>3/3/11: Exson/Baran/Phil fix to customer login to ensure that other customers orders are not displayed when searching by customer ref or order no</p> <p>3/3/11: Tim launchpad mods to revision 4441 including change to allow supplier currency to be changed if there are no transactions already against the supplier. Ensure credit note session variable is unset before attempting to create a new credit note from the supplier form. Tim's work to add perisable expiry dates to the serial items logic - affects quite a few scripts. Headings to stock check script even if no quantity is shown. Portrait quotations. Not included change to default delivery date to the date the customer requested - left to be the current day's date. Not included Tim's unit pricing work .. yet launchpad revisions 4442-4447 inclusive</p> <p>27/2/11: Phil/Tim/Peter launchpad added category option for MRPShortages.php links with matching quotes in WorkOrderEntry</p> Modified: trunk/includes/LanguageSetup.php =================================================================== --- trunk/includes/LanguageSetup.php 2011-03-03 09:14:45 UTC (rev 4502) +++ trunk/includes/LanguageSetup.php 2011-03-04 19:40:47 UTC (rev 4503) @@ -37,7 +37,7 @@ //putenv('LANG=$Language_Country'); bindtextdomain ('messages', $PathPrefix . 'locale'); textdomain ('messages'); - bind_textdomain_codeset('messages', _('ISO-8859-1')); + bind_textdomain_codeset('messages', 'UTF-8'); $locale_info = localeconv(); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-04 19:40:53
|
Revision: 4503 http://web-erp.svn.sourceforge.net/web-erp/?rev=4503&view=rev Author: daintree Date: 2011-03-04 19:40:47 +0000 (Fri, 04 Mar 2011) Log Message: ----------- Kovacs Attila fixes GROUP BY clauses in SQL and laguage binding always UTF-8 Modified Paths: -------------- trunk/Stocks.php trunk/doc/Change.log.html trunk/includes/LanguageSetup.php Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2011-03-03 09:14:45 UTC (rev 4502) +++ trunk/Stocks.php 2011-03-04 19:40:47 UTC (rev 4503) @@ -2,8 +2,6 @@ /* $Id$ */ -//$PageSecurity = 11; - include('includes/session.inc'); $title = _('Item Maintenance'); include('includes/header.inc'); @@ -19,7 +17,7 @@ } if (isset($StockID) and !isset($_POST['UpdateCategories'])) { - $sql = "SELECT COUNT(stockid) FROM stockmaster WHERE stockid='".$StockID."'"; + $sql = "SELECT COUNT(stockid) FROM stockmaster WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]==0) { @@ -48,7 +46,7 @@ } elseif ( $_FILES['ItemPicture']['size'] > ($_SESSION['MaxImageSize']*1024)) { //File Size Check prnMsg(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $_SESSION['MaxImageSize'],'warn'); $UploadTheFile ='No'; - } elseif ( $_FILES['ItemPicture']['type'] == "text/plain" ) { //File Type Check + } elseif ( $_FILES['ItemPicture']['type'] == 'text/plain' ) { //File Type Check prnMsg( _('Only graphics files can be uploaded'),'warn'); $UploadTheFile ='No'; } elseif (file_exists($filename)){ @@ -219,7 +217,7 @@ $OldControlled = $myrow[1]; $OldSerialised = $myrow[2]; - $sql = "SELECT SUM(locstock.quantity) FROM locstock WHERE stockid='".$StockID."'"; + $sql = "SELECT SUM(locstock.quantity) FROM locstock WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $stkqtychk = DB_fetch_row($result); @@ -268,7 +266,7 @@ /*now check that if it was a Manufactured, Kitset, Phantom or Assembly and is being changed to a purchased or dummy - that no BOM exists */ if (($OldMBFlag=='M' OR $OldMBFlag =='K' OR $OldMBFlag=='A' OR $OldMBFlag=='G') AND ($_POST['MBFlag']=='B' OR $_POST['MBFlag']=='D')) { - $sql = "SELECT COUNT(*) FROM bom WHERE parent = '".$StockID."'"; + $sql = "SELECT COUNT(*) FROM bom WHERE parent = '".$StockID."' GROUP BY parent"; $result = DB_query($sql,$db); $ChkBOM = DB_fetch_row($result); if ($ChkBOM[0]!=0){ @@ -279,7 +277,7 @@ /*now check that if it was Manufac, Phantom or Purchased and is being changed to assembly or kitset, it is not a component on an existing BOM */ if (($OldMBFlag=='M' OR $OldMBFlag =='B' OR $OldMBFlag=='D' OR $OldMBFlag=='G') AND ($_POST['MBFlag']=='A' OR $_POST['MBFlag']=='K')) { - $sql = "SELECT COUNT(*) FROM bom WHERE component = '".$StockID."'"; + $sql = "SELECT COUNT(*) FROM bom WHERE component = '".$StockID."' GROUP BY component"; $result = DB_query($sql,$db); $ChkBOM = DB_fetch_row($result); if ($ChkBOM[0]!=0){ @@ -462,7 +460,7 @@ // PREVENT DELETES IF DEPENDENT RECORDS IN 'StockMoves' - $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockid='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -471,7 +469,7 @@ echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('stock movements that refer to this item'); } else { - $sql= "SELECT COUNT(*) FROM bom WHERE component='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM bom WHERE component='".$StockID."' GROUP BY component"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -479,7 +477,7 @@ prnMsg( _('Cannot delete this item record because there are bills of material that require this part as a component'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('bills of material that require this part as a component'); } else { - $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -487,7 +485,7 @@ prnMsg( _('Cannot delete this item record because there are existing sales orders for this part'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales order items against this part'); } else { - $sql= "SELECT COUNT(*) FROM salesanalysis WHERE stockid='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM salesanalysis WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -495,7 +493,7 @@ prnMsg(_('Cannot delete this item because sales analysis records exist for it'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales analysis records against this part'); } else { - $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -503,7 +501,7 @@ prnMsg(_('Cannot delete this item because there are existing purchase order items for it'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('purchase order item record relating to this part'); } else { - $sql = "SELECT SUM(quantity) AS qoh FROM locstock WHERE stockid='".$StockID."'"; + $sql = "SELECT SUM(quantity) AS qoh FROM locstock WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]!=0) { Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-03 09:14:45 UTC (rev 4502) +++ trunk/doc/Change.log.html 2011-03-04 19:40:47 UTC (rev 4503) @@ -1,5 +1,7 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>5/3/11: Kovács Attila fix to Stocks.php to use ANSI GROUP BY for aggregate functions SQL</p> +<p>5/3/11: Kovács Attila fix to LanguageSetup.php to use utf-8 not ISO-8859-1. Phil hardcoded UTF- now as no dynamic changing of character set required all translations are utf-8</p> <p>3/3/11: Exson/Baran/Phil fix to customer login to ensure that other customers orders are not displayed when searching by customer ref or order no</p> <p>3/3/11: Tim launchpad mods to revision 4441 including change to allow supplier currency to be changed if there are no transactions already against the supplier. Ensure credit note session variable is unset before attempting to create a new credit note from the supplier form. Tim's work to add perisable expiry dates to the serial items logic - affects quite a few scripts. Headings to stock check script even if no quantity is shown. Portrait quotations. Not included change to default delivery date to the date the customer requested - left to be the current day's date. Not included Tim's unit pricing work .. yet launchpad revisions 4442-4447 inclusive</p> <p>27/2/11: Phil/Tim/Peter launchpad added category option for MRPShortages.php links with matching quotes in WorkOrderEntry</p> Modified: trunk/includes/LanguageSetup.php =================================================================== --- trunk/includes/LanguageSetup.php 2011-03-03 09:14:45 UTC (rev 4502) +++ trunk/includes/LanguageSetup.php 2011-03-04 19:40:47 UTC (rev 4503) @@ -37,7 +37,7 @@ //putenv('LANG=$Language_Country'); bindtextdomain ('messages', $PathPrefix . 'locale'); textdomain ('messages'); - bind_textdomain_codeset('messages', _('ISO-8859-1')); + bind_textdomain_codeset('messages', 'UTF-8'); $locale_info = localeconv(); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-03 09:14:52
|
Revision: 4502 http://web-erp.svn.sourceforge.net/web-erp/?rev=4502&view=rev Author: daintree Date: 2011-03-03 09:14:45 +0000 (Thu, 03 Mar 2011) Log Message: ----------- New Portrait quotation OutputSerialItems Added Paths: ----------- trunk/PDFQuotationPortrait.php trunk/includes/OutputSerialItems.php trunk/includes/PDFQuotationPortraitPageHeader.inc Added: trunk/PDFQuotationPortrait.php =================================================================== --- trunk/PDFQuotationPortrait.php (rev 0) +++ trunk/PDFQuotationPortrait.php 2011-03-03 09:14:45 UTC (rev 4502) @@ -0,0 +1,252 @@ +<?php + +/* $Id: PDFQuotationPortrait.php 4491 2011-02-15 06:31:08Z daintree $ */ + + +include('includes/session.inc'); +include('includes/SQL_CommonFunctions.inc'); + +//Get Out if we have no order number to work with +If (!isset($_GET['QuotationNo']) || $_GET['QuotationNo']==""){ + $title = _('Select Quotation To Print'); + include('includes/header.inc'); + echo '<div class="centre"><br><br><br>'; + prnMsg( _('Select a Quotation 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 .'&Quotations=Quotes_Only">' . _('Quotations') . '</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 quotation header details for Order Number') . ' ' . $_GET['QuotationNo'] . ' ' . _('from the database'); + +$sql = "SELECT salesorders.customerref, + salesorders.comments, + salesorders.orddate, + salesorders.deliverto, + salesorders.deladd1, + salesorders.deladd2, + salesorders.deladd3, + salesorders.deladd4, + salesorders.deladd5, + salesorders.deladd6, + debtorsmaster.name, + debtorsmaster.address1, + debtorsmaster.address2, + debtorsmaster.address3, + debtorsmaster.address4, + debtorsmaster.address5, + debtorsmaster.address6, + shippers.shippername, + salesorders.printedpackingslip, + salesorders.datepackingslipprinted, + salesorders.branchcode, + locations.taxprovinceid, + 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.quotation=1 + AND salesorders.orderno='" . $_GET['QuotationNo'] ."'"; + +$result=DB_query($sql,$db, $ErrMsg); + +//If there are no rows, there's a problem. +if (DB_num_rows($result)==0){ + $title = _('Print Quotation Error'); + include('includes/header.inc'); + echo '<div class="centre"><br><br><br>'; + prnMsg( _('Unable to Locate Quotation Number') . ' : ' . $_GET['QuotationNo'] . ' ', 'error'); + echo '<br><br><br><table class="table_index"><tr><td class="menu_group_item"> + <li><a href="'. $rootpath . '/SelectSalesOrder.php?'. SID .'&Quotations=Quotes_Only">' . _('Outstanding Quotations') . '</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); +} + +/*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'; +include('includes/PDFStarter.php'); +$pdf->addInfo('Title', _('Customer Quotation') ); +$pdf->addInfo('Subject', _('Quotation') . ' ' . $_GET['QuotationNo']); +$FontSize=12; +$PageNumber = 1; +$line_height=24; +// $pdf->selectFont('./fonts/Helvetica.afm'); + +/* Now ... Has the order got any line items still outstanding to be invoiced */ + +$ErrMsg = _('There was a problem retrieving the quotation line details for quotation Number') . ' ' . + $_GET['QuotationNo'] . ' ' . _('from the database'); + +$sql = "SELECT salesorderdetails.stkcode, + stockmaster.description, + salesorderdetails.quantity, + salesorderdetails.qtyinvoiced, + salesorderdetails.unitprice, + salesorderdetails.discountpercent, + stockmaster.taxcatid, + salesorderdetails.narrative + FROM salesorderdetails INNER JOIN stockmaster + ON salesorderdetails.stkcode=stockmaster.stockid + WHERE salesorderdetails.orderno='" . $_GET['QuotationNo'] . "'"; + +$result=DB_query($sql,$db, $ErrMsg); + +$ListCount = 0; // UldisN + +if (DB_num_rows($result)>0){ + /*Yes there are line items to start the ball rolling with a page header */ + include('includes/PDFQuotationPortraitPageHeader.inc'); + + $QuotationTotal =0; + $QuotationTotalEx=0; + $TaxTotal=0; + + while ($myrow2=DB_fetch_array($result)){ + + $ListCount ++; + + if ((strlen($myrow2['narrative']) >200 AND $YPos-$line_height <= 75) + OR (strlen($myrow2['narrative']) >1 AND $YPos-$line_height <= 62) + OR $YPos-$line_height <= 50){ + /* We reached the end of the page so finsih off the page and start a newy */ + $PageNumber++; + include ('includes/PDFQuotationPageHeader.inc'); + + } //end if need a new page headed up + + $DisplayQty = number_format($myrow2['quantity'],2); + $DisplayPrevDel = number_format($myrow2['qtyinvoiced'],2); + $DisplayPrice = number_format($myrow2['unitprice'],2); + $DisplayDiscount = number_format($myrow2['discountpercent']*100,2) . '%'; + $SubTot = $myrow2['unitprice']*$myrow2['quantity']*(1-$myrow2['discountpercent']); + $TaxProv = $myrow['taxprovinceid']; + $TaxCat = $myrow2['taxcatid']; + $Branch = $myrow['branchcode']; + $sql3 = " select taxgrouptaxes.taxauthid from taxgrouptaxes INNER JOIN custbranch ON taxgrouptaxes.taxgroupid=custbranch.taxgroupid WHERE custbranch.branchcode='" .$Branch ."'"; + $result3=DB_query($sql3,$db, $ErrMsg); + while ($myrow3=DB_fetch_array($result3)){ + $TaxAuth = $myrow3['taxauthid']; + } + + $sql4 = "SELECT * FROM taxauthrates WHERE dispatchtaxprovince='" .$TaxProv ."' AND taxcatid='" .$TaxCat ."' AND taxauthority='" .$TaxAuth ."'"; + $result4=DB_query($sql4,$db, $ErrMsg); + while ($myrow4=DB_fetch_array($result4)){ + $TaxClass = 100 * $myrow4['taxrate']; + } + + $DisplayTaxClass = $TaxClass . "%"; + $TaxAmount = (($SubTot/100)*(100+$TaxClass))-$SubTot; + $DisplayTaxAmount = number_format($TaxAmount,2); + + $LineTotal = $SubTot + $TaxAmount; + $DisplayTotal = number_format($LineTotal,2); + + $FontSize=10; + + $LeftOvers = $pdf->addTextWrap($XPos+1,$YPos,100,$FontSize,$myrow2['stkcode']); + $LeftOvers = $pdf->addTextWrap(120,$YPos,295,$FontSize,$myrow2['description']); + $LeftOvers = $pdf->addTextWrap(180,$YPos,85,$FontSize,$DisplayQty,'right'); + $LeftOvers = $pdf->addTextWrap(230,$YPos,85,$FontSize,$DisplayPrice,'right'); + if ($DisplayDiscount > 0){ + $LeftOvers = $pdf->addTextWrap(280,$YPos,85,$FontSize,$DisplayDiscount,'right'); + } + $LeftOvers = $pdf->addTextWrap(330,$YPos,85,$FontSize,$DisplayTaxClass,'right'); + $LeftOvers = $pdf->addTextWrap(410,$YPos,85,$FontSize,$DisplayTaxAmount,'center'); + $LeftOvers = $pdf->addTextWrap(460,$YPos,90,$FontSize,$DisplayTotal,'right'); + if (strlen($myrow2['narrative'])>1){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos+1,$YPos,750,10,$myrow2['narrative']); + if (strlen($LeftOvers>1)){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos+1,$YPos,750,10,$LeftOvers); + } + } + $QuotationTotal +=$LineTotal; + $QuotationTotalEx +=$SubTot; + $TaxTotal +=$TaxAmount; + + /*increment a line down for the next line item */ + $YPos -= ($line_height); + + } //end while there are line items to print out + if ((strlen($myrow['comments']) >200 AND $YPos-$line_height <= 75) + OR (strlen($myrow['comments']) >1 AND $YPos-$line_height <= 62) + OR $YPos-$line_height <= 50){ + /* We reached the end of the page so finsih off the page and start a newy */ + $PageNumber++; + include ('includes/PDFQuotationPageHeader.inc'); + + } //end if need a new page headed up + + $LeftOvers = $pdf->addTextWrap($XPos,$YPos-80,200,10,_('Notes:')); + $LeftOvers = $pdf->addText($XPos,$YPos-95,10,$myrow['comments']); + + if (strlen($LeftOvers)>1){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos,$YPos,700,10,$LeftOvers); + if (strlen($LeftOvers)>1){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos,$YPos,700,10,$LeftOvers); + if (strlen($LeftOvers)>1){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos,$YPos,700,10,$LeftOvers); + if (strlen($LeftOvers)>1){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos,$YPos,10,$FontSize,$LeftOvers); + } + } + } + } + $YPos -= ($line_height); + $LeftOvers = $pdf->addTextWrap(40,$YPos,655,$FontSize,_('Total Tax'),'right'); + $LeftOvers = $pdf->addTextWrap(700,$YPos,90,$FontSize,number_format($TaxTotal,2),'right'); + $YPos -= 12; + $LeftOvers = $pdf->addTextWrap(40,$YPos,655,$FontSize,_('Quotation Excluding Tax'),'right'); + $LeftOvers = $pdf->addTextWrap(700,$YPos,90,$FontSize,number_format($QuotationTotalEx,2),'right'); + $YPos -= 12; + $LeftOvers = $pdf->addTextWrap(40,$YPos,655,$FontSize,_('Quotation Including Tax'),'right'); + $LeftOvers = $pdf->addTextWrap(700,$YPos,90,$FontSize,number_format($QuotationTotal,2),'right'); + +} /*end if there are line details to show on the quotation*/ + + +//$pdfcode = $pdf->output('PDFQuotation.pdf', 'I'); +//$len = strlen($pdfcode); +if ($ListCount == 0){ + $title = _('Print Quotation Error'); + include('includes/header.inc'); + echo '<p>'. _('There were no items on the quotation') . '. ' . _('The quotation cannot be printed'). + '<br><a href="' . $rootpath . '/SelectSalesOrder.php?' . SID . '&Quotation=Quotes_only">'. _('Print Another Quotation'). + '</a>' . '<br>'. '<a href="' . $rootpath . '/index.php?' . SID . '">' . _('Back to the menu') . '</a>'; + include('includes/footer.inc'); + exit; +} else { +/* + header('Content-type: application/pdf'); + header('Content-Length: ' . $len); + header('Content-Disposition: inline; filename=Quotation.pdf'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); +//echo 'here'; + $pdf->Output('PDFQuotation.pdf', 'I'); +*/ + $pdf->OutputI($_SESSION['DatabaseName'] . '_Quotation_' . date('Y-m-d') . '.pdf');//UldisN + $pdf->__destruct(); //UldisN +} +?> Added: trunk/includes/OutputSerialItems.php =================================================================== --- trunk/includes/OutputSerialItems.php (rev 0) +++ trunk/includes/OutputSerialItems.php 2011-03-03 09:14:45 UTC (rev 4502) @@ -0,0 +1,210 @@ +<?php +/* $Id$*/ +/*Input Serial Items - used for inputing serial numbers or batch/roll/bundle references +for controlled items - used in: +- ConfirmDispatchControlledInvoice.php +- GoodsReceivedControlled.php +- StockAdjustments.php +- StockTransfers.php +- CreditItemsControlled.php + +*/ + +//we start with a batch or serial no header and need to display something for verification... +global $tableheader; + +include ('includes/Add_SerialItemsOut.php'); + +global $tableheader; +/* Link to clear the list and start from scratch */ +$EditLink = '<br><div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&EditControlled=true&StockID=' . $LineItem->StockID . + '&LineNo=' . $LineNo .'">'. _('Edit'). '</a> | '; +$RemoveLink = '<a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&DELETEALL=YES&StockID=' . $LineItem->StockID . + '&LineNo=' . $LineNo .'">'. _('Remove All'). '</a><br></div>'; +$sql="SELECT perishable + FROM stockmaster + WHERE stockid='".$StockID."'"; +$result=DB_query($sql, $db); +$myrow=DB_fetch_array($result); +$Perishable=$myrow['perishable']; +if ($LineItem->Serialised==1){ + $tableheader .= '<tr> + <th>'. _('Serial No').'</th> + </tr>'; + $listtableheader=$tableheader; +} else if ($LineItem->Serialised==0 and $Perishable==1){ + $tableheader = '<tr> + <th>'. _('Batch/Roll/Bundle'). ' #</th> + <th>'. _('Available'). '</th> + <th>'. _('Quantity'). '</th> + <th>'. _('Expiry Date'). '</th> + </tr>'; + $listtableheader = '<tr> + <th>'. _('Batch/Roll/Bundle'). ' #</th> + <th>'. _('Quantity'). '</th> + <th>'. _('Expiry Date'). '</th> + </tr>'; +} else { + $tableheader = '<tr> + <th>'. _('Batch/Roll/Bundle'). ' #</th> + <th>'. _('Quantity'). '</th> + </tr>'; + $listtableheader=$tableheader; +} + +echo $EditLink . $RemoveLink; + +if (isset($_GET['LineNo'])){ + $LineNo = $_GET['LineNo']; +} elseif (isset($_POST['LineNo'])){ + $LineNo = $_POST['LineNo']; +} + +/*Display the batches already entered with quantities if not serialised */ + +echo '<table class=selection><tr><td valign=top><table class=selection>'; +echo $listtableheader; + +$TotalQuantity = 0; /*Variable to accumulate total quantity received */ +$RowCounter =0; + +$k=0; +foreach ($LineItem->SerialItems as $Bundle){ + + if ($RowCounter == 10){ + echo $listtableheader; + $RowCounter =0; + } else { + $RowCounter++; + } + + if ($k==1){ + echo '<tr bgcolor="#CCCCCC">'; + $k=0; + } else { + echo '<tr bgcolor="#EEEEEE">'; + $k=1; + } + + echo '<td>' . $Bundle->BundleRef . '</td>'; + + if ($LineItem->Serialised==0 and $Perishable==0){ + echo '<td class=number>' . number_format($Bundle->BundleQty, $LineItem->DecimalPlaces) . '</td>'; + } else if ($LineItem->Serialised==0 and $Perishable==1){ + echo '<td class=number>' . number_format($Bundle->BundleQty, $LineItem->DecimalPlaces) . '</td>'; + echo '<td class=number>' . $Bundle->ExpiryDate . '</td>'; + } + + echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . 'Delete=' . $Bundle->BundleRef . '&StockID=' . $LineItem->StockID . '&LineNo=' . $LineNo .'">'. _('Delete'). '</a></td></tr>'; + + $TotalQuantity += $Bundle->BundleQty; +} + + +/*Display the totals and rule off before allowing new entries */ +if ($LineItem->Serialised==1){ + echo '<tr><td class=number><B>'. _('Total Quantity'). ': ' . number_format($TotalQuantity,$LineItem->DecimalPlaces) . '</b></td></tr>'; +} else { + echo '<tr><td class=number><B>'. _('Total Quantity'). ':</b></td><td class=number><b>' . number_format($TotalQuantity,$LineItem->DecimalPlaces) . '</b></td></tr>'; +} + +/*Close off old table */ +echo '</table></td><td valign=top>'; + +/*Start a new table for the Serial/Batch ref input in one column (as a sub table +then the multi select box for selection of existing bundle/serial nos for dispatch if applicable*/ +//echo '<TABLE><TR><TD valign=TOP>'; + +/*in the first column add a table for the input of newies */ +echo '<table class=selection>'; +echo $tableheader; + + +echo '<form action="' . $_SERVER['PHP_SELF'] . '?=' . SID . '" name="Ga6uF5Wa" method="post"> + <input type=hidden name=LineNo value="' . $LineNo . '"> + <input type=hidden name=StockID value="' . $StockID . '"> + <input type=hidden name=EntryType value="KEYED">'; +echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; +if ( isset($_GET['EditControlled']) ) { + $EditControlled = isset($_GET['EditControlled'])?$_GET['EditControlled']:false; +} elseif ( isset($_POST['EditControlled']) ){ + $EditControlled = isset($_POST['EditControlled'])?$_POST['EditControlled']:false; +} else { + $EditControlled=false; +} +$TotalQuantity = 0; /*Variable to accumulate total quantity received */ +$RowCounter =0; + +$k=0; + +$StartAddingAt = 0; +if ($EditControlled){ + foreach ($LineItem->SerialItems as $Bundle){ + + echo '<tr><td valign=top><input type=text name="SerialNo'. $StartAddingAt .'" + value="'.$Bundle->BundleRef.'" size=21 maxlength=20></td>'; + + /*if the item is controlled not serialised - batch quantity required so just enter bundle refs + into the form for entry of quantities manually */ + + if ($LineItem->Serialised==1){ + echo '<input type=hidden name="Qty' . $StartAddingAt .'" Value=1></TR>'; + } else if ($LineItem->Serialised==0 and $Perishable==1) { + echo '<td><input type=text class="number" name="Qty' . $StartAddingAt .'" size=11 + value="'. number_format($Bundle->BundleQty, $LineItem->DecimalPlaces). '" maxlength=10></tr>'; + } else { + echo '<td><input type=text class="number" name="Qty' . $StartAddingAt .'" size=11 + value="'. number_format($Bundle->BundleQty, $LineItem->DecimalPlaces). '" maxlength=10></tr>'; + } + + $StartAddingAt++; + } +} + +$sql="SELECT serialno, + quantity, + expirationdate + FROM stockserialitems + WHERE stockid='".$StockID."' + AND loccode='".$_SESSION['Items']->Location."'"; +$result=DB_query($sql, $db); + +$RowNumber=0; +while ($myrow=DB_fetch_array($result)){ + + echo '<tr><td valign=top>'.$myrow['serialno'].'<input type=hidden name="SerialNo'. ($RowNumber) .'" size=21 value="'.$myrow['serialno'].'" maxlength=20></td>'; + + /*if the item is controlled not serialised - batch quantity required so just enter bundle refs + into the form for entry of quantities manually */ + + if ($LineItem->Serialised==1){ + echo '<input type=hidden name="Qty' . ($StartAddingAt+$RowNumber) .'" Value=1></tr>'; + } else if ($LineItem->Serialised==0 and $Perishable==1) { + if (isset($LineItem->SerialItems[$myrow['serialno']])) { + echo '<td class=number>'.number_format($myrow['quantity']-$LineItem->SerialItems[$myrow['serialno']]->BundleQty,$LineItem->DecimalPlaces).'</td>'; + } else { + echo '<td class=number>'.number_format($myrow['quantity'],$LineItem->DecimalPlaces).'</td>'; + } + echo '<td><input type=text class="number" name="Qty' . ($StartAddingAt+$RowNumber) .'" size=11 value="0" maxlength=10></td>'; + echo '<td><input type=hidden class="date" name="ExpiryDate' . ($StartAddingAt+$RowNumber) .'" size=11 + value="'.ConvertSQLDate($myrow['expirationdate']).'" alt="'.$_SESSION['DefaultDateFormat'].'" maxlength=10>'.ConvertSQLDate($myrow['expirationdate']).'</td></tr>'; + } else { + echo '<td><input type=text class="number" name="Qty' . ($StartAddingAt+$RowNumber) .'" size=11 value="'.$myrow['quantity'].'" maxlength=10></tr>'; + } + $RowNumber++; +} + +echo '</table>'; +echo '<br><div class=centre><input type=submit name="AddBatches" value="'. _('Enter'). '"></div>'; +echo '</form></td><td valign=top>'; +$ShowExisting=True; +$_POST['EntryType']='Sequential'; +if ($ShowExisting){ + include('includes/InputSerialItemsExisting.php'); +} +echo '</td></tr></table><script type="text/javascript"> +//<![CDATA[ +document.Ga6uF5Wa.SerialNo0.focus(); +//]]> +</script>'; /*end of nested table */ +?> \ No newline at end of file Added: trunk/includes/PDFQuotationPortraitPageHeader.inc =================================================================== --- trunk/includes/PDFQuotationPortraitPageHeader.inc (rev 0) +++ trunk/includes/PDFQuotationPortraitPageHeader.inc 2011-03-03 09:14:45 UTC (rev 4502) @@ -0,0 +1,136 @@ +<?php +/* $Id: PDFQuotationPortrait.php 4491 2011-02-15 06:31:08Z daintree $ */ + +if ($PageNumber>1){ + $pdf->newPage(); +} + +$XPos = $Page_Width/2 - 140; +$pdf->addJpegFromFile($_SESSION['LogoFile'],$XPos+90,720,0,60); + +$XPos = $XPos + 130; + +$FontSize=18; +$pdf->addText($XPos,820,$FontSize, _('Quotation')); +$FontSize=12; +$YPos = 720; +$pdf->addText($XPos, $YPos,$FontSize, $_SESSION['CompanyRecord']['coyname']); +$FontSize =10; +$pdf->addText($XPos, $YPos-12,$FontSize, $_SESSION['CompanyRecord']['regoffice1']); +$pdf->addText($XPos, $YPos-21,$FontSize, $_SESSION['CompanyRecord']['regoffice2']); +$pdf->addText($XPos, $YPos-30,$FontSize, $_SESSION['CompanyRecord']['regoffice3'] . ' ' . $_SESSION['CompanyRecord']['regoffice4'] . ' ' . $_SESSION['CompanyRecord']['regoffice5']); +$pdf->addText($XPos, $YPos-39,$FontSize, _('Ph') . ': ' . $_SESSION['CompanyRecord']['telephone'] . ' ' . _('Fax'). ': ' . $_SESSION['CompanyRecord']['fax']); +$pdf->addText($XPos, $YPos-48,$FontSize, $_SESSION['CompanyRecord']['email']); + + +$XPos = 46; +$YPos = 770; + +$FontSize=12; +$pdf->addText($XPos, $YPos+10,$FontSize, _('Delivery To').':' ); +$pdf->addText($XPos, $YPos- 3,$FontSize, $myrow['deliverto']); +$pdf->addText($XPos, $YPos-15,$FontSize, $myrow['deladd1']); +$pdf->addText($XPos, $YPos-30,$FontSize, $myrow['deladd2']); +$pdf->addText($XPos, $YPos-45,$FontSize, $myrow['deladd3'] . ' ' . $myrow['deladd4'] . ' ' . $myrow['deladd5']); + +$YPos -= 80; + +$pdf->addText($XPos, $YPos,$FontSize, _('Quotation For').':'); +$pdf->addText($XPos, $YPos-15,$FontSize, $myrow['name']); +$pdf->addText($XPos, $YPos-30,$FontSize, $myrow['address1']); +$pdf->addText($XPos, $YPos-45,$FontSize, $myrow['address2']); +$pdf->addText($XPos, $YPos-60,$FontSize, $myrow['address3'] . ' ' . $myrow['address4'] . ' ' . $myrow['address5']); + + +$XPos= 50; +$YPos += 25; +/*draw a nice curved corner box around the delivery details */ +/*from the top right */ +$pdf->partEllipse($XPos+200,$YPos+60,0,90,10,10); +/*line to the top left */ +$pdf->line($XPos+200, $YPos+70,$XPos, $YPos+70); +/*Dow top left corner */ +$pdf->partEllipse($XPos, $YPos+60,90,180,10,10); +/*Do a line to the bottom left corner */ +$pdf->line($XPos-10, $YPos+60,$XPos-10, $YPos); +/*Now do the bottom left corner 180 - 270 coming back west*/ +$pdf->partEllipse($XPos, $YPos,180,270,10,10); +/*Now a line to the bottom right */ +$pdf->line($XPos, $YPos-10,$XPos+200, $YPos-10); +/*Now do the bottom right corner */ +$pdf->partEllipse($XPos+200, $YPos,270,360,10,10); +/*Finally join up to the top right corner where started */ +$pdf->line($XPos+210, $YPos,$XPos+210, $YPos+60); + + +$YPos -= 90; +/*draw a nice curved corner box around the billing details */ +/*from the top right */ +$pdf->partEllipse($XPos+200,$YPos+60,0,90,10,10); +/*line to the top left */ +$pdf->line($XPos+200, $YPos+70,$XPos, $YPos+70); +/*Dow top left corner */ +$pdf->partEllipse($XPos, $YPos+60,90,180,10,10); +/*Do a line to the bottom left corner */ +$pdf->line($XPos-10, $YPos+60,$XPos-10, $YPos); +/*Now do the bottom left corner 180 - 270 coming back west*/ +$pdf->partEllipse($XPos, $YPos,180,270,10,10); +/*Now a line to the bottom right */ +$pdf->line($XPos, $YPos-10,$XPos+200, $YPos-10); +/*Now do the bottom right corner */ +$pdf->partEllipse($XPos+200, $YPos,270,360,10,10); +/*Finally join up to the top right corner where started */ +$pdf->line($XPos+210, $YPos,$XPos+210, $YPos+60); + + +$pdf->addText(490, 790,$FontSize, _('Number'). ':'); +$pdf->addText(535, 790,$FontSize, $_GET['QuotationNo']); +$pdf->addText(490, 790-15,$FontSize, _('Your Ref'). ':'); +$pdf->addText(520, 790-15,$FontSize, $myrow['customerref']); +$pdf->addText(490, 790-30,$FontSize, _('Date'). ':'); +$pdf->addText(520, 790-30,$FontSize, ConvertSQLDate($myrow['orddate'])); +$pdf->addText(490, 790-45,$FontSize, _('Page'). ':'); +$pdf->addText(520, 790-45,$FontSize, $PageNumber); + +$YPos -= 45; +$XPos = 40; + +$FontSize=10; +$LeftOvers = $pdf->addTextWrap($XPos+2,$YPos,100,$FontSize, _('Item Code'),'left'); +$LeftOvers = $pdf->addTextWrap(120,$YPos,235,$FontSize, _('Item Description'),'left'); +$LeftOvers = $pdf->addTextWrap(180,$YPos,85,$FontSize, _('Quantity'),'right'); +$LeftOvers = $pdf->addTextWrap(230,$YPos,85,$FontSize,_('Price'),'right'); +$LeftOvers = $pdf->addTextWrap(280,$YPos,85,$FontSize, _('Discount'),'right'); +$LeftOvers = $pdf->addTextWrap(330,$YPos,85,$FontSize, _('Tax Class'),'right'); +$LeftOvers = $pdf->addTextWrap(400,$YPos,85,$FontSize, _('Tax Amount'),'right'); +$LeftOvers = $pdf->addTextWrap(450,$YPos,90,$FontSize, _('Total'),'right'); + + +/*draw a box with nice round corner for entering line items */ +/*90 degree arc at top right of box 0 degrees starts a bottom */ +$pdf->partEllipse($Page_Width-$Right_Margin-0, $Bottom_Margin+560,0,90,10,10); +/*line to the top left */ +$pdf->line($Page_Width-$Right_Margin-0, $Bottom_Margin+570,$Left_Margin+10, $Bottom_Margin+570); + +/*line under headings to top left */ +$pdf->line($Page_Width-$Right_Margin+10, $Bottom_Margin+538,$Left_Margin, $Bottom_Margin+538); + + +/*Dow top left corner */ +$pdf->partEllipse($Left_Margin+10, $Bottom_Margin+560,90,180,10,10); +/*Do a line to the bottom left corner */ +$pdf->line($Left_Margin, $Bottom_Margin+560,$Left_Margin, $Bottom_Margin+10); +/*Now do the bottom left corner 180 - 270 coming back west*/ +$pdf->partEllipse($Left_Margin+10, $Bottom_Margin+10,180,270,10,10); +/*Now a line to the bottom right */ +$pdf->line($Left_Margin+10, $Bottom_Margin,$Page_Width-$Right_Margin-0, $Bottom_Margin); +/*Now do the bottom right corner */ +$pdf->partEllipse($Page_Width-$Right_Margin-0, $Bottom_Margin+10,270,360,10,10); +/*Finally join up to the top right corner where started */ +$pdf->line($Page_Width-$Right_Margin+10, $Bottom_Margin+10,$Page_Width-$Right_Margin+10, $Bottom_Margin+560); + +$YPos -= $line_height; + +$FontSize =12; + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-03 09:14:52
|
Revision: 4502 http://web-erp.svn.sourceforge.net/web-erp/?rev=4502&view=rev Author: daintree Date: 2011-03-03 09:14:45 +0000 (Thu, 03 Mar 2011) Log Message: ----------- New Portrait quotation OutputSerialItems Added Paths: ----------- trunk/PDFQuotationPortrait.php trunk/includes/OutputSerialItems.php trunk/includes/PDFQuotationPortraitPageHeader.inc Added: trunk/PDFQuotationPortrait.php =================================================================== --- trunk/PDFQuotationPortrait.php (rev 0) +++ trunk/PDFQuotationPortrait.php 2011-03-03 09:14:45 UTC (rev 4502) @@ -0,0 +1,252 @@ +<?php + +/* $Id: PDFQuotationPortrait.php 4491 2011-02-15 06:31:08Z daintree $ */ + + +include('includes/session.inc'); +include('includes/SQL_CommonFunctions.inc'); + +//Get Out if we have no order number to work with +If (!isset($_GET['QuotationNo']) || $_GET['QuotationNo']==""){ + $title = _('Select Quotation To Print'); + include('includes/header.inc'); + echo '<div class="centre"><br><br><br>'; + prnMsg( _('Select a Quotation 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 .'&Quotations=Quotes_Only">' . _('Quotations') . '</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 quotation header details for Order Number') . ' ' . $_GET['QuotationNo'] . ' ' . _('from the database'); + +$sql = "SELECT salesorders.customerref, + salesorders.comments, + salesorders.orddate, + salesorders.deliverto, + salesorders.deladd1, + salesorders.deladd2, + salesorders.deladd3, + salesorders.deladd4, + salesorders.deladd5, + salesorders.deladd6, + debtorsmaster.name, + debtorsmaster.address1, + debtorsmaster.address2, + debtorsmaster.address3, + debtorsmaster.address4, + debtorsmaster.address5, + debtorsmaster.address6, + shippers.shippername, + salesorders.printedpackingslip, + salesorders.datepackingslipprinted, + salesorders.branchcode, + locations.taxprovinceid, + 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.quotation=1 + AND salesorders.orderno='" . $_GET['QuotationNo'] ."'"; + +$result=DB_query($sql,$db, $ErrMsg); + +//If there are no rows, there's a problem. +if (DB_num_rows($result)==0){ + $title = _('Print Quotation Error'); + include('includes/header.inc'); + echo '<div class="centre"><br><br><br>'; + prnMsg( _('Unable to Locate Quotation Number') . ' : ' . $_GET['QuotationNo'] . ' ', 'error'); + echo '<br><br><br><table class="table_index"><tr><td class="menu_group_item"> + <li><a href="'. $rootpath . '/SelectSalesOrder.php?'. SID .'&Quotations=Quotes_Only">' . _('Outstanding Quotations') . '</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); +} + +/*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'; +include('includes/PDFStarter.php'); +$pdf->addInfo('Title', _('Customer Quotation') ); +$pdf->addInfo('Subject', _('Quotation') . ' ' . $_GET['QuotationNo']); +$FontSize=12; +$PageNumber = 1; +$line_height=24; +// $pdf->selectFont('./fonts/Helvetica.afm'); + +/* Now ... Has the order got any line items still outstanding to be invoiced */ + +$ErrMsg = _('There was a problem retrieving the quotation line details for quotation Number') . ' ' . + $_GET['QuotationNo'] . ' ' . _('from the database'); + +$sql = "SELECT salesorderdetails.stkcode, + stockmaster.description, + salesorderdetails.quantity, + salesorderdetails.qtyinvoiced, + salesorderdetails.unitprice, + salesorderdetails.discountpercent, + stockmaster.taxcatid, + salesorderdetails.narrative + FROM salesorderdetails INNER JOIN stockmaster + ON salesorderdetails.stkcode=stockmaster.stockid + WHERE salesorderdetails.orderno='" . $_GET['QuotationNo'] . "'"; + +$result=DB_query($sql,$db, $ErrMsg); + +$ListCount = 0; // UldisN + +if (DB_num_rows($result)>0){ + /*Yes there are line items to start the ball rolling with a page header */ + include('includes/PDFQuotationPortraitPageHeader.inc'); + + $QuotationTotal =0; + $QuotationTotalEx=0; + $TaxTotal=0; + + while ($myrow2=DB_fetch_array($result)){ + + $ListCount ++; + + if ((strlen($myrow2['narrative']) >200 AND $YPos-$line_height <= 75) + OR (strlen($myrow2['narrative']) >1 AND $YPos-$line_height <= 62) + OR $YPos-$line_height <= 50){ + /* We reached the end of the page so finsih off the page and start a newy */ + $PageNumber++; + include ('includes/PDFQuotationPageHeader.inc'); + + } //end if need a new page headed up + + $DisplayQty = number_format($myrow2['quantity'],2); + $DisplayPrevDel = number_format($myrow2['qtyinvoiced'],2); + $DisplayPrice = number_format($myrow2['unitprice'],2); + $DisplayDiscount = number_format($myrow2['discountpercent']*100,2) . '%'; + $SubTot = $myrow2['unitprice']*$myrow2['quantity']*(1-$myrow2['discountpercent']); + $TaxProv = $myrow['taxprovinceid']; + $TaxCat = $myrow2['taxcatid']; + $Branch = $myrow['branchcode']; + $sql3 = " select taxgrouptaxes.taxauthid from taxgrouptaxes INNER JOIN custbranch ON taxgrouptaxes.taxgroupid=custbranch.taxgroupid WHERE custbranch.branchcode='" .$Branch ."'"; + $result3=DB_query($sql3,$db, $ErrMsg); + while ($myrow3=DB_fetch_array($result3)){ + $TaxAuth = $myrow3['taxauthid']; + } + + $sql4 = "SELECT * FROM taxauthrates WHERE dispatchtaxprovince='" .$TaxProv ."' AND taxcatid='" .$TaxCat ."' AND taxauthority='" .$TaxAuth ."'"; + $result4=DB_query($sql4,$db, $ErrMsg); + while ($myrow4=DB_fetch_array($result4)){ + $TaxClass = 100 * $myrow4['taxrate']; + } + + $DisplayTaxClass = $TaxClass . "%"; + $TaxAmount = (($SubTot/100)*(100+$TaxClass))-$SubTot; + $DisplayTaxAmount = number_format($TaxAmount,2); + + $LineTotal = $SubTot + $TaxAmount; + $DisplayTotal = number_format($LineTotal,2); + + $FontSize=10; + + $LeftOvers = $pdf->addTextWrap($XPos+1,$YPos,100,$FontSize,$myrow2['stkcode']); + $LeftOvers = $pdf->addTextWrap(120,$YPos,295,$FontSize,$myrow2['description']); + $LeftOvers = $pdf->addTextWrap(180,$YPos,85,$FontSize,$DisplayQty,'right'); + $LeftOvers = $pdf->addTextWrap(230,$YPos,85,$FontSize,$DisplayPrice,'right'); + if ($DisplayDiscount > 0){ + $LeftOvers = $pdf->addTextWrap(280,$YPos,85,$FontSize,$DisplayDiscount,'right'); + } + $LeftOvers = $pdf->addTextWrap(330,$YPos,85,$FontSize,$DisplayTaxClass,'right'); + $LeftOvers = $pdf->addTextWrap(410,$YPos,85,$FontSize,$DisplayTaxAmount,'center'); + $LeftOvers = $pdf->addTextWrap(460,$YPos,90,$FontSize,$DisplayTotal,'right'); + if (strlen($myrow2['narrative'])>1){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos+1,$YPos,750,10,$myrow2['narrative']); + if (strlen($LeftOvers>1)){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos+1,$YPos,750,10,$LeftOvers); + } + } + $QuotationTotal +=$LineTotal; + $QuotationTotalEx +=$SubTot; + $TaxTotal +=$TaxAmount; + + /*increment a line down for the next line item */ + $YPos -= ($line_height); + + } //end while there are line items to print out + if ((strlen($myrow['comments']) >200 AND $YPos-$line_height <= 75) + OR (strlen($myrow['comments']) >1 AND $YPos-$line_height <= 62) + OR $YPos-$line_height <= 50){ + /* We reached the end of the page so finsih off the page and start a newy */ + $PageNumber++; + include ('includes/PDFQuotationPageHeader.inc'); + + } //end if need a new page headed up + + $LeftOvers = $pdf->addTextWrap($XPos,$YPos-80,200,10,_('Notes:')); + $LeftOvers = $pdf->addText($XPos,$YPos-95,10,$myrow['comments']); + + if (strlen($LeftOvers)>1){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos,$YPos,700,10,$LeftOvers); + if (strlen($LeftOvers)>1){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos,$YPos,700,10,$LeftOvers); + if (strlen($LeftOvers)>1){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos,$YPos,700,10,$LeftOvers); + if (strlen($LeftOvers)>1){ + $YPos -= 10; + $LeftOvers = $pdf->addTextWrap($XPos,$YPos,10,$FontSize,$LeftOvers); + } + } + } + } + $YPos -= ($line_height); + $LeftOvers = $pdf->addTextWrap(40,$YPos,655,$FontSize,_('Total Tax'),'right'); + $LeftOvers = $pdf->addTextWrap(700,$YPos,90,$FontSize,number_format($TaxTotal,2),'right'); + $YPos -= 12; + $LeftOvers = $pdf->addTextWrap(40,$YPos,655,$FontSize,_('Quotation Excluding Tax'),'right'); + $LeftOvers = $pdf->addTextWrap(700,$YPos,90,$FontSize,number_format($QuotationTotalEx,2),'right'); + $YPos -= 12; + $LeftOvers = $pdf->addTextWrap(40,$YPos,655,$FontSize,_('Quotation Including Tax'),'right'); + $LeftOvers = $pdf->addTextWrap(700,$YPos,90,$FontSize,number_format($QuotationTotal,2),'right'); + +} /*end if there are line details to show on the quotation*/ + + +//$pdfcode = $pdf->output('PDFQuotation.pdf', 'I'); +//$len = strlen($pdfcode); +if ($ListCount == 0){ + $title = _('Print Quotation Error'); + include('includes/header.inc'); + echo '<p>'. _('There were no items on the quotation') . '. ' . _('The quotation cannot be printed'). + '<br><a href="' . $rootpath . '/SelectSalesOrder.php?' . SID . '&Quotation=Quotes_only">'. _('Print Another Quotation'). + '</a>' . '<br>'. '<a href="' . $rootpath . '/index.php?' . SID . '">' . _('Back to the menu') . '</a>'; + include('includes/footer.inc'); + exit; +} else { +/* + header('Content-type: application/pdf'); + header('Content-Length: ' . $len); + header('Content-Disposition: inline; filename=Quotation.pdf'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); +//echo 'here'; + $pdf->Output('PDFQuotation.pdf', 'I'); +*/ + $pdf->OutputI($_SESSION['DatabaseName'] . '_Quotation_' . date('Y-m-d') . '.pdf');//UldisN + $pdf->__destruct(); //UldisN +} +?> Added: trunk/includes/OutputSerialItems.php =================================================================== --- trunk/includes/OutputSerialItems.php (rev 0) +++ trunk/includes/OutputSerialItems.php 2011-03-03 09:14:45 UTC (rev 4502) @@ -0,0 +1,210 @@ +<?php +/* $Id$*/ +/*Input Serial Items - used for inputing serial numbers or batch/roll/bundle references +for controlled items - used in: +- ConfirmDispatchControlledInvoice.php +- GoodsReceivedControlled.php +- StockAdjustments.php +- StockTransfers.php +- CreditItemsControlled.php + +*/ + +//we start with a batch or serial no header and need to display something for verification... +global $tableheader; + +include ('includes/Add_SerialItemsOut.php'); + +global $tableheader; +/* Link to clear the list and start from scratch */ +$EditLink = '<br><div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&EditControlled=true&StockID=' . $LineItem->StockID . + '&LineNo=' . $LineNo .'">'. _('Edit'). '</a> | '; +$RemoveLink = '<a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&DELETEALL=YES&StockID=' . $LineItem->StockID . + '&LineNo=' . $LineNo .'">'. _('Remove All'). '</a><br></div>'; +$sql="SELECT perishable + FROM stockmaster + WHERE stockid='".$StockID."'"; +$result=DB_query($sql, $db); +$myrow=DB_fetch_array($result); +$Perishable=$myrow['perishable']; +if ($LineItem->Serialised==1){ + $tableheader .= '<tr> + <th>'. _('Serial No').'</th> + </tr>'; + $listtableheader=$tableheader; +} else if ($LineItem->Serialised==0 and $Perishable==1){ + $tableheader = '<tr> + <th>'. _('Batch/Roll/Bundle'). ' #</th> + <th>'. _('Available'). '</th> + <th>'. _('Quantity'). '</th> + <th>'. _('Expiry Date'). '</th> + </tr>'; + $listtableheader = '<tr> + <th>'. _('Batch/Roll/Bundle'). ' #</th> + <th>'. _('Quantity'). '</th> + <th>'. _('Expiry Date'). '</th> + </tr>'; +} else { + $tableheader = '<tr> + <th>'. _('Batch/Roll/Bundle'). ' #</th> + <th>'. _('Quantity'). '</th> + </tr>'; + $listtableheader=$tableheader; +} + +echo $EditLink . $RemoveLink; + +if (isset($_GET['LineNo'])){ + $LineNo = $_GET['LineNo']; +} elseif (isset($_POST['LineNo'])){ + $LineNo = $_POST['LineNo']; +} + +/*Display the batches already entered with quantities if not serialised */ + +echo '<table class=selection><tr><td valign=top><table class=selection>'; +echo $listtableheader; + +$TotalQuantity = 0; /*Variable to accumulate total quantity received */ +$RowCounter =0; + +$k=0; +foreach ($LineItem->SerialItems as $Bundle){ + + if ($RowCounter == 10){ + echo $listtableheader; + $RowCounter =0; + } else { + $RowCounter++; + } + + if ($k==1){ + echo '<tr bgcolor="#CCCCCC">'; + $k=0; + } else { + echo '<tr bgcolor="#EEEEEE">'; + $k=1; + } + + echo '<td>' . $Bundle->BundleRef . '</td>'; + + if ($LineItem->Serialised==0 and $Perishable==0){ + echo '<td class=number>' . number_format($Bundle->BundleQty, $LineItem->DecimalPlaces) . '</td>'; + } else if ($LineItem->Serialised==0 and $Perishable==1){ + echo '<td class=number>' . number_format($Bundle->BundleQty, $LineItem->DecimalPlaces) . '</td>'; + echo '<td class=number>' . $Bundle->ExpiryDate . '</td>'; + } + + echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . 'Delete=' . $Bundle->BundleRef . '&StockID=' . $LineItem->StockID . '&LineNo=' . $LineNo .'">'. _('Delete'). '</a></td></tr>'; + + $TotalQuantity += $Bundle->BundleQty; +} + + +/*Display the totals and rule off before allowing new entries */ +if ($LineItem->Serialised==1){ + echo '<tr><td class=number><B>'. _('Total Quantity'). ': ' . number_format($TotalQuantity,$LineItem->DecimalPlaces) . '</b></td></tr>'; +} else { + echo '<tr><td class=number><B>'. _('Total Quantity'). ':</b></td><td class=number><b>' . number_format($TotalQuantity,$LineItem->DecimalPlaces) . '</b></td></tr>'; +} + +/*Close off old table */ +echo '</table></td><td valign=top>'; + +/*Start a new table for the Serial/Batch ref input in one column (as a sub table +then the multi select box for selection of existing bundle/serial nos for dispatch if applicable*/ +//echo '<TABLE><TR><TD valign=TOP>'; + +/*in the first column add a table for the input of newies */ +echo '<table class=selection>'; +echo $tableheader; + + +echo '<form action="' . $_SERVER['PHP_SELF'] . '?=' . SID . '" name="Ga6uF5Wa" method="post"> + <input type=hidden name=LineNo value="' . $LineNo . '"> + <input type=hidden name=StockID value="' . $StockID . '"> + <input type=hidden name=EntryType value="KEYED">'; +echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; +if ( isset($_GET['EditControlled']) ) { + $EditControlled = isset($_GET['EditControlled'])?$_GET['EditControlled']:false; +} elseif ( isset($_POST['EditControlled']) ){ + $EditControlled = isset($_POST['EditControlled'])?$_POST['EditControlled']:false; +} else { + $EditControlled=false; +} +$TotalQuantity = 0; /*Variable to accumulate total quantity received */ +$RowCounter =0; + +$k=0; + +$StartAddingAt = 0; +if ($EditControlled){ + foreach ($LineItem->SerialItems as $Bundle){ + + echo '<tr><td valign=top><input type=text name="SerialNo'. $StartAddingAt .'" + value="'.$Bundle->BundleRef.'" size=21 maxlength=20></td>'; + + /*if the item is controlled not serialised - batch quantity required so just enter bundle refs + into the form for entry of quantities manually */ + + if ($LineItem->Serialised==1){ + echo '<input type=hidden name="Qty' . $StartAddingAt .'" Value=1></TR>'; + } else if ($LineItem->Serialised==0 and $Perishable==1) { + echo '<td><input type=text class="number" name="Qty' . $StartAddingAt .'" size=11 + value="'. number_format($Bundle->BundleQty, $LineItem->DecimalPlaces). '" maxlength=10></tr>'; + } else { + echo '<td><input type=text class="number" name="Qty' . $StartAddingAt .'" size=11 + value="'. number_format($Bundle->BundleQty, $LineItem->DecimalPlaces). '" maxlength=10></tr>'; + } + + $StartAddingAt++; + } +} + +$sql="SELECT serialno, + quantity, + expirationdate + FROM stockserialitems + WHERE stockid='".$StockID."' + AND loccode='".$_SESSION['Items']->Location."'"; +$result=DB_query($sql, $db); + +$RowNumber=0; +while ($myrow=DB_fetch_array($result)){ + + echo '<tr><td valign=top>'.$myrow['serialno'].'<input type=hidden name="SerialNo'. ($RowNumber) .'" size=21 value="'.$myrow['serialno'].'" maxlength=20></td>'; + + /*if the item is controlled not serialised - batch quantity required so just enter bundle refs + into the form for entry of quantities manually */ + + if ($LineItem->Serialised==1){ + echo '<input type=hidden name="Qty' . ($StartAddingAt+$RowNumber) .'" Value=1></tr>'; + } else if ($LineItem->Serialised==0 and $Perishable==1) { + if (isset($LineItem->SerialItems[$myrow['serialno']])) { + echo '<td class=number>'.number_format($myrow['quantity']-$LineItem->SerialItems[$myrow['serialno']]->BundleQty,$LineItem->DecimalPlaces).'</td>'; + } else { + echo '<td class=number>'.number_format($myrow['quantity'],$LineItem->DecimalPlaces).'</td>'; + } + echo '<td><input type=text class="number" name="Qty' . ($StartAddingAt+$RowNumber) .'" size=11 value="0" maxlength=10></td>'; + echo '<td><input type=hidden class="date" name="ExpiryDate' . ($StartAddingAt+$RowNumber) .'" size=11 + value="'.ConvertSQLDate($myrow['expirationdate']).'" alt="'.$_SESSION['DefaultDateFormat'].'" maxlength=10>'.ConvertSQLDate($myrow['expirationdate']).'</td></tr>'; + } else { + echo '<td><input type=text class="number" name="Qty' . ($StartAddingAt+$RowNumber) .'" size=11 value="'.$myrow['quantity'].'" maxlength=10></tr>'; + } + $RowNumber++; +} + +echo '</table>'; +echo '<br><div class=centre><input type=submit name="AddBatches" value="'. _('Enter'). '"></div>'; +echo '</form></td><td valign=top>'; +$ShowExisting=True; +$_POST['EntryType']='Sequential'; +if ($ShowExisting){ + include('includes/InputSerialItemsExisting.php'); +} +echo '</td></tr></table><script type="text/javascript"> +//<![CDATA[ +document.Ga6uF5Wa.SerialNo0.focus(); +//]]> +</script>'; /*end of nested table */ +?> \ No newline at end of file Added: trunk/includes/PDFQuotationPortraitPageHeader.inc =================================================================== --- trunk/includes/PDFQuotationPortraitPageHeader.inc (rev 0) +++ trunk/includes/PDFQuotationPortraitPageHeader.inc 2011-03-03 09:14:45 UTC (rev 4502) @@ -0,0 +1,136 @@ +<?php +/* $Id: PDFQuotationPortrait.php 4491 2011-02-15 06:31:08Z daintree $ */ + +if ($PageNumber>1){ + $pdf->newPage(); +} + +$XPos = $Page_Width/2 - 140; +$pdf->addJpegFromFile($_SESSION['LogoFile'],$XPos+90,720,0,60); + +$XPos = $XPos + 130; + +$FontSize=18; +$pdf->addText($XPos,820,$FontSize, _('Quotation')); +$FontSize=12; +$YPos = 720; +$pdf->addText($XPos, $YPos,$FontSize, $_SESSION['CompanyRecord']['coyname']); +$FontSize =10; +$pdf->addText($XPos, $YPos-12,$FontSize, $_SESSION['CompanyRecord']['regoffice1']); +$pdf->addText($XPos, $YPos-21,$FontSize, $_SESSION['CompanyRecord']['regoffice2']); +$pdf->addText($XPos, $YPos-30,$FontSize, $_SESSION['CompanyRecord']['regoffice3'] . ' ' . $_SESSION['CompanyRecord']['regoffice4'] . ' ' . $_SESSION['CompanyRecord']['regoffice5']); +$pdf->addText($XPos, $YPos-39,$FontSize, _('Ph') . ': ' . $_SESSION['CompanyRecord']['telephone'] . ' ' . _('Fax'). ': ' . $_SESSION['CompanyRecord']['fax']); +$pdf->addText($XPos, $YPos-48,$FontSize, $_SESSION['CompanyRecord']['email']); + + +$XPos = 46; +$YPos = 770; + +$FontSize=12; +$pdf->addText($XPos, $YPos+10,$FontSize, _('Delivery To').':' ); +$pdf->addText($XPos, $YPos- 3,$FontSize, $myrow['deliverto']); +$pdf->addText($XPos, $YPos-15,$FontSize, $myrow['deladd1']); +$pdf->addText($XPos, $YPos-30,$FontSize, $myrow['deladd2']); +$pdf->addText($XPos, $YPos-45,$FontSize, $myrow['deladd3'] . ' ' . $myrow['deladd4'] . ' ' . $myrow['deladd5']); + +$YPos -= 80; + +$pdf->addText($XPos, $YPos,$FontSize, _('Quotation For').':'); +$pdf->addText($XPos, $YPos-15,$FontSize, $myrow['name']); +$pdf->addText($XPos, $YPos-30,$FontSize, $myrow['address1']); +$pdf->addText($XPos, $YPos-45,$FontSize, $myrow['address2']); +$pdf->addText($XPos, $YPos-60,$FontSize, $myrow['address3'] . ' ' . $myrow['address4'] . ' ' . $myrow['address5']); + + +$XPos= 50; +$YPos += 25; +/*draw a nice curved corner box around the delivery details */ +/*from the top right */ +$pdf->partEllipse($XPos+200,$YPos+60,0,90,10,10); +/*line to the top left */ +$pdf->line($XPos+200, $YPos+70,$XPos, $YPos+70); +/*Dow top left corner */ +$pdf->partEllipse($XPos, $YPos+60,90,180,10,10); +/*Do a line to the bottom left corner */ +$pdf->line($XPos-10, $YPos+60,$XPos-10, $YPos); +/*Now do the bottom left corner 180 - 270 coming back west*/ +$pdf->partEllipse($XPos, $YPos,180,270,10,10); +/*Now a line to the bottom right */ +$pdf->line($XPos, $YPos-10,$XPos+200, $YPos-10); +/*Now do the bottom right corner */ +$pdf->partEllipse($XPos+200, $YPos,270,360,10,10); +/*Finally join up to the top right corner where started */ +$pdf->line($XPos+210, $YPos,$XPos+210, $YPos+60); + + +$YPos -= 90; +/*draw a nice curved corner box around the billing details */ +/*from the top right */ +$pdf->partEllipse($XPos+200,$YPos+60,0,90,10,10); +/*line to the top left */ +$pdf->line($XPos+200, $YPos+70,$XPos, $YPos+70); +/*Dow top left corner */ +$pdf->partEllipse($XPos, $YPos+60,90,180,10,10); +/*Do a line to the bottom left corner */ +$pdf->line($XPos-10, $YPos+60,$XPos-10, $YPos); +/*Now do the bottom left corner 180 - 270 coming back west*/ +$pdf->partEllipse($XPos, $YPos,180,270,10,10); +/*Now a line to the bottom right */ +$pdf->line($XPos, $YPos-10,$XPos+200, $YPos-10); +/*Now do the bottom right corner */ +$pdf->partEllipse($XPos+200, $YPos,270,360,10,10); +/*Finally join up to the top right corner where started */ +$pdf->line($XPos+210, $YPos,$XPos+210, $YPos+60); + + +$pdf->addText(490, 790,$FontSize, _('Number'). ':'); +$pdf->addText(535, 790,$FontSize, $_GET['QuotationNo']); +$pdf->addText(490, 790-15,$FontSize, _('Your Ref'). ':'); +$pdf->addText(520, 790-15,$FontSize, $myrow['customerref']); +$pdf->addText(490, 790-30,$FontSize, _('Date'). ':'); +$pdf->addText(520, 790-30,$FontSize, ConvertSQLDate($myrow['orddate'])); +$pdf->addText(490, 790-45,$FontSize, _('Page'). ':'); +$pdf->addText(520, 790-45,$FontSize, $PageNumber); + +$YPos -= 45; +$XPos = 40; + +$FontSize=10; +$LeftOvers = $pdf->addTextWrap($XPos+2,$YPos,100,$FontSize, _('Item Code'),'left'); +$LeftOvers = $pdf->addTextWrap(120,$YPos,235,$FontSize, _('Item Description'),'left'); +$LeftOvers = $pdf->addTextWrap(180,$YPos,85,$FontSize, _('Quantity'),'right'); +$LeftOvers = $pdf->addTextWrap(230,$YPos,85,$FontSize,_('Price'),'right'); +$LeftOvers = $pdf->addTextWrap(280,$YPos,85,$FontSize, _('Discount'),'right'); +$LeftOvers = $pdf->addTextWrap(330,$YPos,85,$FontSize, _('Tax Class'),'right'); +$LeftOvers = $pdf->addTextWrap(400,$YPos,85,$FontSize, _('Tax Amount'),'right'); +$LeftOvers = $pdf->addTextWrap(450,$YPos,90,$FontSize, _('Total'),'right'); + + +/*draw a box with nice round corner for entering line items */ +/*90 degree arc at top right of box 0 degrees starts a bottom */ +$pdf->partEllipse($Page_Width-$Right_Margin-0, $Bottom_Margin+560,0,90,10,10); +/*line to the top left */ +$pdf->line($Page_Width-$Right_Margin-0, $Bottom_Margin+570,$Left_Margin+10, $Bottom_Margin+570); + +/*line under headings to top left */ +$pdf->line($Page_Width-$Right_Margin+10, $Bottom_Margin+538,$Left_Margin, $Bottom_Margin+538); + + +/*Dow top left corner */ +$pdf->partEllipse($Left_Margin+10, $Bottom_Margin+560,90,180,10,10); +/*Do a line to the bottom left corner */ +$pdf->line($Left_Margin, $Bottom_Margin+560,$Left_Margin, $Bottom_Margin+10); +/*Now do the bottom left corner 180 - 270 coming back west*/ +$pdf->partEllipse($Left_Margin+10, $Bottom_Margin+10,180,270,10,10); +/*Now a line to the bottom right */ +$pdf->line($Left_Margin+10, $Bottom_Margin,$Page_Width-$Right_Margin-0, $Bottom_Margin); +/*Now do the bottom right corner */ +$pdf->partEllipse($Page_Width-$Right_Margin-0, $Bottom_Margin+10,270,360,10,10); +/*Finally join up to the top right corner where started */ +$pdf->line($Page_Width-$Right_Margin+10, $Bottom_Margin+10,$Page_Width-$Right_Margin+10, $Bottom_Margin+560); + +$YPos -= $line_height; + +$FontSize =12; + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-03 09:13:19
|
Revision: 4501 http://web-erp.svn.sourceforge.net/web-erp/?rev=4501&view=rev Author: daintree Date: 2011-03-03 09:13:12 +0000 (Thu, 03 Mar 2011) Log Message: ----------- Tim launchpad revisions to 4441 excluding price units stuff Modified Paths: -------------- trunk/ConfirmDispatchControlled_Invoice.php trunk/ConfirmDispatch_Invoice.php trunk/DeliveryDetails.php trunk/GoodsReceived.php trunk/GoodsReceivedControlled.php trunk/SelectCompletedOrder.php trunk/SelectCustomer.php trunk/SelectSupplier.php trunk/StockCheck.php trunk/StockSerialItems.php trunk/SupplierCredit.php trunk/Suppliers.php trunk/doc/Change.log.html trunk/includes/Add_SerialItems.php trunk/includes/Add_SerialItemsOut.php trunk/includes/DefineSerialItems.php trunk/includes/InputSerialItems.php trunk/includes/InputSerialItemsKeyed.php trunk/includes/PDFStockCheckPageHeader.inc Modified: trunk/ConfirmDispatchControlled_Invoice.php =================================================================== --- trunk/ConfirmDispatchControlled_Invoice.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/ConfirmDispatchControlled_Invoice.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -66,7 +66,7 @@ $InOutModifier=1; $ShowExisting=false; -include ('includes/InputSerialItems.php'); +include ('includes/OutputSerialItems.php'); /*TotalQuantity set inside this include file from the sum of the bundles of the item selected for dispatch */ Modified: trunk/ConfirmDispatch_Invoice.php =================================================================== --- trunk/ConfirmDispatch_Invoice.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/ConfirmDispatch_Invoice.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -219,18 +219,24 @@ } foreach ($_SESSION['Items']->LineItems as $Itm) { - if (is_numeric($_POST[$Itm->LineNumber . '_QtyDispatched' ])AND $_POST[$Itm->LineNumber . '_QtyDispatched'] <= ($_SESSION['Items']->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyInv)){ + if (sizeOf($Itm->SerialItems) > 0) { + $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched = 0; //initialise QtyDispatched + foreach ($Itm->SerialItems as $SerialItem) { //calculate QtyDispatched from bundle quantities + $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched += $SerialItem->BundleQty; + } + } else if (is_numeric($_POST[$Itm->LineNumber . '_QtyDispatched' ])AND $_POST[$Itm->LineNumber . '_QtyDispatched'] <= ($_SESSION['Items']->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyInv)){ $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched = $_POST[$Itm->LineNumber . '_QtyDispatched']; } + + foreach ($Itm->Taxes as $TaxLine) { if (isset($_POST[$Itm->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate'])){ $_SESSION['Items']->LineItems[$Itm->LineNumber]->Taxes[$TaxLine->TaxCalculationOrder]->TaxRate = $_POST[$Itm->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate']/100; } } + } //end foreach lineitem - } - } /* Always display dispatch quantities and recalc freight for items being dispatched */ @@ -382,15 +388,15 @@ echo '<td class="number">'.$DisplayTaxAmount.'</td><td class="number">'.$DisplayGrossLineTotal.'</td>'; if ($LnItm->Controlled==1){ - - echo '<td><a href="' . $rootpath . '/ConfirmDispatchControlled_Invoice.php?' . SID . '&LineNo='. $LnItm->LineNumber.'">'; - - if ($LnItm->Serialised==1){ - echo _("Enter Serial Numbers"); - } else { /*Just batch/roll/lot control */ - echo _('Enter Batch/Roll/Lot #'); + if (!isset($_POST['ProcessInvoice'])) { + echo '<td><a href="' . $rootpath . '/ConfirmDispatchControlled_Invoice.php?' . SID . '&LineNo='. $LnItm->LineNumber.'">'; + if ($LnItm->Serialised==1){ + echo _('Enter Serial Numbers'); + } else { /*Just batch/roll/lot control */ + echo _('Enter Batch/Roll/Lot #'); + } + echo '</a></td>'; } - echo '</a></td>'; } echo '</tr>'; if (strlen($LnItm->Narrative)>1){ @@ -717,7 +723,7 @@ /*Start an SQL transaction */ -DB_Txn_Begin($db); + DB_Txn_Begin($db); if ($DefaultShipVia != $_SESSION['Items']->ShipVia){ $SQL = "UPDATE custbranch Modified: trunk/DeliveryDetails.php =================================================================== --- trunk/DeliveryDetails.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/DeliveryDetails.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -580,8 +580,8 @@ } else { /*link to print the quotation */ - echo '<br><table class=selection><tr><td><img src="'.$rootpath.'/css/'.$theme.'/images/reports.png" title="' . _('Order') . '" alt=""></td><td>' . ' ' . '<a href="' . $rootpath . '/PDFQuotation.php?identifier='.$identifier . '&QuotationNo=' . $OrderNo . '">'. _('Print Quotation') .'</a></td></tr></table>'; - + echo '<br><table class=selection><tr><td><img src="'.$rootpath.'/css/'.$theme.'/images/reports.png" title="' . _('Order') . '" alt=""></td><td>' . ' ' . '<a href="' . $rootpath . '/PDFQuotation.php?' . SID .'identifier='.$identifier . '&QuotationNo=' . $OrderNo . '">'. _('Print Quotation (Landscape)') .'</a></td></tr></table>'; + echo '<br><table class=selection><tr><td><img src="'.$rootpath.'/css/'.$theme.'/images/reports.png" title="' . _('Order') . '" alt=""></td><td>' . ' ' . '<a href="' . $rootpath . '/PDFQuotationPortrait.php?' . SID .'identifier='.$identifier . '&QuotationNo=' . $OrderNo . '">'. _('Print Quotation (Portrait)') .'</a></td></tr></table>'; } echo '<br><table class=selection><tr><td><img src="'.$rootpath.'/css/'.$theme.'/images/sales.png" title="' . _('Order') . '" alt=""></td><td>' . ' ' . '<a href="'. $rootpath .'/SelectOrderItems.php?identifier='.$identifier . '&NewOrder=Yes">'. _('Add Another Sales Order') .'</a></td></tr></table>'; } else { Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/GoodsReceived.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -516,11 +516,13 @@ loccode, serialno, qualitytext, + expirationdate, quantity) VALUES ('" . $OrderLine->StockID . "', '" . $_SESSION['PO'.$identifier]->Location . "', '" . $Item->BundleRef . "', '', + '" . FormatDateForSQL($Item->ExpiryDate) . "', '" . $Item->BundleQty . "')"; } Modified: trunk/GoodsReceivedControlled.php =================================================================== --- trunk/GoodsReceivedControlled.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/GoodsReceivedControlled.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -4,8 +4,6 @@ include('includes/DefinePOClass.php'); include('includes/DefineSerialItems.php'); -//$PageSecurity = 11; - include('includes/session.inc'); $title = _('Receive Controlled Items'); @@ -32,7 +30,7 @@ exit; } -if (isset($_GET['LineNo'])){ +if (isset($_GET['LineNo']) AND $_GET['LineNo']>0){ $LineNo = $_GET['LineNo']; } elseif (isset($_POST['LineNo'])){ $LineNo = $_POST['LineNo']; Modified: trunk/SelectCompletedOrder.php =================================================================== --- trunk/SelectCompletedOrder.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/SelectCompletedOrder.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -64,8 +64,16 @@ if (isset($OrderNumber)) { echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/sales.png" title="' . _('Sales Order') . '" alt="" />' . ' ' . _('Order Number') . ' - ' . $OrderNumber . '</p>'; + if (strlen($_SESSION['UserBranch'])>1){ + echo _('For customer') . ': ' . $SelectedCustomer; + echo "<input type=hidden name='SelectedCustomer' value='".$SelectedCustomer."'>"; + } } elseif (isset($CustomerRef)) { echo _('Customer Ref') . ' - ' . $CustomerRef; + if (strlen($_SESSION['UserBranch'])>1){ + echo ' ' . _('and for customer') . ': ' . $SelectedCustomer .' ' . _('and') . ' '; + echo "<input type=hidden name='SelectedCustomer' value='".$SelectedCustomer."'>"; + } } else { if (isset($SelectedCustomer)) { echo _('For customer') . ': ' . $SelectedCustomer .' ' . _('and') . ' '; @@ -212,13 +220,42 @@ $SelectedStockItem = $myrow[0]; $_POST['SearchOrders']='True'; unset($StockItemsResult); - echo '<br>' . _('For the part') . ': ' . $SelectedStockItem . ' ' . _('and') . " <input type=hidden name='SelectedStockItem' value='$SelectedStockItem'>"; + echo '<br />' . _('For the part') . ': ' . $SelectedStockItem . ' ' . _('and') . " <input type=hidden name='SelectedStockItem' value='$SelectedStockItem'>"; } } } else if (isset($_POST['SearchOrders']) AND Is_Date($_POST['OrdersAfterDate'])==1) { //figure out the SQL required from the inputs available if (isset($OrderNumber)) { + if (isset($SelectedCustomer)) { + $SQL = "SELECT salesorders.orderno, + debtorsmaster.name, + custbranch.brname, + salesorders.customerref, + salesorders.orddate, + salesorders.deliverydate, + salesorders.deliverto, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue + FROM salesorders, + salesorderdetails, + debtorsmaster, + custbranch + WHERE salesorders.orderno = salesorderdetails.orderno + AND salesorders.branchcode = custbranch.branchcode + AND salesorders.debtorno = debtorsmaster.debtorno + AND debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.debtorno='" . $SelectedCustomer ."' + AND salesorders.orderno='". $OrderNumber ."' + AND salesorders.quotation=0 + AND salesorderdetails.completed".$completed." + GROUP BY salesorders.orderno, + debtorsmaster.name, + custbranch.brname, + salesorders.customerref, + salesorders.orddate, + salesorders.deliverydate, + salesorders.deliverto + ORDER BY salesorders.orderno"; + } else { //Set order number and SelectedCustomer not set $SQL = "SELECT salesorders.orderno, debtorsmaster.name, custbranch.brname, @@ -245,7 +282,9 @@ salesorders.deliverydate, salesorders.deliverto ORDER BY salesorders.orderno"; + } } elseif (isset($CustomerRef)) { + if (isset($SelectedCustomer)) { $SQL = "SELECT salesorders.orderno, debtorsmaster.name, custbranch.brname, @@ -261,6 +300,7 @@ AND salesorders.branchcode = custbranch.branchcode AND salesorders.debtorno = debtorsmaster.debtorno AND debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.debtorno='" . $SelectedCustomer ."' AND salesorders.customerref like '%". $CustomerRef."%' AND salesorders.quotation=0 AND salesorderdetails.completed".$completed." @@ -272,6 +312,34 @@ salesorders.deliverydate, salesorders.deliverto ORDER BY salesorders.orderno"; + } else { //customer not selected + $SQL = "SELECT salesorders.orderno, + debtorsmaster.name, + custbranch.brname, + salesorders.customerref, + salesorders.orddate, + salesorders.deliverydate, + salesorders.deliverto, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue + FROM salesorders, + salesorderdetails, + debtorsmaster, + custbranch + WHERE salesorders.orderno = salesorderdetails.orderno + AND salesorders.branchcode = custbranch.branchcode + AND salesorders.debtorno = debtorsmaster.debtorno + AND debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.customerref like '%". $CustomerRef."%' + AND salesorders.quotation=0 + AND salesorderdetails.completed".$completed." + GROUP BY salesorders.orderno, + debtorsmaster.name, + custbranch.brname, + salesorders.customerref, + salesorders.orddate, + salesorders.deliverydate, + salesorders.deliverto + ORDER BY salesorders.orderno"; + } } else { $DateAfterCriteria = FormatDateforSQL($_POST['OrdersAfterDate']); @@ -399,8 +467,8 @@ $SalesOrdersResult = DB_query($SQL,$db); if (DB_error_no($db) !=0) { - echo '<br>' . _('No orders were returned by the SQL because') . ' ' . DB_error_msg($db); - echo "<br>$SQL"; + echo '<br />' . _('No orders were returned by the SQL because') . ' ' . DB_error_msg($db); + echo "<br />$SQL"; } }//end of which button clicked options @@ -416,22 +484,22 @@ echo "<tr><td></td>"; } -if (!isset($OrderNumber) or $OrderNumber==''){ - echo '<td>' . _('Order Number') . ':</td><td>' . "<input type='text' name='OrderNumber' maxlength =8 size=9></td><td>" . _('for all orders placed after') . - ": </td><td><input type='text' class='date' alt='".$_SESSION['DefaultDateFormat']."' name='OrdersAfterDate' maxlength =10 size=11 value=" . $_POST['OrdersAfterDate'] . "></td><td>" . - "<input type='submit' name='SearchOrders' value='" . _('Search Orders') . "'></td></tr>"; - echo '<tr><td></td><td>' . _('Customer Ref') . ':</td><td>' . "<input type='text' name='CustomerRef' maxlength =8 size=9></td> +echo '<td>' . _('Order Number') . ':</td> + <td>' . "<input type='text' name='OrderNumber' maxlength =8 size=9 value ='" . $_POST['OrderNumber'] . "'></td> + <td>" . _('for all orders placed after') . ": </td><td><input type='text' class='date' alt='".$_SESSION['DefaultDateFormat']."' name='OrdersAfterDate' maxlength =10 size=11 value=" . $_POST['OrdersAfterDate'] . "></td> + <td>" . "<input type='submit' name='SearchOrders' value='" . _('Search Orders') . "'></td></tr>"; +echo '<tr><td></td><td>' . _('Customer Ref') . ':</td><td>' . "<input type='text' name='CustomerRef' maxlength =8 size=9></td> <td></td><td colspan=2><input type='checkbox' ".$ShowChecked." name='completed' />"._('Show Completed orders only') . "</td></tr>"; -} + echo '</table>'; if (!isset($SelectedStockItem)) { $SQL='SELECT categoryid, categorydescription FROM stockcategory ORDER BY categorydescription'; $result1 = DB_query($SQL,$db); - echo '<br>'; + echo '<br />'; echo '<div class="page_help_text"><font size=1>' . _('To search for sales orders for a specific part use the part selection facilities below') . ' </font></div>'; - echo '<br><table class=selection>'; + echo '<br /><table class=selection>'; echo '<tr><td><font size=1>' . _('Select a stock category') . ':</font>'; echo '<select name="StockCat">'; @@ -461,7 +529,7 @@ If (isset($StockItemsResult)) { - echo '<br><table cellpadding=2 colspan=7 class=selection>'; + echo '<br /><table cellpadding=2 colspan=7 class=selection>'; $TableHeadings = "<tr><th>" . _('Code') . "</th>" . "<th>" . _('Description') . "</th>" . @@ -511,7 +579,7 @@ /*show a table of the orders returned by the SQL */ - echo '<br><table cellpadding=2 colspan=6 width=90% class=selection>'; + echo '<br /><table cellpadding=2 colspan=6 width=90% class=selection>'; $tableheader = "<tr><th>" . _('Order') . " #</th> <th>" . _('Customer') . "</th> Modified: trunk/SelectCustomer.php =================================================================== --- trunk/SelectCustomer.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/SelectCustomer.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -1,6 +1,6 @@ <?php /* $Id$*/ -//$PageSecurity = 2; + include ('includes/session.inc'); $title = _('Search Customers'); include ('includes/header.inc'); @@ -119,8 +119,9 @@ custbranch.phoneno, custbranch.faxno FROM debtorsmaster LEFT JOIN custbranch - ON debtorsmaster.debtorno = custbranch.debtorno, debtortype - WHERE debtorsmaster.typeid = debtortype.typeid"; + ON debtorsmaster.debtorno = custbranch.debtorno + INNER JOIN debtortype + ON debtorsmaster.typeid = debtortype.typeid"; } else { if (strlen($_POST['Keywords']) > 0) { //using the customer name Modified: trunk/SelectSupplier.php =================================================================== --- trunk/SelectSupplier.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/SelectSupplier.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -166,7 +166,7 @@ echo '</td><td valign=top class="select">'; /* Supplier Transactions */ echo "<a href=\"$rootpath/PO_Header.php?" . SID . '&NewOrder=Yes&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Purchase Order for This Supplier') . '</a><br>'; echo "<a href=\"$rootpath/SupplierInvoice.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Suppliers Invoice') . '</a><br>'; - echo "<a href=\"$rootpath/SupplierCredit.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Suppliers Credit Note') . '</a><br>'; + echo "<a href=\"$rootpath/SupplierCredit.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . '&New=True' . "\">" . _('Enter a Suppliers Credit Note') . '</a><br>'; echo "<a href=\"$rootpath/Payments.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Payment to, or Receipt from the Supplier') . '</a><br>'; echo '<br>'; echo "<br><a href='$rootpath/ReverseGRN.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "'>" . _('Reverse an Outstanding Goods Received Note (GRN)') . '</a>'; Modified: trunk/StockCheck.php =================================================================== --- trunk/StockCheck.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/StockCheck.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -175,8 +175,9 @@ $FontSize=10; $YPos -=$line_height; - if ($_POST['ShowInfo']==true){ + if (isset($_POST['ShowInfo']) and $_POST['ShowInfo']==true){ + $SQL = "SELECT SUM(salesorderdetails.quantity - salesorderdetails.qtyinvoiced) AS qtydemand FROM salesorderdetails, salesorders Modified: trunk/StockSerialItems.php =================================================================== --- trunk/StockSerialItems.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/StockSerialItems.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -1,8 +1,8 @@ <?php /* $Id$*/ -//$PageSecurity = 2; + include('includes/session.inc'); $title = _('Stock Of Controlled Items'); include('includes/header.inc'); @@ -28,21 +28,23 @@ mbflag, decimalplaces, serialised, - controlled + controlled, + perishable FROM stockmaster WHERE stockid='".$StockID."'", $db, _('Could not retrieve the requested item because')); -$myrow = DB_fetch_row($result); +$myrow = DB_fetch_array($result); -$Description = $myrow[0]; -$UOM = $myrow[1]; -$DecimalPlaces = $myrow[3]; -$Serialised = $myrow[4]; -$Controlled = $myrow[5]; +$Description = $myrow['description']; +$UOM = $myrow['units']; +$DecimalPlaces = $myrow['decimalplaces']; +$Serialised = $myrow['serialised']; +$Controlled = $myrow['controlled']; +$Perishable = $myrow['perishable']; -if ($myrow[2]=='K' OR $myrow[2]=='A' OR $myrow[2]=='D'){ +if ($myrow['mbflag']=='K' OR $myrow['mbflag']=='A' OR $myrow['mbflag']=='D'){ prnMsg(_('This item is either a kitset or assembly or a dummy part and cannot have a stock holding') . '. ' . _('This page cannot be displayed') . '. ' . _('Only serialised or controlled items can be displayed in this page'),'error'); include('includes/footer.inc'); @@ -59,7 +61,8 @@ $myrow = DB_fetch_row($result); $sql = "SELECT serialno, - quantity + quantity, + expirationdate FROM stockserialitems WHERE loccode='" . $_GET['Location'] . "' AND stockid = '" . $StockID . "' @@ -72,30 +75,48 @@ echo '<table cellpadding=2 class=selection>'; if ($Serialised==1){ - echo '<tr<th colspan=3><font color=navy size=2>' . _('Serialised items in') . ' '; + echo '<tr><th colspan="5"><font color=navy size=2>' . _('Serialised items in') . ' '; } else { - echo '<tr<th colspan=3><font color=navy size=2>' . _('Controlled items in') . ' '; + echo '<tr><th colspan="11"><font color=navy size=2>' . _('Controlled items in') . ' '; } echo $myrow[0]. '</font></th></tr>'; -echo "<tr><th colspan=3><font color=navy size=2>".$StockID ."-". $Description ."</b> (" . _('In units of') . ' ' . $UOM . ')</font></th></tr>'; +echo "<tr><th colspan=11><font color=navy size=2>".$StockID ."-". $Description ."</b> (" . _('In units of') . ' ' . $UOM . ')</font></th></tr>'; if ($Serialised == 1){ - $tableheader = "<tr> - <th>" . _('Serial Number') . "</th> - <th>" . _('Serial Number') . "</th> - <th>" . _('Serial Number') . "</th> - </tr>"; -} else { - $tableheader = "<tr> - <th>" . _('Batch/Bundle Ref') . "</th> - <th>" . _('Quantity On Hand') . "</th> - <th>" . _('Batch/Bundle Ref') . "</th> - <th>" . _('Quantity On Hand') . "</th> - <th>" . _('Batch/Bundle Ref') . "</th> - <th>" . _('Quantity On Hand') . "</th> + $tableheader = '<tr> + <th>' . _('Serial Number') . '</th> + <th></th> + <th>' . _('Serial Number') . '</th> + <th></th> + <th>' . _('Serial Number') . '</th> + </tr>'; +} else if ($Serialised == 0 and $Perishable==0){ + $tableheader = '<tr> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> + <th></th> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> + <th></th> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> </tr>"; +} else if ($Serialised == 0 and $Perishable==1){ + $tableheader = '<tr> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> + <th>' . _('Expiry Date') . '</th> + <th></th> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> + <th>' . _('Expiry Date') . '</th> + <th></th> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> + <th>' . _('Expiry Date') . '</th> + </tr>'; } echo $tableheader; $TotalQuantity =0; @@ -115,15 +136,17 @@ $TotalQuantity += $myrow['quantity']; if ($Serialised == 1){ - printf('<td>%s</td>', - $myrow['serialno'] - ); - } else { - printf("<td>%s</td> - <td class=number>%s</td>", - $myrow['serialno'], - number_format($myrow['quantity'],$DecimalPlaces) - ); + echo '<td>'.$myrow['serialno'].'/td>'; + echo '<th></th>'; + } else if ($Serialised == 0 and $Perishable==0) { + echo '<td>'.$myrow['serialno'].'</td> + <td class="number">'.number_format($myrow['quantity'],$DecimalPlaces).'</td>'; + echo '<th></th>'; + } else if ($Serialised == 0 and $Perishable==1){ + echo '<td>'.$myrow['serialno'].'</td> + <td class="number">'.number_format($myrow['quantity'],$DecimalPlaces). '</td> + <td>' . ConvertSQLDate($myrow['expirationdate']). '</td>'; + echo '<th></th>'; } $j++; If ($j == 36){ @@ -144,5 +167,4 @@ echo '</form>'; include('includes/footer.inc'); - ?> \ No newline at end of file Modified: trunk/SupplierCredit.php =================================================================== --- trunk/SupplierCredit.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/SupplierCredit.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -35,6 +35,10 @@ //this is available from the menu on this page already //echo "<a href='" . $rootpath . '/SelectSupplier.php?' . SID . "'>" . _('Back to Suppliers') . '</a><br>'; +if (isset($_GET['New'])) { + unset($_SESSION['SuppTrans']); +} + if (!isset($_SESSION['SuppTrans']->SupplierName)) { $sql='SELECT suppname FROM suppliers WHERE supplierid="'.$_GET['SupplierID'].'"'; $result = DB_query($sql,$db); Modified: trunk/Suppliers.php =================================================================== --- trunk/Suppliers.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/Suppliers.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -444,11 +444,11 @@ } if (!isset($_POST['New'])) { - $supptranssql = "SELECT COUNT(supplierno) - FROM supptrans - WHERE supplierno='".$SupplierID ."'"; + $supptranssql = "SELECT supplierno + FROM supptrans + WHERE supplierno='".$SupplierID ."'"; $suppresult = DB_query($supptranssql, $db); - $supptrans = DB_fetch_row($suppresult); + $supptrans = DB_num_rows($suppresult); $suppcurrssql = "SELECT currcode FROM suppliers @@ -481,7 +481,7 @@ WHERE supplierid = '".$SupplierID."'"; } else { if ($suppcurr[0] != $_POST['CurrCode']) { - prnMsg( _('Cannot change currency code as transactions already exist'), info); + prnMsg( _('Cannot change currency code as transactions already exist'), 'info'); } $sql = "UPDATE suppliers SET suppname='" . $_POST['SuppName'] . "', address1='" . $_POST['Address1'] . "', Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/doc/Change.log.html 2011-03-03 09:13:12 UTC (rev 4501) @@ -1,6 +1,9 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> -<p>27/2/11: Phil/Tim/Peter launchpad added category option for MRPShortages.php </p> +<p>3/3/11: Exson/Baran/Phil fix to customer login to ensure that other customers orders are not displayed when searching by customer ref or order no</p> +<p>3/3/11: Tim launchpad mods to revision 4441 including change to allow supplier currency to be changed if there are no transactions already against the supplier. Ensure credit note session variable is unset before attempting to create a new credit note from the supplier form. Tim's work to add perisable expiry dates to the serial items logic - affects quite a few scripts. Headings to stock check script even if no quantity is shown. Portrait quotations. Not included change to default delivery date to the date the customer requested - left to be the current day's date. Not included Tim's unit pricing work .. yet launchpad revisions 4442-4447 inclusive</p> +<p>27/2/11: Phil/Tim/Peter launchpad added category option for MRPShortages.php links with matching quotes in WorkOrderEntry</p> +<p>27/2/11: Phil StockUsage.php now totals usage each month even in months where there was none - average now includes months with no usage</p> <p>27/2/11: Phil fix units deletion issue reported by Exson in UnitsOfMeasure.php script - checked for none existant units field in contracts table - removed the check</p> <p>22/2/11: Phil fix PDFTopItems.php for changed variable names - now using CamelCase tried to rework to conform</p> <p>22/2/11: Phil remove options for PDFLanguage that are not unique in WWW_Users.php - make it default to the users settings in the SESSION for UserSettings.php</p> Modified: trunk/includes/Add_SerialItems.php =================================================================== --- trunk/includes/Add_SerialItems.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/Add_SerialItems.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -66,7 +66,7 @@ } if (!$SerialError){ - $LineItem->SerialItems[$NewSerialNo] = new SerialItem ($_POST['SerialNo' . $i], $NewQty); + $LineItem->SerialItems[$NewSerialNo] = new SerialItem ($_POST['SerialNo' . $i], $NewQty, $_POST['ExpiryDate' . $i]); } } } /* end if posted Serialno . i is not blank */ @@ -75,7 +75,8 @@ if (!isset($_POST['Bundles'])) { $_POST['Bundles']=0; } - for ($i=0;$i < count($_POST['Bundles']);$i++){ /*there is an entry in the multi select list box */ + echo count($_POST['Bundles']); + for ($i=0;$i < count($_POST['Bundles'])-1;$i++){ /*there is an entry in the multi select list box */ if ($LineItem->Serialised==1){ /*only if the item is serialised */ $LineItem->SerialItems[$_POST['Bundles'][$i]] = new SerialItem ($_POST['Bundles'][$i], ($InOutModifier>0?1:-1) ); } else { Modified: trunk/includes/Add_SerialItemsOut.php =================================================================== --- trunk/includes/Add_SerialItemsOut.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/Add_SerialItemsOut.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -3,11 +3,10 @@ /*ProcessSerialItems.php takes the posted variables and adds to the SerialItems array in either the cartclass->LineItems->SerialItems or the POClass->LineItems->SerialItems */ - if (isset($_POST['AddBatches'])){ for ($i=0;$i < 10;$i++){ - if(strlen($_POST['SerialNo' . $i])>0){ + if(isset($_POST['SerialNo' . $i]) and strlen($_POST['SerialNo' . $i])>0){ $ExistingBundleQty = ValidBundleRef($StockID, $LocationOut, $_POST['SerialNo' . $i]); if ($ExistingBundleQty >0){ $AddThisBundle = true; @@ -15,30 +14,31 @@ the first entered one - no warning given though ? */ if ($_POST['Qty' . $i] > $ExistingBundleQty){ if ($LineItem->Serialised ==1){ - echo "<BR>" . $_POST['SerialNo' . $i] . " " . _('has already been sold'); + echo "<br />" . $_POST['SerialNo' . $i] . " " . _('has already been sold'); $AddThisBundle = false; } elseif ($ExistingBundleQty==0) { /* and its a batch */ - echo "<BR>There is none of " . $_POST['SerialNo' . $i] . " left."; + echo "<br />There is none of " . $_POST['SerialNo' . $i] . " left."; $AddThisBundle = false; } else { - echo '<BR>' . _('There is only') . ' ' . $ExistingBundleQty . ' ' . _('of') . ' ' . $_POST['SerialNo' . $i] . ' ' . _('remaining') . '. ' . _('The entered quantity will be reduced to the remaining amount left of this batch/bundle/roll'); + echo '<br />' . _('There is only') . ' ' . $ExistingBundleQty . ' ' . _('of') . ' ' . $_POST['SerialNo' . $i] . + ' ' . _('remaining') . '. ' . _('The entered quantity will be reduced to the remaining amount left of this batch/bundle/roll'); $_POST['Qty' . $i] = $ExistingBundleQty; $AddThisBundle = true; } } - if ($AddThisBundle==true){ - $LineItem->SerialItems[$_POST['SerialNo' . $i]] = new SerialItem ($_POST['SerialNo' . $i], $_POST['Qty' . $i]); + if ($AddThisBundle==true and $_POST['Qty' . $i]>0){ + $LineItem->SerialItems[$_POST['SerialNo' . $i]] = new SerialItem ($_POST['SerialNo' . $i], $_POST['Qty' . $i], $_POST['ExpiryDate' . $i]); } } /*end if ExistingBundleQty >0 */ } /* end if posted Serialno . i is not blank */ } /* end of the loop aroung the form input fields */ - for ($i=0;$i < count($_POST['Bundles']);$i++){ /*there is an entry in the multi select list box */ - if ($LineItem->Serialised==1){ /*only if the item is serialised */ - $LineItem->SerialItems[$_POST['Bundles'][$i]] = new SerialItem ($_POST['Bundles'][$i], 1); - } - } +// for ($i=0;$i < count($_POST['Bundles']);$i++){ /*there is an entry in the multi select list box */ +// if ($LineItem->Serialised==1){ /*only if the item is serialised */ +// $LineItem->SerialItems[$_POST['Bundles'][$i]] = new SerialItem ($_POST['Bundles'][$i], 1); +// } +// } } /*end if the user hit the enter button */ @@ -47,4 +47,8 @@ unset($LineItem->SerialItems[$_GET['Delete']]); } +if (isset($_GET['DELETEALL'])){ + $LineItem->SerialItems=array(); +} + ?> Modified: trunk/includes/DefineSerialItems.php =================================================================== --- trunk/includes/DefineSerialItems.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/DefineSerialItems.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -4,10 +4,10 @@ function ValidBundleRef ($StockID, $LocCode, $BundleRef){ global $db; - $SQL = "SELECT quantity - FROM stockserialitems - WHERE stockid='" . $StockID . "' - AND loccode ='" . $LocCode . "' + $SQL = "SELECT quantity + FROM stockserialitems + WHERE stockid='" . $StockID . "' + AND loccode ='" . $LocCode . "' AND serialno='" . $BundleRef . "'"; $Result = DB_query($SQL, $db); if (DB_num_rows($Result)==0){ @@ -22,12 +22,14 @@ var $BundleRef; var $BundleQty; + var $ExpiryDate; //Constructor - function SerialItem($BundleRef, $BundleQty){ + function SerialItem($BundleRef, $BundleQty, $ExpiryDate='0000-00-00'){ $this->BundleRef = $BundleRef; $this->BundleQty = $BundleQty; + $this->ExpiryDate = $ExpiryDate; } }//class SerialItem ?> \ No newline at end of file Modified: trunk/includes/InputSerialItems.php =================================================================== --- trunk/includes/InputSerialItems.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/InputSerialItems.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -88,15 +88,27 @@ '&LineNo=' . $LineNo .'">'. _('Edit'). '</a> | '; $RemoveLink = '<a href="' . $_SERVER['PHP_SELF'] . '?identifier=' . $identifier . '&DELETEALL=YES&StockID=' . $LineItem->StockID . '&LineNo=' . $LineNo .'">'. _('Remove All'). '</a><br></div>'; +$sql="SELECT perishable + FROM stockmaster + WHERE stockid='".$StockID."'"; +$result=DB_query($sql, $db); +$myrow=DB_fetch_array($result); +$Perishable=$myrow['perishable']; if ($LineItem->Serialised==1){ $tableheader .= '<tr> <th>'. _('Serial No').'</th> - </Tr>'; + </tr>'; +} else if ($LineItem->Serialised==0 and $Perishable==1){ + $tableheader = '<tr> + <th>'. _('Batch/Roll/Bundle'). ' #</th> + <th>'. _('Quantity'). '</th> + <th>'. _('Expiry Date'). '</th> + </tr>'; } else { - $tableheader = '<TR> + $tableheader = '<tr> <th>'. _('Batch/Roll/Bundle'). ' #</th> - <th class=tableheader>'. _('Quantity'). '</th> - </tr>'; + <th>'. _('Quantity'). '</th> + </tr>'; } echo $EditLink . $RemoveLink; Modified: trunk/includes/InputSerialItemsKeyed.php =================================================================== --- trunk/includes/InputSerialItemsKeyed.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/InputSerialItemsKeyed.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -47,8 +47,11 @@ echo '<td>' . $Bundle->BundleRef . '</td>'; - if ($LineItem->Serialised==0){ + if ($LineItem->Serialised==0 and $Perishable==0){ echo '<td class=number>' . number_format($Bundle->BundleQty, $LineItem->DecimalPlaces) . '</td>'; + } else if ($LineItem->Serialised==0 and $Perishable==1){ + echo '<td class=number>' . number_format($Bundle->BundleQty, $LineItem->DecimalPlaces) . '</td>'; + echo '<td class=number>' . $Bundle->ExpiryDate . '</td>'; } echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?identifier=' . $identifier . '&Delete=' . $Bundle->BundleRef . '&StockID=' . $LineItem->StockID . '&LineNo=' . $LineNo .'">'. _('Delete'). '</a></td></tr>'; @@ -81,7 +84,7 @@ <input type=hidden name=StockID value="' . $StockID . '"> <input type=hidden name="identifier" value="' . $identifier . '"> <input type=hidden name=EntryType value="KEYED">'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; +echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; if ( isset($_GET['EditControlled']) ) { $EditControlled = isset($_GET['EditControlled'])?$_GET['EditControlled']:false; } elseif ( isset($_POST['EditControlled']) ){ @@ -102,6 +105,9 @@ if ($LineItem->Serialised==1){ echo '<input type=hidden name="Qty' . $StartAddingAt .'" Value=1></TR>'; + } else if ($LineItem->Serialised==0 and $Perishable==1) { + echo '<td><input type=text class="number" name="Qty' . $StartAddingAt .'" size=11 + value="'. number_format($Bundle->BundleQty, $LineItem->DecimalPlaces). '" maxlength=10></tr>'; } else { echo '<td><input type=text class="number" name="Qty' . $StartAddingAt .'" size=11 value="'. number_format($Bundle->BundleQty, $LineItem->DecimalPlaces). '" maxlength=10></tr>'; @@ -120,6 +126,10 @@ if ($LineItem->Serialised==1){ echo '<input type=hidden name="Qty' . ($StartAddingAt+$i) .'" Value=1></tr>'; + } else if ($LineItem->Serialised==0 and $Perishable==1) { + echo '<td><input type=text class="number" name="Qty' . ($StartAddingAt+$i) .'" size=11 maxlength=10></td>'; + echo '<td><input type=text class="date" name="ExpiryDate' . ($StartAddingAt+$i) .'" size=11 + value="" alt="'.$_SESSION['DefaultDateFormat'].'" maxlength=10></td></tr>'; } else { echo '<td><input type=text class="number" name="Qty' . ($StartAddingAt+$i) .'" size=11 maxlength=10></tr>'; } @@ -136,4 +146,4 @@ document.Ga6uF5Wa.SerialNo0.focus(); //]]> </script>'; /*end of nested table */ -?> +?> \ No newline at end of file Modified: trunk/includes/PDFStockCheckPageHeader.inc =================================================================== --- trunk/includes/PDFStockCheckPageHeader.inc 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/PDFStockCheckPageHeader.inc 2011-03-03 09:13:12 UTC (rev 4501) @@ -28,16 +28,22 @@ $Xpos = $Left_Margin+1; /*draw vertical lines */ -$pdf->line(350, $YPos-$line_height,350, $Bottom_Margin+24); -$pdf->line(415, $YPos-$line_height,415, $Bottom_Margin+24); -$pdf->line(475, $YPos-$line_height,475, $Bottom_Margin+24); +$pdf->line(370, $YPos+$BoxHeight,370, $Bottom_Margin+24); $LeftOvers = $pdf->addTextWrap($Xpos,$YPos,300-$Left_Margin,$FontSize,_('Item'), 'centre'); -if ($_POST['ShowInfo']==true){ +if (isset($_POST['ShowInfo']) and $_POST['ShowInfo']==true){ + /*draw vertical lines */ + $pdf->line(415, $YPos-$line_height,415, $Bottom_Margin+24); + $pdf->line(475, $YPos-$line_height,475, $Bottom_Margin+24); $LeftOvers = $pdf->addTextWrap(341,$YPos,60,$FontSize,_('QOH'), 'centre'); $LeftOvers = $pdf->addTextWrap(341+61,$YPos,80,$FontSize,_('Cust Ords'), 'centre'); $LeftOvers = $pdf->addTextWrap(341+61+61,$YPos,80,$FontSize,_('Available'), 'centre'); - } +} else { + /*draw vertical lines */ + $pdf->line(435, $YPos+$BoxHeight,435, $Bottom_Margin+24); + $LeftOvers = $pdf->addTextWrap(371,$YPos,60,$FontSize,_('Quantity'), 'centre'); + $LeftOvers = $pdf->addTextWrap(341+61+61,$YPos,80,$FontSize,_('Remarks'), 'centre'); +} $FontSize=10; $YPos -=($line_height); ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-03-03 09:13:19
|
Revision: 4501 http://web-erp.svn.sourceforge.net/web-erp/?rev=4501&view=rev Author: daintree Date: 2011-03-03 09:13:12 +0000 (Thu, 03 Mar 2011) Log Message: ----------- Tim launchpad revisions to 4441 excluding price units stuff Modified Paths: -------------- trunk/ConfirmDispatchControlled_Invoice.php trunk/ConfirmDispatch_Invoice.php trunk/DeliveryDetails.php trunk/GoodsReceived.php trunk/GoodsReceivedControlled.php trunk/SelectCompletedOrder.php trunk/SelectCustomer.php trunk/SelectSupplier.php trunk/StockCheck.php trunk/StockSerialItems.php trunk/SupplierCredit.php trunk/Suppliers.php trunk/doc/Change.log.html trunk/includes/Add_SerialItems.php trunk/includes/Add_SerialItemsOut.php trunk/includes/DefineSerialItems.php trunk/includes/InputSerialItems.php trunk/includes/InputSerialItemsKeyed.php trunk/includes/PDFStockCheckPageHeader.inc Modified: trunk/ConfirmDispatchControlled_Invoice.php =================================================================== --- trunk/ConfirmDispatchControlled_Invoice.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/ConfirmDispatchControlled_Invoice.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -66,7 +66,7 @@ $InOutModifier=1; $ShowExisting=false; -include ('includes/InputSerialItems.php'); +include ('includes/OutputSerialItems.php'); /*TotalQuantity set inside this include file from the sum of the bundles of the item selected for dispatch */ Modified: trunk/ConfirmDispatch_Invoice.php =================================================================== --- trunk/ConfirmDispatch_Invoice.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/ConfirmDispatch_Invoice.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -219,18 +219,24 @@ } foreach ($_SESSION['Items']->LineItems as $Itm) { - if (is_numeric($_POST[$Itm->LineNumber . '_QtyDispatched' ])AND $_POST[$Itm->LineNumber . '_QtyDispatched'] <= ($_SESSION['Items']->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyInv)){ + if (sizeOf($Itm->SerialItems) > 0) { + $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched = 0; //initialise QtyDispatched + foreach ($Itm->SerialItems as $SerialItem) { //calculate QtyDispatched from bundle quantities + $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched += $SerialItem->BundleQty; + } + } else if (is_numeric($_POST[$Itm->LineNumber . '_QtyDispatched' ])AND $_POST[$Itm->LineNumber . '_QtyDispatched'] <= ($_SESSION['Items']->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyInv)){ $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched = $_POST[$Itm->LineNumber . '_QtyDispatched']; } + + foreach ($Itm->Taxes as $TaxLine) { if (isset($_POST[$Itm->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate'])){ $_SESSION['Items']->LineItems[$Itm->LineNumber]->Taxes[$TaxLine->TaxCalculationOrder]->TaxRate = $_POST[$Itm->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate']/100; } } + } //end foreach lineitem - } - } /* Always display dispatch quantities and recalc freight for items being dispatched */ @@ -382,15 +388,15 @@ echo '<td class="number">'.$DisplayTaxAmount.'</td><td class="number">'.$DisplayGrossLineTotal.'</td>'; if ($LnItm->Controlled==1){ - - echo '<td><a href="' . $rootpath . '/ConfirmDispatchControlled_Invoice.php?' . SID . '&LineNo='. $LnItm->LineNumber.'">'; - - if ($LnItm->Serialised==1){ - echo _("Enter Serial Numbers"); - } else { /*Just batch/roll/lot control */ - echo _('Enter Batch/Roll/Lot #'); + if (!isset($_POST['ProcessInvoice'])) { + echo '<td><a href="' . $rootpath . '/ConfirmDispatchControlled_Invoice.php?' . SID . '&LineNo='. $LnItm->LineNumber.'">'; + if ($LnItm->Serialised==1){ + echo _('Enter Serial Numbers'); + } else { /*Just batch/roll/lot control */ + echo _('Enter Batch/Roll/Lot #'); + } + echo '</a></td>'; } - echo '</a></td>'; } echo '</tr>'; if (strlen($LnItm->Narrative)>1){ @@ -717,7 +723,7 @@ /*Start an SQL transaction */ -DB_Txn_Begin($db); + DB_Txn_Begin($db); if ($DefaultShipVia != $_SESSION['Items']->ShipVia){ $SQL = "UPDATE custbranch Modified: trunk/DeliveryDetails.php =================================================================== --- trunk/DeliveryDetails.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/DeliveryDetails.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -580,8 +580,8 @@ } else { /*link to print the quotation */ - echo '<br><table class=selection><tr><td><img src="'.$rootpath.'/css/'.$theme.'/images/reports.png" title="' . _('Order') . '" alt=""></td><td>' . ' ' . '<a href="' . $rootpath . '/PDFQuotation.php?identifier='.$identifier . '&QuotationNo=' . $OrderNo . '">'. _('Print Quotation') .'</a></td></tr></table>'; - + echo '<br><table class=selection><tr><td><img src="'.$rootpath.'/css/'.$theme.'/images/reports.png" title="' . _('Order') . '" alt=""></td><td>' . ' ' . '<a href="' . $rootpath . '/PDFQuotation.php?' . SID .'identifier='.$identifier . '&QuotationNo=' . $OrderNo . '">'. _('Print Quotation (Landscape)') .'</a></td></tr></table>'; + echo '<br><table class=selection><tr><td><img src="'.$rootpath.'/css/'.$theme.'/images/reports.png" title="' . _('Order') . '" alt=""></td><td>' . ' ' . '<a href="' . $rootpath . '/PDFQuotationPortrait.php?' . SID .'identifier='.$identifier . '&QuotationNo=' . $OrderNo . '">'. _('Print Quotation (Portrait)') .'</a></td></tr></table>'; } echo '<br><table class=selection><tr><td><img src="'.$rootpath.'/css/'.$theme.'/images/sales.png" title="' . _('Order') . '" alt=""></td><td>' . ' ' . '<a href="'. $rootpath .'/SelectOrderItems.php?identifier='.$identifier . '&NewOrder=Yes">'. _('Add Another Sales Order') .'</a></td></tr></table>'; } else { Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/GoodsReceived.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -516,11 +516,13 @@ loccode, serialno, qualitytext, + expirationdate, quantity) VALUES ('" . $OrderLine->StockID . "', '" . $_SESSION['PO'.$identifier]->Location . "', '" . $Item->BundleRef . "', '', + '" . FormatDateForSQL($Item->ExpiryDate) . "', '" . $Item->BundleQty . "')"; } Modified: trunk/GoodsReceivedControlled.php =================================================================== --- trunk/GoodsReceivedControlled.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/GoodsReceivedControlled.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -4,8 +4,6 @@ include('includes/DefinePOClass.php'); include('includes/DefineSerialItems.php'); -//$PageSecurity = 11; - include('includes/session.inc'); $title = _('Receive Controlled Items'); @@ -32,7 +30,7 @@ exit; } -if (isset($_GET['LineNo'])){ +if (isset($_GET['LineNo']) AND $_GET['LineNo']>0){ $LineNo = $_GET['LineNo']; } elseif (isset($_POST['LineNo'])){ $LineNo = $_POST['LineNo']; Modified: trunk/SelectCompletedOrder.php =================================================================== --- trunk/SelectCompletedOrder.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/SelectCompletedOrder.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -64,8 +64,16 @@ if (isset($OrderNumber)) { echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/sales.png" title="' . _('Sales Order') . '" alt="" />' . ' ' . _('Order Number') . ' - ' . $OrderNumber . '</p>'; + if (strlen($_SESSION['UserBranch'])>1){ + echo _('For customer') . ': ' . $SelectedCustomer; + echo "<input type=hidden name='SelectedCustomer' value='".$SelectedCustomer."'>"; + } } elseif (isset($CustomerRef)) { echo _('Customer Ref') . ' - ' . $CustomerRef; + if (strlen($_SESSION['UserBranch'])>1){ + echo ' ' . _('and for customer') . ': ' . $SelectedCustomer .' ' . _('and') . ' '; + echo "<input type=hidden name='SelectedCustomer' value='".$SelectedCustomer."'>"; + } } else { if (isset($SelectedCustomer)) { echo _('For customer') . ': ' . $SelectedCustomer .' ' . _('and') . ' '; @@ -212,13 +220,42 @@ $SelectedStockItem = $myrow[0]; $_POST['SearchOrders']='True'; unset($StockItemsResult); - echo '<br>' . _('For the part') . ': ' . $SelectedStockItem . ' ' . _('and') . " <input type=hidden name='SelectedStockItem' value='$SelectedStockItem'>"; + echo '<br />' . _('For the part') . ': ' . $SelectedStockItem . ' ' . _('and') . " <input type=hidden name='SelectedStockItem' value='$SelectedStockItem'>"; } } } else if (isset($_POST['SearchOrders']) AND Is_Date($_POST['OrdersAfterDate'])==1) { //figure out the SQL required from the inputs available if (isset($OrderNumber)) { + if (isset($SelectedCustomer)) { + $SQL = "SELECT salesorders.orderno, + debtorsmaster.name, + custbranch.brname, + salesorders.customerref, + salesorders.orddate, + salesorders.deliverydate, + salesorders.deliverto, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue + FROM salesorders, + salesorderdetails, + debtorsmaster, + custbranch + WHERE salesorders.orderno = salesorderdetails.orderno + AND salesorders.branchcode = custbranch.branchcode + AND salesorders.debtorno = debtorsmaster.debtorno + AND debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.debtorno='" . $SelectedCustomer ."' + AND salesorders.orderno='". $OrderNumber ."' + AND salesorders.quotation=0 + AND salesorderdetails.completed".$completed." + GROUP BY salesorders.orderno, + debtorsmaster.name, + custbranch.brname, + salesorders.customerref, + salesorders.orddate, + salesorders.deliverydate, + salesorders.deliverto + ORDER BY salesorders.orderno"; + } else { //Set order number and SelectedCustomer not set $SQL = "SELECT salesorders.orderno, debtorsmaster.name, custbranch.brname, @@ -245,7 +282,9 @@ salesorders.deliverydate, salesorders.deliverto ORDER BY salesorders.orderno"; + } } elseif (isset($CustomerRef)) { + if (isset($SelectedCustomer)) { $SQL = "SELECT salesorders.orderno, debtorsmaster.name, custbranch.brname, @@ -261,6 +300,7 @@ AND salesorders.branchcode = custbranch.branchcode AND salesorders.debtorno = debtorsmaster.debtorno AND debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.debtorno='" . $SelectedCustomer ."' AND salesorders.customerref like '%". $CustomerRef."%' AND salesorders.quotation=0 AND salesorderdetails.completed".$completed." @@ -272,6 +312,34 @@ salesorders.deliverydate, salesorders.deliverto ORDER BY salesorders.orderno"; + } else { //customer not selected + $SQL = "SELECT salesorders.orderno, + debtorsmaster.name, + custbranch.brname, + salesorders.customerref, + salesorders.orddate, + salesorders.deliverydate, + salesorders.deliverto, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue + FROM salesorders, + salesorderdetails, + debtorsmaster, + custbranch + WHERE salesorders.orderno = salesorderdetails.orderno + AND salesorders.branchcode = custbranch.branchcode + AND salesorders.debtorno = debtorsmaster.debtorno + AND debtorsmaster.debtorno = custbranch.debtorno + AND salesorders.customerref like '%". $CustomerRef."%' + AND salesorders.quotation=0 + AND salesorderdetails.completed".$completed." + GROUP BY salesorders.orderno, + debtorsmaster.name, + custbranch.brname, + salesorders.customerref, + salesorders.orddate, + salesorders.deliverydate, + salesorders.deliverto + ORDER BY salesorders.orderno"; + } } else { $DateAfterCriteria = FormatDateforSQL($_POST['OrdersAfterDate']); @@ -399,8 +467,8 @@ $SalesOrdersResult = DB_query($SQL,$db); if (DB_error_no($db) !=0) { - echo '<br>' . _('No orders were returned by the SQL because') . ' ' . DB_error_msg($db); - echo "<br>$SQL"; + echo '<br />' . _('No orders were returned by the SQL because') . ' ' . DB_error_msg($db); + echo "<br />$SQL"; } }//end of which button clicked options @@ -416,22 +484,22 @@ echo "<tr><td></td>"; } -if (!isset($OrderNumber) or $OrderNumber==''){ - echo '<td>' . _('Order Number') . ':</td><td>' . "<input type='text' name='OrderNumber' maxlength =8 size=9></td><td>" . _('for all orders placed after') . - ": </td><td><input type='text' class='date' alt='".$_SESSION['DefaultDateFormat']."' name='OrdersAfterDate' maxlength =10 size=11 value=" . $_POST['OrdersAfterDate'] . "></td><td>" . - "<input type='submit' name='SearchOrders' value='" . _('Search Orders') . "'></td></tr>"; - echo '<tr><td></td><td>' . _('Customer Ref') . ':</td><td>' . "<input type='text' name='CustomerRef' maxlength =8 size=9></td> +echo '<td>' . _('Order Number') . ':</td> + <td>' . "<input type='text' name='OrderNumber' maxlength =8 size=9 value ='" . $_POST['OrderNumber'] . "'></td> + <td>" . _('for all orders placed after') . ": </td><td><input type='text' class='date' alt='".$_SESSION['DefaultDateFormat']."' name='OrdersAfterDate' maxlength =10 size=11 value=" . $_POST['OrdersAfterDate'] . "></td> + <td>" . "<input type='submit' name='SearchOrders' value='" . _('Search Orders') . "'></td></tr>"; +echo '<tr><td></td><td>' . _('Customer Ref') . ':</td><td>' . "<input type='text' name='CustomerRef' maxlength =8 size=9></td> <td></td><td colspan=2><input type='checkbox' ".$ShowChecked." name='completed' />"._('Show Completed orders only') . "</td></tr>"; -} + echo '</table>'; if (!isset($SelectedStockItem)) { $SQL='SELECT categoryid, categorydescription FROM stockcategory ORDER BY categorydescription'; $result1 = DB_query($SQL,$db); - echo '<br>'; + echo '<br />'; echo '<div class="page_help_text"><font size=1>' . _('To search for sales orders for a specific part use the part selection facilities below') . ' </font></div>'; - echo '<br><table class=selection>'; + echo '<br /><table class=selection>'; echo '<tr><td><font size=1>' . _('Select a stock category') . ':</font>'; echo '<select name="StockCat">'; @@ -461,7 +529,7 @@ If (isset($StockItemsResult)) { - echo '<br><table cellpadding=2 colspan=7 class=selection>'; + echo '<br /><table cellpadding=2 colspan=7 class=selection>'; $TableHeadings = "<tr><th>" . _('Code') . "</th>" . "<th>" . _('Description') . "</th>" . @@ -511,7 +579,7 @@ /*show a table of the orders returned by the SQL */ - echo '<br><table cellpadding=2 colspan=6 width=90% class=selection>'; + echo '<br /><table cellpadding=2 colspan=6 width=90% class=selection>'; $tableheader = "<tr><th>" . _('Order') . " #</th> <th>" . _('Customer') . "</th> Modified: trunk/SelectCustomer.php =================================================================== --- trunk/SelectCustomer.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/SelectCustomer.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -1,6 +1,6 @@ <?php /* $Id$*/ -//$PageSecurity = 2; + include ('includes/session.inc'); $title = _('Search Customers'); include ('includes/header.inc'); @@ -119,8 +119,9 @@ custbranch.phoneno, custbranch.faxno FROM debtorsmaster LEFT JOIN custbranch - ON debtorsmaster.debtorno = custbranch.debtorno, debtortype - WHERE debtorsmaster.typeid = debtortype.typeid"; + ON debtorsmaster.debtorno = custbranch.debtorno + INNER JOIN debtortype + ON debtorsmaster.typeid = debtortype.typeid"; } else { if (strlen($_POST['Keywords']) > 0) { //using the customer name Modified: trunk/SelectSupplier.php =================================================================== --- trunk/SelectSupplier.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/SelectSupplier.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -166,7 +166,7 @@ echo '</td><td valign=top class="select">'; /* Supplier Transactions */ echo "<a href=\"$rootpath/PO_Header.php?" . SID . '&NewOrder=Yes&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Purchase Order for This Supplier') . '</a><br>'; echo "<a href=\"$rootpath/SupplierInvoice.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Suppliers Invoice') . '</a><br>'; - echo "<a href=\"$rootpath/SupplierCredit.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Suppliers Credit Note') . '</a><br>'; + echo "<a href=\"$rootpath/SupplierCredit.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . '&New=True' . "\">" . _('Enter a Suppliers Credit Note') . '</a><br>'; echo "<a href=\"$rootpath/Payments.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "\">" . _('Enter a Payment to, or Receipt from the Supplier') . '</a><br>'; echo '<br>'; echo "<br><a href='$rootpath/ReverseGRN.php?" . SID . '&SupplierID=' . $_SESSION['SupplierID'] . "'>" . _('Reverse an Outstanding Goods Received Note (GRN)') . '</a>'; Modified: trunk/StockCheck.php =================================================================== --- trunk/StockCheck.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/StockCheck.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -175,8 +175,9 @@ $FontSize=10; $YPos -=$line_height; - if ($_POST['ShowInfo']==true){ + if (isset($_POST['ShowInfo']) and $_POST['ShowInfo']==true){ + $SQL = "SELECT SUM(salesorderdetails.quantity - salesorderdetails.qtyinvoiced) AS qtydemand FROM salesorderdetails, salesorders Modified: trunk/StockSerialItems.php =================================================================== --- trunk/StockSerialItems.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/StockSerialItems.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -1,8 +1,8 @@ <?php /* $Id$*/ -//$PageSecurity = 2; + include('includes/session.inc'); $title = _('Stock Of Controlled Items'); include('includes/header.inc'); @@ -28,21 +28,23 @@ mbflag, decimalplaces, serialised, - controlled + controlled, + perishable FROM stockmaster WHERE stockid='".$StockID."'", $db, _('Could not retrieve the requested item because')); -$myrow = DB_fetch_row($result); +$myrow = DB_fetch_array($result); -$Description = $myrow[0]; -$UOM = $myrow[1]; -$DecimalPlaces = $myrow[3]; -$Serialised = $myrow[4]; -$Controlled = $myrow[5]; +$Description = $myrow['description']; +$UOM = $myrow['units']; +$DecimalPlaces = $myrow['decimalplaces']; +$Serialised = $myrow['serialised']; +$Controlled = $myrow['controlled']; +$Perishable = $myrow['perishable']; -if ($myrow[2]=='K' OR $myrow[2]=='A' OR $myrow[2]=='D'){ +if ($myrow['mbflag']=='K' OR $myrow['mbflag']=='A' OR $myrow['mbflag']=='D'){ prnMsg(_('This item is either a kitset or assembly or a dummy part and cannot have a stock holding') . '. ' . _('This page cannot be displayed') . '. ' . _('Only serialised or controlled items can be displayed in this page'),'error'); include('includes/footer.inc'); @@ -59,7 +61,8 @@ $myrow = DB_fetch_row($result); $sql = "SELECT serialno, - quantity + quantity, + expirationdate FROM stockserialitems WHERE loccode='" . $_GET['Location'] . "' AND stockid = '" . $StockID . "' @@ -72,30 +75,48 @@ echo '<table cellpadding=2 class=selection>'; if ($Serialised==1){ - echo '<tr<th colspan=3><font color=navy size=2>' . _('Serialised items in') . ' '; + echo '<tr><th colspan="5"><font color=navy size=2>' . _('Serialised items in') . ' '; } else { - echo '<tr<th colspan=3><font color=navy size=2>' . _('Controlled items in') . ' '; + echo '<tr><th colspan="11"><font color=navy size=2>' . _('Controlled items in') . ' '; } echo $myrow[0]. '</font></th></tr>'; -echo "<tr><th colspan=3><font color=navy size=2>".$StockID ."-". $Description ."</b> (" . _('In units of') . ' ' . $UOM . ')</font></th></tr>'; +echo "<tr><th colspan=11><font color=navy size=2>".$StockID ."-". $Description ."</b> (" . _('In units of') . ' ' . $UOM . ')</font></th></tr>'; if ($Serialised == 1){ - $tableheader = "<tr> - <th>" . _('Serial Number') . "</th> - <th>" . _('Serial Number') . "</th> - <th>" . _('Serial Number') . "</th> - </tr>"; -} else { - $tableheader = "<tr> - <th>" . _('Batch/Bundle Ref') . "</th> - <th>" . _('Quantity On Hand') . "</th> - <th>" . _('Batch/Bundle Ref') . "</th> - <th>" . _('Quantity On Hand') . "</th> - <th>" . _('Batch/Bundle Ref') . "</th> - <th>" . _('Quantity On Hand') . "</th> + $tableheader = '<tr> + <th>' . _('Serial Number') . '</th> + <th></th> + <th>' . _('Serial Number') . '</th> + <th></th> + <th>' . _('Serial Number') . '</th> + </tr>'; +} else if ($Serialised == 0 and $Perishable==0){ + $tableheader = '<tr> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> + <th></th> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> + <th></th> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> </tr>"; +} else if ($Serialised == 0 and $Perishable==1){ + $tableheader = '<tr> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> + <th>' . _('Expiry Date') . '</th> + <th></th> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> + <th>' . _('Expiry Date') . '</th> + <th></th> + <th>' . _('Batch/Bundle Ref') . '</th> + <th>' . _('Quantity On Hand') . '</th> + <th>' . _('Expiry Date') . '</th> + </tr>'; } echo $tableheader; $TotalQuantity =0; @@ -115,15 +136,17 @@ $TotalQuantity += $myrow['quantity']; if ($Serialised == 1){ - printf('<td>%s</td>', - $myrow['serialno'] - ); - } else { - printf("<td>%s</td> - <td class=number>%s</td>", - $myrow['serialno'], - number_format($myrow['quantity'],$DecimalPlaces) - ); + echo '<td>'.$myrow['serialno'].'/td>'; + echo '<th></th>'; + } else if ($Serialised == 0 and $Perishable==0) { + echo '<td>'.$myrow['serialno'].'</td> + <td class="number">'.number_format($myrow['quantity'],$DecimalPlaces).'</td>'; + echo '<th></th>'; + } else if ($Serialised == 0 and $Perishable==1){ + echo '<td>'.$myrow['serialno'].'</td> + <td class="number">'.number_format($myrow['quantity'],$DecimalPlaces). '</td> + <td>' . ConvertSQLDate($myrow['expirationdate']). '</td>'; + echo '<th></th>'; } $j++; If ($j == 36){ @@ -144,5 +167,4 @@ echo '</form>'; include('includes/footer.inc'); - ?> \ No newline at end of file Modified: trunk/SupplierCredit.php =================================================================== --- trunk/SupplierCredit.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/SupplierCredit.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -35,6 +35,10 @@ //this is available from the menu on this page already //echo "<a href='" . $rootpath . '/SelectSupplier.php?' . SID . "'>" . _('Back to Suppliers') . '</a><br>'; +if (isset($_GET['New'])) { + unset($_SESSION['SuppTrans']); +} + if (!isset($_SESSION['SuppTrans']->SupplierName)) { $sql='SELECT suppname FROM suppliers WHERE supplierid="'.$_GET['SupplierID'].'"'; $result = DB_query($sql,$db); Modified: trunk/Suppliers.php =================================================================== --- trunk/Suppliers.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/Suppliers.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -444,11 +444,11 @@ } if (!isset($_POST['New'])) { - $supptranssql = "SELECT COUNT(supplierno) - FROM supptrans - WHERE supplierno='".$SupplierID ."'"; + $supptranssql = "SELECT supplierno + FROM supptrans + WHERE supplierno='".$SupplierID ."'"; $suppresult = DB_query($supptranssql, $db); - $supptrans = DB_fetch_row($suppresult); + $supptrans = DB_num_rows($suppresult); $suppcurrssql = "SELECT currcode FROM suppliers @@ -481,7 +481,7 @@ WHERE supplierid = '".$SupplierID."'"; } else { if ($suppcurr[0] != $_POST['CurrCode']) { - prnMsg( _('Cannot change currency code as transactions already exist'), info); + prnMsg( _('Cannot change currency code as transactions already exist'), 'info'); } $sql = "UPDATE suppliers SET suppname='" . $_POST['SuppName'] . "', address1='" . $_POST['Address1'] . "', Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/doc/Change.log.html 2011-03-03 09:13:12 UTC (rev 4501) @@ -1,6 +1,9 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> -<p>27/2/11: Phil/Tim/Peter launchpad added category option for MRPShortages.php </p> +<p>3/3/11: Exson/Baran/Phil fix to customer login to ensure that other customers orders are not displayed when searching by customer ref or order no</p> +<p>3/3/11: Tim launchpad mods to revision 4441 including change to allow supplier currency to be changed if there are no transactions already against the supplier. Ensure credit note session variable is unset before attempting to create a new credit note from the supplier form. Tim's work to add perisable expiry dates to the serial items logic - affects quite a few scripts. Headings to stock check script even if no quantity is shown. Portrait quotations. Not included change to default delivery date to the date the customer requested - left to be the current day's date. Not included Tim's unit pricing work .. yet launchpad revisions 4442-4447 inclusive</p> +<p>27/2/11: Phil/Tim/Peter launchpad added category option for MRPShortages.php links with matching quotes in WorkOrderEntry</p> +<p>27/2/11: Phil StockUsage.php now totals usage each month even in months where there was none - average now includes months with no usage</p> <p>27/2/11: Phil fix units deletion issue reported by Exson in UnitsOfMeasure.php script - checked for none existant units field in contracts table - removed the check</p> <p>22/2/11: Phil fix PDFTopItems.php for changed variable names - now using CamelCase tried to rework to conform</p> <p>22/2/11: Phil remove options for PDFLanguage that are not unique in WWW_Users.php - make it default to the users settings in the SESSION for UserSettings.php</p> Modified: trunk/includes/Add_SerialItems.php =================================================================== --- trunk/includes/Add_SerialItems.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/Add_SerialItems.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -66,7 +66,7 @@ } if (!$SerialError){ - $LineItem->SerialItems[$NewSerialNo] = new SerialItem ($_POST['SerialNo' . $i], $NewQty); + $LineItem->SerialItems[$NewSerialNo] = new SerialItem ($_POST['SerialNo' . $i], $NewQty, $_POST['ExpiryDate' . $i]); } } } /* end if posted Serialno . i is not blank */ @@ -75,7 +75,8 @@ if (!isset($_POST['Bundles'])) { $_POST['Bundles']=0; } - for ($i=0;$i < count($_POST['Bundles']);$i++){ /*there is an entry in the multi select list box */ + echo count($_POST['Bundles']); + for ($i=0;$i < count($_POST['Bundles'])-1;$i++){ /*there is an entry in the multi select list box */ if ($LineItem->Serialised==1){ /*only if the item is serialised */ $LineItem->SerialItems[$_POST['Bundles'][$i]] = new SerialItem ($_POST['Bundles'][$i], ($InOutModifier>0?1:-1) ); } else { Modified: trunk/includes/Add_SerialItemsOut.php =================================================================== --- trunk/includes/Add_SerialItemsOut.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/Add_SerialItemsOut.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -3,11 +3,10 @@ /*ProcessSerialItems.php takes the posted variables and adds to the SerialItems array in either the cartclass->LineItems->SerialItems or the POClass->LineItems->SerialItems */ - if (isset($_POST['AddBatches'])){ for ($i=0;$i < 10;$i++){ - if(strlen($_POST['SerialNo' . $i])>0){ + if(isset($_POST['SerialNo' . $i]) and strlen($_POST['SerialNo' . $i])>0){ $ExistingBundleQty = ValidBundleRef($StockID, $LocationOut, $_POST['SerialNo' . $i]); if ($ExistingBundleQty >0){ $AddThisBundle = true; @@ -15,30 +14,31 @@ the first entered one - no warning given though ? */ if ($_POST['Qty' . $i] > $ExistingBundleQty){ if ($LineItem->Serialised ==1){ - echo "<BR>" . $_POST['SerialNo' . $i] . " " . _('has already been sold'); + echo "<br />" . $_POST['SerialNo' . $i] . " " . _('has already been sold'); $AddThisBundle = false; } elseif ($ExistingBundleQty==0) { /* and its a batch */ - echo "<BR>There is none of " . $_POST['SerialNo' . $i] . " left."; + echo "<br />There is none of " . $_POST['SerialNo' . $i] . " left."; $AddThisBundle = false; } else { - echo '<BR>' . _('There is only') . ' ' . $ExistingBundleQty . ' ' . _('of') . ' ' . $_POST['SerialNo' . $i] . ' ' . _('remaining') . '. ' . _('The entered quantity will be reduced to the remaining amount left of this batch/bundle/roll'); + echo '<br />' . _('There is only') . ' ' . $ExistingBundleQty . ' ' . _('of') . ' ' . $_POST['SerialNo' . $i] . + ' ' . _('remaining') . '. ' . _('The entered quantity will be reduced to the remaining amount left of this batch/bundle/roll'); $_POST['Qty' . $i] = $ExistingBundleQty; $AddThisBundle = true; } } - if ($AddThisBundle==true){ - $LineItem->SerialItems[$_POST['SerialNo' . $i]] = new SerialItem ($_POST['SerialNo' . $i], $_POST['Qty' . $i]); + if ($AddThisBundle==true and $_POST['Qty' . $i]>0){ + $LineItem->SerialItems[$_POST['SerialNo' . $i]] = new SerialItem ($_POST['SerialNo' . $i], $_POST['Qty' . $i], $_POST['ExpiryDate' . $i]); } } /*end if ExistingBundleQty >0 */ } /* end if posted Serialno . i is not blank */ } /* end of the loop aroung the form input fields */ - for ($i=0;$i < count($_POST['Bundles']);$i++){ /*there is an entry in the multi select list box */ - if ($LineItem->Serialised==1){ /*only if the item is serialised */ - $LineItem->SerialItems[$_POST['Bundles'][$i]] = new SerialItem ($_POST['Bundles'][$i], 1); - } - } +// for ($i=0;$i < count($_POST['Bundles']);$i++){ /*there is an entry in the multi select list box */ +// if ($LineItem->Serialised==1){ /*only if the item is serialised */ +// $LineItem->SerialItems[$_POST['Bundles'][$i]] = new SerialItem ($_POST['Bundles'][$i], 1); +// } +// } } /*end if the user hit the enter button */ @@ -47,4 +47,8 @@ unset($LineItem->SerialItems[$_GET['Delete']]); } +if (isset($_GET['DELETEALL'])){ + $LineItem->SerialItems=array(); +} + ?> Modified: trunk/includes/DefineSerialItems.php =================================================================== --- trunk/includes/DefineSerialItems.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/DefineSerialItems.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -4,10 +4,10 @@ function ValidBundleRef ($StockID, $LocCode, $BundleRef){ global $db; - $SQL = "SELECT quantity - FROM stockserialitems - WHERE stockid='" . $StockID . "' - AND loccode ='" . $LocCode . "' + $SQL = "SELECT quantity + FROM stockserialitems + WHERE stockid='" . $StockID . "' + AND loccode ='" . $LocCode . "' AND serialno='" . $BundleRef . "'"; $Result = DB_query($SQL, $db); if (DB_num_rows($Result)==0){ @@ -22,12 +22,14 @@ var $BundleRef; var $BundleQty; + var $ExpiryDate; //Constructor - function SerialItem($BundleRef, $BundleQty){ + function SerialItem($BundleRef, $BundleQty, $ExpiryDate='0000-00-00'){ $this->BundleRef = $BundleRef; $this->BundleQty = $BundleQty; + $this->ExpiryDate = $ExpiryDate; } }//class SerialItem ?> \ No newline at end of file Modified: trunk/includes/InputSerialItems.php =================================================================== --- trunk/includes/InputSerialItems.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/InputSerialItems.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -88,15 +88,27 @@ '&LineNo=' . $LineNo .'">'. _('Edit'). '</a> | '; $RemoveLink = '<a href="' . $_SERVER['PHP_SELF'] . '?identifier=' . $identifier . '&DELETEALL=YES&StockID=' . $LineItem->StockID . '&LineNo=' . $LineNo .'">'. _('Remove All'). '</a><br></div>'; +$sql="SELECT perishable + FROM stockmaster + WHERE stockid='".$StockID."'"; +$result=DB_query($sql, $db); +$myrow=DB_fetch_array($result); +$Perishable=$myrow['perishable']; if ($LineItem->Serialised==1){ $tableheader .= '<tr> <th>'. _('Serial No').'</th> - </Tr>'; + </tr>'; +} else if ($LineItem->Serialised==0 and $Perishable==1){ + $tableheader = '<tr> + <th>'. _('Batch/Roll/Bundle'). ' #</th> + <th>'. _('Quantity'). '</th> + <th>'. _('Expiry Date'). '</th> + </tr>'; } else { - $tableheader = '<TR> + $tableheader = '<tr> <th>'. _('Batch/Roll/Bundle'). ' #</th> - <th class=tableheader>'. _('Quantity'). '</th> - </tr>'; + <th>'. _('Quantity'). '</th> + </tr>'; } echo $EditLink . $RemoveLink; Modified: trunk/includes/InputSerialItemsKeyed.php =================================================================== --- trunk/includes/InputSerialItemsKeyed.php 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/InputSerialItemsKeyed.php 2011-03-03 09:13:12 UTC (rev 4501) @@ -47,8 +47,11 @@ echo '<td>' . $Bundle->BundleRef . '</td>'; - if ($LineItem->Serialised==0){ + if ($LineItem->Serialised==0 and $Perishable==0){ echo '<td class=number>' . number_format($Bundle->BundleQty, $LineItem->DecimalPlaces) . '</td>'; + } else if ($LineItem->Serialised==0 and $Perishable==1){ + echo '<td class=number>' . number_format($Bundle->BundleQty, $LineItem->DecimalPlaces) . '</td>'; + echo '<td class=number>' . $Bundle->ExpiryDate . '</td>'; } echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?identifier=' . $identifier . '&Delete=' . $Bundle->BundleRef . '&StockID=' . $LineItem->StockID . '&LineNo=' . $LineNo .'">'. _('Delete'). '</a></td></tr>'; @@ -81,7 +84,7 @@ <input type=hidden name=StockID value="' . $StockID . '"> <input type=hidden name="identifier" value="' . $identifier . '"> <input type=hidden name=EntryType value="KEYED">'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; +echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; if ( isset($_GET['EditControlled']) ) { $EditControlled = isset($_GET['EditControlled'])?$_GET['EditControlled']:false; } elseif ( isset($_POST['EditControlled']) ){ @@ -102,6 +105,9 @@ if ($LineItem->Serialised==1){ echo '<input type=hidden name="Qty' . $StartAddingAt .'" Value=1></TR>'; + } else if ($LineItem->Serialised==0 and $Perishable==1) { + echo '<td><input type=text class="number" name="Qty' . $StartAddingAt .'" size=11 + value="'. number_format($Bundle->BundleQty, $LineItem->DecimalPlaces). '" maxlength=10></tr>'; } else { echo '<td><input type=text class="number" name="Qty' . $StartAddingAt .'" size=11 value="'. number_format($Bundle->BundleQty, $LineItem->DecimalPlaces). '" maxlength=10></tr>'; @@ -120,6 +126,10 @@ if ($LineItem->Serialised==1){ echo '<input type=hidden name="Qty' . ($StartAddingAt+$i) .'" Value=1></tr>'; + } else if ($LineItem->Serialised==0 and $Perishable==1) { + echo '<td><input type=text class="number" name="Qty' . ($StartAddingAt+$i) .'" size=11 maxlength=10></td>'; + echo '<td><input type=text class="date" name="ExpiryDate' . ($StartAddingAt+$i) .'" size=11 + value="" alt="'.$_SESSION['DefaultDateFormat'].'" maxlength=10></td></tr>'; } else { echo '<td><input type=text class="number" name="Qty' . ($StartAddingAt+$i) .'" size=11 maxlength=10></tr>'; } @@ -136,4 +146,4 @@ document.Ga6uF5Wa.SerialNo0.focus(); //]]> </script>'; /*end of nested table */ -?> +?> \ No newline at end of file Modified: trunk/includes/PDFStockCheckPageHeader.inc =================================================================== --- trunk/includes/PDFStockCheckPageHeader.inc 2011-02-27 09:18:42 UTC (rev 4500) +++ trunk/includes/PDFStockCheckPageHeader.inc 2011-03-03 09:13:12 UTC (rev 4501) @@ -28,16 +28,22 @@ $Xpos = $Left_Margin+1; /*draw vertical lines */ -$pdf->line(350, $YPos-$line_height,350, $Bottom_Margin+24); -$pdf->line(415, $YPos-$line_height,415, $Bottom_Margin+24); -$pdf->line(475, $YPos-$line_height,475, $Bottom_Margin+24); +$pdf->line(370, $YPos+$BoxHeight,370, $Bottom_Margin+24); $LeftOvers = $pdf->addTextWrap($Xpos,$YPos,300-$Left_Margin,$FontSize,_('Item'), 'centre'); -if ($_POST['ShowInfo']==true){ +if (isset($_POST['ShowInfo']) and $_POST['ShowInfo']==true){ + /*draw vertical lines */ + $pdf->line(415, $YPos-$line_height,415, $Bottom_Margin+24); + $pdf->line(475, $YPos-$line_height,475, $Bottom_Margin+24); $LeftOvers = $pdf->addTextWrap(341,$YPos,60,$FontSize,_('QOH'), 'centre'); $LeftOvers = $pdf->addTextWrap(341+61,$YPos,80,$FontSize,_('Cust Ords'), 'centre'); $LeftOvers = $pdf->addTextWrap(341+61+61,$YPos,80,$FontSize,_('Available'), 'centre'); - } +} else { + /*draw vertical lines */ + $pdf->line(435, $YPos+$BoxHeight,435, $Bottom_Margin+24); + $LeftOvers = $pdf->addTextWrap(371,$YPos,60,$FontSize,_('Quantity'), 'centre'); + $LeftOvers = $pdf->addTextWrap(341+61+61,$YPos,80,$FontSize,_('Remarks'), 'centre'); +} $FontSize=10; $YPos -=($line_height); ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-02-27 09:18:49
|
Revision: 4500 http://web-erp.svn.sourceforge.net/web-erp/?rev=4500&view=rev Author: daintree Date: 2011-02-27 09:18:42 +0000 (Sun, 27 Feb 2011) Log Message: ----------- various Modified Paths: -------------- trunk/GoodsReceived.php trunk/MRPShortages.php trunk/PDFQuotation.php trunk/StockUsage.php trunk/WorkOrderEntry.php trunk/doc/Change.log.html Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/GoodsReceived.php 2011-02-27 09:18:42 UTC (rev 4500) @@ -4,8 +4,6 @@ /* $Revision: 1.44 $ */ -//$PageSecurity = 11; now stored in the database - /* Session started in header.inc for password checking and authorisation level check */ include('includes/DefinePOClass.php'); include('includes/DefineSerialItems.php'); @@ -72,6 +70,7 @@ if (!isset($_POST['ProcessGoodsReceived'])) { if (!isset($_POST['DefaultReceivedDate'])){ + /* This is meant to be the date the goods are received - it does not make sense to set this to the date that we requested delivery in the purchase order - I have not applied your change here Tim for this reason - let me know if I have it wrong - Phil */ $_POST['DefaultReceivedDate'] = Date($_SESSION['DefaultDateFormat']); } Modified: trunk/MRPShortages.php =================================================================== --- trunk/MRPShortages.php 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/MRPShortages.php 2011-02-27 09:18:42 UTC (rev 4500) @@ -1,20 +1,20 @@ <?php /*$Id$ */ - -/* $Revision: 1.7 $ */ // MRPShortages.php - Report of parts with demand greater than supply as determined by MRP -//$PageSecurity = 2; + include('includes/session.inc'); +//ANSI SQL??? $sql='show tables where Tables_in_'.$_SESSION['DatabaseName'].'="mrprequirements"'; + $result=DB_query($sql,$db); if (DB_num_rows($result)==0) { - $title='MRP error'; + $title=_('MRP error'); include('includes/header.inc'); echo '<br>'; - prnMsg( _('The MRP calculation must be run before you can run this report').'<br>'. - _('To run the MRP calculation click').' '.'<a href='.$rootpath .'/MRP.php?' . SID .'>'._('here').'</a>', 'error'); + prnMsg( _('The MRP calculation must be run before you can run this report').'<br />'. + _('To run the MRP calculation click').' '.'<a href="'.$rootpath .'/MRP.php">'._('here').'</a>', 'error'); include('includes/footer.inc'); exit; } @@ -103,7 +103,14 @@ extcost HAVING demand > supply ORDER BY '" . $_POST['Sort']."'"; - $sql = "SELECT stockmaster.stockid, + + if ($_POST['CategoryID'] == 'All'){ + $SQLCategory = ' '; + }else{ + $SQLCategory = "WHERE stockmaster.categoryid = '" . $_POST['CategoryID'] . "'"; + } + + $sql = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.mbflag, stockmaster.actualcost, @@ -117,8 +124,9 @@ stockmaster.overheadcost ) as extcost FROM stockmaster LEFT JOIN demandtotal ON stockmaster.stockid = demandtotal.part - LEFT JOIN supplytotal ON stockmaster.stockid = supplytotal.part - GROUP BY stockmaster.stockid, + LEFT JOIN supplytotal ON stockmaster.stockid = supplytotal.part " + . $SQLCategory . + "GROUP BY stockmaster.stockid, stockmaster.description, stockmaster.mbflag, stockmaster.actualcost, @@ -137,9 +145,9 @@ $title = _('MRP Shortages') . ' - ' . _('Problem Report'); include('includes/header.inc'); prnMsg( _('The MRP shortages could not be retrieved by the SQL because') . ' ' . DB_error_msg($db),'error'); - echo "</br><a href='" .$rootpath .'/index.php?' . SID . "'>" . _('Back to the menu') . '</a>'; + echo '<br/><a href="' .$rootpath .'/index.php">' . _('Back to the menu') . '</a>'; if ($debug==1){ - echo "</br>$sql"; + echo '<br/>' . $sql; } include('includes/footer.inc'); exit; @@ -149,9 +157,9 @@ $title = _('MRP Shortages') . ' - ' . _('Problem Report'); include('includes/header.inc'); prnMsg( _('No MRP shortages retrieved'), 'warn'); - echo "</br><a href='" .$rootpath .'/index.php?' . SID . "'>" . _('Back to the menu') . '</a>'; + echo '<br /><a href="' .$rootpath .'/index.php">' . _('Back to the menu') . '</a>'; if ($debug==1){ - echo "</br>$sql"; + echo "<br />$sql"; } include('includes/footer.inc'); exit; @@ -216,28 +224,7 @@ $pdf->addTextWrap(300,$YPos,180,$FontSize,_('Total Extended Shortage:'), 'right'); $DisplayTotalVal = number_format($Total_Shortage,2); $pdf->addTextWrap(510,$YPos,60,$FontSize,$DisplayTotalVal, 'right'); -/* UldisN - $pdfcode = $pdf->output(); - $len = strlen($pdfcode); - if ($len<=20){ - $title = _('Print MRP Shortages Error'); - include('includes/header.inc'); - prnMsg(_('There were no items with demand greater than supply'),'error'); - echo "</br><a href='$rootpath/index.php?" . SID . "'>" . _('Back to the menu') . '</a>'; - include('includes/footer.inc'); - exit; - } else { - header('Content-type: application/pdf'); - header("Content-Length: " . $len); - header('Content-Disposition: inline; filename=MRPShortages.pdf'); - header('Expires: 0'); - header('Cache-Control: private, post-check=0, pre-check=0'); - header('Pragma: public'); - - $pdf->Output('MRPShortages.pdf', 'I'); - } -*/ $pdf->OutputD($_SESSION['DatabaseName'] . '_MRPShortages_' . date('Y-m-d').'.pdf');//UldisN $pdf->__destruct(); //UldisN } else { /*The option to print PDF was not hit so display form */ @@ -250,14 +237,24 @@ echo '<form action=' . $_SERVER['PHP_SELF'] . " method='post'>"; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo "<table class=selection>"; + echo '<table class=selection>'; + echo '</select></td></tr>'; + echo '<tr><td>' . _('Inventory Category') . ':</td><td><select name="CategoryID">'; + echo '<option selected value="All">' . _('All Stock Categories'); + $sql = 'SELECT categoryid, + categorydescription + FROM stockcategory'; + $result = DB_query($sql,$db); + while ($myrow = DB_fetch_array($result)) { + echo '<option value="' . $myrow['categoryid'] . '">' . $myrow['categoryid'] . ' - ' .$myrow['categorydescription'] . '</option>'; + } //end while loop echo '<tr><td>' . _('Sort') . ":</td><td><select name='Sort'>"; - echo "<option selected value='extcost'>" . _('Extended Shortage Dollars')."</option>"; - echo "<option value='stockid'>" . _('Part Number')."</option>"; + echo "<option selected value='extcost'>" . _('Extended Shortage Dollars').'</option>'; + echo "<option value='stockid'>" . _('Part Number').'</option>'; echo '</select></td></tr>'; echo '<tr><td>' . _('Print Option') . ":</td><td><select name='Fill'>"; - echo "<option selected value='yes'>" . _('Print With Alternating Highlighted Lines')."</option>"; - echo "<option value='no'>" . _('Plain Print')."</option>"; + echo "<option selected value='yes'>" . _('Print With Alternating Highlighted Lines').'</option>'; + echo "<option value='no'>" . _('Plain Print').'</option>'; echo '</select></td></tr>'; echo "</table><br><div class='centre'><input type=submit name='PrintPDF' value='" . _('Print PDF') . "'></div>"; Modified: trunk/PDFQuotation.php =================================================================== --- trunk/PDFQuotation.php 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/PDFQuotation.php 2011-02-27 09:18:42 UTC (rev 4500) @@ -1,10 +1,7 @@ <?php /* $Id$*/ -/* $Revision: 1.11 $ */ -//$PageSecurity = 2; - include('includes/session.inc'); include('includes/SQL_CommonFunctions.inc'); Modified: trunk/StockUsage.php =================================================================== --- trunk/StockUsage.php 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/StockUsage.php 2011-02-27 09:18:42 UTC (rev 4500) @@ -2,7 +2,6 @@ /* $Id$*/ -//$PageSecurity = 2; include('includes/session.inc'); @@ -93,32 +92,38 @@ /*HideMovt ==1 if the movement was only created for the purpose of a transaction but is not a physical movement eg. A price credit will create a movement record for the purposes of display on a credit note but there is no physical stock movement - it makes sense honest ??? */ + +$CurrentPeriod = GetPeriod(Date($_SESSION['DefaultDateFormat']),$db); + if (isset($_POST['ShowUsage'])){ if($_POST['StockLocation']=='All'){ $sql = "SELECT periods.periodno, periods.lastdate_in_period, - SUM(-stockmoves.qty) AS qtyused - FROM stockmoves INNER JOIN periods - ON stockmoves.prd=periods.periodno - WHERE (stockmoves.type=10 OR stockmoves.type=11 OR stockmoves.type=28) - AND stockmoves.hidemovt=0 - AND stockmoves.stockid = '" . $StockID . "' + SUM(CASE WHEN (stockmoves.type=10 Or stockmoves.type=11 OR stockmoves.type=28) + AND stockmoves.hidemovt=0 + AND stockmoves.stockid = '" . $StockID . "' + THEN -stockmoves.qty ELSE 0 END) AS qtyused + FROM periods LEFT JOIN stockmoves + ON periods.periodno=stockmoves.prd + WHERE periods.periodno <='" . $CurrentPeriod . "' GROUP BY periods.periodno, periods.lastdate_in_period ORDER BY periodno DESC LIMIT " . $_SESSION['NumberOfPeriodsOfStockUsage']; } else { $sql = "SELECT periods.periodno, periods.lastdate_in_period, - SUM(-stockmoves.qty) AS qtyused - FROM stockmoves INNER JOIN periods - ON stockmoves.prd=periods.periodno - WHERE (stockmoves.type=10 Or stockmoves.type=11 OR stockmoves.type=28) - AND stockmoves.hidemovt=0 - AND stockmoves.loccode='" . $_POST['StockLocation'] . "' - AND stockmoves.stockid = '" . $StockID . "' + SUM(CASE WHEN (stockmoves.type=10 Or stockmoves.type=11 OR stockmoves.type=28) + AND stockmoves.hidemovt=0 + AND stockmoves.stockid = '" . $StockID . "' + AND stockmoves.loccode='" . $_POST['StockLocation'] . "' + THEN -stockmoves.qty ELSE 0 END) AS qtyused + FROM periods LEFT JOIN stockmoves + ON periods.periodno=stockmoves.prd + WHERE periods.periodno <='" . $CurrentPeriod . "' GROUP BY periods.periodno, periods.lastdate_in_period ORDER BY periodno DESC LIMIT " . $_SESSION['NumberOfPeriodsOfStockUsage']; + } $MovtsResult = DB_query($sql, $db); if (DB_error_no($db) !=0) { Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/WorkOrderEntry.php 2011-02-27 09:18:42 UTC (rev 4500) @@ -2,8 +2,6 @@ /* $Id$*/ -//$PageSecurity = 10; - include('includes/session.inc'); $title = _('Work Order Entry'); include('includes/header.inc'); @@ -252,9 +250,9 @@ if (isset($_POST['submit'])) { //The update button has been clicked - echo '<div class=centre><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Enter a new work order') . '</a>'; - echo '<br><a href="' . $rootpath . '/SelectWorkOrder.php?' . SID . '">' . _('Select an existing work order') . '</a>'; - echo '<br><a href="'. $rootpath . '/WorkOrderCosting.php?' . SID . '&WO=' . $_REQUEST['WO'] . '">' . _('Go to Costing'). '</a></div>'; + echo '<div class=centre><a href="' . $_SERVER['PHP_SELF'] .'">' . _('Enter a new work order') . '</a>'; + echo '<br><a href="' . $rootpath . '/SelectWorkOrder.php">' . _('Select an existing work order') . '</a>'; + echo '<br><a href="'. $rootpath . '/WorkOrderCosting.php&WO=' . $_REQUEST['WO'] . '">' . _('Go to Costing'). '</a></div>'; $Input_Error = false; //hope for the best for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ @@ -659,9 +657,6 @@ echo "<script>defaultControl(document.forms[0].OutputQty".$_GET['Line'].");</script>"; } - echo '</form>'; - include('includes/footer.inc'); - ?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/doc/Change.log.html 2011-02-27 09:18:42 UTC (rev 4500) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>27/2/11: Phil/Tim/Peter launchpad added category option for MRPShortages.php </p> <p>27/2/11: Phil fix units deletion issue reported by Exson in UnitsOfMeasure.php script - checked for none existant units field in contracts table - removed the check</p> <p>22/2/11: Phil fix PDFTopItems.php for changed variable names - now using CamelCase tried to rework to conform</p> <p>22/2/11: Phil remove options for PDFLanguage that are not unique in WWW_Users.php - make it default to the users settings in the SESSION for UserSettings.php</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2011-02-27 09:18:49
|
Revision: 4500 http://web-erp.svn.sourceforge.net/web-erp/?rev=4500&view=rev Author: daintree Date: 2011-02-27 09:18:42 +0000 (Sun, 27 Feb 2011) Log Message: ----------- various Modified Paths: -------------- trunk/GoodsReceived.php trunk/MRPShortages.php trunk/PDFQuotation.php trunk/StockUsage.php trunk/WorkOrderEntry.php trunk/doc/Change.log.html Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/GoodsReceived.php 2011-02-27 09:18:42 UTC (rev 4500) @@ -4,8 +4,6 @@ /* $Revision: 1.44 $ */ -//$PageSecurity = 11; now stored in the database - /* Session started in header.inc for password checking and authorisation level check */ include('includes/DefinePOClass.php'); include('includes/DefineSerialItems.php'); @@ -72,6 +70,7 @@ if (!isset($_POST['ProcessGoodsReceived'])) { if (!isset($_POST['DefaultReceivedDate'])){ + /* This is meant to be the date the goods are received - it does not make sense to set this to the date that we requested delivery in the purchase order - I have not applied your change here Tim for this reason - let me know if I have it wrong - Phil */ $_POST['DefaultReceivedDate'] = Date($_SESSION['DefaultDateFormat']); } Modified: trunk/MRPShortages.php =================================================================== --- trunk/MRPShortages.php 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/MRPShortages.php 2011-02-27 09:18:42 UTC (rev 4500) @@ -1,20 +1,20 @@ <?php /*$Id$ */ - -/* $Revision: 1.7 $ */ // MRPShortages.php - Report of parts with demand greater than supply as determined by MRP -//$PageSecurity = 2; + include('includes/session.inc'); +//ANSI SQL??? $sql='show tables where Tables_in_'.$_SESSION['DatabaseName'].'="mrprequirements"'; + $result=DB_query($sql,$db); if (DB_num_rows($result)==0) { - $title='MRP error'; + $title=_('MRP error'); include('includes/header.inc'); echo '<br>'; - prnMsg( _('The MRP calculation must be run before you can run this report').'<br>'. - _('To run the MRP calculation click').' '.'<a href='.$rootpath .'/MRP.php?' . SID .'>'._('here').'</a>', 'error'); + prnMsg( _('The MRP calculation must be run before you can run this report').'<br />'. + _('To run the MRP calculation click').' '.'<a href="'.$rootpath .'/MRP.php">'._('here').'</a>', 'error'); include('includes/footer.inc'); exit; } @@ -103,7 +103,14 @@ extcost HAVING demand > supply ORDER BY '" . $_POST['Sort']."'"; - $sql = "SELECT stockmaster.stockid, + + if ($_POST['CategoryID'] == 'All'){ + $SQLCategory = ' '; + }else{ + $SQLCategory = "WHERE stockmaster.categoryid = '" . $_POST['CategoryID'] . "'"; + } + + $sql = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.mbflag, stockmaster.actualcost, @@ -117,8 +124,9 @@ stockmaster.overheadcost ) as extcost FROM stockmaster LEFT JOIN demandtotal ON stockmaster.stockid = demandtotal.part - LEFT JOIN supplytotal ON stockmaster.stockid = supplytotal.part - GROUP BY stockmaster.stockid, + LEFT JOIN supplytotal ON stockmaster.stockid = supplytotal.part " + . $SQLCategory . + "GROUP BY stockmaster.stockid, stockmaster.description, stockmaster.mbflag, stockmaster.actualcost, @@ -137,9 +145,9 @@ $title = _('MRP Shortages') . ' - ' . _('Problem Report'); include('includes/header.inc'); prnMsg( _('The MRP shortages could not be retrieved by the SQL because') . ' ' . DB_error_msg($db),'error'); - echo "</br><a href='" .$rootpath .'/index.php?' . SID . "'>" . _('Back to the menu') . '</a>'; + echo '<br/><a href="' .$rootpath .'/index.php">' . _('Back to the menu') . '</a>'; if ($debug==1){ - echo "</br>$sql"; + echo '<br/>' . $sql; } include('includes/footer.inc'); exit; @@ -149,9 +157,9 @@ $title = _('MRP Shortages') . ' - ' . _('Problem Report'); include('includes/header.inc'); prnMsg( _('No MRP shortages retrieved'), 'warn'); - echo "</br><a href='" .$rootpath .'/index.php?' . SID . "'>" . _('Back to the menu') . '</a>'; + echo '<br /><a href="' .$rootpath .'/index.php">' . _('Back to the menu') . '</a>'; if ($debug==1){ - echo "</br>$sql"; + echo "<br />$sql"; } include('includes/footer.inc'); exit; @@ -216,28 +224,7 @@ $pdf->addTextWrap(300,$YPos,180,$FontSize,_('Total Extended Shortage:'), 'right'); $DisplayTotalVal = number_format($Total_Shortage,2); $pdf->addTextWrap(510,$YPos,60,$FontSize,$DisplayTotalVal, 'right'); -/* UldisN - $pdfcode = $pdf->output(); - $len = strlen($pdfcode); - if ($len<=20){ - $title = _('Print MRP Shortages Error'); - include('includes/header.inc'); - prnMsg(_('There were no items with demand greater than supply'),'error'); - echo "</br><a href='$rootpath/index.php?" . SID . "'>" . _('Back to the menu') . '</a>'; - include('includes/footer.inc'); - exit; - } else { - header('Content-type: application/pdf'); - header("Content-Length: " . $len); - header('Content-Disposition: inline; filename=MRPShortages.pdf'); - header('Expires: 0'); - header('Cache-Control: private, post-check=0, pre-check=0'); - header('Pragma: public'); - - $pdf->Output('MRPShortages.pdf', 'I'); - } -*/ $pdf->OutputD($_SESSION['DatabaseName'] . '_MRPShortages_' . date('Y-m-d').'.pdf');//UldisN $pdf->__destruct(); //UldisN } else { /*The option to print PDF was not hit so display form */ @@ -250,14 +237,24 @@ echo '<form action=' . $_SERVER['PHP_SELF'] . " method='post'>"; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo "<table class=selection>"; + echo '<table class=selection>'; + echo '</select></td></tr>'; + echo '<tr><td>' . _('Inventory Category') . ':</td><td><select name="CategoryID">'; + echo '<option selected value="All">' . _('All Stock Categories'); + $sql = 'SELECT categoryid, + categorydescription + FROM stockcategory'; + $result = DB_query($sql,$db); + while ($myrow = DB_fetch_array($result)) { + echo '<option value="' . $myrow['categoryid'] . '">' . $myrow['categoryid'] . ' - ' .$myrow['categorydescription'] . '</option>'; + } //end while loop echo '<tr><td>' . _('Sort') . ":</td><td><select name='Sort'>"; - echo "<option selected value='extcost'>" . _('Extended Shortage Dollars')."</option>"; - echo "<option value='stockid'>" . _('Part Number')."</option>"; + echo "<option selected value='extcost'>" . _('Extended Shortage Dollars').'</option>'; + echo "<option value='stockid'>" . _('Part Number').'</option>'; echo '</select></td></tr>'; echo '<tr><td>' . _('Print Option') . ":</td><td><select name='Fill'>"; - echo "<option selected value='yes'>" . _('Print With Alternating Highlighted Lines')."</option>"; - echo "<option value='no'>" . _('Plain Print')."</option>"; + echo "<option selected value='yes'>" . _('Print With Alternating Highlighted Lines').'</option>'; + echo "<option value='no'>" . _('Plain Print').'</option>'; echo '</select></td></tr>'; echo "</table><br><div class='centre'><input type=submit name='PrintPDF' value='" . _('Print PDF') . "'></div>"; Modified: trunk/PDFQuotation.php =================================================================== --- trunk/PDFQuotation.php 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/PDFQuotation.php 2011-02-27 09:18:42 UTC (rev 4500) @@ -1,10 +1,7 @@ <?php /* $Id$*/ -/* $Revision: 1.11 $ */ -//$PageSecurity = 2; - include('includes/session.inc'); include('includes/SQL_CommonFunctions.inc'); Modified: trunk/StockUsage.php =================================================================== --- trunk/StockUsage.php 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/StockUsage.php 2011-02-27 09:18:42 UTC (rev 4500) @@ -2,7 +2,6 @@ /* $Id$*/ -//$PageSecurity = 2; include('includes/session.inc'); @@ -93,32 +92,38 @@ /*HideMovt ==1 if the movement was only created for the purpose of a transaction but is not a physical movement eg. A price credit will create a movement record for the purposes of display on a credit note but there is no physical stock movement - it makes sense honest ??? */ + +$CurrentPeriod = GetPeriod(Date($_SESSION['DefaultDateFormat']),$db); + if (isset($_POST['ShowUsage'])){ if($_POST['StockLocation']=='All'){ $sql = "SELECT periods.periodno, periods.lastdate_in_period, - SUM(-stockmoves.qty) AS qtyused - FROM stockmoves INNER JOIN periods - ON stockmoves.prd=periods.periodno - WHERE (stockmoves.type=10 OR stockmoves.type=11 OR stockmoves.type=28) - AND stockmoves.hidemovt=0 - AND stockmoves.stockid = '" . $StockID . "' + SUM(CASE WHEN (stockmoves.type=10 Or stockmoves.type=11 OR stockmoves.type=28) + AND stockmoves.hidemovt=0 + AND stockmoves.stockid = '" . $StockID . "' + THEN -stockmoves.qty ELSE 0 END) AS qtyused + FROM periods LEFT JOIN stockmoves + ON periods.periodno=stockmoves.prd + WHERE periods.periodno <='" . $CurrentPeriod . "' GROUP BY periods.periodno, periods.lastdate_in_period ORDER BY periodno DESC LIMIT " . $_SESSION['NumberOfPeriodsOfStockUsage']; } else { $sql = "SELECT periods.periodno, periods.lastdate_in_period, - SUM(-stockmoves.qty) AS qtyused - FROM stockmoves INNER JOIN periods - ON stockmoves.prd=periods.periodno - WHERE (stockmoves.type=10 Or stockmoves.type=11 OR stockmoves.type=28) - AND stockmoves.hidemovt=0 - AND stockmoves.loccode='" . $_POST['StockLocation'] . "' - AND stockmoves.stockid = '" . $StockID . "' + SUM(CASE WHEN (stockmoves.type=10 Or stockmoves.type=11 OR stockmoves.type=28) + AND stockmoves.hidemovt=0 + AND stockmoves.stockid = '" . $StockID . "' + AND stockmoves.loccode='" . $_POST['StockLocation'] . "' + THEN -stockmoves.qty ELSE 0 END) AS qtyused + FROM periods LEFT JOIN stockmoves + ON periods.periodno=stockmoves.prd + WHERE periods.periodno <='" . $CurrentPeriod . "' GROUP BY periods.periodno, periods.lastdate_in_period ORDER BY periodno DESC LIMIT " . $_SESSION['NumberOfPeriodsOfStockUsage']; + } $MovtsResult = DB_query($sql, $db); if (DB_error_no($db) !=0) { Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/WorkOrderEntry.php 2011-02-27 09:18:42 UTC (rev 4500) @@ -2,8 +2,6 @@ /* $Id$*/ -//$PageSecurity = 10; - include('includes/session.inc'); $title = _('Work Order Entry'); include('includes/header.inc'); @@ -252,9 +250,9 @@ if (isset($_POST['submit'])) { //The update button has been clicked - echo '<div class=centre><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Enter a new work order') . '</a>'; - echo '<br><a href="' . $rootpath . '/SelectWorkOrder.php?' . SID . '">' . _('Select an existing work order') . '</a>'; - echo '<br><a href="'. $rootpath . '/WorkOrderCosting.php?' . SID . '&WO=' . $_REQUEST['WO'] . '">' . _('Go to Costing'). '</a></div>'; + echo '<div class=centre><a href="' . $_SERVER['PHP_SELF'] .'">' . _('Enter a new work order') . '</a>'; + echo '<br><a href="' . $rootpath . '/SelectWorkOrder.php">' . _('Select an existing work order') . '</a>'; + echo '<br><a href="'. $rootpath . '/WorkOrderCosting.php&WO=' . $_REQUEST['WO'] . '">' . _('Go to Costing'). '</a></div>'; $Input_Error = false; //hope for the best for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ @@ -659,9 +657,6 @@ echo "<script>defaultControl(document.forms[0].OutputQty".$_GET['Line'].");</script>"; } - echo '</form>'; - include('includes/footer.inc'); - ?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-02-27 04:53:34 UTC (rev 4499) +++ trunk/doc/Change.log.html 2011-02-27 09:18:42 UTC (rev 4500) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>27/2/11: Phil/Tim/Peter launchpad added category option for MRPShortages.php </p> <p>27/2/11: Phil fix units deletion issue reported by Exson in UnitsOfMeasure.php script - checked for none existant units field in contracts table - removed the check</p> <p>22/2/11: Phil fix PDFTopItems.php for changed variable names - now using CamelCase tried to rework to conform</p> <p>22/2/11: Phil remove options for PDFLanguage that are not unique in WWW_Users.php - make it default to the users settings in the SESSION for UserSettings.php</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |