project.php 28 KB

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