From 25840c2b3dca1a846f7c72c0b64d9064046defb0 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 25 Aug 2020 12:40:29 +0200 Subject: [PATCH 01/27] Create Event - Add fields --- htdocs/comm/action/card.php | 27 ++++++++++++++++++++++++++- htdocs/core/class/html.form.class.php | 21 +++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index eb723013f81..7090438c7ce 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -64,6 +64,10 @@ $apmin = GETPOST('apmin'); $p2hour = GETPOST('p2hour'); $p2min = GETPOST('p2min'); +$offsetvalue = GETPOST('offsetvalue'); +$offsetunit = GETPOST('offsetunittype_duration'); +$typeremind = GETPOST('typeremind'); + $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")); @@ -1106,7 +1110,28 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print '


'; + + print ''; + + //Reminder + print ''; + + //Reminder Type + print ''; + + //Notification + print ''; + + print '
'.$langs->trans("Reminder").''; + print ''; + print '
'.$langs->trans("ReminderType").''; + print $form->select_type_duration('offsetunit'); + print '
'.$langs->trans("TypeRemind").''; + print $form->selectarray('typeremind', array('mail'=>$langs->trans('EMail'), 'push'=>$langs->trans('OSNotif'))); + print '
'; + + dol_fiche_end(); print '
'; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5567813db79..d102b0133f4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5673,6 +5673,27 @@ class Form return $retstring; } + public function select_type_duration($prefix){ + + global $langs; + + $retstring = ''; + + $TDurationTypes = array('year'=>$langs->trans('Years'), 'month'=>$langs->trans('Month'), 'week'=>$langs->trans('Weeks'), 'day'=>$langs->trans('Days'), 'minute'=>$langs->trans('Minutes')); + + $retstring .= '"; + + print $retstring; + return; + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to show a form to select a duration on a page From 94b2f3c5e1f921acb1eb30e418b6edf461907cdd Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 25 Aug 2020 12:57:36 +0200 Subject: [PATCH 02/27] Add $conf conditions --- htdocs/comm/action/card.php | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 7090438c7ce..d3548a2505f 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1110,26 +1110,33 @@ if ($action == 'create') print ''; - print '


'; - print ''; + if($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) + { + print '


'; - //Reminder - print ''; + print '
'.$langs->trans("Reminder").''; - print ''; - print '
'; - //Reminder Type - print ''; + //Reminder + print ''; - //Notification - print ''; + //Reminder Type + print ''; - print '
'.$langs->trans("ReminderType").''; - print $form->select_type_duration('offsetunit'); - print '
'.$langs->trans("Reminder").''; + print ''; + print '
'.$langs->trans("TypeRemind").''; - print $form->selectarray('typeremind', array('mail'=>$langs->trans('EMail'), 'push'=>$langs->trans('OSNotif'))); - print '
'.$langs->trans("ReminderType").''; + print $form->select_type_duration('offsetunit'); + print '
'; + //Notification + $TRemindTypes = array(); + if(!empty($conf->global->AGENDA_REMINDER_EMAIL)) $TRemindTypes['mail'] = $langs->trans('EMail'); + if(!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes['push'] = $langs->trans('OSNotif'); + print ''.$langs->trans("TypeRemind").''; + print $form->selectarray('typeremind',$TRemindTypes); + print ''; + + print ''; + } dol_fiche_end(); From 6a94c0f52fd45250aba8a47e18b9e93e031e1741 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 25 Aug 2020 16:43:57 +0200 Subject: [PATCH 03/27] Add model type mail --- htdocs/admin/mails_templates.php | 1 + htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + 3 files changed, 3 insertions(+) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index bdd9f571123..ad9627a817d 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['event_push'] = $langs->trans('MailToSendEventPush'); $elementList['user'] = $langs->trans('MailToUser'); $parameters = array('elementList'=>$elementList); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index fbbdf81ff93..317dba89233 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2019,3 +2019,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=Notification événement diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 236b4c61bd9..fce8aa988e0 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -2011,3 +2011,4 @@ RssNote=Remarque: Chaque définition de flux RSS fournit un widget que vous deve JumpToBoxes=Aller à la Configuration -> Widgets MeasuringUnitTypeDesc=Utilisez ici une valeur comme "taille", "surface", "volume", "poids", "temps" MeasuringScaleDesc=L'échelle est le nombre de positions où vous devez déplacer la partie décimale pour qu'elle corresponde à l'unité de référence par défaut. Pour le type d'unité "temps", c'est le nombre de secondes. Les valeurs comprises entre 80 et 99 sont des valeurs réservées. +MailToSendEventPush=Notification événement From 7df993c7edeac411d0dcd9e7c2d895141611f48f Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 25 Aug 2020 17:26:32 +0200 Subject: [PATCH 04/27] Add "select_model_mail" function + add select to create event --- htdocs/comm/action/card.php | 19 ++++++++++----- htdocs/core/class/html.form.class.php | 33 +++++++++++++++++++++++++++ htdocs/langs/fr_FR/agenda.lang | 3 +++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index d3548a2505f..cda05d21784 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1118,23 +1118,30 @@ if ($action == 'create') print ''; //Reminder - print ''; - //Reminder Type - print ''; - //Notification + //Reminder Type $TRemindTypes = array(); if(!empty($conf->global->AGENDA_REMINDER_EMAIL)) $TRemindTypes['mail'] = $langs->trans('EMail'); if(!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes['push'] = $langs->trans('OSNotif'); - print ''; + //Mail Model + //TODO : ajouter les conditions pour l'affichage de ce champs : si au moins un model existe et si Email est le type de rappel sélectionné + print ''; + + print '
'.$langs->trans("Reminder").''; + print '
'.$langs->trans("ReminderTime").''; print ''; print '
'.$langs->trans("ReminderType").''; + //Time Type + print '
'.$langs->trans("TimeType").''; print $form->select_type_duration('offsetunit'); print '
'.$langs->trans("TypeRemind").''; - print $form->selectarray('typeremind',$TRemindTypes); + print '
'.$langs->trans("ReminderType").''; + print $form->selectarray('remindertype',$TRemindTypes); print '
'.$langs->trans("Model").''; + print $form->select_model_mail('eventpush', 'event_push'); + print '
'; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d102b0133f4..8d54dc78b13 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7965,4 +7965,37 @@ class Form return $ret; } + + 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 .= '"; + + print $retstring; + return; + } } diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang index 6da45f7976d..e0d3e1fcbdf 100644 --- a/htdocs/langs/fr_FR/agenda.lang +++ b/htdocs/langs/fr_FR/agenda.lang @@ -158,3 +158,6 @@ 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=Durée du rappel +TimeType=Type de durée +ReminderType=Type de rappel From a4018f41f7f36f47a9f7b189ecf4eda98a0b9c26 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Aug 2020 10:52:36 +0200 Subject: [PATCH 05/27] WIP --- htdocs/comm/action/card.php | 6 ++++-- htdocs/core/class/html.form.class.php | 7 ++++++- htdocs/langs/en_US/agenda.lang | 4 ++++ htdocs/langs/fr_FR/agenda.lang | 3 ++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index cda05d21784..b31d6a4d226 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -66,7 +66,8 @@ $p2min = GETPOST('p2min'); $offsetvalue = GETPOST('offsetvalue'); $offsetunit = GETPOST('offsetunittype_duration'); -$typeremind = GETPOST('typeremind'); +$remindertype = GETPOST('remindertype'); +$modelmail = GETPOST('eventpushmodel_mail'); $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")); @@ -1113,7 +1114,8 @@ if ($action == 'create') if($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) { - print '


'; + print '


'; + print load_fiche_titre($langs->trans("AddReminder"), '', ''); print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8d54dc78b13..e3757e3c0ed 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5673,7 +5673,7 @@ class Form return $retstring; } - public function select_type_duration($prefix){ + public function select_type_duration($prefix, $selected = 'month'){ global $langs; @@ -5684,7 +5684,12 @@ class Form $retstring .= ''; + + print "\n".''."\n"; + + print '
'.$langs->trans("AddReminder").'
'; @@ -1145,6 +1165,7 @@ if ($action == 'create') print '
'; + print '
'; } dol_fiche_end(); From 42f492877e0b25409496a81dce25f987ae9ac13c Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Aug 2020 11:36:32 +0200 Subject: [PATCH 07/27] WIP --- htdocs/comm/action/card.php | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index b705e1193ee..c81180b4764 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1120,18 +1120,6 @@ if ($action == 'create') print '
'; print ''.$langs->trans("AddReminder").''; - print "\n".''."\n"; - print ''; + + print "\n".''."\n"; } dol_fiche_end(); From d3ac39589a44f07f855d1920551aced05924c36a Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Aug 2020 12:48:12 +0200 Subject: [PATCH 08/27] WIP --- htdocs/comm/action/card.php | 40 +++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c81180b4764..78e0a109bf8 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'; @@ -67,9 +68,11 @@ $p2min = GETPOST('p2min'); $addreminder = GETPOST('addreminder'); $offsetvalue = GETPOST('offsetvalue'); $offsetunit = GETPOST('offsetunittype_duration'); -$remindertype = GETPOST('remindertype'); +$remindertype = GETPOST('selectremindertype'); $modelmail = GETPOST('eventpushmodel_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")); @@ -384,6 +387,31 @@ 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. + //Reminder + if($addreminder == 'on'){ + $actionCommReminder = new ActionCommReminder($db); + +// if($offsetunit == 'minute'){ +// $timeBeforeEvent = convertTime2Seconds('', $offsetvalue); +// } elseif($offsetunit == 'hour'){ +// $timeBeforeEvent = convertTime2Seconds($offsetvalue); +// } elseif ($offsetunit == 'day') { +// $timeBeforeEvent = 3600 * 24 * $offsetvalue; +// } elseif ($offsetunit == 'week') { +// $timeBeforeEvent = 3600 * 24 * 7 * $offsetvalue; +// } elseif ($offsetunit == 'month') { +// $timeBeforeEvent = 3600 * 24 * 7 * $offsetvalue; +// } +// var_dump($datep); exit; +// +// $actionCommReminder->typeremind = $remindertype; +// $actionCommReminder->fk_user = $user; +// $actionCommReminder->offsetunit = $offsetunit; +// $actionCommReminder->offsetvalue = $offsetvalue; +// $actionCommReminder->offsetvalue = 'todo'; + + } + $db->commit(); if (!empty($backtopage)) { @@ -1139,10 +1167,10 @@ if ($action == 'create') //Reminder Type $TRemindTypes = array(); - if(!empty($conf->global->AGENDA_REMINDER_EMAIL)) $TRemindTypes['mail'] = $langs->trans('EMail'); + if(!empty($conf->global->AGENDA_REMINDER_EMAIL)) $TRemindTypes['email'] = $langs->trans('EMail'); if(!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes['push'] = $langs->trans('OSNotif'); print ''.$langs->trans("ReminderType").''; - print $form->selectarray('remindertype',$TRemindTypes); + print $form->selectarray('selectremindertype',$TRemindTypes); print ''; //Mail Model @@ -1165,9 +1193,9 @@ if ($action == 'create') } }); - $("#remindertype").click(function(){ - var selected_option = $("#remindertype option:selected").val(); - if(selected_option == "mail") { + $("#selectremindertype").click(function(){ + var selected_option = $("#selectremindertype option:selected").val(); + if(selected_option == "email") { $("#select_eventpushmodel_mail").closest("tr").show(); } else { $("#select_eventpushmodel_mail").closest("tr").hide(); From 2fb582483617125c38b326c90f0af0da03c38e3c Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Aug 2020 15:12:08 +0200 Subject: [PATCH 09/27] Calcul date of reminder for event create --- htdocs/comm/action/card.php | 45 +++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 78e0a109bf8..e1a5b1876b9 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -389,26 +389,34 @@ if (empty($reshook) && $action == 'add') //Reminder if($addreminder == 'on'){ + $actionCommReminder = new ActionCommReminder($db); -// if($offsetunit == 'minute'){ -// $timeBeforeEvent = convertTime2Seconds('', $offsetvalue); -// } elseif($offsetunit == 'hour'){ -// $timeBeforeEvent = convertTime2Seconds($offsetvalue); -// } elseif ($offsetunit == 'day') { -// $timeBeforeEvent = 3600 * 24 * $offsetvalue; -// } elseif ($offsetunit == 'week') { -// $timeBeforeEvent = 3600 * 24 * 7 * $offsetvalue; -// } elseif ($offsetunit == 'month') { -// $timeBeforeEvent = 3600 * 24 * 7 * $offsetvalue; -// } -// var_dump($datep); exit; -// -// $actionCommReminder->typeremind = $remindertype; -// $actionCommReminder->fk_user = $user; -// $actionCommReminder->offsetunit = $offsetunit; -// $actionCommReminder->offsetvalue = $offsetvalue; -// $actionCommReminder->offsetvalue = 'todo'; + if($offsetunit == 'minute'){ + $dateremind = strtotime("-".$offsetvalue." minutes", $datep); + } elseif($offsetunit == 'hour'){ + $dateremind = strtotime("-".$offsetvalue." hours", $datep); + } elseif ($offsetunit == 'day') { + $dateremind = strtotime("-".$offsetvalue." day", $datep); + } elseif ($offsetunit == 'week') { + $dateremind = strtotime("-".$offsetvalue." week", $datep); + } elseif ($offsetunit == 'month') { + $dateremind = strtotime("-".$offsetvalue." month", $datep); + } elseif ($offsetunit == 'year') { + $dateremind = strtotime("-".$offsetvalue." year", $datep); + } + + $actionCommReminder->dateremind = date('Y-m-d H:i:s', $dateremind); + $actionCommReminder->typeremind = $remindertype; + $actionCommReminder->fk_user = $user; + $actionCommReminder->offsetunit = $offsetunit; + $actionCommReminder->offsetvalue = $offsetvalue; + $actionCommReminder->offsetvalue = 'todo'; + //TODO : $fk_project + + $res = $actionCommReminder->create($user); + + var_dump($res); exit; } @@ -1174,7 +1182,6 @@ if ($action == 'create') print ''; //Mail Model - //TODO : ajouter les conditions pour l'affichage de ce champs : si au moins un model existe et si Email est le type de rappel sélectionné print ''.$langs->trans("Model").''; print $form->select_model_mail('eventpush', 'event_push'); print ''; From d4e6a9871c29474710674b3c22586eec22eb11bc Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Aug 2020 15:14:07 +0200 Subject: [PATCH 10/27] Update select_type_duration() function --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e3757e3c0ed..4ea835acd36 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5679,7 +5679,7 @@ class Form $retstring = ''; - $TDurationTypes = array('year'=>$langs->trans('Years'), 'month'=>$langs->trans('Month'), 'week'=>$langs->trans('Weeks'), 'day'=>$langs->trans('Days'), 'minute'=>$langs->trans('Minutes')); + $TDurationTypes = array('year'=>$langs->trans('Years'), 'month'=>$langs->trans('Month'), 'week'=>$langs->trans('Weeks'), 'day'=>$langs->trans('Days'),'week'=>$langs->trans('Weeks'), 'day'=>$langs->trans('Days'), 'hour'=>$langs->trans('Hours'), 'minute'=>$langs->trans('Minutes')); $retstring .= ''; From cf9337b6449a8ccc8a737b35357314b1a605adc1 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Aug 2020 15:58:14 +0200 Subject: [PATCH 13/27] Add fk_project to actioncommreminder object --- htdocs/comm/action/card.php | 1 + htdocs/comm/action/class/actioncommreminder.class.php | 8 +++++++- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 5eefb341c3c..cd550a1b8dd 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -412,6 +412,7 @@ if (empty($reshook) && $action == 'add') $actionCommReminder->offsetunit = $offsetunit; $actionCommReminder->offsetvalue = $offsetvalue; $actionCommReminder->status = $actionCommReminder::STATUS_TODO; + $actionCommReminder->fk_project = $object->id; //TODO : $fk_project $res = $actionCommReminder->create($user); diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index db66112a261..58da9134a29 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -80,7 +80,8 @@ class ActionCommReminder extends CommonObject '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_project' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>59, 'notnull'=>1), ); /** @@ -109,6 +110,11 @@ class ActionCommReminder extends CommonObject */ public $status; + /** + * @var int Project + */ + public $fk_project; + const STATUS_TODO = 0; const STATUS_DONE = 1; 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 954f93a72cd..08b6389aac6 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 @@ -281,4 +281,5 @@ 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_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; \ No newline at end of file +ALTER TABLE llx_actioncomm_reminder ADD COLUMN entity integer NOT NULL DEFAULT 1; +ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_project integer NOT NULL; \ No newline at end of file From a01d1b58c7c04267daf24f707ffa05e8ce338efc Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Aug 2020 16:06:20 +0200 Subject: [PATCH 14/27] Add fk_email_template --- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/class/actioncommreminder.class.php | 6 ++++++ htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index cd550a1b8dd..18e836823e0 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1180,7 +1180,7 @@ if ($action == 'create') print ''; //Mail Model - print ''.$langs->trans("Model").''; + print ''.$langs->trans("EMailTemplates").''; print $form->select_model_mail('eventpush', 'event_push'); print ''; diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 58da9134a29..383acddb70c 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -82,6 +82,7 @@ class ActionCommReminder extends CommonObject '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'=>58, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')), 'fk_project' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>59, 'notnull'=>1), + 'fk_email_template' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>59, 'notnull'=>0), ); /** @@ -115,6 +116,11 @@ class ActionCommReminder extends CommonObject */ public $fk_project; + /** + * @var int Template Mail + */ + public $fk_email_template; + const STATUS_TODO = 0; const STATUS_DONE = 1; 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 08b6389aac6..676655815dc 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 @@ -282,4 +282,5 @@ 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_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_project integer NOT NULL; \ No newline at end of file +ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_project integer NOT NULL; +ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_email_template integer; \ No newline at end of file From cc29654f476a886b5bc6046ae27805cacc6d187e Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Aug 2020 16:48:09 +0200 Subject: [PATCH 15/27] WIP : rename fk_project to fk_actioncomm + add line to sql file to install --- htdocs/comm/action/card.php | 12 ++++++------ .../comm/action/class/actioncommreminder.class.php | 6 +++--- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 5 +++-- .../mysql/tables/llx_actioncomm_reminder.key.sql | 2 +- .../install/mysql/tables/llx_actioncomm_reminder.sql | 6 +++++- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 18e836823e0..5465e00887a 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -69,7 +69,7 @@ $addreminder = GETPOST('addreminder'); $offsetvalue = GETPOST('offsetvalue'); $offsetunit = GETPOST('offsetunittype_duration'); $remindertype = GETPOST('selectremindertype'); -$modelmail = GETPOST('eventpushmodel_mail'); +$modelmail = GETPOST('agendasendmodel_mail'); //var_dump($_POST); exit; @@ -412,8 +412,8 @@ if (empty($reshook) && $action == 'add') $actionCommReminder->offsetunit = $offsetunit; $actionCommReminder->offsetvalue = $offsetvalue; $actionCommReminder->status = $actionCommReminder::STATUS_TODO; - $actionCommReminder->fk_project = $object->id; - //TODO : $fk_project + $actionCommReminder->fk_actioncomm = $object->id; + if($remindertype == 'email') $actionCommReminder->fk_email_template = $modelmail; $res = $actionCommReminder->create($user); } @@ -1181,7 +1181,7 @@ if ($action == 'create') //Mail Model print ''.$langs->trans("EMailTemplates").''; - print $form->select_model_mail('eventpush', 'event_push'); + print $form->select_model_mail('agendasend', 'agenda_send'); print ''; @@ -1201,9 +1201,9 @@ if ($action == 'create') $("#selectremindertype").click(function(){ var selected_option = $("#selectremindertype option:selected").val(); if(selected_option == "email") { - $("#select_eventpushmodel_mail").closest("tr").show(); + $("#select_agendasendmodel_mail").closest("tr").show(); } else { - $("#select_eventpushmodel_mail").closest("tr").hide(); + $("#select_agendasendmodel_mail").closest("tr").hide(); }; }); })'; diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 383acddb70c..9e7f8f62fc1 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -81,8 +81,8 @@ class ActionCommReminder extends CommonObject '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'=>58, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')), - 'fk_project' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>59, 'notnull'=>1), - 'fk_email_template' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>59, 'notnull'=>0), + 'fk_actioncomm' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>59, 'notnull'=>1), + 'fk_email_template' => array('type'=>'integer', 'label'=>'EmailTemplate', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>0), ); /** @@ -114,7 +114,7 @@ class ActionCommReminder extends CommonObject /** * @var int Project */ - public $fk_project; + public $fk_actioncomm; /** * @var int Template Mail 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 676655815dc..3a6d9a98d0b 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 @@ -282,5 +282,6 @@ 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_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_project integer NOT NULL; -ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_email_template integer; \ No newline at end of file +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; From efe60ebc58654910bd0d4492c0df1dc24cb1e684 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Aug 2020 17:02:34 +0200 Subject: [PATCH 16/27] Error management --- htdocs/comm/action/card.php | 11 ++++++++++- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/fr_FR/main.lang | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 5465e00887a..d783af604b7 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -387,7 +387,7 @@ 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. - //Reminder + //Create eminder if($addreminder == 'on'){ $actionCommReminder = new ActionCommReminder($db); @@ -416,6 +416,15 @@ if (empty($reshook) && $action == 'add') 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(); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 186272da1b6..0203f2e7af2 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1082,3 +1082,4 @@ MODIFYInDolibarr=Record %s modified DELETEInDolibarr=Record %s deleted VALIDATEInDolibarr=Record %s validated APPROVEDInDolibarr=Record %s approved +ErrorReminderActionCommCreation=Error creating the reminder notification for this event \ No newline at end of file diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 1d5dd9bc6cb..aaadd7e31fe 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -1043,4 +1043,4 @@ AmountMustBePositive=Le montant doit être positif. ByStatus=Par statut InformationMessage=Information ASAP=Dès que possible - +ErrorReminderActionCommCreation=Erreur lors de la création de la notification de rappel de cet événement From 6a60228bc3f55b18d7ca50f4a2363454c2f243f0 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Aug 2020 17:11:32 +0200 Subject: [PATCH 17/27] Translation --- htdocs/comm/action/card.php | 2 +- htdocs/langs/en_US/agenda.lang | 2 ++ htdocs/langs/en_US/main.lang | 3 +-- htdocs/langs/fr_FR/agenda.lang | 2 ++ htdocs/langs/fr_FR/main.lang | 3 +-- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index d783af604b7..bf7b7ccfaf4 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1183,7 +1183,7 @@ if ($action == 'create') //Reminder Type $TRemindTypes = array(); if(!empty($conf->global->AGENDA_REMINDER_EMAIL)) $TRemindTypes['email'] = $langs->trans('EMail'); - if(!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes['push'] = $langs->trans('OSNotif'); + if(!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes['push'] = $langs->trans('BrowserPush'); print ''.$langs->trans("ReminderType").''; print $form->selectarray('selectremindertype',$TRemindTypes); print ''; diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 6d59e464660..bbfb143cee8 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -164,3 +164,5 @@ 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 0203f2e7af2..7ebcc9dd609 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1081,5 +1081,4 @@ CREATEInDolibarr=Record %s create MODIFYInDolibarr=Record %s modified DELETEInDolibarr=Record %s deleted VALIDATEInDolibarr=Record %s validated -APPROVEDInDolibarr=Record %s approved -ErrorReminderActionCommCreation=Error creating the reminder notification for this event \ No newline at end of file +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 8a097ed73d2..80d1c953e0b 100644 --- a/htdocs/langs/fr_FR/agenda.lang +++ b/htdocs/langs/fr_FR/agenda.lang @@ -162,3 +162,5 @@ 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 aaadd7e31fe..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 -ErrorReminderActionCommCreation=Erreur lors de la création de la notification de rappel de cet événement +ASAP=Dès que possible \ No newline at end of file From bbc554070cdc57ec1be27d6d073c3552338fc64f Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 27 Aug 2020 09:33:40 +0200 Subject: [PATCH 18/27] Fix --- htdocs/comm/action/class/actioncommreminder.class.php | 2 +- htdocs/langs/en_US/admin.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 9e7f8f62fc1..2d327cfc409 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -81,7 +81,7 @@ class ActionCommReminder extends CommonObject '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'=>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), + '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), ); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 317dba89233..6b8d3a0a9b0 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2019,4 +2019,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=Notification événement +MailToSendEventPush=Event notification From 9d1fc28eba249121916ca5bbd6be854c095b50a6 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 27 Aug 2020 09:35:02 +0200 Subject: [PATCH 19/27] Fix type reminder "push" to "browser" --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index bf7b7ccfaf4..d05b0914254 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1183,7 +1183,7 @@ if ($action == 'create') //Reminder Type $TRemindTypes = array(); if(!empty($conf->global->AGENDA_REMINDER_EMAIL)) $TRemindTypes['email'] = $langs->trans('EMail'); - if(!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes['push'] = $langs->trans('BrowserPush'); + if(!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes['browser'] = $langs->trans('BrowserPush'); print ''.$langs->trans("ReminderType").''; print $form->selectarray('selectremindertype',$TRemindTypes); print ''; From 4ef26443006e095cdb822a8743589940475b01a9 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 27 Aug 2020 10:29:23 +0200 Subject: [PATCH 20/27] Use date.lib.php functions --- htdocs/comm/action/card.php | 14 +++++++------- htdocs/core/lib/date.lib.php | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index d05b0914254..9ab1cf3366a 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -393,20 +393,20 @@ if (empty($reshook) && $action == 'add') $actionCommReminder = new ActionCommReminder($db); if($offsetunit == 'minute'){ - $dateremind = strtotime("-".$offsetvalue." minutes", $datep); + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i'); } elseif($offsetunit == 'hour'){ - $dateremind = strtotime("-".$offsetvalue." hours", $datep); + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'h'); } elseif ($offsetunit == 'day') { - $dateremind = strtotime("-".$offsetvalue." day", $datep); + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'd'); } elseif ($offsetunit == 'week') { - $dateremind = strtotime("-".$offsetvalue." week", $datep); + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'w'); } elseif ($offsetunit == 'month') { - $dateremind = strtotime("-".$offsetvalue." month", $datep); + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'm'); } elseif ($offsetunit == 'year') { - $dateremind = strtotime("-".$offsetvalue." year", $datep); + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'y'); } - $actionCommReminder->dateremind = date('Y-m-d H:i:s', $dateremind); + $actionCommReminder->dateremind = $db->idate($dateremind); $actionCommReminder->typeremind = $remindertype; $actionCommReminder->fk_user = $user; $actionCommReminder->offsetunit = $offsetunit; 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); From b0fe7bc2e0913057d08e93e220ad0d591d5ece05 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 27 Aug 2020 08:47:57 +0000 Subject: [PATCH 21/27] Fixing style errors. --- htdocs/comm/action/card.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 9ab1cf3366a..46c42bff6ad 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -388,13 +388,12 @@ if (empty($reshook) && $action == 'add') 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'){ - + if ($addreminder == 'on'){ $actionCommReminder = new ActionCommReminder($db); - if($offsetunit == 'minute'){ + if ($offsetunit == 'minute'){ $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i'); - } elseif($offsetunit == 'hour'){ + } elseif ($offsetunit == 'hour'){ $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'h'); } elseif ($offsetunit == 'day') { $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'd'); @@ -413,11 +412,11 @@ if (empty($reshook) && $action == 'add') $actionCommReminder->offsetvalue = $offsetvalue; $actionCommReminder->status = $actionCommReminder::STATUS_TODO; $actionCommReminder->fk_actioncomm = $object->id; - if($remindertype == 'email') $actionCommReminder->fk_email_template = $modelmail; + if ($remindertype == 'email') $actionCommReminder->fk_email_template = $modelmail; $res = $actionCommReminder->create($user); - if($res <= 0){ + if ($res <= 0){ // If error $db->rollback(); $langs->load("errors"); @@ -1156,9 +1155,8 @@ if ($action == 'create') print ''; - if($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) + if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) { - //checkbox create reminder print '
'; print ''.$langs->trans("AddReminder").''; @@ -1182,10 +1180,10 @@ if ($action == 'create') //Reminder Type $TRemindTypes = array(); - if(!empty($conf->global->AGENDA_REMINDER_EMAIL)) $TRemindTypes['email'] = $langs->trans('EMail'); - if(!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes['browser'] = $langs->trans('BrowserPush'); + if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) $TRemindTypes['email'] = $langs->trans('EMail'); + if (!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes['browser'] = $langs->trans('BrowserPush'); print ''.$langs->trans("ReminderType").''; - print $form->selectarray('selectremindertype',$TRemindTypes); + print $form->selectarray('selectremindertype', $TRemindTypes); print ''; //Mail Model From 5856033892819d90aeba821aa75d04227e454b8d Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 27 Aug 2020 11:15:08 +0200 Subject: [PATCH 22/27] Replace "agenda_send" and "event_push" to "actioncomm_send" --- htdocs/admin/mails_templates.php | 2 +- htdocs/comm/action/card.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 128a55a4889..3414f00b5d1 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -168,7 +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['event_push'] = $langs->trans('MailToSendEventPush'); +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 46c42bff6ad..7ecc12a621d 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -69,7 +69,7 @@ $addreminder = GETPOST('addreminder'); $offsetvalue = GETPOST('offsetvalue'); $offsetunit = GETPOST('offsetunittype_duration'); $remindertype = GETPOST('selectremindertype'); -$modelmail = GETPOST('agendasendmodel_mail'); +$modelmail = GETPOST('actioncommsendmodel_mail'); //var_dump($_POST); exit; @@ -1188,7 +1188,7 @@ if ($action == 'create') //Mail Model print ''.$langs->trans("EMailTemplates").''; - print $form->select_model_mail('agendasend', 'agenda_send'); + print $form->select_model_mail('actioncommsend', 'actioncomm_send'); print ''; @@ -1208,9 +1208,9 @@ if ($action == 'create') $("#selectremindertype").click(function(){ var selected_option = $("#selectremindertype option:selected").val(); if(selected_option == "email") { - $("#select_agendasendmodel_mail").closest("tr").show(); + $("#select_actioncommsendmodel_mail").closest("tr").show(); } else { - $("#select_agendasendmodel_mail").closest("tr").hide(); + $("#select_actioncommsendmodel_mail").closest("tr").hide(); }; }); })'; From 9cd63d68bd77ef39485f9410873912ca445bde22 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Aug 2020 17:58:02 +0200 Subject: [PATCH 23/27] Update admin.lang --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6b8d3a0a9b0..68fe34652c4 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2019,4 +2019,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=Event notification +MailToSendEventPush=Event remind by email From ca47eb2c9f31fc32c957f6ddd42065eae4ba949f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Aug 2020 04:55:24 +0200 Subject: [PATCH 24/27] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e5f12703d39..5acecccd4fa 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5683,7 +5683,7 @@ class Form $retstring .= ''; - foreach($TModels as $id_model=>$label_model){ + foreach ($TModels as $id_model=>$label_model){ $retstring .= '