dolibarr  13.0.2
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 <https://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', 'users'));
39 
40 $action = GETPOST('action', 'aZ09');
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 $reg = array();
55 if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
56 {
57  $code = $reg[1];
58  $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
59  if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
60  {
61  Header("Location: ".$_SERVER["PHP_SELF"]);
62  exit;
63  } else {
64  dol_print_error($db);
65  }
66 }
67 
68 if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
69 {
70  $code = $reg[1];
71  if (dolibarr_del_const($db, $code, $conf->entity) > 0)
72  {
73  Header("Location: ".$_SERVER["PHP_SELF"]);
74  exit;
75  } else {
76  dol_print_error($db);
77  }
78 }
79 if ($action == 'set')
80 {
81  $getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE');
82  $defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter;
83  dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
84  dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity);
85  dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
86  dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
87 } elseif ($action == 'specimen') // For orders
88 {
89  $modele = GETPOST('module', 'alpha');
90 
91  $commande = new CommandeFournisseur($db);
92  $commande->initAsSpecimen();
93  $commande->thirdparty = $specimenthirdparty;
94 
95  // Search template files
96  $file = ''; $classname = ''; $filefound = 0;
97  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
98  foreach ($dirmodels as $reldir)
99  {
100  $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
101  if (file_exists($file))
102  {
103  $filefound = 1;
104  $classname = "pdf_".$modele;
105  break;
106  }
107  }
108 
109  if ($filefound)
110  {
111  require_once $file;
112 
113  $module = new $classname($db, $commande);
114 
115  if ($module->write_file($commande, $langs) > 0)
116  {
117  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
118  return;
119  } else {
120  setEventMessages($module->error, $module->errors, 'errors');
121  dol_syslog($module->error, LOG_ERR);
122  }
123  } else {
124  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
125  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
126  }
127 }
128 
129 // Activate a model
130 elseif ($action == 'setmodel')
131 {
132  //print "sssd".$value;
133  $ret = addDocumentModel($value, $type, $label, $scandir);
134 } elseif ($action == 'del')
135 {
136  $ret = delDocumentModel($value, $type);
137  if ($ret > 0)
138  {
139  if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
140  }
141 }
142 
143 // Set default model
144 elseif ($action == 'setdoc')
145 {
146  if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
147  {
148  // La constante qui a ete lue en avant du nouveau set
149  // on passe donc par une variable pour avoir un affichage coherent
150  $conf->global->ACTION_EVENT_ADDON_PDF = $value;
151  }
152 
153  // On active le modele
154  $ret = delDocumentModel($value, $type);
155  if ($ret > 0)
156  {
157  $ret = addDocumentModel($value, $type, $label, $scandir);
158  }
159 }
160 
161 
167 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
168 
169 $wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
170 llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
171 
172 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
173 print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
174 
175 
176 
177 $head = agenda_prepare_head();
178 
179 print dol_get_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action');
180 
181 
182 /*
183  * Documents models for supplier orders
184  */
185 
186 
187 // Define array def of models
188 $def = array();
189 
190 $sql = "SELECT nom";
191 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
192 $sql .= " WHERE type = 'action'";
193 $sql .= " AND entity = ".$conf->entity;
194 
195 $resql = $db->query($sql);
196 if ($resql)
197 {
198  $i = 0;
199  $num_rows = $db->num_rows($resql);
200  while ($i < $num_rows)
201  {
202  $array = $db->fetch_array($resql);
203  array_push($def, $array[0]);
204  $i++;
205  }
206 } else {
207  dol_print_error($db);
208 }
209 
210 if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
211 {
212  print load_fiche_titre($langs->trans("AgendaModelModule"), '', '');
213 
214  print '<table class="noborder centpercent">'."\n";
215  print '<tr class="liste_titre">'."\n";
216  print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
217  print '<td>'.$langs->trans("Description").'</td>'."\n";
218  print '<td class="center" width="60">'.$langs->trans("Status").'</td>'."\n";
219  print '<td class="center" width="60">'.$langs->trans("Default").'</td>'."\n";
220  print '<td class="center" width="40">'.$langs->trans("ShortInfo").'</td>';
221  print '<td class="center" width="40">'.$langs->trans("Preview").'</td>';
222  print '</tr>'."\n";
223 
224  clearstatcache();
225 
226  foreach ($dirmodels as $reldir)
227  {
228  $dir = dol_buildpath($reldir."core/modules/action/doc");
229 
230  if (is_dir($dir))
231  {
232  $handle = opendir($dir);
233  if (is_resource($handle))
234  {
235  while (($file = readdir($handle)) !== false)
236  {
237  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
238  {
239  $name = substr($file, 4, dol_strlen($file) - 16);
240  $classname = substr($file, 0, dol_strlen($file) - 12);
241 
242  require_once $dir.'/'.$file;
243  $module = new $classname($db, new ActionComm($db));
244 
245  print '<tr class="oddeven">'."\n";
246  print "<td>";
247  print (empty($module->name) ? $name : $module->name);
248  print "</td>\n";
249  print "<td>\n";
250  require_once $dir.'/'.$file;
251  $module = new $classname($db, $specimenthirdparty);
252  if (method_exists($module, 'info'))
253  print $module->info($langs);
254  else print $module->description;
255  print "</td>\n";
256 
257  // Active
258  if (in_array($name, $def))
259  {
260  print '<td class="center">'."\n";
261  if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name")
262  {
263  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">';
264  print img_picto($langs->trans("Enabled"), 'switch_on');
265  print '</a>';
266  } else {
267  print img_picto($langs->trans("Enabled"), 'switch_on');
268  }
269  print "</td>";
270  } else {
271  print '<td class="center">'."\n";
272  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
273  print "</td>";
274  }
275 
276  // Default
277  print '<td class="center">';
278  if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name")
279  {
280  print img_picto($langs->trans("Default"), 'on');
281  } else {
282  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&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>';
283  }
284  print '</td>';
285 
286  // Info
287  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
288  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
289  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
290  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
291  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
292  print '<td class="center">';
293  print $form->textwithpicto('', $htmltooltip, 1, 0);
294  print '</td>';
295  print '<td class="center">';
296  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
297  print '</td>';
298 
299  print "</tr>\n";
300  }
301  }
302  closedir($handle);
303  }
304  }
305  }
306  print '</table><br>';
307 }
308 
309 print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
310 print '<input type="hidden" name="token" value="'.newToken().'">';
311 print '<input type="hidden" name="action" value="set">';
312 
313 print '<table class="noborder allwidth">'."\n";
314 print '<tr class="liste_titre">'."\n";
315 print '<td>'.$langs->trans("Parameters").'</td>'."\n";
316 print '<td class="center">&nbsp;</td>'."\n";
317 print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
318 print '</tr>'."\n";
319 
320 // Manual or automatic
321 
322 print '<tr class="oddeven">'."\n";
323 print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE").'</td>'."\n";
324 print '<td class="center">&nbsp;</td>'."\n";
325 print '<td class="right">'."\n";
326 //print ajax_constantonoff('AGENDA_USE_EVENT_TYPE'); Do not use ajax here, we need to reload page to change other combo list
327 if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
328 {
329  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_USE_EVENT_TYPE&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
330 } else {
331  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_USE_EVENT_TYPE&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
332 }
333 print '</td></tr>'."\n";
334 
335 // AGENDA_DEFAULT_VIEW
336 print '<tr class="oddeven">'."\n";
337 $htmltext = $langs->trans("ThisValueCanOverwrittenOnUserLevel", $langs->transnoentitiesnoconv("UserGUISetup"));
338 print '<td>'.$form->textwithpicto($langs->trans("AGENDA_DEFAULT_VIEW"), $htmltext).'</td>'."\n";
339 print '<td class="center">&nbsp;</td>'."\n";
340 print '<td class="right">'."\n";
341 $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"));
342 print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
343 print '</td></tr>'."\n";
344 
345 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
346 {
347  print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
348  print '<tr class="oddeven">'."\n";
349  print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";
350  print '<td class="center">&nbsp;</td>'."\n";
351  print '<td class="right nowrap">'."\n";
352  $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1);
353  print '</td></tr>'."\n";
354 }
355 
356 // AGENDA_DEFAULT_FILTER_TYPE
357 print '<tr class="oddeven">'."\n";
358 print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_TYPE").'</td>'."\n";
359 print '<td class="center">&nbsp;</td>'."\n";
360 print '<td class="right nowrap">'."\n";
361 $multiselect = 0;
362 if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) {
363  // We use an option here because it adds bugs when used on agenda page "peruser" and "list"
364  $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE));
365 }
366 $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AGENDA_DEFAULT_FILTER_TYPE", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 1, $multiselect);
367 print '</td></tr>'."\n";
368 
369 // AGENDA_DEFAULT_FILTER_STATUS
370 // TODO Remove to use the default generic feature
371 print '<tr class="oddeven">'."\n";
372 print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_STATUS").'</td>'."\n";
373 print '<td class="center">&nbsp;</td>'."\n";
374 print '<td class="right">'."\n";
375 $formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2, 'minwidth100');
376 print '</td></tr>'."\n";
377 
378 print '</table>';
379 
381 
382 print '<div class="center"><input class="button button-save" type="submit" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
383 
384 print '</form>';
385 
386 print "<br>";
387 
388 // End of page
389 llxFooter();
390 $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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Class to manage building of HTML components.
Class to manage agenda events (actions)
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.
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
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.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
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.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59