phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r4129 - phpcompta/trunk/include


From: phpcompta-dev
Subject: [Phpcompta-dev] r4129 - phpcompta/trunk/include
Date: Wed, 25 May 2011 22:04:15 +0200 (CEST)

Author: danydb
Date: 2011-05-25 22:04:14 +0200 (Wed, 25 May 2011)
New Revision: 4129

Modified:
   phpcompta/trunk/include/class_acc_account_ledger.php
   phpcompta/trunk/include/export_gl_csv.php
   phpcompta/trunk/include/export_gl_pdf.php
   phpcompta/trunk/include/impress_gl_comptes.inc.php
Log:
0000271: Filter pour grand livre : compte non sold?\195?\169

Modified: phpcompta/trunk/include/class_acc_account_ledger.php
===================================================================
--- phpcompta/trunk/include/class_acc_account_ledger.php        2011-05-24 
21:12:54 UTC (rev 4128)
+++ phpcompta/trunk/include/class_acc_account_ledger.php        2011-05-25 
20:04:14 UTC (rev 4129)
@@ -102,12 +102,13 @@
      * \param  $p_from date from
      * \param  $p_to   end date
      *\param $let 0 means all rows, 1 only lettered, 2 only unlettered
+        * \param $solded 0 means all account, 1 means only accounts with a 
saldo <> 0
      *\note the data are filtered by the access of the current user
      * \return double array 
(j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal)
      *         (tot_deb,tot_credit
      *
      */
-    function get_row_date($p_from,$p_to,$let=0)
+    function get_row_date($p_from,$p_to,$let=0,$solded=0)
     {
         $user=new User($this->db);
         $filter_sql=$user->get_ledger_sql('ALL',3);
@@ -123,11 +124,32 @@
             $sql_let=' and j_id not in (select j_id from letter_cred union 
select j_id from letter_deb) ';
             break;
         }
+       if ( $solded == 1)
+         {
+           $filter=str_replace('jrn_def_id','jr_def_id',$filter_sql);
+           $bal_sql="with signed_amount as 
+                                               (select case when j_debit='t' 
then j_montant else 0 end as amount_deb,
+                                                               case when 
j_debit='f' then j_montant else 0 end as amount_cred,
+                                                               j_poste 
+                                                               from jrnx join 
jrn on (j_grpt = jr_grpt_id)
+                                                               where 
+                                                               j_poste=$1 and
+                                                               $filter and
+                                                               ( 
to_date($2,'DD.MM.YYYY') <= j_date and 
+                                  to_date($3,'DD.MM.YYYY') >= j_date  ))
+                                               select sum(amount_deb) as 
s_deb,sum(amount_cred) as s_cred, j_poste from signed_amount
+                                               group by j_poste
+                                               ";
+           $r=$this->db->get_array($bal_sql,array($this->id,$p_from,$p_to));
+           if ( $this->db->count() == 0 ) return array();
+           if ($r[0]['s_deb']==$r[0]['s_cred']) return array(); 
+         }
         $Res=$this->db->exec_sql("select  jr_id,to_char(j_date,'DD.MM.YYYY') 
as j_date_fmt,j_date,".
                                  "case when j_debit='t' then j_montant else 0 
end as deb_montant,".
                                  "case when j_debit='f' then j_montant else 0 
end as cred_montant,".
                                  " jr_comment as description,jrn_def_name as 
jrn_name,".
-                                 "j_debit, 
jr_internal,jr_pj_number,coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter 
".
+                                 "j_debit, jr_internal,jr_pj_number,
+                                                                
coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter ".
                                  ",pcm_lib ".
                                 ",jr_tech_per,p_exercice ".
                                  " from jrnx left join jrn_def on 
(jrn_def_id=j_jrn_def )".
@@ -441,16 +463,20 @@
         $hid->input("type","poste").$str_ople.
         $hid->input('p_action','impress').
         $hid->input("from_periode",$_REQUEST['from_periode']).
-        $hid->input("to_periode",$_REQUEST['to_periode']).
-         $hid->input('from_poste',$_REQUEST['from_poste']).
-         $hid->input('to_poste',$_REQUEST['to_poste'])
+        $hid->input("to_periode",$_REQUEST['to_periode'])
          ;
 
        if ( isset($_REQUEST['letter'] )) echo HtmlInput::hidden('letter','2');
+       if ( isset($_REQUEST['solded'] )) echo HtmlInput::hidden('solded','1');
 
+       if (isset($_REQUEST['from_poste'])) 
+         echo $hid->input('from_poste',$_REQUEST['from_poste']);
 
+       if (isset($_REQUEST['to_poste'])) 
+         echo $hid->input('to_poste',$_REQUEST['to_poste']);
 
-        if (isset($_REQUEST['poste_id'])) echo 
$hid->input("poste_id",$_REQUEST['poste_id']);
+        if (isset($_REQUEST['poste_id'])) 
+         echo $hid->input("poste_id",$_REQUEST['poste_id']);
 
         if (isset($_REQUEST['poste_fille']))
             echo $hid->input('poste_fille','on');
@@ -466,12 +492,16 @@
         $hid->input("type","poste").$str_ople.
         $hid->input('p_action','impress').
         $hid->input("from_periode",$_REQUEST['from_periode']).
-        $hid->input("to_periode",$_REQUEST['to_periode']).
-         $hid->input('from_poste',$_REQUEST['from_poste']).
-         $hid->input('to_poste',$_REQUEST['to_poste']);
+         $hid->input("to_periode",$_REQUEST['to_periode']);
 
+       if (isset($_REQUEST['from_poste'])) 
+         echo $hid->input('from_poste',$_REQUEST['from_poste']);
 
+       if (isset($_REQUEST['to_poste'])) 
+         echo $hid->input('to_poste',$_REQUEST['to_poste']);
+
        if ( isset($_REQUEST['letter'] )) echo HtmlInput::hidden('letter','2');
+       if ( isset($_REQUEST['solded'] )) echo HtmlInput::hidden('solded','1');
 
         if (isset($_REQUEST['poste_fille']))
             echo $hid->input('poste_fille','on');

Modified: phpcompta/trunk/include/export_gl_csv.php
===================================================================
--- phpcompta/trunk/include/export_gl_csv.php   2011-05-24 21:12:54 UTC (rev 
4128)
+++ phpcompta/trunk/include/export_gl_csv.php   2011-05-25 20:04:14 UTC (rev 
4129)
@@ -93,14 +93,24 @@
 // Header
 $header = array( "Date", "Référence", "Libellé", "Pièce", "Débit", "Crédit", 
"Solde" );
 
-$let=(isset($_GET['letter']))?2:0;
+$l=(isset($_GET['letter']))?2:0;
+$s=(isset($_REQUEST['solded']))?1:0;
 
 foreach ($a_poste as $poste)
 {
  
 
-    $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']);
-    
list($array,$tot_deb,$tot_cred)=$Poste->get_row_date($from_periode,$to_periode,$let);
+  $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']);
+  
+  $array1=$Poste->get_row_date($from_periode,$to_periode,$l,$s);
+  // don't print empty account
+  if ( count($array1) == 0 )
+    {
+      continue;
+    }
+  $array=$array1[0];
+  $tot_deb=$array1[1];
+  $tot_cred=$array1[2];
 
     // don't print empty account
     if ( count($array) == 0 )

Modified: phpcompta/trunk/include/export_gl_pdf.php
===================================================================
--- phpcompta/trunk/include/export_gl_pdf.php   2011-05-24 21:12:54 UTC (rev 
4128)
+++ phpcompta/trunk/include/export_gl_pdf.php   2011-05-25 20:04:14 UTC (rev 
4129)
@@ -86,19 +86,23 @@
 // Column widths (in mm)
 $width  = array( 13    , 20         , 60       , 15     ,  12     , 20     , 
20      , 20      );
 $l=(isset($_REQUEST['letter']))?2:0;
+$s=(isset($_REQUEST['solded']))?1:0;
 
 foreach ($a_poste as $poste)
 {
 
   $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']);
 
-    
list($array,$tot_deb,$tot_cred)=$Poste->get_row_date($from_periode,$to_periode,$l);
 
-    // don't print empty account
-    if ( count($array) == 0 )
+  $array1=$Poste->get_row_date($from_periode,$to_periode,$l,$s);
+  // don't print empty account
+  if ( count($array1) == 0 )
     {
         continue;
     }
+  $array=$array1[0];
+  $tot_deb=$array1[1];
+  $tot_cred=$array1[2];
 
     $pdf->SetFont('DejaVuCond','',10);
     $Libelle=sprintf("%s - %s ",$Poste->id,$Poste->get_name());

Modified: phpcompta/trunk/include/impress_gl_comptes.inc.php
===================================================================
--- phpcompta/trunk/include/impress_gl_comptes.inc.php  2011-05-24 21:12:54 UTC 
(rev 4128)
+++ phpcompta/trunk/include/impress_gl_comptes.inc.php  2011-05-25 20:04:14 UTC 
(rev 4129)
@@ -57,8 +57,8 @@
 $date_from=new IDate('from_periode');
 $date_to=new IDate('to_periode');
 $year=$User->get_exercice();
-$date_from->value=(isset($_REQUEST['from_periode']))?$_REQUEST['from_periode']:$first_day;
-$date_to->value=(isset($_REQUEST['to_periode']))?$_REQUEST['to_periode']:$last_day;
+$date_from->value=(isset($_REQUEST['from_periode'])&& 
isDate($_REQUEST['from_periode'])!=0)?$_REQUEST['from_periode']:$first_day;
+$date_to->value=(isset($_REQUEST['to_periode']) && 
isDate($_REQUEST['to_periode']) !=0  )?$_REQUEST['to_periode']:$last_day;
 echo td(_('Depuis').$date_from->input());
 echo td(_('Jusque ').$date_to->input());
 
@@ -73,6 +73,9 @@
 $to_poste->value=HtmlInput::default_value('to_poste','',$_REQUEST);
 $to_poste->set_attribute('account','to_poste');
 
+$solded=new ICheckbox('solded');
+$solded->selected=(isset($_REQUEST['solded']))?true:false;
+
 echo '<tr>';
 echo td(_('Depuis le poste')).td($from_poste->input());
 echo '</tr>';
@@ -82,9 +85,16 @@
 echo '</tr>';
 
 echo '<tr>';
-echo td('Uniquement les comptes non lettrés');
+echo td('Uniquement les opérations non lettrées');
 echo td($letter->input());
 echo '</tr>';
+
+echo '<tr>';
+echo td('Uniquement les comptes non soldés');
+echo td($solded->input());
+echo '</tr>';
+
+
 //
 echo '</TABLE>';
 print HtmlInput::submit('bt_html','Visualisation');
@@ -107,8 +117,8 @@
 
     if ($from_poste->value != '') 
       {
-       $cond_poste = '  where ';
-       $cond_poste .=' pcm_val >= upper 
(\''.Database::escape_string($from_poste->value).'\')';
+               $cond_poste = '  where ';
+               $cond_poste .=' pcm_val >= upper 
(\''.Database::escape_string($from_poste->value).'\')';
       }
 
     if ( $to_poste->value != '')
@@ -141,14 +151,16 @@
 
 
     echo '<table class="result">';
-
+       $l=(isset($_REQUEST['letter']))?2:0;
+       $s=(isset($_REQUEST['solded']))?1:0;
+       
     foreach ($a_poste as $poste_id )
     {
         $Poste=new Acc_Account_Ledger ($cn, $poste_id['pcm_val']);
         $Poste->load();
-       $l=(isset($_REQUEST['letter']))?2:0;
+       
 
-        $Poste->get_row_date( $_GET['from_periode'], $_GET['to_periode'],$l);
+        $Poste->get_row_date( $_GET['from_periode'], 
$_GET['to_periode'],$l,$s);
         if ( empty($Poste->row))
         {
             continue;




reply via email to

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