dolibarr  16.0.5
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) {
41 }
42 
43 $value = GETPOST('value', 'alpha');
44 $action = GETPOST('action', 'aZ09');
45 $label = GETPOST('label', 'alpha');
46 $scandir = GETPOST('scan_dir', 'alpha');
47 $type = 'project';
48 
49 
50 /*
51  * Actions
52  */
53 
54 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
55 
56 if ($action == 'updateMask') {
57  $maskconstproject = GETPOST('maskconstproject', 'alpha');
58  $maskproject = GETPOST('maskproject', 'alpha');
59 
60  if ($maskconstproject) {
61  $res = dolibarr_set_const($db, $maskconstproject, $maskproject, 'chaine', 0, '', $conf->entity);
62  }
63 
64  if (!($res > 0)) {
65  $error++;
66  }
67 
68  if (!$error) {
69  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
70  } else {
71  setEventMessages($langs->trans("Error"), null, 'errors');
72  }
73 }
74 
75 if ($action == 'updateMaskTask') {
76  $maskconstmasktask = GETPOST('maskconsttask', 'alpha');
77  $masktaskt = GETPOST('masktask', 'alpha');
78 
79  if ($maskconstmasktask) {
80  $res = dolibarr_set_const($db, $maskconstmasktask, $masktaskt, 'chaine', 0, '', $conf->entity);
81  }
82 
83  if (!($res > 0)) {
84  $error++;
85  }
86 
87  if (!$error) {
88  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
89  } else {
90  setEventMessages($langs->trans("Error"), null, 'errors');
91  }
92 } elseif ($action == 'specimen') {
93  $modele = GETPOST('module', 'alpha');
94 
95  $project = new Project($db);
96  $project->initAsSpecimen();
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  $file = dol_buildpath($reldir."core/modules/project/doc/pdf_".$modele.".modules.php", 0);
103  if (file_exists($file)) {
104  $filefound = 1;
105  $classname = "pdf_".$modele;
106  break;
107  }
108  }
109 
110  if ($filefound) {
111  require_once $file;
112 
113  $module = new $classname($db);
114 
115  if ($module->write_file($project, $langs) > 0) {
116  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project&file=SPECIMEN.pdf");
117  return;
118  } else {
119  setEventMessages($obj->error, $obj->errors, 'errors');
120  dol_syslog($obj->error, LOG_ERR);
121  }
122  } else {
123  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
124  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
125  }
126 } elseif ($action == 'specimentask') {
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  $file = dol_buildpath($reldir."core/modules/project/task/doc/pdf_".$modele.".modules.php", 0);
137  if (file_exists($file)) {
138  $filefound = 1;
139  $classname = "pdf_".$modele;
140  break;
141  }
142  }
143 
144  if ($filefound) {
145  require_once $file;
146 
147  $module = new $classname($db);
148 
149  if ($module->write_file($project, $langs) > 0) {
150  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project_task&file=SPECIMEN.pdf");
151  return;
152  } else {
153  setEventMessages($obj->error, $obj->errors, 'errors');
154  dol_syslog($obj->error, LOG_ERR);
155  }
156  } else {
157  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
158  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
159  }
160 } elseif ($action == 'set') {
161  // Activate a model
162  $ret = addDocumentModel($value, $type, $label, $scandir);
163 } elseif ($action == 'settask') {
164  // Activate a model for task
165  $ret = addDocumentModel($value, 'project_task', $label, $scandir);
166 } elseif ($action == 'del') {
167  $ret = delDocumentModel($value, $type);
168  if ($ret > 0) {
169  if ($conf->global->PROJECT_ADDON_PDF == "$value") {
170  dolibarr_del_const($db, 'PROJECT_ADDON_PDF', $conf->entity);
171  }
172  }
173 } elseif ($action == 'deltask') {
174  $ret = delDocumentModel($value, 'project_task');
175  if ($ret > 0) {
176  if ($conf->global->PROJECT_TASK_ADDON_PDF == "$value") {
177  dolibarr_del_const($db, 'PROJECT_TASK_ADDON_PDF', $conf->entity);
178  }
179  }
180 } elseif ($action == 'setdoc') {
181  // Set default model
182  dolibarr_set_const($db, "PROJECT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity);
183 
184  // On active le modele
185  $ret = delDocumentModel($value, $type);
186  if ($ret > 0) {
187  $ret = addDocumentModel($value, $type, $label, $scandir);
188  }
189 } elseif ($action == 'setdoctask') {
190  if (dolibarr_set_const($db, "PROJECT_TASK_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
191  // La constante qui a ete lue en avant du nouveau set
192  // on passe donc par une variable pour avoir un affichage coherent
193  $conf->global->PROJECT_TASK_ADDON_PDF = $value;
194  }
195 
196  // On active le modele
197  $ret = delDocumentModel($value, 'project_task');
198  if ($ret > 0) {
199  $ret = addDocumentModel($value, 'project_task', $label, $scandir);
200  }
201 } elseif ($action == 'setmod') {
202  // TODO Verifier si module numerotation choisi peut etre active
203  // par appel methode canBeActivated
204 
205  dolibarr_set_const($db, "PROJECT_ADDON", $value, 'chaine', 0, '', $conf->entity);
206 } elseif ($action == 'setmodtask') {
207  // TODO Verifier si module numerotation choisi peut etre active
208  // par appel methode canBeActivated
209 
210  dolibarr_set_const($db, "PROJECT_TASK_ADDON", $value, 'chaine', 0, '', $conf->entity);
211 } elseif ($action == 'updateoptions') {
212  if (GETPOST('PROJECT_USE_SEARCH_TO_SELECT')) {
213  $companysearch = GETPOST('activate_PROJECT_USE_SEARCH_TO_SELECT', 'alpha');
214  if (dolibarr_set_const($db, "PROJECT_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity)) {
215  $conf->global->PROJECT_USE_SEARCH_TO_SELECT = $companysearch;
216  }
217  }
218  if (GETPOST('PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY')) {
219  $projectToSelect = GETPOST('projectToSelect', 'alpha');
220  dolibarr_set_const($db, 'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY', $projectToSelect, 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value
221  }
222  if (GETPOST('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
223  $timesheetFreezeDuration = GETPOST('timesheetFreezeDuration', 'alpha');
224  dolibarr_set_const($db, 'PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS', intval($timesheetFreezeDuration), 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value
225  }
226 } elseif (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) {
227  // Set boolean (on/off) constants
228  if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) {
229  dol_print_error($db);
230  }
231 }
232 
233 /*
234  * View
235  */
236 
237 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
238 
239 llxHeader("", $langs->trans("ProjectsSetup"));
240 
241 $form = new Form($db);
242 
243 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
244 print load_fiche_titre($langs->trans("ProjectsSetup"), $linkback, 'title_setup');
245 
247 
248 print dol_get_fiche_head($head, 'project', $langs->trans("Projects"), -1, 'project');
249 
250 
251 
252 // Main options
253 $form = new Form($db);
254 
255 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
256 print '<input type="hidden" name="token" value="'.newToken().'">';
257 print '<input type="hidden" name="action" value="setmainoptions">';
258 
259 print '<table class="noborder centpercent">';
260 print '<tr class="liste_titre">';
261 print "<td>".$langs->trans("Parameters")."</td>\n";
262 print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
263 print '<td width="80">&nbsp;</td></tr>'."\n";
264 
265 print '<tr class="oddeven">';
266 print '<td width="80%">'.$langs->trans("ManageOpportunitiesStatus").'</td>';
267 print '<td width="60" class="right">';
268 print ajax_constantonoff("PROJECT_USE_OPPORTUNITIES", null, null, 0, 0, 1);
269 print '</td><td class="right">';
270 print "</td>";
271 print '</tr>';
272 
273 
274 print '<tr class="oddeven">';
275 print '<td width="80%">'.$langs->trans("ManageTasks").'</td>';
276 print '<td width="60" class="right">';
277 print ajax_constantonoff("PROJECT_HIDE_TASKS", array(), null, 1);
278 print '</td><td class="right">';
279 print "</td>";
280 print '</tr>';
281 
282 print '</table></form>';
283 
284 print '<br>';
285 
286 
287 
288 /*
289  * Projects Numbering model
290  */
291 
292 print load_fiche_titre($langs->trans("ProjectsNumberingModules"), '', '');
293 
294 print '<table class="noborder centpercent">';
295 print '<tr class="liste_titre">';
296 print '<td width="100">'.$langs->trans("Name").'</td>';
297 print '<td>'.$langs->trans("Description").'</td>';
298 print '<td>'.$langs->trans("Example").'</td>';
299 print '<td class="center" width="60">'.$langs->trans("Activated").'</td>';
300 print '<td class="center" width="80">'.$langs->trans("ShortInfo").'</td>';
301 print "</tr>\n";
302 
303 clearstatcache();
304 
305 foreach ($dirmodels as $reldir) {
306  $dir = dol_buildpath($reldir."core/modules/project/");
307 
308  if (is_dir($dir)) {
309  $handle = opendir($dir);
310  if (is_resource($handle)) {
311  while (($file = readdir($handle)) !== false) {
312  if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) {
313  $file = $reg[1];
314  $classname = substr($file, 4);
315 
316  require_once $dir.$file.'.php';
317 
318  $module = new $file;
319 
320  // Show modules according to features level
321  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
322  continue;
323  }
324  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
325  continue;
326  }
327 
328  if ($module->isEnabled()) {
329  print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
330  print $module->info();
331  print '</td>';
332 
333  // Show example of numbering model
334  print '<td class="nowrap">';
335  $tmp = $module->getExample();
336  if (preg_match('/^Error/', $tmp)) {
337  $langs->load("errors");
338  print '<div class="error">'.$langs->trans($tmp).'</div>';
339  } elseif ($tmp == 'NotConfigured') {
340  print $langs->trans($tmp);
341  } else {
342  print $tmp;
343  }
344  print '</td>'."\n";
345 
346  print '<td class="center">';
347  if ($conf->global->PROJECT_ADDON == 'mod_'.$classname) {
348  print img_picto($langs->trans("Activated"), 'switch_on');
349  } else {
350  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
351  }
352  print '</td>';
353 
354  $project = new Project($db);
355  $project->initAsSpecimen();
356 
357  // Info
358  $htmltooltip = '';
359  $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
360  $nextval = $module->getNextValue($mysoc, $project);
361  if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
362  $htmltooltip .= ''.$langs->trans("NextValue").': ';
363  if ($nextval) {
364  $htmltooltip .= $nextval.'<br>';
365  } else {
366  $htmltooltip .= $langs->trans($module->error).'<br>';
367  }
368  }
369 
370  print '<td class="center">';
371  print $form->textwithpicto('', $htmltooltip, 1, 0);
372  print '</td>';
373 
374  print '</tr>';
375  }
376  }
377  }
378  closedir($handle);
379  }
380  }
381 }
382 
383 print '</table><br>';
384 
385 
386 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
387  // Task numbering module
388  print load_fiche_titre($langs->trans("TasksNumberingModules"), '', '');
389 
390  print '<table class="noborder centpercent">';
391  print '<tr class="liste_titre">';
392  print '<td width="100">'.$langs->trans("Name").'</td>';
393  print '<td>'.$langs->trans("Description").'</td>';
394  print '<td>'.$langs->trans("Example").'</td>';
395  print '<td class="center" width="60">'.$langs->trans("Activated").'</td>';
396  print '<td class="center" width="80">'.$langs->trans("ShortInfo").'</td>';
397  print "</tr>\n";
398 
399  clearstatcache();
400 
401  foreach ($dirmodels as $reldir) {
402  $dir = dol_buildpath($reldir."core/modules/project/task/");
403 
404  if (is_dir($dir)) {
405  $handle = opendir($dir);
406  if (is_resource($handle)) {
407  while (($file = readdir($handle)) !== false) {
408  if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) {
409  $file = $reg[1];
410  $classname = substr($file, 4);
411 
412  require_once $dir.$file.'.php';
413 
414  $module = new $file;
415 
416  // Show modules according to features level
417  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
418  continue;
419  }
420  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
421  continue;
422  }
423 
424  if ($module->isEnabled()) {
425  print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
426  print $module->info();
427  print '</td>';
428 
429  // Show example of numbering module
430  print '<td class="nowrap">';
431  $tmp = $module->getExample();
432  if (preg_match('/^Error/', $tmp)) {
433  $langs->load("errors");
434  print '<div class="error">'.$langs->trans($tmp).'</div>';
435  } elseif ($tmp == 'NotConfigured') {
436  print $langs->trans($tmp);
437  } else {
438  print $tmp;
439  }
440  print '</td>'."\n";
441 
442  print '<td class="center">';
443  if ($conf->global->PROJECT_TASK_ADDON == 'mod_'.$classname) {
444  print img_picto($langs->trans("Activated"), 'switch_on');
445  } else {
446  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodtask&token='.newToken().'&value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
447  }
448  print '</td>';
449 
450  $project = new Project($db);
451  $project->initAsSpecimen();
452 
453  // Info
454  $htmltooltip = '';
455  $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
456  $nextval = $module->getNextValue($mysoc, $project);
457  if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
458  $htmltooltip .= ''.$langs->trans("NextValue").': ';
459  if ($nextval) {
460  $htmltooltip .= $nextval.'<br>';
461  } else {
462  $htmltooltip .= $langs->trans($module->error).'<br>';
463  }
464  }
465 
466  print '<td class="center">';
467  print $form->textwithpicto('', $htmltooltip, 1, 0);
468  print '</td>';
469 
470  print '</tr>';
471  }
472  }
473  }
474  closedir($handle);
475  }
476  }
477  }
478 
479  print '</table><br>';
480 }
481 
482 
483 /*
484  * Document templates generators
485  */
486 
487 print load_fiche_titre($langs->trans("ProjectsModelModule"), '', '');
488 
489 // Defini tableau def de modele
490 $type = 'project';
491 $def = array();
492 
493 $sql = "SELECT nom";
494 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
495 $sql .= " WHERE type = '".$db->escape($type)."'";
496 $sql .= " AND entity = ".$conf->entity;
497 
498 $resql = $db->query($sql);
499 if ($resql) {
500  $i = 0;
501  $num_rows = $db->num_rows($resql);
502  while ($i < $num_rows) {
503  $array = $db->fetch_array($resql);
504  array_push($def, $array[0]);
505  $i++;
506  }
507 } else {
508  dol_print_error($db);
509 }
510 
511 print "<table class=\"noborder\" width=\"100%\">\n";
512 print "<tr class=\"liste_titre\">\n";
513 print ' <td width="100">'.$langs->trans("Name")."</td>\n";
514 print " <td>".$langs->trans("Description")."</td>\n";
515 print '<td class="center" width="60">'.$langs->trans("Activated")."</td>\n";
516 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
517 print '<td class="center" width="80">'.$langs->trans("ShortInfo").'</td>';
518 print '<td class="center" width="80">'.$langs->trans("Preview").'</td>';
519 print "</tr>\n";
520 
521 clearstatcache();
522 
523 foreach ($dirmodels as $reldir) {
524  foreach (array('', '/doc') as $valdir) {
525  $dir = dol_buildpath($reldir."core/modules/project/".$valdir);
526 
527  if (is_dir($dir)) {
528  $handle = opendir($dir);
529  if (is_resource($handle)) {
530  while (($file = readdir($handle)) !== false) {
531  $filelist[] = $file;
532  }
533  closedir($handle);
534  arsort($filelist);
535 
536  foreach ($filelist as $file) {
537  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
538  if (file_exists($dir.'/'.$file)) {
539  $name = substr($file, 4, dol_strlen($file) - 16);
540  $classname = substr($file, 0, dol_strlen($file) - 12);
541 
542  require_once $dir.'/'.$file;
543  $module = new $classname($db);
544 
545  $modulequalified = 1;
546  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
547  $modulequalified = 0;
548  }
549  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
550  $modulequalified = 0;
551  }
552 
553  if ($modulequalified) {
554  print '<tr class="oddeven"><td width="100">';
555  print (empty($module->name) ? $name : $module->name);
556  print "</td><td>\n";
557  if (method_exists($module, 'info')) {
558  print $module->info($langs);
559  } else {
560  print $module->description;
561  }
562  print "</td>\n";
563 
564  // Active
565  if (in_array($name, $def)) {
566  print "<td class=\"center\">\n";
567  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">';
568  print img_picto($langs->trans("Enabled"), 'switch_on');
569  print '</a>';
570  print "</td>";
571  } else {
572  print "<td class=\"center\">\n";
573  print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
574  print "</td>";
575  }
576 
577  // Default
578  print "<td class=\"center\">";
579  if ($conf->global->PROJECT_ADDON_PDF == "$name") {
580  print img_picto($langs->trans("Default"), 'on');
581  } else {
582  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
583  }
584  print '</td>';
585 
586  // Info
587  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
588  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
589  if ($module->type == 'pdf') {
590  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
591  }
592  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
593  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
594 
595  print '<td class="center">';
596  print $form->textwithpicto('', $htmltooltip, 1, 0);
597  print '</td>';
598 
599  // Preview
600  print '<td class="center">';
601  if ($module->type == 'pdf') {
602  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
603  } else {
604  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
605  }
606  print '</td>';
607 
608  print "</tr>\n";
609  }
610  }
611  }
612  }
613  }
614  }
615  }
616 }
617 
618 print '</table><br>';
619 
620 
621 
622 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
623  /*
624  * Modeles documents for Task
625  */
626 
627  print load_fiche_titre($langs->trans("TaskModelModule"), '', '');
628 
629  // Defini tableau def de modele
630  $type = 'project_task';
631  $def = array();
632 
633  $sql = "SELECT nom";
634  $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
635  $sql .= " WHERE type = '".$db->escape($type)."'";
636  $sql .= " AND entity = ".$conf->entity;
637 
638  $resql = $db->query($sql);
639  if ($resql) {
640  $i = 0;
641  $num_rows = $db->num_rows($resql);
642  while ($i < $num_rows) {
643  $array = $db->fetch_array($resql);
644  array_push($def, $array[0]);
645  $i++;
646  }
647  } else {
648  dol_print_error($db);
649  }
650 
651  print "<table class=\"noborder\" width=\"100%\">\n";
652  print "<tr class=\"liste_titre\">\n";
653  print ' <td width="100">'.$langs->trans("Name")."</td>\n";
654  print " <td>".$langs->trans("Description")."</td>\n";
655  print '<td class="center" width="60">'.$langs->trans("Activated")."</td>\n";
656  print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
657  print '<td class="center" width="80">'.$langs->trans("ShortInfo").'</td>';
658  print '<td class="center" width="80">'.$langs->trans("Preview").'</td>';
659  print "</tr>\n";
660 
661  clearstatcache();
662 
663  foreach ($dirmodels as $reldir) {
664  foreach (array('', '/doc') as $valdir) {
665  $dir = dol_buildpath($reldir."core/modules/project/task/".$valdir);
666 
667  if (is_dir($dir)) {
668  $handle = opendir($dir);
669  if (is_resource($handle)) {
670  while (($file = readdir($handle)) !== false) {
671  $filelist[] = $file;
672  }
673  closedir($handle);
674  arsort($filelist);
675 
676  foreach ($filelist as $file) {
677  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
678  if (file_exists($dir.'/'.$file)) {
679  $name = substr($file, 4, dol_strlen($file) - 16);
680  $classname = substr($file, 0, dol_strlen($file) - 12);
681 
682  require_once $dir.'/'.$file;
683  $module = new $classname($db);
684 
685  $modulequalified = 1;
686  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
687  $modulequalified = 0;
688  }
689  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
690  $modulequalified = 0;
691  }
692 
693  if ($modulequalified) {
694  print '<tr class="oddeven"><td width="100">';
695  print (empty($module->name) ? $name : $module->name);
696  print "</td><td>\n";
697  if (method_exists($module, 'info')) {
698  print $module->info($langs);
699  } else {
700  print $module->description;
701  }
702  print "</td>\n";
703 
704  // Active
705  if (in_array($name, $def)) {
706  print "<td class=\"center\">\n";
707  print '<a href="'.$_SERVER["PHP_SELF"].'?action=deltask&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">';
708  print img_picto($langs->trans("Enabled"), 'switch_on');
709  print '</a>';
710  print "</td>";
711  } else {
712  print "<td class=\"center\">\n";
713  print '<a href="'.$_SERVER["PHP_SELF"].'?action=settask&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
714  print "</td>";
715  }
716 
717  // Defaut
718  print "<td class=\"center\">";
719  if ($conf->global->PROJECT_TASK_ADDON_PDF == "$name") {
720  print img_picto($langs->trans("Default"), 'on');
721  } else {
722  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoctask&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
723  }
724  print '</td>';
725 
726  // Info
727  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
728  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
729  if ($module->type == 'pdf') {
730  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
731  }
732  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
733  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
734 
735  print '<td class="center">';
736  print $form->textwithpicto('', $htmltooltip, 1, 0);
737  print '</td>';
738 
739  // Preview
740  print '<td class="center">';
741  if ($module->type == 'pdf') {
742  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimentask&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
743  } else {
744  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
745  }
746  print '</td>';
747  print "</tr>\n";
748  }
749  }
750  }
751  }
752  }
753  }
754  }
755  }
756 
757  print '</table><br>';
758 }
759 
760 
761 print load_fiche_titre($langs->trans("Other"), '', '');
762 
763 // Other options
764 $form = new Form($db);
765 
766 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
767 print '<input type="hidden" name="token" value="'.newToken().'">';
768 print '<input type="hidden" name="action" value="updateoptions">';
769 print '<input type="hidden" name="page_y" value="">';
770 
771 print '<table class="noborder centpercent">';
772 print '<tr class="liste_titre">';
773 print "<td>".$langs->trans("Parameters")."</td>\n";
774 print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
775 print '<td width="80">&nbsp;</td></tr>'."\n";
776 
777 print '<tr class="oddeven">';
778 print '<td width="80%">'.$langs->trans("UseSearchToSelectProject").'</td>';
779 if (!$conf->use_javascript_ajax) {
780  print '<td class="nowrap right" colspan="2">';
781  print $langs->trans("NotAvailableWhenAjaxDisabled");
782  print "</td>";
783 } else {
784  print '<td width="60" class="right">';
785  $arrval = array('0'=>$langs->trans("No"),
786  '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
787  '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
788  '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
789  );
790  print $form->selectarray("activate_PROJECT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
791  print '</td><td class="right">';
792  print '<input type="submit" class="button small reposition" name="PROJECT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
793  print "</td>";
794 }
795 print '</tr>';
796 
797 print '<tr class="oddeven">';
798 print '<td>'.$langs->trans("AllowToSelectProjectFromOtherCompany").'</td>';
799 
800 print '<td class="right" width="60" colspan="2">';
801 print '<input type="text" id="projectToSelect" name="projectToSelect" value="'.$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.'"/>&nbsp;';
802 print $form->textwithpicto('', $langs->trans('AllowToLinkFromOtherCompany'));
803 print '<input type="submit" class="button small reposition" name="PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY" value="'.$langs->trans("Modify").'">';
804 print '</td>';
805 print '</tr>';
806 
807 $key = 'PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE';
808 echo '<tr class="oddeven">',
809  '<td class="left">',
810  $form->textwithpicto($langs->transnoentities($key), $langs->transnoentities($key . '_help')),
811  '</td>',
812  '<td class="right" colspan="2">',
813  ajax_constantonoff($key),
814  '</td>',
815  '</tr>';
816 
817 print '<tr class="oddeven">';
818 print '<td>'.$langs->trans("TimesheetPreventAfterFollowingMonths").'</td>';
819 
820 print '<td class="right" width="60" colspan="2">';
821 print '<input type="number" class="width50" id="timesheetFreezeDuration" name="timesheetFreezeDuration" min="0" step="1" value="'.$conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS.'"/>&nbsp;';
822 print '<input type="submit" class="button small reposition" name="PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS" value="'.$langs->trans("Modify").'">';
823 print '</td>';
824 print '</tr>';
825 print '</table>';
826 
827 
828 print '</form>';
829 
830 // End of page
831 llxFooter();
832 $db->close();
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6491
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
project_admin_prepare_head
project_admin_prepare_head()
Prepare array with list of tabs.
Definition: project.lib.php:488
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:552
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
delDocumentModel
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1894
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='')
On/off button for constant.
Definition: ajax.lib.php:573
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3747
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dolibarr_set_const
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:627
addDocumentModel
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1863
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4211
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
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 ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59