dolibarr 24.0.0-beta
printsheet.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4 * Copyright (C) 2006-2017 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
6 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2025 William Mead <william@m34d.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Do not use GETPOST, the function does not exists yet.
30if (!empty($_POST['mode']) && $_POST['mode'] === 'label') { // Page is called to build a PDF and output, we must not renew the token.
31 if (!defined('NOTOKENRENEWAL')) {
32 define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
33 }
34}
35
36// Load Dolibarr environment
37require '../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/modules/printsheet/modules_labels.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
42
54// Load translation files required by the page
55$langs->loadLangs(array('admin', 'members', 'errors'));
56
57// Choice of print year or current year.
58$now = dol_now();
59$year = dol_print_date($now, '%Y');
60$month = dol_print_date($now, '%m');
61$day = dol_print_date($now, '%d');
62$forbarcode = GETPOST('forbarcode', 'alphanohtml');
63$fk_barcode_type = GETPOSTINT('fk_barcode_type');
64$mode = GETPOST('mode', 'aZ09');
65$modellabel = GETPOST("modellabel", 'aZ09'); // Doc template to use
66$numberofsticker = GETPOSTINT('numberofsticker');
67
68$label_product_ref_option = GETPOSTISSET('label_product_ref_option');
69$label_product_label_option = GETPOSTISSET('label_product_label_option');
70
71if (getDolGlobalString('MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS')) {
72 $label_product_ref = (GETPOSTISSET('label_product_ref') ? GETPOST('label_product_ref', 'nohtml') : null);
73} else {
74 $label_product_ref = (GETPOSTISSET('label_product_ref') ? GETPOST('label_product_ref', 'alpha') : null);
75}
76
77if (getDolGlobalString('MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS')) {
78 $security_check = 'nohtml';
79} else {
80 $security_check = !getDolGlobalString('MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML') ? 'alphanohtml' : 'restricthtml';
81}
82$label_product_label = (GETPOSTISSET('label_product_label') ? GETPOST('label_product_label', $security_check) : null);
83
84$mesg = '';
85
86$action = GETPOST('action', 'aZ09');
87
88$producttmp = new Product($db);
89$thirdpartytmp = new Societe($db);
90
91// Security check (enable the most restrictive one)
92//if ($user->socid > 0) accessforbidden();
93//if ($user->socid > 0) $socid = $user->socid;
94if (!isModEnabled('barcode')) {
95 accessforbidden('Module not enabled');
96}
97if (!$user->hasRight('barcode', 'read')) {
99}
100// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
101$hookmanager->initHooks(array('printsheettools'));
102
103restrictedArea($user, 'barcode');
104
105$object = new stdClass();
106
107
108/*
109 * Actions
110 */
111
112// Note that $action and $object may have been modified by some
113$parameters = array();
114$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
115if ($reshook < 0) {
116 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
117}
118
119if (empty($reshook)) {
120 if (GETPOST('submitproduct')) {
121 $action = ''; // We reset because we don't want to build doc
122 if (GETPOSTINT('productid') > 0) {
123 $result = $producttmp->fetch(GETPOSTINT('productid'));
124 if ($result < 0) {
125 setEventMessage($producttmp->error, 'errors');
126 }
127 $forbarcode = $producttmp->barcode;
128 $fk_barcode_type = $producttmp->barcode_type;
129
130 if (empty($fk_barcode_type) && getDolGlobalString('PRODUIT_DEFAULT_BARCODE_TYPE')) {
131 $fk_barcode_type = getDolGlobalString('PRODUIT_DEFAULT_BARCODE_TYPE');
132 }
133
134 if (empty($forbarcode) || empty($fk_barcode_type)) {
135 setEventMessages($langs->trans("DefinitionOfBarCodeForProductNotComplete", $producttmp->getNomUrl()), null, 'warnings');
136 }
137
138 if (empty($label_product_ref) && $label_product_ref_option) {
139 $label_product_ref = $producttmp->ref;
140 }
141
142 if (empty($label_product_label) && $label_product_label_option) {
143 $label_product_label = $producttmp->label;
144 }
145 }
146 }
147 if (GETPOST('submitthirdparty')) {
148 $action = ''; // We reset because we don't want to build doc
149 if (GETPOSTINT('socid') > 0) {
150 $thirdpartytmp->fetch(GETPOSTINT('socid'));
151 $forbarcode = $thirdpartytmp->barcode;
152 $fk_barcode_type = $thirdpartytmp->barcode_type_code;
153
154 if (empty($fk_barcode_type) && getDolGlobalString('GENBARCODE_BARCODETYPE_THIRDPARTY')) {
155 $fk_barcode_type = getDolGlobalString('GENBARCODE_BARCODETYPE_THIRDPARTY');
156 }
157
158 if (empty($forbarcode) || empty($fk_barcode_type)) {
159 setEventMessages($langs->trans("DefinitionOfBarCodeForThirdpartyNotComplete", $thirdpartytmp->getNomUrl()), null, 'warnings');
160 }
161 }
162 }
163
164 if ($action == 'builddoc' && $user->hasRight('barcode', 'read')) {
165 $result = 0;
166 $error = 0;
167
168 if (empty($forbarcode)) { // barcode value
169 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BarcodeValue")), null, 'errors');
170 $error++;
171 }
172 $MAXLENGTH = 51200; // Limit set to 50Ko
173 if (dol_strlen($forbarcode) > $MAXLENGTH) { // barcode value
174 setEventMessages($langs->trans("ErrorFieldTooLong", $langs->transnoentitiesnoconv("BarcodeValue")).' ('.$langs->trans("RequireXStringMax", $MAXLENGTH).')', null, 'errors');
175 $error++;
176 }
177 if (empty($fk_barcode_type)) { // barcode type = barcode encoding
178 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BarcodeType")), null, 'errors');
179 $error++;
180 }
181
182 if (GETPOSTINT('productid') > 0) {
183 $result = $producttmp->fetch(GETPOSTINT('productid'));
184 if ($result < 0) {
185 setEventMessage($producttmp->error, 'errors');
186 }
187 if (empty($label_product_ref) && $label_product_ref_option) {
188 $label_product_ref = $producttmp->ref;
189 }
190
191 if (empty($label_product_label) && $label_product_label_option) {
192 $label_product_label = $producttmp->label;
193 }
194 }
195
196 $stdobject = null;
197 if (!$error) {
198 // Get encoder (barcode_type_coder) from barcode type id (barcode_type)
199 $stdobject = new GenericObject($db);
200 $stdobject->barcode_type = $fk_barcode_type;
201 $result = $stdobject->fetchBarCode();
202 if ($result <= 0) {
203 $error++;
204 setEventMessages('Failed to get bar code type information '.$stdobject->error, $stdobject->errors, 'errors');
205 }
206 }
207
208 $encoding = null;
209 $diroutput = null;
210 $template = null;
211 $is2d = false;
212 $code = $forbarcode;
213
214 if (!$error && $stdobject !== null) {
215 $generator = $stdobject->barcode_type_coder; // coder (loaded by fetchBarCode). Engine.
216 $encoding = strtoupper($stdobject->barcode_type_code); // code (loaded by fetchBarCode). Example 'ean', 'isbn', ...
217
218 $diroutput = $conf->barcode->dir_temp;
219 dol_mkdir($diroutput);
220
221 // Generate barcode
222 $dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
223
224 foreach ($dirbarcode as $reldir) {
225 $dir = dol_buildpath($reldir, 0);
226 $newdir = dol_osencode($dir);
227
228 // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
229 if (!is_dir($newdir)) {
230 continue;
231 }
232
233 $result = @include_once $newdir.$generator.'.modules.php';
234 if ($result) {
235 break;
236 }
237 }
238
239 // Load barcode class for generating barcode image
240 $classname = "mod".ucfirst($generator);
241 // $module can be modTcpdfbarcode or modPhpbarcode that both extends ModeleBarCode
242 $module = new $classname($db);
243
244 // Build the file on disk for generator not able to return the document on the fly.
245 if ($generator != 'tcpdfbarcode') { // $generator can be 'phpbarcode' (with this generator, barcode is generated on disk first) or 'tcpdfbarcode' (no need to enter this section with this generator).
246 '@phan-var-force modPhpbarcode $module';
247 $template = 'standardlabel';
248 if ($module->encodingIsSupported($encoding)) {
249 $barcodeimage = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
250 dol_delete_file($barcodeimage);
251 // File is created with full name $barcodeimage = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
252 $result = $module->writeBarCode($code, $encoding, 'Y', 4, 1);
253 if ($result <= 0 || !dol_is_file($barcodeimage)) {
254 $error++;
255 setEventMessages('Failed to generate image file of barcode for code='.$code.' encoding='.$encoding.' file='.basename($barcodeimage), null, 'errors');
256 setEventMessages($module->error, null, 'errors');
257 }
258 } else {
259 $error++;
260 setEventMessages("Error, encoding ".$encoding." is not supported by encoder ".$generator.'. You must choose another barcode type or install a barcode generation engine that support '.$encoding, null, 'errors');
261 }
262 } else {
263 '@phan-var-force modTcpdfbarcode $module';
264 $template = 'tcpdflabel';
265 $encoding = $module->getTcpdfEncodingType($encoding); //convert to TCPDF compatible encoding types
266 $is2d = $module->is2d;
267 }
268 }
269
270 if (!$error) {
272 // List of values to scan for a replacement
273 $substitutionarray = array(
274 // old
275 '%LOGIN%' => $user->login,
276 '%COMPANY%' => $mysoc->name,
277 '%ADDRESS%' => $mysoc->address,
278 '%ZIP%' => $mysoc->zip,
279 '%TOWN%' => $mysoc->town,
280 '%COUNTRY%' => $mysoc->country,
281 '%COUNTRY_CODE%' => $mysoc->country_code,
282 '%EMAIL%' => $mysoc->email,
283 '%YEAR%' => $year,
284 '%MONTH%' => $month,
285 '%DAY%' => $day,
286 '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT,
287 '%SERVER%' => $dolibarr_main_url_root,
288 // new
289 '__LOGIN__' => $user->login,
290 '__COMPANY__' => $mysoc->name,
291 '__ADDRESS__' => $mysoc->address,
292 '__ZIP__' => $mysoc->zip,
293 '__TOWN__' => $mysoc->town,
294 '__COUNTRY__' => $mysoc->country,
295 '__COUNTRY_CODE__' => $mysoc->country_code,
296 '__EMAIL__' => $mysoc->email,
297 '__YEAR__' => $year,
298 '__MONTH__' => $month,
299 '__DAY__' => $day,
300 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
301 '__SERVER__' => $dolibarr_main_url_root,
302 );
303 complete_substitutions_array($substitutionarray, $langs);
304
305 $arrayofrecords = array();
306 // For labels
307 if ($mode == 'label') {
308 $txtforsticker = "%PHOTO%"; // Photo will be barcode image, %BARCODE% possible when using TCPDF generator
309 $textleft = make_substitutions(getDolGlobalString('BARCODE_LABEL_LEFT_TEXT', $txtforsticker), $substitutionarray);
310 if ((GETPOSTINT('productid') > 0) && $label_product_ref_option) {
311 $textheader = $label_product_ref;
312 } else {
313 $textheader = make_substitutions(getDolGlobalString('BARCODE_LABEL_HEADER_TEXT'), $substitutionarray);
314 }
315 if ((GETPOSTINT('productid') > 0) && $label_product_label_option) {
316 $textfooter = $label_product_label;
317 } else {
318 $textfooter = make_substitutions(getDolGlobalString('BARCODE_LABEL_FOOTER_TEXT'), $substitutionarray);
319 }
320 $textright = make_substitutions(getDolGlobalString('BARCODE_LABEL_RIGHT_TEXT'), $substitutionarray);
321 $forceimgscalewidth = getDolGlobalString('BARCODE_FORCEIMGSCALEWIDTH', 1);
322 $forceimgscaleheight = getDolGlobalString('BARCODE_FORCEIMGSCALEHEIGHT', 1);
323
324 $MAXSTICKERS = 1000;
325 if ($numberofsticker <= $MAXSTICKERS) {
326 for ($i = 0; $i < $numberofsticker; $i++) {
327 $arrayofrecords[] = array(
328 'textleft' => $textleft,
329 'textheader' => $textheader,
330 'textfooter' => $textfooter,
331 'textright' => $textright,
332 'code' => $code,
333 'encoding' => $encoding,
334 'is2d' => $is2d,
335 'photo' => !empty($barcodeimage) ? $barcodeimage : '' // Photo must be a file that exists with format supported by TCPDF
336 );
337 }
338 } else {
339 $mesg = $langs->trans("ErrorQuantityIsLimitedTo", $MAXSTICKERS);
340 $error++;
341 }
342 }
343
344 // Build and output PDF
345 if (!$error && $mode == 'label') {
346 if (!count($arrayofrecords)) {
347 $mesg = $langs->trans("ErrorRecordNotFound");
348 }
349 if (empty($modellabel) || $modellabel == '-1') {
350 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE"));
351 }
352
353 $outfile = $langs->trans("BarCode").'_sheets_'.dol_print_date(dol_now(), 'dayhourlog').'.pdf';
354
355 if (!$mesg) {
356 $outputlangs = $langs;
357
358 $previousConf = getDolGlobalInt('TCPDF_THROW_ERRORS_INSTEAD_OF_DIE');
359 $conf->global->TCPDF_THROW_ERRORS_INSTEAD_OF_DIE = 1;
360
361 // This generates and send PDF to output
362 // TODO Move
363 try {
364 $result = doc_label_pdf_create($db, $arrayofrecords, $modellabel, $outputlangs, (string) $diroutput, (string) $template, dol_sanitizeFileName($outfile));
365 } catch (Exception $e) {
366 $mesg = $langs->trans('ErrorGeneratingBarcode');
367 $error++;
368 }
369
370 $conf->global->TCPDF_THROW_ERRORS_INSTEAD_OF_DIE = $previousConf;
371 }
372 }
373
374 if ($result <= 0 || $mesg || $error) {
375 if (empty($mesg)) {
376 $mesg = 'Error '.$result;
377 }
378
379 setEventMessages($mesg, null, 'errors');
380 } else {
381 $db->close();
382 exit;
383 }
384 }
385 }
386}
387
388
389/*
390 * View
391 */
392
393$form = new Form($db);
394
395llxHeader('', $langs->trans("BarCodePrintsheet"), '', '', 0, 0, '', '', '', 'mod-barcode page-printsheet');
396
397print load_fiche_titre($langs->trans("BarCodePrintsheet"), '', 'barcode');
398print '<br>';
399
400print '<span class="opacitymedium">'.$langs->trans("PageToGenerateBarCodeSheets", $langs->transnoentitiesnoconv("BuildPageToPrint")).'</span><br>';
401print '<br>';
402
403//print img_picto('','puce').' '.$langs->trans("PrintsheetForOneBarCode").'<br>';
404//print '<br>';
405
406print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; // The target is for brothers that open the file instead of downloading it
407print '<input type="hidden" name="mode" value="label">';
408print '<input type="hidden" name="action" value="builddoc">';
409print '<input type="hidden" name="token" value="'.currentToken().'">'; // The page will not renew the token but force download of a file, so we must use here currentToken
410
411print '<div class="tagtable">';
412
413// Sheet format
414print ' <div class="tagtr">';
415print ' <div class="tagtd">';
416print $langs->trans("DescADHERENT_ETIQUETTE_TYPE").' &nbsp; ';
417print '</div><div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;">';
418// List of possible labels (defined into $_Avery_Labels variable set into core/lib/format_cards.lib.php)
419$arrayoflabels = array();
420foreach (array_keys($_Avery_Labels) as $codecards) {
421 $labeltoshow = $_Avery_Labels[$codecards]['name'];
422 //$labeltoshow.=' ('.$_Avery_Labels[$row['code']]['paper-size'].')';
423 $arrayoflabels[$codecards] = $labeltoshow;
424}
425asort($arrayoflabels);
426print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel') ? GETPOST('modellabel') : getDolGlobalString('ADHERENT_ETIQUETTE_TYPE')), 1, 0, 0, '', 0, 0, 0, '', '', 1);
427print '</div></div>';
428
429// Number of stickers to print
430print ' <div class="tagtr">';
431print ' <div class="tagtd">';
432print $langs->trans("NumberOfStickers").' &nbsp; ';
433print '</div><div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;">';
434print '<input size="4" type="text" name="numberofsticker" value="'.(GETPOST('numberofsticker') ? GETPOSTINT('numberofsticker') : 10).'">';
435print '</div></div>';
436
437print '</div>';
438
439
440print '<br>';
441
442
443// Add javascript to make choice dynamic
444print '<script type="text/javascript">
445jQuery(document).ready(function() {
446 function init_selectors()
447 {
448 if (jQuery("#fillmanually:checked").val() == "fillmanually")
449 {
450 jQuery("#submitproduct").prop("disabled", true);
451 jQuery("#submitthirdparty").prop("disabled", true);
452 jQuery("#search_productid").prop("disabled", true);
453 jQuery("#socid").prop("disabled", true);
454 jQuery(".showforproductselector").hide();
455 jQuery(".showforthirdpartyselector").hide();
456 }
457 if (jQuery("#fillfromproduct:checked").val() == "fillfromproduct")
458 {
459 jQuery("#submitproduct").removeAttr("disabled");
460 jQuery("#submitthirdparty").prop("disabled", true);
461 jQuery("#search_productid").removeAttr("disabled");
462 jQuery("#socid").prop("disabled", true);
463 jQuery(".showforproductselector").show();
464 jQuery(".showforthirdpartyselector").hide();
465 }
466 if (jQuery("#fillfromthirdparty:checked").val() == "fillfromthirdparty")
467 {
468 jQuery("#submitproduct").prop("disabled", true);
469 jQuery("#submitthirdparty").removeAttr("disabled");
470 jQuery("#search_productid").prop("disabled", true);
471 jQuery("#socid").removeAttr("disabled");
472 jQuery(".showforproductselector").hide();
473 jQuery(".showforthirdpartyselector").show();
474 }
475 }
476 init_selectors();
477 jQuery(".radiobarcodeselect").click(function() {
478 init_selectors();
479 });
480
481 function init_gendoc_button()
482 {
483 if (jQuery("#select_fk_barcode_type").val() > 0 && jQuery("#forbarcode").val())
484 {
485 jQuery("#submitformbarcodegen").removeAttr("disabled");
486 }
487 else
488 {
489 jQuery("#submitformbarcodegen").prop("disabled", true);
490 }
491 }
492 init_gendoc_button();
493 jQuery("#select_fk_barcode_type").change(function() {
494 init_gendoc_button();
495 });
496 jQuery("#forbarcode").keyup(function() {
497 init_gendoc_button()
498 });
499});
500</script>';
501
502// Checkbox to select from free text
503print '<input id="fillmanually" type="radio" '.((!GETPOST("selectorforbarcode") || GETPOST("selectorforbarcode") == 'fillmanually') ? 'checked ' : '').'name="selectorforbarcode" value="fillmanually" class="radiobarcodeselect"><label for="fillmanually"> '.$langs->trans("FillBarCodeTypeAndValueManually").'</label>';
504print '<br>';
505
506if ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire')) {
507 print '<input id="fillfromproduct" type="radio" '.((GETPOST("selectorforbarcode") == 'fillfromproduct') ? 'checked ' : '').'name="selectorforbarcode" value="fillfromproduct" class="radiobarcodeselect"><label for="fillfromproduct"> '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'</label>';
508 print '<br>';
509 print '<div class="showforproductselector">';
510 $form->select_produits(GETPOSTINT('productid'), 'productid', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1);
511 print ' &nbsp; <input type="submit" class="button small" id="submitproduct" name="submitproduct" value="'.(dol_escape_htmltag($langs->trans("GetBarCode"))).'">';
512 print '</div>';
513}
514
515if ($user->hasRight('societe', 'lire')) {
516 print '<input id="fillfromthirdparty" type="radio" '.((GETPOST("selectorforbarcode") == 'fillfromthirdparty') ? 'checked ' : '').'name="selectorforbarcode" value="fillfromthirdparty" class="radiobarcodeselect"><label for="fillfromthirdparty"> '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'</label>';
517 print '<br>';
518 print '<div class="showforthirdpartyselector">';
519 print $form->select_company(GETPOSTINT('socid'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300');
520 print ' &nbsp; <input type="submit" id="submitthirdparty" name="submitthirdparty" class="button showforthirdpartyselector small" value="'.(dol_escape_htmltag($langs->trans("GetBarCode"))).'">';
521 print '</div>';
522}
523
524print '<br><br>';
525
526if ($producttmp->id > 0) {
527 print $langs->trans("BarCodeDataForProduct", '').' '.$producttmp->getNomUrl(1).'<br>';
528}
529if ($thirdpartytmp->id > 0) {
530 print $langs->trans("BarCodeDataForThirdparty", '').' '.$thirdpartytmp->getNomUrl(1).'<br>';
531}
532
533print '<div class="tagtable">';
534
535// Barcode type
536print ' <div class="tagtr">';
537print ' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
538print $langs->trans("BarcodeType").' &nbsp; ';
539print '</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
540require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php';
541$formbarcode = new FormBarCode($db);
542print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1);
543print '</div></div>';
544
545// Barcode value
546print ' <div class="tagtr">';
547print ' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
548print $langs->trans("BarcodeValue").' &nbsp; ';
549print '</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
550print '<input size="16" type="text" name="forbarcode" id="forbarcode" value="'.$forbarcode.'">';
551print '</div></div>';
552
553// Product ref & label
554
555if ($producttmp->id > 0) {
556 print ' <div class="tagtr">';
557 print ' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 500px;">';
558 print '<input id="label_product_ref_option" name="label_product_ref_option" type="checkbox" '.(GETPOSTISSET("label_product_ref_option") ? 'checked ' : '').' class="checkforselect"><label for="label_product_ref_option"> '.$langs->trans("BarcodeLabelProductRef").'</label>';
559 print '</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 500px;">';
560 print '<input type="text" name="label_product_ref" id="label_product_ref" placeholder="'.$langs->trans("BarcodeLabelProductRefPlaceholder").'" value="'.$label_product_ref.'">';
561 print '</div></div>';
562 print ' <div class="tagtr">';
563 print ' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 500px;">';
564 print '<input id="label_product_label_option" name="label_product_label_option" type="checkbox" '.(GETPOSTISSET("label_product_label_option") ? 'checked ' : '').' class="checkforselect"><label for="label_product_label_option"> '.$langs->trans("BarcodeLabelProductLabel").'</label>';
565 print '</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 500px;">';
566 print '<input type="text" name="label_product_label" id="label_product_label" placeholder="'.$langs->trans("BarcodeLabelProductLabelPlaceholder").'" value="'.$label_product_label.'">';
567 print '</div></div>';
568}
569
570/*
571$barcodestickersmask=GETPOST('barcodestickersmask');
572print '<br>'.$langs->trans("BarcodeStickersMask").':<br>';
573print '<textarea cols="40" type="text" name="barcodestickersmask" value="'.GETPOST('barcodestickersmask').'">'.$barcodestickersmask.'</textarea>';
574print '<br>';
575*/
576
577print '</div>';
578
579print '<br><input type="submit" class="button" id="submitformbarcodegen" '.(GETPOST("selectorforbarcode") ? '' : 'disabled ').'value="'.$langs->trans("BuildPageToPrint").'">';
580
581print '</form>';
582print '<br>';
583
584// End of page
585llxFooter();
586$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
global $dolibarr_main_url_root
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 barcode HTML.
Class to manage generation of HTML components Only common components must be here.
Class of a generic business object.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
global $mysoc
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.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_is_file($pathoffile)
Return if path is a file.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outputdir='', $template='standardlabel', $filename='tmp_address_sheet.pdf')
Create a document onto disk according to template module.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.