navigation  interaction  search

 other resources

Changeset 192

Show
Ignore:
Timestamp:
02/22/07 17:58:16
Author:
brieb
Message:

Implements #24

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phpbms/common/javascript/common.js

    r191 r192  
    179179} 
    180180 
    181 function englishTime(thedate){ 
    182                         var ampm = " AM"; 
    183                         var hours = thedate.getHours() 
    184                         if(hours==0) hours=12; 
    185                         if (hours>12){ 
    186                                 var ampm = " PM"; 
    187                                 hours=hours-12 
    188                         } 
    189                         var minutes=thedate.getMinutes(); 
    190                         if(minutes<10) 
    191                                 minutes="0"+minutes; 
    192                         return hours+":"+minutes+ampm; 
    193 } 
    194  
    195 function englishDate(thedate){ 
    196         return (thedate.getMonth()+1)+"/"+thedate.getDate()+"/"+thedate.getFullYear();   
    197 } 
    198  
    199 function dateFromField(englishdate,englishtime){ 
    200         var theyear= parseInt(englishdate.substring(englishdate.lastIndexOf("/")+1),10); 
    201         var themonth= parseInt(englishdate.substring(0,englishdate.indexOf("/")),10)-1; 
    202         var theday= parseInt(englishdate.substring(englishdate.indexOf("/")+1,englishdate.lastIndexOf("/")),10); 
    203         var thedate= new Date(theyear,themonth,theday); 
    204         if(englishtime){ 
    205                 var thehour=parseInt(englishtime.substring(0,englishtime.indexOf(":")),10); 
    206                 var theminute=parseInt(englishtime.substring(englishtime.indexOf(":")+1,englishtime.indexOf(" ")),10); 
    207                 var AMPM=englishtime.substring(englishtime.indexOf(" ")+1); 
    208                 if(AMPM=="PM" && thehour!=12) 
    209                         thehour+=12; 
    210                 else if (AMPM=="AM" && thehour==12) 
    211                         thehour=0; 
    212                 thedate.setHours(thehour,theminute); 
    213         } 
    214         return thedate;  
    215 } 
    216181 
    217182/* DATE AND TIME --------------------------------------------------------------- */ 
    218183/* ----------------------------------------------------------------------------- */ 
     184function stringToDatetime(sDate,sTime){ 
     185        thedate=stringToDate(sDate) 
     186        if(sTime){ 
     187                var thetime=stringToTime(sTime); 
     188                thedate.setHours(thetime.getHours()); 
     189                thedate.setMinutes(thetime.getMinutes()); 
     190                thedate.setSeconds(thetime.getSeconds()); 
     191        } 
     192        return thedate; 
     193} 
     194 
    219195function stringToDate(sDate,format){ 
    220196        if (!format) format=DATE_FORMAT; 
     
    253229        if(thedate){ 
    254230                var sep; 
     231                var month; 
     232                var day; 
    255233                switch(format){ 
    256234                        case "SQL": 
    257                                 sep="-"; 
    258                                 sdate= thedate.getFullYear()+sep+(thedate.getMonth()+1)+sep+thedate.getDate(); 
     235                                sep="-";                         
     236                                month=thedate.getMonth()+1; 
     237                                if(month<10) month="0"+month; 
     238                                day=thedate.getDate(); 
     239                                if(day<10) day="0"+day;                                  
     240                                sdate= thedate.getFullYear()+sep+month+sep+day; 
    259241                        break; 
    260242                         
    261243                        case "English, US": 
    262244                                sep="/"; 
    263                                 sdate= (thedate.getMonth()+1)+sep+thedate.getDate()+sep+thedate.getFullYear(); 
     245                                month=thedate.getMonth()+1; 
     246                                if(month<10) month="0"+month; 
     247                                day=thedate.getDate(); 
     248                                if(day<10) day="0"+day;                                  
     249                                sdate= month+sep+day+sep+thedate.getFullYear(); 
    264250                        break; 
    265251                } 
     
    329315        return sTime; 
    330316} 
     317/* CURRENCY -------------------------------------------------------------------- */ 
     318/* ----------------------------------------------------------------------------- */ 
     319function numberToCurrency(number){ 
     320        var currency=""; 
     321        if(isNaN(parseFloat(number))) number=0; 
     322 
     323        if(number<0) 
     324                currency+="-"; 
     325        number=Math.abs(number); 
     326        currency+=CURRENCY_SYMBOL; 
     327        if(number>0 && number <0) 
     328                currency+="0"; 
     329 
     330        var withThousands=parseInt(number).toString(); 
     331        var objRegExp  = new RegExp('(-?[0-9]+)([0-9]{3})'); 
     332        while(objRegExp.test(withThousands)) 
     333       withThousands = withThousands.replace(objRegExp, '$1'+THOUSANDS_SEPARATOR+'$2'); 
     334 
     335        var lessthanone=Math.round((number-Math.round(number))*(Math.pow(10,CURRENCY_ACCURACY))).toString(); 
     336        while(lessthanone.length<CURRENCY_ACCURACY) 
     337                lessthanone="0"+lessthanone; 
     338        currency+=withThousands; 
     339        if(CURRENCY_ACCURACY!=0) 
     340                currency+=DECIMAL_SYMBOL+lessthanone; 
     341        return currency; 
     342} 
     343 
     344function currencyToNumber(currency){ 
     345        var number=0; 
     346        var thousSep=THOUSANDS_SEPARATOR; 
     347        if(thousSep=="." || thousSep=="*" || thousSep=="[" || thousSep=="]" || thousSep=="-" || thousSep=="+") 
     348                thousSep="\\"+thousSep; 
     349        var objRegExp  = new RegExp(thousSep,"g"); 
     350        currency=currency.replace(objRegExp,""); 
     351        currency=currency.replace(CURRENCY_SYMBOL,""); 
     352        currency=currency.replace(DECIMAL_SYMBOL,"."); 
     353        if(currency) 
     354                number=parseFloat(currency); 
     355        return number 
     356} 
    331357 
    332358/* MODAL ----------------------------------------------------------------------- */ 
  • trunk/phpbms/common/javascript/fields.js

    r191 r192  
    218218// checks and formats a field to dollars 
    219219function validateCurrency(theitem){ 
    220         var theCurrency=theitem.value; 
    221         var i; 
    222         var thenumber=""; 
    223         var newdollar; 
    224          
    225         for(i=0;i<theCurrency.length;i++){ 
    226                 if (theCurrency.charAt(i)!="$" && theCurrency.charAt(i)!="+" && theCurrency.charAt(i)!=",") thenumber=thenumber+theCurrency.charAt(i); 
    227         } 
    228         //if the first number is a ".", add a 0 
    229         if (thenumber.charAt(0)==".") thenumber="0"+thenumber; 
    230  
    231         //get rid of trailing zeros and possibly "." 
    232         while(thenumber.charAt(thenumber.length-1)=="0" && thenumber.indexOf(".")!=-1) thenumber=thenumber.substring(0,thenumber.length-1); 
    233         if(thenumber.charAt(thenumber.length-1)==".") thenumber=thenumber.substring(0,thenumber.length-1); 
    234  
    235         theitem.value=formatCurrency(thenumber); 
     220        theitem.value=numberToCurrency(thenumber); 
    236221         
    237222        //in case the field has an additional onchange code to be run 
     
    246231} 
    247232 
    248 function formatCurrency(thenumber){ 
    249         var newdollar,retval 
    250         thenumber=thenumber.toString();  
    251         //check for number               
    252         if (isNaN(parseFloat(thenumber)) || thenumber.length!=((parseFloat(thenumber)).toString()).length) thenumber="0.00"; 
    253  
    254         // add the dollar sign... remember that if it is a negative number, the minus sign goes in front 
    255         if(thenumber.charAt(0)=="-") { 
    256                         newdollar="-$"; 
    257                         thenumber=thenumber.substring(1,thenumber.length); 
    258                 } else newdollar="$"; 
    259  
    260         var big_string = ""+(Math.round(100*(Math.abs(thenumber))))  //rounding the absolute value times 100 
    261         var biglen = big_string.length                            //how the string gets handled depends on its length 
    262         if (biglen == 0)                   //null 
    263                 {retval = "0.00"}  
    264         else if (biglen == 1)              //1 to 9 (.01 to .09 cents) 
    265                 {retval = "0.0"+big_string} 
    266         else if (biglen == 2)              //10 to 99 (.10 to .99 cents) 
    267                 {retval = "0."+big_string} 
    268         else  {                                                   //all cases above 100 ($1.00) 
    269                         //The substring method returns all characters in the string 
    270                         // starting with and including the the first argument, 
    271                         // up to but not including the second argument.   
    272                         var hundredths_digit = big_string.substring(biglen-1,biglen)   
    273                         var tenths_digit = big_string.substring(biglen-2,biglen-1)     
    274                         var integer_digits = big_string.substring(0,biglen-2) 
    275                         // commafy,  borrowed from Danny Goodman, "Javascript Bible" 
    276                         var re = /(-?\d+)(\d{3})/ 
    277                         while (re.test(integer_digits))  { 
    278                                 integer_digits = integer_digits.replace(re, "$1,$2") 
    279                         } 
    280                         retval = integer_digits + "." + tenths_digit + hundredths_digit 
    281         }   
    282     newdollar = newdollar+retval; 
    283          
    284         return newdollar; 
    285 } 
    286  
    287 function currencyToNumber(thecurrency){ 
    288         var i; 
    289         var thenumber=""; 
    290         for(i=0;i<thecurrency.length;i++){ 
    291                 if (thecurrency.charAt(i)!="$" && thecurrency.charAt(i)!="+" && thecurrency.charAt(i)!=",") thenumber=thenumber+thecurrency.charAt(i); 
    292         } 
    293         //if the first number is a ".", add a 0 
    294         if (thenumber.charAt(0)==".") thenumber="0"+thenumber; 
    295  
    296         //get rid of trailing zeros and possibly "." 
    297         while(thenumber.charAt(thenumber.length-1)=="0" && thenumber.indexOf(".")!=-1) thenumber=thenumber.substring(0,thenumber.length-1); 
    298         if(thenumber.charAt(thenumber.length-1)==".") thenumber=thenumber.substring(0,thenumber.length-1); 
    299          
    300         if (isNaN(parseFloat(thenumber)) || thenumber.length!=((parseFloat(thenumber)).toString()).length) thenumber="0.00";     
    301          
    302         thenumber=parseFloat(thenumber); 
    303         return thenumber; 
    304 } 
    305  
    306  
    307 function  processUniqueReqChange(){ 
    308          if (req.readyState == 4) { 
    309                 // only if "OK" 
    310                 if (req.status == 200) {                         
    311                         var response = req.responseXML.documentElement; 
    312                         var thename = response.getElementsByTagName('name')[0].firstChild.data; 
    313                         var isunique = response.getElementsByTagName('isunique')[0].firstChild.data; 
    314                          
    315                         if(isunique==0) 
    316                                 alert("This field requires a unique value.<br/><br/>Another record already exists with this value."); 
    317                 } 
    318         } 
    319 } 
    320233 
    321234function getNumberFromPercentage(thenumber){ 
     
    337250         
    338251        var theurl=path+"checkunique.php?value="+encodeURIComponent(thevalue); 
    339         theurl=theurl+"&table="+thetable
    340         theurl=theurl+"&name="+thename
    341         theurl=theurl+"&field="+thefield
    342         theurl=theurl+"&excludeid="+excludeid
     252        theurl=theurl+"&table="+encodeURIComponent(thetable)
     253        theurl=theurl+"&name="+encodeURIComponent(thename)
     254        theurl=theurl+"&field="+encodeURIComponent(thefield)
     255        theurl=theurl+"&excludeid="+parseInt(excludeid)
    343256 
    344257        loadXMLDoc(theurl,processUniqueReqChange,true); 
  • trunk/phpbms/common/stylesheet/mozilla/forms.css

    r176 r192  
    1414FORM{margin:0px;padding:0px;} 
    1515 
    16  
     16.currency{text-align:right;} 
    1717.uneditable,.uneditable:Focus {background-color:transparent; border-color:#ABB1B1;color:#666666;} 
    1818.disabledtext{color:#CCCCCC;} 
  • trunk/phpbms/common/stylesheet/mozilla/queryresults.css

    r145 r192  
    4141 
    4242.querytable td.queryfooter, .queryfooter{ 
     43        white-space:nowrap; 
    4344        background:#BBBBBB; 
    4445        border:1px solid #999999; 
  • trunk/phpbms/include/common_functions.php

    r191 r192  
    132132 
    133133// date/time functions 
    134 // It will add the quotes for you. 
    135134//===================================================================== 
    136135define("DATE_FORMAT",$_SESSION["date_format"]); 
     
    308307} 
    309308 
     309// Currency functions 
     310//===================================================================== 
     311function numberToCurrency($number){ 
     312        $currency=""; 
     313        if($number<0) 
     314                $currency.="-"; 
     315        $currency.=$_SESSION["currency_symbol"].number_format(abs($number),$_SESSION["currency_accuracy"],$_SESSION["decimal_symbol"],$_SESSION["thousands_separator"]); 
     316        return $currency; 
     317} 
     318 
     319function currencyToNumber($currency){ 
     320        $number=str_replace($_SESSION["currency_symbol"],"",$currency); 
     321        $number=str_replace($_SESSION["thousands_separator"],"",$number); 
     322        $number=str_replace($_SESSION["decimal_symbol"],".",$number); 
     323        $number=((real) $number); 
     324         
     325        return $number; 
     326} 
     327 
     328 
    310329 
    311330//============================================================================ 
     
    371390} 
    372391 
    373 function currencyFormat($number){ 
    374         if(!is_numeric($number)) return $number; 
    375         if($number <0) 
    376                 $thenumber="-$".number_format(abs($number),2); 
    377         else 
    378                 $thenumber="$".number_format($number,2); 
    379         return $thenumber; 
    380 } 
    381  
    382392function booleanFormat($bool){ 
    383393        if($bool==1) 
     
    391401        switch($format){ 
    392402                case "currency": 
    393                         $value=currencyFormat($value); 
     403                        $value=numberToCurrency($value); 
    394404                break; 
    395405                case "boolean": 
  • trunk/phpbms/include/fields.php

    r191 r192  
    235235 
    236236//============================================================================================ 
    237 function field_dollar($name,$value=0,$required=false,$message="",$attributes="") { 
    238         /* 
    239            name =                       Name of the field 
    240            value =                      Value for field  
     237function field_currency($name,$value=0,$required=false,$message="",$attributes="") { 
     238        /* 
     239           name =                       Name of the field 
     240           value =                      Value for field 
    241241           required =           true/false wether the field is validated by javascript before submitting for blank values 
    242242           message =            message displayed if not validate                                                
     
    246246 
    247247        if(!is_numeric($value)) $value=0; 
    248         $value=currencyFormat($value); 
     248        $value=numberToCurrency($value); 
    249249         
    250250        ?><input name="<?php echo $name?>" id="<?php echo $name?>" type="text" value="<?php echo $value?>" <?php 
    251         if ($attributes) foreach($attributes as $attribute => $tvalue) echo " ".$attribute."=\"".$tvalue."\""; 
    252         ?> onchange="validateCurrency(this);" style="text-align:right;" /><?php 
     251        if ($attributes)  
     252                foreach($attributes as $attribute => $tvalue)  
     253                        if($attribute!="onchange" && $attribute!="class")echo " ".$attribute."=\"".$tvalue."\""; 
     254        ?> onchange="validateCurrency(this);<?php if(isset($attributes["onchange"])) echo $attributes["onchange"] ?>" class="currency<?php if(isset($attributes["class"])) echo " ".$attributes["class"] ?>" /><?php 
     255 
    253256        if ($required) {?><script language="JavaScript" type="text/javascript">requiredArray[requiredArray.length]=new Array('<?php echo $name?>','<?php echo $message?>');</script><?php }//end required if 
    254257} 
  • trunk/phpbms/include/jstransport.php

    r191 r192  
    2323        ?>TIME_FORMAT="<?php echo $_SESSION["time_format"]?>";<?php 
    2424        echo "\n\n"; 
     25 
     26        //currency formating 
     27        ?>CURRENCY_SYMBOL="<?php echo $_SESSION["currency_symbol"]?>";<?php 
     28        echo "\n"; 
     29        ?>CURRENCY_ACCURACY=<?php echo $_SESSION["currency_accuracy"]?>;<?php 
     30        echo "\n"; 
     31        ?>DECIMAL_SYMBOL="<?php echo $_SESSION["decimal_symbol"]?>";<?php 
     32        echo "\n"; 
     33        ?>THOUSANDS_SEPARATOR="<?php echo $_SESSION["thousands_separator"]?>";<?php 
     34        echo "\n"; 
     35 
    2536         
    2637        if(isset($_SESSION["include_js"])){ 
  • trunk/phpbms/install/settings.sql

    r191 r192  
    1111INSERT INTO `settings` (`name`, `value`) VALUES ('date_format','English, US'); 
    1212INSERT INTO `settings` (`name`, `value`) VALUES ('time_format','12 Hour'); 
     13INSERT INTO `settings` (`name`, `value`) VALUES ('currency_symbol','$'); 
     14INSERT INTO `settings` (`name`, `value`) VALUES ('decimal_symbol','.'); 
     15INSERT INTO `settings` (`name`, `value`) VALUES ('thousands_separator',','); 
     16INSERT INTO `settings` (`name`, `value`) VALUES ('currency_accuracy','2'); 
  • trunk/phpbms/install/updatev0.7.sql

    r191 r192  
    6363INSERT INTO `settings` (`name`, `value`) VALUES ('date_format','English, US'); 
    6464INSERT INTO `settings` (`name`, `value`) VALUES ('time_format','12 Hour'); 
     65INSERT INTO `settings` (`name`, `value`) VALUES ('currency_symbol','$'); 
     66INSERT INTO `settings` (`name`, `value`) VALUES ('decimal_symbol','.'); 
     67INSERT INTO `settings` (`name`, `value`) VALUES ('thousands_separator',','); 
  • trunk/phpbms/modules/base/adminsettings.php

    r191 r192  
    113113                <p> 
    114114                        <label for="sencryption_seed">encryption seed</label><br /> 
    115                         <?php field_text("sencryption_seed",$_SESSION["encryption_seed"],1,"Application name cannot be blank.","",Array("size"=>"32","maxlength"=>"128","readonly"=>"readonly","class"=>"uneditable")); ?> 
     115                        <?php field_text("sencryption_seed",$_SESSION["encryption_seed"],1,"Encryption seed name cannot be blank.","",Array("size"=>"32","maxlength"=>"128","readonly"=>"readonly","class"=>"uneditable")); ?> 
    116116                </p> 
    117117 
     
    211211                        </select> 
    212212                </p> 
    213  
     213                <p>&nbsp;</p> 
     214                <p> 
     215                        <label for="scurrency_symbol">currency symbol</label><br /> 
     216                        <?php field_text("scurrency_symbol",$_SESSION["currency_symbol"],1,"Currency symbol name cannot be blank.","",Array("size"=>"4","maxlength"=>"8")); ?> 
     217                </p> 
     218                <p> 
     219                        <label for="scurrency_accuracy">currency decimal points of accuracy</label><br /> 
     220                        <?php field_text("scurrency_accuracy",$_SESSION["currency_accuracy"],1,"Currency accuracy name cannot be blank and must be a valid integer.","integer",Array("size"=>"4","maxlength"=>"1")); ?> 
     221                </p> 
     222                <p> 
     223                        <label for="sdecimal_symbol">decimal symbol</label><br /> 
     224                        <?php field_text("sdecimal_symbol",$_SESSION["decimal_symbol"],1,"Decimal symbol name cannot be blank.","",Array("size"=>"4","maxlength"=>"1")); ?> 
     225                </p> 
     226                <p> 
     227                        <label for="sthousands_separator">thousands separator</label><br /> 
     228                        <?php field_text("sthousands_separator",$_SESSION["thousands_separator"],1,"Thousands separator name cannot be blank.","",Array("size"=>"4","maxlength"=>"1")); ?> 
     229                </p> 
    214230        </fieldset> 
    215231        <?php  
  • trunk/phpbms/modules/base/include/notes_addedit_include.php

    r191 r192  
    207207                        if(isset($variables["completed"])) { 
    208208                                $querystatement.="completed=1, ";  
    209                                 $querystatement.="completeddate=\"".sqlDateFromString($variables["completeddate"]).", ";  
     209                                $querystatement.="completeddate=\"".sqlDateFromString($variables["completeddate"])."\", ";  
    210210                        }else { 
    211211                                $querystatement.="completed=0, completeddate=NULL, "; 
  • trunk/phpbms/modules/base/javascript/notes.js

    r166 r192  
    176176                var endtimefield=getObjectFromID("endtime"); 
    177177                var starttimefield=getObjectFromID("starttime"); 
    178                 var thestart=dateFromField(startdatefield.value,starttimefield.value); 
    179                 var theend=dateFromField(enddatefield.value,endtimefield.value); 
     178                var thestart=stringToDatetime(startdatefield.value,starttimefield.value); 
     179                var theend=stringToDatetime(enddatefield.value,endtimefield.value); 
    180180                if (thestart>theend){ 
    181181                        theend=thestart; 
    182182                        theend.setHours(theend.getHours()+1); 
    183                         enddatefield.value=englishDate(theend); 
     183                        enddatefield.value=dateToString(theend); 
    184184                        if(starttimefield.value) 
    185                                 endtimefield.value=englishTime(theend); 
     185                                endtimefield.value=timeToString(theend); 
    186186                } 
    187187        } 
     
    219219                        if(type=="end") 
    220220                                today.setHours(today.getHours()+1); 
    221                         thedate.value= englishDate(today); 
    222                         thetime.value= englishTime(today); 
     221                        thedate.value= dateToString(today); 
     222                        thetime.value= timeToString(today); 
    223223                } 
    224224                thetext.className=null; 
     
    370370        var startdate= getObjectFromID("startdate"); 
    371371        if(startdate.value=="") return false; 
    372         var thedate= dateFromField(startdate.value) 
     372        var thedate= stringToDatetime(startdate.value) 
    373373        var theday= parseInt(startdate.value.substring(startdate.value.indexOf("/")+1,startdate.value.lastIndexOf("/")),10); 
    374374         
  • trunk/phpbms/modules/bms/discounts_addedit.php

    r176 r192  
    7979                        <p> 
    8080                                <strong>Orders</strong> (<?php echo $stats["Order"]["total"]?>)<br/> 
    81                                 total: <?php echo currencyFormat($stats["Order"]["sum"])?> 
     81                                total: <?php echo numberToCurrency($stats["Order"]["sum"])?> 
    8282                        </p> 
    8383                        <p> 
    8484                                <strong>Invoices</strong> (<?php echo $stats["Invoice"]["total"]?>)<br /> 
    85                                 total: <?php echo currencyFormat($stats["Invoice"]["sum"])?> 
     85                                total: <?php echo numberToCurrency($stats["Invoice"]["sum"])?> 
    8686                        </p> 
    8787                </fieldset> 
     
    109109                        <p id="aValue"> 
    110110                                <label for="amountvalue">value</label><br /> 
    111                                 <?php field_dollar("amountvalue",$therecord["value"],1,"Value is required",Array("size"=>"10","maxlength"=>"10"))?> 
     111                                <?php field_currency("amountvalue",$therecord["value"],1,"Value is required",Array("size"=>"10","maxlength"=>"10"))?> 
    112112                        </p>                     
    113113                </fieldset> 
  • trunk/phpbms/modules/bms/include/discounts_addedit_include.php

    r170 r192  
    123123                                        $variables["percentvalue"]="0"; 
    124124                                $querystatement.="value=".$variables["percentvalue"].", ";  
    125                         } else { 
    126                                 $amountvalue=ereg_replace("\\\$|,","",$variables["amountvalue"]); 
    127                                 $querystatement.="value=".$amountvalue.", ";  
    128                         } 
     125                        } else  
     126                                $querystatement.="value=".currencyToNumber($variables["amountvalue"]).", ";  
    129127 
    130128        //==== Almost all records should have this ========= 
     
    158156                                        $variables["percentvalue"]="0"; 
    159157                                $querystatement.=$variables["percentvalue"].", ";  
    160                         } else { 
    161                                 $amountvalue=ereg_replace("\\\$|,","",$variables["amountvalue"]); 
    162                                 $querystatement.=$amountvalue.", ";  
    163                         } 
     158                        } else  
     159                                $querystatement.=currencyToNumber($variables["amountvalue"]).", ";  
    164160                                 
    165161        //==== Almost all records should have this ========= 
  • trunk/phpbms/modules/bms/include/invoices_addedit_include.php

    r191 r192  
    146146                        while($therecord=mysql_fetch_array($queryresult)){ 
    147147                                if($therecord["type"]=="amount") 
    148                                         $therecord["value"]=currencyFormat($therecord["value"]); 
     148                                        $therecord["value"]=numberToCurrency($therecord["value"]); 
    149149                                else 
    150150                                        $therecord["value"].="%"; 
     
    168168                        $therecord["name"].=": ".$therecord["value"]; 
    169169                } else 
    170                         $therecord["name"].=": ".currencyFormat($therecord["value"]); 
     170                        $therecord["name"].=": ".numberToCurrency($therecord["value"]); 
    171171        } 
    172172        $therecord["name"]=htmlspecialchars($therecord["name"]); 
     
    447447                        $querystatement.="orderdate=".$tempdate.", ";  
    448448 
    449                                 $discountamount=ereg_replace("\\\$|,","",$variables["discountamount"]); 
    450                         $querystatement.="discountamount=".$discountamount.", "; 
     449                        $querystatement.="discountamount=".currencyToNumber($variables["discountamount"]).", "; 
    451450                        if($variables["discountid"]=="")$variables["discountid"]="NULL"; 
    452451                        $querystatement.="discountid=".$variables["discountid"].", ";  
     
    467466                        $querystatement.="country=\"".$variables["country"]."\", ";  
    468467 
    469                                 $totaltni=ereg_replace("\\\$|,","",$variables["totaltni"]); 
    470                                 $totaltaxable=ereg_replace("\\\$|,","",$variables["totaltaxable"]); 
    471                                 $totalti=ereg_replace("\\\$|,","",$variables["totalti"]); 
    472                                 $shipping=ereg_replace("\\\$|,","",$variables["shipping"]); 
    473                                 $tax=ereg_replace("\\\$|,","",$variables["tax"]); 
    474                                 $amountpaid=ereg_replace("\\\$|,","",$variables["amountpaid"]); 
    475  
    476                         $querystatement.="totaltni=".$totaltni.", ";  
    477                         $querystatement.="totaltaxable=".$totaltaxable.", ";  
    478                         $querystatement.="totalti=".$totalti.", ";  
    479                         $querystatement.="shipping=".$shipping.", ";  
    480                         $querystatement.="tax=".$tax.", ";  
    481                         $querystatement.="amountpaid=".$amountpaid.", ";  
     468                        $querystatement.="totaltni=".currencyToNumber($variables["totaltni"]).", ";  
     469                        $querystatement.="totaltaxable=".currencyToNumber($variables["totaltaxable"]).", ";  
     470                        $querystatement.="totalti=".currencyToNumber($variables["totalti"]).", ";  
     471                        $querystatement.="shipping=".currencyToNumber($variables["shipping"]).", ";  
     472                        $querystatement.="tax=".currencyToNumber($variables["tax"]).", ";  
     473                        $querystatement.="amountpaid=".currencyToNumber($variables["amountpaid"]).", ";  
    482474 
    483475                        $querystatement.="totalcost=".$variables["totalcost"].", ";  
     
    565557                        $querystatement.=((int)$variables["statusid"]).", "; 
    566558                        $querystatement.=((int) $variables["assignedtoid"]).", "; 
    567                         if($variables["statusdate"]=="" || $variables["statusdate"]=="0/0/0000") $tempdate="NULL"; 
     559                        if($variables["statusdate"]=="") $tempdate="NULL"; 
    568560                        else 
    569561                                $tempdate="\"".sqlDateFromString($variables["statusdate"])."\""; 
    570562                        $querystatement.=$tempdate.", "; 
    571563                         
    572                                 if($variables["orderdate"]=="" || $variables["orderdate"]=="0/0/0000") $tempdate="NULL"; 
     564                                if($variables["orderdate"]=="") $tempdate="NULL"; 
    573565                                else 
    574566                                        $tempdate="\"".sqlDateFromString($variables["orderdate"])."\""; 
    575567                        $querystatement.=$tempdate.", ";  
    576568 
    577                                 $discountamount=ereg_replace("\\\$|,","",$variables["discountamount"]); 
    578                         $querystatement.=$discountamount.", ";                           
     569                        $querystatement.=currencyToNumber($variables["discountamount"]).", ";                            
    579570                        if($variables["discountid"]=="")$variables["discountid"]="NULL"; 
    580571                        $querystatement.=$variables["discountid"].", ";  
    581572 
    582                                 if($variables["invoicedate"]=="" || $variables["invoicedate"]=="0/0/0000") $tempdate="NULL"; 
     573                                if($variables["invoicedate"]=="") $tempdate="NULL"; 
    583574                                else 
    584575                                        $tempdate="\"".sqlDateFromString($variables["invoicedate"])."\""; 
     
    595586                        $querystatement.="\"".$variables["country"]."\", ";  
    596587 
    597                                 $totaltni=ereg_replace("\\\$|,","",$variables["totaltni"]); 
    598                                 $totaltaxable=ereg_replace("\\\$|,","",$variables["totaltaxable"]); 
    599                                 $totalti=ereg_replace("\\\$|,","",$variables["totalti"]); 
    600                                 $shipping=ereg_replace("\\\$|,","",$variables["shipping"]); 
    601                                 $tax=ereg_replace("\\\$|,","",$variables["tax"]); 
    602                                 $amountpaid=ereg_replace("\\\$|,","",$variables["amountpaid"]); 
    603  
    604                         $querystatement.=$totaltni.", ";  
    605                         $querystatement.=$totaltaxable.", ";  
    606                         $querystatement.=$totalti.", ";  
    607                         $querystatement.=$shipping.", ";  
    608                         $querystatement.=$tax.", ";  
    609                         $querystatement.=$amountpaid.", ";  
     588                        $querystatement.=currencyToNumber($variables["totaltni"]).", ";  
     589                        $querystatement.=currencyToNumber($variables["totaltaxable"]).", ";  
     590                        $querystatement.=currencyToNumber($variables["totalti"]).", ";  
     591                        $querystatement.=currencyToNumber($variables["shipping"]).", ";  
     592                        $querystatement.=currencyToNumber($variables["tax"]).", ";  
     593                        $querystatement.=currencyToNumber($variables["amountpaid"]).", ";  
    610594 
    611595                        $querystatement.=$variables["totalcost"].", ";  
  • trunk/phpbms/modules/bms/include/products_addedit_include.php

    r189 r192  
    142142                        if(isset($variables["inactive"])) $querystatement.="inactive=1, "; else $querystatement.="inactive=0, "; 
    143143                        if(isset($variables["taxable"])) $querystatement.="taxable=1, "; else $querystatement.="taxable=0, "; 
    144                  
    145                                 $unitprice=ereg_replace("\\\$|,","",$variables["unitprice"]); 
    146                                 $unitcost=ereg_replace("\\\$|,","",$variables["unitcost"]); 
    147                          
    148                         $querystatement.="unitprice=".$unitprice.", ";  
    149                         $querystatement.="unitcost=".$unitcost.", ";  
     144                                         
     145                        $querystatement.="unitprice=".currencyToNumber($variables["unitprice"]).", ";  
     146                        $querystatement.="unitcost=".currencyToNumber($variables["unitcost"]).", ";  
    150147                        $querystatement.="unitofmeasure=\"".$variables["unitofmeasure"]."\", ";  
    151148 
     
    239236                        if(isset($variables["taxable"])) $querystatement.="1, "; else $querystatement.="0, "; 
    240237                        $querystatement.="\"".$variables["memo"]."\", ";  
    241                  
    242                                 $unitprice=ereg_replace("\\\$|,","",$variables["unitprice"]); 
    243                                 $unitcost=ereg_replace("\\\$|,","",$variables["unitcost"]); 
    244                          
    245                         $querystatement.=$unitprice.", ";  
    246                         $querystatement.=$unitcost.", ";  
     238                                         
     239                        $querystatement.=currencyToNumber($variables["unitprice"]).", ";  
     240                        $querystatement.=currencyToNumber($variables["unitcost"]).", ";  
    247241                        $querystatement.="\"".$variables["unitofmeasure"]."\", ";  
    248242 
  • trunk/phpbms/modules/bms/invoices_addedit.php

    r184 r192  
    234234                        </td> 
    235235                        <td width="100%"><input name="memo" type="text" id="memo" size="12" maxlength="255" tabindex="17" /></td> 
    236                         <td align="right" nowrap><input name="price" type="text" id="price" value="<?php echo currencyFormat(0)?>" size="10" maxlength="16" onchange="calculateExtended()" class="fieldCurrency"  tabindex="18"  /></td> 
     236                        <td align="right" nowrap><input name="price" type="text" id="price" value="<?php echo numberToCurrency(0)?>" size="10" maxlength="16" onchange="calculateExtended()" class="fieldCurrency"  tabindex="18"  /></td> 
    237237                        <td align="center" nowrap><input name="qty" type="text" id="qty" value="1" size="5" maxlength="16" onchange="calculateExtended()" tabindex="19"  /></td> 
    238                         <td align="right" nowrap><input name="extended" type="text" i