dolibarr  9.0.0
agenda_other.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2008-2016 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
5  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6  * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
7  * Copyright (C) 2017 Open-DSI <support@open-dsi.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
29 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
33 
34 if (!$user->admin)
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array('admin', 'other', 'agenda'));
39 
40 $action = GETPOST('action','alpha');
41 $value = GETPOST('value','alpha');
42 $param = GETPOST('param','alpha');
43 $cancel = GETPOST('cancel','alpha');
44 $scandir = GETPOST('scan_dir','alpha');
45 $type = 'action';
46 
47 
48 /*
49  * Actions
50  */
51 
52 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
53 
54 if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
55 {
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  {
60  Header("Location: ".$_SERVER["PHP_SELF"]);
61  exit;
62  }
63  else
64  {
65  dol_print_error($db);
66  }
67 }
68 
69 if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
70 {
71  $code=$reg[1];
72  if (dolibarr_del_const($db, $code, $conf->entity) > 0)
73  {
74  Header("Location: ".$_SERVER["PHP_SELF"]);
75  exit;
76  }
77  else
78  {
79  dol_print_error($db);
80  }
81 }
82 if ($action == 'set')
83 {
84  dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
85  dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity);
86  dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
87  dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
88 }
89 else if ($action == 'specimen') // For orders
90 {
91  $modele=GETPOST('module','alpha');
92 
93  $commande = new CommandeFournisseur($db);
94  $commande->initAsSpecimen();
95  $commande->thirdparty=$specimenthirdparty;
96 
97  // Search template files
98  $file=''; $classname=''; $filefound=0;
99  $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
100  foreach($dirmodels as $reldir)
101  {
102  $file=dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php",0);
103  if (file_exists($file))
104  {
105  $filefound=1;
106  $classname = "pdf_".$modele;
107  break;
108  }
109  }
110 
111  if ($filefound)
112  {
113  require_once $file;
114 
115  $module = new $classname($db,$commande);
116 
117  if ($module->write_file($commande,$langs) > 0)
118  {
119  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
120  return;
121  }
122  else
123  {
124  setEventMessages($module->error, $module->errors, 'errors');
125  dol_syslog($module->error, LOG_ERR);
126  }
127  }
128  else
129  {
130  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
131  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
132  }
133 }
134 
135 // Activate a model
136 else if ($action == 'setmodel')
137 {
138  //print "sssd".$value;
139  $ret = addDocumentModel($value, $type, $label, $scandir);
140 }
141 
142 else if ($action == 'del')
143 {
144  $ret = delDocumentModel($value, $type);
145  if ($ret > 0)
146  {
147  if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF',$conf->entity);
148  }
149 }
150 
151 // Set default model
152 else if ($action == 'setdoc')
153 {
154  if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
155  {
156  // La constante qui a ete lue en avant du nouveau set
157  // on passe donc par une variable pour avoir un affichage coherent
158  $conf->global->ACTION_EVENT_ADDON_PDF = $value;
159  }
160 
161  // On active le modele
162  $ret = delDocumentModel($value, $type);
163  if ($ret > 0)
164  {
165  $ret = addDocumentModel($value, $type, $label, $scandir);
166  }
167 }
168 
169 
175 $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
176 
177 $wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
178 llxHeader('', $langs->trans("AgendaSetup"),$wikihelp);
179 
180 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
181 print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
182 
183 
184 
185 $head=agenda_prepare_head();
186 
187 dol_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action');
188 
189 
190 /*
191  * Documents models for supplier orders
192  */
193 
194 
195 // Define array def of models
196 $def = array();
197 
198 $sql = "SELECT nom";
199 $sql.= " FROM ".MAIN_DB_PREFIX."document_model";
200 $sql.= " WHERE type = 'action'";
201 $sql.= " AND entity = ".$conf->entity;
202 
203 $resql=$db->query($sql);
204 if ($resql)
205 {
206  $i = 0;
207  $num_rows=$db->num_rows($resql);
208  while ($i < $num_rows)
209  {
210  $array = $db->fetch_array($resql);
211  array_push($def, $array[0]);
212  $i++;
213  }
214 }
215 else
216 {
217  dol_print_error($db);
218 }
219 
220 if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
221 {
222  print load_fiche_titre($langs->trans("AgendaModelModule"),'','');
223 
224  print '<table class="noborder" width="100%">'."\n";
225  print '<tr class="liste_titre">'."\n";
226  print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
227  print '<td>'.$langs->trans("Description").'</td>'."\n";
228  print '<td align="center" width="60">'.$langs->trans("Status").'</td>'."\n";
229  print '<td align="center" width="60">'.$langs->trans("Default").'</td>'."\n";
230  print '<td align="center" width="40">'.$langs->trans("ShortInfo").'</td>';
231  print '<td align="center" width="40">'.$langs->trans("Preview").'</td>';
232  print '</tr>'."\n";
233 
234  clearstatcache();
235 
236  foreach ($dirmodels as $reldir)
237  {
238  $dir = dol_buildpath($reldir."core/modules/action/doc/");
239 
240  if (is_dir($dir))
241  {
242  $handle=opendir($dir);
243  if (is_resource($handle))
244  {
245  while (($file = readdir($handle))!==false)
246  {
247  if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
248  {
249  $name = substr($file, 4, dol_strlen($file) -16);
250  $classname = substr($file, 0, dol_strlen($file) -12);
251 
252  require_once $dir.'/'.$file;
253  $module = new $classname($db, new ActionComm($db));
254 
255  print '<tr class="oddeven">'."\n";
256  print "<td>";
257  print (empty($module->name)?$name:$module->name);
258  print "</td>\n";
259  print "<td>\n";
260  require_once $dir.$file;
261  $module = new $classname($db,$specimenthirdparty);
262  if (method_exists($module,'info'))
263  print $module->info($langs);
264  else
265  print $module->description;
266  print "</td>\n";
267 
268  // Active
269  if (in_array($name, $def))
270  {
271 
272  print '<td align="center">'."\n";
273  if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name")
274  {
275  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">';
276  print img_picto($langs->trans("Enabled"),'switch_on');
277  print '</a>';
278  }
279  else
280  {
281  print img_picto($langs->trans("Enabled"),'switch_on');
282  }
283  print "</td>";
284  }
285  else
286  {
287  print '<td align="center">'."\n";
288  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
289  print "</td>";
290  }
291 
292  // Default
293  print '<td align="center">';
294  if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name")
295  {
296  print img_picto($langs->trans("Default"),'on');
297  }
298  else
299  {
300  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
301  }
302  print '</td>';
303 
304  // Info
305  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
306  $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
307  $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
308  $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
309  $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
310  print '<td align="center">';
311  print $form->textwithpicto('',$htmltooltip,1,0);
312  print '</td>';
313  print '<td align="center">';
314  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>';
315  print '</td>';
316 
317  print "</tr>\n";
318  }
319  }
320  closedir($handle);
321  }
322  }
323  }
324  print '</table><br>';
325 }
326 
327 print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
328 print '<input type="hidden" name="action" value="set">';
329 
330 print '<table class="noborder allwidth">'."\n";
331 print '<tr class="liste_titre">'."\n";
332 print '<td>'.$langs->trans("Parameters").'</td>'."\n";
333 print '<td align="center">&nbsp;</td>'."\n";
334 print '<td align="right">'.$langs->trans("Value").'</td>'."\n";
335 print '</tr>'."\n";
336 
337 // Manual or automatic
338 
339 print '<tr class="oddeven">'."\n";
340 print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE").'</td>'."\n";
341 print '<td align="center">&nbsp;</td>'."\n";
342 print '<td align="right">'."\n";
343 //print ajax_constantonoff('AGENDA_USE_EVENT_TYPE'); Do not use ajax here, we need to reload page to change other combo list
344 if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
345 {
346  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_USE_EVENT_TYPE">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
347 }
348 else
349 {
350  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_USE_EVENT_TYPE">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
351 }
352 print '</td></tr>'."\n";
353 
354 // AGENDA_DEFAULT_VIEW
355 print '<tr class="oddeven">'."\n";
356 print '<td>'.$langs->trans("AGENDA_DEFAULT_VIEW").'</td>'."\n";
357 print '<td align="center">&nbsp;</td>'."\n";
358 print '<td align="right">'."\n";
359 $tmplist=array(''=>'&nbsp;', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser"));
360 print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
361 print '</td></tr>'."\n";
362 
363 if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
364 {
365 
366  print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
367  print '<tr class="oddeven">'."\n";
368  print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";
369  print '<td align="center">&nbsp;</td>'."\n";
370  print '<td align="right" class="nowrap">'."\n";
371  $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1);
372  print '</td></tr>'."\n";
373 }
374 
375 // AGENDA_DEFAULT_FILTER_TYPE
376 print '<tr class="oddeven">'."\n";
377 print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_TYPE").'</td>'."\n";
378 print '<td align="center">&nbsp;</td>'."\n";
379 print '<td align="right" class="nowrap">'."\n";
380 $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AGENDA_DEFAULT_FILTER_TYPE", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 1);
381 print '</td></tr>'."\n";
382 
383 // AGENDA_DEFAULT_FILTER_STATUS
384 // TODO Remove to use the default generic feature
385 print '<tr class="oddeven">'."\n";
386 print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_STATUS").'</td>'."\n";
387 print '<td align="center">&nbsp;</td>'."\n";
388 print '<td align="right">'."\n";
389 $formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2, 'minwidth100');
390 print '</td></tr>'."\n";
391 
392 print '</table>';
393 
394 dol_fiche_end();
395 
396 print '<div class="center"><input class="button" type="submit" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
397 
398 print '</form>';
399 
400 print "<br>";
401 
402 // End of page
403 llxFooter();
404 $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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
Class to manage building of HTML components.
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.
Class to manage agenda events (actions)
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $wikihelp
View.
Definition: agenda.php:120