phpcompta-dev
[Top][All Lists]
Advanced

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

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


From: phpcompta-dev
Subject: [Phpcompta-dev] r4117 - in phpcompta/trunk: html include include/template
Date: Sun, 22 May 2011 18:08:17 +0200 (CEST)

Author: danydb
Date: 2011-05-22 18:08:17 +0200 (Sun, 22 May 2011)
New Revision: 4117

Added:
   phpcompta/trunk/include/export_anc_balance_group_csv.php
   phpcompta/trunk/include/template/anc_balance_group.php
Modified:
   phpcompta/trunk/html/export.php
   phpcompta/trunk/include/anc_imp.inc.php
   phpcompta/trunk/include/class_anc_acc_link.php
   phpcompta/trunk/include/class_anc_group.php
   phpcompta/trunk/include/class_anc_print.php
Log:

0000267: Comptabilit?\195?\169 analytique : groupe

Modified: phpcompta/trunk/html/export.php
===================================================================
--- phpcompta/trunk/html/export.php     2011-05-20 23:29:12 UTC (rev 4116)
+++ phpcompta/trunk/html/export.php     2011-05-22 16:08:17 UTC (rev 4117)
@@ -164,6 +164,10 @@
     require_once('export_anc_acc_list_csv.php');
     exit();
     break;
+  case 'CSV/AncBalGroup':
+    require_once('export_anc_balance_group_csv.php');
+    exit();
+    break;
 
    default:
     alert('Action inconnue '.$_GET['act']);

Modified: phpcompta/trunk/include/anc_imp.inc.php
===================================================================
--- phpcompta/trunk/include/anc_imp.inc.php     2011-05-20 23:29:12 UTC (rev 
4116)
+++ phpcompta/trunk/include/anc_imp.inc.php     2011-05-22 16:08:17 UTC (rev 
4117)
@@ -39,7 +39,7 @@
             array("?p_action=ca_imp&sub=bc2&$str_dossier",_("Balance 
croisée"),_("Balance croisée de 2 plans analytiques"),"bc2"),
            
array("?p_action=ca_imp&sub=tab&$str_dossier",_("Tableau"),_("Tableau lié à la 
comptabilité"),'tab'),
            array("?p_action=ca_imp&sub=lico&$str_dossier",_("Balance 
comptabilité"),_("Lien entre comptabilité et Comptabilité analytique"),'lico'),
-           
array("?p_action=ca_imp&sub=groupe&$str_dossier",_("Groupe"),_("Balance par 
groupe"),'gr'),
+           
array("?p_action=ca_imp&sub=group&$str_dossier",_("Groupe"),_("Balance par 
groupe"),'group'),
 
            );
 $sub=(isset($_GET['sub']))?$_GET['sub']:'no';
@@ -167,3 +167,22 @@
        echo $gl->display_html();
     }
   }
+//---------------------------------------------------------------------------
+// Balance by group
+//---------------------------------------------------------------------------
+if ( $sub == 'group') 
+  {
+    require_once('class_anc_group.php');
+    $gr=new Anc_Group($cn);
+    $gr->get_request();
+    echo '<form method="get">';
+    echo $gr->display_form($str_hidden);
+    echo '<p>'.HtmlInput::submit('Recherche','Recherche').'</p>';
+    echo '</form>';
+    if ( isset($_GET['result']))
+    {
+      echo $gr->show_button($str_hidden);
+      
+      echo $gr->display_html();
+    }
+  }

Modified: phpcompta/trunk/include/class_anc_acc_link.php
===================================================================
--- phpcompta/trunk/include/class_anc_acc_link.php      2011-05-20 23:29:12 UTC 
(rev 4116)
+++ phpcompta/trunk/include/class_anc_acc_link.php      2011-05-22 16:08:17 UTC 
(rev 4117)
@@ -32,19 +32,6 @@
     $this->cn=$p_cn;
   }
 
-  function check()
-  {
-    
-    /*
-     * check date
-     */
-    if (($this->from != '' && isDate ($this->from) == 0)
-       || 
-       ($this->to != '' && isDate ($this->to) == 0))
-      return -1;
-
-    return 0;
-  }  
   /**
    address@hidden get the parameters
    */

Modified: phpcompta/trunk/include/class_anc_group.php
===================================================================
--- phpcompta/trunk/include/class_anc_group.php 2011-05-20 23:29:12 UTC (rev 
4116)
+++ phpcompta/trunk/include/class_anc_group.php 2011-05-22 16:08:17 UTC (rev 
4117)
@@ -27,11 +27,12 @@
 require_once ('class_database.php');
 require_once ('constant.php');
 require_once ('class_dossier.php');
+require_once('class_anc_print.php');
 
 /*! \brief class for the group of the analytic account
  *
  */
-class Anc_Group
+class Anc_Group extends Anc_Print
 {
     var $db;
     var $ga_id;
@@ -126,6 +127,114 @@
         }
         return $res;
     }
+
+    function set_sql_filter()
+    {
+        $sql="";
+        $and="and ";
+        if ( $this->from != "" )
+        {
+            $sql.=" $and  oa_date >= to_date('".$this->from."','DD.MM.YYYY')";
+            $and=" and ";
+        }
+        if ( $this->to != "" )
+        {
+            $sql.=" $and oa_date <= to_date('".$this->to."','DD.MM.YYYY')";
+            $and=" and ";
+        }
+        if ( $this->from_poste != "" )
+        {
+            $sql.=" $and upper(po_name)>= upper('".$this->from_poste."')";
+            $and=" and ";
+        }
+        if ( $this->to_poste != "" )
+        {
+            $sql.=" $and upper(po_name)<= upper('".$this->to_poste."')";
+            $and=" and ";
+        }
+        return $sql;
+
+    }
+
+    function get_result()
+    {
+      $filter_date=$this->set_sql_filter();
+
+      $sql="with m as (select po_id,
+       po_name,
+       ga_id,
+       case when  oa_debit = 't' then oa_amount 
+       else 0
+       end  as amount_deb,
+       case when oa_debit = 'f' then oa_amount 
+       else 0
+       end as amount_cred,
+       oa_date
+       from operation_analytique 
+join poste_analytique using (po_id) 
+where pa_id=$1 $filter_date )
+select sum(amount_cred) as sum_cred, sum(amount_deb)as 
sum_deb,po_name,ga_id,ga_description
+from m left join groupe_analytique using (ga_id)
+group by ga_id,po_name,ga_description
+order by ga_description,po_name";
+      $ret=$this->db->get_array($sql,array($this->pa_id));
+
+      return $ret;
+    }
+
+    function display_html()
+    {
+      if ( $this->check()  != 0)
+       {
+         alert('Désolé mais une des dates données n\'est pas valide');
+         return;
+       }
+
+      $array=$this->get_result();
+      if ( empty ($array) ) return "";
+      require_once('template/anc_balance_group.php');
+
+      
+    }
+  /**
+   address@hidden display the button export CSV
+   address@hidden $p_hidden is a string containing hidden items
+   address@hidden html string
+   */  
+  function show_button($p_hidden)
+  {
+    $r="";
+    $r.= '<form method="GET" action="export.php"  style="display:inline">';
+    $r.= HtmlInput::hidden("act","CSV/AncBalGroup");
+    $r.= HtmlInput::hidden("to",$this->to);
+    $r.= HtmlInput::hidden("from",$this->from);
+    $r.= HtmlInput::hidden("pa_id",$this->pa_id);
+    $r.= HtmlInput::hidden("from_poste",$this->from_poste);
+    $r.= HtmlInput::hidden("to_poste",$this->to_poste);
+    $r.= $p_hidden;
+    $r.= dossier::hidden();
+    $r.=HtmlInput::submit('bt_csv',"Export en CSV");
+    $r.= '</form>';
+    return $r;
+  }
+  function export_csv()
+  {
+    $array=$this->get_result();
+    printf('"groupe";"activité";"débit";"credit";"solde"');
+    printf("\r\n");
+    bcscale(2);
+    for ($i=0;$i<count($array);$i++)
+      {
+       printf('"%s";"%s";%s;%s;%s',
+              $array[$i]['ga_id'],
+              $array[$i]['po_name'],
+              nb($array[$i]['sum_deb']),
+              nb($array[$i]['sum_cred']),
+              nb(bcsub($array[$i]['sum_cred'],$array[$i]['sum_deb']))
+              );
+       printf("\r\n");
+      }
+  }
     static function test_me()
     {
 

Modified: phpcompta/trunk/include/class_anc_print.php
===================================================================
--- phpcompta/trunk/include/class_anc_print.php 2011-05-20 23:29:12 UTC (rev 
4116)
+++ phpcompta/trunk/include/class_anc_print.php 2011-05-22 16:08:17 UTC (rev 
4117)
@@ -164,5 +164,19 @@
         return $sql;
 
     }
+  function check()
+  {
+    
+    /*
+     * check date
+     */
+    if (($this->from != '' && isDate ($this->from) == 0)
+       || 
+       ($this->to != '' && isDate ($this->to) == 0))
+      return -1;
 
+    return 0;
+  }  
+
+
 }

Added: phpcompta/trunk/include/export_anc_balance_group_csv.php
===================================================================
--- phpcompta/trunk/include/export_anc_balance_group_csv.php                    
        (rev 0)
+++ phpcompta/trunk/include/export_anc_balance_group_csv.php    2011-05-22 
16:08:17 UTC (rev 4117)
@@ -0,0 +1,36 @@
+<?php
+/*
+ *   This file is part of PhpCompta.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+/* $Revision$ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/*!\file
+ * \brief export balance by group
+ */
+
+require_once('class_anc_group.php');
+
+header('Pragma: public');
+header('Content-type: application/csv'); 
+header('Content-Disposition: 
attachment;filename="anc-balance-group-export.csv"',FALSE);
+
+$a=new Anc_Group($cn);
+$a->get_request();
+$a->export_csv();
+?>
\ No newline at end of file

Added: phpcompta/trunk/include/template/anc_balance_group.php
===================================================================
--- phpcompta/trunk/include/template/anc_balance_group.php                      
        (rev 0)
+++ phpcompta/trunk/include/template/anc_balance_group.php      2011-05-22 
16:08:17 UTC (rev 4117)
@@ -0,0 +1,78 @@
+<?php
+/**
+ * defined variable $array with the result included from class_anc_group
+ */
+$prev=''; 
+?>
+
+<table class="result">
+
+<?php
+$idx=0;bcscale(2);$solde=0;$tot_group_deb=0;$tot_group_cred=0;
+for ($i=0;$i<count($array);$i++):
+echo '<tr>';
+if ( $i==0) {
+       $prev=$array[$i]['ga_id'];
+       echo '<tr>';
+       echo td($array[$i]['ga_id'],' colspan="5" 
style="width:auto;font-size:120%"');
+        echo '</tr>';
+        ?>
+        <tr>
+<th>Activité</th>
+<th style="text-align:right" >Débit</th>
+<th style="text-align:right">Crébit</th>
+<th style="text-align:right">Solde</th>
+</tr>
+        <?php
+       }
+if ( $prev != $array[$i]['ga_id'])
+{
+       $prev=$array[$i]['ga_id'];
+       
+       echo '<tr>';
+       echo td('Solde');
+       echo td(nbm($tot_group_deb),' class="num"');
+       echo td(nbm($tot_group_cred),' class="num"');
+       echo td(nbm(bcsub($tot_group_cred,$tot_group_deb)),' class="num"');
+                               
+       echo '</tr>';
+       $tot_group_deb=0;$tot_group_cred=0;
+               $prev=$array[$i]['ga_id'];
+       echo '<tr>';
+       echo td($array[$i]['ga_id'],' colspan="5" 
style="width:auto;font-size:120%"');
+        echo '</tr>';
+        ?>
+        <tr>
+<th>Activité</th>
+<th style="text-align:right">Débit</th>
+<th style="text-align:right" >Crébit</th>
+<th style="text-align:right" >Solde</th>
+</tr>
+<?php
+}
+if ($idx %2 == 0)
+  echo '<tr>';
+else
+  echo '<tr class="odd">';
+               echo td($array[$i]['po_name']);
+echo td(nbm($array[$i]['sum_deb']),' class="num"');
+echo td(nbm($array[$i]['sum_cred']),' class="num"');
+$solde=bcsub($array[$i]['sum_cred'],$array[$i]['sum_deb']);
+echo td(nbm($solde),' class="num"');
+               $tot_group_deb=bcadd($tot_group_deb,$array[$i]['sum_deb']);
+               $tot_group_cred=bcadd($tot_group_cred,$array[$i]['sum_cred']);
+echo '</tr>';
+$idx++;
+endfor;
+       
+echo '<tr>';
+
+echo td('Solde');
+echo td(nbm($tot_group_deb),' class="num"');
+echo td(nbm($tot_group_cred),' class="num"');
+echo td(nbm(bcsub($tot_group_cred,$tot_group_deb)),' class="num"');
+                               
+echo '</tr>';
+?>
+
+</table>
\ No newline at end of file




reply via email to

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