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