dolibarr 25.0.0-alpha
reception_setup.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@atm-consulting.fr>
3 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024-2026 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';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
32
42$langs->loadLangs(array("admin", "receptions", 'other'));
43
44
45if (!$user->admin) {
47}
48
49$action = GETPOST('action', 'aZ09');
50$value = GETPOST('value', 'alpha');
51$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
52
53$label = GETPOST('label', 'alpha');
54$scandir = GETPOST('scan_dir', 'alpha');
55$type = 'reception';
56
57
58/*
59 * Actions
60 */
61
62if (isModEnabled('reception') && !getDolGlobalString('MAIN_SUBMODULE_RECEPTION')) {
63 // This option should always be set to on when module is on.
64 dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity);
65}
66
67if (!getDolGlobalString('RECEPTION_ADDON_NUMBER')) {
68 $conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl';
69}
70
71
72/*
73 * Actions
74 */
75$error = 0;
76
77include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
78
79if ($action == 'updateMask') {
80 $maskconst = GETPOST('maskconstreception', 'aZ09');
81 $maskvalue = GETPOST('maskreception', 'alpha');
82 if (!empty($maskconst) && preg_match('/_MASK$/', $maskconst)) {
83 $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
84 }
85
86 if (isset($res)) {
87 if ($res > 0) {
88 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
89 } else {
90 setEventMessages($langs->trans("Error"), null, 'errors');
91 }
92 }
93} elseif ($action == 'set_param') {
94 $freetext = GETPOST('RECEPTION_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
95 $res = dolibarr_set_const($db, "RECEPTION_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
96 if ($res <= 0) {
97 $error++;
98 setEventMessages($langs->trans("Error"), null, 'errors');
99 }
100
101 $draft = GETPOST('RECEPTION_DRAFT_WATERMARK', 'alpha');
102 $res = dolibarr_set_const($db, "RECEPTION_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
103 if ($res <= 0) {
104 $error++;
105 setEventMessages($langs->trans("Error"), null, 'errors');
106 }
107
108 if (!$error) {
109 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
110 }
111} elseif ($action == 'specimen') {
112 $modele = GETPOST('module', 'alpha');
113
114 $exp = new Reception($db);
115 $exp->initAsSpecimen();
116
117 // Search template files
118 $file = '';
119 $classname = '';
120 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
121 foreach ($dirmodels as $reldir) {
122 $file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0);
123 if (file_exists($file)) {
124 $classname = "pdf_".$modele;
125 break;
126 }
127 }
128
129 if ($classname !== '') {
130 require_once $file;
131
132 $module = new $classname($db);
133 '@phan-var-force ModelePdfReception $module';
136 if ($module->write_file($exp, $langs) > 0) {
137 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=reception&file=SPECIMEN.pdf");
138 return;
139 } else {
140 setEventMessages($module->error, $module->errors, 'errors');
141 dol_syslog($module->error, LOG_ERR);
142 }
143 } else {
144 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
145 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
146 }
147} elseif ($action == 'set') {
148 // Activate a model
149 $ret = addDocumentModel($value, $type, $label, $scandir);
150} elseif ($action == 'del') {
151 $ret = delDocumentModel($value, $type);
152 if ($ret > 0) {
153 if (getDolGlobalString('RECEPTION_ADDON_PDF') == "$value") {
154 dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity);
155 }
156 }
157} elseif ($action == 'setdoc') {
158 // Set default model
159 if (dolibarr_set_const($db, "RECEPTION_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
160 // The constant that was read before the new set
161 // so we go through a variable to get a consistent display
162 $conf->global->RECEPTION_ADDON_PDF = $value;
163 }
164
165 // On active le modele
166 $ret = delDocumentModel($value, $type);
167 if ($ret > 0) {
168 $ret = addDocumentModel($value, $type, $label, $scandir);
169 }
170} elseif ($action == 'setmodel') {
171 dolibarr_set_const($db, "RECEPTION_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity);
172}
173
174
175
176
177/*
178 * View
179 */
180
181$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
182
183$form = new Form($db);
184
185llxHeader('', $langs->trans("ReceptionsSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-reception_setup');
186
187$linkback = '<a href="'.dolBuildUrl(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>';
188
189print load_fiche_titre($langs->trans("ReceptionsSetup"), $linkback, 'title_setup');
190print '<br>';
192
193print dol_get_fiche_head($head, 'reception', $langs->trans("Receptions"), -1, 'reception');
194
195// Reception numbering model
196
197$reception = new Reception($db);
198$reception->initAsSpecimen();
199
200printNumberingModuleList('reception', 'mod_reception_', 'RECEPTION_ADDON_NUMBER', $langs->trans("ReceptionsNumberingModules"), $reception, 'setmodel');
201
202print '<br>';
203
204/*
205 * Documents models for Receptions Receipt
206 */
207printDocumentModelList('reception', 'reception', 'RECEPTION_ADDON_PDF', $langs->trans("ReceptionsReceiptModel"), array(
208 'Logo' => 'option_logo',
209 'PaymentMode' => 'option_modereg',
210 'PaymentConditions' => 'option_condreg',
211 'MultiLanguage' => 'option_multilang',
212 'WatermarkOnDraftOrders' => 'option_draft_watermark',
213));
214
215print '<br>';
216
217
218/*
219 * Other options
220 */
221
222print load_fiche_titre($langs->trans("OtherOptions"), '', '');
223
224print '<table class="noborder centpercent">';
225print '<tr class="liste_titre">';
226print "<td>".$langs->trans("Parameter")."</td>\n";
227print "<td></td>\n";
228print '</tr>';
229
230// Notifications
231/*
232print '<tr class="oddeven">';
233print '<td>'.img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("Notifications").'</td>';
234print '<td>';
235print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification");
236print '</td></tr>';
237*/
238
239// More PDF options
240print '<tr class="oddeven">';
241print '<td>'.img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("MoreOptionsRelatedToPDF").'</td>';
242print '<td>';
243print img_picto('', 'url', 'class="pictofixedwidth"').'<a href="'.DOL_URL_ROOT.'/admin/pdf_other.php">'.$langs->trans("SeeInPDFSetupPage").'</a>';
244print '</td></tr>';
245
246print '</table>';
247
248
249print '</form>';
250
251llxFooter();
252$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
Class to manage generation of HTML components Only common components must be here.
Class to manage receptions.
if(! $sortfield) if(! $sortorder) $module
Definition list.php:193
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.
Definition html.lib.php:540
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
reception_admin_prepare_head()
Return array head with list of tabs to view object information.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.