project.php 27 KB

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