project.php 28 KB

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