diff --git a/html/js/calc.js b/html/js/calc.js index 59ca90be9..a0aadf57a 100644 --- a/html/js/calc.js +++ b/html/js/calc.js @@ -35,18 +35,20 @@ function cal() return; } try { - Compute(); - sub=eval(p_variable); + Compute(); + sub=eval(p_variable); + var result=parseFloat(sub); + result=Math.round(result*100)/100; } catch(exception) { alert("Mauvaise formule\n"+p_variable); return false; } p_history=p_history+'
'+p_variable; - p_history+="="+sub; - var str_sub="
Total :"+p_variable+" = "+sub+""; - this.document.getElementById("sub_total").innerHTML=str_sub; - this.document.getElementById("listing").innerHTML=p_history; - this.document.getElementById('inp').value=""; + p_history+="="+result.toString(); + var str_sub="
Total :"+p_variable+" = "+result.toString()+""; + this.document.getElementById("sub_total").innerHTML=str_sub; + this.document.getElementById("listing").innerHTML=p_history; + this.document.getElementById('inp').value=""; } // Clean // @@ -62,12 +64,9 @@ function Clean() function Compute() { - var tot=0; - var ret=""; - tot=eval(p_variable); - ret+="
"; - ret+="Total = "+tot+''; - this.document.getElementById('inp').value=""; - //this.document.getElementById('result').innerHTML=ret; - this.document.getElementById('inp').focus(); + var tot=0; + var ret=""; + + this.document.getElementById('inp').value=""; + this.document.getElementById('inp').focus(); } diff --git a/html/js/scripts.js b/html/js/scripts.js index 0d6b22af7..c984d5d37 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -81,7 +81,7 @@ function trim(s) { */ function g(ID) { if (document.getElementById) { - return document.getElementById(ID); + return this.document.getElementById(ID); } else if (document.all) { return document.all[ID]; } else { @@ -606,4 +606,17 @@ function unselect_checkbox(form_id) { e.checked=false; } } +} +/** +* show the calculator +*/ +function show_calc() { + if ( g('calc1')) { this.document.getElementById('inp').value="";return;} + var sid='calc1'; + var shtml=''; + shtml+='
Cette calculatrice vous permet de calculer, écrivez simplement les opérations que vous voulez puis la touche retour. exemple : 1+2+3*(1/5) '; +shtml+='

Taper une formule (ex 20*5.1) puis enter
'; + + var obj={id:sid,html:shtml,drag:true,style:'position:absolute;display:block;top:30px;left:150px;width:250px;border:1px solid black;background-color:#99b1df;font-size:12'}; + add_div(obj); } \ No newline at end of file diff --git a/include/ac_common.php b/include/ac_common.php index 542038325..74fb34603 100644 --- a/include/ac_common.php +++ b/include/ac_common.php @@ -187,7 +187,7 @@ function html_page_start($p_theme="",$p_script="",$p_script2="") ". $p_script2. " - "; + "; echo ' diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index cfb6e5327..681b47733 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -1319,12 +1319,6 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj $f_add_button->set_attribute('jrn',$this->id); $f_add_button->javascript=" select_card_type(this);"; $ret.=$f_add_button->input(); - // show compute - $cal=new IButton('calc'); - $cal->label='Calculatrice'; - $cal->javascript=" showIPopup('compute') "; - $str_cal_button=$cal->input(); - $ret.=$str_cal_button; // Load the javascript // diff --git a/include/class_acc_ledger_fin.php b/include/class_acc_ledger_fin.php index 10c7fb356..ca7e7851d 100644 --- a/include/class_acc_ledger_fin.php +++ b/include/class_acc_ledger_fin.php @@ -340,11 +340,6 @@ class Acc_Ledger_Fin extends Acc_Ledger { $wConcerned->extra2='paid'; $array[$i]['concerned']=$wConcerned->input(); } - // show compute - $cal=new IButton('calc'); - $cal->label='Calculatrice'; - $cal->javascript=" showIPopup('compute') "; - $str_cal_button=$cal->input(); ob_start(); require_once('template/form_ledger_fin.php'); diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php index 86b49f558..031442aae 100644 --- a/include/class_acc_ledger_purchase.php +++ b/include/class_acc_ledger_purchase.php @@ -1012,11 +1012,6 @@ array } $f_type=_('Fournisseur'); - // show compute - $cal=new IButton('calc'); - $cal->label='Calculatrice'; - $cal->javascript=" showIPopup('compute') "; - $str_cal_button=$cal->input(); ob_start(); require_once('template/form_ledger_detail.php'); diff --git a/include/class_acc_ledger_sold.php b/include/class_acc_ledger_sold.php index 7879f7f7c..7947366fd 100644 --- a/include/class_acc_ledger_sold.php +++ b/include/class_acc_ledger_sold.php @@ -1135,11 +1135,6 @@ class Acc_Ledger_Sold extends Acc_Ledger { }// foreach article $f_type=_('Client'); - // show compute - $cal=new IButton('calc'); - $cal->label='Calculatrice'; - $cal->javascript=" showIPopup('compute') "; - $str_cal_button=$cal->input(); ob_start(); require_once('template/form_ledger_detail.php'); diff --git a/include/class_ibutton.php b/include/class_ibutton.php index 417f0ff35..28a02e601 100644 --- a/include/class_ibutton.php +++ b/include/class_ibutton.php @@ -68,6 +68,13 @@ require_once('class_html_input.php'); $select_all->javascript="unselect_checkbox($p_form)"; return $select_all->input(); } + static function show_calc() { + $calc=new IButton('shcalc'); + $calc->label=_('Calculatrice'); + $calc->javascript="show_calc()"; + return $calc->input(); + + } static public function test_me() { diff --git a/include/compta_ach.inc.php b/include/compta_ach.inc.php index 8a1e7e08b..c67760de0 100644 --- a/include/compta_ach.inc.php +++ b/include/compta_ach.inc.php @@ -40,16 +40,6 @@ $pop_tva->title=_('Choix TVA'); $pop_tva->value=''; echo $pop_tva->input(); $p_action=(isset($_REQUEST['p_action']))?$_REQUEST['p_action']:''; -//---------------------------------------------------------------------- -// create compute button -require_once ('class_ipopup.php'); -$compute=new IPopup('compute'); -$compute->value=JS_CALC_LINE; -$compute->drag=true; $compute->blocking=false; -$compute->title="Calculatrice"; -$compute->set_height("350"); -$compute->set_width("500"); -echo $compute->input(); $cn=new Database(dossier::id()); //menu = show a list of ledger diff --git a/include/compta_fin.inc.php b/include/compta_fin.inc.php index a2c321e7b..ff295b5ca 100644 --- a/include/compta_fin.inc.php +++ b/include/compta_fin.inc.php @@ -41,15 +41,6 @@ $search_card->title=_('Recherche de fiche'); $search_card->value=''; echo $search_card->input(); -$compute=new IPopup('compute'); -$compute->value=JS_CALC_LINE; -$compute->drag=true; $compute->blocking=false; -$compute->title="Calculatrice"; -$compute->set_height("350"); -$compute->set_width("500"); -echo $compute->input(); - - $cn=new Database(dossier::id()); $menu_action="?p_action=fin&".dossier::get(); $menu=array( diff --git a/include/compta_ven.inc.php b/include/compta_ven.inc.php index 7ac766b79..65aa5f94a 100644 --- a/include/compta_ven.inc.php +++ b/include/compta_ven.inc.php @@ -41,16 +41,6 @@ $pop_tva=new IPopup('popup_tva'); $pop_tva->title=_('Choix TVA'); $pop_tva->value=''; echo $pop_tva->input(); -//---------------------------------------------------------------------- -// create compute button -$compute=new IPopup('compute'); -$compute->value=JS_CALC_LINE; -//$compute->title="Calculatrice"; -$compute->drag=true; -$compute->blocking=false; -$compute->set_height("350"); -$compute->set_width("500"); -echo $compute->input(); $p_action=(isset($_REQUEST['p_action']))?$_REQUEST['p_action']:''; $gDossier=dossier::id(); @@ -328,7 +318,7 @@ if ( $def == 2 ) { echo $html; echo $bar; echo '

'.HtmlInput::submit('paid',_('Mise à jour paiement')).IButton::select_checkbox('fpaidv').IButton::unselect_checkbox('fpaidv').'

'; - echo IButton::select_checkbox('fpaid'); + echo ''; echo ''; diff --git a/include/function_javascript.php b/include/function_javascript.php index 40ed11ed9..1d264d563 100644 --- a/include/function_javascript.php +++ b/include/function_javascript.php @@ -825,7 +825,6 @@ function load_all_script() echo js_include('dragdrop.js'); echo js_include('controls.js'); echo js_include('slider.js'); - echo js_include('acc_ledger.js'); echo js_include('accounting_item.js'); echo js_include('acc_report.js'); diff --git a/include/quick_writing.inc.php b/include/quick_writing.inc.php index 1395e8573..f277f7e2e 100644 --- a/include/quick_writing.inc.php +++ b/include/quick_writing.inc.php @@ -47,13 +47,6 @@ $pop_tva->title=_('Choix TVA'); $pop_tva->value=''; echo $pop_tva->input(); -$compute=new IPopup('compute'); -$compute->value=JS_CALC_LINE; -$compute->drag=true; $compute->blocking=false; -$compute->title="Calculatrice"; -$compute->set_height("350"); -$compute->set_width("500"); -echo $compute->input(); $cn=new Database(dossier::id()); $id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1; diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index 32e4367c2..e45c2c742 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -16,7 +16,7 @@

- +
diff --git a/include/template/form_ledger_fin.php b/include/template/form_ledger_fin.php index 9961d8bc5..700f5f65c 100644 --- a/include/template/form_ledger_fin.php +++ b/include/template/form_ledger_fin.php @@ -13,7 +13,7 @@ input();?> input();?>
- +
diff --git a/include/user_menu.php b/include/user_menu.php index f2fdaaffc..58e2b31e8 100644 --- a/include/user_menu.php +++ b/include/user_menu.php @@ -431,6 +431,8 @@ function menu_tool($p_from) { $r.= '
'; $r.= '
'; $r.= "

Dossier : ".h(dossier::name())."

"; + $r.=IButton::show_calc(); + $r.= '
'; $r.= '
'; if ( $p_from == 'compta') $view='E'; @@ -451,7 +453,9 @@ function menu_tool($p_from) { ) ; $gDossier=dossier::id(); - $r.= '
'; + + $r.= '
'; + $r.=''; foreach($amodule as $col ) { $url=$col['value'].'?'.dossier::get(); if ( $p_from==$col['value']) { @@ -477,6 +481,7 @@ function menu_tool($p_from) { $r.= '
'; $r.= ''; + $r.= ''; $r.= ''; return $r;