|
From: <dai...@us...> - 2011-09-21 09:41:27
|
Revision: 4699
http://web-erp.svn.sourceforge.net/web-erp/?rev=4699&view=rev
Author: daintree
Date: 2011-09-21 09:41:21 +0000 (Wed, 21 Sep 2011)
Log Message:
-----------
number_formats
Modified Paths:
--------------
trunk/PricesBasedOnMarkUp.php
trunk/PricesByCost.php
trunk/Prices_Customer.php
trunk/PrintCheque.php
Modified: trunk/PricesBasedOnMarkUp.php
===================================================================
--- trunk/PricesBasedOnMarkUp.php 2011-09-21 07:32:16 UTC (rev 4698)
+++ trunk/PricesBasedOnMarkUp.php 2011-09-21 09:41:21 UTC (rev 4699)
@@ -1,9 +1,6 @@
<?php
-/* $Revision: 1.9 $ */
/* $Id$*/
-//$PageSecurity=11;
-
include('includes/session.inc');
$title=_('Update Pricing');
include('includes/header.inc');
@@ -48,7 +45,7 @@
<td><select name="CurrCode">';
if (!isset($_POST['CurrCode'])){
- echo '<option selected value=0>' . _('No Price List Currency Selected');
+ echo '<option selected value=0>' . _('No Price List Currency Selected') . '</option>';
}
while ($Currencies=DB_fetch_array($result)){
@@ -94,7 +91,7 @@
echo '<option selected VALUE=0>' . _('No Price List Selected') . '</option>';
}
while ($PriceLists=DB_fetch_array($PricesResult)){
- if (isset($_POST['BasePriceList']) and $_POST['BasePriceList']==$PriceLists['typeabbrev']){
+ if (isset($_POST['BasePriceList']) AND $_POST['BasePriceList']==$PriceLists['typeabbrev']){
echo '<option selected value="' . $PriceLists['typeabbrev'] . '">' . $PriceLists['sales_type'] . '</option>';
} else {
echo '<option value="' . $PriceLists['typeabbrev'] . '">' . $PriceLists['sales_type'] . '</option>';
@@ -161,10 +158,10 @@
}
echo '<tr><td>' . _('Percentage Increase (positive) or decrease (negative)') . '</td>
- <td><input type="text" name="IncreasePercent" class=number size=4 maxlength=4 VALUE="' . $_POST['IncreasePercent'] . '"></td></tr></table>';
+ <td><input type="text" name="IncreasePercent" class="number" size="4" maxlength="4" value="' . $_POST['IncreasePercent'] . '"></td></tr></table>';
-echo '<p><div class="centre"><input type=submit name="UpdatePrices" VALUE="' . _('Update Prices') . '\' onclick="return confirm(\'' . _('Are you sure you wish to update or add all the prices according to the criteria selected?') . '\');"></div>';
+echo '<p><div class="centre"><input type="submit" name="UpdatePrices" value="' . _('Update Prices') . '\' onclick="return confirm(\'' . _('Are you sure you wish to update or add all the prices according to the criteria selected?') . '\');"></div>';
echo '</form>';
@@ -247,7 +244,7 @@
AND categoryid <='" . $_POST['StkCatTo'] . "'";
$PartsResult = DB_query($sql,$db);
- $IncrementPercentage = $_POST['IncreasePercent']/100;
+ $IncrementPercentage = filter_number_format($_POST['IncreasePercent']/100);
$CurrenciesResult = DB_query("SELECT rate FROM currencies WHERE currabrev='" . $_POST['CurrCode'] . "'",$db);
$CurrencyRow = DB_fetch_row($CurrenciesResult);
@@ -300,7 +297,7 @@
prnMsg(_('The cost for this item is not set up or is set up as less than or equal to zero - no price changes will be made based on zero cost items. The item concerned is:') . ' ' . $myrow['stockid'],'warn');
}
}
-
+ $_POST['RoundingFactor'] = filter_number_format($_POST['RoundingFactor']);
if ($_POST['CostType']!='OtherPriceList'){
$RoundedPrice = round(($Cost * (1+ $IncrementPercentage) * $CurrencyRate+($_POST['RoundingFactor']/2))/$_POST['RoundingFactor']) * $_POST['RoundingFactor'];
if ($RoundedPrice <=0){
@@ -315,15 +312,15 @@
if ($Cost > 0) {
$CurrentPriceResult = DB_query("SELECT price,
- startdate,
- enddate
- FROM prices
- WHERE typeabbrev= '" . $_POST['PriceList'] . "'
- AND debtorno =''
- AND currabrev='" . $_POST['CurrCode'] . "'
- AND startdate <='" . Date('Y-m-d') . "'
- AND (enddate>='" . Date('Y-m-d') . "' OR enddate='0000-00-00')
- AND stockid='" . $myrow['stockid'] . "'",$db);
+ startdate,
+ enddate
+ FROM prices
+ WHERE typeabbrev= '" . $_POST['PriceList'] . "'
+ AND debtorno =''
+ AND currabrev='" . $_POST['CurrCode'] . "'
+ AND startdate <='" . Date('Y-m-d') . "'
+ AND (enddate>='" . Date('Y-m-d') . "' OR enddate='0000-00-00')
+ AND stockid='" . $myrow['stockid'] . "'",$db);
if (DB_num_rows($CurrentPriceResult)==1){
$DayPriorToNewPrice = DateAdd($_POST['PriceStartDate'],'d',-1);
$CurrentPriceRow = DB_fetch_array($CurrentPriceResult);
@@ -336,8 +333,8 @@
AND stockid='" . $myrow['stockid'] . "'";
$ErrMsg =_('Error updating prices for') . ' ' . $myrow['stockid'] . ' ' . _('because');
$result = DB_query($UpdateSQL,$db,$ErrMsg);
-
- }
+
+ }
$sql = "INSERT INTO prices (stockid,
typeabbrev,
currabrev,
@@ -349,11 +346,11 @@
'" . $_POST['CurrCode'] . "',
'" . FormatDateForSQL($_POST['PriceStartDate']) . "',
'" . $SQLEndDate . "',
- '" . $RoundedPrice . "')";
+ '" . filter_number_format($RoundedPrice) . "')";
$ErrMsg =_('Error inserting new price for') . ' ' . $myrow['stockid'] . ' ' . _('because');
$result = DB_query($sql,$db,$ErrMsg);
prnMsg(_('Inserting new price for') . ' ' . $myrow['stockid'] . ' ' . _('to') . ' ' . $RoundedPrice,'info');
-
+
}// end if cost > 0
}//end while loop around items in the category
}
Modified: trunk/PricesByCost.php
===================================================================
--- trunk/PricesByCost.php 2011-09-21 07:32:16 UTC (rev 4698)
+++ trunk/PricesByCost.php 2011-09-21 09:41:21 UTC (rev 4699)
@@ -27,20 +27,20 @@
prices.debtorno,
prices.branchcode,
(stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost) as cost,
- prices.price as price,
- prices.debtorno AS customer,
+ prices.price as price,
+ prices.debtorno AS customer,
prices.branchcode AS branch,
prices.startdate,
prices.enddate,
currencies.decimalplaces,
currencies.rate
- FROM stockmaster INNER JOIN prices
+ FROM stockmaster INNER JOIN prices
ON stockmaster.stockid=prices.stockid
- INNER JOIN currencies
+ INNER JOIN currencies
ON prices.currabrev=currencies.currabrev
- WHERE stockmaster.discontinued = 0
+ WHERE stockmaster.discontinued = 0
" . $Category . "
- AND prices.price" . $Comparator . "(stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost) * '" . $_POST['Margin'] . "'
+ AND prices.price" . $Comparator . "(stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost) * '" . filter_number_format($_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')";
@@ -53,7 +53,7 @@
while ($myrow = DB_fetch_array($result)) {
/*The logic here goes like this:
* 1. If the price at the same start and end date already exists then do nowt!!
- * 2. If not then check if a price with the start date of today already exists - then we should be updating it
+ * 2. If not then check if a price with the start date of today already exists - then we should be updating it
* 3. If not either of the above then insert the new price
*/
$SQLTestExists = "SELECT price FROM prices
@@ -62,13 +62,13 @@
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.startdate ='" . $_POST['StartDate_' . $PriceCounter] . "'
AND prices.enddate ='" . $_POST['EndDate_' . $PriceCounter] . "'
- AND prices.price ='" . $_POST['Price_' . $PriceCounter] . "'";
+ AND prices.price ='" . filter_number_format($_POST['Price_' . $PriceCounter]) . "'";
$TestExistsResult = DB_query($SQLTestExists,$db);
if (DB_num_rows($TestExistsResult)==0){ //the price doesn't currently exist
//now check to see if a new price has already been created from start date of today
-
+
$SQLTestExists = "SELECT price FROM prices
WHERE stockid = '" . $_POST['StockID_' . $PriceCounter] . "'
AND prices.typeabbrev ='" . $_POST['SalesType'] . "'
@@ -79,7 +79,7 @@
$TestExistsResult = DB_query($SQLTestExists,$db);
if (DB_num_rows($TestExistsResult)==1){
//then we are updating
- $SQLUpdate = "UPDATE prices SET price = '" . $_POST['Price_' . $PriceCounter] . "'
+ $SQLUpdate = "UPDATE prices SET price = '" . filter_number_format($_POST['Price_' . $PriceCounter]) . "'
WHERE stockid = '" . $_POST['StockID_' . $PriceCounter] . "'
AND prices.typeabbrev ='" . $_POST['SalesType'] . "'
AND prices.currabrev ='" . $_POST['CurrCode'] . "'
@@ -109,7 +109,7 @@
startdate
) VALUES (
'" . $_POST['StockID_' . $PriceCounter] . "',
- '" . $_POST['Price_' . $PriceCounter] . "',
+ '" . filter_number_format($_POST['Price_' . $PriceCounter]) . "',
'" . $_POST['SalesType'] . "',
'" . $_POST['CurrCode'] . "',
'" . $_POST['DebtorNo_' . $PriceCounter] . "',
@@ -163,7 +163,7 @@
echo '<form action="' .$_SERVER['PHP_SELF'] .'" method="POST" name="update">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo'<input type="hidden" value=' . $_POST['StockCat'] . ' name="StockCat">
- <input type="hidden" value=' . $_POST['Margin'] . ' name="Margin">
+ <input type="hidden" value=' . filter_number_format($_POST['Margin']) . ' name="Margin">
<input type="hidden" value=' . $_POST['CurrCode'] . ' name="CurrCode">
<input type="hidden" value=' . $_POST['Comparator'] . ' name="Comparator">
<input type="hidden" value=' . $_POST['SalesType'] . ' name="SalesType">';
@@ -186,11 +186,11 @@
} /*end of else Cost */
//variables for update
- echo '<input type="hidden" value=' . $myrow['stockid'] . ' name="StockID_' . $PriceCounter .'">
- <input type="hidden" value=' . $myrow['debtorno'] . ' name="DebtorNo_' . $PriceCounter .'">
- <input type="hidden" value=' . $myrow['branchcode'] . ' name="BranchCode_' . $PriceCounter .'">
- <input type="hidden" value=' . $myrow['startdate'] . ' name="StartDate_' . $PriceCounter .'">
- <input type="hidden" value=' . $myrow['enddate'] . ' name="EndDate_' . $PriceCounter .'">';
+ echo '<input type="hidden" value=' . $myrow['stockid'] . ' name="StockID_' . $PriceCounter .'" />
+ <input type="hidden" value=' . $myrow['debtorno'] . ' name="DebtorNo_' . $PriceCounter .'" />
+ <input type="hidden" value=' . $myrow['branchcode'] . ' name="BranchCode_' . $PriceCounter .'" />
+ <input type="hidden" value=' . $myrow['startdate'] . ' name="StartDate_' . $PriceCounter .'" />
+ <input type="hidden" value=' . $myrow['enddate'] . ' name="EndDate_' . $PriceCounter .'" />';
//variable for current margin
if ($myrow['price'] != 0){
$CurrentGP = (($myrow['price']/$myrow['rate'])-$Cost)*100 / ($myrow['price']/$myrow['rate']);
@@ -198,7 +198,7 @@
$CurrentGP = 0;
}
//variable for proposed
- $ProposedPrice = $Cost * $_POST['Margin'];
+ $ProposedPrice = $Cost * filter_number_format($_POST['Margin']);
if ($myrow['enddate']=='0000-00-00'){
$EndDateDisplay = _('No End Date');
} else {
@@ -210,10 +210,10 @@
<td>' . $myrow['branch'] . '</td>
<td>' . ConvertSQLDate($myrow['startdate']) . '</td>
<td>' . $EndDateDisplay . '</td>
- <td class="number">' . locale_number_format($Cost, $_SESSION['CompanyRecord']['decimalplaces']) . '</td>
+ <td class="number">' . locale_money_format($Cost, $_SESSION['CompanyRecord']['decimalplaces']) . '</td>
<td class="number">' . locale_number_format($CurrentGP, 1) . '%</td>
- <td class="number">' . locale_number_format($ProposedPrice, $myrow['decimalplaces']) . '</td>
- <td><input type="text" class="number" name="Price_' . $PriceCounter . '" maxlength=14 size=10 value="' . $myrow['price'] . '"></td>
+ <td class="number">' . locale_money_format($ProposedPrice, $myrow['decimalplaces']) . '</td>
+ <td><input type="text" class="number" name="Price_' . $PriceCounter . '" maxlength=14 size=10 value="' . locale_money_format($myrow['price'],$myrow['decimalplaces']) . '"></td>
</tr> ';
$PriceCounter++;
} //end of looping
@@ -254,7 +254,7 @@
if (!isset($_POST['Margin'])){
$_POST['Margin']=1;
}
- echo '<td><input type="text" class="number" name="Margin" MAXLENGTH =8 size=8 value=' .$_POST['Margin'] . '></td></tr>';
+ echo '<td><input type="text" class="number" name="Margin" maxlength="8" size="8" value=' .$_POST['Margin'] . '></td></tr>';
$result = DB_query("SELECT typeabbrev, sales_type FROM salestypes", $db);
echo '<tr><td>' . _('Sales Type') . '/' . _('Price List') . ':</td>
<td><select name="SalesType">';
Modified: trunk/Prices_Customer.php
===================================================================
--- trunk/Prices_Customer.php 2011-09-21 07:32:16 UTC (rev 4698)
+++ trunk/Prices_Customer.php 2011-09-21 09:41:21 UTC (rev 4699)
@@ -70,7 +70,7 @@
//first off validate inputs sensible
- if (!is_double((double) trim($_POST['Price'])) OR $_POST['Price']=="") {
+ if (!is_numeric(filter_number_format($_POST['Price'])) OR $_POST['Price']=='') {
$InputError = 1;
$msg = _('The price entered must be numeric');
}
@@ -105,13 +105,13 @@
$msg = _('The end date is expected to be after today. There is no point entering a new price where the effective date is before today!');
}
- if ((isset($_POST['Editing']) and $_POST['Editing']=='Yes') AND mb_strlen($Item)>1 AND $InputError !=1) {
+ if ((isset($_POST['Editing']) AND $_POST['Editing']=='Yes') AND mb_strlen($Item)>1 AND $InputError !=1) {
//editing an existing price
$sql = "UPDATE prices SET typeabbrev='" . $SalesType . "',
currabrev='" . $CurrCode . "',
- price='" . $_POST['Price'] . "',
+ price='" . filter_number_format($_POST['Price']) . "',
branchcode='" . $_POST['Branch'] . "',
startdate='" . FormatDateForSQL($_POST['StartDate']) . "',
enddate='" . FormatDateForSQL($_POST['EndDate']) . "'
@@ -138,7 +138,7 @@
'".$SalesType."',
'".$CurrCode."',
'" . $_SESSION['CustomerID'] . "',
- '" . $_POST['Price'] . "',
+ '" . filter_number_format($_POST['Price']) . "',
'" . $_POST['Branch'] . "',
'" . FormatDateForSQL($_POST['StartDate']) . "',
'" . FormatDateForSQL($_POST['EndDate']) . "'
@@ -294,7 +294,7 @@
echo '<input type=hidden name="Editing" value="Yes">';
echo '<input type=hidden name="OldStartDate" value="' . $_GET['StartDate'] .'">';
echo '<input type=hidden name="OldEndDate" value="' . $_GET['EndDate'] . '">';
- $_POST['Price']=$_GET['Price'];
+ $_POST['Price']=filter_number_format($_GET['Price']);
$_POST['Branch']=$_GET['Branch'];
$_POST['StartDate'] = ConvertSQLDate($_GET['StartDate']);
if (Is_Date($_GET['EndDate'])){
Modified: trunk/PrintCheque.php
===================================================================
--- trunk/PrintCheque.php 2011-09-21 07:32:16 UTC (rev 4698)
+++ trunk/PrintCheque.php 2011-09-21 09:41:21 UTC (rev 4699)
@@ -13,7 +13,7 @@
$PageNumber=1;
$line_height=12;
-$result = db_query("SELECT hundredsname FROM currencies WHERE currabrev='" . $_SESSION['PaymentDetail']->Currency . "'",$db);
+$result = db_query("SELECT hundredsname, decimalplaces FROM currencies WHERE currabrev='" . $_SESSION['PaymentDetail']->Currency . "'",$db);
If (DB_num_rows($result) == 0){
include ('includes/header.inc');
@@ -24,6 +24,7 @@
$CurrencyRow = db_fetch_row($result);
$HundredsName = $CurrencyRow[0];
+$CurrDecimalPlaces = $CurrencyRow[1];
// cheque
$YPos= $Page_Height-5*$line_height;
@@ -34,7 +35,7 @@
$LeftOvers = $pdf->addTextWrap(75,$YPos,475,$FontSize,$AmountWords, 'left');
$YPos -= 1*$line_height;
$LeftOvers = $pdf->addTextWrap($Page_Width-225,$YPos,100,$FontSize,$_SESSION['PaymentDetail']->DatePaid, 'left');
-$LeftOvers = $pdf->addTextWrap($Page_Width-75,$YPos,75,$FontSize,locale_number_format(round($_SESSION['PaymentDetail']->Amount,2),2), 'left');
+$LeftOvers = $pdf->addTextWrap($Page_Width-75,$YPos,75,$FontSize,locale_money_format($_SESSION['PaymentDetail']->Amount,$CurrDecimalPlaces), 'left');
$YPos -= 1*$line_height;
$LeftOvers = $pdf->addTextWrap(75,$YPos,300,$FontSize,$_SESSION['PaymentDetail']->SuppName, 'left');
@@ -51,7 +52,7 @@
$YPos -= 2*$line_height;
$LeftOvers = $pdf->addTextWrap(75,$YPos,300,$FontSize, $AmountWords, 'left');
-$LeftOvers = $pdf->addTextWrap(375,$YPos,100,$FontSize, locale_number_format($_SESSION['PaymentDetail']->Amount,2), 'right');
+$LeftOvers = $pdf->addTextWrap(375,$YPos,100,$FontSize, locale_money_format($_SESSION['PaymentDetail']->Amount,$CurrDecimalPlaces), 'right');
// remittance advice 1
@@ -66,7 +67,7 @@
$LeftOvers = $pdf->addTextWrap(25,$YPos,75,$FontSize,$_SESSION['PaymentDetail']->DatePaid, 'left');
$LeftOvers = $pdf->addTextWrap(100,$YPos,100,$FontSize,$_SESSION['PaymentDetail']->SupplierID, 'left');
$LeftOvers = $pdf->addTextWrap(250,$YPos,75,$FontSize,$_GET['ChequeNum'], 'left');
-$LeftOvers = $pdf->addTextWrap(350,$YPos,75,$FontSize,locale_number_format(round($_SESSION['PaymentDetail']->Amount,2),2), 'left');
+$LeftOvers = $pdf->addTextWrap(350,$YPos,75,$FontSize,locale_money_format($_SESSION['PaymentDetail']->Amount,$CurrDecimalPlaces), 'left');
// remittance advice 2
$YPos -= 15*$line_height;
@@ -80,7 +81,7 @@
$LeftOvers = $pdf->addTextWrap(25,$YPos,75,$FontSize,$_SESSION['PaymentDetail']->DatePaid, 'left');
$LeftOvers = $pdf->addTextWrap(100,$YPos,100,$FontSize,$_SESSION['PaymentDetail']->SupplierID, 'left');
$LeftOvers = $pdf->addTextWrap(250,$YPos,75,$FontSize,$_GET['ChequeNum'], 'left');
-$LeftOvers = $pdf->addTextWrap(350,$YPos,75,$FontSize,locale_number_format(round($_SESSION['PaymentDetail']->Amount,2),2), 'left');
+$LeftOvers = $pdf->addTextWrap(350,$YPos,75,$FontSize,locale_money_format($_SESSION['PaymentDetail']->Amount,$CurrDecimalPlaces), 'left');
$pdf->OutputD($_SESSION['DatabaseName'] . '_Cheque_' . date('Y-m-d') . '_ChequeNum_' . $_GET['ChequeNum'] . '.pdf');
$pdf->__destruct();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|