From 52cc9a97995065c68cfe28acf192446d204cec2e Mon Sep 17 00:00:00 2001 From: sparkyx Date: Thu, 21 Jan 2021 06:37:46 +0100 Subject: [PATCH] Fix : PHP compatibility with count Fix : Dossier::set_current Code cleaning , --- include/class/acc_ledger.class.php | 3 ++- include/class/acc_ledger_search.class.php | 5 +++-- include/class/dossier.class.php | 2 +- include/compta_fin_rec.inc.php | 12 +++++++++--- include/compta_fin_saldo.inc.php | 4 ++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index e9683ee31..ae10b9096 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -1388,12 +1388,13 @@ class Acc_Ledger extends jrn_def_sql /** * @brief get the first ledger * @param type - * @return the j_id + * @return the j_id or null if no user available */ public function get_first($p_type, $p_access=3) { global $g_user; $all=$g_user->get_ledger($p_type, $p_access); + if (empty ($all)) return NULL; return $all[0]; } diff --git a/include/class/acc_ledger_search.class.php b/include/class/acc_ledger_search.class.php index b435c8dc3..a85dfc59e 100644 --- a/include/class/acc_ledger_search.class.php +++ b/include/class/acc_ledger_search.class.php @@ -1198,7 +1198,8 @@ class Acc_Ledger_Search echo HtmlInput::title_box(_("Journaux"), $p_div."jrn_search"); echo '
'; echo '
'; - echo HtmlInput::hidden('nb_jrn', count($p_array)); + $nb_array=(empty($p_array))?0:count($p_array); + echo HtmlInput::hidden('nb_jrn', $nb_array); echo _('Filtre ').HtmlInput::filter_table($p_div.'tb_jrn', '0,1,2', 2); echo HtmlInput::anchor_action(_('Inverser sel'),' toggle_checkbox(\''."{$p_div}search_frm".'\')','sel_'.$p_div,"nav"); echo "-"; @@ -1222,7 +1223,7 @@ class Acc_Ledger_Search echo ''; echo ''; - for ($e=0;$e$p_dossier]); + put_global([ [ "key"=>"gDossier","value"=>$p_dossier]]); self::check(); } diff --git a/include/compta_fin_rec.inc.php b/include/compta_fin_rec.inc.php index 8b53fa8bd..6fc2dd936 100644 --- a/include/compta_fin_rec.inc.php +++ b/include/compta_fin_rec.inc.php @@ -134,11 +134,17 @@ $Ledger = new Acc_Ledger_Fin($cn, 0); if (!isset($_REQUEST['p_jrn'])) { $a = $Ledger->get_first('fin'); - $Ledger->id = $a['jrn_def_id']; + if ( isset($a['jrn_def_id'])) { + $Ledger->id = $a['jrn_def_id']; + } else { + $Ledger->id=0; + } } else - $Ledger->id = $_REQUEST['p_jrn']; -$jrn_priv = $g_user->get_ledger_access($Ledger->id); +{ + $Ledger->id =$http->request("p_jrn","number",0); +} +$jrn_priv = ($Ledger->id == 0)?"X":$g_user->get_ledger_access($Ledger->id); if (isset($_GET["p_jrn"]) && $jrn_priv == "X") { NoAccess(); diff --git a/include/compta_fin_saldo.inc.php b/include/compta_fin_saldo.inc.php index 42b6e9bde..cc0d95790 100644 --- a/include/compta_fin_saldo.inc.php +++ b/include/compta_fin_saldo.inc.php @@ -62,9 +62,9 @@ $filter_year=" j_tech_per in (select p_id from parm_periode where p_exercice=' $idx=0; bcscale(2); $tot_extrait=0; $tot_diff=0; $tot_operation=0; - +$nb_array=(empty($array))?0:count($array); // for each account -for ($i=0; $iid==0) {