29require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncommreminder.class.php';
43 public $element =
'action';
48 public $table_element =
'actioncomm';
53 public $table_rowid =
'id';
58 public $picto =
'action';
63 public $ismultientitymanaged = 1;
70 public $restrictiononfksoc = 2;
184 public $date_start_in_calendar;
189 public $date_end_in_calendar;
200 public $durationp = -1;
205 public $fulldayevent = 0;
225 public $transparency;
235 public $userassigned = array();
250 public $socpeopleassigned = array();
255 public $otherassigned = array();
260 public $reminders = array();
306 public $fk_bookcal_calendar;
326 public $actions = array();
341 public $email_sender;
360 public $email_subject;
387 public $recurdateend;
389 public $calling_duration;
408 public $fields = array();
431 global $langs, $conf;
437 if (!isset($this->userownerid) || (
string) $this->userownerid ===
'') {
438 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);
439 $this->errors[] =
'ErrorActionCommPropertyUserowneridNotDefined';
444 $this->label =
dol_trunc(trim($this->label), 128);
445 $this->location =
dol_trunc(trim($this->location), 128);
446 $this->note_private =
dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private));
447 if (empty($this->percentage)) {
448 $this->percentage = 0;
450 if (empty($this->priority) || !is_numeric($this->priority)) {
453 if (empty($this->fulldayevent)) {
454 $this->fulldayevent = 0;
456 if (empty($this->transparency)) {
457 $this->transparency = 0;
459 if ($this->percentage > 100) {
460 $this->percentage = 100;
462 if (empty($this->datep) && $this->datep !=
'0') {
465 if (!empty($this->datep) && !empty($this->datef)) {
466 $this->durationp = ($this->datef - $this->datep);
468 if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) {
469 $this->datef = $this->datep;
471 if (!isset($this->fk_project) || $this->fk_project < 0) {
472 $this->fk_project = 0;
475 if ($this->elementtype ==
'facture') {
476 $this->elementtype =
'invoice';
478 if ($this->elementtype ==
'commande') {
479 $this->elementtype =
'order';
481 if ($this->elementtype ==
'contrat') {
482 $this->elementtype =
'contract';
484 if (empty($this->fk_element) && !empty($this->elementid)) {
485 $this->fk_element = $this->elementid;
488 if (!is_array($this->userassigned) && !empty($this->userassigned)) {
489 $tmpid = (int) $this->userassigned;
490 $this->userassigned = array();
491 $this->userassigned[$tmpid] = array(
'id'=>$tmpid,
'transparency'=>$this->transparency);
494 $userownerid = $this->userownerid;
495 $userdoneid = $this->userdoneid;
498 if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) {
499 $this->userassigned = array($userownerid=>array(
'id'=>$userownerid,
'transparency'=>$this->transparency));
502 if (!$this->type_id || !$this->type_code) {
503 $key = empty($this->type_id) ? $this->type_code : $this->type_id;
507 $result = $cactioncomm->fetch($key);
510 $this->type_id = $cactioncomm->id;
511 $this->type_code = $cactioncomm->code;
512 } elseif ($result == 0) {
513 $this->error = $langs->trans(
'ErrorActionCommBadType', $this->type_id, $this->type_code);
516 $this->error = $cactioncomm->error;
520 $code = empty($this->code) ? $this->type_code : $this->code;
523 if (!$this->type_id) {
524 $this->error =
"ErrorWrongParameters";
530 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm";
535 $sql .=
"durationp,";
536 $sql .=
"fk_action,";
540 $sql .=
"fk_project,";
542 $sql .=
"fk_contact,";
543 $sql .=
"fk_user_author,";
544 $sql .=
"fk_user_action,";
545 $sql .=
"fk_user_done,";
546 $sql .=
"label,percent,priority,fulldayevent,location,";
547 $sql .=
"transparency,";
548 $sql .=
"fk_element,";
549 $sql .=
"elementtype,";
550 $sql .=
"fk_bookcal_calendar,";
552 $sql .=
"extraparams,";
554 $sql .=
"email_msgid,";
555 $sql .=
"email_from,";
556 $sql .=
"email_sender,";
558 $sql .=
"email_tocc,";
559 $sql .=
"email_tobcc,";
560 $sql .=
"email_subject,";
561 $sql .=
"errors_to,";
563 $sql .=
"recurrule,";
564 $sql .=
"recurdateend,";
566 $sql .=
"event_paid,";
569 $sql .=
") VALUES (";
570 $sql .=
"'(PROV)', ";
571 $sql .=
"'".$this->db->idate($now).
"', ";
572 $sql .=
"'".$this->db->idate($this->datep).
"', ";
573 $sql .= (strval($this->datef) !=
'' ?
"'".$this->db->idate($this->datef).
"'" :
"null").
", ";
574 $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp !=
'') ?
"'".$this->db->escape($this->durationp).
"'" :
"null").
", ";
575 $sql .= (isset($this->type_id) ? $this->type_id :
"null").
",";
576 $sql .= ($code ? (
"'".$this->db->escape($code).
"'") :
"null").
", ";
577 $sql .= (!empty($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
"null").
", ";
578 $sql .= ((isset($this->socid) && $this->socid > 0) ? ((
int) $this->socid) :
"null").
", ";
579 $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? ((
int) $this->fk_project) :
"null").
", ";
580 $sql .=
" '".$this->db->escape($this->note_private).
"', ";
581 $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? ((
int) $this->contact_id) :
"null").
", ";
582 $sql .= (isset($user->id) && $user->id > 0 ? $user->id :
"null").
", ";
583 $sql .= ($userownerid > 0 ? $userownerid :
"null").
", ";
584 $sql .= ($userdoneid > 0 ? $userdoneid :
"null").
", ";
585 $sql .=
"'".$this->db->escape($this->label).
"', ";
586 $sql .=
"'".$this->db->escape($this->percentage).
"', ";
587 $sql .=
"'".$this->db->escape($this->priority).
"', ";
588 $sql .=
"'".$this->db->escape($this->fulldayevent).
"', ";
589 $sql .=
"'".$this->db->escape($this->location).
"', ";
590 $sql .=
"'".$this->db->escape($this->transparency).
"', ";
591 $sql .= (!empty($this->fk_element) ? ((int) $this->fk_element) :
"null").
", ";
592 $sql .= (!empty($this->elementtype) ?
"'".$this->db->escape($this->elementtype).
"'" :
"null").
", ";
593 $sql .= (!empty($this->fk_bookcal_calendar) ?
"'".$this->db->escape($this->fk_bookcal_calendar).
"'" :
"null").
", ";
594 $sql .= ((int) $conf->entity).
",";
595 $sql .= (!empty($this->extraparams) ?
"'".$this->db->escape($this->extraparams).
"'" :
"null").
", ";
597 $sql .= (!empty($this->email_msgid) ?
"'".$this->db->escape($this->email_msgid).
"'" :
"null").
", ";
598 $sql .= (!empty($this->email_from) ?
"'".$this->db->escape($this->email_from).
"'" :
"null").
", ";
599 $sql .= (!empty($this->email_sender) ?
"'".$this->db->escape($this->email_sender).
"'" :
"null").
", ";
600 $sql .= (!empty($this->email_to) ?
"'".$this->db->escape($this->email_to).
"'" :
"null").
", ";
601 $sql .= (!empty($this->email_tocc) ?
"'".$this->db->escape($this->email_tocc).
"'" :
"null").
", ";
602 $sql .= (!empty($this->email_tobcc) ?
"'".$this->db->escape($this->email_tobcc).
"'" :
"null").
", ";
603 $sql .= (!empty($this->email_subject) ?
"'".$this->db->escape($this->email_subject).
"'" :
"null").
", ";
604 $sql .= (!empty($this->errors_to) ?
"'".$this->db->escape($this->errors_to).
"'" :
"null").
", ";
605 $sql .= (!empty($this->recurid) ?
"'".$this->db->escape($this->recurid).
"'" :
"null").
", ";
606 $sql .= (!empty($this->recurrule) ?
"'".$this->db->escape($this->recurrule).
"'" :
"null").
", ";
607 $sql .= (!empty($this->recurdateend) ?
"'".$this->db->idate($this->recurdateend).
"'" :
"null").
", ";
608 $sql .= (!empty($this->num_vote) ? (int) $this->num_vote :
"null").
", ";
609 $sql .= (!empty($this->event_paid) ? (int) $this->event_paid : 0).
", ";
610 $sql .= (!empty($this->
status) ? (int) $this->
status :
"0").
", ";
611 $sql .= (!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
614 dol_syslog(get_class($this).
"::add", LOG_DEBUG);
615 $resql = $this->db->query($sql);
617 $this->
ref = $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"actioncomm",
"id");
618 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"actioncomm SET ref='".$this->db->escape($this->
ref).
"' WHERE id=".$this->id;
619 $resql = $this->db->query($sql);
622 dol_syslog(
'Error to process ref: '.$this->db->lasterror(), LOG_ERR);
623 $this->errors[] = $this->db->lasterror();
628 $already_inserted = array();
629 foreach ($this->userassigned as $key => $val) {
631 if (!is_array($val)) {
632 $val = array(
'id'=>$val);
635 if ($val[
'id'] > 0) {
636 if (!empty($already_inserted[$val[
'id']])) {
640 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
641 $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'])).
")";
643 $resql = $this->db->query($sql);
646 dol_syslog(
'Error to process userassigned: ' . $this->db->lasterror(), LOG_ERR);
647 $this->errors[] = $this->db->lasterror();
649 $already_inserted[$val[
'id']] =
true;
657 if (!empty($this->socpeopleassigned)) {
658 $already_inserted = array();
659 foreach ($this->socpeopleassigned as $id => $val) {
661 if (!empty($already_inserted[$id])) {
665 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
666 $sql .=
" VALUES(".((int) $this->
id).
", 'socpeople', ".((int) $id).
", 0, 0, 0)";
668 $resql = $this->db->query($sql);
671 dol_syslog(
'Error to process socpeopleassigned: ' . $this->db->lasterror(), LOG_ERR);
672 $this->errors[] = $this->db->lasterror();
674 $already_inserted[$id] =
true;
688 if (!$error && !$notrigger) {
701 $this->db->rollback();
705 $this->db->rollback();
706 $this->error = $this->db->lasterror();
727 $objFrom = clone $this;
738 $this->recurrule =
'';
739 $this->recurdateend =
'';
742 $this->context[
'createfromclone'] =
'createfromclone';
743 $result = $this->
create($fuser);
750 if (is_object($hookmanager)) {
751 $parameters = array(
'objFrom'=>$objFrom);
753 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $this, $action);
768 unset($this->context[
'createfromclone']);
775 $this->db->rollback();
790 public function fetch($id, $ref =
'', $ref_ext =
'', $email_msgid =
'', $loadresources = 1)
794 if (empty($id) && empty($ref) && empty($ref_ext) && empty($email_msgid)) {
795 dol_syslog(get_class($this).
"::fetch Bad parameters", LOG_WARNING);
799 $sql =
"SELECT a.id,";
800 $sql .=
" a.ref as ref,";
801 $sql .=
" a.entity,";
802 $sql .=
" a.ref_ext,";
804 $sql .=
" a.datep2,";
805 $sql .=
" a.durationp,";
807 $sql .=
" a.tms as datem,";
808 $sql .=
" a.code, a.label, a.note as note_private,";
809 $sql .=
" a.fk_soc,";
810 $sql .=
" a.fk_project,";
811 $sql .=
" a.fk_user_author, a.fk_user_mod,";
812 $sql .=
" a.fk_user_action, a.fk_user_done,";
813 $sql .=
" a.fk_contact, a.percent as percentage,";
814 $sql .=
" a.fk_element as elementid, a.elementtype,";
815 $sql .=
" a.priority, a.fulldayevent, a.location, a.transparency,";
816 $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,";
817 $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,";
818 $sql .=
" s.nom as socname,";
819 $sql .=
" u.firstname, u.lastname as lastname,";
820 $sql .=
" num_vote, event_paid, a.status";
821 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a ";
822 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action=c.id ";
823 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_author";
824 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on s.rowid = a.fk_soc";
827 $sql .=
" a.ref = '".$this->db->escape($ref).
"'";
828 } elseif ($ref_ext) {
829 $sql .=
" a.ref_ext = '".$this->db->escape($ref_ext).
"'";
830 } elseif ($email_msgid) {
831 $sql .=
" a.email_msgid = '".$this->db->escape($email_msgid).
"'";
833 $sql .=
" a.id = ".((int) $id);
836 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
837 $resql = $this->db->query($sql);
839 $num = $this->db->num_rows($resql);
841 $obj = $this->db->fetch_object($resql);
843 $this->
id = $obj->id;
844 $this->entity = $obj->entity;
845 $this->
ref = $obj->ref;
846 $this->ref_ext = $obj->ref_ext;
849 $this->type_id = $obj->type_id;
850 $this->type_code = $obj->type_code;
851 $this->type_color = $obj->type_color;
852 $this->type_picto = $obj->type_picto;
853 $this->
type = $obj->type_type;
855 $this->code = $obj->code;
856 $this->label = $obj->label;
857 $this->datep = $this->db->jdate($obj->datep);
858 $this->datef = $this->db->jdate($obj->datep2);
860 $this->datec = $this->db->jdate($obj->datec);
861 $this->datem = $this->db->jdate($obj->datem);
863 $this->note = $obj->note_private;
864 $this->note_private = $obj->note_private;
865 $this->percentage = $obj->percentage;
867 $this->authorid = $obj->fk_user_author;
868 $this->usermodid = $obj->fk_user_mod;
870 if (!is_object($this->author)) {
871 $this->author =
new User($this->db);
873 $this->author->id = $obj->fk_user_author;
874 $this->author->firstname = $obj->firstname;
875 $this->author->lastname = $obj->lastname;
876 if (!is_object($this->usermod)) {
877 $this->usermod =
new User($this->db);
879 $this->usermod->id = $obj->fk_user_mod;
881 $this->userownerid = $obj->fk_user_action;
882 $this->priority = $obj->priority;
883 $this->fulldayevent = $obj->fulldayevent;
884 $this->location = $obj->location;
885 $this->transparency = $obj->transparency;
887 $this->socid = $obj->fk_soc;
888 $this->contact_id = $obj->fk_contact;
889 $this->fk_project = $obj->fk_project;
894 $this->fk_element = $obj->elementid;
895 $this->elementid = $obj->elementid;
896 $this->elementtype = $obj->elementtype;
898 $this->num_vote = $obj->num_vote;
899 $this->event_paid = $obj->event_paid;
900 $this->
status = $obj->status;
903 $this->email_msgid=$obj->email_msgid;
904 $this->email_from=$obj->email_from;
905 $this->email_sender=$obj->email_sender;
906 $this->email_to=$obj->email_to;
907 $this->email_tocc=$obj->email_tocc;
908 $this->email_tobcc=$obj->email_tobcc;
909 $this->email_subject=$obj->email_subject;
910 $this->errors_to=$obj->errors_to;
914 if ($loadresources) {
919 $this->db->free($resql);
921 $this->error = $this->db->lasterror();
935 $this->userassigned = array();
936 $this->socpeopleassigned = array();
938 $sql =
'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency';
939 $sql .=
' FROM '.MAIN_DB_PREFIX.
'actioncomm_resources';
940 $sql .=
' WHERE fk_actioncomm = '.((int) $this->
id);
941 $sql .=
" AND element_type IN ('user', 'socpeople')";
942 $resql = $this->db->query($sql);
945 if ($this->userownerid > 0) {
946 $this->userassigned[$this->userownerid] = array(
'id'=>$this->userownerid);
949 while ($obj = $this->db->fetch_object($resql)) {
950 if ($obj->fk_element > 0) {
951 switch ($obj->element_type) {
953 $this->userassigned[$obj->fk_element] = array(
'id'=>$obj->fk_element,
'mandatory'=>$obj->mandatory,
'answer_status'=>$obj->answer_status,
'transparency'=>$obj->transparency);
954 if (empty($this->userownerid)) {
955 $this->userownerid = $obj->fk_element;
959 $this->socpeopleassigned[$obj->fk_element] = array(
'id'=>$obj->fk_element,
'mandatory'=>$obj->mandatory,
'answer_status'=>$obj->answer_status,
'transparency'=>$obj->transparency);
982 $sql =
"SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency";
983 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm_resources";
984 $sql .=
" WHERE element_type = 'user' AND fk_actioncomm = ".((int) $this->
id);
986 $resql2 = $this->db->query($sql);
988 $this->userassigned = array();
991 if ($this->userownerid > 0) {
993 $this->userassigned[$this->userownerid] = array(
'id'=>$this->userownerid);
996 while ($obj = $this->db->fetch_object($resql2)) {
997 if ($obj->fk_element > 0) {
998 $this->userassigned[$obj->fk_element] = array(
'id'=>$obj->fk_element,
999 'mandatory'=>$obj->mandatory,
1000 'answer_status'=>$obj->answer_status,
1001 'transparency'=>$obj->transparency);
1004 if ($override ===
true) {
1006 if (empty($this->userownerid)) {
1007 $this->userownerid = $obj->fk_element;
1026 public function delete($notrigger = 0)
1032 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1038 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm";
1039 $sql .=
" WHERE fk_actioncomm=".((int) $this->
id);
1041 $res = $this->db->query($sql);
1043 $this->error = $this->db->lasterror();
1050 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_resources";
1051 $sql .=
" WHERE fk_actioncomm=".((int) $this->
id);
1053 $res = $this->db->query($sql);
1055 $this->error = $this->db->lasterror();
1061 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1062 $sql .=
" WHERE fk_actioncomm = ".((int) $this->
id);
1064 $res = $this->db->query($sql);
1066 $this->error = $this->db->lasterror();
1076 dol_syslog(get_class($this).
"::delete error -3 ".$this->error, LOG_ERR);
1082 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm";
1083 $sql .=
" WHERE id=".((int) $this->
id);
1085 $res = $this->db->query($sql);
1087 $this->error = $this->db->lasterror();
1103 $this->db->commit();
1106 $this->db->rollback();
1110 $this->db->rollback();
1111 $this->error = $this->db->lasterror();
1126 global $langs, $conf, $hookmanager;
1131 $this->label = trim($this->label);
1132 $this->note_private =
dol_htmlcleanlastbr(trim(!isset($this->note_private) ? $this->note : $this->note_private));
1133 if (empty($this->percentage)) {
1134 $this->percentage = 0;
1136 if (empty($this->priority) || !is_numeric($this->priority)) {
1137 $this->priority = 0;
1139 if (empty($this->transparency)) {
1140 $this->transparency = 0;
1142 if (empty($this->fulldayevent)) {
1143 $this->fulldayevent = 0;
1145 if ($this->percentage > 100) {
1146 $this->percentage = 100;
1149 if ($this->datep && $this->datef) {
1150 $this->durationp = ($this->datef - $this->datep);
1153 if ($this->datep && $this->datef && $this->datep > $this->datef) {
1154 $this->datef = $this->datep;
1157 if ($this->fk_project < 0) {
1158 $this->fk_project = 0;
1162 if ($this->percentage == 0 && $this->userdoneid > 0) {
1163 $this->error =
"ErrorCantSaveADoneUserWithZeroPercentage";
1167 $socid = (($this->socid > 0) ? $this->socid : 0);
1168 $contactid = (($this->contact_id > 0) ? $this->contact_id : 0);
1169 $userownerid = ($this->userownerid ? $this->userownerid : 0);
1170 $userdoneid = ($this->userdoneid ? $this->userdoneid : 0);
1173 if ($this->type_id > 0) {
1174 if (empty($this->type_code)) {
1176 $result = $cactioncomm->fetch($this->type_id);
1177 if ($result >= 0 && !empty($cactioncomm->code)) {
1178 $this->type_code = $cactioncomm->code;
1183 $code = $this->code;
1184 if (empty($code) || (!empty($this->oldcopy) && $this->oldcopy->type_code != $this->type_code)) {
1185 $code = $this->type_code;
1190 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"actioncomm";
1191 $sql .=
" SET percent = '".$this->db->escape($this->percentage).
"'";
1192 $sql .=
", fk_action = ".(int) $this->type_id;
1193 $sql .=
", code = " . ($code ?
"'".$this->db->escape($code).
"'" :
"null");
1194 $sql .=
", label = ".($this->label ?
"'".$this->db->escape($this->label).
"'" :
"null");
1195 $sql .=
", datep = ".(strval($this->datep) !=
'' ?
"'".$this->db->idate($this->datep).
"'" :
'null');
1196 $sql .=
", datep2 = ".(strval($this->datef) !=
'' ?
"'".$this->db->idate($this->datef).
"'" :
'null');
1197 $sql .=
", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp !=
'' ?
"'".$this->db->escape($this->durationp).
"'" :
"null");
1198 $sql .=
", note = '".$this->db->escape($this->note_private).
"'";
1199 $sql .=
", fk_project =".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null");
1200 $sql .=
", fk_soc =".($socid > 0 ? ((int) $socid) :
"null");
1201 $sql .=
", fk_contact =".($contactid > 0 ? ((int) $contactid) :
"null");
1202 $sql .=
", priority = '".$this->db->escape($this->priority).
"'";
1203 $sql .=
", fulldayevent = '".$this->db->escape($this->fulldayevent).
"'";
1204 $sql .=
", location = ".($this->location ?
"'".$this->db->escape($this->location).
"'" :
"null");
1205 $sql .=
", transparency = '".$this->db->escape($this->transparency).
"'";
1206 $sql .=
", fk_user_mod = ".((int) $user->id);
1207 $sql .=
", fk_user_action = ".($userownerid > 0 ? ((int) $userownerid) :
"null");
1208 $sql .=
", fk_user_done = ".($userdoneid > 0 ? ((int) $userdoneid) :
"null");
1209 if (!empty($this->fk_element)) {
1210 $sql .=
", fk_element=".($this->fk_element ? ((int) $this->fk_element) :
"null");
1212 if (!empty($this->elementtype)) {
1213 $sql .=
", elementtype=".($this->elementtype ?
"'".$this->db->escape($this->elementtype).
"'" :
"null");
1215 if (!empty($this->num_vote)) {
1216 $sql .=
", num_vote=".($this->num_vote ? (int) $this->num_vote :
null);
1218 if (!empty($this->event_paid)) {
1219 $sql .=
", event_paid=".($this->event_paid ? (int) $this->event_paid : 0);
1221 if (!empty($this->
status)) {
1222 $sql .=
", status=".($this->status ? (int) $this->
status : 0);
1224 $sql .=
" WHERE id=".((int) $this->
id);
1226 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1227 if ($this->db->query($sql)) {
1240 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_resources where fk_actioncomm = ".((int) $this->
id).
" AND element_type = 'user'";
1241 $resql = $this->db->query($sql);
1243 $already_inserted = array();
1244 foreach ($this->userassigned as $key => $val) {
1245 if (!is_array($val)) {
1246 $val = array(
'id'=>$val);
1248 if (!empty($already_inserted[$val[
'id']])) {
1252 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
1253 $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'])).
")";
1255 $resql = $this->db->query($sql);
1258 $this->errors[] = $this->db->lasterror();
1260 $already_inserted[$val[
'id']] =
true;
1267 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_resources where fk_actioncomm = ".((int) $this->
id).
" AND element_type = 'socpeople'";
1268 $resql = $this->db->query($sql);
1270 if (!empty($this->socpeopleassigned)) {
1271 $already_inserted = array();
1272 foreach (array_keys($this->socpeopleassigned) as $key => $val) {
1273 if (!is_array($val)) {
1274 $val = array(
'id'=>$val);
1276 if (!empty($already_inserted[$val[
'id']])) {
1280 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
1281 $sql .=
" VALUES(".((int) $this->
id).
", 'socpeople', ".((int) $val[
'id']).
", 0, 0, 0)";
1283 $resql = $this->db->query($sql);
1286 $this->errors[] = $this->db->lasterror();
1288 $already_inserted[$val[
'id']] =
true;
1294 if (!$error && !$notrigger) {
1304 $this->db->commit();
1307 $this->db->rollback();
1308 dol_syslog(get_class($this).
"::update ".join(
',', $this->errors), LOG_ERR);
1312 $this->db->rollback();
1313 $this->error = $this->db->lasterror();
1331 public function getActions($socid = 0, $fk_element = 0, $elementtype =
'', $filter =
'', $sortfield =
'a.datep', $sortorder =
'DESC', $limit = 0)
1333 global $conf, $langs, $hookmanager;
1335 $resarray = array();
1337 dol_syslog(get_class().
"::getActions", LOG_DEBUG);
1340 if (!is_object($hookmanager)) {
1341 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1344 $hookmanager->initHooks(array(
'agendadao'));
1346 $sql =
"SELECT a.id";
1347 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
1349 $parameters = array(
'sql' => &$sql,
'socid' => $socid,
'fk_element' => $fk_element,
'elementtype' => $elementtype);
1350 $reshook = $hookmanager->executeHooks(
'getActionsListFrom', $parameters);
1351 if (!empty($hookmanager->resPrint)) {
1352 $sql.= $hookmanager->resPrint;
1354 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
1355 if (!empty($socid)) {
1356 $sql .=
" AND a.fk_soc = ".((int) $socid);
1358 if (!empty($elementtype)) {
1359 if ($elementtype ==
'project') {
1360 $sql .=
' AND a.fk_project = '.((int) $fk_element);
1361 } elseif ($elementtype ==
'contact') {
1362 $sql .=
' AND a.id IN';
1363 $sql .=
" (SELECT fk_actioncomm FROM ".MAIN_DB_PREFIX.
"actioncomm_resources WHERE";
1364 $sql .=
" element_type = 'socpeople' AND fk_element = ".((int) $fk_element).
')';
1366 $sql .=
" AND a.fk_element = ".((int) $fk_element).
" AND a.elementtype = '".$this->db->escape($elementtype).
"'";
1369 if (!empty($filter)) {
1373 $parameters = array(
'sql' => &$sql,
'socid' => $socid,
'fk_element' => $fk_element,
'elementtype' => $elementtype);
1374 $reshook = $hookmanager->executeHooks(
'getActionsListWhere', $parameters);
1375 if (!empty($hookmanager->resPrint)) {
1376 $sql.= $hookmanager->resPrint;
1378 if ($sortorder && $sortfield) {
1379 $sql .= $this->db->order($sortfield, $sortorder);
1381 $sql .= $this->db->plimit($limit, 0);
1383 $resql = $this->db->query($sql);
1385 $num = $this->db->num_rows($resql);
1388 for ($i = 0; $i < $num; $i++) {
1389 $obj = $this->db->fetch_object($resql);
1390 $actioncommstatic =
new ActionComm($this->db);
1391 $actioncommstatic->fetch($obj->id);
1392 $resarray[$i] = $actioncommstatic;
1395 $this->db->free($resql);
1398 return $this->db->lasterror();
1413 global $conf, $langs;
1415 if (empty($load_state_board)) {
1416 $sql =
"SELECT a.id, a.datep as dp";
1418 $this->nb = array();
1419 $sql =
"SELECT count(a.id) as nb";
1421 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
1422 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
1423 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
1425 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
1426 $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);
1428 $sql .=
" WHERE 1 = 1";
1429 if (empty($load_state_board)) {
1430 $sql .=
" AND a.percent >= 0 AND a.percent < 100";
1432 $sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
1433 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
1434 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
1437 $sql .=
" AND a.fk_soc = ".((int) $user->socid);
1439 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
1440 $sql .=
" AND (a.fk_user_author = ".((int) $user->id).
" OR a.fk_user_action = ".((int) $user->id).
" OR a.fk_user_done = ".((int) $user->id);
1441 $sql .=
" OR ar.fk_element = ".((int) $user->id);
1445 $resql = $this->db->query($sql);
1447 if (empty($load_state_board)) {
1450 $response->warning_delay = $conf->agenda->warning_delay / 60 / 60 / 24;
1451 $response->label = $langs->trans(
"ActionsToDo");
1452 $response->labelShort = $langs->trans(
"ActionsToDoShort");
1453 $response->url = DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&actioncode=0&status=todo&mainmenu=agenda';
1454 if ($user->hasRight(
"agenda",
"allactions",
"read")) {
1455 $response->url .=
'&filtert=-1';
1457 $response->img =
img_object(
'',
"action",
'class="inline-block valigntextmiddle"');
1460 while ($obj = $this->db->fetch_object($resql)) {
1461 if (empty($load_state_board)) {
1462 $response->nbtodo++;
1463 $agenda_static->datep = $this->db->jdate($obj->dp);
1464 if ($agenda_static->hasDelay()) {
1465 $response->nbtodolate++;
1468 $this->nb[
"actionscomm"] = $obj->nb;
1472 $this->db->free($resql);
1473 if (empty($load_state_board)) {
1480 $this->error = $this->db->error();
1497 $sql .=
' tms as datem,';
1498 $sql .=
' fk_user_author,';
1499 $sql .=
' fk_user_mod';
1500 $sql .=
' FROM '.MAIN_DB_PREFIX.
'actioncomm as a';
1501 $sql .=
' WHERE a.id = '.((int) $id);
1503 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
1504 $result = $this->db->query($sql);
1506 if ($this->db->num_rows($result)) {
1507 $obj = $this->db->fetch_object($result);
1509 $this->
id = $obj->id;
1511 $this->user_creation_id = $obj->fk_user_author;
1512 $this->user_modification_id = $obj->fk_user_mod;
1513 $this->date_creation = $this->db->jdate($obj->datec);
1514 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1516 $this->db->free($result);
1532 return $this->
LibStatut($this->percentage, $mode, $hidenastatus, $this->datep);
1545 public function LibStatut($percent, $mode, $hidenastatus = 0, $datestart =
'')
1550 $labelStatus = $langs->transnoentitiesnoconv(
'StatusNotApplicable');
1551 if ($percent == -1 && !$hidenastatus) {
1552 $labelStatus = $langs->transnoentitiesnoconv(
'StatusNotApplicable');
1553 } elseif ($percent == 0) {
1554 $labelStatus = $langs->transnoentitiesnoconv(
'StatusActionToDo').
' (0%)';
1555 } elseif ($percent > 0 && $percent < 100) {
1556 $labelStatus = $langs->transnoentitiesnoconv(
'StatusActionInProcess').
' ('.$percent.
'%)';
1557 } elseif ($percent >= 100) {
1558 $labelStatus = $langs->transnoentitiesnoconv(
'StatusActionDone').
' (100%)';
1561 $labelStatusShort = $langs->transnoentitiesnoconv(
'StatusNotApplicable');
1562 if ($percent == -1 && !$hidenastatus) {
1563 $labelStatusShort = $langs->trans(
'NA');
1564 } elseif ($percent == 0) {
1565 $labelStatusShort =
'0%';
1566 } elseif ($percent > 0 && $percent < 100) {
1567 $labelStatusShort = $percent.
'%';
1568 } elseif ($percent >= 100) {
1569 $labelStatusShort =
'100%';
1572 $statusType =
'status9';
1573 if ($percent == -1 && !$hidenastatus) {
1574 $statusType =
'status9';
1576 if ($percent == 0) {
1577 $statusType =
'status1';
1579 if ($percent > 0 && $percent < 100) {
1580 $statusType =
'status3';
1582 if ($percent >= 100) {
1583 $statusType =
'status6';
1586 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
1597 global $conf, $langs, $user;
1598 $langs->load(
'agenda');
1601 $nofetch = !empty($params[
'nofetch']);
1605 if ($this->type_code) {
1606 $langs->load(
"commercial");
1607 $labeltype = ($langs->transnoentities(
"Action".$this->type_code) !=
"Action".$this->type_code) ? $langs->transnoentities(
"Action".$this->type_code) : $this->type_label;
1610 if ($this->type_code !=
'AC_OTH_AUTO') {
1611 $labeltype = $langs->trans(
'ActionAC_MANUAL');
1615 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
'Action').
'</u>';
1616 if (!empty($this->
ref)) {
1619 if (!empty($this->label)) {
1620 $datas[
'title'] =
'<br><b>'.$langs->trans(
'Title').
':</b> '.
dol_escape_htmltag($this->label);
1622 if (!empty($labeltype)) {
1623 $datas[
'labeltype'] =
'<br><b>'.$langs->trans(
'Type').
':</b> '.
dol_escape_htmltag($labeltype);
1625 if (!empty($this->location)) {
1626 $datas[
'location'] =
'<br><b>'.$langs->trans(
'Location').
':</b> '.
dol_escape_htmltag($this->location);
1628 if (isset($this->transparency)) {
1629 $datas[
'transparency'] =
'<br><b>'.$langs->trans(
'Busy').
':</b> '.
yn($this->transparency);
1631 if (!empty($this->email_msgid)) {
1632 $langs->load(
"mails");
1633 $datas[
'space'] =
'<br>';
1635 $datas[
'mailtopic'] =
'<br><b>'.$langs->trans(
'MailTopic').
':</b> '.
dol_escape_htmltag($this->email_subject);
1636 $datas[
'mailfrom'] =
'<br><b>'.$langs->trans(
'MailFrom').
':</b> '.str_replace(array(
'<',
'>'), array(
'&lt',
'&gt'), $this->email_from);
1637 $datas[
'mailto'] =
'<br><b>'.$langs->trans(
'MailTo').
':</b> '.str_replace(array(
'<',
'>'), array(
'&lt',
'&gt'), $this->email_to);
1638 if (!empty($this->email_tocc)) {
1639 $datas[
'mailcc'] =
'<br><b>'.$langs->trans(
'MailCC').
':</b> '.str_replace(array(
'<',
'>'), array(
'&lt',
'&gt'), $this->email_tocc);
1646 if (!empty($this->note_private)) {
1647 $datas[
'description'] =
'<br><b>'.$langs->trans(
'Description').
':</b><br>';
1651 $datas[
'note'] =
'<div class="tenlinesmax">';
1652 $datas[
'note'] .= (
dol_textishtml($texttoshow) ? str_replace(array(
"\r",
"\n"),
"", $texttoshow) : str_replace(array(
"\r",
"\n"),
'<br>', $texttoshow));
1653 $datas[
'note'] .=
'</div>';
1656 if (isModEnabled(
'categorie') && !$nofetch) {
1657 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1658 $form =
new Form($this->db);
1659 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_ACTIONCOMM, 1);
1678 public function getNomUrl($withpicto = 0, $maxlength = 0, $classname =
'', $option =
'', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1)
1680 global $conf, $langs, $user, $hookmanager, $action;
1682 if (!empty($conf->dol_no_mouse_hover)) {
1687 if ($user->hasRight(
'agenda',
'myactions',
'read') && ($this->authorid == $user->id || $this->userownerid == $user->id)) {
1690 if ($user->hasRight(
'agenda',
'myactions',
'read') && array_key_exists($user->id, $this->userassigned)) {
1693 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
1700 $label = $this->label;
1701 if (empty($label)) {
1702 $label = $this->libelle;
1709 if ($this->type_code) {
1710 $langs->load(
"commercial");
1711 $labeltype = ($langs->transnoentities(
"Action".$this->type_code) !=
"Action".$this->type_code) ? $langs->transnoentities(
"Action".$this->type_code) : $this->type_label;
1714 if ($this->type_code !=
'AC_OTH_AUTO') {
1715 $labeltype = $langs->trans(
'ActionAC_MANUAL');
1719 $tooltip =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
'Action').
'</u>';
1720 if (!empty($this->
ref)) {
1723 if (!empty($label)) {
1726 if (!empty($labeltype)) {
1729 if (!empty($this->location)) {
1730 $tooltip .=
'<br><b>'.$langs->trans(
'Location').
':</b> '.
dol_escape_htmltag($this->location);
1732 if (isset($this->transparency)) {
1733 $tooltip .=
'<br><b>'.$langs->trans(
'Busy').
':</b> '.
yn($this->transparency);
1735 if (!empty($this->email_msgid)) {
1736 $langs->load(
"mails");
1739 $tooltip .=
'<br><b>'.$langs->trans(
'MailTopic').
':</b> '.
dol_escape_htmltag($this->email_subject);
1740 $tooltip .=
'<br><b>'.$langs->trans(
'MailFrom').
':</b> '.str_replace(array(
'<',
'>'), array(
'&lt',
'&gt'), !empty($this->email_from) ? $this->email_from :
'');
1741 $tooltip .=
'<br><b>'.$langs->trans(
'MailTo').
':</b> '.str_replace(array(
'<',
'>'), array(
'&lt',
'&gt'), !empty($this->email_to) ? $this->email_to :
'');
1742 if (!empty($this->email_tocc)) {
1743 $tooltip .=
'<br><b>'.$langs->trans(
'MailCC').
':</b> '.str_replace(array(
'<',
'>'), array(
'&lt',
'&gt'), $this->email_tocc);
1750 if (!empty($this->note_private)) {
1751 $tooltip .=
'<br><br><b>'.$langs->trans(
'Description').
':</b><br>';
1753 $tooltip .=
'<div class="tenlinesmax">';
1754 $tooltip .= (
dol_textishtml($texttoshow) ? str_replace(array(
"\r",
"\n"),
"", $texttoshow) : str_replace(array(
"\r",
"\n"),
'<br>', $texttoshow));
1755 $tooltip .=
'</div>';
1758 $classfortooltip =
'classfortooltip';
1763 'objecttype' => $this->element,
1764 'option' => $option,
1767 $classfortooltip =
'classforajaxtooltip';
1768 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1773 if (empty($notooltip)) {
1775 $label = $langs->trans(
"ShowAction");
1776 $linkclose .=
' alt="'.dol_escape_htmltag($tooltip, 1).
'"';
1778 $linkclose .= ($tooltip ?
' title="'.dol_escape_htmltag($tooltip, 1).
'"' :
' title="tocomplete"');
1779 $linkclose .= $dataparams.
' class="'.$classname.
' '.$classfortooltip.
'"';
1781 $linkclose .=
' class="'.$classname.
'"';
1785 if ($option ==
'birthday') {
1786 $url = DOL_URL_ROOT.
'/contact/perso.php?id='.$this->id;
1787 } elseif ($option ==
'holiday') {
1788 $url = DOL_URL_ROOT.
'/holiday/card.php?id='.$this->id;
1790 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$this->id;
1793 if ($option !==
'nolink') {
1795 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1796 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1797 $add_save_lastsearch_values = 1;
1799 if ($add_save_lastsearch_values) {
1800 $url .=
'&save_lastsearch_values=1';
1804 $linkstart =
'<a href="'.$url.
'"';
1805 $linkstart .= $linkclose.
'>';
1808 if ($option ==
'nolink') {
1813 if ($withpicto == 2) {
1815 $label = $labeltype;
1820 $label = $labeltype;
1822 if ($maxlength < 0) {
1823 $labelshort = $this->ref;
1825 $labelshort =
dol_trunc($label, $maxlength);
1832 $label .= (preg_match(
'/'.preg_quote($labeltype,
'/').
'/', $label) ?
'' :
' ('.$langs->transnoentities(
"Action".$this->type_code).
')');
1837 $result .= $linkstart;
1839 $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);
1842 $result .= $linkend;
1845 $hookmanager->initHooks(array(
'actiondao'));
1846 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1847 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1849 $result = $hookmanager->resPrint;
1851 $result .= $hookmanager->resPrint;
1864 public function getTypePicto($morecss =
'pictofixedwidth paddingright', $titlealt =
'')
1871 if ($this->type_color) {
1872 $color =
'style="color: #'.$this->type_color.
' !important;"';
1874 if ($this->type_picto) {
1875 $imgpicto =
img_picto($titlealt, $this->type_picto,
'',
false, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1877 if ($this->type_code ==
'AC_RDV') {
1878 $imgpicto =
img_picto($titlealt,
'meeting', $color,
false, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1879 } elseif ($this->type_code ==
'AC_TEL') {
1880 $imgpicto =
img_picto($titlealt,
'object_phoning', $color,
false, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1881 } elseif ($this->type_code ==
'AC_FAX') {
1882 $imgpicto =
img_picto($titlealt,
'object_phoning_fax', $color,
false, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1883 } elseif ($this->type_code ==
'AC_EMAIL' || $this->type_code ==
'AC_EMAIL_IN' || (!empty($this->code) && preg_match(
'/_SENTBYMAIL/', $this->code))) {
1884 $imgpicto =
img_picto($titlealt,
'object_email', $color,
false, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1885 } elseif ($this->type_code ==
'AC_INT') {
1886 $imgpicto =
img_picto($titlealt,
'object_intervention', $color,
false, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1887 } elseif (!empty($this->code) && preg_match(
'/^TICKET_MSG/', $this->code)) {
1888 $imgpicto =
img_picto($titlealt,
'object_conversation', $color,
false, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1889 } elseif ($this->
type !=
'systemauto') {
1890 $imgpicto =
img_picto($titlealt,
'user-cog', $color,
false, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1892 $imgpicto =
img_picto($titlealt,
'cog', $color,
false, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1897 if ($this->
type !=
'systemauto') {
1898 $imgpicto =
img_picto($titlealt,
'user-cog',
'',
false, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1900 $imgpicto =
img_picto($titlealt,
'cog',
'',
false, 0, 0,
'', ($morecss ?
' '.$morecss :
''));
1921 if (!is_array($categories)) {
1922 $categories = array($categories);
1926 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1928 $existing = $c->containing($this->
id, Categorie::TYPE_ACTIONCOMM,
'id');
1931 if (is_array($existing)) {
1932 $to_del = array_diff($existing, $categories);
1933 $to_add = array_diff($categories, $existing);
1936 $to_add = $categories;
1940 foreach ($to_del as $del) {
1941 if ($c->fetch($del) > 0) {
1942 $c->del_type($this, Categorie::TYPE_ACTIONCOMM);
1945 foreach ($to_add as $add) {
1946 if ($c->fetch($add) > 0) {
1947 $c->add_type($this, Categorie::TYPE_ACTIONCOMM);
1965 public function build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholiday = 0)
1967 global $hookmanager;
1970 global $conf, $langs, $dolibarr_main_url_root, $mysoc;
1972 require_once DOL_DOCUMENT_ROOT.
"/core/lib/xcal.lib.php";
1973 require_once DOL_DOCUMENT_ROOT.
"/core/lib/date.lib.php";
1974 require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
1976 dol_syslog(get_class($this).
"::build_exportfile Build export file format=".$format.
", type=".$type.
", cachedelay=".$cachedelay.
", filename=".$filename.
", filters size=".count($filters), LOG_DEBUG);
1979 if (empty($format)) {
1986 if ($format ==
'ical') {
1989 $filename = $format.
'.'.$extension;
1993 $result =
dol_mkdir($conf->agenda->dir_temp);
1994 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
2008 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2010 dol_syslog(get_class($this).
"::build_exportfile file ".$outputfile.
" is not older than now - cachedelay (".$nowgmt.
" - ".$cachedelay.
"). Build is canceled");
2017 $eventarray = array();
2019 $sql =
"SELECT a.id,";
2020 $sql .=
" a.datep,";
2021 $sql .=
" a.datep2,";
2022 $sql .=
" a.durationp,";
2023 $sql .=
" a.datec, a.tms as datem,";
2024 $sql .=
" a.label, a.code, a.note as note_private, a.fk_action as type_id,";
2025 $sql .=
" a.fk_soc,";
2026 $sql .=
" a.fk_user_author, a.fk_user_mod,";
2027 $sql .=
" a.fk_user_action,";
2028 $sql .=
" a.fk_contact, a.percent as percentage,";
2029 $sql .=
" a.fk_element, a.elementtype,";
2030 $sql .=
" a.priority, a.fulldayevent, a.location, a.transparency,";
2031 $sql .=
" u.firstname, u.lastname, u.email,";
2032 $sql .=
" s.nom as socname,";
2033 $sql .=
" c.id as type_id, c.code as type_code, c.libelle as type_label,";
2034 $sql .=
" num_vote, event_paid, a.status";
2035 $sql .=
" FROM (".MAIN_DB_PREFIX.
"c_actioncomm as c, ".MAIN_DB_PREFIX.
"actioncomm as a)";
2036 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_author";
2037 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on s.rowid = a.fk_soc";
2039 $parameters = array(
'filters' => $filters);
2040 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
2041 $sql .= $hookmanager->resPrint;
2044 if ($filters[
'logint']) {
2045 $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
2047 $sql .=
" WHERE a.fk_action=c.id";
2048 $sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
2049 foreach ($filters as $key => $value) {
2050 if ($key ==
'notolderthan' && $value !=
'') {
2051 $sql .=
" AND a.datep >= '".$this->db->idate($now - ($value * 24 * 60 * 60)).
"'";
2053 if ($key ==
'year') {
2057 $sql .=
" AND a.id=".(is_numeric($value) ? $value : 0);
2059 if ($key ==
'idfrom') {
2060 $sql .=
" AND a.id >= ".(is_numeric($value) ? $value : 0);
2062 if ($key ==
'idto') {
2063 $sql .=
" AND a.id <= ".(is_numeric($value) ? $value : 0);
2065 if ($key ==
'project') {
2066 $sql .=
" AND a.fk_project=".(is_numeric($value) ? $value : 0);
2068 if ($key ==
'actiontype') {
2069 $sql .=
" AND c.type = '".$this->db->escape($value).
"'";
2071 if ($key ==
'notactiontype') {
2072 $sql .=
" AND c.type <> '".$this->db->escape($value).
"'";
2075 if ($key ==
'logint') {
2076 $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
2078 if ($key ==
'logina') {
2081 if (preg_match(
'/^!/', $logina)) {
2082 $logina = preg_replace(
'/^!/',
'', $logina);
2085 $userforfilter =
new User($this->db);
2086 $result = $userforfilter->fetch(
'', $logina);
2088 $sql .=
" AND a.fk_user_author ".$condition.
" ".$userforfilter->id;
2089 } elseif ($result < 0 || $condition ==
'=') {
2090 $sql .=
" AND a.fk_user_author = 0";
2093 if ($key ==
'logint') {
2096 if (preg_match(
'/^!/', $logint)) {
2097 $logint = preg_replace(
'/^!/',
'', $logint);
2100 $userforfilter =
new User($this->db);
2101 $result = $userforfilter->fetch(
'', $logint);
2103 $sql .=
" AND ar.fk_element = ".((int) $userforfilter->id);
2104 } elseif ($result < 0 || $condition ==
'=') {
2105 $sql .=
" AND ar.fk_element = 0";
2108 if ($key ==
'module') {
2109 $sql .=
" AND c.module LIKE '%".$this->db->escape($value).
"'";
2111 if ($key ==
'status') {
2112 $sql .=
" AND a.status =".((int) $value);
2116 $sql .=
" AND a.datep IS NOT NULL";
2118 $parameters = array(
'filters' => $filters);
2119 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
2120 $sql .= $hookmanager->resPrint;
2122 $sql .=
" ORDER by datep";
2125 dol_syslog(get_class($this).
"::build_exportfile select events", LOG_DEBUG);
2126 $resql = $this->db->query($sql);
2129 while ($obj = $this->db->fetch_object($resql)) {
2134 $event[
'uid'] =
'dolibarragenda-'.$this->db->database_name.
'-'.$obj->id.
"@".$_SERVER[
"SERVER_NAME"];
2135 $event[
'type'] = $type;
2137 $datestart = $this->db->jdate($obj->datep) - (!
getDolGlobalString(
'AGENDA_EXPORT_FIX_TZ') ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
2140 if (is_numeric($this->db->jdate($obj->datep2))) {
2141 $dateend = $this->db->jdate($obj->datep2) - (!
getDolGlobalString(
'AGENDA_EXPORT_FIX_TZ') ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
2144 $dateend = $datestart;
2147 $duration = ($datestart && $dateend) ? ($dateend - $datestart) : 0;
2148 $event[
'summary'] = $obj->label.($obj->socname ?
" (".$obj->socname.
")" :
"");
2150 $event[
'desc'] = $obj->note_private;
2151 $event[
'startdate'] = $datestart;
2152 $event[
'enddate'] = $dateend;
2153 $event[
'duration'] = $duration;
2155 $event[
'priority'] = $obj->priority;
2156 $event[
'fulldayevent'] = $obj->fulldayevent;
2157 $event[
'location'] = $obj->location;
2158 $event[
'transparency'] = (($obj->transparency > 0) ?
'OPAQUE' :
'TRANSPARENT');
2159 $event[
'category'] = $obj->type_label;
2160 $event[
'email'] = $obj->email;
2162 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
2163 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2165 $url = $urlwithroot.
'/comm/action/card.php?id='.$obj->id;
2166 $event[
'url'] = $url;
2167 $event[
'created'] = $this->db->jdate($obj->datec) - (!
getDolGlobalString(
'AGENDA_EXPORT_FIX_TZ') ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
2168 $event[
'modified'] = $this->db->jdate($obj->datem) - (!
getDolGlobalString(
'AGENDA_EXPORT_FIX_TZ') ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
2169 $event[
'num_vote'] = $this->num_vote;
2170 $event[
'event_paid'] = $this->event_paid;
2171 $event[
'status'] = $this->status;
2174 $this->
id = $obj->id;
2177 $assignedUserArray = array();
2179 foreach ($this->userassigned as $key => $value) {
2180 $assignedUser =
new User($this->db);
2181 $assignedUser->fetch($value[
'id']);
2183 $assignedUserArray[$key] = $assignedUser;
2186 $event[
'assignedUsers'] = $assignedUserArray;
2188 if ($qualified && $datestart) {
2189 $eventarray[] = $event;
2194 $parameters = array(
'filters' => $filters,
'eventarray' => &$eventarray);
2195 $reshook = $hookmanager->executeHooks(
'addMoreEventsExport', $parameters);
2197 $eventarray = $hookmanager->resArray;
2200 $this->error = $this->db->lasterror();
2204 if ($exportholiday == 1) {
2205 $langs->load(
"holiday");
2206 $title = $langs->transnoentities(
"Holidays");
2208 $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";
2209 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
2210 $sql .=
" WHERE u.rowid = x.fk_user";
2211 $sql .=
" AND u.statut = '1'";
2212 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
2214 $resql = $this->db->query($sql);
2216 $num = $this->db->num_rows($resql);
2220 $obj = $this->db->fetch_object($resql);
2223 if ($obj->halfday == 1) {
2224 $event[
'fulldayevent'] =
false;
2228 } elseif ($obj->halfday == -1) {
2229 $event[
'fulldayevent'] =
false;
2234 $event[
'fulldayevent'] =
true;
2241 $timestampStart = $timestampStart - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600);
2242 $timestampEnd = $timestampEnd - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600);
2245 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
2246 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2247 $url = $urlwithroot.
'/holiday/card.php?id='.$obj->rowid;
2249 $event[
'uid'] =
'dolibarrholiday-'.$this->db->database_name.
'-'.$obj->rowid.
"@".$_SERVER[
"SERVER_NAME"];
2251 $event[
'type'] =
'event';
2252 $event[
'category'] =
"Holiday";
2253 $event[
'transparency'] =
'OPAQUE';
2254 $event[
'email'] = $obj->email;
2255 $event[
'created'] = $timestampStart;
2256 $event[
'modified'] = $timestampStart;
2257 $event[
'startdate'] = $timestampStart;
2258 $event[
'enddate'] = $timestampEnd;
2259 $event[
'duration'] = $timestampEnd - $timestampStart;
2260 $event[
'url'] = $url;
2262 if ($obj->status == 2) {
2264 $event[
'summary'] = $title.
" - ".$obj->lastname.
" (wait for approval)";
2267 $event[
'summary'] = $title.
" - ".$obj->lastname;
2270 $eventarray[] = $event;
2277 $langs->load(
"agenda");
2282 $more = $langs->transnoentities(
"User").
' '.$login;
2285 $more = $langs->transnoentities(
"ActionsAskedBy").
' '.$logina;
2288 $more = $langs->transnoentities(
"ActionsToDoBy").
' '.$logint;
2291 $more = $langs->transnoentities(
"ActionsDoneBy").
' '.$logind;
2294 $title =
'Dolibarr actions '.$mysoc->name.
' - '.$more;
2296 $desc .=
' ('.$mysoc->name.
' - built by Dolibarr)';
2298 $title =
'Dolibarr actions '.$mysoc->name;
2299 $desc = $langs->transnoentities(
'ListOfActions');
2300 $desc .=
' ('.$mysoc->name.
' - built by Dolibarr)';
2304 $outputfiletmp = tempnam($conf->agenda->dir_temp,
'tmp');
2308 if ($format ==
'vcal') {
2309 $result =
build_calfile($format, $title, $desc, $eventarray, $outputfiletmp);
2310 } elseif ($format ==
'ical') {
2311 $result =
build_calfile($format, $title, $desc, $eventarray, $outputfiletmp);
2312 } elseif ($format ==
'rss') {
2313 $result =
build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp);
2317 if (
dol_move($outputfiletmp, $outputfile, 0, 1, 0, 0)) {
2320 $this->error =
'Failed to rename '.$outputfiletmp.
' into '.$outputfile;
2321 dol_syslog(get_class($this).
"::build_exportfile ".$this->error, LOG_ERR);
2326 dol_syslog(get_class($this).
"::build_exportfile build_xxxfile function fails to for format=".$format.
" outputfiletmp=".$outputfile, LOG_ERR);
2328 $langs->load(
"errors");
2329 $this->error = $langs->trans(
"ErrorFailToCreateFile", $outputfile);
2351 $this->specimen = 1;
2353 $this->type_code =
'AC_OTH';
2354 $this->code =
'AC_SPECIMEN_CODE';
2355 $this->label =
'Label of event Specimen';
2356 $this->datec = $now;
2357 $this->datem = $now;
2358 $this->datep = $now;
2359 $this->datef = $now;
2360 $this->fulldayevent = 0;
2361 $this->percentage = 0;
2363 $this->location =
'Location';
2364 $this->transparency = 1;
2365 $this->priority = 1;
2367 $this->note_private =
"This is a 'private' note.";
2369 $this->userownerid = $user->id;
2370 $this->userassigned[$user->id] = array(
'id'=>$user->id,
'transparency'=> 1);
2401 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'actioncomm SET fk_element = ' . ((int) $dest_id) .
' WHERE elementtype="product" AND fk_element = '.((int) $origin_id);
2403 if (!$dbs->
query($sql)) {
2422 return $this->datep && ($this->datep < ($now - $conf->agenda->warning_delay));
2436 global $conf, $langs, $user;
2440 $this->reminders = array();
2443 $sql =
"SELECT rowid as id, typeremind, dateremind, status, offsetvalue, offsetunit, fk_user, fk_email_template, lasterror";
2444 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
2445 $sql .=
" WHERE fk_actioncomm = ".((int) $this->
id);
2447 $sql .=
" AND dateremind <= '".$this->db->idate(
dol_now()).
"'";
2450 $sql .=
" AND typeremind = '".$this->db->escape($type).
"'";
2453 $sql .=
" AND fk_user = ".((int) $fk_user);
2456 $sql .=
" AND typeremind <> 'email'";
2459 $sql .=
" AND typeremind <> 'browser'";
2462 $sql .= $this->db->order(
"dateremind",
"ASC");
2463 $resql = $this->db->query($sql);
2466 while ($obj = $this->db->fetch_object($resql)) {
2468 $tmpactioncommreminder->id = $obj->id;
2469 $tmpactioncommreminder->typeremind = $obj->typeremind;
2470 $tmpactioncommreminder->dateremind = $obj->dateremind;
2471 $tmpactioncommreminder->offsetvalue = $obj->offsetvalue;
2472 $tmpactioncommreminder->offsetunit = $obj->offsetunit;
2473 $tmpactioncommreminder->status = $obj->status;
2474 $tmpactioncommreminder->fk_user = $obj->fk_user;
2475 $tmpactioncommreminder->fk_email_template = $obj->fk_email_template;
2476 $tmpactioncommreminder->lasterror = $obj->lasterror;
2478 $this->reminders[$obj->id] = $tmpactioncommreminder;
2481 $this->error = $this->db->lasterror();
2485 return count($this->reminders);
2497 global $conf, $langs, $user;
2503 $errorsMsg = array();
2505 if (!isModEnabled(
'agenda')) {
2506 $langs->load(
"agenda");
2507 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Agenda"));
2511 $langs->load(
"agenda");
2512 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Agenda"));
2524 $sql =
"SELECT rowid as id FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
2525 $sql .=
" WHERE typeremind = 'email'";
2526 $sql .=
" AND status = 0";
2527 $sql .=
" AND dateremind <= '".$this->db->idate($now).
"'";
2528 $sql .=
" AND entity IN (".getEntity(
'actioncomm').
")";
2529 $sql .= $this->db->order(
"dateremind",
"ASC");
2530 $resql = $this->db->query($sql);
2533 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
2534 $formmail =
new FormMail($this->db);
2536 while ($obj = $this->db->fetch_object($resql)) {
2537 $res = $actionCommReminder->fetch($obj->id);
2540 $errorsMsg[] =
"Failed to load invoice ActionComm Reminder";
2545 $arraymessage = $formmail->getEMailTemplate($this->db,
'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1);
2548 $res = $this->
fetch($actionCommReminder->fk_actioncomm);
2560 $sendContent =
make_substitutions($langs->trans($arraymessage->content), $substitutionarray);
2563 $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->transnoentities(
'EventReminder'));
2566 $recipient =
new User($this->db);
2567 $res = $recipient->fetch($actionCommReminder->fk_user);
2569 if (!empty($recipient->email)) {
2570 $to = $recipient->email;
2572 $errormesg =
"Failed to send remind to user id=".$actionCommReminder->fk_user.
". No email defined for user.";
2576 $errormesg =
"Failed to load recipient with user id=".$actionCommReminder->fk_user;
2583 $errormesg =
"Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM";
2592 $cMailFile =
new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(),
'',
"", 0, 1, $errors_to,
'',
'',
'',
'',
'');
2595 if ($cMailFile->sendfile()) {
2598 $errormesg =
'Failed to send email to: '.$to.
' '.$cMailFile->error.join(
',', $cMailFile->errors);
2604 $actionCommReminder->status = $actionCommReminder::STATUS_DONE;
2606 $res = $actionCommReminder->update($user);
2608 $errorsMsg[] =
"Failed to update status to done of ActionComm Reminder";
2613 $actionCommReminder->status = $actionCommReminder::STATUS_ERROR;
2614 $actionCommReminder->lasterror =
dol_trunc($errormesg, 128,
'right',
'UTF-8', 1);
2616 $res = $actionCommReminder->update($user);
2618 $errorsMsg[] =
"Failed to update status to error of ActionComm Reminder";
2622 $errorsMsg[] = $errormesg;
2626 $errorsMsg[] =
'Failed to fetch record actioncomm with ID = '.$actionCommReminder->fk_actioncomm;
2637 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
2638 $sql .=
" WHERE dateremind < '".$this->db->idate($now - (3600 * 24 * 32)).
"'";
2639 $sql .=
" AND status = ".((int) $actionCommReminder::STATUS_DONE);
2640 $resql = $this->db->query($sql);
2643 $errorsMsg[] =
'Failed to delete old reminders';
2649 $this->output =
'Nb of emails sent : '.$nbMailSend;
2650 $this->db->commit();
2652 dol_syslog(__METHOD__.
" end - ".$this->output, LOG_INFO);
2656 $this->db->commit();
2657 $this->error =
'Nb of emails sent : '.$nbMailSend.
', '.(!empty($errorsMsg)) ? join(
', ', $errorsMsg) : $error;
2659 dol_syslog(__METHOD__.
" end - ".$this->error, LOG_INFO);
2677 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"actioncomm ";
2678 $sql .=
" SET percent = ".(int) $percent;
2679 if ($usermodid > 0) {
2680 $sql .=
", fk_user_mod = ".$usermodid;
2682 $sql .=
" WHERE id = ".((int) $id);
2684 if ($this->db->query($sql)) {
2685 $this->db->commit();
2688 $this->db->rollback();
2689 $this->error = $this->db->lasterror();
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
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%.
fetch_userassigned($override=true)
Initialize this->userassigned array with list of id of user assigned to event.
info($id)
Charge les informations 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.
getNomUrl($withpicto=0, $maxlength=0, $classname='', $option='', $overwritepicto=0, $notooltip=0, $save_lastsearch_value=-1)
Return URL of event Use $this->id, $this->type_code, $this->label and $this->type_label.
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.
$recurid
Properties to manage the recurring events.
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)
Udpate the percent value of a event with the given id.
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...
getTypePicto($morecss='pictofixedwidth paddingright', $titlealt='')
Return Picto of type of event.
static replaceProduct(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a product id with another one.
__construct(DoliDB $db)
Constructor.
initAsSpecimen()
Initialise an instance with random values.
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 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.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
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())
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.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
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...
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_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.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_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:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
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.