dolibarr  13.0.2
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 require '../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php';
29 
30 if (!$user->admin)
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array("admin", "other", "agenda"));
35 
36 $action = GETPOST('action', 'aZ09');
37 $value = GETPOST('value', 'alpha');
38 $param = GETPOST('param', 'alpha');
39 $cancel = GETPOST('cancel', 'alpha');
40 $scandir = GETPOST('scandir', 'alpha');
41 $type = 'action';
42 
43 
44 /*
45  * Actions
46  */
47 
48 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
49 
50 if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
51 {
52  $code = $reg[1];
53  $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
54  if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
55  {
56  Header("Location: ".$_SERVER["PHP_SELF"]);
57  exit;
58  } else {
59  dol_print_error($db);
60  }
61 }
62 
63 if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
64 {
65  $code = $reg[1];
66  if (dolibarr_del_const($db, $code, $conf->entity) > 0)
67  {
68  Header("Location: ".$_SERVER["PHP_SELF"]);
69  exit;
70  } else {
71  dol_print_error($db);
72  }
73 }
74 if ($action == 'set')
75 {
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 {
82  $modele = GETPOST('module', 'alpha');
83 
84  $commande = new CommandeFournisseur($db);
85  $commande->initAsSpecimen();
86  $commande->thirdparty = $specimenthirdparty;
87 
88  // Search template files
89  $file = ''; $classname = ''; $filefound = 0;
90  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
91  foreach ($dirmodels as $reldir)
92  {
93  $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
94  if (file_exists($file))
95  {
96  $filefound = 1;
97  $classname = "pdf_".$modele;
98  break;
99  }
100  }
101 
102  if ($filefound)
103  {
104  require_once $file;
105 
106  $module = new $classname($db, $commande);
107 
108  if ($module->write_file($commande, $langs) > 0)
109  {
110  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
111  return;
112  } else {
113  setEventMessages($module->error, $module->errors, 'errors');
114  dol_syslog($module->error, LOG_ERR);
115  }
116  } else {
117  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
118  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
119  }
120 }
121 
122 // Activate a model
123 elseif ($action == 'setmodel')
124 {
125  //print "sssd".$value;
126  $ret = addDocumentModel($value, $type, $label, $scandir);
127 } elseif ($action == 'del')
128 {
129  $ret = delDocumentModel($value, $type);
130  if ($ret > 0)
131  {
132  if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
133  }
134 }
135 
136 // Set default model
137 elseif ($action == 'setdoc')
138 {
139  if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
140  {
141  // The constant that has been read in front of the new set
142  // is therefore passed through a variable to have a coherent display
143  $conf->global->ACTION_EVENT_ADDON_PDF = $value;
144  }
145 
146  // On active le modele
147  $ret = delDocumentModel($value, $type);
148  if ($ret > 0)
149  {
150  $ret = addDocumentModel($value, $type, $label, $scandir);
151  }
152 }
153 
154 
160 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
161 llxHeader();
162 
163 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
164 print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
165 
166 
167 
168 $head = agenda_prepare_head();
169 
170 print dol_get_fiche_head($head, 'reminders', $langs->trans("Agenda"), -1, 'action');
171 
172 print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
173 print '<input type="hidden" name="token" value="'.newToken().'">';
174 print '<input type="hidden" name="action" value="set">';
175 
176 print '<table class="noborder allwidth">'."\n";
177 print '<tr class="liste_titre">'."\n";
178 print '<td>'.$langs->trans("Parameters").'</td>'."\n";
179 print '<td class="center">&nbsp;</td>'."\n";
180 print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
181 print '</tr>'."\n";
182 
183 // AGENDA REMINDER BROWSER
184 print '<tr class="oddeven">'."\n";
185 print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n";
186 print '<td class="center">&nbsp;</td>'."\n";
187 print '<td class="right">'."\n";
188 
189 if (empty($conf->global->AGENDA_REMINDER_BROWSER)) {
190  if (!isHTTPS()) {
191  $langs->load("errors");
192  print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
193  }
194  print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
195  print '</td></tr>'."\n";
196 } else {
197  if (!isHTTPS()) {
198  $langs->load("errors");
199  print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
200  }
201  print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
202  print '</td></tr>'."\n";
203 
204  print '<tr class="oddeven">'."\n";
205  print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n";
206  print '<td class="center">&nbsp;</td>'."\n";
207  print '<td class="right">'."\n";
208 
209  if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) {
210  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
211  } else {
212  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
213  }
214 
215  print '</td></tr>'."\n";
216 }
217 
218 $job = new Cronjob($db);
219 $job->fetch(0, 'ActionComm', 'sendEmailsReminder');
220 
221 // AGENDA REMINDER EMAIL
222 print '<tr class="oddeven">'."\n";
223 print '<td>'.$langs->trans('AGENDA_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"));
224 if (!empty($conf->cron->enabled)) {
225  if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) {
226  if ($job->id > 0) {
227  if ($job->status == $job::STATUS_ENABLED) {
228  print '<br><span class="opacitymedium">'.$langs->trans("AGENDA_REMINDER_EMAIL_NOTE", $langs->transnoentitiesnoconv("sendEmailsReminder")).'</span>';
229  }
230  }
231  }
232 }
233 print '</td>'."\n";
234 print '<td class="center">&nbsp;</td>'."\n";
235 print '<td class="right">'."\n";
236 
237 if (empty($conf->cron->enabled)) {
238  print '<span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module2300Name")).'</span>';
239 } else {
240  if (empty($conf->global->AGENDA_REMINDER_EMAIL)) {
241  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_EMAIL&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
242  } else {
243  // Get the max frequency of reminder
244  if ($job->id > 0) {
245  if ($job->status != $job::STATUS_ENABLED) {
246  print '<span class="opacitymedium warning">'.$langs->trans("JobXMustBeEnabled", $langs->transnoentitiesnoconv("sendEmailsReminder")).'</span>';
247  } else {
248  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_EMAIL&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
249  }
250  }
251  }
252 }
253 print '</td></tr>'."\n";
254 
255 print '</table>';
256 
258 
259 //print '<div class="center"><input class="button button-save" type="submit" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
260 
261 print '</form>';
262 
263 print "<br>";
264 
265 // End of page
266 llxFooter();
267 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1748
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.
Class to manage building of HTML components.
agenda_prepare_head()
Prepare array with list of tabs.
Definition: agenda.lib.php:358
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).
Definition: admin.lib.php:575
addDocumentModel($name, $type, $label= '', $description= '')
Add document model used by doc generator.
Definition: admin.lib.php:1717
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dolibarr_del_const($db, $name, $entity=1)
Effacement d&#39;une constante dans la base de donnees.
Definition: admin.lib.php:499
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
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 Calling this function terminate execution ...
Class to manage predefined suppliers products.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
isHTTPS()
Return if we are using a HTTPS connexion Check HTTPS (no way to be modified by user but may be empty ...
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Cron Job class.
llxFooter()
Empty footer.
Definition: wrapper.php:59