dolibarr  9.0.0
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 <http://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 
29 if (!$user->admin)
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array("admin","other","agenda"));
34 
35 $action = GETPOST('action','alpha');
36 $value = GETPOST('value','alpha');
37 $param = GETPOST('param','alpha');
38 $cancel = GETPOST('cancel','alpha');
39 $scandir = GETPOST('scandir','alpha');
40 $type = 'action';
41 
42 
43 /*
44  * Actions
45  */
46 
47 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
48 
49 if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
50 {
51  $code=$reg[1];
52  $value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
53  if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
54  {
55  Header("Location: ".$_SERVER["PHP_SELF"]);
56  exit;
57  }
58  else
59  {
60  dol_print_error($db);
61  }
62 }
63 
64 if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
65 {
66  $code=$reg[1];
67  if (dolibarr_del_const($db, $code, $conf->entity) > 0)
68  {
69  Header("Location: ".$_SERVER["PHP_SELF"]);
70  exit;
71  }
72  else
73  {
74  dol_print_error($db);
75  }
76 }
77 if ($action == 'set')
78 {
79  dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
80  dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity);
81  dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
82  dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
83 }
84 else if ($action == 'specimen') // For orders
85 {
86  $modele=GETPOST('module','alpha');
87 
88  $commande = new CommandeFournisseur($db);
89  $commande->initAsSpecimen();
90  $commande->thirdparty=$specimenthirdparty;
91 
92  // Search template files
93  $file=''; $classname=''; $filefound=0;
94  $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
95  foreach($dirmodels as $reldir)
96  {
97  $file=dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php",0);
98  if (file_exists($file))
99  {
100  $filefound=1;
101  $classname = "pdf_".$modele;
102  break;
103  }
104  }
105 
106  if ($filefound)
107  {
108  require_once $file;
109 
110  $module = new $classname($db,$commande);
111 
112  if ($module->write_file($commande,$langs) > 0)
113  {
114  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
115  return;
116  }
117  else
118  {
119  setEventMessages($module->error, $module->errors, 'errors');
120  dol_syslog($module->error, LOG_ERR);
121  }
122  }
123  else
124  {
125  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
126  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
127  }
128 }
129 
130 // Activate a model
131 else if ($action == 'setmodel')
132 {
133  //print "sssd".$value;
134  $ret = addDocumentModel($value, $type, $label, $scandir);
135 }
136 
137 else if ($action == 'del')
138 {
139  $ret = delDocumentModel($value, $type);
140  if ($ret > 0)
141  {
142  if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF',$conf->entity);
143  }
144 }
145 
146 // Set default model
147 else if ($action == 'setdoc')
148 {
149  if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
150  {
151  // La constante qui a ete lue en avant du nouveau set
152  // on passe donc par une variable pour avoir un affichage coherent
153  $conf->global->ACTION_EVENT_ADDON_PDF = $value;
154  }
155 
156  // On active le modele
157  $ret = delDocumentModel($value, $type);
158  if ($ret > 0)
159  {
160  $ret = addDocumentModel($value, $type, $label, $scandir);
161  }
162 }
163 
164 
170 $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
171 llxHeader();
172 
173 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
174 print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
175 
176 
177 
178 $head=agenda_prepare_head();
179 
180 dol_fiche_head($head, 'reminders', $langs->trans("Agenda"), -1, 'action');
181 
182 print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
183 print '<input type="hidden" name="action" value="set">';
184 
185 print '<table class="noborder allwidth">'."\n";
186 print '<tr class="liste_titre">'."\n";
187 print '<td>'.$langs->trans("Parameters").'</td>'."\n";
188 print '<td align="center">&nbsp;</td>'."\n";
189 print '<td align="right">'.$langs->trans("Value").'</td>'."\n";
190 print '</tr>'."\n";
191 
192 
193 // AGENDA REMINDER EMAIL
194 if ($conf->global->MAIN_FEATURES_LEVEL > 0)
195 {
196  print '<tr class="oddeven">'."\n";
197  print '<td>'.$langs->trans('AGENDA_REMINDER_EMAIL', $langs->transnoentities("Module2300Name")).'</td>'."\n";
198  print '<td align="center">&nbsp;</td>'."\n";
199  print '<td align="right">'."\n";
200 
201  if (empty($conf->global->AGENDA_REMINDER_EMAIL)) {
202  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_EMAIL">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>';
203  print '</td></tr>'."\n";
204  } else {
205  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_EMAIL">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>';
206  print '</td></tr>'."\n";
207  }
208 }
209 
210 // AGENDA REMINDER BROWSER
211 if ($conf->global->MAIN_FEATURES_LEVEL > 0)
212 {
213  print '<tr class="oddeven">'."\n";
214  print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n";
215  print '<td align="center">&nbsp;</td>'."\n";
216  print '<td align="right">'."\n";
217 
218  if (empty($conf->global->AGENDA_REMINDER_BROWSER)) {
219  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>';
220  print '</td></tr>'."\n";
221  } else {
222  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>';
223  print '</td></tr>'."\n";
224 
225  print '<tr class="oddeven">'."\n";
226  print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n";
227  print '<td align="center">&nbsp;</td>'."\n";
228  print '<td align="right">'."\n";
229 
230  if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) {
231  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>';
232  } else {
233  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>';
234  }
235 
236  print '</td></tr>'."\n";
237  }
238 }
239 
240 print '</table>';
241 
242 dol_fiche_end();
243 
244 print '<div class="center"><input class="button" type="submit" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
245 
246 print '</form>';
247 
248 print "<br>";
249 
250 // End of page
251 llxFooter();
252 $db->close();
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1643
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
Class to manage building of HTML components.
agenda_prepare_head()
Prepare array with list of tabs.
Definition: agenda.lib.php:399
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:510
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1609
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
dolibarr_del_const($db, $name, $entity=1)
Effacement d&#39;une constante dans la base de donnees.
Definition: admin.lib.php:435
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:44
Class to manage predefined suppliers products.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') else if($action=='specimen') else if($action=='setmodel') else if($action=='del') else if($action=='setdoc') $formactions
View.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.