diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 7260baf26..1e9cfbeef 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -252,7 +252,7 @@ function ledger_fin_add_row() new_tt=new_tt.replace(/e_other0_amount/g,"e_other"+nb.value+'_amount'); new_tt=new_tt.replace(/e_concerned0/g,"e_concerned"+nb.value); new_tt=new_tt.replace(/e_other0_label/g,"e_other"+nb.value+'_label'); - // new_tt=new_tt.replace(/dateop0/g,"date"+nb.value); + new_tt=new_tt.replace(/dateop0/g,"date"+nb.value); newCell.innerHTML=new_tt; new_tt.evalScripts(); } diff --git a/html/js/infobulle.js b/html/js/infobulle.js index d68fd3dae..e46cb1f11 100644 --- a/html/js/infobulle.js +++ b/html/js/infobulle.js @@ -43,7 +43,7 @@ content[12]="Document généré uniquement si le mode de paiement est utilisé"; content[13]="Vous pouvez utiliser le % pour indiquer le poste parent"; content[14]="Attention, le poste comptable doit exister, il ne sera pas vérifié"; content[15]="Laissez à 0 pour ne rien changer"; -content[16]="Si vous ne remplissez pas la date d'opération, ce sera la date de l'extrait qui sera utilisée"; +content[16]="Vous devez donner la date par opération"; function showBulle(p_ctl) { diff --git a/html/js/scripts.js b/html/js/scripts.js index 911d0143e..7cc2ba1a3 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -1561,4 +1561,33 @@ function stock_inv_detail(p_dossier,p_id) } } ); +} +function show_fin_chdate(obj_id) +{ + try + { + var ch=$(obj_id).options[$(obj_id).selectedIndex].value; + if (ch == 2 ) { + $('chdate_ext').hide(); + $('thdate').show(); + } + if (ch == 1 ) { + $('chdate_ext').show(); + $('thdate').hide(); + } + var nb=$('nb_item').value; + for (i=0;icheck_jrn($_GET['j'])=='X' ) return '{"saldo":"0"}'; /* make a filter on the exercice */ $filter_year=" j_tech_per in (select p_id from parm_periode ". - "where p_exercice='".$user->get_exercice()."')"; + "where p_exercice='".$g_user->get_exercice()."')"; $id=$cn->get_value('select jrn_def_bank from jrn_def where jrn_def_id=$1',array($_GET['j'])); diff --git a/include/class_acc_ledger_fin.php b/include/class_acc_ledger_fin.php index 879531fb8..ffb5be09c 100644 --- a/include/class_acc_ledger_fin.php +++ b/include/class_acc_ledger_fin.php @@ -79,41 +79,44 @@ class Acc_Ledger_Fin extends Acc_Ledger $poste = new Acc_Account_Ledger($this->db, $bank_accounting); if ($poste->load() == false) throw new Exception('Le poste comptable du compte en banque de ce journal est invalide'); + if ($chdate != 1 && $chdate != 2) throw new Exception ('Le choix de date est invalide'); + if ( $chdate == 1 ) + { + /* check if the date is valid */ + if (isDate($e_date) == null) + { + throw new Exception('Date invalide', 2); + } + $oPeriode = new Periode($this->db); + if ($this->check_periode() == false) + { + $periode = $oPeriode->find_periode($e_date); + } + else + { + $oPeriode->p_id = $periode; + list ($min, $max) = $oPeriode->get_date_limit(); + if (cmpDate($e_date, $min) < 0 || + cmpDate($e_date, $max) > 0) + throw new Exception(_('Date et periode ne correspondent pas'), 6); + } - /* check if the date is valid */ - if (isDate($e_date) == null) - { - throw new Exception('Date invalide', 2); - } - $oPeriode = new Periode($this->db); - if ($this->check_periode() == false) - { - $periode = $oPeriode->find_periode($e_date); - } - else - { - $oPeriode->p_id = $periode; - list ($min, $max) = $oPeriode->get_date_limit(); - if (cmpDate($e_date, $min) < 0 || - cmpDate($e_date, $max) > 0) - throw new Exception(_('Date et periode ne correspondent pas'), 6); - } + /* check if the periode is closed */ + if ($this->is_closed($periode) == 1) + { + throw new Exception(_('Periode fermee'), 6); + } - /* check if the periode is closed */ - if ($this->is_closed($periode) == 1) - { - throw new Exception(_('Periode fermee'), 6); - } - - /* check if we are using the strict mode */ - if ($this->check_strict() == true) - { - /* if we use the strict mode, we get the date of the last - operation */ - $last_date = $this->get_last_date(); - if ($last_date != null && cmpDate($e_date, $last_date) < 0) - throw new Exception(_('Vous utilisez le mode strict la dernière operation est à la date du ') - . $last_date . _(' vous ne pouvez pas encoder à une date antérieure'), 15); + /* check if we are using the strict mode */ + if ($this->check_strict() == true) + { + /* if we use the strict mode, we get the date of the last + operation */ + $last_date = $this->get_last_date(); + if ($last_date != null && cmpDate($e_date, $last_date) < 0) + throw new Exception(_('Vous utilisez le mode strict la dernière operation est à la date du ') + . $last_date . _(' vous ne pouvez pas encoder à une date antérieure'), 15); + } } $acc_pay = new Acc_Operation($this->db); @@ -161,6 +164,45 @@ class Acc_Ledger_Fin extends Acc_Ledger $fiche->get_by_qcode(${'e_other' . $i}); if ($fiche->belong_ledger($p_jrn, 'deb') != 1) throw new Exception('La fiche ' . ${'e_other' . $i} . 'n\'est pas accessible à ce journal', 10); + if ($chdate == 2) + { + {/* check if the date is valid */ + if (isDate(${'dateop' . $i}) == null) + { + throw new Exception('Date invalide', 2); + } + $oPeriode = new Periode($this->db); + if ($this->check_periode() == false) + { + $periode = $oPeriode->find_periode(${'dateop' . $i}); + } + else + { + $oPeriode->p_id = $periode; + list ($min, $max) = $oPeriode->get_date_limit(); + if (cmpDate(${'dateop' . $i}, $min) < 0 || + cmpDate(${'dateop' . $i}, $max) > 0) + throw new Exception(_('Date et periode ne correspondent pas'), 6); + } + + /* check if the periode is closed */ + if ($this->is_closed($periode) == 1) + { + throw new Exception(_('Periode fermee'), 6); + } + + /* check if we are using the strict mode */ + if ($this->check_strict() == true) + { + /* if we use the strict mode, we get the date of the last + operation */ + $last_date = $this->get_last_date(); + if ($last_date != null && cmpDate(${'dateop' . $i}, $last_date) < 0) + throw new Exception(_('Vous utilisez le mode strict la dernière operation est à la date du ') + . $last_date . _(' vous ne pouvez pas encoder à une date antérieure'), 15); + } + } + } $nb++; } if ($nb == 0) @@ -423,7 +465,7 @@ class Acc_Ledger_Fin extends Acc_Ledger // Date //-- $r.=""; - $r.=' Date : ' . $e_date; + if ( $chdate == 1 ) $r.=' Date : ' . $e_date; // Periode //-- $r.=""; @@ -482,6 +524,7 @@ class Acc_Ledger_Fin extends Acc_Ledger //------------------------------------------------- $r.=''; $r.=""; + if ($chdate==2) $r.=''; $r.=""; $r.=""; $r.=""; @@ -523,7 +566,9 @@ class Acc_Ledger_Fin extends Acc_Ledger $tiers_label = $fTiers->strAttribut(ATTR_DEF_NAME); - $r.=""; + $r.=""; + if ($chdate==2) $r.=td(${"dateop".$i}); + $r.=""; // label $r.='
DateNomCommentaireMontant
" . ${'e_other' . $i} . "
" . ${'e_other' . $i} . "'; $r.=$fTiers->strAttribut(ATTR_DEF_NAME); @@ -591,15 +636,17 @@ class Acc_Ledger_Fin extends Acc_Ledger if (isset($periode)) $r.=HtmlInput::hidden('periode', $periode); $r.=dossier::hidden(); - $r.=HtmlInput::hidden('sa', 'n'); + $r.=HtmlInput::hidden('sa', 'n','chdate'); for ($i = 0; $i < $nb_item; $i++) { - $tiers = (isset(${"e_other" . $i})) ? ${"e_other" . $i} : "" - ; + $tiers = (isset(${"e_other" . $i})) ? ${"e_other" . $i} : "" ; + $r.=HtmlInput::hidden('e_other' . $i, $tiers); $r.=HtmlInput::hidden('e_other' . $i, $tiers); $r.=HtmlInput::hidden('e_other' . $i . '_comment', ${'e_other' . $i . '_comment'}); $r.=HtmlInput::hidden('e_other' . $i . '_amount', ${'e_other' . $i . '_amount'}); $r.=HtmlInput::hidden('e_concerned' . $i, ${'e_concerned' . $i}); + $r.=HtmlInput::hidden('dateop' . $i, ${'dateop' . $i}); + $r.=HtmlInput::hidden('chdate' , $chdate); } return $r; @@ -625,17 +672,6 @@ class Acc_Ledger_Fin extends Acc_Ledger $e_bank_account = $fBank->strAttribut(ATTR_DEF_QUICKCODE); // Get the saldo $pPeriode = new Periode($this->db); - if ($this->check_periode() == true) - { - $pPeriode->p_id = $periode; - } - else - { - $pPeriode->find_periode($e_date); - } - $exercice = $pPeriode->get_exercice(); - - $filter_year = " j_tech_per in (select p_id from parm_periode where p_exercice='" . $exercice . "')"; $sposte = $fBank->strAttribut(ATTR_DEF_ACCOUNT); // if 2 accounts, take only the debit one for customer if (strpos($sposte, ',') != 0) @@ -649,8 +685,27 @@ class Acc_Ledger_Fin extends Acc_Ledger } $acc_account = new Acc_Account_Ledger($this->db, $poste_val); - $solde = $acc_account->get_solde($filter_year); - $new_solde = $solde; + + // If date = deposit date + if ($chdate == 1 ) + { + if ($this->check_periode() == true) + { + $pPeriode->p_id = $periode; + } + else + { + $pPeriode->find_periode($e_date); + } + $exercice = $pPeriode->get_exercice(); + $filter_year = " j_tech_per in (select p_id from parm_periode where p_exercice='" . $exercice . "')"; + $solde = $acc_account->get_solde($filter_year); + $new_solde = $solde; + } + + + + try { @@ -658,14 +713,34 @@ class Acc_Ledger_Fin extends Acc_Ledger $amount = 0.0; $idx_operation = 0; $ret = ''; - $ret.=tr(th('n° interne') . th('Quick Code') . th('Nom') . th('Libellé') . th('Montant', ' style="text-align:right"')); + $ret.=tr(th('Date').th('n° interne') . th('Quick Code') . th('Nom') . th('Libellé') . th('Montant', ' style="text-align:right"')); // Credit = goods + $get_solde=true; for ($i = 0; $i < $nb_item; $i++) { // if tiers is set and amount != 0 insert it into the database // and quit the loop ? if (strlen(trim(${"e_other$i"})) == 0) continue; + + if ( $chdate == 2 ) $e_date=${'dateop'.$i}; + // if date is date of operation + if ($chdate == 2 && $get_solde ) + { + $get_solde=false; + if ($this->check_periode() == true) + { + $pPeriode->p_id = $periode; + } + else + { + $pPeriode->find_periode($e_date); + } + $exercice = $pPeriode->get_exercice(); + $filter_year = " j_tech_per in (select p_id from parm_periode where p_exercice='" . $exercice . "')"; + $solde = $acc_account->get_solde($filter_year); + $new_solde = $solde; + } $fPoste = new Fiche($this->db); $fPoste->get_by_qcode(${"e_other$i"}); @@ -828,7 +903,7 @@ class Acc_Ledger_Fin extends Acc_Ledger $js_detail = HtmlInput::detail_op($jr_id, $internal); // Compute display - $row = td($js_detail) . td(${"e_other$i"}) . td($fPoste->strAttribut(ATTR_DEF_NAME)) . td(${"e_other" . $i . "_comment"}) . td(nbm(${"e_other$i" . "_amount"}), 'class="num"'); + $row = td($e_date).td($js_detail) . td(${"e_other$i"}) . td($fPoste->strAttribut(ATTR_DEF_NAME)) . td(${"e_other" . $i . "_comment"}) . td(nbm(${"e_other$i" . "_amount"}), 'class="num"'); $ret.=tr($row); diff --git a/include/template/form_ledger_fin.php b/include/template/form_ledger_fin.php index 9f4a810f6..2482f40ad 100644 --- a/include/template/form_ledger_fin.php +++ b/include/template/form_ledger_fin.php @@ -3,7 +3,20 @@

get_name()?>

+value=array( + array('value'=>1,'label'=>"Avec date d'extrait"), + array('value'=>2,'label'=>"Avec date opérations") + ); + $wchdate->selected=(isset($chdate))?$chdate:1; + $wchdate->javascript='onchange="show_fin_chdate(\'chdate\')"'; +?> +input();?> + + +

@@ -21,7 +34,7 @@
- + @@ -29,19 +42,27 @@ -'; // echo td($item['dateop']); +echo td($item['dateop'],' style="display:none" id="tdchdate'.$i.'"'); echo td($item['qcode'].$item['search']); echo td($item['cname']); echo td($item['comment']); echo td($item['amount']); echo td($item['concerned']); echo ''; +$i++; + } ?>
code
- +