eventorganization.php 26 KB

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