Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

consultationedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: consultationedit.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 /*
28 Edit a consultation
29 */
30
31 // include_once( "classes/INIFile.php" );
32
33 $ini =& eZINI::instance( 'site.ini' );
34 $Language = $ini->variable( "eZContactMain", "Language" );
35
36 // include_once( "ezuser/classes/ezusergroup.php" );
37 // include_once( "ezuser/classes/ezpermission.php" );
38
39 // deletes the dayview cache file for a given day
40 function deleteCache( $SiteDesign, $language, $year, $month, $day, $userID )
41 {
42 eZPBFile::unlink( "kernel/ezcalendar/user/cache/dayview.tpl-$SiteDesign-$language-$year-$month-$day-$userID.cache" );
43 eZPBFile::unlink( "kernel/ezcalendar/user/cache/monthview.tpl-$SiteDesign-$language-$year-$month-$userID.cache" );
44 eZPBFile::unlink( "kernel/ezcalendar/user/cache/dayview.tpl-$SiteDesign-$language-$year-$month-$day-$userID-private.cache" );
45 eZPBFile::unlink( "kernel/ezcalendar/user/cache/monthview.tpl-$SiteDesign-$language-$year-$month-$userID-private.cache" );
46 }
47
48 //Adds a "0" in front of the value if it's below 10.
49 function addZero( $value )
50 {
51 settype( $value, "integer" );
52 $ret = $value;
53 if ( $ret < 10 )
54 {
55 $ret = "0". $ret;
56 }
57 return $ret;
58 }
59
60 if ( isset( $new_consultation ) )
61 {
62 unset( $new_consultation );
63 // include_once( "classes/ezhttptool.php" );
64 eZHTTPTool::header( "Location: /contact/consultation/person/new" );
65 exit();
66 }
67
68 $user =& eZUser::currentUser();
69 if ( !is_a( $user, "eZUser" ) )
70 {
71 // include_once( "classes/ezhttptool.php" );
72 eZHTTPTool::header( "Location: contact/nopermission/login" );
73 exit();
74 }
75
76 if ( !eZPermission::checkPermission( $user, "eZContact", "Consultation" ) )
77 {
78 // include_once( "classes/ezhttptool.php" );
79 eZHTTPTool::header( "Location: contact/nopermission/consultation" );
80 exit();
81 }
82
83 // include_once( "ezmail/classes/ezmail.php" );
84 // include_once( "classes/eztemplate.php" );
85 // include_once( "classes/ezdatetime.php" );
86 // include_once( "ezcontact/classes/ezconsultation.php" );
87
88 if ( isset( $Action ) && $Action == "delete" or isset( $Delete ) )
89 {
90 unset( $person );
91 unset( $company );
92 if ( isset( $ConsultationList ) )
93 {
94 foreach ( $ConsultationList as $consultation_id )
95 {
96 $consultation = new eZConsultation( $consultation_id );
97 if ( !isset( $person ) and !isset( $company ) )
98 {
99 $person = $consultation->person( $user );
100 $company = $consultation->company( $user );
101 }
102 $consultation->delete();
103 }
104 if ( is_numeric( $person ) )
105 {
106 $contact_type = "person";
107 $contact_id = $person;
108 }
109 else if ( is_numeric( $company ) )
110 {
111 $contact_type = "company";
112 $contact_id = $company;
113 }
114 }
115 else
116 {
117 $contact_type = $SubAction;
118 if ( $contact_type = "company" )
119 {
120 $contact_id = $CompanyID;
121 }
122 else
123 {
124 $contact_id = $PersonID;
125 }
126 }
127
128 if ( isset( $contact_type ) && isset( $contact_id ) )
129 {
130 // include_once( "classes/ezhttptool.php" );
131 eZHTTPTool::header( "Location: /contact/consultation/$contact_type/list/$contact_id" );
132 }
133 else
134 {
135 // include_once( "classes/ezhttptool.php" );
136 eZHTTPTool::header( "Location: /contact/consultation/list" );
137 }
138 exit;
139 }
140
141 // include_once( "ezcontact/classes/ezconsultationtype.php" );
142 // include_once( "ezuser/classes/ezuser.php" );
143 // include_once( "ezuser/classes/ezusergroup.php" );
144
145 $error = false;
146
147 $t = new eZTemplate( "kernel/ezcontact/admin/" . $ini->variable( "eZContactMain", "AdminTemplateDir" ),
148 "kernel/ezcontact/admin/intl", $Language, "consultationedit.php" );
149 $t->setAllStrings();
150
151 $t->set_file( "consultation_edit", "consultationedit.tpl" );
152 $t->set_block( "consultation_edit", "consultation_item_tpl", "consultation_item" );
153
154 $t->set_block( "consultation_item_tpl", "consultation_date_item_tpl", "consultation_date_item" );
155 $t->set_block( "consultation_item_tpl", "group_notice_select_tpl", "group_notice_select" );
156 $t->set_block( "consultation_item_tpl", "day_item_tpl", "day_item" );
157
158 $t->set_block( "consultation_item_tpl", "no_status_item_tpl", "no_status_item" );
159 $t->set_block( "consultation_item_tpl", "status_item_tpl", "status_item" );
160 $t->set_block( "status_item_tpl", "status_select_tpl", "status_select" );
161
162 $t->set_block( "consultation_edit", "contact_item_tpl", "contact_item" );
163 $t->set_block( "contact_item_tpl", "company_contact_select_tpl", "company_contact_select" );
164 $t->set_block( "contact_item_tpl", "person_contact_select_tpl", "person_contact_select" );
165
166 $t->set_block( "consultation_edit", "company_contact_item_tpl", "company_contact_item" );
167 $t->set_block( "consultation_edit", "person_contact_item_tpl", "person_contact_item" );
168
169 $t->set_block( "consultation_edit", "hidden_company_contact_item_tpl", "hidden_company_contact_item" );
170 $t->set_block( "consultation_edit", "hidden_person_contact_item_tpl", "hidden_person_contact_item" );
171
172 $t->set_block( "consultation_edit", "person_id_item_tpl", "person_id_item" );
173 $t->set_block( "consultation_edit", "company_id_item_tpl", "company_id_item" );
174
175 $t->set_block( "consultation_edit", "errors_tpl", "errors_item" );
176
177 $t->set_block( "errors_tpl", "error_company_person_item_tpl", "error_company_person_item" );
178 $t->set_block( "errors_tpl", "error_no_company_person_item_tpl", "error_no_company_person_item" );
179 $t->set_block( "errors_tpl", "error_no_status_item_tpl", "error_no_status_item" );
180 $t->set_block( "errors_tpl", "error_short_description_item_tpl", "error_short_description_item" );
181 $t->set_block( "errors_tpl", "error_description_item_tpl", "error_description_item" );
182 $t->set_block( "errors_tpl", "error_email_notice_item_tpl", "error_email_notice_item" );
183
184 $t->set_var( "consultation_date", "" );
185 $t->set_var( "consultation_date_item", "" );
186
187 $t->set_var( "short_description", "" );
188 $t->set_var( "description", "" );
189 $t->set_var( "email_notification", "" );
190
191 $t->set_var( "group_notice_id", "" );
192 $t->set_var( "is_selected", "" );
193 $t->set_var( "group_notice_name", "" );
194
195 $t->set_var( "consultant_type", "" );
196 $t->set_var( "person_id_item", "" );
197 $t->set_var( "company_id_item", "" );
198
199
200
201
202 if ( isset( $PersonID ) and !isset( $PersonContact ) )
203 $PersonContact = $PersonID;
204 if ( isset( $CompanyID ) and !isset( $CompanyContact ) )
205 $CompanyContact = $CompanyID;
206
207 if ( isset( $PersonID ) )
208 {
209 $t->set_var( "consultant_type", "person/" );
210 $t->set_var( "person_id", $PersonID );
211 $t->parse( "person_id_item", "person_id_item_tpl" );
212 }
213 else if ( isset( $CompanyID ) )
214 {
215 $t->set_var( "consultant_type", "company/" );
216 $t->set_var( "company_id", $CompanyID );
217 $t->parse( "company_id_item", "company_id_item_tpl" );
218 }
219
220 $t->set_var( "hidden_company_contact_item", "" );
221 $t->set_var( "hidden_person_contact_item", "" );
222
223 $t->set_var( "state_id", "" );
224
225 if ( $Action == "insert" || $Action == "update" )
226 {
227 $t->set_var( "error_company_person_item", "" );
228 $t->set_var( "error_no_company_person_item", "" );
229 $t->set_var( "error_no_status_item", "" );
230 $t->set_var( "error_short_description_item", "" );
231 $t->set_var( "error_description_item", "" );
232 $t->set_var( "error_email_notice_item", "" );
233
234 if ( isset( $PersonContact ) && isset( $CompanyContact ) )
235 {
236 $t->parse( "error_company_person_item", "error_company_person_item_tpl" );
237 $error = true;
238 }
239
240 if ( !isset( $PersonContact ) && !isset( $CompanyContact ) )
241 {
242 $t->parse( "error_no_company_person_item", "error_no_company_person_item_tpl" );
243 $error = true;
244 }
245
246 if ( $StatusID == -1 )
247 {
248 $t->parse( "error_no_status_item", "error_no_status_item_tpl" );
249 $error = true;
250 }
251
252 if ( empty( $ShortDescription ) )
253 {
254 $t->parse( "error_short_description_item", "error_short_description_item_tpl" );
255 $error = true;
256 }
257
258 if ( empty( $Description ) )
259 {
260 $t->parse( "error_description_item", "error_description_item_tpl" );
261 $error = true;
262 }
263
264 // if ( empty( $EmailNotice ) )
265 // {
266 // $t->parse( "error_email_notification_item", "error_email_notificiation_item_tpl" );
267 // $error = true;
268 // }
269
270 // if ( empty( $GroupNotice[] ) )
271 // {
272 // $t->parse( "error_group_notification_item", "error_group_notification_item_tpl" );
273 // $error = true;
274 // }
275
276 if ( $error == true )
277 {
278 $t->parse( "errors_item", "errors_tpl" );
279 }
280 }
281
282 if ( $error == false )
283 {
284 $t->set_var( "errors_item", "" );
285 }
286 else
287 {
288 $Action = "formdata";
289 }
290
291 $user =& eZUser::currentUser();
292
293 if ( !$user )
294 {
295 // include_once( "classes/ezhttptool.php" );
296 eZHTTPTool::header( "Location: /user/login" );
297 exit();
298 }
299
300 $userID = $user->ID();
301
302 if ( ( isset( $Action ) && $Action == "insert" || isset( $Action ) && $Action == "update" ) && $error == false )
303 {
304 if ( isset( $ConsultationID ) && $ConsultationID != 'new' && $ConsultationID > 0 )
305 {
306 $consultation = new eZConsultation( $ConsultationID );
307 $oldDate = $consultation->date();
308 if( !is_null( $oldDate ) )
309 {
310 deleteCache( "default", $Language, $oldDate->year(), addZero( $oldDate->month() ), addZero( $oldDate->day() ), $userID );
311 deleteCache( "default", $Language, $ConsultationYear, addZero( $ConsultationMonth ), addZero( $ConsultationDay ), $userID );
312 }
313 }
314 else
315 {
316 $consultation = new eZConsultation();
317 }
318 $consultation->setShortDescription( $ShortDescription );
319 $consultation->setDescription( $Description );
320 $consultation->setDate( new eZDateTime( $ConsultationYear, $ConsultationMonth, $ConsultationDay ) );
321 $consultation->setState( $StatusID );
322 $consultation->setEmail( $EmailNotice );
323 $consultation->store();
324
325 if ( isset( $CompanyContact ) )
326 {
327 $contact_type = "company";
328 $contact_id = $CompanyContact;
329 $consultation->removeConsultationFromCompany( $CompanyContact, $user->id() );
330 $consultation->addConsultationToCompany( $CompanyContact, $user->id() );
331 }
332 else if ( isset( $PersonContact ) )
333 {
334 $contact_type = "person";
335 $contact_id = $PersonContact;
336 $consultation->removeConsultationFromPerson( $PersonContact, $user->id() );
337 $consultation->addConsultationToPerson( $PersonContact, $user->id() );
338 }
339
340 $consultation->removeGroups();
341 foreach ( $GroupNotice as $group )
342 {
343 $consultation->addGroup( $group );
344 }
345
346 $ConsultationID = $consultation->id();
347
348 $t->set_var( "consultation_id", $ConsultationID );
349
350 $consult_id = $ConsultationID . "-" . $user->id();
351
352 if ( isset( $CompanyContact ) )
353 {
354 $company = new eZCompany( $CompanyContact );
355 $consult_name = $company->name();
356 $consult_id .= "-" . $CompanyContact;
357 }
358 else if ( isset( $PersonContact ) )
359 {
360 $person = new eZPerson( $PersonContact );
361 $consult_name = $person->name();
362 $consult_id .= "-" . $PersonContact;
363 }
364
365 $mail_t = new eZTemplate( "kernel/ezcontact/admin/" . $ini->variable( "eZContactMain", "AdminTemplateDir" ),
366 "kernel/ezcontact/admin/intl", $Language, "consultationmail" );
367 $mail_t->setAllStrings();
368
369 $mail_t->set_file( array( "consultation_mail" => "consultationmail.tpl" ) );
370 $mail_t->set_block( "consultation_mail", "subject_tpl", "subject" );
371 $mail_t->set_block( "consultation_mail", "body_tpl", "body" );
372
373 $stateid = $consultation->state();
374 $state = new eZConsultationType( $stateid );
375
376 $mail_t->set_var( "consultation_name", $consult_name );
377 $mail_t->set_var( "short_description", $consultation->shortDescription() );
378 $mail_t->set_var( "type_name", $state->name() );
379 $mail_t->set_var( "description", $consultation->description() );
380 $mail_t->set_var( "consultation_id", $consult_id );
381 $mail_t->set_var( "signature", $user->signature() );
382
383 $mail = new eZMail();
384 $mail->setFromName( $user->name() );
385 $mail->setFrom( $user->email() );
386
387 $mail_t->parse( "subject", "subject_tpl" );
388 $mail_t->parse( "body", "body_tpl" );
389
390 $mail->setSubject( $mail_t->get_var( "subject" ) );
391 $mail->setBody( $mail_t->get_var( "body" ) );
392
393 $emails = $consultation->emailList();
394 foreach ( $emails as $email )
395 {
396 $mail->setTo( $email );
397 $mail->send();
398 }
399
400 foreach ( $GroupNotice as $groupid )
401 {
402 $users = eZUserGroup::users( $groupid );
403 foreach ( $users as $mail_user )
404 {
405 $mail->setTo( $mail_user->namedEmail() );
406 $mail->send();
407 }
408 }
409
410 if ( isset( $contact_type ) && isset( $contact_id ) )
411 {
412 // include_once( "classes/ezhttptool.php" );
413 eZHTTPTool::header( "Location: /contact/consultation/$contact_type/list/$contact_id" );
414 }
415 else
416 {
417 // include_once( "classes/ezhttptool.php" );
418 eZHTTPTool::header( "Location: /contact/consultation/list" );
419 }
420 exit();
421 }
422
423 /*
424 The user wants to create a new consultation.
425
426 We present an empty form.
427 */
428 if ( isset( $Action ) && $Action == "new" )
429 {
430 if ( $ConsultationID != 0 ) // 1
431 {
432 // include_once( "classes/ezhttptool.php" );
433 eZHTTPTool::header( "Location: /contact/consultation/edit/$ConsultationID" );
434 exit();
435 }
436
437 if ( isset( $CompanyID ) )
438 {
439 $t->set_var( "company_contact", $CompanyID );
440 $t->parse( "hidden_company_contact_item", "hidden_company_contact_item_tpl" );
441 $t->set_var( "hidden_person_contact_item", "" );
442 }
443 else if ( isset( $PersonID ) )
444 {
445 $t->set_var( "person_contact", $PersonID );
446 $t->parse( "hidden_person_contact_item", "hidden_person_contact_item_tpl" );
447 $t->set_var( "hidden_company_contact_item", "" );
448 }
449 else
450 {
451 $t->set_var( "hidden_company_contact_item", "" );
452 $t->set_var( "hidden_person_contact_item", "" );
453 }
454
455 $currentDate = new eZDateTime();
456 for ( $i = 1; $i <= 31; $i++ )
457 {
458 $t->set_var( "day_id", $i );
459 $t->set_var( "day_value", $i );
460 if ( $currentDate->day() == $i )
461 $t->set_var( "day_selected", "selected" );
462 else
463 $t->set_var( "day_selected", "" );
464
465 $t->parse( "day_item", "day_item_tpl", true );
466 }
467
468 if ( $currentDate->month() == 1 )
469 $t->set_var( "select_january", "selected" );
470 else
471 $t->set_var( "select_january", "" );
472
473 if ( $currentDate->month() == 2 )
474 $t->set_var( "select_february", "selected" );
475 else
476 $t->set_var( "select_february", "" );
477
478 if ( $currentDate->month() == 3 )
479 $t->set_var( "select_march", "selected" );
480 else
481 $t->set_var( "select_march", "" );
482
483 if ( $currentDate->month() == 4 )
484 $t->set_var( "select_april", "selected" );
485 else
486 $t->set_var( "select_april", "" );
487
488 if ( $currentDate->month() == 5 )
489 $t->set_var( "select_may", "selected" );
490 else
491 $t->set_var( "select_may", "" );
492
493 if ( $currentDate->month() == 6 )
494 $t->set_var( "select_june", "selected" );
495 else
496 $t->set_var( "select_june", "" );
497
498 if ( $currentDate->month() == 7 )
499 $t->set_var( "select_july", "selected" );
500 else
501 $t->set_var( "select_july", "" );
502
503 if ( $currentDate->month() == 8 )
504 $t->set_var( "select_august", "selected" );
505 else
506 $t->set_var( "select_august", "" );
507
508 if ( $currentDate->month() == 9 )
509 $t->set_var( "select_september", "selected" );
510 else
511 $t->set_var( "select_september", "" );
512
513 if ( $currentDate->month() == 10 )
514 $t->set_var( "select_october", "selected" );
515 else
516 $t->set_var( "select_october", "" );
517
518 if ( $currentDate->month() == 11 )
519 $t->set_var( "select_november", "selected" );
520 else
521 $t->set_var( "select_november", "" );
522
523 if ( $currentDate->month() == 12 )
524 $t->set_var( "select_december", "selected" );
525 else
526 $t->set_var( "select_december", "" );
527
528 $t->set_var( "consultationyear", $currentDate->year() );
529
530 $Action_value = "insert";
531 $t->set_var( "consultation_id", "0" );
532 $t->parse( "consultation_item", "consultation_item_tpl" );
533 }
534
535 $status_id = 0;
536 $groups = array();
537
538 /*
539 The user wants to edit an existing person.
540
541 We present a form with the info.
542 */
543 if ( isset( $Action ) && $Action == "edit" )
544 {
545 $Action_value = "update";
546 $consultation = new eZConsultation( $ConsultationID );
547
548 $t->set_var( "short_description", $consultation->shortDescription() );
549 $t->set_var( "description", $consultation->description() );
550 $t->set_var( "email_notification", $consultation->emails() );
551 $status_id = $consultation->state();
552
553 $companyid = $consultation->company( $user->id() );
554 $personid = $consultation->person( $user->id() );
555 if ( $companyid )
556 {
557 $CompanyID = $companyid;
558 $t->set_var( "company_contact", $CompanyID );
559 $t->parse( "hidden_company_contact_item", "hidden_company_contact_item_tpl" );
560 $t->set_var( "hidden_person_contact_item", "" );
561 }
562 else if ( $personid )
563 {
564 $PersonID = $personid;
565 $t->set_var( "person_contact", $PersonID );
566 $t->parse( "hidden_person_contact_item", "hidden_person_contact_item_tpl" );
567 $t->set_var( "hidden_company_contact_item", "" );
568 }
569
570 $currentDate = $consultation->date();
571 if( $currentDate == null )
572 $currentDate = new eZDateTime();
573
574 if( $currentDate != null )
575 {
576 for ( $i = 1; $i <= 31; $i++ )
577 {
578 $t->set_var( "day_id", $i );
579 $t->set_var( "day_value", $i );
580 if ( $currentDate->day() == $i )
581 $t->set_var( "day_selected", "selected" );
582 else
583 $t->set_var( "day_selected", "" );
584
585 $t->parse( "day_item", "day_item_tpl", true );
586 }
587
588 if ( $currentDate->month() == 1 )
589 $t->set_var( "select_january", "selected" );
590 else
591 $t->set_var( "select_january", "" );
592
593 if ( $currentDate->month() == 2 )
594 $t->set_var( "select_february", "selected" );
595 else
596 $t->set_var( "select_february", "" );
597
598 if ( $currentDate->month() == 3 )
599 $t->set_var( "select_march", "selected" );
600 else
601 $t->set_var( "select_march", "" );
602
603 if ( $currentDate->month() == 4 )
604 $t->set_var( "select_april", "selected" );
605 else
606 $t->set_var( "select_april", "" );
607
608 if ( $currentDate->month() == 5 )
609 $t->set_var( "select_may", "selected" );
610 else
611 $t->set_var( "select_may", "" );
612
613 if ( $currentDate->month() == 6 )
614 $t->set_var( "select_june", "selected" );
615 else
616 $t->set_var( "select_june", "" );
617
618 if ( $currentDate->month() == 7 )
619 $t->set_var( "select_july", "selected" );
620 else
621 $t->set_var( "select_july", "" );
622
623 if ( $currentDate->month() == 8 )
624 $t->set_var( "select_august", "selected" );
625 else
626 $t->set_var( "select_august", "" );
627
628 if ( $currentDate->month() == 9 )
629 $t->set_var( "select_september", "selected" );
630 else
631 $t->set_var( "select_september", "" );
632
633 if ( $currentDate->month() == 10 )
634 $t->set_var( "select_october", "selected" );
635 else
636 $t->set_var( "select_october", "" );
637
638 if ( $currentDate->month() == 11 )
639 $t->set_var( "select_november", "selected" );
640 else
641 $t->set_var( "select_november", "" );
642
643 if ( $currentDate->month() == 12 )
644 $t->set_var( "select_december", "selected" );
645 else
646 $t->set_var( "select_december", "" );
647
648 $t->set_var( "consultationyear", $currentDate->year() );
649 }
650
651 $groups = $consultation->groupIDList();
652
653 $t->set_var( "consultation_id", $ConsultationID );
654
655 $t->parse( "consultation_item", "consultation_item_tpl" );
656 }
657
658 if ( isset( $Action ) && $Action == "formdata" )
659 {
660 if( !isset( $ConsultationID ) or $ConsultationID == "new" )
661 $ConsultationID = 0;
662 $Action_value = "insert";
663 $t->set_var( "consultation_id", $ConsultationID );
664 $t->set_var( "short_description", $ShortDescription );
665 $t->set_var( "description", $Description );
666 $t->set_var( "email_notification", $EmailNotice );
667
668
669
670 for ( $i = 1; $i <= 31; $i++ )
671 {
672 $t->set_var( "day_id", $i );
673 $t->set_var( "day_value", $i );
674 if ( isset( $ConsultationDay ) && $ConsultationDay == $i )
675 $t->set_var( "day_selected", "selected" );
676 else
677 $t->set_var( "day_selected", "" );
678
679 $t->parse( "day_item", "day_item_tpl", true );
680 }
681
682 if ( $ConsultationMonth == 1 )
683 $t->set_var( "select_january", "selected" );
684 else
685 $t->set_var( "select_january", "" );
686
687 if ( $ConsultationMonth == 2 )
688 $t->set_var( "select_february", "selected" );
689 else
690 $t->set_var( "select_february", "" );
691
692 if ( $ConsultationMonth == 3 )
693 $t->set_var( "select_march", "selected" );
694 else
695 $t->set_var( "select_march", "" );
696
697 if ( $ConsultationMonth == 4 )
698 $t->set_var( "select_april", "selected" );
699 else
700 $t->set_var( "select_april", "" );
701
702 if ( $ConsultationMonth == 5 )
703 $t->set_var( "select_may", "selected" );
704 else
705 $t->set_var( "select_may", "" );
706
707 if ( $ConsultationMonth == 6 )
708 $t->set_var( "select_june", "selected" );
709 else
710 $t->set_var( "select_june", "" );
711
712 if ( $ConsultationMonth == 7 )
713 $t->set_var( "select_july", "selected" );
714 else
715 $t->set_var( "select_july", "" );
716
717 if ( $ConsultationMonth == 8 )
718 $t->set_var( "select_august", "selected" );
719 else
720 $t->set_var( "select_august", "" );
721
722 if ( $ConsultationMonth == 9 )
723 $t->set_var( "select_september", "selected" );
724 else
725 $t->set_var( "select_september", "" );
726
727 if ( $ConsultationMonth == 10 )
728 $t->set_var( "select_october", "selected" );
729 else
730 $t->set_var( "select_october", "" );
731
732 if ( $ConsultationMonth == 11 )
733 $t->set_var( "select_november", "selected" );
734 else
735 $t->set_var( "select_november", "" );
736
737 if ( $ConsultationMonth == 12 )
738 $t->set_var( "select_december", "selected" );
739 else
740 $t->set_var( "select_december", "" );
741
742 $t->set_var( "consultationyear", $ConsultationYear );
743
744 $status_id = $StatusID;
745 $groups = $GroupNotice;
746 if ( !isset( $groups ) )
747 $groups = array();
748
749 // Group list here
750
751 $t->parse( "consultation_item", "consultation_item_tpl" );
752 }
753
754 if ( !( isset( $CompanyID ) || isset( $PersonID ) ) )
755 {
756 $company = new eZCompany();
757 $companies = $company->getAll();
758 if ( !is_array( $companies ) )
759 $companies = array();
760 foreach ( $companies as $company )
761 {
762 $t->set_var( "contact_id", $company->id() );
763 $t->set_var( "contact_name", $company->name() );
764 if ( isset( $CompanyContact ) && $CompanyContact == $company->id() )
765 $t->set_var( "selected", "selected" );
766 else
767 $t->set_var( "selected", "" );
768
769 $t->parse( "company_contact_select", "company_contact_select_tpl", true );
770 }
771
772 $person = new eZPerson();
773 $persons = $person->getAll();
774 if ( !is_array( $persons ) )
775 $persons = array();
776 foreach ( $persons as $person )
777 {
778 $t->set_var( "contact_id", $person->id() );
779 $t->set_var( "contact_firstname", $person->firstName() );
780 $t->set_var( "contact_lastname", $person->lastName() );
781 if ( isset( $PersonContact ) && $PersonContact == $person->id() )
782 $t->set_var( "selected", "selected" );
783 else
784 $t->set_var( "selected", "" );
785 $t->parse( "person_contact_select", "person_contact_select_tpl", true );
786 }
787
788 $t->parse( "contact_item", "contact_item_tpl" );
789 $t->set_var( "company_contact_item", "" );
790 $t->set_var( "person_contact_item", "" );
791 }
792 else
793 {
794 $t->set_var( "contact_item" );
795 if ( isset( $CompanyID ) )
796 {
797 $t->parse( "company_contact_item", "company_contact_item_tpl" );
798 $t->set_var( "person_contact_item", "" );
799 $company = new eZCompany( $CompanyID );
800 $t->set_var( "company_name", $company->name() );
801 }
802 else if ( isset( $PersonID ) )
803 {
804 $t->parse( "person_contact_item", "person_contact_item_tpl" );
805 $t->set_var( "company_contact_item", "" );
806 $person = new eZPerson( $PersonID );
807 $t->set_var( "person_firstname", $person->firstName() );
808 $t->set_var( "person_lastname", $person->lastName() );
809 }
810 else
811 {
812 }
813 }
814
815 // Create consultation types
816
817 $types = eZConsultationType::findTypes();
818 if ( count( $types ) > 0 )
819 {
820 foreach ( $types as $type )
821 {
822 $t->set_var( "status_id", $type->id() );
823 if ( $type->id() == $status_id )
824 $t->set_var( "selected", "selected" );
825 else
826 $t->set_var( "selected", "" );
827 $t->set_var( "status_name", $type->name() );
828
829 $t->parse( "status_select", "status_select_tpl", true );
830 }
831 $t->parse( "status_item", "status_item_tpl" );
832 $t->set_var( "no_status_item", "" );
833 }
834 else
835 {
836 $t->parse( "no_status_item", "no_status_item_tpl" );
837 $t->set_var( "status_item", "" );
838 }
839
840 // Group list
841 $group = new eZUserGroup();
842 $group_list = $group->getAll();
843 foreach ( $group_list as $group_item )
844 {
845 if ( in_array( $group_item->id(), $groups ) )
846 $t->set_var( "is_selected", "selected" );
847 else
848 $t->set_var( "is_selected", "" );
849 $t->set_var( "group_notice_id", $group_item->id() );
850 $t->set_var( "group_notice_name", $group_item->name() );
851
852 $t->parse( "group_notice_select", "group_notice_select_tpl", true );
853 }
854
855
856 // Template variabler.
857
858 $t->set_var( "action_value", $Action_value );
859
860 $t->pparse( "output", "consultation_edit" );
861
862 ?>
$i
$i
Definition: admin/adlist.php:91
$companies
else $companies
Definition: admin/consultationlist.php:221
$day
else $day
Definition: appointmentedit.php:665
$year
else $year
Definition: appointmentedit.php:655
$month
else $month
Definition: appointmentedit.php:660
$Description
$Description
Definition: articlelistrss.php:38
$types
$types
Definition: articlepreview.php:108
eZCompany
Definition: ezcompany.php:54
eZConsultationType
Definition: ezconsultationtype.php:54
eZConsultationType\findTypes
static findTypes()
Definition: ezconsultationtype.php:224
eZConsultation
Definition: ezconsultation.php:60
eZDateTime
Definition: ezdatetime.php:55
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZMail
Definition: ezmail.php:57
eZPBFile\unlink
static unlink( $filename)
Definition: ezpbfile.php:352
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZPerson
Definition: ezperson.php:43
eZTemplate
Definition: eztemplate.php:107
eZUserGroup
Definition: ezusergroup.php:66
eZUserGroup\users
static users( $GroupID=false, $order="Login", $search=false)
Definition: ezusergroup.php:291
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$type
$type
Definition: classes/admin/linkselect.php:220
$Action
$Action
Definition: companysearch.php:80
$company
if(!is_numeric( $Year)) if(!is_numeric( $Month)) if(!is_numeric( $Day)) $company
Definition: companystats.php:72
$emails
$emails
Definition: companyview.php:525
$Action_value
$Action_value
Definition: companyview.php:559
$persons
$persons
Definition: companyview.php:386
$groups
$groups
Definition: consultationedit.php:536
$t
$t
Definition: consultationedit.php:147
$user
if(isset( $new_consultation)) $user
Definition: consultationedit.php:68
$Language
$Language
Definition: consultationedit.php:34
$ini
$ini
Definition: consultationedit.php:33
addZero
addZero( $value)
Definition: consultationedit.php:49
$group_list
$group_list
Definition: consultationedit.php:842
deleteCache
deleteCache( $SiteDesign, $language, $year, $month, $day, $userID)
Definition: consultationedit.php:40
$userID
if(! $user) $userID
Definition: consultationedit.php:300
$group
$group
Definition: consultationedit.php:841
$error
if(!is_a( $user, "eZUser")) if(!eZPermission::checkPermission( $user, "eZContact", "Consultation")) if(isset( $Action) && $Action=="delete" or isset( $Delete)) $error
Definition: consultationedit.php:145
$status_id
if((isset( $Action) && $Action=="insert"||isset( $Action) && $Action=="update") && $error==false) if(isset( $Action) && $Action=="new") $status_id
Definition: consultationedit.php:535
$companyid
$companyid
Definition: consultationview.php:119
$personid
$personid
Definition: consultationview.php:120
$mail
$mail
Definition: ezbulkmail/admin/maillist.php:61
$SiteDesign
$SiteDesign
Definition: ezbulkmail/user/datasupplier.php:31
$users
$users
Definition: ezmessage/admin/messageedit.php:138
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
exit
exit
Definition: folder.php:81
$language
$language
Definition: messageform.php:32
$person
switch( $LimitType) $person
Definition: personlist.php:137
$StatusID
$StatusID
Definition: todoedit.php:125
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.