phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r4936 - in phpcompta/trunk: html/js include include/temp


From: phpcompta-dev
Subject: [Phpcompta-dev] r4936 - in phpcompta/trunk: html/js include include/template
Date: Mon, 18 Jun 2012 21:15:07 +0200 (CEST)

Author: danydb
Date: 2012-06-18 21:15:06 +0200 (Mon, 18 Jun 2012)
New Revision: 4936

Modified:
   phpcompta/trunk/html/js/acc_ledger.js
   phpcompta/trunk/html/js/infobulle.js
   phpcompta/trunk/html/js/scripts.js
   phpcompta/trunk/include/ajax_bank_saldo.php
   phpcompta/trunk/include/class_acc_ledger_fin.php
   phpcompta/trunk/include/template/form_ledger_fin.php
Log:
0000530: Ajouter la possibilit?\195?\169 d'entrer une date par 
op?\195?\169ration dans la saisie du journal de banque

Modified: phpcompta/trunk/html/js/acc_ledger.js
===================================================================
--- phpcompta/trunk/html/js/acc_ledger.js       2012-06-18 16:26:43 UTC (rev 
4935)
+++ phpcompta/trunk/html/js/acc_ledger.js       2012-06-18 19:15:06 UTC (rev 
4936)
@@ -252,7 +252,7 @@
         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();
     }

Modified: phpcompta/trunk/html/js/infobulle.js
===================================================================
--- phpcompta/trunk/html/js/infobulle.js        2012-06-18 16:26:43 UTC (rev 
4935)
+++ phpcompta/trunk/html/js/infobulle.js        2012-06-18 19:15:06 UTC (rev 
4936)
@@ -43,7 +43,7 @@
 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)
 {

Modified: phpcompta/trunk/html/js/scripts.js
===================================================================
--- phpcompta/trunk/html/js/scripts.js  2012-06-18 16:26:43 UTC (rev 4935)
+++ phpcompta/trunk/html/js/scripts.js  2012-06-18 19:15:06 UTC (rev 4936)
@@ -1561,4 +1561,33 @@
                                      }
                                  }
                                  );
+}
+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;i<nb;i++) {
+                       if ( $('tdchdate'+i)) {
+                               if (ch == 2) {
+                                       $('tdchdate'+i).show();
+                               }
+                               if (ch == 1 ) {
+                                       $('tdchdate'+i).hide();
+
+                               }
+                       }
+               }
+       }catch (e) {
+               alert(e.message);
+       }
 }
\ No newline at end of file

Modified: phpcompta/trunk/include/ajax_bank_saldo.php
===================================================================
--- phpcompta/trunk/include/ajax_bank_saldo.php 2012-06-18 16:26:43 UTC (rev 
4935)
+++ phpcompta/trunk/include/ajax_bank_saldo.php 2012-06-18 19:15:06 UTC (rev 
4936)
@@ -53,7 +53,7 @@
 /*  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']));

Modified: phpcompta/trunk/include/class_acc_ledger_fin.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_fin.php    2012-06-18 16:26:43 UTC 
(rev 4935)
+++ phpcompta/trunk/include/class_acc_ledger_fin.php    2012-06-18 19:15:06 UTC 
(rev 4936)
@@ -79,41 +79,44 @@
                $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');
-
-               /*  check if the date is valid */
-               if (isDate($e_date) == null)
+               if ($chdate != 1 && $chdate != 2) throw new Exception ('Le 
choix de date est invalide');
+               if ( $chdate == 1 )
                {
-                       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 @@
                        $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 @@
                //  Date
                //--
                $r.="<tr>";
-               $r.='<td> Date : </td><td>' . $e_date;
+               if ( $chdate == 1 ) $r.='<td> Date : </td><td>' . $e_date;
                // Periode
                //--
                $r.="<td>";
@@ -482,6 +524,7 @@
                //-------------------------------------------------
                $r.='<TABLE style="width:100%" id="fin_item">';
                $r.="<TR>";
+               if ($chdate==2) $r.='<th>Date</th>';
                $r.="<th style=\"width:auto;text-align:left\" 
colspan=\"2\">Nom</TH>";
                $r.="<th style=\"text-align:left\" >Commentaire</TH>";
                $r.="<th style=\"text-align:right\">Montant</TH>";
@@ -523,7 +566,9 @@
 
                        $tiers_label = $fTiers->strAttribut(ATTR_DEF_NAME);
 
-                       $r.="<TR><td>" . ${'e_other' . $i} . "</TD>";
+                       $r.="<TR>";
+                       if ($chdate==2) $r.=td(${"dateop".$i});
+                       $r.="<td>" . ${'e_other' . $i} . "</TD>";
                        // label
                        $r.='<TD style="width:25%;border-bottom:1px dotted 
grey;">';
                        $r.=$fTiers->strAttribut(ATTR_DEF_NAME);
@@ -591,15 +636,17 @@
                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 @@
                $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,23 +685,62 @@
                }
 
                $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
                {
                        $this->db->start();
                        $amount = 0.0;
                        $idx_operation = 0;
                        $ret = '<table class="result" style="width:75%">';
-                       $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 @@
 
                                $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);
 

Modified: phpcompta/trunk/include/template/form_ledger_fin.php
===================================================================
--- phpcompta/trunk/include/template/form_ledger_fin.php        2012-06-18 
16:26:43 UTC (rev 4935)
+++ phpcompta/trunk/include/template/form_ledger_fin.php        2012-06-18 
19:15:06 UTC (rev 4936)
@@ -3,7 +3,20 @@
        <h2 id="jrn_name"> <?=$this->get_name()?></h2>
 </div>
 <legend><?=$f_legend ?> </legend>
+<?
+       $wchdate=new ISelect('chdate');
+       $wchdate->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\')"';
+?>
+<?=$wchdate->input();?>
+<span id="chdate_ext">
    <?=_('Date').' '.$f_date ?>
+</span>
+
 <?=$f_period?><br>
 <?=$f_jrn?><br>
 <?=_('Banque')?><?=$f_bank ?>
@@ -21,7 +34,7 @@
    <fieldset><legend><?=_('Opérations')?></legend>
 <table id="fin_item" width="100%" border="0">
 <tr>
-<!--<th style="text-align: 
left"><?=_('Date')?><?=HtmlInput::infobulle(16)?></TH> -->
+<th id="thdate" style="display:none;text-align: 
left"><?=_('Date')?><?=HtmlInput::infobulle(16)?></TH>
 <th style="text-align: left;width: auto">code<?HtmlInput::infobulle(0)?></TH>
    <th style="text-align: left"><?=_('Fiche')?></TH>
    <th style="text-align: left"><?=_('Commentaire')?></TH>
@@ -29,19 +42,27 @@
    <th style="text-align: left;width:auto"colspan="2"> <?=_('Op. 
Concernée(s)')?></th>
 </tr>
 
-<? foreach ($array as $item) {
+<?
+$i=0;
+foreach ($array as $item) {
+
 echo '<tr>';
 // 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 '</tr>';
+$i++;
+
 }
 ?>
 </table>
 </fieldset>
 </fieldset>
+<script>
+       show_fin_chdate('chdate');
+</script>
 
-



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]