From 689dfc28be3ebcf8b978efd3cb5aea70dda61797 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 17 Dec 2017 18:47:21 +0100 Subject: [PATCH] Task #1378 : show only the ledger of a given type --- html/js/scripts.js | 40 ++++++++++++++++++++++++++++++ include/cfgledger.inc.php | 5 ++++ include/class/acc_ledger.class.php | 2 +- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index 02c4792c3..65192cddb 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -3002,4 +3002,44 @@ function pin (object_id) { ); $('pin_'+object_id).firstChild.innerHTML="≊"; } +} +/** + * Show only the rows into the table (p_table_id) with the attribute (p_attribute_name) and if this attribute + * has the value of (attribut_value) + * @param p_table_id table id + * @param p_attribute_name the name of the attribute + * @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)) { + throw "Invalide table id" + } + var mTable=$(p_table_id) ; + var ncount=mTable.rows.length + for (var i = 0;i < ncount;i++) { + var mRow=mTable.rows[i]; + if (mRow.getAttribute(p_attribute_name) != undefined && mRow.getAttribute(p_attribute_name)!=p_attribute_value){ + mRow.hide(); + } else { + mRow.show(); + } + } +} +/** + * Show all the rows into the table (p_table_id) + * @param p_table_id table id + */ +function show_all_row(p_table_id) +{ + if ( ! $(p_table_id)) { + throw "Invalide table id" + } + var mTable=$(p_table_id) ; + var ncount=mTable.rows.length + for (var i = 0;i < ncount;i++) { + var mRow=mTable.rows[i]; + mRow.show(); + } + } \ No newline at end of file diff --git a/include/cfgledger.inc.php b/include/cfgledger.inc.php index 7002f6e22..d9fc2b372 100644 --- a/include/cfgledger.inc.php +++ b/include/cfgledger.inc.php @@ -159,6 +159,11 @@ switch ($sa) // Display list of ledgers ////////////////////////////////////////////////////////////////////////// if ( $show_menu == 1 ) { + echo HtmlInput::anchor_action(_("Tout"), 'show_all_row(\'cfgledger_table_id\')','ledger_all_bt','smallbutton '); + echo HtmlInput::anchor_action(_("Financier"), 'show_only_row(\'cfgledger_table_id\',\'ledger_type\',\'FIN\')','ledger_fin_bt','smallbutton '); + echo HtmlInput::anchor_action(_("Achat"), 'show_only_row(\'cfgledger_table_id\',\'ledger_type\',\'ACH\')','ledger_ach_bt','smallbutton '); + echo HtmlInput::anchor_action(_("OpĂ©rations Diverses"), 'show_only_row(\'cfgledger_table_id\',\'ledger_type\',\'ODS\')','ledger_ods_bt','smallbutton '); + echo HtmlInput::anchor_action(_("Vente"), 'show_only_row(\'cfgledger_table_id\',\'ledger_type\',\'VEN\')','ledger_ven_bt','smallbutton '); echo '
'; echo $ledger->listing(); echo '
'; diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index a14640302..975541238 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -2617,7 +2617,7 @@ class Acc_Ledger extends jrn_def_sql { $l_line=Database::fetch_array($ret, $i); $url=$base_url."&sa=detail&p_jrn=".$l_line['jrn_def_id']; - $r.=sprintf('%s', $url, + $r.=sprintf('%s', $l_line['jrn_def_type'],$url, h($l_line['jrn_def_name']).' ('.$l_line['jrn_def_type'].')'); } $r.="";