dolibarr 21.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
28
29// Libraries
30require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
31require_once DOL_DOCUMENT_ROOT.'/core/lib/eventorganization.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
33
42// Translations
43$langs->loadLangs(array("admin", "eventorganization", "categories"));
44
45// Parameters
46$action = GETPOST('action', 'aZ09');
47$cancel = GETPOST('cancel', 'aZ09');
48$backtopage = GETPOST('backtopage', 'alpha');
49
50$value = GETPOST('value', 'alpha');
51$label = GETPOST('label', 'alpha');
52$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
53
54$scandir = GETPOST('scan_dir', 'alpha');
55$type = 'myobject';
56
57$arrayofparameters = array(
58 'EVENTORGANIZATION_TASK_LABEL' => array('type' => 'textarea','enabled' => 1, 'css' => ''),
59 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1, 'css' => ''),
60 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1, 'css' => ''),
61 'EVENTORGANIZATION_FILTERATTENDEES_CAT' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1, 'css' => ''),
62 'EVENTORGANIZATION_FILTERATTENDEES_TYPE' => array('type' => 'thirdparty_type:', 'enabled' => 1, 'css' => ''),
63 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
64 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
65 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
66 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
67 //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1, 'css' => ''),
68 //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1, 'css' => ''),
69 'SERVICE_BOOTH_LOCATION' => array('type' => 'product', 'enabled' => 1, 'css' => ''),
70 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION' => array('type' => 'product', 'enabled' => 1, 'css' => ''),
71 'EVENTORGANIZATION_SECUREKEY' => array('type' => 'securekey', 'enabled' => 1, 'css' => ''),
72);
73
74$error = 0;
75$setupnotempty = 0;
76
77$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
78
79// Access control
80if (empty($user->admin)) {
82}
83
84
85
86/*
87 * Actions
88 */
89
90if ($cancel) {
91 $action = '';
92}
93
94include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
95
96if ($action == 'updateMask') {
97 $maskconstorder = GETPOST('maskconstorder', 'aZ09');
98 $maskorder = GETPOST('maskorder', 'alpha');
99
100 if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) {
101 $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
102 if (!($res > 0)) {
103 $error++;
104 }
105 }
106
107 if (!$error) {
108 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
109 } else {
110 setEventMessages($langs->trans("Error"), null, 'errors');
111 }
112} elseif ($action == 'setmod') {
113 // TODO Check if numbering module chosen can be activated by calling method canBeActivated
114 $tmpobjectkey = GETPOST('object', 'aZ09');
115 if (!empty($tmpobjectkey)) {
116 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey)."_ADDON";
117 dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
118 }
119} elseif ($action == 'set') {
120 // Activate a model
121 $ret = addDocumentModel($value, $type, $label, $scandir);
122} elseif ($action == 'del') {
123 $ret = delDocumentModel($value, $type);
124 if ($ret > 0) {
125 $tmpobjectkey = GETPOST('object', 'aZ09');
126 if (!empty($tmpobjectkey)) {
127 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
128 if (getDolGlobalString($constforval) == "$value") {
129 dolibarr_del_const($db, $constforval, $conf->entity);
130 }
131 }
132 }
133}/* elseif ($action == 'setdoc') {
134 // Set or unset default model
135 $tmpobjectkey = GETPOST('object', 'aZ09');
136 if (!empty($tmpobjectkey)) {
137 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
138 if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
139 // The constant that was read before the new set
140 // We therefore requires a variable to have a coherent view
141 $conf->global->$constforval = $value;
142 }
143
144 // We disable/enable the document template (into llx_document_model table)
145 $ret = delDocumentModel($value, $type);
146 if ($ret > 0) {
147 $ret = addDocumentModel($value, $type, $label, $scandir);
148 }
149 }
150} elseif ($action == 'unsetdoc') {
151 $tmpobjectkey = GETPOST('object', 'aZ09');
152 if (!empty($tmpobjectkey)) {
153 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
154 dolibarr_del_const($db, $constforval, $conf->entity);
155 }
156}*/
157
158
159
160/*
161 * View
162 */
163
164$form = new Form($db);
165
166$page_name = "EventOrganizationSetup";
167
168llxHeader('', $langs->trans($page_name), '', '', 0, 0, '', '', '', 'mod-admin page-eventorganization');
169
170// Subheader
171$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
172
173print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
174
175// Configuration header
177print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, 'eventorganization');
178
179// Setup page goes here
180echo '<span class="opacitymedium">'.$langs->trans("EventOrganizationSetupPage").'</span><br><br>';
181
182
183if ($action == 'edit') {
184 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
185 print '<input type="hidden" name="token" value="'.newToken().'">';
186 print '<input type="hidden" name="action" value="update">';
187
188 print '<table class="noborder centpercent">';
189 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
190
191 foreach ($arrayofparameters as $constname => $val) {
192 if ($val['enabled'] == 1) {
193 $setupnotempty++;
194 print '<tr class="oddeven"><td><!-- '.$constname.' -->';
195 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
196 $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
197 print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
198 print '</td><td>';
199
200 if ($val['type'] == 'textarea') {
201 print '<textarea class="flat" name="'.$constname.'" id="'.$constname.'" cols="50" rows="5" wrap="soft">' . "\n";
202 print getDolGlobalString($constname);
203 print "</textarea>\n";
204 } elseif ($val['type'] == 'html') {
205 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
206 $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
207 $doleditor->Create();
208 } elseif ($val['type'] == 'yesno') {
209 print $form->selectyesno($constname, getDolGlobalString($constname), 1);
210 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
211 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
212 $formmail = new FormMail($db);
213
214 $tmp = explode(':', $val['type']);
215 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
216 //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
217 $arrayofmessagename = array();
218 if (is_array($formmail->lines_model)) {
219 foreach ($formmail->lines_model as $modelmail) {
220 //var_dump($modelmail);
221 $moreonlabel = '';
222 if (!empty($arrayofmessagename[$modelmail->label])) {
223 $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
224 }
225 // The 'label' is the key that is unique if we exclude the language
226 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\‍(|\‍)/', '', $modelmail->label)) . $moreonlabel;
227 }
228 }
229 print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
230 } elseif (preg_match('/category:/', $val['type'])) {
231 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
232 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
233 $formother = new FormOther($db);
234
235 $tmp = explode(':', $val['type']);
236 print img_picto('', 'category', 'class="pictofixedwidth"');
237 print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
238 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
239 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
240 $formcompany = new FormCompany($db);
241 print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname, 'customerorprospect', 'form', '', 1);
242 } elseif ($val['type'] == 'securekey') {
243 print '<input type="text" class="flat" id="'.$constname.'" name="'.$constname.'" value="'.(GETPOST($constname, 'alpha') ? GETPOST($constname, 'alpha') : getDolGlobalString($constname)).'" size="40">';
244 if (!empty($conf->use_javascript_ajax)) {
245 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
246 }
247
248 // Add button to autosuggest a key
249 include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
250 print dolJSToSetRandomPassword($constname, 'generate_token'.$constname);
251 } elseif ($val['type'] == 'product') {
252 if (isModEnabled("product") || isModEnabled("service")) {
253 $selected = getDolGlobalString($constname);
254 print img_picto('', 'product', 'class="pictofixedwidth"');
255 print $form->select_produits($selected, $constname, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, 'maxwidth500 widthcentpercentminusx', 0, '', null, 1);
256 }
257 } else {
258 print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . getDolGlobalString($constname) . '">';
259 }
260 print '</td></tr>';
261 }
262 }
263 print '</table>';
264
265 print $form->buttonsSaveCancel();
266
267 print '</form>';
268 print '<br>';
269} else {
270 if (!empty($arrayofparameters)) {
271 print '<table class="noborder centpercent">';
272 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
273
274 foreach ($arrayofparameters as $constname => $val) {
275 if ($val['enabled'] == 1) {
276 $setupnotempty++;
277 print '<tr class="oddeven">';
278 print '<td><!-- '.$constname.' -->';
279 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
280 $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
281 print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
282 print '</td><td>';
283
284 if ($val['type'] == 'textarea') {
285 print dol_nl2br(getDolGlobalString($constname));
286 } elseif ($val['type'] == 'html') {
287 print getDolGlobalString($constname);
288 } elseif ($val['type'] == 'yesno') {
289 print ajax_constantonoff($constname);
290 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
291 if (getDolGlobalString($constname)) {
292 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
293 $formmail = new FormMail($db);
294
295 $tmp = explode(':', $val['type']);
296 $labelemailtemplate = getDolGlobalString($constname);
297 if ($labelemailtemplate && $labelemailtemplate != '-1') {
298 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
299 if (is_numeric($template) && $template < 0) {
300 setEventMessages($formmail->error, $formmail->errors, 'errors');
301 } else {
302 if ($template->label != 'default') {
303 print $langs->trans($template->label);
304 }
305 }
306 }
307 }
308 } elseif (preg_match('/category:/', $val['type'])) {
309 if (getDolGlobalString($constname)) {
310 $c = new Categorie($db);
311 $result = $c->fetch(getDolGlobalString($constname));
312 if ($result < 0) {
313 setEventMessages(null, $c->errors, 'errors');
314 }
315 $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
316 $toprint = array();
317 foreach ($ways as $way) {
318 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
319 }
320 print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
321 }
322 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
323 if (getDolGlobalString($constname) == 2) {
324 print $langs->trans("Prospect");
325 } elseif (getDolGlobalString($constname) == 3) {
326 print $langs->trans("ProspectCustomer");
327 } elseif (getDolGlobalString($constname) == 1) {
328 print $langs->trans("Customer");
329 } elseif (getDolGlobalString($constname) == 0) {
330 print $langs->trans("NorProspectNorCustomer");
331 }
332 } elseif ($val['type'] == 'product') {
333 $product = new Product($db);
334 $idproduct = getDolGlobalString($constname);
335 if ($idproduct > 0) {
336 $resprod = $product->fetch($idproduct);
337 if ($resprod > 0) {
338 print $product->getNomUrl(1);
339 } elseif ($resprod < 0) {
340 setEventMessages($product->error, $product->errors, "errors");
341 }
342 }
343 } else {
344 print getDolGlobalString($constname);
345 }
346 print '</td>';
347
348 print '</tr>';
349 }
350 }
351
352 print '</table>';
353
354 print '<div class="tabsAction">';
355 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
356 print '</div>';
357 } else {
358 print '<br>'.$langs->trans("NothingToSetup");
359 }
360}
361
362
363// Page end
364print dol_get_fiche_end();
365
366llxFooter();
367$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:71
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.