Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

admin/consultationlist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: consultationlist.php 9529 2002-05-14 11:17:05Z jhe $
5 //
6 // Created on: <23-Oct-2000 17:53:46 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/ezhttptool.php" );
29 $ini =& eZINI::instance( 'site.ini' );
30 $Language = $ini->variable( "eZContactMain", "Language" );
31
32 // include_once( "classes/eztemplate.php" );
33
34 // include_once( "ezuser/classes/ezusergroup.php" );
35 // include_once( "ezuser/classes/ezpermission.php" );
36
37 $user =& eZUser::currentUser();
38 if ( !is_a( $user, "eZUser" ) )
39 {
40 // include_once( "classes/ezhttptool.php" );
41 eZHTTPTool::header( "Location: /contact/nopermission/login" );
42 exit();
43 }
44
45 if ( !eZPermission::checkPermission( $user, "eZContact", "Consultation" ) )
46 {
47 // include_once( "classes/ezhttptool.php" );
48 eZHTTPTool::header( "Location: /contact/nopermission/consultation" );
49 exit();
50 }
51
52 if ( isset( $ConsultationList ) )
53 {
54 $templatefile = "consultationdetaillist.tpl";
55 $languagefile = "consultationdetaillist.php";
56 }
57 else
58 {
59 $templatefile = "consultationlist.tpl";
60 $languagefile = "consultationlist.php";
61 }
62
63 $t = new eZTemplate( "kernel/ezcontact/admin/" . $ini->variable( "eZContactMain", "AdminTemplateDir" ),
64 "kernel/ezcontact/admin/intl", $Language, $languagefile );
65 $t->setAllStrings();
66
67 // include_once( "ezcontact/classes/ezconsultation.php" );
68 // include_once( "classes/ezlocale.php" );
69
70 $t->set_file( "consultation_page", $templatefile );
71
72 if ( isset( $ConsultationList ) )
73 {
74 $t->set_block( "consultation_page", "no_consultations_item_tpl", "no_consultations_item" );
75 $t->set_block( "consultation_page", "consultation_table_item_tpl", "consultation_table_item" );
76 $t->set_block( "consultation_table_item_tpl", "consultation_item_tpl", "consultation_item" );
77
78 $t->set_block( "consultation_table_item_tpl", "new_company_consultation_item_tpl", "new_company_consultation_item" );
79 $t->set_block( "consultation_table_item_tpl", "new_person_consultation_item_tpl", "new_person_consultation_item" );
80
81 $t->set_var( "consultation_item", "" );
82 $t->set_var( "no_consultations_item", "" );
83 $t->set_var( "consultation_table_item", "" );
84 }
85 else
86 {
87 $t->set_block( "consultation_page", "no_companies_item_tpl", "no_companies_item" );
88 $t->set_block( "consultation_page", "company_table_item_tpl", "company_table_item" );
89 $t->set_block( "company_table_item_tpl", "company_item_tpl", "company_item" );
90
91 $t->set_block( "consultation_page", "no_persons_item_tpl", "no_persons_item" );
92 $t->set_block( "consultation_page", "person_table_item_tpl", "person_table_item" );
93 $t->set_block( "person_table_item_tpl", "person_item_tpl", "person_item" );
94
95 $t->set_var( "errors", "" );
96
97 $t->set_var( "company_item", "" );
98 $t->set_var( "no_companies_item", "" );
99 $t->set_var( "company_table_item", "" );
100
101 $t->set_var( "person_item", "" );
102 $t->set_var( "no_persons_item", "" );
103 $t->set_var( "person_table_item", "" );
104 }
105
106 $user =& eZUser::currentUser();
107
108 if ( !$user )
109 {
110 eZHTTPTool::header( "Location: /user/login" );
111 exit();
112 }
113
114 if ( isset( $ConsultationList ) )
115 {
116 // List specific consultations
117
118 if ( !isset( $CompanyID ) && !isset( $PersonID ) )
119 {
120 die( "Neither CompanyID or PersonID is set" );
121 }
122
123 if ( empty( $OrderBy ) )
124 {
125 $OrderBy = "Date";
126 }
127
128 if ( isset( $CompanyID ) )
129 {
130 if ( $ini->variable( "eZContactMain", "ShowAllConsultations" ) == "enabled" )
131 {
132 if ( $ini->variable( "eZContactMain", "ShowRelatedConsultations" ) == "enabled" )
133 $consultations = eZConsultation::findConsultationsByContact( $CompanyID, -1, $OrderBy, false, 0, -1, true );
134 else
135 $consultations = eZConsultation::findConsultationsByContact( $CompanyID, -1, $OrderBy, false );
136 }
137 else
138 {
139 if ( $ini->variable( "eZContactMain", "ShowRelatedConsultations" ) == "enabled" )
140 $consultations = eZConsultation::findConsultationsByContact( $CompanyID, $user->id(), $OrderBy, false, 0, -1, true );
141 else
142 $consultations = eZConsultation::findConsultationsByContact( $CompanyID, $user->id(), $OrderBy, false );
143 }
144
145 $t->set_var( "consultation_type", "company" );
146 $t->set_var( "company_id", $CompanyID );
147 $company = new eZCompany( $CompanyID );
148 $t->set_var( "contact_name", $company->name() );
149 }
150 else if ( isset( $PersonID ) )
151 {
152 if ( $ini->variable( "eZContactMain", "ShowAllConsultations" ) == "enabled" )
153 {
154 if ( $ini->variable( "eZContactMain", "ShowRelatedConsultations" ) == "enabled" )
155 $consultations = eZConsultation::findConsultationsByContact( $PersonID, -1, $OrderBy, true, 0, -1, true );
156 else
157 $consultations = eZConsultation::findConsultationsByContact( $PersonID, -1, $OrderBy, true );
158 }
159 else
160 {
161 if ( $ini->variable( "eZContactMain", "ShowRelatedConsultations" ) == "enabled" )
162 $consultations = eZConsultation::findConsultationsByContact( $PersonID, $user->id(), $OrderBy, true, 0, -1, true );
163 else
164 $consultations = eZConsultation::findConsultationsByContact( $PersonID, $user->id(), $OrderBy, true );
165 }
166
167 $t->set_var( "consultation_type", "person" );
168 $t->set_var( "person_id", $PersonID );
169 $person = new eZPerson( $PersonID );
170 $t->set_var( "contact_name", $person->name() );
171 }
172
173 $count = count( $consultations );
174
175 if ( $i < 0 )
176 {
177 $t->set_block( );
178 }
179
180 $locale = new eZLocale( $Language );
181 $i = 0;
182
183 foreach ( $consultations as $consultation )
184 {
185 $t->set_var( "bg_color", ( $i % 2 ) == 0 ? "bglight" : "bgdark" );
186 $t->set_var( "consultation_id", $consultation->id() );
187 $t->set_var( "consultation_date", $locale->format( $consultation->date() ) );
188 $t->set_var( "consultation_short_description", $consultation->shortDescription() );
189 $t->set_var( "consultation_status_id", $consultation->state() );
190 $t->set_var( "consultation_status", eZConsultation::stateName( $consultation->state() ) );
191 $t->parse( "consultation_item", "consultation_item_tpl", true );
192 $i++;
193 }
194
195 if ( $count > 0 )
196 {
197 $t->parse( "consultation_table_item", "consultation_table_item_tpl", true );
198 }
199 else
200 {
201 $t->parse( "no_consultations_item", "no_consultations_item_tpl", true );
202 }
203
204 if ( isset( $CompanyID ) )
205 {
206 $t->set_var( "new_person_consultation_item", "" );
207 $t->parse( "new_company_consultation_item", "new_company_consultation_item_tpl" );
208 }
209 else if ( isset( $PersonID ) )
210 {
211 $t->parse( "new_person_consultation_item", "new_person_consultation_item_tpl" );
212 $t->set_var( "new_company_consultation_item", "" );
213 }
214 }
215 else
216 {
217 // Find companies which the user has consulted with
218 if ( $ini->variable( "eZContactMain", "ShowAllConsultations" ) == "enabled" )
219 $companies = eZConsultation::findConsultedCompanies( -1 );
220 else
221 $companies = eZConsultation::findConsultedCompanies( $user->id() );
222 $count = count( $companies );
223
224 if ( $i < 0 )
225 {
226 $t->set_block( );
227 }
228
229 for ( $i = 0; $i < $count; $i++ )
230 {
231 if ( ( $i % 2 ) == 0 )
232 {
233 $t->set_var( "bg_color", "bglight" );
234 }
235 else
236 {
237 $t->set_var( "bg_color", "bgdark" );
238 }
239
240 $t->set_var( "company_id", $companies[$i]->id() );
241 $t->set_var( "company_name", $companies[$i]->name() );
242 if ( $ini->variable( "eZContactMain", "ShowAllConsultations" ) == "enabled" )
243 $t->set_var( "consultation_count", eZConsultation::companyConsultationCount( $companies[$i]->id(), -1 ) );
244 else
245 $t->set_var( "consultation_count", eZConsultation::companyConsultationCount( $companies[$i]->id(), $user->id() ) );
246 $t->parse( "company_item", "company_item_tpl", true );
247 }
248
249 if ( $count > 0 )
250 {
251 $t->parse( "company_table_item", "company_table_item_tpl", true );
252 }
253 else
254 {
255 $t->parse( "no_companies_item", "no_companies_item_tpl", true );
256 }
257
258 // Find persons which the user has consulted with
259
260 if ( $ini->variable( "eZContactMain", "ShowAllConsultations" ) == "enabled" )
261 $persons = eZConsultation::findConsultedPersons( -1 );
262 else
263 $persons = eZConsultation::findConsultedPersons( $user->id() );
264
265 $count = count( $persons );
266
267 if ( $i < 0 )
268 {
269 $t->set_block( );
270 }
271
272 for ( $i = 0; $i < $count; $i++ )
273 {
274 if ( ( $i % 2 ) == 0 )
275 {
276 $t->set_var( "bg_color", "bglight" );
277 }
278 else
279 {
280 $t->set_var( "bg_color", "bgdark" );
281 }
282
283 $t->set_var( "person_id", $persons[$i]->id() );
284 $t->set_var( "person_firstname", $persons[$i]->firstName() );
285 $t->set_var( "person_lastname", $persons[$i]->lastName() );
286 if ( $ini->variable( "eZContactMain", "ShowAllConsultations" ) == "enabled" )
287 $t->set_var( "consultation_count", (new eZConsultation())->personConsultationCount( $persons[$i]->id(), -1 ) );
288 else
289 $t->set_var( "consultation_count", (new eZConsultation())->personConsultationCount( $persons[$i]->id(), $user->id() ) );
290 $t->parse( "person_item", "person_item_tpl", true );
291 }
292
293 if ( $count > 0 )
294 {
295 $t->parse( "person_table_item", "person_table_item_tpl", true );
296 }
297 else
298 {
299 $t->parse( "no_persons_item", "no_persons_item_tpl", true );
300 }
301 }
302
303 $t->pparse( "output", "consultation_page" );
304
305 ?>
$locale
$locale
Definition: admin/adlist.php:127
$i
$i
Definition: admin/adlist.php:91
$companies
else $companies
Definition: admin/consultationlist.php:221
$t
$t
Definition: admin/consultationlist.php:63
$languagefile
$languagefile
Definition: admin/consultationlist.php:60
$user
$user
Definition: admin/consultationlist.php:37
$persons
else $persons
Definition: admin/consultationlist.php:263
$Language
$Language
Definition: admin/consultationlist.php:30
$ini
$ini
Definition: admin/consultationlist.php:29
$count
$count
Definition: admin/consultationlist.php:222
eZCompany
Definition: ezcompany.php:54
eZConsultation
Definition: ezconsultation.php:60
eZConsultation\findConsultedCompanies
static findConsultedCompanies( $user)
Definition: ezconsultation.php:406
eZConsultation\stateName
static stateName( $state)
Definition: ezconsultation.php:856
eZConsultation\findConsultedPersons
static findConsultedPersons( $user)
Definition: ezconsultation.php:431
eZConsultation\companyConsultationCount
static companyConsultationCount( $company, $user)
Definition: ezconsultation.php:687
eZConsultation\findConsultationsByContact
static findConsultationsByContact( $contact, $user, $OrderBy="ID", $is_person=true, $index=0, $max=-1, $relations=false)
Definition: ezconsultation.php:509
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZLocale
Definition: ezlocale.php:119
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZPerson
Definition: ezperson.php:43
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$company
if(!is_numeric( $Year)) if(!is_numeric( $Month)) if(!is_numeric( $Day)) $company
Definition: companystats.php:72
exit
exit
Definition: folder.php:81
$person
switch( $LimitType) $person
Definition: personlist.php:137
$OrderBy
$OrderBy
Definition: reciverpopup.php:21
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.