phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r4862 - in phpcompta/trunk: html include sql


From: phpcompta-dev
Subject: [Phpcompta-dev] r4862 - in phpcompta/trunk: html include sql
Date: Tue, 5 Jun 2012 22:15:26 +0200 (CEST)

Author: danydb
Date: 2012-06-05 22:15:25 +0200 (Tue, 05 Jun 2012)
New Revision: 4862

Added:
   phpcompta/trunk/include/export_follow_up_csv.php
Modified:
   phpcompta/trunk/html/export.php
   phpcompta/trunk/include/action.common.inc.php
   phpcompta/trunk/include/class_extension.php
   phpcompta/trunk/include/class_follow_up.php
   phpcompta/trunk/sql/upgrade.sql
Log:
0000602: Export des actions de gestion en CSV

Modified: phpcompta/trunk/html/export.php
===================================================================
--- phpcompta/trunk/html/export.php     2012-06-05 20:00:10 UTC (rev 4861)
+++ phpcompta/trunk/html/export.php     2012-06-05 20:15:25 UTC (rev 4862)
@@ -161,6 +161,9 @@
   case 'CSV:reportinit':
          require_once('export_reportinit_csv.php');
          break;
+  case 'CSV:ActionGestion':
+         require_once 'export_follow_up_csv.php';
+         break;
    default:
     alert('Action inconnue '.$_GET['act']);
     exit();

Modified: phpcompta/trunk/include/action.common.inc.php
===================================================================
--- phpcompta/trunk/include/action.common.inc.php       2012-06-05 20:00:10 UTC 
(rev 4861)
+++ phpcompta/trunk/include/action.common.inc.php       2012-06-05 20:15:25 UTC 
(rev 4862)
@@ -172,6 +172,13 @@
 if ( $sub_action == "list" )
   {
     Follow_Up::ShowActionList($cn,$base);
+       // Add a button to export to Csv
+       echo '<form method="GET" ACTION="export.php">';
+       echo 
HtmlInput::request_to_hidden(array("gDossier","qcode","start_date","end_date","ag_id","ag_dest_query",
+                       "tdoc","see_all","all_action","query"));
+       echo HtmlInput::hidden("act", "CSV:ActionGestion");
+       echo HtmlInput::submit("follow_up_csv", "Export CSV");
+       echo "</form>";
   }
 
//--------------------------------------------------------------------------------
 // Add an action

Modified: phpcompta/trunk/include/class_extension.php
===================================================================
--- phpcompta/trunk/include/class_extension.php 2012-06-05 20:00:10 UTC (rev 
4861)
+++ phpcompta/trunk/include/class_extension.php 2012-06-05 20:15:25 UTC (rev 
4862)
@@ -149,5 +149,18 @@
                        echo alert($exc->getMessage());
                }
        }
+       /**
+        *remove all the schema from the plugins
+        * @param Database $p_cn
+        */
+       static function clean(Database $p_cn)
+       {
+               
$a_ext=array("tva_belge","amortissement","impdol","coprop","importbank");
+               for($i=0;$i<count($a_ext);$i++){
+                       if ($p_cn->exist_schema($a_ext[$i])) {
+                               $p_cn->exec_sql("drop schema ".$a_ext[$i]." 
cascade");
+                       }
+               }
+       }
 }
 

Modified: phpcompta/trunk/include/class_follow_up.php
===================================================================
--- phpcompta/trunk/include/class_follow_up.php 2012-06-05 20:00:10 UTC (rev 
4861)
+++ phpcompta/trunk/include/class_follow_up.php 2012-06-05 20:15:25 UTC (rev 
4862)
@@ -1,4 +1,5 @@
 <?php
+
 /*
  *   This file is part of PhpCompta.
  *
@@ -62,15 +63,15 @@
 class Follow_Up
 {
 
-       var $db;        /* !<  $db  database connexion    */
+       var $db; /* !<  $db  database connexion    */
        var $ag_timestamp;  /* !<   $ag_timestamp document date 
(ag_gestion.ag_timestamp) */
        var $dt_id;   /* !<   $dt_id type of the document (document_type.dt_id) 
*/
-       var $ag_state;  /* !<   $ag_state stage of the document (printed, send 
to client...) */
+       var $ag_state; /* !<   $ag_state stage of the document (printed, send 
to client...) */
        var $d_number;   /* !<   $d_number number of the document */
        var $d_filename; /* !<   $d_filename filename's document      */
        var $d_mimetype; /* !<   $d_mimetype document's filename      */
        var $ag_title;   /* !<   $ag_title title document             */
-       var $f_id;      /* !<   $f_id_dest fiche id (From field )  */
+       var $f_id; /* !<   $f_id_dest fiche id (From field )  */
        var $ag_ref;  /* !< $ag_ref is the ref  */
        var $ag_hour;  /* !< $ag_hour is the hour of the meeting, action */
        var $ag_priority; /* !< $ag_priority is the priority 1 High, 2 medium, 
3 low */
@@ -179,9 +180,9 @@
                                ag_id in (select aga_greatest from 
action_gestion_related where aga_least =$1)
                                or
                                ag_id in (select aga_least from 
action_gestion_related where aga_greatest =$1)
-                               order by ag_timestamp",array($this->ag_id));
-               $iaction=new IRelated_Action('action');
-               $iaction->value=(isset($this->action))?$this->action:"";
+                               order by ag_timestamp", array($this->ag_id));
+               $iaction = new IRelated_Action('action');
+               $iaction->value = (isset($this->action)) ? $this->action : "";
 
                // state
                // Retrieve the value
@@ -633,7 +634,8 @@
                {
                        $act = new Follow_Up_Detail($this->db);
                        $act->from_array($_POST, $i);
-                       if ($act->f_id == 0 )continue;
+                       if ($act->f_id == 0)
+                               continue;
                        $act->ag_id = $this->ag_id;
                        $act->save();
                }
@@ -661,7 +663,7 @@
        function myList($p_base, $p_filter = "", $p_search = "")
        {
                // for the sort
-               $url = HtmlInput::get_to_string(array("qcode", "ag_dest_query", 
"query", "tdoc", "date_start", "date_end", "see_all", "all_action")) .  '&' . 
$p_base;
+               $url = HtmlInput::get_to_string(array("qcode", "ag_dest_query", 
"query", "tdoc", "date_start", "date_end", "see_all", "all_action")) . '&' . 
$p_base;
 
                $table = new Sort_Table();
                $table->add('Date', $url, 'order by ag_timestamp asc', 'order 
by ag_timestamp desc', 'da', 'dd');
@@ -919,7 +921,7 @@
                                $this->f_id_dest, /* 4 */
                                $this->ag_state, /* 5 */
                                $this->ag_id, /* 6 */
-                               $this->ag_hour, /* 7*/
+                               $this->ag_hour, /* 7 */
                                $this->ag_priority, /* 8 */
                                $this->ag_dest, /* 9 */
                                $ag_cal, /* 10 */
@@ -936,8 +938,10 @@
                {
                        $act = new Follow_Up_Detail($this->db);
                        $act->from_array($_POST, $i);
-                       if ( $act->f_id == 0 && $act->ad_id != 0 ) 
$act->delete();
-                       if ($act->f_id == 0 ) continue;
+                       if ($act->f_id == 0 && $act->ad_id != 0)
+                               $act->delete();
+                       if ($act->f_id == 0)
+                               continue;
                        $act->save();
                }
                if (trim($this->ag_comment) != '')
@@ -993,7 +997,6 @@
                $this->operation = (isset($p_array['operation'])) ? 
$p_array['operation'] : null;
                $this->op = (isset($p_array['op'])) ? $p_array['op'] : null;
                $this->action = (isset($p_array['action'])) ? 
$p_array['action'] : null;
-
        }
 
        /* !\brief remove the action
@@ -1034,7 +1037,9 @@
                return $array;
        }
 
-
+       /**
+        * insert a related operation
+        */
        function insert_operation()
        {
                if (trim($this->operation) == '')
@@ -1050,6 +1055,9 @@
                }
        }
 
+       /**
+        * remove a related operation
+        */
        function remove_operation()
        {
                if ($this->op == null)
@@ -1060,11 +1068,12 @@
                        $this->db->exec_sql("delete from 
action_gestion_operation where ago_id=$1", array($op[$i]));
                }
        }
+
        /**
-        *Display only a search box for searching an action
+        * Display only a search box for searching an action
         * @param $cn database connx
         */
-       static function display_search($cn,$inner=false)
+       static function display_search($cn, $inner = false)
        {
                $a = (isset($_GET['query'])) ? $_GET['query'] : "";
                $qcode = (isset($_GET['qcode'])) ? $_GET['qcode'] : "";
@@ -1085,11 +1094,12 @@
                /**
                 * Show the default button (add action, show search...)
                 */
-               if (!$inner) require_once 'template/action_button.php';
+               if (!$inner)
+                       require_once 'template/action_button.php';
 
                $w = new ICard();
                $w->name = 'qcode';
-               $w->id=$w->generate_id($w->name);
+               $w->id = $w->generate_id($w->name);
                $w->value = $qcode;
                $w->extra = "all";
                $w->typecard = 'all';
@@ -1128,7 +1138,6 @@
                $str_ag_dest = $ag_dest->input();
                // show the  action in
                require_once 'template/action_search.php';
-
        }
 
        static function ShowActionList($cn, $p_base)
@@ -1144,18 +1153,22 @@
 
 
 
-               $r = $act->myList($p_base, "", $query );
+               $r = $act->myList($p_base, "", $query);
                echo $r;
        }
 
        /**
-        *Get date from $_GET and create the sql stmt for the query
+        * Get date from $_GET and create the sql stmt for the query
         * @see Follow_Up::ShowActionList
         * @return string SQL condition
         */
-       static function create_query($cn)
+       static function create_query($cn, $p_array = null)
        {
-               $query="";
+               if ($p_array == null)
+                       $p_array = $_GET;
+
+               extract($p_array);
+               $query = "";
                if (isset($_REQUEST['query']))
                {
                        // if a query is request build the sql stmt
@@ -1166,7 +1179,7 @@
                }
 
                $str = "";
-               if (isset($_GET['qcode']))
+               if (isset($qcode))
                {
 
                        // verify that qcode is not empty
@@ -1182,38 +1195,43 @@
                                        $str = " and (f_id_dest= " . $fiche->id 
. " ) ";
                        }
                }
-               if (isset($_GET['tdoc']) && $_GET['tdoc'] != -1)
+               if (isset($tdoc) && $tdoc != -1)
                {
-                       $query .= ' and dt_id = ' . Formatstring($_GET['tdoc']);
+                       $query .= ' and dt_id = ' . sql_string($tdoc);
                }
                if (!isset($_GET['see_all']))
                        $query .= ' and ag_state in (2,3) ';
-               if (! isset($_GET['all_action']))
+               if (!isset($all_action))
                {
                        $query .=" and (ag_owner='" . $_SESSION['g_user'] . "' 
or ag_dest in (select p_id from profile_user where user_name='" . 
$_SESSION['g_user'] . "') or ag_dest is null )";
                }
-               if (isset($_GET['date_start']) && isDate($_GET['date_start']) 
!= null)
+               if (isset($date_start) && isDate($date_start) != null)
                {
-                       $date_start = $_GET['date_start'];
                        $query.=" and ag_timestamp >= 
to_date('$date_start','DD.MM.YYYY')";
                }
-               if (isset($_GET['date_end']) && isDate($_GET['date_end']) != 
null)
+               if (isset($date_end) && isDate($date_end) != null)
                {
-                       $date_end = $_GET['date_end'];
                        $query.=" and ag_timestamp <= 
to_date('$date_end','DD.MM.YYYY')";
                }
-               if (isset($_GET['ag_dest_query']))
+               if (isset($ag_dest_query))
                {
-                       if ($_GET['ag_dest_query'] != 0)
-                               $query.= " and ag_dest = " . 
sql_string($_GET['ag_dest_query']);
+                       if ($ag_dest_query != 0)
+                               $query.= " and ag_dest = " . 
sql_string($ag_dest_query);
                }
-               if ( isNumber($_GET['ag_id'])==1 && $_GET['ag_id'] != 0) {
-                       $query=" and ag_id= ".$_GET['ag_id'];
+               if (isNumber($ag_id) == 1 && $ag_id != 0)
+               {
+                       $query = " and ag_id= " . $ag_id;
                }
-               return $query. $str;
+               return $query . $str;
        }
 
-       static function short_list($cn,$p_sql) {
+       /**
+        * Show the result of a search in an inner windows, the result is 
limited to 25
+        * @param type $cn database connx
+        * @param type $p_sql the query
+        */
+       static function short_list($cn, $p_sql)
+       {
                $sql = "
              select ag_id,to_char(ag_timestamp,'DD.MM.YY') as my_date,
                         f_id_dest,
@@ -1225,13 +1243,15 @@
              where $p_sql";
                $max_line = $cn->count_sql($sql);
 
-               $limit=($max_line > 25)?25:$max_line;
-               $Res = $cn->exec_sql($sql . "limit ".$limit);
+               $limit = ($max_line > 25) ? 25 : $max_line;
+               $Res = $cn->exec_sql($sql . "limit " . $limit);
                $a_row = Database::fetch_all($Res);
                require_once 'template/action_search_result.php';
-
        }
 
+       /**
+        * Insert a related action into the table action_gestion_related
+        */
        function insert_action()
        {
                if (trim($this->action) == '')
@@ -1240,11 +1260,53 @@
                for ($i = 0; $i < count($array); $i++)
                {
                        if ($this->db->get_value("select count(*) from 
action_gestion_related
-                               where (aga_least=$1 and aga_greatest=$2) or 
(aga_greatest=$1 and aga_least=$2)", array($array[$i],$this->ag_id)) == 0 && 
$this->ag_id != $array[$i])
+                               where (aga_least=$1 and aga_greatest=$2) or 
(aga_greatest=$1 and aga_least=$2)", array($array[$i], $this->ag_id)) == 0 && 
$this->ag_id != $array[$i])
                        {
                                $this->db->exec_sql("insert into 
action_gestion_related(aga_least,aga_greatest) values ($1,$2)", 
array($this->ag_id, $array[$i]));
                        }
                }
        }
 
+       /**
+        * export to CSV the query the p_array has
+        * @param array $p_array
+        */
+       function export_csv($p_array)
+       {
+               extract($p_array);
+
+
+               $p_search=self::create_query($this->db, $p_array);
+               $sql = "
+             select ag_id,
+                       to_char(ag_timestamp,'DD.MM.YYYY') as my_date,
+                        to_char(ag_remind_date,'DD.MM.YYYY') as my_remind,
+                               (select ad_value from fiche_Detail where 
f_id=action_gestion.f_id_dest and ad_id=1) as name,
+             ag_title,
+                       dt_value,
+                       ag_ref,
+                       ag_priority,
+                       ag_state,
+                       coalesce((select p_name from profile where 
p_id=ag_dest),'Aucun groupe') as dest
+             from action_gestion
+             join document_type on (ag_type=dt_id)
+             where  true  $p_search order by ag_timestamp,ag_id";
+               $ret=$this->db->exec_sql($sql);
+
+               if ( Database::num_row($ret)==0)exit();
+               $this->db->query_to_csv($ret,array(
+                               array("title"=>"doc id","type"=>"string"),
+                               array("title"=>"date","type"=>"date"),
+                               array("title"=>"rappel","type"=>"date"),
+                               array("title"=>"nom","type"=>"string"),
+                               array("title"=>"titre","type"=>"string"),
+                               array("title"=>"type 
document","type"=>"string"),
+                               array("title"=>"ref","type"=>"string"),
+                               array("title"=>"priorite","type"=>"string"),
+                               array("title"=>"etat","type"=>"string"),
+                               array("title"=>"profil","type"=>"string")
+                               )
+                       );
+       }
+
 }

Added: phpcompta/trunk/include/export_follow_up_csv.php
===================================================================
--- phpcompta/trunk/include/export_follow_up_csv.php                            
(rev 0)
+++ phpcompta/trunk/include/export_follow_up_csv.php    2012-06-05 20:15:25 UTC 
(rev 4862)
@@ -0,0 +1,40 @@
+<?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 Action Gestion to csv, taking in account the search
+ *
+ */
+require_once 'class_follow_up.php';
+header('Pragma: public');
+header('Content-type: application/csv');
+header('Content-Disposition: attachment;filename="action-gestion.csv"',FALSE);
+
+$follow=new Follow_Up($cn);
+
+echo $follow->export_csv($_GET);
+
+exit();
+
+?>

Modified: phpcompta/trunk/sql/upgrade.sql
===================================================================
--- phpcompta/trunk/sql/upgrade.sql     2012-06-05 20:00:10 UTC (rev 4861)
+++ phpcompta/trunk/sql/upgrade.sql     2012-06-05 20:15:25 UTC (rev 4862)
@@ -179,4 +179,7 @@
 
 update menu_ref set me_menu='Action Gestion' where me_code='FOLLOW';
 
-DROP FUNCTION comptaproc.action_get_tree(bigint);
\ No newline at end of file
+DROP FUNCTION comptaproc.action_get_tree(bigint);
+
+insert into menu_ref(me_code,me_menu,me_type) values 
('CSV:ActionGestion','Export Action Gestion','PR');
+insert into profile_menu(me_code,p_id,p_type_display,pm_default) values 
('CSV:ActionGestion',1,'P',0);
\ No newline at end of file



---
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]