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