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