dolibarr 21.0.0-beta
agenda_reminder.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
32require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php';
33
42if (!$user->admin) {
44}
45
46// Load translation files required by the page
47$langs->loadLangs(array("admin", "other", "agenda"));
48
49$action = GETPOST('action', 'aZ09');
50$value = GETPOST('value', 'alpha');
51$label = GETPOST('label', 'alpha');
52$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
53
54$param = GETPOST('param', 'alpha');
55$cancel = GETPOST('cancel', 'alpha');
56$scandir = GETPOST('scandir', 'alpha');
57$type = 'action';
58
59$form = new Form($db);
60
61/*
62 * Actions
63 */
64
65include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
66
67if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
68 $code = $reg[1];
69 $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
70 if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
71 header("Location: ".$_SERVER["PHP_SELF"]);
72 exit;
73 } else {
74 dol_print_error($db);
75 }
76}
77
78if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
79 $code = $reg[1];
80 if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
81 header("Location: ".$_SERVER["PHP_SELF"]);
82 exit;
83 } else {
84 dol_print_error($db);
85 }
86}
87if ($action == 'set') {
88 dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
89 dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity);
90 dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
91 dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
92 dolibarr_set_const($db, 'AGENDA_DEFAULT_REMINDER_OFFSET', GETPOSTINT('AGENDA_DEFAULT_REMINDER_OFFSET'), 'chaine', 0, '', $conf->entity);
93 dolibarr_set_const($db, 'AGENDA_DEFAULT_REMINDER_OFFSET_UNIT', GETPOST('AGENDA_DEFAULT_REMINDER_OFFSET_UNIT_type_duration'), 'chaine', 0, '', $conf->entity);
94 dolibarr_set_const($db, 'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL', GETPOSTINT('AGENDA_DEFAULT_REMINDER_EMAIL_MODELmodel_mail'), 'chaine', 0, '', $conf->entity);
95 dolibarr_set_const($db, 'AGENDA_DEFAULT_REMINDER_EVENT_TYPES', json_encode(GETPOST('AGENDA_DEFAULT_REMINDER_EVENT_TYPES')), 'chaine', 0, '', $conf->entity);
96} elseif ($action == 'specimen') { // For orders
97 $modele = GETPOST('module', 'alpha');
98
99 $commande = new CommandeFournisseur($db);
100 $commande->initAsSpecimen();
101 $specimenthirdparty = new Societe($db);
102 $specimenthirdparty->initAsSpecimen();
103 $commande->thirdparty = $specimenthirdparty;
104
105 // Search template files
106 $file = '';
107 $classname = '';
108 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
109 foreach ($dirmodels as $reldir) {
110 $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
111 if (file_exists($file)) {
112 $classname = "pdf_".$modele;
113 break;
114 }
115 }
116
117 if ($classname !== '') {
118 require_once $file;
119
120 $module = new $classname($db, $commande);
121 '@phan-var-force pdf_standard_actions $module';
124 if ($module->write_file($commande, $langs) > 0) {
125 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
126 return;
127 } else {
128 setEventMessages($module->error, $module->errors, 'errors');
129 dol_syslog($module->error, LOG_ERR);
130 }
131 } else {
132 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
133 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
134 }
135} elseif ($action == 'setmodel') {
136 // Activate a model
137 //print "sssd".$value;
138 $ret = addDocumentModel($value, $type, $label, $scandir);
139} elseif ($action == 'del') {
140 $ret = delDocumentModel($value, $type);
141 if ($ret > 0) {
142 if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") {
143 dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
144 }
145 }
146} elseif ($action == 'setdoc') {
147 // Set default model
148 if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
149 // The constant that has been read in front of the new set
150 // is therefore passed through a variable to have a coherent display
151 $conf->global->ACTION_EVENT_ADDON_PDF = $value;
152 }
153
154 // On active le modele
155 $ret = delDocumentModel($value, $type);
156 if ($ret > 0) {
157 $ret = addDocumentModel($value, $type, $label, $scandir);
158 }
159}
160
161
167$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
168llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-agenda_reminder');
169
170$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
171print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
172
173
174$head = agenda_prepare_head();
175
176print dol_get_fiche_head($head, 'reminders', $langs->trans("Agenda"), -1, 'action');
177
178print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
179print '<input type="hidden" name="token" value="'.newToken().'">';
180print '<input type="hidden" name="action" value="set">';
181
182print '<table class="noborder allwidth">'."\n";
183print '<tr class="liste_titre">'."\n";
184print '<td>'.$langs->trans("Parameters").'</td>'."\n";
185print '<td class="center">&nbsp;</td>'."\n";
186print '<td class="right"></td>'."\n";
187print '</tr>'."\n";
188
189// AGENDA REMINDER BROWSER
190print '<tr class="oddeven">'."\n";
191print '<td>';
192print $langs->trans('AGENDA_REMINDER_BROWSER').'<br>';
193print '<span class="opacitymedium">'.$langs->trans('AGENDA_REMINDER_BROWSERHelp').'</span>';
194print '</td>'."\n";
195print '<td class="center">&nbsp;</td>'."\n";
196print '<td class="right nowraponall">'."\n";
197
198if (!getDolGlobalString('AGENDA_REMINDER_BROWSER')) {
199 /*if (!isHTTPS()) {
200 $langs->load("errors");
201 print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
202 }*/
203 print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
204 print '</td></tr>'."\n";
205} else {
206 /*if (!isHTTPS()) {
207 $langs->load("errors");
208 print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
209 }*/
210 print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
211 print '</td></tr>'."\n";
212
213 /* This feature need to use the old method AGENDA_NOTIFICATION_METHOD = 'jsnotification' that is broken on a lot of browser setup
214 print '<tr class="oddeven">'."\n";
215 print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n";
216 print '<td class="center">&nbsp;</td>'."\n";
217 print '<td class="right">'."\n";
218
219 if (!getDolGlobalString('AGENDA_REMINDER_BROWSER_SOUND')) {
220 print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND&token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
221 } else {
222 print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND&token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
223 }
224
225 print '</td></tr>'."\n";
226 */
227}
228
229$job = new Cronjob($db);
230$job->fetch(0, 'ActionComm', 'sendEmailsReminder');
231
232// AGENDA REMINDER EMAIL
233print '<tr class="oddeven">'."\n";
234print '<td>';
235print $langs->trans('AGENDA_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"));
236if (isModEnabled('cron')) {
237 if (getDolGlobalString('AGENDA_REMINDER_EMAIL')) {
238 if ($job->id > 0) {
239 if ($job->status == $job::STATUS_ENABLED) {
240 print '<br><span class="opacitymedium">'.$langs->trans("AGENDA_REMINDER_EMAIL_NOTE", $langs->transnoentitiesnoconv("sendEmailsReminder")).'</span>';
241 }
242 }
243 }
244}
245print '</td>'."\n";
246print '<td class="center">&nbsp;</td>'."\n";
247print '<td class="right nowraponall">'."\n";
248
249if (!isModEnabled('cron')) {
250 print '<span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module2300Name")).'</span>';
251} else {
252 if (!getDolGlobalString('AGENDA_REMINDER_EMAIL')) {
253 print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_EMAIL&token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
254 } else {
255 // Get the max frequency of reminder
256 if ($job->id > 0) {
257 if ($job->status != $job::STATUS_ENABLED) {
258 $langs->load("cron");
259 print '<span class="opacitymedium warning">'.$langs->trans("JobXMustBeEnabled", $langs->transnoentitiesnoconv("sendEmailsReminder")).'</span>';
260 } else {
261 print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_EMAIL&token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
262 }
263 } else {
264 $langs->load("cron");
265 print '<span class="opacitymedium warning">'.$langs->trans("JobNotFound", $langs->transnoentitiesnoconv("sendEmailsReminder")).'</span>';
266 }
267 }
268}
269
270// AGENDA DEFAULT REMINDER EVENT TYPE
271if (getDolGlobalString('AGENDA_REMINDER_EMAIL')) {
272 print '<tr class="oddeven">'."\n";
273 print '<td>';
274 print $langs->trans('AGENDA_DEFAULT_REMINDER_EVENT_TYPES', $langs->transnoentities("Module2300Name"));
275 print '<br><span class="opacitymedium">'.$langs->trans("AGENDA_DEFAULT_REMINDER_EVENT_TYPES_NOTE", $langs->transnoentitiesnoconv("sendEmailsReminder")).'</span>';
276 print '</td>'."\n";
277 print '<td class="center">&nbsp;</td>'."\n";
278 print '<td class="right nowraponall">'."\n";
279 if (!isModEnabled('cron')) {
280 print '<span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module2300Name")).'</span>';
281 } else {
282 if (GETPOSTISSET('AGENDA_DEFAULT_REMINDER_EVENT_TYPES')) {
283 $selected = GETPOST('AGENDA_DEFAULT_REMINDER_EVENT_TYPES');
284 } else {
285 $selected = json_decode(getDolGlobalString('AGENDA_DEFAULT_REMINDER_EVENT_TYPES', ''));
286 }
287 print $formactions->select_type_actions($selected, "AGENDA_DEFAULT_REMINDER_EVENT_TYPES", "systemauto", 0, -1, 1, 1);
288 print '</td></tr>';
289 }
290}
291
292// AGENDA DEFAULT REMINDER OFFSET
293if (getDolGlobalString('AGENDA_REMINDER_EMAIL')) {
294 print '<tr class="oddeven">'."\n";
295 print '<td>';
296 print $langs->trans('AGENDA_DEFAULT_REMINDER_OFFSET', $langs->transnoentities("Module2300Name"));
297 print '</td>'."\n";
298 print '<td class="center">&nbsp;</td>'."\n";
299 print '<td class="right nowraponall">'."\n";
300 if (!isModEnabled('cron')) {
301 print '<span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module2300Name")).'</span>';
302 } else {
303 print '<input class="width50" type="number" name="AGENDA_DEFAULT_REMINDER_OFFSET" value="'.(GETPOSTISSET('AGENDA_DEFAULT_REMINDER_OFFSET') ? GETPOSTINT('AGENDA_DEFAULT_REMINDER_OFFSET') : getDolGlobalInt('AGENDA_DEFAULT_REMINDER_OFFSET', 30)).'"> ';
304 $selected = (GETPOSTISSET('AGENDA_DEFAULT_REMINDER_OFFSET_UNIT_type_duration') ? GETPOST('AGENDA_DEFAULT_REMINDER_OFFSET_UNIT_type_duration') : getDolGlobalString('AGENDA_DEFAULT_REMINDER_OFFSET_UNIT', 'i'));
305 print $form->selectTypeDuration('AGENDA_DEFAULT_REMINDER_OFFSET_UNIT_', $selected, array('y', 'm'));
306 }
307}
308
309// AGENDA DEFAULT EMAIL MODEL
310if (getDolGlobalString('AGENDA_REMINDER_EMAIL')) {
311 print '<tr class="oddeven">'."\n";
312 print '<td>';
313 print $langs->trans('AGENDA_DEFAULT_REMINDER_EMAIL_MODEL', $langs->transnoentities("Module2300Name"));
314 print '</td>'."\n";
315 print '<td class="center">&nbsp;</td>'."\n";
316 print '<td class="right nowraponall">'."\n";
317 if (!isModEnabled('cron')) {
318 print '<span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module2300Name")).'</span>';
319 } else {
320 $selected = (GETPOSTISSET('AGENDA_DEFAULT_REMINDER_EMAIL_MODELmodel_mail') ? GETPOST('AGENDA_DEFAULT_REMINDER_EMAIL_MODELmodel_mail') : getDolGlobalInt('AGENDA_DEFAULT_REMINDER_EMAIL_MODEL', 0));
321 print $form->selectModelMail('AGENDA_DEFAULT_REMINDER_EMAIL_MODEL', 'actioncomm_send', 1, 1, $selected);
322 }
323}
324print '</td></tr>'."\n";
325
326print '</table>';
327
328print dol_get_fiche_end();
329
330print '<div class="center">';
331print '<input type="submit" id="save" name="save" class="button hideifnotset button-save" value="'.$langs->trans("Save").'">';
332print '</div>';
333
334print '</form>';
335
336print "<br>";
337
338// End of page
339llxFooter();
340$db->close();
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
delDocumentModel($name, $type)
Delete document model used by doc generator.
agenda_prepare_head()
Prepare array with list of tabs.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage predefined suppliers products.
Cron Job class.
Class to manage building of HTML components.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.