dolibarr 25.0.0-alpha
conferenceorboothattendee.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program 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 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Put here all includes required by your class file
27require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
28//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
29//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
30
35{
39 public $module = 'eventorganization';
40
44 public $element = 'conferenceorboothattendee';
45
49 public $table_element = 'eventorganization_conferenceorboothattendee';
50
54 public $picto = 'contact';
55
56 const STATUS_DRAFT = 0;
57 const STATUS_VALIDATED = 1;
58 const STATUS_USED = 5; // was present, presence confirmed, no more entrances can be done using this ticket
59 const STATUS_CANCELED = 9;
60
87 // BEGIN MODULEBUILDER PROPERTIES
91 public $fields = array(
92 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id"),
93 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'position' => 10, 'notnull' => 1, 'visible' => 2, 'index' => 1, 'showoncombobox' => 1, 'comment' => "Reference of object"),
94 //'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>0, 'index'=>1, 'picto'=>'agenda'),
95 'fk_project' => array('type' => 'integer:Project:projet/class/project.class.php:1', 'label' => 'Project', 'enabled' => "isModEnabled('project')", 'position' => 20, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'picto' => 'project', 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'),
96 'email' => array('type' => 'mail', 'label' => 'EmailAttendee', 'enabled' => 1, 'position' => 30, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'autofocusoncreate' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'csslist' => 'tdoverflowmax150'),
97 'firstname' => array('type' => 'varchar(100)', 'label' => 'Firstname', 'enabled' => 1, 'position' => 31, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'csslist' => 'tdoverflowmax125', 'showoncombobox' => 1),
98 'lastname' => array('type' => 'varchar(100)', 'label' => 'Lastname', 'enabled' => 1, 'position' => 32, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'csslist' => 'tdoverflowmax125', 'showoncombobox' => 1),
99 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label' => 'ThirdParty', 'enabled' => 'isModEnabled("societe")', 'position' => 40, 'notnull' => -1, 'visible' => 1, 'index' => 1, 'help' => "OrganizationEventLinkToThirdParty", 'picto' => 'company', 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'),
100 'email_company' => array('type' => 'mail', 'label' => 'EmailCompany', 'enabled' => 1, 'position' => 41, 'notnull' => 0, 'visible' => -2, 'searchall' => 1),
101 'date_subscription' => array('type' => 'datetime', 'label' => 'DateOfRegistration', 'enabled' => 1, 'position' => 56, 'notnull' => 1, 'visible' => 1, 'showoncombobox' => 1,),
102 'fk_invoice' => array('type' => 'integer:Facture:compta/facture/class/facture.class.php', 'label' => 'Invoice', 'enabled' => 'isModEnabled("invoice")', 'position' => 57, 'notnull' => 0, 'visible' => 1, 'index' => 0, 'picto' => 'bill', 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'),
103 'amount' => array('type' => 'price', 'label' => 'AmountPaid', 'enabled' => 1, 'position' => 57, 'notnull' => 0, 'visible' => 1, 'default' => 'null', 'isameasure' => 1, 'help' => "AmountOfRegistrationPaid",),
104 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 61, 'notnull' => 0, 'visible' => 3,),
105 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 62, 'notnull' => 0, 'visible' => 3,),
106 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2, 'css' => 'nowraponall'),
107 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2,),
108 'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => 1, 'position' => 510, 'notnull' => -1, 'visible' => -2),
109 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2,),
110 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'position' => 600, 'notnull' => 0, 'visible' => 0,),
111 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,),
112 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'position' => 1010, 'notnull' => -1, 'visible' => 0,),
113 'ip' => array('type' => 'varchar(250)', 'label' => 'IPAddress', 'enabled' => 1, 'position' => 900, 'notnull' => -1, 'visible' => -2,),
114 'status' => array('type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 1000, 'default' => '0', 'notnull' => 1, 'visible' => 1, 'index' => 1, 'arrayofkeyval' => array('0' => 'Draft', '1' => 'Registered', '5' => 'ShowedUp', '9' => 'Canceled'),),
115 );
119 public $rowid;
123 public $ref;
127 public $fk_actioncomm;
131 public $fk_project;
135 public $email;
139 public $firstname;
143 public $lastname;
147 public $fk_soc;
151 public $email_company;
155 public $date_subscription;
159 public $fk_invoice;
163 public $amount;
164
168 public $fk_user_creat;
172 public $fk_user_modif;
176 public $last_main_doc;
180 public $import_key;
184 public $model_pdf;
185
189 public $status;
190 // END MODULEBUILDER PROPERTIES
191
192
193 // If this object has a subtable with lines
194
195 // /**
196 // * @var string Name of subtable line
197 // */
198 // public $table_element_line = 'eventorganization_conferenceorboothattendeeline';
199
200 // /**
201 // * @var string Field with ID of parent key if this object has a parent
202 // */
203 // public $fk_element = 'fk_conferenceorboothattendee';
204
205 // /**
206 // * @var string Name of subtable class that manage subtable lines
207 // */
208 // public $class_element_line = 'ConferenceOrBoothAttendeeline';
209
210 // /**
211 // * @var array List of child tables. To test if we can delete object.
212 // */
213 // protected $childtables = array();
214
215 // /**
216 // * @var array List of child tables. To know object to delete on cascade.
217 // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
218 // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
219 // */
220 // protected $childtablesoncascade = array('eventorganization_conferenceorboothattendeedet');
221
222 // /**
223 // * @var ConferenceOrBoothAttendeeLine[] Array of subtable lines
224 // */
225 // public $lines = array();
226
227
228
234 public function __construct(DoliDB $db)
235 {
236 global $langs;
237
238 $this->db = $db;
239
240 $this->ismultientitymanaged = 'fk_project@projet';
241 $this->isextrafieldmanaged = 1;
242
243 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid'])) {
244 $this->fields['rowid']['visible'] = 0;
245 }
246 if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
247 $this->fields['entity']['enabled'] = 0;
248 }
249
250 if (getDolGlobalString('EVENTORGANIZATION_FILTERATTENDEES_CAT')) {
251 $this->fields['fk_soc']['type'] .= ' AND rowid IN (SELECT DISTINCT c.fk_soc FROM '.MAIN_DB_PREFIX.'categorie_societe as c WHERE c.fk_categorie='.getDolGlobalInt('EVENTORGANIZATION_FILTERATTENDEES_CAT').')';
252 }
253 if (getDolGlobalString('EVENTORGANIZATION_FILTERATTENDEES_TYPE') !== ''
254 && getDolGlobalString('EVENTORGANIZATION_FILTERATTENDEES_TYPE') !== '-1') {
255 $this->fields['fk_soc']['type'] .= ' AND (client:=:'.((int) getDolGlobalInt('EVENTORGANIZATION_FILTERATTENDEES_TYPE', 0) . ')');
256 }
257
258 // Example to show how to set values of fields definition dynamically
259 /*if ($user->rights->eventorganization->conferenceorboothattendee->read) {
260 $this->fields['myfield']['visible'] = 1;
261 $this->fields['myfield']['noteditable'] = 0;
262 }*/
263
264 // Unset fields that are disabled
265 foreach ($this->fields as $key => $val) {
266 if (isset($val['enabled']) && empty($val['enabled'])) {
267 unset($this->fields[$key]);
268 }
269 }
270
271 // Translate some data of arrayofkeyval
272 if (is_object($langs)) {
273 foreach ($this->fields as $key => $val) {
274 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
275 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
276 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
277 }
278 }
279 }
280 }
281 }
282
290 public function create(User $user, $notrigger = 0)
291 {
292 global $langs;
293
294 if (!isValidEmail($this->email)) {
295 $langs->load("errors");
296 $this->errors[] = $langs->trans("ErrorBadEMail", $this->email);
297 return -1;
298 }
299
300 $result = $this->createCommon($user, $notrigger);
301 if ($result > 0) {
302 $result = $this->fetch($result);
303 if ($result > 0 && empty($this->ref)) {
304 $this->ref = (string) $this->id;
305 $result = $this->update($user);
306 }
307 }
308 return $result;
309 }
310
318 public function createFromClone(User $user, $fromid)
319 {
320 global $langs, $extrafields;
321 $error = 0;
322
323 dol_syslog(__METHOD__, LOG_DEBUG);
324
325 $object = new self($this->db);
326
327 $this->db->begin();
328
329 // Load source object
330 $result = $object->fetchCommon($fromid);
331 if ($result > 0 && !empty($object->table_element_line)) {
332 $object->fetchLines();
333 }
334
335 // get lines so they will be clone
336 //foreach($this->lines as $line)
337 // $line->fetch_optionals();
338
339 // Reset some properties
340 unset($object->id);
341 unset($object->fk_user_creat);
342 unset($object->user_creation_id);
343 unset($object->import_key);
344
345 // Clear fields
346 $object->ref = "(PROV)";
347 $object->status = self::STATUS_DRAFT;
348 $object->date_creation = dol_now();
349 $object->date_modification = null;
350
351 // Clear extrafields that are unique
352 if (is_array($object->array_options) && count($object->array_options) > 0) {
353 $extrafields->fetch_name_optionals_label($this->table_element);
354 foreach ($object->array_options as $key => $option) {
355 $shortkey = preg_replace('/options_/', '', $key);
356 if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
357 unset($object->array_options[$key]);
358 }
359 }
360 }
361
362 // Create clone
363 $object->context['createfromclone'] = 'createfromclone';
364 $result = $object->createCommon($user);
365 if ($result < 0) {
366 $error++;
368 } else {
369 $object->ref = (string) $object->id;
370 $result = $object->update($user);
371 }
372
373 if (!$error) {
374 // copy internal contacts
375 if ($this->copy_linked_contact($object, 'internal') < 0) {
376 $error++;
377 }
378 }
379
380 if (!$error) {
381 // copy external contacts if same company
382 if (!empty($this->fk_soc) && $this->fk_soc == $object->socid) {
383 if ($this->copy_linked_contact($object, 'external') < 0) {
384 $error++;
385 }
386 }
387 }
388
389 unset($object->context['createfromclone']);
390
391 // End
392 if (!$error) {
393 $this->db->commit();
394 return $object;
395 } else {
396 $this->db->rollback();
397 return -1;
398 }
399 }
400
408 public function fetch($id, $ref = null)
409 {
410 $result = $this->fetchCommon($id, $ref, '', 0);
411 if ($result > 0 && !empty($this->table_element_line)) {
412 $this->fetchLines();
413 }
414 return $result;
415 }
416
422 public function fetchLines()
423 {
424 $this->lines = array();
425
426 $result = $this->fetchLinesCommon();
427 return $result;
428 }
429
430
443 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
444 {
445 dol_syslog(__METHOD__, LOG_DEBUG);
446
447 $records = array();
448
449 $sql = 'SELECT ';
450 $sql .= $this->getFieldList('t');
451 $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
452 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id = t.fk_actioncomm";
453 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
454 $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
455 } else {
456 $sql .= ' WHERE 1 = 1';
457 }
458
459 // Manage filter
460 if (is_array($filter)) { // deprecated, use $filter = USF syntax
461 dol_syslog("You are using a deprecated use of fetchAll. filter parameter must be an USF string now.", LOG_WARNING);
462 $sqlwhere = array();
463 if (count($filter) > 0) {
464 foreach ($filter as $key => $value) {
465 if ($key == 't.rowid' || $key == 't.fk_soc' || $key == 't.fk_project' || $key == 't.fk_actioncomm') {
466 $sqlwhere[] = $this->db->sanitize($key).' = '.((int) $value);
467 } elseif (!empty($this->fields[$key]) && in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
468 $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate((int) $value)."'";
469 } elseif ($key == 'customsql') {
470 $sqlwhere[] = $value;
471 } elseif (strpos($value, '%') === false) {
472 $sqlwhere[] = $this->db->sanitize($key).' IN ('.$this->db->sanitize($this->db->escape($value)).')';
473 } else {
474 $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($value)."%'";
475 }
476 }
477 }
478 if (count($sqlwhere) > 0) {
479 $sql .= ' AND ('.implode(' '.$this->db->sanitize($filtermode).' ', $sqlwhere).')';
480 }
481
482 $filter = '';
483 }
484
485 // Manage filter
486 $errormessage = '';
487 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
488 if ($errormessage) {
489 $this->errors[] = $errormessage;
490 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
491 return -1;
492 }
493
494 if (!empty($sortfield)) {
495 $sql .= $this->db->order($sortfield, $sortorder);
496 }
497 if (!empty($limit)) {
498 $sql .= $this->db->plimit($limit, $offset);
499 }
500
501 $resql = $this->db->query($sql);
502 if ($resql) {
503 $num = $this->db->num_rows($resql);
504 $i = 0;
505 while ($i < ($limit ? min($limit, $num) : $num)) {
506 $obj = $this->db->fetch_object($resql);
507
508 $record = new self($this->db);
509 $record->setVarsFromFetchObj($obj);
510
511 $records[$record->id] = $record;
512
513 $i++;
514 }
515 $this->db->free($resql);
516
517 return $records;
518 } else {
519 $this->errors[] = 'Error '.$this->db->lasterror();
520 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
521
522 return -1;
523 }
524 }
525
533 public function update(User $user, $notrigger = 0)
534 {
535 return $this->updateCommon($user, $notrigger);
536 }
537
545 public function delete(User $user, $notrigger = 0)
546 {
547 return $this->deleteCommon($user, $notrigger);
548 //return $this->deleteCommon($user, $notrigger, 1);
549 }
550
559 public function deleteLine(User $user, $idline, $notrigger = 0)
560 {
561 if ($this->status < 0) {
562 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
563 return -2;
564 }
565
566 return $this->deleteLineCommon($user, $idline, $notrigger);
567 }
568
569
577 public function validate($user, $notrigger = 0)
578 {
579 global $conf;
580
581 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
582
583 $error = 0;
584
585 // Protection
586 if ($this->status == self::STATUS_VALIDATED) {
587 dol_syslog(get_class($this)."::validate action abandoned: already validated", LOG_WARNING);
588 return 0;
589 }
590
591 $now = dol_now();
592
593 $this->db->begin();
594
595 // Define new ref
596 $num = (string) $this->ref;
597 if (preg_match('/^[\‍(]?PROV/i', $num) || empty($num)) { // empty should not happened, but when it occurs, the test saves life
598 $num = $this->getNextNumRef();
599 }
600
601 $this->newref = (string) $num;
602
603 if (!empty($num)) {
604 // Validate
605 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
606 $sql .= " SET ref = '".$this->db->escape($num)."',";
607 $sql .= " status = ".self::STATUS_VALIDATED;
608 if (!empty($this->fields['date_validation'])) { // @phan-suppress-current-line PhanTypeMismatchProperty
609 $sql .= ", date_validation = '".$this->db->idate($now)."'";
610 }
611 if (!empty($this->fields['fk_user_valid'])) { // @phan-suppress-current-line PhanTypeMismatchProperty
612 $sql .= ", fk_user_valid = ".((int) $user->id);
613 }
614 $sql .= " WHERE rowid = ".((int) $this->id);
615
616 dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
617 $resql = $this->db->query($sql);
618 if (!$resql) {
619 dol_print_error($this->db);
620 $this->error = $this->db->lasterror();
621 $error++;
622 }
623
624 if (!$error && !$notrigger) {
625 // Call trigger
626 $result = $this->call_trigger('CONFERENCEORBOOTHATTENDEE_VALIDATE', $user);
627 if ($result < 0) {
628 $error++;
629 }
630 // End call triggers
631 }
632 }
633
634 if (!$error) {
635 $this->oldref = $this->ref;
636
637 // Rename directory if dir was a temporary ref
638 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
639 // Now we rename also files into index
640 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'conferenceorboothattendee/".$this->db->escape($this->newref)."'";
641 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'conferenceorboothattendee/".$this->db->escape($this->ref)."' and entity = ".((int) $conf->entity);
642 $resql = $this->db->query($sql);
643 if (!$resql) {
644 $error++;
645 $this->error = $this->db->lasterror();
646 }
647 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'conferenceorboothattendee/".$this->db->escape($this->newref)."'";
648 $sql .= " WHERE filepath = 'conferenceorboothattendee/".$this->db->escape($this->ref)."' and entity = ".((int) $conf->entity);
649 $resql = $this->db->query($sql);
650 if (!$resql) {
651 $error++;
652 $this->error = $this->db->lasterror();
653 }
654
655 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
656 $oldref = dol_sanitizeFileName($this->ref);
657 $newref = dol_sanitizeFileName($num);
658 $dirsource = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$oldref;
659 $dirdest = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref;
660 if (!$error && file_exists($dirsource)) {
661 dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
662
663 if (@rename($dirsource, $dirdest)) {
664 dol_syslog("Rename ok");
665 // Rename docs starting with $oldref with $newref
666 $listoffiles = dol_dir_list($conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
667 foreach ($listoffiles as $fileentry) {
668 $dirsource = $fileentry['name'];
669 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
670 $dirsource = $fileentry['path'].'/'.$dirsource;
671 $dirdest = $fileentry['path'].'/'.$dirdest;
672 @rename($dirsource, $dirdest);
673 }
674 }
675 }
676 }
677 }
678
679 // Set new ref and current status
680 if (!$error) {
681 $this->ref = $num;
682 $this->status = self::STATUS_VALIDATED;
683 }
684
685 if (!$error) {
686 $this->db->commit();
687 return 1;
688 } else {
689 $this->db->rollback();
690 return -1;
691 }
692 }
693
694 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
700 public function fetch_projet()
701 {
702 // phpcs:enable
703 include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
704
705 /* Done with DolDeprecationHandler
706 if (empty($this->fk_project) && !empty($this->fk_projet)) {
707 $this->fk_project = $this->fk_projet; // For backward compatibility
708 }
709 */
710 if (empty($this->fk_project)) {
711 return 0;
712 }
713
714 $project = new Project($this->db);
715 $result = $project->fetch($this->fk_project);
716
717 $this->project = $project;
718
719 return $result;
720 }
721
729 public function setDraft($user, $notrigger = 0)
730 {
731 // Protection
732 if ($this->status <= self::STATUS_DRAFT) {
733 return 0;
734 }
735
736 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'CONFERENCEORBOOTHATTENDEE_UNVALIDATE');
737 }
738
746 public function cancel($user, $notrigger = 0)
747 {
748 // Protection
749 if ($this->status != self::STATUS_VALIDATED) {
750 return 0;
751 }
752
753 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_CANCEL');
754 }
755
763 public function reopen($user, $notrigger = 0)
764 {
765 // Protection
766 if ($this->status != self::STATUS_CANCELED) {
767 return 0;
768 }
769
770 return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_REOPEN');
771 }
772
783 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
784 {
785 global $conf, $langs, $hookmanager;
786
787 if (!empty($conf->dol_no_mouse_hover)) {
788 $notooltip = 1; // Force disable tooltips
789 }
790
791 $result = '';
792
793 $label = img_picto('', $this->picto).' <u>'.$langs->trans("ConferenceOrBoothAttendee").'</u>';
794 if (isset($this->status)) {
795 $label .= ' '.$this->getLibStatut(5);
796 }
797 $label .= '<br>';
798 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
799 $label .= '<br><b>'.$langs->trans('DateOfRegistration').':</b> '.dol_print_date($this->date_subscription, 'dayhour');
800 $label .= '<br><b>'.$langs->trans('AmountPaid').':</b> '.$this->amount;
801
802 $url = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?id='.$this->id;
803
804 if ($option != 'nolink') {
805 // Add param to save lastsearch_values or not
806 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
807 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
808 $add_save_lastsearch_values = 1;
809 }
810 if ($add_save_lastsearch_values) {
811 $url .= '&save_lastsearch_values=1';
812 }
813
814 if ($option == 'conforboothid') {
815 $url .= '&conforboothid='.((int) $this->fk_actioncomm);
816 }
817
818 if ($option == 'projectid') {
819 $url .= '&fk_project='.((int) $this->fk_project).'&withproject=1';
820 }
821
822 if ($option == 'thirdpartyid') {
823 $url = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_list.php?thirdpartyid='.$this->id;
824 }
825
826 if ($option == 'conforboothidproject') {
827 $url .= '&conforboothid='.((int) $this->fk_actioncomm).'&withproject=1';
828 }
829 }
830
831 $linkclose = '';
832 if (empty($notooltip)) {
833 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
834 $label = $langs->trans("ShowConferenceOrBoothAttendee");
835 $linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"';
836 }
837 $linkclose .= ' title="'.dolPrintHTMLForAttribute($label).'"';
838 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
839 } else {
840 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
841 }
842
843 if ($option == 'nolink') {
844 $linkstart = '<span';
845 } else {
846 $linkstart = '<a href="'.$url.'"';
847 }
848 $linkstart .= $linkclose.'>';
849 if ($option == 'nolink') {
850 $linkend = '</span>';
851 } else {
852 $linkend = '</a>';
853 }
854
855 $result .= $linkstart;
856
857 if (empty($this->showphoto_on_popup)) {
858 if ($withpicto) {
859 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
860 }
861 } else {
862 if ($withpicto) {
863 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
864
865 list($class, $module) = explode('@', $this->picto);
866 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
867 $filearray = dol_dir_list($upload_dir, "files");
868 $filename = $filearray[0]['name'];
869 if (!empty($filename)) {
870 $pospoint = strpos($filearray[0]['name'], '.');
871
872 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.dol_substr($filename, 0, $pospoint).'_mini'.dol_substr($filename, $pospoint);
873 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
874 $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
875 } else {
876 $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';
877 }
878
879 $result .= '</div>';
880 } else {
881 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
882 }
883 }
884 }
885
886 if ($withpicto != 2) {
887 $result .= $this->ref;
888 }
889
890 $result .= $linkend;
891 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
892
893 global $action, $hookmanager;
894 $hookmanager->initHooks(array('conferenceorboothattendeedao'));
895 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
896 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
897 if ($reshook > 0) {
898 $result = $hookmanager->resPrint;
899 } else {
900 $result .= $hookmanager->resPrint;
901 }
902
903 return $result;
904 }
905
912 public function getLabelStatus($mode = 0)
913 {
914 return $this->LibStatut($this->status, $mode);
915 }
916
923 public function getLibStatut($mode = 0)
924 {
925 return $this->LibStatut($this->status, $mode);
926 }
927
928 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
936 public function LibStatut($status, $mode = 0)
937 {
938 // phpcs:enable
939 global $langs;
940
941 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
942 //$langs->load("eventorganization@eventorganization");
943 $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
944 $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Registered');
945 $this->labelStatus[self::STATUS_USED] = $langs->trans('ShowedUp');
946 $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
947 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft');
948 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Registered');
949 $this->labelStatusShort[self::STATUS_USED] = $langs->trans('ShowedUp');
950 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled');
951 }
952
953 $labelStatus = $this->labelStatus[$status];
954 $labelStatusShort = $this->labelStatusShort[$status];
955
956 $statusType = 'status'.$status;
957 if ($status == self::STATUS_VALIDATED) {
958 $statusType = 'status2';
959 }
960 if ($status == self::STATUS_CANCELED) {
961 $statusType = 'status9';
962 }
963
964 if ($status == self::STATUS_VALIDATED && $this->date_subscription && $this->amount) {
965 $statusType = 'status4';
966 $labelStatus .= ' - '.$langs->trans("Paid");
967 }
968
969 if ($status == self::STATUS_USED) {
970 $statusType = 'status6';
971 }
972
973 return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
974 }
975
982 public function info($id)
983 {
984 $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
985 $sql .= ' fk_user_creat, fk_user_modif';
986 $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
987 $sql .= ' WHERE t.rowid = '.((int) $id);
988 $result = $this->db->query($sql);
989 if ($result) {
990 if ($this->db->num_rows($result)) {
991 $obj = $this->db->fetch_object($result);
992
993 $this->id = $obj->rowid;
994
995 $this->user_creation_id = $obj->fk_user_creat;
996 $this->user_modification_id = $obj->fk_user_modif;
997 $this->date_creation = $this->db->jdate($obj->datec);
998 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
999 }
1000
1001 $this->db->free($result);
1002 } else {
1003 dol_print_error($this->db);
1004 }
1005 }
1006
1013 public function initAsSpecimen()
1014 {
1015 return $this->initAsSpecimenCommon();
1016 }
1017
1023 public function getNextNumRef()
1024 {
1025 global $langs, $conf;
1026 $langs->load("eventorganization@eventorganization");
1027
1028 if (!getDolGlobalString('EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON')) {
1029 $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON = 'mod_conferenceorboothattendee_standard';
1030 }
1031
1032 if (getDolGlobalString('EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON')) {
1033 $mybool = false;
1034
1035 $file = getDolGlobalString('EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON') . ".php";
1036 $classname = getDolGlobalString('EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON');
1037
1038 // Include file with class
1039 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
1040 foreach ($dirmodels as $reldir) {
1041 $dir = dol_buildpath($reldir."core/modules/eventorganization/");
1042
1043 // Load file with numbering class (if found)
1044 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1045 }
1046
1047 if (!$mybool) {
1048 dol_print_error(null, "Failed to include file ".$file);
1049 return '';
1050 }
1051
1052 if (class_exists($classname)) {
1053 $obj = new $classname();
1054 '@phan-var-force CommonNumRefGenerator $obj';
1055 $numref = $obj->getNextValue($this);
1056
1057 if ($numref != '' && $numref != '-1') {
1058 return $numref;
1059 } else {
1060 $this->error = $obj->error;
1061 //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
1062 return "";
1063 }
1064 } else {
1065 print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
1066 return "";
1067 }
1068 } else {
1069 print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
1070 return "";
1071 }
1072 }
1073
1085 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1086 {
1087 global $conf, $langs;
1088
1089 $result = 0;
1090
1091 $langs->load("eventorganization@eventorganization");
1092
1093 if (!dol_strlen($modele)) {
1094 $modele = 'standard_conferenceorboothattendee';
1095
1096 if (!empty($this->model_pdf)) {
1097 $modele = $this->model_pdf;
1098 } elseif (getDolGlobalString('CONFERENCEORBOOTHATTENDEE_ADDON_PDF')) {
1099 $modele = getDolGlobalString('CONFERENCEORBOOTHATTENDEE_ADDON_PDF');
1100 }
1101 }
1102
1103 $modelpath = "core/modules/eventorganization/doc/";
1104
1105 if (!empty($modele)) {
1106 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1107 }
1108
1109 return $result;
1110 }
1111
1120 public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
1121 {
1122 $tables = array(
1123 'eventorganization_conferenceorboothattendee'
1124 );
1125
1126 return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables);
1127 }
1128
1138 public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0)
1139 {
1140 $lastname = $this->lastname;
1141 $firstname = $this->firstname;
1142 if (empty($lastname)) {
1143 $lastname = (isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : (isset($this->societe) ? $this->societe : (isset($this->company) ? $this->company : '')))));
1144 }
1145
1146 $ret = '';
1147
1148 $ret .= dolGetFirstLastname((string) $firstname, (string) $lastname, $nameorder);
1149
1150 return dol_trunc($ret, $maxlen);
1151 }
1152}
1153
1154
1155require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1156
1161{
1162 // To complete with content of an object ConferenceOrBoothAttendeeLine
1163 // We should have a field rowid, fk_conferenceorboothattendee and position
1164
1170 public function __construct(DoliDB $db)
1171 {
1172 $this->db = $db;
1173
1174 $this->isextrafieldmanaged = 0;
1175 }
1176}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$object ref
Definition info.php:90
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
setErrorsFromObject($object)
setErrorsFromObject
createCommon(User $user, $notrigger=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class for ConferenceOrBoothAttendee.
cancel($user, $notrigger=0)
Set cancel status.
createFromClone(User $user, $fromid)
Clone an object into another one.
getLibStatut($mode=0)
Return the label of the status.
info($id)
Load the info information in the object.
fetch($id, $ref=null)
Load object in memory from the database.
getLabelStatus($mode=0)
Return the label of the status.
create(User $user, $notrigger=0)
Create object into database.
fetchLines()
Load object lines in memory from the database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
LibStatut($status, $mode=0)
Return the status.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
fetch_projet()
Load the project with id $this->fk_project into this->project.
getFullName($langs, $option=0, $nameorder=-1, $maxlen=0)
Return full name ('name+' '+lastname)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
update(User $user, $notrigger=0)
Update object into database.
reopen($user, $notrigger=0)
Set back to validated status.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
setDraft($user, $notrigger=0)
Set draft status.
validate($user, $notrigger=0)
Validate object.
Class ConferenceOrBoothAttendeeLine.
Class to manage Dolibarr database access.
Class to manage projects.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:169
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:65
dol_now($mode='gmt')
Return date for now.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as p p num_paiement as f pf amount as amount
Definition receipt.php:494
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140