30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
51$action =
GETPOST(
'action',
'aZ09');
52$modulepart =
GETPOST(
'modulepart',
'aZ09');
59include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
61if ($action ==
'setbarcodeproducton') {
62 $barcodenumberingmodule =
GETPOST(
'value',
'alpha');
63 $res =
dolibarr_set_const($db,
"BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule,
'chaine', 0,
'',
$conf->entity);
64 if ($barcodenumberingmodule ==
'mod_barcode_product_standard' && !
getDolGlobalString(
'BARCODE_STANDARD_PRODUCT_MASK')) {
65 $res =
dolibarr_set_const($db,
"BARCODE_STANDARD_PRODUCT_MASK",
'04{0000000000}',
'chaine', 0,
'',
$conf->entity);
67} elseif ($action ==
'setbarcodeproductoff') {
71if ($action ==
'setbarcodethirdpartyon') {
72 $barcodenumberingmodule =
GETPOST(
'value',
'alpha');
73 $res =
dolibarr_set_const($db,
"BARCODE_THIRDPARTY_ADDON_NUM", $barcodenumberingmodule,
'chaine', 0,
'',
$conf->entity);
74 if ($barcodenumberingmodule ==
'mod_barcode_thirdparty_standard' && !
getDolGlobalString(
'BARCODE_STANDARD_THIRDPARTY_MASK')) {
75 $res =
dolibarr_set_const($db,
"BARCODE_STANDARD_THIRDPARTY_MASK",
'04{0000000000}',
'chaine', 0,
'',
$conf->entity);
77} elseif ($action ==
'setbarcodethirdpartyoff') {
81if ($action ==
'setcoder') {
82 $coder =
GETPOST(
'coder',
'alpha');
84 $sqlp =
"UPDATE ".MAIN_DB_PREFIX.
"c_barcode_type";
85 $sqlp .=
" SET coder = '".$db->escape($coder).
"'";
86 $sqlp .=
" WHERE rowid = ".((int) $code_id);
87 $sqlp .=
" AND entity = ".((int)
$conf->entity);
89 $resql = $db->query($sqlp);
93} elseif ($action ==
'update') {
95 $location =
GETPOST(
'GENBARCODE_LOCATION',
'alpha');
98 $coder_id =
GETPOST(
'PRODUIT_DEFAULT_BARCODE_TYPE',
'alpha');
100 $coder_id =
GETPOST(
'GENBARCODE_BARCODETYPE_THIRDPARTY',
'alpha');
101 $res =
dolibarr_set_const($db,
"GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,
'chaine', 0,
'',
$conf->entity);
104 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
106 setEventMessages($langs->trans(
"Error"),
null,
'errors');
108} elseif ($action ==
'updateengine') {
109 $sql =
"SELECT rowid, coder";
110 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
111 $sql .=
" WHERE entity = ".((int)
$conf->entity);
112 $sql .=
" ORDER BY code";
114 $resql = $db->query($sql);
116 $num = $db->num_rows($resql);
120 $obj = $db->fetch_object($resql);
122 if (
GETPOST(
'coder'.$obj->rowid,
'alpha')) {
123 $coder =
GETPOST(
'coder'.$obj->rowid,
'alpha');
124 $code_id = $obj->rowid;
126 $sqlp =
"UPDATE ".MAIN_DB_PREFIX.
"c_barcode_type";
127 $sqlp .=
" SET coder = '".$db->escape($coder).
"'";
128 $sqlp .=
" WHERE rowid = ".((int) $code_id);
129 $sqlp .=
" AND entity = ".((int)
$conf->entity);
131 $upsql = $db->query($sqlp);
133 dol_print_error($db);
147$form =
new Form($db);
150$help_url =
'EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra|DE:Modul_Barcode';
151llxHeader(
'', $langs->trans(
"BarcodeSetup"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-admin page-barcode');
153$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>';
155print
load_fiche_titre($langs->trans(
"BarcodeSetup"), $linkback,
'title_setup');
163print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" spellcheck="false">';
164print
'<input type="hidden" name="token" value="'.newToken().
'">';
165print
"<input type=\"hidden\" name=\"action\" value=\"update\">";
167print
'<div class="div-table-responsive-no-min">';
168print
'<table class="noborder centpercent">';
169print
'<tr class="liste_titre">';
170print
'<td>'.$langs->trans(
"Feature").
'</td>';
171print
'<td width="60" class="center"></td>';
172print
'<td> </td>';
177 print
'<tr class="oddeven">';
178 print
'<td>'.img_picto(
'',
'product',
'class="pictofixedwidth"').$langs->trans(
"UseBarCodeForProducts").
'</td>';
179 print
'<td width="60" class="right">';
180 print ajax_constantonoff(
'BARCODE_USE_ON_PRODUCT', array(),
null, 0, 0, 1);
182 print
'<td> </td>';
188 print
'<tr class="oddeven">';
189 print
'<td>'.img_picto(
'',
'company',
'class="pictofixedwidth"').$langs->trans(
"UseBarCodeForThirdParties").
'</td>';
190 print
'<td width="60" class="right">';
191 print ajax_constantonoff(
'BARCODE_USE_ON_THIRDPARTY', array(),
null, 0, 0, 1);
193 print
'<td> </td>';
205$barcodelist = array();
211$dirbarcode = array_merge(array(
"/core/modules/barcode/doc/"),
$conf->modules_parts[
'barcode']);
213foreach ($dirbarcode as $reldir) {
218 if (!is_dir($newdir)) {
222 $handle = @opendir($newdir);
223 if (is_resource($handle)) {
224 while (($file = readdir($handle)) !==
false) {
226 if (is_readable($newdir.$file)) {
228 if (preg_match(
'/(.*)\.modules\.php$/i', $file, $reg)) {
232 require_once $newdir.$file;
233 $classname =
"mod".ucfirst($filebis);
236 '@phan-var-force ModeleBarCode $module';
247 $barcodelist[$filebis] =
$module->info($langs);
255'@phan-var-force array<string,string> $barcodelist';
260 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"Product").
")",
'',
'product');
262 print
'<div class="div-table-responsive-no-min">';
263 print
'<table class="noborder centpercent">';
264 print
'<tr class="liste_titre">';
265 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
266 print
'<td>'.$langs->trans(
"Description").
'</td>';
267 print
'<td>'.$langs->trans(
"Example").
'</td>';
268 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
269 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
272 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'),
$conf->modules_parts[
'barcode']);
274 foreach ($dirbarcodenum as $dirroot) {
277 $handle = @opendir($dir);
278 if (is_resource($handle)) {
279 while (($file = readdir($handle)) !==
false) {
280 if (preg_match(
'/^mod_barcode_product_.*php$/', $file)) {
290 $modBarCode =
new $file();
291 '@phan-var-force ModeleNumRefBarCode $modBarCode';
293 print
'<tr class="oddeven">';
294 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
295 print $modBarCode->info($langs);
297 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
300 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproductoff&token='.
newToken().
'&value='.urlencode($file).
'">';
301 print img_picto($langs->trans(
"Activated"),
'switch_on');
304 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproducton&token='.
newToken().
'&value='.urlencode($file).
'">';
305 print img_picto($langs->trans(
"Disabled"),
'switch_off');
308 print
'<td class="center">';
309 $s = $modBarCode->getToolTip($langs,
null, -1);
310 print $form->textwithpicto(
'', $s, 1);
320 print
dolButtonToOpenUrlInDialogPopup(
'barcodeinitproduct', $langs->trans(
"MassBarcodeInit"), $langs->trans(
"GoOnThisPageToInitBarCode").
' '.img_picto(
'',
'url'),
'/barcode/codeinit.php',
'',
'small');
321 print
'<br><br><br>';
328 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"ThirdParty").
")",
'',
'company');
330 print
'<div class="div-table-responsive-no-min">';
331 print
'<table class="noborder centpercent">';
332 print
'<tr class="liste_titre">';
333 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
334 print
'<td>'.$langs->trans(
"Description").
'</td>';
335 print
'<td>'.$langs->trans(
"Example").
'</td>';
336 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
337 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
340 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'),
$conf->modules_parts[
'barcode']);
342 foreach ($dirbarcodenum as $dirroot) {
345 $handle = @opendir($dir);
346 if (is_resource($handle)) {
347 while (($file = readdir($handle)) !==
false) {
348 if (preg_match(
'/^mod_barcode_thirdparty_.*php$/', $file)) {
358 $modBarCode =
new $file();
360 '@phan-var-force ModeleNumRefBarCode $modBarCode';
362 print
'<tr class="oddeven">';
363 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
364 print $modBarCode->info($langs);
366 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
369 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyoff&token='.
newToken().
'&value='.urlencode($file).
'">';
370 print img_picto($langs->trans(
"Activated"),
'switch_on');
373 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyon&token='.
newToken().
'&value='.urlencode($file).
'">';
374 print img_picto($langs->trans(
"Disabled"),
'switch_off');
377 print
'<td class="center">';
378 $s = $modBarCode->getToolTip($langs,
null, -1);
379 print $form->textwithpicto(
'', $s, 1);
389 print
dolButtonToOpenUrlInDialogPopup(
'barcodeinitthirdparty', $langs->trans(
"MassBarcodeInit"), $langs->trans(
"GoOnThisPageToInitBarCode").
' '.img_picto(
'',
'url'),
'/barcode/codeinit.php',
'',
'small');
390 print
'<br><br><br>';
399 print
load_fiche_titre($langs->trans(
"BarcodeEncodeModule"),
'',
'barcode');
401 if (empty(
$conf->use_javascript_ajax)) {
402 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="form_engine" spellcheck="false">';
403 print
'<input type="hidden" name="token" value="'.newToken().
'">';
404 print
'<input type="hidden" name="action" value="updateengine">';
407 print
'<div class="div-table-responsive-no-min">';
408 print
'<table class="noborder centpercent">';
409 print
'<tr class="liste_titre">';
410 print
'<td>'.$langs->trans(
"Name").
'</td>';
411 print
'<td>'.$langs->trans(
"Description").
'</td>';
412 print
'<td width="200" class="center">'.$langs->trans(
"Example").
'</td>';
413 print
'<td class="center" width="60">'.$langs->trans(
"CodeBarGenerator").
'</td>';
416 $sql =
"SELECT rowid, code as encoding, libelle as label, coder, example";
417 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
418 $sql .=
" WHERE entity = ".((int)
$conf->entity);
419 $sql .=
" ORDER BY code";
422 $resql = $db->query($sql);
424 $num = $db->num_rows($resql);
428 $obj = $db->fetch_object($resql);
430 print
'<tr class="oddeven">';
431 print
'<td width="100">';
434 print $langs->trans(
'BarcodeDesc'.$obj->encoding);
441 print
'<td class="center">';
442 if ($obj->coder && $obj->coder != -1) {
445 foreach ($dirbarcode as $reldir) {
450 if (!is_dir($newdir)) {
454 $result = @include_once $newdir.$obj->coder.
'.modules.php';
460 $classname =
"mod".ucfirst($obj->coder);
461 if (class_exists($classname)) {
463 '@phan-var-force ModeleBarCode $module';
464 if (
$module->encodingIsSupported($obj->encoding)) {
466 $result =
$module->writeBarCode($obj->example, $obj->encoding,
'Y');
468 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).
'&code='.urlencode($obj->example).
'&encoding='.urlencode($obj->encoding);
470 print
'<img src="'.$url.
'" title="'.$obj->example.
'" border="0">';
472 print $langs->trans(
"FormatNotSupportedByGenerator");
475 print
'ErrorClassNotFoundInModule '.$classname.
' '.$obj->coder;
479 print
'<span class="opacitymedium">'.$langs->trans(
"ChooseABarCode").
'</span>';
483 print
'<td class="center">';
484 print $formbarcode->setBarcodeEncoder($obj->coder, $barcodelist, $obj->rowid,
'form'.$i);
485 print
"</td></tr>\n";
493 if (empty(
$conf->use_javascript_ajax)) {
494 print $form->buttonsSaveCancel(
"Save",
'');
507 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" spellcheck="false">';
508 print
'<input type="hidden" name="token" value="'.newToken().
'">';
509 print
"<input type=\"hidden\" name=\"action\" value=\"update\">";
511 print
'<div class="div-table-responsive-no-min">';
512 print
'<table class="noborder centpercent">';
513 print
'<tr class="liste_titre">';
514 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
515 print
'<td width="60" class="center"></td>';
516 print
'<td> </td>';
520 if (
getDolGlobalString(
"BARCODE_ALLOW_CLI_BARCODE_GENERATOR") && !isset($_SERVER[
'WINDIR'])) {
521 print
'<tr class="oddeven">';
522 print
'<td>'.$langs->trans(
"GenbarcodeLocation").
'</td>';
523 print
'<td width="60" class="center">';
524 print
'<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.getDolGlobalString(
'GENBARCODE_LOCATION').
'">';
526 $langs->load(
"errors");
527 print
'<br><span class="error">'.$langs->trans(
"ErrorFileNotFound",
getDolGlobalString(
'GENBARCODE_LOCATION')).
'</span>';
530 print
'<td> </td>';
536 print
'<tr class="oddeven">';
537 print
'<td>'.img_picto(
'',
'product',
'class="pictofixedwidth"').$langs->trans(
"SetDefaultBarcodeTypeProducts").
'</td>';
538 print
'<td width="60" class="right">';
539 print $formbarcode->selectBarcodeType(
getDolGlobalInt(
'PRODUIT_DEFAULT_BARCODE_TYPE'),
"PRODUIT_DEFAULT_BARCODE_TYPE", 1);
541 print
'<td> </td>';
547 print
'<tr class="oddeven">';
548 print
'<td>'.img_picto(
'',
'company',
'class="pictofixedwidth"').$langs->trans(
"SetDefaultBarcodeTypeThirdParties").
'</td>';
549 print
'<td width="60" class="right">';
550 print $formbarcode->selectBarcodeType(
getDolGlobalInt(
'GENBARCODE_BARCODETYPE_THIRDPARTY'),
"GENBARCODE_BARCODETYPE_THIRDPARTY", 1);
552 print
'<td> </td>';
559 print
'<div class="tabsAction">';
560 print
'<input type="submit" class="button" name="submit_GENBARCODE_BARCODETYPE_THIRDPARTY" value="'.$langs->trans(
"Modify").
'">';
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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(! $sortfield) if(! $sortorder) $module
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.