31require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/CSMSFile.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncommreminder.class.php';
46 public $element =
'action';
52 public $TRIGGER_PREFIX =
'ACTION';
57 public $table_element =
'actioncomm';
62 public $table_rowid =
'id';
67 public $picto =
'action';
74 public $restrictiononfksoc = 2;
182 public $date_start_in_calendar;
187 public $date_end_in_calendar;
198 public $durationp = -1;
203 public $fulldayevent = 0;
223 public $transparency;
233 public $userassigned = array();
243 public $socpeopleassigned = array();
248 public $otherassigned = array();
253 public $reminders = array();
304 public $fk_bookcal_calendar;
324 public $actions = array();
339 public $email_reply_to;
344 public $email_sender;
363 public $email_subject;
398 public $recurdateend;
401 public $calling_duration;
426 "id" => array(
"type" =>
"integer",
"label" =>
"Ref",
"enabled" =>
"1",
'position' => 10,
'notnull' => 1,
"visible" =>
"1",),
427 "ref" => array(
"type" =>
"varchar(30)",
"label" =>
"Ref",
"enabled" =>
"1",
'position' => 15,
'notnull' => 1,
"visible" =>
"0",
"csslist" =>
"tdoverflowmax150",
"showoncombobox" =>
"1",),
428 "ref_ext" => array(
"type" =>
"varchar(255)",
"label" =>
"Refext",
"enabled" =>
"1",
'position' => 20,
'notnull' => 0,
"visible" =>
"0",),
429 "datep" => array(
"type" =>
"datetime",
"label" =>
"DateStart",
"enabled" =>
"1",
'position' => 25,
'notnull' => 0,
"visible" =>
"1",),
430 "datep2" => array(
"type" =>
"datetime",
"label" =>
"DateEnd",
"enabled" =>
"1",
'position' => 26,
'notnull' => 0,
"visible" =>
"-1",),
431 "fk_action" => array(
"type" =>
"integer",
"label" =>
"Fkaction",
"enabled" =>
"1",
'position' => 40,
'notnull' => 0,
"visible" =>
"0",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
432 "code" => array(
"type" =>
"varchar(50)",
"label" =>
"Code",
"enabled" =>
"1",
'position' => 45,
'notnull' => 0,
"visible" =>
"0",
"showoncombobox" =>
"1",),
433 "label" => array(
"type" =>
"varchar(255)",
"label" =>
"Title",
"enabled" =>
"1",
'position' => 50,
'notnull' => 1,
"visible" =>
"1",
"alwayseditable" =>
"1",
"css" =>
"minwidth300",
"cssview" =>
"wordbreak",
"csslist" =>
"tdoverflowmax150",),
434 "note" => array(
"type" =>
"mediumtext",
"label" =>
"Description",
"enabled" =>
"1",
'position' => 51,
'notnull' => 0,
"visible" =>
"-1",),
435 "fk_project" => array(
"type" =>
"integer",
"label" =>
"Project",
"picto" =>
"project",
"enabled" =>
"1",
'position' => 75,
'notnull' => 0,
"visible" =>
"0",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
436 "fk_soc" => array(
"type" =>
"integer",
"label" =>
"ThirdParty",
"picto" =>
"company",
"enabled" =>
"1",
'position' => 80,
'notnull' => 0,
"visible" =>
"0",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
437 "fk_contact" => array(
"type" =>
"integer",
"label" =>
"Contact",
"picto" =>
"contact",
"enabled" =>
"1",
'position' => 85,
'notnull' => 0,
"visible" =>
"-1",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
438 "fk_parent" => array(
"type" =>
"integer",
"label" =>
"Parent",
"enabled" =>
"1",
'position' => 90,
'notnull' => 1,
"visible" =>
"0",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
439 "fk_user_action" => array(
"type" =>
"integer",
"label" =>
"Fkuseraction",
"picto" =>
"user",
"enabled" =>
"1",
'position' => 95,
'notnull' => 0,
"visible" =>
"0",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
440 "transparency" => array(
"type" =>
"integer",
"label" =>
"Transparency",
"enabled" =>
"1",
'position' => 100,
'notnull' => 0,
"visible" =>
"0",),
441 "fk_user_done" => array(
"type" =>
"integer",
"label" =>
"Fkuserdone",
"picto" =>
"user",
"enabled" =>
"1",
'position' => 105,
'notnull' => 0,
"visible" =>
"0",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
442 "priority" => array(
"type" =>
"smallint(6)",
"label" =>
"Priority",
"enabled" =>
"1",
'position' => 110,
'notnull' => 0,
"visible" =>
"0",),
443 "fulldayevent" => array(
"type" =>
"smallint(6)",
"label" =>
"Fulldayevent",
"enabled" =>
"1",
'position' => 115,
'notnull' => 1,
"visible" =>
"0",),
444 "location" => array(
"type" =>
"varchar(128)",
"label" =>
"Location",
"enabled" =>
"1",
'position' => 125,
'notnull' => 0,
"visible" =>
"0",),
445 "durationp" => array(
"type" =>
"double",
"label" =>
"Durationp",
"enabled" =>
"1",
'position' => 130,
'notnull' => 0,
"visible" =>
"0",),
446 "durationa" => array(
"type" =>
"double",
"label" =>
"Durationa",
"enabled" =>
"1",
'position' => 135,
'notnull' => 0,
"visible" =>
"0",),
447 "fk_element" => array(
"type" =>
"integer",
"label" =>
"LinkedObject",
"enabled" =>
"getDolGlobalString('AGENDA_SHOW_LINKED_OBJECT')",
'position' => 145,
'notnull' => 0,
"visible" =>
"0",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
448 "elementtype" => array(
"type" =>
"varchar(255)",
"label" =>
"Elementtype",
"enabled" =>
"1",
'position' => 150,
'notnull' => 0,
"visible" =>
"0",),
449 "email_msgid" => array(
"type" =>
"varchar(256)",
"label" =>
"Emailmsgid",
"enabled" =>
"1",
'position' => 155,
'notnull' => 0,
"visible" =>
"0",),
450 "email_subject" => array(
"type" =>
"varchar(256)",
"label" =>
"Emailsubject",
"enabled" =>
"1",
'position' => 160,
'notnull' => 0,
"visible" =>
"0",),
451 "email_from" => array(
"type" =>
"varchar(256)",
"label" =>
"Emailfrom",
"enabled" =>
"1",
'position' => 165,
'notnull' => 0,
"visible" =>
"0",),
452 "email_sender" => array(
"type" =>
"varchar(256)",
"label" =>
"Emailsender",
"enabled" =>
"1",
'position' => 170,
'notnull' => 0,
"visible" =>
"0",),
453 "email_to" => array(
"type" =>
"varchar(256)",
"label" =>
"Emailto",
"enabled" =>
"1",
'position' => 175,
'notnull' => 0,
"visible" =>
"0",),
454 "email_tocc" => array(
"type" =>
"varchar(256)",
"label" =>
"Emailtocc",
"enabled" =>
"1",
'position' => 180,
'notnull' => 0,
"visible" =>
"0",),
455 "email_tobcc" => array(
"type" =>
"varchar(256)",
"label" =>
"Emailtobcc",
"enabled" =>
"1",
'position' => 185,
'notnull' => 0,
"visible" =>
"0",),
456 "errors_to" => array(
"type" =>
"varchar(256)",
"label" =>
"Errorsto",
"enabled" =>
"1",
'position' => 190,
'notnull' => 0,
"visible" =>
"0",),
457 "recurid" => array(
"type" =>
"varchar(128)",
"label" =>
"Recurid",
"enabled" =>
"1",
'position' => 195,
'notnull' => 0,
"visible" =>
"0",),
458 "recurrule" => array(
"type" =>
"varchar(128)",
"label" =>
"Recurrule",
"enabled" =>
"1",
'position' => 200,
'notnull' => 0,
"visible" =>
"0",),
459 "recurdateend" => array(
"type" =>
"datetime",
"label" =>
"Recurdateend",
"enabled" =>
"1",
'position' => 205,
'notnull' => 0,
"visible" =>
"0",),
460 "import_key" => array(
"type" =>
"varchar(14)",
"label" =>
"ImportId",
"enabled" =>
"1",
'position' => 900,
'notnull' => 0,
"visible" =>
"-1",),
461 "extraparams" => array(
"type" =>
"varchar(255)",
"label" =>
"Extraparams",
"enabled" =>
"1",
'position' => 215,
'notnull' => 0,
"visible" =>
"0",),
462 "calling_duration" => array(
"type" =>
"integer",
"label" =>
"Callingduration",
"enabled" =>
"1",
'position' => 220,
'notnull' => 0,
"visible" =>
"0",),
463 "visibility" => array(
"type" =>
"varchar(12)",
"label" =>
"Visibility",
"enabled" =>
"1",
'position' => 225,
'notnull' => 0,
"visible" =>
"0",),
464 "reply_to" => array(
"type" =>
"varchar(255)",
"label" =>
"Replyto",
"enabled" =>
"1",
'position' => 230,
'notnull' => 0,
"visible" =>
"0",),
465 "num_vote" => array(
"type" =>
"integer",
"label" =>
"Numvote",
"enabled" =>
"1",
'position' => 235,
'notnull' => 0,
"visible" =>
"0",),
466 "event_paid" => array(
"type" =>
"smallint(6)",
"label" =>
"Eventpaid",
"enabled" =>
"1",
'position' => 240,
'notnull' => 1,
"visible" =>
"0",),
467 "status" => array(
"type" =>
"smallint(6)",
"label" =>
"Status",
"enabled" =>
"1",
'position' => 500,
'notnull' => 1,
"visible" =>
"0",),
468 "ip" => array(
"type" =>
"varchar(250)",
"label" =>
"Ip",
"enabled" =>
"1",
'position' => 250,
'notnull' => 0,
"visible" =>
"0",),
469 "fk_bookcal_calendar" => array(
"type" =>
"integer",
"label" =>
"Fkbookcalcalendar",
"enabled" =>
"1",
'position' => 255,
'notnull' => 0,
"visible" =>
"0",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
470 "fk_task" => array(
"type" =>
"integer",
"label" =>
"Task",
"picto" =>
"task",
"enabled" =>
"1",
'position' => 260,
'notnull' => 0,
"visible" =>
"0",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
471 "fk_user_author" => array(
"type" =>
"integer",
"label" =>
"UserCreation",
"picto" =>
"user",
"enabled" =>
"1",
'position' => 505,
'notnull' => 0,
"visible" =>
"0",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
472 "fk_user_mod" => array(
"type" =>
"integer",
"label" =>
"UserModification",
"picto" =>
"user",
"enabled" =>
"1",
'position' => 506,
'notnull' => 0,
"visible" =>
"0",
"css" =>
"maxwidth500 widthcentpercentminusxx",),
473 "datec" => array(
"type" =>
"datetime",
"label" =>
"DateCreation",
"enabled" =>
"1",
'position' => 510,
'notnull' => 0,
"visible" =>
"-1",),
474 "tms" => array(
"type" =>
"timestamp",
"label" =>
"DateModification",
"enabled" =>
"1",
'position' => 520,
'notnull' => 1,
"visible" =>
"-1",),
475 "percent" => array(
"type" =>
"smallint(6)",
"label" =>
"Status",
"enabled" =>
"1",
'position' => 1000,
'notnull' => 1,
"visible" =>
"1",),
489 $this->ismultientitymanaged = 1;
502 global $langs, $conf;
508 if (!isset($this->userownerid) || (
string) $this->userownerid ===
'') {
509 dol_syslog(
"You tried to create an event but mandatory property userownerid was empty (you can define it to 0 for anonymous event)", LOG_WARNING);
510 $this->errors[] =
'ErrorActionCommPropertyUserowneridNotDefined';
515 $this->label =
dol_trunc(trim($this->label), 128);
516 $this->location = (!empty($this->location) ?
dol_trunc(trim($this->location), 128) :
"");
517 $this->note_private =
dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private));
518 if (empty($this->percentage)) {
519 $this->percentage = 0;
521 if (empty($this->priority) || !is_numeric($this->priority)) {
524 if (empty($this->fulldayevent)) {
525 $this->fulldayevent = 0;
527 if (empty($this->transparency)) {
528 $this->transparency = 0;
530 if ($this->percentage > 100) {
531 $this->percentage = 100;
533 if (empty($this->datep) && $this->datep !=
'0') {
536 if (!empty($this->datep) && !empty($this->datef)) {
537 $this->durationp = ($this->datef - $this->datep);
539 if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) {
540 $this->datef = $this->datep;
542 if (!isset($this->fk_project) || $this->fk_project < 0) {
543 $this->fk_project = 0;
545 if (!isset($this->fk_task) || $this->fk_task < 0) {
549 if ($this->elementtype ==
'facture') {
550 $this->elementtype =
'invoice';
552 if ($this->elementtype ==
'commande') {
553 $this->elementtype =
'order';
555 if ($this->elementtype ==
'contrat') {
556 $this->elementtype =
'contract';
558 if (empty($this->fk_element) && !empty($this->elementid)) {
559 $this->fk_element = $this->elementid;
561 if (empty($this->elementid) && !empty($this->fk_element)) {
562 $this->elementid = $this->fk_element;
565 if (!is_array($this->userassigned) && !empty($this->userassigned)) {
566 $tmpid = (int) $this->userassigned;
567 $this->userassigned = array();
568 $this->userassigned[$tmpid] = array(
'id' => $tmpid,
'transparency' => $this->transparency);
571 $userownerid = $this->userownerid;
574 if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) {
575 $this->userassigned = array($userownerid => array(
'id' => $userownerid,
'transparency' => $this->transparency));
578 if (!$this->type_id || !$this->type_code) {
579 $key = empty($this->type_id) ? $this->type_code : $this->type_id;
583 $result = $cactioncomm->fetch($key);
586 $this->type_id = $cactioncomm->id;
587 $this->type_code = $cactioncomm->code;
588 } elseif ($result == 0) {
589 $this->error = $langs->trans(
'ErrorActionCommBadType', $this->type_id, $this->type_code);
592 $this->error = $cactioncomm->error;
596 $code = empty($this->code) ? $this->type_code : $this->code;
599 if (!$this->type_id) {
600 $this->error =
"ErrorWrongParameters";
604 $extraparams = (!empty($this->extraparams) ? json_encode($this->extraparams) :
null);
605 $extraparams =
dol_trunc($extraparams, 250);
609 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm";
614 $sql .=
"durationp,";
615 $sql .=
"fk_action,";
619 $sql .=
"fk_project,";
621 $sql .=
"fk_contact,";
622 $sql .=
"fk_user_author,";
623 $sql .=
"fk_user_action,";
625 $sql .=
"label,percent,priority,fulldayevent,location,";
626 $sql .=
"transparency,";
627 $sql .=
"fk_element,";
628 $sql .=
"elementtype,";
629 $sql .=
"fk_bookcal_calendar,";
631 $sql .=
"extraparams,";
633 $sql .=
"email_msgid,";
634 $sql .=
"email_from,";
635 $sql .=
"email_sender,";
637 $sql .=
"email_tocc,";
638 $sql .=
"email_tobcc,";
639 $sql .=
"email_subject,";
640 $sql .=
"errors_to,";
642 $sql .=
"recurrule,";
643 $sql .=
"recurdateend,";
645 $sql .=
"event_paid,";
648 $sql .=
") VALUES (";
649 $sql .=
"'(PROV)', ";
650 $sql .=
"'".$this->db->idate($now).
"', ";
651 $sql .=
"'".$this->db->idate($this->datep).
"', ";
652 $sql .= (strval($this->datef) !=
'' ?
"'".$this->db->idate($this->datef).
"'" :
"null").
", ";
653 $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp !=
'') ?
"'".$this->db->escape((
string) $this->durationp).
"'" :
"null").
", ";
654 $sql .= (isset($this->type_id) ? $this->type_id :
"null").
",";
655 $sql .= ($code ? (
"'".$this->db->escape($code).
"'") :
"null").
", ";
656 $sql .= (!empty($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
"null").
", ";
657 $sql .= ((isset($this->socid) && $this->socid > 0) ? ((
int) $this->socid) :
"null").
", ";
658 $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? ((
int) $this->fk_project) :
"null").
", ";
659 $sql .=
" '".$this->db->escape($this->note_private).
"', ";
660 $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? ((
int) $this->contact_id) :
"null").
", ";
661 $sql .= (isset($user->id) && $user->id > 0 ? $user->id :
"null").
", ";
662 $sql .= ($userownerid > 0 ? $userownerid :
"null").
", ";
663 $sql .= (!empty($this->fk_task) ? ((int) $this->fk_task) :
"null").
", ";
664 $sql .=
"'".$this->db->escape($this->label).
"', ";
665 $sql .=
"'".$this->db->escape((
string) $this->percentage).
"', ";
666 $sql .=
"'".$this->db->escape((
string) $this->priority).
"', ";
667 $sql .=
"'".$this->db->escape((
string) $this->fulldayevent).
"', ";
668 $sql .=
"'".$this->db->escape($this->location).
"', ";
669 $sql .=
"'".$this->db->escape((
string) $this->transparency).
"', ";
670 $sql .= (!empty($this->elementid) ? ((int) $this->elementid) :
"null").
", ";
671 $sql .= (!empty($this->elementtype) ?
"'".$this->db->escape($this->elementtype).
"'" :
"null").
", ";
672 $sql .= (!empty($this->fk_bookcal_calendar) ?
"'".$this->db->escape((
string) $this->fk_bookcal_calendar).
"'" :
"null").
", ";
673 $sql .= ((int) $conf->entity).
",";
674 $sql .= (!empty($extraparams) ?
"'".$this->db->escape($extraparams).
"'" :
"null").
", ";
676 $sql .= (!empty($this->email_msgid) ?
"'".$this->db->escape($this->email_msgid).
"'" :
"null").
", ";
677 $sql .= (!empty($this->email_from) ?
"'".$this->db->escape($this->email_from).
"'" :
"null").
", ";
678 $sql .= (!empty($this->email_sender) ?
"'".$this->db->escape($this->email_sender).
"'" :
"null").
", ";
679 $sql .= (!empty($this->email_to) ?
"'".$this->db->escape($this->email_to).
"'" :
"null").
", ";
680 $sql .= (!empty($this->email_tocc) ?
"'".$this->db->escape($this->email_tocc).
"'" :
"null").
", ";
681 $sql .= (!empty($this->email_tobcc) ?
"'".$this->db->escape($this->email_tobcc).
"'" :
"null").
", ";
682 $sql .= (!empty($this->email_subject) ?
"'".$this->db->escape($this->email_subject).
"'" :
"null").
", ";
683 $sql .= (!empty($this->errors_to) ?
"'".$this->db->escape($this->errors_to).
"'" :
"null").
", ";
684 $sql .= (!empty($this->recurid) ?
"'".$this->db->escape($this->recurid).
"'" :
"null").
", ";
685 $sql .= (!empty($this->recurrule) ?
"'".$this->db->escape($this->recurrule).
"'" :
"null").
", ";
686 $sql .= (!empty($this->recurdateend) ?
"'".$this->db->idate($this->recurdateend).
"'" :
"null").
", ";
687 $sql .= (!empty($this->num_vote) ? (int) $this->num_vote :
"null").
", ";
688 $sql .= (!empty($this->event_paid) ? (int) $this->event_paid : 0).
", ";
689 $sql .= (!empty($this->
status) ? (int) $this->
status :
"0").
", ";
690 $sql .= (!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
693 dol_syslog(get_class($this).
"::add", LOG_DEBUG);
694 $resql = $this->db->query($sql);
696 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"actioncomm",
"id");
697 $this->
ref = (string) $this->
id;
698 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"actioncomm SET ref='".$this->db->escape($this->
ref).
"' WHERE id=".$this->id;
699 $resql = $this->db->query($sql);
702 dol_syslog(
'Error to process ref: '.$this->db->lasterror(), LOG_ERR);
703 $this->errors[] = $this->db->lasterror();
708 $already_inserted = array();
709 foreach ($this->userassigned as $key => $val) {
711 if (!is_array($val)) {
712 $val = array(
'id' => $val);
715 if ($val[
'id'] > 0) {
716 if (!empty($already_inserted[$val[
'id']])) {
720 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
721 $sql .=
" VALUES(".((int) $this->
id).
", 'user', ".((int) $val[
'id']).
", ".(empty($val[
'mandatory']) ?
'0' : ((int) $val[
'mandatory'])).
", ".(empty($val[
'transparency']) ?
'0' : ((int) $val[
'transparency'])).
", ".(empty($val[
'answer_status']) ?
'0' : ((int) $val[
'answer_status'])).
")";
723 $resql = $this->db->query($sql);
726 dol_syslog(
'Error to process userassigned: ' . $this->db->lasterror(), LOG_ERR);
727 $this->errors[] = $this->db->lasterror();
729 $already_inserted[$val[
'id']] =
true;
737 if (!empty($this->socpeopleassigned)) {
738 $already_inserted = array();
739 foreach ($this->socpeopleassigned as $id => $val) {
741 if (!empty($already_inserted[$id])) {
745 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
746 $sql .=
" VALUES(".((int) $this->
id).
", 'socpeople', ".((int)
$id).
", 0, 0, 0)";
748 $resql = $this->db->query($sql);
751 dol_syslog(
'Error to process socpeopleassigned: ' . $this->db->lasterror(), LOG_ERR);
752 $this->errors[] = $this->db->lasterror();
754 $already_inserted[
$id] =
true;
768 if (!$error && !$notrigger) {
770 $result = $this->call_trigger(
'ACTION_CREATE', $user);
781 $this->db->rollback();
785 $this->db->rollback();
786 $this->error = $this->db->lasterror();
807 $objFrom = clone $this;
818 $this->recurrule =
'';
819 $this->recurdateend =
'';
822 $this->context[
'createfromclone'] =
'createfromclone';
823 $result = $this->
create($fuser);
828 if ($resultcat < 0) {
835 if (is_object($hookmanager)) {
836 $parameters = array(
'objFrom' => $objFrom);
838 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $this, $action);
846 $result = $this->call_trigger(
'ACTION_CLONE', $fuser);
853 unset($this->context[
'createfromclone']);
860 $this->db->rollback();
875 public function fetch($id, $ref =
'', $ref_ext =
'', $email_msgid =
'', $loadresources = 1)
877 if (empty($id) && empty($ref) && empty($ref_ext) && empty($email_msgid)) {
878 dol_syslog(get_class($this).
"::fetch Bad parameters", LOG_WARNING);
882 $sql =
"SELECT a.id,";
883 $sql .=
" a.ref as ref,";
884 $sql .=
" a.entity,";
885 $sql .=
" a.ref_ext,";
887 $sql .=
" a.datep2,";
888 $sql .=
" a.durationp,";
890 $sql .=
" a.tms as datem,";
891 $sql .=
" a.code, a.label, a.note as note_private,";
892 $sql .=
" a.fk_soc,";
893 $sql .=
" a.fk_project,";
894 $sql .=
" a.fk_user_author, a.fk_user_mod,";
895 $sql .=
" a.fk_user_action,";
896 $sql .=
" a.fk_task,";
897 $sql .=
" a.fk_contact, a.percent as percentage,";
898 $sql .=
" a.fk_element as elementid, a.elementtype,";
899 $sql .=
" a.priority, a.fulldayevent, a.location, a.transparency,";
900 $sql .=
" a.email_msgid, a.email_subject, a.email_from, a.email_sender, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,";
901 $sql .=
" a.recurid, a.recurrule, a.recurdateend,";
902 $sql .=
" c.id as type_id, c.type as type_type, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,";
903 $sql .=
" s.nom as socname,";
904 $sql .=
" u.firstname, u.lastname as lastname,";
905 $sql .=
" num_vote, event_paid, a.status";
906 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a ";
907 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action=c.id ";
908 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_author";
909 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on s.rowid = a.fk_soc";
912 $sql .=
" a.ref = '".$this->db->escape($ref).
"'";
913 } elseif ($ref_ext) {
914 $sql .=
" a.ref_ext = '".$this->db->escape($ref_ext).
"'";
915 } elseif ($email_msgid) {
916 $sql .=
" a.email_msgid = '".$this->db->escape($email_msgid).
"'";
918 $sql .=
" a.id = ".((int) $id);
921 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
922 $resql = $this->db->query($sql);
924 $num = $this->db->num_rows($resql);
926 $obj = $this->db->fetch_object($resql);
928 $this->
id = $obj->id;
929 $this->entity = $obj->entity;
930 $this->
ref = $obj->ref;
931 $this->ref_ext = $obj->ref_ext;
934 $this->type_id = $obj->type_id;
935 $this->type_code = $obj->type_code;
936 $this->type_color = $obj->type_color;
937 $this->type_picto = $obj->type_picto;
938 $this->
type = $obj->type_type;
939 $this->type_label = $obj->type_label;
941 $this->code = $obj->code;
942 $this->label = $obj->label;
943 $this->datep = $this->db->jdate($obj->datep);
944 $this->datef = $this->db->jdate($obj->datep2);
946 $this->datec = $this->db->jdate($obj->datec);
947 $this->datem = $this->db->jdate($obj->datem);
949 $this->note = $obj->note_private;
950 $this->note_private = $obj->note_private;
951 $this->percentage = $obj->percentage;
953 $this->authorid = $obj->fk_user_author;
954 $this->usermodid = $obj->fk_user_mod;
956 if (!is_object($this->author)) {
957 $this->author =
new User($this->db);
959 $this->author->id = $obj->fk_user_author;
960 $this->author->firstname = $obj->firstname;
961 $this->author->lastname = $obj->lastname;
962 if (!is_object($this->usermod)) {
963 $this->usermod =
new User($this->db);
965 $this->usermod->id = $obj->fk_user_mod;
967 $this->userownerid = $obj->fk_user_action;
968 $this->fk_task = $obj->fk_task;
969 $this->priority = $obj->priority;
970 $this->fulldayevent = $obj->fulldayevent;
971 $this->location = $obj->location;
972 $this->transparency = $obj->transparency;
974 $this->socid = $obj->fk_soc;
975 $this->contact_id = $obj->fk_contact;
976 $this->fk_project = $obj->fk_project;
981 $this->fk_element = $obj->elementid;
982 $this->elementid = $obj->elementid;
983 $this->elementtype = $obj->elementtype;
985 $this->recurid = $obj->recurid;
986 $this->recurrule = $obj->recurrule;
987 $this->recurdateend = $this->db->jdate($obj->recurdateend);
989 $this->num_vote = $obj->num_vote;
990 $this->event_paid = $obj->event_paid;
991 $this->
status = $obj->status;
994 $this->email_msgid = $obj->email_msgid;
995 $this->email_from = $obj->email_from;
996 $this->email_sender = $obj->email_sender;
997 $this->email_to = $obj->email_to;
998 $this->email_tocc = $obj->email_tocc;
999 $this->email_tobcc = $obj->email_tobcc;
1000 $this->email_subject = $obj->email_subject;
1001 $this->errors_to = $obj->errors_to;
1005 if ($loadresources) {
1010 $this->db->free($resql);
1012 $this->error = $this->db->lasterror();
1026 $this->userassigned = array();
1027 $this->socpeopleassigned = array();
1029 $sql =
'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency';
1030 $sql .=
' FROM '.MAIN_DB_PREFIX.
'actioncomm_resources';
1031 $sql .=
' WHERE fk_actioncomm = '.((int) $this->
id);
1032 $sql .=
" AND element_type IN ('user', 'socpeople')";
1033 $resql = $this->db->query($sql);
1036 if ($this->userownerid > 0) {
1037 $this->userassigned[$this->userownerid] = array(
'id' => $this->userownerid);
1040 while ($obj = $this->db->fetch_object($resql)) {
1041 if ($obj->fk_element > 0) {
1042 switch ($obj->element_type) {
1044 $this->userassigned[$obj->fk_element] = array(
'id' => $obj->fk_element,
'mandatory' => $obj->mandatory,
'answer_status' => $obj->answer_status,
'transparency' => $obj->transparency);
1045 if (empty($this->userownerid)) {
1046 $this->userownerid = $obj->fk_element;
1050 $this->socpeopleassigned[$obj->fk_element] = array(
'id' => $obj->fk_element,
'mandatory' => $obj->mandatory,
'answer_status' => $obj->answer_status,
'transparency' => $obj->transparency);
1073 $sql =
"SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency";
1074 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm_resources";
1075 $sql .=
" WHERE element_type = 'user' AND fk_actioncomm = ".((int) $this->
id);
1077 $resql2 = $this->db->query($sql);
1079 $this->userassigned = array();
1082 if ($this->userownerid > 0) {
1084 $this->userassigned[$this->userownerid] = array(
'id' => $this->userownerid);
1087 while ($obj = $this->db->fetch_object($resql2)) {
1088 if ($obj->fk_element > 0) {
1089 $this->userassigned[$obj->fk_element] = array(
'id' => $obj->fk_element,
1090 'mandatory' => $obj->mandatory,
1091 'answer_status' => $obj->answer_status,
1092 'transparency' => $obj->transparency);
1095 if ($override ===
true) {
1097 if (empty($this->userownerid)) {
1098 $this->userownerid = $obj->fk_element;
1117 public function delete($user, $notrigger = 0)
1121 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1127 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm";
1128 $sql .=
" WHERE fk_actioncomm=".((int) $this->
id);
1130 $res = $this->db->query($sql);
1132 $this->error = $this->db->lasterror();
1139 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_resources";
1140 $sql .=
" WHERE fk_actioncomm=".((int) $this->
id);
1142 $res = $this->db->query($sql);
1144 $this->error = $this->db->lasterror();
1150 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1151 $sql .=
" WHERE fk_actioncomm = ".((int) $this->
id);
1153 $res = $this->db->query($sql);
1155 $this->error = $this->db->lasterror();
1165 dol_syslog(get_class($this).
"::delete error -3 ".$this->error, LOG_ERR);
1171 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm";
1172 $sql .=
" WHERE id=".((int) $this->
id);
1174 $res = $this->db->query($sql);
1176 $this->error = $this->db->lasterror();
1184 $result = $this->call_trigger(
'ACTION_DELETE', $user);
1192 $this->db->commit();
1195 $this->db->rollback();
1199 $this->db->rollback();
1200 $this->error = $this->db->lasterror();
1218 $this->label = trim($this->label);
1219 $this->note_private =
dol_htmlcleanlastbr(trim(!isset($this->note_private) ? $this->note : $this->note_private));
1220 if (empty($this->percentage)) {
1221 $this->percentage = 0;
1223 if (empty($this->priority) || !is_numeric($this->priority)) {
1224 $this->priority = 0;
1226 if (empty($this->transparency)) {
1227 $this->transparency = 0;
1229 if (empty($this->fulldayevent)) {
1230 $this->fulldayevent = 0;
1232 if ($this->percentage > 100) {
1233 $this->percentage = 100;
1236 if ($this->datep && $this->datef) {
1237 $this->durationp = ($this->datef - $this->datep);
1240 if ($this->datep && $this->datef && $this->datep > $this->datef) {
1241 $this->datef = $this->datep;
1244 if ($this->fk_project < 0) {
1245 $this->fk_project = 0;
1248 $socid = (($this->socid > 0) ? $this->socid : 0);
1249 $contactid = (($this->contact_id > 0) ? $this->contact_id : 0);
1250 $userownerid = ($this->userownerid ? $this->userownerid : 0);
1253 if ($this->type_id > 0) {
1254 if (empty($this->type_code)) {
1256 $result = $cactioncomm->fetch($this->type_id);
1257 if ($result >= 0 && !empty($cactioncomm->code)) {
1258 $this->type_code = $cactioncomm->code;
1263 $code = $this->code;
1264 if (empty($code) || (!empty($this->oldcopy) && $this->oldcopy->type_code != $this->type_code)) {
1265 $code = $this->type_code;
1270 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"actioncomm";
1271 $sql .=
" SET percent = '".$this->db->escape((
string) $this->percentage).
"'";
1272 $sql .=
", fk_action = ".(int) $this->type_id;
1273 $sql .=
", code = " . ($code ?
"'".$this->db->escape($code).
"'" :
"null");
1274 $sql .=
", label = ".($this->label ?
"'".$this->db->escape($this->label).
"'" :
"null");
1275 $sql .=
", datep = ".(strval($this->datep) !=
'' ?
"'".$this->db->idate($this->datep).
"'" :
'null');
1276 $sql .=
", datep2 = ".(strval($this->datef) !=
'' ?
"'".$this->db->idate($this->datef).
"'" :
'null');
1277 $sql .=
", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp !=
'' ?
"'".$this->db->escape((
string) $this->durationp).
"'" :
"null");
1278 $sql .=
", note = '".$this->db->escape($this->note_private).
"'";
1279 $sql .=
", fk_project =".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null");
1280 $sql .=
", fk_soc =".($socid > 0 ? ((int) $socid) :
"null");
1281 $sql .=
", fk_contact =".($contactid > 0 ? ((int) $contactid) :
"null");
1282 $sql .=
", priority = '".$this->db->escape((
string) $this->priority).
"'";
1283 $sql .=
", fulldayevent = '".$this->db->escape((
string) $this->fulldayevent).
"'";
1284 $sql .=
", location = ".($this->location ?
"'".$this->db->escape($this->location).
"'" :
"null");
1285 $sql .=
", transparency = '".$this->db->escape((
string) $this->transparency).
"'";
1286 $sql .=
", fk_user_mod = ".((int) $user->id);
1287 $sql .=
", fk_user_action = ".($userownerid > 0 ? ((int) $userownerid) :
"null");
1288 $sql .=
", fk_task = ".(!empty($this->fk_task) ? ((int) $this->fk_task) :
"null");
1289 if (!empty($this->fk_element)) {
1290 $sql .=
", fk_element=".($this->fk_element ? ((int) $this->fk_element) :
"null");
1292 if (!empty($this->elementtype)) {
1293 $sql .=
", elementtype=".($this->elementtype ?
"'".$this->db->escape($this->elementtype).
"'" :
"null");
1295 if (!empty($this->num_vote)) {
1296 $sql .=
", num_vote=".($this->num_vote ? (int) $this->num_vote :
null);
1298 if (!empty($this->event_paid)) {
1299 $sql .=
", event_paid=".($this->event_paid ? (int) $this->event_paid : 0);
1301 if (!empty($this->
status)) {
1302 $sql .=
", status=".($this->status ? (int) $this->
status : 0);
1304 $sql .=
" WHERE id=".((int) $this->
id);
1306 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1307 if ($this->db->query($sql)) {
1320 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_resources where fk_actioncomm = ".((int) $this->
id).
" AND element_type = 'user'";
1321 $resql = $this->db->query($sql);
1323 $already_inserted = array();
1324 foreach ($this->userassigned as $key => $val) {
1325 if (!is_array($val)) {
1326 $val = array(
'id' => $val);
1328 if (!isset($val[
'id']) || !is_scalar($val[
'id'])) {
1331 if (!empty($already_inserted[$val[
'id']])) {
1335 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
1336 $sql .=
" VALUES(".((int) $this->
id).
", 'user', ".((int) $val[
'id']).
", ".(empty($val[
'mandatory']) ?
'0' : ((int) $val[
'mandatory'])).
", ".(empty($val[
'transparency']) ?
'0' : ((int) $val[
'transparency'])).
", ".(empty($val[
'answer_status']) ?
'0' : ((int) $val[
'answer_status'])).
")";
1338 $resql = $this->db->query($sql);
1341 $this->errors[] = $this->db->lasterror();
1343 $already_inserted[$val[
'id']] =
true;
1350 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_resources where fk_actioncomm = ".((int) $this->
id).
" AND element_type = 'socpeople'";
1351 $resql = $this->db->query($sql);
1353 if (!empty($this->socpeopleassigned)) {
1354 $already_inserted = array();
1355 foreach ($this->socpeopleassigned as $val) {
1356 if (!is_array($val)) {
1357 $val = array(
'id' => $val);
1359 if (!empty($already_inserted[$val[
'id']])) {
1363 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
1364 $sql .=
" VALUES(".((int) $this->
id).
", 'socpeople', ".((int) $val[
'id']).
", 0, 0, 0)";
1366 $resql = $this->db->query($sql);
1369 $this->errors[] = $this->db->lasterror();
1371 $already_inserted[$val[
'id']] =
true;
1377 if (!$error && !$notrigger) {
1379 $result = $this->call_trigger(
'ACTION_MODIFY', $user);
1387 $this->db->commit();
1390 $this->db->rollback();
1391 dol_syslog(get_class($this).
"::update ".implode(
',', $this->errors), LOG_ERR);
1395 $this->db->rollback();
1396 $this->error = $this->db->lasterror();
1414 public function getActions($socid = 0, $fk_element = 0, $elementtype =
'', $filter =
'', $sortfield =
'a.datep', $sortorder =
'DESC', $limit = 0)
1416 global $hookmanager;
1418 $resarray = array();
1420 dol_syslog(get_class($this).
"::getActions", LOG_DEBUG);
1423 if (!is_object($hookmanager)) {
1424 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1427 $hookmanager->initHooks(array(
'agendadao'));
1429 $sql =
"SELECT a.id";
1430 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
1432 $parameters = array(
'sql' => &$sql,
'socid' => $socid,
'fk_element' => $fk_element,
'elementtype' => $elementtype);
1433 $reshook = $hookmanager->executeHooks(
'getActionsListFrom', $parameters);
1434 if (!empty($hookmanager->resPrint)) {
1435 $sql .= $hookmanager->resPrint;
1437 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
1438 if (!empty($socid)) {
1439 $sql .=
" AND a.fk_soc = ".((int) $socid);
1441 if (!empty($elementtype)) {
1442 if ($elementtype ==
'project') {
1443 $sql .=
' AND a.fk_project = '.((int) $fk_element);
1444 } elseif ($elementtype ==
'contact') {
1445 $sql .=
' AND EXISTS';
1446 $sql .=
" (SELECT r.rowid FROM ".MAIN_DB_PREFIX.
"actioncomm_resources as r WHERE";
1447 $sql .=
" r.element_type = 'socpeople' AND r.fk_element = ".((int) $fk_element).
' AND r.fk_actioncomm = a.id)';
1448 } elseif ($elementtype ==
'user') {
1449 $sql .=
" AND (a.fk_user_action = ".((int) $fk_element).
" OR EXISTS";
1450 $sql .=
" (SELECT r.rowid FROM ".MAIN_DB_PREFIX.
"actioncomm_resources as r WHERE";
1451 $sql .=
" r.element_type = 'user' AND r.fk_element = ".((int) $fk_element).
' AND r.fk_actioncomm = a.id)';
1454 $sql .=
" AND a.fk_element = ".((int) $fk_element).
" AND a.elementtype = '".$this->db->escape($elementtype).
"'";
1457 if (!empty($filter)) {
1461 $parameters = array(
'sql' => &$sql,
'socid' => $socid,
'fk_element' => $fk_element,
'elementtype' => $elementtype);
1462 $reshook = $hookmanager->executeHooks(
'getActionsListWhere', $parameters);
1463 if (!empty($hookmanager->resPrint)) {
1464 $sql .= $hookmanager->resPrint;
1466 if ($sortorder && $sortfield) {
1467 $sql .= $this->db->order($sortfield, $sortorder);
1469 $sql .= $this->db->plimit($limit, 0);
1471 $resql = $this->db->query($sql);
1473 $num = $this->db->num_rows($resql);
1476 for ($i = 0; $i < $num; $i++) {
1477 $obj = $this->db->fetch_object($resql);
1478 $actioncommstatic =
new ActionComm($this->db);
1479 $actioncommstatic->fetch($obj->id);
1480 $resarray[$i] = $actioncommstatic;
1483 $this->db->free($resql);
1486 return $this->db->lasterror();
1501 global $conf, $langs;
1503 if (empty($load_state_board)) {
1504 $sql =
"SELECT a.id, a.datep as dp";
1506 $this->nb = array();
1507 $sql =
"SELECT count(a.id) as nb";
1509 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
1510 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
1511 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources AS ar ON a.id = ar.fk_actioncomm AND ar.element_type ='user' AND ar.fk_element = ".((int) $user->id);
1513 $sql .=
" WHERE 1 = 1";
1514 if (empty($load_state_board)) {
1515 $sql .=
" AND a.percent >= 0 AND a.percent < 100";
1517 $sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
1518 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
1519 $sql .=
" AND (a.fk_user_author = ".((int) $user->id).
" OR a.fk_user_action = ".((int) $user->id);
1520 $sql .=
" OR ar.fk_element = ".((int) $user->id);
1525 if (!$user->hasRight(
'societe',
'client',
'voir')) {
1526 $search_sale = $user->id;
1529 if ($search_sale && $search_sale !=
'-1') {
1530 if ($search_sale == -2) {
1531 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
1532 } elseif ($search_sale > 0) {
1533 $sql .=
" AND (a.fk_soc IS NULL OR EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc AND sc.fk_user = ".((int) $search_sale).
"))";
1537 $resql = $this->db->query($sql);
1540 if (empty($load_state_board)) {
1543 $response->warning_delay = $conf->agenda->warning_delay / 60 / 60 / 24;
1544 $response->label = $langs->trans(
"ActionsToDo");
1545 $response->labelShort = $langs->trans(
"ActionsToDoShort");
1546 $response->url = DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&actioncode=0&status=todo&mainmenu=agenda';
1547 if ($user->hasRight(
"agenda",
"allactions",
"read")) {
1548 $response->url .=
'&filtert=-1';
1550 $response->img =
img_object(
'',
"action",
'class="inline-block valigntextmiddle"');
1553 while ($obj = $this->db->fetch_object($resql)) {
1554 if (empty($load_state_board)) {
1555 '@phan-var-force WorkboardResponse $response
1556 @phan-var-force ActionComm $agenda_static';
1557 $response->nbtodo++;
1558 $agenda_static->datep = $this->db->jdate($obj->dp);
1559 if ($agenda_static->hasDelay()) {
1560 $response->nbtodolate++;
1563 $this->nb[
"actionscomm"] = $obj->nb;
1567 $this->db->free($resql);
1575 $this->error = $this->db->error();
1592 $sql .=
' tms as datem,';
1593 $sql .=
' fk_user_author,';
1594 $sql .=
' fk_user_mod';
1595 $sql .=
' FROM '.MAIN_DB_PREFIX.
'actioncomm as a';
1596 $sql .=
' WHERE a.id = '.((int) $id);
1598 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
1599 $result = $this->db->query($sql);
1601 if ($this->db->num_rows($result)) {
1602 $obj = $this->db->fetch_object($result);
1604 $this->
id = $obj->id;
1606 $this->user_creation_id = $obj->fk_user_author;
1607 $this->user_modification_id = $obj->fk_user_mod;
1608 $this->date_creation = $this->db->jdate($obj->datec);
1609 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1611 $this->db->free($result);
1627 return $this->
LibStatut($this->percentage, $mode, $hidenastatus, $this->datep);
1640 public function LibStatut($percent, $mode, $hidenastatus = 0, $datestart =
'')
1645 $labelStatus = $langs->transnoentitiesnoconv(
'StatusNotApplicable');
1646 if ($percent == -1 && !$hidenastatus) {
1647 $labelStatus = $langs->transnoentitiesnoconv(
'StatusNotApplicable');
1648 } elseif ($percent == 0) {
1649 $labelStatus = $langs->transnoentitiesnoconv(
'StatusActionToDo').
' (0%)';
1650 } elseif ($percent > 0 && $percent < 100) {
1651 $labelStatus = $langs->transnoentitiesnoconv(
'StatusActionInProcess').
' ('.$percent.
'%)';
1652 } elseif ($percent >= 100) {
1653 $labelStatus = $langs->transnoentitiesnoconv(
'StatusActionDone').
' (100%)';
1656 $labelStatusShort = $langs->transnoentitiesnoconv(
'StatusNotApplicable');
1657 if ($percent == -1 && !$hidenastatus) {
1658 $labelStatusShort = $langs->trans(
'NA');
1659 } elseif ($percent == 0) {
1660 $labelStatusShort =
'0%';
1661 } elseif ($percent > 0 && $percent < 100) {
1662 $labelStatusShort = $percent.
'%';
1663 } elseif ($percent >= 100) {
1664 $labelStatusShort =
'100%';
1667 $statusType =
'status9';
1668 if ($percent == -1 && !$hidenastatus) {
1669 $statusType =
'status9';
1671 if ($percent == 0) {
1672 $statusType =
'status1';
1674 if ($percent > 0 && $percent < 100) {
1675 $statusType =
'status3';
1677 if ($percent >= 100) {
1678 $statusType =
'status6';
1681 $params = array(
'badgeParams' => array(
'attr' => array(
'title' =>
'<b>'.$langs->trans(
"Progression").
'</b> : '.$labelStatus)));
1683 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode,
'', $params);
1694 global $langs, $form;
1696 $langs->load(
'agenda');
1699 $nofetch = !empty($params[
'nofetch']);
1703 if ($this->type_code) {
1704 $langs->load(
"commercial");
1705 $labeltype = ($langs->transnoentities(
"Action".$this->type_code) !=
"Action".$this->type_code) ? $langs->transnoentities(
"Action".$this->type_code) : $this->type_label;
1708 if ($this->type_code !=
'AC_OTH_AUTO') {
1709 $labeltype = $langs->trans(
'ActionAC_MANUAL');
1712 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
'Action').
'</u>';
1713 if (!empty($this->
ref)) {
1716 if (!empty($this->label)) {
1717 $datas[
'title'] =
'<br><b>'.$langs->trans(
'Title').
':</b> '.
dol_escape_htmltag($this->label);
1719 if (!empty($labeltype)) {
1720 $datas[
'labeltype'] =
'<br><b>'.$langs->trans(
'Type').
':</b> '.
dol_escape_htmltag($labeltype);
1722 if (!empty($this->location)) {
1723 $datas[
'location'] =
'<br><b>'.$langs->trans(
'Location').
':</b> '.
dol_escape_htmltag($this->location);
1725 if (isset($this->transparency) && $this->datef && $this->datep != $this->datef && isset($this->transparency)) {
1726 $datas[
'transparency'] =
'<br><b>'.$langs->trans(
'Busy').
':</b> '.
yn($this->transparency);
1729 $datas[
'date'] =
'<br><b>'.$langs->trans(
'Date').
':</b> '.
dol_print_date($this->datep,
'dayhourreduceformat',
'tzuserrel');
1733 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1734 if ($tmpa[
'hours'] != $tmpb[
'hours'] || $tmpa[
'minutes'] != $tmpb[
'minutes']) {
1735 $datas[
'date'] .=
'-'.dol_print_date($this->datef,
'hour',
'tzuserrel');
1738 $datas[
'date'] .=
'-'.dol_print_date($this->datef,
'dayhourreduceformat',
'tzuserrel');
1742 if (!empty($this->recurid)) {
1743 $datas[
'recurring'] =
'<br><b>'.$langs->trans(
"RecurringEvent").
':</b> ';
1744 $datas[
'recurring'] .=
img_picto($langs->trans(
"EventPartOfARecurringSerie", $this->recurid),
'recurring',
'class="pictofixedwidth"');
1746 if (preg_match(
'/FREQ=MONTHLY_BYMONTHDAY(\d+)/', $this->recurrule, $reg)) {
1747 $datas[
'recurring'] .= $langs->trans(
"EveryMonth").
' <span class="opacitymedium small">('.$langs->trans(
"DayOfMonth").
' '.$reg[1].
' - '.$langs->trans(
"Until").
' '.
dol_print_date($this->recurdateend,
'day').
')</span>';
1751 if (!empty($this->email_msgid)) {
1752 $langs->load(
"mails");
1753 $datas[
'space'] =
'<br>';
1755 $datas[
'mailtopic'] =
'<br><b>'.$langs->trans(
'MailTopic').
':</b> '.
dol_escape_htmltag($this->email_subject);
1756 $datas[
'mailfrom'] =
'<br><b>'.$langs->trans(
'MailFrom').
':</b> '.
dol_htmlentities($this->email_from);
1757 $datas[
'mailto'] =
'<br><b>'.$langs->trans(
'MailTo').
':</b> '.
dol_htmlentities($this->email_to);
1758 if (!empty($this->email_tocc)) {
1759 $datas[
'mailcc'] =
'<br><b>'.$langs->trans(
'MailCC').
':</b> '.
dol_htmlentities($this->email_tocc);
1766 if (!empty($this->note_private)) {
1767 $datas[
'description'] =
'<br><hr>';
1771 $datas[
'note'] =
'<div class="tenlinesmax">';
1772 $datas[
'note'] .= (
dol_textishtml($texttoshow) ? str_replace(array(
"\r",
"\n"),
"", $texttoshow) : str_replace(array(
"\r",
"\n"),
'<br>', $texttoshow));
1773 $datas[
'note'] .=
'</div>';
1778 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1780 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1781 $form =
new Form($this->db);
1783 $tmpcategstring = $form->showCategories($this->
id, Categorie::TYPE_ACTIONCOMM, 1);
1784 if ($tmpcategstring) {
1785 $datas[
'categories'] =
'<br>'.$tmpcategstring;
1805 public function getNomUrl($withpicto = 0, $maxlength = 0, $morecss =
'', $option =
'', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1)
1807 global $conf, $langs, $user, $hookmanager, $action;
1809 if (!empty($conf->dol_no_mouse_hover)) {
1814 if ($user->hasRight(
'agenda',
'myactions',
'read') && ($this->authorid == $user->id || $this->userownerid == $user->id)) {
1817 if ($user->hasRight(
'agenda',
'myactions',
'read') && array_key_exists($user->id, $this->userassigned)) {
1820 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
1827 $label = $this->label;
1837 'id' => (string) $this->
id,
1838 'objecttype' => $this->element.($this->module ?
'@'.$this->module :
''),
1839 'option' => $option,
1842 $classfortooltip =
'classfortooltip';
1845 $classfortooltip =
'classforajaxtooltip';
1846 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1852 if (empty($notooltip)) {
1854 $label = $langs->trans(
"ShowAction");
1855 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
1857 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
1858 $linkclose .= $dataparams.
' class="'.$morecss.
' '.$classfortooltip.
'"';
1860 $linkclose .=
' class="'.$morecss.
'"';
1863 $query = [
'id' => $this->id];
1864 if ($option ==
'birthday') {
1865 $baseurl = DOL_URL_ROOT.
'/contact/perso.php';
1866 } elseif ($option ==
'holiday') {
1867 $baseurl = DOL_URL_ROOT.
'/holiday/card.php';
1869 $baseurl = DOL_URL_ROOT.
'/comm/action/card.php';
1872 if ($option !==
'nolink') {
1874 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1875 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1876 $add_save_lastsearch_values = 1;
1878 if ($add_save_lastsearch_values) {
1879 $query += [
'save_lastsearch_values' => 1];
1884 $linkstart =
'<a href="'.$url.
'"';
1885 $linkstart .= $linkclose.
'>';
1888 if ($option ==
'nolink') {
1893 if ($withpicto == 2) {
1895 $label = $labeltype;
1900 if (empty($this->label)) {
1901 $label = $labeltype;
1903 $label = $this->label;
1906 if ($maxlength < 0) {
1907 $labelshort = $this->ref;
1909 $labelshort =
dol_trunc(empty($this->label) ? $labeltype : $this->label, $maxlength);
1916 $label .= (preg_match(
'/'.preg_quote($labeltype,
'/').
'/', $label) ?
'' :
' ('.$langs->transnoentities(
"Action".$this->type_code).
')');
1921 $result .= $linkstart;
1923 $result .=
img_object(($notooltip ?
'' : $langs->trans(
"ShowAction").
': '.$label), ($overwritepicto ? $overwritepicto :
'action'), (($this->type_color && $overwritepicto) ?
'style="color: #'.$this->type_color.
' !important;" ' :
'').($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
' class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
1926 $result .= $linkend;
1929 $hookmanager->initHooks(array(
'actiondao'));
1930 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1931 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1933 $result = $hookmanager->resPrint;
1935 $result .= $hookmanager->resPrint;
1949 public function getTypePicto($morecss =
'pictofixedwidth paddingright valignmiddle', $titlealt =
'')
1954 if ($this->type_color) {
1955 $color =
'style="color: #'.$this->type_color.
' !important;"';
1957 if ($this->type_picto) {
1958 $imgpicto =
img_picto($titlealt, $this->type_picto,
'', 0, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1960 if ($this->type_code ===
'AC_RDV') {
1961 $imgpicto =
img_picto($titlealt,
'meeting', $color, 0, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1962 } elseif ($this->type_code ===
'AC_TEL') {
1963 $imgpicto =
img_picto($titlealt,
'object_phoning', $color, 0, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1964 } elseif ($this->type_code ===
'AC_FAX') {
1965 $imgpicto =
img_picto($titlealt,
'object_phoning_fax', $color, 0, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1966 } elseif ($this->type_code ===
'AC_EMAIL' || $this->type_code ===
'AC_EMAIL_IN' || $this->type_code ===
'AC_EMAILING' || (!empty($this->code) && preg_match(
'/_SENTBYMAIL/', $this->code))) {
1967 $imgpicto =
img_picto($titlealt,
'object_email', $color, 0, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1968 } elseif ($this->type_code ===
'AC_INT') {
1969 $imgpicto =
img_picto($titlealt,
'object_intervention', $color, 0, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1970 } elseif (!empty($this->code) && preg_match(
'/^TICKET_MSG/', $this->code)) {
1971 $imgpicto =
img_picto($titlealt,
'object_conversation', $color, 0, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1972 } elseif ((
string) $this->
type !=
'systemauto') {
1973 $imgpicto =
img_picto($titlealt,
'user-cog', $color, 0, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1975 $imgpicto =
img_picto($titlealt,
'cog', $color, 0, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1980 if ($this->
type !=
'systemauto') {
1981 $imgpicto =
img_picto($titlealt,
'user-cog',
'', 0, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1983 $imgpicto =
img_picto($titlealt,
'cog',
'', 0, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1999 global $conf, $langs;
2002 if (!empty($conf->cache[
'actioncommgetypelabel'])) {
2003 $arraylist = $conf->cache[
'actioncommgetypelabel'];
2005 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
2007 $arraylist = $caction->liste_array(1,
'code',
'', (
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 0 : 1),
'', 1);
2008 $conf->cache[
'actioncommgetypelabel'] = $arraylist;
2011 $labeltype = $this->type_code;
2013 $labeltype =
'AC_OTH';
2015 if (!empty($this->code) && preg_match(
'/^TICKET_MSG/', $this->code)) {
2016 $labeltype = $langs->trans(
"Message");
2018 if (!empty($arraylist[$labeltype])) {
2019 $labeltype = $arraylist[$labeltype];
2021 if ($this->type_code ==
'AC_OTH_AUTO' && ($this->type_code != $this->code) && $labeltype && !empty($arraylist[$this->code])) {
2022 $labeltype .=
' - '.$arraylist[$this->code];
2026 if ($this->
type ==
'systemauto' && $mode == 1) {
2027 $labeltype .=
' ('.$langs->trans(
"auto").
')';
2029 if ($this->
type ==
'systemauto' && $mode == 2) {
2030 $labeltype = $langs->trans(
"AutoActions").($this->type_code ==
'AC_OTH_AUTO' ?
'' :
': '.$labeltype);
2031 } elseif ($this->
type !=
'systemauto' && $mode == 2) {
2032 $labeltype = $langs->trans(
"ManualActions").($this->type_code ==
'AC_OTH' ?
'' :
': '.$labeltype);
2052 if (!is_array($categories)) {
2053 $categories = array($categories);
2057 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2059 $existing =
$c->containing($this->
id, Categorie::TYPE_ACTIONCOMM,
'id');
2062 if (is_array($existing)) {
2063 $to_del = array_diff($existing, $categories);
2064 $to_add = array_diff($categories, $existing);
2067 $to_add = $categories;
2071 foreach ($to_del as $del) {
2072 if (
$c->fetch($del) > 0) {
2073 $c->del_type($this, Categorie::TYPE_ACTIONCOMM);
2076 foreach ($to_add as $add) {
2077 if (
$c->fetch($add) > 0) {
2078 $c->add_type($this, Categorie::TYPE_ACTIONCOMM);
2096 public function build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholiday = 0)
2098 global $hookmanager;
2103 require_once DOL_DOCUMENT_ROOT.
"/core/lib/xcal.lib.php";
2104 require_once DOL_DOCUMENT_ROOT.
"/core/lib/date.lib.php";
2105 require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
2107 dol_syslog(get_class($this).
"::build_exportfile Build export file format=".$format.
", type=".$type.
", cachedelay=".$cachedelay.
", filename=".$filename.
", filters size=".count($filters), LOG_DEBUG);
2110 if (empty($format)) {
2117 if ($format ==
'ical') {
2120 $filename = $format.
'.'.$extension;
2124 $result =
dol_mkdir($conf->agenda->dir_temp);
2125 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
2133 $eventorganization =
'';
2139 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2141 dol_syslog(get_class($this).
"::build_exportfile file ".$outputfile.
" is not older than now - cachedelay (".$nowgmt.
" - ".$cachedelay.
"). Build is canceled");
2148 $eventarray = array();
2150 if (!empty($filters[
'module']) && $filters[
'module'] ==
'project@eventorganization') {
2151 $sql =
"SELECT p.rowid as id,";
2152 $sql .=
" p.date_start_event as datep,";
2153 $sql .=
" p.date_end_event as datep2,";
2154 $sql .=
" p.datec, p.tms as datem,";
2155 $sql .=
" p.title as label, '' as code, p.note_public, p.note_private, 0 as type_id,";
2156 $sql .=
" p.fk_soc,";
2157 $sql .=
" p.fk_user_creat as fk_user_author, p.fk_user_modif as fk_user_mod,";
2158 $sql .=
" 0 as fk_user_action,";
2159 $sql .=
" 0 as fk_contact, 100 as percentage,";
2160 $sql .=
" 0 as fk_element, '' as elementtype,";
2161 $sql .=
" 1 as priority, 0 as fulldayevent, p.location, 0 as transparency,";
2162 $sql .=
" u.firstname, u.lastname, '".$this->db->escape(
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"' as email,";
2163 $sql .=
" s.nom as socname,";
2164 $sql .=
" 0 as type_id, '' as type_code, '' as type_label";
2165 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
2166 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = p.fk_user_creat";
2167 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on s.rowid = p.fk_soc";
2169 $parameters = array(
'filters' => $filters);
2170 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
2171 $sql .= $hookmanager->resPrint;
2173 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
2175 foreach ($filters as $key => $value) {
2176 if ($key ==
'notolderthan' && $value !=
'') {
2177 $sql .=
" AND p.date_start_event >= '".$this->db->idate($now - ($value * 24 * 60 * 60)).
"'";
2179 if ($key ==
'year') {
2183 $sql .=
" AND p.id = ".(is_numeric($value) ? $value : 0);
2185 if ($key ==
'idfrom') {
2186 $sql .=
" AND p.id >= ".(is_numeric($value) ? $value : 0);
2188 if ($key ==
'idto') {
2189 $sql .=
" AND p.id <= ".(is_numeric($value) ? $value : 0);
2191 if ($key ==
'project') {
2192 $sql .=
" AND p.rowid = ".(is_numeric($value) ? $value : 0);
2194 if ($key ==
'status') {
2195 $sql .=
" AND p.fk_statut = ".((int) $value);
2200 $sql .=
" ORDER by date_start_event";
2202 $eventorganization =
'project';
2204 $sql =
"SELECT a.id,";
2205 $sql .=
" a.datep,";
2206 $sql .=
" a.datep2,";
2207 $sql .=
" a.datec, a.tms as datem,";
2208 $sql .=
" a.label, a.code, '' as note_public, a.note as note_private, a.fk_action as type_id,";
2209 $sql .=
" a.fk_soc,";
2210 $sql .=
" a.fk_user_author, a.fk_user_mod,";
2211 $sql .=
" a.fk_user_action,";
2212 $sql .=
" a.fk_contact, a.percent as percentage,";
2213 $sql .=
" a.fk_element, a.elementtype,";
2214 $sql .=
" a.priority, a.fulldayevent, a.location, a.transparency,";
2215 $sql .=
" u.firstname, u.lastname, u.email,";
2216 $sql .=
" s.nom as socname,";
2217 $sql .=
" c.id as type_id, c.code as type_code, c.libelle as type_label,";
2218 $sql .=
" num_vote, event_paid, a.status";
2219 $sql .=
" FROM (".MAIN_DB_PREFIX.
"c_actioncomm as c, ".MAIN_DB_PREFIX.
"actioncomm as a)";
2220 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_author";
2221 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on s.rowid = a.fk_soc";
2223 $parameters = array(
'filters' => $filters);
2224 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
2225 $sql .= $hookmanager->resPrint;
2228 if (!empty($filters[
'logint']) && $filters[
'logint']) {
2229 $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
2231 $sql .=
" WHERE a.fk_action = c.id";
2232 $sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
2234 foreach ($filters as $key => $value) {
2235 if ($key ==
'notolderthan' && $value !=
'') {
2236 $sql .=
" AND a.datep >= '".$this->db->idate($now - ($value * 24 * 60 * 60)).
"'";
2238 if ($key ==
'year') {
2242 $sql .=
" AND a.id = ".(is_numeric($value) ? $value : 0);
2244 if ($key ==
'idfrom') {
2245 $sql .=
" AND a.id >= ".(is_numeric($value) ? $value : 0);
2247 if ($key ==
'idto') {
2248 $sql .=
" AND a.id <= ".(is_numeric($value) ? $value : 0);
2250 if ($key ==
'project') {
2251 $sql .=
" AND a.fk_project = ".(is_numeric($value) ? $value : 0);
2253 if ($key ==
'notactiontype') {
2254 $sql .=
" AND c.type <> '".$this->db->escape($value).
"'";
2256 if ($key ==
'actiontype') {
2259 if (preg_match(
'/^!/', $newvalue)) {
2260 $newvalue = preg_replace(
'/^!/',
'', $value);
2263 $arraynewvalue = explode(
',', $newvalue);
2265 foreach ($arraynewvalue as $tmpval) {
2266 $newvalue .= ($newvalue ?
"," :
"").
"'".$tmpval.
"'";
2269 $sql .=
" AND c.type NOT IN (".$this->db->sanitize($newvalue, 1).
")";
2271 $sql .=
" AND c.type IN (".$this->db->sanitize($newvalue, 1).
")";
2274 if ($key ==
'actioncode') {
2277 if (preg_match(
'/^!/', $newvalue)) {
2278 $newvalue = preg_replace(
'/^!/',
'', $value);
2281 $arraynewvalue = explode(
',', $newvalue);
2283 foreach ($arraynewvalue as $tmpval) {
2284 $newvalue .= ($newvalue ?
"," :
"").
"'".$tmpval.
"'";
2287 $sql .=
" AND a.code NOT IN (".$this->db->sanitize($newvalue, 1).
")";
2289 $sql .=
" AND a.code IN (".$this->db->sanitize($newvalue, 1).
")";
2294 if ($key ==
'logint') {
2295 $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
2297 if ($key ==
'logina') {
2300 if (preg_match(
'/^!/', $logina)) {
2301 $logina = preg_replace(
'/^!/',
'', $logina);
2304 $userforfilter =
new User($this->db);
2305 $result = $userforfilter->fetch(0, $logina);
2307 $sql .=
" AND a.fk_user_author ".$condition.
" ".$userforfilter->id;
2308 } elseif ($result < 0 || $condition ==
'=') {
2309 $sql .=
" AND a.fk_user_author = 0";
2312 if ($key ==
'logint') {
2315 if (preg_match(
'/^!/', $logint)) {
2316 $logint = preg_replace(
'/^!/',
'', $logint);
2319 $userforfilter =
new User($this->db);
2320 $result = $userforfilter->fetch(0, $logint);
2322 $sql .=
" AND ar.fk_element = ".((int) $userforfilter->id);
2323 } elseif ($result < 0 || $condition ==
'=') {
2324 $sql .=
" AND ar.fk_element = 0";
2327 if ($key ==
'module') {
2328 if ($value ==
'conforbooth@eventorganization') {
2329 $value =
'@eventorganization';
2331 $sql .=
" AND c.module LIKE '%".$this->db->escape($value).
"'";
2333 if ($key ==
'status') {
2334 $sql .=
" AND a.status = ".((int) $value);
2338 $sql .=
" AND a.datep IS NOT NULL";
2340 $parameters = array(
'filters' => $filters);
2341 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
2342 $sql .= $hookmanager->resPrint;
2344 $sql .=
" ORDER by datep";
2347 if (!empty($filters[
'limit'])) {
2348 $sql .= $this->db->plimit((
int) $filters[
'limit']);
2353 dol_syslog(get_class($this).
"::build_exportfile select event(s)", LOG_DEBUG);
2355 $resql = $this->db->query($sql);
2358 while ($obj = $this->db->fetch_object($resql)) {
2363 $event[
'uid'] =
'dolibarragenda-'.$this->db->database_name.
'-'.$obj->id.
"@".$_SERVER[
"SERVER_NAME"];
2364 $event[
'type'] = $type;
2366 $datestart = (int) $this->db->jdate($obj->datep) - (
getDolGlobalInt(
'AGENDA_EXPORT_FIX_TZ') * 3600);
2369 if (is_numeric($this->db->jdate($obj->datep2))) {
2370 $dateend = (int) $this->db->jdate($obj->datep2) - (
getDolGlobalInt(
'AGENDA_EXPORT_FIX_TZ') * 3600);
2373 $dateend = $datestart;
2376 $duration = ($datestart && $dateend) ? ($dateend - $datestart) : 0;
2377 $event[
'summary'] = $obj->label.($obj->socname ?
" (".$obj->socname.
")" :
"");
2379 if (!empty($filters[
'module']) && $filters[
'module'] ==
'project@eventorganization') {
2380 $event[
'desc'] = $obj->note_public;
2382 $event[
'desc'] = $obj->note_private;
2384 $event[
'startdate'] = $datestart;
2385 $event[
'enddate'] = $dateend;
2386 $event[
'duration'] = $duration;
2388 $event[
'priority'] = $obj->priority;
2389 $event[
'fulldayevent'] = $obj->fulldayevent;
2390 $event[
'location'] = $obj->location;
2391 $event[
'transparency'] = (($obj->transparency > 0) ?
'OPAQUE' :
'TRANSPARENT');
2392 $event[
'category'] = $obj->type_label;
2393 $event[
'email'] = $obj->email;
2396 if ($eventorganization !=
'') {
2397 $link_subscription =
$dolibarr_main_url_root.
'/public/eventorganization/attendee_new.php?id='.((int) $obj->id).
'&type=global&noregistration=1';
2399 $link_subscription .=
'&securekey='.urlencode($encodedsecurekey);
2401 $event[
'url'] = $link_subscription;
2404 $event[
'created'] = (int) $this->db->jdate($obj->datec) - (
getDolGlobalInt(
'AGENDA_EXPORT_FIX_TZ') * 3600);
2405 $event[
'modified'] = (int) $this->db->jdate($obj->datem) - (
getDolGlobalInt(
'AGENDA_EXPORT_FIX_TZ') * 3600);
2406 $event[
'num_vote'] = $this->num_vote;
2407 $event[
'event_paid'] = $this->event_paid;
2408 $event[
'status'] = $this->status;
2411 $this->
id = $obj->id;
2414 $assignedUserArray = array();
2416 foreach ($this->userassigned as $key => $value) {
2417 $assignedUser =
new User($this->db);
2418 $assignedUser->fetch($value[
'id']);
2420 $assignedUserArray[$key] = $assignedUser;
2423 if (!empty($filters[
'module']) && $filters[
'module'] !=
'project@eventorganization') {
2424 $event[
'assignedUsers'] = $assignedUserArray;
2427 if ($qualified && $datestart) {
2428 $eventarray[] = $event;
2433 $parameters = array(
'filters' => $filters,
'eventarray' => &$eventarray);
2434 $reshook = $hookmanager->executeHooks(
'addMoreEventsExport', $parameters);
2436 $eventarray = $hookmanager->resArray;
2439 $this->error = $this->db->lasterror();
2443 if ($exportholiday == 1) {
2444 $langs->load(
"holiday");
2445 $title = $langs->transnoentities(
"Holidays");
2447 $sql =
"SELECT u.rowid as uid, u.lastname, u.firstname, u.email, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status";
2448 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
2449 $sql .=
" WHERE u.rowid = x.fk_user";
2450 $sql .=
" AND u.statut = '1'";
2451 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
2453 $resql = $this->db->query($sql);
2455 $num = $this->db->num_rows($resql);
2459 $obj = $this->db->fetch_object($resql);
2462 if ($obj->halfday == 1) {
2463 $event[
'fulldayevent'] =
false;
2467 } elseif ($obj->halfday == -1) {
2468 $event[
'fulldayevent'] =
false;
2473 $event[
'fulldayevent'] =
true;
2480 $timestampStart -= ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600);
2481 $timestampEnd -= ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600);
2484 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2485 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2486 $url = $urlwithroot.
'/holiday/card.php?id='.$obj->rowid;
2488 $event[
'uid'] =
'dolibarrholiday-'.$this->db->database_name.
'-'.$obj->rowid.
"@".$_SERVER[
"SERVER_NAME"];
2490 $event[
'type'] =
'event';
2491 $event[
'category'] =
"Holiday";
2492 $event[
'transparency'] =
'OPAQUE';
2493 $event[
'email'] = $obj->email;
2494 $event[
'created'] = $timestampStart;
2495 $event[
'modified'] = $timestampStart;
2496 $event[
'startdate'] = $timestampStart;
2497 $event[
'enddate'] = $timestampEnd;
2498 $event[
'duration'] = $timestampEnd - $timestampStart;
2499 $event[
'url'] = $url;
2501 if ($obj->status == 2) {
2503 $event[
'summary'] = $title.
" - ".$obj->lastname.
" (wait for approval)";
2506 $event[
'summary'] = $title.
" - ".$obj->lastname;
2509 $eventarray[] = $event;
2516 $langs->load(
"agenda");
2522 $more = $langs->transnoentities(
"User").
' '.$login;
2525 $more = $langs->transnoentities(
"ActionsAskedBy").
' '.$logina;
2528 $more = $langs->transnoentities(
"ActionsToDoBy").
' '.$logint;
2530 if ($eventorganization) {
2531 $langs->load(
"eventorganization");
2532 $title = $langs->transnoentities(
"OrganizedEvent").(empty($eventarray[0][
'label']) ?
'' :
' '.$eventarray[0][
'label']);
2533 $more =
'ICS file - '.$langs->transnoentities(
"OrganizedEvent").(empty($eventarray[0][
'label']) ?
'' :
' '.$eventarray[0][
'label']);
2536 if (empty($title)) {
2537 $title =
'Dolibarr actions '.$mysoc->name.
' - '.$more;
2540 $desc .=
' ('.$mysoc->name.
' - built by Dolibarr)';
2542 if (empty($title)) {
2543 $title = $langs->transnoentities(
"Events").
' '.
$mysoc->name;
2545 $desc = $langs->transnoentities(
'ListOfActions');
2546 $desc .=
' ('.$mysoc->name.
' - built by Dolibarr)';
2550 $outputfiletmp = tempnam($conf->agenda->dir_temp,
'tmp');
2554 if ($format ==
'vcal') {
2555 $result =
build_calfile($format, $title, $desc, $eventarray, $outputfiletmp);
2556 } elseif ($format ==
'ical') {
2557 $result =
build_calfile($format, $title, $desc, $eventarray, $outputfiletmp);
2558 } elseif ($format ==
'rss') {
2559 $result =
build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp);
2563 if (
dol_move($outputfiletmp, $outputfile,
'0', 1, 0, 0)) {
2566 $this->error =
'Failed to rename '.$outputfiletmp.
' into '.$outputfile;
2567 dol_syslog(get_class($this).
"::build_exportfile ".$this->error, LOG_ERR);
2572 dol_syslog(get_class($this).
"::build_exportfile build_xxxfile function fails to for format=".$format.
" outputfiletmp=".$outputfile, LOG_ERR);
2574 $langs->load(
"errors");
2575 $this->error = $langs->trans(
"ErrorFailToCreateFile", $outputfile);
2597 $this->specimen = 1;
2599 $this->type_code =
'AC_OTH';
2600 $this->code =
'AC_SPECIMEN_CODE';
2601 $this->label =
'Label of event Specimen';
2602 $this->datec = $now;
2603 $this->datem = $now;
2604 $this->datep = $now;
2605 $this->datef = $now;
2606 $this->fulldayevent = 0;
2607 $this->percentage = 0;
2609 $this->location =
'Location';
2610 $this->transparency = 1;
2611 $this->priority = 1;
2613 $this->note_private =
"This is a 'private' note.";
2615 $this->userownerid = $user->id;
2616 $this->userassigned[$user->id] = array(
'id' => $user->id,
'transparency' => 1);
2647 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'actioncomm SET fk_element = ' . ((int) $dest_id) .
' WHERE elementtype="product" AND fk_element = '.((int) $origin_id);
2649 if (!$dbs->
query($sql)) {
2668 return $this->datep && ($this->datep < ($now - $conf->agenda->warning_delay));
2684 $this->reminders = array();
2687 $sql =
"SELECT rowid as id, typeremind, dateremind, status, offsetvalue, offsetunit, fk_user, fk_email_template, lasterror";
2688 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
2689 $sql .=
" WHERE fk_actioncomm = ".((int) $this->
id);
2691 $sql .=
" AND dateremind <= '".$this->db->idate(
dol_now()).
"'";
2694 $sql .=
" AND typeremind = '".$this->db->escape($type).
"'";
2697 $sql .=
" AND fk_user = ".((int) $fk_user);
2700 $sql .=
" AND typeremind <> 'email'";
2703 $sql .=
" AND typeremind <> 'browser'";
2706 $sql .= $this->db->order(
"dateremind",
"ASC");
2707 $resql = $this->db->query($sql);
2710 while ($obj = $this->db->fetch_object($resql)) {
2712 $tmpactioncommreminder->id = $obj->id;
2713 $tmpactioncommreminder->typeremind = $obj->typeremind;
2714 $tmpactioncommreminder->dateremind = $this->db->jdate($obj->dateremind);
2715 $tmpactioncommreminder->offsetvalue = $obj->offsetvalue;
2716 $tmpactioncommreminder->offsetunit = $obj->offsetunit;
2717 $tmpactioncommreminder->status = $obj->status;
2718 $tmpactioncommreminder->fk_user = $obj->fk_user;
2719 $tmpactioncommreminder->fk_email_template = $obj->fk_email_template;
2720 $tmpactioncommreminder->lasterror = $obj->lasterror;
2721 $tmpactioncommreminder->fk_actioncomm = $this->id;
2723 $this->reminders[$obj->id] = $tmpactioncommreminder;
2726 $this->error = $this->db->lasterror();
2730 return count($this->reminders);
2742 global $langs, $user;
2748 $errorsMsg = array();
2751 $langs->load(
"agenda");
2752 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Agenda"));
2756 $langs->load(
"agenda");
2757 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Agenda"));
2769 $sql =
"SELECT rowid as id FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
2770 $sql .=
" WHERE typeremind = 'email'";
2771 $sql .=
" AND status = 0";
2772 $sql .=
" AND dateremind <= '".$this->db->idate($now).
"'";
2773 $sql .=
" AND entity IN (".getEntity(
'actioncomm').
")";
2774 $sql .= $this->db->order(
"dateremind",
"ASC");
2775 $resql = $this->db->query($sql);
2778 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
2779 $formmail =
new FormMail($this->db);
2782 while ($obj = $this->db->fetch_object($resql)) {
2783 $res = $actionCommReminder->fetch($obj->id);
2786 $errorsMsg[] =
"Failed to load invoice ActionComm Reminder";
2791 $arraymessage = $formmail->getEMailTemplate($this->db,
'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1);
2794 $res = $this->
fetch($actionCommReminder->fk_actioncomm);
2801 $substitutionarray = getCommonSubstitutionArray($langs, 0,
null, $this);
2806 $sendContent =
make_substitutions($langs->trans($arraymessage->content), $substitutionarray);
2809 $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : $langs->transnoentitiesnoconv(
'EventReminder');
2813 $recipient =
new User($this->db);
2814 $res = $recipient->fetch($actionCommReminder->fk_user);
2816 if (!empty($recipient->email)) {
2817 $to = $recipient->email;
2819 $errormesg =
"Failed to send remind to user id=" . $actionCommReminder->fk_user .
". No email defined for user.";
2823 $errormesg =
"Failed to load recipient with user id=" . $actionCommReminder->fk_user;
2830 $errormesg =
"Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM";
2839 $cMailFile =
new CMailFile($sendTopic, (
string) $to, $from, $sendContent, array(), array(), array(),
'',
"", 0, 1, $errors_to,
'',
'',
'',
'',
'');
2842 if ($cMailFile->sendfile()) {
2845 $errormesg =
'Failed to send email to: ' . $to .
' ' . $cMailFile->error . implode(
',', $cMailFile->errors);
2851 $actionCommReminder->status = $actionCommReminder::STATUS_DONE;
2853 $res = $actionCommReminder->update($user);
2855 $errorsMsg[] =
"Failed to update status to done of ActionComm Reminder";
2860 $actionCommReminder->status = $actionCommReminder::STATUS_ERROR;
2861 $actionCommReminder->lasterror =
dol_trunc($errormesg, 128,
'right',
'UTF-8', 1);
2863 $res = $actionCommReminder->update($user);
2865 $errorsMsg[] =
"Failed to update status to error of ActionComm Reminder";
2869 $errorsMsg[] = $errormesg;
2873 $errorsMsg[] =
'Failed to fetch record actioncomm with ID = '.$actionCommReminder->fk_actioncomm;
2884 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
2885 $sql .=
" WHERE dateremind < '".$this->db->idate($now - (3600 * 24 * 32)).
"'";
2886 $sql .=
" AND status = ".((int) $actionCommReminder::STATUS_DONE);
2887 $resql = $this->db->query($sql);
2890 $errorsMsg[] =
'Failed to delete old reminders';
2896 $this->output =
'Nb of emails sent : '.$nbMailSend;
2897 $this->db->commit();
2899 dol_syslog(__METHOD__.
" end - ".$this->output, LOG_INFO);
2903 $this->db->commit();
2904 $this->error =
'Nb of emails sent : '.$nbMailSend.
', '.(!empty($errorsMsg) ? implode(
', ', $errorsMsg) : $error);
2906 dol_syslog(__METHOD__.
" end - ".$this->error, LOG_INFO);
2920 global $langs, $user;
2926 $errorsMsg = array();
2929 $langs->load(
"agenda");
2930 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Agenda"));
2934 $langs->load(
"agenda");
2935 $this->output = $langs->trans(
'EventRemindersBySmsNotEnabled', $langs->transnoentitiesnoconv(
"Agenda"));
2947 $sql =
"SELECT rowid as id FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
2948 $sql .=
" WHERE typeremind = 'sms'";
2949 $sql .=
" AND status = 0";
2950 $sql .=
" AND dateremind <= '".$this->db->idate($now).
"'";
2951 $sql .=
" AND entity IN (".getEntity(
'actioncomm').
")";
2952 $sql .= $this->db->order(
"dateremind",
"ASC");
2953 $resql = $this->db->query($sql);
2956 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
2957 $formmail =
new FormMail($this->db);
2960 while ($obj = $this->db->fetch_object($resql)) {
2961 $res = $actionCommReminder->fetch($obj->id);
2964 $errorsMsg[] =
"Failed to load invoice ActionComm Reminder";
2969 $arraymessage = $formmail->getEMailTemplate($this->db,
'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1);
2972 $res = $this->
fetch($actionCommReminder->fk_actioncomm);
2979 $substitutionarray = getCommonSubstitutionArray($langs, 0,
null, $this);
2990 $recipient =
new User($this->db);
2991 $res = $recipient->fetch($actionCommReminder->fk_user);
2993 if (!empty($recipient->user_mobile)) {
2994 $to = $recipient->user_mobile;
2996 $errormesg =
"Failed to send remind to user id=" . $actionCommReminder->fk_user .
". No email defined for user.";
3000 $errormesg =
"Failed to load recipient with user id=" . $actionCommReminder->fk_user;
3007 $errormesg =
"Failed to get sender into global setup MAIN_SMS_FROM";
3016 $CSMSFile =
new CSMSFile((
string) $to, $from, $sendContent, 0, 0, 3, 1);
3019 if ($CSMSFile->sendfile()) {
3022 $errormesg =
'Failed to send email to: ' . $to .
' ' . $CSMSFile->error . implode(
',', $CSMSFile->errors);
3028 $actionCommReminder->status = $actionCommReminder::STATUS_DONE;
3030 $res = $actionCommReminder->update($user);
3032 $errorsMsg[] =
"Failed to update status to done of ActionComm Reminder";
3037 $actionCommReminder->status = $actionCommReminder::STATUS_ERROR;
3038 $actionCommReminder->lasterror =
dol_trunc($errormesg, 128,
'right',
'UTF-8', 1);
3040 $res = $actionCommReminder->update($user);
3042 $errorsMsg[] =
"Failed to update status to error of ActionComm Reminder";
3046 $errorsMsg[] = $errormesg;
3050 $errorsMsg[] =
'Failed to fetch record actioncomm with ID = '.$actionCommReminder->fk_actioncomm;
3061 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
3062 $sql .=
" WHERE dateremind < '".$this->db->idate($now - (3600 * 24 * 32)).
"'";
3063 $sql .=
" AND status = ".((int) $actionCommReminder::STATUS_DONE);
3064 $resql = $this->db->query($sql);
3067 $errorsMsg[] =
'Failed to delete old reminders';
3073 $this->output =
'Nb of SMS sent : '.$nbSmsSent;
3074 $this->db->commit();
3075 dol_syslog(__METHOD__.
" end - ".$this->output, LOG_INFO);
3079 $this->db->commit();
3080 $this->error =
'Nb of SMS sent : '.$nbSmsSent.
', '.(!empty($errorsMsg) ? implode(
', ', $errorsMsg) : $error);
3081 dol_syslog(__METHOD__.
" end - ".$this->error, LOG_INFO);
3099 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"actioncomm ";
3100 $sql .=
" SET percent = ".(int) $percent;
3101 if ($usermodid > 0) {
3102 $sql .=
", fk_user_mod = ".((int) $usermodid);
3104 $sql .=
" WHERE id = ".((int) $id);
3106 if ($this->db->query($sql)) {
3107 $this->db->commit();
3110 $this->db->rollback();
3111 $this->error = $this->db->lasterror();
$id
Support class for third parties, contacts, members, users or resources.
global $dolibarr_main_url_root
Class to manage agenda events (actions)
const EVENT_FINISHED
Typical value for a event that is in a finished state.
hasDelay()
Is the action delayed?
build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholiday=0)
Export events from database into a cal file.
getTooltipContentArray($params)
getTooltipContentArray
update(User $user, $notrigger=0)
Update action into database If percentage = 100, on met a jour date 100%.
sendSmsReminder()
Send reminders by sms CAN BE A CRON TASK.
fetch_userassigned($override=true)
Initialize this->userassigned array with list of id of user assigned to event.
info($id)
Charge les information d'ordre info dans l'objet facture.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
const EVENT_IN_PROGRESS
Typical value for a event that is in a progress state.
sendEmailsReminder()
Send reminders by emails CAN BE A CRON TASK.
create(User $user, $notrigger=0)
Add an action/event into database.
const EVENT_TODO
Typical value for a event that is in a todo state.
setCategories($categories)
Sets object to supplied categories.
createFromClone(User $fuser, $socid)
Load an object from its id and create a new one in database.
getNomUrl($withpicto=0, $maxlength=0, $morecss='', $option='', $overwritepicto=0, $notooltip=0, $save_lastsearch_value=-1)
Return URL of event This uses $this->id, $this->type_code, $this->label and $this->type_label.
LibStatut($percent, $mode, $hidenastatus=0, $datestart='')
Return label of action status.
getActions($socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='a.datep', $sortorder='DESC', $limit=0)
Load all objects with filters.
load_board($user, $load_state_board=0)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
fetch($id, $ref='', $ref_ext='', $email_msgid='', $loadresources=1)
Load object from database.
updatePercent($id, $percent, $usermodid=0)
Update the percent value of a event with the given id.
getTypeLabel($mode=0)
Return label of type of event.
loadReminders($type='', $fk_user=0, $onlypast=true)
Load event reminder of events.
fetchResources()
Initialize $this->userassigned & this->socpeopleassigned array with list of id of user and contact as...
static replaceProduct(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a product id with another one.
getTypePicto($morecss='pictofixedwidth paddingright valignmiddle', $titlealt='')
Return Picto of type of event.
__construct(DoliDB $db)
Constructor.
initAsSpecimen()
Initialise an instance with random values.
$fields
Array with all fields and their property.
getLibStatut($mode, $hidenastatus=0)
Return the label of the status.
Class for ActionCommReminder.
Class to manage different types of events.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to send SMS Usage: $smsfile = new CSMSFile($subject,$sendto,$replyto,$message,...
Class to manage categories.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
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...
fetch_thirdparty($force_thirdparty_id=0)
Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty.
setErrorsFromObject($object)
setErrorsFromObject
deleteExtraFields()
Delete all extra fields values for the current object.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
cloneCategories($fromId, $toId, $type='')
Copy related categories to another object.
Class to manage Dolibarr database access.
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...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_move($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=1, $moreinfo=array(), $entity=null)
Move a file into another name.
dol_filemtime($pathoffile)
Return time of a file.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_now($mode='gmt')
Return date for now.
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)
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_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.
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.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
query($query, $usesavepoint=0, $type='auto', $result_mode=0)
Execute a SQL request and return the resultset.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.
build_calfile($format, $title, $desc, $events_array, $outputfile)
Build a file from an array of events All input params and data must be encoded in $conf->charset_outp...
build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter='', $url='', $langcode='')
Build a file from an array of events.