dolibarr 21.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) ---Put here your own copyright and developer email---
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Put here all includes required by your class file
28require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
29//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
30//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
31
36{
40 public $module = 'eventorganization';
41
45 public $element = 'conferenceorboothattendee';
46
50 public $table_element = 'eventorganization_conferenceorboothattendee';
51
55 public $picto = 'contact';
56
57 public $paid = 0;
58
59 const STATUS_DRAFT = 0;
60 const STATUS_VALIDATED = 1;
61 const STATUS_CANCELED = 9;
62
63
90 // BEGIN MODULEBUILDER PROPERTIES
94 public $fields = array(
95 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id"),
96 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'position' => 10, 'notnull' => 1, 'visible' => 2, 'index' => 1, 'comment' => "Reference of object"),
97 //'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'),
98 'fk_project' => array('type' => 'integer:Project:projet/class/project.class.php:1', 'label' => 'Project', 'enabled' => "isModEnabled('project')", 'position' => 20, 'notnull' => 1, 'visible' => 0, 'index' => 1, 'picto' => 'project', 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'),
99 'email' => array('type' => 'mail', 'label' => 'EmailAttendee', 'enabled' => 1, 'position' => 30, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'autofocusoncreate' => 1, 'searchall' => 1, 'csslist' => 'tdoverflowmax150'),
100 'firstname' => array('type' => 'varchar(100)', 'label' => 'Firstname', 'enabled' => 1, 'position' => 31, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'csslist' => 'tdoverflowmax125'),
101 'lastname' => array('type' => 'varchar(100)', 'label' => 'Lastname', 'enabled' => 1, 'position' => 32, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'csslist' => 'tdoverflowmax125'),
102 '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'),
103 'email_company' => array('type' => 'mail', 'label' => 'EmailCompany', 'enabled' => 1, 'position' => 41, 'notnull' => 0, 'visible' => -2, 'searchall' => 1),
104 'date_subscription' => array('type' => 'datetime', 'label' => 'DateOfRegistration', 'enabled' => 1, 'position' => 56, 'notnull' => 1, 'visible' => 1, 'showoncombobox' => 1,),
105 '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'),
106 'amount' => array('type' => 'price', 'label' => 'AmountPaid', 'enabled' => 1, 'position' => 57, 'notnull' => 0, 'visible' => 1, 'default' => 'null', 'isameasure' => 1, 'help' => "AmountOfRegistrationPaid",),
107 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 61, 'notnull' => 0, 'visible' => 3,),
108 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 62, 'notnull' => 0, 'visible' => 3,),
109 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2, 'css' => 'nowraponall'),
110 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2,),
111 'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => 1, 'position' => 510, 'notnull' => -1, 'visible' => -2),
112 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2,),
113 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'position' => 600, 'notnull' => 0, 'visible' => 0,),
114 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,),
115 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'position' => 1010, 'notnull' => -1, 'visible' => 0,),
116 'ip' => array('type' => 'varchar(250)', 'label' => 'IPAddress', 'enabled' => 1, 'position' => 900, 'notnull' => -1, 'visible' => -2,),
117 'status' => array('type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 1000, 'default' => '0', 'notnull' => 1, 'visible' => 1, 'index' => 1, 'arrayofkeyval' => array('0' => 'Draft', '1' => 'Validated', '9' => 'Canceled'),),
118 );
119 public $rowid;
120 public $ref;
121 public $fk_actioncomm;
122 public $fk_project;
123 public $email;
124 public $firstname;
125 public $lastname;
126 public $fk_soc;
127 public $email_company;
128 public $date_subscription;
129 public $fk_invoice;
130 public $amount;
131 public $note_public;
132 public $note_private;
133 public $fk_user_creat;
134 public $fk_user_modif;
135 public $last_main_doc;
136 public $import_key;
137 public $model_pdf;
138 public $status;
139 // END MODULEBUILDER PROPERTIES
140
141
142 // If this object has a subtable with lines
143
144 // /**
145 // * @var string Name of subtable line
146 // */
147 // public $table_element_line = 'eventorganization_conferenceorboothattendeeline';
148
149 // /**
150 // * @var string Field with ID of parent key if this object has a parent
151 // */
152 // public $fk_element = 'fk_conferenceorboothattendee';
153
154 // /**
155 // * @var string Name of subtable class that manage subtable lines
156 // */
157 // public $class_element_line = 'ConferenceOrBoothAttendeeline';
158
159 // /**
160 // * @var array List of child tables. To test if we can delete object.
161 // */
162 // protected $childtables = array();
163
164 // /**
165 // * @var array List of child tables. To know object to delete on cascade.
166 // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
167 // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
168 // */
169 // protected $childtablesoncascade = array('eventorganization_conferenceorboothattendeedet');
170
171 // /**
172 // * @var ConferenceOrBoothAttendeeLine[] Array of subtable lines
173 // */
174 // public $lines = array();
175
176
177
183 public function __construct(DoliDB $db)
184 {
185 global $conf, $langs;
186
187 $this->db = $db;
188
189 $this->ismultientitymanaged = 'fk_project@projet';
190 $this->isextrafieldmanaged = 1;
191
192 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid'])) {
193 $this->fields['rowid']['visible'] = 0;
194 }
195 if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
196 $this->fields['entity']['enabled'] = 0;
197 }
198
199 if (getDolGlobalString('EVENTORGANIZATION_FILTERATTENDEES_CAT')) {
200 $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='.(int) $conf->global->EVENTORGANIZATION_FILTERATTENDEES_CAT.')';
201 }
202 if (isset($conf->global->EVENTORGANIZATION_FILTERATTENDEES_TYPE)
203 && getDolGlobalString('EVENTORGANIZATION_FILTERATTENDEES_TYPE') !== ''
204 && getDolGlobalString('EVENTORGANIZATION_FILTERATTENDEES_TYPE') !== '-1') {
205 $this->fields['fk_soc']['type'] .= ' AND client = '.((int) getDolGlobalInt('EVENTORGANIZATION_FILTERATTENDEES_TYPE', 0));
206 }
207
208 // Example to show how to set values of fields definition dynamically
209 /*if ($user->rights->eventorganization->conferenceorboothattendee->read) {
210 $this->fields['myfield']['visible'] = 1;
211 $this->fields['myfield']['noteditable'] = 0;
212 }*/
213
214 // Unset fields that are disabled
215 foreach ($this->fields as $key => $val) {
216 if (isset($val['enabled']) && empty($val['enabled'])) {
217 unset($this->fields[$key]);
218 }
219 }
220
221 // Translate some data of arrayofkeyval
222 if (is_object($langs)) {
223 foreach ($this->fields as $key => $val) {
224 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
225 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
226 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
227 }
228 }
229 }
230 }
231 }
232
240 public function create(User $user, $notrigger = 0)
241 {
242 global $langs;
243
244 if (!isValidEmail($this->email)) {
245 $langs->load("errors");
246 $this->errors[] = $langs->trans("ErrorBadEMail", $this->email);
247 return -1;
248 }
249
250 $result = $this->createCommon($user, $notrigger);
251 if ($result > 0) {
252 $result = $this->fetch($result);
253 if ($result > 0) {
254 $this->ref = (string) $this->id;
255 $result = $this->update($user);
256 }
257 }
258 return $result;
259 }
260
268 public function createFromClone(User $user, $fromid)
269 {
270 global $langs, $extrafields;
271 $error = 0;
272
273 dol_syslog(__METHOD__, LOG_DEBUG);
274
275 $object = new self($this->db);
276
277 $this->db->begin();
278
279 // Load source object
280 $result = $object->fetchCommon($fromid);
281 if ($result > 0 && !empty($object->table_element_line)) {
282 $object->fetchLines();
283 }
284
285 // get lines so they will be clone
286 //foreach($this->lines as $line)
287 // $line->fetch_optionals();
288
289 // Reset some properties
290 unset($object->id);
291 unset($object->fk_user_creat);
292 unset($object->import_key);
293
294 // Clear fields
295 if (property_exists($object, 'ref')) {
296 $object->ref = empty($this->fields['ref']['default']) ? "(PROV)" : $this->fields['ref']['default'];
297 }
298 if (property_exists($object, 'label')) {
299 $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
300 }
301 if (property_exists($object, 'status')) {
302 $object->status = self::STATUS_DRAFT;
303 }
304 if (property_exists($object, 'date_creation')) {
305 $object->date_creation = dol_now();
306 }
307 if (property_exists($object, 'date_modification')) {
308 $object->date_modification = null;
309 }
310 // ...
311 // Clear extrafields that are unique
312 if (is_array($object->array_options) && count($object->array_options) > 0) {
313 $extrafields->fetch_name_optionals_label($this->table_element);
314 foreach ($object->array_options as $key => $option) {
315 $shortkey = preg_replace('/options_/', '', $key);
316 if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
317 //var_dump($key);
318 //var_dump($clonedObj->array_options[$key]); exit;
319 unset($object->array_options[$key]);
320 }
321 }
322 }
323
324 // Create clone
325 $object->context['createfromclone'] = 'createfromclone';
326 $result = $object->createCommon($user);
327 if ($result < 0) {
328 $error++;
330 } else {
331 $object->ref = (string) $object->id;
332 $result = $object->update($user);
333 }
334
335 if (!$error) {
336 // copy internal contacts
337 if ($this->copy_linked_contact($object, 'internal') < 0) {
338 $error++;
339 }
340 }
341
342 if (!$error) {
343 // copy external contacts if same company
344 if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
345 if ($this->copy_linked_contact($object, 'external') < 0) {
346 $error++;
347 }
348 }
349 }
350
351 unset($object->context['createfromclone']);
352
353 // End
354 if (!$error) {
355 $this->db->commit();
356 return $object;
357 } else {
358 $this->db->rollback();
359 return -1;
360 }
361 }
362
370 public function fetch($id, $ref = null)
371 {
372 $result = $this->fetchCommon($id, $ref);
373 if ($result > 0 && !empty($this->table_element_line)) {
374 $this->fetchLines();
375 }
376 return $result;
377 }
378
384 public function fetchLines()
385 {
386 $this->lines = array();
387
388 $result = $this->fetchLinesCommon();
389 return $result;
390 }
391
392
405 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
406 {
407 dol_syslog(__METHOD__, LOG_DEBUG);
408
409 $records = array();
410
411 $sql = 'SELECT ';
412 $sql .= $this->getFieldList('t');
413 $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
414 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id = t.fk_actioncomm";
415 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
416 $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
417 } else {
418 $sql .= ' WHERE 1 = 1';
419 }
420
421 // Manage filter
422 $errormessage = '';
423 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
424 if ($errormessage) {
425 $this->errors[] = $errormessage;
426 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
427 return -1;
428 }
429
430 if (!empty($sortfield)) {
431 $sql .= $this->db->order($sortfield, $sortorder);
432 }
433 if (!empty($limit)) {
434 $sql .= $this->db->plimit($limit, $offset);
435 }
436
437 $resql = $this->db->query($sql);
438 if ($resql) {
439 $num = $this->db->num_rows($resql);
440 $i = 0;
441 while ($i < ($limit ? min($limit, $num) : $num)) {
442 $obj = $this->db->fetch_object($resql);
443
444 $record = new self($this->db);
445 $record->setVarsFromFetchObj($obj);
446
447 $records[$record->id] = $record;
448
449 $i++;
450 }
451 $this->db->free($resql);
452
453 return $records;
454 } else {
455 $this->errors[] = 'Error '.$this->db->lasterror();
456 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
457
458 return -1;
459 }
460 }
461
469 public function update(User $user, $notrigger = 0)
470 {
471 return $this->updateCommon($user, $notrigger);
472 }
473
481 public function delete(User $user, $notrigger = 0)
482 {
483 return $this->deleteCommon($user, $notrigger);
484 //return $this->deleteCommon($user, $notrigger, 1);
485 }
486
495 public function deleteLine(User $user, $idline, $notrigger = 0)
496 {
497 if ($this->status < 0) {
498 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
499 return -2;
500 }
501
502 return $this->deleteLineCommon($user, $idline, $notrigger);
503 }
504
505
513 public function validate($user, $notrigger = 0)
514 {
515 global $conf;
516
517 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
518
519 $error = 0;
520
521 // Protection
522 if ($this->status == self::STATUS_VALIDATED) {
523 dol_syslog(get_class($this)."::validate action abandoned: already validated", LOG_WARNING);
524 return 0;
525 }
526
527 $now = dol_now();
528
529 $this->db->begin();
530
531 // Define new ref
532 if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
533 $num = $this->getNextNumRef();
534 } else {
535 $num = $this->ref;
536 }
537 $this->newref = $num;
538
539 if (!empty($num)) {
540 // Validate
541 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
542 $sql .= " SET ref = '".$this->db->escape($num)."',";
543 $sql .= " status = ".self::STATUS_VALIDATED;
544 if (!empty($this->fields['date_validation'])) {
545 $sql .= ", date_validation = '".$this->db->idate($now)."'";
546 }
547 if (!empty($this->fields['fk_user_valid'])) {
548 $sql .= ", fk_user_valid = ".$user->id;
549 }
550 $sql .= " WHERE rowid = ".((int) $this->id);
551
552 dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
553 $resql = $this->db->query($sql);
554 if (!$resql) {
555 dol_print_error($this->db);
556 $this->error = $this->db->lasterror();
557 $error++;
558 }
559
560 if (!$error && !$notrigger) {
561 // Call trigger
562 $result = $this->call_trigger('CONFERENCEORBOOTHATTENDEE_VALIDATE', $user);
563 if ($result < 0) {
564 $error++;
565 }
566 // End call triggers
567 }
568 }
569
570 if (!$error) {
571 $this->oldref = $this->ref;
572
573 // Rename directory if dir was a temporary ref
574 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
575 // Now we rename also files into index
576 $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)."'";
577 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'conferenceorboothattendee/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
578 $resql = $this->db->query($sql);
579 if (!$resql) {
580 $error++;
581 $this->error = $this->db->lasterror();
582 }
583 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'conferenceorboothattendee/".$this->db->escape($this->newref)."'";
584 $sql .= " WHERE filepath = 'conferenceorboothattendee/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
585 $resql = $this->db->query($sql);
586 if (!$resql) {
587 $error++;
588 $this->error = $this->db->lasterror();
589 }
590
591 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
592 $oldref = dol_sanitizeFileName($this->ref);
593 $newref = dol_sanitizeFileName($num);
594 $dirsource = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$oldref;
595 $dirdest = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref;
596 if (!$error && file_exists($dirsource)) {
597 dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
598
599 if (@rename($dirsource, $dirdest)) {
600 dol_syslog("Rename ok");
601 // Rename docs starting with $oldref with $newref
602 $listoffiles = dol_dir_list($conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
603 foreach ($listoffiles as $fileentry) {
604 $dirsource = $fileentry['name'];
605 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
606 $dirsource = $fileentry['path'].'/'.$dirsource;
607 $dirdest = $fileentry['path'].'/'.$dirdest;
608 @rename($dirsource, $dirdest);
609 }
610 }
611 }
612 }
613 }
614
615 // Set new ref and current status
616 if (!$error) {
617 $this->ref = $num;
618 $this->status = self::STATUS_VALIDATED;
619 }
620
621 if (!$error) {
622 $this->db->commit();
623 return 1;
624 } else {
625 $this->db->rollback();
626 return -1;
627 }
628 }
629
630 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
636 public function fetch_projet()
637 {
638 // phpcs:enable
639 include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
640
641 if (empty($this->fk_project) && !empty($this->fk_projet)) {
642 $this->fk_project = $this->fk_projet; // For backward compatibility
643 }
644 if (empty($this->fk_project)) {
645 return 0;
646 }
647
648 $project = new Project($this->db);
649 $result = $project->fetch($this->fk_project);
650
651 $this->projet = $project; // deprecated
652 $this->project = $project;
653 return $result;
654 }
655
663 public function setDraft($user, $notrigger = 0)
664 {
665 // Protection
666 if ($this->status <= self::STATUS_DRAFT) {
667 return 0;
668 }
669
670 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'CONFERENCEORBOOTHATTENDEE_UNVALIDATE');
671 }
672
680 public function cancel($user, $notrigger = 0)
681 {
682 // Protection
683 if ($this->status != self::STATUS_VALIDATED) {
684 return 0;
685 }
686
687 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_CANCEL');
688 }
689
697 public function reopen($user, $notrigger = 0)
698 {
699 // Protection
700 if ($this->status != self::STATUS_CANCELED) {
701 return 0;
702 }
703
704 return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_REOPEN');
705 }
706
717 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
718 {
719 global $conf, $langs, $hookmanager;
720
721 if (!empty($conf->dol_no_mouse_hover)) {
722 $notooltip = 1; // Force disable tooltips
723 }
724
725 $result = '';
726
727 $label = img_picto('', $this->picto).' <u>'.$langs->trans("ConferenceOrBoothAttendee").'</u>';
728 if (isset($this->status)) {
729 $label .= ' '.$this->getLibStatut(5);
730 }
731 $label .= '<br>';
732 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
733 $label .= '<br><b>'.$langs->trans('DateOfRegistration').':</b> '.dol_print_date($this->date_subscription, 'dayhour');
734 $label .= '<br><b>'.$langs->trans('AmountPaid').':</b> '.$this->amount;
735
736 $url = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?id='.$this->id;
737
738 if ($option != 'nolink') {
739 // Add param to save lastsearch_values or not
740 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
741 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
742 $add_save_lastsearch_values = 1;
743 }
744 if ($add_save_lastsearch_values) {
745 $url .= '&save_lastsearch_values=1';
746 }
747
748 if ($option == 'conforboothid') {
749 $url .= '&conforboothid='.((int) $this->fk_actioncomm);
750 }
751
752 if ($option == 'projectid') {
753 $url .= '&fk_project='.((int) $this->fk_project).'&withproject=1';
754 }
755
756 if ($option == 'conforboothidproject') {
757 $url .= '&conforboothid='.((int) $this->fk_actioncomm).'&withproject=1';
758 }
759 }
760
761 $linkclose = '';
762 if (empty($notooltip)) {
763 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
764 $label = $langs->trans("ShowConferenceOrBoothAttendee");
765 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
766 }
767 $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
768 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
769 } else {
770 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
771 }
772
773 if ($option == 'nolink') {
774 $linkstart = '<span';
775 } else {
776 $linkstart = '<a href="'.$url.'"';
777 }
778 $linkstart .= $linkclose.'>';
779 if ($option == 'nolink') {
780 $linkend = '</span>';
781 } else {
782 $linkend = '</a>';
783 }
784
785 $result .= $linkstart;
786
787 if (empty($this->showphoto_on_popup)) {
788 if ($withpicto) {
789 $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);
790 }
791 } else {
792 if ($withpicto) {
793 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
794
795 list($class, $module) = explode('@', $this->picto);
796 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
797 $filearray = dol_dir_list($upload_dir, "files");
798 $filename = $filearray[0]['name'];
799 if (!empty($filename)) {
800 $pospoint = strpos($filearray[0]['name'], '.');
801
802 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
803 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
804 $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>';
805 } else {
806 $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>';
807 }
808
809 $result .= '</div>';
810 } else {
811 $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);
812 }
813 }
814 }
815
816 if ($withpicto != 2) {
817 $result .= $this->ref;
818 }
819
820 $result .= $linkend;
821 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
822
823 global $action, $hookmanager;
824 $hookmanager->initHooks(array('conferenceorboothattendeedao'));
825 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
826 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
827 if ($reshook > 0) {
828 $result = $hookmanager->resPrint;
829 } else {
830 $result .= $hookmanager->resPrint;
831 }
832
833 return $result;
834 }
835
842 public function getLabelStatus($mode = 0)
843 {
844 return $this->LibStatut($this->status, $mode);
845 }
846
853 public function getLibStatut($mode = 0)
854 {
855 return $this->LibStatut($this->status, $mode);
856 }
857
858 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
866 public function LibStatut($status, $mode = 0)
867 {
868 // phpcs:enable
869 global $langs;
870
871 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
872 //$langs->load("eventorganization@eventorganization");
873 $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
874 $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated');
875 $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
876 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft');
877 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Validated');
878 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled');
879 }
880
881 $statusType = 'status'.$status;
882 //if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
883 if ($status == self::STATUS_CANCELED) {
884 $statusType = 'status6';
885 }
886
887 if ($status == self::STATUS_VALIDATED && $this->date_subscription && $this->amount) {
888 $statusType = 'status4';
889 $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated').' - '.$langs->trans("Paid");
890 }
891
892 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
893 }
894
901 public function info($id)
902 {
903 $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
904 $sql .= ' fk_user_creat, fk_user_modif';
905 $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
906 $sql .= ' WHERE t.rowid = '.((int) $id);
907 $result = $this->db->query($sql);
908 if ($result) {
909 if ($this->db->num_rows($result)) {
910 $obj = $this->db->fetch_object($result);
911
912 $this->id = $obj->rowid;
913
914 $this->user_creation_id = $obj->fk_user_creat;
915 $this->user_modification_id = $obj->fk_user_modif;
916 $this->date_creation = $this->db->jdate($obj->datec);
917 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
918 }
919
920 $this->db->free($result);
921 } else {
922 dol_print_error($this->db);
923 }
924 }
925
932 public function initAsSpecimen()
933 {
934 return $this->initAsSpecimenCommon();
935 }
936
942 public function getNextNumRef()
943 {
944 global $langs, $conf;
945 $langs->load("eventorganization@eventorganization");
946
947 if (!getDolGlobalString('EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON')) {
948 $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON = 'mod_conferenceorboothattendee_standard';
949 }
950
951 if (getDolGlobalString('EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON')) {
952 $mybool = false;
953
954 $file = getDolGlobalString('EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON') . ".php";
955 $classname = getDolGlobalString('EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON');
956
957 // Include file with class
958 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
959 foreach ($dirmodels as $reldir) {
960 $dir = dol_buildpath($reldir."core/modules/eventorganization/");
961
962 // Load file with numbering class (if found)
963 $mybool = ((bool) @include_once $dir.$file) || $mybool;
964 }
965
966 if ($mybool === false) {
967 dol_print_error(null, "Failed to include file ".$file);
968 return '';
969 }
970
971 if (class_exists($classname)) {
972 $obj = new $classname();
973 $numref = $obj->getNextValue($this);
974
975 if ($numref != '' && $numref != '-1') {
976 return $numref;
977 } else {
978 $this->error = $obj->error;
979 //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
980 return "";
981 }
982 } else {
983 print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
984 return "";
985 }
986 } else {
987 print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
988 return "";
989 }
990 }
991
1003 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1004 {
1005 global $conf, $langs;
1006
1007 $result = 0;
1008 $includedocgeneration = 0;
1009
1010 $langs->load("eventorganization@eventorganization");
1011
1012 if (!dol_strlen($modele)) {
1013 $modele = 'standard_conferenceorboothattendee';
1014
1015 if (!empty($this->model_pdf)) {
1016 $modele = $this->model_pdf;
1017 } elseif (getDolGlobalString('CONFERENCEORBOOTHATTENDEE_ADDON_PDF')) {
1018 $modele = getDolGlobalString('CONFERENCEORBOOTHATTENDEE_ADDON_PDF');
1019 }
1020 }
1021
1022 $modelpath = "core/modules/eventorganization/doc/";
1023
1024 if ($includedocgeneration && !empty($modele)) {
1025 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1026 }
1027
1028 return $result;
1029 }
1030
1038 public function doScheduledJob()
1039 {
1040 global $conf, $langs;
1041
1042 //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
1043
1044 $error = 0;
1045 $this->output = '';
1046 $this->error = '';
1047
1048 dol_syslog(__METHOD__, LOG_DEBUG);
1049
1050 $now = dol_now();
1051
1052 $this->db->begin();
1053
1054 // ...
1055
1056 $this->db->commit();
1057
1058 return $error;
1059 }
1060
1069 public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
1070 {
1071 $tables = array(
1072 'eventorganization_conferenceorboothattendee'
1073 );
1074
1075 return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables);
1076 }
1077
1087 public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0)
1088 {
1089 $lastname = $this->lastname;
1090 $firstname = $this->firstname;
1091 if (empty($lastname)) {
1092 $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 : '')))));
1093 }
1094
1095 $ret = '';
1096
1097 $ret .= dolGetFirstLastname($firstname, $lastname, $nameorder);
1098
1099 return dol_trunc($ret, $maxlen);
1100 }
1101}
1102
1103
1104require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1105
1110{
1111 // To complete with content of an object ConferenceOrBoothAttendeeLine
1112 // We should have a field rowid, fk_conferenceorboothattendee and position
1113
1119 public function __construct(DoliDB $db)
1120 {
1121 $this->db = $db;
1122
1123 $this->isextrafieldmanaged = 0;
1124 }
1125}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition security.php:626
$object ref
Definition info.php:79
Parent class of all other business classes (invoices, contracts, proposals, orders,...
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.
call_trigger($triggerName, $user)
Call trigger based on this instance.
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.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
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.
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:63
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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 dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:142