noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
compute_direct.js
Go to the documentation of this file.
00001 /*
00002  *   This file is part of NOALYSS.
00003  *
00004  *   NOALYSS is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation; either version 2 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   NOALYSS is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with NOALYSS; if not, write to the Free Software
00016  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 /*!\file
00019  *\brief common function for "Ecriture directe"
00020  */
00021 function checkTotalDirect()
00022 {
00023     var ie4=false;
00024     if ( document.all )
00025     {
00026         ie4=true;
00027     }// Ajouter getElementById par document.all[str]
00028     var total_deb=0.0;
00029     var total_cred=0.0;
00030 
00031 
00032     var nb_item_id=document.getElementById('nb_item');
00033     if ( ! nb_item_id )
00034     {
00035         return;
00036     }
00037 
00038     var nb_item=nb_item_id.value;
00039 
00040     for (var i=0;i <nb_item ;i++)
00041     {
00042         var doc_amount=document.getElementById("amount"+i);
00043         if ( ! doc_amount )
00044         {
00045             return;
00046         }
00047         var side=document.getElementsByName("ck"+i);
00048         if ( ! side )
00049         {
00050             return;
00051         }
00052         var amount=parseFloat(doc_amount.value);
00053 
00054         if ( isNaN(amount) == true)
00055         {
00056             amount=0.0;
00057         }
00058         for (var e=0;e<side.length;e++)
00059         {
00060             if ( side[e].checked == true)
00061             {
00062                 //      alert('checked !!! '+side[e].value);
00063                 total_deb+=amount;
00064             }
00065             else
00066             {
00067                 total_cred+=amount;
00068             }
00069         }
00070 
00071         //    alert("amount ="+i+"="+amount+" cred/deb = "+deb+"total d/b"+total_deb+"/"+total_cred);
00072     }
00073 
00074 
00075 
00076     r_total_cred=Math.round(total_cred*100)/100;
00077     r_total_deb=Math.round(total_deb*100)/100;
00078     document.getElementById('totalDeb').innerHTML=r_total_deb;
00079     document.getElementById('totalCred').innerHTML=r_total_cred;
00080     var diff=0;
00081     if ( r_total_deb != r_total_cred )
00082     {
00083         document.getElementById("totalDiff").style.color="red";
00084         document.getElementById("totalDiff").style.fontWeight="bold";
00085         document.getElementById("totalDiff").innerHTML="Différence";
00086         diff=total_deb-total_cred;
00087         diff=Math.round(diff*100)/100;
00088         document.getElementById("totalDiff").innerHTML=diff;
00089 
00090     }
00091     else
00092     {
00093         document.getElementById("totalDiff").innerHTML="0.0";
00094     }
00095 }
00096 
 All Data Structures Namespaces Files Functions Variables Enumerations