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