task #7524 improve ca
This commit is contained in:
parent
245a62c28c
commit
e2751833aa
8 changed files with 87 additions and 4 deletions
66
html/js/caod_compute.js
Normal file
66
html/js/caod_compute.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
function caod_checkTotal() {
|
||||
var ie4=false;
|
||||
if ( document.all ) {
|
||||
ie4=true;
|
||||
}// Ajouter getElementById par document.all[str]
|
||||
var total_deb=0.0;
|
||||
var total_cred=0.0;
|
||||
var nb_item=10;
|
||||
|
||||
for (var i=0;i <nb_item ;i++) {
|
||||
var doc_amount=document.getElementById("pamount"+i);
|
||||
if ( ! doc_amount ) { return;}
|
||||
var side=document.getElementById("pdeb"+i);
|
||||
if ( ! side ) { return;}
|
||||
var amount=parseFloat(doc_amount.value);
|
||||
|
||||
if ( isNaN(amount) == true) {
|
||||
amount=0.0;
|
||||
}
|
||||
if ( side.checked == false ) {
|
||||
total_cred+=amount;
|
||||
}
|
||||
if ( side.checked == true ) {
|
||||
total_deb+=amount;
|
||||
}
|
||||
|
||||
// alert("amount ="+i+"="+amount+" cred/deb = "+deb+"total d/b"+total_deb+"/"+total_cred);
|
||||
}
|
||||
|
||||
|
||||
|
||||
r_total_cred=Math.round(total_cred*100)/100;
|
||||
r_total_deb=Math.round(total_deb*100)/100;
|
||||
document.getElementById('totalDeb').innerHTML=r_total_deb;
|
||||
document.getElementById('totalCred').innerHTML=r_total_cred;
|
||||
|
||||
if ( r_total_deb != r_total_cred ) {
|
||||
document.getElementById("totalDiff").style.color="red";
|
||||
document.getElementById("totalDiff").style.fontWeight="bold";
|
||||
document.getElementById("totalDiff").innerHTML="Différence";
|
||||
diff=total_deb-total_cred;
|
||||
diff=Math.round(diff*100)/100;
|
||||
document.getElementById("totalDiff").innerHTML=diff
|
||||
|
||||
} else {
|
||||
document.getElementById("totalDiff").innerHTML="0.0";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ if ( isset($_GET['new'])) {
|
|||
//show the form for entering a new Anc_Operation
|
||||
//------------------------------------------
|
||||
$a=new groupop($cn);
|
||||
|
||||
echo JS_CAOD_COMPUTE;
|
||||
$wSubmit=new widget('hidden',"p_action","ca_od");
|
||||
$wSubmit->table=0;
|
||||
echo '<div class="u_redcontent">';
|
||||
|
|
@ -131,6 +131,12 @@ if ( isset($_GET['new'])) {
|
|||
echo $a->form();
|
||||
echo $wSubmit->Submit("save","Sauver");
|
||||
echo '</form>';
|
||||
echo '<div class="info">
|
||||
Débit = <span id="totalDeb"></span>
|
||||
Crédit = <span id="totalCred"></span>
|
||||
Difference = <span id="totalDiff"></span>
|
||||
</div>
|
||||
';
|
||||
|
||||
echo '</div>';
|
||||
exit();
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ class balance_ca_bs extends print_ca {
|
|||
$r.="<th>Débit</th>";
|
||||
$r.="<th>Crédit</th>";
|
||||
$r.="<th>Solde</th>";
|
||||
$r.="<th>D/C</th>";
|
||||
$r.="</tr>";
|
||||
|
||||
$array=$this->get_data();
|
||||
|
|
@ -138,6 +139,9 @@ class balance_ca_bs extends print_ca {
|
|||
$r.=sprintf("<td>%12.2f</td>",$row['sum_deb']);
|
||||
$r.=sprintf("<td>%12.2f</td>",$row['sum_cred']);
|
||||
$r.=sprintf("<td>%12.2f</td>",$row['solde']);
|
||||
$deb=($row['sum_deb'] > $row['sum_cred')?"D":"C";
|
||||
$deb=($row['solde'] == 0 )?'':$deb;
|
||||
$r.=sprintf("<td>%s</td>",$deb);
|
||||
$r.="</tr>";
|
||||
}
|
||||
$r.="</table>";
|
||||
|
|
|
|||
|
|
@ -133,11 +133,13 @@ class groupop
|
|||
$wAmount=new widget("text","","pamount$i",0.0);
|
||||
$wAmount->size=12;
|
||||
$wAmount->table=1;
|
||||
$wAmount->javascript=" onChange=caod_checkTotal()";
|
||||
$wAmount->readonly=$p_readonly;
|
||||
|
||||
$wDebit=new widget("checkbox","","pdeb$i");
|
||||
$wDebit->table=1;
|
||||
$wDebit->readonly=$p_readonly;
|
||||
$wDebit->javascript=" onChange=caod_checkTotal()";
|
||||
if ( isset ($this->a_operation[$i])) {
|
||||
$wSelect->selected=$this->a_operation[$i]->po_id;
|
||||
$wAmount->value=$this->a_operation[$i]->oa_amount;
|
||||
|
|
|
|||
|
|
@ -194,13 +194,13 @@ class widget {
|
|||
if (strtoupper($this->type)=="CHECKBOX") {
|
||||
if ( $this->readonly == true) {
|
||||
$check=( $this->selected==true )?"checked":"unchecked";
|
||||
$r='<input type="CHECKBOX" name="'.$this->name.'"';
|
||||
$r='<input type="CHECKBOX" id="'.$this->name.'" name="'.$this->name.'"';
|
||||
$r.=" $check";
|
||||
$r.=' disabled>';
|
||||
|
||||
} else {
|
||||
$check=( $this->selected==true )?"checked":"unchecked";
|
||||
$r='<input type="CHECKBOX" name="'.$this->name.'"';
|
||||
$r='<input type="CHECKBOX" id="'.$this->name.'" name="'.$this->name.'"';
|
||||
$r.=" $check";
|
||||
$r.=' '.$disabled." ".$this->javascript.'>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,6 +183,10 @@ define ('JS_COMPUTE_DIRECT','
|
|||
</script>');
|
||||
|
||||
|
||||
define ('JS_CAOD_COMPUTE','
|
||||
<script type="text/javascript" language="javascript" src="js/caod_compute.js">
|
||||
</script>');
|
||||
|
||||
// One line calculator
|
||||
define ("JS_CALC_LINE",'
|
||||
<div style="border:outset black 3px; position:float; float:right;background-color:white;font-family:sans-serif;font-size:9pt;">
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ echo '<div class="u_redcontent">';
|
|||
if ( isset ($_POST["DATABASE"]) ) {
|
||||
$cn=DbConnect();
|
||||
$dos=trim($_POST["DATABASE"]);
|
||||
$dos=FormatString($dos);
|
||||
if (strlen($dos)==0) {
|
||||
echo ("Dataname name is empty");
|
||||
exit -1;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ if length(trim(NEW.ga_id)) = 0 then
|
|||
NEW.ga_id:=NULL;
|
||||
return NEW;
|
||||
end if;
|
||||
select ga_id from groupe_analytique where ga_id=NEW.ga_id;
|
||||
perform 'select ga_id from groupe_analytique where ga_id='||NEW.ga_id;
|
||||
if NOT FOUND then
|
||||
raise exception' Inexistent Group Analytic %',NEW.ga_id;
|
||||
end if;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue