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/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', 'aZ09');
  74. $maskorder = GETPOST('maskorder', 'alpha');
  75. if ($maskconstorder && preg_match('/_MASK$/', $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. // Add button to autosuggest a key
  234. include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
  235. print dolJSToSetRandomPassword($constname, 'generate_token'.$constname);
  236. } elseif ($val['type'] == 'product') {
  237. if (isModEnabled("product") || isModEnabled("service")) {
  238. $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
  239. $form->select_produits($selected, $constname, '', 0);
  240. }
  241. } else {
  242. print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . getDolGlobalString($constname) . '">';
  243. }
  244. print '</td></tr>';
  245. }
  246. }
  247. print '</table>';
  248. print $form->buttonsSaveCancel();
  249. print '</form>';
  250. print '<br>';
  251. } else {
  252. if (!empty($arrayofparameters)) {
  253. print '<table class="noborder centpercent">';
  254. print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  255. foreach ($arrayofparameters as $constname => $val) {
  256. if ($val['enabled']==1) {
  257. $setupnotempty++;
  258. print '<tr class="oddeven">';
  259. print '<td><!-- '.$constname.' -->';
  260. $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
  261. $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
  262. print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
  263. print '</td><td>';
  264. if ($val['type'] == 'textarea') {
  265. print dol_nl2br(getDolGlobalString($constname));
  266. } elseif ($val['type']== 'html') {
  267. print getDolGlobalString($constname);
  268. } elseif ($val['type'] == 'yesno') {
  269. print ajax_constantonoff($constname);
  270. } elseif (preg_match('/emailtemplate:/', $val['type'])) {
  271. if (getDolGlobalString($constname)) {
  272. include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
  273. $formmail = new FormMail($db);
  274. $tmp = explode(':', $val['type']);
  275. $labelemailtemplate = getDolGlobalString($constname);
  276. if ($labelemailtemplate && $labelemailtemplate != '-1') {
  277. $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
  278. if (is_numeric($template) && $template < 0) {
  279. setEventMessages($formmail->error, $formmail->errors, 'errors');
  280. } else {
  281. if ($template->label != 'default') {
  282. print $langs->trans($template->label);
  283. }
  284. }
  285. }
  286. }
  287. } elseif (preg_match('/category:/', $val['type'])) {
  288. if (getDolGlobalString($constname)) {
  289. $c = new Categorie($db);
  290. $result = $c->fetch(getDolGlobalString($constname));
  291. if ($result < 0) {
  292. setEventMessages(null, $c->errors, 'errors');
  293. }
  294. $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
  295. $toprint = array();
  296. foreach ($ways as $way) {
  297. $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
  298. }
  299. print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
  300. }
  301. } elseif (preg_match('/thirdparty_type/', $val['type'])) {
  302. if (getDolGlobalString($constname)==2) {
  303. print $langs->trans("Prospect");
  304. } elseif (getDolGlobalString($constname)==3) {
  305. print $langs->trans("ProspectCustomer");
  306. } elseif (getDolGlobalString($constname)==1) {
  307. print $langs->trans("Customer");
  308. } elseif (getDolGlobalString($constname)==0) {
  309. print $langs->trans("NorProspectNorCustomer");
  310. }
  311. } elseif ($val['type'] == 'product') {
  312. $product = new Product($db);
  313. $idproduct = getDolGlobalString($constname);
  314. if ($idproduct > 0) {
  315. $resprod = $product->fetch($idproduct);
  316. if ($resprod > 0) {
  317. print $product->getNomUrl(1);
  318. } elseif ($resprod < 0) {
  319. setEventMessages($product->error, $product->errors, "errors");
  320. }
  321. }
  322. } else {
  323. print getDolGlobalString($constname);
  324. }
  325. print '</td>';
  326. print '</tr>';
  327. }
  328. }
  329. print '</table>';
  330. print '<div class="tabsAction">';
  331. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
  332. print '</div>';
  333. } else {
  334. print '<br>'.$langs->trans("NothingToSetup");
  335. }
  336. }
  337. /*$moduledir = 'eventorganization';
  338. $myTmpObjects = array();
  339. $myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
  340. foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
  341. if ($myTmpObjectKey == 'MyObject') {
  342. continue;
  343. }
  344. if ($myTmpObjectArray['includerefgeneration']) {
  345. $setupnotempty++;
  346. print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
  347. print '<table class="noborder centpercent">';
  348. print '<tr class="liste_titre">';
  349. print '<td>'.$langs->trans("Name").'</td>';
  350. print '<td>'.$langs->trans("Description").'</td>';
  351. print '<td class="nowrap">'.$langs->trans("Example").'</td>';
  352. print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
  353. print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
  354. print '</tr>'."\n";
  355. clearstatcache();
  356. foreach ($dirmodels as $reldir) {
  357. $dir = dol_buildpath($reldir."core/modules/".$moduledir);
  358. if (is_dir($dir)) {
  359. $handle = opendir($dir);
  360. if (is_resource($handle)) {
  361. while (($file = readdir($handle)) !== false) {
  362. if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
  363. $file = substr($file, 0, dol_strlen($file) - 4);
  364. require_once $dir.'/'.$file.'.php';
  365. $module = new $file($db);
  366. // Show modules according to features level
  367. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  368. continue;
  369. }
  370. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  371. continue;
  372. }
  373. if ($module->isEnabled()) {
  374. dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
  375. print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
  376. print $module->info();
  377. print '</td>';
  378. // Show example of numbering model
  379. print '<td class="nowrap">';
  380. $tmp = $module->getExample();
  381. if (preg_match('/^Error/', $tmp)) {
  382. $langs->load("errors");
  383. print '<div class="error">'.$langs->trans($tmp).'</div>';
  384. } elseif ($tmp == 'NotConfigured') {
  385. print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
  386. } else {
  387. print $tmp;
  388. }
  389. print '</td>'."\n";
  390. print '<td class="center">';
  391. $constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
  392. if (getDolGlobalString($constforvar) == $file) {
  393. print img_picto($langs->trans("Activated"), 'switch_on');
  394. } else {
  395. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
  396. print img_picto($langs->trans("Disabled"), 'switch_off');
  397. print '</a>';
  398. }
  399. print '</td>';
  400. $mytmpinstance = new $myTmpObjectKey($db);
  401. $mytmpinstance->initAsSpecimen();
  402. // Info
  403. $htmltooltip = '';
  404. $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
  405. $nextval = $module->getNextValue($mytmpinstance);
  406. if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
  407. $htmltooltip .= ''.$langs->trans("NextValue").': ';
  408. if ($nextval) {
  409. if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
  410. $nextval = $langs->trans($nextval);
  411. }
  412. $htmltooltip .= $nextval.'<br>';
  413. } else {
  414. $htmltooltip .= $langs->trans($module->error).'<br>';
  415. }
  416. }
  417. print '<td class="center">';
  418. print $form->textwithpicto('', $htmltooltip, 1, 0);
  419. print '</td>';
  420. print "</tr>\n";
  421. }
  422. }
  423. }
  424. closedir($handle);
  425. }
  426. }
  427. }
  428. print "</table><br>\n";
  429. }
  430. if ($myTmpObjectArray['includedocgeneration']) {
  431. $setupnotempty++;
  432. $type = strtolower($myTmpObjectKey);
  433. print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
  434. // Load array def with activated templates
  435. $def = array();
  436. $sql = "SELECT nom";
  437. $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
  438. $sql .= " WHERE type = '".$db->escape($type)."'";
  439. $sql .= " AND entity = ".$conf->entity;
  440. $resql = $db->query($sql);
  441. if ($resql) {
  442. $i = 0;
  443. $num_rows = $db->num_rows($resql);
  444. while ($i < $num_rows) {
  445. $array = $db->fetch_array($resql);
  446. array_push($def, $array[0]);
  447. $i++;
  448. }
  449. } else {
  450. dol_print_error($db);
  451. }
  452. print "<table class=\"noborder\" width=\"100%\">\n";
  453. print "<tr class=\"liste_titre\">\n";
  454. print '<td>'.$langs->trans("Name").'</td>';
  455. print '<td>'.$langs->trans("Description").'</td>';
  456. print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
  457. print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
  458. print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
  459. print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
  460. print "</tr>\n";
  461. clearstatcache();
  462. foreach ($dirmodels as $reldir) {
  463. foreach (array('', '/doc') as $valdir) {
  464. $realpath = $reldir."core/modules/".$moduledir.$valdir;
  465. $dir = dol_buildpath($realpath);
  466. if (is_dir($dir)) {
  467. $handle = opendir($dir);
  468. if (is_resource($handle)) {
  469. while (($file = readdir($handle)) !== false) {
  470. $filelist[] = $file;
  471. }
  472. closedir($handle);
  473. arsort($filelist);
  474. foreach ($filelist as $file) {
  475. if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
  476. if (file_exists($dir.'/'.$file)) {
  477. $name = substr($file, 4, dol_strlen($file) - 16);
  478. $classname = substr($file, 0, dol_strlen($file) - 12);
  479. require_once $dir.'/'.$file;
  480. $module = new $classname($db);
  481. $modulequalified = 1;
  482. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  483. $modulequalified = 0;
  484. }
  485. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  486. $modulequalified = 0;
  487. }
  488. if ($modulequalified) {
  489. print '<tr class="oddeven"><td width="100">';
  490. print (empty($module->name) ? $name : $module->name);
  491. print "</td><td>\n";
  492. if (method_exists($module, 'info')) {
  493. print $module->info($langs);
  494. } else {
  495. print $module->description;
  496. }
  497. print '</td>';
  498. // Active
  499. if (in_array($name, $def)) {
  500. print '<td class="center">'."\n";
  501. print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.$name.'">';
  502. print img_picto($langs->trans("Enabled"), 'switch_on');
  503. print '</a>';
  504. print '</td>';
  505. } else {
  506. print '<td class="center">'."\n";
  507. 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>';
  508. print "</td>";
  509. }
  510. // Default
  511. print '<td class="center">';
  512. $constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
  513. if (getDolGlobalString($constforvar) == $name) {
  514. //print img_picto($langs->trans("Default"), 'on');
  515. // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
  516. 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>';
  517. } else {
  518. 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>';
  519. }
  520. print '</td>';
  521. // Info
  522. $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
  523. $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
  524. if ($module->type == 'pdf') {
  525. $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
  526. }
  527. $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
  528. $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  529. $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
  530. $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
  531. print '<td class="center">';
  532. print $form->textwithpicto('', $htmltooltip, 1, 0);
  533. print '</td>';
  534. // Preview
  535. print '<td class="center">';
  536. if ($module->type == 'pdf') {
  537. print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
  538. } else {
  539. print img_object($langs->trans("PreviewNotAvailable"), 'generic');
  540. }
  541. print '</td>';
  542. print "</tr>\n";
  543. }
  544. }
  545. }
  546. }
  547. }
  548. }
  549. }
  550. }
  551. print '</table>';
  552. }
  553. }
  554. */
  555. // Page end
  556. print dol_get_fiche_end();
  557. llxFooter();
  558. $db->close();