diff --git a/html/js/calc.js b/html/js/calc.js new file mode 100644 index 000000000..9a4d09bb9 --- /dev/null +++ b/html/js/calc.js @@ -0,0 +1,113 @@ +/* + * This file is part of PhpCompta. + * + * PhpCompta is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpCompta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PhpCompta; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/* $Revision$ */ + +// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr + +/* !\file + */ + +/* \brief This file show a little online calculator, in the caller + * the span id result, listing, the id form calc_line and the + * input id inp must exist see constant.php JS_CALC_LINE + * + */ + +var str=""; +var val=""; +var counter=0; + +// add input +function cal() +{ + p_variable=this.document.getElementById('inp').value; + if (p_variable.search(/^\s*$/) !=-1) { + return; + } +if ( counter==0) +{ + this.document.getElementById('result').innerHTML=""; +} +// if both parenthesis are not found we increase the counter +if ( p_variable.search(/\)+/) == -1 && p_variable.search(/\(+/) ==-1) { + if ( counter%2 == 0) + { + // number only + var regex=/^\(?[0-9]*\.*[0-9]*\)?$/; + + if ( p_variable.search(regex) ==-1) + { + alert ('Nombre uniquement'); + return; + } + } else + { + var regex=/^\/?\+?-?\*?=?$/; + // signs + if ( p_variable.search(regex) ==-1) + { + alert ('Signe + - * / = uniquement'); + return; + } + + } + counter++; +} + +if ( p_variable == "=" ) { + Compute(); + str=""; + val=""; + counter=0; + return; + } + str=str+p_variable; + val=val+p_variable; +var str_sub=""; +if ( counter%2 != 0 ) +{ + sub=eval(val); + str_sub="
Total :"+val+" = "+sub+""; + this.document.getElementById("sub_total").innerHTML=str_sub; +} + //alert ('value is '+p_variable+'Global :'+str); + this.document.getElementById("listing").innerHTML=str; + this.document.getElementById('inp').value=""; +} +// Clean +// +function Clean() +{ + str=""; + this.document.getElementById('listing').innerHTML=""; + this.document.getElementById('result').innerHTML=""; +// this.document.getElementById('sub_total').innerHTML=""; + this.document.getElementById('inp').value=""; +} + +function Compute() +{ + var tot=0; + var ret=""; + tot=eval(val); + ret+="
"; + ret+="Total = "+tot+''; + this.document.getElementById('inp').value=""; + this.document.getElementById('result').innerHTML=ret; + this.document.getElementById('inp').focus(); +} \ No newline at end of file diff --git a/html/style-light.css b/html/style-light.css index 30a1fb417..da2da7d53 100644 --- a/html/style-light.css +++ b/html/style-light.css @@ -137,6 +137,7 @@ div.u_redcontent{ div.u_content{ position: float; float:left; + padding-top:7px; width:100%; font-size:9px; font-family:sans-serif; @@ -151,13 +152,7 @@ div.no span{ } -div.u_content span { - position :float; - float:left; - margin-left:40px; -} div.u_content table { - width:100%; border:solid blue 2px ; border-style:outset; } diff --git a/include/constant.php b/include/constant.php index 0c53b6ca4..47879106a 100644 --- a/include/constant.php +++ b/include/constant.php @@ -338,31 +338,21 @@ function SetIt(p_value,p_ctl) { "); // One line calculator -define ("JS_CALC_LINE"," - -
- -Answer: -
- - - -
- - -
- - - - -" +

Calculette

+ +
+ + +
+ + +
+ +' ); define ("JS_TVA","