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