Passed
Branch develop (7a9ea1)
by
unknown
36:03
created

ConferenceOrBoothAttendee::fetchAll()   D

Complexity

Conditions 18
Paths 96

Size

Total Lines 67
Code Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 18
eloc 46
nc 96
nop 6
dl 0
loc 67
rs 4.8666
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* Copyright (C) 2017  Laurent Destailleur <[email protected]>
3
 * Copyright (C) ---Put here your own copyright and developer email---
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
/**
20
 * \file        class/conferenceorboothattendee.class.php
21
 * \ingroup     eventorganization
22
 * \brief       This file is a CRUD class file for ConferenceOrBoothAttendee (Create/Read/Update/Delete)
23
 */
24
25
// Put here all includes required by your class file
26
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
27
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
28
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
29
30
/**
31
 * Class for ConferenceOrBoothAttendee
32
 */
33
class ConferenceOrBoothAttendee extends CommonObject
34
{
35
	/**
36
	 * @var string ID of module.
37
	 */
38
	public $module = 'eventorganization';
39
40
	/**
41
	 * @var string ID to identify managed object.
42
	 */
43
	public $element = 'conferenceorboothattendee';
44
45
	/**
46
	 * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
47
	 */
48
	public $table_element = 'eventorganization_conferenceorboothattendee';
49
50
	/**
51
	 * @var int  Does this object support multicompany module ?
52
	 * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
53
	 */
54
	public $ismultientitymanaged = 0;
55
56
	/**
57
	 * @var int  Does object support extrafields ? 0=No, 1=Yes
58
	 */
59
	public $isextrafieldmanaged = 1;
60
61
	/**
62
	 * @var string String with name of icon for conferenceorboothattendee. Must be the part after the 'object_' into object_conferenceorboothattendee.png
63
	 */
64
	public $picto = 'contact';
65
66
	public $paid = 0;
67
68
	const STATUS_DRAFT = 0;
69
	const STATUS_VALIDATED = 1;
70
	const STATUS_CANCELED = 9;
71
72
73
	/**
74
	 *  'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
75
	 *         Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
76
	 *  'label' the translation key.
77
	 *  'picto' is code of a picto to show before value in forms
78
	 *  'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
79
	 *  'position' is the sort order of field.
80
	 *  'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
81
	 *  'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
82
	 *  'noteditable' says if field is not editable (1 or 0)
83
	 *  'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
84
	 *  'index' if we want an index in database.
85
	 *  'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
86
	 *  'searchall' is 1 if we want to search in this field when making a search from the quick search button.
87
	 *  'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
88
	 *  'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200'
89
	 *  'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
90
	 *  'showoncombobox' if value of the field must be visible into the label of the combobox that list record
91
	 *  'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
92
	 *  'arrayofkeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
93
	 *  'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
94
	 *  'comment' is not used. You can store here any text of your choice. It is not used by application.
95
	 *
96
	 *  Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
97
	 */
98
99
	// BEGIN MODULEBUILDER PROPERTIES
100
	/**
101
	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
102
	 */
103
	public $fields=array(
104
		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
105
		'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"),
106
		'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status = 1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty", 'picto'=>'company', 'css'=>'maxwidth500'),
107
		'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>0, 'index'=>1, 'picto'=>'agenda'),
108
		'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>54, 'notnull'=>1, 'visible'=>0, 'index'=>1, 'picto'=>'project'),
109
		'email' => array('type'=>'mail', 'label'=>'Email', 'enabled'=>'1', 'position'=>55, 'notnull'=>1, 'visible'=>1, 'index'=>1,),
110
		'date_subscription' => array('type'=>'datetime', 'label'=>'DateOfRegistration', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',),
111
		'amount' => array('type'=>'price', 'label'=>'AmountPaid', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",),
112
		'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
113
		'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
114
		'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
115
		'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
116
		'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>-1, 'visible'=>-2),
117
		'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
118
		'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
119
		'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
120
		'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
121
		'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'),),
122
	);
123
	public $rowid;
124
	public $ref;
125
	public $fk_soc;
126
	public $fk_actioncomm;
127
	public $email;
128
	public $date_subscription;
129
	public $amount;
130
	public $note_public;
131
	public $note_private;
132
	public $date_creation;
133
	public $tms;
134
	public $fk_user_creat;
135
	public $fk_user_modif;
136
	public $last_main_doc;
137
	public $import_key;
138
	public $model_pdf;
139
	public $status;
140
	// END MODULEBUILDER PROPERTIES
141
142
143
	// If this object has a subtable with lines
144
145
	// /**
146
	//  * @var string    Name of subtable line
147
	//  */
148
	// public $table_element_line = 'eventorganization_conferenceorboothattendeeline';
149
150
	// /**
151
	//  * @var string    Field with ID of parent key if this object has a parent
152
	//  */
153
	// public $fk_element = 'fk_conferenceorboothattendee';
154
155
	// /**
156
	//  * @var string    Name of subtable class that manage subtable lines
157
	//  */
158
	// public $class_element_line = 'ConferenceOrBoothAttendeeline';
159
160
	// /**
161
	//  * @var array	List of child tables. To test if we can delete object.
162
	//  */
163
	// protected $childtables = array();
164
165
	// /**
166
	//  * @var array    List of child tables. To know object to delete on cascade.
167
	//  *               If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
168
	//  *               call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
169
	//  */
170
	// protected $childtablesoncascade = array('eventorganization_conferenceorboothattendeedet');
171
172
	// /**
173
	//  * @var ConferenceOrBoothAttendeeLine[]     Array of subtable lines
174
	//  */
175
	// public $lines = array();
176
177
178
179
	/**
180
	 * Constructor
181
	 *
182
	 * @param DoliDb $db Database handler
183
	 */
184
	public function __construct(DoliDB $db)
185
	{
186
		global $conf, $langs;
187
188
		$this->db = $db;
189
190
		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
191
			$this->fields['rowid']['visible'] = 0;
192
		}
193
		if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
194
			$this->fields['entity']['enabled'] = 0;
195
		}
196
197
		if (!empty($conf->global->EVENTORGANIZATION_FILTERATTENDEES_CAT)) {
198
			$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.')';
199
		}
200
		if (isset($conf->global->EVENTORGANIZATION_FILTERATTENDEES_TYPE)
201
			&& $conf->global->EVENTORGANIZATION_FILTERATTENDEES_TYPE !== ''
202
			&& $conf->global->EVENTORGANIZATION_FILTERATTENDEES_TYPE !== '-1') {
203
			$this->fields['fk_soc']['type'] .= ' AND client = '.(int) $conf->global->EVENTORGANIZATION_FILTERATTENDEES_TYPE;
204
		}
205
206
		// Example to show how to set values of fields definition dynamically
207
		/*if ($user->rights->eventorganization->conferenceorboothattendee->read) {
208
			$this->fields['myfield']['visible'] = 1;
209
			$this->fields['myfield']['noteditable'] = 0;
210
		}*/
211
212
		// Unset fields that are disabled
213
		foreach ($this->fields as $key => $val) {
214
			if (isset($val['enabled']) && empty($val['enabled'])) {
215
				unset($this->fields[$key]);
216
			}
217
		}
218
219
		// Translate some data of arrayofkeyval
220
		if (is_object($langs)) {
221
			foreach ($this->fields as $key => $val) {
222
				if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
223
					foreach ($val['arrayofkeyval'] as $key2 => $val2) {
224
						$this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
225
					}
226
				}
227
			}
228
		}
229
	}
230
231
	/**
232
	 * Create object into database
233
	 *
234
	 * @param  User $user      User that creates
235
	 * @param  bool $notrigger false=launch triggers after, true=disable triggers
236
	 * @return int             <0 if KO, Id of created object if OK
237
	 */
238
	public function create(User $user, $notrigger = false)
239
	{
240
		global $langs;
241
242
		if (!isValidEMail($this->email)) {
243
			$langs->load("errors");
244
			$this->errors[] = $langs->trans("ErrorBadEMail", $this->email);
245
			return -1;
246
		}
247
248
		$result = $this->createCommon($user, $notrigger);
249
		if ($result>0) {
250
			$result =$this->fetch($result);
251
			if ($result>0) {
252
				$this->ref = $this->id;
253
				$result = $this->update($user);
254
			}
255
		}
256
		return $result;
257
	}
258
259
	/**
260
	 * Clone an object into another one
261
	 *
262
	 * @param  	User 	$user      	User that creates
263
	 * @param  	int 	$fromid     Id of object to clone
264
	 * @return 	mixed 				New object created, <0 if KO
265
	 */
266
	public function createFromClone(User $user, $fromid)
267
	{
268
		global $langs, $extrafields;
269
		$error = 0;
270
271
		dol_syslog(__METHOD__, LOG_DEBUG);
272
273
		$object = new self($this->db);
274
275
		$this->db->begin();
276
277
		// Load source object
278
		$result = $object->fetchCommon($fromid);
279
		if ($result > 0 && !empty($object->table_element_line)) {
280
			$object->fetchLines();
281
		}
282
283
		// get lines so they will be clone
284
		//foreach($this->lines as $line)
285
		//	$line->fetch_optionals();
286
287
		// Reset some properties
288
		unset($object->id);
289
		unset($object->fk_user_creat);
290
		unset($object->import_key);
291
292
		// Clear fields
293
		if (property_exists($object, 'ref')) {
294
			$object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
295
		}
296
		if (property_exists($object, 'label')) {
297
			$object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
298
		}
299
		if (property_exists($object, 'status')) {
300
			$object->status = self::STATUS_DRAFT;
301
		}
302
		if (property_exists($object, 'date_creation')) {
303
			$object->date_creation = dol_now();
304
		}
305
		if (property_exists($object, 'date_modification')) {
306
			$object->date_modification = null;
307
		}
308
		// ...
309
		// Clear extrafields that are unique
310
		if (is_array($object->array_options) && count($object->array_options) > 0) {
311
			$extrafields->fetch_name_optionals_label($this->table_element);
312
			foreach ($object->array_options as $key => $option) {
313
				$shortkey = preg_replace('/options_/', '', $key);
314
				if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
315
					//var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
316
					unset($object->array_options[$key]);
317
				}
318
			}
319
		}
320
321
		// Create clone
322
		$object->context['createfromclone'] = 'createfromclone';
323
		$result = $object->createCommon($user);
324
		if ($result < 0) {
325
			$error++;
326
			$this->error = $object->error;
327
			$this->errors = $object->errors;
328
		}
329
330
		if (!$error) {
331
			// copy internal contacts
332
			if ($this->copy_linked_contact($object, 'internal') < 0) {
333
				$error++;
334
			}
335
		}
336
337
		if (!$error) {
338
			// copy external contacts if same company
339
			if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
340
				if ($this->copy_linked_contact($object, 'external') < 0) {
341
					$error++;
342
				}
343
			}
344
		}
345
346
		unset($object->context['createfromclone']);
347
348
		// End
349
		if (!$error) {
350
			$this->db->commit();
351
			return $object;
352
		} else {
353
			$this->db->rollback();
354
			return -1;
355
		}
356
	}
357
358
	/**
359
	 * Load object in memory from the database
360
	 *
361
	 * @param int    $id   Id object
362
	 * @param string $ref  Ref
363
	 * @return int         <0 if KO, 0 if not found, >0 if OK
364
	 */
365
	public function fetch($id, $ref = null)
366
	{
367
		$result = $this->fetchCommon($id, $ref);
368
		if ($result > 0 && !empty($this->table_element_line)) {
369
			$this->fetchLines();
370
		}
371
		return $result;
372
	}
373
374
	/**
375
	 * Load object lines in memory from the database
376
	 *
377
	 * @return int         <0 if KO, 0 if not found, >0 if OK
378
	 */
379
	public function fetchLines()
380
	{
381
		$this->lines = array();
382
383
		$result = $this->fetchLinesCommon();
384
		return $result;
385
	}
386
387
388
	/**
389
	 * Load list of objects in memory from the database.
390
	 *
391
	 * @param  string      $sortorder    Sort Order
392
	 * @param  string      $sortfield    Sort field
393
	 * @param  int         $limit        limit
394
	 * @param  int         $offset       Offset
395
	 * @param  array       $filter       Filter array. Example array('field'=>'valueforlike', 'customurl'=>...). WARNING: customerurl must be a sanitized SQL string.
396
	 * @param  string      $filtermode   Filter mode (AND or OR)
397
	 * @return array|int                 int <0 if KO, array of pages if OK
398
	 */
399
	public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
400
	{
401
		global $conf;
402
403
		dol_syslog(__METHOD__, LOG_DEBUG);
404
405
		$records = array();
406
407
		$sql = 'SELECT ';
408
		$sql .= $this->getFieldList('t');
409
		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
410
		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id = t.fk_actioncomm";
411
		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
412
			$sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
413
		} else {
414
			$sql .= ' WHERE 1 = 1';
415
		}
416
		// Manage filter
417
		$sqlwhere = array();
418
		if (count($filter) > 0) {
419
			foreach ($filter as $key => $value) {
420
				if ($key == 't.rowid' || $key == 't.fk_soc' || $key == 't.fk_project' || $key == 't.fk_actioncomm') {
421
					$sqlwhere[] = $key.'='.((int) $value);
422
				} elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
423
					$sqlwhere[] = $key." = '".$this->db->idate($value)."'";
424
				} elseif ($key == 'customsql') {
425
					$sqlwhere[] = $value;
426
				} elseif (strpos($value, '%') === false) {
427
					$sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')';
428
				} else {
429
					$sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
430
				}
431
			}
432
		}
433
		if (count($sqlwhere) > 0) {
434
			$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
435
		}
436
437
		if (!empty($sortfield)) {
438
			$sql .= $this->db->order($sortfield, $sortorder);
439
		}
440
		if (!empty($limit)) {
441
			$sql .= $this->db->plimit($limit, $offset);
442
		}
443
444
		$resql = $this->db->query($sql);
445
		if ($resql) {
446
			$num = $this->db->num_rows($resql);
447
			$i = 0;
448
			while ($i < ($limit ? min($limit, $num) : $num)) {
449
				$obj = $this->db->fetch_object($resql);
450
451
				$record = new self($this->db);
452
				$record->setVarsFromFetchObj($obj);
453
454
				$records[$record->id] = $record;
455
456
				$i++;
457
			}
458
			$this->db->free($resql);
459
460
			return $records;
461
		} else {
462
			$this->errors[] = 'Error '.$this->db->lasterror();
463
			dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
464
465
			return -1;
466
		}
467
	}
468
469
	/**
470
	 * Update object into database
471
	 *
472
	 * @param  User $user      User that modifies
473
	 * @param  bool $notrigger false=launch triggers after, true=disable triggers
474
	 * @return int             <0 if KO, >0 if OK
475
	 */
476
	public function update(User $user, $notrigger = false)
477
	{
478
		return $this->updateCommon($user, $notrigger);
479
	}
480
481
	/**
482
	 * Delete object in database
483
	 *
484
	 * @param User $user       User that deletes
485
	 * @param bool $notrigger  false=launch triggers after, true=disable triggers
486
	 * @return int             <0 if KO, >0 if OK
487
	 */
488
	public function delete(User $user, $notrigger = false)
489
	{
490
		return $this->deleteCommon($user, $notrigger);
491
		//return $this->deleteCommon($user, $notrigger, 1);
492
	}
493
494
	/**
495
	 *  Delete a line of object in database
496
	 *
497
	 *	@param  User	$user       User that delete
498
	 *  @param	int		$idline		Id of line to delete
499
	 *  @param 	bool 	$notrigger  false=launch triggers after, true=disable triggers
500
	 *  @return int         		>0 if OK, <0 if KO
501
	 */
502
	public function deleteLine(User $user, $idline, $notrigger = false)
503
	{
504
		if ($this->status < 0) {
505
			$this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
506
			return -2;
507
		}
508
509
		return $this->deleteLineCommon($user, $idline, $notrigger);
510
	}
511
512
513
	/**
514
	 *	Validate object
515
	 *
516
	 *	@param		User	$user     		User making status change
517
	 *  @param		int		$notrigger		1=Does not execute triggers, 0= execute triggers
518
	 *	@return  	int						<=0 if OK, 0=Nothing done, >0 if KO
519
	 */
520
	public function validate($user, $notrigger = 0)
521
	{
522
		global $conf, $langs;
523
524
		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
525
526
		$error = 0;
527
528
		// Protection
529
		if ($this->status == self::STATUS_VALIDATED) {
530
			dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
531
			return 0;
532
		}
533
534
		/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorboothattendee->write))
535
		 || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorboothattendee->conferenceorboothattendee_advance->validate))))
536
		 {
537
		 $this->error='NotEnoughPermissions';
538
		 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
539
		 return -1;
540
		 }*/
541
542
		$now = dol_now();
543
544
		$this->db->begin();
545
546
		// Define new ref
547
		if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
548
			$num = $this->getNextNumRef();
549
		} else {
550
			$num = $this->ref;
551
		}
552
		$this->newref = $num;
553
554
		if (!empty($num)) {
555
			// Validate
556
			$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
557
			$sql .= " SET ref = '".$this->db->escape($num)."',";
558
			$sql .= " status = ".self::STATUS_VALIDATED;
559
			if (!empty($this->fields['date_validation'])) {
560
				$sql .= ", date_validation = '".$this->db->idate($now)."'";
561
			}
562
			if (!empty($this->fields['fk_user_valid'])) {
563
				$sql .= ", fk_user_valid = ".$user->id;
564
			}
565
			$sql .= " WHERE rowid = ".((int) $this->id);
566
567
			dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
568
			$resql = $this->db->query($sql);
569
			if (!$resql) {
570
				dol_print_error($this->db);
571
				$this->error = $this->db->lasterror();
572
				$error++;
573
			}
574
575
			if (!$error && !$notrigger) {
576
				// Call trigger
577
				$result = $this->call_trigger('CONFERENCEORBOOTHATTENDEE_VALIDATE', $user);
578
				if ($result < 0) {
579
					$error++;
580
				}
581
				// End call triggers
582
			}
583
		}
584
585
		if (!$error) {
586
			$this->oldref = $this->ref;
587
588
			// Rename directory if dir was a temporary ref
589
			if (preg_match('/^[\(]?PROV/i', $this->ref)) {
590
				// Now we rename also files into index
591
				$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)."'";
592
				$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'conferenceorboothattendee/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
593
				$resql = $this->db->query($sql);
594
				if (!$resql) {
595
					$error++; $this->error = $this->db->lasterror();
596
				}
597
598
				// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
599
				$oldref = dol_sanitizeFileName($this->ref);
600
				$newref = dol_sanitizeFileName($num);
601
				$dirsource = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$oldref;
602
				$dirdest = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref;
603
				if (!$error && file_exists($dirsource)) {
604
					dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
605
606
					if (@rename($dirsource, $dirdest)) {
607
						dol_syslog("Rename ok");
608
						// Rename docs starting with $oldref with $newref
609
						$listoffiles = dol_dir_list($conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
610
						foreach ($listoffiles as $fileentry) {
611
							$dirsource = $fileentry['name'];
612
							$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
613
							$dirsource = $fileentry['path'].'/'.$dirsource;
614
							$dirdest = $fileentry['path'].'/'.$dirdest;
615
							@rename($dirsource, $dirdest);
616
						}
617
					}
618
				}
619
			}
620
		}
621
622
		// Set new ref and current status
623
		if (!$error) {
624
			$this->ref = $num;
625
			$this->status = self::STATUS_VALIDATED;
626
		}
627
628
		if (!$error) {
629
			$this->db->commit();
630
			return 1;
631
		} else {
632
			$this->db->rollback();
633
			return -1;
634
		}
635
	}
636
637
638
	/**
639
	 *	Set draft status
640
	 *
641
	 *	@param	User	$user			Object user that modify
642
	 *  @param	int		$notrigger		1=Does not execute triggers, 0=Execute triggers
643
	 *	@return	int						<0 if KO, >0 if OK
644
	 */
645
	public function setDraft($user, $notrigger = 0)
646
	{
647
		// Protection
648
		if ($this->status <= self::STATUS_DRAFT) {
649
			return 0;
650
		}
651
652
		/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write))
653
		 || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate))))
654
		 {
655
		 $this->error='Permission denied';
656
		 return -1;
657
		 }*/
658
659
		return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'CONFERENCEORBOOTHATTENDEE_UNVALIDATE');
660
	}
661
662
	/**
663
	 *	Set cancel status
664
	 *
665
	 *	@param	User	$user			Object user that modify
666
	 *  @param	int		$notrigger		1=Does not execute triggers, 0=Execute triggers
667
	 *	@return	int						<0 if KO, 0=Nothing done, >0 if OK
668
	 */
669
	public function cancel($user, $notrigger = 0)
670
	{
671
		// Protection
672
		if ($this->status != self::STATUS_VALIDATED) {
673
			return 0;
674
		}
675
676
		/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write))
677
		 || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate))))
678
		 {
679
		 $this->error='Permission denied';
680
		 return -1;
681
		 }*/
682
683
		return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_CANCEL');
684
	}
685
686
	/**
687
	 *	Set back to validated status
688
	 *
689
	 *	@param	User	$user			Object user that modify
690
	 *  @param	int		$notrigger		1=Does not execute triggers, 0=Execute triggers
691
	 *	@return	int						<0 if KO, 0=Nothing done, >0 if OK
692
	 */
693
	public function reopen($user, $notrigger = 0)
694
	{
695
		// Protection
696
		if ($this->status != self::STATUS_CANCELED) {
697
			return 0;
698
		}
699
700
		/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write))
701
		 || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate))))
702
		 {
703
		 $this->error='Permission denied';
704
		 return -1;
705
		 }*/
706
707
		return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_REOPEN');
708
	}
709
710
	/**
711
	 *  Return a link to the object card (with optionaly the picto)
712
	 *
713
	 *  @param  int     $withpicto                  Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
714
	 *  @param  string  $option                     On what the link point to ('nolink', ...)
715
	 *  @param  int     $notooltip                  1=Disable tooltip
716
	 *  @param  string  $morecss                    Add more css on link
717
	 *  @param  int     $save_lastsearch_value      -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
718
	 *  @return	string                              String with URL
719
	 */
720
	public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
721
	{
722
		global $conf, $langs, $hookmanager;
723
724
		if (!empty($conf->dol_no_mouse_hover)) {
725
			$notooltip = 1; // Force disable tooltips
726
		}
727
728
		$result = '';
729
730
		$label = img_picto('', $this->picto).' <u>'.$langs->trans("ConferenceOrBoothAttendee").'</u>';
731
		if (isset($this->status)) {
732
			$label .= ' '.$this->getLibStatut(5);
733
		}
734
		$label .= '<br>';
735
		$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
736
		$label .= '<br><b>'.$langs->trans('DateOfRegistration').':</b> '.dol_print_date($this->date_subscription, 'dayhour');
737
		$label .= '<br><b>'.$langs->trans('AmountPaid').':</b> '.$this->amount;
738
739
		$url = dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.$this->id;
740
741
		if ($option != 'nolink') {
742
			// Add param to save lastsearch_values or not
743
			$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
744
			if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
745
				$add_save_lastsearch_values = 1;
746
			}
747
			if ($add_save_lastsearch_values) {
748
				$url .= '&save_lastsearch_values=1';
749
			}
750
751
			if ($option == 'conforboothid') {
752
				$url .= '&conforboothid='.((int) $this->fk_actioncomm);
753
			}
754
755
			if ($option == 'projectid') {
756
				$url .= '&fk_project='.((int) $this->fk_project).'&withproject=1';
757
			}
758
759
			if ($option == 'conforboothidproject') {
760
				$url .= '&conforboothid='.((int) $this->fk_actioncomm).'&withproject=1' ;
761
			}
762
		}
763
764
		$linkclose = '';
765
		if (empty($notooltip)) {
766
			if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
767
				$label = $langs->trans("ShowConferenceOrBoothAttendee");
768
				$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
769
			}
770
			$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
771
			$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
772
		} else {
773
			$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
774
		}
775
776
		if ($option == 'nolink') {
777
			$linkstart = '<span';
778
		} else {
779
			$linkstart = '<a href="'.$url.'"';
780
		}
781
		$linkstart .= $linkclose.'>';
782
		if ($option == 'nolink') {
783
			$linkend = '</span>';
784
		} else {
785
			$linkend = '</a>';
786
		}
787
788
		$result .= $linkstart;
789
790
		if (empty($this->showphoto_on_popup)) {
791
			if ($withpicto) {
792
				$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);
793
			}
794
		} else {
795
			if ($withpicto) {
796
				require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
797
798
				list($class, $module) = explode('@', $this->picto);
799
				$upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
800
				$filearray = dol_dir_list($upload_dir, "files");
801
				$filename = $filearray[0]['name'];
802
				if (!empty($filename)) {
803
					$pospoint = strpos($filearray[0]['name'], '.');
804
805
					$pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
806
					if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
807
						$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>';
808
					} else {
809
						$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>';
810
					}
811
812
					$result .= '</div>';
813
				} else {
814
					$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);
815
				}
816
			}
817
		}
818
819
		if ($withpicto != 2) {
820
			$result .= $this->ref;
821
		}
822
823
		$result .= $linkend;
824
		//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
825
826
		global $action, $hookmanager;
827
		$hookmanager->initHooks(array('conferenceorboothattendeedao'));
828
		$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
829
		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
830
		if ($reshook > 0) {
831
			$result = $hookmanager->resPrint;
832
		} else {
833
			$result .= $hookmanager->resPrint;
834
		}
835
836
		return $result;
837
	}
838
839
	/**
840
	 *  Return the label of the status
841
	 *
842
	 *  @param  int		$mode          0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
843
	 *  @return	string 			       Label of status
844
	 */
845
	public function getLibStatut($mode = 0)
846
	{
847
		return $this->LibStatut($this->status, $mode);
848
	}
849
850
	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
851
	/**
852
	 *  Return the status
853
	 *
854
	 *  @param	int		$status        Id status
855
	 *  @param  int		$mode          0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
856
	 *  @return string 			       Label of status
857
	 */
858
	public function LibStatut($status, $mode = 0)
859
	{
860
		// phpcs:enable
861
		global $langs;
862
863
		if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
864
			//$langs->load("eventorganization@eventorganization");
865
			$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
866
			$this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated');
867
			$this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
868
			$this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft');
869
			$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Validated');
870
			$this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled');
871
		}
872
873
		$statusType = 'status'.$status;
874
		//if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
875
		if ($status == self::STATUS_CANCELED) {
876
			$statusType = 'status6';
877
		}
878
879
		if ($status == self::STATUS_VALIDATED && $this->date_subscription && $this->amount) {
880
			$statusType = 'status4';
881
			$this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated').' - '.$langs->trans("Paid");
882
		}
883
884
		return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
885
	}
886
887
	/**
888
	 *	Load the info information in the object
889
	 *
890
	 *	@param  int		$id       Id of object
891
	 *	@return	void
892
	 */
893
	public function info($id)
894
	{
895
		$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
896
		$sql .= ' fk_user_creat, fk_user_modif';
897
		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
898
		$sql .= ' WHERE t.rowid = '.((int) $id);
899
		$result = $this->db->query($sql);
900
		if ($result) {
901
			if ($this->db->num_rows($result)) {
902
				$obj = $this->db->fetch_object($result);
903
				$this->id = $obj->rowid;
904
				if ($obj->fk_user_author) {
905
					$cuser = new User($this->db);
906
					$cuser->fetch($obj->fk_user_author);
907
					$this->user_creation = $cuser;
908
				}
909
910
				if ($obj->fk_user_valid) {
911
					$vuser = new User($this->db);
912
					$vuser->fetch($obj->fk_user_valid);
913
					$this->user_validation = $vuser;
914
				}
915
916
				if ($obj->fk_user_cloture) {
917
					$cluser = new User($this->db);
918
					$cluser->fetch($obj->fk_user_cloture);
919
					$this->user_cloture = $cluser;
920
				}
921
922
				$this->date_creation     = $this->db->jdate($obj->datec);
923
				$this->date_modification = $this->db->jdate($obj->datem);
924
				$this->date_validation   = $this->db->jdate($obj->datev);
925
			}
926
927
			$this->db->free($result);
928
		} else {
929
			dol_print_error($this->db);
930
		}
931
	}
932
933
	/**
934
	 * Initialise object with example values
935
	 * Id must be 0 if object instance is a specimen
936
	 *
937
	 * @return void
938
	 */
939
	public function initAsSpecimen()
940
	{
941
		$this->initAsSpecimenCommon();
942
	}
943
944
	/**
945
	 * 	Create an array of lines
946
	 *
947
	 * 	@return array|int		array of lines if OK, <0 if KO
948
	 */
949
	public function getLinesArray()
950
	{
951
		$this->lines = array();
952
953
		$objectline = new ConferenceOrBoothAttendeeLine($this->db);
954
		$result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_conferenceorboothattendee = '.((int) $this->id)));
0 ignored issues
show
Bug introduced by
The method fetchAll() does not exist on ConferenceOrBoothAttendeeLine. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

954
		/** @scrutinizer ignore-call */ 
955
  $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_conferenceorboothattendee = '.((int) $this->id)));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
955
956
		if (is_numeric($result)) {
957
			$this->error = $this->error;
958
			$this->errors = $this->errors;
959
			return $result;
960
		} else {
961
			$this->lines = $result;
962
			return $this->lines;
963
		}
964
	}
965
966
	/**
967
	 *  Returns the reference to the following non used object depending on the active numbering module.
968
	 *
969
	 *  @return string      		Object free reference
970
	 */
971
	public function getNextNumRef()
972
	{
973
		global $langs, $conf;
974
		$langs->load("eventorganization@eventorganization");
975
976
		if (empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON)) {
977
			$conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON = 'mod_conferenceorboothattendee_standard';
978
		}
979
980
		if (!empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON)) {
981
			$mybool = false;
982
983
			$file = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON.".php";
984
			$classname = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON;
985
986
			// Include file with class
987
			$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
988
			foreach ($dirmodels as $reldir) {
989
				$dir = dol_buildpath($reldir."core/modules/eventorganization/");
990
991
				// Load file with numbering class (if found)
992
				$mybool |= @include_once $dir.$file;
993
			}
994
995
			if ($mybool === false) {
996
				dol_print_error('', "Failed to include file ".$file);
997
				return '';
998
			}
999
1000
			if (class_exists($classname)) {
1001
				$obj = new $classname();
1002
				$numref = $obj->getNextValue($this);
1003
1004
				if ($numref != '' && $numref != '-1') {
1005
					return $numref;
1006
				} else {
1007
					$this->error = $obj->error;
1008
					//dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
1009
					return "";
1010
				}
1011
			} else {
1012
				print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
1013
				return "";
1014
			}
1015
		} else {
1016
			print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
1017
			return "";
1018
		}
1019
	}
1020
1021
	/**
1022
	 *  Create a document onto disk according to template module.
1023
	 *
1024
	 *  @param	    string		$modele			Force template to use ('' to not force)
1025
	 *  @param		Translate	$outputlangs	objet lang a utiliser pour traduction
1026
	 *  @param      int			$hidedetails    Hide details of lines
1027
	 *  @param      int			$hidedesc       Hide description
1028
	 *  @param      int			$hideref        Hide ref
1029
	 *  @param      null|array  $moreparams     Array to provide more information
1030
	 *  @return     int         				0 if KO, 1 if OK
1031
	 */
1032
	public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1033
	{
1034
		global $conf, $langs;
1035
1036
		$result = 0;
1037
		$includedocgeneration = 0;
1038
1039
		$langs->load("eventorganization@eventorganization");
1040
1041
		if (!dol_strlen($modele)) {
1042
			$modele = 'standard_conferenceorboothattendee';
1043
1044
			if (!empty($this->model_pdf)) {
1045
				$modele = $this->model_pdf;
1046
			} elseif (!empty($conf->global->CONFERENCEORBOOTHATTENDEE_ADDON_PDF)) {
1047
				$modele = $conf->global->CONFERENCEORBOOTHATTENDEE_ADDON_PDF;
1048
			}
1049
		}
1050
1051
		$modelpath = "core/modules/eventorganization/doc/";
1052
1053
		if ($includedocgeneration && !empty($modele)) {
1054
			$result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1055
		}
1056
1057
		return $result;
1058
	}
1059
1060
	/**
1061
	 * Action executed by scheduler
1062
	 * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters'
1063
	 * Use public function doScheduledJob($param1, $param2, ...) to get parameters
1064
	 *
1065
	 * @return	int			0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
1066
	 */
1067
	public function doScheduledJob()
1068
	{
1069
		global $conf, $langs;
1070
1071
		//$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
1072
1073
		$error = 0;
1074
		$this->output = '';
1075
		$this->error = '';
1076
1077
		dol_syslog(__METHOD__, LOG_DEBUG);
1078
1079
		$now = dol_now();
1080
1081
		$this->db->begin();
1082
1083
		// ...
1084
1085
		$this->db->commit();
1086
1087
		return $error;
1088
	}
1089
1090
	/**
1091
	 * Function used to replace a thirdparty id with another one.
1092
	 *
1093
	 * @param DoliDB $db Database handler
1094
	 * @param int $origin_id Old thirdparty id
1095
	 * @param int $dest_id New thirdparty id
1096
	 * @return bool
1097
	 */
1098
	public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
1099
	{
1100
		$tables = array(
1101
			'eventorganization_conferenceorboothattendee'
1102
		);
1103
1104
		return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
1105
	}
1106
}
1107
1108
1109
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1110
1111
/**
1112
 * Class ConferenceOrBoothAttendeeLine. You can also remove this and generate a CRUD class for lines objects.
1113
 */
1114
class ConferenceOrBoothAttendeeLine extends CommonObjectLine
1115
{
1116
	// To complete with content of an object ConferenceOrBoothAttendeeLine
1117
	// We should have a field rowid, fk_conferenceorboothattendee and position
1118
1119
	/**
1120
	 * @var int  Does object support extrafields ? 0=No, 1=Yes
1121
	 */
1122
	public $isextrafieldmanaged = 0;
1123
1124
	/**
1125
	 * Constructor
1126
	 *
1127
	 * @param DoliDb $db Database handler
1128
	 */
1129
	public function __construct(DoliDB $db)
1130
	{
1131
		$this->db = $db;
1132
	}
1133
}
1134