dolibarr 24.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-2025 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024-2025 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', 'alpha');
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
57if (empty($action)) {
58 $action = 'edit';
59}
60
61$arrayofparameters = array(
62 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1, 'css' => ''),
63 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1, 'css' => ''),
64 'EVENTORGANIZATION_FILTERATTENDEES_CAT' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1, 'css' => ''),
65 'EVENTORGANIZATION_FILTERATTENDEES_TYPE' => array('type' => 'thirdparty_type:', 'enabled' => 1, 'css' => ''),
66 'EVENTORGANIZATION_TASK_LABEL' => array('type' => 'textarea','enabled' => 1, 'css' => 'height100'),
67 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
68 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
69 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
70 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1, 'css' => ''),
71 //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1, 'css' => ''),
72 //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1, 'css' => ''),
73 'SERVICE_BOOTH_LOCATION' => array('type' => 'product', 'enabled' => 1, 'css' => 'maxwidth500'),
74 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION' => array('type' => 'product', 'enabled' => 1, 'css' => 'maxwidth500'),
75);
76
77$error = 0;
78$setupnotempty = 0;
79
80$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
81
82// Access control
83if (empty($user->admin)) {
85}
86
87
88
89/*
90 * Actions
91 */
92
93if ($cancel) {
94 $action = '';
95}
96
97include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
98
99if ($action == 'updateMask') {
100 $maskconstorder = GETPOST('maskconstorder', 'aZ09');
101 $maskorder = GETPOST('maskorder', 'alpha');
102
103 if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) {
104 $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
105 if (!($res > 0)) {
106 $error++;
107 }
108 }
109
110 if (!$error) {
111 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
112 } else {
113 setEventMessages($langs->trans("Error"), null, 'errors');
114 }
115} elseif ($action == 'setmod') {
116 // TODO Check if numbering module chosen can be activated by calling method canBeActivated
117 $tmpobjectkey = GETPOST('object', 'aZ09');
118 if (!empty($tmpobjectkey)) {
119 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey)."_ADDON";
120 dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
121 }
122} elseif ($action == 'set') {
123 // Activate a model
124 $ret = addDocumentModel($value, $type, $label, $scandir);
125} elseif ($action == 'del') {
126 $ret = delDocumentModel($value, $type);
127 if ($ret > 0) {
128 $tmpobjectkey = GETPOST('object', 'aZ09');
129 if (!empty($tmpobjectkey)) {
130 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
131 if (getDolGlobalString($constforval) == "$value") {
132 dolibarr_del_const($db, $constforval, $conf->entity);
133 }
134 }
135 }
136}
137
138
139/*
140 * View
141 */
142
143$form = new Form($db);
144
145$page_name = "EventOrganizationSetup";
146
147llxHeader('', $langs->trans($page_name), '', '', 0, 0, '', '', '', 'mod-admin page-eventorganization');
148
149// Subheader
150$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
151
152print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
153
154// Configuration header
156print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, 'eventorganization');
157
158// Setup page goes here
159//print '<span class="opacitymedium">'.$langs->trans("EventOrganizationSetupPage").'</span><br>';
160print '<br>';
161
162
163if ($action == 'edit') {
164 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
165 print '<input type="hidden" name="token" value="'.newToken().'">';
166 print '<input type="hidden" name="action" value="update">';
167
168 print '<table class="noborder centpercent">';
169 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td></td></tr>';
170
171 foreach ($arrayofparameters as $constname => $val) {
172 if ($val['enabled'] == 1) {
173 $setupnotempty++;
174 print '<tr class="oddeven"><td><!-- '.$constname.' -->';
175 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
176 $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
177 print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
178 print '</td><td>';
179
180 if ($val['type'] == 'textarea') {
181 print '<textarea class="flat" name="'.$constname.'" id="'.$constname.'" cols="50" rows="5" wrap="soft">' . "\n";
182 print getDolGlobalString($constname);
183 print "</textarea>\n";
184 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
185 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
186 $formmail = new FormMail($db);
187
188 $tmp = explode(':', $val['type']);
189 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
190 //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
191 $arrayofmessagename = array();
192 if (is_array($formmail->lines_model)) {
193 foreach ($formmail->lines_model as $modelmail) {
194 //var_dump($modelmail);
195 $moreonlabel = '';
196 if (!empty($arrayofmessagename[$modelmail->label])) {
197 $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
198 }
199 // The 'label' is the key that is unique if we exclude the language
200 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\‍(|\‍)/', '', $modelmail->label)) . $moreonlabel;
201 }
202 }
203 print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
204 } elseif (preg_match('/category:/', $val['type'])) {
205 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
206 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
207 $formother = new FormOther($db);
208
209 $tmp = explode(':', $val['type']);
210 print img_picto('', 'category', 'class="pictofixedwidth"');
211 print $formother->select_categories($tmp[1], getDolGlobalInt($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
212 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
213 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
214 $formcompany = new FormCompany($db);
215 print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname, 'customerorprospect', 'form', '', '1');
216 } elseif ($val['type'] == 'product') {
217 if (isModEnabled("product") || isModEnabled("service")) {
218 $selected = getDolGlobalInt($constname);
219 print img_picto('', 'product', 'class="pictofixedwidth"');
220 print $form->select_produits($selected, $constname, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, 'maxwidth500 widthcentpercentminusx', 0, '', null, 1);
221 }
222 } else {
223 print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . getDolGlobalString($constname) . '">';
224 }
225 print '</td></tr>';
226 }
227 }
228 print '</table>';
229
230 print $form->buttonsSaveCancel('Save', '');
231
232 print '</form>';
233 print '<br>';
234} else {
235 print '<table class="noborder centpercent">';
236 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td></td></tr>';
237
238 foreach ($arrayofparameters as $constname => $val) {
239 /*if ($val['enabled'] != 1) {
240 continue;
241 }*/
242 $setupnotempty++;
243 print '<tr class="oddeven">';
244 print '<td><!-- '.$constname.' -->';
245 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
246 $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
247 print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
248 print '</td><td>';
249
250 if ($val['type'] == 'textarea') {
251 print dol_nl2br(getDolGlobalString($constname));
252 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
253 if (getDolGlobalString($constname)) {
254 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
255 $formmail = new FormMail($db);
256
257 $tmp = explode(':', $val['type']);
258 $labelemailtemplate = getDolGlobalString($constname);
259 if ($labelemailtemplate && $labelemailtemplate != '-1') {
260 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalInt($constname));
261 if (is_numeric($template) && $template < 0) {
262 setEventMessages($formmail->error, $formmail->errors, 'errors');
263 } else {
264 if ($template->label != 'default') {
265 print $langs->trans($template->label);
266 }
267 }
268 }
269 }
270 } elseif (preg_match('/category:/', $val['type'])) {
271 if (getDolGlobalInt($constname)) {
272 $c = new Categorie($db);
273 $result = $c->fetch(getDolGlobalInt($constname));
274 if ($result < 0) {
275 setEventMessages(null, $c->errors, 'errors');
276 }
277 $ways = $c->print_all_ways('auto', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
278 $toprint = array();
279 foreach ($ways as $way) {
280 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
281 }
282 print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
283 }
284 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
285 if (getDolGlobalString($constname) == 2) {
286 print $langs->trans("Prospect");
287 } elseif (getDolGlobalString($constname) == 3) {
288 print $langs->trans("ProspectCustomer");
289 } elseif (getDolGlobalString($constname) == 1) {
290 print $langs->trans("Customer");
291 } elseif (getDolGlobalString($constname) == 0) {
292 print $langs->trans("NorProspectNorCustomer");
293 }
294 } elseif ($val['type'] == 'product') {
295 $product = new Product($db);
296 $idproduct = getDolGlobalInt($constname);
297 if ($idproduct > 0) {
298 $resprod = $product->fetch($idproduct);
299 if ($resprod > 0) {
300 print $product->getNomUrl(1);
301 } elseif ($resprod < 0) {
302 setEventMessages($product->error, $product->errors, "errors");
303 }
304 }
305 } else {
306 print getDolGlobalString($constname);
307 }
308 print '</td>';
309
310 print '</tr>';
311 }
312
313 print '</table>';
314
315 print '<div class="tabsAction">';
316 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
317 print '</div>';
318}
319
320
321// Page end
322print dol_get_fiche_end();
323
324llxFooter();
325$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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
$c
Definition line.php:334
Class to manage categories.
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 to manage a HTML form to send a unitary email Usage: $formail = new FormMail($db) $formmail->pr...
Class to help generate other html components Only common components are here.
Class to manage products or services.
eventorganizationAdminPrepareHead()
Prepare admin pages header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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, $allowothertags=array())
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, $morecssdiv='')
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.