From 5715a582f86c2d97a166b24e575f8f8876707907 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 27 Nov 2019 22:19:57 +0100 Subject: [PATCH] Acc_Ledger_Search , fix small bug + Test file --- include/class/acc_ledger_search.class.php | 30 ++-- include/export/export_histo_csv.php | 5 +- include/template/ledger_search.php | 2 +- .../include/class/acc_ledger_search.Test.php | 133 ++++++++++++++++++ 4 files changed, 156 insertions(+), 14 deletions(-) create mode 100644 unit-test/include/class/acc_ledger_search.Test.php diff --git a/include/class/acc_ledger_search.class.php b/include/class/acc_ledger_search.class.php index 9ffc29292..12ba84e18 100644 --- a/include/class/acc_ledger_search.class.php +++ b/include/class/acc_ledger_search.class.php @@ -19,8 +19,7 @@ */ // Copyright (2016) Author Dany De Bontridder -if (!defined('ALLOWED')) - die('Appel direct ne sont pas permis'); +// if (!defined('ALLOWED')) die('Appel direct ne sont pas permis'); /** * @file @@ -36,8 +35,8 @@ class Acc_Ledger_Search /** * @brief return a HTML string with the form for the search - * @param $p_type if the type of ledger possible values=ALL,VEN,ACH,ODS,FIN - * @param $all_type_ledger + * @param $p_type if the type of ledger possible values=ALL,VEN,ACH,ODS,FIN: uppercase ! + * @param $all_type_ledger * values : * - 1 means all the ledger of this type * - 0 No have the "Tous les journaux" availables @@ -50,7 +49,7 @@ class Acc_Ledger_Search function __construct($p_type, $p_all=1, $p_div="") { $this->cn=Dossier::connect(); - $this->type=$p_type; + $this->set_type($p_type); $this->all=$p_all; $this->div=$p_div; } @@ -72,6 +71,10 @@ class Acc_Ledger_Search public function set_type($type) { + if (! in_array($type, ["ALL","VEN","ACH","ODS","FIN"])) + { + throw new Exception ("ALS02 : type invalide $type",EXC_PARAM_VALUE); + } $this->type=$type; } @@ -265,7 +268,7 @@ class Acc_Ledger_Search * @brief this function will create a sql stmt to use to create the list for * the ledger, * @param $p_array is usually the $_GET, - * @param $p_order the order of the row + * @param $p_order the order of the row --> not used * @param $p_where is the sql condition if not null then the $p_array will not be used * \note the p_action will be used to filter the ledger but gl means ALL * struct array $p_array @@ -407,7 +410,7 @@ class Acc_Ledger_Search $and=''; $g_user=new User($this->cn); - $p_action=$ledger_type; + $p_action=(isset ($ledger_type)) ? $ledger_type:$this->type; if ($p_action=='') $p_action='ALL'; if ($r_jrn==-1) @@ -571,6 +574,8 @@ class Acc_Ledger_Search $where=$fil_ledger.$fil_amount.$fil_date.$fil_desc.$fil_sec.$fil_amount. $fil_qcode.$fil_paid.$fil_account.$fil_date_paid.$fil_hide_operation; $sql.=" where ".$where; + + // Q?? Why do we return where if it is included in SQL ? return array($sql, $where); } @@ -583,6 +588,7 @@ class Acc_Ledger_Search */ function display_search_form() { + $http=new HttpInput(); $r=''; $r.='