noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 73/119: Contact option : export CSV


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 73/119: Contact option : export CSV
Date: Mon, 26 Oct 2020 18:27:26 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 75190f41e1735cb71f0a22f8fc74aae9d0a4c2d0
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: Sat Oct 10 21:21:14 2020 +0200

    Contact option : export CSV
---
 html/export.php                                 |  1 +
 include/action.common.inc.php                   |  3 ++
 include/export/export_follow_up_contact_csv.php | 68 +++++++++++++++++++++++++
 include/template/detail-action.php              | 10 +++-
 sql/upgrade.sql                                 |  4 +-
 5 files changed, 83 insertions(+), 3 deletions(-)

diff --git a/html/export.php b/html/export.php
index d32bc49..9b5044c 100644
--- a/html/export.php
+++ b/html/export.php
@@ -50,6 +50,7 @@ if ( $action=='X'  || $g_user->check_print($action)==0 )
 
  $prfile=$cn->get_value("select me_file from menu_ref where 
me_code=$1",array($action));
  if ( $prfile == "") {
+     print $action;
      die (_('Export impossible'));
  }
  require_once NOALYSS_INCLUDE."/export/$prfile";
diff --git a/include/action.common.inc.php b/include/action.common.inc.php
index 33904ec..257915c 100644
--- a/include/action.common.inc.php
+++ b/include/action.common.inc.php
@@ -209,9 +209,11 @@ if ($sub_action == 'detail')
             $act->ag_id = $ag_id;
             echo $act->get();
         }
+      
         
        if ($g_user->can_write_action($ag_id)  == true)
        {
+            
             echo '<form  enctype="multipart/form-data"  id="action_common_frm" 
class="print" action="do.php"  method="post"   >';
             echo $supl_hidden;
             echo HtmlInput::hidden('ac', $http->request('ac'));
@@ -221,6 +223,7 @@ if ($sub_action == 'detail')
             echo '<input type="hidden" id="delete" name="delete" value="0">';
             echo HtmlInput::submit("save", "Sauve",' 
onclick="$(\'delete\').value=0"');
             echo HtmlInput::submit("add_action_here", _("Ajoute un événement à 
celui-ci"),' onclick="$(\'delete\').value=0"');
+            
             // 
             if ($g_user->can_delete_action($ag_id))
             {
diff --git a/include/export/export_follow_up_contact_csv.php 
b/include/export/export_follow_up_contact_csv.php
new file mode 100644
index 0000000..569f94f
--- /dev/null
+++ b/include/export/export_follow_up_contact_csv.php
@@ -0,0 +1,68 @@
+<?php
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   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
+ */
+// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
+
+if (!defined('ALLOWED'))
+    die('Appel direct ne sont pas permis');
+require_once NOALYSS_INCLUDE.'/class/follow_up.class.php';
+require_once NOALYSS_INCLUDE.'/lib/noalyss_csv.class.php';
+
+$http=new HttpInput();
+$ag_id=$http->get("ag_id", "number");
+
+if ( $g_user->can_read_action($ag_id) == false ) return;
+
+
+/**
+ * @file
+ * @brief export a follow up in CSV 
+ */
+$csv=new Noalyss_CSV("followup".$ag_id);
+$csv->send_header();
+
+$document=new Follow_Up($cn);
+echo $document->export_csv(["tdoc"=>$ag_id]);
+
+$ret=$cn->exec_sql("select f_id,(select ad_value from fiche_detail where 
f_id=a.f_id and ad_id=25) as company,
+(select ad_value from fiche_detail where f_id=a.f_id and ad_id=1) as name,
+(select ad_value from fiche_detail where f_id=a.f_id and ad_id=32) as 
first_name,
+(select ad_value from fiche_detail where f_id=a.f_id and ad_id=23) as 
quick_code,
+cor.cor_label,
+apo.ap_value 
+from action_person a 
+left join action_person_option apo ON  (a.ap_id=apo.action_person_id)
+left join contact_option_ref cor on (apo.contact_option_ref_id=cor.cor_id)
+where ag_id=$1",[$ag_id]);
+$aTitle= array ( 
+            array("title"=>_("fiche_id"), "type"=>"string"),
+            array("title"=>_("société"), "type"=>"string"),
+            array("title"=>_("nom"), "type"=>"string"),
+            array("title"=>_("prénom"), "type"=>"string"),
+            array("title"=>_("qcode"), "type"=>"string"),
+            array("title"=>_("option"), "type"=>"string"),
+            array("title"=>_("valeur"), "type"=>"string"));
+$cn->query_to_csv($ret,$aTitle);
+
+$ret=$cn->exec_sql('select t_tag,t_description from action_tags join tags 
using (t_id) where ag_id=$1',[$ag_id]);
+$aTitle=array(
+    array('title'=>_('Etiquette'),"type"=>"string"),
+    array('title'=>_("Description"),"type"=>"string")
+);
+$cn->query_to_csv($ret,$aTitle);
\ No newline at end of file
diff --git a/include/template/detail-action.php 
b/include/template/detail-action.php
index 5155590..fc5c20b 100644
--- a/include/template/detail-action.php
+++ b/include/template/detail-action.php
@@ -80,7 +80,13 @@ $uniq=uniqid("tab",TRUE);
                ?>
               </td>
               <td>
-
+                    <?php
+                    $csv="export.php?".
+                            http_build_query(["gDossier"=>Dossier::id(),
+                                "act"=>"CSV:FollowUpContactOption",
+                                "ag_id"=>$ag_id]);
+                    echo HtmlInput::anchor(_("Export CSV"), $csv);
+                    ?>
               </td>
           </tr>
           <?php endif; ?>
@@ -149,7 +155,7 @@ $uniq=uniqid("tab",TRUE);
 <?php if ($this->ag_id > 0 ): ?>
           <tr>
             <TD>
-                Dossier / tags
+                Dossier / Etiquette
             </TD>
             
             <td id="action_tag_td">
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index e3b85d5..4d158dd 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -20,4 +20,6 @@ ALTER TABLE public.jnt_document_option_contact ADD CONSTRAINT 
jnt_document_optio
 insert into attr_def(ad_id,ad_text,ad_type,ad_size) values 
(54,'Actif','check','1');
 insert into attr_min(frd_id,ad_id) select frd_id , 54 from fiche_def_ref ;
 insert into jnt_fic_attr  (fd_id,ad_id,jnt_order) select fd_id,54,30 from 
fiche_def;
-insert into fiche_detail (f_id,ad_id,ad_value) select f_id, 54,1 from 
fiche_detail where ad_id=1;
\ No newline at end of file
+insert into fiche_detail (f_id,ad_id,ad_value) select f_id, 54,1 from 
fiche_detail where ad_id=1;
+insert into menu_ref(me_code,me_menu,me_file,me_type) values 
('CSV:FollowUpContactOption','Export action 
suivi','export_follow_up_contact_csv.php','PR');
+insert into profile_menu (me_code,p_id,p_type_display) select 
'CSV:FollowUpContactOption',p_id,'P' from profile;



reply via email to

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