29 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
32 require_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();
321 public $actions = array();
336 public $email_sender;
355 public $email_subject;
382 public $recurdateend;
384 public $calling_duration;
403 public $fields = array();
426 global $langs, $conf;
432 if (!isset($this->userownerid) || (
string) $this->userownerid ===
'') {
433 dol_syslog(
"You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING);
434 $this->errors[] =
'ErrorActionCommPropertyUserowneridNotDefined';
439 $this->label =
dol_trunc(trim($this->label), 128);
440 $this->location =
dol_trunc(trim($this->location), 128);
441 $this->note_private =
dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private));
442 if (empty($this->percentage)) {
443 $this->percentage = 0;
445 if (empty($this->priority) || !is_numeric($this->priority)) {
448 if (empty($this->fulldayevent)) {
449 $this->fulldayevent = 0;
451 if (empty($this->transparency)) {
452 $this->transparency = 0;
454 if ($this->percentage > 100) {
455 $this->percentage = 100;
458 if (!empty($this->datep) && !empty($this->datef)) {
459 $this->durationp = ($this->datef - $this->datep);
462 if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) {
463 $this->datef = $this->datep;
466 if (!isset($this->fk_project) || $this->fk_project < 0) {
467 $this->fk_project = 0;
470 if ($this->elementtype ==
'facture') {
471 $this->elementtype =
'invoice';
473 if ($this->elementtype ==
'commande') {
474 $this->elementtype =
'order';
476 if ($this->elementtype ==
'contrat') {
477 $this->elementtype =
'contract';
480 if (!is_array($this->userassigned) && !empty($this->userassigned)) {
481 $tmpid = (int) $this->userassigned;
482 $this->userassigned = array();
483 $this->userassigned[$tmpid] = array(
'id'=>$tmpid,
'transparency'=>$this->transparency);
486 $userownerid = $this->userownerid;
487 $userdoneid = $this->userdoneid;
490 if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) {
491 $this->userassigned = array($userownerid=>array(
'id'=>$userownerid,
'transparency'=>$this->transparency));
494 if (!$this->type_id || !$this->type_code) {
495 $key = empty($this->type_id) ? $this->type_code : $this->type_id;
499 $result = $cactioncomm->fetch($key);
502 $this->type_id = $cactioncomm->id;
503 $this->type_code = $cactioncomm->code;
504 } elseif ($result == 0) {
505 $this->error = $langs->trans(
'ErrorActionCommBadType', $this->type_id, $this->type_code);
508 $this->error = $cactioncomm->error;
512 $code = empty($this->
code) ? $this->type_code : $this->code;
515 if (!$this->type_id) {
516 $this->error =
"ErrorWrongParameters";
522 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm";
527 $sql .=
"durationp,";
528 $sql .=
"fk_action,";
532 $sql .=
"fk_project,";
534 $sql .=
"fk_contact,";
535 $sql .=
"fk_user_author,";
536 $sql .=
"fk_user_action,";
537 $sql .=
"fk_user_done,";
538 $sql .=
"label,percent,priority,fulldayevent,location,";
539 $sql .=
"transparency,";
540 $sql .=
"fk_element,";
541 $sql .=
"elementtype,";
543 $sql .=
"extraparams,";
545 $sql .=
"email_msgid,";
546 $sql .=
"email_from,";
547 $sql .=
"email_sender,";
549 $sql .=
"email_tocc,";
550 $sql .=
"email_tobcc,";
551 $sql .=
"email_subject,";
552 $sql .=
"errors_to,";
554 $sql .=
"recurrule,";
555 $sql .=
"recurdateend,";
557 $sql .=
"event_paid,";
560 $sql .=
") VALUES (";
561 $sql .=
"'(PROV)', ";
562 $sql .=
"'".$this->db->idate($now).
"', ";
563 $sql .= (strval($this->datep) !=
'' ?
"'".$this->db->idate($this->datep).
"'" :
"null").
", ";
564 $sql .= (strval($this->datef) !=
'' ?
"'".$this->db->idate($this->datef).
"'" :
"null").
", ";
565 $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp !=
'') ?
"'".$this->
db->escape($this->durationp).
"'" :
"null").
", ";
566 $sql .= (isset($this->type_id) ? $this->type_id :
"null").
",";
567 $sql .= ($code ? (
"'".$this->db->escape($code).
"'") :
"null").
", ";
568 $sql .= (!empty($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
"null").
", ";
569 $sql .= ((isset($this->socid) && $this->socid > 0) ? ((
int) $this->socid) :
"null").
", ";
570 $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? ((
int) $this->fk_project) :
"null").
", ";
571 $sql .=
" '".$this->db->escape($this->note_private).
"', ";
572 $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? ((
int) $this->contact_id) :
"null").
", ";
573 $sql .= (isset($user->id) && $user->id > 0 ? $user->id :
"null").
", ";
574 $sql .= ($userownerid > 0 ? $userownerid :
"null").
", ";
575 $sql .= ($userdoneid > 0 ? $userdoneid :
"null").
", ";
576 $sql .=
"'".$this->db->escape($this->label).
"', ";
577 $sql .=
"'".$this->db->escape($this->percentage).
"', ";
578 $sql .=
"'".$this->db->escape($this->priority).
"', ";
579 $sql .=
"'".$this->db->escape($this->fulldayevent).
"', ";
580 $sql .=
"'".$this->db->escape($this->location).
"', ";
581 $sql .=
"'".$this->db->escape($this->transparency).
"', ";
582 $sql .= (!empty($this->fk_element) ? ((int) $this->fk_element) :
"null").
", ";
583 $sql .= (!empty($this->elementtype) ?
"'".$this->db->escape($this->elementtype).
"'" :
"null").
", ";
584 $sql .= ((int) $conf->entity).
",";
585 $sql .= (!empty($this->extraparams) ?
"'".$this->db->escape($this->extraparams).
"'" :
"null").
", ";
587 $sql .= (!empty($this->email_msgid) ?
"'".$this->db->escape($this->email_msgid).
"'" :
"null").
", ";
588 $sql .= (!empty($this->email_from) ?
"'".$this->db->escape($this->email_from).
"'" :
"null").
", ";
589 $sql .= (!empty($this->email_sender) ?
"'".$this->db->escape($this->email_sender).
"'" :
"null").
", ";
590 $sql .= (!empty($this->email_to) ?
"'".$this->db->escape($this->email_to).
"'" :
"null").
", ";
591 $sql .= (!empty($this->email_tocc) ?
"'".$this->db->escape($this->email_tocc).
"'" :
"null").
", ";
592 $sql .= (!empty($this->email_tobcc) ?
"'".$this->db->escape($this->email_tobcc).
"'" :
"null").
", ";
593 $sql .= (!empty($this->email_subject) ?
"'".$this->db->escape($this->email_subject).
"'" :
"null").
", ";
594 $sql .= (!empty($this->errors_to) ?
"'".$this->db->escape($this->errors_to).
"'" :
"null").
", ";
595 $sql .= (!empty($this->recurid) ?
"'".$this->db->escape($this->recurid).
"'" :
"null").
", ";
596 $sql .= (!empty($this->recurrule) ?
"'".$this->db->escape($this->recurrule).
"'" :
"null").
", ";
597 $sql .= (!empty($this->recurdateend) ?
"'".$this->db->idate($this->recurdateend).
"'" :
"null").
", ";
598 $sql .= (!empty($this->num_vote) ? (int) $this->num_vote :
"null").
", ";
599 $sql .= (!empty($this->event_paid) ? (int) $this->event_paid : 0).
", ";
600 $sql .= (!empty($this->status) ? (int) $this->status :
"0").
", ";
601 $sql .= (!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
604 dol_syslog(get_class($this).
"::add", LOG_DEBUG);
607 $this->
ref = $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"actioncomm",
"id");
608 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"actioncomm SET ref='".$this->
db->escape($this->
ref).
"' WHERE id=".$this->id;
612 dol_syslog(
'Error to process ref: '.$this->
db->lasterror(), LOG_ERR);
613 $this->errors[] = $this->
db->lasterror();
618 $already_inserted = array();
619 foreach ($this->userassigned as $key => $val) {
621 if (!is_array($val)) {
622 $val = array(
'id'=>$val);
625 if ($val[
'id'] > 0) {
626 if (!empty($already_inserted[$val[
'id']])) {
630 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
631 $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'])).
")";
636 dol_syslog(
'Error to process userassigned: ' . $this->
db->lasterror(), LOG_ERR);
637 $this->errors[] = $this->
db->lasterror();
639 $already_inserted[$val[
'id']] =
true;
647 if (!empty($this->socpeopleassigned)) {
648 $already_inserted = array();
649 foreach ($this->socpeopleassigned as $id => $val) {
651 if (!empty($already_inserted[$id])) {
655 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
656 $sql .=
" VALUES(".((int) $this->
id).
", 'socpeople', ".((int) $id).
", 0, 0, 0)";
661 dol_syslog(
'Error to process socpeopleassigned: ' . $this->
db->lasterror(), LOG_ERR);
662 $this->errors[] = $this->
db->lasterror();
664 $already_inserted[$id] =
true;
678 if (!$error && !$notrigger) {
691 $this->
db->rollback();
695 $this->
db->rollback();
696 $this->error = $this->
db->lasterror();
717 $objFrom = clone $this;
728 $this->recurrule =
'';
729 $this->recurdateend =
'';
732 $this->context[
'createfromclone'] =
'createfromclone';
733 $result = $this->
create($fuser);
740 if (is_object($hookmanager)) {
741 $parameters = array(
'objFrom'=>$objFrom);
743 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $this, $action);
757 unset($this->context[
'createfromclone']);
764 $this->
db->rollback();
779 public function fetch($id, $ref =
'', $ref_ext =
'', $email_msgid =
'', $loadresources = 1)
783 if (empty($id) && empty($ref) && empty($ref_ext) && empty($email_msgid)) {
784 dol_syslog(get_class($this).
"::fetch Bad parameters", LOG_WARNING);
788 $sql =
"SELECT a.id,";
789 $sql .=
" a.ref as ref,";
790 $sql .=
" a.entity,";
791 $sql .=
" a.ref_ext,";
793 $sql .=
" a.datep2,";
794 $sql .=
" a.durationp,";
796 $sql .=
" a.tms as datem,";
797 $sql .=
" a.code, a.label, a.note as note_private,";
798 $sql .=
" a.fk_soc,";
799 $sql .=
" a.fk_project,";
800 $sql .=
" a.fk_user_author, a.fk_user_mod,";
801 $sql .=
" a.fk_user_action, a.fk_user_done,";
802 $sql .=
" a.fk_contact, a.percent as percentage,";
803 $sql .=
" a.fk_element as elementid, a.elementtype,";
804 $sql .=
" a.priority, a.fulldayevent, a.location, a.transparency,";
805 $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,";
806 $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,";
807 $sql .=
" s.nom as socname,";
808 $sql .=
" u.firstname, u.lastname as lastname,";
809 $sql .=
" num_vote, event_paid, a.status";
810 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a ";
811 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action=c.id ";
812 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_author";
813 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on s.rowid = a.fk_soc";
816 $sql .=
" a.ref = '".$this->db->escape($ref).
"'";
817 } elseif ($ref_ext) {
818 $sql .=
" a.ref_ext = '".$this->db->escape($ref_ext).
"'";
819 } elseif ($email_msgid) {
820 $sql .=
" a.email_msgid = '".$this->db->escape($email_msgid).
"'";
822 $sql .=
" a.id = ".((int) $id);
825 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
830 $obj = $this->
db->fetch_object(
$resql);
832 $this->
id = $obj->id;
833 $this->entity = $obj->entity;
834 $this->
ref = $obj->ref;
835 $this->ref_ext = $obj->ref_ext;
838 $this->type_id = $obj->type_id;
839 $this->type_code = $obj->type_code;
840 $this->type_color = $obj->type_color;
841 $this->type_picto = $obj->type_picto;
842 $this->
type = $obj->type_type;
845 $transcode = $langs->trans(
"Action".$obj->type_code.
'Short');
846 $this->type_short = (($transcode !=
"Action".$obj->type_code.
'Short') ? $transcode :
'');
848 $this->
code = $obj->code;
849 $this->label = $obj->label;
850 $this->datep = $this->
db->jdate($obj->datep);
851 $this->datef = $this->
db->jdate($obj->datep2);
853 $this->datec = $this->
db->jdate($obj->datec);
854 $this->datem = $this->
db->jdate($obj->datem);
856 $this->note = $obj->note_private;
857 $this->note_private = $obj->note_private;
858 $this->percentage = $obj->percentage;
860 $this->authorid = $obj->fk_user_author;
861 $this->usermodid = $obj->fk_user_mod;
863 if (!is_object($this->author)) {
864 $this->author =
new User($this->
db);
866 $this->author->id = $obj->fk_user_author;
867 $this->author->firstname = $obj->firstname;
868 $this->author->lastname = $obj->lastname;
869 if (!is_object($this->usermod)) {
870 $this->usermod =
new User($this->
db);
872 $this->usermod->id = $obj->fk_user_mod;
874 $this->userownerid = $obj->fk_user_action;
875 $this->priority = $obj->priority;
876 $this->fulldayevent = $obj->fulldayevent;
877 $this->location = $obj->location;
878 $this->transparency = $obj->transparency;
880 $this->socid = $obj->fk_soc;
881 $this->contact_id = $obj->fk_contact;
882 $this->fk_project = $obj->fk_project;
887 $this->fk_element = $obj->elementid;
888 $this->elementid = $obj->elementid;
889 $this->elementtype = $obj->elementtype;
891 $this->num_vote = $obj->num_vote;
892 $this->event_paid = $obj->event_paid;
893 $this->status = $obj->status;
896 $this->email_msgid=$obj->email_msgid;
897 $this->email_from=$obj->email_from;
898 $this->email_sender=$obj->email_sender;
899 $this->email_to=$obj->email_to;
900 $this->email_tocc=$obj->email_tocc;
901 $this->email_tobcc=$obj->email_tobcc;
902 $this->email_subject=$obj->email_subject;
903 $this->errors_to=$obj->errors_to;
907 if ($loadresources) {
914 $this->error = $this->
db->lasterror();
928 $this->userassigned = array();
929 $this->socpeopleassigned = array();
931 $sql =
'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency';
932 $sql .=
' FROM '.MAIN_DB_PREFIX.
'actioncomm_resources';
933 $sql .=
' WHERE fk_actioncomm = '.((int) $this->
id);
934 $sql .=
" AND element_type IN ('user', 'socpeople')";
938 if ($this->userownerid > 0) {
939 $this->userassigned[$this->userownerid] = array(
'id'=>$this->userownerid);
942 while ($obj = $this->
db->fetch_object(
$resql)) {
943 if ($obj->fk_element > 0) {
944 switch ($obj->element_type) {
946 $this->userassigned[$obj->fk_element] = array(
'id'=>$obj->fk_element,
'mandatory'=>$obj->mandatory,
'answer_status'=>$obj->answer_status,
'transparency'=>$obj->transparency);
947 if (empty($this->userownerid)) {
948 $this->userownerid = $obj->fk_element;
952 $this->socpeopleassigned[$obj->fk_element] = array(
'id'=>$obj->fk_element,
'mandatory'=>$obj->mandatory,
'answer_status'=>$obj->answer_status,
'transparency'=>$obj->transparency);
975 $sql =
"SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency";
976 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm_resources";
977 $sql .=
" WHERE element_type = 'user' AND fk_actioncomm = ".((int) $this->
id);
979 $resql2 = $this->
db->query($sql);
981 $this->userassigned = array();
984 if ($this->userownerid > 0) {
986 $this->userassigned[$this->userownerid] = array(
'id'=>$this->userownerid);
989 while ($obj = $this->
db->fetch_object($resql2)) {
990 if ($obj->fk_element > 0) {
991 $this->userassigned[$obj->fk_element] = array(
'id'=>$obj->fk_element,
992 'mandatory'=>$obj->mandatory,
993 'answer_status'=>$obj->answer_status,
994 'transparency'=>$obj->transparency);
997 if ($override ===
true) {
999 if (empty($this->userownerid)) {
1000 $this->userownerid = $obj->fk_element;
1018 public function delete($notrigger = 0)
1024 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1030 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm";
1031 $sql .=
" WHERE fk_actioncomm=".((int) $this->
id);
1033 $res = $this->
db->query($sql);
1035 $this->error = $this->
db->lasterror();
1042 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_resources";
1043 $sql .=
" WHERE fk_actioncomm=".((int) $this->
id);
1045 $res = $this->
db->query($sql);
1047 $this->error = $this->
db->lasterror();
1053 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1054 $sql .=
" WHERE fk_actioncomm = ".((int) $this->
id);
1056 $res = $this->
db->query($sql);
1058 $this->error = $this->
db->lasterror();
1068 dol_syslog(get_class($this).
"::delete error -3 ".$this->error, LOG_ERR);
1074 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm";
1075 $sql .=
" WHERE id=".((int) $this->
id);
1077 $res = $this->
db->query($sql);
1079 $this->error = $this->
db->lasterror();
1095 $this->
db->commit();
1098 $this->
db->rollback();
1102 $this->
db->rollback();
1103 $this->error = $this->
db->lasterror();
1118 global $langs, $conf, $hookmanager;
1123 $this->label = trim($this->label);
1124 $this->note_private =
dol_htmlcleanlastbr(trim(!isset($this->note_private) ? $this->note : $this->note_private));
1125 if (empty($this->percentage)) {
1126 $this->percentage = 0;
1128 if (empty($this->priority) || !is_numeric($this->priority)) {
1129 $this->priority = 0;
1131 if (empty($this->transparency)) {
1132 $this->transparency = 0;
1134 if (empty($this->fulldayevent)) {
1135 $this->fulldayevent = 0;
1137 if ($this->percentage > 100) {
1138 $this->percentage = 100;
1141 if ($this->datep && $this->datef) {
1142 $this->durationp = ($this->datef - $this->datep);
1145 if ($this->datep && $this->datef && $this->datep > $this->datef) {
1146 $this->datef = $this->datep;
1149 if ($this->fk_project < 0) {
1150 $this->fk_project = 0;
1154 if ($this->percentage == 0 && $this->userdoneid > 0) {
1155 $this->error =
"ErrorCantSaveADoneUserWithZeroPercentage";
1159 $socid = (($this->socid > 0) ? $this->socid : 0);
1160 $contactid = (($this->contact_id > 0) ? $this->contact_id : 0);
1161 $userownerid = ($this->userownerid ? $this->userownerid : 0);
1162 $userdoneid = ($this->userdoneid ? $this->userdoneid : 0);
1165 if ($this->type_id > 0) {
1166 if (empty($this->type_code)) {
1168 $result = $cactioncomm->fetch($this->type_id);
1169 if ($result >= 0 && !empty($cactioncomm->code)) {
1170 $this->type_code = $cactioncomm->code;
1175 $code = $this->code;
1176 if (empty($code) || (!empty($this->oldcopy) && $this->oldcopy->type_code != $this->type_code)) {
1177 $code = $this->type_code;
1182 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"actioncomm";
1183 $sql .=
" SET percent = '".$this->db->escape($this->percentage).
"'";
1184 $sql .=
", fk_action = ".(int) $this->type_id;
1185 $sql .=
", code = " . ($code ?
"'".$this->db->escape($code).
"'" :
"null");
1186 $sql .=
", label = ".($this->label ?
"'".$this->db->escape($this->label).
"'" :
"null");
1187 $sql .=
", datep = ".(strval($this->datep) !=
'' ?
"'".$this->db->idate($this->datep).
"'" :
'null');
1188 $sql .=
", datep2 = ".(strval($this->datef) !=
'' ?
"'".$this->db->idate($this->datef).
"'" :
'null');
1189 $sql .=
", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp !=
'' ?
"'".$this->db->escape($this->durationp).
"'" :
"null");
1190 $sql .=
", note = '".$this->db->escape($this->note_private).
"'";
1191 $sql .=
", fk_project =".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null");
1192 $sql .=
", fk_soc =".($socid > 0 ? ((int) $socid) :
"null");
1193 $sql .=
", fk_contact =".($contactid > 0 ? ((int) $contactid) :
"null");
1194 $sql .=
", priority = '".$this->db->escape($this->priority).
"'";
1195 $sql .=
", fulldayevent = '".$this->db->escape($this->fulldayevent).
"'";
1196 $sql .=
", location = ".($this->location ?
"'".$this->db->escape($this->location).
"'" :
"null");
1197 $sql .=
", transparency = '".$this->db->escape($this->transparency).
"'";
1198 $sql .=
", fk_user_mod = ".((int) $user->id);
1199 $sql .=
", fk_user_action = ".($userownerid > 0 ? ((int) $userownerid) :
"null");
1200 $sql .=
", fk_user_done = ".($userdoneid > 0 ? ((int) $userdoneid) :
"null");
1201 if (!empty($this->fk_element)) {
1202 $sql .=
", fk_element=".($this->fk_element ? ((int) $this->fk_element) :
"null");
1204 if (!empty($this->elementtype)) {
1205 $sql .=
", elementtype=".($this->elementtype ?
"'".$this->db->escape($this->elementtype).
"'" :
"null");
1207 if (!empty($this->num_vote)) {
1208 $sql .=
", num_vote=".($this->num_vote ? (int) $this->num_vote :
null);
1210 if (!empty($this->event_paid)) {
1211 $sql .=
", event_paid=".($this->event_paid ? (int) $this->event_paid : 0);
1213 if (!empty($this->status)) {
1214 $sql .=
", status=".($this->status ? (int) $this->status : 0);
1216 $sql .=
" WHERE id=".((int) $this->
id);
1218 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1219 if ($this->
db->query($sql)) {
1232 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_resources where fk_actioncomm = ".((int) $this->
id).
" AND element_type = 'user'";
1235 $already_inserted = array();
1236 foreach ($this->userassigned as $key => $val) {
1237 if (!is_array($val)) {
1238 $val = array(
'id'=>$val);
1240 if (!empty($already_inserted[$val[
'id']]))
continue;
1242 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
1243 $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'])).
")";
1248 $this->errors[] = $this->
db->lasterror();
1250 $already_inserted[$val[
'id']] =
true;
1257 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_resources where fk_actioncomm = ".((int) $this->
id).
" AND element_type = 'socpeople'";
1260 if (!empty($this->socpeopleassigned)) {
1261 $already_inserted = array();
1262 foreach (array_keys($this->socpeopleassigned) as $key => $val) {
1263 if (!is_array($val)) {
1264 $val = array(
'id'=>$val);
1266 if (!empty($already_inserted[$val[
'id']]))
continue;
1268 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
1269 $sql .=
" VALUES(".((int) $this->
id).
", 'socpeople', ".((int) $val[
'id']).
", 0, 0, 0)";
1274 $this->errors[] = $this->
db->lasterror();
1276 $already_inserted[$val[
'id']] =
true;
1282 if (!$error && !$notrigger) {
1292 $this->
db->commit();
1295 $this->
db->rollback();
1296 dol_syslog(get_class($this).
"::update ".join(
',', $this->errors), LOG_ERR);
1300 $this->
db->rollback();
1301 $this->error = $this->
db->lasterror();
1319 public function getActions($socid = 0, $fk_element = 0, $elementtype =
'', $filter =
'', $sortfield =
'a.datep', $sortorder =
'DESC', $limit = 0)
1321 global $conf, $langs;
1323 $resarray = array();
1325 dol_syslog(get_class().
"::getActions", LOG_DEBUG);
1327 require_once DOL_DOCUMENT_ROOT .
'/core/class/hookmanager.class.php';
1330 $hookmanager->initHooks(array(
'agendadao'));
1332 $sql =
"SELECT a.id";
1333 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
1335 $parameters = array(
'sql' => &$sql,
'socid' => $socid,
'fk_element' => $fk_element,
'elementtype' => $elementtype);
1336 $reshook = $hookmanager->executeHooks(
'getActionsListFrom', $parameters);
1337 if (!empty($hookmanager->resPrint)) $sql.= $hookmanager->resPrint;
1338 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
1339 if (!empty($socid)) {
1340 $sql .=
" AND a.fk_soc = ".((int) $socid);
1342 if (!empty($elementtype)) {
1343 if ($elementtype ==
'project') {
1344 $sql .=
' AND a.fk_project = '.((int) $fk_element);
1345 } elseif ($elementtype ==
'contact') {
1346 $sql .=
' AND a.id IN';
1347 $sql .=
" (SELECT fk_actioncomm FROM ".MAIN_DB_PREFIX.
"actioncomm_resources WHERE";
1348 $sql .=
" element_type = 'socpeople' AND fk_element = ".((int) $fk_element).
')';
1350 $sql .=
" AND a.fk_element = ".((int) $fk_element).
" AND a.elementtype = '".$this->
db->escape($elementtype).
"'";
1353 if (!empty($filter)) {
1357 $parameters = array(
'sql' => &$sql,
'socid' => $socid,
'fk_element' => $fk_element,
'elementtype' => $elementtype);
1358 $reshook = $hookmanager->executeHooks(
'getActionsListWhere', $parameters);
1359 if (!empty($hookmanager->resPrint)) $sql.= $hookmanager->resPrint;
1360 if ($sortorder && $sortfield) {
1361 $sql .= $this->
db->order($sortfield, $sortorder);
1363 $sql .= $this->
db->plimit($limit, 0);
1367 $num = $this->
db->num_rows(
$resql);
1370 for ($i = 0; $i < $num; $i++) {
1371 $obj = $this->
db->fetch_object(
$resql);
1373 $actioncommstatic->fetch($obj->id);
1374 $resarray[$i] = $actioncommstatic;
1380 return $this->
db->lasterror();
1395 global $conf, $langs;
1397 if (empty($load_state_board)) {
1398 $sql =
"SELECT a.id, a.datep as dp";
1400 $this->nb = array();
1401 $sql =
"SELECT count(a.id) as nb";
1403 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
1404 if (empty($user->rights->societe->client->voir) && !$user->socid) {
1405 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
1407 if (empty($user->rights->agenda->allactions->read)) {
1408 $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);
1410 $sql .=
" WHERE 1 = 1";
1411 if (empty($load_state_board)) {
1412 $sql .=
" AND a.percent >= 0 AND a.percent < 100";
1414 $sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
1415 if (empty($user->rights->societe->client->voir) && !$user->socid) {
1416 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
1419 $sql .=
" AND a.fk_soc = ".((int) $user->socid);
1421 if (empty($user->rights->agenda->allactions->read)) {
1422 $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);
1423 $sql .=
" OR ar.fk_element = ".((int) $user->id);
1429 if (empty($load_state_board)) {
1432 $response->warning_delay = $conf->agenda->warning_delay / 60 / 60 / 24;
1433 $response->label = $langs->trans(
"ActionsToDo");
1434 $response->labelShort = $langs->trans(
"ActionsToDoShort");
1435 $response->url = DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&actioncode=0&status=todo&mainmenu=agenda';
1436 if ($user->hasRight(
"agenda",
"allactions",
"read")) {
1437 $response->url .=
'&filtert=-1';
1439 $response->img =
img_object(
'',
"action",
'class="inline-block valigntextmiddle"');
1442 while ($obj = $this->
db->fetch_object(
$resql)) {
1443 if (empty($load_state_board)) {
1444 $response->nbtodo++;
1445 $agenda_static->datep = $this->
db->jdate($obj->dp);
1446 if ($agenda_static->hasDelay()) {
1447 $response->nbtodolate++;
1450 $this->nb[
"actionscomm"] = $obj->nb;
1455 if (empty($load_state_board)) {
1462 $this->error = $this->
db->error();
1479 $sql .=
' tms as datem,';
1480 $sql .=
' fk_user_author,';
1481 $sql .=
' fk_user_mod';
1482 $sql .=
' FROM '.MAIN_DB_PREFIX.
'actioncomm as a';
1483 $sql .=
' WHERE a.id = '.((int) $id);
1485 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
1486 $result = $this->
db->query($sql);
1488 if ($this->
db->num_rows($result)) {
1489 $obj = $this->
db->fetch_object($result);
1490 $this->
id = $obj->id;
1491 $this->user_creation_id = $obj->fk_user_author;
1492 $this->user_modification_id = $obj->fk_user_mod;
1493 $this->date_creation = $this->
db->jdate($obj->datec);
1494 $this->date_modification = empty($obj->datem) ?
'' : $this->
db->jdate($obj->datem);
1496 $this->
db->free($result);
1512 return $this->
LibStatut($this->percentage, $mode, $hidenastatus, $this->datep);
1525 public function LibStatut($percent, $mode, $hidenastatus = 0, $datestart =
'')
1530 $labelStatus = $langs->transnoentitiesnoconv(
'StatusNotApplicable');
1531 if ($percent == -1 && !$hidenastatus) {
1532 $labelStatus = $langs->transnoentitiesnoconv(
'StatusNotApplicable');
1533 } elseif ($percent == 0) {
1534 $labelStatus = $langs->transnoentitiesnoconv(
'StatusActionToDo').
' (0%)';
1535 } elseif ($percent > 0 && $percent < 100) {
1536 $labelStatus = $langs->transnoentitiesnoconv(
'StatusActionInProcess').
' ('.$percent.
'%)';
1537 } elseif ($percent >= 100) {
1538 $labelStatus = $langs->transnoentitiesnoconv(
'StatusActionDone').
' (100%)';
1541 $labelStatusShort = $langs->transnoentitiesnoconv(
'StatusNotApplicable');
1542 if ($percent == -1 && !$hidenastatus) {
1543 $labelStatusShort = $langs->trans(
'NA');
1544 } elseif ($percent == 0) {
1545 $labelStatusShort =
'0%';
1546 } elseif ($percent > 0 && $percent < 100) {
1547 $labelStatusShort = $percent.
'%';
1548 } elseif ($percent >= 100) {
1549 $labelStatusShort =
'100%';
1552 $statusType =
'status9';
1553 if ($percent == -1 && !$hidenastatus) {
1554 $statusType =
'status9';
1556 if ($percent == 0) {
1557 $statusType =
'status1';
1559 if ($percent > 0 && $percent < 100) {
1560 $statusType =
'status3';
1562 if ($percent >= 100) {
1563 $statusType =
'status6';
1566 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
1582 public function getNomUrl($withpicto = 0, $maxlength = 0, $classname =
'', $option =
'', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1)
1584 global $conf, $langs, $user, $hookmanager, $action;
1586 if (!empty($conf->dol_no_mouse_hover)) {
1591 if (!empty($user->rights->agenda->myactions->read) && $this->authorid == $user->id) {
1594 if (!empty($user->rights->agenda->myactions->read) && array_key_exists($user->id, $this->userassigned)) {
1597 if (!empty($user->rights->agenda->allactions->read)) {
1604 $label = $this->label;
1605 if (empty($label)) {
1606 $label = $this->libelle;
1613 if ($this->type_code) {
1614 $labeltype = ($langs->transnoentities(
"Action".$this->type_code) !=
"Action".$this->type_code) ? $langs->transnoentities(
"Action".$this->type_code) : $this->type_label;
1616 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1617 if ($this->type_code !=
'AC_OTH_AUTO') {
1618 $labeltype = $langs->trans(
'ActionAC_MANUAL');
1622 $tooltip =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
'Action').
'</u>';
1623 if (!empty($this->
ref)) {
1626 if (!empty($label)) {
1629 if (!empty($labeltype)) {
1632 if (!empty($this->location)) {
1633 $tooltip .=
'<br><b>'.$langs->trans(
'Location').
':</b> '.
dol_escape_htmltag($this->location);
1635 if (isset($this->transparency)) {
1636 $tooltip .=
'<br><b>'.$langs->trans(
'Busy').
':</b> '.
yn($this->transparency);
1638 if (!empty($this->email_msgid)) {
1639 $langs->load(
"mails");
1642 $tooltip .=
'<br><b>'.$langs->trans(
'MailTopic').
':</b> '.
dol_escape_htmltag($this->email_subject);
1643 $tooltip .=
'<br><b>'.$langs->trans(
'MailFrom').
':</b> '.str_replace(array(
'<',
'>'), array(
'&lt',
'&gt'), $this->email_from);
1644 $tooltip .=
'<br><b>'.$langs->trans(
'MailTo').
':</b> '.str_replace(array(
'<',
'>'), array(
'&lt',
'&gt'), $this->email_to);
1645 if (!empty($this->email_tocc)) {
1646 $tooltip .=
'<br><b>'.$langs->trans(
'MailCC').
':</b> '.str_replace(array(
'<',
'>'), array(
'&lt',
'&gt'), $this->email_tocc);
1653 if (!empty($this->note_private)) {
1654 $tooltip .=
'<br><br><b>'.$langs->trans(
'Description').
':</b><br>';
1656 $tooltip .=
'<div class="tenlinesmax">';
1657 $tooltip .= (
dol_textishtml($texttoshow) ? str_replace(array(
"\r",
"\n"),
"", $texttoshow) : str_replace(array(
"\r",
"\n"),
'<br>', $texttoshow));
1658 $tooltip .=
'</div>';
1664 if (empty($notooltip)) {
1665 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1666 $label = $langs->trans(
"ShowAction");
1667 $linkclose .=
' alt="'.dol_escape_htmltag($tooltip, 1).
'"';
1669 $linkclose .=
' title="'.dol_escape_htmltag($tooltip, 1, 0,
'', 1).
'"';
1670 $linkclose .=
' class="'.$classname.
' classfortooltip"';
1672 $linkclose .=
' class="'.$classname.
'"';
1676 if ($option ==
'birthday') {
1677 $url = DOL_URL_ROOT.
'/contact/perso.php?id='.$this->id;
1678 } elseif ($option ==
'holiday') {
1679 $url = DOL_URL_ROOT.
'/holiday/card.php?id='.$this->id;
1681 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$this->id;
1684 if ($option !==
'nolink') {
1686 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1687 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1688 $add_save_lastsearch_values = 1;
1690 if ($add_save_lastsearch_values) {
1691 $url .=
'&save_lastsearch_values=1';
1695 $linkstart =
'<a href="'.$url.
'"';
1696 $linkstart .= $linkclose.
'>';
1699 if ($option ==
'nolink') {
1704 if ($withpicto == 2) {
1705 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1706 $label = $labeltype;
1710 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($label)) {
1711 $label = $labeltype;
1713 if ($maxlength < 0) {
1714 $labelshort = $this->ref;
1716 $labelshort =
dol_trunc($label, $maxlength);
1721 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1723 $label .= (preg_match(
'/'.preg_quote($labeltype,
'/').
'/', $label) ?
'' :
' ('.$langs->transnoentities(
"Action".$this->type_code).
')');
1728 $result .= $linkstart;
1730 $result .=
img_object(($notooltip ?
'' : $langs->trans(
"ShowAction").
': '.$label), ($overwritepicto ? $overwritepicto :
'action'), (($this->type_color && $overwritepicto) ?
'style="color: #'.$this->type_color.
' !important;" ' :
'').($notooltip ?
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"' :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
1733 $result .= $linkend;
1736 $hookmanager->initHooks(array(
'actiondao'));
1737 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1738 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1740 $result = $hookmanager->resPrint;
1742 $result .= $hookmanager->resPrint;
1758 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1760 if ($this->type_color) {
1761 $color =
'style="color: #'.$this->type_color.
' !important;"';
1763 if ($this->type_picto) {
1764 $imgpicto =
img_picto(
'', $this->type_picto,
'class="paddingright"');
1766 if ($this->type_code ==
'AC_RDV') {
1767 $imgpicto =
img_picto(
'',
'meeting', $color,
false, 0, 0,
'',
'paddingright');
1768 } elseif ($this->type_code ==
'AC_TEL') {
1769 $imgpicto =
img_picto(
'',
'object_phoning', $color,
false, 0, 0,
'',
'paddingright');
1770 } elseif ($this->type_code ==
'AC_FAX') {
1771 $imgpicto =
img_picto(
'',
'object_phoning_fax', $color,
false, 0, 0,
'',
'paddingright');
1772 } elseif ($this->type_code ==
'AC_EMAIL' || $this->type_code ==
'AC_EMAIL_IN' || preg_match(
'/_SENTBYMAIL/', $this->
code)) {
1773 $imgpicto =
img_picto(
'',
'object_email', $color,
false, 0, 0,
'',
'paddingright');
1774 } elseif ($this->type_code ==
'AC_INT') {
1775 $imgpicto =
img_picto(
'',
'object_intervention', $color,
false, 0, 0,
'',
'paddingright');
1776 } elseif (preg_match(
'/^TICKET_MSG/', $this->
code)) {
1777 $imgpicto =
img_picto(
'',
'object_conversation', $color,
false, 0, 0,
'',
'paddingright');
1778 } elseif ($this->
type !=
'systemauto') {
1779 $imgpicto =
img_picto(
'',
'user-cog', $color,
false, 0, 0,
'',
'paddingright');
1781 $imgpicto =
img_picto(
'',
'cog', $color,
false, 0, 0,
'',
'paddingright');
1786 if ($this->
type !=
'systemauto') {
1787 $imgpicto =
img_picto(
'',
'user-cog',
'',
false, 0, 0,
'',
'paddingright');
1789 $imgpicto =
img_picto(
'',
'cog',
'',
false, 0, 0,
'',
'paddingright');
1809 if (!is_array($categories)) {
1810 $categories = array($categories);
1814 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1816 $existing = $c->containing($this->
id, Categorie::TYPE_ACTIONCOMM,
'id');
1819 if (is_array($existing)) {
1820 $to_del = array_diff($existing, $categories);
1821 $to_add = array_diff($categories, $existing);
1824 $to_add = $categories;
1828 foreach ($to_del as $del) {
1829 if ($c->fetch($del) > 0) {
1830 $c->del_type($this, Categorie::TYPE_ACTIONCOMM);
1833 foreach ($to_add as $add) {
1834 if ($c->fetch($add) > 0) {
1835 $c->add_type($this, Categorie::TYPE_ACTIONCOMM);
1853 public function build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholiday = 0)
1855 global $hookmanager;
1858 global $conf, $langs, $dolibarr_main_url_root, $mysoc;
1860 require_once DOL_DOCUMENT_ROOT.
"/core/lib/xcal.lib.php";
1861 require_once DOL_DOCUMENT_ROOT.
"/core/lib/date.lib.php";
1862 require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
1864 dol_syslog(get_class($this).
"::build_exportfile Build export file format=".$format.
", type=".$type.
", cachedelay=".$cachedelay.
", filename=".$filename.
", filters size=".count($filters), LOG_DEBUG);
1867 if (empty($format)) {
1874 if ($format ==
'ical') {
1877 $filename = $format.
'.'.$extension;
1881 $result =
dol_mkdir($conf->agenda->dir_temp);
1882 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
1887 $login =
''; $logina =
''; $logind =
''; $logint =
'';
1893 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1895 dol_syslog(get_class($this).
"::build_exportfile file ".$outputfile.
" is not older than now - cachedelay (".$nowgmt.
" - ".$cachedelay.
"). Build is canceled");
1902 $eventarray = array();
1904 $sql =
"SELECT a.id,";
1905 $sql .=
" a.datep,";
1906 $sql .=
" a.datep2,";
1907 $sql .=
" a.durationp,";
1908 $sql .=
" a.datec, a.tms as datem,";
1909 $sql .=
" a.label, a.code, a.note as note_private, a.fk_action as type_id,";
1910 $sql .=
" a.fk_soc,";
1911 $sql .=
" a.fk_user_author, a.fk_user_mod,";
1912 $sql .=
" a.fk_user_action,";
1913 $sql .=
" a.fk_contact, a.percent as percentage,";
1914 $sql .=
" a.fk_element, a.elementtype,";
1915 $sql .=
" a.priority, a.fulldayevent, a.location, a.transparency,";
1916 $sql .=
" u.firstname, u.lastname, u.email,";
1917 $sql .=
" s.nom as socname,";
1918 $sql .=
" c.id as type_id, c.code as type_code, c.libelle as type_label,";
1919 $sql .=
" num_vote, event_paid, a.status";
1920 $sql .=
" FROM (".MAIN_DB_PREFIX.
"c_actioncomm as c, ".MAIN_DB_PREFIX.
"actioncomm as a)";
1921 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_author";
1922 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on s.rowid = a.fk_soc";
1924 $parameters = array(
'filters' => $filters);
1925 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
1926 $sql .= $hookmanager->resPrint;
1929 if ($filters[
'logint']) {
1930 $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
1932 $sql .=
" WHERE a.fk_action=c.id";
1933 $sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
1934 foreach ($filters as $key => $value) {
1935 if ($key ==
'notolderthan' && $value !=
'') {
1936 $sql .=
" AND a.datep >= '".$this->db->idate($now - ($value * 24 * 60 * 60)).
"'";
1938 if ($key ==
'year') {
1942 $sql .=
" AND a.id=".(is_numeric($value) ? $value : 0);
1944 if ($key ==
'idfrom') {
1945 $sql .=
" AND a.id >= ".(is_numeric($value) ? $value : 0);
1947 if ($key ==
'idto') {
1948 $sql .=
" AND a.id <= ".(is_numeric($value) ? $value : 0);
1950 if ($key ==
'project') {
1951 $sql .=
" AND a.fk_project=".(is_numeric($value) ? $value : 0);
1953 if ($key ==
'actiontype') {
1954 $sql .=
" AND c.type = '".$this->db->escape($value).
"'";
1956 if ($key ==
'notactiontype') {
1957 $sql .=
" AND c.type <> '".$this->db->escape($value).
"'";
1960 if ($key ==
'logint') {
1961 $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
1963 if ($key ==
'logina') {
1966 if (preg_match(
'/^!/', $logina)) {
1967 $logina = preg_replace(
'/^!/',
'', $logina);
1970 $userforfilter =
new User($this->
db);
1971 $result = $userforfilter->fetch(
'', $logina);
1973 $sql .=
" AND a.fk_user_author ".$condition.
" ".$userforfilter->id;
1974 } elseif ($result < 0 || $condition ==
'=') {
1975 $sql .=
" AND a.fk_user_author = 0";
1978 if ($key ==
'logint') {
1981 if (preg_match(
'/^!/', $logint)) {
1982 $logint = preg_replace(
'/^!/',
'', $logint);
1985 $userforfilter =
new User($this->
db);
1986 $result = $userforfilter->fetch(
'', $logint);
1988 $sql .=
" AND ar.fk_element = ".((int) $userforfilter->id);
1989 } elseif ($result < 0 || $condition ==
'=') {
1990 $sql .=
" AND ar.fk_element = 0";
1993 if ($key ==
'module') {
1994 $sql .=
" AND c.module LIKE '%".$this->db->escape($value).
"'";
1996 if ($key ==
'status') {
1997 $sql .=
" AND a.status =".((int) $value);
2001 $sql .=
" AND a.datep IS NOT NULL";
2003 $parameters = array(
'filters' => $filters);
2004 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
2005 $sql .= $hookmanager->resPrint;
2007 $sql .=
" ORDER by datep";
2010 dol_syslog(get_class($this).
"::build_exportfile select events", LOG_DEBUG);
2016 while ($obj = $this->
db->fetch_object(
$resql)) {
2021 $event[
'uid'] =
'dolibarragenda-'.$this->db->database_name.
'-'.$obj->id.
"@".$_SERVER[
"SERVER_NAME"];
2022 $event[
'type'] = $type;
2024 $datestart = $this->
db->jdate($obj->datep) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
2027 if (is_numeric($this->
db->jdate($obj->datep2))) {
2028 $dateend = $this->
db->jdate($obj->datep2) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
2031 $dateend = $datestart;
2034 $duration = ($datestart && $dateend) ? ($dateend - $datestart) : 0;
2035 $event[
'summary'] = $obj->label.($obj->socname ?
" (".$obj->socname.
")" :
"");
2037 $event[
'desc'] = $obj->note_private;
2038 $event[
'startdate'] = $datestart;
2039 $event[
'enddate'] = $dateend;
2040 $event[
'duration'] = $duration;
2042 $event[
'priority'] = $obj->priority;
2043 $event[
'fulldayevent'] = $obj->fulldayevent;
2044 $event[
'location'] = $obj->location;
2045 $event[
'transparency'] = (($obj->transparency > 0) ?
'OPAQUE' :
'TRANSPARENT');
2046 $event[
'category'] = $obj->type_label;
2047 $event[
'email'] = $obj->email;
2049 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
2050 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2052 $url = $urlwithroot.
'/comm/action/card.php?id='.$obj->id;
2053 $event[
'url'] = $url;
2054 $event[
'created'] = $this->
db->jdate($obj->datec) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
2055 $event[
'modified'] = $this->
db->jdate($obj->datem) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
2056 $event[
'num_vote'] = $this->num_vote;
2057 $event[
'event_paid'] = $this->event_paid;
2058 $event[
'status'] = $this->status;
2061 $this->
id = $obj->id;
2064 $assignedUserArray = array();
2066 foreach ($this->userassigned as $key => $value) {
2067 $assignedUser =
new User($this->
db);
2068 $assignedUser->fetch($value[
'id']);
2070 $assignedUserArray[$key] = $assignedUser;
2073 $event[
'assignedUsers'] = $assignedUserArray;
2075 if ($qualified && $datestart) {
2076 $eventarray[] = $event;
2081 $parameters = array(
'filters' => $filters,
'eventarray' => &$eventarray);
2082 $reshook = $hookmanager->executeHooks(
'addMoreEventsExport', $parameters);
2084 $eventarray = $hookmanager->resArray;
2087 $this->error = $this->
db->lasterror();
2091 if ($exportholiday == 1) {
2092 $langs->load(
"holiday");
2093 $title = $langs->trans(
"Holidays");
2095 $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";
2096 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
2097 $sql .=
" WHERE u.rowid = x.fk_user";
2098 $sql .=
" AND u.statut = '1'";
2099 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
2103 $num = $this->
db->num_rows(
$resql);
2107 $obj = $this->
db->fetch_object(
$resql);
2110 if ($obj->halfday == -1) {
2111 $event[
'fulldayevent'] =
false;
2115 } elseif ($obj->halfday == 1) {
2116 $event[
'fulldayevent'] =
false;
2121 $event[
'fulldayevent'] =
true;
2127 if (!empty($conf->global->AGENDA_EXPORT_FIX_TZ)) {
2128 $timestampStart = $timestampStart - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600);
2129 $timestampEnd = $timestampEnd - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600);
2132 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
2133 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2134 $url = $urlwithroot.
'/holiday/card.php?id='.$obj->rowid;
2136 $event[
'uid'] =
'dolibarrholiday-'.$this->db->database_name.
'-'.$obj->rowid.
"@".$_SERVER[
"SERVER_NAME"];
2138 $event[
'type'] =
'event';
2139 $event[
'category'] =
"Holiday";
2140 $event[
'transparency'] =
'OPAQUE';
2141 $event[
'email'] = $obj->email;
2142 $event[
'created'] = $timestampStart;
2143 $event[
'modified'] = $timestampStart;
2144 $event[
'startdate'] = $timestampStart;
2145 $event[
'enddate'] = $timestampEnd;
2146 $event[
'duration'] = $timestampEnd - $timestampStart;
2147 $event[
'url'] = $url;
2149 if ($obj->status == 2) {
2151 $event[
'summary'] = $title.
" - ".$obj->lastname.
" (wait for approval)";
2154 $event[
'summary'] = $title.
" - ".$obj->lastname;
2157 $eventarray[] = $event;
2164 $langs->load(
"agenda");
2169 $more = $langs->transnoentities(
"User").
' '.$login;
2172 $more = $langs->transnoentities(
"ActionsAskedBy").
' '.$logina;
2175 $more = $langs->transnoentities(
"ActionsToDoBy").
' '.$logint;
2178 $more = $langs->transnoentities(
"ActionsDoneBy").
' '.$logind;
2181 $title =
'Dolibarr actions '.$mysoc->name.
' - '.$more;
2183 $desc .=
' ('.$mysoc->name.
' - built by Dolibarr)';
2185 $title =
'Dolibarr actions '.$mysoc->name;
2186 $desc = $langs->transnoentities(
'ListOfActions');
2187 $desc .=
' ('.$mysoc->name.
' - built by Dolibarr)';
2191 $outputfiletmp = tempnam($conf->agenda->dir_temp,
'tmp');
2192 @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK));
2195 if ($format ==
'vcal') {
2196 $result =
build_calfile($format, $title, $desc, $eventarray, $outputfiletmp);
2197 } elseif ($format ==
'ical') {
2198 $result =
build_calfile($format, $title, $desc, $eventarray, $outputfiletmp);
2199 } elseif ($format ==
'rss') {
2200 $result =
build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp);
2204 if (
dol_move($outputfiletmp, $outputfile, 0, 1)) {
2207 $this->error =
'Failed to rename '.$outputfiletmp.
' into '.$outputfile;
2208 dol_syslog(get_class($this).
"::build_exportfile ".$this->error, LOG_ERR);
2213 dol_syslog(get_class($this).
"::build_exportfile build_xxxfile function fails to for format=".$format.
" outputfiletmp=".$outputfile, LOG_ERR);
2215 $langs->load(
"errors");
2216 $this->error = $langs->trans(
"ErrorFailToCreateFile", $outputfile);
2238 $this->specimen = 1;
2240 $this->type_code =
'AC_OTH';
2241 $this->
code =
'AC_SPECIMEN_CODE';
2242 $this->label =
'Label of event Specimen';
2243 $this->datec = $now;
2244 $this->datem = $now;
2245 $this->datep = $now;
2246 $this->datef = $now;
2247 $this->fulldayevent = 0;
2248 $this->percentage = 0;
2250 $this->location =
'Location';
2251 $this->transparency = 1;
2252 $this->priority = 1;
2254 $this->note_private =
"This is a 'private' note.";
2256 $this->userownerid = $user->id;
2257 $this->userassigned[$user->id] = array(
'id'=>$user->id,
'transparency'=> 1);
2288 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'actioncomm SET fk_element = ' . ((int) $dest_id) .
' WHERE elementtype="product" AND fk_element = '.((int) $origin_id);
2290 if (!$dbs->
query($sql)) {
2309 return $this->datep && ($this->datep < ($now - $conf->agenda->warning_delay));
2323 global $conf, $langs, $user;
2327 $this->reminders = array();
2330 $sql =
"SELECT rowid as id, typeremind, dateremind, status, offsetvalue, offsetunit, fk_user";
2331 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
2332 $sql .=
" WHERE fk_actioncomm = ".((int) $this->
id);
2334 $sql .=
" AND dateremind <= '".$this->db->idate(
dol_now()).
"'";
2337 $sql .=
" AND typeremind ='".$this->db->escape($type).
"'";
2340 $sql .=
" AND fk_user = ".((int) $fk_user);
2342 if (empty($conf->global->AGENDA_REMINDER_EMAIL)) {
2343 $sql .=
" AND typeremind != 'email'";
2345 if (empty($conf->global->AGENDA_REMINDER_BROWSER)) {
2346 $sql .=
" AND typeremind != 'browser'";
2349 $sql .= $this->
db->order(
"dateremind",
"ASC");
2353 while ($obj = $this->
db->fetch_object(
$resql)) {
2355 $tmpactioncommreminder->id = $obj->id;
2356 $tmpactioncommreminder->typeremind = $obj->typeremind;
2357 $tmpactioncommreminder->dateremind = $obj->dateremind;
2358 $tmpactioncommreminder->offsetvalue = $obj->offsetvalue;
2359 $tmpactioncommreminder->offsetunit = $obj->offsetunit;
2360 $tmpactioncommreminder->status = $obj->status;
2361 $tmpactioncommreminder->fk_user = $obj->fk_user;
2363 $this->reminders[$obj->id] = $tmpactioncommreminder;
2366 $this->error = $this->
db->lasterror();
2370 return count($this->reminders);
2382 global $conf, $langs, $user;
2388 $errorsMsg = array();
2391 $langs->load(
"agenda");
2392 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Agenda"));
2395 if (empty($conf->global->AGENDA_REMINDER_EMAIL)) {
2396 $langs->load(
"agenda");
2397 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Agenda"));
2409 $sql =
"SELECT rowid as id FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
2410 $sql .=
" WHERE typeremind = 'email' AND status = 0";
2411 $sql .=
" AND dateremind <= '".$this->db->idate($now).
"'";
2412 $sql .=
" AND entity IN (".getEntity(
'actioncomm').
")";
2413 $sql .= $this->
db->order(
"dateremind",
"ASC");
2417 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
2420 while ($obj = $this->
db->fetch_object(
$resql)) {
2421 $res = $actionCommReminder->fetch($obj->id);
2424 $errorsMsg[] =
"Failed to load invoice ActionComm Reminder";
2429 $arraymessage = $formmail->getEMailTemplate($this->
db,
'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1);
2432 $res = $this->
fetch($actionCommReminder->fk_actioncomm);
2443 $sendContent =
make_substitutions($langs->trans($arraymessage->content), $substitutionarray);
2446 $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->transnoentities(
'EventReminder'));
2449 $recipient =
new User($this->
db);
2450 $res = $recipient->fetch($actionCommReminder->fk_user);
2452 if (!empty($recipient->email)) {
2453 $to = $recipient->email;
2455 $errormesg =
"Failed to send remind to user id=".$actionCommReminder->fk_user.
". No email defined for user.";
2459 $errormesg =
"Failed to load recipient with user id=".$actionCommReminder->fk_user;
2464 $from = $conf->global->MAIN_MAIL_EMAIL_FROM;
2466 $errormesg =
"Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM";
2472 $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
2475 $cMailFile =
new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(),
'',
"", 0, 1, $errors_to,
'',
'',
'',
'',
'');
2478 if ($cMailFile->sendfile()) {
2481 $errormesg = $cMailFile->error.
' : '.$to;
2487 $actionCommReminder->status = $actionCommReminder::STATUS_DONE;
2489 $res = $actionCommReminder->update($user);
2491 $errorsMsg[] =
"Failed to update status to done of ActionComm Reminder";
2496 $actionCommReminder->status = $actionCommReminder::STATUS_ERROR;
2497 $actionCommReminder->lasterror =
dol_trunc($errormesg, 128,
'right',
'UTF-8', 1);
2499 $res = $actionCommReminder->update($user);
2501 $errorsMsg[] =
"Failed to update status to error of ActionComm Reminder";
2505 $errorsMsg[] = $errormesg;
2509 $errorsMsg[] =
'Failed to fetch record actioncomm with ID = '.$actionCommReminder->fk_actioncomm;
2520 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
2521 $sql .=
" WHERE dateremind < '".$this->db->idate($now - (3600 * 24 * 32)).
"'";
2522 $sql .=
" AND status = ".((int) $actionCommReminder::STATUS_DONE);
2526 $errorsMsg[] =
'Failed to delete old reminders';
2532 $this->output =
'Nb of emails sent : '.$nbMailSend;
2533 $this->
db->commit();
2536 $this->
db->commit();
2537 $this->error =
'Nb of emails sent : '.$nbMailSend.
', '.(!empty($errorsMsg)) ? join(
', ', $errorsMsg) : $error;
2554 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"actioncomm ";
2555 $sql .=
" SET percent = ".(int) $percent;
2556 if ($usermodid > 0) $sql .=
", fk_user_mod = ".$usermodid;
2557 $sql .=
" WHERE id = ".((int) $id);
2559 if ($this->
db->query($sql)) {
2560 $this->
db->commit();
2563 $this->
db->rollback();
2564 $this->error = $this->
db->lasterror();
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.
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.
getTypePicto()
Return Picto of type of event.
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...
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...
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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_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_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=1)
Move a file into another name.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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)
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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...
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.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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)
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
$conf db
API class for accounts.
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge,...
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.