phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r4558 - in phpcompta/trunk: html include include/templat


From: phpcompta-dev
Subject: [Phpcompta-dev] r4558 - in phpcompta/trunk: html include include/template
Date: Mon, 5 Dec 2011 21:19:07 +0100 (CET)

Author: danydb
Date: 2011-12-05 21:19:05 +0100 (Mon, 05 Dec 2011)
New Revision: 4558

Modified:
   phpcompta/trunk/html/ajax_misc.php
   phpcompta/trunk/include/class_lettering.php
   phpcompta/trunk/include/template/letter_prop.php
Log:
484: Affichage de tous les op?\195?\169rations lettr?\195?\169es dans le 
d?\195?\169tail


Modified: phpcompta/trunk/html/ajax_misc.php
===================================================================
--- phpcompta/trunk/html/ajax_misc.php  2011-12-04 21:26:23 UTC (rev 4557)
+++ phpcompta/trunk/html/ajax_misc.php  2011-12-05 20:19:05 UTC (rev 4558)
@@ -260,7 +260,7 @@
        case 'dl':
                require_once('class_lettering.php');
                $exercice = $user->get_exercice();
-                if ($user->check_module("LETCARD") == 0 && 
$user->check_module("LETACC") == 0) exit();
+        if ($user->check_module("LETCARD") == 0 && 
$user->check_module("LETACC") == 0) exit();
                $periode = new Periode($cn);
                list($first_per, $last_per) = $periode->get_limit($exercice);
 

Modified: phpcompta/trunk/include/class_lettering.php
===================================================================
--- phpcompta/trunk/include/class_lettering.php 2011-12-04 21:26:23 UTC (rev 
4557)
+++ phpcompta/trunk/include/class_lettering.php 2011-12-05 20:19:05 UTC (rev 
4558)
@@ -28,11 +28,11 @@
 /**
  address@hidden mother class for the lettering by account and by card
  * use the tables jnt_letter, letter_deb and letter_cred
- * - "account"=>"account",       => the accounting of the j_id (use by 
Lettering_Account) 
- * - "quick_code"=>"quick_code", => the quick_code of the j_id (used by 
Lettering_Card) 
- * - "start"=>"start",    => date of the first day 
- * - "end"=>"end",                => date of the last day 
- * - "sql_ledger"=>"sql_ledger"  => the sql clause to filter on the available 
ledgers 
+ * - "account"=>"account",       => the accounting of the j_id (use by 
Lettering_Account)
+ * - "quick_code"=>"quick_code", => the quick_code of the j_id (used by 
Lettering_Card)
+ * - "start"=>"start",    => date of the first day
+ * - "end"=>"end",                => date of the last day
+ * - "sql_ledger"=>"sql_ledger"  => the sql clause to filter on the available 
ledgers
 */
 class Lettering
 {
@@ -85,16 +85,30 @@
      */
     function insert_couple($j_id1,$j_id2)
     {
-        $jl_id=$this->db->get_next_seq("jnt_letter_jl_id_seq");
-        $this->db->exec_sql('insert into jnt_letter(jl_id) values($1)',
-                            array($jl_id));
+
         /*  take needed data */
         $first=$this->db->get_value('select j_debit from jrnx where 
j_id=$1',array($j_id1));
         if ( $this->db->count() == 0 ) throw new Exception ('Opération non 
existante');
 
         $second=$this->db->get_value('select j_debit from jrnx where 
j_id=$1',array($j_id2));
         if ( $this->db->count() == 0 ) throw new Exception ('Opération non 
existante');
-        /* insert */
+               $sql_already="select distinct(jl_id)
+                       from jnt_letter
+                       left outer join letter_deb using (jl_id)
+                       left outer join letter_cred using (jl_id)
+                       where
+                       letter_deb.j_id = $1 or letter_cred.j_id=$1";
+
+               $already=$this->db->get_array($sql_already,array($j_id1));
+               if ( count ($already ) > 0) return;
+
+               $already=$this->db->get_array($sql_already,array($j_id2));
+               if ( count ($already ) > 0) return;
+
+               $jl_id=$this->db->get_next_seq("jnt_letter_jl_id_seq");
+        $this->db->exec_sql('insert into jnt_letter(jl_id) values($1)',
+                            array($jl_id));
+               /* insert */
         if ( $first == 't')
         {
             // save into letter_deb
@@ -128,7 +142,7 @@
      address@hidden $p_array
     @code
     'gDossier' => string '13' (length=2)
-    'letter_j_id' => 
+    'letter_j_id' =>
       array
         0 => string '5' (length=1)
         1 => string '23' (length=2)
@@ -228,8 +242,21 @@
         ob_clean();
         return $r;
     }
+       function get_linked($p_jlid)
+       {
+               $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
+             from jrnx join jrn on (j_grpt = jr_grpt_id)
+                        where
+                        j_id in (select j_id from letter_cred where jl_id=$1
+                                       union all
+                                       select j_id from letter_deb where 
jl_id=$1)";
+
+               $this->linked=$this->db->get_array($sql,array($p_jlid));
+       }
     /**
-     *show only the lettered records from jrnx 
+     *show only the lettered records from jrnx
      *it fills the array $this->content
      */
     protected function show_lettered()
@@ -243,7 +270,7 @@
         return $r;
     }
     /**
-     *show only the not lettered records from jrnx 
+     *show only the not lettered records from jrnx
      *it fills the array $this->content
      */
     protected function show_not_lettered()
@@ -282,14 +309,21 @@
     {
         $j_debit=$this->db->get_value('select j_Debit from jrnx where 
j_id=$1',array($p_jid));
         $amount_init=$this->db->get_value('select j_montant from jrnx where 
j_id=$1',array($p_jid));
+
         $this->get_filter($p_jid);
         // retrieve jnt_letter.id
         $sql="select distinct(jl_id) from jnt_letter  left outer join 
letter_deb using (jl_id) left outer join letter_cred using (jl_id)
              where letter_deb.j_id = $1 or letter_cred.j_id=$2";
-        $jnt_id=$this->db->get_value($sql,array($p_jid,$p_jid));
+        $a_jnt_id=$this->db->get_array($sql,array($p_jid,$p_jid));
 
-        if ($this->db->count()==0 ) $jnt_id=-2;
-
+        if (count($a_jnt_id)==0 )
+               {
+                       $jnt_id=-2;
+               } else
+               {
+                       $jnt_id=$a_jnt_id[0]['jl_id'];
+               }
+               $this->get_linked($jnt_id);
         ob_start();
         require_once('template/letter_prop.php');
         $r=ob_get_contents();
@@ -332,6 +366,7 @@
         $this->account=$p_account;
         $this->object_type='account';
     }
+
     /**
      * fills the this->content, datas are filtered thanks
      * - fil_deb poss values t (debit), f(credit), ' ' (everything)

Modified: phpcompta/trunk/include/template/letter_prop.php
===================================================================
--- phpcompta/trunk/include/template/letter_prop.php    2011-12-04 21:26:23 UTC 
(rev 4557)
+++ phpcompta/trunk/include/template/letter_prop.php    2011-12-05 20:19:05 UTC 
(rev 4558)
@@ -8,7 +8,7 @@
 ?>
   <h2 class="info2"><?=_('Désolé aucun résultat trouvé')?></h2>
 
-<?     
+<?
   else :
 ?>
 <table class="result">
@@ -39,11 +39,47 @@
 </tr>
 
 <?php
-   $amount_deb=($j_debit=='t')?$amount_init:0;
+$this->content=array_merge($this->linked,$this->content);
+$amount_deb=($j_debit=='t')?$amount_init:0;
 $amount_cred=($j_debit=='f')?$amount_init:0;
+
+$linked_limit=count($this->linked);
+
 for ($i=0;$i<count($this->content);$i++):
   $class="";
 if ( ($i % 2) == 0 ) $class="odd";
+if ( $i < $linked_limit ) $class="even";
+if ($linked_limit != 0 && $i==$linked_limit)
+{
+       ?>
+<tr>
+<th>
+</th>
+<th>
+   <?=_('Lettrage')?>
+</th>
+<th>
+   <?=_('Date')?>
+</th>
+<th>
+   <?=_('Ref')?>
+</th>
+<th>
+   <?=_('Description')?>
+</th>
+<th>
+   <?=_('Montant')?>
+</th>
+<th>
+   <?=_('Debit / Credit')?>
+</th>
+<th>
+  <?=_('Op. concerné')?>
+</th>
+</tr>
+<?
+
+}
 ?>
   <tr <? echo "class=\"$class\""; ?> >
 <td>
@@ -52,7 +88,7 @@
 
    if ($this->content[$i]['j_id']==$p_jid) continue;
 $check=new ICheckbox('ck'.$i);
-if ( $jnt_id == $this->content[$i]['letter'] ) $check->selected=true; else 
$check->selected=false;
+if ( $jnt_id == $this->content[$i]['letter'] && $i < $linked_limit) 
$check->selected=true; else $check->selected=false;
 
 if ( $this->content[$i]['letter'] == -1 ||  $check->selected == true )
        echo $check->input();
@@ -94,18 +130,19 @@
 </td>
 
 </tr>
-
-<?php
+<?
+if ($i<$linked_limit)
+{
   $amount_deb+=( $jnt_id == $this->content[$i]['letter'] && 
$this->content[$i]['j_debit']=='t')?$this->content[$i]['j_montant']:0;
   $amount_cred+=( $jnt_id == $this->content[$i]['letter'] && 
$this->content[$i]['j_debit']=='f')?$this->content[$i]['j_montant']:0;
-
+}
     endfor;
 ?>
 </TABLE>
+  <h2 class="info"> Total lettré</h2>
 <span style="display:block;font-size:14px"><?=_('Total Debit')?>   
<?=$amount_deb?></span>
 <span style="display:block;font-size:14px"><?=_('Total Credit')?>   
<?=$amount_cred?></span>
 
-</table>
 <?php endif;?>
 <?=HtmlInput::button('check_all','Sélectionner tout',' 
onclick="select_checkbox(\'letter_form\')"');?>
 <?=HtmlInput::button('check_none','Tout Désélectionner ',' 
onclick="unselect_checkbox(\'letter_form\')"');?>
\ No newline at end of file




reply via email to

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