dolibarr  13.0.2
project.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2010-2014 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2011-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2011-2015 Juanjo Menent <jmenent@2byte.es>
5  * Copyright (C) 2011-2018 Philippe Grand <philippe.grand@atoo-net.com>
6  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
7  * Copyright (C) 2015 Marcos GarcĂ­a <marcosgdf@gmail.com>
8  * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
30 require '../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array('admin', 'errors', 'other', 'projects'));
38 
39 if (!$user->admin) accessforbidden();
40 
41 $value = GETPOST('value', 'alpha');
42 $action = GETPOST('action', 'aZ09');
43 $label = GETPOST('label', 'alpha');
44 $scandir = GETPOST('scan_dir', 'alpha');
45 $type = 'project';
46 
47 
48 /*
49  * Actions
50  */
51 
52 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
53 
54 if ($action == 'updateMask')
55 {
56  $maskconstproject = GETPOST('maskconstproject', 'alpha');
57  $maskproject = GETPOST('maskproject', 'alpha');
58 
59  if ($maskconstproject) $res = dolibarr_set_const($db, $maskconstproject, $maskproject, 'chaine', 0, '', $conf->entity);
60 
61  if (!($res > 0)) $error++;
62 
63  if (!$error)
64  {
65  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
66  } else {
67  setEventMessages($langs->trans("Error"), null, 'errors');
68  }
69 }
70 
71 if ($action == 'updateMaskTask')
72 {
73  $maskconstmasktask = GETPOST('maskconsttask', 'alpha');
74  $masktaskt = GETPOST('masktask', 'alpha');
75 
76  if ($maskconstmasktask) $res = dolibarr_set_const($db, $maskconstmasktask, $masktaskt, 'chaine', 0, '', $conf->entity);
77 
78  if (!($res > 0)) $error++;
79 
80  if (!$error)
81  {
82  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
83  } else {
84  setEventMessages($langs->trans("Error"), null, 'errors');
85  }
86 } elseif ($action == 'specimen')
87 {
88  $modele = GETPOST('module', 'alpha');
89 
90  $project = new Project($db);
91  $project->initAsSpecimen();
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/project/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);
112 
113  if ($module->write_file($project, $langs) > 0)
114  {
115  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project&file=SPECIMEN.pdf");
116  return;
117  } else {
118  setEventMessages($obj->error, $obj->errors, 'errors');
119  dol_syslog($obj->error, LOG_ERR);
120  }
121  } else {
122  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
123  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
124  }
125 } elseif ($action == 'specimentask')
126 {
127  $modele = GETPOST('module', 'alpha');
128 
129  $project = new Project($db);
130  $project->initAsSpecimen();
131 
132  // Search template files
133  $file = ''; $classname = ''; $filefound = 0;
134  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
135  foreach ($dirmodels as $reldir)
136  {
137  $file = dol_buildpath($reldir."core/modules/project/task/doc/pdf_".$modele.".modules.php", 0);
138  if (file_exists($file))
139  {
140  $filefound = 1;
141  $classname = "pdf_".$modele;
142  break;
143  }
144  }
145 
146  if ($filefound)
147  {
148  require_once $file;
149 
150  $module = new $classname($db);
151 
152  if ($module->write_file($project, $langs) > 0)
153  {
154  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project_task&file=SPECIMEN.pdf");
155  return;
156  } else {
157  setEventMessages($obj->error, $obj->errors, 'errors');
158  dol_syslog($obj->error, LOG_ERR);
159  }
160  } else {
161  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
162  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
163  }
164 }
165 
166 // Activate a model
167 elseif ($action == 'set')
168 {
169  $ret = addDocumentModel($value, $type, $label, $scandir);
170 }
171 // Activate a model for task
172 elseif ($action == 'settask')
173 {
174  $ret = addDocumentModel($value, 'project_task', $label, $scandir);
175 } elseif ($action == 'del')
176 {
177  $ret = delDocumentModel($value, $type);
178  if ($ret > 0)
179  {
180  if ($conf->global->PROJECT_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_ADDON_PDF', $conf->entity);
181  }
182 }
183 if ($action == 'deltask')
184 {
185  $ret = delDocumentModel($value, 'project_task');
186  if ($ret > 0)
187  {
188  if ($conf->global->PROJECT_TASK_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_TASK_ADDON_PDF', $conf->entity);
189  }
190 }
191 
192 // Set default model
193 elseif ($action == 'setdoc')
194 {
195  dolibarr_set_const($db, "PROJECT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity);
196 
197  // On active le modele
198  $ret = delDocumentModel($value, $type);
199  if ($ret > 0)
200  {
201  $ret = addDocumentModel($value, $type, $label, $scandir);
202  }
203 } elseif ($action == 'setdoctask')
204 {
205  if (dolibarr_set_const($db, "PROJECT_TASK_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
206  {
207  // La constante qui a ete lue en avant du nouveau set
208  // on passe donc par une variable pour avoir un affichage coherent
209  $conf->global->PROJECT_TASK_ADDON_PDF = $value;
210  }
211 
212  // On active le modele
213  $ret = delDocumentModel($value, 'project_task');
214  if ($ret > 0)
215  {
216  $ret = addDocumentModel($value, 'project_task', $label, $scandir);
217  }
218 } elseif ($action == 'setmod')
219 {
220  // TODO Verifier si module numerotation choisi peut etre active
221  // par appel methode canBeActivated
222 
223  dolibarr_set_const($db, "PROJECT_ADDON", $value, 'chaine', 0, '', $conf->entity);
224 } elseif ($action == 'setmodtask')
225 {
226  // TODO Verifier si module numerotation choisi peut etre active
227  // par appel methode canBeActivated
228 
229  dolibarr_set_const($db, "PROJECT_TASK_ADDON", $value, 'chaine', 0, '', $conf->entity);
230 } elseif ($action == 'updateoptions')
231 {
232  if (GETPOST('PROJECT_USE_SEARCH_TO_SELECT'))
233  {
234  $companysearch = GETPOST('activate_PROJECT_USE_SEARCH_TO_SELECT', 'alpha');
235  if (dolibarr_set_const($db, "PROJECT_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity))
236  {
237  $conf->global->PROJECT_USE_SEARCH_TO_SELECT = $companysearch;
238  }
239  }
240  if (GETPOST('PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY'))
241  {
242  $projectToSelect = GETPOST('projectToSelect', 'alpha');
243  dolibarr_set_const($db, 'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY', $projectToSelect, 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value
244  }
245 }
246 
247 
248 /*
249  * View
250  */
251 
252 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
253 
254 llxHeader("", $langs->trans("ProjectsSetup"));
255 
256 $form = new Form($db);
257 
258 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
259 print load_fiche_titre($langs->trans("ProjectsSetup"), $linkback, 'title_setup');
260 
262 
263 print dol_get_fiche_head($head, 'project', $langs->trans("Projects"), -1, 'project');
264 
265 
266 
267 // Main options
268 $form = new Form($db);
269 
270 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
271 print '<input type="hidden" name="token" value="'.newToken().'">';
272 print '<input type="hidden" name="action" value="setmainoptions">';
273 
274 print '<table class="noborder centpercent">';
275 print '<tr class="liste_titre">';
276 print "<td>".$langs->trans("Parameters")."</td>\n";
277 print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
278 print '<td width="80">&nbsp;</td></tr>'."\n";
279 
280 print '<tr class="oddeven">';
281 print '<td width="80%">'.$langs->trans("ManageOpportunitiesStatus").'</td>';
282 print '<td width="60" class="right">';
283 print ajax_constantonoff("PROJECT_USE_OPPORTUNITIES");
284 print '</td><td class="right">';
285 print "</td>";
286 print '</tr>';
287 
288 
289 print '<tr class="oddeven">';
290 print '<td width="80%">'.$langs->trans("ManageTasks").'</td>';
291 print '<td width="60" class="right">';
292 print ajax_constantonoff("PROJECT_HIDE_TASKS", array(), null, 1);
293 print '</td><td class="right">';
294 print "</td>";
295 print '</tr>';
296 
297 print '</table></form>';
298 
299 print '<br>';
300 
301 
302 
303 /*
304  * Projects Numbering model
305  */
306 
307 print load_fiche_titre($langs->trans("ProjectsNumberingModules"), '', '');
308 
309 print '<table class="noborder centpercent">';
310 print '<tr class="liste_titre">';
311 print '<td width="100">'.$langs->trans("Name").'</td>';
312 print '<td>'.$langs->trans("Description").'</td>';
313 print '<td>'.$langs->trans("Example").'</td>';
314 print '<td class="center" width="60">'.$langs->trans("Activated").'</td>';
315 print '<td class="center" width="80">'.$langs->trans("ShortInfo").'</td>';
316 print "</tr>\n";
317 
318 clearstatcache();
319 
320 foreach ($dirmodels as $reldir)
321 {
322  $dir = dol_buildpath($reldir."core/modules/project/");
323 
324  if (is_dir($dir))
325  {
326  $handle = opendir($dir);
327  if (is_resource($handle))
328  {
329  while (($file = readdir($handle)) !== false)
330  {
331  if (preg_match('/^(mod_.*)\.php$/i', $file, $reg))
332  {
333  $file = $reg[1];
334  $classname = substr($file, 4);
335 
336  require_once $dir.$file.'.php';
337 
338  $module = new $file;
339 
340  // Show modules according to features level
341  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
342  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
343 
344  if ($module->isEnabled())
345  {
346  print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
347  print $module->info();
348  print '</td>';
349 
350  // Show example of numbering model
351  print '<td class="nowrap">';
352  $tmp = $module->getExample();
353  if (preg_match('/^Error/', $tmp)) {
354  $langs->load("errors");
355  print '<div class="error">'.$langs->trans($tmp).'</div>';
356  } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
357  else print $tmp;
358  print '</td>'."\n";
359 
360  print '<td class="center">';
361  if ($conf->global->PROJECT_ADDON == 'mod_'.$classname)
362  {
363  print img_picto($langs->trans("Activated"), 'switch_on');
364  } else {
365  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
366  }
367  print '</td>';
368 
369  $project = new Project($db);
370  $project->initAsSpecimen();
371 
372  // Info
373  $htmltooltip = '';
374  $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
375  $nextval = $module->getNextValue($mysoc, $project);
376  if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
377  {
378  $htmltooltip .= ''.$langs->trans("NextValue").': ';
379  if ($nextval)
380  {
381  $htmltooltip .= $nextval.'<br>';
382  } else {
383  $htmltooltip .= $langs->trans($module->error).'<br>';
384  }
385  }
386 
387  print '<td class="center">';
388  print $form->textwithpicto('', $htmltooltip, 1, 0);
389  print '</td>';
390 
391  print '</tr>';
392  }
393  }
394  }
395  closedir($handle);
396  }
397  }
398 }
399 
400 print '</table><br>';
401 
402 
403 if (empty($conf->global->PROJECT_HIDE_TASKS))
404 {
405  // Task numbering module
406  print load_fiche_titre($langs->trans("TasksNumberingModules"), '', '');
407 
408  print '<table class="noborder centpercent">';
409  print '<tr class="liste_titre">';
410  print '<td width="100">'.$langs->trans("Name").'</td>';
411  print '<td>'.$langs->trans("Description").'</td>';
412  print '<td>'.$langs->trans("Example").'</td>';
413  print '<td class="center" width="60">'.$langs->trans("Activated").'</td>';
414  print '<td class="center" width="80">'.$langs->trans("ShortInfo").'</td>';
415  print "</tr>\n";
416 
417  clearstatcache();
418 
419  foreach ($dirmodels as $reldir)
420  {
421  $dir = dol_buildpath($reldir."core/modules/project/task/");
422 
423  if (is_dir($dir))
424  {
425  $handle = opendir($dir);
426  if (is_resource($handle))
427  {
428  while (($file = readdir($handle)) !== false)
429  {
430  if (preg_match('/^(mod_.*)\.php$/i', $file, $reg))
431  {
432  $file = $reg[1];
433  $classname = substr($file, 4);
434 
435  require_once $dir.$file.'.php';
436 
437  $module = new $file;
438 
439  // Show modules according to features level
440  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
441  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
442 
443  if ($module->isEnabled())
444  {
445  print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
446  print $module->info();
447  print '</td>';
448 
449  // Show example of numbering module
450  print '<td class="nowrap">';
451  $tmp = $module->getExample();
452  if (preg_match('/^Error/', $tmp)) {
453  $langs->load("errors");
454  print '<div class="error">'.$langs->trans($tmp).'</div>';
455  } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
456  else print $tmp;
457  print '</td>'."\n";
458 
459  print '<td class="center">';
460  if ($conf->global->PROJECT_TASK_ADDON == 'mod_'.$classname)
461  {
462  print img_picto($langs->trans("Activated"), 'switch_on');
463  } else {
464  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodtask&amp;token='.newToken().'&amp;value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
465  }
466  print '</td>';
467 
468  $project = new Project($db);
469  $project->initAsSpecimen();
470 
471  // Info
472  $htmltooltip = '';
473  $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
474  $nextval = $module->getNextValue($mysoc, $project);
475  if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
476  {
477  $htmltooltip .= ''.$langs->trans("NextValue").': ';
478  if ($nextval)
479  {
480  $htmltooltip .= $nextval.'<br>';
481  } else {
482  $htmltooltip .= $langs->trans($module->error).'<br>';
483  }
484  }
485 
486  print '<td class="center">';
487  print $form->textwithpicto('', $htmltooltip, 1, 0);
488  print '</td>';
489 
490  print '</tr>';
491  }
492  }
493  }
494  closedir($handle);
495  }
496  }
497  }
498 
499  print '</table><br>';
500 }
501 
502 
503 /*
504  * Document templates generators
505  */
506 
507 print load_fiche_titre($langs->trans("ProjectsModelModule"), '', '');
508 
509 // Defini tableau def de modele
510 $type = 'project';
511 $def = array();
512 
513 $sql = "SELECT nom";
514 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
515 $sql .= " WHERE type = '".$db->escape($type)."'";
516 $sql .= " AND entity = ".$conf->entity;
517 
518 $resql = $db->query($sql);
519 if ($resql)
520 {
521  $i = 0;
522  $num_rows = $db->num_rows($resql);
523  while ($i < $num_rows)
524  {
525  $array = $db->fetch_array($resql);
526  array_push($def, $array[0]);
527  $i++;
528  }
529 } else {
530  dol_print_error($db);
531 }
532 
533 print "<table class=\"noborder\" width=\"100%\">\n";
534 print "<tr class=\"liste_titre\">\n";
535 print ' <td width="100">'.$langs->trans("Name")."</td>\n";
536 print " <td>".$langs->trans("Description")."</td>\n";
537 print '<td class="center" width="60">'.$langs->trans("Activated")."</td>\n";
538 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
539 print '<td class="center" width="80">'.$langs->trans("ShortInfo").'</td>';
540 print '<td class="center" width="80">'.$langs->trans("Preview").'</td>';
541 print "</tr>\n";
542 
543 clearstatcache();
544 
545 foreach ($dirmodels as $reldir)
546 {
547  foreach (array('', '/doc') as $valdir)
548  {
549  $dir = dol_buildpath($reldir."core/modules/project/".$valdir);
550 
551  if (is_dir($dir))
552  {
553  $handle = opendir($dir);
554  if (is_resource($handle))
555  {
556  while (($file = readdir($handle)) !== false)
557  {
558  $filelist[] = $file;
559  }
560  closedir($handle);
561  arsort($filelist);
562 
563  foreach ($filelist as $file)
564  {
565  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
566  {
567  if (file_exists($dir.'/'.$file))
568  {
569  $name = substr($file, 4, dol_strlen($file) - 16);
570  $classname = substr($file, 0, dol_strlen($file) - 12);
571 
572  require_once $dir.'/'.$file;
573  $module = new $classname($db);
574 
575  $modulequalified = 1;
576  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
577  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
578 
579  if ($modulequalified)
580  {
581  print '<tr class="oddeven"><td width="100">';
582  print (empty($module->name) ? $name : $module->name);
583  print "</td><td>\n";
584  if (method_exists($module, 'info')) print $module->info($langs);
585  else print $module->description;
586  print "</td>\n";
587 
588  // Active
589  if (in_array($name, $def))
590  {
591  print "<td class=\"center\">\n";
592  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
593  print img_picto($langs->trans("Enabled"), 'switch_on');
594  print '</a>';
595  print "</td>";
596  } else {
597  print "<td class=\"center\">\n";
598  print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
599  print "</td>";
600  }
601 
602  // Default
603  print "<td class=\"center\">";
604  if ($conf->global->PROJECT_ADDON_PDF == "$name")
605  {
606  print img_picto($langs->trans("Default"), 'on');
607  } else {
608  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
609  }
610  print '</td>';
611 
612  // Info
613  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
614  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
615  if ($module->type == 'pdf')
616  {
617  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
618  }
619  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
620  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
621 
622  print '<td class="center">';
623  print $form->textwithpicto('', $htmltooltip, 1, 0);
624  print '</td>';
625 
626  // Preview
627  print '<td class="center">';
628  if ($module->type == 'pdf')
629  {
630  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
631  } else {
632  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
633  }
634  print '</td>';
635 
636  print "</tr>\n";
637  }
638  }
639  }
640  }
641  }
642  }
643  }
644 }
645 
646 print '</table><br/>';
647 
648 
649 
650 if (empty($conf->global->PROJECT_HIDE_TASKS))
651 {
652  /*
653  * Modeles documents for Task
654  */
655 
656  print load_fiche_titre($langs->trans("TaskModelModule"), '', '');
657 
658  // Defini tableau def de modele
659  $type = 'project_task';
660  $def = array();
661 
662  $sql = "SELECT nom";
663  $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
664  $sql .= " WHERE type = '".$db->escape($type)."'";
665  $sql .= " AND entity = ".$conf->entity;
666 
667  $resql = $db->query($sql);
668  if ($resql)
669  {
670  $i = 0;
671  $num_rows = $db->num_rows($resql);
672  while ($i < $num_rows)
673  {
674  $array = $db->fetch_array($resql);
675  array_push($def, $array[0]);
676  $i++;
677  }
678  } else {
679  dol_print_error($db);
680  }
681 
682  print "<table class=\"noborder\" width=\"100%\">\n";
683  print "<tr class=\"liste_titre\">\n";
684  print ' <td width="100">'.$langs->trans("Name")."</td>\n";
685  print " <td>".$langs->trans("Description")."</td>\n";
686  print '<td class="center" width="60">'.$langs->trans("Activated")."</td>\n";
687  print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
688  print '<td class="center" width="80">'.$langs->trans("ShortInfo").'</td>';
689  print '<td class="center" width="80">'.$langs->trans("Preview").'</td>';
690  print "</tr>\n";
691 
692  clearstatcache();
693 
694  foreach ($dirmodels as $reldir)
695  {
696  foreach (array('', '/doc') as $valdir)
697  {
698  $dir = dol_buildpath($reldir."core/modules/project/task/".$valdir);
699 
700  if (is_dir($dir))
701  {
702  $handle = opendir($dir);
703  if (is_resource($handle))
704  {
705  while (($file = readdir($handle)) !== false)
706  {
707  $filelist[] = $file;
708  }
709  closedir($handle);
710  arsort($filelist);
711 
712  foreach ($filelist as $file)
713  {
714  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
715  {
716  if (file_exists($dir.'/'.$file))
717  {
718  $name = substr($file, 4, dol_strlen($file) - 16);
719  $classname = substr($file, 0, dol_strlen($file) - 12);
720 
721  require_once $dir.'/'.$file;
722  $module = new $classname($db);
723 
724  $modulequalified = 1;
725  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
726  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
727 
728  if ($modulequalified)
729  {
730  print '<tr class="oddeven"><td width="100">';
731  print (empty($module->name) ? $name : $module->name);
732  print "</td><td>\n";
733  if (method_exists($module, 'info')) print $module->info($langs);
734  else print $module->description;
735  print "</td>\n";
736 
737  // Active
738  if (in_array($name, $def))
739  {
740  print "<td class=\"center\">\n";
741  print '<a href="'.$_SERVER["PHP_SELF"].'?action=deltask&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
742  print img_picto($langs->trans("Enabled"), 'switch_on');
743  print '</a>';
744  print "</td>";
745  } else {
746  print "<td class=\"center\">\n";
747  print '<a href="'.$_SERVER["PHP_SELF"].'?action=settask&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
748  print "</td>";
749  }
750 
751  // Defaut
752  print "<td class=\"center\">";
753  if ($conf->global->PROJECT_TASK_ADDON_PDF == "$name")
754  {
755  print img_picto($langs->trans("Default"), 'on');
756  } else {
757  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoctask&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
758  }
759  print '</td>';
760 
761  // Info
762  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
763  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
764  if ($module->type == 'pdf')
765  {
766  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
767  }
768  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
769  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
770 
771  print '<td class="center">';
772  print $form->textwithpicto('', $htmltooltip, 1, 0);
773  print '</td>';
774 
775  // Preview
776  print '<td class="center">';
777  if ($module->type == 'pdf')
778  {
779  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimentask&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
780  } else {
781  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
782  }
783  print '</td>';
784  print "</tr>\n";
785  }
786  }
787  }
788  }
789  }
790  }
791  }
792  }
793 
794  print '</table><br/>';
795 }
796 
797 
798 print load_fiche_titre($langs->trans("Other"), '', '');
799 
800 // Other options
801 $form = new Form($db);
802 
803 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
804 print '<input type="hidden" name="token" value="'.newToken().'">';
805 print '<input type="hidden" name="action" value="updateoptions">';
806 
807 print '<table class="noborder centpercent">';
808 print '<tr class="liste_titre">';
809 print "<td>".$langs->trans("Parameters")."</td>\n";
810 print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
811 print '<td width="80">&nbsp;</td></tr>'."\n";
812 
813 print '<tr class="oddeven">';
814 print '<td width="80%">'.$langs->trans("UseSearchToSelectProject").'</td>';
815 if (!$conf->use_javascript_ajax)
816 {
817  print '<td class="nowrap right" colspan="2">';
818  print $langs->trans("NotAvailableWhenAjaxDisabled");
819  print "</td>";
820 } else {
821  print '<td width="60" class="right">';
822  $arrval = array('0'=>$langs->trans("No"),
823  '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
824  '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
825  '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
826  );
827  print $form->selectarray("activate_PROJECT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
828  print '</td><td class="right">';
829  print '<input type="submit" class="button" name="PROJECT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
830  print "</td>";
831 }
832 print '</tr>';
833 
834 print '<tr class="oddeven">';
835 print '<td>'.$langs->trans("AllowToSelectProjectFromOtherCompany").'</td>';
836 
837 print '<td class="right" width="60" colspan="2">';
838 print '<input type="text" id="projectToSelect" name="projectToSelect" value="'.$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.'"/>&nbsp;';
839 print $form->textwithpicto('', $langs->trans('AllowToLinkFromOtherCompany'));
840 print '<input type="submit" class="button" name="PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY" value="'.$langs->trans("Modify").'">';
841 print '</td>';
842 
843 print '</table>';
844 
845 
846 print '</form>';
847 
848 // End of page
849 llxFooter();
850 $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
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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.
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
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)
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0)
On/off button for constant.
Definition: ajax.lib.php:503
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
Definition: notice.php:44
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 ...
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;.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Definition: categories.php:101
project_admin_prepare_head()
Prepare array with list of tabs.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.