diff --git a/html/css/style-classic7.css b/html/css/style-classic7.css index bab8568b8..410b6815a 100644 --- a/html/css/style-classic7.css +++ b/html/css/style-classic7.css @@ -25,16 +25,18 @@ BODY { color:darkblue !important; background-color:#FCFDFD; --hover : rgba(108, 130, 208, 0.9); - --border-size:4px; + --border-size:8px; --accent-color:lightblue; + --input-color:#4b4b91; + --color-red:Crimson; } input{ font-family: 'OpenSansRegular'; padding : 2px; margin:2px; - border:1px solid #4b4b91; - font-size:14px; - color:#4b4b91; + border:1px solid var(--input-color); + + color:var(--input-color); } input:focus { @@ -112,16 +114,16 @@ h2 { background-color:#9fbcd6; /*! margin:1px; */ font-style: italic; - font-size:15px; + font-size:1.1rem !important; margin-top: 5px; - font-size: 1.1rem; -margin-bottom: 1rem; -margin-top: 1rem; -margin-right:1rem; -margin-left:1rem; -border-radius: 10px 0px; -padding:1rem; + font-size: 1.20rem; + margin-bottom: 1rem; + margin-top: 1rem; + margin-right:1rem; + margin-left:1rem; + border-radius: 10px; + padding:1rem; } @media only screen and (max-width: 1280px) { h2{ @@ -261,6 +263,43 @@ td.tool a.mtitle:hover { transition:color 300ms ease-in-out; } + #module .nav-pills a.nav-link:hover { + color:white !important; + border:1px solid transparent; + } + #module .nav-item-active , #module .nav-item-active > a.nav-link{ + background-color: #5d90cd ; + color:white !important; + border: 0px solid black; + } + /* animate module : sliding */ + #module .nav-item-module { + position:relative; + background-color: white; + color:navy; + } + #module .nav-item-module.nav-item-slide::before { + content:''; + top:0; + left:0; + bottom:0; + right:0; + position:absolute; + background-color:#5d90cd; + z-index:-1; + transform:scaleX(0); + transition:transform 300ms ease-in-out; + mix-blend-mode: darken; + } + #module .nav-item-module.nav-item-slide:hover::before, + #module .nav-item-module.nav-item-slide:focus::before { + transform:scaleX(1); + } + #module .nav-item-slide { + z-index:0; + transition:color 300ms ease-in-out; + } + @@ -280,6 +319,7 @@ td.tool a.mtitle:hover { /** menu left (not used) */ + div.lmenu { float:left; clear:left; @@ -301,7 +341,7 @@ div.content{ width:99.7%; font-family: Arial, Helvetica, "Liberation Sans", FreeSans, sans-serif; font-family: 'OpenSansRegular'; - font-size:12px; + font-size:100%; font-size:1rem; } @@ -471,7 +511,7 @@ tr.odd > td,tr.even > td { } .highlight { font-weight: bolder; - font-size:14px; + font-size:105%; font-size:1.05rem; } tr.highlight { @@ -671,7 +711,7 @@ a.document:hover { margin:1px; } .input_text { - border:1px solid #4b4b91; + border:1px solid var(--input-color); margin:1px; border-radius: 5px; } @@ -698,7 +738,7 @@ a.document:hover { h1.legend, legend { font-weight: bold; font-style: italic; - font-size: 19.2px; + font-size: 120%; font-size: 1.2rem; border: navy; border-width: 1px; @@ -968,7 +1008,7 @@ a#smallanchorbutton, .smallbutton, a.smallbutton,div.content a.smallbutton { font-weight: normal; text-decoration:none; font-family: arial,verdana,sans-serif,helvetica; - font-size:12px; + font-size:85%; font-size:0.85rem; font-family: SansationLight; border-style: ridge ; @@ -1050,7 +1090,7 @@ td.toolselected a.mtitle { background-color:#FF0000; } div.topmenu { - font-size:13.6px; + font-size:100%; font-size:1rem; } @@ -1135,7 +1175,7 @@ div.inner_box { border:1px solid #00008B; -moz-box-shadow: 10px 10px 5px #888; box-shadow: 15px 15px 15px #888; - font-size:14.4px; + font-size:90%; font-size:0.9rem; width: 100%; left:0px ; @@ -1154,7 +1194,7 @@ div.inner_box { border:1px solid #00008B; -moz-box-shadow: 10px 10px 5px #888; box-shadow: 15px 15px 15px #888; - font-size:14.4px; + font-size:90%; font-size:0.9rem; width: 50%; left:22% ; @@ -1496,7 +1536,7 @@ div.content a.nav:hover img,a.nav:hover img { } div.foldercontent { - font-size:14px; + font-size:95%; font-size:0.95rem; width: 95%; margin-left: 2.5%; @@ -1522,7 +1562,7 @@ div.foldercontent { } div.foldercontent { - font-size:14px; + font-size:95%; font-size:0.95rem; width: 95%; margin-left: 2.5%; @@ -1603,7 +1643,7 @@ div.myfieldset border-style: groove; } div.menu2 a.mtitle{ - font-size:13.6px; + font-size:100%; font-size:1rem; font-weight: normal; /*color: darkblue;*/ @@ -1629,7 +1669,7 @@ div.menu2 table { /*! border-spacing:1px; */ } div.menu3 { - font-size:13.6px; + font-size:80%; font-size:0.80rem; } @@ -1640,7 +1680,7 @@ div.menu3 { margin-left:30px; } #folder { - border: 1px solid #4b4b91; + border: 1px solid var(--input-color); border-collapse: separate; border-radius: 10px; border-spacing: 0px; @@ -1887,7 +1927,7 @@ left:25%; /**========*/ #error_div h2 { - background: #FF0000; + background: var(--color-red); } div#error_content_div { color:#FF0000; @@ -1902,7 +1942,7 @@ td.workday ol { } input.inum { text-align:right; - border:1px solid #4b4b91; + border:1px solid var(--input-color); margin:2px; border-radius: 5px; } @@ -1912,7 +1952,7 @@ div.box { font-family: 'openSansRegular'; overflow:hidden; border:1px solid #00008B; - font-size:10px; + font-size:90%; font-size:0.90rem; border-radius:5px; width:97%; @@ -1962,7 +2002,7 @@ div.even ,div.box tr.even { padding:2px; } #jrn_name_div h2{ - font-size:38.4px; + font-size:240%; font-size: 2.4rem; } #search_account { @@ -2187,7 +2227,7 @@ hr { ******************************************************************************/ li.highlight,tr.highlight{ font-weight: bolder; - font-size:14px; + font-size:90%; background-color: #8A8787; color:whitesmoke !important; border-width: 2px; @@ -2256,7 +2296,7 @@ div.content a.tinybutton,a.tinybutton{ /* background-image: url("font/bg-submit2.gif"); background-repeat: repeat-x; background-position: left; */ - font-size: 8px; + font-size: 70%; font-size: 0.7rem; padding-bottom: 0px; padding-top: 0px; @@ -2279,7 +2319,7 @@ input[type="button"].tinybutton { font-weight: bold; text-decoration: none; font-family: arial,verdana,sans-serif,helvetica; - font-size: 8px; + font-size: 70%; font-size: 0.7rem; padding-bottom: 0px; padding-top: 0px; @@ -2472,7 +2512,7 @@ width: 85%; /*! background-image: url("font/bg-submit2.gif"); */ /*! background-repeat: repeat-x; */ /*! background-position: left; */ - font-size:12px; + font-size:85%; font-size:0.85rem; font-family: SansationLight; border-style: ridge ; @@ -2508,7 +2548,8 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', end width: 75%; display: inline-block; background-color: white; - font-size: 16px; + font-size: 100%; + font-size: 1rem; padding: 8px; } @@ -2758,7 +2799,7 @@ div.bxbutton .icon margin-left: 6px; margin-right:6px; /*! padding-top:10px; */ - font-size:14px; + font-size:100%; font-size:1rem; cursor: pointer; border:0px; @@ -3283,10 +3324,10 @@ margin:1px; margin: 1px; background: navy; color: white; - border-radius: 3px; + border-radius: 4px; } .nav-fill .nav-item:hover { - background-color:#6393c1; + background-color:#6393c1; color:navy; text-decoration: none; } @@ -3301,9 +3342,39 @@ margin:1px; color:white ; } -li.li-active { - background-color: lightgray !important; + /****************************************/ + /* MENU LEVEL 0 */ + /****************************************/ +.nav-level0 { + } + + /* SM */ + @media (min-width: 576px) { + + } + + /* MD */ + @media (min-width: 768px) { + .nav-level0 > li >a { + padding:6%; + } + + } + + /* LG */ + @media (min-width: 992px) { + + } + + /* XL */ + @media (min-width: 1200px) { + + } +/****************************************/ + /* MENU LEVEL2 */ +/****************************************/ + .nav-level2 { background-color: hsl(240, 39%, 41.2%); } @@ -3316,10 +3387,21 @@ li.li-active { color:navy; text-decoration: none; } + + /* MD */ + @media (min-width: 768px) { + .nav-level2 .nav-item { + padding : 0%; + } + } + +/****************************************/ + /* MENU LEVEL 3 */ + /***************************************/ .nav-level3 { background-color:#336699; - - + + } .nav-level3>li { border-right: 1px #9fbcd6 ridge; @@ -3337,9 +3419,9 @@ li.li-active { border-radius:0px !important; } -/** - * Module for smartphone menu - */ + /****************************************/ + /* Module for smartphone menu */ + /***************************************/ #mobile_module .nav-pills a.nav-link { background-color:transparent !important; color:navy !important; @@ -3722,7 +3804,7 @@ h2.h-section { height:var(--border-size); background-color:lightblue; transform:scaleX(0); - transition:transform 300ms ease-in-out; + transition:transform 150ms ease-in-out; } .nav-item.nav-item-underline:hover::before, @@ -3733,7 +3815,7 @@ h2.h-section { .nav-item.li-active.nav-item-underline::before { transform: scale(1); - background-color: darkred; + background-color: #d03100; } /** @@ -3747,9 +3829,58 @@ h2.h-section { left: 0; right: 0; background-color:darkorange; - height: 3px; + height: var(--border-size); } .nav-level3 .nav-link.active::after { background-color:yellow; - } \ No newline at end of file + } +/*** + * Animate menu + * + */ + +.nav-item { + position:relative; + +} + +.nav-item.nav-item-underline::before { + content:''; + left:0; + bottom:0; + right:0; + position:absolute; + height:var(--border-size); + background-color:lightblue; + transform:scaleX(0); + transition:transform 300ms ease-in-out; +} + +.nav-item.nav-item-underline:hover::before, +.nav-item.nav-item-underline:focus::before +{ + transform:scaleX(1); +} + + .nav-item.li-active.nav-item-underline::before { + transform: scale(1); + background-color: var(--color-red); + } + + /** + * For level 2 and 3 no animation but border difference if active + */ + + .nav-level2 .nav-link.active::after, .nav-level3 .nav-link.active::after { + content: ''; + position: absolute; + bottom: 0; + left: 0; + right: 0; + background-color:darkorange; + } + + .nav-level3 .nav-link.active::after { + background-color:yellow; + } diff --git a/html/export.php b/html/export.php index 4c4443cca..b5faeb100 100644 --- a/html/export.php +++ b/html/export.php @@ -53,6 +53,27 @@ if ( $action=='X' || $g_user->check_print($action)==0 ) // get file and execute it $prfile=$cn->get_value("select me_file from menu_ref where me_code=$1",array($action)); + +if ( LOGINPUT) +{ + $file_loginput=fopen($_ENV['TMP'].'/export-'.$prfile.'-'.$_SERVER['REQUEST_TIME'].'.php','a+'); + fwrite ($file_loginput,"search($http->request("plugin_code")) != -1 ) { exit(); } + if ( LOGINPUT) + { + $file_loginput=fopen($_ENV['TMP'].'/plugin-export-'.$ext->me_code.'-'.$_SERVER['REQUEST_TIME'].'.php','a+'); + fwrite ($file_loginput,"me_code."\n"); + fwrite($file_loginput, '$_GET='.var_export($_GET,true)); + fwrite($file_loginput,";\n"); + fwrite($file_loginput, '$_POST='.var_export($_POST,true)); + fwrite($file_loginput,";\n"); + fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;'); + fwrite($file_loginput,"\n"); + fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;'); + fwrite($file_loginput,"\n"); + fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);'); + fwrite($file_loginput,"\n"); + $string='require_once "'.NOALYSS_PLUGIN.DIRECTORY_SEPARATOR.dirname(trim($ext->getp('me_file'))).DIRECTORY_SEPARATOR.'raw.php'.'";'; + fwrite($file_loginput,sprintf("%s",$string)); + fwrite($file_loginput,"\n"); + fclose($file_loginput); + } /* call the ajax script */ - require_once(NOALYSS_PLUGIN.DIRECTORY_SEPARATOR.dirname(trim($ext->getp('me_file'))).DIRECTORY_SEPARATOR.'raw.php'); + require_once NOALYSS_PLUGIN.DIRECTORY_SEPARATOR.dirname(trim($ext->getp('me_file'))).DIRECTORY_SEPARATOR.'raw.php'; } else { diff --git a/html/js/acc_currency.js b/html/js/acc_currency.js index 5c6d238d1..f2188a9fe 100644 --- a/html/js/acc_currency.js +++ b/html/js/acc_currency.js @@ -45,7 +45,7 @@ function CurrencyRateDelete(p_dossier, p_id) if ( answer['status'] == 'NOK') { smoke.alert(answer['content']); } else { - $('currency_rate_'+p_id).hide(); + id$('currency_rate_'+p_id).hide(); alternate_row_color("currency_rate_table"); } } @@ -64,11 +64,11 @@ function CurrencyUpdateValue(p_dossier,p_code,p_update) new Ajax.Request("ajax_misc.php",{ method:"get", asynchronous:false, - parameters:{p_code:$(p_code).value,gDossier:p_dossier,op:'CurrencyRate'}, + parameters:{p_code:id$(p_code).value,gDossier:p_dossier,op:'CurrencyRate'}, onSuccess:function (req) { var answer=req.responseText.evalJSON(); if ( answer.status == "OK") { - $(p_update).value=answer.content; + id$(p_update).value=answer.content; } else { smoke.alert(answer.content); } @@ -84,11 +84,11 @@ function CurrencyUpdateCode(p_dossier,p_code,p_update) { new Ajax.Request("ajax_misc.php",{ method:"get", - parameters:{p_code:$(p_code).value,gDossier:p_dossier,op:'CurrencyCode'}, + parameters:{p_code:id$(p_code).value,gDossier:p_dossier,op:'CurrencyCode'}, onSuccess:function (req) { var answer=req.responseText.evalJSON(); if ( answer.status == "OK") { - $(p_update).innerHTML=answer.content; + id$(p_update).innerHTML=answer.content; } else { smoke.alert(answer.content); } @@ -104,22 +104,22 @@ function CurrencyCompute(p_rate,p_update) { var tvac=1; - if ($('tvac')) { - tvac=$('tvac').innerHTML; - } else if ($("htva")) { - tvac=$('htva').innerHTML; + if (document.getElementById('tvac')) { + tvac=id$('tvac').innerHTML; + } else if (document.getElementById("htva")) { + tvac=id$('htva').innerHTML; } if ( isNaN(tvac)) { tvac=1; } - var rate=$(p_rate).value; + var rate=id$(p_rate).value; if ( isNaN(rate)) { rate=1; } var tot=tvac/rate; tot=Math.round(tot*100)/100; - $(p_update).innerHTML=tot; + id$(p_update).innerHTML=tot; } /** @@ -131,8 +131,8 @@ function CurrencyCompute(p_rate,p_update) */ function CurrencyComputeMisc(p_rate,p_update) { - var debAmount=$('totalDeb').innerHTML; - var credAmount=$('totalCred').innerHTML; + var debAmount=id$('totalDeb').innerHTML; + var credAmount=id$('totalCred').innerHTML; if ( isNaN(debAmount)) { debAmount=0; @@ -140,17 +140,17 @@ function CurrencyComputeMisc(p_rate,p_update) if ( isNaN(credAmount)) { credAmount=0; } - var rate=$(p_rate).value; + var rate=id$(p_rate).value; if ( isNaN(rate) || parseFloat(rate) == 0) { rate=1; } var totDeb=debAmount/rate; totDeb=Math.round(totDeb*100)/100; - $('default_currency_deb').innerHTML=totDeb; + id$('default_currency_deb').innerHTML=totDeb; var totCred=credAmount/rate; totCred=Math.round(totCred*100)/100; - $('default_currency_cred').innerHTML=totCred; + id$('default_currency_cred').innerHTML=totCred; } @@ -166,10 +166,10 @@ function CurrencyComputeMisc(p_rate,p_update) function LedgerCurrencyUpdate(p_dossier,p_code,p_update,p_rate,p_eur_amount) { // Hide or show the row of the table with the amount in EUR - if ($(p_code).value != 0) { - $('row_currency').show(); + if (document.getElementById(p_code).value != 0) { + id$('row_currency').show(); }else { - $('row_currency').hide(); + id$('row_currency').hide(); } CurrencyUpdateValue(p_dossier,p_code,p_rate); CurrencyUpdateCode(p_dossier,p_code,p_update); @@ -189,10 +189,10 @@ function LedgerCurrencyUpdate(p_dossier,p_code,p_update,p_rate,p_eur_amount) function LedgerCurrencyUpdateMisc(p_dossier,p_code,p_update,p_rate,p_eur_amount) { // Hide or show the row of the table with the amount in EUR (= default currency) - if ($(p_code).value != -1) { - $('row_currency').show(); + if (document.getElementById(p_code).value != -1) { + id$('row_currency').show(); }else { - $('row_currency').hide(); + id$('row_currency').hide(); } CurrencyUpdateValue(p_dossier,p_code,p_rate); CurrencyUpdateCode(p_dossier,p_code,p_update); diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index c4891fa53..86c6fc0e6 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -32,10 +32,10 @@ var layer = 1; * \brief update the list of available predefined operation when we change the ledger. */ function update_predef(p_type, p_direct, p_ac) { - var jrn = g("p_jrn").value; - var dossier = g("gDossier").value; + var jrn = id$("p_jrn").value; + var dossier = id$("gDossier").value; var querystring = 'gDossier=' + dossier + '&l=' + jrn + '&t=' + p_type + '&d=' + p_direct + "&op=up_predef&ac=" + p_ac; - g("p_jrn_predef").value = jrn; + id$("p_jrn_predef").value = jrn; var action = new Ajax.Request( "ajax_misc.php", { @@ -44,7 +44,7 @@ function update_predef(p_type, p_direct, p_ac) { onFailure: error_get_predef, onSuccess: function (req) { try { - $('info_div').innerHTML = "ok"; + id$('info_div').innerHTML = "ok"; var answer = req.responseXML; var a = answer.getElementsByTagName('code'); var html = answer.getElementsByTagName('value'); @@ -55,9 +55,9 @@ function update_predef(p_type, p_direct, p_ac) { var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); // document.getElementsByName(name_ctl)[0].value = code_html; - $('modele_op_div').innerHTML = code_html; + id$('modele_op_div').innerHTML = code_html; } catch (e) { - $('info_div').innerHTML = e.message; + id$('info_div').innerHTML = e.message; } } } @@ -69,8 +69,8 @@ function update_predef(p_type, p_direct, p_ac) { */ function update_pay_method() { waiting_box(); - var jrn = g("p_jrn").value; - var dossier = g("gDossier").value; + var jrn = id$("p_jrn").value; + var dossier = id$("gDossier").value; var querystring = 'gDossier=' + dossier + '&l=' + jrn + "&op=up_pay_method"; var action = new Ajax.Request( "ajax_misc.php", @@ -81,7 +81,7 @@ function update_pay_method() { onSuccess: function (req) { remove_waiting_box(); var answer = req.responseText; - $('payment').innerHTML = answer; + id$('payment').innerHTML = answer; } } ); @@ -92,8 +92,8 @@ function update_pay_method() { */ function update_other_tax() { waiting_box(); - var jrn = g("p_jrn").value; - var dossier = g("gDossier").value; + var jrn = id$("p_jrn").value; + var dossier = id$("gDossier").value; var querystring = {gDossier: dossier, jrn_id: jrn, op: "up_other_tax"}; var action = new Ajax.Request( "ajax_misc.php", @@ -105,7 +105,7 @@ function update_other_tax() { remove_waiting_box(); var answer = req.responseText; answer.evalScripts(); - $('additional_tax_div').innerHTML = answer; + id$('additional_tax_div').innerHTML = answer; } } ); @@ -115,8 +115,8 @@ function update_other_tax() { * update ctl id =jrn_name with the value of p_jrn */ function update_name() { - var jrn_id = $('p_jrn').value; - var dossier = g("gDossier").value; + var jrn_id = id$('p_jrn').value; + var dossier = id$("gDossier").value; var querystring = 'gDossier=' + dossier + '&l=' + jrn_id + "&op=ledger_description"; var action = new Ajax.Request( "ajax_misc.php", @@ -125,7 +125,7 @@ function update_name() { parameters: querystring, onFailure: error_get_pj, onSuccess: function (req) { - $('jrn_name_div').innerHTML = req.responseText; + id$('jrn_name_div').innerHTML = req.responseText; } } ); @@ -143,9 +143,9 @@ function error_get_predef(request, json) { /** * update the list of available predefined operation when we change the ledger. */ -function update_pj() { - var jrn = g("p_jrn").value; - var dossier = g("gDossier").value; +function update_receipt() { + var jrn = id$("p_jrn").value; + var dossier = id$("gDossier").value; var querystring = 'gDossier=' + dossier + '&l=' + jrn + "&op=upd_receipt"; var action = new Ajax.Request( "ajax_misc.php", @@ -162,8 +162,8 @@ function update_pj() { * ask the name, quick_code of the bank for the ledger */ function update_bank() { - var jrn = g('p_jrn').value; - var dossier = g('gDossier').value; + var jrn = id$('p_jrn').value; + var dossier = id$('gDossier').value; var qs = 'gDossier=' + dossier + '&op=bkname&p_jrn=' + jrn; var action = new Ajax.Request( "ajax_misc.php", @@ -186,10 +186,10 @@ function update_row(ctl) { if (ctl === 'quick_item') { row_to_keep = 1; } /* for ODS , only 1 rows to keep */ - var jrn = g('p_jrn').value; - var dossier = g('gDossier').value; + var jrn = id$('p_jrn').value; + var dossier = id$('gDossier').value; var qs = encodeURI('gDossier=' + dossier + '&op=minrow&j=' + jrn + '&ctl=' + ctl); - var current_row = parseFloat($('nb_item').value); + var current_row = parseFloat(id$('nb_item').value); var action = new Ajax.Request( "ajax_misc.php", { @@ -201,11 +201,11 @@ function update_row(ctl) { var answer = request.responseText.evalJSON(true); var row = parseFloat(answer.row); - var table_to_update = $(ctl); + var table_to_update = id$(ctl); if (current_row > row) { // Too many row, we always must keep 2 rows for the sum - var delta = $('nb_item').value - row; - var idx = $('nb_item').value; + var delta = id$('nb_item').value - row; + var idx = id$('nb_item').value; for (var i = 0; i < delta; i++) { var pos_row = table_to_update.rows.length; var cell0 = table_to_update.rows[pos_row - row_to_keep].cells[0]; @@ -239,7 +239,7 @@ function update_row(ctl) { } } - $('nb_item').value = table_to_update.rows.length - row_to_keep; + id$('nb_item').value = table_to_update.rows.length - row_to_keep; } if (current_row < row) { // We need to add rows @@ -271,8 +271,8 @@ function update_row(ctl) { * @brief hide or show the column quantity */ function update_visibility_quantity() { - var jrn = g("p_jrn").value; - var dossier = g("gDossier").value; + var jrn = id$("p_jrn").value; + var dossier = id$("gDossier").value; var querystring = 'gDossier=' + dossier + '&l=' + jrn + "&op=update_visibility_quantity"; var action = new Ajax.Request( "ajax_misc.php", @@ -321,7 +321,7 @@ function success_update_bank(req) { var name_ctl = a[0].firstChild.nodeValue; var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); - $(name_ctl).innerHTML = code_html; + id$(name_ctl).innerHTML = code_html; } catch (e) { alert_box("success_update_bank" + e.message); } @@ -331,8 +331,8 @@ function success_update_bank(req) { * call ajax, ask what is the last date for the current ledger */ function get_last_date() { - var jrn = g('p_jrn').value; - var dossier = g('gDossier').value; + var jrn = id$('p_jrn').value; + var dossier = id$('gDossier').value; var qs = 'gDossier=' + dossier + '&op=lastdate&p_jrn=' + jrn; var action = new Ajax.Request( "ajax_misc.php", @@ -372,12 +372,12 @@ function success_get_last_date(req) { function success_get_pj(request, json) { var answer = request.responseText.evalJSON(true); - var obj = g("e_pj"); + var obj = id$("e_pj"); obj.value = ''; if (answer.length == 0) return; obj.value = answer.pj; - g("e_pj_suggest").value = answer.pj; + id$("e_pj_suggest").value = answer.pj; } /** @@ -392,10 +392,10 @@ function error_get_pj(request, json) { */ function ledger_fin_add_row() { var style = 'class="input_text"'; - var mytable = g("fin_item").tBodies[0]; + var mytable = id$("fin_item").tBodies[0]; var line = mytable.rows.length; var row = mytable.insertRow(line); - var nb = g("nb_item"); + var nb = id$("nb_item"); var rowToCopy = mytable.rows[1]; var nNumberCell = rowToCopy.cells.length; for (var e = 0; e < nNumberCell; e++) { @@ -415,15 +415,15 @@ function ledger_fin_add_row() { newCell.className = rowToCopy.cells[e].className; new_tt.evalScripts(); } - g("e_other" + nb.value).value = ""; - g("e_other_name" + nb.value).value = ""; - g("e_other" + nb.value + '_amount').value = "0"; - g("e_other" + nb.value + '_comment').value = ""; - g("e_concerned" + nb.value).value = ""; + id$("e_other" + nb.value).value = ""; + id$("e_other_name" + nb.value).value = ""; + id$("e_other" + nb.value + '_amount').value = "0"; + id$("e_other" + nb.value + '_comment').value = ""; + id$("e_concerned" + nb.value).value = ""; - var ch = $('chdate').options[$('chdate').selectedIndex].value; + var ch = id$('chdate').options[id$('chdate').selectedIndex].value; if (ch == 1) { - $('tdchdate' + nb.value).hide(); + id$('tdchdate' + nb.value).hide(); } nb.value++; } @@ -433,11 +433,11 @@ function ledger_fin_add_row() { * @param string p_elid is the id of element with the number of rows to add, and p_elid+"_ledger" is the type of ledger : M : Misc Operation O : Sales or purchase and F for financial */ function ledger_add_multiple(p_elid) { - var nbrow = $(p_elid).value; + var nbrow = id$(p_elid).value; if (nbrow == NaN) { nbrow = 1; } - var type_ledger = $(p_elid + "_ledger").value; + var type_ledger = id$(p_elid + "_ledger").value; var i = 0; for (i = 0; i < nbrow; i++) { if (type_ledger == 'O') { @@ -464,12 +464,12 @@ function ledger_add_multiple(p_elid) { function ledger_add_row() { try { style = 'class="input_text"'; - var mytable = g("sold_item").tBodies[0]; + var mytable = id$("sold_item").tBodies[0]; var ofirstRow = mytable.rows[1]; var line = mytable.rows.length; var nCell = mytable.rows[1].cells.length; var row = mytable.insertRow(line); - var nb = g("nb_item"); + var nb = id$("nb_item"); for (var e = 0; e < nCell; e++) { var newCell = row.insertCell(e); var tt = ofirstRow.cells[e].innerHTML; @@ -483,13 +483,13 @@ function ledger_add_row() { new_tt.evalScripts(); } - $("e_march" + nb.value + "_label").innerHTML = ''; - $("e_march" + nb.value + "_label").value = ''; - $("e_march" + nb.value + "_price").value = '0'; - $("e_march" + nb.value).value = ""; - $("e_quant" + nb.value).value = "1"; - if ($("e_march" + nb.value + "_tva_amount")) - $("e_march" + nb.value + "_tva_amount").value = 0; + id$("e_march" + nb.value + "_label").innerHTML = ''; + id$("e_march" + nb.value + "_label").value = ''; + id$("e_march" + nb.value + "_price").value = '0'; + id$("e_march" + nb.value).value = ""; + id$("e_quant" + nb.value).value = "1"; + if (document.getElementById("e_march" + nb.value + "_tva_amount")) + id$("e_march" + nb.value + "_tva_amount").value = 0; nb.value++; @@ -505,17 +505,17 @@ function ledger_add_row() { * @param the number of the changed ctrl */ function compute_ledger(p_ctl_nb) { - var dossier = g("gDossier").value; + var dossier = id$("gDossier").value; var a = -1; if (document.getElementById("e_march" + p_ctl_nb + '_tva_amount')) { - a = trim(g("e_march" + p_ctl_nb + '_tva_amount').value); - g("e_march" + p_ctl_nb + '_tva_amount').value = a; + a = trim(id$("e_march" + p_ctl_nb + '_tva_amount').value); + id$("e_march" + p_ctl_nb + '_tva_amount').value = a; } if (!document.getElementById("e_march" + p_ctl_nb)) { return; } - g("e_march" + p_ctl_nb).value = trim(g("e_march" + p_ctl_nb).value); - var qcode = g("e_march" + p_ctl_nb).value; + id$("e_march" + p_ctl_nb).value = trim(id$("e_march" + p_ctl_nb).value); + var qcode = id$("e_march" + p_ctl_nb).value; if (qcode.length == 0) { clean_ledger(p_ctl_nb); @@ -526,19 +526,19 @@ function compute_ledger(p_ctl_nb) { * if tva_id is empty send a value of -1 */ var tva_id = -1; - if (g('e_march' + p_ctl_nb + '_tva_id')) { - tva_id = g('e_march' + p_ctl_nb + '_tva_id').value; + if (document.getElementById('e_march' + p_ctl_nb + '_tva_id')) { + tva_id = id$('e_march' + p_ctl_nb + '_tva_id').value; if (trim(tva_id) == '') { tva_id = -1; } } - g('e_march' + p_ctl_nb + '_price').value = trim(g('e_march' + p_ctl_nb + '_price').value); - var price = g('e_march' + p_ctl_nb + '_price').value; + id$('e_march' + p_ctl_nb + '_price').value = trim(id$('e_march' + p_ctl_nb + '_price').value); + var price = id$('e_march' + p_ctl_nb + '_price').value; - g('e_quant' + p_ctl_nb).value = trim(g('e_quant' + p_ctl_nb).value); - var quantity = g('e_quant' + p_ctl_nb).value; - let other_tax = g("other_tax"); + id$('e_quant' + p_ctl_nb).value = trim(id$('e_quant' + p_ctl_nb).value); + var quantity = id$('e_quant' + p_ctl_nb).value; + let other_tax = document.getElementById("other_tax"); let other_tax_id = (other_tax && other_tax.checked) ? other_tax.value : -1; var querystring = { @@ -569,26 +569,26 @@ function refresh_ledger() { var htva = 0; var tvac = 0; - nb_item = g("nb_item").value; + nb_item = id$("nb_item").value; for (var i = 0; i < nb_item; i++) { - if (g('tva_march' + i)) - tva += g('tva_march' + i).value * 1; - if (g('htva_march' + i)) - htva += g('htva_march' + i).value * 1; - if (g('tvac_march' + i)) - tvac += g('tvac_march' + i).value * 1; + if (document.getElementById('tva_march' + i)) + tva += id$('tva_march' + i).value * 1; + if (document.getElementById('htva_march' + i)) + htva += id$('htva_march' + i).value * 1; + if (document.getElementById('tvac_march' + i)) + tvac += id$('tvac_march' + i).value * 1; } - id_tva = g("tva"); - id_htva = g("htva"); - id_tvac = g("tvac"); - id_other_tax = g("other_tax_amount"); + id_tva = id$("tva"); + id_htva = id$("htva"); + id_tvac = id$("tvac"); + id_other_tax = document.getElementById("other_tax_amount"); if (id_tva) id_tva.innerHTML = Math.round(tva * 100) / 100; if (id_htva) id_htva.innerHTML = Math.round(htva * 100) / 100; if (id_other_tax) { let total_operation = tvac + parseFloat(id_other_tax.value); - $('total_operation_other_tax').innerHTML = Math.round(total_operation * 100) / 100; + id$('total_operation_other_tax').innerHTML = Math.round(total_operation * 100) / 100; } if (id_tvac) id_tvac.innerHTML = Math.round(tvac * 100) / 100; @@ -607,15 +607,15 @@ function success_compute_ledger(request, json) { var rtva = answer.tva; var rhtva = answer.htva; var rtvac = answer.tvac; - let other_tax = g("other_tax_amount") + let other_tax = id$("other_tax_amount") if (other_tax) { other_tax.value = answer.other_tax; } if (rtva == 'NA') { var rhtva = answer.htva * 1; - g('htva_march' + ctl).value = rhtva; - g('tvac_march' + ctl).value = rtvac; - g('sum').show(); + id$('htva_march' + ctl).value = rhtva; + id$('tvac_march' + ctl).value = rtvac; + id$('sum').show(); refresh_ledger(); CurrencyCompute('p_currency_rate', 'p_currency_euro'); @@ -624,17 +624,18 @@ function success_compute_ledger(request, json) { rtva = answer.tva * 1; - g('sum').show(); - if (g('e_march' + ctl + '_tva_amount').value == "" || g('e_march' + ctl + '_tva_amount').value == 0) { - g('tva_march' + ctl).value = rtva; - g('e_march' + ctl + '_tva_amount').value = rtva; + id$('sum').show(); + if (document.getElementById('e_march' + ctl + '_tva_amount').value == "" || + document.getElementById('e_march' + ctl + '_tva_amount').value == 0) { + id$('tva_march' + ctl).value = rtva; + id$('e_march' + ctl + '_tva_amount').value = rtva; } else { - g('tva_march' + ctl).value = g('e_march' + ctl + '_tva_amount').value; + id$('tva_march' + ctl).value = id$('e_march' + ctl + '_tva_amount').value; } - g('htva_march' + ctl).value = Math.round(parseFloat(rhtva) * 100) / 100; - var tmp1 = Math.round(parseFloat(g('htva_march' + ctl).value) * 100) / 100; - var tmp2 = Math.round(parseFloat(g('tva_march' + ctl).value) * 100) / 100; - g('tvac_march' + ctl).value = Math.round((tmp1 + tmp2) * 100) / 100; + id$('htva_march' + ctl).value = Math.round(parseFloat(rhtva) * 100) / 100; + var tmp1 = Math.round(parseFloat(id$('htva_march' + ctl).value) * 100) / 100; + var tmp2 = Math.round(parseFloat(id$('tva_march' + ctl).value) * 100) / 100; + id$('tvac_march' + ctl).value = Math.round((tmp1 + tmp2) * 100) / 100; refresh_ledger(); CurrencyCompute('p_currency_rate', 'p_currency_euro'); @@ -649,7 +650,7 @@ function error_compute_ledger(request, json) { function compute_all_ledger() { var loop = 0; - let nb_item = g("nb_item").value; + let nb_item = id$("nb_item").value; for (loop = 0; loop < nb_item; loop++) { compute_ledger(loop); } @@ -658,53 +659,52 @@ function compute_all_ledger() { var tvac = 0; for (var i = 0; i < nb_item; i++) { - if (g('tva_march')) - tva += g('tva_march' + i).value * 1; - if (g('htva_march' + i)) - htva += g('htva_march' + i).value * 1; - if (g('tvac_march' + i)) - tvac += g('tvac_march' + i).value * 1; + if (document.getElementById('tva_march')) + tva += id$('tva_march' + i).value * 1; + if (document.getElementById('htva_march' + i)) + htva += id$('htva_march' + i).value * 1; + if (document.getElementById('tvac_march' + i)) + tvac += id$('tvac_march' + i).value * 1; } - id_other_tax = g("other_tax_amount"); - if (g('tva')) - g('tva').innerHTML = Math.round(tva * 100) / 100; - if (g('htva')) - g('htva').innerHTML = Math.round(htva * 100) / 100; + id_other_tax = document.getElementById("other_tax_amount"); + if (document.getElementById('tva')) id$('tva').innerHTML = Math.round(tva * 100) / 100; + if (document.getElementById ('htva')) + id$('htva').innerHTML = Math.round(htva * 100) / 100; if (id_other_tax) { tvac += id_other_tax.value; } - if (g('tvac')) - g('tvac').innerHTML = Math.round(tvac * 100) / 100; + if (document.getElementById('tvac')) + id$('tvac').innerHTML = Math.round(tvac * 100) / 100; } function clean_tva(p_ctl) { - if (g('e_march' + p_ctl + '_tva_amount')) - g('e_march' + p_ctl + '_tva_amount').value = 0; + if (document.getElementById('e_march' + p_ctl + '_tva_amount')) + id$('e_march' + p_ctl + '_tva_amount').value = 0; } function clean_ledger(p_ctl_nb) { - if (g("e_march" + p_ctl_nb)) { - g("e_march" + p_ctl_nb).value = trim(g("e_march" + p_ctl_nb).value); + if (document.getElementById("e_march" + p_ctl_nb)) { + id$("e_march" + p_ctl_nb).value = trim(id$("e_march" + p_ctl_nb).value); } - if (g('e_march' + p_ctl_nb + '_price')) { - g('e_march' + p_ctl_nb + '_price').value = ''; + if (document.getElementById('e_march' + p_ctl_nb + '_price')) { + id$('e_march' + p_ctl_nb + '_price').value = ''; } - if (g('e_quant' + p_ctl_nb)) { - g('e_quant' + p_ctl_nb).value = '1'; + if (document.getElementById('e_quant' + p_ctl_nb)) { + id$('e_quant' + p_ctl_nb).value = '1'; } - if (g('tva_march' + p_ctl_nb + '_show')) { - g('tva_march' + p_ctl_nb + '_show').value = '0'; + if (document.getElementById('tva_march' + p_ctl_nb + '_show')) { + id$('tva_march' + p_ctl_nb + '_show').value = '0'; } - if (g('tva_march' + p_ctl_nb)) { - g('tva_march' + p_ctl_nb).value = 0; + if (document.getElementById('tva_march' + p_ctl_nb)) { + id$('tva_march' + p_ctl_nb).value = 0; } - if (g('htva_march' + p_ctl_nb)) { - g('htva_march' + p_ctl_nb).value = 0; + if (document.getElementById('htva_march' + p_ctl_nb)) { + id$('htva_march' + p_ctl_nb).value = 0; } - if (g('tvac_march' + p_ctl_nb)) { - g('tvac_march' + p_ctl_nb).value = 0; + if (document.getElementById('tvac_march' + p_ctl_nb)) { + id$('tvac_march' + p_ctl_nb).value = 0; } } @@ -714,12 +714,12 @@ function clean_ledger(p_ctl_nb) { */ function quick_writing_add_row() { style = 'class="input_text"'; - var mytable = g("quick_item").tBodies[0]; + var mytable = id$("quick_item").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("nb_item"); + var nb = id$("nb_item"); var oNewRow = mytable.insertRow(nNumberRow); for (var e = 0; e < nNumberCell; e++) { @@ -735,17 +735,17 @@ function quick_writing_add_row() { new_tt.evalScripts(); } - var ck = $('ck' + nb.value); + var ck = id$('ck' + nb.value); ck.addEventListener('click', function (event) { display_range_dcside(event, ck); display_dcside(ck); }); - $("qc_" + nb.value).value = ""; - $("amount" + nb.value).value = ""; - $("poste" + nb.value).value = ""; - $("ld" + nb.value).value = ""; + id$("qc_" + nb.value).value = ""; + id$("amount" + nb.value).value = ""; + id$("poste" + nb.value).value = ""; + id$("ld" + nb.value).value = ""; nb.value++; @@ -805,7 +805,7 @@ function view_history_account(p_value, dossier, p_exercice) { add_div(popup); success_box(req, xml); - $(idbox).style.top = calcy(140 + (layer * 3)) + "px"; + id$(idbox).style.top = calcy(140 + (layer * 3)) + "px"; } } ); @@ -845,8 +845,8 @@ function view_history_anc_account(p_value, dossier, p_exercice) { if (req.responseText === 'NOCONX') { reconnect();return;} add_div(popup); - $(idbox).innerHTML = req.responseText; - $(idbox).style.top = calcy(140 + (layer * 3)) + "px"; + id$(idbox).innerHTML = req.responseText; + id$(idbox).style.top = calcy(140 + (layer * 3)) + "px"; } } ); @@ -881,7 +881,7 @@ function update_history_account(obj) { if (req.responseText === 'NOCONX') { reconnect();return;} success_box(req, xml); - g(obj.div).style.top = calcy(140 + (layer * 3)) + "px"; + id$(obj.div).style.top = calcy(140 + (layer * 3)) + "px"; } }); } catch (e) { @@ -925,7 +925,7 @@ function view_history_card(p_value, dossier, p_exercice) { add_div(popup); success_box(req, xml); - g(idbox).style.top = calcy(140 + (layer * 3)) + "px"; + id$(idbox).style.top = calcy(140 + (layer * 3)) + "px"; } } ); @@ -962,8 +962,8 @@ function view_followup_card(p_value, dossier) { if (req.responseText === 'NOCONX') { reconnect();return;} add_div(popup); - $(idbox).update(req.responseText); - g(idbox).style.top = calcy(140 + (layer * 3)) + "px"; + id$(idbox).update(req.responseText); + id$(idbox).style.top = calcy(140 + (layer * 3)) + "px"; } } ); @@ -997,7 +997,7 @@ function update_history_card(obj) { remove_waiting_box(); success_box(req, xml); - g(obj.div).style.top = calcy(140 + (layer * 3)) + "px"; + id$(obj.div).style.top = calcy(140 + (layer * 3)) + "px"; } }); } catch (e) { @@ -1039,8 +1039,8 @@ function removeOperation(p_jr_id, dossier, div) { *@param pointer to the FORM */ function reverseOperation(obj) { - var qs = $(obj).serialize() + "&op=ledger"; - g('ext' + obj.divname).style.display = 'none'; + var qs = id$(obj).serialize() + "&op=ledger"; + id$('ext' + obj.divname).style.display = 'none'; waiting_box(); new Ajax.Request( "ajax_misc.php", @@ -1112,8 +1112,8 @@ function modifyOperation(p_value, dossier) { remove_waiting_box(); add_div(popup); success_box(xml, txt); - $(id_div).style.position = "absolute"; - $(id_div).style.top = calcy(100 + (layer * 3)) + "px"; + id$(id_div).style.position = "absolute"; + id$(id_div).style.top = calcy(100 + (layer * 3)) + "px"; } } ); @@ -1154,9 +1154,9 @@ function dropLink(p_dossier, p_div, p_jr_id, p_jr_id2) { *@see ICard::input */ function filter_card(obj, queryString) { - jrn = $('p_jrn').value; + jrn = id$('p_jrn').value; if (jrn == -1) { - type = $('ledger_type').value; + type = id$('ledger_type').value; queryString = queryString + '&type=' + type; } else { queryString = queryString + '&j=' + jrn; @@ -1182,10 +1182,10 @@ function dsp_letter(obj) { onSuccess: success_dsp_letter } ); - g('search').style.display = 'none'; - g('list').style.display = 'none'; - $('detail').innerHTML = loading(); - g('detail').style.display = 'block'; + id$('search').style.display = 'none'; + id$('list').style.display = 'none'; + id$('detail').innerHTML = loading(); + id$('detail').style.display = 'block'; } catch (e) { alert_box('dsp_letter failed ' + e.message); } @@ -1203,20 +1203,20 @@ function success_dsp_letter(req) { var name_ctl = a[0].firstChild.nodeValue; var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); - $('detail').innerHTML = code_html; + id$('detail').innerHTML = code_html; } catch (e) { alert_box(e.message); } try { code_html.evalScripts(); } catch (e) { - alert_box("DSPLETTER:" + content[48] + e.message); + alert_box("DSPLETTER1:" + content[48] + e.message); } } function error_dsp_letter(req) { - alert_box("DSPLETTER:" + content[48]); + alert_box("DSPLETTER2:" + content[48]); } function search_letter(obj) { @@ -1251,10 +1251,10 @@ function search_letter(obj) { onSuccess: success_dsp_letter } ); - $('list').hide(); - $('search').hide(); - $('detail').innerHTML = loading(); - $('detail').show(); + id$('list').hide(); + id$('search').hide(); + id$('detail').innerHTML = loading(); + id$('detail').show(); } catch (e) { alert_box('search_letter ' + e.message); } @@ -1268,10 +1268,10 @@ function search_letter(obj) { */ function op_save(obj) { try { - var queryString = $(obj).serialize(true); + var queryString = id$(obj).serialize(true); queryString ["gDossier"] = obj.gDossier.value; var rapt2 = "rapt" + obj.whatdiv.value; - queryString ["rapt"] = g(rapt2).value; + queryString ["rapt"] = id$(rapt2).value; queryString ["jr_id"] = obj.jr_id.value; var jr_id = obj.jr_id.value; queryString ["div"] = obj.whatdiv.value; @@ -1283,7 +1283,7 @@ function op_save(obj) { /* * Operation detail is in a new window */ - if (g('inpopup')) { + if (document.getElementById('inpopup')) { var action = new Ajax.Request('ajax_misc.php', { method: 'post', @@ -1327,8 +1327,8 @@ function op_save(obj) { try { var answer = xml.responseXML; var html = answer.getElementsByTagName('code'); - $(divid).innerHTML = unescape(getNodeText(html[0])); - $(divid).innerHTML.evalScripts(); + id$(divid).innerHTML = unescape(getNodeText(html[0])); + id$(divid).innerHTML.evalScripts(); remove_waiting_box(); } catch (e) { console.error("D1. op_save") @@ -1348,8 +1348,8 @@ function op_save(obj) { } function get_history_account(ctl, dossier) { - if ($(ctl).value != '') { - view_history_account($(ctl).value, dossier); + if (document.getElementById(ctl).value != '') { + view_history_account(id$(ctl).value, dossier); } } @@ -1398,12 +1398,12 @@ function show_reconcile(p_div, p_let) { function gestion_add_row() { try { style = 'class="input_text"'; - var mytable = g("art").tBodies[0]; + var mytable = id$("art").tBodies[0]; var ofirstRow = mytable.rows[1]; var line = mytable.rows.length; var nCell = mytable.rows[1].cells.length; var row = mytable.insertRow(line); - var nb = g("nb_item"); + var nb = id$("nb_item"); for (var e = 0; e < nCell; e++) { var newCell = row.insertCell(e); var tt = ofirstRow.cells[e].innerHTML; @@ -1421,14 +1421,14 @@ function gestion_add_row() { new_tt.evalScripts(); } - g("e_march" + nb.value + "_label").innerHTML = ' '; - g("e_march" + nb.value + "_label").value = ''; - g("e_march" + nb.value + "_price").value = '0'; - g("e_march" + nb.value).value = ""; - g("e_quant" + nb.value).value = "1"; - g('tvac_march' + nb.value).value = "0"; - if ($("e_march" + nb.value + "_tva_amount")) - g("e_march" + nb.value + "_tva_amount").value = 0; + id$("e_march" + nb.value + "_label").innerHTML = ' '; + id$("e_march" + nb.value + "_label").value = ''; + id$("e_march" + nb.value + "_price").value = '0'; + id$("e_march" + nb.value).value = ""; + id$("e_quant" + nb.value).value = "1"; + id$('tvac_march' + nb.value).value = "0"; + if (document.getElementById("e_march" + nb.value + "_tva_amount")) + id$("e_march" + nb.value + "_tva_amount").value = 0; nb.value++; @@ -1446,7 +1446,7 @@ function document_remove(p_dossier, p_div, p_jrid) { { parameters: {"op": "ledger", "gDossier": p_dossier, "div": p_div, "p_jrid": p_jrid, 'act': 'rmf'}, onSuccess: function (x) { - $('receipt' + p_div).innerHTML = x.responseText; + id$('receipt' + p_div).innerHTML = x.responseText; } }) } @@ -1481,7 +1481,7 @@ function manage_search_filter(p_obj) { 'style': 'top:' + y + 'px;left:' + x + 'px;position:absolute;width:400px', drag: 1 }); - $('boxfilter' + p_obj.div).show(); + id$('boxfilter' + p_obj.div).show(); } }); } @@ -1503,11 +1503,11 @@ function save_filter(p_div, p_dossier) { eltValue['gDossier'] = p_dossier; eltValue['op'] = "save_filter"; eltValue['div'] = p_div; - eltValue['filter_name'] = $(p_div + "filter_new").value; + eltValue['filter_name'] = id$(p_div + "filter_new").value; // Get all elt from the form for (var i = 0; i < elt.length; i++) { var idx = elt[i]; - eltValue[idx] = $(p_div + elt[i]).value; + eltValue[idx] = id$(p_div + elt[i]).value; } if (eltValue['amount_min'] == "") eltValue["amount_min"] = 0; @@ -1518,7 +1518,7 @@ function save_filter(p_div, p_dossier) { eltValue['r_jrn'] = []; for (i = 0; i < eltValue['nb_jrn']; i++) { var idx = p_div + 'r_jrn[' + i + ']'; - eltValue['r_jrn' + i] = $(idx).value + eltValue['r_jrn' + i] = id$(idx).value } } @@ -1539,8 +1539,8 @@ function save_filter(p_div, p_dossier) { var new_item = document.createElement('li'); new_item.innerHTML = answer.filter_name; new_item.setAttribute("id", "manageli" + p_div + "_" + answer.filter_id); - $('manage' + p_div).appendChild(new_item); - $(p_div + "filter_new").value = ""; + id$('manage' + p_div).appendChild(new_item); + id$(p_div + "filter_new").value = ""; } else { throw answer.message; } @@ -1570,10 +1570,10 @@ function load_filter(p_div, p_dossier, p_filter_id) { , 'p_currency_code', 'tva_id_search']; for (var i = 0; i < elt.length; i++) { var idx = elt[i]; - $(p_div + idx).value = answer[elt[i]]; + id$(p_div + idx).value = answer[elt[i]]; } // fillup the r_jrn array - var eltLedgerId = $("ledger_id" + p_div); + var eltLedgerId = id$("ledger_id" + p_div); eltLedgerId.innerHTML = ""; var eltHidden = document.createElement("input"); eltHidden.setAttribute("name", p_div + "nb_jrn"); @@ -1599,7 +1599,7 @@ function load_filter(p_div, p_dossier, p_filter_id) { uf_tag: answer.uf_tag }, onSuccess: function (req) { - $(p_div + 'tag_choose_td').update(req.responseText); + id$(p_div + 'tag_choose_td').update(req.responseText); } }) @@ -1629,9 +1629,9 @@ function delete_filter(p_div, p_dossier, p_filter_id) { try { var answer = req.evalJSON; - var child = $("manageli" + p_div + "_" + p_filter_id); + var child = id$("manageli" + p_div + "_" + p_filter_id); if (child) { - $("manage" + p_div).removeChild(child); + id$("manage" + p_div).removeChild(child); } } catch (e) { console.log(e.message) @@ -1651,16 +1651,16 @@ function reset_filter(p_div) { var elt = ['date_start', 'date_end', 'date_paid_start', 'date_paid_end', 'desc', 'amount_min', 'amount_max', 'qcode', 'accounting', 'tva_id_search']; for (var i = 0; i < elt.length; i++) { var idx = elt[i]; - $(p_div + idx).value = ""; + id$(p_div + idx).value = ""; } - if ($(p_div + "date_start_hidden")) { - $(p_div + "date_start").value = $(p_div + "date_start_hidden").value; + if (document.getElementById(p_div + "date_start_hidden")) { + id$(p_div + "date_start").value = id$(p_div + "date_start_hidden").value; } - if ($(p_div + "date_end_hidden")) { - $(p_div + "date_end").value = $(p_div + "date_end_hidden").value; + if (document.getElementById(p_div + "date_end_hidden")) { + id$(p_div + "date_end").value = id$(p_div + "date_end_hidden").value; } // clean all the selected ledger - var eltLedgerId = $("ledger_id" + p_div); + var eltLedgerId = id$("ledger_id" + p_div); eltLedgerId.innerHTML = ""; var eltHidden = document.createElement("input"); eltHidden.setAttribute("name", p_div + "nb_jrn"); @@ -1670,7 +1670,7 @@ function reset_filter(p_div) { eltLedgerId.appendChild(eltHidden); // By default , unpaid is uncked - $(p_div + "operation_filter").value = "all"; + id$(p_div + "operation_filter").value = "all"; } function display_list_filter(p_dossier,access_code,ledger_type) { @@ -1744,7 +1744,7 @@ function tax_detail_view (dossier_id,date_from,date_to,nLedger_id,nTva_id) removeDiv(dgbox); // For form , most of the parameters are in the FORM // method is then POST - //var queryString=$(p_form_id).serialize(true); + //var queryString=id$(p_form_id).serialize(true); var queryString = { op: 'tax_detail', @@ -1771,7 +1771,7 @@ function tax_detail_view (dossier_id,date_from,date_to,nLedger_id,nTva_id) var y=calcy(15); var div_style="position:absolute;"+";top:"+y+"px"; add_div({id:dgbox,cssclass:'inner_box',html:loading(),style:div_style,drag:true}); - $(dgbox).update(req.responseText); + id$(dgbox).update(req.responseText); } } @@ -1791,7 +1791,7 @@ var operation_exercice = { waiting_box(); var queryString = { op: 'operation_exercice+update_periode', - folder: $('dos_id').value, + folder: id$('dos_id').value, gDossier: dossier_id }; var action = new Ajax.Request( @@ -1807,7 +1807,7 @@ var operation_exercice = { return; } - $("select_exercice_id").update(req.responseText); + id$("select_exercice_id").update(req.responseText); } } @@ -1823,13 +1823,13 @@ var operation_exercice = { removeDiv(dgbox); // For form , most of the parameters are in the FORM // method is then POST - //var queryString=$(p_form_id).serialize(true); + //var queryString=id$(p_form_id).serialize(true); console.debug(row_operation_exercice); var queryString = { op: 'operation_exercice+modify_row', oe_id: oe_id, row_id: row_operation_exercice, - gDossier: $('gDossier').value + gDossier: id$('gDossier').value }; var action = new Ajax.Request( "ajax_misc.php", @@ -1847,7 +1847,7 @@ var operation_exercice = { var y = calcy(15); var div_style = "position:absolute;" + ";top:" + y + "px"; add_div({id: dgbox, cssclass: 'inner_box', html: loading(), style: div_style, drag: true}); - $(dgbox).update(req.responseText); + id$(dgbox).update(req.responseText); } } ); @@ -1865,9 +1865,9 @@ var operation_exercice = { // For form , most of the parameters are in the FORM // method is then POST - //var queryString=$(p_form_id).serialize(true); + //var queryString=id$(p_form_id).serialize(true); - var queryString = $('operation_exercice_input_row_frm').serialize(true); + var queryString = id$('operation_exercice_input_row_frm').serialize(true); var action = new Ajax.Request( "ajax_misc.php", @@ -1890,24 +1890,24 @@ var operation_exercice = { row.setAttribute("oed_id", rowid); row.setAttribute("oe_id", req.responseJSON['oe_id']); row.update(req.responseJSON['content']); - $("operation_exercice_tb").appendChild(row); + id$("operation_exercice_tb").appendChild(row); row.addEventListener("click", function (event) { operation_exercice.click_modify_row(row) }) } else { - $("oe_" + rowid).update(req.responseJSON['content']); + id$("oe_" + rowid).update(req.responseJSON['content']); } new Effect.Highlight("oe_" + req.responseJSON['row_id'], { startcolor: '#FAD4D4', endcolor: '#F78082' }); operation_exercice.display_total(rowid) - $(dgbox).remove(); + id$(dgbox).remove(); return; } - $(dgbox).update(req.responseText); + id$(dgbox).update(req.responseText); } } @@ -1925,7 +1925,7 @@ var operation_exercice = { var queryString = { op: 'operation_exercice+display_total', row_id: row_id, - gDossier: $('gDossier').value + gDossier: id$('gDossier').value }; var action = new Ajax.Request( "ajax_misc.php", @@ -1940,7 +1940,7 @@ var operation_exercice = { return; } - $(dgbox).update(req.responseText); + id$(dgbox).update(req.responseText); } } @@ -1957,7 +1957,7 @@ var operation_exercice = { var queryString = { op: 'operation_exercice+delete_row', row_id: row_id, - gDossier: $('gDossier').value + gDossier: id$('gDossier').value }; var action = new Ajax.Request( "ajax_misc.php", @@ -1974,8 +1974,8 @@ var operation_exercice = { if (req.responseJSON["row_id"] != "") { operation_exercice.display_total(req.responseJSON["row_id"]) } - $('oe_' + queryString['row_id']).remove(); - $('operation_exercice_bx').remove(); + id$('oe_' + queryString['row_id']).remove(); + id$('operation_exercice_bx').remove(); } } ); @@ -1994,7 +1994,7 @@ var operation_exercice = { var dgbox = "oe_transfer_div"; waiting_box(); - var queryString = $("operation_exercice_transfer_frm").serialize(true); + var queryString = id$("operation_exercice_transfer_frm").serialize(true); var action = new Ajax.Request( "ajax_misc.php", { @@ -2009,7 +2009,7 @@ var operation_exercice = { } var answer=req.responseJSON; - $('operation_exercice_transfer_info').update(answer.content); + id$('operation_exercice_transfer_info').update(answer.content); } diff --git a/html/js/accounting_item.js b/html/js/accounting_item.js index 20db90d03..9c261a847 100644 --- a/html/js/accounting_item.js +++ b/html/js/accounting_item.js @@ -49,7 +49,7 @@ function search_accounting(obj) removeDiv('search_account'); add_div({id:'search_account',cssclass:'inner_box',html:loading(),style:div_style,drag:false}); - var dossier=$('gDossier').value; + var dossier=id$('gDossier').value; var queryString="gDossier="+dossier; @@ -61,8 +61,8 @@ function search_accounting(obj) { queryString+="&j="+obj.jrn; }else { - if ($("p_jrn")) { - queryString+="&j="+$("p_jrn").value; + if (document.getElementById("p_jrn")) { + queryString+="&j="+id$("p_jrn").value; } } if ( obj.account) @@ -97,10 +97,10 @@ function search_accounting(obj) } else { - if ($(obj).account) + if (id$(obj).account) { - var e=$(obj).account; - var str_account=$(e).value; + var e=id$(obj).account; + var str_account=id$(e).value; queryString+="&q="+str_account; } } @@ -130,7 +130,7 @@ function search_accounting(obj) */ function search_get_poste(obj) { - var dossier=$('gDossier').value; + var dossier=id$('gDossier').value; var queryString="gDossier="+dossier; queryString+="&op=account"; @@ -169,7 +169,7 @@ function search_get_poste(obj) queryString+="&bracket"; } - $('asearch').innerHTML=loading(); + id$('asearch').innerHTML=loading(); var action=new Ajax.Request ( 'ajax_misc.php', { method:'get', @@ -201,7 +201,7 @@ function result_poste_search(req) var nodeXml=html[0]; var code_html=getNodeText(nodeXml); code_html=unescape_xml(code_html); - $('search_account').innerHTML=code_html; + id$('search_account').innerHTML=code_html; } catch (e) { diff --git a/html/js/admin.js b/html/js/admin.js index 6c4643e32..91c2c8232 100644 --- a/html/js/admin.js +++ b/html/js/admin.js @@ -33,8 +33,8 @@ function folder_display(p_user) * */ var p_filter = ""; - if ($('database_filter_input')) { - p_filter = $('database_filter_input').value; + if (document.getElementById('database_filter_input')) { + p_filter = id$('database_filter_input').value; } /* * Ajax request to display the folder @@ -46,11 +46,11 @@ function folder_display(p_user) // table id = database_list var folder = {}; var create = false; - if (!$('folder_list_div')) { + if (!document.getElementById('folder_list_div')) { folder = create_div({'id': 'folder_list_div', 'cssclass': "inner_box", 'style': 'width:90%,right:5%;top:100px'}); create = true; } - folder = $('folder_list_div'); + folder = id$('folder_list_div'); // Analyze XML answer var answer = p_xml.responseXML; var a = answer.getElementsByTagName('status'); @@ -66,7 +66,7 @@ function folder_display(p_user) folder.innerHTML.evalScripts(); // show it folder.show(); - $('database_filter_input').focus(); + id$('database_filter_input').focus(); } }); } @@ -123,7 +123,7 @@ function folder_add(p_user, p_dossier) } var content = getNodeText(html[0]); - var nb = $('database_list').rows.length + 1; + var nb = id$('database_list').rows.length + 1; var row = new Element('tr', {'id': 'row' + p_dossier}); if (nb % 2 == 0) { row.addClassName('even'); @@ -131,8 +131,8 @@ function folder_add(p_user, p_dossier) row.addClassName('odd'); } row.innerHTML = unescape_xml(content); - $('database_list').appendChild(row); - $('row_db_'+p_dossier).hide(); + id$('database_list').appendChild(row); + id$('row_db_'+p_dossier).hide(); remove_waiting_box(); } }); @@ -157,16 +157,16 @@ function display_admin_answer(p_dossier,p_action) var folder; var create = false; - if (!$(div_display)) { + if (!document.getElementById(div_display)) { folder = create_div({'id': div_display, 'cssclass': "inner_box", style: 'width:90%;right:5%;top:100px'}); create = true; } - folder=$(div_display); + folder=id$(div_display); var content = getNodeText(html[0]); folder.innerHTML=unescape_xml(content); var pos=calcy(250); - $(div_display).setStyle({top:pos+'px'}); + id$(div_display).setStyle({top:pos+'px'}); folder.show(); remove_waiting_box(); diff --git a/html/js/ajax_fiche.js b/html/js/ajax_fiche.js index 03415c18a..d4051de21 100644 --- a/html/js/ajax_fiche.js +++ b/html/js/ajax_fiche.js @@ -27,29 +27,21 @@ /** * clean the row (the label, price and vat) - * @param p_ctl the calling ctrl + * @param {string} p_ctl the calling ctrl */ function clean_Fid(p_ctl) { - nSell=p_ctl+"_price"; - nTvaAmount=p_ctl+"_tva_amount"; - nBuy=p_ctl+"_price"; - nTva_id=p_ctl+"_tva_id"; - if ( $(nSell) ) - { - $(nSell).value=""; + + document.getElementById(p_ctl).value=''; + var aField=['_price','_tva_amount','_tva_id']; + for ( field of aField) { + let obj=document.getElementById(p_ctl+field); + if ( obj ) {obj.value='0'} } - if ( $(nBuy) ) - { - $(nBuy).value=""; - } - if ( $(nTva_id) ) - { - $(nTva_id).value="-1"; - } - if ( $(nTvaAmount)) - { - $(nTvaAmount).value=0; + var aField=['_label']; + for ( field of aField) { + let obj=document.getElementById(p_ctl+field); + if ( obj ) {obj.value=''} } } function errorFid(request,json) @@ -58,7 +50,7 @@ function errorFid(request,json) } /** * this function fills the data from fid.php, - * @param {object} p_ctl : field of the input, + * @param {object or string} p_ctl : field of the input, : object or string * possible object member * - label field to update with the card's name * - price field to update with the card's price @@ -68,56 +60,56 @@ function errorFid(request,json) */ function ajaxFid(p_ctl) { + debugger try { - var gDossier=$('gDossier').value; - var jrn=$(p_ctl).jrn; - $(p_ctl).value=$(p_ctl).value.toUpperCase(); - if ( jrn == undefined ) + var gDossier=id$('gDossier').value; + // if p_ctl is a string that find the object + var dome =id$(p_ctl); + + var jrn = (dome.jrn) ? dome.jrn.value:-1; + dome.value=dome.value.toUpperCase(); + + if ( jrn == undefined && document.getElementById('p_jrn')!=undefined) { - if ($('p_jrn')!=undefined) - { - jrn=$('p_jrn').value; - } + jrn=id$('p_jrn').value; } - if ( jrn == undefined ) + + + if ( trim(dome.value)=="" ) { - jrn=-1; - } - if ( trim($(p_ctl).value)=="" ) - { - nLabel=$(p_ctl).label; - if ($(nLabel) ) + nLabel=id$(dome).label; + if (document.getElementById(nLabel) ) { - $(nLabel).value=""; - $(nLabel).innerHTML=" "; - clean_Fid(p_ctl); + id$(nLabel).value=""; + id$(nLabel).innerHTML=" "; + clean_Fid(dome.id); return; } } - var queryString="FID="+trim($(p_ctl).value); - if ( $(p_ctl).label) + var queryString="FID="+trim(dome.value); + if ( dome.label) { - queryString+='&l='+$(p_ctl).label; + queryString+='&l='+dome.label; } - if ( $(p_ctl).tvaid) + if ( dome.tvaid) { - queryString+='&t='+$(p_ctl).tvaid; + queryString+='&t='+dome.tvaid; } - if ( $(p_ctl).price) + if ( dome.price) { - queryString+='&p='+$(p_ctl).price; + queryString+='&p='+dome.price; } - if ( $(p_ctl).purchase) + if ( dome.purchase) { - queryString+='&b='+$(p_ctl).purchase; + queryString+='&b='+dome.purchase; } - if ( $(p_ctl).typecard) + if ( dome.typecard) { - queryString+='&d='+$(p_ctl).typecard; + queryString+='&d='+dome.typecard; } queryString=queryString+"&j="+jrn+'&gDossier='+gDossier; - queryString=queryString+'&ctl='+p_ctl.id; + queryString=queryString+'&ctl='+dome.id; queryString=encodeURI(queryString); var action=new Ajax.Request ( @@ -196,9 +188,9 @@ function ajax_error_saldo(request,json) */ function ajax_saldo(p_ctl) { - var gDossier=$('gDossier').value; - var ctl_value=trim($(p_ctl).value); - var jrn=$('p_jrn').value; + var gDossier=id$('gDossier').value; + var ctl_value=trim(id$(p_ctl).value); + var jrn=id$('p_jrn').value; queryString="FID="+ctl_value+"&op=saldo"; queryString=queryString+'&gDossier='+gDossier+'&j='+jrn; queryString=queryString+'&ctl='+ctl_value; @@ -221,7 +213,7 @@ function ajax_saldo(p_ctl) function ajax_success_saldo(request,json) { var answer=request.responseText.evalJSON(true); - $('first_sold').value=answer.saldo; + id$('first_sold').value=answer.saldo; } @@ -231,8 +223,8 @@ function ajax_success_saldo(request,json) function ajax_get_success(request,json) { var answer=request.responseText.evalJSON(false); - $(answer.ctl).show(); - $(answer.ctl).innerHTML=answer.html; + id$(answer.ctl).show(); + id$(answer.ctl).innerHTML=answer.html; } /*!\brief callback function for ajax_get when fails */ @@ -252,7 +244,7 @@ var category_card={}; * @param string p_object_name , name of the prefix for id */ category_card.add_attribut=function (p_dossier,p_fiche_def_ref,p_object_name) { - var select=$("sel"+p_object_name); + var select=id$("sel"+p_object_name); var selected_attr=select.value; new Ajax.Request("ajax_misc.php",{ method:"post", @@ -268,7 +260,7 @@ category_card.add_attribut=function (p_dossier,p_fiche_def_ref,p_object_name) { if ( answer.status == 'OK') { var newli = document.createElement("li") - $(p_object_name + "_list").append(newli); + id$(p_object_name + "_list").append(newli); newli.replace(answer.content); document.getElementById('attribut_order').value = Sortable.serialize(p_object_name + "_list"); select.remove(select.selectedIndex); @@ -304,11 +296,11 @@ category_card.remove_attribut=function (p_dossier,p_fiche_def_ref,p_object_name, onSuccess:function(req) { var answer=req.responseText.evalJSON(); if ( answer.status == 'OK') { - $(p_object_name+"_elt"+p_attribute_id).remove(); + id$(p_object_name+"_elt"+p_attribute_id).remove(); var option=document.createElement("option"); option.text=answer['content']; option.value=p_attribute_id; - $('sel'+p_object_name).add(option); + id$('sel'+p_object_name).add(option); } else { smoke.alert(answer.message); } @@ -328,11 +320,11 @@ category_card.check_vatnumber=function(p_domid) { // For form , most of the parameters are in the FORM // method is then POST - //var queryString=$(p_form_id).serialize(true); + //var queryString=id$(p_form_id).serialize(true); var queryString = { op: 'check_vatnumber', - vatnr:$(p_domid).value, + vatnr:id$(p_domid).value, boxid: dgbox, p_domid:p_domid }; @@ -352,14 +344,14 @@ category_card.check_vatnumber=function(p_domid) { if ( answer.status == 'OK') { - $(dgbox).update(answer.html); - $(p_domid).value=answer.vat; - $(p_domid).removeClassName("notice") - $(p_domid).addClassName("valid") + id$(dgbox).update(answer.html); + id$(p_domid).value=answer.vat; + id$(p_domid).removeClassName("notice") + id$(p_domid).addClassName("valid") } else { - $(p_domid).addClassName("notice"); - $(p_domid).removeClassName("valid"); - $(dgbox).update(answer.html); + id$(p_domid).addClassName("notice"); + id$(p_domid).removeClassName("valid"); + id$(dgbox).update(answer.html); } } diff --git a/html/js/anc_script.js b/html/js/anc_script.js index f238ad35f..1dfbaca36 100644 --- a/html/js/anc_script.js +++ b/html/js/anc_script.js @@ -31,7 +31,7 @@ */ function add_row(p_table, p_seq) { - var mytable = g(p_table).tBodies[0]; + var mytable = id$(p_table).tBodies[0]; if (!mytable) { return; @@ -120,14 +120,14 @@ function anc_refresh_remain(p_table, p_seq) var remain = tot_line - tot_table; remain = Math.round(remain * 100) / 100; - $('remain' + p_table).innerHTML = remain; + id$('remain' + p_table).innerHTML = remain; if (remain == 0) { - $('remain' + p_table).style.color = "green" + id$('remain' + p_table).style.color = "green" } else { - $('remain' + p_table).style.color = "red" + id$('remain' + p_table).style.color = "red" } } catch (a) { @@ -152,7 +152,7 @@ function verify_ca(div) while (idx < 50) { var table = div + 't' + idx; - if (g(table)) + if (document.getElementById(table)) { var total_amount = 0; // table is found compute the different val[] @@ -182,12 +182,12 @@ function verify_ca(div) var diff = amount*100 - total_amount*100; if (Math.round(diff/100) != 0.0) { - g(table).style.backgroundColor = 'red'; + id$(table).style.backgroundColor = 'red'; amount_error++; } else { - g(table).style.backgroundColor = 'lightgreen'; + id$(table).style.backgroundColor = 'lightgreen'; } idx++; @@ -216,7 +216,7 @@ function verify_ca(div) */ function search_ca(p_dossier, p_target, p_source) { - var pa_id = g(p_source).value; + var pa_id = id$(p_source).value; waiting_box(); removeDiv('search_anc'); var qs = "op=openancsearch&gDossier=" + p_dossier + "&ctl=searchanc"; @@ -237,7 +237,7 @@ function search_ca(p_dossier, p_target, p_source) cssclass: "inner_box", style: pos }); - $('searchanc').innerHTML = req.responseText; + id$('searchanc').innerHTML = req.responseText; } catch (e) { alert_box(e.message); @@ -251,7 +251,7 @@ function search_anc_form(obj) { var qs = "op=resultancsearch&ctl=searchanc&"; var name = obj.id; - qs += $(name).serialize(false); + qs += id$(name).serialize(false); waiting_box(); var action = new Ajax.Request('ajax_misc.php', { @@ -261,7 +261,7 @@ function search_anc_form(obj) onSuccess: function(req) { try { remove_waiting_box(); - $('searchanc').innerHTML = req.responseText; + id$('searchanc').innerHTML = req.responseText; req.responseText.evalScripts(); } catch (e) { @@ -281,16 +281,16 @@ function caod_checkTotal() }// Ajouter getElementById par document.all[str] var total_deb = 0.0; var total_cred = 0.0; - var nb_item = g('nbrow').value; + var nb_item = id$('nbrow').value; for (var i = 0; i < nb_item; i++) { - var doc_amount = g("pamount" + i); + var doc_amount = id$("pamount" + i); if (!doc_amount) { return; } - var side = g("pdeb" + i); + var side = id$("pdeb" + i); if (!side) { return; @@ -316,22 +316,22 @@ function caod_checkTotal() 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; + id$('totalDeb').innerHTML = r_total_deb; + id$('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"; + id$("totalDiff").style.color = "red"; + id$("totalDiff").style.fontWeight = "bold"; + id$("totalDiff").innerHTML = "Différence"; var diff = total_deb - total_cred; diff = Math.round(diff * 100) / 100; - g("totalDiff").innerHTML = diff; + id$("totalDiff").innerHTML = diff; } else { - g("totalDiff").innerHTML = "0.0"; + id$("totalDiff").innerHTML = "0.0"; } } @@ -352,7 +352,7 @@ function anc_remove_operation(p_dossier, p_oa_group) var queryString = encodeJSON(obj); var e = new Ajax.Request("ajax_misc.php", {method: 'get', parameters: queryString,onSuccess:function req() { - $("tr"+p_oa_group).remove(); + id$("tr"+p_oa_group).remove(); } }); @@ -370,12 +370,12 @@ function anc_remove_operation(p_dossier, p_oa_group) function anc_add_row(tableid) { var style = 'class="input_text"'; - var mytable = g(tableid).tBodies[0]; + var mytable = id$(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 nb = id$("nbrow"); var oNewRow = mytable.insertRow(nNumberRow); for (var e = 0; e < nNumberCell; e++) { @@ -388,7 +388,7 @@ function anc_add_row(tableid) newCell.innerHTML = new_tt; new_tt.evalScripts(); } - $("pamount" + nb.value).value = "0"; + id$("pamount" + nb.value).value = "0"; nb.value++; } /** @@ -438,7 +438,7 @@ function anc_key_compute(p_dossier, p_table, p_amount, p_key_id) var code_html = getNodeText(html[0]); // Firefox ne prend que les 4096 car. code_html = unescape_xml(code_html); - $(name_ctl).innerHTML = code_html; + id$(name_ctl).innerHTML = code_html; code_html.evalScripts(); removeDiv('div_anc_key_choice'); } catch (e) @@ -491,7 +491,7 @@ function anc_key_choice(p_dossier, p_table, p_amount,p_ledger) 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; + id$(name_ctl).innerHTML = code_html; } catch (e) { error_message(e.message); @@ -540,7 +540,7 @@ function anc_key_clean(p_dossier, p_table, p_amount,p_ledger,p_jrnx_id,p_sequenc var code_html = getNodeText(html[0]); // Firefox ne prend que les 4096 car. code_html = unescape_xml(code_html); - $(p_table+"t"+p_sequence).innerHTML=code_html; + id$(p_table+"t"+p_sequence).innerHTML=code_html; } catch (e) { error_message(e.message); @@ -561,7 +561,7 @@ function anc_key_clean(p_dossier, p_table, p_amount,p_ledger,p_jrnx_id,p_sequenc */ function add_row_key(p_table) { - var mytable = g(p_table).tBodies[0]; + var mytable = id$(p_table).tBodies[0]; if (!mytable) { return; @@ -595,7 +595,7 @@ function add_row_key(p_table) cell.innerHTML = txt; } } - $('total_key').innerHTML="?"; + id$('total_key').innerHTML="?"; } function anc_key_compute_table() { @@ -615,7 +615,7 @@ function anc_key_compute_table() } tot=tot+Math.round(value*100)/100; } - $('total_key').innerHTML=Math.round(tot*100)/100; + id$('total_key').innerHTML=Math.round(tot*100)/100; } @@ -627,7 +627,7 @@ function anc_detail_op(p_oa_group,gDossier) { parameters:{"gDossier":gDossier,"op":"anc_detail_op","oa_group":p_oa_group}, onSuccess:function (req) { add_div({"id":"anc_detail_op_div","cssclass":"inner_box","style":"position:fixed;top:5%"}); - $('anc_detail_op_div').update(req.responseText); + id$('anc_detail_op_div').update(req.responseText); remove_waiting_box(); } }); diff --git a/html/js/card.js b/html/js/card.js index c3e17db9a..e8168fa19 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -34,7 +34,7 @@ function boxsearch_card(p_dossier) { waiting_box(); removeDiv('boxsearch_card_div'); - var queryString="gDossier="+p_dossier+"&op=cardsearch"+"&card="+encodeURI($("card_search").value); + var queryString="gDossier="+p_dossier+"&op=cardsearch"+"&card="+encodeURI(id$("card_search").value); var action = new Ajax.Request( "ajax_misc.php" , { @@ -49,8 +49,8 @@ function boxsearch_card(p_dossier) var y=calcy(15); var div_style="position:absolute;"+";top:"+y+"px"; add_div({id:'boxsearch_card_div',cssclass:'inner_box',html:loading(),style:div_style,drag:true}); - $('boxsearch_card_div').innerHTML=req.responseText; - sorttable.makeSortable($('tb_fiche')); + id$('boxsearch_card_div').innerHTML=req.responseText; + sorttable.makeSortable(id$('tb_fiche')); } } ); @@ -76,9 +76,9 @@ function search_card(obj) { try { - var gDossier=$('gDossier').value; + var gDossier=id$('gDossier').value; var inp=obj.inp; - var string_to_search=$(inp).value; + var string_to_search=id$(inp).value; var label=obj.label; var typecard=obj.typecard; var price=obj.price; @@ -93,8 +93,8 @@ function search_card(obj) } if ( jrn==undefined) { - if ( g('p_jrn')) { - jrn=$('p_jrn').value; + if ( document.getElementById('p_jrn')) { + jrn=id$('p_jrn').value; } else { jrn=-1; @@ -114,7 +114,7 @@ function search_card(obj) 'amount_from_type':amount_from_type, 'inactive_card':inactive_card }); - if ( $('search_card') ) { + if ( document.getElementById('search_card') ) { removeDiv('search_card'); } @@ -164,7 +164,7 @@ function action_concerned_save_card(obj) var nodeXml = html[0]; var code_html = getNodeText(nodeXml); code_html = unescape_xml(code_html); - $(namectl).update(code_html); + id$(namectl).update(code_html); removeDiv('search_card'); /* if dialog box exist with list other card, then refresh it */ if ( document.getElementById("action_concerned_list_dv") ) { @@ -222,7 +222,7 @@ function action_concerned_list(p_obj) { code_html = unescape_xml(code_html); - $('action_concerned_list_dv').innerHTML = code_html; + id$('action_concerned_list_dv').innerHTML = code_html; } catch (e) { alert_box(e.message); } @@ -336,9 +336,9 @@ function action_concerned_search_card(obj) sx = document.body.scrollTop + 60; } var div_style = "top:" + sx + "px;height:52rem"; - if ( ! $('search_card')) { add_div({id: 'search_card', cssclass: 'inner_box', html: "", style: div_style, drag: true}); } - $('search_card').innerHTML = code_html; - $('query').focus(); + if ( ! document.getElementById('search_card')) { add_div({id: 'search_card', cssclass: 'inner_box', html: "", style: div_style, drag: true}); } + id$('search_card').innerHTML = code_html; + id$('query').focus(); activate_checkbox_range('select_card_ck'); }catch (e) { alert_box(e.message); @@ -360,10 +360,11 @@ function action_concerned_search_card(obj) *@param obj form *@note the same as search_card, except it answer to a FORM and not * to a click event + * @see ajax_card.php */ function search_get_card(obj) { - var dossier=$('gDossier').value; + var dossier=id$('gDossier').value; var queryString="gDossier="+dossier; queryString+="&op2=fs&op=card"; @@ -417,7 +418,7 @@ function search_get_card(obj) } queryString=encodeURI(queryString); - $('asearch').innerHTML=loading(); + id$('asearch').innerHTML=loading(); var action=new Ajax.Request ( 'ajax_misc.php', { @@ -430,6 +431,7 @@ function search_get_card(obj) } /** * show the answer of ajax request + * @see search_get_card *@param answer in XML */ function result_card_search(req) @@ -466,9 +468,9 @@ function result_card_search(req) var div_style="top:"+sx+"px;min-height:80%;height:auto"; add_div({id:'search_card',cssclass:'inner_box',html:"",style:div_style,drag:false,effect:'blinddown'}); - $('search_card').innerHTML=code_html; + id$('search_card').innerHTML=code_html; - if ($('query')) { $('query').focus();} + if (document.getElementById('query')) { id$('query').focus();} } catch (e) { @@ -500,12 +502,12 @@ function result_card_search(req) */ function setCtrl(p_ctrl,p_quickcode,p_ctrlname,p_label) { - var ctrl=g(p_ctrl); + var ctrl=id$(p_ctrl); if ( ctrl ) { ctrl.value=p_quickcode; } - var ctrl_name=g(p_ctrlname); + var ctrl_name=id$(p_ctrlname); if ( ctrl_name ) { ctrl_name.value=p_label; @@ -514,29 +516,7 @@ function setCtrl(p_ctrl,p_quickcode,p_ctrlname,p_label) -/** - * clean the row (the label, price and vat) - * @param p_ctl the calling ctrl - */ -function clean_Fid(p_ctl) -{ - nSell=p_ctl+"_price"; - nBuy=p_ctl+"_price"; - nTva_id=p_ctl+"_tva_id"; - if ( $(nSell) ) - { - $(nSell).value=""; - } - if ( $(nBuy) ) - { - $(nBuy).value=""; - } - if ( $(nTva_id) ) - { - $(nTva_id).value="-1"; - } -} function errorFid(request,json) { alert_box(content[53]); @@ -583,7 +563,7 @@ function fill_fin_data_onchange(ctl) function fill_fin_data(text,li) { ajaxFid(text); - ajax_saldo($(text.id)); + ajax_saldo(id$(text.id)); } /** * show the ipopup window and display the details of a card, @@ -611,17 +591,17 @@ function fill_ipopcard(obj) var popup={'id': content,'cssclass':'inner_box2','style':str_style,'html':"",'drag':false}; add_div(popup); - var dossier=$('gDossier').value; + var dossier=id$('gDossier').value; var qcode=''; - if ( $(obj).qcode != undefined ) + if ( obj.qcode != undefined ) { qcode=obj.qcode; } else { - qcode=$(obj).value; + qcode=id$(obj).value; } - // ctl=$(obj).id; + // ctl=id$(obj).id; var queryString='gDossier='+dossier; queryString+='&qcode='+qcode; @@ -671,7 +651,7 @@ function successFill_ipopcard(req,json) var code_html=getNodeText(html[0]); code_html=unescape_xml(code_html); - $(name_ctl).innerHTML=code_html; + id$(name_ctl).innerHTML=code_html; } catch (e) { @@ -698,16 +678,16 @@ function successFill_ipopcard(req,json) */ function select_card_type(obj) { - var dossier=$('gDossier').value; + var dossier=id$('gDossier').value; var elementId=""; // give a filter, -1 if not - var filter=$(obj).filter; + var filter=id$(obj).filter; if ( filter==undefined) { filter=-1; } var content="select_card_div"; - if ( $(content)){removeDiv(content);} + if ( document.getElementById(content)){removeDiv(content);} var sx=0; sx=calcy(160); @@ -721,25 +701,25 @@ function select_card_type(obj) queryString+='&ctl='+content; queryString+='&op2=st'; // st for selecting type queryString+='&op=card'; // st for selecting type - if ( $(obj).win_refresh!=undefined) + if ( document.getElementById(obj).win_refresh!=undefined) { queryString+='&ref'; } /* if an element id must be updated after creating a new card */ - if ( $(obj).elementId) { - var elementId=$(obj).elementId; + if ( document.getElementById(obj).elementId) { + var elementId=id$(obj).elementId; queryString+="&eltid="+elementId; } queryString+='&fil='+filter; // filter on the ledger, -1 if not - var oledger=$(obj).jrn; + var oledger=id$(obj).jrn; if (oledger==undefined) { ledger=-1; } else { - ledger=$(obj).jrn; + ledger=id$(obj).jrn; } queryString+='&ledger='+ledger; @@ -773,7 +753,7 @@ function select_card_type(obj) return; } fill_box(req); - $('lk_cat_card_table').focus(); + id$('lk_cat_card_table').focus(); } } ); @@ -810,7 +790,7 @@ function dis_blank_card(obj) add_div(popup); if ( obj.gDossier.value != undefined ) { - var dossier=$('gDossier').value; + var dossier=id$('gDossier').value; } else { var dossier=obj.gDossier; } @@ -848,11 +828,11 @@ function form_blank_card(obj) var str_style="top:"+nTop+"px;left:"+nLeft+"px;width:60em;height:auto"; var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':loading(),'drag':true}; - if ( $(content)) {removeDiv(content);} + if ( document.getElementById(content)) {removeDiv(content);} add_div(popup); - var dossier=$('gDossier').value; + var dossier=id$('gDossier').value; var queryString='gDossier='+dossier; queryString+='&ctl='+content; @@ -878,8 +858,8 @@ function form_blank_card(obj) */ function save_card(obj) { - var content=$(obj).ipopup; - var accounting= $(obj)['av_text5']; + var content=id$(obj).ipopup; + var accounting= id$(obj)['av_text5']; if ( accounting && accounting.value.length > 40 ) { smoke.alert('Poste comptable trop grand'); return false; @@ -887,9 +867,9 @@ function save_card(obj) // Data must be taken here - var data=$('save_card').serialize(false); + var data=id$('save_card').serialize(false); waiting_box(); - var dossier=$('gDossier').value; + var dossier=id$('gDossier').value; var queryString='gDossier='+dossier; queryString+='&ctl='+content; queryString+=data; @@ -922,7 +902,7 @@ function save_card(obj) // if status == OK and after_save == 1 // then add a row to the table if ( status_value == 'OK' && after_save == 1) { - var table_card=$('fiche_tb_id'); + var table_card=id$('fiche_tb_id'); f_id=getNodeText(req.responseXML.getElementsByTagName("f_id")[0]); var row=new Element('tr'); row.id="row_card"+f_id; @@ -943,9 +923,9 @@ function save_card(obj) var eltid=getNodeText(elt[0]); if ( eltid !="") { var eltvalue=req.responseXML.getElementsByTagName("elt_value"); - $(eltid).value=getNodeText(eltvalue[0]); + id$(eltid).value=getNodeText(eltvalue[0]); fill_data_onchange(eltid); - $(eltid).focus(); + id$(eltid).focus(); } } if (status_value == "OK") { @@ -984,12 +964,12 @@ function add_category(obj) // show ipopup var div={id:obj.ipopup, cssclass:"inner_box",drag:1,style:div_style}; - if ( $(div) ) { + if ( document.getElementById(div) ) { removeDiv(div); } add_div(div); waiting_box(); - var dossier=$('gDossier').value; + var dossier=id$('gDossier').value; var queryString='gDossier='+dossier; queryString+='&op2=ac'; queryString+='&op=card'; @@ -1014,15 +994,15 @@ function add_category(obj) */ function save_card_category(obj) { - if ( ! $(obj).ipopup) + if ( ! document.getElementById(obj).ipopup) { alert_box('Erreur pas d\' attribut ipopup '+obj.id); return; }; try { // Data must be taken here - data=$('newcat').serialize(false); - var dossier=$('gDossier').value; + data=id$('newcat').serialize(false); + var dossier=id$('gDossier').value; var queryString='ctl='+obj.ipopup+'&'; queryString+=data; queryString+='&op2=scc'; // sc for save card @@ -1124,7 +1104,7 @@ function action_save_concerned(p_form_id) { var code_html = getNodeText(nodeXml); code_html = unescape_xml(code_html); removeDiv('search_card'); - $('concerned_card_td').innerHTML = code_html; + id$('concerned_card_td').innerHTML = code_html; } catch (e) { } @@ -1156,10 +1136,10 @@ function action_remove_concerned(p_dossier,p_fiche_id,p_action_id) var nodeXml=html[0]; var code_html = getNodeText(nodeXml); code_html = unescape_xml(code_html); - $('concerned_card_td').innerHTML = code_html; + id$('concerned_card_td').innerHTML = code_html; removeDiv('search_card'); - $(namectl).remove(); + id$(namectl).remove(); } catch (e) { if ( console) { console.log('Erreur ') + e.message;} @@ -1234,7 +1214,7 @@ function modify_card(p_fiche_id) console.error("card_gdossier error"); throw ("card_gdossier not set"); } - var dossier = $('card_gdossier').value; + var dossier = id$('card_gdossier').value; var action = new Ajax.Request('ajax_misc.php', @@ -1262,8 +1242,8 @@ function delete_card_id(p_fiche_id) console.error("card_gdossier error"); throw ("card_gdossier not set"); } - $(row).addClassName("background-selected"); - var dossier = $('card_gdossier').value; + id$(row).addClassName("background-selected"); + var dossier = id$('card_gdossier').value; smoke.confirm(content[47], function (e) { if (e) { waiting_box(); @@ -1272,7 +1252,7 @@ function delete_card_id(p_fiche_id) parameters: {'gDossier':dossier,"op":'card',"op2":"rm_card","f_id":p_fiche_id,'ctl':row} , onSuccess: function (req) { remove_waiting_box(); - var table_card=$('fiche_tb_id'); + var table_card=id$('fiche_tb_id'); var answer = req.responseXML; var a = answer.getElementsByTagName('ctl'); if (a.length == 0) @@ -1288,7 +1268,7 @@ function delete_card_id(p_fiche_id) if ((code_html) == "OK") { Effect.Fade(row, {duration: 0.1}); - table_card.tBodies[0].removeChild($(row)); + table_card.tBodies[0].removeChild(id$(row)); alternate_row_color("fiche_tb_id"); } else { smoke.alert(code_html); @@ -1298,7 +1278,7 @@ function delete_card_id(p_fiche_id) }); } else{ - $(row).removeClassName("background-selected"); + id$(row).removeClassName("background-selected"); } }); @@ -1338,11 +1318,11 @@ function card_update_row(obj) if ( document.getElementById(name_ctl)) { // update the row - $(name_ctl).innerHTML = code_html; + id$(name_ctl).innerHTML = code_html; new Effect.Highlight(name_ctl ,{startcolor: '#FAD4D4',endcolor: '#F78082' }); } - $(a[0].firstChild.nodeValue).remove(); + id$(a[0].firstChild.nodeValue).remove(); } catch (e) { @@ -1391,7 +1371,7 @@ function linked_card_option(p_action_person_id,p_dossier) { onSuccess:function(req) { remove_waiting_box(); add_div({ "id":"d_linked_card_option",cssclass:"inner_box",style:"position:fixed;top:30%;min-width:20rem;width:auto;",drag:0}); - $("d_linked_card_option").update(req.responseText); + id$("d_linked_card_option").update(req.responseText); } }); @@ -1414,7 +1394,7 @@ function save_linked_card_option(obj) onSuccess:function(req) { remove_waiting_box(); removeDiv("d_linked_card_option"); - $("other_"+obj.action_person_id.value).update(req.responseText); + id$("other_"+obj.action_person_id.value).update(req.responseText); new Effect.Highlight("other_"+obj.action_person_id.value,{startcolor: '#FAD4D4',endcolor: '#F78082' }); } }); @@ -1503,10 +1483,10 @@ CategoryCardDefinition.prototype.add_attribut = function (attribut_id) { // if successfull add id on existing_list and remove from available_list // remove from available_list - $('avail_attr_' + attribut_id).remove(); + id$('avail_attr_' + attribut_id).remove(); var parser = new DOMParser(); var element = parser.parseFromString(req.responseText, 'text/html'); - $(here.existing_list).appendChild(element.body.firstChild); + id$(here.existing_list).appendChild(element.body.firstChild); new Effect.Highlight('existing_attr_' + attribut_id, { startcolor: '#FAD4D4', endcolor: '#F78082' @@ -1551,10 +1531,10 @@ CategoryCardDefinition.prototype.remove_attribut = function (attribut_id) { // if successfull add id on existing_list and remove from available_list // remove from available_list - $('existing_attr_' + attribut_id).remove(); + id$('existing_attr_' + attribut_id).remove(); var parser = new DOMParser(); var element = parser.parseFromString(req.responseText, 'text/html'); - $(here.available_list).appendChild(element.body.firstChild); + id$(here.available_list).appendChild(element.body.firstChild); alternate_row_color_list(here.available_list); Sortable.create('attribut_card', {tag: 'li', hoverclass: inner_box}); diff --git a/html/js/infobulle.js b/html/js/infobulle.js index e2d054392..2ab0cfd96 100644 --- a/html/js/infobulle.js +++ b/html/js/infobulle.js @@ -81,9 +81,9 @@ function displaySelectBox(p_name) { newDiv.id="select_box_content"+p_name; document.body.appendChild(newDiv); newDiv.addClassName("select_box"); - $("select_box_content"+p_name).onmouseleave=function() { + id$("select_box_content"+p_name).onmouseleave=function() { try { - var newDiv=$("select_box_content"+p_name); + var newDiv=id$("select_box_content"+p_name); newDiv.setStyle({display:"none"}); } catch(e) { alert(e.message); @@ -92,7 +92,7 @@ function displaySelectBox(p_name) { } else { newDiv=document.getElementById("select_box_content"+p_name); } - newDiv.innerHTML=$("select_box"+p_name).innerHTML; + newDiv.innerHTML=id$("select_box"+p_name).innerHTML; var viewport = document.viewport.getDimensions(); var locPosY=posY; if ( posY+offsetY+ newDiv.getHeight() > window.innerHeight -3) { @@ -101,14 +101,15 @@ function displaySelectBox(p_name) { newDiv.style.top=locPosY+"px"; newDiv.style.left=document.getElementById(p_name+"_bt").offsetLeft+"px"; - newDiv.setStyle({display:"block",position:"absolute","z-index":999}); + card_layer++; + newDiv.setStyle({display:"block",position:"absolute","z-index":card_layer}); - if ( $("search_"+p_name+"_list") ) { + if ( id$("search_"+p_name+"_list") ) { var sTmp = newDiv.innerHTML; var regex=new RegExp(p_name+"_list","g"); sTmp = sTmp.replace(regex,p_name+"_t_list"); newDiv.innerHTML=sTmp; - $("search_"+p_name+"_t_list").focus(); + id$("search_"+p_name+"_t_list").focus(); } } catch(e) { alert(e.message); diff --git a/html/js/managetable.js b/html/js/managetable.js index 7b522288d..8026f1e21 100644 --- a/html/js/managetable.js +++ b/html/js/managetable.js @@ -384,7 +384,7 @@ var ManageTable = function (p_table_name) $(obj.id).setStyle(here.mt_style); remove_waiting_box(); $(obj.id).update(x['html']); - Effect.SlideDown(obj.id,{duration:0.3,scaleX:false,scaleY:true,scaleContent:false}); + $(obj.id).show(); } catch (e) { smoke.alert(content[48] + e.message); } diff --git a/html/js/modele_document.js b/html/js/modele_document.js index 6bbf8d12f..6872f2e6e 100644 --- a/html/js/modele_document.js +++ b/html/js/modele_document.js @@ -71,8 +71,8 @@ function modify_document_success_box(req,json) var code_html=getNodeText(html[0]); code_html=unescape_xml(code_html); - g(name_ctl).innerHTML=code_html; - g(name_ctl).style.height='auto'; + id$(name_ctl).innerHTML=code_html; + id$(name_ctl).style.height='auto'; } catch (e) { diff --git a/html/js/noalyss_debug.js b/html/js/noalyss_debug.js new file mode 100644 index 000000000..cf9e3bdbb --- /dev/null +++ b/html/js/noalyss_debug.js @@ -0,0 +1,22 @@ +/* + * This file is part of NOALYSS. + * + * NOALYSS 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. + * + * NOALYSS 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 NOALYSS; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/** + * @file this file is for enable debug , just check variable document.debug_noalyss + */ +document.debug_noalyss=true; \ No newline at end of file diff --git a/html/js/noalyss_script.js b/html/js/noalyss_script.js index e4d4e7070..080b9c483 100644 --- a/html/js/noalyss_script.js +++ b/html/js/noalyss_script.js @@ -28,14 +28,15 @@ var ask_reload = 0; // tag_choose Element which contains all the selected tags var tag_choose = ''; var aDraggableElement = new Array(); - +// Layer for z-index , see function get_next_layer , must be used in PHP and JS +var layer=0; // document.viewport depends of prototype.js var viewport = document.viewport.getDimensions(); // Gets the viewport as an object literal var width = viewport.width; // Usable window width var height = viewport.height; /** - * return undefined if nothing is found , otherwise return the DOM elemnt + * return undefined if nothing is found , otherwise return the DOM elemnt, try to find an DOM Element inside p_element * @param {type} p_name_dom * @param {type} name_child * @returns {undefined} @@ -73,7 +74,7 @@ function infodiv(req, json) { var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); - g(name_ctl + "info").innerHTML = code_html; + id$(name_ctl + "info").innerHTML = code_html; } catch (e) { alert_box("success_box" + e.message); } @@ -95,7 +96,7 @@ function deleteRow(tb, obj) { var td = obj.parentNode; var tr = td.parentNode; var lidx = tr.rowIndex; - g(tb).deleteRow(lidx); + id$(tb).deleteRow(lidx); } else { return; @@ -106,7 +107,7 @@ function deleteRow(tb, obj) { function deleteRowRec(tb, obj) { var tr = obj; var lidx = tr.rowIndex; - g(tb).deleteRow(lidx); + id$(tb).deleteRow(lidx); } /*!\brief remove trailing and heading space @@ -122,32 +123,47 @@ function trim(s) { * @param ID is a string * @return the found object of undefined if not found */ -function g(ID) { - if (document.getElementById) { - return this.document.getElementById(ID); +function id$(ID) { + if (ID instanceof Object ) return ID; + if (document.getElementById(ID)) { + return document.getElementById(ID); } else if (document.all) { return document.all[ID]; } else { + document.debug_noalyss&&console.error(`id$ ${ID}`) return undefined; } } +/** + * this function is deprecated and replaced by id$ + * @deprecated + * @param ID + * @returns {*} + */ +function g(ID) { + document.debug_noalyss&& console.warn(`g(${ID} is deprecated, use id$`); + return id$(ID); +} +function get_next_layer(){ + return layer++; +} /** * enable the type of periode */ function enable_type_periode() { - if ($("type_periode").options[$("type_periode").selectedIndex].value == 0) { - $('from_periode').enable(); - $('to_periode').enable(); - $('from_date').disable(); - $('to_date').disable(); - $('p_step').enable(); + if (document.getElementById("type_periode").options[id$("type_periode").selectedIndex].value == 0) { + id$('from_periode').enable(); + id$('to_periode').enable(); + id$('from_date').disable(); + id$('to_date').disable(); + id$('p_step').enable(); } else { - $('from_periode').disable(); - $('to_periode').disable(); - $('from_date').enable(); - $('to_date').enable(); - $('p_step').disable(); + id$('from_periode').disable(); + id$('to_periode').disable(); + id$('from_date').enable(); + id$('to_date').enable(); + id$('p_step').disable(); } } @@ -188,11 +204,11 @@ function encodeJSON(obj) { } function hide(p_param) { - g(p_param).style.display = 'none'; + id$(p_param).style.display = 'none'; } function show(p_param) { - g(p_param).style.display = 'block'; + id$(p_param).style.display = 'block'; } /** @@ -201,7 +217,7 @@ function show(p_param) { *@param selectIt : the value selected in case of Field is a object select, numeric */ function SetFocus(Field, SelectIt) { - var elem = g(Field); + var elem = id$(Field); if (elem) { elem.focus(); } @@ -226,21 +242,21 @@ function set_inparent(p_ctl, p_value, p_add) { @param p_add if we don't replace the current value but we add something */ function set_value(p_ctl, p_value, p_add) { - if (g(p_ctl)) { - var g_ctrl = g(p_ctl); + if (document.getElementById(p_ctl)) { + var g_ctrl = id$(p_ctl); if (p_add != undefined && p_add === 1) { if (g_ctrl.value) { p_value = g_ctrl.value + ',' + p_value; } } if (g_ctrl.tagName === 'INPUT') { - g(p_ctl).value = p_value; + id$(p_ctl).value = p_value; } if (g_ctrl.tagName === 'SPAN') { - g(p_ctl).innerHTML = p_value; + id$(p_ctl).innerHTML = p_value; } if (g_ctrl.tagName === 'SELECT') { - g(p_ctl).value = p_value; + id$(p_ctl).value = p_value; } } } @@ -302,7 +318,7 @@ function format_number(obj, p_prec) { value = Math.round(value * arrondi) / arrondi; - $(obj).value = value; + id$(obj).value = value; } /** @@ -340,37 +356,37 @@ function format_date(p_object) { * @param rotate : if true with rotate the object of p_button otherwise */ function toggleHideShow(p_obj, p_button, rotate) { - var div_obj = g(p_obj); + var div_obj = id$(p_obj); var stat = div_obj.style.display; - var str = (g(p_button)) ? g(p_button).value : ""; + var str = (id$(p_button)) ? id$(p_button).value : ""; if (stat === 'none') { // specific for the DIV id search_form if (div_obj.id == 'search_form') { show(p_obj); } else { - $(p_obj).show() + id$(p_obj).show() } str = str.replace(/Afficher/, content[62]); - g(p_button).value = str; + id$(p_button).value = str; } else { // specific for the DIV di search_form if (!div_obj.id == 'search_form') { hide(p_obj); } else { - $(p_obj).hide() + id$(p_obj).hide() } str = str.replace(/Cacher/, content[63]); - g(p_button).value = str; + id$(p_button).value = str; } if (!rotate) return; if (stat == "none") { - g(p_button).addClassName("icon-up-open-1") - g(p_button).removeClassName(" icon-down-open-2") + id$(p_button).addClassName("icon-up-open-1") + id$(p_button).removeClassName(" icon-down-open-2") } else { - g(p_button).removeClassName("icon-up-open-1") - g(p_button).addClassName(" icon-down-open-2") + id$(p_button).removeClassName("icon-up-open-1") + id$(p_button).addClassName(" icon-down-open-2") } @@ -459,7 +475,7 @@ function success_misc(req) { var nodeXml = html[0]; var code_html = getNodeText(nodeXml); code_html = unescape_xml(code_html); - $("user_cal").innerHTML = code_html; + id$("user_cal").innerHTML = code_html; } catch (e) { alert_box(e.message); } @@ -523,9 +539,9 @@ function cat_doc_remove(p_dt_id, p_dossier) { alert_box('erreur
' + message_text); return; } - $('row' + row_id).style.textDecoration = "line-through"; - $('X' + row_id).style.display = 'none'; - $('M' + row_id).style.display = 'none'; + id$('row' + row_id).style.textDecoration = "line-through"; + id$('X' + row_id).style.display = 'none'; + id$('M' + row_id).style.display = 'none'; } catch (e) { alert_box(e.message); } @@ -553,7 +569,7 @@ function cat_doc_change(p_dt_id, p_dossier) { onSuccess: function (req) { remove_waiting_box(); add_div({id: 'change_doc_div', style: str_style, cssclass: 'inner_box', drag: "1"}); - $('change_doc_div').innerHTML = req.responseText; + id$('change_doc_div').innerHTML = req.responseText; } } @@ -567,7 +583,7 @@ function cat_doc_change(p_dt_id, p_dossier) { */ function popup_select_tva(obj, p_function_callback) { try { - if ($('tva_select')) { + if (document.getElementById('tva_select')) { removeDiv('tva_select'); } @@ -612,8 +628,8 @@ function popup_select_tva(obj, p_function_callback) { 'drag': false }; add_div(popup); - $('lk_tva_select_table').focus(); - sorttable.makeSortable($('tva_select_table')); + id$('lk_tva_select_table').focus(); + sorttable.makeSortable(id$('tva_select_table')); if (p_function_callback) { p_function_callback.call(null); } @@ -694,10 +710,10 @@ function create_div(obj) { try { var top = document; var elt = null; - if (!$(obj.id)) { + if (!document.getElementById(obj.id)) { elt = top.createElement('div'); } else { - elt = $(obj.id); + elt = id$(obj.id); } if (obj.id) { elt.setAttribute('id', obj.id); @@ -763,11 +779,11 @@ function add_div(obj) { /** * remove a object created with add_div - * @param elt id of the elt + * @param str_elt string id of the elt */ -function removeDiv(elt) { - if (g(elt)) { - document.body.removeChild(g(elt)); +function removeDiv(str_elt) { + if (document.getElementById(str_elt)) { + document.body.removeChild(id$(str_elt)); } // if reloaded if asked the window will be reloaded when // the box is closed @@ -778,8 +794,8 @@ function removeDiv(elt) { } function waiting_node() { - $('info_div').innerHTML = 'Un instant'; - $('info_div').style.display = "block"; + id$('info_div').innerHTML = 'Un instant'; + id$('info_div').style.display = "block"; } /** @@ -793,7 +809,7 @@ function waiting_box() { }; var y = fixed_position(10, 250) obj.style = y + ";width:20%;margin-left:40%;"; - if ($('wait_box')) { + if (document.getElementById('wait_box')) { removeDiv('wait_box'); } waiting_node(); @@ -817,7 +833,7 @@ function waiting_box() { function show_box(obj) { add_div(obj); if (!obj.fixed) { - g(obj.id).style.top = calcy(40) + "px"; + id$(obj.id).style.top = calcy(40) + "px"; show(obj.id); } else { show(obj.id); @@ -852,11 +868,11 @@ function success_box(req, json) { var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); - g(name_ctl).innerHTML = code_html; - g(name_ctl).style.height = 'auto'; + id$(name_ctl).innerHTML = code_html; + id$(name_ctl).style.height = 'auto'; if (name_ctl == 'popup') - g(name_ctl).style.width = 'auto'; + id$(name_ctl).style.width = 'auto'; } catch (e) { alert_box("success_box" + e.message); } @@ -879,10 +895,10 @@ function show_ledger_choice(json_obj) { waiting_box(); var i = 0; var query = "gDossier=" + json_obj.dossier + '&type=' + json_obj.type + '&div=' + json_obj.div + '&op=ledger_show'; - query = query + '&nbjrn=' + $(json_obj.div + 'nb_jrn').value; + query = query + '&nbjrn=' + id$(json_obj.div + 'nb_jrn').value; query = query + '&all_type=' + json_obj.all_type; - for (i = 0; i < $(json_obj.div + 'nb_jrn').value; i++) { - query = query + "&r_jrn[]=" + $(json_obj.div + 'r_jrn[' + i + ']').value; + for (i = 0; i < id$(json_obj.div + 'nb_jrn').value; i++) { + query = query + "&r_jrn[]=" + id$(json_obj.div + 'r_jrn[' + i + ']').value; } query = encodeURI(query); var action = new Ajax.Request( @@ -926,7 +942,7 @@ function show_ledger_choice(json_obj) { code_html = unescape_xml(code_html); remove_waiting_box(); - g(obj.id).innerHTML = code_html; + id$(obj.id).innerHTML = code_html; } catch (e) { alert_box("show_ledger_callback" + e.message); @@ -951,10 +967,10 @@ function show_ledger_choice(json_obj) { */ function hide_ledger_choice(p_frm_search) { try { - var nb = $(p_frm_search).nb_jrn.value; + var nb = id$(p_frm_search).nb_jrn.value; var div = ""; - if ($(p_frm_search).div) { - div = $(p_frm_search).div.value; + if (document.getElementById(p_frm_search).div) { + div = id$(p_frm_search).div.value; } var i = 0; var str = ""; @@ -964,13 +980,13 @@ function hide_ledger_choice(p_frm_search) { for (i = 0; i < nb; i++) { n_name = div + "r_jrn[" + sel + "]"; name = div + "r_jrn" + i; - if ($(name).checked) { - str += ''; + if (document.getElementById(name).checked) { + str += ''; sel++; } } str += ''; - $('ledger_id' + div).innerHTML = str; + id$('ledger_id' + div).innerHTML = str; removeDiv(div + 'jrn_search'); return false; } catch (e) { @@ -984,14 +1000,14 @@ function hide_ledger_choice(p_frm_search) { * show the cat of ledger choice */ function show_cat_choice() { - g('div_cat').style.visibility = 'visible'; + id$('div_cat').style.visibility = 'visible'; } /** * hide the cat of ledger choice */ function hide_cat_choice() { - g('div_cat').style.visibility = 'hidden'; + id$('div_cat').style.visibility = 'hidden'; } /** @@ -999,12 +1015,12 @@ function hide_cat_choice() { */ function for_add_row(tableid) { style = 'class="input_text"'; - var mytable = g(tableid).tBodies[0]; + var mytable = id$(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 nb = id$("nbrow"); var oNewRow = mytable.insertRow(nNumberRow); for (var e = 0; e < nNumberCell; e++) { var newCell = oRow.insertCell(e); @@ -1019,10 +1035,10 @@ function for_add_row(tableid) { newCell.innerHTML = new_tt; new_tt.evalScripts(); } - $("an_cat_acc" + nb.value).value = ""; - $("an_qc" + nb.value).value = ""; - $("an_label" + nb.value).value = ""; - $("an_cat_amount" + nb.value).value = "0"; + id$("an_cat_acc" + nb.value).value = ""; + id$("an_qc" + nb.value).value = ""; + id$("an_label" + nb.value).value = ""; + id$("an_cat_amount" + nb.value).value = "0"; nb.value++; } @@ -1031,7 +1047,7 @@ function for_add_row(tableid) { * @param form_id id of the form */ function toggle_checkbox(form_id) { - var form = g(form_id); + var form = id$(form_id); for (var i = 0; i < form.length; i++) { var e = form.elements[i]; if (e.type === 'checkbox') { @@ -1049,7 +1065,7 @@ function toggle_checkbox(form_id) { * @param form_id id of the form */ function select_checkbox(form_id) { - var form = $(form_id); + var form = id$(form_id); for (var i = 0; i < form.length; i++) { var e = form.elements[i]; if (e.type === 'checkbox') { @@ -1066,7 +1082,7 @@ function select_checkbox(form_id) { * @param attribute value */ function select_checkbox_attribute(form_id, p_attribute_name, p_attribute_value) { - var form = $(form_id); + var form = id$(form_id); for (var i = 0; i < form.length; i++) { var e = form.elements[i]; if (e.type === 'checkbox' && e.getAttribute(p_attribute_name) == p_attribute_value) { @@ -1080,7 +1096,7 @@ function select_checkbox_attribute(form_id, p_attribute_name, p_attribute_value) * @param form_id id of the form */ function unselect_checkbox(form_id) { - var form = $(form_id); + var form = id$(form_id); for (var i = 0; i < form.length; i++) { var e = form.elements[i]; if (e.type === 'checkbox') { @@ -1093,7 +1109,7 @@ function unselect_checkbox(form_id) { * show the calculator */ function show_calc() { - if (g('calc1')) { + if (document.getElementById('calc1')) { this.document.getElementById('inp').value = ""; this.document.getElementById('inp').focus(); return; @@ -1126,7 +1142,7 @@ function display_periode(p_dossier, p_id) { 'style': 'width:30em', 'drag': true }; - if (!$('mod_periode')) { + if (!document.getElementById('mod_periode')) { add_div(popup); } var action = new Ajax.Request( @@ -1138,8 +1154,8 @@ function display_periode(p_dossier, p_id) { onSuccess: success_display_periode } ); - $('mod_periode').style.top = (posY - 70) + "px"; - $('mod_periode').style.left = (posX - 70) + "px"; + id$('mod_periode').style.top = (posY - 70) + "px"; + id$('mod_periode').style.left = (posX - 70) + "px"; } catch (e) { alert_box("display_periode " + e.message); } @@ -1160,7 +1176,7 @@ function success_display_periode(req) { var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); - $('mod_periode').innerHTML = code_html; + id$('mod_periode').innerHTML = code_html; } catch (e) { alert_box("success_display_periode".e.message); } @@ -1174,7 +1190,7 @@ function success_display_periode(req) { function save_periode(obj) { try { - var queryString = $(obj).serialize() + "&op=save_per"; + var queryString = id$(obj).serialize() + "&op=save_per"; var action = new Ajax.Request( "ajax_misc.php", @@ -1219,7 +1235,7 @@ function fill_box(req) { var name_ctl = a[0].firstChild.nodeValue; var code_html = getNodeText(html[0]); // Firefox ne prend que les 4096 car. code_html = unescape_xml(code_html); - $(name_ctl).innerHTML = code_html; + id$(name_ctl).innerHTML = code_html; } catch (e) { alert_box(e.message); if (console) { @@ -1269,7 +1285,7 @@ function mod_predf_op(dossier_id, od_id, p_ledger) { function save_predf_op(obj) { waiting_box(); - var querystring = $(obj).serialize() + '&op=save_predf'; + var querystring = id$(obj).serialize() + '&op=save_predf'; // Create a ajax request to get all the person var action = new Ajax.Request('ajax_misc.php', { @@ -1286,8 +1302,8 @@ function save_predf_op(obj) { /** *ctl_concern is the widget to update *amount_id is either a html obj. or an amount and the field tiers if given - * @param {type} dossier - * @param {type} ctl_concern + * @param {int} dossier + * @param {string} ctl_concern DOM id that receive the number * @param {float or string} amount_id Amount or DOM Id of the element containing the amount * @param {float} ledger * @param {type} p_id_targetDom Element (div) where to display the search result @@ -1297,12 +1313,12 @@ function save_predf_op(obj) { function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target, p_tiers) { if (amount_id === undefined) { amount_id = 0; - } else if ($(amount_id)) { - if ($(amount_id).value) { - amount_id = $(amount_id).value; + } else if (document.getElementById(amount_id)) { + if (id$(amount_id).value) { + amount_id = id$(amount_id).value; } else if - ($(amount_id).innerHTML) { - amount_id = $(amount_id).innerHTML; + (id$(amount_id).innerHTML) { + amount_id = id$(amount_id).innerHTML; } } var tiers = ""; @@ -1318,8 +1334,8 @@ function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target, var str_style = fixed_position(77, 99); str_style += ";width:92%;overflow:auto;"; waiting_box(); - var hide_operation = $(ctl_concern).getAttribute("hide_operation"); - var single_operation = $(ctl_concern).getAttribute("single_operation"); + var hide_operation = id$(ctl_concern).getAttribute("hide_operation"); + var single_operation = id$(ctl_concern).getAttribute("single_operation"); var param_send = { gDossier: dossier, @@ -1345,7 +1361,7 @@ function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target, remove_waiting_box(); var div = {id: target, cssclass: 'inner_box', style: str_style, drag: 0}; add_div(div); - $(target).innerHTML = req.responseText; + id$(target).innerHTML = req.responseText; req.responseText.evalScripts(); } } @@ -1353,15 +1369,16 @@ function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target, } /** - * search in a popin obj if the object form + * search in a popin obj if the object form, + * @param obj DOM of the FORM */ function search_operation(obj) { try { - var dossier = g('gDossier').value; + var dossier = id$('gDossier').value; waiting_box(); var target = "search" + layer; - if ($(obj)["target"]) { - target = $(obj)["target"].value; + if (obj["target"]) { + target = obj["target"].value; } var qs = Form.serialize('search_form_ajx') + "&op=search_op"; var action = new Ajax.Request('ajax_misc.php', @@ -1371,7 +1388,7 @@ function search_operation(obj) { onFailure: null, onSuccess: function (req) { remove_waiting_box(); - $(target).innerHTML = req.responseText; + id$(target).innerHTML = req.responseText; req.responseText.evalScripts(); } } @@ -1386,7 +1403,11 @@ function search_operation(obj) { * Update the field e_concerned, from class_iconcerned * Value is the field where to put the quick-code but only if one checkbox has been * selected - * @param {type} obj + * @param {DOM Element} obj : DOM FORM , + * - element : ctlc : will contain the JRN.JR_ID , + * - tiers : the name of the counterparty + * - target : DGBOX displaying the search result + * * @returns {undefined} */ function set_reconcile(obj) { @@ -1405,13 +1426,13 @@ function set_reconcile(obj) { if (elmt.checked === true) { var str_name = elmt.name; var nValue = str_name.replace("jr_concerned", ""); - if ($(ctlc.value).value != '') { - $(ctlc.value).value += ','; + if (id$(ctlc.value).value != '') { + id$(ctlc.value).value += ','; } else { if (tiers && tiers.value != "") { - $(tiers.value).value = elmt.value; + id$(tiers.value).value = elmt.value; /* set the name */ new Ajax.Request("fid.php", { method: "get", @@ -1423,15 +1444,15 @@ function set_reconcile(obj) { var num = tiers_card.replace("e_other", ""); var tiers_name_id = "e_other" + "_name" + num; var answer = req.responseText.evalJSON(); - $(tiers_name_id).value = answer["name"]; + id$(tiers_name_id).value = answer["name"]; } }); } } if (single_operation == 0) { - $(ctlc.value).value += nValue; + id$(ctlc.value).value += nValue; } else { - $(ctlc.value).value = nValue; + id$(ctlc.value).value = nValue; } } @@ -1444,13 +1465,13 @@ function set_reconcile(obj) { } function remove_waiting_node() { - $('info_div').innerHTML = ""; - $('info_div').style.display = "none"; + id$('info_div').innerHTML = ""; + id$('info_div').style.display = "none"; } function remove_waiting_box() { - if ($('wait_box')) { + if (document.getElementById('wait_box')) { Effect.Fade('wait_box', {duration: 0.6}); } @@ -1474,10 +1495,10 @@ function get_profile_detail(gDossier, profile_id) { onFailure: null, onSuccess: function (req) { remove_waiting_box(); - $('list_profile').hide(); - $('detail_profile').innerHTML = req.responseText; + id$('list_profile').hide(); + id$('detail_profile').innerHTML = req.responseText; req.responseText.evalScripts(); - $('detail_profile').show(); + id$('detail_profile').show(); if (profile_id != "-1") profile_show('profile_gen_div'); } @@ -1539,7 +1560,7 @@ function mod_menu(gdossier, pm_id) { try { remove_waiting_box(); add_div({id: "divdm" + pm_id, drag: 1, cssclass: "inner_box", style: pos}); - $('divdm' + pm_id).innerHTML = req.responseText; + id$('divdm' + pm_id).innerHTML = req.responseText; } catch (e) { alert_box(e.message); } @@ -1571,13 +1592,13 @@ function display_sub_menu(p_dossier, p_profile, p_dep, p_level) { onSuccess: function (req) { try { remove_waiting_box(); - if ($('menu_table').rows.length > p_level) { - $('menu_table').rows[1].remove(); + if (id$('menu_table').rows.length > p_level) { + id$('menu_table').rows[1].remove(); } - $('sub' + p_dep).addClassName("selectedmenu"); + id$('sub' + p_dep).addClassName("selectedmenu"); var new_row = document.createElement('TR'); new_row.innerHTML = req.responseText; - $('menu_table').appendChild(new_row); + id$('menu_table').appendChild(new_row); } catch (e) { alert_box(e.message); } @@ -1605,9 +1626,9 @@ function remove_sub_menu(p_dossier, profile_menu_id) { onSuccess: function (req) { try { remove_waiting_box(); - $('sub' + profile_menu_id).remove(); - if ($('menu_table').rows.length > 1) { - $('menu_table').rows[1].remove(); + id$('sub' + profile_menu_id).remove(); + if (id$('menu_table').rows.length > 1) { + id$('menu_table').rows[1].remove(); } } catch (e) { @@ -1655,7 +1676,7 @@ function add_menu(obj) { try { remove_waiting_box(); add_div({id: "divdm" + p_id, drag: 1, "cssclass": "inner_box", "style": pos}); - $('divdm' + p_id).innerHTML = req.responseText; + id$('divdm' + p_id).innerHTML = req.responseText; } catch (e) { alert_box(e.message); } @@ -1685,7 +1706,7 @@ function add_plugin(p_dossier) { remove_waiting_box(); var pos = fixed_position(250, 150) + ";width:30%"; add_div({id: "divplugin", drag: 1, cssclass: "inner_box", style: pos}); - $('divplugin').innerHTML = req.responseText; + id$('divplugin').innerHTML = req.responseText; } catch (e) { alert_box(e.message); } @@ -1715,7 +1736,7 @@ function mod_plugin(p_dossier, me_code) { remove_waiting_box(); var pos = fixed_position(250, 150) + ";width:30%"; add_div({id: "divplugin", drag: 1, cssclass: "inner_box", style: pos}); - $('divplugin').innerHTML = req.responseText; + id$('divplugin').innerHTML = req.responseText; } catch (e) { alert_box(e.message); @@ -1745,7 +1766,7 @@ function create_menu(p_dossier) { cssclass: "inner_box", style: pos }); - $('divmenu').innerHTML = req.responseText; + id$('divmenu').innerHTML = req.responseText; } catch (e) { alert_box(e.message); } @@ -1774,7 +1795,7 @@ function modify_menu(p_dossier, me_code) { cssclass: "inner_box", style: pos }); - $('divmenu').innerHTML = req.responseText; + id$('divmenu').innerHTML = req.responseText; } catch (e) { alert_box(e.message); @@ -1799,7 +1820,7 @@ function get_properties(obj) { */ function rapport_add_row(p_dossier) { style = 'style="border: 1px solid blue;"'; - var table = $("rap1"); + var table = id$("rap1"); var line = table.rows.length; var row = table.insertRow(line); @@ -1818,7 +1839,7 @@ function rapport_add_row(p_dossier) { cellbutton.innerHTML = but_html; but_html.evalScripts(); - g('form' + line).value = ''; + id$('form' + line).value = ''; } /** @@ -1827,7 +1848,7 @@ function rapport_add_row(p_dossier) { function search_action(dossier, ctl_concern) { try { waiting_box(); - var dossier = g('gDossier').value; + var dossier = id$('gDossier').value; var target = "search_action_div"; removeDiv(target); @@ -1854,7 +1875,7 @@ function search_action(dossier, ctl_concern) { try { remove_waiting_box(); add_div(div); - $('search_action_div').innerHTML = req.responseText; + id$('search_action_div').innerHTML = req.responseText; req.responseText.evalScripts(); } catch (e) { alert_box(e.message); @@ -1869,7 +1890,7 @@ function search_action(dossier, ctl_concern) { function result_search_action(obj) { try { - var queryString = $(obj).serialize() + "&op=search_action"; + var queryString = id$(obj).serialize() + "&op=search_action"; var action = new Ajax.Request( "ajax_misc.php", { @@ -1879,7 +1900,7 @@ function result_search_action(obj) { onSuccess: function (req) { try { remove_waiting_box(); - $('search_action_div').innerHTML = req.responseText; + id$('search_action_div').innerHTML = req.responseText; req.responseText.evalScripts(); } catch (e) { alert_box(e.message); @@ -1898,7 +1919,7 @@ function result_search_action(obj) { function set_action_related(p_obj) { try { - var obj = $(p_obj); + var obj = id$(p_obj); var ctlc = obj.elements['ctlc']; for (var e = 0; e < obj.elements.length; e++) { @@ -1908,10 +1929,10 @@ function set_action_related(p_obj) { if (elmt.checked === true) { var str_name = elmt.name; var nValue = elmt.value; - if ($(ctlc.value).value != '') { - $(ctlc.value).value += ','; + if (id$(ctlc.value).value != '') { + id$(ctlc.value).value += ','; } - $(ctlc.value).value += nValue; + id$(ctlc.value).value += nValue; } } } @@ -1944,7 +1965,7 @@ function stock_repo_change(p_dossier, r_id) { onSuccess: function (req) { remove_waiting_box(); add_div({id: 'change_stock_repo_div', style: str_style, cssclass: 'inner_box', drag: "1"}); - $('change_stock_repo_div').innerHTML = req.responseText; + id$('change_stock_repo_div').innerHTML = req.responseText; } } @@ -1967,7 +1988,7 @@ function stock_inv_detail(p_dossier, p_id) { onSuccess: function (req) { remove_waiting_box(); add_div({id: 'view_mod_stock_div', style: str_style, cssclass: 'inner_box', drag: "1"}); - $('view_mod_stock_div').innerHTML = req.responseText; + id$('view_mod_stock_div').innerHTML = req.responseText; req.responseText.evalScripts(); } } @@ -1976,23 +1997,23 @@ function stock_inv_detail(p_dossier, p_id) { function show_fin_chdate(obj_id) { try { - var ch = $(obj_id).options[$(obj_id).selectedIndex].value; + var ch = id$(obj_id).options[id$(obj_id).selectedIndex].value; if (ch == 2) { - $('chdate_ext').hide(); - $('thdate').show(); + id$('chdate_ext').hide(); + id$('thdate').show(); } if (ch == 1) { - $('chdate_ext').show(); - $('thdate').hide(); + id$('chdate_ext').show(); + id$('thdate').hide(); } - var nb = $('nb_item').value; + var nb = id$('nb_item').value; for (i = 0; i < nb; i++) { - if ($('tdchdate' + i)) { + if (document.getElementById('tdchdate' + i)) { if (ch == 2) { - $('tdchdate' + i).show(); + id$('tdchdate' + i).show(); } if (ch == 1) { - $('tdchdate' + i).hide(); + id$('tdchdate' + i).hide(); } } @@ -2009,18 +2030,18 @@ function profile_show(p_div) { try { var div = ['profile_gen_div', 'profile_menu_div', 'profile_print_div', 'profile_gestion_div', 'profile_repo_div', 'profile_menu_mobile_div']; for (var r = 0; r < div.length; r++) { - $(div[r]).hide(); + id$(div[r]).hide(); } - $(p_div).show(); + id$(p_div).show(); } catch (e) { alert_box(e.message); } } function detail_category_show(p_div, p_dossier, p_id) { - $(p_div).show(); + id$(p_div).show(); waiting_box(); - $('detail_category_div').innerHTML = ""; + id$('detail_category_div').innerHTML = ""; var queryString = "gDossier=" + p_dossier + "&id=" + p_id + "&op=fddetail"; var action = new Ajax.Request( "ajax_misc.php", @@ -2029,9 +2050,9 @@ function detail_category_show(p_div, p_dossier, p_id) { onFailure: ajax_misc_failure, onSuccess: function (req) { remove_waiting_box(); - $('list_cat_div').hide(); - $('detail_category_div').innerHTML = req.responseText; - $('detail_category_div').show(); + id$('list_cat_div').hide(); + id$('detail_category_div').innerHTML = req.responseText; + id$('detail_category_div').show(); req.responseText.evalScripts(); } } @@ -2043,7 +2064,7 @@ function detail_category_show(p_div, p_dossier, p_id) { */ function check_new_category() { - if ( $('nom_mod_id').value.trim()=="") { + if ( id$('nom_mod_id').value.trim()=="") { new Effect.Highlight('nom_mod_id',{startcolor:"#ff0000"}); smoke.alert('Nom catégorie obligatoire'); return false; @@ -2085,7 +2106,7 @@ function check_date(p_str_date) { * @see check_date */ function check_date_id(p_id_date) { - var str_date = $(p_id_date).value; + var str_date = id$(p_id_date).value; return check_date(str_date); } @@ -2133,7 +2154,7 @@ function view_action(ag_id, dossier, modify) { cssclass: "inner_box", style: pos }); - $(id).innerHTML = code_html; + id$(id).innerHTML = code_html; if (ctl_txt == 'ok') { // compute detail var detail = in_child(id, "follow_up_detail"); @@ -2162,9 +2183,9 @@ function view_action(ag_id, dossier, modify) { * @see HtmlInput::filter_table */ function filter_table(phrase, _id, colnr, start_row) { - $('info_div').innerHTML = content[65]; - $('info_div').style.display = "block"; - var words = $(phrase).value.toLowerCase(); + id$('info_div').innerHTML = content[65]; + id$('info_div').style.display = "block"; + var words = id$(phrase).value.toLowerCase(); var table = document.getElementById(_id); // if colnr contains a comma then check several columns @@ -2196,20 +2217,20 @@ function filter_table(phrase, _id, colnr, start_row) { } else { table.rows[r].style.display = 'none'; } - $('info_div').style.display = "none"; - $('info_div').innerHTML = ""; + id$('info_div').style.display = "none"; + id$('info_div').innerHTML = ""; } if (tot_found == 0) { - if ($('info_' + _id)) { - $('info_' + _id).innerHTML = content[69]; + if (document.getElementById('info_' + _id)) { + id$('info_' + _id).innerHTML = content[69]; } } else { - if ($('info_' + _id)) { - $('info_' + _id).innerHTML = " "; + if (document.getElementById('info_' + _id)) { + id$('info_' + _id).innerHTML = " "; } } - $('info_div').style.display = "none"; - $('info_div').innerHTML = ""; + id$('info_div').style.display = "none"; + id$('info_div').innerHTML = ""; } /** @@ -2220,9 +2241,9 @@ function filter_table(phrase, _id, colnr, start_row) { * @see HtmlInput::filter_list */ function filter_list(phrase, _id) { - $('info_div').innerHTML = content[65]; - $('info_div').style.display = "block"; - var words = $(phrase).value.toLowerCase(); + id$('info_div').innerHTML = content[65]; + id$('info_div').style.display = "block"; + var words = id$(phrase).value.toLowerCase(); var l_list = document.getElementById(_id); @@ -2252,16 +2273,16 @@ function filter_list(phrase, _id) { } if (tot_found == 0) { - if ($('info_' + _id)) { - $('info_' + _id).innerHTML = content[69]; + if (document.getElementById('info_' + _id)) { + id$('info_' + _id).innerHTML = content[69]; } } else { - if ($('info_' + _id)) { - $('info_' + _id).innerHTML = " "; + if (document.getElementById('info_' + _id)) { + id$('info_' + _id).innerHTML = " "; } } - $('info_div').style.display = "none"; - $('info_div').innerHTML = ""; + id$('info_div').style.display = "none"; + id$('info_div').innerHTML = ""; } /** @@ -2272,9 +2293,9 @@ function filter_list(phrase, _id) { * @see HtmlInput::filter_list */ function filter_multiselect(phrase, _id) { - $('info_div').innerHTML = content[65]; - $('info_div').style.display = "block"; - var words = $(phrase).value.toLowerCase(); + id$('info_div').innerHTML = content[65]; + id$('info_div').style.display = "block"; + var words = id$(phrase).value.toLowerCase(); var l_list = document.getElementById(_id); var tot_found = 0; @@ -2289,16 +2310,16 @@ function filter_multiselect(phrase, _id) { } else { l_list.options[r].style.display = 'none'; } - $('info_div').style.display = "none"; - $('info_div').innerHTML = ""; + id$('info_div').style.display = "none"; + id$('info_div').innerHTML = ""; } if (tot_found == 0) { - if ($('info_' + _id)) { - $('info_' + _id).innerHTML = content[69]; + if (document.getElementById('info_' + _id)) { + id$('info_' + _id).innerHTML = content[69]; } } else { - if ($('info_' + _id)) { - $('info_' + _id).innerHTML = " "; + if (document.getElementById('info_' + _id)) { + id$('info_' + _id).innerHTML = " "; } } } @@ -2309,10 +2330,10 @@ function filter_multiselect(phrase, _id) { */ function display_task(p_id) { - $(p_id).style.top = posY + 'px'; - $(p_id).style.left = "10%"; - $(p_id).style.width = "80%"; - $(p_id).style.display = 'block'; + id$(p_id).style.top = posY + 'px'; + id$(p_id).style.left = "10%"; + id$(p_id).style.width = "80%"; + id$(p_id).style.display = 'block'; } @@ -2321,15 +2342,15 @@ function display_task(p_id) { * Set a message in the info */ function info_message(p_message) { - $('info_div').innerHTML = p_message; - $('info_div').style.display = "block"; + id$('info_div').innerHTML = p_message; + id$('info_div').style.display = "block"; } /** * hide the info box */ function info_hide() { - $('info_div').style.display = "none"; + id$('info_div').style.display = "none"; } /** @@ -2349,10 +2370,10 @@ function ask_navigator(p_dossier) { onSuccess: function (req) { remove_waiting_box(); add_div({id: 'navi_div', style: 'top:2em;', cssclass: 'inner_box'}); - $('navi_div').innerHTML = req.responseText; + id$('navi_div').innerHTML = req.responseText; try { req.responseText.evalScripts(); - sorttable.makeSortable($("navi_tb")); + sorttable.makeSortable(id$("navi_tb")); } catch (e) { alert_box("answer_box Impossible executer script de la reponse\n" + e.message); } @@ -2387,7 +2408,7 @@ function set_preference(p_dossier) { return; } add_div({id: 'preference_div', drag: 1}); - $('preference_div').innerHTML = req.responseText; + id$('preference_div').innerHTML = req.responseText; try { req.responseText.evalScripts(); } catch (e) { @@ -2422,7 +2443,7 @@ function show_bookmark(p_dossier) { onSuccess: function (req) { remove_waiting_box(); add_div({id: 'bookmark_div', cssclass: 'inner_box', drag: 1}); - $('bookmark_div').innerHTML = req.responseText; + id$('bookmark_div').innerHTML = req.responseText; try { req.responseText.evalScripts(); } catch (e) { @@ -2444,7 +2465,7 @@ function show_bookmark(p_dossier) { function save_bookmark() { try { waiting_box(); - var queryString = "op=bookmark&" + $("bookmark_frm").serialize(); + var queryString = "op=bookmark&" + id$("bookmark_frm").serialize(); var action = new Ajax.Request( "ajax_misc.php", { @@ -2454,7 +2475,7 @@ function save_bookmark() { remove_waiting_box(); // removeDiv('bookmark_div'); // - $('bookmark_div').innerHTML = req.responseText; + id$('bookmark_div').innerHTML = req.responseText; try { req.responseText.evalScripts(); } catch (e) { @@ -2476,7 +2497,7 @@ function save_bookmark() { function remove_bookmark() { try { waiting_box(); - var queryString = "op=bookmark&" + $("bookmark_del_frm").serialize(); + var queryString = "op=bookmark&" + id$("bookmark_del_frm").serialize(); var action = new Ajax.Request( "ajax_misc.php", { @@ -2484,7 +2505,7 @@ function remove_bookmark() { onFailure: ajax_misc_failure, onSuccess: function (req) { remove_waiting_box(); - $('bookmark_div').innerHTML = req.responseText; + id$('bookmark_div').innerHTML = req.responseText; try { req.responseText.evalScripts(); } catch (e) { @@ -2506,8 +2527,8 @@ function remove_bookmark() { *@note there is no protection */ function error_message(message) { - $('error_content_div').innerHTML = message; - $('error_div').style.visibility = 'visible'; + id$('error_content_div').innerHTML = message; + id$('error_div').style.visibility = 'visible'; } /** @@ -2534,7 +2555,7 @@ function show_tag(p_dossier, p_ac, p_tag_id, p_post) { remove_waiting_box(); var posy = calcy(250); add_div({id: 'tag_div', cssclass: 'inner_box', drag: 0, style: "position:fixed;top:15%;"}); - $('tag_div').innerHTML = code_html; + id$('tag_div').innerHTML = code_html; try { code_html.evalScripts(); } catch (e) { @@ -2555,7 +2576,7 @@ function show_tag(p_dossier, p_ac, p_tag_id, p_post) { function save_tag() { try { waiting_box(); - var queryString = "op=tag_save&" + $("tag_detail_frm").serialize(); + var queryString = "op=tag_save&" + id$("tag_detail_frm").serialize(); var action = new Ajax.Request( "ajax_misc.php", { @@ -2604,7 +2625,7 @@ function action_tag_select(p_dossier, ag_id) { add_div({id: 'tag_div', style: pos, cssclass: 'inner_box tag', drag: 0}); remove_waiting_box(); - $('tag_div').innerHTML = code_html; + id$('tag_div').innerHTML = code_html; } } ); @@ -2639,7 +2660,7 @@ function action_tag_add(p_dossier, ag_id, t_id, p_isgroup) { var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); remove_waiting_box(); - $('action_tag_td').innerHTML = code_html; + id$('action_tag_td').innerHTML = code_html; removeDiv('tag_div'); } } @@ -2675,7 +2696,7 @@ function action_tag_remove(p_dossier, ag_id, t_id) { var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); remove_waiting_box(); - $('action_tag_td').innerHTML = code_html; + id$('action_tag_td').innerHTML = code_html; } } @@ -2701,8 +2722,8 @@ function activate_tag(p_dossier, p_tag_id) { remove_waiting_box(); var answer = req.responseText.evalJSON(); var tagId = "tag_onoff" + p_tag_id; - $(tagId).update(answer.code); - $(tagId).setStyle(answer.style); + id$(tagId).update(answer.code); + id$(tagId).setStyle(answer.style); remove_waiting_box(); } }) @@ -2737,10 +2758,10 @@ function search_display_tag(p_dossier, p_prefix, p_object) { code_html = unescape_xml(code_html); remove_waiting_box(); add_div({id: p_prefix + 'tag_div', style: 'left:10%;width:70%', cssclass: 'inner_box', drag: 1}); - $(p_prefix + 'tag_div').style.top = calcy(200) + "px" - $(p_prefix + 'tag_div').style.left = 20 + "%"; + id$(p_prefix + 'tag_div').style.top = calcy(200) + "px" + id$(p_prefix + 'tag_div').style.left = 20 + "%"; remove_waiting_box(); - $(p_prefix + 'tag_div').innerHTML = code_html; + id$(p_prefix + 'tag_div').innerHTML = code_html; code_html.evalScripts(); } } @@ -2762,7 +2783,7 @@ function search_add_tag(p_dossier, p_tag_id, p_prefix, p_obj) { try { var clear_button = 0; if (tag_choose === '' && p_prefix === 'search') { - tag_choose = $(p_prefix + 'tag_choose_td').innerHTML; + tag_choose = id$(p_prefix + 'tag_choose_td').innerHTML; clear_button = 1; } waiting_box(); @@ -2782,7 +2803,7 @@ function search_add_tag(p_dossier, p_tag_id, p_prefix, p_obj) { var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); remove_waiting_box(); - $(p_prefix + 'tag_choose_td').innerHTML = $(p_prefix + 'tag_choose_td').innerHTML + code_html; + id$(p_prefix + 'tag_choose_td').innerHTML = id$(p_prefix + 'tag_choose_td').innerHTML + code_html; removeDiv(p_prefix + 'tag_div'); } } @@ -2798,7 +2819,7 @@ function search_add_tag(p_dossier, p_tag_id, p_prefix, p_obj) { */ function search_clear_tag(p_dossier, p_prefix) { if (p_prefix != 'search') { - $(p_prefix + 'tag_choose_td').innerHTML = ""; + id$(p_prefix + 'tag_choose_td').innerHTML = ""; return; } try { @@ -2817,7 +2838,7 @@ function search_clear_tag(p_dossier, p_prefix) { } var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); - $(p_prefix + 'tag_choose_td').innerHTML = code_html; + id$(p_prefix + 'tag_choose_td').innerHTML = code_html; tag_choose = ""; } } @@ -2856,8 +2877,8 @@ function calendar_zoom(obj) { var per_periode = null; var notitle = 0; var from = 0; - if ($(obj.invalue)) { - per_periode = $(obj.invalue).value; + if (id$(obj.invalue)) { + per_periode = id$(obj.invalue).value; } if (obj.notitle && obj.notitle == 1) { notitle = 1; @@ -2895,7 +2916,7 @@ function calendar_zoom(obj) { if (obj.outdiv === undefined) { obj.outdiv = 'calendar_zoom_div'; } - if ($(obj.outdiv) == undefined) { + if (id$(obj.outdiv) == undefined) { var str_style = 'top:10%;min-height:60rem'; // var str_style = fixed_position(0, 120); add_div({ @@ -2906,8 +2927,8 @@ function calendar_zoom(obj) { }); } remove_waiting_box(); - $(obj.outdiv).innerHTML = code_html; - $(obj.outdiv).show(); + id$(obj.outdiv).innerHTML = code_html; + id$(obj.outdiv).show(); } } ); @@ -2924,12 +2945,12 @@ function calendar_zoom(obj) { function stock_add_row() { try { style = 'class="input_text"'; - var mytable = g("stock_tb").tBodies[0]; + var mytable = id$("stock_tb").tBodies[0]; var ofirstRow = mytable.rows[1]; var line = mytable.rows.length; var nCell = mytable.rows[1].cells.length; var row = mytable.insertRow(line); - var nb = g("row"); + var nb = id$("row"); for (var e = 0; e < nCell; e++) { var newCell = row.insertCell(e); if (mytable.rows[1].cells[e].hasClassName('num')) { @@ -2944,10 +2965,10 @@ function stock_add_row() { new_tt.evalScripts(); } - g("sg_code" + nb.value).innerHTML = ' '; - g("sg_code" + nb.value).value = ''; - g("label" + nb.value).innerHTML = ''; - g("sg_quantity" + nb.value).value = '0'; + id$("sg_code" + nb.value).innerHTML = ' '; + id$("sg_code" + nb.value).value = ''; + id$("label" + nb.value).innerHTML = ''; + id$("sg_quantity" + nb.value).value = '0'; nb.value++; @@ -2959,8 +2980,8 @@ function stock_add_row() { } function show_description(p_id) { - $('print_desc' + p_id).hide(); - $('input_desc' + p_id).show(); + id$('print_desc' + p_id).hide(); + id$('input_desc' + p_id).show(); } @@ -2996,9 +3017,9 @@ function show_tabs(a_tabs, p_display_tab) { } var i = 0; for (i = 0; i < a_tabs.length; i++) { - $(a_tabs[i]).hide(); + id$(a_tabs[i]).hide(); } - $(p_display_tab).show(); + id$(p_display_tab).show(); } catch (e) { alert_box(e.message); } @@ -3050,8 +3071,8 @@ function create_anchor_up() { newElt.setAttribute('id', 'up_top'); newElt.innerHTML = ''; - var parent = $('info_div').parentNode; - parent.insertBefore(newElt, $('info_div')); + var parent = id$('info_div').parentNode; + parent.insertBefore(newElt, id$('info_div')); } @@ -3074,13 +3095,13 @@ function init_scroll() { } ; if (document.viewport.getScrollOffsets().top > 0) { - if ($('go_up').visible() == false) { - $('go_up').setOpacity(0.65); - $('go_up').show(); - $('go_up').style.zIndex = 99; + if (id$('go_up').visible() == false) { + id$('go_up').setOpacity(0.65); + id$('go_up').show(); + id$('go_up').style.zIndex = 99; } } else { - $('go_up').hide(); + id$('go_up').hide(); } } @@ -3142,7 +3163,7 @@ function confirm_box(p_obj, p_message, p_callback_true, p_waiting) { if (p_waiting) { waiting_box(); } - $(name).submit(); + id$(name).submit(); } }); } else { @@ -3165,7 +3186,7 @@ function confirm_box(p_obj, p_message, p_callback_true, p_waiting) { * @returns void */ function alert_box(p_message) { - smoke.alert(p_message, undefined, {ok: 'ok', classname: "inner_box"}); + smoke.alert(p_message, undefined, {ok: 'ok', classname: "inner_box",title:'ATTENTION'}); } @@ -3174,7 +3195,7 @@ function alert_box(p_message) { * @param string p_table id of the table */ function alternate_row_color(p_table) { - var table_colored = $(p_table); + var table_colored = id$(p_table); if (!table_colored.tBodies[0]) return; var len = table_colored.tBodies[0].rows.length; @@ -3197,7 +3218,7 @@ function alternate_row_color(p_table) { * @param p_list {string} DOM id of the list */ function alternate_row_color_list(p_list) { - var list_colored = $(p_list); + var list_colored = id$(p_list); if ( list_colored.children.length==0 ) return; var len = list_colored.children.length; @@ -3225,7 +3246,7 @@ function pin(object_id) { if (aDraggableElement[object_id]) { aDraggableElement[object_id].destroy(); aDraggableElement[object_id] = undefined; - $('pin_' + object_id).innerHTML = ""; + id$('pin_' + object_id).innerHTML = ""; } else { aDraggableElement[object_id] = new Draggable(object_id, { starteffect: function () { @@ -3233,7 +3254,7 @@ function pin(object_id) { } } ); - $('pin_' + object_id).innerHTML = ""; + id$('pin_' + object_id).innerHTML = ""; } } @@ -3245,10 +3266,10 @@ function pin(object_id) { * @param p_attribute_value the value of the attribute we want to show */ function show_only_row(p_table_id, p_attribute_name, p_attribute_value) { - if (!$(p_table_id)) { + if (!id$(p_table_id)) { throw "Invalide table id" } - var mTable = $(p_table_id); + var mTable = id$(p_table_id); var ncount = mTable.rows.length for (var i = 0; i < ncount; i++) { var mRow = mTable.rows[i]; @@ -3265,10 +3286,10 @@ function show_only_row(p_table_id, p_attribute_name, p_attribute_value) { * @param p_table_id table id */ function show_all_row(p_table_id) { - if (!$(p_table_id)) { + if (!id$(p_table_id)) { throw "Invalide table id" } - var mTable = $(p_table_id); + var mTable = id$(p_table_id); var ncount = mTable.rows.length for (var i = 0; i < ncount; i++) { var mRow = mTable.rows[i]; @@ -3349,7 +3370,7 @@ var Periode = function (p_ledger) { var answer = req.responseText.evalJSON(); remove_waiting_box(); if (answer.status == "OK") { - $("row_per_" + p_periode_id).remove(); + id$("row_per_" + p_periode_id).remove(); alternate_row_color("periode_tbl"); } else { smoke.alert(answer.content); @@ -3398,7 +3419,7 @@ var Periode = function (p_ledger) { "cssclass": "inner_box", 'html': "wait" }); - $('mod_periode').update(json.content); + id$('mod_periode').update(json.content); } }); }; @@ -3452,7 +3473,7 @@ var Periode = function (p_ledger) { remove_waiting_box(); var json = req.responseText.evalJSON(); if (json.status == 'OK') { - $('row_per_' + p_periode_id).update(json.content); + id$('row_per_' + p_periode_id).update(json.content); new Effect.Highlight('row_per_' + p_periode_id, {startcolor: '#FAD4D4', endcolor: '#F78082'}); } else { smoke.alert(json.content); @@ -3492,7 +3513,7 @@ var Periode = function (p_ledger) { remove_waiting_box(); var json = req.responseText.evalJSON(); if (json.status == 'OK') { - $('row_per_' + p_periode_id).update(json.content); + id$('row_per_' + p_periode_id).update(json.content); new Effect.Highlight('row_per_' + p_periode_id, { startcolor: '#FAD4D4', endcolor: '#F78082' @@ -3511,7 +3532,7 @@ var Periode = function (p_ledger) { * @returns {Boolean} */ this.save = function (p_frm) { - var js_param = $(p_frm).serialize(true); + var js_param = id$(p_frm).serialize(true); waiting_box(); js_param["js_var"] = this.js_obj_name; js_param["act"] = "save"; @@ -3525,7 +3546,7 @@ var Periode = function (p_ledger) { var answer = req.responseText.evalJSON(); remove_waiting_box(); if (answer.status == "OK") { - $('row_per_' + js_param['periode_id']).update(answer.content); + id$('row_per_' + js_param['periode_id']).update(answer.content); removeDiv('mod_periode'); new Effect.Highlight('row_per_' + js_param['periode_id'], { startcolor: '#FAD4D4', @@ -3555,7 +3576,7 @@ var Periode = function (p_ledger) { } } if (count == 0) { - smoke.signal("Sélectionner au moins une période", function () { + smoke.signal("Sélectionner au moins une période", function () { }, {duration: 1500}); return; } @@ -3582,7 +3603,7 @@ var Periode = function (p_ledger) { */ this.insert_periode = function () { var p_frm = 'insert_periode_frm'; - var js_param = $(p_frm).serialize(true); + var js_param = id$(p_frm).serialize(true); waiting_box(); js_param["js_var"] = this.js_obj_name; js_param["act"] = "insert_periode"; @@ -3598,11 +3619,11 @@ var Periode = function (p_ledger) { remove_waiting_box(); if (answer.status == "OK") { var new_row = document.createElement("tr"); - $('periode_tbl').append(new_row); + id$('periode_tbl').append(new_row); new_row.replace(answer.content); // hide the form - $('periode_add').hide(); + id$('periode_add').hide(); new Effect.Highlight('row_per_' + answer.p_id, {startcolor: '#FAD4D4', endcolor: '#F78082'}); alternate_row_color('periode_tbl'); } else { @@ -3619,8 +3640,8 @@ var Periode = function (p_ledger) { * @param p_table_id DOM ID of the table */ Periode.filter_exercice = function (p_table_id) { - var rows = $(p_table_id).rows; - var selected_value = $('p_exercice_sel').value; + var rows = id$(p_table_id).rows; + var selected_value = id$('p_exercice_sel').value; for (var i = 1; i < rows.length; i++) { var exercice = rows[i].getAttribute("per_exercice"); if (selected_value == -1) { @@ -3661,7 +3682,7 @@ function progress_bar_start(p_taskid, p_message) { cssclass: "inner_box", style: "z-index:1000;position:fixed;top:30%;width:40%;left:30%" }); - $("message" + progressIdx).update('

' + content[65] + '

' + message); + id$("message" + progressIdx).update('

' + content[65] + '

' + message); // Create a div add_div({id: "progressDiv" + progressIdx, cssclass: "progressbar", html: '0'}); // Check status every sec. @@ -3685,7 +3706,7 @@ function progress_bar_check(p_idx, p_taskid) { onSuccess: function (req) { try { var answer = req.responseText.evalJSON(); - var progress_div = $("progressDiv" + progressIdx); + var progress_div = id$("progressDiv" + progressIdx); var a_child = progress_div.childNodes; var i = 0; for (i = 0; i < a_child.length; i++) { @@ -3704,10 +3725,10 @@ function progress_bar_check(p_idx, p_taskid) { clearInterval(progressBar[p_idx]); progressValue.innerHTML = "Success"; Effect.BlindUp("progressDiv" + p_idx, {duration: 1.0, scaleContent: false}) - $("message" + p_idx).remove(); - $("blocking" + p_idx).remove(); + id$("message" + p_idx).remove(); + id$("blocking" + p_idx).remove(); setTimeout(function () { - $("progressDiv" + progressIdx).remove + id$("progressDiv" + progressIdx).remove }, 1100); } } catch (e) { @@ -3729,7 +3750,7 @@ function progress_bar_check(p_idx, p_taskid) { */ function updatePeriodePreference(p_dossier) { waiting_box(); - var exercice = $('exercice_setting').value; + var exercice = id$('exercice_setting').value; new Ajax.Updater('setting_period', "ajax_misc.php", { method: "get", parameters: {"op": "pref_exercice", "gDossier": p_dossier, "exercice": exercice} @@ -3747,7 +3768,7 @@ function updatePeriodePreference(p_dossier) { */ function updatePeriode(p_dossier, p_exercice, p_periode_from, p_periode_to, p_last) { waiting_box(); - var exercice = $(p_exercice).value; + var exercice = id$(p_exercice).value; new Ajax.Updater(p_periode_from, "ajax_misc.php", { method: "get", @@ -3798,9 +3819,9 @@ function toggle_lock(p_domid) { * @returns {undefined} */ function show_ledger_fin_currency() { - var ledger = $('p_jrn').value; - var dossier = $('gDossier').value; - // $('ledger_currency'). + var ledger = id$('p_jrn').value; + var dossier = id$('gDossier').value; + // id$('ledger_currency'). var a = new Ajax.Updater("ledger_currency", "ajax_misc.php", { @@ -3814,14 +3835,14 @@ function show_ledger_fin_currency() { function updatePreference() { try { waiting_box(); - var param = $('preference_frm').serialize() + "&op=preference&action=save"; + var param = id$('preference_frm').serialize() + "&op=preference&action=save"; new Ajax.Request("ajax_misc.php", { method: "post", parameters: param, onSuccess: function (req) { var answer = req.responseText.evalJSON(); - // $('pagestyle').setAttribute('href', style.style); + // id$('pagestyle').setAttribute('href', style.style); if (answer['psw'] == 'NOK') { smoke.alert(answer['msg']); } else { @@ -3843,14 +3864,14 @@ function updatePreference() { * @see param_jrn.php */ function toggle_onoff(icon_domid, p_value_domid) { - if ($(p_value_domid).value == 0) { - $(p_value_domid).value = 1; - $(icon_domid).innerHTML = ''; - $(icon_domid).style = 'color:green'; + if (id$(p_value_domid).value == 0) { + id$(p_value_domid).value = 1; + id$(icon_domid).innerHTML = ''; + id$(icon_domid).style = 'color:green'; } else { - $(p_value_domid).value = 0; - $(icon_domid).innerHTML = ''; - $(icon_domid).style = 'color:red'; + id$(p_value_domid).value = 0; + id$(icon_domid).innerHTML = ''; + id$(icon_domid).style = 'color:red'; } } @@ -3862,12 +3883,12 @@ function toggle_onoff(icon_domid, p_value_domid) { */ function toggle_checkbox_onoff(icon_domid, p_value_domid) { - if ($(p_value_domid).value == 0) { - $(p_value_domid).value = 1; - $(icon_domid).innerHTML = ''; + if (id$(p_value_domid).value == 0) { + id$(p_value_domid).value = 1; + id$(icon_domid).innerHTML = ''; } else { - $(p_value_domid).value = 0; - $(icon_domid).innerHTML = ''; + id$(p_value_domid).value = 0; + id$(icon_domid).innerHTML = ''; } } @@ -3881,9 +3902,9 @@ function toggle_checkbox_onoff(icon_domid, p_value_domid) { function toggle_row_warning_enable(p_enable, p_row) { var warning = document.getElementsByName('negative_amount')[0].value if ( warning == 1) { - $(p_row).show(); + id$(p_row).show(); } else { - $(p_row).hide(); + id$(p_row).hide(); } } @@ -3960,7 +3981,7 @@ var operation_tag = function (p_div) { add_div({id: 'tag_div', style: pos, cssclass: 'inner_box tag', drag: 0}); remove_waiting_box(); - $('tag_div').innerHTML = code_html; + id$('tag_div').innerHTML = code_html; } } ); @@ -3999,7 +4020,7 @@ var operation_tag = function (p_div) { var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); remove_waiting_box(); - $('operation_tag_td' + ctl).innerHTML = code_html; + id$('operation_tag_td' + ctl).innerHTML = code_html; removeDiv('tag_div'); } } @@ -4042,7 +4063,7 @@ var operation_tag = function (p_div) { var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); remove_waiting_box(); - $('operation_tag_td' + ctl).innerHTML = code_html; + id$('operation_tag_td' + ctl).innerHTML = code_html; } } @@ -4111,10 +4132,10 @@ function full_size(p_div) { if (!div_dom) return; if (div_dom.hasClassName('fullsize')) { div_dom.removeClassName('fullsize'); - $('size_' + p_div).innerHTML = ''; + id$('size_' + p_div).innerHTML = ''; } else { div_dom.addClassName('fullsize'); - $('size_' + p_div).innerHTML = ''; + id$('size_' + p_div).innerHTML = ''; } } @@ -4133,7 +4154,7 @@ function download_document(p_url) { */ function download_document_form(p_form_id) { waiting_box(); - var url = "export.php?" + $(p_form_id).serialize(); + var url = "export.php?" + id$(p_form_id).serialize(); document.location = url; remove_waiting_box(); return false; @@ -4223,7 +4244,7 @@ function event_display_detail(p_dossier, p_detail) { } - $(dgbox).update(req.responseText) + id$(dgbox).update(req.responseText) } } @@ -4256,7 +4277,7 @@ function event_display_main(p_dossier) { return; } - $(dgbox).update(req.responseText) + id$(dgbox).update(req.responseText) } } @@ -4273,13 +4294,13 @@ function event_display_main(p_dossier) { */ function check_password_strength(p_pass_domid, p_result_domid, details) { try { - if ($(p_pass_domid).value == "") { - $(p_result_domid).update(""); + if (id$(p_pass_domid).value == "") { + id$(p_result_domid).update(""); return; } var queryString = { 'op': "password_chk" - , pass: $(p_pass_domid).value + , pass: id$(p_pass_domid).value }; var action = new Ajax.Request( "ajax_misc.php", @@ -4296,14 +4317,14 @@ function check_password_strength(p_pass_domid, p_result_domid, details) { console.debug(answer); if (answer['password'] == 'nok') { - $(p_pass_domid).setStyle("background-color:red"); + id$(p_pass_domid).setStyle("background-color:red"); if (details) { - $(p_result_domid).update(answer['msg']) + id$(p_result_domid).update(answer['msg']) } return; } - $(p_pass_domid).setStyle("background-color: lightgreen"); - $(p_result_domid).update("") + id$(p_pass_domid).setStyle("background-color: lightgreen"); + id$(p_result_domid).update("") } } ); @@ -4393,7 +4414,7 @@ Widget.prototype.display = function (box,user_widget_id,widget_code) { reconnect(); return; } - $(box).replace(req.responseText); + id$(box).replace(req.responseText); } } @@ -4435,7 +4456,7 @@ Widget.prototype.manage = function () { add_div({id: box, cssclass: 'inner_box', html: loading(), style: style,drag:false}) - $(box).update(req.responseText); + id$(box).update(req.responseText); } } ); @@ -4450,8 +4471,8 @@ Widget.prototype.manage = function () { */ Widget.prototype.create_sortable=function() { - Sortable.create('contain_widget',{tag:'li',onUpdate:function(){ $('order_widget_hidden').value=Sortable.serialize('contain_widget')}}) - $('order_widget_hidden').value=Sortable.serialize('contain_widget'); + Sortable.create('contain_widget',{tag:'li',onUpdate:function(){ id$('order_widget_hidden').value=Sortable.serialize('contain_widget')}}) + id$('order_widget_hidden').value=Sortable.serialize('contain_widget'); } /** * Save the order of widget @@ -4465,7 +4486,7 @@ Widget.prototype.save = function () { // For form , most of the parameters are in the FORM // method is then POST - //var queryString=$(p_form_id).serialize(true); + //var queryString=id$(p_form_id).serialize(true); var queryString = { op : 'widget', @@ -4521,7 +4542,7 @@ Widget.prototype.refresh = function () { return; } - $(dgbox).replace(req.responseText); + id$(dgbox).replace(req.responseText); } } @@ -4535,8 +4556,8 @@ Widget.prototype.refresh = function () { * @param user_widget_id {integer} */ Widget.prototype.delete=function (user_widget_id) { - $('elt_'+user_widget_id).remove() - $('order_widget_hidden').value=Sortable.serialize('contain_widget'); + id$('elt_'+user_widget_id).remove() + id$('order_widget_hidden').value=Sortable.serialize('contain_widget'); } /** * display list widget we can add @@ -4568,7 +4589,7 @@ Widget.prototype.input = function () { add_div({id: box, cssclass: 'inner_box', html: loading(), style: style}) - $(box).update(req.responseText); + id$(box).update(req.responseText); } @@ -4587,8 +4608,8 @@ Widget.prototype.add=function (widget_code) { { here=this; var param = {}; - if ($(widget_code+"_param")) { - param=$(widget_code+"_param").serialize() + if (document.getElementById(widget_code+"_param")) { + param=id$(widget_code+"_param").serialize() } query = { op : 'widget', @@ -4609,7 +4630,7 @@ Widget.prototype.add=function (widget_code) { return; } var new_element=new Element("li"); - $('contain_widget').appendChild(new_element); + id$('contain_widget').appendChild(new_element); new_element.replace(req.responseText) removeDiv('widget_box_select_id') here.create_sortable() @@ -4659,13 +4680,13 @@ Widget.prototype.remove_ident = function () * @param widget_domid {string} dom id of the widget to toggle the size */ Widget.prototype.toggle_full_size=function (widget_domid) { - if ( $(widget_domid).hasClassName('widget-full_size')) { - $(widget_domid).removeClassName('widget-full_size'); + if ( id$(widget_domid).hasClassName('widget-full_size')) { + id$(widget_domid).removeClassName('widget-full_size'); } else { - $(widget_domid).addClassName('widget-full_size'); + id$(widget_domid).addClassName('widget-full_size'); layer++; - $(widget_domid).style.zIndex=layer; + id$(widget_domid).style.zIndex=layer; } }; diff --git a/html/lang/en_US/LC_MESSAGES/messages.po b/html/lang/en_US/LC_MESSAGES/messages.po index 1c3cdee69..9e6bebc57 100644 --- a/html/lang/en_US/LC_MESSAGES/messages.po +++ b/html/lang/en_US/LC_MESSAGES/messages.po @@ -14,7 +14,7 @@ msgstr "" "Project-Id-Version: NOALYSS 672\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-07 17:50+0200\n" -"PO-Revision-Date: 2024-09-10 10:26+0200\n" +"PO-Revision-Date: 2022-08-30 00:39+0200\n" "Last-Translator: dany \n" "Language-Team: French \n" "Language: en_US\n" @@ -18028,7 +18028,7 @@ msgstr "List depreciable property" #: include/database.item.php:94 include/database.item.php:88 #: include/database.item.php:90 include/database.item.php:74 msgid "Liste des changements manuels des stocks" -msgstr "List of books stock changes" +msgstr "History " #: include/database.item.php:98 include/database.item.php:101 #: include/database.item.php:95 include/database.item.php:93 @@ -18050,7 +18050,7 @@ msgstr "List of contacts" #: include/ext/skel/index.php:46 include/ext/tva/index.php:35 #: include/ext/tva/index.php:38 include/ext/tva/index.php:39 msgid "Liste des déclarations TVA" -msgstr "List of VAT returns" +msgstr "History VAT forms" #: include/template/operation_exercice-list_draft.php:40 #, fuzzy @@ -18065,7 +18065,7 @@ msgstr "Folders" #: include/impress_jrn.inc.php:147 include/impress_jrn.inc.php:140 msgid "Liste détaillées opérations " -msgstr "List of detailled entries" +msgstr "Detailled List " #: include/search.inc.php:118 include/search.inc.php:119 #: include/ajax/ajax_search_operation.php:119 diff --git a/html/test.php b/html/test.php index e5eeb9adc..7afef0b02 100644 --- a/html/test.php +++ b/html/test.php @@ -24,26 +24,28 @@ * * - first do not forget to create the authorized_debug file in the html folder * - secund the test must be adapted to this page : if you do a post (or get) from a test, you won't get any result - * if the $_REQUEST[test_select] is not set, so set it . + * if the $_REQUEST[test_select] is not set, so set it . + * + * */ include_once("../include/constant.php"); include_once("lib/ac_common.php"); -require_once('class/database.class.php'); -require_once ('class/dossier.class.php'); -require_once('lib/html_input.class.php'); -require_once('lib/icon_action.class.php'); -require_once ('lib/function_javascript.php'); -require_once 'class/noalyss_user.class.php'; -require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; + + + html_page_start(); global $http; - +define ('TEST_UNIT',1); $http=new HttpInput(); - +if ( ini_get('zend.assertions') != 1 ) { + echo_warning(_('Attention zend.assertions devrait être activé')); + echo p('Il faut changer dans votre fichier .htaccess ou php.ini'); + echo 'voir https://www.php.net/manual/fr/ini.core.php#ini.zend.assertions'; +} $gDossier=$http->request('gDossier',"number", -1); if ($gDossier==-1) { @@ -64,20 +66,27 @@ if (!file_exists('authorized_debug')) exit(); } define('ALLOWED', 1); + +global $aAvaible_module; + +/* + * Find all the folders + */ +$directory=NOALYSS_BASE."/scenario"; +$folder=scandir($directory); +$nb_folder=count($folder); + +for ($i=0; $i<$nb_folder;$i++) +{ + if (is_dir("{$directory}/".$folder[$i]) && $folder[$i] != '.' && $folder[$i] !='..') + { + $aAvaible_module[]=$folder[$i]; + + } +} + load_all_script(); // To enable assert , set "zend.assertions" in the php.ini file -ini_set("assert.active",1); -assert_options(ASSERT_ACTIVE, 1); -assert_options(ASSERT_WARNING, 1); -//removed in PHP8 assert_options(ASSERT_QUIET_EVAL, 1); -function my_assert_handler($file, $line, $code) -{ - echo "
Assert Failed : - File '$file'
- Line '$line'
- Code '$code'

"; -} -assert_options(ASSERT_CALLBACK, 'my_assert_handler'); /******************************************************************************************************************/ /* Utilities /******************************************************************************************************************/ @@ -97,34 +106,81 @@ function get_card_with_activity() { } /* - * Loading of all scenario + * Loading of all scenario HTML + XML */ -$scan=scandir('../scenario/'); -$maxscan=count($scan); -$cnt_scenario=0;$scenario=array(); +function retrieve_files($directory) :array +{ + $scan=scandir($directory); + $maxscan=count($scan); + $cnt_scenario=0;$scenario=array(); -for ($e_scan=0; $e_scan<$maxscan; $e_scan++) - { - if (is_file('../scenario/'.$scan[$e_scan])&&strpos($scan[$e_scan], '.php')==true) + for ($e_scan=0; $e_scan<$maxscan; $e_scan++) { - $description=""; - $a_description=file('../scenario/'.$scan[$e_scan]); - $max_description=count($a_description); - for ($w=0; $w<$max_description; $w++) + if (is_file("{$directory}/".$scan[$e_scan])&&strpos($scan[$e_scan], '.php')==true) { - if (strpos($a_description[$w], '@description:')==true) + $description=""; + $a_description=file("{$directory}/".$scan[$e_scan]); + $max_description=count($a_description); + for ($w=0; $w<$max_description; $w++) { - $description=$a_description[$w]; - $description=noalyss_str_replace('//@description:', '', $description); + if (strpos($a_description[$w], '@description:')==true) + { + $description=$a_description[$w]; + $description=noalyss_str_replace('//@description:', '', $description); + } } + $scenario[$cnt_scenario]['file']="{$directory}/".$scan[$e_scan]; + $scenario[$cnt_scenario]['desc']=$description; + $cnt_scenario++; + + } - $scenario[$cnt_scenario]['file']=$scan[$e_scan]; - $scenario[$cnt_scenario]['desc']=$description; - $cnt_scenario++; - - } + return $scenario; +} +function display_test($title,$gDossierLogInput,$aHtml_files) +{ + + echo h1($title); + + $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts",'module'=>$title)); + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $nb_html=count($aHtml_files); + for ($e=0; $e<$nb_html; $e++) + { + + $get='test.php?'.http_build_query(array('script'=>$aHtml_files[$e]['file'], 'gDossier'=>$gDossierLogInput, 'description'=>$aHtml_files[$e]['desc'])); + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo '
'; + echo ''; + echo "Tous les tests du module $title "; + echo ''; + echo ''; + echo ''; + echo 'Tous les scripts'; + echo ''; + echo '
'; + echo $e; + echo ''; + echo ''; + echo basename($aHtml_files[$e]['file']); + echo ''; + echo ''.$aHtml_files[$e]['desc'].'
'; +} + + + $script=$http->request('script', "string",''); $min=$cn->get_value("select p_id from parm_periode order by p_start asc limit 1"); $max=$cn->get_value("select p_id from parm_periode order by p_start desc limit 1"); @@ -137,81 +193,76 @@ if ($script=="") * cherche pour fichier a include, s'il y en a alors les affiche * avec une description */ - - echo ''; $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts")); - echo ''; - echo ''; - echo ''; - echo ''; + print '

'; + printf( ' Tous les test ',$get); + print '

'; + foreach ($aAvaible_module as $mod) { + $html_files = retrieve_files(NOALYSS_BASE . '/scenario/' . $mod); + display_test($mod,$gDossierLogInput,$html_files); - for ($e=0; $e<$cnt_scenario; $e++) - { - - $get='test.php?'.http_build_query(array('script'=>$scenario[$e]['file'], 'gDossier'=>$gDossierLogInput, 'description'=>$scenario[$e]['desc'])); - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - echo '
'; - echo ''; - echo "Tous "; - echo ''; - echo 'Tous les scripts
'; - echo $e; - echo ''; - echo ''; - echo $scenario[$e]['file']; - echo ''; - echo ''.$scenario[$e]['desc'].'
'; + + } else if ($script=='all') { - $nb=$http->get('nb_script', "number",0); - + $nb=$http->get('nb_script', "number",1); + $start_mem=memory_get_usage(); $start_time=microtime(true); - $script=noalyss_str_replace('../', '', $script); - - echo '

'.$nb." ".$scenario[$nb]['file']."

"; - echo '

description = '.$scenario[$nb]["desc"].'

'; - include '../scenario/'.$scenario[$nb]['file']; - echo ''; - echo ''; - $end_mem=memory_get_usage(); - $end_time=microtime(true); + $module=$http->get('module','string','all'); + $scenario=[]; + if ($module=='all') { + foreach ($aAvaible_module as $mod) { + $html_files = retrieve_files(NOALYSS_BASE . '/scenario/' . $mod); + $scenario = array_merge($html_files, $scenario); + } + } elseif (in_array($module, $aAvaible_module) ) { + $scenario=retrieve_files(NOALYSS_BASE.'/scenario/'.$module); - echo "

start mem : ".$start_mem; - echo '

'; - echo "

end mem : ".$end_mem; - echo '

'; - echo "

Diff = ".($end_mem-$start_mem)." bytes "; - echo "

Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes "; - echo "

Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes "; - echo '

'; - echo "

Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes

"; - $nb++; - if ( $nb == $maxscan ) { - echo "Dernier test"; - } else { - $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'nb_script'=>$nb)); - echo ''; - echo $scenario[$nb]['file']; + } + + $maxscan=$http->get('nb_script', "number",count($scenario)-1); + $maxscan++; + for ($i=$nb;$i< $maxscan;$i++) { + echo '

'.$nb." ".$scenario[$nb]['file']."

"; + echo '

description = '.$scenario[$nb]["desc"].'

'; + include $scenario[$nb]['file']; + echo ''; + echo ''; + $end_mem=memory_get_usage(); + $end_time=microtime(true); + + echo "

start mem : ".$start_mem; + echo '

'; + echo "

end mem : ".$end_mem; + echo '

'; + echo "

Diff = ".($end_mem-$start_mem)." bytes "; + echo "

Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes "; + echo "

Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes "; + echo '

'; + echo "

Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes

"; + $nb++; + if ( $nb == $maxscan ) { + echo "Dernier test"; + } else { + $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'nb_script'=>$nb)); + echo '
'; + echo $scenario[$nb]['file']; + echo ''; + } } } else { $start_mem=memory_get_usage(); $start_time=microtime(true); - $script=noalyss_str_replace('../', '', $script); $description=$http->get("description","string", "aucune description"); echo '

'.$script."

"; echo '

description = '.$description.'

'; - include '../scenario/'.$script; + include $script; $end_mem=memory_get_usage(); $end_time=microtime(true); @@ -225,4 +276,4 @@ else echo "

Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes "; echo '

'; echo "

Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes

"; -} \ No newline at end of file +} diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php index 7e0dcf1f7..466ab6aae 100644 --- a/include/ajax/ajax_card.php +++ b/include/ajax/ajax_card.php @@ -326,7 +326,8 @@ case 'st': $r.=''.h($array[$i]['fd_label']).''; $r.=''; $r.=''; - $r.=''.h($array[$i]['fd_description'])."($nb_count)".''; + $r.=''.h + ($array[$i]['fd_description'])."($nb_count)".''; $r.=''; $r.=""; @@ -342,7 +343,7 @@ case 'st': } $xml=escape_xml($html); - header('Content-type: text/xml; charset=UTF-8'); +if (!defined("TEST_UNIT")) header('Content-type: text/xml; charset=UTF-8'); echo << diff --git a/include/ajax/ajax_display_letter.php b/include/ajax/ajax_display_letter.php index bfd8d391a..d52330045 100644 --- a/include/ajax/ajax_display_letter.php +++ b/include/ajax/ajax_display_letter.php @@ -231,7 +231,8 @@ $html.=$date_error; // echo $html;exit; $html=escape_xml($html); -header('Content-type: text/xml; charset=UTF-8'); +if (! defined('TEST_UNIT')) + header('Content-type: text/xml; charset=UTF-8'); echo << diff --git a/include/ajax/ajax_ledger.php b/include/ajax/ajax_ledger.php index d130998ee..60e2cff5d 100644 --- a/include/ajax/ajax_ledger.php +++ b/include/ajax/ajax_ledger.php @@ -94,8 +94,6 @@ if ($ledger == "") { $html = escape_xml($html); if (!headers_sent()) { header('Content-type: text/xml; charset=UTF-8'); - } else { - echo "HTML" . unescape_xml($html); } echo << @@ -397,7 +395,7 @@ switch ($action) { ', array($jr_id)); $cn->exec_sql("select comptaproc.jrn_add_note($1,$2)", array($jr_id, $http->post('jrn_note'))); - $rapt = $_POST['rapt']; + $rapt = $http->post('rapt'); if ($g_parameter->MY_UPDLAB == 'Y' && isset ($_POST['j_id'])) { $a_rowid = $http->post("j_id"); @@ -486,7 +484,7 @@ switch ($action) { case 'ask_extdate': $date = new IDate('p_date'); $html .= "
"; - $html .= HtmlInput::hidden('jr_id', $_REQUEST['jr_id']) . + $html .= HtmlInput::hidden('jr_id', $http->request('jr_id','number')) . HtmlInput::hidden('div', $div) . dossier::hidden() . HtmlInput::hidden('act', 'reverseop'); @@ -543,10 +541,9 @@ switch ($action) { $html = escape_xml($html); if (!headers_sent()) { header('Content-type: text/xml; charset=UTF-8'); -} else { - echo "HTML" . unescape_xml($html); } + echo << diff --git a/include/ajax/ajax_search_operation.php b/include/ajax/ajax_search_operation.php index afc86d173..6f42d7591 100644 --- a/include/ajax/ajax_search_operation.php +++ b/include/ajax/ajax_search_operation.php @@ -18,8 +18,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Copyright Author Dany De Bontridder danydb@aevalys.eu -/*! \file +/*! + * \file * \brief Search module + * \see javascript search_reconcile + +\param dossier_id int in $_GET dossier id needed to connect to the right folder +\param ctlc in $_GET string of DOM ID that receives the result when operation is selected +\param tiers in $_GET +\param amount_id float in $_GET amount to search +\param target in $_GET element to update +\param hide_operation in $_GET +\param single_operation in $_GET + */ + +/** + * @var $op comes from $_GET['op'] , that is the parameter from ajax to select the action (route) to perform. + * @var $g_user type of Noalyss_User , connected user */ if (!defined('ALLOWED')) die('Appel direct ne sont pas permis'); @@ -35,6 +50,7 @@ $cn=Dossier::connect(); $base=basename($_SERVER['PHP_SELF']); + $inside=false; $tiers=$http->get("tiers", "string", ""); // With the amount id, we find the amount in a html elt @@ -83,7 +99,8 @@ if (isset($_GET['amount_min'])&&isset($_GET['amount_max'])&&($_GET['amount_max'] ); } //----------------------------------------------------- -// Display search result +// Display search result, value from the search FORM +// //----------------------------------------------------- if (isset($_GET['viewsearch'])) { diff --git a/include/anc_pa.inc.php b/include/anc_pa.inc.php index b77026234..5dfc4c0f6 100644 --- a/include/anc_pa.inc.php +++ b/include/anc_pa.inc.php @@ -120,7 +120,7 @@ if ($sa=="pa_detail") $ret.=HtmlInput::submit('export_analytic_axis',_("Export CSV")); $ret.=''; $ret.=HtmlInput::button_anchor(_('Efface ce plan'), '', 'remove_analytic_plan', - 'onclick="return confirm_box(\'remove_analytic_plan\',\'Effacer ?\',function () {window.location=\'do.php?ac='.$_REQUEST['ac'].'&pa_id='.$_GET['pa_id'].'&sa=pa_delete&'.$str_dossier.'\';})"', + 'onclick="return confirm_box(\'remove_analytic_plan\',\'Effacer ?\',function () {window.location=\'do.php?ac='.$http->request('ac').'&pa_id='.$http->get('pa_id','number').'&sa=pa_delete&'.$str_dossier.'\';})"', 'smallbutton'); $ret.=''; diff --git a/include/bank.inc.php b/include/bank.inc.php index 61017cc98..a0db678e7 100644 --- a/include/bank.inc.php +++ b/include/bank.inc.php @@ -93,7 +93,7 @@ if ( $low_action == "list" ) ?> - + show_list(); -$js=sprintf("onclick=\"show_tag('%s','%s','%s','p')\"", Dossier::id(), $_REQUEST['ac'], '-1'); +$js=sprintf("onclick=\"show_tag('%s','%s','%s','p')\"", Dossier::id(), $http->request('ac'), '-1'); echo HtmlInput::button("tag_add", "Création étiquette", $js); ?> diff --git a/include/class/acc_account_ledger.class.php b/include/class/acc_account_ledger.class.php index 2e3aa4079..ec62751e7 100644 --- a/include/class/acc_account_ledger.class.php +++ b/include/class/acc_account_ledger.class.php @@ -634,6 +634,7 @@ class Acc_Account_Ledger */ static function HtmlTableHeader($actiontarget="poste") { + $http=new \HttpInput(); switch($actiontarget) { case 'poste': @@ -651,13 +652,13 @@ class Acc_Account_Ledger echo ""; echo ''; - $str_ople=(isset($_REQUEST['ople']))?HtmlInput::hidden('ople',$_REQUEST['ople']):''; + $str_ople=(isset($_REQUEST['ople']))?HtmlInput::hidden('ople',$http->request('ople')):''; if ($actiontarget=='poste') { echo '"; + $hid->input("type","poste").$hid->input('ac',$http->request('ac')).""; } $id=uniqid("pdf_"); @@ -668,21 +669,21 @@ class Acc_Account_Ledger HtmlInput::hidden('act',$action_pdf). $hid->input("type","poste").$str_ople. $hid->input('p_action','impress'). - $hid->input("from_periode",$_REQUEST['from_periode']). - $hid->input("to_periode",$_REQUEST['to_periode']) + $hid->input("from_periode",$http->request('from_periode')). + $hid->input("to_periode",$http->request('to_periode')) ; if ( isset($_REQUEST['letter'] )) echo HtmlInput::hidden('letter','2'); if ( isset($_REQUEST['solded'] )) echo HtmlInput::hidden('solded','1'); if (isset($_REQUEST['from_poste'])) - echo HtmlInput::hidden('from_poste',$_REQUEST['from_poste']); + echo HtmlInput::hidden('from_poste',$http->request('from_poste')); if (isset($_REQUEST['to_poste'])) - echo HtmlInput::hidden('to_poste',$_REQUEST['to_poste']); + echo HtmlInput::hidden('to_poste',$http->request('to_poste')); if (isset($_REQUEST['poste_id'])) - echo HtmlInput::hidden("poste_id",$_REQUEST['poste_id']); + echo HtmlInput::hidden("poste_id",$http->request('poste_id')); if (isset($_REQUEST['poste_fille'])) echo $hid->input('poste_fille','on'); @@ -697,17 +698,17 @@ class Acc_Account_Ledger HtmlInput::hidden('act',$action_csv). $hid->input("type","poste").$str_ople. $hid->input('p_action','impress'). - $hid->input("from_periode",$_REQUEST['from_periode']). - $hid->input("to_periode",$_REQUEST['to_periode']); + $hid->input("from_periode",$http->request('from_periode')). + $hid->input("to_periode",$http->request('to_periode')); if (isset($_REQUEST['from_poste'])) - echo HtmlInput::hidden('from_poste',$_REQUEST['from_poste']); + echo HtmlInput::hidden('from_poste',$http->request('from_poste')); if (isset($_REQUEST['to_poste'])) - echo HtmlInput::hidden('to_poste',$_REQUEST['to_poste']); + echo HtmlInput::hidden('to_poste',$http->request('to_poste')); if (isset($_REQUEST['poste_id'])) - echo HtmlInput::hidden("poste_id",$_REQUEST['poste_id']); + echo HtmlInput::hidden("poste_id",$http->request('poste_id')); if ( isset($_REQUEST['letter'] )) echo HtmlInput::hidden('letter','2'); if ( isset($_REQUEST['solded'] )) echo HtmlInput::hidden('solded','1'); @@ -716,7 +717,7 @@ class Acc_Account_Ledger echo $hid->input('poste_fille','on'); if (isset($_REQUEST['oper_detail'])) echo $hid->input('oper_detail','on'); - if (isset($_REQUEST['poste_id'])) echo $hid->input("poste_id",$_REQUEST['poste_id']); + if (isset($_REQUEST['poste_id'])) echo $hid->input("poste_id",$http->request('poste_id')); echo ""; echo ''; + /* check there is no other row for this one like TVA_ND */ + /** + * @var $anl_extra array of rows from operation_analytique concerning the current record + * + */ + $anl_extra=$cn->get_array('select distinct j1.f_id, + o1.j_id j_id_anx, + j1.j_poste, + j1.j_debit, + j1.j_montant + from operation_analytique o1 + join jrnx j1 on (o1.j_id=j1.j_id) + where oa_jrnx_id_source = $1', + [$q['j_id']]); + if (count($anl_extra) > 0) + { + foreach ($anl_extra as $item_anl_extra) { + + $anc_op = new Anc_Operation($cn); + $anc_op->j_id =$item_anl_extra['j_id_anx']; + $anc_op->in_div=uniqid(); + $side=($item_anl_extra['j_debit'] == 'f')?'C':'D'; + $n=""; + if ( $item_anl_extra['f_id'] != "") { + $n=$cn->get_value('select ad_value from fiche_detail + where + f_id =$1 + and ad_id=$2' + ,[$item_anl_extra['f_id'],ATTR_DEF_QUICKCODE]); + } + + /* compute total price */ + bcscale(2); + $str_anc.=''; + $str_anc.=td($n); + $str_anc.=td($item_anl_extra['j_poste']); + + $str_anc.=td(nbm($item_anl_extra['j_montant'])." {$side}"); + $str_anc.=$anc_op->display_table(0, $htva, $anc_op->in_div); + + $str_anc.=''; + } + + } + } } $class=($e%2==0)?' class="even"':'class="odd"'; /* diff --git a/include/template/ledger_search.php b/include/template/ledger_search.php index 6a8010f03..7aca0e803 100644 --- a/include/template/ledger_search.php +++ b/include/template/ledger_search.php @@ -1,10 +1,31 @@ +
'. dossier::hidden(). HtmlInput::submit('bt_other',"Autre poste"). - $hid->input("type","poste").$hid->input('ac',$_REQUEST['ac'])."
'; diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 51fc616f2..ca9223c9f 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -22,12 +22,13 @@ require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; require_once NOALYSS_INCLUDE.'/database/jrn_def_sql.class.php'; require_once NOALYSS_INCLUDE.'/database/operation_currency_sql.class.php'; -/** \file +/** + * \file * @brief Class for jrn, class acc_ledger for manipulating the ledger */ /** - * @class + * @class Acc_Ledger * @brief Class for jrn, class acc_ledger for manipulating the ledger AND some acc. operations * */ @@ -45,6 +46,7 @@ class Acc_Ledger extends jrn_def_sql /** + * @brief construct * @param $p_cn database connexion * @param $p_id jrn.jrn_def_id */ @@ -896,7 +898,7 @@ class Acc_Ledger extends jrn_def_sql $add_js=""; if ($g_parameter->MY_PJ_SUGGEST !='N') { - $add_js="update_pj();"; + $add_js="update_receipt();"; } if ($g_parameter->MY_DATE_SUGGEST=='Y') { diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index 394284953..153000c69 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -311,7 +311,7 @@ class Acc_Ledger_Fin extends Acc_Ledger if ($g_parameter->MY_DATE_SUGGEST=='Y') $onchange.='get_last_date();'; if ($g_parameter->MY_PJ_SUGGEST=='Y') - $onchange.='update_pj();'; + $onchange.='update_receipt();'; $add_js='onchange="'.$onchange.'"'; $wLedger=$this->select_ledger('FIN', 2, FALSE); diff --git a/include/class/acc_ledger_history.class.php b/include/class/acc_ledger_history.class.php index 38b2b8847..d244cb9f0 100644 --- a/include/class/acc_ledger_history.class.php +++ b/include/class/acc_ledger_history.class.php @@ -38,7 +38,7 @@ abstract class Acc_Ledger_History public $db; //!< database connx protected $ledger_type; //! type of ledger VEN , ACH , ODS, FIN protected $filter_operation; //!< to filter paid, unpaid or all operation - + protected $data; // Contains data see acc_ledger_history_financial->get_row /** * * @param Database $cn diff --git a/include/class/acc_ledger_history_generic.class.php b/include/class/acc_ledger_history_generic.class.php index 6bbabe3b1..53f5bcf2d 100644 --- a/include/class/acc_ledger_history_generic.class.php +++ b/include/class/acc_ledger_history_generic.class.php @@ -33,7 +33,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History { - private $data; //!< array of rows + /** * Constructor diff --git a/include/class/acc_ledger_history_purchase.class.php b/include/class/acc_ledger_history_purchase.class.php index 0dca3160f..3e03c08c0 100644 --- a/include/class/acc_ledger_history_purchase.class.php +++ b/include/class/acc_ledger_history_purchase.class.php @@ -32,8 +32,6 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History { - private $data;//!< Contains rows from SQL - /** * @param mixed $data */ diff --git a/include/class/acc_ledger_history_sale.class.php b/include/class/acc_ledger_history_sale.class.php index 0240db9b1..0b3b80208 100644 --- a/include/class/acc_ledger_history_sale.class.php +++ b/include/class/acc_ledger_history_sale.class.php @@ -31,8 +31,7 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History { - private $data; //!< Contains rows from SQL - + public function __construct(\Database $cn, $pa_ledger, $p_from, $p_to, $p_mode) diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index ad114e14f..6c1c6031c 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -19,27 +19,32 @@ // Copyright Author Dany De Bontridder danydb@aevalys.eu -/*!\file +/*! + * \file * \brief class for the purchase, herits from acc_ledger */ require_once NOALYSS_INCLUDE.'/lib/user_common.php'; require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; -/*!\brief Handle the ledger of purchase, +/*! + * \class Acc_Ledger_Purchase + * \brief Handle the ledger of purchase, * * */ class Acc_Ledger_Purchase extends Acc_Ledger { private $payment_operation; /*ledger_type='ACH'; parent::__construct($p_cn,$p_init); $this->payment_operation=-1; } - /*!\brief verify that the data are correct before inserting or confirming + /*! + * \brief verify that the data are correct before inserting or confirming *\param an array (usually $_POST) *\return String *\throw Exception if an error occurs @@ -472,7 +477,8 @@ class Acc_Ledger_Purchase extends Acc_Ledger } } - /*!\brief insert into the database, it calls first the verify function + /*! + * \brief insert into the database, it calls first the verify function * change the value of this->jr_id and this->jr_internal. * It generates the document and save the middle of payment, if 'gen_invoice is set * and e_mp @@ -548,19 +554,36 @@ class Acc_Ledger_Purchase extends Acc_Ledger try { bcscale(4); - // total amount of the purchase + // variable : $tot_amount float : total amount of the purchase (debit) $tot_amount=0; + // variable : $tot_tva float : total amount of the VAT $tot_tva=0; + $tot_debit=0; $this->db->start(); + // variable : $tot_nd float total not Deductible $tot_nd=0; + // variable : $tot_perso float total private amount $tot_perso=0; + // variable : $tot_tva_nd float total vat not deductible $tot_tva_nd=0; + + // variable : $tot_tva_ndded float total vat not deductible - deductible via another tax $tot_tva_ndded=0; - $tot_tva_reversed=0; + + $tot_tva_reversed=0; //@todo to remove + + // variable : $tva array that will contain all the VAT Amount $tva=array(); + + // variable : $tva_reverse array that contain all the VAT autoreverse AND negative + $tva_reverse = array(); + + // variable : $tot_amount_cur : total amount in currency $tot_amount_cur=0; + // find the currency from v_currency_last_value + // variable : $currency_rate_ref Acc_Currency , currency object for this operation $currency_rate_ref=new Acc_Currency($this->db, $p_currency_code); /* Save all the items without vat and no deductible vat and expense*/ @@ -571,7 +594,8 @@ class Acc_Ledger_Purchase extends Acc_Ledger /* First we save all the items without vat */ $fiche=new Fiche($this->db); $fiche->get_by_qcode(${"e_march".$i}); - $tva_both=0; + // variable : $tva_both integer 1 for autoreverse ,0 normal, fetch it once for this item, + $tva_both=0; /* tva */ if ($g_parameter->MY_TVA_USE=='Y') { @@ -676,13 +700,14 @@ class Acc_Ledger_Purchase extends Acc_Ledger if ( $g_parameter->MY_TVA_USE=='Y') { $tva_item=$acc_amount->amount_vat; - - if (isset($tva[$idx_tva])) - { + $tva[$idx_tva]=(isset( $tva[$idx_tva]))? $tva[$idx_tva]:0; + if ($tva_both == 0 || $tva_item >= 0){ $tva[$idx_tva]=bcadd($tva[$idx_tva], $tva_item); + }else { + // $tva_item < 0 && $tva_both == 1 + $tva_reverse[$idx_tva]=(isset($tva_reverse[$idx_tva]))?$tva_reverse[$idx_tva]:0; + $tva_reverse[$idx_tva]=bcadd($tva_item,$tva_reverse[$idx_tva]); } - else - $tva[$idx_tva]=$tva_item; } /* Save the stock */ /* if the quantity is < 0 then the stock increase (return of @@ -853,8 +878,6 @@ class Acc_Ledger_Purchase extends Acc_Ledger foreach ($tva as $i => $value) { $oTva=Acc_Tva::build($this->db,$i); - $oTva->load(); - $poste_vat=$oTva->get_side('d'); $cust_amount=round(bcadd($tot_amount,$tot_tva),2); @@ -867,12 +890,15 @@ class Acc_Ledger_Purchase extends Acc_Ledger $acc_operation->type='d'; $acc_operation->periode=$tperiode; if ( $value > 0 ) $tot_debit=bcadd($tot_debit,abs($value)); + if ( $oTva->get_parameter("both_side") == 1 && $value ==0 ) continue; $acc_operation->insert_jrnx(); // if TVA is on both side, we deduce it immediately if ( $oTva->get_parameter("both_side")==1 ) { - $poste_vat=$oTva->get_side('c'); + // $x temp variable is the tva_reverse_account and will be used to check $poste_vat + $x=$oTva->get_parameter("tva_reverse_account"); + $poste_vat =(trim($x??"")=="")? $oTva->get_side('c'):$x; if ( $poste_vat == '#') { $poste_vat=$oTva->get_side('d'); @@ -880,16 +906,54 @@ class Acc_Ledger_Purchase extends Acc_Ledger $acc_operation=new Acc_Operation($this->db); $acc_operation->date=$e_date; $acc_operation->poste=$poste_vat; - $acc_operation->amount=$tot_tva_reversed; + $acc_operation->amount=$value; $acc_operation->grpt=$seq; $acc_operation->jrn=$p_jrn; $acc_operation->type='c'; $acc_operation->periode=$tperiode; $acc_operation->insert_jrnx(); - if ( $value < 0 ) $tot_debit=bcadd($tot_debit,abs($value)); + //if ( $value < 0 ) $tot_debit=bcadd($tot_debit,abs($value)); } - } + } // LOOP : foreach $tva + foreach ($tva_reverse as $i => $value) { + $oTva = Acc_Tva::build($this->db,$i); + $poste_vat = $oTva->get_side('d'); + if ( $poste_vat == '#') + { + $poste_vat=$oTva->get_side('c'); + } + + $acc_operation = new Acc_Operation($this->db); + $acc_operation->date = $e_date; + $acc_operation->poste = $poste_vat; + $acc_operation->amount = $value; + $acc_operation->grpt = $seq; + $acc_operation->jrn = $p_jrn; + $acc_operation->type = 'd'; + $acc_operation->periode = $tperiode; + + $acc_operation->insert_jrnx(); + + // if TVA is on both side, we deduce it immediately + $poste_vat = $oTva->get_side('c'); + if ( $poste_vat == '#') + { + $poste_vat=$oTva->get_side('d'); + } + $acc_operation = new Acc_Operation($this->db); + $acc_operation->date = $e_date; + $acc_operation->poste = $poste_vat; + $acc_operation->amount = $value; + $acc_operation->grpt = $seq; + $acc_operation->jrn = $p_jrn; + $acc_operation->type = 'c'; + $acc_operation->periode = $tperiode; + $acc_operation->insert_jrnx(); + $tot_debit = bcadd($tot_debit, $value); + $tot_debit = round($tot_debit, 2); + $n_both = $value; + } //LOOP: foreach $tva_reverse } /* insert into jrn */ @@ -1015,7 +1079,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $acc_pay->grpt=$acseq; $acc_pay->jrn=$mp->get_parameter('ledger_target'); $acc_pay->periode=$tperiode; - $acc_pay->type=($famount>=0)?'d':'c'; + $acc_pay->type=($famount>=0)?'d':'c'; $let_other=$acc_pay->insert_jrnx(); // insert into operation_currency @@ -1057,11 +1121,11 @@ class Acc_Ledger_Purchase extends Acc_Ledger $r1=$this->get_id($internal); $r2=$this->get_id($acinternal); - /* - * add lettering - */ - $oletter=new Lettering($this->db); - $oletter->insert_couple($let_client,$let_other); + /* + * add lettering + */ + $oletter=new Lettering($this->db); + $oletter->insert_couple($let_client,$let_other); /* set the flag paid */ $Res=$this->db->exec_sql("update jrn set jr_rapt='paid' where jr_id=$1",array($r1)); @@ -1225,7 +1289,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $add_js=""; if ( $g_parameter->MY_PJ_SUGGEST !='N') { - $add_js="update_pj();"; + $add_js="update_receipt();"; } if ($g_parameter->MY_DATE_SUGGEST == 'Y') { @@ -1518,7 +1582,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger /* if we suggest the pj n# the run the script */ if ( $g_parameter->MY_PJ_SUGGEST !='N') { - $r.=''; + $r.=''; } // set focus on date $r.= create_script("$('".$Date->id."').focus()"); diff --git a/include/class/acc_ledger_sale.class.php b/include/class/acc_ledger_sale.class.php index 2f57664fe..1888669fc 100644 --- a/include/class/acc_ledger_sale.class.php +++ b/include/class/acc_ledger_sale.class.php @@ -300,21 +300,28 @@ class Acc_Ledger_Sale extends Acc_Ledger { bcscale(4); try { - // total amount of the sales (credit) + // variable : $tot_amount : total amount of the sales (credit) $tot_amount = 0; - // total amount of the VAT + // variable : $tot_tva : total amount of the VAT $tot_tva = 0; // tot debit if item's amount < 0 $tot_debit = 0; - // total amount in currency + // variable : $tot_amount_cur : total amount in currency $tot_amount_cur=0; $this->db->start(); + // variable : $tva array that will contain all the VAT Amount $tva = array(); + // variable : $tva_reverse array that contain all the VAT autoreverse AND negative + $tva_reverse = array(); + // find the currency from v_currency_last_value + // variable : $currency_rate_ref Acc_Currency , currency object for this operation $currency_rate_ref=new Acc_Currency($this->db, $p_currency_code); + /* Save all the items without vat */ for ($i = 0; $i < $nb_item; $i++) { + // variable : $n_both float auto-reverse amount $n_both = 0; if ( empty(${'e_march'.$i}) || empty(${'e_quant'.$i}) ) continue; @@ -328,7 +335,6 @@ class Acc_Ledger_Sale extends Acc_Ledger { $tot_amount = bcadd($tot_amount, $amount); $tot_amount = round($tot_amount, 2); - if ( DEBUGNOALYSS > 1 ) { echo __LINE__." tot_amount $tot_amount
";} $acc_operation = new Acc_Operation($this->db); $acc_operation->date = $e_date; $sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT); @@ -367,39 +373,44 @@ class Acc_Ledger_Sale extends Acc_Ledger { if ($g_parameter->MY_TVA_USE == 'Y') { /* Compute sum vat */ $oTva = Acc_Tva::build($this->db, trim(${'e_march' . $i . '_tva_id'})); - $oTva->load(); $idx_tva =$oTva->get_parameter("id"); + // variable : $auto_reverse = if the oTVA autoreverse, fetch it once for this item, + $auto_reverse=$oTva->get_parameter("both_side"); $tva_item_currency = ${'e_march' . $i . '_tva_amount'}; /* if empty then we need to compute it */ if (trim($tva_item_currency) == '' || ${'e_march'.$i.'_tva_amount'} == 0) { - /* retrieve tva */ - $l = Acc_Tva::build($this->db, $idx_tva); - $l->load(); - $tva_item_currency = bcmul($amount, $l->get_parameter('rate')); - $tva_item=round($tva_item_currency,2); + $tva_item_currency = bcmul($amount, $oTva->get_parameter('rate')); + $tva_item=round($tva_item_currency,2); } $tva_item=bcdiv($tva_item_currency,$p_currency_rate); $tva_item=round($tva_item,2); - if (isset($tva[$idx_tva])) + + $tva[$idx_tva]=(isset($tva[$idx_tva]))?$tva[$idx_tva]:0; + + if ( $auto_reverse == 0) { $tva[$idx_tva]=bcadd($tva_item,$tva[$idx_tva]); $tva[$idx_tva]=round($tva[$idx_tva],2); + $tot_tva = bcadd($tva_item, $tot_tva); + $tot_tva = round($tot_tva, 2); } else { - $tva[$idx_tva]=$tva_item; - } - if ($oTva->get_parameter("both_side") == 0) { - $tot_tva = bcadd($tva_item, $tot_tva); - $tot_tva = round($tot_tva, 2); - } else { $n_both = $tva_item; $tva_item_currency = 0; if ($n_both<0) { $tot_debit=round(bcadd($tot_debit, abs($n_both)),2); + $tva_reverse[$idx_tva]=(isset($tva_reverse[$idx_tva]))?$tva_reverse[$idx_tva]:0; + $tva_reverse[$idx_tva]=bcadd($tva_item,$tva_reverse[$idx_tva]); + $tva_reverse[$idx_tva]=round($tva_reverse[$idx_tva],2); + + } else { + $tva[$idx_tva]=bcadd($tva_item,$tva[$idx_tva]); + $tva[$idx_tva]=round($tva[$idx_tva],2); + } } } @@ -548,20 +559,16 @@ class Acc_Ledger_Sale extends Acc_Ledger { $operation_currency->j_id=$let_tiers ; $operation_currency->insert(); - - /** save all vat + + /************************************************************************************************** + * save all vat * $i contains the tva_id and value contains the vat amount * if if ($g_parameter->MY_TVA_USE == 'Y' ) - */ + ************************************************************************************************** */ if ($g_parameter->MY_TVA_USE == 'Y') { - if ( DEBUGNOALYSS > 1 ) { - var_dump($tva); - } + foreach ($tva as $i => $value) { $oTva = Acc_Tva::build($this->db,$i); - - $oTva->load(); - $poste_vat = $oTva->get_side('c'); $cust_amount = bcadd($tot_amount, $tot_tva); @@ -578,14 +585,16 @@ class Acc_Ledger_Sale extends Acc_Ledger { $tot_debit=bcadd($tot_debit, abs($value)); $tot_debit=round($tot_debit, 2); } + if ( $oTva->get_parameter("both_side") == 1 && $value ==0 ) continue; $acc_operation->insert_jrnx(); - if ( DEBUGNOALYSS > 1 ) { - echo __LINE__." tot_tva $tot_tva
"; - } // if TVA is on both side, we deduce it immediately - if ($oTva->get_parameter("both_side") == 1) { - $poste_vat = $oTva->get_side('d'); + if ($oTva->get_parameter("both_side") == 1 ) { + // $x temp variable is the tva_reverse_account and will be used to check $poste_vat + $x=$oTva->get_parameter("tva_reverse_account"); + + $poste_vat =(trim($x??"")=="")? $oTva->get_side('d'):$x; + if ($poste_vat == '#') $poste_vat=$oTva->get_side('c'); $cust_amount = bcadd($tot_amount, $tot_tva); $acc_operation = new Acc_Operation($this->db); $acc_operation->date = $e_date; @@ -600,7 +609,52 @@ class Acc_Ledger_Sale extends Acc_Ledger { $tot_debit = round($tot_debit, 2); $n_both = $value; } + } + foreach ($tva_reverse as $i => $value) { + $oTva = Acc_Tva::build($this->db,$i); + $poste_vat = $oTva->get_side('c'); + if ( $poste_vat == '#') + { + $poste_vat=$oTva->get_side('d'); + } + + $acc_operation = new Acc_Operation($this->db); + $acc_operation->date = $e_date; + $acc_operation->poste = $poste_vat; + $acc_operation->amount = $value; + $acc_operation->grpt = $seq; + $acc_operation->jrn = $p_jrn; + $acc_operation->type = 'c'; + $acc_operation->periode = $tperiode; + if ($value<0) + { + $tot_debit=bcadd($tot_debit, abs($value)); + $tot_debit=round($tot_debit, 2); + } + $acc_operation->insert_jrnx(); + + // if TVA is on both side, we deduce it immediately + $poste_vat = $oTva->get_side('d'); + if ( $poste_vat == '#') + { + $poste_vat=$oTva->get_side('c'); + } + $acc_operation = new Acc_Operation($this->db); + $acc_operation->date = $e_date; + $acc_operation->poste = $poste_vat; + $acc_operation->amount = $value; + $acc_operation->grpt = $seq; + $acc_operation->jrn = $p_jrn; + $acc_operation->type = 'd'; + $acc_operation->periode = $tperiode; + $acc_operation->insert_jrnx(); + $tot_debit = bcadd($tot_debit, $value); + $tot_debit = round($tot_debit, 2); + $n_both = $value; + + } + } // if ($g_parameter->MY_TVA_USE=='Y') /* * Balance the amount on D and C , the difference must be inserted as "difference due to a rounded value" @@ -1366,7 +1420,7 @@ EOF; /* if we suggest the next pj, then we need a javascript */ $add_js = ""; if ($g_parameter->MY_PJ_SUGGEST != 'N') { - $add_js = "update_pj();"; + $add_js = "update_receipt();"; } if ($g_parameter->MY_DATE_SUGGEST == 'Y') { $add_js.='get_last_date();'; diff --git a/include/class/acc_ledger_search.class.php b/include/class/acc_ledger_search.class.php index d94dd2a37..2a25e2fbc 100644 --- a/include/class/acc_ledger_search.class.php +++ b/include/class/acc_ledger_search.class.php @@ -35,10 +35,10 @@ class Acc_Ledger_Search protected $cn; //!< Database Connection private $type; //!< type of ledger : FIN,ODS,VEN,ACH - private $all; //!< Flag to indicate if all ledgers must searched (1 for yes) - private $div; //! prefix for id of DOM id - //! id of the ledger - var $id ; + private $all; //!< Flag to indicate if all ledgers must be searched (1 for yes) + private $div; //!< prefix for id of DOM id + var $id ; //!< id of the ledger + /** * @brief return a HTML string with the form for the search * @param $p_type if the type of ledger possible values=ALL,VEN,ACH,ODS,FIN: uppercase ! @@ -47,9 +47,9 @@ class Acc_Ledger_Search * - 1 means all the ledger of this type * - 0 No have the "Tous les journaux" availables * @param $div is the div (for reconciliation) - * @param type $p_type - * @param type $p_all - * @param type $p_div + * @param string $p_type ACH, VEN , ODS or FIN + * @param int $p_all 1 means all the ledger + * @param string $p_div prefix of the DOM ID * * @todo the parameter $all_type_ledger is useless : ALL means all the ledgers, VEN all the ledger of sales... */ @@ -258,7 +258,7 @@ class Acc_Ledger_Search } /** - * Build the button for managing the filter for search + * @brief Build the button for managing the filter for search * @param type $p_div id prefix of the div, button, table .. * @param $this->type if the type of ledger possible values=ALL,VEN,ACH,ODS,FIN * @param $all_type_ledger diff --git a/include/class/acc_operation.class.php b/include/class/acc_operation.class.php index a09581c95..08c332870 100644 --- a/include/class/acc_operation.class.php +++ b/include/class/acc_operation.class.php @@ -860,9 +860,12 @@ EOF; $cn=Dossier::connect(); $g_user=new Noalyss_user($cn); $a=new Acc_Operation($cn); - $a->jr_id=1444; + $a->jr_id=993; $b=$a->get_quant(); + echo h1('contain of get_quant() '); var_dump($b); + echo h1('contain of get_jrnx_detail()'); + var_dump($a->get_jrnx_detail()); } /** * Return a select object to choose the type of operation diff --git a/include/class/acc_operation_note.class.php b/include/class/acc_operation_note.class.php index 9a2638347..c6188b6e8 100644 --- a/include/class/acc_operation_note.class.php +++ b/include/class/acc_operation_note.class.php @@ -25,7 +25,7 @@ */ /*! - * \class + * \class Acc_Operation_Note * \brief Manage the note attached to an operation */ diff --git a/include/class/acc_tva.class.php b/include/class/acc_tva.class.php index d9fcf4d28..43a66b9b7 100644 --- a/include/class/acc_tva.class.php +++ b/include/class/acc_tva.class.php @@ -41,13 +41,17 @@ class Acc_Tva "comment"=>"tva_comment", "account"=>"tva_poste", "both_side"=>'tva_both_side', - 'tva_code'); + 'tva_reverse_account'=>'tva_reverse_account', + 'tva_code'=>'tva_code'); public $tva_id, $tva_label, $tva_rate, $tva_comment, $tva_poste, - $tva_both_side,$tva_code; + $tva_both_side, + $tva_code, + $tva_reverse_account; + private $cn; //!< Database connection private Tva_Rate_SQL $tva_rate_sql; @@ -63,6 +67,7 @@ class Acc_Tva $this->tva_poste=&$this->tva_rate_sql->tva_poste; $this->tva_both_side=&$this->tva_rate_sql->tva_both_side; $this->tva_code=&$this->tva_rate_sql->tva_code; + $this->tva_reverse_account=&$this->tva_rate_sql->tva_reverse_account; } /** @@ -90,7 +95,7 @@ class Acc_Tva return $this->$idx; } - echo (__FILE__.":".__LINE__.'Erreur attribut inexistant'); + echo (__FILE__.":".__LINE__."AT97:Erreur attribut inexistant [$p_string]"); } public function set_parameter($p_string,$p_value) { diff --git a/include/class/admin.class.php b/include/class/admin.class.php index e22468b5b..a90254638 100644 --- a/include/class/admin.class.php +++ b/include/class/admin.class.php @@ -40,7 +40,7 @@ class Admin extends Fiche var $vat_number; /*!< $vat_number vat number */ /*! \brief Constructor - /* only a db connection is needed */ + * only a db connection is needed */ function __construct($p_cn,$p_id=0) { $this->fiche_def_ref=FICHE_TYPE_ADM_TAX; diff --git a/include/class/anc_operation.class.php b/include/class/anc_operation.class.php index 49ff5aa44..ceb7cd033 100644 --- a/include/class/anc_operation.class.php +++ b/include/class/anc_operation.class.php @@ -717,16 +717,15 @@ EOF; return $result; } /** - * Save the ND VAT with prorata + * @brief Save the ND VAT in ANL, and distribute the amount among ANL Axis proportionnaly to the source * - * @param $p_array usually $_POST - * @param $p_item item of the form - * @param $p_j_id jrnx.j_id concerned writing - * @param $p_nd amount nd vat - * @see Anc_Operation::save_form_plan_vat_nd - * @return type + * @param $p_array array usually $_POST + * @param $p_item int nb of the item of the form + * @param $p_j_id int jrnx.j_id concerned writing + * @param $p_nd float amount nd vat + * @see Anc_Operation::save_form_plan() */ - function save_form_plan_vat_nd($p_array,$p_item,$p_j_id,$p_nd) + function save_form_plan_vat_nd($p_array,$p_item,$p_j_id,$p_nd):void { bcscale(4); extract($p_array, EXTR_SKIP); @@ -734,18 +733,16 @@ EOF; if ( ! isset(${'amount_t'.$p_item}) ) throw new Exception ('amount not set'); - - $tot=0; - /* variable for in array - pa_id array of existing pa_id - hplan double array with the pa_id (column) - val double array by row with amount - op contains sequence - p_item is used to identify what op is concerned + + /** + * variable for in array + * @var pa_id array of existing pa_id + @var hplan double array with the pa_id as key (column) + @var val double array by row with amount + * @var op contains sequence + @var p_item is used to identify what op is concerned */ - /* echo "j_id = $j_id p_item = $p_item hplan=".var_export($hplan[$p_item],true)." val = ".var_export($val[$p_item],true).'
'; */ - /* for each row */ - // for ($i=0;$ioa_amount); - } -// utilité ??? -// if ( $tot != $p_nd && count($a_Anc_Operation) > 0 ) -// { -// $diff= bcsub($tot, $p_nd); -// $a_Anc_Operation[0]->oa_amount=bcsub($a_Anc_Operation[0]->oa_amount,$diff); -// } + for ($i=0;$i<$nb_op;$i++) { $a_Anc_Operation[$i]->add(); } + } /*!\brief it called for each item, the data are taken from $p_array * data and set before in this. Amount will be transformed thanks the $this->currency_rate; diff --git a/include/class/anc_plan.class.php b/include/class/anc_plan.class.php index 5a0de039f..e4d841f4a 100644 --- a/include/class/anc_plan.class.php +++ b/include/class/anc_plan.class.php @@ -185,7 +185,7 @@ class Anc_Plan function exist() { $a=$this->db->count_sql("select pa_id from plan_analytique where pa_id=$1", - array($this->pa_id)); + array($this->id)); return ($a==0)?false:true; @@ -193,7 +193,7 @@ class Anc_Plan /** *@brief return an HTML string containing hidden input type to * hold the differant PA_ID - *@param $p_array contains a array, it is the result of the fct + *@param $p_array array contains a array, it is the result of the fct * Anc_Plan::get_list *@return html string *@see Anc_Plan::get_list diff --git a/include/class/anticipation.class.php b/include/class/anticipation.class.php index 9ed971254..1e43a1f14 100644 --- a/include/class/anticipation.class.php +++ b/include/class/anticipation.class.php @@ -25,7 +25,7 @@ * */ /** - * @class + * @class Anticipation * @brief Manage the anticipation of expense, sales,... * @see Forecast Forecast_Cat Forecast_Item * diff --git a/include/class/bank.class.php b/include/class/bank.class.php index cb77756fc..0ab215cb7 100644 --- a/include/class/bank.class.php +++ b/include/class/bank.class.php @@ -39,8 +39,7 @@ class Bank extends Fiche var $cp; /*!< $cp Zip code */ var $vat_number; /*!< $vat_number vat number */ - /*! \brief Constructor - /* only a db connection is needed */ + /*! \brief Constructor only a db connection is needed */ function __construct($p_cn,$p_id=0) { $this->fiche_def_ref=FICHE_TYPE_FIN; diff --git a/include/class/card_pdf.class.php b/include/class/card_pdf.class.php index 08a570ba3..366a51c30 100644 --- a/include/class/card_pdf.class.php +++ b/include/class/card_pdf.class.php @@ -5,7 +5,7 @@ * */ /** - * @class + * @class Card_PDF * @brief Class Card_PDF */ class Card_PDF extends \PDF diff --git a/include/class/customer.class.php b/include/class/customer.class.php index 1a16872b2..4217e04b1 100644 --- a/include/class/customer.class.php +++ b/include/class/customer.class.php @@ -39,7 +39,8 @@ class Customer extends Fiche var $vat_number; /*!< $vat_number vat number */ /*! \brief Constructor - /* only a db connection is needed */ + * only a db connection is needed + */ function __construct($p_cn,$p_id=0) { $this->fiche_def_ref=FICHE_TYPE_CLIENT; diff --git a/include/class/document_type.class.php b/include/class/document_type.class.php index 170e81e24..ee6c6a6d9 100644 --- a/include/class/document_type.class.php +++ b/include/class/document_type.class.php @@ -27,21 +27,24 @@ /** * @class Document_Type *@brief class for the table document_type , a document_type is a kind of action in the follow up - * - * < dt_id pk document_type - * < dt_value value */ class Document_Type { - /** document_type - * \brief constructor - * \param $p_cn database connx - */ + var $db; //!< Database Connection + var $dt_id; //!< primary key see SQL DOCUMENT_TYPE.DT_ID + var $dt_value; //!< description of the document see SQL DOCUMENT_TYPE.DT_VALUE + var $dt_prefix; //!< prefix for numbering see SQL DOCUMENT_TYPE.DT_PREFIX - function __construct($p_cn, $p_id = -1) + /** + * \brief + * \brief constructor document_type + * \param $p_cn database connx + * \param $dt_id primary key see SQL DOCUMENT_TYPE.DT_ID + */ + function __construct(\Database $p_cn, int $dt_id = -1) { $this->db = $p_cn; - $this->dt_id = $p_id; + $this->dt_id = $dt_id; } /** @@ -51,9 +54,9 @@ class Document_Type function get() { $sql = "select * from document_type where dt_id=$1"; - $R = $this->db->exec_sql($sql, array($this->dt_id)); - if ($this->db->count($R) == 0) return 1; - $r = Database::fetch_array($R, 0); + $r = $this->db->get_row($sql, array($this->dt_id)); + if ( $r == null ) return 1; + $this->dt_id = $r['dt_id']; $this->dt_value = $r['dt_value']; $this->dt_prefix = $r['dt_prefix']; @@ -72,6 +75,7 @@ class Document_Type $array = array(); for ($i = 0; $i < count($r); $i++) { + $tmp=array(); $tmp['dt_value'] = $r[$i]['dt_value']; $tmp['dt_prefix'] = $r[$i]['dt_prefix']; @@ -99,7 +103,7 @@ class Document_Type * Restart the increment of the document * @param type $p_int */ - function set_number($p_int) + function set_number(int $p_int) { try { @@ -107,8 +111,74 @@ class Document_Type } catch (Exception $e) { - record_log($e); alert("Erreur " . $e->getMessage()); } } + + function __toString(): string + { + return sprintf("dt_id : [%d] \n dt_value [%s] \n dt_prefix [%s]\n",$this->dt_id,$this->dt_value,$this->dt_prefix); + } + + /** + * @brief unit test for Document_Type + * @return void + */ + static function test_me() + { + // if (! defined('TEST_UNIT')) return; + $cn=Dossier::connect(); + function prv_echo_error($msg,int $lineno) { + print '

'; + print "ERROR : $lineno"; + print $msg; + print '

'; + } + // prepare test + $old_value=[]; + try { + $cn->start(); + $old_value[0]=$cn->get_row('select * from document_type where dt_id=$1',[8]); + $old_value[1]=$cn->get_row('select * from document_type where dt_id=$1',[6]); + + $cn->exec_sql("update document_type set dt_value='Email' where dt_id=$1",[6]); + $cn->exec_sql("update document_type set dt_prefix='PML' where dt_id=$1",[8]); + $document_type=new Document_Type($cn,8); + echo $document_type; + + if ( $document_type->get() == 1 ) { + } + + if ( $document_type->dt_prefix!='PML') { + prv_echo_error("PREFIX :". $document_type,__LINE__); + } + + $document_type->set_number(6); + $document_type->get(); + + if ( $document_type->dt_value!='Email') { + prv_echo_error("VALUE :". $document_type,__LINE__); + } + $list=Document_Type::get_list($cn); + + // list array > 1 and key =5 + if (count ($list) == 0) { + prv_echo_error("GET_LIST :EMPTY",__LINE__); + } else { + foreach (['js_mod','dt_id','dt_value','dt_prefix','js_remove'] as $key) { + if ( ! isset ($list[0][$key])) { + prv_echo_error ('NOT SET '.$key,__LINE__); + } else { + echo '
';
+                       var_dump( $list[0][$key]);
+                       echo '
'; + } + } + } + } catch (\Exception $e) { + prv_echo_error("EXCEPTION :". $document_type,__LINE__); + print_r($e->getTraceAsString()); + } + $cn->rollback(); + } } diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index c058174ad..6f0748dd5 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -34,7 +34,7 @@ require_once NOALYSS_INCLUDE.'/lib/user_common.php'; */ /** - * \class + * \class Follow_Up * \brief class_action for manipulating actions * action can be : *
    diff --git a/include/class/lettering.class.php b/include/class/lettering.class.php index 33b1fc1c1..ef970cad1 100644 --- a/include/class/lettering.class.php +++ b/include/class/lettering.class.php @@ -20,11 +20,13 @@ // Copyright Author Dany De Bontridder danydb@aevalys.eu -/* !\file +/*! + *\file * \brief letter the accounting entry (row level) */ /** + * @class * @brief mother class for the lettering by account and by card * use the tables jnt_letter, letter_deb and letter_cred * - "account"=>"account", => the accounting of the j_id (use by Lettering_Account) @@ -32,7 +34,14 @@ * - "start"=>"start", => date of the first day * - "end"=>"end", => date of the last day * - "sql_ledger"=>"sql_ledger" => the sql clause to filter on the available ledgers + * + * @see unit-test/include/class/acc_letterTest.php + * @see test scenario scenario/XML/ajax_display_letter.php */ + + + +#[\AllowDynamicProperties] class Lettering { @@ -50,6 +59,7 @@ class Lettering var $sql_ledger; var $object_type; var $content; + /** * constructor * @param $p_init resource to database @@ -351,7 +361,7 @@ class Lettering } /** - * show only the lettered records from jrnx + * @brief show only the lettered records from jrnx * it fills the array $this->content */ protected function show_lettered() @@ -366,7 +376,7 @@ class Lettering } /** - * show only the lettered records from jrnx + * @brief show only the lettered records from jrnx * it fills the array $this->content */ protected function show_lettered_diff() @@ -381,7 +391,7 @@ class Lettering } /** - * show only the not lettered records from jrnx + * @brief show only the not lettered records from jrnx * it fills the array $this->content */ protected function show_not_lettered() @@ -479,8 +489,12 @@ class Lettering } /** - * only for operation retrieved thanks a account (jrnx.j_poste) + *@class + * @brief only for operation retrieved thanks a account (jrnx.j_poste) * manage the accounting entries for a given account + * + * @see unit-test/include/class/acc_letterTest.php + * */ class Lettering_Account extends Lettering { @@ -493,7 +507,7 @@ class Lettering_Account extends Lettering } /** - * fills the this->content, datas are filtered thanks + * @brief fills the this->content, datas are filtered thanks * - fil_deb poss values t (debit), f(credit), ' ' (everything) * - fil_amount_max max amount * - fil_amount_min min amount @@ -548,7 +562,7 @@ class Lettering_Account extends Lettering } /** - * fills this->content with all the operation for the this->account(jrnx.j_poste) + * @brief fills this->content with all the operation for the this->account(jrnx.j_poste) */ public function get_all() { @@ -577,7 +591,7 @@ class Lettering_Account extends Lettering } /** - * same as get_all but only for lettered operation + * @brief same as get_all but only for lettered operation */ public function get_letter() { @@ -606,7 +620,7 @@ class Lettering_Account extends Lettering } /** - * same as get_all but only for lettered operation + *@brief same as get_all but only for lettered operation */ public function get_letter_diff() { @@ -637,7 +651,7 @@ class Lettering_Account extends Lettering } /** - * same as get_all but only for unlettered operation + *@brief same as get_all but only for unlettered operation */ public function get_unletter() { @@ -663,7 +677,8 @@ class Lettering_Account extends Lettering } /** - * only for operation retrieved thanks a quick_code + * @class + * @brief only for operation retrieved thanks a quick_code * manage the accounting entries for a given card */ class Lettering_Card extends Lettering @@ -683,7 +698,7 @@ class Lettering_Card extends Lettering } /** - * fills the this->content, datas are filtered thanks + *@brief fills the this->content, datas are filtered thanks * - fil_deb poss values t (debit), f(credit), ' ' (everything) * - fil_amount_max max amount * - fil_amount_min min amount @@ -743,7 +758,7 @@ class Lettering_Card extends Lettering } /** - * fills this->content with all the operation for the this->quick_code(j_qcode) + * @brief fills this->content with all the operation for the this->quick_code(j_qcode) */ public function get_all() { @@ -773,7 +788,7 @@ class Lettering_Card extends Lettering } /** - * same as get_all but only for lettered operation + * @brief same as get_all but only for lettered operation */ public function get_letter() { @@ -801,6 +816,10 @@ class Lettering_Card extends Lettering $this->content=$this->db->get_array($sql, array($this->quick_code, $this->start, $this->end)); } + /** + * @brief lettered operation with a different amount + * @return void + */ public function get_letter_diff() { $sql=" @@ -829,7 +848,7 @@ class Lettering_Card extends Lettering } /** - * same as get_all but only for unlettered operation + * @brief same as get_all but only for unlettered operation */ public function get_unletter() { @@ -852,7 +871,7 @@ class Lettering_Card extends Lettering } /** - * fill $this->content with the rows from this query + * @brief fill $this->content with the rows from this query * Columns are * - j_id, id of jrnx * - j_date, date opeation (yyyy.mm.dd) diff --git a/include/class/manager.class.php b/include/class/manager.class.php index 5a9a8ddaf..2dc9275e0 100644 --- a/include/class/manager.class.php +++ b/include/class/manager.class.php @@ -41,7 +41,7 @@ class Manager extends Fiche var $vat_number; /*!< $vat_number vat number */ /*! \brief Constructor - /* only a db connection is needed */ + * only a db connection is needed */ function __construct($p_cn,$p_id=0) { $this->fiche_def_ref=FICHE_TYPE_EMPL; diff --git a/include/class/noalyss_appearance.class.php b/include/class/noalyss_appearance.class.php index 27f7b3471..60fcf0a8d 100644 --- a/include/class/noalyss_appearance.class.php +++ b/include/class/noalyss_appearance.class.php @@ -25,7 +25,7 @@ */ /** - * @class + * @class Noalyss_Appearance * @brief Contains some parameters to change appearance of noalyss, the colors are saved * into the table parm_appearance */ @@ -35,7 +35,7 @@ class Noalyss_Appearance 'MENU1' => '#000074', 'BODY' => '#ffffff', 'MENU2' => '#3d3d87', - 'MENU1-SELECTED' => '#7191ea', + 'MENU1-SELECTED' => '#000074', 'TR-ODD'=>'#DCE7F5', 'TR-EVEN'=>'#ffffff', 'INNER-BOX'=>'#DCE1EF', @@ -170,9 +170,7 @@ class Noalyss_Appearance .nav-pills .nav-link { color: {$menu1_font} !important; } - .nav-link:hover { - background-color:{$menu1_selected}; - } + table.sortable, table.table_large, table.result ,table.resultfooter { color:{$font_table} !important; } diff --git a/include/class/operation_opening.class.php b/include/class/operation_opening.class.php index f727ec852..3d6f6b640 100644 --- a/include/class/operation_opening.class.php +++ b/include/class/operation_opening.class.php @@ -23,7 +23,7 @@ */ /** - * @class + * @class Operation_Opening * @brief Operation ouverture */ class Operation_Opening extends Operation_Exercice diff --git a/include/class/periode.class.php b/include/class/periode.class.php index dee39238e..77beb78b5 100644 --- a/include/class/periode.class.php +++ b/include/class/periode.class.php @@ -100,15 +100,21 @@ EOF; function is_closed() { if ($this->jrn_def_id!=0) + { + $sql="select status from jrn_periode ". - " where jrn_def_id=".$this->jrn_def_id. - " and p_id =".$this->p_id; + " where jrn_def_id=$2 ". + " and p_id = $1"; + $status=$this->cn->get_value($sql,[$this->p_id,$this->jrn_def_id]); + } else + { $sql="select p_closed as status from parm_periode ". " where ". - " p_id =".$this->p_id; - $res=$this->cn->exec_sql($sql); - $status=Database::fetch_result($res, 0, 0); + " p_id = $1"; + $status=$this->cn->get_value($sql,[$this->p_id]); + + } if ($status=='CL'||$status=='t'||$status=='CE') return 1; return 0; diff --git a/include/class/pre_operation.class.php b/include/class/pre_operation.class.php index 366b9790c..1b542736f 100644 --- a/include/class/pre_operation.class.php +++ b/include/class/pre_operation.class.php @@ -518,7 +518,7 @@ class Pre_operation } /*! -@class +@class Pre_operation_detail @brief mother of the pre_op_XXX, it contains only one data : an * object Pre_Operation. The child class contains an array of * Pre_Operation object diff --git a/include/class/supplier.class.php b/include/class/supplier.class.php index 8a2fe14c9..da64ccf43 100644 --- a/include/class/supplier.class.php +++ b/include/class/supplier.class.php @@ -39,7 +39,7 @@ class Supplier extends Fiche var $vat_number; /*!< $vat_number vat number */ /*! \brief Constructor - /* only a db connection is needed */ + * only a db connection is needed */ function __construct($p_cn,$p_id=0) { $this->fiche_def_ref=FICHE_TYPE_FOURNISSEUR; diff --git a/include/class/tax_summary.class.php b/include/class/tax_summary.class.php index 7417034ff..dffb954ac 100644 --- a/include/class/tax_summary.class.php +++ b/include/class/tax_summary.class.php @@ -136,26 +136,45 @@ class Tax_Summary ) "; $cnt=$this->db->get_value($sql, [$this->date_start, $this->date_end]); - if ($cnt==0) + $cnt_ledger=$this->db->get_value(" + select count(*) from jrnx + where + jrnx.j_jrn_def in (select jrn_def_id from jrn_def where jrn_def_type = 'VEN') + and j_date >= to_date($1,'DD.MM.YYYY') + and j_date <= to_date($2,'DD.MM.YYYY') + ", [$this->date_start, $this->date_end]); + if ($cnt==0 && $cnt_ledger !=0) { - throw new Exception(_("Données manquantes"),100); + + throw new Exception('TX148:'._("Données manquantes"),100); + } /* -------------Purchase --------------------------------- */ + $sql="select count(*) from quant_purchase where j_id in (select j_id from jrnx where - jrnx.j_jrn_def in (select jrn_def_id from jrn_def where jrn_def_type = 'VEN') + jrnx.j_jrn_def in (select jrn_def_id from jrn_def where jrn_def_type = 'ACH') and j_date >= to_date($1,'DD.MM.YYYY') and j_date <= to_date($2,'DD.MM.YYYY') ) "; $cnt=$this->db->get_value($sql, [$this->date_start, $this->date_end]); - if ($cnt>0) + + $cnt_ledger=$this->db->get_value(" + select count(*) from jrnx + where + jrnx.j_jrn_def in (select jrn_def_id from jrn_def where jrn_def_type = 'ACH') + and j_date >= to_date($1,'DD.MM.YYYY') + and j_date <= to_date($2,'DD.MM.YYYY') + ", [$this->date_start, $this->date_end]); + + if ($cnt ==0 && $cnt_ledger !=0) { - throw new Exception(_("Données manquantes"),100); + throw new Exception('TX175'._("Données manquantes"),100); } } private function build_exigibility() diff --git a/include/class/todo_list.class.php b/include/class/todo_list.class.php index af3928e89..94e6bf507 100644 --- a/include/class/todo_list.class.php +++ b/include/class/todo_list.class.php @@ -79,7 +79,8 @@ class Todo_List } if ( strcmp ($p_idx, 'tl_date') == 0 ) { - if ( noalyss_strlentrim($p_value) ==0 ||strlen($p_value) > 12 || isDate ($p_value) == false) return false; + if ( noalyss_strlentrim($p_value) ==0 ||strlen($p_value) > 12 || isDate ($p_value) == false) + { $p_value = null;return true;} } if ( strcmp ($p_idx, 'tl_title') == 0 ) { @@ -113,7 +114,7 @@ class Todo_List { if ( isDate($this->tl_date) == false ) { - $this->tl_date=date('d.m.Y'); + $this->tl_date=null; } return 0; } @@ -129,7 +130,7 @@ class Todo_List { if ( $this->verify() != 0 ) return; if (trim($this->tl_title)=='') - $this->tl_title=mb_substr(trim($this->tl_desc),0,30); + $this->tl_title=mb_substr(trim($this->tl_desc??""),0,30); if (trim($this->tl_title)=='') { @@ -142,6 +143,12 @@ class Todo_List $sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login,is_public) ". " values (to_date($1,'DD.MM.YYYY'),$2,$3,$4,$5) returning tl_id"; + + if ($this->tl_date == null) { + $sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login,is_public) ". + " values ($1,$2,$3,$4,$5) returning tl_id"; + + } $res=$this->cn->exec_sql( $sql, array($this->tl_date, @@ -172,6 +179,11 @@ class Todo_List $sql="update todo_list set tl_title=$1,tl_date=to_date($2,'DD.MM.YYYY'),tl_desc=$3,is_public=$5 ". " where tl_id = $4"; + + if ($this->tl_date == null) { + $sql="update todo_list set tl_title=$1,tl_date=$2,tl_desc=$3,is_public=$5 ". + " where tl_id = $4"; + } $res=$this->cn->exec_sql( $sql, array($this->tl_title, @@ -296,7 +308,7 @@ class Todo_List } /** - * Display the note + * @brief Display the note * @return html string */ function display() diff --git a/include/class/tva_rate_mtable.class.php b/include/class/tva_rate_mtable.class.php index 95552c4dd..8d7897868 100644 --- a/include/class/tva_rate_mtable.class.php +++ b/include/class/tva_rate_mtable.class.php @@ -36,7 +36,7 @@ class Tva_Rate_MTable extends Manage_Table_SQL //!< previous tva_id, used to know if we update or insert, private $previous_id; - + private $a_comment; //!< Supplemental explanation /** * @@ -52,15 +52,18 @@ class Tva_Rate_MTable extends Manage_Table_SQL $this->set_col_label("tva_rate", _("taux")); $this->set_col_label("tva_comment", _("Description")); $this->set_col_label("tva_both_side", _("Autoliquidation")); + $this->set_col_label("tva_reverse_account", _('Poste comptable autoliquidation')); $this->set_col_label("tva_sale", _("TVA Vente (C)")); $this->set_col_label("tva_purchase", _("TVA Achat (D)")); + $this->set_property_visible('tva_reverse_account', false); $this->set_col_type("tva_both_side", "select", array( ["value"=>0, "label"=>_("Non")], ["value"=>1, "label"=>_("Oui")] )); + $this->set_col_type("tva_reverse_account", 'custom'); $this->set_property_updatable("tva_id", true); $this->set_col_label("tva_payment_purchase",_("Exigible achat")); $this->set_col_type("tva_payment_purchase","select", @@ -76,9 +79,18 @@ class Tva_Rate_MTable extends Manage_Table_SQL array("value"=>'P',"label"=>"Paiement") ) ); - $this->a_info=["tva_purchase"=>44,"tva_both_side"=>43,"tva_sale"=>45 - ,"tva_payment_sale"=>74,"tva_payment_purchase"=>74]; + $this->a_info=[ + "tva_purchase"=>44,"tva_both_side"=>43,"tva_sale"=>45 + ,"tva_payment_sale"=>74,"tva_payment_purchase"=>74,'tva_reverse_account'=>88]; $this->previous_id=null; + $this->a_comment=array( + 'tva_purchase'=>_("Ne donnez pas ce poste comptable si ce code n'est pas utilisé à l'achat"), + 'tva_both_side'=>_("Autoliquidation : Utilisé en même temps au crédit et au débit"), + 'tva_sale'=>_("Ne donnez pas ce poste comptable si ce code n'est pas utilisé à la vente"), + 'tva_payment_purchase'=>_('TVA due ou récupérable quand l\'opération est payée ou exécutée'), + 'tva_payment_sale'=>_('TVA due ou récupérable quand l\'opération est payée ou exécutée'), + 'tva_reverse_account'=>_("Forcer ce poste comptable pour autoliquidation : par défault, le poste d'autoliquidation est calculé : soit celui qui est en contrepartie, soit le même (voir manuel)") + ); } /** @@ -107,6 +119,7 @@ class Tva_Rate_MTable extends Manage_Table_SQL function input() { $nb_order=count($this->a_order); + $this->set_property_visible('tva_reverse_account', true); echo ""; for ($i=0; $i<$nb_order; $i++) { @@ -181,6 +194,16 @@ class Tva_Rate_MTable extends Manage_Table_SQL echo $inum->input(); echo \HtmlInput::hidden("old_tva_id",$value); + } elseif ($key=='tva_reverse_account') + { + $text=new IPoste("tva_reverse_account"); + $text->value=$value; + $min_size=10; + $text->set_attribute('gDossier', Dossier::id()); + $text->set_attribute('jrn', 0); + $text->set_attribute('account', 'tva_reverse_account'); + $text->size=$min_size; + echo $text->input(); } echo ""; } @@ -190,12 +213,28 @@ class Tva_Rate_MTable extends Manage_Table_SQL HtmlInput::hidden($key, $value) ); } + echo ''; } echo ""; } echo "
    '; + if (isset ($this->a_comment[$key])) { + echo $this->a_comment[$key]; + } + echo '
    "; } + /** + * @brief add the TVA_REVERSE_ACCOUNT + * @return void + */ + function from_request() + { + parent::from_request(); + $http=new \HttpInput(); + $this->table->tva_reverse_account=$http->request('tva_reverse_account'); + } + /** * @brief save the data in TVA_RATE * if tva_both_side is 1 and tva_purchase or tva_sale is empty then @@ -230,6 +269,7 @@ class Tva_Rate_MTable extends Manage_Table_SQL $tva_rate->setp("tva_label", $this->table->tva_label); $tva_rate->setp("tva_comment", $this->table->tva_comment); $tva_rate->setp("tva_both_side", $this->table->tva_both_side); + $tva_rate->setp("tva_reverse_account", $this->table->tva_reverse_account); // TVA accounting must be joined and separated with a comma $tva_purchase=(trim($this->table->tva_purchase)=="")?"#":$this->table->tva_purchase; @@ -249,7 +289,7 @@ class Tva_Rate_MTable extends Manage_Table_SQL } /** - * Check data are valid + * @brief Check data are valid * 1. tva_rate between 0 & 1 * 2. label is uniq * 3. accounting must exist @@ -340,6 +380,26 @@ class Tva_Rate_MTable extends Manage_Table_SQL if (isNumber($this->table->tva_code) == 1){ $this->set_error("tva_code", _("code tva : doit aussi contenir des lettres")); } + /** + * auto reverse VAT : check that the accounting is used + */ + if ( $this->table->tva_both_side==0 && trim($this->table->tva_reverse_account??"") != "") + { + $this->set_error("tva_reverse_account", _("Pas d'autoliquidation demandé")); + } + if ( $this->table->tva_both_side==1 && trim($this->table->tva_reverse_account??"") != "") + { + $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1", + [$this->table->tva_reverse_account]); + if ($count==0) + { + $this->set_error("tva_reverse_account", _("Poste comptable inexistant")); + } + } + // label cannot be empty + if ( trim($this->table->tva_label??"")=="") { + $this->set_error("tva_label", _('Le label ne peut être vide')); + } if ($this->count_error()!=0) return false; return true; diff --git a/include/company.inc.php b/include/company.inc.php index 04adf430d..8da5be4ec 100644 --- a/include/company.inc.php +++ b/include/company.inc.php @@ -321,7 +321,7 @@ echo Icon_Action::tips($anc_filter->title);
    input('p_alphanum') ?>
    diff --git a/include/compta_ven.inc.php b/include/compta_ven.inc.php index f0eafa255..9943602d8 100644 --- a/include/compta_ven.inc.php +++ b/include/compta_ven.inc.php @@ -302,7 +302,7 @@ echo '
    '; /* if we suggest the pj n# the run the script */ if ( $g_parameter->MY_PJ_SUGGEST=='Y') { - echo ''; + echo ''; } $e_date=$http->request("e_date","string",""); diff --git a/include/constant.php b/include/constant.php index e81d73934..806867ebb 100644 --- a/include/constant.php +++ b/include/constant.php @@ -28,7 +28,7 @@ global $version_noalyss; define('NOALYSS_VERSION', 9300 ); // Database schema version -define("DBVERSION", 202); +define("DBVERSION", 203); // version for MONO_DATABASE define("MONO_DATABASE", 25); diff --git a/include/database/operation_exercice_detail_sql.class.php b/include/database/operation_exercice_detail_sql.class.php index a05afb44b..551bc9e97 100644 --- a/include/database/operation_exercice_detail_sql.class.php +++ b/include/database/operation_exercice_detail_sql.class.php @@ -27,8 +27,8 @@ */ /** - * @class - * @brief abstract of the table + * @class Operation_Exercice_Detail_SQL + * @brief abstract of the table operation_exercice_detail */ class Operation_Exercice_Detail_SQL extends Table_Data_SQL { diff --git a/include/database/tva_rate_sql.class.php b/include/database/tva_rate_sql.class.php index 5fc0593da..78bb589b4 100644 --- a/include/database/tva_rate_sql.class.php +++ b/include/database/tva_rate_sql.class.php @@ -51,6 +51,7 @@ class Tva_Rate_SQL extends Table_Data_SQL ,"tva_payment_purchase"=>"tva_payment_purchase" ,"tva_payment_sale"=>"tva_payment_sale" ,"tva_code"=>"tva_code" + ,'tva_reverse_account'=>'tva_reverse_account' ); /* * Type of columns @@ -65,6 +66,7 @@ class Tva_Rate_SQL extends Table_Data_SQL ,"tva_payment_purchase"=>"text" ,"tva_payment_sale"=>"text" ,"tva_code"=>"text" + ,'tva_reverse_account'=>'text' ); diff --git a/include/database/v_tva_rate_sql.class.php b/include/database/v_tva_rate_sql.class.php index f336b6433..5d74a662b 100644 --- a/include/database/v_tva_rate_sql.class.php +++ b/include/database/v_tva_rate_sql.class.php @@ -49,6 +49,7 @@ class V_Tva_Rate_SQL extends Table_Data_SQL , "tva_purchase"=>"tva_purchase" , "tva_sale"=>"tva_sale" , "tva_both_side"=>"tva_both_side" + ,'tva_reverse_account'=>'tva_reverse_account' ,'tva_payment_purchase'=>'tva_payment_purchase' ,'tva_payment_sale'=>'tva_payment_sale' @@ -65,6 +66,7 @@ class V_Tva_Rate_SQL extends Table_Data_SQL , "tva_purchase"=>"text" , "tva_sale"=>"text" , "tva_both_side"=>"numeric" + ,'tva_reverse_account'=>'text' , 'tva_payment_purchase'=>'text' , 'tva_payment_sale'=>'text' ); diff --git a/include/export/export_gl_csv.php b/include/export/export_gl_csv.php index 98a7411da..f02cd464b 100644 --- a/include/export/export_gl_csv.php +++ b/include/export/export_gl_csv.php @@ -35,7 +35,7 @@ [from_poste] => [to_poste] => ) -@encode +@endcode */ if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); diff --git a/include/extension_choice.inc.php b/include/extension_choice.inc.php deleted file mode 100644 index 8bc6c1785..000000000 --- a/include/extension_choice.inc.php +++ /dev/null @@ -1,54 +0,0 @@ -'; -@html_page_start($_SESSION[SESSION_KEY.'g_theme']); - -$cn=Dossier::connect(); -global $g_user; -$g_user=new Noalyss_user($cn); -$g_user->check(); -$only_plugin=$g_user->check_dossier(dossier::id()); - - -/* javascript file */ -echo load_all_script(); - -/* show all the extension we can access */ -$a=new ISelect('plugin_code'); -$a->value=Extension::make_array($cn); -$a->selected=(isset($_REQUEST['plugin_code']))?strtoupper($_REQUEST['plugin_code']):''; - -/* no plugin available */ -if ( count($a->value) == 0 ) -{ - alert(j(_("Aucune extension disponible"))); - exit; -} - -/* only one plugin available then we don't propose a choice*/ -if ( count($a->value)==1 ) -{ - $_REQUEST['plugin_code']=$a->value[0]['value']; -} -echo '
    '; -/*else -{ - if (!isset($_REQUEST['ac'])) echo_warning ("ac non positionné"); - echo '
    '; - echo Dossier::hidden(); - echo HtmlInput::request_to_hidden(array('plugin_code','ac')); - echo _('Extension').$a->input().HtmlInput::submit('go',_("Choix de l'extension")); - echo '
    '; - echo '
    '; -}*/ - -//if ( isset($_REQUEST['plugin_code'])) -// require_once NOALYSS_INCLUDE.'/extension_get.inc.php'; -?> diff --git a/include/lettering.gestion.inc.php b/include/lettering.gestion.inc.php index e3251389c..ac201118d 100644 --- a/include/lettering.gestion.inc.php +++ b/include/lettering.gestion.inc.php @@ -1,7 +1,29 @@ '; @@ -22,13 +44,13 @@ $periode=new Periode($cn); list($first_per,$last_per)=$periode->get_limit($exercice); $start=new IDate('start'); -$start->value=(isset($_GET['start']))?$http->get('start'):$first_per->first_day(); +$start->value=(isset($_GET['start']))?$http->get('start','date'):$first_per->first_day(); $r=td(_('Date début')); $r.=td($start->input()); echo tr($r); $end=new IDate('end'); -$end->value=(isset($_GET['end']))?$_GET['end']:$last_per->last_day(); +$end->value=(isset($_GET['end']))?$http->get('end','date'):$last_per->last_day(); $r=td(_('Date fin')); $r.=td($end->input()); echo tr($r); @@ -52,7 +74,7 @@ echo '
    '; echo HtmlInput::submit("seek",_('Recherche')); echo ''; echo ''; -//if (! isset($_REQUEST['seek'])) exit; + echo '
    '; //-------------------------------------------------------------------------------- // record the data @@ -74,7 +96,7 @@ if ( isset($_GET['start']) && isset($_GET['end'])) } } echo '
    '; -$fiche=new Fiche($cn,$_REQUEST['f_id']); +$fiche=new Fiche($cn, $http->request('f_id',"number")); $quick_code=$fiche->get_quick_code(); $letter=new Lettering_Card($cn); $letter->set_parameter('quick_code',$quick_code); diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index 9b5a2a87a..588d06292 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -36,9 +36,9 @@ function h($p_string) { return ( $p_string === null)?"":htmlspecialchars($p_string,ENT_QUOTES|ENT_HTML5,'UTF-8',true); } -function p($p_string) +function p($p_string, $p_extra='') { - return '

    '.$p_string."

    "; + return '

    '.$p_string.""; } function span($p_string, $p_extra='') { @@ -1800,4 +1800,5 @@ function sanitize_filename($filename) $new_filename=strtolower($filename_no)."-".date("Ymd-Hi").$filename_suff; return $new_filename; -} \ No newline at end of file +} + diff --git a/include/lib/function_javascript.php b/include/lib/function_javascript.php index c5478fa92..c94def571 100644 --- a/include/lib/function_javascript.php +++ b/include/lib/function_javascript.php @@ -2784,7 +2784,9 @@ EOF; echo js_include('acc_currency.js'); echo js_include('taggroup.js'); echo js_include('noalyss_checkbox.js'); - + if (DEBUGNOALYSS > 1) { + echo js_include('noalyss_debug.js'); + } } /** diff --git a/include/lib/http_input.class.php b/include/lib/http_input.class.php index 535573f4b..894095439 100644 --- a/include/lib/http_input.class.php +++ b/include/lib/http_input.class.php @@ -172,7 +172,7 @@ class HttpInput } if (!array_key_exists($p_name,$this->array)) { - throw new Exception(_('Paramètre invalide')."[$p_name]", + throw new Exception("C175."._('Paramètre invalide')."[$p_name]", EXC_PARAM_VALUE); } $this->check_type($p_name, $p_type); diff --git a/include/lib/icard.class.php b/include/lib/icard.class.php index 01b5a8dc0..8d195cc83 100644 --- a/include/lib/icard.class.php +++ b/include/lib/icard.class.php @@ -476,7 +476,7 @@ class ICard extends HtmlInput } $input='

    '. - Icon_Action::clean_zone(uniqid("remove"),"$('{$this->id}').value=''"). + Icon_Action::clean_zone(uniqid("remove"),"clean_Fid('{$this->id}');compute_all_ledger();"). "
    "; $input.=sprintf(' diff --git a/include/lib/input_checkbox.class.php b/include/lib/input_checkbox.class.php index aa1cc8f5f..f14ecd7cd 100644 --- a/include/lib/input_checkbox.class.php +++ b/include/lib/input_checkbox.class.php @@ -28,7 +28,7 @@ * value , either 1 or 0 EXPERIMENTAL */ /** - * @class + * @class InputCheckBox * @brief modern checkbox, using a javascript to change the icon when clicked and a hidden field, there is always a * value , either 1 or 0 , EXPERIMENTAL */ diff --git a/include/lib/iposte.class.php b/include/lib/iposte.class.php index 74ea4b054..3cd03c11a 100644 --- a/include/lib/iposte.class.php +++ b/include/lib/iposte.class.php @@ -88,12 +88,12 @@ class IPoste extends HtmlInput $this->extra2="all"; $this->extra=""; $this->attribute=array(); - $this->id=$p_id; + $this->id=$p_id; $this->nb_row=1; } - static function ipopup($p_name) + static function ipopup($p_name) { $ip=new IPopup($p_name); $ip->title='Plan comptable'; diff --git a/include/lib/manage_table_sql.class.php b/include/lib/manage_table_sql.class.php index e0f2b6b39..fbce42565 100644 --- a/include/lib/manage_table_sql.class.php +++ b/include/lib/manage_table_sql.class.php @@ -218,7 +218,7 @@ class Manage_Table_SQL */ function send_header() { - header('Content-type:text/xml;charset="UTF-8"'); + @header('Content-type:text/xml;charset="UTF-8"'); } /** diff --git a/include/lib/message_javascript.php b/include/lib/message_javascript.php index 75b38033c..a42c4bfdf 100644 --- a/include/lib/message_javascript.php +++ b/include/lib/message_javascript.php @@ -121,4 +121,6 @@ content[84]=""; content[86]=""; content[87]=""; +content[88]=""; + diff --git a/include/lib/noalyss_csv.class.php b/include/lib/noalyss_csv.class.php index 0ac94699f..11dcbb700 100644 --- a/include/lib/noalyss_csv.class.php +++ b/include/lib/noalyss_csv.class.php @@ -77,11 +77,16 @@ class Noalyss_Csv } /*** - *@brief Send an header for CSV , the filename is corrected + *@brief Send an header for CSV , the filename is corrected. If TEST_UNIT is defined, the function is called + * from a test file (located in scenario , see manual )and no header are requested */ function send_header() { $this->correct_name(); + if ( defined('TEST_UNIT')) { + + return; + } header('Pragma: public'); header('Content-type: application/csv'); header("Content-Disposition: attachment;filename=\"{$this->filename}\"", @@ -292,5 +297,32 @@ class Noalyss_Csv $this->size = $size; return $this; } + /** + * @brief convert CSV strings (content of a file) into HTML table, + * @param $string CSV files + */ + static function csv2table ($string) + { + $a_field=[';',',']; + $sep_field=$a_field[$_SESSION[SESSION_KEY.'csv_fieldsep']]; + $a_field=['.',',']; + $sep_dec=$a_field[$_SESSION[SESSION_KEY.'csv_decimal']]; + $encoding=$_SESSION[SESSION_KEY.'csv_encoding']; + $aRow=explode("\r\n", $string); + + echo ''; + foreach ($aRow as $row) { + echo ''; + $aCol=explode($sep_field, $row); + foreach ($aCol as $col) { + echo ''; + } + echo ''; + + } + echo '
    '; + echo h($col); + echo '
    '; + } } diff --git a/include/lib/output_html_tab.class.php b/include/lib/output_html_tab.class.php index 89ff75cde..fa1cb2723 100644 --- a/include/lib/output_html_tab.class.php +++ b/include/lib/output_html_tab.class.php @@ -23,7 +23,61 @@ /** * @file * @brief Display the tabs - * + * @code + * // create TAQ , with a url + $tab = new Html_Tab('tab1',_("Titre 1")); + $tab->set_mode('link'); + $tab->set_link("test.php?". + http_build_query([ "gDossier"=>Dossier::id(), + "script"=>"html_tab.test.php", + "a"=>1, + "b"=>2])); + * + // create a TAB and give the content + $tab2 = new Html_Tab('tab2',_("Titre 2")); + $tab2->set_content("" + . "
    Très longue chaine HTML pour 2" + . "
    Très longue chaine HTML pour 2" + . "
    Très longue chaine HTML pour 2" + . "
    Très longue chaine HTML pour 2" + . "
    Très longue chaine HTML pour 2" + . "
    Très longue chaine HTML pour 2" + . "
    Très longue chaine HTML pour 2" + . "
    Très longue chaine HTML pour 2" + . "
    Très longue chaine HTML pour 2" + . "
    Très longue chaine HTML pour 2" + . "
    Très longue chaine HTML pour 2" + . "
    Très longue chaine HTML pour 2"); + + $tab3 = new Html_Tab('tab3',_("Titre 3")); + $tab3->set_content('

    ' + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + . "
    Très longue chaine HTML pour 3" + .'

    ' + ); + + $output = new Output_Html_Tab; + + $output->add($tab); + $output->add($tab2); + $output->add($tab3); + + // show all the TABS +$output->output(); + * + * @endcode */ /** diff --git a/include/lib/pdf_core.class.php b/include/lib/pdf_core.class.php index 9111751ea..47fffea84 100644 --- a/include/lib/pdf_core.class.php +++ b/include/lib/pdf_core.class.php @@ -65,7 +65,7 @@ class PDF_Core extends TFPDF private $cells=array(); - + protected $bigger; public function __construct ( $orientation = 'P', $unit = 'mm', $format = 'A4') { $this->bigger=0; diff --git a/include/opening.inc.php b/include/opening.inc.php deleted file mode 100644 index 18fa6cae9..000000000 --- a/include/opening.inc.php +++ /dev/null @@ -1,268 +0,0 @@ -request("sa", "string", ""); -$g_user->Check(); - -require_once NOALYSS_INCLUDE.'/lib/user_menu.php'; - -// Correct (last step) -if (isset($_POST['correct'])) -{ - $p_jrn=$http->request("p_jrn", "number"); - $ledger=new Acc_Ledger($cn, $p_jrn); - require_once NOALYSS_INCLUDE.'/operation_ods_new.inc.php'; - return; -} - -// confirm before saving -if (isset($_POST['summary'])) -{ - try - { - $p_jrn=$http->request("p_jrn", "number"); - $ledger=new Acc_Ledger($cn, $p_jrn); - $ledger->with_concerned=false; - $ledger->verify($_POST); - require_once NOALYSS_INCLUDE.'/operation_ods_confirm.inc.php'; - } - catch (Exception $e) - { - echo alert($e->getMessage()); - require(NOALYSS_INCLUDE.'/operation_ods_new.inc.php'); - } - return; -} - -// record -if (isset($_POST['save'])) -{ - $p_jrn=$http->request("p_jrn", "number"); - $array=$_POST; - $ledger=new Acc_Ledger($cn, $p_jrn); - $ledger->with_concerned=false; - try - { - $ledger->save($array); - $jr_id=$cn->get_value('select jr_id from jrn where jr_internal=$1', - array($ledger->internal)); - - echo '

    '._("Opération enregistrée")." "._("Piece ").h($ledger->pj).'

    '; - if (strcmp($ledger->pj, $_POST['e_pj'])!=0) - { - echo '

    '._('Attention numéro pièce existante, elle a du être adaptée').'

    '; - } - printf('%s
    ', - $jr_id, dossier::id(), $ledger->internal); - - // show feedback - echo '
    '; echo '

    '.$ledger->get_name().'

    '; echo '
    '; - echo $ledger->confirm($_POST, true); - } - catch (Exception $e) - { - require(NOALYSS_INCLUDE.'/operation_ods_new.inc.php'); - alert($e->getMessage()); - } - return; -} - - -/* -------------------------------------------------- - * step 1 if nothing is asked we show the available folders - */ -if ($sa=='') -{ - echo '
    '; - - echo '

    '._("Etape 1 : choix du dossier").'

    '; - - echo _('Choisissez le dossier où sont les soldes à importer'); - $avail=$g_user->get_available_folder(); - - if (empty($avail)) - { - echo '*** '._("Aucun dossier").' ***'; - return; - } - echo '
    '; - echo HtmlInput::hidden('ac', $_REQUEST['ac']); - echo HtmlInput::hidden('sa', 'step2'); - echo dossier::hidden(); - $wAvail=new ISelect(); - /* compute select list */ - $array=array(); - $i=0; - foreach ($avail as $r) - { - $array[$i]['value']=$r['dos_id']; - $array[$i]['label']=$r['dos_name']; - $i++; - } - $wAvail->selected=Dossier::id(); - $wAvail->value=$array; - printf (_('Choix du dossier : %s'), - $wAvail->input('f')); - echo HtmlInput::submit('ok', _('Continuer')); - - echo '
    '; - echo '
    '; - echo '
    '; - return; -} -/* -------------------------------------------------- - * Step 2 choose now the exercice of this folder - */ -$back='do.php?ac='.$http->request("ac").'&'.dossier::get(); -if ($sa=='step2') -{ - echo '
    '. - '

    '._('Etape 2 : période').'

    '. - '

    '.dossier::name($_REQUEST['f']).'

    '. - '
    '. - _("Choisissez l'exercice clôturé (exercice N-1) du dossier à reporter pour les a-nouveaux (exercice N)"); - echo dossier::hidden(); - echo HtmlInput::hidden('ac', $_REQUEST['ac']); - echo HtmlInput::hidden('sa', 'step3'); - echo HtmlInput::hidden('f', $_REQUEST['f']); - $cn=new Database($_REQUEST['f']); - $periode=$cn->make_array("select distinct p_exercice,p_exercice from parm_periode order by p_exercice"); - $w=new ISelect(); - $w->table=0; - $w->label=_('Periode N-1'); - $w->readonly=false; - $w->value=$periode; - $w->name="p_periode"; - $w->selected=$g_user->get_exercice()-1; - echo "

    "; - echo _('Période N-1').' : '.$w->input(); - echo "

    "; - echo HtmlInput::submit('ok', _('Continuer')); - echo dossier::hidden(); - echo "
    "; - echo HtmlInput::button_anchor(_('Retour'), $back); - exit(0); -} -/* -------------------------------------------------- - * select the ledger where we will import the data - */ -if ($sa=='step3') -{ - echo '
    '. - '

    Etape 3

    '. - '

    '.dossier::name($_REQUEST['f']).'

    '. - '
    '. - _(" Choisissez le journal qui contiendra l'opération d'ouverture "); - echo dossier::hidden(); - echo HtmlInput::hidden('p_action', 'ouv'); - echo HtmlInput::hidden('sa', 'step4'); - echo HtmlInput::hidden('f', $_REQUEST['f']); - echo HtmlInput::hidden('p_periode', $_REQUEST['p_periode']); - $wLedger=new ISelect(); - $g_user=new Noalyss_user($cn); - $avail=$g_user->get_ledger('ODS'); - /* compute select list */ - $array=array(); - $i=0; - foreach ($avail as $r) - { - $array[$i]['value']=$r['jrn_def_id']; - $array[$i]['label']=$r['jrn_def_name']; - $i++; - } - $wLedger->value=$array; - echo $wLedger->input('p_jrn'); - echo HtmlInput::submit('ok', 'Continuer'); - echo HtmlInput::hidden('ac', $_REQUEST['ac']); - echo dossier::hidden(); - echo "
    "; - echo HtmlInput::button_anchor('Retour', - $back.'&sa=step2&f='.$_REQUEST['f']); - exit(0); -} -/* -------------------------------------------------- - * Step 4 we import data from the selected folder and year and - * transform it into a misc operation - */ -if ($sa=='step4') -{ - echo '
    '; - echo '

    '._("étape 4").'

    '; - $dossier_id=$http->request("f","number"); - $p_periode=$http->request("p_periode","number"); - $p_jrn=$http->request("p_jrn","number"); - $cn_target=new Database($dossier_id); - $saldo=new Acc_Ledger($cn_target, 0); - $array=$saldo->get_saldo_exercice($p_periode); - /* we need to transform the array into a Acc_Ledger array */ - - $result=array(); - $result['desc']=sprintf(_("Ecriture d'ouverture %d"),$g_user->get_exercice()); - $result['nb_item']=sizeof($array); - $result['p_jrn']=$p_jrn; - $result["ac"]=$http->request("ac"); - $result['p_periode']=$p_periode; - $result['gDossier']=Dossier::id(); - $result['jr_optype']="OPE"; - // default date = first day of Exercice - $periode=new Periode($cn,$g_user->get_periode()); - list($periode_start,$periode_end)=$periode->get_limit($g_user->get_exercice()); - $result["e_date"]=$periode_start->first_day(); - - $idx=0; - - foreach ($array as $row) - { - $qcode='qc_'.$idx; - $poste='poste'.$idx; - $amount='amount'.$idx; - $ck='ck'.$idx; - $result[$qcode]=$row['j_qcode']; - if (trim($row['j_qcode']??"")=='') - $result[$poste]=$row['j_poste']; - $result[$amount]=abs($row['solde']); - if ($row['solde']>0) - $result[$ck]='on'; - $idx++; - } - $cn=Dossier::connect(); - $jrn=new Acc_Ledger($cn,$p_jrn); - $_POST=$result; - $_REQUEST=$result; - $ledger=new Acc_Ledger($cn, $p_jrn); - require_once NOALYSS_INCLUDE.'/operation_ods_new.inc.php'; - - echo '
    '; -} \ No newline at end of file diff --git a/include/sql/mod1/data.sql b/include/sql/mod1/data.sql index f15f5c971..6a49eb3bc 100644 --- a/include/sql/mod1/data.sql +++ b/include/sql/mod1/data.sql @@ -4,6 +4,7 @@ set search_path = public,comptaproc,pg_catalog ; SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; +SET transaction_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); @@ -43,7 +44,6 @@ SELECT pg_catalog.lo_create('2346476'); - INSERT INTO public.action (ac_id, ac_description, ac_module, ac_code) VALUES (800, 'Ajout de fiche', 'fiche', 'FICADD'); INSERT INTO public.action (ac_id, ac_description, ac_module, ac_code) VALUES (805, 'Création, modification et effacement de fiche', 'fiche', 'FIC'); INSERT INTO public.action (ac_id, ac_description, ac_module, ac_code) VALUES (910, 'création, modification et effacement de catégorie de fiche', 'fiche', 'FICCAT'); diff --git a/include/sql/mod1/make-sql b/include/sql/mod1/make-sql index 8b725ae28..f7116ea34 100755 --- a/include/sql/mod1/make-sql +++ b/include/sql/mod1/make-sql @@ -9,7 +9,7 @@ export TEMPLATE=${DOMAIN}mod1 psql -X $TEMPLATE -c "delete from user_local_pref" psql -X $TEMPLATE -c "delete from user_local_pref" -pg_dump -O -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql +pg_dump -Ox -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql sed -i -e "/COMMENT ON EXTENSION/d" schema.sql sed -i -e "/CREATE EXTENSION/d" schema.sql sed -ne '0,/ADD CONSTRAINT/p' schema.sql > tmpSchema.sql diff --git a/include/sql/mod1/schema.sql b/include/sql/mod1/schema.sql index fdabc9401..6fd9d06e4 100644 --- a/include/sql/mod1/schema.sql +++ b/include/sql/mod1/schema.sql @@ -3,6 +3,7 @@ SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; +SET transaction_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); diff --git a/include/sql/mod2/make-sql b/include/sql/mod2/make-sql index 5adf3172e..eec26117c 100755 --- a/include/sql/mod2/make-sql +++ b/include/sql/mod2/make-sql @@ -9,7 +9,7 @@ export TEMPLATE=${DOMAIN}mod2 psql -X $TEMPLATE -c "delete from user_local_pref" psql -X $TEMPLATE -c "delete from user_local_pref" -pg_dump -O -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql +pg_dump -Ox -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql sed -i -e "/COMMENT ON EXTENSION/d" schema.sql sed -i -e "/CREATE EXTENSION/d" schema.sql sed -ne '0,/ADD CONSTRAINT/p' schema.sql > tmpSchema.sql @@ -17,5 +17,5 @@ sed -ne '/ADD CONSTRAINT/,$p' schema.sql |sed -e '1d' > constraint.sql cp tmpSchema.sql schema.sql echo "set search_path = public,comptaproc,pg_catalog ;" > data.sql -pg_dump -O -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" >> data.sql +pg_dump -Ox -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" >> data.sql diff --git a/include/sql/patch/upgrade202.sql b/include/sql/patch/upgrade202.sql new file mode 100644 index 000000000..d183afa61 --- /dev/null +++ b/include/sql/patch/upgrade202.sql @@ -0,0 +1,25 @@ +begin; + +alter table tva_rate add column tva_reverse_account account_type; +alter table tva_rate add constraint fk_tva_reverse_account foreign key (tva_reverse_account) references tmp_pcmn(pcm_val) on delete set null on update cascade ; + +comment on column tva_rate.tva_reverse_account is 'Accouting for reversed VAT'; + +drop VIEW public.v_tva_rate; + +CREATE OR REPLACE VIEW public.v_tva_rate +AS SELECT tva_id, + tva_rate, + tva_code, + tva_label, + tva_comment, + tva_reverse_account, + split_part(tva_poste, ','::text, 1) AS tva_purchase, + split_part(tva_poste, ','::text, 2) AS tva_sale, + tva_both_side, + tva_payment_purchase, + tva_payment_sale +FROM tva_rate; + +insert into version (val,v_description) values (203,'C0TVA force accounting for autoreverse VAT'); +commit; diff --git a/include/template/ledger_detail_ach.php b/include/template/ledger_detail_ach.php index aadb8e91d..2eae6976e 100644 --- a/include/template/ledger_detail_ach.php +++ b/include/template/ledger_detail_ach.php @@ -1,6 +1,11 @@ @@ -270,7 +275,53 @@ global $div,$g_parameter,$cn,$access,$jr_id,$obj; $str_anc.=td($poste); $str_anc.=td(nbm($htva)." {$side}"); $str_anc.=$anc_op->display_table(1, $htva, $div); - } + + $str_anc.='
- + - + - + diff --git a/include/template/menu.php b/include/template/menu.php index fa21b41f9..7a0ffcc2f 100644 --- a/include/template/menu.php +++ b/include/template/menu.php @@ -7,7 +7,7 @@ ?>
'; + echo '
'; + +?> + +

Format Area

+
+value= $http->post("enrich","raw",""); + +$itext->set_enrichText("enrich"); +echo $itext->input(); +?> + + +
+

Plain Area

+ value= strip_tags($http->post("enrich2","raw","")); + + $itext->set_enrichText("plain"); + echo $itext->input(); + ?> + + +

+ + +

+ +
diff --git a/scenario/progress-bar.test.php b/scenario/LIB/progress-bar.test.php similarity index 99% rename from scenario/progress-bar.test.php rename to scenario/LIB/progress-bar.test.php index f7fdb68e6..7bef62a8c 100644 --- a/scenario/progress-bar.test.php +++ b/scenario/LIB/progress-bar.test.php @@ -1,4 +1,4 @@ - diff --git a/scenario/select-box-test.php b/scenario/LIB/select-box-test.php similarity index 100% rename from scenario/select-box-test.php rename to scenario/LIB/select-box-test.php diff --git a/scenario/LIB/select_dialog.test.php b/scenario/LIB/select_dialog.test.php new file mode 100644 index 000000000..799fee523 --- /dev/null +++ b/scenario/LIB/select_dialog.test.php @@ -0,0 +1,45 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); + +/** + * @file + * @brief test the select_dialog class + * @see Select_Dialog + */ +require_once NOALYSS_INCLUDE."/lib/select_dialog.class.php"; + +$selbox=new Select_Dialog("action_add_action2", _("Ajout action")); +$aDocumentType=$cn->get_array("select dt_id,dt_value from document_type order by 2"); +$nbDocumentType=count($aDocumentType); +$dossier_id=Dossier::id(); +for ($i=0; $i<$nbDocumentType; $i++) +{ + $selbox->add_url($aDocumentType[$i]['dt_value'], + "do.php?".http_build_query([ + "gDossier"=>$dossier_id, + "sa"=>"update", + "add_action_here"=>"yes", + "action_type"=>$aDocumentType[$i]["dt_id"]])); +} +echo $selbox->input(); diff --git a/scenario/smoke.php b/scenario/LIB/smoke.php similarity index 73% rename from scenario/smoke.php rename to scenario/LIB/smoke.php index fa7e2e7f4..75c772b7b 100644 --- a/scenario/smoke.php +++ b/scenario/LIB/smoke.php @@ -36,14 +36,17 @@

smoke prompt

-	function func_callback_prompt(ev)
+
+    	function func_callback_prompt(ev)
 	{
 		if (ev) { alert ("accepted  "+ev);}
 		console.debug(ev);
 		return true;
 	}
-	
-smoke.prompt('Confirmez-vous',func_callback_prompt,{title:"Titre"});
+	function smoke_prompt()
+	{
+		smoke.prompt('Donnez un élement',func_callback_prompt,{title:"Titre"});
+	}
 
+

smoke signal

+ + + +
+
+        function signal() { smoke.signal('Sauvé',function(e){},{duration:500}); }
+
+
+
diff --git a/scenario/LIB/test_inner_box-widget.php b/scenario/LIB/test_inner_box-widget.php new file mode 100644 index 000000000..95683f2f2 --- /dev/null +++ b/scenario/LIB/test_inner_box-widget.php @@ -0,0 +1,111 @@ +dialog box avec different elements comme autocomplete , IDate, SelectBox pour règler problème de positionnement quand on défile (scroll) les éléments +/* + * Copyright (C) 2021 Dany De Bontridder + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +?> + + +
+ +
+ +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +

+ + + + +

Select Box

+ set_position("in-absolute"); + + $a->add_url("List (link)","?id=5&".Dossier::get()); + $a->add_javascript("Hello (Javascript)","alert('hello')"); + $a->add_value("Value = 10 (set value)",10); + $a->add_value("Value = 1 (set value)",1); + $a->add_value("Value = 15 (set value)",15); + + echo $a->input(); + + ?> +

Select Box

+
+

include 'select-box-test.php';

+ + +
+
+ +
+ + +
+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +

+

+ Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus magna felis sollicitudin mauris. Integer in mauris eu nibh euismod gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis risus a elit. Etiam tempor. Ut ullamcorper, ligula eu tempor congue, eros est euismod turpis, id tincidunt sapien risus a quam. Maecenas fermentum consequat mi. Donec fermentum. Pellentesque malesuada nulla a mi. Duis sapien sem, aliquet nec, commodo eget, consequat quis, neque. Aliquam faucibus, elit ut dictum aliquet, felis nisl adipiscing sapien, sed malesuada diam lacus eget erat. Cras mollis scelerisque nunc. Nullam arcu. Aliquam consequat. Curabitur augue lorem, dapibus quis, laoreet et, pretium ac, nisi. Aenean magna nisl, mollis quis, molestie eu, feugiat in, orci. In hac habitasse platea dictumst. +

+

+ Fusce convallis, mauris imperdiet gravida bibendum, nisl turpis suscipit mauris, sed placerat ipsum urna sed risus. In convallis tellus a mauris. Curabitur non elit ut libero tristique sodales. Mauris a lacus. Donec mattis semper leo. In hac habitasse platea dictumst. Vivamus facilisis diam at odio. Mauris dictum, nisi eget consequat elementum, lacus ligula molestie metus, non feugiat orci magna ac sem. Donec turpis. Donec vitae metus. Morbi tristique neque eu mauris. Quisque gravida ipsum non sapien. Proin turpis lacus, scelerisque vitae, elementum at, lobortis ac, quam. Aliquam dictum eleifend risus. In hac habitasse platea dictumst. Etiam sit amet diam. Suspendisse odio. Suspendisse nunc. In semper bibendum libero. +

+ +

+ Proin nonummy, lacus eget pulvinar lacinia, pede felis dignissim leo, vitae tristique magna lacus sit amet eros. Nullam ornare. Praesent odio ligula, dapibus sed, tincidunt eget, dictum ac, nibh. Nam quis lacus. Nunc eleifend molestie velit. Morbi lobortis quam eu velit. Donec euismod vestibulum massa. Donec non lectus. Aliquam commodo lacus sit amet nulla. Cras dignissim elit et augue. Nullam non diam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In hac habitasse platea dictumst. Aenean vestibulum. Sed lobortis elit quis lectus. Nunc sed lacus at augue bibendum dapibus. +

+

+ Aliquam vehicula sem ut pede. Cras purus lectus, egestas eu, vehicula at, imperdiet sed, nibh. Morbi consectetuer luctus felis. Donec vitae nisi. Aliquam tincidunt feugiat elit. Duis sed elit ut turpis ullamcorper feugiat. Praesent pretium, mauris sed fermentum hendrerit, nulla lorem iaculis magna, pulvinar scelerisque urna tellus a justo. Suspendisse pulvinar massa in metus. Duis quis quam. Proin justo. Curabitur ac sapien. Nam erat. Praesent ut quam. +

+

+ Vivamus commodo, augue et laoreet euismod, sem sapien tempor dolor, ac egestas sem ligula quis lacus. Donec vestibulum tortor ac lacus. Sed posuere vestibulum nisl. Curabitur eleifend fermentum justo. Nullam imperdiet. Integer sit amet mauris imperdiet risus sollicitudin rutrum. Ut vitae turpis. Nulla facilisi. Quisque tortor velit, scelerisque et, facilisis vel, tempor sed, urna. Vivamus nulla elit, vestibulum eget, semper et, scelerisque eget, lacus. Pellentesque viverra purus. Quisque elit. Donec ut dolor. +

+

+ Duis volutpat elit et erat. In at nulla at nisl condimentum aliquet. Quisque elementum pharetra lacus. Nunc gravida arcu eget nunc. Nulla iaculis egestas magna. Aliquam erat volutpat. Sed pellentesque orci. Etiam lacus lorem, iaculis sit amet, pharetra quis, imperdiet sit amet, lectus. Integer quis elit ac mi aliquam pretium. Nullam mauris orci, porttitor eget, sollicitudin non, vulputate id, risus. Donec varius enim nec sem. Nam aliquam lacinia enim. Quisque eget lorem eu purus dignissim ultricies. Fusce porttitor hendrerit ante. Mauris urna diam, cursus id, mattis eget, tempus sit amet, risus. Curabitur eu felis. Sed eu mi. Nullam lectus mauris, luctus a, mattis ac, tempus non, leo. Cras mi nulla, rhoncus id, laoreet ut, ultricies id, odio. +

+

+ Donec imperdiet. Vestibulum auctor tortor at orci. Integer semper, nisi eget suscipit eleifend, erat nisl hendrerit justo, eget vestibulum lorem justo ac leo. Integer sem velit, pharetra in, fringilla eu, fermentum id, felis. Vestibulum sed felis. In elit. Praesent et pede vel ante dapibus condimentum. Donec magna. Quisque id risus. Mauris vulputate pellentesque leo. Duis vulputate, ligula at venenatis tincidunt, orci nunc interdum leo, ac egestas elit sem ut lacus. Etiam non diam quis arcu egestas commodo. Curabitur nec massa ac massa gravida condimentum. Aenean id libero. Pellentesque vitae tellus. Fusce lectus est, accumsan ac, bibendum sed, porta eget, augue. Etiam faucibus. Quisque tempus purus eu ante. +

+ +
+ \ No newline at end of file diff --git a/scenario/test_manage_table_sql.php b/scenario/LIB/test_manage_table_sql.php similarity index 100% rename from scenario/test_manage_table_sql.php rename to scenario/LIB/test_manage_table_sql.php diff --git a/scenario/XML/ajax-add-card-category.php b/scenario/XML/ajax-add-card-category.php new file mode 100644 index 000000000..16945d8e6 --- /dev/null +++ b/scenario/XML/ajax-add-card-category.php @@ -0,0 +1,33 @@ + '42', + 'ctl' => 'select_card_div', + 'op' => 'card', + 'op2'=>'st', + 'fil' => '-1', + 'ledger' => '2', +); +$_POST['gDossier']=$gDossierLogInput; +$_GET['gDossier']=$gDossierLogInput; + $_REQUEST=array_merge($_GET,$_POST); +ob_start(); + include NOALYSS_HOME.'/ajax_misc.php'; +$output=ob_get_clean(); +echo '
'; +$xml=simplexml_load_string($output); +print "ctl {$xml->ctl}"; +echo '
'; +print "code "; +print '
'; +print_r($xml->code); +echo '
'; +echo ''; +echo htmlentities($xml->code); +echo ''; + +echo '
'; +print "fiche_cat "; +print_r($xml->fiche_cat); +echo '
'; + diff --git a/scenario/ajax-detail-operation1.php b/scenario/XML/ajax-detail-operation1.php similarity index 68% rename from scenario/ajax-detail-operation1.php rename to scenario/XML/ajax-detail-operation1.php index 8874afe42..0b51759ed 100644 --- a/scenario/ajax-detail-operation1.php +++ b/scenario/XML/ajax-detail-operation1.php @@ -3,7 +3,7 @@ $_GET=array ( 'op' => 'ledger', 'act' => 'de', - 'jr_id' => '2856', + 'jr_id' => '137', 'div' => 'det2', ); $_POST=array ( @@ -11,4 +11,9 @@ $_POST=array ( $_POST['gDossier']=$gDossierLogInput; $_GET['gDossier']=$gDossierLogInput; $_REQUEST=array_merge($_GET,$_POST); +ob_start(); include 'ajax_misc.php'; +$output=ob_get_contents(); +ob_clean(); +echo unescape_xml($output); + echo htmlentities($output); diff --git a/scenario/ajax-detail-operation2.php b/scenario/XML/ajax-detail-operation2.php similarity index 59% rename from scenario/ajax-detail-operation2.php rename to scenario/XML/ajax-detail-operation2.php index 1ef2ce551..13b214d9c 100644 --- a/scenario/ajax-detail-operation2.php +++ b/scenario/XML/ajax-detail-operation2.php @@ -1,9 +1,9 @@ 'ledger', 'act' => 'de', - 'jr_id' => '2870', + 'jr_id' => '147', 'div' => 'det2', ); $_POST=array ( @@ -11,4 +11,10 @@ $_POST=array ( $_POST['gDossier']=$gDossierLogInput; $_GET['gDossier']=$gDossierLogInput; $_REQUEST=array_merge($_GET,$_POST); + +ob_start(); include 'ajax_misc.php'; +$output=ob_get_contents(); +ob_clean(); +echo unescape_xml($output); +echo htmlentities($output); diff --git a/scenario/ajax-detail-operation3.php b/scenario/XML/ajax-detail-operation3.php similarity index 64% rename from scenario/ajax-detail-operation3.php rename to scenario/XML/ajax-detail-operation3.php index a14539381..3881b69a8 100644 --- a/scenario/ajax-detail-operation3.php +++ b/scenario/XML/ajax-detail-operation3.php @@ -3,12 +3,16 @@ $_GET=array ( 'op' => 'ledger', 'act' => 'de', - 'jr_id' => '3532', + 'jr_id' => '213', 'div' => 'det2', ); $_POST=array ( ); $_POST['gDossier']=$gDossierLogInput; $_GET['gDossier']=$gDossierLogInput; - $_REQUEST=array_merge($_GET,$_POST); +ob_start(); include 'ajax_misc.php'; +$output=ob_get_contents(); +ob_clean(); +echo unescape_xml($output); +echo htmlentities($output); diff --git a/scenario/ajax-detail-operation4.php b/scenario/XML/ajax-detail-operation4.php similarity index 67% rename from scenario/ajax-detail-operation4.php rename to scenario/XML/ajax-detail-operation4.php index 92f1ca8f3..cbb2fb1dd 100644 --- a/scenario/ajax-detail-operation4.php +++ b/scenario/XML/ajax-detail-operation4.php @@ -3,7 +3,7 @@ $_GET=array ( 'op'=>"ledger", 'act' => 'de', - 'jr_id' => '2826', + 'jr_id' => '316', 'div' => 'det2', ); $_POST=array ( @@ -11,4 +11,9 @@ $_POST=array ( $_POST['gDossier']=$gDossierLogInput; $_GET['gDossier']=$gDossierLogInput; $_REQUEST=array_merge($_GET,$_POST); +ob_start(); include 'ajax_misc.php'; +$output=ob_get_contents(); +ob_clean(); +echo unescape_xml($output); +echo htmlentities($output); diff --git a/scenario/XML/ajax_display_letter.php b/scenario/XML/ajax_display_letter.php new file mode 100644 index 000000000..4e81bab88 --- /dev/null +++ b/scenario/XML/ajax_display_letter.php @@ -0,0 +1,41 @@ + '25', + 'j_id' => '343', + 'obj_type' => 'card', + 'search_start' => '01.01.2019', + 'search_end' => '31.12.2019', + 'op' => 'dl', +); +$_POST=array ( +); +$_POST['gDossier']=$gDossierLogInput; +$_GET['gDossier']=$gDossierLogInput; + $_REQUEST=array_merge($_GET,$_POST); +echo h1('Raw'); +include 'ajax_misc.php'; + +echo h1('Détail'); +ob_start(); +include 'ajax_misc.php'; +$var=ob_get_contents(); +ob_end_clean(); + + +$xml=simplexml_load_string($var); + +foreach ($xml as $key=>$value) { + echo ("key is $key
"); + echo ''; + echo '
'; + print_r( $value); + echo '
'; + + +} \ No newline at end of file diff --git a/scenario/ach-new.php b/scenario/ach-new.php deleted file mode 100644 index 48501bb35..000000000 --- a/scenario/ach-new.php +++ /dev/null @@ -1,34 +0,0 @@ - '42', - 'ac' => 'COMPTA/MENUACH/ACH', -); -$_POST=array ( - 'gDossier' => '42', - 'nb_item' => '1', - 'p_jrn' => '3', - 'e_date' => '01.03.2016', - 'e_ech' => '', - 'e_client' => 'IMMOB', - 'e_pj' => 'ACH1', - 'e_pj_suggest' => 'ACH1', - 'e_comm' => 'Loyer', - 'e_march0' => 'LOYER', - 'e_march0_price' => '2560', - 'e_quant0' => '1', - 'htva_march0' => '2560', - 'e_march0_tva_id' => '4', - 'e_march0_tva_amount' => '0', - 'tva_march0' => '0', - 'tvac_march0' => '2560', - 'jrn_type' => 'ACH', - 'p_action' => 'ach', - 'sa' => 'p', - 'e_mp' => '0', - 'view_invoice' => 'Enregistrer', -); -$_POST['gDossier']=$gDossierLogInput; -$_GET['gDossier']=$gDossierLogInput; - $_REQUEST=array_merge($_GET,$_POST); -include 'compta_ach.inc.php'; diff --git a/scenario/ajax-add-card-category.php b/scenario/ajax-add-card-category.php deleted file mode 100644 index 10aeab903..000000000 --- a/scenario/ajax-add-card-category.php +++ /dev/null @@ -1,16 +0,0 @@ - '42', - 'ctl' => 'select_card_div', - 'op' => 'card', - 'op2'=>'st', - 'fil' => '-1', - 'ledger' => '2', -); -$_POST=array ( -); -$_POST['gDossier']=$gDossierLogInput; -$_GET['gDossier']=$gDossierLogInput; - $_REQUEST=array_merge($_GET,$_POST); -include NOALYSS_HOME.'/ajax_misc.php'; diff --git a/scenario/ajax-save-operation.php b/scenario/ajax-save-operation.php deleted file mode 100644 index 80fdd7365..000000000 --- a/scenario/ajax-save-operation.php +++ /dev/null @@ -1,37 +0,0 @@ - 'det2', - 'jr_id' => '2856', - 'gDossier' => '27', - 'p_date' => '05.12.2013', - 'p_ech' => '', - 'p_date_paid' => '', - 'npj' => 'ACH607', - 'lib' => 'Consommable, ptit matériel', - 'jrn_note' => '', - 'j_id' => - array ( - 0 => '7629', - 1 => '7630', - ), - 'BON_COMMANDE' => '', - 'OTHER' => '', - 'raptdet2' => '', - 'related' => '327,231,330', - 'Fermer' => 'Fermer', - 'save' => 'Sauver', - 'Effacer' => 'Effacer', - 'bextdet2' => 'Extourner', - 'rapt' => '', - 'div' => 'det2', - 'act' => 'save', - 'op'=>'ledger', - 'jr_optype'=>'NOR' -); -$_POST['gDossier']=$gDossierLogInput; -$_GET['gDossier']=$gDossierLogInput; - $_REQUEST=array_merge($_GET,$_POST); -include 'ajax_misc.php'; diff --git a/scenario/ajax_acc_plan_mtable.php b/scenario/ajax_acc_plan_mtable.php deleted file mode 100644 index c782969ca..000000000 --- a/scenario/ajax_acc_plan_mtable.php +++ /dev/null @@ -1,64 +0,0 @@ - - -if (!defined('ALLOWED')) - die('Appel direct ne sont pas permis'); -if ( ! defined ("AJAX_TEST")) { - echo "Can not be called directly but via ajax_test.php"; - return; -} -/** - * @file - * @brief Test the ajax call from test_manage_table_sql.php - */ -$http=new HttpInput(); -try { -$table=$http->request('table'); -$action=$http->request('action'); -$p_id=$http->request('p_id', "number"); -$ctl_id=$http->request('ctl'); -} catch(Exception $e) { - echo $e->getMessage(); -} -require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php"; -require_once NOALYSS_INCLUDE."/class/acc_plan_mtable.class.php"; - -$obj=new Acc_Plan_SQL($cn); -$obj->set_limit_fiche_qcode(5); -$obj->set_pk_value($p_id); -$obj->load(); -$manage_table=new Acc_Plan_MTable($obj); -$manage_table->add_json_param("TestAjaxFile", - NOALYSS_HOME."/../scenario/ajax_acc_plan_mtable.php"); -$manage_table->set_object_name($ctl_id); -$manage_table->set_callback("ajax_test.php"); -if ($action=="input") -{ - header('Content-type: text/xml; charset=UTF-8'); - echo $manage_table->ajax_input()->saveXML(); - return; -} -elseif ($action == "save") -{ - $xml=$manage_table->ajax_save(); - header('Content-type: text/xml; charset=UTF-8'); - echo $xml->saveXML(); -} \ No newline at end of file diff --git a/scenario/ajax_manage_table_sql.php b/scenario/ajax_manage_table_sql.php deleted file mode 100644 index d7401060b..000000000 --- a/scenario/ajax_manage_table_sql.php +++ /dev/null @@ -1,79 +0,0 @@ - - -if (!defined('ALLOWED')) - die('Appel direct ne sont pas permis'); -if ( ! defined ("AJAX_TEST")) { - echo "Can not be called directly but via AJAX"; - return; -} -/** - * @file - * @brief Test the ajax call from test_manage_table_sql.php - */ -$http=new HttpInput(); -try { -$table=$http->request('table'); -$action=$http->request('action'); -$p_id=$http->request('p_id', "number"); -$ctl_id=$http->request('ctl'); -} catch(Exception $e) { - - echo $e->getMessage(); -} -require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php"; -require_once NOALYSS_INCLUDE."/database/acc_plan_sql.class.php"; - - - -if ($action=="input") -{ - $obj=new Acc_Plan_SQL($cn); - $obj->set_limit_fiche_qcode(5); - $obj->set_pk_value($p_id); - $obj->load(); - $manage_table=new Manage_Table_SQL($obj); - $manage_table->add_json_param("TestAjaxFile", - NOALYSS_HOME."/../scenario/ajax_manage_table_sql.php"); - - $manage_table->set_object_name($ctl_id); - $manage_table->set_col_label('pcm_val', "Poste"); - $manage_table->set_col_label('parent_accounting', "Dépend"); - $manage_table->set_col_label('pcm_lib', "Libellé"); - $manage_table->set_col_label('pcm_type', - "Type de menu".Icon_Action::infobulle(33)); - header('Content-type: text/xml; charset=UTF-8'); - echo $manage_table->ajax_input()->saveXML(); - return; -} elseif ($action=="save") -{ -$obj=new Acc_Plan_SQL($cn); - $obj->set_limit_fiche_qcode(5); - $obj->set_pk_value($p_id); - $obj->load(); - $manage_table=new Manage_Table_SQL($obj); - $manage_table->set_object_name($ctl_id); - $manage_table->add_json_param("TestAjaxFile", - NOALYSS_HOME."/../scenario/ajax_manage_table_sql.php"); - header('Content-type: text/xml; charset=UTF-8'); - echo $manage_table->ajax_save()->saveXML(); - return; -} \ No newline at end of file diff --git a/scenario/cfgpcm-ajout-poste.php b/scenario/cfgpcm-ajout-poste.php deleted file mode 100644 index a85711b3a..000000000 --- a/scenario/cfgpcm-ajout-poste.php +++ /dev/null @@ -1,19 +0,0 @@ - '42', - 'ac' => 'PARAM/C0PCMN', -); -$_POST=array ( - 'p_action' => 'pcmn', - 'gDossier' => '42', - 'p_val' => '4519', - 'p_lib' => 'Compte TVA', - 'p_parent' => '451', - 'p_type' => 'ACT', - 'Ajout' => 'Ajout', -); -$_POST['gDossier']=$gDossierLogInput; -$_GET['gDossier']=$gDossierLogInput; - $_REQUEST=array_merge($_GET,$_POST); -include 'param_pcmn.inc.php'; diff --git a/scenario/document_type.php b/scenario/document_type.php new file mode 100644 index 000000000..931fb571c --- /dev/null +++ b/scenario/document_type.php @@ -0,0 +1,43 @@ + '42', - 'ac' => 'COMPTA/MENUODS/ODS', -); -$_POST=array ( - 'ac' => 'COMPTA/MENUODS/ODS', - 'e_date' => '14.11.2014', - 'desc' => 'TVA', - 'period' => '102', - 'e_pj' => 'ODS1', - 'e_pj_suggest' => 'ODS1', - 'mt' => '1415996970.8822', - 'e_comm' => 'TVA', - 'jrn_type' => 'ODS', - 'p_jrn' => '4', - 'nb_item' => '5', - 'jrn_concerned' => '', - 'gDossier' => '42', - 'poste0' => '4519', - 'ld0' => 'Compte TVA', - 'amount0' => '250', - 'poste1' => '6700', - 'ld1' => 'Paiement TVA', - 'amount1' => '250', - 'ck1' => '', - 'opd_name' => 'Paiement TVA', - 'od_description' => '', - 'save' => 'Confirmer', -); -$_POST['gDossier']=$gDossierLogInput; -$_GET['gDossier']=$gDossierLogInput; - $_REQUEST=array_merge($_GET,$_POST); -include 'compta_ods.inc.php'; diff --git a/scenario/ods-record.php b/scenario/ods-record.php deleted file mode 100644 index efb976484..000000000 --- a/scenario/ods-record.php +++ /dev/null @@ -1,44 +0,0 @@ - '42', - 'ac' => 'COMPTA/MENUODS/ODS', -); -$_POST=array ( - 'gDossier' => '42', - 'ac' => 'COMPTA/MENUODS/ODS', - 'p_jrn' => '4', - 'e_date' => '14.11.2016', - 'e_pj' => 'ODS1', - 'e_pj_suggest' => 'ODS1', - 'desc' => 'TVA', - 'nb_item' => '5', - 'jrn_type' => 'ODS', - 'qc_0' => '', - 'poste0' => '4519', - 'ld0' => 'Compte TVA', - 'amount0' => '250', - 'qc_1' => '', - 'poste1' => '6700', - 'ld1' => 'Paiement TVA', - 'amount1' => '250', - 'ck1' => '', - 'qc_2' => '', - 'poste2' => '', - 'ld2' => '', - 'amount2' => '', - 'qc_3' => '', - 'poste3' => '', - 'ld3' => '', - 'amount3' => '', - 'qc_4' => '', - 'poste4' => '', - 'ld4' => '', - 'amount4' => '', - 'jrn_concerned' => '', - 'summary' => 'Sauvez', -); -$_POST['gDossier']=$gDossierLogInput; -$_GET['gDossier']=$gDossierLogInput; - $_REQUEST=array_merge($_GET,$_POST); -include 'compta_ods.inc.php'; diff --git a/scenario/readme.txt b/scenario/readme.txt index 71fd91f97..de86d24f2 100644 --- a/scenario/readme.txt +++ b/scenario/readme.txt @@ -37,6 +37,23 @@ L'objectif étant de pouvoir tester et de rejouer facilement les actions que vou Il est aussi possible de faire vos tests unitaire ici , autrement qu'avec PHPUNIT (voir répertiore php-unit) +Vous pouver l'utiliser pour les sorties ajax, mises au point de librarie, scénario , cela permet de tester les +fichiers à include (.inc.php) , les exports , les réponses ajax et appeler les fonctions test_me dans les classes +(static function test_me() ). + +Dans votre code, vous pouvez ajouter des portions de code ainsi + + if (defined ('TEST_UNIT')) { + // exécuté uniquement si appelé pour les tests unitaires + + } + +Les répertoires : +---------------- +HTML : vérification pour les fichiers inclus +LIB : concerne les libraries +XML : réponse de script ajax, réponse souvent en XML +LOCAL : vos propres scripts, pour vos développements, ne seront pas dans GIT ----------------------- ENGLISH @@ -55,5 +72,18 @@ You point you browser noalyss/html/test.php an you click on the link with the and you can rerun the file , it works also for ajax. -It is useful to test ajax answer , unit test or testing a class +It is useful to test ajax answer , unit test or testing a class (with static function test_me() ) +In your code, you can do + + if (defined ('TEST_UNIT')) { + // executed only if calling script is test.php, + + } + +FOLDERS +---------------- +HTML : test the files to include +LIB : concerns libraries +XML : ajax script response often XML or JSON +LOCAL : Your own scripts for developping , not included in GIT diff --git a/scenario/ven-new.php b/scenario/ven-new.php deleted file mode 100644 index d86305fa8..000000000 --- a/scenario/ven-new.php +++ /dev/null @@ -1,43 +0,0 @@ - '42', - 'ac' => 'COMPTA/VENMENU/VEN', -); -$_POST=array ( - 'ledger_type' => 'VEN', - 'ac' => 'COMPTA/VENMENU/VEN', - 'sa' => 'p', - 'gDossier' => '42', - 'nb_item' => '2', - 'p_jrn' => '2', - 'e_date' => '14.11.2016', - 'e_ech' => '', - 'e_client' => 'CLIENT1 ', - 'e_pj' => 'VEN1', - 'e_pj_suggest' => 'VEN1', - 'e_comm' => 'Première vente', - 'e_march0' => 'DEPLAC', - 'e_march0_price' => '120', - 'e_quant0' => '1', - 'htva_march0' => '120', - 'e_march0_tva_id' => '1', - 'e_march0_tva_amount' => '25.2', - 'tva_march0' => '25.2', - 'tvac_march0' => '145.2', - 'e_march1' => '', - 'e_march1_price' => '', - 'e_quant1' => '1', - 'htva_march1' => '0', - 'e_march1_tva_id' => '', - 'e_march1_tva_amount' => '', - 'tva_march1' => '0', - 'tvac_march1' => '0', - 'jrn_type' => 'VEN', - 'e_mp' => '0', - 'view_invoice' => 'Enregistrer', -); -$_POST['gDossier']=$gDossierLogInput; -$_GET['gDossier']=$gDossierLogInput; - $_REQUEST=array_merge($_GET,$_POST); -include 'compta_ven.inc.php'; diff --git a/scenario/ven-record.php b/scenario/ven-record.php deleted file mode 100644 index 5c119ee4b..000000000 --- a/scenario/ven-record.php +++ /dev/null @@ -1,40 +0,0 @@ - '42', - 'ac' => 'COMPTA/VENMENU/VEN', -); -$_POST=array ( - 'gDossier' => '42', - 'bon_comm' => '', - 'other_info' => '', - 'e_client' => 'CLIENT1 ', - 'nb_item' => '2', - 'p_jrn' => '2', - 'mt' => '1415995185.7619', - 'e_comm' => 'Première vente', - 'e_date' => '14.11.2016', - 'e_ech' => '', - 'e_pj' => 'VEN1', - 'e_pj_suggest' => 'VEN1', - 'e_mp' => '0', - 'jrn_type' => 'VEN', - 'e_march0' => 'DEPLAC', - 'e_march0_price' => '120', - 'e_march0_tva_id' => '1', - 'e_march0_tva_amount' => '25.2', - 'e_quant0' => '1', - 'e_march1' => '', - 'e_march1_price' => '', - 'e_march1_tva_id' => '', - 'e_march1_tva_amount' => '', - 'e_quant1' => '1', - 'ac' => 'COMPTA/VENMENU/VEN', - 'opd_name' => '', - 'od_description' => '', - 'record' => 'Enregistrement', -); -$_POST['gDossier']=$gDossierLogInput; -$_GET['gDossier']=$gDossierLogInput; - $_REQUEST=array_merge($_GET,$_POST); -include 'compta_ven.inc.php'; diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 139597f9c..fe37f2c7e 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,2 +1,3 @@ - - +-- change color selected menu +update parm_appearance set a_value='#000074' where a_code='MENU1-SELECTED' and a_value='#7191ea'; +ALTER TABLE public.todo_list ALTER COLUMN tl_date drop NOT NULL; diff --git a/unit-test/create-dossier-test.sh b/unit-test/create-dossier-test.sh index a609f783b..b3f65e29c 100755 --- a/unit-test/create-dossier-test.sh +++ b/unit-test/create-dossier-test.sh @@ -1,6 +1,6 @@ #!/bin/bash -export PGCLUSTER=12/main +export PGCLUSTER=17/main DOSSIER_TEST=rel91dossier25 FILE_TEST=dossier25.sql diff --git a/unit-test/dossier25.sql.gz b/unit-test/dossier25.sql.gz index a7b28e950..300bc6ae4 100644 Binary files a/unit-test/dossier25.sql.gz and b/unit-test/dossier25.sql.gz differ diff --git a/unit-test/include/class/acc_balanceTest.php b/unit-test/include/class/acc_balanceTest.php index 9e7b5f458..09e35e492 100644 --- a/unit-test/include/class/acc_balanceTest.php +++ b/unit-test/include/class/acc_balanceTest.php @@ -64,9 +64,11 @@ class Acc_BalanceTest extends TestCase $this->object->filter_cat(array()); $this->assertEquals($this->object->jrn,null); $this->object->filter_cat(array('2'=>'FIN')); + sort($this->object->jrn); $this->assertEquals([1,83,152],$this->object->jrn); $this->object->filter_cat(array('1'=>'ACH','2'=>'FIN')); - $this->assertEquals([35,3,1,83,152],$this->object->jrn); + sort($this->object->jrn); + $this->assertEquals([1,3,35,83,152],$this->object->jrn); } /** *@covers Acc_Balance::summary_add diff --git a/unit-test/include/class/acc_ledgerTest.php b/unit-test/include/class/acc_ledgerTest.php index b8bb5d86c..73c3dd605 100644 --- a/unit-test/include/class/acc_ledgerTest.php +++ b/unit-test/include/class/acc_ledgerTest.php @@ -901,7 +901,7 @@ class Acc_LedgerTest extends TestCase ob_end_clean(); \Noalyss\Facility::save_file(__DIR__."/file", "acc_ledger-input_new.html", $result); $size=filesize(__DIR__."/file/acc_ledger-input_new.html"); - $this->assertTrue($size == 15948 ," output input_new is not what it is expected"); + $this->assertTrue($size == 16044 ," output input_new is not what it is expected"); } diff --git a/unit-test/include/class/acc_ledger_purchaseTest.php b/unit-test/include/class/acc_ledger_purchaseTest.php index e7c13a162..8d9e292c1 100644 --- a/unit-test/include/class/acc_ledger_purchaseTest.php +++ b/unit-test/include/class/acc_ledger_purchaseTest.php @@ -65,6 +65,89 @@ class Acc_Ledger_PurchaseTest extends TestCase "p_currency_code"=>1 ); + // create accounting for reversed VAT with neg. amount + $g_connection->exec_sql(" + INSERT INTO public.tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent,pcm_type,pcm_direct_use) VALUES + ('4119999','TVA Test UNIT','411','ACT','Y') on conflict do nothing"); + // variable: $array1 = used for autoreverse with 2 VAT Codes + $this->array1=array ( + 'e_client' => 'FOURNI1', + 'nb_item' => '10', + 'p_jrn' => '3', + 'jrn_note_input' => '', + 'e_comm' => 'Documentation', + 'e_date' => '30.01.2020', + 'e_ech' => '', + 'jrn_type' => 'ACH', + 'e_pj' => 'ACH53', + 'e_pj_suggest' => 'ACH53', + 'p_currency_rate' => '1', + 'p_currency_code' => '0', + 'mt' => '1734717784.385', + 'e_mp' => '0', + 'e_march0' => 'DOCUME', + 'e_march0_price' => '120', + 'e_march0_tva_id' => '5', + 'e_march0_tva_amount' => '0', + 'e_quant0' => '1', + 'e_march1' => 'DOCUME', + 'e_march1_price' => '-10', + 'e_march1_tva_id' => '3', + 'e_march1_tva_amount' => '0', + 'e_quant1' => '1', + 'e_march2' => '', + 'e_march2_price' => '', + 'e_march2_tva_id' => '', + 'e_march2_tva_amount' => '', + 'e_quant2' => '1', + 'e_march3' => '', + 'e_march3_price' => '', + 'e_march3_tva_id' => '', + 'e_march3_tva_amount' => '', + 'e_quant3' => '1', + 'e_march4' => '', + 'e_march4_price' => '', + 'e_march4_tva_id' => '', + 'e_march4_tva_amount' => '', + 'e_quant4' => '1', + 'e_march5' => '', + 'e_march5_price' => '', + 'e_march5_tva_id' => '', + 'e_march5_tva_amount' => '', + 'e_quant5' => '1', + 'e_march6' => '', + 'e_march6_price' => '', + 'e_march6_tva_id' => '', + 'e_march6_tva_amount' => '', + 'e_quant6' => '1', + 'e_march7' => '', + 'e_march7_price' => '', + 'e_march7_tva_id' => '', + 'e_march7_tva_amount' => '', + 'e_quant7' => '1', + 'e_march8' => '', + 'e_march8_price' => '', + 'e_march8_tva_id' => '', + 'e_march8_tva_amount' => '', + 'e_quant8' => '1', + 'e_march9' => '', + 'e_march9_price' => '', + 'e_march9_tva_id' => '', + 'e_march9_tva_amount' => '', + 'e_quant9' => '1', + 'ac' => 'COMPTA/MENUACH/ACH', + 'bon_comm' => '', + 'other_info' => '', + 'opd_name' => '', + 'od_description' => '', + 'reverse_date' => '', + 'ext_label' => '', + 'jr_optype' => 'NOR', + 'action_gestion' => '', + 'record' => 'Enregistrement', + + ); + } /** @@ -458,6 +541,9 @@ class Acc_Ledger_PurchaseTest extends TestCase $g_connection->exec_sql("delete from jrn where jr_mt=$1", [$p_internal]); $g_connection->exec_sql("delete from jrnx where j_grpt not in (select jr_grpt_id from jrn)"); $g_connection->exec_sql("alter sequence s_jrn_pj3 restart with 52"); + // set TVA_RATE by default + $g_connection->exec_sql("update tva_rate set tva_poste='41142,45142' where tva_id=5"); + $g_connection->exec_sql("update tva_rate set tva_reverse_account=null where tva_id=5"); } /** @@ -476,4 +562,261 @@ class Acc_Ledger_PurchaseTest extends TestCase $ret=$this->object->get_detail_purchase(92,103,'unpaid'); $this->assertEquals(5,Database::num_row($ret),'only unpaid operations'); } + + /** + * @testdox Reverse VAT1 : find out the accounting when there is 2 accountings + * and column tva_reverse_account is null + * @covers Acc_Ledger_Sale::insert + */ + public function testInsertReverseVAT1() + { + global $g_connection; + + $array=$this->array; + // item 0 uses the tva_id = 5 + $array['e_march0_tva_id']=5; + $array["pa_id"]=array(2); + $array["op"]=array(0, 1); + $array["amount_t0"]=24.2; + $array["hplan"]=array(array(-1), array(-1)); + $array["val"]=array(array(24, 2), array(1212.5)); + $array["mt"]="1572704002.1732"; + $this->clean_operation(); + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",[$array["mt"]]); + $this->assertEquals(0,$cnt); + $this->object->insert($array); + + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",[$array["mt"]]); + $this->assertEquals(1,$cnt); + // check that the accounting for reverse VAT is 41142 and 45142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572704002.1732' + and j1.j_poste ='41142' + and j1.j_debit ='t' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account debit is wrong'); + + // check that the accounting for reverse VAT is 41142 and 45142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572704002.1732' + and j1.j_poste ='45142' + and j1.j_debit ='f' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account credit is wrong'); + + $this->clean_operation(); + + + } + /** + * @testdox Reverse VAT2 : find out the accounting when there is only 1 accounting + * and column tva_reverse_account is null + * @covers Acc_Ledger_Sale::insert + */ + public function testInsertReverseVAT2() + { + global $g_connection; + + $array=$this->array; + // item 0 uses the tva_id = 5 + $array['e_march0_tva_id']=5; + + + $array["pa_id"]=array(2); + $array["op"]=array(0, 1); + $array["amount_t0"]=24.2; + $array["hplan"]=array(array(-1), array(-1)); + $array["val"]=array(array(24, 2), array(1212.5)); + $array["mt"]="1572704002.1732"; + $this->clean_operation(); + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",[$array["mt"]]); + $this->assertEquals(0,$cnt); + + $g_connection->exec_sql("update tva_rate set tva_poste='41142,#' where tva_id=5"); + $this->object->insert($array); + + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",[$array["mt"]]); + $this->assertEquals(1,$cnt); + + + // check that the accounting for reverse VAT is only 41142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572704002.1732' + and j1.j_poste ='41142' + and j1.j_debit ='f' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account credit is wrong'); + + // check that the accounting for reverse VAT is only 45142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572704002.1732' + and j1.j_poste ='41142' + and j1.j_debit ='t' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account credit is wrong'); + + $this->clean_operation(); + + + } + /** + * @testdox Reverse VAT3 : use value from column tva_reverse_account is null + * @covers Acc_Ledger_Purchase::insert + */ + public function testInsertReverseVAT3() + { + global $g_connection; + + $array=$this->array; + // item 0 uses the tva_id = 5 + $array['e_march0_tva_id']=5; + + + $array["pa_id"]=array(2); + $array["op"]=array(0, 1); + $array["amount_t0"]=24.2; + $array["hplan"]=array(array(-1), array(-1)); + $array["val"]=array(array(24, 2), array(1212.5)); + $array["mt"]="1572704002.1732"; + $this->clean_operation(); + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",array($array["mt"])); + $this->assertEquals(0,$cnt); + + $g_connection->exec_sql("update tva_rate set tva_reverse_account='4119999' where tva_id=5"); + $this->object->insert($array); + + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",array($array["mt"])); + $this->assertEquals(1,$cnt); + + + // check that the accounting for reverse VAT is only 45142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572704002.1732' + and j1.j_poste ='4119999' + and j1.j_debit ='f' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account credit is wrong'); + + // check that the accounting for reverse VAT is only 45142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572704002.1732' + and j1.j_poste ='41142' + and j1.j_debit ='t' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account credit is wrong'); + + $this->clean_operation(); + + } + + /** + * @testdox Reverse VAT4 :Use 2 different VAT Autoreverse mix negative and positive amounts + * @covers Acc_Ledger_Sale::insert + * @return void + */ + function testInsertReverseVAT4() { + global $g_connection; + $array=$this->array1; + $old_autoreverse=$g_connection->get_value("select tva_both_side from tva_rate where tva_id=3 "); + // set autoreverse to 1 + $g_connection->get_value("update tva_rate set tva_both_side = 1 where tva_id=3 "); + + // clean + $g_connection->exec_sql("delete from jrn where jr_mt=$1",[1734717784.385]); + $this->object->insert($array); + + $accounting=new \Acc_Operation($g_connection); + $accounting->jr_id=$this->object->jr_id; + $aResult=$accounting->get_jrnx_detail(); + + $this->assertTrue(count($aResult)==7, 'Number of rows is '.count($aResult)."instead of 7"); + + foreach($aResult as $result) { + switch ($result['j_poste']) { + case '41142': + $this->assertEquals(25.20, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + case '6194': + if ( $result['debit']=='D') + $this->assertEquals(120, $result['j_montant'],"erreur account {$result['j_poste']}"); + else + $this->assertEquals(10, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + case '4400005': + $this->assertEquals(110, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + } + } + + // cancel change + $g_connection->get_value("update tva_rate set tva_both_side = $1 where tva_id=3 ",[$old_autoreverse]); + $g_connection->exec_sql("delete from jrn where jr_mt=$1",[1734717784.385]); + + + } + /** + * @testdox Reverse VAT5 :Use 2 same VAT Autoreverse mix negative and positive amounts + * @covers Acc_Ledger_Sale::insert + * @return void + */ + function testInsertReverseVAT5() { + global $g_connection; + $array=$this->array1; + + $array['e_march1_tva_id']=5; + + // clean + $g_connection->exec_sql("delete from jrn where jr_mt=$1",[1734717784.385]); + $this->object->insert($array); + + $accounting=new \Acc_Operation($g_connection); + $accounting->jr_id=$this->object->jr_id; + $aResult=$accounting->get_jrnx_detail(); + + $this->assertTrue(count($aResult)==7, 'Number of rows is '.count($aResult)."instead of 7"); + + foreach($aResult as $result) { + switch ($result['j_poste']) { + case '41142': + if ( $result['debit']=='D') + $this->assertEquals(25.20, $result['j_montant'],"erreur account {$result['j_poste']}"); + else + $this->assertEquals(2.1, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + case '6194': + if ( $result['debit']=='D') + $this->assertEquals(120, $result['j_montant'],"erreur account {$result['j_poste']}"); + else + $this->assertEquals(10, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + case '4400005': + $this->assertEquals(110, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + } + } + + // cancel change + + $g_connection->exec_sql("delete from jrn where jr_mt=$1",[1734717784.385]); + + + } } diff --git a/unit-test/include/class/acc_ledger_saleTest.php b/unit-test/include/class/acc_ledger_saleTest.php index a9965efe2..b9eb6756e 100644 --- a/unit-test/include/class/acc_ledger_saleTest.php +++ b/unit-test/include/class/acc_ledger_saleTest.php @@ -70,6 +70,45 @@ class Acc_Ledger_SaleTest extends TestCase "p_currency_rate"=>1, "p_currency_code"=>0, "view_invoice"=>"Enregistrer"); + // create accounting for reversed VAT + $g_connection->exec_sql(" + INSERT INTO public.tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent,pcm_type,pcm_direct_use) VALUES + ('4119999','TVA Test UNIT','411','ACT','Y') on conflict do nothing"); + // create accounting for reversed VAT with neg. amount + $this->array1=array( 'e_client' => 'CLIENT1', + 'nb_item' => '2', + 'p_jrn' => '2', + 'jrn_note_input' => '', + 'mt' => '1734720448.0036', + 'p_currency_rate' => '1', + 'p_currency_code' => '0', + 'e_comm' => '', + 'e_date' => '27.06.2020', + 'e_ech' => '', + 'e_pj' => 'VEN41', + 'e_pj_suggest' => 'VEN41', + 'e_mp' => '0', + 'jrn_type' => 'VEN', + 'e_march0' => 'DEPLAC', + 'e_march0_price' => '20', + 'e_march0_tva_id' => '5', + 'e_march0_tva_amount' => '0', + 'e_quant0' => '1', + 'e_march1' => 'DEPLAC', + 'e_march1_price' => '-5', + 'e_march1_tva_id' => '5', + 'e_march1_tva_amount' => '0', + 'e_quant1' => '1', + 'ac' => 'COMPTA/VENMENU/VEN', + 'bon_comm' => '', + 'other_info' => '', + 'opd_name' => '', + 'od_description' => '', + 'reverse_date' => '', + 'ext_label' => '', + 'jr_optype' => 'NOR', + 'action_gestion' => '', + 'record' => 'Enregistrement'); } /** @@ -101,6 +140,11 @@ class Acc_Ledger_SaleTest extends TestCase $g_connection->exec_sql("delete from jrnx where j_grpt not in (select jr_grpt_id from jrn)"); $g_connection->exec_sql("alter sequence s_jrn_pj2 restart with 40"); + // set TVA_RATE by default + $g_connection->exec_sql("update tva_rate set tva_poste='41142,45142' where tva_id=5"); + $g_connection->exec_sql("update tva_rate set tva_reverse_account=null where tva_id=5"); + + } /** * @covers Acc_Ledger_Sale::verify @@ -182,8 +226,169 @@ class Acc_Ledger_SaleTest extends TestCase $this->clean_operation(); } + /** + * @testdox Reverse VAT1 : find out the accounting when there is 2 accountings + * and column tva_reverse_account is null + * @covers Acc_Ledger_Sale::insert + */ + public function testInsertReverseVAT1() + { + global $g_connection; + + $array=$this->array; + // item 0 uses the tva_id = 5 + $array['e_march0_tva_id']=5; + $array["pa_id"]=array(2); + $array["op"]=array(0, 1); + $array["amount_t0"]=24.2; + $array["hplan"]=array(array(-1), array(-1)); + $array["val"]=array(array(24, 2), array(1212.5)); + $array["mt"]="1572714478.3155"; + $this->clean_operation(); + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",["1572714478.3155"]); + $this->assertEquals(0,$cnt); + $this->object->insert($array); + + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",["1572714478.3155"]); + $this->assertEquals(1,$cnt); + // check that the accounting for reverse VAT is 41142 and 45142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572714478.3155' + and j1.j_poste ='41142' + and j1.j_debit ='t' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account debit is wrong'); + + // check that the accounting for reverse VAT is 41142 and 45142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572714478.3155' + and j1.j_poste ='45142' + and j1.j_debit ='f' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account credit is wrong'); + + $this->clean_operation(); + } + /** + * @testdox Reverse VAT2 : find out the accounting when there is only 1 accounting + * and column tva_reverse_account is null + * @covers Acc_Ledger_Sale::insert + */ + public function testInsertReverseVAT2() + { + global $g_connection; + + $array=$this->array; + // item 0 uses the tva_id = 5 + $array['e_march0_tva_id']=5; + + + $array["pa_id"]=array(2); + $array["op"]=array(0, 1); + $array["amount_t0"]=24.2; + $array["hplan"]=array(array(-1), array(-1)); + $array["val"]=array(array(24, 2), array(1212.5)); + $array["mt"]="1572714478.3155"; + $this->clean_operation(); + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",["1572714478.3155"]); + $this->assertEquals(0,$cnt); + + $g_connection->exec_sql("update tva_rate set tva_poste='#,45142' where tva_id=5"); + $this->object->insert($array); + + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",["1572714478.3155"]); + $this->assertEquals(1,$cnt); + + + // check that the accounting for reverse VAT is only 45142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572714478.3155' + and j1.j_poste ='45142' + and j1.j_debit ='f' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account credit is wrong'); + + // check that the accounting for reverse VAT is only 45142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572714478.3155' + and j1.j_poste ='45142' + and j1.j_debit ='t' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account credit is wrong'); + + $this->clean_operation(); + + + } + /** + * @testdox Reverse VAT3 : use value from column tva_reverse_account is null + * @covers Acc_Ledger_Sale::insert + */ + public function testInsertReverseVAT3() + { + global $g_connection; + + $array=$this->array; + // item 0 uses the tva_id = 5 + $array['e_march0_tva_id']=5; + + + $array["pa_id"]=array(2); + $array["op"]=array(0, 1); + $array["amount_t0"]=24.2; + $array["hplan"]=array(array(-1), array(-1)); + $array["val"]=array(array(24, 2), array(1212.5)); + $array["mt"]="1572714478.3155"; + $this->clean_operation(); + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",["1572714478.3155"]); + $this->assertEquals(0,$cnt); + + $g_connection->exec_sql("update tva_rate set tva_reverse_account='4119999' where tva_id=5"); + $this->object->insert($array); + + $cnt=$g_connection->get_value("select count(*) from jrn where jr_mt=$1",["1572714478.3155"]); + $this->assertEquals(1,$cnt); + + + // check that the accounting for reverse VAT is only 45142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572714478.3155' + and j1.j_poste ='4119999' + and j1.j_debit ='t' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account credit is wrong'); + + // check that the accounting for reverse VAT is only 45142 + $sql=" + select count(*) + from jrnx j1 join jrn j2 on (j1.j_grpt=j2.jr_grpt_id) + where + j2.jr_mt ='1572714478.3155' + and j1.j_poste ='45142' + and j1.j_debit ='f' + "; + $this->assertEquals(1, $g_connection->get_value($sql),'fails : reversed account credit is wrong'); + + $this->clean_operation(); + + } /** * @covers Acc_Ledger_Sale::insert */ @@ -331,5 +536,100 @@ class Acc_Ledger_SaleTest extends TestCase $ret=$this->object->get_detail_sale(92,103,'unpaid'); $this->assertEquals(5,Database::num_row($ret),'only unpaid operations'); } + /** + * @testdox Reverse VAT4 :Use 2 different VAT Autoreverse mix negative and positive amounts + * @covers Acc_Ledger_Sale::insert + * @return void + */ + function testInsertReverseVAT4() { + global $g_connection; + $array=$this->array1; + $old_autoreverse=$g_connection->get_value("select tva_both_side from tva_rate where tva_id=3 "); + // set autoreverse to 1 + $g_connection->get_value("update tva_rate set tva_both_side = 1 where tva_id=3 "); + $array['e_march1_tva_id']=3; + // clean + $g_connection->exec_sql("delete from jrn where jr_mt=$1",[1734717784.385]); + $this->object->insert($array); + + $accounting=new \Acc_Operation($g_connection); + $accounting->jr_id=$this->object->jr_id; + $aResult=$accounting->get_jrnx_detail(); + + $this->assertTrue(count($aResult)==7, 'Number of rows is '.count($aResult)."instead of 7"); + + foreach($aResult as $result) { + switch ($result['j_poste']) { + case '41142': + if ( $result['debit']=='D') + $this->assertEquals(4.20, $result['j_montant'],"erreur account {$result['j_poste']}"); + else + $this->assertEquals(1.05, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + case '7000005': + if ( $result['debit']=='D') + $this->assertEquals(5, $result['j_montant'],"erreur account {$result['j_poste']}"); + else + $this->assertEquals(20, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + case '4000005': + $this->assertEquals(15, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + } + } + + // cancel change + $g_connection->get_value("update tva_rate set tva_both_side = $1 where tva_id=3 ",[$old_autoreverse]); + $g_connection->exec_sql("delete from jrn where jr_mt=$1",[$array['mt']]); + $g_connection->exec_sql('delete from jrnx where jrnx.j_grpt not in (select jr_grpt_id from jrn)'); + + } + /** + * @testdox Reverse VAT5 :Use 2 same VAT Autoreverse mix negative and positive amounts + * @covers Acc_Ledger_Sale::insert + * @return void + */ + function testInsertReverseVAT5() { + global $g_connection; + $array=$this->array1; + + $array['e_march1_tva_id']=5; + + // clean0 + $g_connection->exec_sql("delete from jrn where jr_mt=$1",[1734717784.385]); + $this->object->insert($array); + + $accounting=new \Acc_Operation($g_connection); + $accounting->jr_id=$this->object->jr_id; + $aResult=$accounting->get_jrnx_detail(); + + $this->assertTrue(count($aResult)==7, 'Number of rows is '.count($aResult)."instead of 7"); + + foreach($aResult as $result) { + switch ($result['j_poste']) { + case '41142': + if ( $result['debit']=='D') + $this->assertEquals(4.20, $result['j_montant'],"erreur account {$result['j_poste']}"); + else + $this->assertEquals(1.05, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + case '7000005': + if ( $result['debit']=='D') + $this->assertEquals(5, $result['j_montant'],"erreur account {$result['j_poste']}"); + else + $this->assertEquals(20, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + case '4000005': + $this->assertEquals(15, $result['j_montant'],"erreur account {$result['j_poste']}"); + break; + } + } + + // cancel change + + $g_connection->exec_sql("delete from jrn where jr_mt=$1",[$array['mt']]); + $g_connection->exec_sql('delete from jrnx where jrnx.j_grpt not in (select jr_grpt_id from jrn)'); + + } } diff --git a/unit-test/include/class/acc_letter.Test.php b/unit-test/include/class/acc_letterTest.php similarity index 99% rename from unit-test/include/class/acc_letter.Test.php rename to unit-test/include/class/acc_letterTest.php index 410a5a9b1..f6be39006 100644 --- a/unit-test/include/class/acc_letter.Test.php +++ b/unit-test/include/class/acc_letterTest.php @@ -33,7 +33,7 @@ use PHPUnit\Framework\TestCase; */ require DIRTEST.'/global.php'; -class Acc_Letter extends TestCase +class Acc_LetterTest extends TestCase { /** * @var Fiche