dolibarr 21.0.0-alpha
eventorganization.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2021 Florian Henry <florian.henry@scopen.fr>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
26require '../main.inc.php';
27
28global $langs, $user;
29
30// Libraries
31require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
32require_once DOL_DOCUMENT_ROOT.'/core/lib/eventorganization.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
34
35// Translations
36$langs->loadLangs(array("admin", "eventorganization", "categories"));
37
38// Parameters
39$action = GETPOST('action', 'aZ09');
40$cancel = GETPOST('cancel', 'aZ09');
41$backtopage = GETPOST('backtopage', 'alpha');
42
43$value = GETPOST('value', 'alpha');
44$label = GETPOST('label', 'alpha');
45$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
46
47$scandir = GETPOST('scan_dir', 'alpha');
48$type = 'myobject';
49
50$arrayofparameters = array(
51 'EVENTORGANIZATION_TASK_LABEL' => array('type' => 'textarea','enabled' => 1, 'css' => ''),
52 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1, 'css' => ''),
53 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1, 'css' => ''),
54 'EVENTORGANIZATION_FILTERATTENDEES_CAT' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1, 'css' => ''),
55 'EVENTORGANIZATION_FILTERATTENDEES_TYPE' => array('type' => 'thirdparty_type:', 'enabled' => 1, 'css' => ''),
56 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
57 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
58 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
59 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
60 //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1, 'css' => ''),
61 //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1, 'css' => ''),
62 'SERVICE_BOOTH_LOCATION' => array('type' => 'product', 'enabled' => 1, 'css' => ''),
63 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION' => array('type' => 'product', 'enabled' => 1, 'css' => ''),
64 'EVENTORGANIZATION_SECUREKEY' => array('type' => 'securekey', 'enabled' => 1, 'css' => ''),
65);
66
67$error = 0;
68$setupnotempty = 0;
69
70$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
71
72// Access control
73if (empty($user->admin)) {
75}
76
77
78
79/*
80 * Actions
81 */
82
83if ($cancel) {
84 $action = '';
85}
86
87include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
88
89if ($action == 'updateMask') {
90 $maskconstorder = GETPOST('maskconstorder', 'aZ09');
91 $maskorder = GETPOST('maskorder', 'alpha');
92
93 if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) {
94 $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
95 if (!($res > 0)) {
96 $error++;
97 }
98 }
99
100 if (!$error) {
101 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
102 } else {
103 setEventMessages($langs->trans("Error"), null, 'errors');
104 }
105} elseif ($action == 'setmod') {
106 // TODO Check if numbering module chosen can be activated by calling method canBeActivated
107 $tmpobjectkey = GETPOST('object', 'aZ09');
108 if (!empty($tmpobjectkey)) {
109 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey)."_ADDON";
110 dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
111 }
112} elseif ($action == 'set') {
113 // Activate a model
114 $ret = addDocumentModel($value, $type, $label, $scandir);
115} elseif ($action == 'del') {
116 $ret = delDocumentModel($value, $type);
117 if ($ret > 0) {
118 $tmpobjectkey = GETPOST('object', 'aZ09');
119 if (!empty($tmpobjectkey)) {
120 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
121 if (getDolGlobalString($constforval) == "$value") {
122 dolibarr_del_const($db, $constforval, $conf->entity);
123 }
124 }
125 }
126}/* elseif ($action == 'setdoc') {
127 // Set or unset default model
128 $tmpobjectkey = GETPOST('object', 'aZ09');
129 if (!empty($tmpobjectkey)) {
130 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
131 if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
132 // The constant that was read before the new set
133 // We therefore requires a variable to have a coherent view
134 $conf->global->$constforval = $value;
135 }
136
137 // We disable/enable the document template (into llx_document_model table)
138 $ret = delDocumentModel($value, $type);
139 if ($ret > 0) {
140 $ret = addDocumentModel($value, $type, $label, $scandir);
141 }
142 }
143} elseif ($action == 'unsetdoc') {
144 $tmpobjectkey = GETPOST('object', 'aZ09');
145 if (!empty($tmpobjectkey)) {
146 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
147 dolibarr_del_const($db, $constforval, $conf->entity);
148 }
149}*/
150
151
152
153/*
154 * View
155 */
156
157$form = new Form($db);
158
159$page_name = "EventOrganizationSetup";
160
161llxHeader('', $langs->trans($page_name), '', '', 0, 0, '', '', '', 'mod-admin page-eventorganization');
162
163// Subheader
164$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
165
166print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
167
168// Configuration header
170print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, 'eventorganization');
171
172// Setup page goes here
173echo '<span class="opacitymedium">'.$langs->trans("EventOrganizationSetupPage").'</span><br><br>';
174
175
176if ($action == 'edit') {
177 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
178 print '<input type="hidden" name="token" value="'.newToken().'">';
179 print '<input type="hidden" name="action" value="update">';
180
181 print '<table class="noborder centpercent">';
182 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
183
184 foreach ($arrayofparameters as $constname => $val) {
185 if ($val['enabled'] == 1) {
186 $setupnotempty++;
187 print '<tr class="oddeven"><td><!-- '.$constname.' -->';
188 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
189 $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
190 print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
191 print '</td><td>';
192
193 if ($val['type'] == 'textarea') {
194 print '<textarea class="flat" name="'.$constname.'" id="'.$constname.'" cols="50" rows="5" wrap="soft">' . "\n";
195 print getDolGlobalString($constname);
196 print "</textarea>\n";
197 } elseif ($val['type'] == 'html') {
198 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
199 $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
200 $doleditor->Create();
201 } elseif ($val['type'] == 'yesno') {
202 print $form->selectyesno($constname, getDolGlobalString($constname), 1);
203 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
204 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
205 $formmail = new FormMail($db);
206
207 $tmp = explode(':', $val['type']);
208 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
209 //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
210 $arrayofmessagename = array();
211 if (is_array($formmail->lines_model)) {
212 foreach ($formmail->lines_model as $modelmail) {
213 //var_dump($modelmail);
214 $moreonlabel = '';
215 if (!empty($arrayofmessagename[$modelmail->label])) {
216 $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
217 }
218 // The 'label' is the key that is unique if we exclude the language
219 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\‍(|\‍)/', '', $modelmail->label)) . $moreonlabel;
220 }
221 }
222 print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
223 } elseif (preg_match('/category:/', $val['type'])) {
224 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
225 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
226 $formother = new FormOther($db);
227
228 $tmp = explode(':', $val['type']);
229 print img_picto('', 'category', 'class="pictofixedwidth"');
230 print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
231 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
232 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
233 $formcompany = new FormCompany($db);
234 print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname, 'customerorprospect', 'form', '', 1);
235 } elseif ($val['type'] == 'securekey') {
236 print '<input type="text" class="flat" id="'.$constname.'" name="'.$constname.'" value="'.(GETPOST($constname, 'alpha') ? GETPOST($constname, 'alpha') : getDolGlobalString($constname)).'" size="40">';
237 if (!empty($conf->use_javascript_ajax)) {
238 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
239 }
240
241 // Add button to autosuggest a key
242 include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
243 print dolJSToSetRandomPassword($constname, 'generate_token'.$constname);
244 } elseif ($val['type'] == 'product') {
245 if (isModEnabled("product") || isModEnabled("service")) {
246 $selected = getDolGlobalString($constname);
247 print img_picto('', 'product', 'class="pictofixedwidth"');
248 print $form->select_produits($selected, $constname, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, 'maxwidth500 widthcentpercentminusx', 0, '', null, 1);
249 }
250 } else {
251 print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . getDolGlobalString($constname) . '">';
252 }
253 print '</td></tr>';
254 }
255 }
256 print '</table>';
257
258 print $form->buttonsSaveCancel();
259
260 print '</form>';
261 print '<br>';
262} else {
263 if (!empty($arrayofparameters)) {
264 print '<table class="noborder centpercent">';
265 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
266
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
277 if ($val['type'] == 'textarea') {
278 print dol_nl2br(getDolGlobalString($constname));
279 } elseif ($val['type'] == 'html') {
280 print getDolGlobalString($constname);
281 } elseif ($val['type'] == 'yesno') {
282 print ajax_constantonoff($constname);
283 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
284 if (getDolGlobalString($constname)) {
285 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
286 $formmail = new FormMail($db);
287
288 $tmp = explode(':', $val['type']);
289 $labelemailtemplate = getDolGlobalString($constname);
290 if ($labelemailtemplate && $labelemailtemplate != '-1') {
291 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
292 if (is_numeric($template) && $template < 0) {
293 setEventMessages($formmail->error, $formmail->errors, 'errors');
294 } else {
295 if ($template->label != 'default') {
296 print $langs->trans($template->label);
297 }
298 }
299 }
300 }
301 } elseif (preg_match('/category:/', $val['type'])) {
302 if (getDolGlobalString($constname)) {
303 $c = new Categorie($db);
304 $result = $c->fetch(getDolGlobalString($constname));
305 if ($result < 0) {
306 setEventMessages(null, $c->errors, 'errors');
307 }
308 $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
309 $toprint = array();
310 foreach ($ways as $way) {
311 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
312 }
313 print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
314 }
315 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
316 if (getDolGlobalString($constname) == 2) {
317 print $langs->trans("Prospect");
318 } elseif (getDolGlobalString($constname) == 3) {
319 print $langs->trans("ProspectCustomer");
320 } elseif (getDolGlobalString($constname) == 1) {
321 print $langs->trans("Customer");
322 } elseif (getDolGlobalString($constname) == 0) {
323 print $langs->trans("NorProspectNorCustomer");
324 }
325 } elseif ($val['type'] == 'product') {
326 $product = new Product($db);
327 $idproduct = getDolGlobalString($constname);
328 if ($idproduct > 0) {
329 $resprod = $product->fetch($idproduct);
330 if ($resprod > 0) {
331 print $product->getNomUrl(1);
332 } elseif ($resprod < 0) {
333 setEventMessages($product->error, $product->errors, "errors");
334 }
335 }
336 } else {
337 print getDolGlobalString($constname);
338 }
339 print '</td>';
340
341 print '</tr>';
342 }
343 }
344
345 print '</table>';
346
347 print '<div class="tabsAction">';
348 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
349 print '</div>';
350 } else {
351 print '<br>'.$langs->trans("NothingToSetup");
352 }
353}
354
355
356// Page end
357print dol_get_fiche_end();
358
359llxFooter();
360$db->close();
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
delDocumentModel($name, $type)
Delete document model used by doc generator.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage categories.
Class to manage a WYSIWYG editor.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new Form...
Class permettant la generation de composants html autre Only common components are here.
Class to manage products or services.
llxFooter()
Footer empty.
Definition document.php:107
eventorganizationAdminPrepareHead()
Prepare admin pages header.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript to autoset a generated password using default module into a HTML element.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.