27require_once DOL_DOCUMENT_ROOT.
"/core/class/commonobject.class.php";
28require_once DOL_DOCUMENT_ROOT.
"/core/lib/functions2.lib.php";
29require_once DOL_DOCUMENT_ROOT.
'/core/class/commonpeople.class.php';
41 public $element =
'dolresource';
46 public $table_element =
'resource';
51 public $picto =
'resource';
71 public $fk_code_type_resource;
89 public $resource_type;
102 public $element_type;
117 public $fulldayevent;
122 public $fk_user_create;
132 public $cache_code_type_resource;
145 $this->cache_code_type_resource = array();
160 $this->date_creation =
dol_now();
163 $new_resource_values = [
175 $this->fk_code_type_resource,
179 foreach ($new_resource_values as $key => $value) {
181 $new_resource_values[$key] = trim($value);
186 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.$this->table_element.
"(";
192 $sql .=
"fk_country,";
194 $sql .=
"description,";
197 $sql .=
"max_users,";
199 $sql .=
"fk_code_type_resource,";
200 $sql .=
"note_public,";
201 $sql .=
"note_private, ";
203 $sql .=
"fk_user_author ";
204 $sql .=
") VALUES (";
205 $sql .= (int) (empty($this->entity) ? ((int)
$conf->entity) : ((int) $this->entity)) .
", ";
206 foreach ($new_resource_values as $value) {
207 $sql .=
" " . (!empty($value) ?
"'" . $this->db->escape($value) .
"'" :
'NULL') .
",";
209 $sql .=
" '" . $this->db->idate($this->date_creation) .
"',";
210 $sql .=
" " . (!empty($user->id) ? ((int) $user->id) :
"null");
216 dol_syslog(get_class($this) .
"::create", LOG_DEBUG);
218 error_log(
'dol_syslog error: ' . $exception->getMessage());
220 $resql = $this->db->query($sql);
223 $this->errors[] =
"Error ".$this->db->lasterror();
227 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
234 if (!$error && !$no_trigger) {
235 $result = $this->call_trigger(
'RESOURCE_CREATE', $user);
243 foreach ($this->errors as $errmsg) {
245 dol_syslog(get_class($this) .
"::create " . $errmsg, LOG_ERR);
247 error_log(
'dol_syslog error: ' . $exception->getMessage());
249 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
251 $this->db->rollback();
266 public function fetch(
int $id,
string $ref =
'')
270 $sql .=
" t.entity,";
272 $sql .=
" t.address,";
275 $sql .=
" t.fk_country,";
276 $sql .=
" t.fk_state,";
277 $sql .=
" t.description,";
280 $sql .=
" t.max_users,";
282 $sql .=
" t.fk_code_type_resource,";
283 $sql .=
" t.note_public,";
284 $sql .=
" t.note_private,";
285 $sql .=
" t.tms as date_modification,";
286 $sql .=
" t.datec as date_creation,";
287 $sql .=
" ty.label as type_label";
288 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
289 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_type_resource as ty ON ty.code=t.fk_code_type_resource";
291 $sql .=
" WHERE t.rowid = ".((int)
$id);
293 $sql .=
" WHERE t.ref = '".$this->db->escape($ref).
"'";
296 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
297 $resql = $this->db->query($sql);
299 if ($this->db->num_rows($resql)) {
300 $obj = $this->db->fetch_object($resql);
302 $this->
id = $obj->rowid;
303 $this->entity = $obj->entity;
304 $this->
ref = $obj->ref;
305 $this->
address = $obj->address;
306 $this->zip = $obj->zip;
307 $this->town = $obj->town;
308 $this->country_id = $obj->fk_country;
309 $this->state_id = $obj->fk_state;
311 $this->phone = $obj->phone;
312 $this->
email = $obj->email;
313 $this->max_users = $obj->max_users;
314 $this->url = $obj->url;
315 $this->fk_code_type_resource = $obj->fk_code_type_resource;
316 $this->note_public = $obj->note_public;
317 $this->note_private = $obj->note_private;
318 $this->date_creation = $this->db->jdate($obj->date_creation);
319 $this->date_modification = $this->db->jdate($obj->date_modification);
320 $this->type_label = $obj->type_label;
326 $this->db->free($resql);
330 $this->error =
"Error ".$this->db->lasterror();
331 dol_syslog(get_class($this).
"::fetch ".$this->error, LOG_ERR);
344 public function update($user =
null,
int $notrigger = 0)
346 global
$conf, $langs;
348 $this->date_modification =
dol_now();
351 if (isset($this->
ref)) {
352 $this->
ref = trim($this->
ref);
357 if (isset($this->zip)) {
358 $this->zip = trim($this->zip);
360 if (isset($this->town)) {
361 $this->town = trim($this->town);
363 if (!is_numeric($this->country_id)) {
364 $this->country_id = 0;
366 if (!is_numeric($this->state_id)) {
372 if (isset($this->phone)) {
373 $this->phone = trim($this->phone);
375 if (isset($this->
email)) {
378 if (isset($this->url)) {
379 $this->url = trim($this->url);
381 if (isset($this->fk_code_type_resource)) {
382 $this->fk_code_type_resource = trim($this->fk_code_type_resource);
384 if (isset($this->note_public)) {
385 $this->note_public = trim($this->note_public);
387 if (isset($this->note_private)) {
388 $this->note_private = trim($this->note_private);
392 if (is_null($this->oldcopy) || (is_object($this->oldcopy) && $this->oldcopy->isEmpty())) {
397 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element.
" SET";
398 $sql .=
" ref=".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"null").
",";
399 $sql .=
" address=".(isset($this->
address) ?
"'".$this->db->escape($this->
address).
"'" :
"null").
",";
400 $sql .=
" zip=".(isset($this->zip) ?
"'".$this->db->escape($this->zip).
"'" :
"null").
",";
401 $sql .=
" town=".(isset($this->town) ?
"'".$this->db->escape($this->town).
"'" :
"null").
",";
402 $sql .=
" fk_country=".($this->country_id > 0 ? (int) $this->country_id :
"null").
",";
403 $sql .=
" fk_state=".($this->state_id > 0 ? (int) $this->state_id :
"null").
",";
404 $sql .=
" description=".(isset($this->
description) ?
"'".$this->db->escape($this->
description).
"'" :
"null").
",";
405 $sql .=
" phone=".(isset($this->phone) ?
"'".$this->db->escape($this->phone).
"'" :
"null").
",";
406 $sql .=
" email=".(isset($this->
email) ?
"'".$this->db->escape($this->
email).
"'" :
"null").
",";
407 $sql .=
" max_users=".(isset($this->max_users) ? (int) $this->max_users :
"null").
",";
408 $sql .=
" url=".(isset($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null").
",";
409 $sql .=
" fk_code_type_resource=".(isset($this->fk_code_type_resource) ?
"'".$this->db->escape($this->fk_code_type_resource).
"'" :
"null").
",";
410 $sql .=
" note_public=".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
411 $sql .=
" note_private=".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
412 $sql .=
" tms=" . (
"'" . $this->db->idate($this->date_modification) .
"',");
413 $sql .=
" fk_user_modif=" . (!empty($user->id) ? ((int) $user->id) :
"null");
414 $sql .=
" WHERE rowid=".((int) $this->
id);
418 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
419 $resql = $this->db->query($sql);
422 $this->errors[] =
"Error ".$this->db->lasterror();
425 if (!$error && $user !==
null) {
428 $result = $this->call_trigger(
'RESOURCE_MODIFY', $user);
436 if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) {
438 if (!empty(
$conf->resource->dir_output)) {
441 if (file_exists($olddir)) {
442 $res = @rename($olddir, $newdir);
444 $langs->load(
"errors");
445 $this->error = $langs->trans(
'ErrorFailToRenameDir', $olddir, $newdir);
462 foreach ($this->errors as $errmsg) {
463 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
464 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
466 $this->db->rollback();
484 $sql .=
" t.resource_id,";
485 $sql .=
" t.resource_type,";
486 $sql .=
" t.element_id,";
487 $sql .=
" t.element_type,";
489 $sql .=
" t.mandatory,";
490 $sql .=
" t.fk_user_create,";
491 $sql .=
" t.tms as date_modification";
492 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as t";
493 $sql .=
" WHERE t.rowid = ".((int)
$id);
495 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
496 $resql = $this->db->query($sql);
498 if ($this->db->num_rows($resql)) {
499 $obj = $this->db->fetch_object($resql);
501 $this->
id = $obj->rowid;
502 $this->resource_id = $obj->resource_id;
503 $this->resource_type = $obj->resource_type;
504 $this->element_id = $obj->element_id;
505 $this->element_type = $obj->element_type;
506 $this->busy = $obj->busy;
507 $this->mandatory = $obj->mandatory;
508 $this->fk_user_create = $obj->fk_user_create;
509 $this->date_modification = $obj->date_modification;
514 if ($obj->element_id && $obj->element_type) {
515 $this->objelement = fetchObjectByElement($obj->element_id, $obj->element_type);
518 $this->db->free($resql);
522 $this->error =
"Error ".$this->db->lasterror();
534 public function delete(
User $user,
int $notrigger = 0)
538 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
546 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
547 $sql .=
" WHERE rowid = ".((int) $rowid);
550 if ($this->db->query($sql)) {
551 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"element_resources";
552 $sql .=
" WHERE element_type='resource' AND resource_id = ".((int) $rowid);
553 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
554 $resql = $this->db->query($sql);
556 $this->error = $this->db->lasterror();
560 $this->error = $this->db->lasterror();
569 dol_syslog(get_class($this).
"::delete error -3 ".$this->error, LOG_ERR);
575 $result = $this->call_trigger(
'RESOURCE_DELETE', $user);
585 if (!empty(
$conf->resource->dir_output)) {
587 if (file_exists($dir)) {
590 $this->errors[] =
'ErrorFailToDeleteDir';
601 $this->db->rollback();
616 public function fetchAll(
string $sortorder,
string $sortfield,
int $limit,
int $offset, $filter =
'')
618 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
623 $sql .=
" t.entity,";
625 $sql .=
" t.address,";
628 $sql .=
" t.fk_country,";
629 $sql .=
" t.fk_state,";
630 $sql .=
" t.description,";
633 $sql .=
" t.max_users,";
635 $sql .=
" t.fk_code_type_resource,";
636 $sql .=
" t.tms as date_modification,";
637 $sql .=
" t.datec as date_creation,";
639 if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element][
'label'])) {
640 foreach ($extrafields->attributes[$this->table_element][
'label'] as $key => $val) {
641 $sql .= ($extrafields->attributes[$this->table_element][
'type'][$key] !=
'separate' ?
"ef.".$key.
" as options_".$key.
', ' :
'');
644 $sql .=
" ty.label as type_label";
645 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
646 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_type_resource as ty ON ty.code=t.fk_code_type_resource";
647 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element.
"_extrafields as ef ON ef.fk_object=t.rowid";
648 $sql .=
" WHERE t.entity IN (".getEntity(
'resource').
")";
651 if (is_array($filter)) {
652 foreach ($filter as $key => $value) {
653 if (strpos($key,
'date')) {
654 $sql .=
" AND ".$this->db->sanitize($key).
" = '".$this->db->idate($value).
"'";
655 } elseif (strpos($key,
'ef.') !==
false) {
656 $sql .=
" AND ".$this->db->sanitize($key).
" = ".((float) $value);
658 $sql .=
" AND ".$this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
669 $this->errors[] = $errormessage;
670 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
674 $sql .= $this->db->order($sortfield, $sortorder);
676 $sql .= $this->db->plimit($limit, $offset);
679 dol_syslog(get_class($this).
"::fetchAll", LOG_DEBUG);
681 $this->lines = array();
682 $resql = $this->db->query($sql);
684 $num = $this->db->num_rows($resql);
686 while ($obj = $this->db->fetch_object($resql)) {
688 $line->id = $obj->rowid;
689 $line->ref = $obj->ref;
690 $line->address = $obj->address;
691 $line->zip = $obj->zip;
692 $line->town = $obj->town;
693 $line->country_id = $obj->fk_country;
694 $line->state_id = $obj->fk_state;
695 $line->description = $obj->description;
696 $this->phone = $obj->phone;
697 $this->
email = $obj->email;
698 $this->max_users = $obj->max_users;
699 $this->url = $obj->url;
700 $line->fk_code_type_resource = $obj->fk_code_type_resource;
701 $line->date_modification = $obj->date_modification;
702 $line->date_creation = $obj->date_creation;
703 $line->type_label = $obj->type_label;
707 $line->fetch_optionals();
709 $this->lines[] = $line;
711 $this->db->free($resql);
715 $this->error = $this->db->lasterror();
730 $this->date_modification =
dol_now();
733 if (!is_numeric($this->resource_id)) {
734 $this->resource_id = 0;
736 if (isset($this->resource_type)) {
737 $this->resource_type = trim($this->resource_type);
739 if (!is_numeric($this->element_id)) {
740 $this->element_id = 0;
742 if (isset($this->element_type)) {
743 $this->element_type = trim($this->element_type);
745 if (isset($this->busy)) {
746 $this->busy = (int) $this->busy;
748 if (isset($this->mandatory)) {
749 $this->mandatory = (int) $this->mandatory;
753 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"element_resources SET";
754 $sql .=
" resource_id = ".(isset($this->resource_id) ? (int) $this->resource_id :
"null").
",";
755 $sql .=
" resource_type = ".(isset($this->resource_type) ?
"'".$this->db->escape($this->resource_type).
"'" :
"null").
",";
756 $sql .=
" element_id = ".(isset($this->element_id) ? (int) $this->element_id :
"null").
",";
757 $sql .=
" element_type = ".(isset($this->element_type) ?
"'".$this->db->escape($this->element_type).
"'" :
"null").
",";
758 $sql .=
" busy = ".(isset($this->busy) ? (int) $this->busy :
"null").
",";
759 $sql .=
" mandatory = ".(isset($this->mandatory) ? (int) $this->mandatory :
"null").
",";
760 $sql .=
" tms = ".(dol_strlen((
string) $this->date_modification) != 0 ?
"'".$this->db->idate($this->date_modification).
"'" :
'null');
761 $sql .=
" WHERE rowid=".((int) $this->
id);
765 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
766 $resql = $this->db->query($sql);
769 $this->errors[] =
"Error ".$this->db->lasterror();
772 if (!$error && $user !==
null) {
775 $result = $this->call_trigger(
'RESOURCE_MODIFY', $user);
785 foreach ($this->errors as $errmsg) {
786 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
787 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
789 $this->db->rollback();
809 $sql =
'SELECT rowid, resource_id, resource_type, busy, mandatory';
810 $sql .=
' FROM '.MAIN_DB_PREFIX.
'element_resources';
811 $sql .=
" WHERE element_id=".((int) $element_id).
" AND element_type='".$this->db->escape($element).
"'";
812 if ($resource_type) {
813 $sql .=
" AND resource_type LIKE '%".$this->db->escape($resource_type).
"%'";
815 $sql .=
' ORDER BY resource_type';
817 dol_syslog(get_class($this).
"::getElementResources", LOG_DEBUG);
819 $resources = array();
820 $resql = $this->db->query($sql);
822 $num = $this->db->num_rows($resql);
825 $obj = $this->db->fetch_object($resql);
827 $resources[$i] = array(
828 'rowid' => $obj->rowid,
829 'resource_id' => $obj->resource_id,
830 'resource_type' => $obj->resource_type,
831 'busy' => $obj->busy,
832 'mandatory' => $obj->mandatory
852 foreach ($resources as $resource) {
853 $this->lines[$i] = fetchObjectByElement($resource[
'resource_id'], $resource[
'resource_type']);
868 if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) {
872 $sql =
"SELECT rowid, code, label, active";
873 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_resource";
874 $sql .=
" WHERE active > 0";
875 $sql .=
" ORDER BY rowid";
876 dol_syslog(get_class($this).
"::load_cache_code_type_resource", LOG_DEBUG);
877 $resql = $this->db->query($sql);
879 $num = $this->db->num_rows($resql);
882 $obj = $this->db->fetch_object($resql);
884 $label = ($langs->trans(
"ResourceTypeShort".$obj->code) !=
"ResourceTypeShort".$obj->code ? $langs->trans(
"ResourceTypeShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
885 $this->cache_code_type_resource[$obj->rowid][
'code'] = $obj->code;
886 $this->cache_code_type_resource[$obj->rowid][
'label'] = $label;
887 $this->cache_code_type_resource[$obj->rowid][
'active'] = $obj->active;
907 $langs->load(
'resource');
911 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Resource").
'</u>';
912 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
916 if (isset($this->type_label)) {
917 $datas[
'label'] =
'<br><b>'.$langs->trans(
"ResourceType").
":</b> ".$this->type_label;
934 public function getNomUrl($withpicto = 0,
string $option =
'',
string $get_params =
'',
int $notooltip = 0,
string $morecss =
'',
int $save_lastsearch_value = -1)
936 global $langs, $hookmanager, $action;
941 'objecttype' => $this->element,
943 $classfortooltip =
'classfortooltip';
946 $classfortooltip =
'classforajaxtooltip';
947 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
953 $url = DOL_URL_ROOT.
'/resource/card.php?id='.$this->id;
955 if ($option !=
'nolink') {
957 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
958 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
959 $add_save_lastsearch_values = 1;
961 if ($add_save_lastsearch_values) {
962 $url .=
'&save_lastsearch_values=1';
967 if (empty($notooltip)) {
969 $label = $langs->trans(
"ShowResource");
970 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
972 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
973 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
975 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
978 $linkstart =
'<a href="'.$url.$get_params.
'"';
979 $linkstart .= $linkclose.
'>';
984 $result .= $linkstart;
986 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ?:
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
988 if ($withpicto != 2) {
989 $result .= $this->ref;
993 $hookmanager->initHooks(array($this->element .
'dao'));
994 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
995 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
997 $result = $hookmanager->resPrint;
999 $result .= $hookmanager->resPrint;
1035 $this->nb = array();
1037 $sql =
"SELECT count(r.rowid) as nb";
1038 $sql .=
" FROM ".MAIN_DB_PREFIX.
"resource as r";
1039 $sql .=
" WHERE r.entity IN (".getEntity(
'resource').
")";
1041 $resql = $this->db->query($sql);
1043 while ($obj = $this->db->fetch_object($resql)) {
1044 $this->nb[
"dolresource"] = $obj->nb;
1046 $this->db->free($resql);
1050 $this->error = $this->db->error();
1073 public function getBookingConflicts($resourceId, $resourceType, $dateStart, $dateEnd, $excludeElementType =
'', $excludeElementId = 0)
1075 $conflicts = array();
1081 $sql =
"SELECT ac.id as element_id, ac.label as ref";
1082 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1083 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = 'action'";
1084 $sql .=
" WHERE er.resource_id = ".((int) $resourceId);
1085 $sql .=
" AND er.resource_type = '".$this->db->escape($resourceType).
"'";
1086 $sql .=
" AND er.busy = 1";
1087 if ($excludeElementType ==
'action' && $excludeElementId > 0) {
1088 $sql .=
" AND ac.id <> ".((int) $excludeElementId);
1090 $sql .=
" AND ac.datep <= '".$this->db->idate($dateEnd).
"'";
1091 $sql .=
" AND (ac.datep2 IS NULL OR ac.datep2 >= '".$this->db->idate($dateStart).
"')";
1093 $resql = $this->db->query($sql);
1095 $this->error = $this->db->lasterror();
1098 while ($obj = $this->db->fetch_object($resql)) {
1099 $conflicts[] = array(
'element_type' =>
'action',
'element_id' => (
int) $obj->element_id,
'ref' => $obj->ref);
1101 $this->db->free($resql);
1108 $sql =
"SELECT f.rowid as element_id, f.ref as ref, MIN(fd.date) as dmin, MAX(fd.date + INTERVAL fd.duree SECOND) as dmax";
1109 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1110 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"fichinter as f ON f.rowid = er.element_id AND er.element_type = 'fichinter'";
1111 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"fichinterdet as fd ON fd.fk_fichinter = f.rowid";
1112 $sql .=
" WHERE er.resource_id = ".((int) $resourceId);
1113 $sql .=
" AND er.resource_type = '".$this->db->escape($resourceType).
"'";
1114 $sql .=
" AND er.busy = 1";
1115 if ($excludeElementType ==
'fichinter' && $excludeElementId > 0) {
1116 $sql .=
" AND f.rowid <> ".((int) $excludeElementId);
1118 $sql .=
" GROUP BY f.rowid, f.ref";
1119 $sql .=
" HAVING MIN(fd.date) <= '".$this->db->idate($dateEnd).
"'";
1120 $sql .=
" AND MAX(fd.date + INTERVAL fd.duree SECOND) >= '".$this->db->idate($dateStart).
"'";
1122 $resql = $this->db->query($sql);
1124 $this->error = $this->db->lasterror();
1127 while ($obj = $this->db->fetch_object($resql)) {
1128 $conflicts[] = array(
'element_type' =>
'fichinter',
'element_id' => (
int) $obj->element_id,
'ref' => $obj->ref);
1130 $this->db->free($resql);
$id
Support class for third parties, contacts, members, users or resources.
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
deleteExtraFields()
Delete all extra fields values for the current object.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
Class to manage Dolibarr database access.
fetchAll(string $sortorder, string $sortfield, int $limit, int $offset, $filter='')
Load resource objects into $this->lines.
loadStateBoard()
Load indicators this->nb for state board.
fetch(int $id, string $ref='')
Load object into memory from database.
fetchElementResources(string $elementType, int $elementId)
Return an int number of resources linked to the element.
getBookingConflicts($resourceId, $resourceType, $dateStart, $dateEnd, $excludeElementType='', $excludeElementId=0)
Look for an existing "busy" booking of a resource that overlaps a given date range,...
static getLibStatusLabel(int $status, int $mode=0)
Get status.
loadCacheCodeTypeResource()
Load in cache resource type code (setup in dictionary)
update($user=null, int $notrigger=0)
Update object in database.
getTooltipContentArray($params)
getTooltipContentArray
fetchElementResource(int $id)
Load data of resource links into memory from database.
getNomUrl($withpicto=0, string $option='', string $get_params='', int $notooltip=0, string $morecss='', int $save_lastsearch_value=-1)
Return clickable link of object (with optional picto)
getElementResources(string $element, int $element_id, string $resource_type='')
Return an array with resources linked to the element.
create(User $user, int $no_trigger=0)
Create object in database.
__construct(DoliDB $db)
Constructor.
updateElementResource($user=null, int $notrigger=0)
Update element resource in database.
getLibStatut(int $mode=0)
Get status label.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_now($mode='gmt')
Return date for now.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
div refaddress div address
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...