dolibarr 24.0.0-beta
inputs.php
1<?php
2/*
3 * Copyright (C) 2024 Anthony Damhet <a.damhet@progiseize.fr>
4 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program and files/directory inner it is free software: you can
7 * redistribute it and/or modify it under the terms of the
8 * GNU Affero General Public License (AGPL) as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU AGPL for more details.
16 *
17 * You should have received a copy of the GNU AGPL
18 * along with this program. If not, see <https://www.gnu.org/licenses/agpl-3.0.html>.
19 */
20
21// Load Dolibarr environment
22require '../../../../main.inc.php';
23
31// Protection if external user
32if ($user->socid > 0) : accessforbidden();
33endif;
34
35// Includes
36dol_include_once('admin/tools/ui/class/documentation.class.php');
37require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
38
39// Load documentation translations
40$langs->load('uxdocumentation');
41
42$action = GETPOST('action', 'alpha');
43
44//
45$documentation = new Documentation($db);
46$morejs = [
47 '/includes/ace/src/ace.js',
48 '/includes/ace/src/ext-statusbar.js',
49 '/includes/ace/src/ext-language_tools.js',
50];
51// Output html head + body - Param is Title
52$documentation->docHeader('Inputs', $morejs);
53
54// Set view for menu and breadcrumb
55// Menu must be set in constructor of documentation class
56$documentation->view = array('Components','Inputs');
57
58// Output sidebar
59$documentation->showSidebar(); ?>
60
61<div class="doc-wrapper">
62
63 <?php $documentation->showBreadCrumb(); ?>
64
65 <div class="doc-content-wrapper">
66
67 <h1 class="documentation-title"><?php echo $langs->trans('DocInputsTitle'); ?></h1>
68 <p class="documentation-text"><?php echo $langs->trans('DocInputsMainDescription'); ?></p>
69
70 <!-- Summary -->
71 <?php $documentation->showSummary(); ?>
72
73 <!-- Basic usage -->
74 <div class="documentation-section" id="setinputssection-basicusage">
75 <h2 class="documentation-title"><?php echo $langs->trans('DocBasicUsage'); ?></h2>
76 <!-- Classic Input -->
77 <p class="documentation-text"><?php echo $langs->trans('DocClassicInputsDescription'); ?></p>
78 <div class="documentation-example">
79 <td>Available Input</td>
80 <td><input id="label" name="label" class="minwidth200" maxlength="255" value=""></td>
81 <br><br>
82 <td>Disabled Input</td>
83 <td><input id="label" name="label" class="minwidth200" maxlength="255" value="" disabled></td>
84 </div>
85 <?php
86 $lines = array(
87 'Available Input',
88 '<input id="label" name="label" class="minwidth200" maxlength="255" value="">',
89 '',
90 'Disabled Input',
91 '<input id="label" name="label" class="minwidth200" maxlength="255" value="" disabled>',
92 );
93 $documentation->showCode($lines); ?>
94
95 <!-- Checkbox input -->
96 <p class="documentation-text"><?php echo $langs->trans('DocCheckboxInputsDescription'); ?></p>
97 <div class="documentation-example">
98 <span class="spannature paddinglarge marginrightonly nonature-back valignmiddle"><label for="prospectinput" class="valignmiddle"><span class="valignmiddle">Prospect</span><input id="prospectinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="prospect" value="1" checked></label></span>
99 <span class="spannature paddinglarge marginrightonly nonature-back valignmiddle"><label for="customerinput" class="valignmiddle"><span class="valignmiddle">Customer</span><input id="customerinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="customer" value="1" checked></label></span>
100 <span class="spannature paddinglarge marginrightonly nonature-back valignmiddle"><label for="supplierinput" class="valignmiddle"><span class="valignmiddle">Supplier</span><input id="supplierinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="supplier" value="1" checked></label></span>
101 </div>
102 <?php
103 $lines = array(
104 '<span class="spannature paddinglarge marginrightonly nonature-back valignmiddle"><label for="prospectinput" class="valignmiddle"><span class="valignmiddle">Prospect</span><input id="prospectinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="prospect" value="1" checked></label></span>',
105 '<span class="spannature paddinglarge marginrightonly nonature-back valignmiddle"><label for="customerinput" class="valignmiddle"><span class="valignmiddle">Customer</span><input id="customerinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="customer" value="1" checked></label></span>',
106 '<span class="spannature paddinglarge marginrightonly nonature-back valignmiddle"><label for="supplierinput" class="valignmiddle"><span class="valignmiddle">Supplier</span><input id="supplierinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="supplier" value="1" checked></label></span>',
107 );
108 $documentation->showCode($lines); ?>
109
110 <!-- Radio input -->
111 <p class="documentation-text"><?php echo $langs->trans('DocRadioInputsDescription'); ?></p>
112 <div class="documentation-example">
113 <input type="radio" id="idforradioinput1" name="radioinput" value="value1"><label for="idforradioinput1" class="marginrightonly"> Radio Input 1</label>
114 <input type="radio" id="idforradioinput2" name="radioinput" value="value2"><label for="idforradioinput2" class="marginrightonly"> Radio Input 2</label>
115 </div>
116 <?php
117 $lines = array(
118 '<input type="radio" id="idforradioinput1" name="radioinput" value="value1"><label for="idforradioinput1" class="marginrightonly"> Radio Input 1</label>',
119 '<input type="radio" id="idforradioinput2" name="radioinput" value="value2"><label for="idforradioinput2" class="marginrightonly"> Radio Input 2</label>'
120 );
121 $documentation->showCode($lines); ?>
122 </div>
123
124 <!-- Helper functions -->
125 <div class="documentation-section" id="setinputssection-helperfunctions">
126 <h2 class="documentation-title"><?php echo $langs->trans('DocHelperFunctionsInputUsage'); ?></h2>
127 <p class="documentation-text"><?php echo $langs->trans('DocSelectInputsDescription'); ?></p>
128 <div class="documentation-example">
129 <td>Select with empty value</td>
130 <?php
131 $values = ['1' => 'value 1', '2' => 'value 2', '3' => 'value 3'];
132 $form = new Form($db);
133 print $form->selectarray('htmlnameselectwithemptyvalue', $values, 'idselectwithemptyvalue', 1, 0, 0, '', 0, 0, 0, '', 'minwidth200');
134 ?>
135 <br><br>
136 <td>Select within empty value</td>
137 <?php
138 $values = ['1' => 'value 1', '2' => 'value 2', '3' => 'value 3'];
139 $form = new Form($db);
140 print $form->selectarray('htmlnameselectwithinemptyvalue', $values, 'idnameselectwithinemptyvalue', 0, 0, 0, '', 0, 0, 0, '', 'minwidth200');
141 ?>
142 </div>
143 <?php
144 $lines = array(
145 '<?php',
146 '',
147 '
167',
168 '',
169
170 '// Select with empty value',
171 'print $form->selectarray(\'htmlnameselectwithemptyvalue\', $values, \'idselectwithemptyvalue\', 1, 0, 0, \'\', 0, 0, 0, \'\', \'minwidth200\');',
172 '',
173 '// Select within empty value',
174 'print $form->selectarray(\'htmlnameselectwithinemptyvalue\', $values, \'idnameselectwithinemptyvalue\', 0,0, 0, \'\', 0, 0, 0, \'\', \'minwidth200\');',
175
176 );
177 $documentation->showCode($lines, 'php'); ?>
178
179 <!-- Multiselect input -->
180 <p class="documentation-text"><?php echo $langs->trans('DocMultiSelectInputsDescription'); ?></p>
181 <div class="documentation-example">
182 <td>Multiselect</td>
183 <?php
184 $values = ['1' => 'value 1', '2' => 'value 2', '3' => 'value 3'];
185 $form = new Form($db);
186 print $form->multiselectarray('categories', $values, GETPOST('categories', 'array'), 0, 0, 'minwidth200', 0, 0);
187 ?>
188 </div>
189 <?php
190 $lines = array(
191 '<?php',
192 '',
193 '
210',
211 '',
212 '// Multiselect',
213 'print $form->multiselectarray(\'categories\', $values, GETPOST(\'categories\', \'array\'), 0, 0, \'minwidth200\', 0, 0);'
214 );
215 $documentation->showCode($lines, 'php'); ?>
216
217 <!-- Date input -->
218 <p class="documentation-text"><?php echo $langs->trans('DocDateSelectInputsDescription'); ?></p>
219 <div class="documentation-example">
220 <td>Date Select</td>
221 <?php
222 $values = ['1' => 'value 1', '2' => 'value 2', '3' => 'value 3'];
223 $form = new Form($db);
224 print $form->selectDate();
225 ?>
226 <br><br>
227 <td>Date Select with hours</td>
228 <?php
229 $values = ['1' => 'value 1', '2' => 'value 2', '3' => 'value 3'];
230 $form = new Form($db);
231 print $form->selectDate('', 're2', 1, 1, 1);
232 ?>
233 </div>
234 <?php
235 $lines = array(
236 '<?php',
237 '
264',
265 '',
266 '// Date Select',
267 'print $form->selectDate();',
268 '',
269 '// Date Select with hours',
270 'print $form->selectDate(\'\', \'re2\', 1, 1, 1);'
271 );
272 $documentation->showCode($lines, 'php'); ?>
273
274
275 <!-- Editor input -->
276 <p class="documentation-text"><?php echo $langs->trans('DocEditorInputsDescription'); ?></p>
277 <div class="documentation-example">
278 <?php
279 $doleditor = new DolEditor('desc', GETPOST('desc', 'restricthtml'), '', 160, 'dolibarr_details', '', false, true, getDolGlobalString('FCKEDITOR_ENABLE_DETAILS'), ROWS_4, '90%');
280 $doleditor->Create();
281 ?>
282 </div>
283 <?php
284 $lines = array(
285 '<?php',
286 '
304',
305 '',
306 '$doleditor = new DolEditor(\'desc\', GETPOST(\'desc\', \'restricthtml\'), \'\', 160, \'dolibarr_details\', \'\', false, true, getDolGlobalString(\'FCKEDITOR_ENABLE_DETAILS\'), ROWS_4, \'90%\');',
307 'print $form->multiselectarray(\'categories\', $values, GETPOST(\'categories\', \'array\'), 0, 0, \'minwidth200\', 0, 0);'
308 );
309 $documentation->showCode($lines, 'php'); ?>
310 </div>
311
312 <!-- Search Filter Tool Input -->
313 <div class="documentation-section" id="setinputssection-getSearchFilterToolInput">
314 <h2 class="documentation-title"><?php echo $langs->trans('DocSearchInputUsage'); ?></h2>
315 <p class="documentation-text"><?php echo $langs->trans('DocSearchInputUsageDescription'); ?></p>
316 <div class="documentation-example">
317 <?php
318 $containerCssSelector = '#demo-search-filter-tool-container-01';
319 print $form->getSearchFilterToolInput(
320 $containerCssSelector. ' .search-item',
321 '',
322 '',
323 ['attr' => [
324 'data-counter-target' => $containerCssSelector. ' .counter',
325 'data-no-item-target' => $containerCssSelector. ' .search-tool-no-results',
326 ],
327 ]
328 );
329 ?>
330
331 <div id="demo-search-filter-tool-container-01">
332 <p>Counter : <strong class="counter">12</strong></p>
333 <ul>
334 <li class="search-item">France</li>
335 <li class="search-item">Italy</li>
336 <li class="search-item">Germany</li>
337 <li class="search-item">Spain</li>
338 <li class="search-item">Canada</li>
339 <li class="search-item">Brazil</li>
340 <li class="search-item">Argentina</li>
341 <li class="search-item">Japan</li>
342 <li class="search-item">Australia</li>
343 <li class="search-item">India</li>
344 <li class="search-item">Egypt</li>
345 <li class="search-item">South Africa</li>
346 </ul>
347 <div class="search-tool-no-results hidden-search-result" ><?php print $langs->trans('NoResults') ?></div>
348 </div>
349
350 </div>
351 <?php
352 $lines = array(
353 '<div class="search-tool-container">',
354 ' <input ',
355 ' type="search"',
356 ' name=""',
357 ' autofocus="" <?php // To use only if search is in top of page ?> ',
358 ' value=""',
359 ' class="search-tool-input" <?php // optional for js filter you can use custom class ?> ',
360 ' placeholder="Search"',
361 ' autocomplete="off"',
362 ' data-search-tool-target="#demo-filter .search-item" <?php // required for js filter ?> ',
363 ' data-counter-target="#demo-filter .counter" <?php // optional for js filter ?> ',
364 ' data-no-item-target="#demo-filter .search-tool-no-results" <?php // optional for js filter ?> ',
365 ' >',
366 '</div>',
367 '<div id="demo-filter">',
368 ' <p>Counter : <strong class="counter">4</strong></p>',
369 ' <ul>',
370 ' <li class="search-item">France</li>',
371 ' <li class="search-item">Italy</li>',
372 ' <li class="search-item">Germany</li>',
373 ' <li class="search-item">Spain</li>',
374 ' </ul>',
375 ' <div class="search-tool-no-results hidden-search-result" >No results</div>',
376 '</div>',
377
378 );
379 $documentation->showCode($lines, 'php');
380
381 $lines = array(
382 '<?php',
383 'print $form->getSearchFilterToolInput(',
384 ' \'#demo-filter .search-item\',',
385 ' \'search-tools-input\',',
386 ' [\'attr\' => [',
387 ' \'data-no-item-target\' => \'#demo-filter .search-tool-no-results\', ',
388 ' \'data-counter-target\' => \'#demo-filter .counter\', ',
389 ' ],',
390 ' ]',
391 '); ',
392 '?>',
393 '',
394 '<div id="demo-filter">',
395 ' <p>Counter : <strong class="counter">4</strong></p>',
396 ' <ul>',
397 ' <li class="search-item">France</li>',
398 ' <li class="search-item">Italy</li>',
399 ' <li class="search-item">Germany</li>',
400 ' <li class="search-item">Spain</li>',
401 ' </ul>',
402 ' <div class="search-tool-no-results hidden-search-result" >No results</div>',
403 '</div>',
404
405 );
406 $documentation->showCode($lines, 'php');
407
408 ?>
409
410 </div>
411 </div>
412
413</div>
414
415<?php
416// Output close body + html
417$documentation->docFooter();
418
419?>
Class to manage UI documentation.
Class to manage a WYSIWYG editor.
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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.
a disabled
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.