diff --git a/include/ajax/ajax_history.php b/include/ajax/ajax_history.php index 8a23e008a..56a736be1 100644 --- a/include/ajax/ajax_history.php +++ b/include/ajax/ajax_history.php @@ -35,6 +35,8 @@ $http=new HttpInput(); if ( $g_user->check_dossier(dossier::id(),true) == 'X' ) exit(); $from_div = (isset($_REQUEST['ajax'])) ? 1 : $div; +$clean_lettering=new Lettering($cn); +$clean_lettering->remove_incoherent(); /////////////////////////////////////////////////////////////////////////// /* first detail for a card */ diff --git a/include/class/lettering.class.php b/include/class/lettering.class.php index 91228c874..de3d8666f 100644 --- a/include/class/lettering.class.php +++ b/include/class/lettering.class.php @@ -224,6 +224,7 @@ class Lettering */ public function save($p_array) { + if (!isset($p_array['letter_j_id'])) { // if nothing selected then remove @@ -287,6 +288,7 @@ class Lettering echo $exc->getMessage(); error_log($exc->getTraceAsString()); $this->db->rollback(); + return; } @@ -384,7 +386,15 @@ class Lettering ob_end_clean(); return $r; } - + /** + * @brief for some reason , sometimes, a record in letter_X doesn't have his counterpart + * in letter_Y + */ + function remove_incoherent() + { + $this->db->exec_sql("delete from letter_cred lc where jl_id not in (select jl_id from letter_deb)"); + $this->db->exec_sql("delete from letter_deb lc where jl_id not in (select jl_id from letter_cred)"); + } /** * wrapper : it call show_all, show_lettered or show_not_lettered depending * of the parameter @@ -392,6 +402,7 @@ class Lettering */ public function show_list($p_type) { + switch ($p_type) { case 'all': @@ -505,7 +516,9 @@ class Lettering_Account extends Lettering isNumber($this->fil_amount_max)==1&& isNumber($this->fil_amount_min)==1&& ($this->fil_amount_max!=0||$this->fil_amount_min!=0)) - $filter_amount=" and (j_montant >= $this->fil_amount_min and j_montant<=$this->fil_amount_max or (coalesce(comptaproc.get_letter_jnt($p_jid),-1)= coalesce(comptaproc.get_letter_jnt(j_id),-1) and coalesce(comptaproc.get_letter_jnt($p_jid),-1) <> -1 )) "; + $filter_amount=" and (j_montant >= $this->fil_amount_min and j_montant<=$this->fil_amount_max " + . " or (coalesce(comptaproc.get_letter_jnt($p_jid),-1)= coalesce(comptaproc.get_letter_jnt(j_id),-1) " + . " and coalesce(comptaproc.get_letter_jnt($p_jid),-1) <> -1 )) "; $sql=" select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, diff --git a/include/fiche.inc.php b/include/fiche.inc.php index 6f0ba282b..cf5cd0ba2 100644 --- a/include/fiche.inc.php +++ b/include/fiche.inc.php @@ -487,6 +487,9 @@ echo $export_pdf; echo $export_print; $fiche = new Fiche($cn); $histo=$http->get("histo","number"); +$clean_lettering=new Lettering($cn); +$clean_lettering->remove_incoherent(); + for ($e = 0; $e < count($afiche); $e++) { $array = Fiche::get_fiche_def($cn, $afiche[$e]['fd_id'], 'name_asc'); diff --git a/include/lettering.account.inc.php b/include/lettering.account.inc.php index 178d63586..184ff6fe5 100644 --- a/include/lettering.account.inc.php +++ b/include/lettering.account.inc.php @@ -124,7 +124,7 @@ $letter=new Lettering_Account($cn); $letter->set_parameter('account',$http->get('acc')); $letter->set_parameter('start',$start->value); $letter->set_parameter('end',$end->value); - +$letter->remove_incoherent(); if ( $sel->selected == 0 ) echo $letter->show_list('all'); if ( $sel->selected == 1 ) diff --git a/include/lettering.card.inc.php b/include/lettering.card.inc.php index c28db7859..d5aa2d69e 100644 --- a/include/lettering.card.inc.php +++ b/include/lettering.card.inc.php @@ -123,7 +123,7 @@ $quick_code=strtoupper(trim($http->get('acc'))); $letter->set_parameter('quick_code',$quick_code); $letter->set_parameter('start',$start->value); $letter->set_parameter('end',$end->value); - +$letter->remove_incoherent(); if ( $sel->selected == 0 ) echo $letter->show_list('all'); if ( $sel->selected == 1 )