noalyss Version-9
card_multiple.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 * @file
24 * @brief in follow-up , add multiple cards to an event, an action
25 */
26
27/**
28 * @class Card_Multiple
29 * @brief in follow-up , add multiple cards to an event, an action
30 */
32{
33 private $sql ; //!< SQL with the right column name
34 function __construct()
35 {
36 $this->sql="select f_id,quick_code,vw_name,accounting,vw_first_name,vw_description,
37 (select ad_value from fiche_detail fd where fd.f_id=vw_fiche_attr.f_id and fd.ad_id=25) as company
38 from vw_fiche_attr ";
39 }
40 /**
41 *
42 * @param type $sql_array
43 * @return type
44 */
46 {
48 $filter="";
49 if ( $sql_array["inactive_card"]==0) {
50 $filter=" and ".$this->filter_enable_card();
51 }
52 // By Cat of card
53 $sql_cat="";
54 if ( $sql_array['search_cat']!=-1) {
55 $sql_cat=' and fd_id = '.sql_string($sql_array['search_cat']);
56 }
58 if ( $sql_array['search_in'] == "-1")
59 {
60 $string_sql=$this->sql."
61 where
62 (vw_name ilike '%$query%'
63 or quick_code ilike '%$query%')
64 ".$filter.$sql_cat."
65 order by vw_name
66 limit
68 } else {
69 $string_sql=sprintf($this->sql." where f_id in (select f_id from fiche_detail where
70 ad_id = '%s' and ad_value ilike '%%%s%%') %s %s"
71 , sql_string($sql_array["search_in"]),$query,$filter,$sql_cat);
72 }
73 return $string_sql;
74 }
75 /**
76 *
77 * @param type $sql_array
78 * @return type
79 */
81 {
84 $filter="";
85 if ( $sql_array["inactive_card"]==0) {
86 $filter="and ".$this->filter_enable_card();
87 }
88 // By Cat of card
89 $sql_cat="";
90 if ( $sql_array['search_cat']!=-1) {
91 $sql_cat=' and fd_id = '.sql_string($sql_array['search_cat']);
92 }
93
94 $string_sql="select count(*)
95 from vw_fiche_attr
96 where
97 ( vw_name ilike '%$query%'
98 or quick_code ilike '%$query%')
99 ".$filter.$sql_cat;
100
101
102 return $cn->get_value($string_sql);
103 }
104 /**
105 *
106 * @return string
107 */
108 private function filter_enable_card()
109 {
110 $filter_enable_card=" f_enable='1' ";
111 return $filter_enable_card;
112 }
113 /**
114 *
115 * @global type $g_user
116 * @param type $ap_id
117 * @return type
118 */
119 function display_option($p_action_person_id)
120 {
121 global $g_user;
123 // retrieve card id (fiche.f_id) and the ag_id (action_gestion.ag_id)
124 $tmp=$cn->get_row("select f_id,ag_id from action_person where ap_id=$1 ", [$p_action_person_id]);
125 if ($tmp==NULL)
126 {
127 record_log("CMDO.01nothing found ".var_export($_REQUEST, true));
128 return;
129 }
130 $fiche_id=$tmp['f_id'];
131 $ag_id=$tmp['ag_id'];
132 if ( ! $g_user->can_read_action($ag_id)) {
133 throw new Exception (_("CMCDO01"."Security"));
134 }
135 // Retrieve Name, first Name and QCODE
136 $aIdentity=$cn->get_row("select (select ad_value from fiche_detail where f_id=$1 and ad_id=1) as name ,
137 (select ad_value from fiche_detail where f_id=$1 and ad_id=32) as first_name ,
138 (select ad_value from fiche_detail where f_id=$1 and ad_id=23) as qcode ",[$fiche_id]);
139
140 // insert new , synchronized
141 $cn->exec_sql("insert into action_person_option (ap_value,contact_option_ref_id ,action_person_id )
142 select null,cor_id,$1
143 from contact_option_ref
144 where
145 cor_id not in (
146 select contact_option_ref_id
147 from action_person_option
148 join action_person a on (a.ap_id=action_person_id)
149 where f_id=$2 and ag_id=$3)",[$p_action_person_id,$fiche_id,$ag_id]);
150
151 // delete disable
152 $cn->exec_sql("delete
153 from action_person_option apo
154 where contact_option_ref_id not in
155 (select contact_option_ref_id from jnt_document_option_contact jdoc join action_gestion on
156 (ag_type=document_type_id)
157 where ag_id=$1 and jdoc_enable=1)",[$ag_id]);
158
159 // First select the option
160 $sql="select ap_id,cor_id,ap_value,cor_type ,cor_label,cor_value_select
161 from contact_option_ref cor
162 join action_person_option apo on (cor.cor_id=apo.contact_option_ref_id)
163 where action_person_id=$1 order by cor_label ";
164
165 $a_option=$cn->get_array($sql,[$p_action_person_id]);
166 require NOALYSS_TEMPLATE."/card_multiple_display_option.php";
167
168 }
169
170}
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition: ac_common.php:511
global $g_user
if no group available , then stop
$ag_id
Definition: action.inc.php:54
$sql_array['query']
$_REQUEST['ac']
$filter
in follow-up , add multiple cards to an event, an action
count_sql($sql_array)
$sql
SQL with the right column name.
build_sql($sql_array)
display_option($p_action_person_id)
@global type $g_user
static connect()
const MAX_CARD_SEARCH
Definition: constant.php:136