diff --git a/include/class_lettering.php b/include/class_lettering.php index 4eef2d2f0..8e322ace7 100644 --- a/include/class_lettering.php +++ b/include/class_lettering.php @@ -292,10 +292,26 @@ class Lettering ob_clean(); return $r; } + /** + *show only the lettered records from jrnx + *it fills the array $this->content + */ + protected function show_lettered_diff() + { + $this->get_letter_diff(); + $r=""; + ob_start(); + include('template/letter_all.php'); + $r=ob_get_contents(); + ob_clean(); + return $r; + } + /** *show only the not lettered records from jrnx *it fills the array $this->content */ + protected function show_not_lettered() { $this->get_unletter(); @@ -324,6 +340,9 @@ class Lettering case 'letter': return $this->show_lettered(); break; + case 'letter_diff': + return $this->show_lettered_diff(); + break; } throw new Exception ("[$p_type] is no unknown"); } @@ -447,7 +466,8 @@ class Lettering_Account extends Lettering $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,jr_pj_number, - coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter + coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter, + comptaproc.letter_compare(coalesce(comptaproc.get_letter_jnt(j_id),-1)) as letter_diff from jrnx join jrn on (j_grpt = jr_grpt_id) where j_poste = $1 and j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date ($3,'DD.MM.YYYY') and $this->sql_ledger @@ -463,13 +483,32 @@ class Lettering_Account extends Lettering $sql=" select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, - coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter + coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter, + comptaproc.letter_compare(coalesce(comptaproc.get_letter_jnt(j_id),-1)) as letter_diff from jrnx join jrn on (j_grpt = jr_grpt_id) where j_poste = $1 and j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date ($3,'DD.MM.YYYY') and $this->sql_ledger and j_id in (select j_id from letter_deb join jnt_letter using (jl_id) union select j_id from letter_cred join jnt_letter using (jl_id) ) order by j_date,j_id"; $this->content=$this->db->get_array($sql,array($this->account,$this->start,$this->end)); + } + /** + * same as get_all but only for lettered operation + */ + public function get_letter_diff() + { + $sql=" + select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, + j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, + coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter, + comptaproc.letter_compare(coalesce(comptaproc.get_letter_jnt(j_id),-1)) as letter_diff + from jrnx join jrn on (j_grpt = jr_grpt_id) + where j_poste = $1 and j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date ($3,'DD.MM.YYYY') + and $this->sql_ledger + and j_id in (select j_id from letter_deb join jnt_letter using (jl_id) union select j_id from letter_cred join jnt_letter using (jl_id) ) + and comptaproc.letter_compare(coalesce(comptaproc.get_letter_jnt(j_id),-1)) <> 0 + order by j_date,j_id"; + $this->content=$this->db->get_array($sql,array($this->account,$this->start,$this->end)); } /** * same as get_all but only for unlettered operation @@ -480,7 +519,8 @@ class Lettering_Account extends Lettering $sql=" select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, - coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter + coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter, + comptaproc.letter_compare(coalesce(comptaproc.get_letter_jnt(j_id),-1)) as letter_diff from jrnx join jrn on (j_grpt = jr_grpt_id) where j_poste = $1 and j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date ($3,'DD.MM.YYYY') and $this->sql_ledger @@ -545,7 +585,8 @@ class Lettering_Card extends Lettering $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, - coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter + coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter, + comptaproc.letter_compare(coalesce(comptaproc.get_letter_jnt(j_id),-1)) as letter_diff from jrnx join jrn on (j_grpt = jr_grpt_id) where j_qcode = upper($1) and j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date ($3,'DD.MM.YYYY') and $this->sql_ledger @@ -563,7 +604,8 @@ class Lettering_Card extends Lettering $sql=" select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, - coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter + coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter, + comptaproc.letter_compare(coalesce(comptaproc.get_letter_jnt(j_id),-1)) as letter_diff from jrnx join jrn on (j_grpt = jr_grpt_id) where j_qcode = upper($1) and j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date ($3,'DD.MM.YYYY') and $this->sql_ledger @@ -580,13 +622,29 @@ class Lettering_Card extends Lettering $sql=" select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, - coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter + coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter, + comptaproc.letter_compare(coalesce(comptaproc.get_letter_jnt(j_id),-1)) as letter_diff from jrnx join jrn on (j_grpt = jr_grpt_id) where j_qcode = upper($1) and j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date ($3,'DD.MM.YYYY') and $this->sql_ledger and j_id in (select j_id from letter_deb join jnt_letter using (jl_id) union select j_id from letter_cred join jnt_letter using (jl_id) ) order by j_date,j_id"; $this->content=$this->db->get_array($sql,array($this->quick_code,$this->start,$this->end)); + } + public function get_letter_diff() + { + $sql=" + select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, + j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, + coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter, + comptaproc.letter_compare(coalesce(comptaproc.get_letter_jnt(j_id),-1)) as letter_diff + from jrnx join jrn on (j_grpt = jr_grpt_id) + where j_qcode = upper($1) and j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date ($3,'DD.MM.YYYY') + and $this->sql_ledger + and j_id in (select j_id from letter_deb join jnt_letter using (jl_id) union select j_id from letter_cred join jnt_letter using (jl_id) ) + and comptaproc.letter_compare(coalesce(comptaproc.get_letter_jnt(j_id),-1))<>0 + order by j_date,j_id"; + $this->content=$this->db->get_array($sql,array($this->quick_code,$this->start,$this->end)); } /** * same as get_all but only for unlettered operation @@ -596,7 +654,8 @@ class Lettering_Card extends Lettering $sql=" select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, - coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter + coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter, + comptaproc.letter_compare(coalesce(comptaproc.get_letter_jnt(j_id),-1)) as letter_diff from jrnx join jrn on (j_grpt = jr_grpt_id) where j_qcode = upper($1) and j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date ($3,'DD.MM.YYYY') and $this->sql_ledger diff --git a/include/export_fiche_balance_csv.php b/include/export_fiche_balance_csv.php index 420cff52e..a5161bf21 100644 --- a/include/export_fiche_balance_csv.php +++ b/include/export_fiche_balance_csv.php @@ -125,12 +125,16 @@ else { $letter->get_unletter(); } + if ($_GET['histo'] == 6) + { + $letter->get_letter_diff(); + } /* skip if nothing to display */ if (count($letter->content) == 0) continue; printf('"%s"'."\n",$row->strAttribut(ATTR_DEF_QUICKCODE), $row->strAttribut(ATTR_DEF_NAME)); - printf('"%s";"%s";"%s";"%s";"%s";"%s";"%s"', + printf('"%s";"%s";"%s";"%s";"%s";"%s";"%s";"%s";"%s"', _('Date'), _('ref'), _('Interne'), @@ -138,7 +142,8 @@ else _('Débit'), _('Crébit'), _('Prog.'), - _('Let.')); + _('Let.'), + _("Diff Let.")); printf("\n"); $amount_deb = 0; $amount_cred = 0; @@ -167,7 +172,10 @@ else } printf ("%s;",nb($prog)); if ($row['letter'] != -1) + { printf('"%s";',$row['letter']); + printf("%s",nb($row['letter_diff'])); + } else printf(";"); printf("\n"); diff --git a/include/export_fiche_balance_pdf.php b/include/export_fiche_balance_pdf.php index 10f41a937..df30a3ae6 100644 --- a/include/export_fiche_balance_pdf.php +++ b/include/export_fiche_balance_pdf.php @@ -180,6 +180,10 @@ else { $letter->get_unletter(); } + if ($_GET['histo'] == 6) + { + $letter->get_letter_diff(); + } /* skip if nothing to display */ if (count($letter->content) == 0) continue; @@ -195,7 +199,7 @@ else $pdf->Cell($tab[2], 7, 'Comm'); $pdf->Cell(40, 7, 'Montant', 0, 0, 'C'); $pdf->Cell($tab[5], 7, 'Let.', 0, 0, 'R'); - $pdf->Cell($tab[6], 7, 'Som. Let.', 0, 0, 'R'); + $pdf->Cell($tab[6], 7, 'Diff. Let.', 0, 0, 'R'); $pdf->ln(); $amount_deb = 0; @@ -236,11 +240,8 @@ else { $pdf->Cell($tab[5], 4, $row['letter'], 0, 0, $align[5], $fill); // get sum for this lettering - $sql = "select sum(j_montant) from jrnx where j_debit=$1 and j_id in " . - " (select j_id from jnt_letter join letter_deb using (jl_id) where jl_id=$2 union " . - " select j_id from jnt_letter join letter_cred using (jl_id) where jl_id=$3)"; - $sum = $cn->get_value($sql, array($row['j_debit'], $row['letter'], $row['letter'])); - $pdf->Cell($tab[6], 4, sprintf('%.2f', $sum), '0', '0', 'R', $fill); + + $pdf->Cell($tab[6], 4, sprintf('%.2f', $row['letter_diff']), '0', '0', 'R', $fill); } else $pdf->Cell($tab[5], 4, "", 0, 0, 'R', $fill); diff --git a/include/impress_fiche.inc.php b/include/impress_fiche.inc.php index ce165faaf..af4f42df5 100644 --- a/include/impress_fiche.inc.php +++ b/include/impress_fiche.inc.php @@ -27,7 +27,7 @@ require_once('class_lettering.php'); $gDossier=dossier::id(); $cn=new Database($gDossier); -global $g_user; +global $g_user,$g_failed;; /** * Show first the form @@ -60,6 +60,7 @@ $histo=new ISelect('histo'); $histo->value=array( array('value'=>0,'label'=>_('Historique')), array('value'=>1,'label'=>_('Historique Lettré')), + array('value'=>6,'label'=>_('Historique Lettré et montants différents')), array('value'=>2,'label'=>_('Historique non Lettré')), array('value'=>3,'label'=>_('Résumé')), array('value'=>4,'label'=>_('Balance')), @@ -271,6 +272,10 @@ for ($e = 0; $e < count($afiche); $e++) { $letter->get_unletter(); } + if ( $_GET['histo'] == 6 ) + { + $letter->get_letter_diff(); + } /* skip if nothing to display */ if (count($letter->content) == 0) continue; @@ -300,9 +305,9 @@ for ($e = 0; $e < count($afiche); $e++) echo ''; $row = $letter->content[$i]; echo td($row['j_date_fmt']); - echo td($row['jr_pj_number']); + echo td(h($row['jr_pj_number'])); echo td(HtmlInput::detail_op($row['jr_id'], $row['jr_internal'])); - echo td($row['jr_comment']); + echo td(h($row['jr_comment'])); if ($row['j_debit'] == 't') { echo td(nbm($row['j_montant']), ' style="text-align:right"'); @@ -319,7 +324,11 @@ for ($e = 0; $e < count($afiche); $e++) } echo td(nbm($prog), 'style="text-align:right"'); if ($row['letter'] != -1) - echo td($row['letter']); + { + $span_error=""; + if ( $row['letter_diff'] != 0 ) $span_error=$g_failed; + echo td($row['letter'].$span_error); + } else echo td(''); echo ''; diff --git a/include/lettering.account.inc.php b/include/lettering.account.inc.php index 9e91d430b..2d88de605 100644 --- a/include/lettering.account.inc.php +++ b/include/lettering.account.inc.php @@ -70,6 +70,7 @@ $sel=new ISelect('type_let'); $sel->value=array( array('value'=>0,'label'=>_('Toutes opérations')), array('value'=>1,'label'=>_('Opérations lettrées')), + array('value'=>3,'label'=>_('Opérations lettrées montants différents')), array('value'=>2,'label'=>_('Opérations NON lettrées')) ); if (isset($_GET['type_let'])) $sel->selected=$_GET['type_let']; @@ -113,7 +114,8 @@ if ( $sel->selected == 1 ) echo $letter->show_list('letter'); if ( $sel->selected == 2 ) echo $letter->show_list('unletter'); - +if ( $sel->selected == 3 ) + echo $letter->show_list('letter_diff'); echo ''; echo ''; echo '