noalyss Version-9
follow_up_other_concerned.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * PhpCompta is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
21
22
23/**
24 * @file
25 * @brief Others concerned card in an action
26 * @see Follow_Up
27 */
28
29/**
30 * @class Follow_Up_Other_Concerned
31 * @brief Others concerned card in an action
32 * @see Follow_Up
33 */
35{
36
37 private $ag_id; /* !< action_gestion.ag_id */
38 private $db; /* !< Database handle */
39
40 function __construct($p_database, $p_action_gestion_id)
41 {
42 $this->db=$p_database;
43 $this->ag_id=$p_action_gestion_id;
44 }
45
46 public function get_ag_id()
47 {
48 return $this->ag_id;
49 }
50
51 public function set_ag_id($ag_id)
52 {
53 $this->ag_id=$ag_id;
54 return $this;
55 }
56
57 public function get_db()
58 {
59 return $this->db;
60 }
61
62 public function set_db($cn)
63 {
64 $this->db=$cn;
65 return $this;
66 }
67
68 /**
69 * Remove another concerned (tiers, supplier...)
70 * @remark type $g_user
71 * @param type $p_fiche_id
72 */
73 function remove_linked_card($p_fiche_id)
74 {
75 global $g_user;
76 if ($g_user->can_write_action($this->ag_id))
77 {
78 $this->db->exec_sql('delete from action_person where ag_id = $1 and f_id = $2',
79 array($this->ag_id, $p_fiche_id));
80 return true;
81 }
82 return false;
83 }
84
85
86 /**
87 * Display the count of other concerned card (tiers, supplier...) in button which call
88 * @return string
89 */
91 {
92 $a_linked=$this->db->get_array('select ap_id,f_id from action_person where ag_id=$1', array($this->ag_id));
93 if (count($a_linked)==0)
94 return "0";
96 $javascript=<<<EOF
97 var obj={dossier:$dossier_id,ag_id:$this->ag_id};action_concerned_list(obj);
98EOF;
99 echo HtmlInput::anchor_action(count($a_linked), $javascript, 'linked_card_bt', "button");
100 }
101
102 /**
103 * Add another concerned (tiers, supplier...)
104 * @remark type $g_user
105 * @param type $p_fiche_id
106 */
107 function insert_linked_card($p_fiche_id)
108 {
109 global $g_user;
110 if ($g_user->can_write_action($this->ag_id))
111 {
112 /**
113 * insert into action_person
114 */
115 $count=$this->db->get_value('select count(*) from action_person where f_id=$1 and ag_id=$2',
116 array($p_fiche_id, $this->ag_id));
117 if ($count==0)
118 {
119 $this->db->exec_sql('insert into action_person (ag_id,f_id) values ($1,$2)',
120 array($this->ag_id, $p_fiche_id));
121 }
122 }
123 }
124
125 /**
126 * Return a HTML string with a button for adding other cards
127 * @return type
128 */
130 {
132 $javascript=<<<EOF
133 var obj={dossier:$dossier,ag_id:$this->ag_id};action_concerned_search_card(obj);
134EOF;
135 $js=HtmlInput::button_action(_('Ajout autres'), $javascript, 'xx', 'smallbutton');
136 return $js;
137 }
138
139 /**
140 * Display one row for all the option of a card
141 * @param int $p_fid card if (fiche.f_id)
142 * @param int $p_row index of the row used for alternate the color of the rows
143 * @param array $aOther Column of the options
144 */
145 function display_row($p_fid, $p_row, $pa_Column)
146 {
147 static $dossier_id;
149
150 $action_person_id=$this->db->get_value("select ap_id from action_person where f_id=$1 and ag_id=$2",
151 [$p_fid, $this->ag_id]);
152
153 // Name , first & quick code from fiche
154 $row=$this->db->get_row("select
155 (select ad_value from fiche_detail fd2 where fd2.f_id=ap.f_id and fd2.ad_id = 1) as xname,
156 (select ad_value from fiche_detail fd2 where fd2.f_id=ap.f_id and fd2.ad_id = 32) as xfirst_name,
157 (select ad_value from fiche_detail fd2 where fd2.f_id=ap.f_id and fd2.ad_id = 23) as xqcode
158 from fiche ap
159 where ap.f_id=$1
160 ", [$p_fid]);
161
162
163 // Detail for this one
164 $detail=HtmlInput::anchor($row['xqcode'], "",
165 sprintf("onclick=\"linked_card_option('%s','%s')\"", $action_person_id, $dossier_id),
166 'class="line"', _("Options"));
167 // remove card
168 $js_remove=sprintf("action_remove_concerned('%s','%s','%s')", dossier::id(), $p_fid, $this->ag_id);
169 $remove=Icon_Action::trash(uniqid(), $js_remove);
170 $r=<<<EOF
171 <tr id="other_{$action_person_id}">
172
173 <td>
174 {$detail}
175 </td>
176 <td>
177 {$row['xname']}
178 </td>
179 <td>
180 {$row['xfirst_name']}
181 </td>
182EOF;
183 $nb_other=count($pa_Column);
184 for ($i=0; $i<$nb_other; $i++)
185 {
186 $value=$this->db->get_value("
187 select apo2.ap_value
188 from action_person_option apo2
189 join action_person ap on (apo2.action_person_id=ap.ap_id)
190 where
191 apo2.contact_option_ref_id =$1
192 and ap.f_id=$2
193 and ap.ag_id=$3
194 ", array($pa_Column[$i]['cor_id'], $p_fid, $this->ag_id));
195 $r.=td($value);
196 }
197 $r.='<td>'.$remove.'</td>';
198 $r.='</tr>';
199 return $r;
200 }
201
202 /**
203 * Display all the person with option in a html table
204 */
205 function display_table()
206 {
207 require_once NOALYSS_TEMPLATE."/follow_up_other_concerned_display_table.php";
208 }
209
210 /**
211 * Get Available options
212 */
213 function get_option()
214 {
215 $aColumn=$this->db->get_array("select cor_id,cor_label,jdoc.jdoc_enable
216 from contact_option_ref cor
217 join jnt_document_option_contact jdoc on (cor.cor_id=jdoc.contact_option_ref_id )
218 join action_gestion ag on (ag.ag_type=jdoc.document_type_id )
219 where ag_id=$1 and jdoc.jdoc_enable=1
220 order by upper(cor_label)", [$this->ag_id]);
221 return $aColumn;
222 }
223
224}
225?>
tr($p_string, $p_extra='')
Definition: ac_common.php:88
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$dossier_id
Definition: ajax_poste.php:43
$fl ag_id
$input_from id
Definition: balance.inc.php:63
$dossier
static id()
return the 'gDossier' value after a check
Others concerned card in an action.
display_row($p_fid, $p_row, $pa_Column)
Display one row for all the option of a card.
__construct($p_database, $p_action_gestion_id)
remove_linked_card($p_fiche_id)
Remove another concerned (tiers, supplier...)
button_action_add_concerned_card()
Return a HTML string with a button for adding other cards.
display_table()
Display all the person with option in a html table.
insert_linked_card($p_fiche_id)
Add another concerned (tiers, supplier...)
display_linked_count()
Display the count of other concerned card (tiers, supplier...) in button which call.
static anchor($p_text, $p_url="", $p_js="", $p_style=' class="line" ', $p_title="click", array $p_attribute=[])
Return a simple anchor with a url or a javascript if $p_js is not null then p_url will be javascript:...
static button_action($action, $javascript, $id=NULL, $p_class="button", $p_symbole="")
button Html with javascript
static anchor_action($action, $javascript, $id=NULL, $p_class="button", $p_symbole="")
Anchor Html with javascript.
static trash($p_id, $p_javascript)
Display the icon of a trashbin.
$count
$SecUser db