diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index 83c8f583450..3414f00b5d1 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -168,6 +168,7 @@ if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementL
if ($conf->projet->enabled) $elementList['project'] = $langs->trans('MailToProject');
if ($conf->ticket->enabled && $user->rights->ticket->read) $elementList['ticket_send'] = $langs->trans('MailToTicket');
if ($conf->recruitment->enabled && $user->rights->recruitment->recruitmentjobposition->read) $elementList['recruitmentcandidature_send'] = $langs->trans('RecruitmentCandidatures');
+if ($conf->agenda->enabled) $elementList['actioncomm_send'] = $langs->trans('MailToSendEventPush');
$elementList['user'] = $langs->trans('MailToUser');
$parameters = array('elementList'=>$elementList);
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 03cb85a6f59..98641ae6192 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncommreminder.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
@@ -64,6 +65,14 @@ $apmin = GETPOST('apmin');
$p2hour = GETPOST('p2hour');
$p2min = GETPOST('p2min');
+$addreminder = GETPOST('addreminder');
+$offsetvalue = GETPOST('offsetvalue');
+$offsetunit = GETPOST('offsetunittype_duration');
+$remindertype = GETPOST('selectremindertype');
+$modelmail = GETPOST('actioncommsendmodel_mail');
+
+//var_dump($_POST); exit;
+
$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear"));
$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month"), GETPOST("p2day"), GETPOST("p2year"));
@@ -378,6 +387,45 @@ if (empty($reshook) && $action == 'add')
$moreparam = '';
if ($user->id != $object->userownerid) $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view.
+ //Create eminder
+ if ($addreminder == 'on'){
+ $actionCommReminder = new ActionCommReminder($db);
+
+ if ($offsetunit == 'minute'){
+ $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i');
+ } elseif ($offsetunit == 'hour'){
+ $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'h');
+ } elseif ($offsetunit == 'day') {
+ $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'd');
+ } elseif ($offsetunit == 'week') {
+ $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'w');
+ } elseif ($offsetunit == 'month') {
+ $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'm');
+ } elseif ($offsetunit == 'year') {
+ $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'y');
+ }
+
+ $actionCommReminder->dateremind = $db->idate($dateremind);
+ $actionCommReminder->typeremind = $remindertype;
+ $actionCommReminder->fk_user = $user;
+ $actionCommReminder->offsetunit = $offsetunit;
+ $actionCommReminder->offsetvalue = $offsetvalue;
+ $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
+ $actionCommReminder->fk_actioncomm = $object->id;
+ if ($remindertype == 'email') $actionCommReminder->fk_email_template = $modelmail;
+
+ $res = $actionCommReminder->create($user);
+
+ if ($res <= 0){
+ // If error
+ $db->rollback();
+ $langs->load("errors");
+ $error = $langs->trans('ErrorReminderActionCommCreation');
+ setEventMessages($error, null, 'errors');
+ $action = 'create'; $donotclearsession = 1;
+ }
+ }
+
$db->commit();
if (!empty($backtopage))
{
@@ -1106,7 +1154,70 @@ if ($action == 'create')
print '';
- dol_fiche_end();
+
+ if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER)
+ {
+ //checkbox create reminder
+ print '
';
+ print '
| '.$langs->trans("AddReminder").' | |
';
+
+ print '';
+
+ print '
';
+ print load_fiche_titre($langs->trans("AddReminder"), '', '');
+
+ print '
';
+ print '
';
+
+ print "\n".''."\n";
+ }
+
+ dol_fiche_end();
print '';
print '';
diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php
index d3f4fb3f238..2d327cfc409 100644
--- a/htdocs/comm/action/class/actioncommreminder.class.php
+++ b/htdocs/comm/action/class/actioncommreminder.class.php
@@ -74,12 +74,15 @@ class ActionCommReminder extends CommonObject
*/
public $fields = array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
- 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,),
+ 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,),
+ 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,),
'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",),
'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,),
'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,),
'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"m, h, d, w",),
- 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')),
+ 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>58, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')),
+ 'fk_actioncomm' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>59, 'notnull'=>1, 'index'=>1,),
+ 'fk_email_template' => array('type'=>'integer', 'label'=>'EmailTemplate', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>0),
);
/**
@@ -87,6 +90,11 @@ class ActionCommReminder extends CommonObject
*/
public $rowid;
+ /**
+ * @var int Entity
+ */
+ public $entity;
+
public $dateremind;
public $typeremind;
@@ -103,6 +111,19 @@ class ActionCommReminder extends CommonObject
*/
public $status;
+ /**
+ * @var int Project
+ */
+ public $fk_actioncomm;
+
+ /**
+ * @var int Template Mail
+ */
+ public $fk_email_template;
+
+ const STATUS_TODO = 0;
+ const STATUS_DONE = 1;
+
// END MODULEBUILDER PROPERTIES
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 22da5ba9e8e..a09bcc455ea 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -5669,6 +5669,38 @@ class Form
return $retstring;
}
+ /**
+ * select_type_duration
+ *
+ * @param string $prefix Prefix
+ * @param string $modelType Model type
+ * @return string HTML select string
+ */
+ public function select_type_duration($prefix, $selected = 'minute')
+ {
+ global $langs;
+
+ $retstring = '';
+
+ $TDurationTypes = array('year'=>$langs->trans('Years'), 'month'=>$langs->trans('Month'), 'week'=>$langs->trans('Weeks'), 'day'=>$langs->trans('Days'), 'hour'=>$langs->trans('Hours'), 'minute'=>$langs->trans('Minutes'));
+
+ $retstring .= '";
+
+ return $retstring;
+ }
+
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Function to show a form to select a duration on a page
@@ -7941,4 +7973,41 @@ class Form
return $ret;
}
+
+ /**
+ * select_model_mail
+ *
+ * @param string $prefix Prefix
+ * @param string $modelType Model type
+ * @return string HTML select string
+ */
+ public function select_model_mail($prefix, $modelType = '') {
+
+ global $langs, $db, $user;
+
+ $retstring = '';
+
+ $TModels = array();
+
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
+ $formmail = new FormMail($db);
+ $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
+
+ if ($result > 0) {
+ foreach ($formmail->lines_model as $model){
+ $TModels[$model->id] = $model->label;
+ }
+ }
+
+ $retstring .= '";
+
+ return $retstring;
+ }
}
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index 22f99312520..1c7ff2cf20e 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -108,7 +108,7 @@ function getServerTimeZoneInt($refgmtdate = 'now')
*
* @param int $time Date timestamp (or string with format YYYY-MM-DD)
* @param int $duration_value Value of delay to add
- * @param int $duration_unit Unit of added delay (d, m, y, w, h)
+ * @param int $duration_unit Unit of added delay (d, m, y, w, h, i)
* @return int New timestamp
*/
function dol_time_plus_duree($time, $duration_value, $duration_unit)
@@ -116,6 +116,7 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit)
global $conf;
if ($duration_value == 0) return $time;
+ if ($duration_unit == 'i') return $time + (60 * $duration_value);
if ($duration_unit == 'h') return $time + (3600 * $duration_value);
if ($duration_unit == 'w') return $time + (3600 * 24 * 7 * $duration_value);
diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
index ca01a0d1b5e..b73826a21ad 100644
--- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
+++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
@@ -297,3 +297,8 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_MODIFY','Candidature modified','Executed when a candidature is modified','recruitment',7512);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_SENTBYMAIL','Mails sent from candidature record','Executed when you send email from candidature record','recruitment',7514);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_DELETE','Candidature deleted','Executed when a candidature is deleted','recruitment',7516);
+
+ALTER TABLE llx_actioncomm_reminder ADD COLUMN entity integer NOT NULL DEFAULT 1;
+ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_actioncomm integer NOT NULL;
+ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_email_template integer;
+ALTER TABLE llx_actioncomm_reminder DROP INDEX uk_actioncomm_reminder_unique, ADD UNIQUE uk_actioncomm_reminder_unique (fk_user, typeremind, offsetvalue, offsetunit, fk_actioncomm);
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_actioncomm_reminder.key.sql b/htdocs/install/mysql/tables/llx_actioncomm_reminder.key.sql
index 94e50d05634..634e474782a 100644
--- a/htdocs/install/mysql/tables/llx_actioncomm_reminder.key.sql
+++ b/htdocs/install/mysql/tables/llx_actioncomm_reminder.key.sql
@@ -20,6 +20,6 @@ ALTER TABLE llx_actioncomm_reminder ADD INDEX idx_actioncomm_reminder_dateremind
ALTER TABLE llx_actioncomm_reminder ADD INDEX idx_actioncomm_reminder_fk_user (fk_user);
-- END MODULEBUILDER INDEXES
-ALTER TABLE llx_actioncomm_reminder ADD UNIQUE INDEX uk_actioncomm_reminder_unique(fk_user, typeremind, offsetvalue, offsetunit);
+ALTER TABLE llx_actioncomm_reminder ADD UNIQUE INDEX uk_actioncomm_reminder_unique(fk_actioncomm, fk_user, typeremind, offsetvalue, offsetunit);
diff --git a/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql b/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql
index 2edb11c45c5..78dd00d6ea5 100644
--- a/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql
+++ b/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql
@@ -22,6 +22,10 @@ CREATE TABLE llx_actioncomm_reminder(
fk_user integer NOT NULL,
offsetvalue integer NOT NULL,
offsetunit varchar(1) NOT NULL,
- status integer NOT NULL DEFAULT 0
+ status integer NOT NULL DEFAULT 0,
+ entity integer NOT NULL DEFAULT 1,
+ fk_actioncomm integer NOT NULL,
+ fk_email_template integer
+
-- END MODULEBUILDER FIELDS
) ENGINE=innodb;
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 54569be2383..36ee351e33d 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -2029,3 +2029,4 @@ MeasuringScaleDesc=The scale is the number of places you have to move the decima
TemplateAdded=Template added
TemplateUpdated=Template updated
TemplateDeleted=Template deleted
+MailToSendEventPush=Template for event reminder emails
diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang
index d048a758996..bbfb143cee8 100644
--- a/htdocs/langs/en_US/agenda.lang
+++ b/htdocs/langs/en_US/agenda.lang
@@ -160,3 +160,9 @@ DateStartPlusOne=Date start + 1 hour
SetAllEventsToTodo=Set all events to todo
SetAllEventsToInProgress=Set all events to in progress
SetAllEventsToFinished=Set all events to finished
+ReminderTime=Reminder period before the event
+TimeType=Duration type
+ReminderType=Callback type
+AddReminder=Create an automatic reminder notification for this event
+ErrorReminderActionCommCreation=Error creating the reminder notification for this event
+BrowserPush=Browser Notification
\ No newline at end of file
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index 0af5c66f0e0..28ac6698981 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -1082,4 +1082,4 @@ CREATEInDolibarr=Record %s create
MODIFYInDolibarr=Record %s modified
DELETEInDolibarr=Record %s deleted
VALIDATEInDolibarr=Record %s validated
-APPROVEDInDolibarr=Record %s approved
+APPROVEDInDolibarr=Record %s approved
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang
index 6da45f7976d..80d1c953e0b 100644
--- a/htdocs/langs/fr_FR/agenda.lang
+++ b/htdocs/langs/fr_FR/agenda.lang
@@ -158,3 +158,9 @@ DateStartPlusOne=Date de début + 1 heure
SetAllEventsToTodo=Réglez tous les événements à "A faire"
SetAllEventsToInProgress=Définir tous les événements à "En cours"
SetAllEventsToFinished=Définir tous les événements sur "Terminés"
+ReminderTime=Délai de rappel avant l'événement
+TimeType=Type de durée
+ReminderType=Type de rappel
+AddReminder=Créer une notification de rappel automatique pour cet évènement
+ErrorReminderActionCommCreation=Erreur lors de la création de la notification de rappel de cet événement
+BrowserPush=Notification navigateur
diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index 1d5dd9bc6cb..54b700cae39 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -1042,5 +1042,4 @@ NotUsedForThisCustomer=Non utilisé pour ce client
AmountMustBePositive=Le montant doit être positif.
ByStatus=Par statut
InformationMessage=Information
-ASAP=Dès que possible
-
+ASAP=Dès que possible
\ No newline at end of file