26require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
27require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
38 public $module =
'eventorganization';
43 public $element =
'conferenceorbooth';
48 public $table_element =
'actioncomm';
54 public $ismultientitymanaged = 1;
59 public $isextrafieldmanaged = 1;
64 public $picto =
'conferenceorbooth';
67 const STATUS_DRAFT = 0;
68 const STATUS_SUGGESTED = 1;
69 const STATUS_CONFIRMED = 2;
70 const STATUS_NOT_QUALIFIED = 3;
71 const STATUS_DONE = 4;
72 const STATUS_CANCELED = 9;
105 public $fields = array(
106 'id' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>
'1',
'position'=>1,
'notnull'=>1,
'visible'=>0,
'noteditable'=>
'1',
'index'=>1,
'css'=>
'left',
'csslist'=>
'left',
'comment'=>
"Id"),
107 'ref' => array(
'type'=>
'integer',
'label'=>
'Ref',
'enabled'=>
'1',
'position'=>1,
'notnull'=>1,
'visible'=>2,
'noteditable'=>
'1',
'index'=>1,
'css'=>
'left',
'csslist'=>
'left',
'comment'=>
"Id"),
108 'label' => array(
'type'=>
'varchar(255)',
'label'=>
'Label',
'enabled'=>
'1',
'position'=>30,
'notnull'=>1,
'visible'=>1,
'searchall'=>1,
'css'=>
'minwidth300',
'csslist'=>
'tdoverflowmax150',
'help'=>
"OrganizationEvenLabelName",
'showoncombobox'=>
'1',
'autofocusoncreate'=>1),
109 'fk_project' => array(
'type'=>
'integer:Project:projet/class/project.class.php:1:(t.usage_organize_event:=:1)',
'label'=>
'Project',
'enabled'=>
"isModEnabled('project')",
'position'=>52,
'notnull'=>-1,
'visible'=>1,
'index'=>1,
'picto'=>
'project',
'css'=>
'maxwidth500',
'csslist'=>
'tdoverflowmax100'),
110 'fk_soc' => array(
'type'=>
'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))',
'label'=>
'ThirdParty',
'enabled'=>
'$conf->societe->enabled',
'position'=>50,
'notnull'=>-1,
'visible'=>1,
'index'=>1,
'help'=>
"OrganizationEventLinkToThirdParty",
'picto'=>
'company',
'csslist'=>
'tdoverflowmax100',
'css'=>
'maxwidth500'),
111 'note' => array(
'type'=>
'html',
'label'=>
'Description',
'enabled'=>
'1',
'position'=>60,
'notnull'=>0,
'visible'=>3),
112 'fk_action' => array(
'type'=>
"sellist:c_actioncomm:libelle:id::module LIKE '%@eventorganization'",
'label'=>
'Format',
'enabled'=>
'1',
'position'=>60,
'notnull'=>1,
'visible'=>1,
'css'=>
'width100',
'csslist'=>
'tdoverflowmax100 maxwidth75'),
113 'datep' => array(
'type'=>
'datetime',
'label'=>
'DateStart',
'enabled'=>
'1',
'position'=>70,
'notnull'=>0,
'visible'=>1,
'showoncombobox'=>
'2',),
114 'datep2' => array(
'type'=>
'datetime',
'label'=>
'DateEnd',
'enabled'=>
'1',
'position'=>71,
'notnull'=>0,
'visible'=>1,
'showoncombobox'=>
'3',),
115 'datec' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>
'1',
'position'=>500,
'notnull'=>1,
'visible'=>-2,
'csslist'=>
'nowraponall'),
116 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>
'1',
'position'=>501,
'notnull'=>0,
'visible'=>-2,
'csslist'=>
'nowraponall'),
117 'fk_user_author' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserAuthor',
'enabled'=>
'1',
'position'=>510,
'notnull'=>1,
'visible'=>-2,
'foreignkey'=>
'user.rowid',
'csslist'=>
'tdoverflowmax100'),
118 'fk_user_mod' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>
'1',
'position'=>511,
'notnull'=>-1,
'visible'=>-2,
'csslist'=>
'tdoverflowmax100'),
119 'num_vote' => array(
'type'=>
'smallint',
'label'=>
'NbVotes',
'enabled'=>
'1',
'position'=>800,
'notnull'=>-1,
'visible'=>5,
'default'=>
'0',
'index'=>0),
120 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>
'1',
'position'=>1000,
'notnull'=>-1,
'visible'=>-2,),
121 'status' => array(
'type'=>
'smallint',
'label'=>
'Status',
'enabled'=>
'1',
'position'=>1000,
'notnull'=>1,
'visible'=>1,
'default'=>
'0',
'index'=>1,
'arrayofkeyval'=>array(
'0'=>
'EvntOrgDraft',
'1'=>
'EvntOrgSuggested',
'2'=>
'EvntOrgConfirmed',
'3' =>
'EvntOrgNotQualified',
'4' =>
'EvntOrgDone',
'9'=>
'EvntOrgCancelled'),),
132 public $fk_user_author;
148 global $conf, $langs;
152 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid'])) {
153 $this->fields[
'id'][
'visible'] = 0;
155 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
156 $this->fields[
'entity'][
'enabled'] = 0;
160 foreach ($this->fields as $key => $val) {
161 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
162 unset($this->fields[$key]);
167 if (is_object($langs)) {
168 foreach ($this->fields as $key => $val) {
169 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
170 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
171 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
189 return parent::create($user, $notrigger);
199 if ($this->status == self::STATUS_DONE) {
200 $this->percentage = 100;
202 if ($this->status == self::STATUS_DRAFT) {
203 $this->percentage = 0;
215 $this->userownerid = $user->id;
216 $this->type_id = $this->fk_action;
217 $this->socid = $this->fk_soc;
218 $this->datef = $this->datep2;
219 $this->note_private = $this->note;
229 $this->fk_action = $this->type_id;
230 $this->fk_soc = $this->socid;
231 $this->datep2 = $this->datef;
244 public function fetch($id, $ref =
null, $ref_ext =
'', $email_msgid =
'', $loadresources = 1)
246 global $dolibarr_main_url_root, $conf, $langs;
248 $result = parent::fetch($id, $ref, $ref_ext, $email_msgid);
250 $link_subscription = $dolibarr_main_url_root.
'/public/eventorganization/attendee_new.php?id='.urlencode($id).
'&type=conf';
253 $link_subscription .=
'&securekey='.urlencode($encodedsecurekey);
273 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
284 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
285 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as cact ON cact.id=t.fk_action AND cact.module LIKE '%@eventorganization'";
286 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
287 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
289 $sql .=
' WHERE 1 = 1';
293 if (count($filter) > 0) {
294 foreach ($filter as $key => $value) {
295 if ($key ==
't.id' || $key ==
't.fk_project' || $key ==
't.fk_soc' || $key ==
't.fk_action') {
296 $sqlwhere[] = $key.
" = ".((int) $value);
297 } elseif (in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
298 $sqlwhere[] = $key.
" = '".$this->db->idate($value).
"'";
299 } elseif ($key ==
'customsql') {
300 $sqlwhere[] = $value;
301 } elseif (strpos($value,
'%') ===
false) {
302 $sqlwhere[] = $key.
' IN ('.$this->db->sanitize($this->db->escape($value)).
')';
304 $sqlwhere[] = $key.
" LIKE '%".$this->db->escape($value).
"%'";
308 if (count($sqlwhere) > 0) {
309 $sql .=
' AND ('.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
312 if (!empty($sortfield)) {
313 $sql .= $this->db->order($sortfield, $sortorder);
315 if (!empty($limit)) {
316 $sql .= $this->db->plimit($limit, $offset);
319 $resql = $this->db->query($sql);
321 $num = $this->db->num_rows($resql);
323 while ($i < ($limit ? min($limit, $num) : $num)) {
324 $obj = $this->db->fetch_object($resql);
326 $record =
new self($this->db);
327 $record->setVarsFromFetchObj($obj);
329 $records[$record->id] = $record;
333 $this->db->free($resql);
337 $this->errors[] =
'Error '.$this->db->lasterror();
338 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
355 return parent::update($user, $notrigger);
364 public function delete($notrigger =
false)
367 return parent::delete($notrigger);
379 global $conf, $langs;
381 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
386 if ($this->status == self::STATUS_CONFIRMED) {
387 dol_syslog(get_class($this).
"::validate action abandonned: already validated", LOG_WARNING);
396 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
397 $sql .=
" status = ".self::STATUS_CONFIRMED;
398 $sql .=
" WHERE id = ".$this->id;
400 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
401 $resql = $this->db->query($sql);
404 $this->error = $this->db->lasterror();
408 if (!$error && !$notrigger) {
410 $result = $this->
call_trigger(
'CONFERENCEORBOOTH_VALIDATE', $user);
419 $this->status = self::STATUS_CONFIRMED;
426 $this->db->rollback();
442 if ($this->status <= self::STATUS_DRAFT) {
453 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'CONFERENCEORBOOTH_UNVALIDATE');
463 public function cancel($user, $notrigger = 0)
466 if ($this->status != self::STATUS_CONFIRMED) {
477 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'CONFERENCEORBOOTH_CANCEL');
487 public function reopen($user, $notrigger = 0)
490 if ($this->status != self::STATUS_CANCELED) {
501 return $this->
setStatusCommon($user, self::STATUS_CONFIRMED, $notrigger,
'CONFERENCEORBOOTH_REOPEN');
517 public function getNomUrl($withpicto = 0, $maxlength = 0, $classname =
'', $option =
'', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1, $morecss =
'')
519 global $conf, $langs, $hookmanager;
521 if (!empty($conf->dol_no_mouse_hover)) {
527 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"ConferenceOrBooth").
'</u>';
528 if (isset($this->status)) {
529 $label .=
' '.$this->getLibStatut(5);
532 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->id;
534 $url = DOL_URL_ROOT.
'/eventorganization/conferenceorbooth_card.php?id='.$this->id;
536 if ($option !=
'nolink') {
538 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
539 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
540 $add_save_lastsearch_values = 1;
542 if ($add_save_lastsearch_values) {
543 $url .=
'&save_lastsearch_values=1';
545 if ($option ==
'withproject') {
546 $url .=
'&withproject=1';
551 if (empty($notooltip)) {
552 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
553 $label = $langs->trans(
"ShowConferenceOrBooth");
554 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
557 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
559 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
562 $linkstart =
'<a href="'.$url.
'"';
563 $linkstart .= $linkclose.
'>';
566 $result .= $linkstart;
568 if (empty($this->showphoto_on_popup)) {
570 $picto =
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
576 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
581 $filename = $filearray[0][
'name'];
582 if (!empty($filename)) {
583 $pospoint = strpos($filearray[0][
'name'],
'.');
585 $pathtophoto =
'/'.$this->ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
586 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=eventorganisation&entity='.$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div>';
590 $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);
595 if ($withpicto != 2) {
596 $result .= $this->ref;
602 global $action, $hookmanager;
603 $hookmanager->initHooks(array(
'conferenceorboothdao'));
604 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
605 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
607 $result = $hookmanager->resPrint;
609 $result .= $hookmanager->resPrint;
638 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
641 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
642 $this->labelStatus[self::STATUS_SUGGESTED] = $langs->transnoentitiesnoconv(
'Suggested');
643 $this->labelStatus[self::STATUS_CONFIRMED] = $langs->transnoentitiesnoconv(
'Confirmed');
644 $this->labelStatus[self::STATUS_NOT_QUALIFIED] = $langs->transnoentitiesnoconv(
'NotSelected');
645 $this->labelStatus[self::STATUS_DONE] = $langs->transnoentitiesnoconv(
'Done');
646 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Canceled');
647 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
648 $this->labelStatusShort[self::STATUS_SUGGESTED] = $langs->transnoentitiesnoconv(
'Suggested');
649 $this->labelStatusShort[self::STATUS_CONFIRMED] = $langs->transnoentitiesnoconv(
'Confirmed');
650 $this->labelStatusShort[self::STATUS_NOT_QUALIFIED] = $langs->transnoentitiesnoconv(
'NotSelected');
651 $this->labelStatusShort[self::STATUS_DONE] = $langs->transnoentitiesnoconv(
'Done');
652 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Canceled');
655 $statusType =
'status'.$status;
657 if ($status == self::STATUS_CANCELED) {
658 $statusType =
'status6';
661 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
673 global $conf, $langs;
675 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
677 $return =
'<div class="box-flex-item box-flex-grow-zero">';
678 $return .=
'<div class="info-box info-box-sm">';
679 $return .=
'<span class="info-box-icon bg-infobox-action">';
681 $return .=
'</span>';
682 $return .=
'<div class="info-box-content">';
683 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
684 if ($selected >= 0) {
685 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
687 if (property_exists($this,
'label')) {
688 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
690 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
691 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
693 if (property_exists($this,
'amount')) {
695 $return .=
'<span class="info-box-label amount">'.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).
'</span>';
697 if (method_exists($this,
'getLibStatut')) {
698 $return .=
'<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3).
'</div>';
715 $sql =
'SELECT rowid, datec as datec, tms as datem,';
716 $sql .=
' fk_user_author, fk_user_mod';
717 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
718 $sql .=
' WHERE t.id = '.((int) $id);
719 $result = $this->db->query($sql);
721 if ($this->db->num_rows($result)) {
722 $obj = $this->db->fetch_object($result);
723 $this->
id = $obj->rowid;
725 $this->user_creation_id = $obj->fk_user_creat;
726 $this->user_modification_id = $obj->fk_user_modif;
727 $this->date_creation = $this->db->jdate($obj->datec);
728 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
731 $this->db->free($result);
759 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
761 global $conf, $langs;
764 $includedocgeneration = 0;
766 $langs->load(
"eventorganization@eventorganization");
769 $modele =
'standard_conferenceorbooth';
771 if (!empty($this->model_pdf)) {
772 $modele = $this->model_pdf;
773 } elseif (!empty($conf->global->CONFERENCEORBOOTH_ADDON_PDF)) {
774 $modele = $conf->global->CONFERENCEORBOOTH_ADDON_PDF;
778 $modelpath =
"core/modules/eventorganization/doc/";
780 if ($includedocgeneration && !empty($modele)) {
781 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
796 global $conf, $langs;
Class to manage agenda events (actions)
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
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.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class for ConferenceOrBooth.
getNomUrl($withpicto=0, $maxlength=0, $classname='', $option='', $overwritepicto=0, $notooltip=0, $save_lastsearch_value=-1, $morecss='')
Return a link to the object card (with optionaly the picto)
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
getActionCommFields()
Get action comm fields.
info($id)
Load the info information in the object.
reopen($user, $notrigger=0)
Set back to validated status.
fetch($id, $ref=null, $ref_ext='', $email_msgid='', $loadresources=1)
Load object in memory from the database.
setPercentageFromStatus()
Set Percentage from status.
setDraft($user, $notrigger=0)
Set draft status.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
update(User $user, $notrigger=false)
Update object into database.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
create(User $user, $notrigger=false)
Create object into database.
cancel($user, $notrigger=0)
Set cancel status.
LibStatutEvent($status, $mode=0)
Return the status.
setActionCommFields(User $user)
Set action comm fields.
__construct(DoliDB $db)
Constructor.
getLibStatut($mode=0, $hidenastatus=0)
Return the label of the status.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
validate($user, $notrigger=0)
Validate object.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
dol_dir_list($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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.