eventorganization.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. <?php
  2. /* Copyright (C) 2021 Florian Henry <florian.henry@scopen.fr>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/admin/setup.php
  19. * \ingroup eventorganization
  20. * \brief EventOrganization setup page.
  21. */
  22. // Load Dolibarr environment
  23. require '../main.inc.php';
  24. global $langs, $user;
  25. // Libraries
  26. require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/eventorganization.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  29. // Translations
  30. $langs->loadLangs(array("admin", "eventorganization"));
  31. // Parameters
  32. $action = GETPOST('action', 'aZ09');
  33. $cancel = GETPOST('cancel', 'aZ09');
  34. $backtopage = GETPOST('backtopage', 'alpha');
  35. $value = GETPOST('value', 'alpha');
  36. $label = GETPOST('label', 'alpha');
  37. $scandir = GETPOST('scan_dir', 'alpha');
  38. $type = 'myobject';
  39. $arrayofparameters = array(
  40. 'EVENTORGANIZATION_TASK_LABEL'=>array('type'=>'textarea','enabled'=>1),
  41. 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
  42. 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
  43. 'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
  44. 'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1),
  45. 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
  46. 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
  47. 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
  48. 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
  49. 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
  50. 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
  51. 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1),
  52. 'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1),
  53. 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1),
  54. );
  55. $error = 0;
  56. $setupnotempty = 0;
  57. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  58. // Access control
  59. if (empty($user->admin)) {
  60. accessforbidden();
  61. }
  62. /*
  63. * Actions
  64. */
  65. if ($cancel) {
  66. $action ='';
  67. }
  68. if ((float) DOL_VERSION >= 6) {
  69. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  70. }
  71. if ($action == 'updateMask') {
  72. $maskconstorder = GETPOST('maskconstorder', 'alpha');
  73. $maskorder = GETPOST('maskorder', 'alpha');
  74. if ($maskconstorder) {
  75. $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
  76. if (!($res > 0)) {
  77. $error++;
  78. }
  79. }
  80. if (!$error) {
  81. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  82. } else {
  83. setEventMessages($langs->trans("Error"), null, 'errors');
  84. }
  85. } elseif ($action == 'specimen') {
  86. $modele = GETPOST('module', 'alpha');
  87. $tmpobjectkey = GETPOST('object');
  88. $tmpobject = new $tmpobjectkey($db);
  89. $tmpobject->initAsSpecimen();
  90. // Search template files
  91. $file = ''; $classname = ''; $filefound = 0;
  92. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  93. foreach ($dirmodels as $reldir) {
  94. $file = dol_buildpath($reldir."core/modules/eventorganization/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
  95. if (file_exists($file)) {
  96. $filefound = 1;
  97. $classname = "pdf_".$modele;
  98. break;
  99. }
  100. }
  101. if ($filefound) {
  102. require_once $file;
  103. $module = new $classname($db);
  104. if ($module->write_file($tmpobject, $langs) > 0) {
  105. header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
  106. return;
  107. } else {
  108. setEventMessages($module->error, null, 'errors');
  109. dol_syslog($module->error, LOG_ERR);
  110. }
  111. } else {
  112. setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
  113. dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
  114. }
  115. } elseif ($action == 'setmod') {
  116. // TODO Check if numbering module chosen can be activated by calling method canBeActivated
  117. $tmpobjectkey = GETPOST('object');
  118. if (!empty($tmpobjectkey)) {
  119. $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey)."_ADDON";
  120. dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
  121. }
  122. } elseif ($action == 'set') {
  123. // Activate a model
  124. $ret = addDocumentModel($value, $type, $label, $scandir);
  125. } elseif ($action == 'del') {
  126. $ret = delDocumentModel($value, $type);
  127. if ($ret > 0) {
  128. $tmpobjectkey = GETPOST('object');
  129. if (!empty($tmpobjectkey)) {
  130. $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
  131. if ($conf->global->$constforval == "$value") {
  132. dolibarr_del_const($db, $constforval, $conf->entity);
  133. }
  134. }
  135. }
  136. }/* elseif ($action == 'setdoc') {
  137. // Set or unset default model
  138. $tmpobjectkey = GETPOST('object');
  139. if (!empty($tmpobjectkey)) {
  140. $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
  141. if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
  142. // The constant that was read before the new set
  143. // We therefore requires a variable to have a coherent view
  144. $conf->global->$constforval = $value;
  145. }
  146. // We disable/enable the document template (into llx_document_model table)
  147. $ret = delDocumentModel($value, $type);
  148. if ($ret > 0) {
  149. $ret = addDocumentModel($value, $type, $label, $scandir);
  150. }
  151. }
  152. } elseif ($action == 'unsetdoc') {
  153. $tmpobjectkey = GETPOST('object');
  154. if (!empty($tmpobjectkey)) {
  155. $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
  156. dolibarr_del_const($db, $constforval, $conf->entity);
  157. }
  158. }*/
  159. /*
  160. * View
  161. */
  162. $form = new Form($db);
  163. $page_name = "EventOrganizationSetup";
  164. llxHeader('', $langs->trans($page_name));
  165. // Subheader
  166. $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
  167. print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
  168. // Configuration header
  169. $head = eventorganizationAdminPrepareHead();
  170. print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, 'eventorganization');
  171. // Setup page goes here
  172. echo '<span class="opacitymedium">'.$langs->trans("EventOrganizationSetupPage").'</span><br><br>';
  173. if ($action == 'edit') {
  174. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  175. print '<input type="hidden" name="token" value="'.newToken().'">';
  176. print '<input type="hidden" name="action" value="update">';
  177. print '<table class="noborder centpercent">';
  178. print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  179. foreach ($arrayofparameters as $constname => $val) {
  180. if ($val['enabled']==1) {
  181. $setupnotempty++;
  182. print '<tr class="oddeven"><td>';
  183. $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
  184. print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
  185. print '</td><td>';
  186. if ($val['type'] == 'textarea') {
  187. print '<textarea class="flat" name="'.$constname.'" id="'.$constname.'" cols="50" rows="5" wrap="soft">' . "\n";
  188. print $conf->global->{$constname};
  189. print "</textarea>\n";
  190. } elseif ($val['type']== 'html') {
  191. require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
  192. $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
  193. $doleditor->Create();
  194. } elseif ($val['type'] == 'yesno') {
  195. print $form->selectyesno($constname, $conf->global->{$constname}, 1);
  196. } elseif (preg_match('/emailtemplate:/', $val['type'])) {
  197. include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
  198. $formmail = new FormMail($db);
  199. $tmp = explode(':', $val['type']);
  200. $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
  201. //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
  202. $arrayofmessagename = array();
  203. if (is_array($formmail->lines_model)) {
  204. foreach ($formmail->lines_model as $modelmail) {
  205. //var_dump($modelmail);
  206. $moreonlabel = '';
  207. if (!empty($arrayofmessagename[$modelmail->label])) {
  208. $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
  209. }
  210. // The 'label' is the key that is unique if we exclude the language
  211. $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel;
  212. }
  213. }
  214. print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
  215. } elseif (preg_match('/category:/', $val['type'])) {
  216. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  217. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  218. $formother = new FormOther($db);
  219. $tmp = explode(':', $val['type']);
  220. print img_picto('', 'category', 'class="pictofixedwidth"');
  221. print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
  222. } elseif (preg_match('/thirdparty_type/', $val['type'])) {
  223. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  224. $formcompany = new FormCompany($db);
  225. print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname, 'customerorprospect', 'form', '', 1);
  226. } elseif ($val['type'] == 'securekey') {
  227. print '<input required="required" type="text" class="flat" id="'.$constname.'" name="'.$constname.'" value="'.(GETPOST($constname, 'alpha') ?GETPOST($constname, 'alpha') : $conf->global->{$constname}).'" size="40">';
  228. if (!empty($conf->use_javascript_ajax)) {
  229. print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
  230. }
  231. if (!empty($conf->use_javascript_ajax)) {
  232. print "\n".'<script type="text/javascript">';
  233. print '$(document).ready(function () {
  234. $("#generate_token'.$constname.'").click(function() {
  235. $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
  236. action: \'getrandompassword\',
  237. generic: true
  238. },
  239. function(token) {
  240. $("#'.$constname.'").val(token);
  241. });
  242. });
  243. });';
  244. print '</script>';
  245. }
  246. } elseif ($val['type'] == 'product') {
  247. if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
  248. $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
  249. $form->select_produits($selected, $constname, '', 0);
  250. }
  251. } else {
  252. print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . $conf->global->{$constname} . '">';
  253. }
  254. print '</td></tr>';
  255. }
  256. }
  257. print '</table>';
  258. print '<br><div class="center">';
  259. print '<input class="button button-save" type="submit" name="save" value="'.$langs->trans("Save").'">';
  260. print ' &nbsp; ';
  261. print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
  262. print '</div>';
  263. print '</form>';
  264. print '<br>';
  265. } else {
  266. if (!empty($arrayofparameters)) {
  267. print '<table class="noborder centpercent">';
  268. print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  269. foreach ($arrayofparameters as $constname => $val) {
  270. if ($val['enabled']==1) {
  271. $setupnotempty++;
  272. print '<tr class="oddeven"><td>';
  273. $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
  274. print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
  275. print '</td><td>';
  276. if ($val['type'] == 'textarea') {
  277. print dol_nl2br($conf->global->{$constname});
  278. } elseif ($val['type']== 'html') {
  279. print $conf->global->{$constname};
  280. } elseif ($val['type'] == 'yesno') {
  281. print ajax_constantonoff($constname);
  282. } elseif (preg_match('/emailtemplate:/', $val['type'])) {
  283. if (!empty($conf->global->{$constname})) {
  284. include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
  285. $formmail = new FormMail($db);
  286. $tmp = explode(':', $val['type']);
  287. $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
  288. if ($template < 0) {
  289. setEventMessages(null, $formmail->errors, 'errors');
  290. }
  291. print $langs->trans($template->label);
  292. }
  293. } elseif (preg_match('/category:/', $val['type'])) {
  294. if (!empty($conf->global->{$constname})) {
  295. $c = new Categorie($db);
  296. $result = $c->fetch($conf->global->{$constname});
  297. if ($result < 0) {
  298. setEventMessages(null, $c->errors, 'errors');
  299. }
  300. $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
  301. $toprint = array();
  302. foreach ($ways as $way) {
  303. $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
  304. }
  305. print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
  306. }
  307. } elseif (preg_match('/thirdparty_type/', $val['type'])) {
  308. if ($conf->global->{$constname}==2) {
  309. print $langs->trans("Prospect");
  310. } elseif ($conf->global->{$constname}==3) {
  311. print $langs->trans("ProspectCustomer");
  312. } elseif ($conf->global->{$constname}==1) {
  313. print $langs->trans("Customer");
  314. } elseif ($conf->global->{$constname}==0) {
  315. print $langs->trans("NorProspectNorCustomer");
  316. }
  317. } elseif ($val['type'] == 'product') {
  318. $product = new Product($db);
  319. $resprod = $product->fetch($conf->global->{$constname});
  320. if ($resprod > 0) {
  321. print $product->getNomUrl(1);
  322. } elseif ($resprod < 0) {
  323. setEventMessages(null, $object->errors, "errors");
  324. }
  325. } else {
  326. print $conf->global->{$constname};
  327. }
  328. print '</td></tr>';
  329. }
  330. }
  331. print '</table>';
  332. print '<div class="tabsAction">';
  333. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
  334. print '</div>';
  335. } else {
  336. print '<br>'.$langs->trans("NothingToSetup");
  337. }
  338. }
  339. /*$moduledir = 'eventorganization';
  340. $myTmpObjects = array();
  341. $myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
  342. foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
  343. if ($myTmpObjectKey == 'MyObject') {
  344. continue;
  345. }
  346. if ($myTmpObjectArray['includerefgeneration']) {
  347. $setupnotempty++;
  348. print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
  349. print '<table class="noborder centpercent">';
  350. print '<tr class="liste_titre">';
  351. print '<td>'.$langs->trans("Name").'</td>';
  352. print '<td>'.$langs->trans("Description").'</td>';
  353. print '<td class="nowrap">'.$langs->trans("Example").'</td>';
  354. print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
  355. print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
  356. print '</tr>'."\n";
  357. clearstatcache();
  358. foreach ($dirmodels as $reldir) {
  359. $dir = dol_buildpath($reldir."core/modules/".$moduledir);
  360. if (is_dir($dir)) {
  361. $handle = opendir($dir);
  362. if (is_resource($handle)) {
  363. while (($file = readdir($handle)) !== false) {
  364. if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
  365. $file = substr($file, 0, dol_strlen($file) - 4);
  366. require_once $dir.'/'.$file.'.php';
  367. $module = new $file($db);
  368. // Show modules according to features level
  369. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  370. continue;
  371. }
  372. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  373. continue;
  374. }
  375. if ($module->isEnabled()) {
  376. dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
  377. print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
  378. print $module->info();
  379. print '</td>';
  380. // Show example of numbering model
  381. print '<td class="nowrap">';
  382. $tmp = $module->getExample();
  383. if (preg_match('/^Error/', $tmp)) {
  384. $langs->load("errors");
  385. print '<div class="error">'.$langs->trans($tmp).'</div>';
  386. } elseif ($tmp == 'NotConfigured') {
  387. print $langs->trans($tmp);
  388. } else {
  389. print $tmp;
  390. }
  391. print '</td>'."\n";
  392. print '<td class="center">';
  393. $constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
  394. if ($conf->global->$constforvar == $file) {
  395. print img_picto($langs->trans("Activated"), 'switch_on');
  396. } else {
  397. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
  398. print img_picto($langs->trans("Disabled"), 'switch_off');
  399. print '</a>';
  400. }
  401. print '</td>';
  402. $mytmpinstance = new $myTmpObjectKey($db);
  403. $mytmpinstance->initAsSpecimen();
  404. // Info
  405. $htmltooltip = '';
  406. $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
  407. $nextval = $module->getNextValue($mytmpinstance);
  408. if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
  409. $htmltooltip .= ''.$langs->trans("NextValue").': ';
  410. if ($nextval) {
  411. if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
  412. $nextval = $langs->trans($nextval);
  413. }
  414. $htmltooltip .= $nextval.'<br>';
  415. } else {
  416. $htmltooltip .= $langs->trans($module->error).'<br>';
  417. }
  418. }
  419. print '<td class="center">';
  420. print $form->textwithpicto('', $htmltooltip, 1, 0);
  421. print '</td>';
  422. print "</tr>\n";
  423. }
  424. }
  425. }
  426. closedir($handle);
  427. }
  428. }
  429. }
  430. print "</table><br>\n";
  431. }
  432. if ($myTmpObjectArray['includedocgeneration']) {
  433. $setupnotempty++;
  434. $type = strtolower($myTmpObjectKey);
  435. print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
  436. // Load array def with activated templates
  437. $def = array();
  438. $sql = "SELECT nom";
  439. $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
  440. $sql .= " WHERE type = '".$db->escape($type)."'";
  441. $sql .= " AND entity = ".$conf->entity;
  442. $resql = $db->query($sql);
  443. if ($resql) {
  444. $i = 0;
  445. $num_rows = $db->num_rows($resql);
  446. while ($i < $num_rows) {
  447. $array = $db->fetch_array($resql);
  448. array_push($def, $array[0]);
  449. $i++;
  450. }
  451. } else {
  452. dol_print_error($db);
  453. }
  454. print "<table class=\"noborder\" width=\"100%\">\n";
  455. print "<tr class=\"liste_titre\">\n";
  456. print '<td>'.$langs->trans("Name").'</td>';
  457. print '<td>'.$langs->trans("Description").'</td>';
  458. print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
  459. print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
  460. print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
  461. print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
  462. print "</tr>\n";
  463. clearstatcache();
  464. foreach ($dirmodels as $reldir) {
  465. foreach (array('', '/doc') as $valdir) {
  466. $realpath = $reldir."core/modules/".$moduledir.$valdir;
  467. $dir = dol_buildpath($realpath);
  468. if (is_dir($dir)) {
  469. $handle = opendir($dir);
  470. if (is_resource($handle)) {
  471. while (($file = readdir($handle)) !== false) {
  472. $filelist[] = $file;
  473. }
  474. closedir($handle);
  475. arsort($filelist);
  476. foreach ($filelist as $file) {
  477. if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
  478. if (file_exists($dir.'/'.$file)) {
  479. $name = substr($file, 4, dol_strlen($file) - 16);
  480. $classname = substr($file, 0, dol_strlen($file) - 12);
  481. require_once $dir.'/'.$file;
  482. $module = new $classname($db);
  483. $modulequalified = 1;
  484. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  485. $modulequalified = 0;
  486. }
  487. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  488. $modulequalified = 0;
  489. }
  490. if ($modulequalified) {
  491. print '<tr class="oddeven"><td width="100">';
  492. print (empty($module->name) ? $name : $module->name);
  493. print "</td><td>\n";
  494. if (method_exists($module, 'info')) {
  495. print $module->info($langs);
  496. } else {
  497. print $module->description;
  498. }
  499. print '</td>';
  500. // Active
  501. if (in_array($name, $def)) {
  502. print '<td class="center">'."\n";
  503. print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
  504. print img_picto($langs->trans("Enabled"), 'switch_on');
  505. print '</a>';
  506. print '</td>';
  507. } else {
  508. print '<td class="center">'."\n";
  509. print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.urlencode($module->scandir).'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
  510. print "</td>";
  511. }
  512. // Default
  513. print '<td class="center">';
  514. $constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
  515. if ($conf->global->$constforvar == $name) {
  516. //print img_picto($langs->trans("Default"), 'on');
  517. // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
  518. print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  519. } else {
  520. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.urlencode($module->scandir).'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  521. }
  522. print '</td>';
  523. // Info
  524. $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
  525. $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
  526. if ($module->type == 'pdf') {
  527. $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
  528. }
  529. $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
  530. $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  531. $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
  532. $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
  533. print '<td class="center">';
  534. print $form->textwithpicto('', $htmltooltip, 1, 0);
  535. print '</td>';
  536. // Preview
  537. print '<td class="center">';
  538. if ($module->type == 'pdf') {
  539. print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
  540. } else {
  541. print img_object($langs->trans("PreviewNotAvailable"), 'generic');
  542. }
  543. print '</td>';
  544. print "</tr>\n";
  545. }
  546. }
  547. }
  548. }
  549. }
  550. }
  551. }
  552. }
  553. print '</table>';
  554. }
  555. }
  556. */
  557. // Page end
  558. print dol_get_fiche_end();
  559. llxFooter();
  560. $db->close();