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