dolibarr 21.0.0-alpha
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 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
26require '../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
30require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php';
31
32if (!$user->admin) {
34}
35
36// Load translation files required by the page
37$langs->loadLangs(array("admin", "other", "agenda"));
38
39$action = GETPOST('action', 'aZ09');
40$value = GETPOST('value', 'alpha');
41$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
42
43$param = GETPOST('param', 'alpha');
44$cancel = GETPOST('cancel', 'alpha');
45$scandir = GETPOST('scandir', 'alpha');
46$type = 'action';
47
48
49/*
50 * Actions
51 */
52
53include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
54
55if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
56 $code = $reg[1];
57 $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
58 if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
59 header("Location: ".$_SERVER["PHP_SELF"]);
60 exit;
61 } else {
62 dol_print_error($db);
63 }
64}
65
66if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
67 $code = $reg[1];
68 if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
69 header("Location: ".$_SERVER["PHP_SELF"]);
70 exit;
71 } else {
72 dol_print_error($db);
73 }
74}
75if ($action == 'set') {
76 dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
77 dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity);
78 dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
79 dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
80} elseif ($action == 'specimen') { // For orders
81 $modele = GETPOST('module', 'alpha');
82
83 $commande = new CommandeFournisseur($db);
84 $commande->initAsSpecimen();
85 $specimenthirdparty = new Societe($db);
86 $specimenthirdparty->initAsSpecimen();
87 $commande->thirdparty = $specimenthirdparty;
88
89 // Search template files
90 $file = '';
91 $classname = '';
92 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
93 foreach ($dirmodels as $reldir) {
94 $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
95 if (file_exists($file)) {
96 $classname = "pdf_".$modele;
97 break;
98 }
99 }
100
101 if ($classname !== '') {
102 require_once $file;
103
104 $module = new $classname($db, $commande);
105 '@phan-var-force pdf_standard_actions $module';
106
107 if ($module->write_file($commande, $langs) > 0) {
108 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
109 return;
110 } else {
111 setEventMessages($module->error, $module->errors, 'errors');
112 dol_syslog($module->error, LOG_ERR);
113 }
114 } else {
115 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
116 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
117 }
118} elseif ($action == 'setmodel') {
119 // Activate a model
120 //print "sssd".$value;
121 $ret = addDocumentModel($value, $type, $label, $scandir);
122} elseif ($action == 'del') {
123 $ret = delDocumentModel($value, $type);
124 if ($ret > 0) {
125 if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") {
126 dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
127 }
128 }
129} elseif ($action == 'setdoc') {
130 // Set default model
131 if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
132 // The constant that has been read in front of the new set
133 // is therefore passed through a variable to have a coherent display
134 $conf->global->ACTION_EVENT_ADDON_PDF = $value;
135 }
136
137 // On active le modele
138 $ret = delDocumentModel($value, $type);
139 if ($ret > 0) {
140 $ret = addDocumentModel($value, $type, $label, $scandir);
141 }
142}
143
144
150$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
151llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-agenda_reminder');
152
153$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
154print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
155
156
157$head = agenda_prepare_head();
158
159print dol_get_fiche_head($head, 'reminders', $langs->trans("Agenda"), -1, 'action');
160
161print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
162print '<input type="hidden" name="token" value="'.newToken().'">';
163print '<input type="hidden" name="action" value="set">';
164
165print '<table class="noborder allwidth">'."\n";
166print '<tr class="liste_titre">'."\n";
167print '<td>'.$langs->trans("Parameters").'</td>'."\n";
168print '<td class="center">&nbsp;</td>'."\n";
169print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
170print '</tr>'."\n";
171
172// AGENDA REMINDER BROWSER
173print '<tr class="oddeven">'."\n";
174print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n";
175print '<td class="center">&nbsp;</td>'."\n";
176print '<td class="right nowraponall">'."\n";
177
178if (!getDolGlobalString('AGENDA_REMINDER_BROWSER')) {
179 if (!isHTTPS()) {
180 $langs->load("errors");
181 print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
182 }
183 print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
184 print '</td></tr>'."\n";
185} else {
186 if (!isHTTPS()) {
187 $langs->load("errors");
188 print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
189 }
190 print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
191 print '</td></tr>'."\n";
192
193 print '<tr class="oddeven">'."\n";
194 print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n";
195 print '<td class="center">&nbsp;</td>'."\n";
196 print '<td class="right">'."\n";
197
198 if (!getDolGlobalString('AGENDA_REMINDER_BROWSER_SOUND')) {
199 print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND&token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
200 } else {
201 print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND&token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
202 }
203
204 print '</td></tr>'."\n";
205}
206
207$job = new Cronjob($db);
208$job->fetch(0, 'ActionComm', 'sendEmailsReminder');
209
210// AGENDA REMINDER EMAIL
211print '<tr class="oddeven">'."\n";
212print '<td>'.$langs->trans('AGENDA_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"));
213if (isModEnabled('cron')) {
214 if (getDolGlobalString('AGENDA_REMINDER_EMAIL')) {
215 if ($job->id > 0) {
216 if ($job->status == $job::STATUS_ENABLED) {
217 print '<br><span class="opacitymedium">'.$langs->trans("AGENDA_REMINDER_EMAIL_NOTE", $langs->transnoentitiesnoconv("sendEmailsReminder")).'</span>';
218 }
219 }
220 }
221}
222print '</td>'."\n";
223print '<td class="center">&nbsp;</td>'."\n";
224print '<td class="right nowraponall">'."\n";
225
226if (!isModEnabled('cron')) {
227 print '<span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module2300Name")).'</span>';
228} else {
229 if (!getDolGlobalString('AGENDA_REMINDER_EMAIL')) {
230 print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_EMAIL&token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
231 } else {
232 // Get the max frequency of reminder
233 if ($job->id > 0) {
234 if ($job->status != $job::STATUS_ENABLED) {
235 $langs->load("cron");
236 print '<span class="opacitymedium warning">'.$langs->trans("JobXMustBeEnabled", $langs->transnoentitiesnoconv("sendEmailsReminder")).'</span>';
237 } else {
238 print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_EMAIL&token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
239 }
240 } else {
241 $langs->load("cron");
242 print '<span class="opacitymedium warning">'.$langs->trans("JobNotFound", $langs->transnoentitiesnoconv("sendEmailsReminder")).'</span>';
243 }
244 }
245}
246print '</td></tr>'."\n";
247
248print '</table>';
249
250print dol_get_fiche_end();
251
252//print '<div class="center"><input class="button button-save" type="submit" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
253
254print '</form>';
255
256print "<br>";
257
258// End of page
259llxFooter();
260$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.
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:70
Class to manage predefined suppliers products.
Cron Job class.
Class to manage building of HTML components.
Class to manage third parties objects (customers, suppliers, prospects...)
llxFooter()
Footer empty.
Definition document.php:107
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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
isHTTPS()
Return if we are using a HTTPS connection Check HTTPS (no way to be modified by user but may be empty...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.