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