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