diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 6d38964ea..7487b7ba6 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -443,7 +443,7 @@ class Acc_Ledger extends jrn_def_sql $sql="select jrn_deb_max_line as value from jrn_def where jrn_def_id=$1"; $r=$this->db->exec_sql($sql, array($this->id)); $Res=Database::fetch_all($r); - if (sizeof($Res)==0) + if ($Res == FALSE || sizeof($Res)==0) return 1; return $Res[0]['value']; } @@ -469,6 +469,7 @@ class Acc_Ledger extends jrn_def_sql $array=Database::fetch_all($ret); $deb=0.0; $cred=0.0; + if ( $array==FALSE) $array=[]; foreach ($array as $line) { @@ -533,7 +534,7 @@ class Acc_Ledger extends jrn_def_sql $r=$this->db->exec_sql($sql, array($this->id)); $res=Database::fetch_all($r); - if (empty($res)) + if ($res==FALSE || empty($res)) return null; return $res[0]; diff --git a/include/class/acc_ledger_history_generic.class.php b/include/class/acc_ledger_history_generic.class.php index 3606193fa..8770f8219 100644 --- a/include/class/acc_ledger_history_generic.class.php +++ b/include/class/acc_ledger_history_generic.class.php @@ -225,6 +225,9 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History $c=0; // Parse data from jrnx and fill diff. field + if ( $data_jrnx == FALSE ){ + $data_jrnx=[]; + } foreach ($data_jrnx as $code) { $idx_tva=0; diff --git a/include/class/acc_operation.class.php b/include/class/acc_operation.class.php index 793fb7327..167325c6b 100644 --- a/include/class/acc_operation.class.php +++ b/include/class/acc_operation.class.php @@ -330,7 +330,7 @@ class Acc_Operation } /*!\brief retrieve data from jrnx *\note the data are filtered by the access of the current user - * \return an array + * \return an array or FALSE if nothing found */ function get_jrnx_detail() { diff --git a/include/class/anc_balance_simple.class.php b/include/class/anc_balance_simple.class.php index 6a9764eea..8419c674c 100644 --- a/include/class/anc_balance_simple.class.php +++ b/include/class/anc_balance_simple.class.php @@ -69,18 +69,18 @@ class Anc_Balance_Simple extends Anc_Print $a=array(); $count=0; $array=Database::fetch_all($res); - foreach ($array as $row) - { - $a[$count]['po_id']=$row['po_id']; - $a[$count]['sum_deb']=$row['sum_deb']; - $a[$count]['sum_cred']=$row['sum_cred']; - $a[$count]['po_name']=$row['po_name']; - $a[$count]['ga_description']=$row['ga_description']; - $a[$count]['solde']=abs($row['sum_deb']-$row['sum_cred']); - $a[$count]['debit']=($row['sum_deb']>$row['sum_cred'])?"debit":"credit"; - $count++; - } - $this->has_data=$count; + foreach ($array as $row) + { + $a[$count]['po_id']=$row['po_id']; + $a[$count]['sum_deb']=$row['sum_deb']; + $a[$count]['sum_cred']=$row['sum_cred']; + $a[$count]['po_name']=$row['po_name']; + $a[$count]['ga_description']=$row['ga_description']; + $a[$count]['solde']=abs($row['sum_deb']-$row['sum_cred']); + $a[$count]['debit']=($row['sum_deb']>$row['sum_cred'])?"debit":"credit"; + $count++; + } + $this->has_data=$count; return $a; diff --git a/include/class/customer.class.php b/include/class/customer.class.php index b6e8efcd0..59fba23ba 100644 --- a/include/class/customer.class.php +++ b/include/class/customer.class.php @@ -144,9 +144,10 @@ class Customer extends Fiche // select the operation //---- - $Res2=$this->cn->exec_sql("select j_poste,j_montant,j_debit from jrnx where j_grpt=".$row1['j_grpt']); + $Res2=$this->cn->exec_sql("select j_poste,j_montant,j_debit from jrnx where j_grpt=$1",[$row1['j_grpt']]); $a_row=Database::fetch_all($Res2); - + if ($a_row==FALSE) $a_row=[]; + // Store the amount in the array //--- foreach ($a_row as $e) diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index e5b3fa05f..67db0c9d8 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -1163,7 +1163,7 @@ class Fiche $sql="select ad_value from fiche_detail where ad_id=23 and f_id=$1"; $Res=$this->cn->exec_sql($sql,array($this->id)); $r=Database::fetch_all($Res); - if ( sizeof($r) == 0 ) + if ( $r == FALSE || sizeof($r) == 0 ) return null; return $r[0]['ad_value']; } diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index 39d9a004f..3f9327142 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -772,7 +772,7 @@ class Follow_Up if ($a_row==false || sizeof($a_row)==0 ) { $r='
'; - $r.='
Aucun enregistrement trouvé'; + $r.='
'._("Aucun enregistrement trouvé"); $r.="
"; return $r; } diff --git a/include/class/gestion_sold.class.php b/include/class/gestion_sold.class.php index c13492b08..4aca544b4 100644 --- a/include/class/gestion_sold.class.php +++ b/include/class/gestion_sold.class.php @@ -68,7 +68,7 @@ class gestion_sold extends gestion_table // $res contains all the line $res=Database::fetch_all($ret); - if ( sizeof($res)==0) return null; + if ( $res == FALSE || sizeof($res)==0) return null; $count=0; foreach ($res as $row) @@ -108,7 +108,7 @@ class gestion_sold extends gestion_table // $res contains all the line $res=Database::fetch_all($ret); - if ( empty($res) ) return null; + if ( $res==FALSE || empty($res) ) return null; foreach ($res[0] as $idx=>$value) $this->$idx=$value; } diff --git a/include/class/pre_op_fin.class.php b/include/class/pre_op_fin.class.php index 3523d427d..f293eb253 100644 --- a/include/class/pre_op_fin.class.php +++ b/include/class/pre_op_fin.class.php @@ -118,14 +118,14 @@ class Pre_op_fin extends Pre_operation_detail return $array; } /*!\brief load the data from the database and return an array - * \return an array + * \return an array or FALSE is nothing found */ function load() { $sql="select opd_id,opd_poste,opd_amount,opd_comment,opd_debit". - " from op_predef_detail where od_id=".$this->operation->od_id. + " from op_predef_detail where od_id=$1 ". " order by opd_id"; - $res=$this->db->exec_sql($sql); + $res=$this->db->exec_sql($sql,[$this->operation->od_id]); $array=Database::fetch_all($res); return $array; } diff --git a/include/class/pre_operation.class.php b/include/class/pre_operation.class.php index 224d4d1f5..885e7a1fd 100644 --- a/include/class/pre_operation.class.php +++ b/include/class/pre_operation.class.php @@ -128,9 +128,9 @@ class Pre_operation function load() { $sql="select od_id,jrn_def_id,od_name,od_item,od_jrn_type,od_description". - " from op_predef where od_id=".$this->od_id. + " from op_predef where od_id=$1 ". " order by od_name"; - $res=$this->db->exec_sql($sql); + $res=$this->db->exec_sql($sql,[$this->od_id]); $array=Database::fetch_all($res); foreach (array('jrn_def_id','od_name','od_item','od_jrn_type','od_description') as $field) { $this->$field=$array[0][$field]; diff --git a/include/lib/database_core.class.php b/include/lib/database_core.class.php index dca335852..c4fb518ac 100644 --- a/include/lib/database_core.class.php +++ b/include/lib/database_core.class.php @@ -728,7 +728,7 @@ class DatabaseCore /**\brief wrapper for the function pg_fetch_all * \param $ret is the result of pg_exec (exec_sql) - * \return double array (row x col ) + * \return double array (row x col ) or false */ static function fetch_all($ret) diff --git a/include/modele.inc.php b/include/modele.inc.php index 2814fc001..dab6e08e4 100644 --- a/include/modele.inc.php +++ b/include/modele.inc.php @@ -111,7 +111,8 @@ if (isset($_POST["FMOD_NAME"])) if (Database::num_row($Res) != 0) { $a_lob = Database::fetch_all($Res); - for ($i = 0; $i < count($a_lob); $i++) + $nb_log=($a_lob == FALSE)?0:count($a_lob); + for ($i = 0; $i < $nb_lob; $i++) $cn_mod->lo_unlink($a_lob[$i]['jr_pj']); } $Res = $cn_mod->exec_sql("truncate table centralized"); diff --git a/include/template/acc_ledger_history_purchase_extended.php b/include/template/acc_ledger_history_purchase_extended.php index 5506b212f..d6429dbb5 100644 --- a/include/template/acc_ledger_history_purchase_extended.php +++ b/include/template/acc_ledger_history_purchase_extended.php @@ -131,7 +131,7 @@ $a_detail=Database::fetch_all($det); diff --git a/include/verif_bilan.inc.php b/include/verif_bilan.inc.php index 73e10e6bb..cf0181a13 100644 --- a/include/verif_bilan.inc.php +++ b/include/verif_bilan.inc.php @@ -66,7 +66,7 @@ order by jrn_def_name $res=$cn->exec_sql($sql); $jrn=Database::fetch_all($res); -$nb_jrn= count($jrn); +$nb_jrn= ($jrn == FALSE) ?0 :count($jrn); if ( $jrn ===false ) { echo $g_succeed." "._("Aucune anomalie dans les montants des journaux"); } @@ -158,7 +158,8 @@ having count(*) > 1 $poste=$cn->execute('get_poste',array($a_fiche_id[$i]['f_id'])); $tmp_qcode=$cn->execute('get_qcode',array($a_fiche_id[$i]['f_id'])); $qcode=Database::fetch_all($tmp_qcode); - if ( $qcode[0]['qcode']=="") { + + if ( $qcode == FALSE || $qcode[0]['qcode']=="") { continue; } ?> @@ -171,7 +172,8 @@ having count(*) > 1