add modification of the notifications
This commit is contained in:
parent
988a532bed
commit
1ed6312f4b
@ -393,7 +393,7 @@ if (empty($reshook) && $action == 'add')
|
|||||||
$moreparam = '';
|
$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.
|
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 reminder
|
//Create reminders
|
||||||
if ($addreminder == 'on'){
|
if ($addreminder == 'on'){
|
||||||
$actionCommReminder = new ActionCommReminder($db);
|
$actionCommReminder = new ActionCommReminder($db);
|
||||||
|
|
||||||
@ -639,9 +639,51 @@ if (empty($reshook) && $action == 'update')
|
|||||||
$categories = GETPOST('categories', 'array');
|
$categories = GETPOST('categories', 'array');
|
||||||
$object->setCategories($categories);
|
$object->setCategories($categories);
|
||||||
|
|
||||||
|
$object->loadReminders();
|
||||||
|
if (!empty($object->reminders))
|
||||||
|
{
|
||||||
|
foreach ($object->reminders as $reminder)
|
||||||
|
{
|
||||||
|
$reminder->delete($user);
|
||||||
|
}
|
||||||
|
$object->reminders = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create reminders
|
||||||
|
if ($addreminder == 'on'){
|
||||||
|
$actionCommReminder = new ActionCommReminder($db);
|
||||||
|
|
||||||
|
$dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit);
|
||||||
|
|
||||||
|
$actionCommReminder->dateremind = $dateremind;
|
||||||
|
$actionCommReminder->typeremind = $remindertype;
|
||||||
|
$actionCommReminder->offsetunit = $offsetunit;
|
||||||
|
$actionCommReminder->offsetvalue = $offsetvalue;
|
||||||
|
$actionCommReminder->status = $actionCommReminder::STATUS_TODO;
|
||||||
|
$actionCommReminder->fk_actioncomm = $object->id;
|
||||||
|
if ($remindertype == 'email') $actionCommReminder->fk_email_template = $modelmail;
|
||||||
|
|
||||||
|
// the notification must be created for every user assigned to the event
|
||||||
|
foreach ($object->userassigned as $userassigned)
|
||||||
|
{
|
||||||
|
$actionCommReminder->fk_user = $userassigned['id'];
|
||||||
|
$res = $actionCommReminder->create($user);
|
||||||
|
|
||||||
|
if ($res <= 0){
|
||||||
|
// If error
|
||||||
|
$langs->load("errors");
|
||||||
|
$error = $langs->trans('ErrorReminderActionCommCreation');
|
||||||
|
setEventMessages($error, null, 'errors');
|
||||||
|
$action = 'create'; $donotclearsession = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unset($_SESSION['assignedtouser']);
|
unset($_SESSION['assignedtouser']);
|
||||||
|
|
||||||
$db->commit();
|
if (!$error) $db->commit();
|
||||||
|
else $db->rollback();
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
@ -1673,38 +1715,78 @@ if ($id > 0)
|
|||||||
|
|
||||||
print '<hr>';
|
print '<hr>';
|
||||||
|
|
||||||
print '<table class="border tableforfield centpercent">';
|
|
||||||
|
|
||||||
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("Reminders").'</td><td>';
|
|
||||||
|
|
||||||
if (count($object->reminders) > 0) {
|
if (count($object->reminders) > 0) {
|
||||||
if (count($object->reminders) > 0) {
|
$checked = 'checked';
|
||||||
$tmpuserstatic = new User($db);
|
$keys = array_keys($object->reminders);
|
||||||
|
$firstreminderId = array_shift($keys);
|
||||||
|
|
||||||
foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
|
$actionCommReminder = $object->reminders[$firstreminderId];
|
||||||
print $TRemindTypes[$actioncommreminder->typeremind];
|
|
||||||
if ($actioncommreminder->fk_user > 0) {
|
}
|
||||||
$tmpuserstatic->fetch($actioncommreminder->fk_user);
|
else
|
||||||
print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')';
|
{
|
||||||
}
|
$checked = '';
|
||||||
print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit];
|
$actionCommReminder = new ActionCommReminder($db);
|
||||||
if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
|
$actionCommReminder->offsetvalue = 10;
|
||||||
print ' - <span class="opacitymedium">';
|
$actionCommReminder->offsetunit = 'i';
|
||||||
print $langs->trans("NotSent");
|
$actionCommReminder->typeremind = 'email';
|
||||||
print ' </span>';
|
|
||||||
} elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
|
|
||||||
print ' - <span class="opacitymedium">';
|
|
||||||
print $langs->trans("Done");
|
|
||||||
print ' </span>';
|
|
||||||
}
|
|
||||||
print '<br>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("AddReminder").'</td><td colspan="3"><input type="checkbox" id="addreminder" name="addreminder" '.$checked.'></td></tr>';
|
||||||
|
|
||||||
|
print '<div class="reminderparameters" '.(empty($checked) ? 'style="display: none;"' : '').'>';
|
||||||
|
|
||||||
|
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="'.$actionCommReminder->offsetvalue.'" size="5">';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
//Time Type
|
||||||
|
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("TimeType").'</td><td colspan="3">';
|
||||||
|
print $form->selectTypeDuration('offsetunit', $actionCommReminder->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, $actionCommReminder->typeremind);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
$hide = '';
|
||||||
|
if ($actionCommReminder->typeremind == 'browser') $hide = 'style="display:none;"';
|
||||||
|
|
||||||
|
//Mail Model
|
||||||
|
print '<tr '.$hide.'><td class="titlefieldcreate nowrap">'.$langs->trans("EMailTemplates").'</td><td colspan="3">';
|
||||||
|
print $form->selectModelMail('actioncommsend', 'actioncomm_send', 1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
print "\n".'<script type="text/javascript">';
|
||||||
|
print '$(document).ready(function () {
|
||||||
|
$("#addreminder").click(function(){
|
||||||
|
if (this.checked) {
|
||||||
|
$(".reminderparameters").show();
|
||||||
|
} else {
|
||||||
|
$(".reminderparameters").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#selectremindertype").change(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();
|
dol_fiche_end();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user