diff --git a/include/anc_balance_double.inc.php b/include/anc_balance_double.inc.php index b8ab929f1..6b56ec8f5 100644 --- a/include/anc_balance_double.inc.php +++ b/include/anc_balance_double.inc.php @@ -15,18 +15,21 @@ echo $bc->display_form(); echo ''; if (isset($_GET['result'])) { - $result=$bc->display_html(); - if ($bc->has_data > 0) - { - echo $bc->show_button(); - echo $result; + try { + $result = $bc->display_html(); + if ($bc->has_data > 0) { + echo $bc->show_button(); + echo $result; + }else + { + echo '

'; + echo _('Aucune donnée trouvée'); + echo '

'; + } + + } catch (Exception $e){ + alert($e->getMessage()); } - else - { - echo '

'; - echo _('Aucune donnée trouvée'); - echo '

'; - } - } + ?> diff --git a/include/class/anc_balance_double.class.php b/include/class/anc_balance_double.class.php index 26fed20b0..3aed8e358 100644 --- a/include/class/anc_balance_double.class.php +++ b/include/class/anc_balance_double.class.php @@ -48,6 +48,8 @@ class Anc_Balance_Double extends Anc_Print function display_html () { + if ($this->pa_id == $this->pa_id2) throw new Exception(_("Pas de croisement avec un seul plan"),1000); + bcscale(2); $r=""; @@ -475,9 +477,8 @@ class Anc_Balance_Double extends Anc_Print operation_analytique as a join operation_analytique as b on (a.oa_row=b.oa_row and a.oa_group=b.oa_group) join poste_analytique as poa on (a.po_id=poa.po_id) join poste_analytique as pob on (b.po_id=pob.po_id) - where poa.pa_id=". - $this->pa_id." - and pob.pa_id=".$this->pa_id2." ".$this->set_sql_filter()." + where poa.pa_id= $1 + and pob.pa_id= $2 ".$this->set_sql_filter()." ) as m join poste_analytique as pa on ( a_po_id=pa.po_id) join poste_analytique as pb on (b_po_id=pb.po_id) @@ -488,7 +489,7 @@ class Anc_Balance_Double extends Anc_Print "; - $array=$this->db->get_array($sql); + $array=$this->db->get_array($sql,[$this->pa_id,$this->pa_id2]); $this->has_data=count($array); if ( $this->has_data == 0 ) return null;