mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 00:52:01 +01:00
Merge pull request #14568 from atm-lena/NEW_AgendaEvent_Remind
Agenda Remind (Part 1)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER)
|
||||
{
|
||||
//checkbox create reminder
|
||||
print '<br>';
|
||||
print '<tr><td>'.$langs->trans("AddReminder").'</td><td colspan="3"><input type="checkbox" id="addreminder" name="addreminder"></td></tr>';
|
||||
|
||||
print '<div class="reminderparameters" style="display: none;">';
|
||||
|
||||
print '<hr>';
|
||||
print load_fiche_titre($langs->trans("AddReminder"), '', '');
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
//Reminder
|
||||
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ReminderTime").'</td><td colspan="3">';
|
||||
print '<input type="number" name="offsetvalue" value="10" size="5">';
|
||||
print '</td></tr>';
|
||||
|
||||
//Time Type
|
||||
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("TimeType").'</td><td colspan="3">';
|
||||
print $form->select_type_duration('offsetunit');
|
||||
print '</td></tr>';
|
||||
|
||||
//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');
|
||||
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ReminderType").'</td><td colspan="3">';
|
||||
print $form->selectarray('selectremindertype', $TRemindTypes);
|
||||
print '</td></tr>';
|
||||
|
||||
//Mail Model
|
||||
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("EMailTemplates").'</td><td colspan="3">';
|
||||
print $form->select_model_mail('actioncommsend', 'actioncomm_send');
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print "\n".'<script type="text/javascript">';
|
||||
print '$(document).ready(function () {
|
||||
$("#addreminder").click(function(){
|
||||
if (this.checked) {
|
||||
$(".reminderparameters").show();
|
||||
} else {
|
||||
$(".reminderparameters").hide();
|
||||
}
|
||||
});
|
||||
|
||||
$("#selectremindertype").click(function(){
|
||||
var selected_option = $("#selectremindertype option:selected").val();
|
||||
if(selected_option == "email") {
|
||||
$("#select_actioncommsendmodel_mail").closest("tr").show();
|
||||
} else {
|
||||
$("#select_actioncommsendmodel_mail").closest("tr").hide();
|
||||
};
|
||||
});
|
||||
})';
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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 .= '<select class="flat" id="select_'.$prefix.'type_duration" name="'.$prefix.'type_duration">';
|
||||
|
||||
foreach ($TDurationTypes as $key=>$typeduration){
|
||||
|
||||
$retstring .= '<option value="'.$key.'"';
|
||||
if($key == $selected)
|
||||
{
|
||||
$retstring .= " selected";
|
||||
}
|
||||
$retstring .= ">".$typeduration."</option>";
|
||||
}
|
||||
|
||||
$retstring .= "</select>";
|
||||
|
||||
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 .= '<select class="flat" id="select_'.$prefix.'model_mail" name="'.$prefix.'model_mail">';
|
||||
|
||||
foreach ($TModels as $id_model=>$label_model){
|
||||
$retstring .= '<option value="'.$id_model.'"';
|
||||
$retstring .= ">".$label_model."</option>";
|
||||
}
|
||||
|
||||
$retstring .= "</select>";
|
||||
|
||||
return $retstring;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user