From f0de5689e7edbfe744408c3c4d17eebd54250e35 Mon Sep 17 00:00:00 2001 From: Dany wm Date: Wed, 6 Dec 2023 18:00:37 +0100 Subject: [PATCH 01/25] FIX : when taken from git NOALYSS_VERSION is undefined --- include/constant.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/constant.php b/include/constant.php index a5fd19ee9..dd4ec698c 100644 --- a/include/constant.php +++ b/include/constant.php @@ -90,6 +90,12 @@ $g_succeed = ""; define('SMALLX', '#xe816;'); define('BUTTONADD', "✚"); +// If noalyss_version is not defined it is likely directly taken from +// git and so this variable is not set, this cause some issue +if (! defined ("NOALYSS_VERSION")) +{ + define("NOALYSS_VERSION",9999); +} define('SVNINFO', NOALYSS_VERSION); if (!defined('DEBUGNOALYSS')) { define("DEBUGNOALYSS", 0); From 06673cfde7ac9792d4f5f3843e331a5ded94c276 Mon Sep 17 00:00:00 2001 From: Dany wm Date: Wed, 6 Dec 2023 18:02:56 +0100 Subject: [PATCH 02/25] FIX : default to use https --- include/constant.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/constant.php b/include/constant.php index dd4ec698c..48584f3e1 100644 --- a/include/constant.php +++ b/include/constant.php @@ -112,9 +112,9 @@ $version_noalyss = SVNINFO; // If you don't want to be notified of the update if (!defined("SITE_UPDATE")) - define("SITE_UPDATE", 'http://www.noalyss.eu/last_version.txt'); + define("SITE_UPDATE", 'https://www.noalyss.eu/last_version.txt'); if (!defined("SITE_UPDATE_PLUGIN")) - define("SITE_UPDATE_PLUGIN", 'http://www.noalyss.eu/plugin_last_version.txt'); + define("SITE_UPDATE_PLUGIN", 'https://www.noalyss.eu/plugin_last_version.txt'); if (!defined("NOALYSS_PACKAGE_REPOSITORY")) { define("NOALYSS_PACKAGE_REPOSITORY", "https://package.noalyss.eu/"); } From fc4ac725d0a65397ca79554161d449e6f9107530 Mon Sep 17 00:00:00 2001 From: Dany wm Date: Thu, 7 Dec 2023 21:41:12 +0100 Subject: [PATCH 03/25] Improve DBG , add stopwatch : timer_start and timer_show --- include/lib/dbg.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/lib/dbg.php b/include/lib/dbg.php index b5ac58d43..a0570b104 100644 --- a/include/lib/dbg.php +++ b/include/lib/dbg.php @@ -134,5 +134,20 @@ EOF; EOF; return $r; } + + public static function timer_start() + { + global $timer; + $timer=hrtime(true); + } + public static function timer_show() + { + global $timer; + // $delta=$timer-microtime(true) ; + echo ''; + echo _("Temps écoulé : "); + echo (hrtime(true)-$timer)/1e+6; + echo ''; + } } ?> From faf7124306adffe7cc36e03799175e0a3014a7d3 Mon Sep 17 00:00:00 2001 From: Dany wm Date: Wed, 6 Dec 2023 18:00:37 +0100 Subject: [PATCH 04/25] FIX : when taken from git NOALYSS_VERSION is undefined --- include/constant.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/constant.php b/include/constant.php index a5fd19ee9..dd4ec698c 100644 --- a/include/constant.php +++ b/include/constant.php @@ -90,6 +90,12 @@ $g_succeed = ""; define('SMALLX', '#xe816;'); define('BUTTONADD', "✚"); +// If noalyss_version is not defined it is likely directly taken from +// git and so this variable is not set, this cause some issue +if (! defined ("NOALYSS_VERSION")) +{ + define("NOALYSS_VERSION",9999); +} define('SVNINFO', NOALYSS_VERSION); if (!defined('DEBUGNOALYSS')) { define("DEBUGNOALYSS", 0); From 3c570c042b91e50d042e4806472a0509dfb93f93 Mon Sep 17 00:00:00 2001 From: Dany wm Date: Thu, 7 Dec 2023 21:41:12 +0100 Subject: [PATCH 05/25] Improve DBG , add stopwatch : timer_start and timer_show --- include/lib/dbg.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/lib/dbg.php b/include/lib/dbg.php index b5ac58d43..a0570b104 100644 --- a/include/lib/dbg.php +++ b/include/lib/dbg.php @@ -134,5 +134,20 @@ EOF; EOF; return $r; } + + public static function timer_start() + { + global $timer; + $timer=hrtime(true); + } + public static function timer_show() + { + global $timer; + // $delta=$timer-microtime(true) ; + echo ''; + echo _("Temps écoulé : "); + echo (hrtime(true)-$timer)/1e+6; + echo ''; + } } ?> From 7eb593b0531540e0a899a476f11f2243ba7bff4d Mon Sep 17 00:00:00 2001 From: Dany wm Date: Thu, 7 Dec 2023 21:43:06 +0100 Subject: [PATCH 06/25] Improve DatabaseCore : fetch_all --- include/lib/database_core.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/lib/database_core.class.php b/include/lib/database_core.class.php index 36eb417d5..0510ce1b6 100644 --- a/include/lib/database_core.class.php +++ b/include/lib/database_core.class.php @@ -764,7 +764,7 @@ class DatabaseCore static function fetch_all($ret) { - return pg_fetch_all($ret); + return pg_fetch_all($ret,PGSQL_ASSOC); } /**\brief wrapper for the function pg_fetch_all From 46a7a72d19581b09c2458fb0951bc17f49e86df6 Mon Sep 17 00:00:00 2001 From: Dany wm Date: Thu, 7 Dec 2023 16:49:40 +0100 Subject: [PATCH 07/25] PRINTGL Main Ledger (GL) improve performance and code prepare the SQL , better filter for accounting --- include/class/acc_account_ledger.class.php | 200 +++++++++++++----- include/export/export_gl_csv.php | 43 +--- include/export/export_gl_pdf.php | 45 +--- include/impress_gl_comptes.inc.php | 70 +++--- ...er.Test.php => acc_account_ledgerTest.php} | 29 +++ 5 files changed, 221 insertions(+), 166 deletions(-) rename unit-test/include/class/{acc_account_ledger.Test.php => acc_account_ledgerTest.php} (91%) diff --git a/include/class/acc_account_ledger.class.php b/include/class/acc_account_ledger.class.php index eb51c051b..f496d3be0 100644 --- a/include/class/acc_account_ledger.class.php +++ b/include/class/acc_account_ledger.class.php @@ -111,55 +111,18 @@ class Acc_Account_Ledger } return array($this->row,$this->tot_deb,$this->tot_cred); } - /*! - * \brief Get data for accounting entry between 2 date - * - *\param $p_from date from DD.MM.YYYY - *\param $p_to end date DD.MM.YYYY - *\param $let 0 means all rows, 1 only lettered, 2 only unlettered - *\param $solded 0 means all account, 1 means only accounts with a saldo <> 0 - *\note the data are filtered by the access of the current user - * \return double array (j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal) - * (tot_deb,tot_credit - * + /** + * @brief build the SQL for get_row_data + * @param $p_from date d.m.Y start date + * @param $p_to date d.m.Y until date + * @param $sql_let sql string for getting lettering info + * @param $filter_sql string SQL for filtering the ledgers , to respect security on ledgers + * @return sql SELECT */ - function get_row_date($p_from,$p_to,$let=0,$solded=0) + function make_sql_accounting_detail($p_from,$p_to,$sql_let,$filter_sql) { - global $g_user; - $filter_sql=$g_user->get_ledger_sql('ALL',3); - $sql_let=''; - switch ($let) - { - case 0: - break; - case 1: - $sql_let=' and j1.j_id in (select j_id from letter_cred union all select j_id from letter_deb)'; - break; - case '2': - $sql_let=' and j1.j_id not in (select j_id from letter_cred union all select j_id from letter_deb) '; - break; - } - if ( $solded == 1) - { - $filter=str_replace('jrn_def_id','jr_def_id',$filter_sql); - $bal_sql="select sum(amount_deb) as s_deb,sum(amount_cred) as s_cred, j_poste - from - (select case when j_debit='t' then j_montant else 0 end as amount_deb, - case when j_debit='f' then j_montant else 0 end as amount_cred, - j_poste - from jrnx join jrn on (j_grpt = jr_grpt_id) - where - j_poste=$1 and - $filter and - ( to_date($2,'DD.MM.YYYY') <= j_date and - to_date($3,'DD.MM.YYYY') >= j_date )) as signed_amount - group by j_poste - "; - $r=$this->db->get_array($bal_sql,array($this->id,$p_from,$p_to)); - if ( $this->db->count() == 0 ) return array(); - if ($r[0]['s_deb']==$r[0]['s_cred']) return array(); - } - $this->row=$this->db->get_array(" + + $sql = " with sqlletter as (select j_id,jl_id from letter_cred union all select j_id , jl_id from letter_deb ) select j1.j_id,jr_id,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,j_date, j_qcode @@ -200,8 +163,43 @@ class Acc_Account_Ledger ( to_date($2,'DD.MM.YYYY') <= j_date and to_date($3,'DD.MM.YYYY') >= j_date ) and $filter_sql $sql_let - order by j_date,substring(jr_pj_number,'[0-9]+$') asc",array($this->id,$p_from,$p_to)); - $res_saldo = $this->db->exec_sql("select sum(deb_montant),sum(cred_montant) from + order by j_date,substring(jr_pj_number,'[0-9]+$') asc"; + return $sql; + } + + /** + * @brief make the SQL for the balanced accounting + * @param $filter filter to respect the security on ledger + * @return sql SELECT + */ + public function make_sql_not_balanced_account($filter) + { + $bal_sql="select sum(amount_deb) as s_deb,sum(amount_cred) as s_cred, j_poste + from + (select case when j_debit='t' then j_montant else 0 end as amount_deb, + case when j_debit='f' then j_montant else 0 end as amount_cred, + j_poste + from jrnx join jrn on (j_grpt = jr_grpt_id) + where + j_poste=$1 and + $filter and + ( to_date($2,'DD.MM.YYYY') <= j_date and + to_date($3,'DD.MM.YYYY') >= j_date )) as signed_amount + group by j_poste + "; + return $bal_sql; + } + + /** + * @brief make the SQL for the balance of an accounting + * @param $filter_sql filter to respect the security on ledger + * @param $sql_let string for getting lettering info + * @return sql SELECT + * + */ + public function make_sql_saldo_account($filter_sql,$sql_let) + { + $sql_saldo="select sum(deb_montant),sum(cred_montant) from (select case when j_debit='t' then j_montant else 0 end as deb_montant, case when j_debit='f' then j_montant else 0 end as cred_montant from jrnx j1 @@ -212,14 +210,73 @@ class Acc_Account_Ledger where j_poste=$1 and ( to_date($2,'DD.MM.YYYY') <= j_date and to_date($3,'DD.MM.YYYY') >= j_date ) - and $filter_sql $sql_let ) as m",array($this->id,$p_from,$p_to)); - $this->tot_deb=$this->tot_cred=0; - - if ( Database::num_row($res_saldo) > 0 ) { - $this->tot_deb=Database::fetch_result($res_saldo, 0, 0); - $this->tot_cred=Database::fetch_result($res_saldo, 0, 1); + and $filter_sql $sql_let ) as m"; + return $sql_saldo; + } + /*! + * \brief Get data for accounting entry between 2 date + * + *\param $p_from date from DD.MM.YYYY + *\param $p_to end date DD.MM.YYYY + *\param $let 0 means all rows, 1 only lettered, 2 only unlettered + *\param $solded 0 means all account, 1 means only accounts with a saldo <> 0 + *\note the data are filtered by the access of the current user + * \return double array (j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal) + * (tot_deb,tot_credit + * + */ + function get_row_date($p_from, $p_to, $let = 0, $solded = 0) + { + global $g_user; + $filter_sql = $g_user->get_ledger_sql('ALL', 3); + $sql_let = ''; + switch ($let) { + case 0: + break; + case 1: + $sql_let = ' and j1.j_id in (select j_id from letter_cred union all select j_id from letter_deb)'; + break; + case '2': + $sql_let = ' and j1.j_id not in (select j_id from letter_cred union all select j_id from letter_deb) '; + break; } - return array($this->row,$this->tot_deb,$this->tot_cred); + // if accounting is balanced , D = C then returns an empty array + if ($solded == 1) { + if ($this->db->is_prepare("not_balanced_account") == false) { + $filter = str_replace('jrn_def_id', 'jr_def_id', $filter_sql); + $sql_balanced = $this->make_sql_not_balanced_account($filter); + $this->db->prepare("not_balanced_account", $sql_balanced); + } + + $ret_balanced = $this->db->execute("not_balanced_account", array($this->id, $p_from, $p_to)); + + $r = Database::fetch_all($ret_balanced); + if (empty($r)) return array(); + if ($r[0]['s_deb'] == $r[0]['s_cred']) return array(); + } + + // get the detail of accouting + if (!$this->db->is_prepare("sql_accounting_detail")) { + $sql = $this->make_sql_accounting_detail($p_from, $p_to, $sql_let, $filter_sql); + $this->db->prepare("sql_accounting_detail", $sql); + + } + $ret = $this->db->execute("sql_accounting_detail", array($this->id, $p_from, $p_to)); + $this->row = Database::fetch_all($ret); + + // $this->row=$this->db->get_array(,array($this->id,$p_from,$p_to)); + if ($this->db->is_prepare("saldo_account") == false) { + $sql_saldo = $this->make_sql_saldo_account($filter_sql, $sql_let); + $this->db->prepare("saldo_account", $sql_saldo); + } + $res_saldo = $this->db->execute("saldo_account", array($this->id, $p_from, $p_to)); + $this->tot_deb = $this->tot_cred = 0; + + if (Database::num_row($res_saldo) > 0) { + $this->tot_deb = Database::fetch_result($res_saldo, 0, 0); + $this->tot_cred = Database::fetch_result($res_saldo, 0, 1); + } + return array($this->row, $this->tot_deb, $this->tot_cred); } @@ -784,5 +841,34 @@ class Acc_Account_Ledger function filter_history($p_table_id) { return _('Filtre rapide').' '.HtmlInput::filter_table($p_table_id, '0,1,2,3,4,5,6,7,8,9,10', 1); } - + + public static function get_used_accounting($from_date, $to_date, $from_accounting, $to_accounting) + { + // check date + if (isDate($from_date) != $from_date || isDate($to_date) != $to_date) { + return array(); + } + // build query + $sql = "select pcm_val,pcm_lib from tmp_pcmn + where pcm_val in + (select j_poste from jrnx where j_date >= to_date('$from_date','DD.MM.YYYY') + and j_date <= to_date('$to_date','DD.MM.YYYY') ) "; + $cond_poste=""; + if ($from_accounting != '') { + $cond_poste .= "and pcm_val >= upper ('" . Database::escape_string($from_accounting) . "')"; + } + + if ($to_accounting != '') { + $cond_poste .= " and pcm_val <= upper ('" . Database::escape_string($to_accounting) . "')"; + } + + $sql = $sql . $cond_poste . ' order by pcm_val::text'; + + // get array + $cn=Dossier::connect(); + $a_poste = $cn->get_array($sql); + // return array + return $a_poste; + + } } diff --git a/include/export/export_gl_csv.php b/include/export/export_gl_csv.php index 995a68d79..98a7411da 100644 --- a/include/export/export_gl_csv.php +++ b/include/export/export_gl_csv.php @@ -53,33 +53,12 @@ $gDossier=dossier::id(); $cn=Dossier::connect(); $export=new Noalyss_Csv(_('grandlivre')); -$poste_id=$http->get('poste_id',"string",""); +$accounting_item_id=$http->get('poste_id',"string",""); $export->send_header(); - $cond_poste=''; - $sql="select pcm_val from tmp_pcmn "; - if ($from_poste != '') - { - $cond_poste = ' where '; - $cond_poste .=" pcm_val >= upper ('".Database::escape_string($from_poste)."')"; - } - if ( $to_poste != '') - { - if ( $cond_poste == '') - { - $cond_poste = " where pcm_val <= upper ('".Database::escape_string($to_poste)."')"; - } - else - { - $cond_poste.=" and pcm_val <= upper ('".Database::escape_string($to_poste)."')"; - } - } +$a_accounting=Acc_Account_Ledger::get_used_accounting($from_periode,$to_periode,$from_poste,$to_poste); - $sql=$sql.$cond_poste.' order by pcm_val::text'; - - $a_poste=$cn->get_array($sql); - -if ( count($a_poste) == 0 ) +if ( count($a_accounting) == 0 ) { echo _('Aucun résultat'); printf("\n"); @@ -92,13 +71,13 @@ $header = array( _("Date"), _("Référence"), _("Libellé"), _("Pièce"),_("Lett $l=(isset($_GET['letter']))?2:0; $s=(isset($_REQUEST['solded']))?1:0; -foreach ($a_poste as $poste) +foreach ($a_accounting as $accounting_item) { - $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']); + $acc_account_ledger=new Acc_Account_Ledger($cn,$accounting_item['pcm_val']); - $array1=$Poste->get_row_date($from_periode,$to_periode,$l,$s); + $array1=$acc_account_ledger->get_row_date($from_periode,$to_periode,$l,$s); // don't print empty account if ( count($array1) == 0 ) { @@ -114,7 +93,7 @@ foreach ($a_poste as $poste) continue; } - $export->add(sprintf("%s - %s ",$Poste->id,$Poste->get_name())); + $export->add(sprintf("%s - %s ",$accounting_item['pcm_val'],$accounting_item['pcm_lib'])); $export->write(); $export->write_header($header); @@ -123,7 +102,7 @@ foreach ($a_poste as $poste) $solde_c = 0.0; bcscale(2); $current_exercice=""; - foreach ($Poste->row as $detail) + foreach ($acc_account_ledger->row as $detail) { /* @@ -148,7 +127,7 @@ foreach ($a_poste as $poste) $export->add($current_exercice); $export->add(""); $export->add(""); - $export->add(_('Total')." ".$Poste->id); + $export->add(_('Total')." ".$acc_account_ledger->id); if ( $solde_d > 0 ) { $export->add($solde_d,"number"); } else { @@ -200,7 +179,7 @@ foreach ($a_poste as $poste) else $export->add(""); $export->add(abs($solde),"number"); - $export->add($Poste->get_amount_side($solde),"text"); + $export->add($acc_account_ledger->get_amount_side($solde),"text"); $export->write(); } @@ -210,7 +189,7 @@ foreach ($a_poste as $poste) $export->add($current_exercice); $export->add(""); $export->add(""); - $export->add(_('Total').$Poste->id); + $export->add(_('Total').$acc_account_ledger->id); if ($solde_d > 0 ) $export->add($solde_d,"number"); else $export->add(""); if ($solde_c > 0 ) $export->add($solde_c,"number"); else $export->add(""); $export->add(abs($solde_c-$solde_d),"number"); diff --git a/include/export/export_gl_pdf.php b/include/export/export_gl_pdf.php index 531a9ef9d..24578f883 100644 --- a/include/export/export_gl_pdf.php +++ b/include/export/export_gl_pdf.php @@ -41,29 +41,7 @@ $cn=Dossier::connect(); $g_user->Check(); $g_user->check_dossier($gDossier); -$sql="select pcm_val from tmp_pcmn "; - -$cond_poste=""; -if ($from_poste != '') - { - $cond_poste = ' where '; - $cond_poste .=' pcm_val >= upper (\''.Database::escape_string($from_poste).'\')'; - } - -if ( $to_poste != '') - { - if ( $cond_poste == '') - { - $cond_poste = ' where pcm_val <= upper (\''.Database::escape_string($to_poste).'\')'; - } - else - { - $cond_poste.=' and pcm_val <= upper (\''.Database::escape_string($to_poste).'\')'; - } - } - -$sql=$sql.$cond_poste.' order by pcm_val::text'; -$a_poste=$cn->get_array($sql); +$a_accounting=Acc_Account_Ledger::get_used_accounting($from_periode,$to_periode,$from_poste,$to_poste); $pdf = new PDF($cn); $pdf->setDossierInfo(_(" Periode : ").$from_periode." - ".$to_periode); @@ -72,7 +50,7 @@ $pdf->AddPage(); $pdf->setTitle("Grand Livre",true); $pdf->SetAuthor('NOALYSS'); -if ( count($a_poste) == 0 ) +if ( count($a_accounting) == 0 ) { $pdf->Output(); return; @@ -87,13 +65,12 @@ $width = array( 13 , 20 , 60 , 15 , 12 , 20 , 20 $l=(isset($_REQUEST['letter']))?2:0; $s=(isset($_REQUEST['solded']))?1:0; -foreach ($a_poste as $poste) +foreach ($a_accounting as $accounting_item) { - $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']); - - - $array1=$Poste->get_row_date($from_periode,$to_periode,$l,$s); + $acc_account_ledger=new Acc_Account_Ledger($cn,$accounting_item['pcm_val']); + + $array1=$acc_account_ledger->get_row_date($from_periode,$to_periode,$l,$s); // don't print empty account if (empty($array1) || count($array1[0]) == 0 ) { @@ -104,7 +81,7 @@ foreach ($a_poste as $poste) $tot_cred=$array1[2]; $pdf->SetFont('DejaVuCond','',10); - $Libelle=sprintf("%s - %s ",$Poste->id,$Poste->get_name()); + $Libelle=sprintf("%s - %s ",$accounting_item['pcm_val'],$accounting_item['pcm_lib']); $pdf->write_cell(0, 7, $Libelle, 1, 1, 'C'); $pdf->SetFont('DejaVuCond','',6); @@ -119,7 +96,7 @@ foreach ($a_poste as $poste) $solde_d = 0.0; $solde_c = 0.0; $current_exercice=""; - foreach ($Poste->row as $detail) + foreach ($acc_account_ledger->row as $detail) { /* @@ -151,7 +128,7 @@ foreach ($a_poste as $poste) $i++; $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]); $i++; - $pdf->write_cell($width[$i], 6, 'Total du compte '.$Poste->id, 0, 0, 'R'); + $pdf->write_cell($width[$i], 6, 'Total du compte '.$acc_account_ledger->id, 0, 0, 'R'); $i++; $pdf->write_cell($width[$i], 6, ($solde_d > 0 ? nbm($solde_d) : ''), 0, 0, $lor[$i]); $i++; @@ -184,7 +161,7 @@ foreach ($a_poste as $poste) } $i = 0; - $side=" ".$Poste->get_amount_side($solde); + $side=" ".$acc_account_ledger->get_amount_side($solde); $pdf->LongLine($width[$i], 6, shrink_date($detail['j_date_fmt']), 0, $lor[$i]); $i++; $pdf->LongLine($width[$i], 6, $detail['jr_internal'], 0, $lor[$i] ); @@ -220,7 +197,7 @@ foreach ($a_poste as $poste) $i++; $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]); $i++; - $pdf->write_cell($width[$i], 6, 'Total du compte '.$Poste->id, 0, 0, 'R'); + $pdf->write_cell($width[$i], 6, 'Total du compte '.$acc_account_ledger->id, 0, 0, 'R'); $i++; $pdf->write_cell($width[$i], 6, ($solde_d > 0 ? nbm($solde_d) : ''), 0, 0, $lor[$i]); $i++; diff --git a/include/impress_gl_comptes.inc.php b/include/impress_gl_comptes.inc.php index d9122c232..84e0855bb 100644 --- a/include/impress_gl_comptes.inc.php +++ b/include/impress_gl_comptes.inc.php @@ -104,44 +104,29 @@ echo ''; //----------------------------------------------------- if ( isset( $_REQUEST['bt_html'] ) ) { + if ( DEBUGNOALYSS > 1 ) \Noalyss\Dbg::timer_start(); + echo '
'; echo Acc_Account_Ledger::HtmlTableHeader("gl_comptes"); echo '
'; - $sql='select pcm_val from tmp_pcmn '; - $cond_poste=''; + try { + $from_periode=$http->request("from_periode","date"); + $to_periode=$http->request("to_periode","date"); - if ($from_poste->value != '') - { - $cond_poste = ' where '; - $cond_poste .=' pcm_val >= upper (\''.Database::escape_string($from_poste->value).'\')'; - } - - if ( $to_poste->value != '') - { - if ( $cond_poste == '') - { - $cond_poste = ' where pcm_val <= upper (\''.Database::escape_string($to_poste->value).'\')'; - } - else - { - $cond_poste.=' and pcm_val <= upper (\''.Database::escape_string($to_poste->value).'\')'; - } - } - - $sql=$sql.$cond_poste.' order by pcm_val::text'; - - $a_poste=$cn->get_array($sql); - - if ( sizeof($a_poste) == 0 ) - { - die("Nothing here. Strange."); - exit; - } - if ( isDate($_REQUEST['from_periode'])==null || isDate($_REQUEST['to_periode'])==null) - { + } catch (Exception $e) { echo alert(_('Date malformée, désolée')); return; } + + + $a_accounting=Acc_Account_Ledger::get_used_accounting($from_periode,$to_periode,$from_poste->value,$to_poste->value); + + if ( sizeof($a_accounting) == 0 ) + { + echo_warning(_("Aucune donnée")); + return; + } + echo '
'; @@ -150,14 +135,12 @@ if ( isset( $_REQUEST['bt_html'] ) ) $s=(isset($_REQUEST['solded']))?1:0; - foreach ($a_poste as $poste_id ) + foreach ($a_accounting as $accounting_id ) { - $Poste=new Acc_Account_Ledger ($cn, $poste_id['pcm_val']); - $Poste->load(); + $acc_account_ledger=new Acc_Account_Ledger ($cn, $accounting_id['pcm_val']); - - $Poste->get_row_date( $_GET['from_periode'], $_GET['to_periode'],$l,$s); - if ( empty($Poste->row)) + $acc_account_ledger->get_row_date( $from_periode, $to_periode,$l,$s); + if ( empty($acc_account_ledger->row)) { continue; } @@ -165,7 +148,7 @@ if ( isset( $_REQUEST['bt_html'] ) ) echo ' -

'. $poste_id['pcm_val'].' '.h($Poste->label).'

+

'. $accounting_id['pcm_val'].' '.h($accounting_id['pcm_lib']).'

'; @@ -188,7 +171,7 @@ if ( isset( $_REQUEST['bt_html'] ) ) $i=0; $current_exercice=""; - foreach ($Poste->row as $detail) + foreach ($acc_account_ledger->row as $detail) { /* * separation per exercice @@ -199,7 +182,7 @@ if ( isset( $_REQUEST['bt_html'] ) ) echo ' '.$current_exercice.' '.''.' - '._("Total du compte").$poste_id['pcm_val'].' + '._("Total du compte").$accounting_id['pcm_val'].' '.''.''.td(""). ''.($solde_d > 0 ? nbm( $solde_d) : '').' '.($solde_c > 0 ? nbm( $solde_c) : '').' @@ -232,7 +215,7 @@ if ( isset( $_REQUEST['bt_html'] ) ) $solde = bcadd($solde,$detail['deb_montant']); $solde_d = bcadd($solde_d,$detail['deb_montant']); } - $side=" ".$Poste->get_amount_side($solde); + $side=" ".$acc_account_ledger->get_amount_side($solde); $letter=""; $html_let=""; if ($detail['letter'] > 0) { @@ -256,7 +239,7 @@ if ( isset( $_REQUEST['bt_html'] ) ) echo ' '.$current_exercice.' '.''.' - '.''.'Total du compte '.$poste_id['pcm_val'].''.' + '.''.'Total du compte '.$accounting_id['pcm_val'].''.' '.''.''.td(""). ''.''.($solde_d > 0 ? nbm( $solde_d) : '').''.' '.''.($solde_c > 0 ? nbm( $solde_c) : '').''.' @@ -272,6 +255,7 @@ if ( isset( $_REQUEST['bt_html'] ) ) echo ''; echo Acc_Account_Ledger::HtmlTableHeader("gl_comptes"); echo "
"; - exit; + if ( DEBUGNOALYSS > 1 ) \Noalyss\Dbg::timer_show(); + return; } ?> diff --git a/unit-test/include/class/acc_account_ledger.Test.php b/unit-test/include/class/acc_account_ledgerTest.php similarity index 91% rename from unit-test/include/class/acc_account_ledger.Test.php rename to unit-test/include/class/acc_account_ledgerTest.php index 309524755..5021476cd 100644 --- a/unit-test/include/class/acc_account_ledger.Test.php +++ b/unit-test/include/class/acc_account_ledgerTest.php @@ -451,5 +451,34 @@ class Acc_Account_LedgerTest extends TestCase $result=$this->object->find_card(); $this->assertEquals($p_card, $result[0]['f_id']); } + public function dataGet_used_accounting() + { + $array=array( + ["01.01.2020","31.12.2020",5,7,4] + ,["01.01.2019","31.12.2020",5,7,10] + ,["01.01.2019","31.12.2020",5,6,3] + ,["01.01.2019","31.12.2020",5,5,0] + ,["01.01.2019","31.12.2020",5,2,0] + ,["01.01.2019","31.12.2020",5,2,0] + ,["01.01.2019","31.14.2020",5,7,0] + ,["01.13.2019","31.14.2020",5,7,0] + ); + return $array; + } + /** + * @brief test function Acc_Account_Ledger::get_used_accounting + * @covers Acc_Account_Ledger::get_used_accounting + * @dataProvider dataGet_used_accounting + */ + public function testGet_UsedAcccounting($from_date,$to_date,$from_accounting,$to_accounting,$nb_accounting) + { + $a_result=Acc_Account_Ledger::get_used_accounting(from_date:$from_date + ,to_date:$to_date + ,from_accounting:$from_accounting + ,to_accounting:$to_accounting); + $this->assertEquals($nb_accounting,count($a_result) + ,"number of accounting incorrect for (\$from_date,\$to_date,\$from_accounting,\$to_accounting,\$nb_accounting : ($from_date,$to_date,$from_accounting,$to_accounting,$nb_accounting"); + + } } From 454b526c592bce93f4b75c1aecee66cdeadb8beb Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 13 Jan 2024 18:46:37 +0100 Subject: [PATCH 08/25] Task 2128 : Ouverture et cloture toujours visible --- .../operation_exercice-input_source.php | 20 ++++++++----------- .../operation_exercice-list_draft.php | 1 + 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/template/operation_exercice-input_source.php b/include/template/operation_exercice-input_source.php index 35a43661b..ed472a5c6 100644 --- a/include/template/operation_exercice-input_source.php +++ b/include/template/operation_exercice-input_source.php @@ -30,15 +30,15 @@ global $g_user; global $g_parameter; //------------------------------------------------------------------------------------------- -// if DEBUG then show both , otherwise if MY_REPORT=Y shows opening otherwise , shows only closing -// Show opening if report == Y or NOALYSS > 1 +// +// Show opening //------------------------------------------------------------------------------------------- -if ( $g_parameter->MY_REPORT=="Y" || DEBUGNOALYSS > 1) : + ?>
-
+
@@ -91,15 +91,14 @@ if ( $g_parameter->MY_REPORT=="Y" || DEBUGNOALYSS > 1) :
1 +// Show closing //------------------------------------------------------------------------------------------- -if ( $g_parameter->MY_REPORT=="N" || DEBUGNOALYSS > 1) : ?>
-
+
@@ -123,7 +122,4 @@ if ( $g_parameter->MY_REPORT=="N" || DEBUGNOALYSS > 1) :
-
- \ No newline at end of file +
\ No newline at end of file diff --git a/include/template/operation_exercice-list_draft.php b/include/template/operation_exercice-list_draft.php index 2b176b6f1..003c9bfce 100644 --- a/include/template/operation_exercice-list_draft.php +++ b/include/template/operation_exercice-list_draft.php @@ -37,6 +37,7 @@ $aUrl = ["ac" => $http->request("ac"), "gDossier" => Dossier::id()]; $checkbox=new ICheckBox("operation_list[]"); $checkbox->set_range("operation_range"); ?> +

Date: Sat, 13 Jan 2024 18:47:42 +0100 Subject: [PATCH 09/25] Get empty upgrade.sql --- sql/upgrade.sql | 96 ------------------------------------------------- 1 file changed, 96 deletions(-) diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 03abdc0a2..e69de29bb 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,96 +0,0 @@ - - --- protect against wrong card in fiche_detail - -CREATE OR REPLACE FUNCTION comptaproc.fiche_detail_check_qcode() - RETURNS trigger - LANGUAGE plpgsql -AS $function$ -declare - i record; -begin - if NEW.ad_id=23 and NEW.ad_value != OLD.ad_value then - update jrnx set j_qcode=NEW.ad_value where j_qcode = OLD.ad_value; - update op_predef_detail set opd_poste=NEW.ad_value where opd_poste=OLD.ad_value; - for i in select ad_id from attr_def where ad_type = 'card' or ad_id=25 loop - update fiche_detail set ad_value=NEW.ad_value where ad_value=OLD.ad_value and ad_id=i.ad_id; - if i.ad_id=19 then - update stock_goods set sg_code=NEW.ad_value where sg_code=OLD.ad_value; - end if; - - end loop; - end if; -return NEW; -end; -$function$; - -drop trigger if exists fiche_detail_check_qcode_trg on public.fiche_detail ; -drop function comptaproc.fiche_detail_qcode_upd(); - -create trigger fiche_detail_check_qcode_trg before insert -or update on -public.fiche_detail for each row execute function comptaproc.fiche_detail_check_qcode(); - - - -update fiche_detail set ad_value=ad_value where ad_id in (select ad_id from attr_def where ad_type='card'); - -insert into parameter values ('MY_REPORT','N') ON CONFLICT DO NOTHING; - -update menu_ref set me_file='payment_method.inc.php' where me_code='CFGPAY'; - -update menu_ref set me_menu='Principal' where me_code='COMPANY'; -update menu_ref set me_menu='Financier' where me_code='MENUFIN'; - -CREATE OR REPLACE FUNCTION comptaproc.set_tech_user() - RETURNS trigger -AS $function$ -declare - /* variable */ - noalyss_user text; -begin - new.tech_user := current_setting('noalyss.user_login'); - new.tech_date := now(); - return NEW; - -exception when others then - new.tech_date := now(); - new.tech_user := current_user; - return NEW; -end ; -$function$ -LANGUAGE plpgsql; - -drop table if exists operation_exercice_detail; -drop table if exists operation_exercice; - -create table operation_exercice -( - oe_id bigint generated by default as identity primary key, - oe_date date null, - oe_type text not null check (oe_type = 'opening' or oe_type = 'closing'), - oe_text text , - oe_dossier_id int not null, - oe_exercice int not null, - jr_internal text, - oe_transfer_date timestamp, - tech_user text, - tech_date timestamp default now() -); - -create table operation_exercice_detail -( - oed_id bigint generated by default as identity primary key, - oe_id bigint references operation_exercice (oe_id) on update cascade on delete cascade not null, - oed_poste account_type , - oed_qcode text , - oed_label text, - oed_amount numeric (20,4), - oed_debit bool -); - -create trigger trg_set_tech_user before insert or update on operation_exercice for each row execute function comptaproc.set_tech_user(); - -update menu_ref set me_code='OPCL' , me_menu='Ouvert./Fermeture',me_file='operation_exercice.inc.php',me_description='Opération de cloture ou d''ouverture d''exercice' - ,me_description_etendue ='Ecriture d''ouverture ou de fermeture , , reporte les soldes des comptes de l''année passé du poste comptable 0xxx à 5xxxx sur l''année courante ou ferme les comptes de 6 à 7 de l''année ' -where me_code='OPEN'; \ No newline at end of file From 68a265fb29ab91a4d1d704a78be0e8b46343308c Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 13 Jan 2024 18:53:43 +0100 Subject: [PATCH 10/25] Bug #0002322: Impression Suivi --- include/category_card.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/category_card.inc.php b/include/category_card.inc.php index 2edbfc168..7ef76e00c 100644 --- a/include/category_card.inc.php +++ b/include/category_card.inc.php @@ -85,7 +85,7 @@ $menu[]=array('href'=>$root.'&sc=bal', 'label'=>_('Balance'), 'alt'=>_('Balance $menu[]=array('href'=>$root.'&sc=balag', 'label'=>_('Balance âgée'), 'alt'=>_('Balance âgée du tiers')); $menu[]=array('href'=>$root.'&sc=let', 'label'=>_('Lettrage'), 'alt'=>_('Opérations & Lettrages')); -echo '
    '; +echo '
      '; for ($i=0; $i Date: Sun, 14 Jan 2024 22:32:17 +0100 Subject: [PATCH 11/25] =?UTF-8?q?Task=20#0002327:=20Balance=20:=20indiqu?= =?UTF-8?q?=C3=A9=20si=20le=20solde=20est=20correct=20d=C3=A9bit=20/=20cr?= =?UTF-8?q?=C3=A9dit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/balance.inc.php | 17 +++++++++++++++-- include/class/acc_balance.class.php | 1 + include/export/export_balance_pdf.php | 13 ++++++++++++- include/lib/message_javascript.php | 2 ++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/include/balance.inc.php b/include/balance.inc.php index 16ff44ea3..3ef72b6ca 100644 --- a/include/balance.inc.php +++ b/include/balance.inc.php @@ -437,8 +437,21 @@ if ( isset($_GET['view'] ) ) echo ''; echo td($view_history); - echo td(h($r['label'])); - + // label + warning if the saldo is incorrect + $label=$r['label']; + if (in_array($r['type'],array('CHA','ACT','PASINV','PROINV')) && $r['sum_deb']<$r['sum_cred']) + { + + $label.=" ".Icon_Action::warnbulle(85); + } + if (in_array($r['type'],array('PRO','PAS','ACTINV','CHAINV')) && $r['sum_deb']>$r['sum_cred']) + { + + $label.=" ".Icon_Action::warnbulle(86); + } + print ''; + print $label; + print ''; if ($previous == 1 ) { echo td(nbm($r['sum_deb_previous']),' class="previous_year"'); echo td(nbm($r['sum_cred_previous']),' class="previous_year" '); diff --git a/include/class/acc_balance.class.php b/include/class/acc_balance.class.php index f079bcf7d..aca291bb0 100644 --- a/include/class/acc_balance.class.php +++ b/include/class/acc_balance.class.php @@ -231,6 +231,7 @@ class Acc_Balance $a['poste']=$r['poste']; $a['label']=mb_substr($poste->get_lib(),0,40); + $a['type']=$poste->get_parameter("pcm_type"); $a['sum_deb']=round($r['sum_deb'],2); $a['sum_cred']=round($r['sum_cred'],2); $a['solde_deb']=round(( $a['sum_deb'] >= $a['sum_cred'] )? $a['sum_deb']- $a['sum_cred']:0,2); diff --git a/include/export/export_balance_pdf.php b/include/export/export_balance_pdf.php index d82bcd8ba..02946d3a4 100644 --- a/include/export/export_balance_pdf.php +++ b/include/export/export_balance_pdf.php @@ -212,7 +212,18 @@ if (!empty($array)) { $fill=$pdf->is_fill($i); - $pdf->LongLine(30, 6, $value['poste'], 0, 'L', $fill); + $label=$value['poste']; + if (in_array($r['type'],array('CHA','ACT','PASINV','PROINV')) && $value['sum_deb']<$value['sum_cred']) + { + + $label.=" ".mb_chr(0x26a0); + } + if (in_array($r['type'],array('PRO','PAS','ACTINV','CHAINV')) && $value['sum_deb']>$value['sum_cred']) + { + + $label.=" ".mb_chr(0x26a0); + } + $pdf->LongLine(30, 6, $label, 0, 'L', $fill); $pdf->LongLine(60, 6, $value['label'], 0, 'L', $fill); $summary_tab = $bal->summary_add($summary_tab, $value['poste'], $value['sum_deb'], diff --git a/include/lib/message_javascript.php b/include/lib/message_javascript.php index aa00f4eaa..1b303d7a2 100644 --- a/include/lib/message_javascript.php +++ b/include/lib/message_javascript.php @@ -118,4 +118,6 @@ content[81]=""; content[83]=""; content[84]=""; +content[85]=""; +content[86]=""; From a821b670db0ac67ac607eadc53c04857fe543bb2 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Fri, 12 Jan 2024 12:59:23 +0100 Subject: [PATCH 12/25] OPTION_CARD : Correct options for FollowUp --- include/class/card_multiple.class.php | 2 +- include/template/form_ledger_detail.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/class/card_multiple.class.php b/include/class/card_multiple.class.php index b7a2f3c82..d9932d250 100644 --- a/include/class/card_multiple.class.php +++ b/include/class/card_multiple.class.php @@ -146,7 +146,7 @@ class Card_Multiple select contact_option_ref_id from action_person_option join action_person a on (a.ap_id=action_person_id) - where f_id=$2)",[$p_action_person_id,$fiche_id]); + where f_id=$2 and ag_id=$3)",[$p_action_person_id,$fiche_id,$ag_id]); // delete disable $cn->exec_sql("delete diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index e72cd2bc5..37e192928 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -7,7 +7,7 @@ */ $default_currency=new Acc_Currency(Dossier::connect(),0); - +\Noalyss\Dbg::echo_file(__FILE__); ?>

      get_name()?>

      From 5f389826a8b22efb5fa3c1f72683c66ad944ae77 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Fri, 12 Jan 2024 17:54:46 +0100 Subject: [PATCH 13/25] Bug Fiche Option --- include/class/follow_up_other_concerned.class.php | 3 ++- include/export/export_follow_up_contact_csv.php | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/class/follow_up_other_concerned.class.php b/include/class/follow_up_other_concerned.class.php index d1ba3aea9..1c4a28c47 100644 --- a/include/class/follow_up_other_concerned.class.php +++ b/include/class/follow_up_other_concerned.class.php @@ -190,7 +190,8 @@ EOF; where apo2.contact_option_ref_id =$1 and ap.f_id=$2 - ", array($pa_Column[$i]['cor_id'], $p_fid)); + and ap.ag_id=$3 + ", array($pa_Column[$i]['cor_id'], $p_fid, $this->ag_id)); $r.=td($value); } $r.=''.$remove.''; diff --git a/include/export/export_follow_up_contact_csv.php b/include/export/export_follow_up_contact_csv.php index ebd929fda..5b1251962 100644 --- a/include/export/export_follow_up_contact_csv.php +++ b/include/export/export_follow_up_contact_csv.php @@ -44,7 +44,7 @@ join fiche_detail f on (a.f_id=f.f_id) join fiche_def fd on (fd.fd_id=f1.fd_id) join jnt_fic_attr jfa on (fd.fd_id=jfa.fd_id and jfa.ad_id=f.ad_id) where ag_id=$1 -order by f1.fd_id, a.f_id,jnt_order;;",[$ag_id]); +order by f1.fd_id, a.f_id,jnt_order",[$ag_id]); $nb=count($aRow); $lastcat=0;$lastcard=0; @@ -105,5 +105,14 @@ where ag_id=$1 and f_id=$2 order by cor_id",array($ag_id,$lastcard)); $csv->add($aRow[$i]['ad_value']); } - +$aOption=$cn->get_array(" select ap_value +from +action_person a +join action_person_option apo on (a.ap_id=apo.action_person_id) +join contact_option_ref cor on (cor.cor_id=apo.contact_option_ref_id) +where ag_id=$1 and f_id=$2 order by cor_id",array($ag_id,$lastcard)); +$nb_option=count($aOption); +for ($h=0;$h < $nb_option;$h++) { + $csv->add($aOption[$h]['ap_value']); +} $csv->write(); \ No newline at end of file From 948a509e1f308cecc515648f3de9094ce6c509ee Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 7 Jan 2024 17:14:24 +0100 Subject: [PATCH 14/25] PHP8.1 compatibility --- include/class/acc_ledger_fin.class.php | 2 +- include/template/dashboard.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index 166037523..de3a2ea72 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -654,7 +654,7 @@ class Acc_Ledger_Fin extends Acc_Ledger td(_("Ancien solde")). td(nbm($solde).$cur, 'class="num"') ); - $new_solde=bcadd($solde, $tot_amount); + $new_solde=bcadd($solde??0, $tot_amount??0); $r.=tr( td(_("Nouveau solde")). td(nbm($new_solde).$cur, ' class="num"') diff --git a/include/template/dashboard.php b/include/template/dashboard.php index 5b1b7c0e7..cd32f25cd 100644 --- a/include/template/dashboard.php +++ b/include/template/dashboard.php @@ -122,7 +122,7 @@ for($i=0;$i - + From e723c5c5b1b637936107fd524b9788b4cb49460d Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 7 Jan 2024 17:17:10 +0100 Subject: [PATCH 15/25] =?UTF-8?q?Task=200002128:=20Cl=C3=B4ture=20comptabi?= =?UTF-8?q?lit=C3=A9=20fran=C3=A7aise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/ajax_misc.php | 13 +- html/js/acc_ledger.js | 1812 +++++++++-------- include/ajax/ajax_operation_exercice.php | 153 ++ include/class/acc_ledger.class.php | 28 - include/class/operation_closing.class.php | 43 + include/class/operation_exercice.class.php | 156 ++ include/class/operation_opening.class.php | 146 ++ include/constant.php | 1 + .../operation_exercice_detail_sql.class.php | 79 + .../database/operation_exercice_sql.class.php | 81 + include/operation_exercice.inc.php | 49 + .../template/operation_exercice-input_row.php | 114 ++ .../operation_exercice-input_source.php | 129 ++ sql/upgrade.sql | 56 +- 14 files changed, 2027 insertions(+), 833 deletions(-) create mode 100644 include/ajax/ajax_operation_exercice.php create mode 100644 include/class/operation_closing.class.php create mode 100644 include/class/operation_exercice.class.php create mode 100644 include/class/operation_opening.class.php create mode 100644 include/database/operation_exercice_detail_sql.class.php create mode 100644 include/database/operation_exercice_sql.class.php create mode 100644 include/operation_exercice.inc.php create mode 100644 include/template/operation_exercice-input_row.php create mode 100644 include/template/operation_exercice-input_source.php diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 0492c3772..173edfb35 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -327,7 +327,18 @@ $path = array( //visibility quantity "update_visibility_quantity"=>"ajax_update_visibility_quantity", // detail customer , supplier operation - "event_display_detail"=>"ajax_event_display_detail" + "event_display_detail"=>"ajax_event_display_detail", + // update periode in opening operation + "operation_exercice+update_periode"=>"ajax_operation_exercice", + // modify row in exercice (opening/closing) operation + "operation_exercice+modify_row"=>"ajax_operation_exercice", + // save row in exercice (opening/closing) operation + "operation_exercice+save_row"=>"ajax_operation_exercice", + // compute the balance after saving row in exercice (opening/closing) operation + "operation_exercice+display_total"=>"ajax_operation_exercice", + // delete row in exercice (opening/closing) operation + "operation_exercice+delete_row"=>"ajax_operation_exercice", + ) ; if (array_key_exists($op, $path)) { diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 41dd5f16f..8c205ff85 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -26,77 +26,75 @@ * */ var layer = 1; + /** * \fn * \brief update the list of available predefined operation when we change the ledger. */ -function update_predef(p_type, p_direct, p_ac) -{ +function update_predef(p_type, p_direct, p_ac) { var jrn = g("p_jrn").value; var dossier = g("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; var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: querystring, - onFailure: error_get_predef, - onSuccess: function (req) { - try { - $('info_div').innerHTML = "ok"; - var answer = req.responseXML; - var a = answer.getElementsByTagName('code'); - var html = answer.getElementsByTagName('value'); - if (a.length == 0) - { - var rec = req.responseText; - alert_box(content[48] + rec); - } - 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; - } catch (e) { - $('info_div').innerHTML = e.message; + "ajax_misc.php", + { + method: 'get', + parameters: querystring, + onFailure: error_get_predef, + onSuccess: function (req) { + try { + $('info_div').innerHTML = "ok"; + var answer = req.responseXML; + var a = answer.getElementsByTagName('code'); + var html = answer.getElementsByTagName('value'); + if (a.length == 0) { + var rec = req.responseText; + alert_box(content[48] + rec); } + 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; + } catch (e) { + $('info_div').innerHTML = e.message; } } + } ); } /** * update the list of payment method when we change the ledger. */ -function update_pay_method() -{ +function update_pay_method() { waiting_box(); var jrn = g("p_jrn").value; var dossier = g("gDossier").value; var querystring = 'gDossier=' + dossier + '&l=' + jrn + "&op=up_pay_method"; var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: querystring, - onFailure: error_get_predef, - onSuccess: function (req) { - remove_waiting_box(); - var answer = req.responseText; - $('payment').innerHTML = answer; - } + "ajax_misc.php", + { + method: 'get', + parameters: querystring, + onFailure: error_get_predef, + onSuccess: function (req) { + remove_waiting_box(); + var answer = req.responseText; + $('payment').innerHTML = answer; } + } ); } + /** * update the list of additional tax */ -function update_other_tax() -{ +function update_other_tax() { waiting_box(); var jrn = g("p_jrn").value; var dossier = g("gDossier").value; - var querystring ={gDossier: dossier,jrn_id:jrn ,op:"up_other_tax"}; + var querystring = {gDossier: dossier, jrn_id: jrn, op: "up_other_tax"}; var action = new Ajax.Request( "ajax_misc.php", { @@ -112,32 +110,32 @@ function update_other_tax() } ); } + /** * update ctl id =jrn_name with the value of p_jrn */ -function update_name() -{ +function update_name() { var jrn_id = $('p_jrn').value; var dossier = g("gDossier").value; var querystring = 'gDossier=' + dossier + '&l=' + jrn_id + "&op=ledger_description"; var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: querystring, - onFailure: error_get_pj, - onSuccess: function (req) { - $('jrn_name_div').innerHTML = req.responseText; - } + "ajax_misc.php", + { + method: 'get', + parameters: querystring, + onFailure: error_get_pj, + onSuccess: function (req) { + $('jrn_name_div').innerHTML = req.responseText; } + } ); } + /** * update the field predef */ -function error_get_predef(request, json) -{ +function error_get_predef(request, json) { alert_box(content[49]); } @@ -145,122 +143,124 @@ function error_get_predef(request, json) /** * update the list of available predefined operation when we change the ledger. */ -function update_pj() -{ +function update_pj() { var jrn = g("p_jrn").value; var dossier = g("gDossier").value; var querystring = 'gDossier=' + dossier + '&l=' + jrn + "&op=upd_receipt"; var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: querystring, - onFailure: error_get_pj, - onSuccess: success_get_pj - } + "ajax_misc.php", + { + method: 'get', + parameters: querystring, + onFailure: error_get_pj, + onSuccess: success_get_pj + } ); } + /** * ask the name, quick_code of the bank for the ledger */ -function update_bank() -{ +function update_bank() { var jrn = g('p_jrn').value; var dossier = g('gDossier').value; var qs = 'gDossier=' + dossier + '&op=bkname&p_jrn=' + jrn; var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: qs, - onFailure: error_get_pj, - onSuccess: success_update_bank - } + "ajax_misc.php", + { + method: 'get', + parameters: qs, + onFailure: error_get_pj, + onSuccess: success_update_bank + } ); } + /** * Update the number of rows when changing of ledger */ -function update_row(ctl) -{ - try - { - var row_to_keep=3; /* Number of row to keep (head and foot)*/ - if ( ctl === 'quick_item' ) { row_to_keep=1;} /* for ODS , only 1 rows to keep */ +function update_row(ctl) { + try { + var row_to_keep = 3; /* Number of row to keep (head and foot)*/ + 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 qs = encodeURI('gDossier=' + dossier + '&op=minrow&j=' + jrn + '&ctl=' + ctl); var current_row = parseFloat($('nb_item').value); var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: qs, - onFailure: null, - onSuccess: function (request, json) - { - try { - var answer = request.responseText.evalJSON(true); - var row = parseFloat(answer.row); - - var table_to_update=$(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; - 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]; - var cell0Element=cell0.childNodes; - var canDelete=true; - /** - * prevent truncating - */ - cell0Element.forEach(function (x) { - if (canDelete && x.nodeName=='INPUT' && x.type==="text" && x.value) - { - canDelete=false; - }} - ); - /* - * prevent truncating - * For ODS we also need to check the second column - * */ - if ( canDelete && ctl === 'quick_item') { - var cell1 = table_to_update.rows[pos_row-row_to_keep].cells[1]; - var cell1Element=cell1.childNodes; - cell1Element.forEach(function (x) { - if (canDelete && x.nodeName=='INPUT' && x.type==="text" && x.value) - { - canDelete=false; - }}); + "ajax_misc.php", + { + method: 'get', + parameters: qs, + onFailure: null, + onSuccess: function (request, json) { + try { + var answer = request.responseText.evalJSON(true); + var row = parseFloat(answer.row); + + var table_to_update = $(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; + 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]; + var cell0Element = cell0.childNodes; + var canDelete = true; + /** + * prevent truncating + */ + cell0Element.forEach(function (x) { + if (canDelete && x.nodeName == 'INPUT' && x.type === "text" && x.value) { + canDelete = false; + } } - if ( canDelete ) { table_to_update.deleteRow(pos_row-row_to_keep);idx--;} - + ); + /* + * prevent truncating + * For ODS we also need to check the second column + * */ + if (canDelete && ctl === 'quick_item') { + var cell1 = table_to_update.rows[pos_row - row_to_keep].cells[1]; + var cell1Element = cell1.childNodes; + cell1Element.forEach(function (x) { + if (canDelete && x.nodeName == 'INPUT' && x.type === "text" && x.value) { + canDelete = false; + } + }); } - $('nb_item').value = table_to_update.rows.length-row_to_keep; - } - if (current_row < row) { - // We need to add rows - var delta = row - current_row ; - for (var i = 0; i < delta; i++) { - if (ctl == 'fin_item') { - ledger_fin_add_row(); - } - if (ctl == 'sold_item') { - ledger_add_row(); - } - if (ctl == 'quick_item') { - quick_writing_add_row(); - } + if (canDelete) { + table_to_update.deleteRow(pos_row - row_to_keep); + idx--; } + } - } catch (e) { - alert_box("update_row:01"+e.message); + $('nb_item').value = table_to_update.rows.length - row_to_keep; } + if (current_row < row) { + // We need to add rows + var delta = row - current_row; + for (var i = 0; i < delta; i++) { + if (ctl == 'fin_item') { + ledger_fin_add_row(); + } + if (ctl == 'sold_item') { + ledger_add_row(); + } + if (ctl == 'quick_item') { + quick_writing_add_row(); + } + } + } + } catch (e) { + alert_box("update_row:01" + e.message); } } + } ); } catch (e) { alert_box(e.message); @@ -270,8 +270,7 @@ function update_row(ctl) /** * @brief hide or show the column quantity */ -function update_visibility_quantity() -{ +function update_visibility_quantity() { var jrn = g("p_jrn").value; var dossier = g("gDossier").value; var querystring = 'gDossier=' + dossier + '&l=' + jrn + "&op=update_visibility_quantity"; @@ -283,21 +282,21 @@ function update_visibility_quantity() onSuccess: function (req) { try { // retrieve quantity - var quantity_col=document.getElementsByClassName("col_quant"); - for (var i=0;i < quantity_col.length;i++){ - if (req.responseText=="0") { + var quantity_col = document.getElementsByClassName("col_quant"); + for (var i = 0; i < quantity_col.length; i++) { + if (req.responseText == "0") { // hide the columns quantity and return quantity_col[i].hide(); quantity_col[i].addClassName('d-none'); } - if (req.responseText=="1") { + if (req.responseText == "1") { // show the columns quantity and return quantity_col[i].show(); quantity_col[i].removeClassName('d-none'); } } } catch (e) { - console.error("update_visibility_quantity"+e.message); + console.error("update_visibility_quantity" + e.message); } @@ -305,80 +304,72 @@ function update_visibility_quantity() } ); } + /** * Put into the span, the name of the bank, the bank account * and the quick_code */ -function success_update_bank(req) -{ - try - { +function success_update_bank(req) { + try { var answer = req.responseXML; var a = answer.getElementsByTagName('code'); var html = answer.getElementsByTagName('value'); - if (a.length == 0) - { + if (a.length == 0) { var rec = req.responseText; - alert_box('UPDBK-'+content[48]+ rec); + alert_box('UPDBK-' + content[48] + rec); } var name_ctl = a[0].firstChild.nodeValue; var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); $(name_ctl).innerHTML = code_html; - } - catch (e) - { + } catch (e) { alert_box("success_update_bank" + e.message); } } + /** * call ajax, ask what is the last date for the current ledger */ -function get_last_date() -{ +function get_last_date() { var jrn = g('p_jrn').value; var dossier = g('gDossier').value; var qs = 'gDossier=' + dossier + '&op=lastdate&p_jrn=' + jrn; var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: qs, - onFailure: error_get_pj, - onSuccess: success_get_last_date - } + "ajax_misc.php", + { + method: 'get', + parameters: qs, + onFailure: error_get_pj, + onSuccess: success_get_last_date + } ); } + /** * callback ajax, set the ctl with the last date from the ledger */ -function success_get_last_date(req) -{ - try - { +function success_get_last_date(req) { + try { var answer = req.responseXML; var a = answer.getElementsByTagName('code'); var html = answer.getElementsByTagName('value'); - if (a.length == 0) - { + if (a.length == 0) { var rec = req.responseText; - alert_box('GETLASTDA:'+content[48] + rec); + alert_box('GETLASTDA:' + content[48] + rec); } var name_ctl = a[0].firstChild.nodeValue; var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); document.getElementsByName(name_ctl)[0].value = code_html; - } - catch (e) - { + } catch (e) { alert_box(e.message); } } + /** * update the field predef */ -function success_get_pj(request, json) -{ +function success_get_pj(request, json) { var answer = request.responseText.evalJSON(true); var obj = g("e_pj"); @@ -388,19 +379,18 @@ function success_get_pj(request, json) obj.value = answer.pj; g("e_pj_suggest").value = answer.pj; } + /** * update the field predef */ -function error_get_pj(request, json) -{ - alert_box("GETPJ:"+content[48]); +function error_get_pj(request, json) { + alert_box("GETPJ:" + content[48]); } /** * add a line in the form for the ledger fin */ -function ledger_fin_add_row() -{ +function ledger_fin_add_row() { var style = 'class="input_text"'; var mytable = g("fin_item").tBodies[0]; var line = mytable.rows.length; @@ -408,8 +398,7 @@ function ledger_fin_add_row() var nb = g("nb_item"); var rowToCopy = mytable.rows[1]; var nNumberCell = rowToCopy.cells.length; - for (var e = 0; e < nNumberCell; e++) - { + for (var e = 0; e < nNumberCell; e++) { var newCell = row.insertCell(e); if (e == 0) { newCell.id = 'tdchdate' + nb.value; @@ -423,7 +412,7 @@ function ledger_fin_add_row() new_tt = new_tt.replace(/e_other0_label/g, "e_other" + nb.value + '_label'); new_tt = new_tt.replace(/dateop0/g, "dateop" + nb.value); newCell.innerHTML = new_tt; - newCell.className=rowToCopy.cells[e].className; + newCell.className = rowToCopy.cells[e].className; new_tt.evalScripts(); } g("e_other" + nb.value).value = ""; @@ -443,29 +432,36 @@ function ledger_fin_add_row() * Add multiple 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; - if (nbrow == NaN) {nbrow=1;} - var type_ledger=$(p_elid+"_ledger").value; - var i=0; - for (i=0;idisplay_dcside(item)) + var type_ledger = $(p_elid + "_ledger").value; + var i = 0; + for (i = 0; i < nbrow; i++) { + if (type_ledger == 'O') { + ledger_add_row(); + } + if (type_ledger == 'F') { + ledger_fin_add_row(); + } + if (type_ledger == 'M') { + quick_writing_add_row(); + } + } + if (type_ledger == 'M') { + var aCheckBox = $$('.debit-credit') + aCheckBox.forEach((item) => display_dcside(item)) } } + /** * add a line in the form for the purchase ledger * @param p_dossier folder id * @param p_table_name */ -function ledger_add_row() -{ +function ledger_add_row() { try { style = 'class="input_text"'; var mytable = g("sold_item").tBodies[0]; @@ -474,8 +470,7 @@ function ledger_add_row() var nCell = mytable.rows[1].cells.length; var row = mytable.insertRow(line); var nb = g("nb_item"); - for (var e = 0; e < nCell; e++) - { + for (var e = 0; e < nCell; e++) { var newCell = row.insertCell(e); var tt = ofirstRow.cells[e].innerHTML; var new_tt = tt.replace(/march0/g, "march" + nb.value); @@ -484,7 +479,7 @@ function ledger_add_row() new_tt = new_tt.replace(/compute_ledger\(0\)/g, "compute_ledger(" + nb.value + ")"); new_tt = new_tt.replace(/clean_tva\(0\)/g, "clean_tva(" + nb.value + ")"); newCell.innerHTML = new_tt; - newCell.className=ofirstRow.cells[e].className; + newCell.className = ofirstRow.cells[e].className; new_tt.evalScripts(); } @@ -503,17 +498,16 @@ function ledger_add_row() alert_box(e.message); } } + /** * compute the sum of a purchase, update the span tvac, htva and tva * all the needed data are taken from the document (hidden field : gdossier) * @param the number of the changed ctrl */ -function compute_ledger(p_ctl_nb) -{ +function compute_ledger(p_ctl_nb) { var dossier = g("gDossier").value; var a = -1; - if (document.getElementById("e_march" + p_ctl_nb + '_tva_amount')) - { + 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; } @@ -523,8 +517,7 @@ function compute_ledger(p_ctl_nb) g("e_march" + p_ctl_nb).value = trim(g("e_march" + p_ctl_nb).value); var qcode = g("e_march" + p_ctl_nb).value; - if (qcode.length == 0) - { + if (qcode.length == 0) { clean_ledger(p_ctl_nb); refresh_ledger(); return; @@ -533,11 +526,9 @@ 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')) - { + if (g('e_march' + p_ctl_nb + '_tva_id')) { tva_id = g('e_march' + p_ctl_nb + '_tva_id').value; - if (trim(tva_id) == '') - { + if (trim(tva_id) == '') { tva_id = -1; } } @@ -547,32 +538,39 @@ function compute_ledger(p_ctl_nb) 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"); - let other_tax_id=(other_tax && other_tax.checked)?other_tax.value:-1; + let other_tax = g("other_tax"); + let other_tax_id = (other_tax && other_tax.checked) ? other_tax.value : -1; - var querystring = { gDossier : dossier , c : qcode ,t :tva_id,p : price , q:quantity,n:p_ctl_nb,'other_tax_id':other_tax_id}; + var querystring = { + gDossier: dossier, + c: qcode, + t: tva_id, + p: price, + q: quantity, + n: p_ctl_nb, + 'other_tax_id': other_tax_id + }; var action = new Ajax.Request( - "compute.php", - { - method: 'get', - parameters: querystring, - onFailure: error_compute_ledger, - onSuccess: success_compute_ledger - } + "compute.php", + { + method: 'get', + parameters: querystring, + onFailure: error_compute_ledger, + onSuccess: success_compute_ledger + } ); } + /** * refresh the purchase screen, recompute vat, total... */ -function refresh_ledger() -{ +function refresh_ledger() { var tva = 0; var htva = 0; var tvac = 0; - nb_item=g("nb_item").value; - for (var i = 0; i < nb_item; i++) - { + nb_item = g("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)) @@ -580,62 +578,57 @@ function refresh_ledger() if (g('tvac_march' + i)) tvac += g('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 = g("tva"); + id_htva = g("htva"); + id_tvac = g("tvac"); + id_other_tax = g("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; + if (id_other_tax) { + let total_operation = tvac + parseFloat(id_other_tax.value); + $('total_operation_other_tax').innerHTML = Math.round(total_operation * 100) / 100; } if (id_tvac) id_tvac.innerHTML = Math.round(tvac * 100) / 100; } + /** * update the field htva, tva_id and tvac, callback function for compute_sold * it the field TVA in the answer contains NA it means that VAT is appliable and then do not * update the VAT field except htva_martc */ -function success_compute_ledger(request, json) -{ +function success_compute_ledger(request, json) { var answer = request.responseText.evalJSON(true); var ctl = answer.ctl; var rtva = answer.tva; var rhtva = answer.htva; var rtvac = answer.tvac; - let other_tax=g("other_tax_amount") - if ( other_tax) { - other_tax.value=answer.other_tax; + let other_tax = g("other_tax_amount") + if (other_tax) { + other_tax.value = answer.other_tax; } - if (rtva == 'NA') - { + if (rtva == 'NA') { var rhtva = answer.htva * 1; g('htva_march' + ctl).value = rhtva; g('tvac_march' + ctl).value = rtvac; g('sum').show(); refresh_ledger(); - CurrencyCompute('p_currency_rate','p_currency_euro'); + CurrencyCompute('p_currency_rate', 'p_currency_euro'); return; } rtva = answer.tva * 1; - g('sum').show(); - if (g('e_march' + ctl + '_tva_amount').value == "" || g('e_march' + ctl + '_tva_amount').value == 0) - { + 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; - } - else - { + } else { g('tva_march' + ctl).value = g('e_march' + ctl + '_tva_amount').value; } g('htva_march' + ctl).value = Math.round(parseFloat(rhtva) * 100) / 100; @@ -643,31 +636,28 @@ function success_compute_ledger(request, json) var tmp2 = Math.round(parseFloat(g('tva_march' + ctl).value) * 100) / 100; g('tvac_march' + ctl).value = Math.round((tmp1 + tmp2) * 100) / 100; refresh_ledger(); - CurrencyCompute('p_currency_rate','p_currency_euro'); - + CurrencyCompute('p_currency_rate', 'p_currency_euro'); + } /** * callback error function for compute_sold */ -function error_compute_ledger(request, json) -{ +function error_compute_ledger(request, json) { alert_box('Ajax does not work'); } -function compute_all_ledger() -{ + +function compute_all_ledger() { var loop = 0; - let nb_item=g("nb_item").value; - for (loop = 0; loop < nb_item; loop++) - { + let nb_item = g("nb_item").value; + for (loop = 0; loop < nb_item; loop++) { compute_ledger(loop); } var tva = 0; var htva = 0; var tvac = 0; - for (var i = 0; i < nb_item; i++) - { + for (var i = 0; i < nb_item; i++) { if (g('tva_march')) tva += g('tva_march' + i).value * 1; if (g('htva_march' + i)) @@ -675,61 +665,54 @@ function compute_all_ledger() if (g('tvac_march' + i)) tvac += g('tvac_march' + i).value * 1; } - id_other_tax=g("other_tax_amount"); + 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; - if (id_other_tax) { tvac+=id_other_tax.value;} + if (id_other_tax) { + tvac += id_other_tax.value; + } if (g('tvac')) g('tvac').innerHTML = Math.round(tvac * 100) / 100; - + } -function clean_tva(p_ctl) -{ +function clean_tva(p_ctl) { if (g('e_march' + p_ctl + '_tva_amount')) g('e_march' + p_ctl + '_tva_amount').value = 0; } -function clean_ledger(p_ctl_nb) -{ - if (g("e_march" + p_ctl_nb)) - { +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 (g('e_march' + p_ctl_nb + '_price')) - { + if (g('e_march' + p_ctl_nb + '_price')) { g('e_march' + p_ctl_nb + '_price').value = ''; } - if (g('e_quant' + p_ctl_nb)) - { + if (g('e_quant' + p_ctl_nb)) { g('e_quant' + p_ctl_nb).value = '1'; } - if (g('tva_march' + p_ctl_nb + '_show')) - { + if (g('tva_march' + p_ctl_nb + '_show')) { g('tva_march' + p_ctl_nb + '_show').value = '0'; } - if (g('tva_march' + p_ctl_nb)) - { + if (g('tva_march' + p_ctl_nb)) { g('tva_march' + p_ctl_nb).value = 0; } - if (g('htva_march' + p_ctl_nb)) - { + if (g('htva_march' + p_ctl_nb)) { g('htva_march' + p_ctl_nb).value = 0; } - if (g('tvac_march' + p_ctl_nb)) - { + if (g('tvac_march' + p_ctl_nb)) { g('tvac_march' + p_ctl_nb).value = 0; } } + /** * add a line in the form for the quick_writing */ -function quick_writing_add_row() -{ +function quick_writing_add_row() { style = 'class="input_text"'; var mytable = g("quick_item").tBodies[0]; var nNumberRow = mytable.rows.length; @@ -739,8 +722,7 @@ function quick_writing_add_row() var nb = g("nb_item"); var oNewRow = mytable.insertRow(nNumberRow); - for (var e = 0; e < nNumberCell; e++) - { + for (var e = 0; e < nNumberCell; e++) { var newCell = oRow.insertCell(e); var tt = rowToCopy.cells[e].innerHTML; new_tt = tt.replace(/qc_0/g, "qc_" + nb.value); @@ -749,12 +731,15 @@ function quick_writing_add_row() new_tt = new_tt.replace(/ck0/g, "ck" + nb.value); new_tt = new_tt.replace(/ld0/g, "ld" + nb.value); newCell.innerHTML = new_tt; - newCell.className=rowToCopy.cells[e].className; + newCell.className = rowToCopy.cells[e].className; new_tt.evalScripts(); } - var ck=$('ck'+nb.value); - ck.addEventListener('click',function(event) { display_range_dcside(event,ck); display_dcside(ck);}); + var ck = $('ck' + nb.value); + ck.addEventListener('click', function (event) { + display_range_dcside(event, ck); + display_dcside(ck); + }); $("qc_" + nb.value).value = ""; @@ -763,230 +748,240 @@ function quick_writing_add_row() $("ld" + nb.value).value = ""; - nb.value++; } -function RefreshMe() -{ + +function RefreshMe() { window.location.reload(); } -function go_next_concerned() -{ +function go_next_concerned() { var form = document.forms[1]; - for (var e = 0; e < form.elements.length; e++) - { + for (var e = 0; e < form.elements.length; e++) { var elmt = form.elements[e]; - if (elmt.type == "checkbox") - { - if (elmt.checked == true) - { + if (elmt.type == "checkbox") { + if (elmt.checked == true) { return confirm(content[52]); } } } return true; } + /** * View the history of an account * @param {type} p_value * @param {type} dossier * @returns {undefined} */ -function view_history_account(p_value, dossier,p_exercice) -{ +function view_history_account(p_value, dossier, p_exercice) { layer++; var idbox = 'det' + layer; var popup = {'id': idbox, 'cssclass': 'inner_box', 'html': loading(), 'drag': false}; - var querystring={'gDossier':dossier,'act':'de','pcm_val':p_value,'div':idbox,'l':layer,'op':'history','exercice':p_exercice}; + var querystring = { + 'gDossier': dossier, + 'act': 'de', + 'pcm_val': p_value, + 'div': idbox, + 'l': layer, + 'op': 'history', + 'exercice': p_exercice + }; waiting_box(); var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: querystring, - onFailure: error_box, - onSuccess: function (req, xml) - { - remove_waiting_box(); - add_div(popup); - success_box(req, xml); - $(idbox).style.top = calcy(140 + (layer * 3)) + "px"; - } + "ajax_misc.php", + { + method: 'get', + parameters: querystring, + onFailure: error_box, + onSuccess: function (req, xml) { + remove_waiting_box(); + add_div(popup); + success_box(req, xml); + $(idbox).style.top = calcy(140 + (layer * 3)) + "px"; } + } ); } + /** * View the history of an account * @param {type} p_value * @param {type} dossier * @returns {undefined} */ -function view_history_anc_account(p_value, dossier,p_exercice) -{ +function view_history_anc_account(p_value, dossier, p_exercice) { layer++; var idbox = 'det' + layer; var popup = {'id': idbox, 'cssclass': 'inner_box', 'html': loading(), 'drag': false}; - var querystring={'gDossier':dossier,'op':'history_anc_account','po_id':p_value,'div':idbox,'l':layer,'act':'history','exercice':p_exercice}; + var querystring = { + 'gDossier': dossier, + 'op': 'history_anc_account', + 'po_id': p_value, + 'div': idbox, + 'l': layer, + 'act': 'history', + 'exercice': p_exercice + }; waiting_box(); var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: querystring, - onFailure: error_box, - onSuccess: function (req, xml) - { - remove_waiting_box(); - add_div(popup); - $(idbox).innerHTML=req.responseText; - $(idbox).style.top = calcy(140 + (layer * 3)) + "px"; - } + "ajax_misc.php", + { + method: 'get', + parameters: querystring, + onFailure: error_box, + onSuccess: function (req, xml) { + remove_waiting_box(); + add_div(popup); + $(idbox).innerHTML = req.responseText; + $(idbox).style.top = calcy(140 + (layer * 3)) + "px"; } + } ); } + /** * Change the view of account history * @param {type} obj * @returns {Boolean} */ -function update_history_account(obj) -{ +function update_history_account(obj) { try { var querystring = { - "l" :obj.div , - "div" :obj.div , - "gDossier" : obj.gDossier, - "pcm_val" : obj.pcm_val , - "ex" : obj.select.options[obj.select.selectedIndex].text, - "op":"history", - "exercice":obj.exercice + "l": obj.div, + "div": obj.div, + "gDossier": obj.gDossier, + "pcm_val": obj.pcm_val, + "ex": obj.select.options[obj.select.selectedIndex].text, + "op": "history", + "exercice": obj.exercice }; waiting_box(); var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: querystring, - onFailure: error_box, - onSuccess: function (req, xml) - { - remove_waiting_box(); - success_box(req, xml); - g(obj.div).style.top = calcy(140 + (layer * 3)) + "px"; - } - }); - } catch (e) - { - alert_box("update_history_account error " + e.message); - } - - return false; -} -/*!\brief Change the view of card history - * \param p_value f_id of the card - */ -function view_history_card(p_value, dossier,p_exercice) -{ - layer++; - var idbox = 'det' + layer; - var popup = {'id':idbox, - 'cssclass': 'inner_box', - 'html':loading(), - 'drag':false}; - var querystring = { 'gDossier' : dossier , - 'act':'de', - 'f_id' : p_value , - 'div' : idbox , - "l" : layer, - "op":"history", - "exercice":p_exercice}; - waiting_box(); - var action = new Ajax.Request( "ajax_misc.php", { method: 'get', parameters: querystring, onFailure: error_box, - onSuccess: function (req, xml) - { + onSuccess: function (req, xml) { remove_waiting_box(); - add_div(popup); success_box(req, xml); - g(idbox).style.top = calcy(140 + (layer * 3)) + "px"; + g(obj.div).style.top = calcy(140 + (layer * 3)) + "px"; } - } - ); -} -/** - * update history view after changing the exercice - * @param {type} obj - * @returns {Boolean} - */ -function update_history_card(obj) -{ - try { - var querystring = { - "l" : obj.div , - "div" : obj.div , - "gDossier" : obj.gDossier, - "f_id" : obj.f_id , - "ex" : obj.select.options[obj.select.selectedIndex].text, - "op":"history", - "exercice":obj.exercice - }; - waiting_box(); - var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: querystring, - onFailure: error_box, - onSuccess: function (req, xml) - { - remove_waiting_box(); - success_box(req, xml); - g(obj.div).style.top = calcy(140 + (layer * 3)) + "px"; - } - }); - } catch (e) - { + }); + } catch (e) { alert_box("update_history_account error " + e.message); } return false; } + +/*!\brief Change the view of card history + * \param p_value f_id of the card + */ +function view_history_card(p_value, dossier, p_exercice) { + layer++; + var idbox = 'det' + layer; + var popup = { + 'id': idbox, + 'cssclass': 'inner_box', + 'html': loading(), + 'drag': false + }; + var querystring = { + 'gDossier': dossier, + 'act': 'de', + 'f_id': p_value, + 'div': idbox, + "l": layer, + "op": "history", + "exercice": p_exercice + }; + waiting_box(); + var action = new Ajax.Request( + "ajax_misc.php", + { + method: 'get', + parameters: querystring, + onFailure: error_box, + onSuccess: function (req, xml) { + remove_waiting_box(); + add_div(popup); + success_box(req, xml); + g(idbox).style.top = calcy(140 + (layer * 3)) + "px"; + } + } + ); +} + +/** + * update history view after changing the exercice + * @param {type} obj + * @returns {Boolean} + */ +function update_history_card(obj) { + try { + var querystring = { + "l": obj.div, + "div": obj.div, + "gDossier": obj.gDossier, + "f_id": obj.f_id, + "ex": obj.select.options[obj.select.selectedIndex].text, + "op": "history", + "exercice": obj.exercice + }; + waiting_box(); + var action = new Ajax.Request( + "ajax_misc.php", + { + method: 'get', + parameters: querystring, + onFailure: error_box, + onSuccess: function (req, xml) { + remove_waiting_box(); + success_box(req, xml); + g(obj.div).style.top = calcy(140 + (layer * 3)) + "px"; + } + }); + } catch (e) { + alert_box("update_history_account error " + e.message); + } + + return false; +} + /** * remove an Operation *@param p_jr_id is the jrn.jr_id *@param dossier *@param the div */ -function removeOperation(p_jr_id, dossier, div) -{ +function removeOperation(p_jr_id, dossier, div) { waiting_box(); - var qs = { "gDossier" : dossier , - "op":"ledger", - "act":"rmop", - "div" : div , - "jr_id" : p_jr_id}; + var qs = { + "gDossier": dossier, + "op": "ledger", + "act": "rmop", + "div": div, + "jr_id": p_jr_id + }; new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: qs, - onFailure: error_box, - onSuccess: infodiv - } + "ajax_misc.php", + { + method: 'get', + parameters: qs, + onFailure: error_box, + onSuccess: infodiv + } ); } @@ -995,36 +990,41 @@ function removeOperation(p_jr_id, dossier, div) * reverse an Operation *@param pointer to the FORM */ -function reverseOperation(obj) -{ - var qs = $(obj).serialize()+ "&op=ledger"; +function reverseOperation(obj) { + var qs = $(obj).serialize() + "&op=ledger"; g('ext' + obj.divname).style.display = 'none'; waiting_box(); new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: qs, - onFailure: error_box, - onSuccess: function (req) { - try { - var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters:{"gDossier" : obj["gDossier"].value,"op":"ledger","act":"de","div":obj['div'].value,"jr_id":obj['jr_id'].value}, - onFailure: error_box, - onSuccess: function (xml, txt) { - - success_box(xml, txt); - infodiv(req); - } - }); - } catch (ex) { - smoke.alert(ex.message); - } + "ajax_misc.php", + { + method: 'get', + parameters: qs, + onFailure: error_box, + onSuccess: function (req) { + try { + var action = new Ajax.Request( + "ajax_misc.php", + { + method: 'get', + parameters: { + "gDossier": obj["gDossier"].value, + "op": "ledger", + "act": "de", + "div": obj['div'].value, + "jr_id": obj['jr_id'].value + }, + onFailure: error_box, + onSuccess: function (xml, txt) { + + success_box(xml, txt); + infodiv(req); + } + }); + } catch (ex) { + smoke.alert(ex.message); } } + } ); return false; @@ -1035,33 +1035,39 @@ function reverseOperation(obj) * \param p_value jrn.jr_id * \param dossier dossier id */ -function modifyOperation(p_value, dossier) -{ +function modifyOperation(p_value, dossier) { layer++; var id_div = 'det' + layer; waiting_box(); - var querystring = { "gDossier" : dossier , - "op":"ledger", - "act":"de", - "div" : id_div , - "jr_id" : p_value}; + var querystring = { + "gDossier": dossier, + "op": "ledger", + "act": "de", + "div": id_div, + "jr_id": p_value + }; var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: querystring, - onFailure: error_box, - onSuccess: function (xml, txt) { - if ( xml.responseText === 'NOCONX') { reconnect();return;} - var popup = {'id': id_div, 'cssclass': 'inner_box' - , 'html': "", 'drag': false}; - remove_waiting_box(); - add_div(popup); - success_box(xml, txt); - $(id_div).style.position = "absolute"; - $(id_div).style.top = calcy(100 + (layer * 3)) + "px"; + "ajax_misc.php", + { + method: 'get', + parameters: querystring, + onFailure: error_box, + onSuccess: function (xml, txt) { + if (xml.responseText === 'NOCONX') { + reconnect(); + return; } + var popup = { + 'id': id_div, 'cssclass': 'inner_box' + , 'html': "", 'drag': false + }; + remove_waiting_box(); + add_div(popup); + success_box(xml, txt); + $(id_div).style.position = "absolute"; + $(id_div).style.top = calcy(100 + (layer * 3)) + "px"; } + } ); } @@ -1069,27 +1075,29 @@ function modifyOperation(p_value, dossier) * \param p_value jrn.jr_id */ -function viewOperation(p_value, p_dossier) -{ +function viewOperation(p_value, p_dossier) { modifyOperation(p_value, p_dossier) } -function dropLink(p_dossier, p_div, p_jr_id, p_jr_id2) -{ - var querystring = { "gDossier" : p_dossier , - "op":"ledger", - "act":"rmr", - "div" : p_div , - "jr_id" : p_jr_id, - "jr_id2" : p_jr_id2}; + +function dropLink(p_dossier, p_div, p_jr_id, p_jr_id2) { + var querystring = { + "gDossier": p_dossier, + "op": "ledger", + "act": "rmr", + "div": p_div, + "jr_id": p_jr_id, + "jr_id2": p_jr_id2 + }; var action = new Ajax.Request('ajax_misc.php', - { - method: 'get', - parameters: querystring, - onFailure: null, - onSuccess: null - } + { + method: 'get', + parameters: querystring, + onFailure: null, + onSuccess: null + } ); } + /** * this function is called before the querystring is send to the * fid2.php, add a filter based on the ledger 'p_jrn' @@ -1097,60 +1105,50 @@ function dropLink(p_dossier, p_div, p_jr_id, p_jr_id2) *@param queryString is the queryString to modify *@see ICard::input */ -function filter_card(obj, queryString) -{ +function filter_card(obj, queryString) { jrn = $('p_jrn').value; - if (jrn == -1) - { + if (jrn == -1) { type = $('ledger_type').value; queryString = queryString + '&type=' + type; - } - else - { + } else { queryString = queryString + '&j=' + jrn; } return queryString; } + /** * to display the lettering for the operation, call * ajax function *@param obj object attribut : gDossier,j_id,obj_type */ -function dsp_letter(obj) -{ - try - { +function dsp_letter(obj) { + try { //var queryString = 'gDossier=' + obj.gDossier + '&j_id=' + obj.j_id + '&op=dl' + '&ot=' + obj.obj_type+'&start='+obj.start; - + var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: obj, - onFailure: error_dsp_letter, - onSuccess: success_dsp_letter - } + "ajax_misc.php", + { + method: 'get', + parameters: obj, + onFailure: error_dsp_letter, + onSuccess: success_dsp_letter + } ); g('search').style.display = 'none'; g('list').style.display = 'none'; $('detail').innerHTML = loading(); g('detail').style.display = 'block'; - } - catch (e) - { + } catch (e) { alert_box('dsp_letter failed ' + e.message); } } -function success_dsp_letter(req) -{ - try - { +function success_dsp_letter(req) { + try { var answer = req.responseXML; var a = answer.getElementsByTagName('code'); var html = answer.getElementsByTagName('value'); - if (a.length == 0) - { + if (a.length == 0) { var rec = req.responseText; alert_box('erreur :' + rec); } @@ -1158,30 +1156,23 @@ function success_dsp_letter(req) var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); $('detail').innerHTML = code_html; - } - catch (e) - { + } catch (e) { alert_box(e.message); } - try - { + try { code_html.evalScripts(); - } - catch (e) - { - alert_box("DSPLETTER:"+content[48] + e.message); + } catch (e) { + alert_box("DSPLETTER:" + content[48] + e.message); } } -function error_dsp_letter(req) -{ - alert_box("DSPLETTER:"+content[48]); + +function error_dsp_letter(req) { + alert_box("DSPLETTER:" + content[48]); } -function search_letter(obj) -{ - try - { +function search_letter(obj) { + try { var str_query = ''; if (obj.elements['gDossier']) str_query = 'gDossier=' + obj.elements['gDossier'].value; @@ -1204,127 +1195,122 @@ function search_letter(obj) var action = new Ajax.Request( - "ajax_misc.php", - { - method: 'get', - parameters: str_query, - onFailure: error_dsp_letter, - onSuccess: success_dsp_letter - } + "ajax_misc.php", + { + method: 'get', + parameters: str_query, + onFailure: error_dsp_letter, + onSuccess: success_dsp_letter + } ); $('list').hide(); $('search').hide(); $('detail').innerHTML = loading(); $('detail').show(); - } - catch (e) - { + } catch (e) { alert_box('search_letter ' + e.message); } } + /** * save an operation in ajax, it concerns only the * comment, the pj and the rapt * the form elements are access by their name *@param obj form */ -function op_save(obj) -{ +function op_save(obj) { try { var queryString = $(obj).serialize(true); - queryString ["gDossier"]= obj.gDossier.value; + queryString ["gDossier"] = obj.gDossier.value; var rapt2 = "rapt" + obj.whatdiv.value; - queryString ["rapt"] = g(rapt2).value; + queryString ["rapt"] = g(rapt2).value; queryString ["jr_id"] = obj.jr_id.value; - var jr_id=obj.jr_id.value; - queryString ["div"]= obj.whatdiv.value; - var divid=obj.whatdiv.value; - queryString ["act"]="save"; - queryString ["op"]="ledger"; - + var jr_id = obj.jr_id.value; + queryString ["div"] = obj.whatdiv.value; + var divid = obj.whatdiv.value; + queryString ["act"] = "save"; + queryString ["op"] = "ledger"; + waiting_box(); /* * Operation detail is in a new window */ - if (g('inpopup')) - { + if (g('inpopup')) { var action = new Ajax.Request('ajax_misc.php', - { - method: 'post', - parameters: queryString, - onFailure: null, - onSuccess: function (req){ - remove_waiting_box(); - var answer=req.getElementsByTagName('code'); - if (answer[0] !=='OK') { - console.error("D2. op_save") - smoke.alert(req.responseText); - } + { + method: 'post', + parameters: queryString, + onFailure: null, + onSuccess: function (req) { + remove_waiting_box(); + var answer = req.getElementsByTagName('code'); + if (answer[0] !== 'OK') { + console.error("D2. op_save") + smoke.alert(req.responseText); } } + } ); // window.close(); - } - else - { + } else { /* *Operation is in a modal box */ var action = new Ajax.Request('ajax_misc.php', - { - method: 'post', - parameters: queryString, - onFailure: null, - onSuccess: function(req,json) { - - - if (req.responseXML == null ){ - smoke.alert(req.responseText); - } - new Ajax.Request('ajax_misc.php', { - parameters:{'gDossier':obj.gDossier.value, - 'act':'de', - 'op':'ledger', - 'jr_id' : jr_id, - 'div' : divid}, - onSuccess:function(xml) { - try { - var answer=xml.responseXML; - var html = answer.getElementsByTagName('code'); - $(divid).innerHTML=unescape(getNodeText(html[0])); - $(divid).innerHTML.evalScripts(); - remove_waiting_box(); - } catch (e) { - console.error("D1. op_save") - alert_box("1038"+e.message) - } - } - }); - + { + method: 'post', + parameters: queryString, + onFailure: null, + onSuccess: function (req, json) { + + + if (req.responseXML == null) { + smoke.alert(req.responseText); } - }); + new Ajax.Request('ajax_misc.php', { + parameters: { + 'gDossier': obj.gDossier.value, + 'act': 'de', + 'op': 'ledger', + 'jr_id': jr_id, + 'div': divid + }, + onSuccess: function (xml) { + try { + var answer = xml.responseXML; + var html = answer.getElementsByTagName('code'); + $(divid).innerHTML = unescape(getNodeText(html[0])); + $(divid).innerHTML.evalScripts(); + remove_waiting_box(); + } catch (e) { + console.error("D1. op_save") + alert_box("1038" + e.message) + } + } + }); + + } + }); } return false; - } catch (e) - { + } catch (e) { console.error("F1. op_save") alert_box(e.message); } } -function get_history_account(ctl, dossier) { - if ($(ctl).value != '') - { + +function get_history_account(ctl, dossier) { + if ($(ctl).value != '') { view_history_account($(ctl).value, dossier); } } + var previous = []; -var let_previous=""; -function show_reconcile(p_div, p_let) -{ - try - { - if (previous.length != 0 || p_let == let_previous ) - { +var let_previous = ""; + +function show_reconcile(p_div, p_let) { + try { + if (previous.length != 0 || p_let == let_previous) { var count_elt = previous.length; var i = 0; for (i = 0; i < count_elt; i++) { @@ -1335,8 +1321,8 @@ function show_reconcile(p_div, p_let) } var name = 'tr_' + p_let + '_' + p_div; var elt = document.getElementsByName(name); - if ( p_let != let_previous ) { - + if (p_let != let_previous) { + previous = elt; var count_elt = elt.length; var i = 0; @@ -1346,24 +1332,22 @@ function show_reconcile(p_div, p_let) elt[i].style.fontWeight = 'bolder'; } - let_previous=p_let; - } - else { - let_previous=""; + let_previous = p_let; + } else { + let_previous = ""; } - } catch (e) - { + } catch (e) { alert_box(e.message); } } + /** * add a line in the form for the purchase ledger */ -function gestion_add_row() -{ +function gestion_add_row() { try { style = 'class="input_text"'; var mytable = g("art").tBodies[0]; @@ -1372,8 +1356,7 @@ function gestion_add_row() var nCell = mytable.rows[1].cells.length; var row = mytable.insertRow(line); var nb = g("nb_item"); - for (var e = 0; e < nCell; e++) - { + for (var e = 0; e < nCell; e++) { var newCell = row.insertCell(e); var tt = ofirstRow.cells[e].innerHTML; var new_tt = tt.replace(/march0/g, "march" + nb.value); @@ -1407,97 +1390,109 @@ function gestion_add_row() } } -function document_remove(p_dossier,p_div,p_jrid) -{ - smoke.confirm(content[50], function (e) - { + +function document_remove(p_dossier, p_div, p_jrid) { + smoke.confirm(content[50], function (e) { if (e) { new Ajax.Request('ajax_misc.php', - { - parameters:{"op":"ledger","gDossier":p_dossier,"div":p_div,"p_jrid":p_jrid,'act':'rmf'}, - onSuccess : function(x) { - $('receipt'+p_div).innerHTML=x.responseText; - } - }) + { + parameters: {"op": "ledger", "gDossier": p_dossier, "div": p_div, "p_jrid": p_jrid, 'act': 'rmf'}, + onSuccess: function (x) { + $('receipt' + p_div).innerHTML = x.responseText; + } + }) } }); } + /*** * receive an object and display a list of filter + form to save one * fill up the span (id : {div}search_filter_span) with the name of the selected filter - * Object = '{'div':'','type':'ALL','all_type':1,'dossier':'10104'}' + * Object = '{'div':'','type':'ALL','all_type':1,'dossier':'10104'}' * @see Acc_Ledger_Search */ function manage_search_filter(p_obj) { waiting_box(); new Ajax.Request("ajax_misc.php", { - method:'get', - parameters:{"op":"display_search_filter","gDossier":p_obj.dossier,"div":p_obj.div,"ledger_type":p_obj.ledger_type,"all_type":p_obj.all_type}, - onSuccess:function(req) { + method: 'get', + parameters: { + "op": "display_search_filter", + "gDossier": p_obj.dossier, + "div": p_obj.div, + "ledger_type": p_obj.ledger_type, + "all_type": p_obj.all_type + }, + onSuccess: function (req) { remove_waiting_box(); - var x=posX; - var y=calcy(200) - create_div({'id':'boxfilter'+p_obj.div,'cssclass':'inner_box','html':req.responseText,'style':'top:'+y+'px;left:'+x+'px;position:absolute;width:400px',drag:1}); - $('boxfilter'+p_obj.div).show(); - } + var x = posX; + var y = calcy(200) + create_div({ + 'id': 'boxfilter' + p_obj.div, + 'cssclass': 'inner_box', + 'html': req.responseText, + 'style': 'top:' + y + 'px;left:' + x + 'px;position:absolute;width:400px', + drag: 1 + }); + $('boxfilter' + p_obj.div).show(); + } }); } /** * Send data from the form and record a new filter , the ajax answer is a json object * with the attribute filter_name,filter_id,status,message - * + * * @param p_div prefix id of all concerned DOM Element - * @param p_dossier + * @param p_dossier * @see Acc_Ledger_Search */ -function save_filter(p_div,p_dossier) { - var elt=['ledger_type','nb_jrn','date_start','date_end', - 'date_paid_start','date_paid_end','desc','amount_min','amount_max','qcode','accounting', - 'operation_filter','tag_option','p_currency_code','tva_id_search']; - var eltValue={}; - var i =0; - eltValue['gDossier']=p_dossier; - eltValue['op']="save_filter"; - eltValue['div']=p_div; - eltValue['filter_name']=$(p_div+"filter_new").value; +function save_filter(p_div, p_dossier) { + var elt = ['ledger_type', 'nb_jrn', 'date_start', 'date_end', + 'date_paid_start', 'date_paid_end', 'desc', 'amount_min', 'amount_max', 'qcode', 'accounting', + 'operation_filter', 'tag_option', 'p_currency_code', 'tva_id_search']; + var eltValue = {}; + var i = 0; + eltValue['gDossier'] = p_dossier; + eltValue['op'] = "save_filter"; + eltValue['div'] = p_div; + eltValue['filter_name'] = $(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; - + for (var i = 0; i < elt.length; i++) { + var idx = elt[i]; + eltValue[idx] = $(p_div + elt[i]).value; + } - if (eltValue['amount_min']=="") eltValue["amount_min"]=0; - if (eltValue['amount_max']=="") eltValue["amount_max"]=0; - + if (eltValue['amount_min'] == "") eltValue["amount_min"] = 0; + if (eltValue['amount_max'] == "") eltValue["amount_max"] = 0; + //ledger's list r_jrn if (eltValue['nb_jrn'] > 0) { - eltValue['r_jrn']=[]; - for (i=0;i