javascript for the analytic accountancy More...
Go to the source code of this file.
Functions | |
| function | add_row (p_table, p_seq) |
| add a row for the CA | |
| function | add_row_key (p_table) |
| Add a row for distribution key. | |
| function | anc_add_row (tableid) |
| add a row in misc operation for ANC the code must be adapted for that | |
| function | anc_key_choice (p_dossier, p_table, p_amount, p_ledger) |
| choose the distribution key in ajax, a window let you choose what key you want to use | |
| function | anc_key_compute (p_dossier, p_table, p_amount, p_key_id) |
| compute and display Analytic activity, related to the choosen distribution key | |
| function | anc_key_compute_table () |
| function | anc_refresh_remain (p_table, p_seq) |
| Refresh remain of account. | |
| function | anc_remove_operation (p_dossier, p_oa_group) |
| remove an operation | |
| function | caod_checkTotal () |
| function | compute_total_table (p_table, seq) |
| Compute total of a form from Anc_Operation::display_form_plan. | |
| function | filter_anc (obj, queryString) |
| this function is called before the querystring is send to the fid2.php, add a filter based on the ledger 'p_jrn' | |
| function | search_anc_form (obj) |
| function | search_ca (p_dossier, p_target, p_source) |
| open a window for searching a CA account, | |
| function | verify_ca (div) |
| Check the amount of the CA. | |
javascript for the analytic accountancy
Definition in file anc_script.js.
| function add_row | ( | p_table, | |
| p_seq | |||
| ) |
add a row for the CA
| p_table_id | |
| p_amount | amount to reach |
Definition at line 31 of file anc_script.js.
References alert(), anc_refresh_remain(), compute_total_table(), g(), and value.
Referenced by Anc_Operation::display_form_plan().
{
var mytable = g(p_table).tBodies[0];
var max = parseFloat(g('amount_t' + p_seq).value);
if (!mytable)
{
return;
}
var new_value = mytable.rows.length + 1;
if (mytable.rows.length > 15)
{
alert("Maximum 15 lignes ");
return;
}
var amount = compute_total_table(p_table, p_seq);
if (max < amount)
{
alert('Montant incorrect : max = ' + max + " calculé=" + amount);
return;
}
// For the detail view (modify_op) there is several form and then several time the
// element
var rowToCopy = mytable.rows[1];
var row = mytable.insertRow(mytable.rows.length);
for (var i = 0; i < rowToCopy.cells.length; i++)
{
var cell = row.insertCell(i);
var txt = rowToCopy.cells[i].innerHTML;
// txt=txt.replace(/row_1/g,"row_"+new_value);
cell.innerHTML = txt;
}
var col = document.getElementsByName("val[" + p_seq + "][]");
col[col.length - 1].value = max - amount;
anc_refresh_remain(p_table, p_seq);
}
| function add_row_key | ( | p_table | ) |
Add a row for distribution key.
This function add a row in the table key distribution
| p_table | table id |
Definition at line 482 of file anc_script.js.
References alert(), g(), nb(), and value.
{
var mytable = g(p_table).tBodies[0];
if (!mytable)
{
return;
}
var table_length=mytable.rows.length ;
if ( table_length > 15)
{
alert("Maximum 15 lignes ");
return;
}
var rowToCopy = mytable.rows[1];
var row = mytable.insertRow(table_length);
var nb=mytable.rows.length -2;
for (var i = 0; i < rowToCopy.cells.length; i++)
{
var cell = row.insertCell(i);
cell.className=rowToCopy.cells[i].className;
var txt = rowToCopy.cells[i].innerHTML;
if ( i == 0 )
{
var change=nb+1;
cell.innerHTML =change+'<input id="row[]" type="hidden" value="-1" name="row[]">';
}
else
{
if (i == rowToCopy.cells.length -1 ) {
txt=txt.replace(/value="[0-9]*.{1}[0-9]*"/,'value="0"')
} else {
txt=txt.replace(/po_id\[0\]/g,'po_id['+nb+']');
}
cell.innerHTML = txt;
}
}
$('total_key').innerHTML="?";
}
| function anc_add_row | ( | tableid | ) |
add a row in misc operation for ANC the code must be adapted for that
Definition at line 341 of file anc_script.js.
References g(), nb(), style, and value.
{
var style = 'class="input_text"';
var mytable = g(tableid).tBodies[0];
var nNumberRow = mytable.rows.length;
var oRow = mytable.insertRow(nNumberRow);
var rowToCopy = mytable.rows[1];
var nNumberCell = rowToCopy.cells.length;
var nb = g("nbrow");
var oNewRow = mytable.insertRow(nNumberRow);
for (var e = 0; e < nNumberCell; e++)
{
var newCell = oRow.insertCell(e);
var tt = rowToCopy.cells[e].innerHTML;
var new_tt = tt.replace(/pop0/g, "pop" + nb.value);
new_tt = new_tt.replace(/pamount0/g, "pamount" + nb.value);
new_tt = new_tt.replace(/pdeb0/g, "pdeb" + nb.value);
newCell.innerHTML = new_tt;
new_tt.evalScripts();
}
$("pamount" + nb.value).value = "0";
nb.value++;
}
| function anc_key_choice | ( | p_dossier, | |
| p_table, | |||
| p_amount, | |||
| p_ledger | |||
| ) |
choose the distribution key in ajax, a window let you choose what key you want to use
| p_dossier | is the dossier |
| p_table | the table id of the target |
| p_amount | amount to distribute |
| p_ledger |
Definition at line 434 of file anc_script.js.
References add_div(), alert(), error_box(), error_message(), fixed_position(), getNodeText(), remove_waiting_box(), style, unescape_xml(), and waiting_box().
Referenced by Anc_Operation::display_form_plan().
{
waiting_box();
var op = 'op=anc_key_choice';
var queryString = op + "&gDossier=" + p_dossier + "&t=" + p_table + "&amount=" + p_amount;
try {
queryString+='&led='+p_ledger;
var action = new Ajax.Request(
"ajax_misc.php",
{
method: 'get',
parameters: queryString,
onFailure: error_box,
onSuccess: function(req, json) {
try
{
var name_ctl = 'div_anc_key_choice';
var answer = req.responseXML;
remove_waiting_box();
var html = answer.getElementsByTagName('code');
if (html.length == 0) {
var rec = req.responseText;
alert('erreur :' + rec);
}
var code_html = getNodeText(html[0]); // Firefox ne prend que les 4096 car.
code_html = unescape_xml(code_html);
var position=fixed_position(50,120);
add_div({id: name_ctl, cssclass: 'inner_box', style: position, drag: 1});
$(name_ctl).innerHTML = code_html;
} catch (e)
{
error_message(e.message);
}
}
}
);
} catch (e) {
error_message(e.message);
}
}
| function anc_key_compute | ( | p_dossier, | |
| p_table, | |||
| p_amount, | |||
| p_key_id | |||
| ) |
compute and display Analytic activity, related to the choosen distribution key
| p_dossier | is the dossier id |
| p_table | is table id to replace |
| p_amount | is the amount to distribute |
| p_key_id | is the choosen key |
Definition at line 385 of file anc_script.js.
References alert(), error_box(), error_message(), getNodeText(), remove_waiting_box(), removeDiv(), unescape_xml(), and waiting_box().
{
waiting_box();
var op = "op=anc_key_compute";
var queryString = op + "&gDossier=" + p_dossier + "&t=" + p_table + "&amount=" + p_amount + '&key=' + p_key_id;
try {
var action = new Ajax.Request(
"ajax_misc.php",
{
method: 'get',
parameters: queryString,
onFailure: error_box,
onSuccess: function(req, json) {
try
{
var name_ctl = p_table;
var answer = req.responseXML;
remove_waiting_box();
var html = answer.getElementsByTagName('code');
if (html.length == 0) {
var rec = req.responseText;
alert('erreur :' + rec);
}
var code_html = getNodeText(html[0]); // Firefox ne prend que les 4096 car.
code_html = unescape_xml(code_html);
$(name_ctl).innerHTML = code_html;
removeDiv('div_anc_key_choice');
} catch (e)
{
error_message(e.message);
}
}
}
);
} catch (e) {
error_message(e.message);
}
}
| function anc_key_compute_table | ( | ) |
Definition at line 520 of file anc_script.js.
References value.
{
var tot=0;
var i=0;
var value=0;
var percent=document.getElementsByName('percent[]');
for (i=0;i<percent.length;i++)
{
value=percent[i].value;
if ( value == 'undefined')
{
value=0;
}
if ( isNaN(value)) {
value=0;
}
tot=tot+Math.round(value*100)/100;
}
$('total_key').innerHTML=Math.round(tot*100)/100;
}| function anc_refresh_remain | ( | p_table, | |
| p_seq | |||
| ) |
Refresh remain of account.
analytic
| p_table | table id |
| p_seq | sequence of the line |
Definition at line 101 of file anc_script.js.
References alert(), compute_total_table(), g(), style, and value.
Referenced by add_row().
{
try
{
var tot_line = parseFloat(g('amount_t' + p_seq).value);
var tot_table = compute_total_table(p_table, p_seq);
var remain = tot_line - tot_table;
remain = Math.round(remain * 100) / 100;
// var popup_table = p_table.toString();
// p_table = popup_table.replace("popup", "");
$('remain' + p_table).innerHTML = remain;
if (remain == 0)
{
$('remain' + p_table).style.color = "green"
}
else
{
$('remain' + p_table).style.color = "red"
}
} catch (a)
{
alert(a.message);
}
}
| function anc_remove_operation | ( | p_dossier, | |
| p_oa_group | |||
| ) |
remove an operation
| p_dossier | is the folder |
| p_oa_group | is the group of the analytic operation |
Definition at line 323 of file anc_script.js.
References encodeJSON(), and g().
{
var a = confirm("Etes-vous sur de vouloir effacer cette operation ?\n");
if (a == false)
return;
var obj = {"oa":
p_oa_group, "gDossier":
p_dossier, "op": "remove_anc"};
var queryString = encodeJSON(obj);
g(p_oa_group).style.display = 'none';
var e = new Ajax.Request("ajax_misc.php",
{method: 'get', parameters: queryString});
}
| function caod_checkTotal | ( | ) |
Definition at line 256 of file anc_script.js.
References g().
{
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 = g('nbrow').value;
for (var i = 0; i < nb_item; i++)
{
var doc_amount = g("pamount" + i);
if (!doc_amount)
{
return;
}
var side = g("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;
}
}
var r_total_cred = Math.round(total_cred * 100) / 100;
var r_total_deb = Math.round(total_deb * 100) / 100;
g('totalDeb').innerHTML = r_total_deb;
g('totalCred').innerHTML = r_total_cred;
if (r_total_deb != r_total_cred)
{
g("totalDiff").style.color = "red";
g("totalDiff").style.fontWeight = "bold";
g("totalDiff").innerHTML = "Différence";
var diff = total_deb - total_cred;
diff = Math.round(diff * 100) / 100;
g("totalDiff").innerHTML = diff;
}
else
{
g("totalDiff").innerHTML = "0.0";
}
}
| function compute_total_table | ( | p_table, | |
| seq | |||
| ) |
Compute total of a form from Anc_Operation::display_form_plan.
| p_table | table id |
| seq | sequence of the line |
Definition at line 75 of file anc_script.js.
References alert(), and value.
Referenced by add_row(), and anc_refresh_remain().
| function filter_anc | ( | obj, | |
| queryString | |||
| ) |
this function is called before the querystring is send to the fid2.php, add a filter based on the ledger 'p_jrn'
| obj | is the input field |
| queryString | is the queryString to modify |
Definition at line 371 of file anc_script.js.
{
var pa_id = obj.plan_ctl;
queryString = queryString + "&pa_id=" + pa_id;
return queryString;
}
| function search_anc_form | ( | obj | ) |
Definition at line 231 of file anc_script.js.
References alert(), name, remove_waiting_box(), and waiting_box().
{
var qs = "op=resultancsearch&ctl=searchanc&";
var name = obj.id;
qs += $(name).serialize(false);
waiting_box();
var action = new Ajax.Request('ajax_misc.php',
{
method: 'get',
parameters: qs,
onFailure: null,
onSuccess: function(req) {
try {
remove_waiting_box();
$('searchanc').innerHTML = req.responseText;
req.responseText.evalScripts();
} catch (e) {
alert(e.message);
}
}
}
);
return false;
}
| function search_ca | ( | p_dossier, | |
| p_target, | |||
| p_source | |||
| ) |
open a window for searching a CA account,
| p_dossier | dossier id |
| p_target | ctrl to update |
| p_source | ctrl containing the pa_id |
Definition at line 198 of file anc_script.js.
References add_div(), alert(), fixed_position(), g(), remove_waiting_box(), removeDiv(), style, and waiting_box().
{
var pa_id = g(p_source).value;
waiting_box();
removeDiv('search_anc');
var qs = "op=openancsearch&gDossier=" + p_dossier + "&ctl=searchanc";
qs += "&c2=" + pa_id + "&c1=" + p_target;
var action = new Ajax.Request('ajax_misc.php',
{
method: 'get',
parameters: qs,
onFailure: null,
onSuccess: function(req) {
try {
remove_waiting_box();
var pos = fixed_position(250, 150) + ";width:30%;height:50%";
add_div({
id: "searchanc",
drag: 1,
cssclass: "inner_box",
style: pos
});
$('searchanc').innerHTML = req.responseText;
} catch (e) {
alert(e.message);
}
}
}
);
}
| function verify_ca | ( | div | ) |
Check the amount of the CA.
| p_style | : error or ok, if ok show a ok box if the amount are equal |
Definition at line 132 of file anc_script.js.
References alert(), g(), table, and value.
{
try
{
var idx = 0;
var amount_error = 0;
// put a maximum
while (idx < 50)
{
var table = div + 't' + idx;
if (g(table))
{
var total_amount = 0;
// table is found compute the different val[]
var array_value = document.getElementsByName('val[' + idx + '][]');
for (var i = 0; i < array_value.length; i++)
{
if (isNaN(array_value[i].value))
{
array_value[i].value = 0;
}
total_amount += parseFloat(array_value[i].value);
}
var amount = parseFloat(g('amount_t' + idx).value);
var diff = amount - total_amount;
if (Math.round(diff, 2) != 0.0)
{
g(table).style.backgroundColor = 'red';
amount_error++;
}
else
{
g(table).style.backgroundColor = 'lightgreen';
}
idx++;
}
else
break;
}
if (amount_error != 0)
{
alert('Désolé, les montants pour la comptabilité analytique sont incorrects');
return false;
}
return true;
}
catch (e)
{
alert(e.message);
return false;
}
}