[Weberp-svn] SF.net SVN: weberp:[8131] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2011-09-11 21:39:18
|
Revision: 8131 http://weberp.svn.sourceforge.net/weberp/?rev=8131&view=rev Author: tim_schofield Date: 2011-09-11 21:39:12 +0000 (Sun, 11 Sep 2011) Log Message: ----------- Show numbers in correct formatting for the users locale Modified Paths: -------------- trunk/Prices.php trunk/includes/class.pdf.php Modified: trunk/Prices.php =================================================================== --- trunk/Prices.php 2011-09-11 21:38:57 UTC (rev 8130) +++ trunk/Prices.php 2011-09-11 21:39:12 UTC (rev 8131) @@ -67,7 +67,7 @@ //first off validate inputs sensible // This gives some date in 1999?? $ZeroDate = Date($_SESSION['DefaultDateFormat'],Mktime(0,0,0,0,0,0)); - + $_POST['Price'] = filter_currency_input($_POST['Price']); if (!is_double((double) trim($_POST['Price'])) OR $_POST['Price']=='') { $InputError = 1; prnMsg( _('The price entered must be numeric'),'error'); @@ -107,7 +107,7 @@ $sql = "UPDATE prices SET typeabbrev='" . $_POST['TypeAbbrev'] . "', currabrev='" . $_POST['CurrAbrev'] . "', - price='" . $_POST['Price'] . "', + price='" . filter_currency_input($_POST['Price']) . "', units='" . $_POST['Units'] . "', conversionfactor='" . $_POST['ConversionFactor'] . "', decimalplaces='" . $_POST['DecimalPlaces'] . "', @@ -154,15 +154,15 @@ startdate, enddate, price) - values ('".$Item."', + VALUES ('".$Item."', '" . $_POST['TypeAbbrev'] . "', '" . $_POST['CurrAbrev'] . "', '" . $_POST['Units'] . "', - '" . $_POST['ConversionFactor'] . "', + '" . filter_number_input($_POST['ConversionFactor']) . "', '" . $_POST['DecimalPlaces'] . "', '" . FormatDateForSQL($_POST['StartDate']) . "', '" . $SQLEndDate. "', - '" . $_POST['Price'] . "')"; + '" . filter_currency_input($_POST['Price']) . "')"; $ErrMsg = _('The new price could not be added'); $result = DB_query($sql,$db,$ErrMsg); @@ -259,9 +259,9 @@ echo '<td>'.$myrow['sales_type'].'</td> <td>'.$myrow['currency'].'</td> <td>'.$myrow['units'].'</td> - <td class="number">'.$myrow['conversionfactor'].'</td> + <td class="number">'.stock_number_format($myrow['conversionfactor'],4).'</td> <td class="number">'.$myrow['decimalplaces'].'</td> - <td class="number">'.number_format($myrow['price'],2).'</td> + <td class="number">'.currency_number_format($myrow['price'],$myrow['currabrev']).'</td> <td>'.ConvertSQLDate($myrow['startdate']).'</td> <td>'.$EndDateDisplay.'</td> </tr>'; @@ -269,9 +269,9 @@ echo '<td>'.$myrow['sales_type'].'</td> <td>'.$myrow['currency'].'</td> <td>'.$myrow['units'].'</td> - <td class="number">'.$myrow['conversionfactor'].'</td> + <td class="number">'.stock_number_format($myrow['conversionfactor']).'</td> <td class="number">'.$myrow['decimalplaces'].'</td> - <td class="number">'.number_format($myrow['price'],2).'</td> + <td class="number">'.currency_number_format($myrow['price'],$myrow['currabrev']).'</td> <td>'.ConvertSQLDate($myrow['startdate']).'</td> <td>'.$EndDateDisplay.'</td> </tr>'; @@ -397,18 +397,18 @@ echo '<tr><td>'. _('Decimal Places') . '<br />'._('to display').'</td>'; if(isset($_POST['DecimalPlaces'])) { - echo '<td><input type="text" class="number" name="DecimalPlaces" size="8" maxlength="8" value="' . $_POST['DecimalPlaces'] . '" />'; + echo '<td><input type="text" class="number" name="DecimalPlaces" size="8" maxlength="8" value="' . stock_number_format($_POST['DecimalPlaces'],0) . '" />'; } else { - echo '<td><input type="text" class="number" name="DecimalPlaces" size="8" maxlength="8" value=0" />'; + echo '<td><input type="text" class="number" name="DecimalPlaces" size="8" maxlength="8" value="0" />'; } echo '</td></tr>'; echo '<tr><td>'. _('Conversion Factor') . '<br />'._('to stock units').'</td>'; if(isset($_POST['ConversionFactor'])) { - echo '<td><input type="text" class="number" name="ConversionFactor" size="8" maxlength="8" value="' . $_POST['ConversionFactor'] . '" />'; + echo '<td><input type="text" class="number" name="ConversionFactor" size="8" maxlength="8" value="' . stock_number_format($_POST['ConversionFactor'],4) . '" />'; } else { - echo '<td><input type="text" class="number" name="ConversionFactor" size="8" maxlength="8" value="1" />'; + echo '<td><input type="text" class="number" name="ConversionFactor" size="8" maxlength="8" value="' . stock_number_format(1.0000,4) . '" />'; } echo '</td></tr>'; @@ -416,9 +416,9 @@ echo '<tr><td>'. _('Price') . ':</td>'; if(isset($_POST['Price'])) { - echo '<td><input type="text" class="number" name="Price" size="12" maxlength="11" value="' . $_POST['Price'] . '" />'; + echo '<td><input type="text" class="number" name="Price" size="12" maxlength="11" value="' . currency_number_format($_POST['Price'],$_POST['CurrAbrev']) . '" />'; } else { - echo '<td><input type="text" class="number" name="Price" size="12" maxlength="11" value="0" />'; + echo '<td><input type="text" class="number" name="Price" size="12" maxlength="11" value="' . currency_number_format(0,$_POST['CurrAbrev']) . '" />'; } echo '</td></tr>'; Modified: trunk/includes/class.pdf.php =================================================================== --- trunk/includes/class.pdf.php 2011-09-11 21:38:57 UTC (rev 8130) +++ trunk/includes/class.pdf.php 2011-09-11 21:39:12 UTC (rev 8131) @@ -150,8 +150,8 @@ if ($angle != 0){ $a = -1*deg2rad((float)$angle); $tmp = "\n q "; - $tmp .= sprintf('%.3f',cos($a)).' '.sprintf('%.3f',(-1.0*sin($a))).' '.sprintf('%.3f',sin($a)).' '.sprintf('%.3f',cos($a)).' '; - $tmp .= sprintf('%.3f',$x0).' '.sprintf('%.3f',$y0).' cm'; + $tmp .= number_format(cos($a),3,'.','').' '.number_format((-1*sin($a)),3,'.','').' '.number_format(sin($a),3,'.','').' '.number_format(cos($a),3,'.','').' '; + $tmp .= number_format($x0,3,'.','').' '.number_format($y0,3,'.','').' cm'; $x0=0; $y0=0; } else { @@ -164,7 +164,7 @@ $c0 = -$r1*sin($t1); $d0 = $r2*cos($t1); - $tmp.="\n".sprintf('%.3f',$a0).' '.sprintf('%.3f',$b0).' m '; + $tmp.="\n".number_format($a0,3,'.','').' '.number_format($b0,3,'.','').' m '; for ($i=1;$i<=$nSeg;$i++){ // draw this bit of the total curve $t1 = $i*$dt+$astart; @@ -172,8 +172,8 @@ $b1 = $y0+$r2*sin($t1); $c1 = -$r1*sin($t1); $d1 = $r2*cos($t1); - $tmp.="\n".sprintf('%.3f',($a0+$c0*$dtm)).' '.sprintf('%.3f',($b0+$d0*$dtm)); - $tmp.= ' '.sprintf('%.3f',($a1-$c1*$dtm)).' '.sprintf('%.3f',($b1-$d1*$dtm)).' '.sprintf('%.3f',$a1).' '.sprintf('%.3f',$b1).' c'; + $tmp.="\n".number_format(($a0+$c0*$dtm),3,'.','').' '.number_format($b0+$d0*$dtm,3,'.',''); + $tmp.= ' '.number_format(($a1-$c1*$dtm),3,'.','').' '.number_format(($b1-$d1*$dtm),3,'.','').' '.number_format($a1,3,'.','').' '.number_format($b1,3,'.','').' c'; $a0=$a1; $b0=$b1; $c0=$c1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |