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 = ".$conf->entity;
89 $resql = $db->query($sqlp);
93} elseif ($action ==
'update') {
94 $location =
GETPOST(
'GENBARCODE_LOCATION',
'alpha');
95 $res =
dolibarr_set_const($db,
"GENBARCODE_LOCATION", $location,
'chaine', 0,
'', $conf->entity);
96 $coder_id =
GETPOST(
'PRODUIT_DEFAULT_BARCODE_TYPE',
'alpha');
97 $res =
dolibarr_set_const($db,
"PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,
'chaine', 0,
'', $conf->entity);
98 $coder_id =
GETPOST(
'GENBARCODE_BARCODETYPE_THIRDPARTY',
'alpha');
99 $res =
dolibarr_set_const($db,
"GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,
'chaine', 0,
'', $conf->entity);
106} elseif ($action ==
'updateengine') {
107 $sql =
"SELECT rowid, coder";
108 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
109 $sql .=
" WHERE entity = ".$conf->entity;
110 $sql .=
" ORDER BY code";
112 $resql = $db->query($sql);
114 $num = $db->num_rows($resql);
118 $obj = $db->fetch_object($resql);
120 if (
GETPOST(
'coder'.$obj->rowid,
'alpha')) {
121 $coder =
GETPOST(
'coder'.$obj->rowid,
'alpha');
122 $code_id = $obj->rowid;
124 $sqlp =
"UPDATE ".MAIN_DB_PREFIX.
"c_barcode_type";
125 $sqlp .=
" SET coder = '".$db->escape($coder).
"'";
126 $sqlp .=
" WHERE rowid = ".((int) $code_id);
127 $sqlp .=
" AND entity = ".$conf->entity;
129 $upsql = $db->query($sqlp);
145$form =
new Form($db);
148$help_url =
'EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra|DE:Modul_Barcode';
149llxHeader(
'', $langs->trans(
"BarcodeSetup"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-admin page-barcode');
151$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>';
153print
load_fiche_titre($langs->trans(
"BarcodeSetup"), $linkback,
'title_setup');
161print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
162print
'<input type="hidden" name="token" value="'.newToken().
'">';
163print
"<input type=\"hidden\" name=\"action\" value=\"update\">";
165print
'<div class="div-table-responsive-no-min">';
166print
'<table class="noborder centpercent">';
167print
'<tr class="liste_titre">';
168print
'<td>'.$langs->trans(
"Feature").
'</td>';
169print
'<td width="60" class="center"></td>';
170print
'<td> </td>';
175 print
'<tr class="oddeven">';
176 print
'<td>'.img_picto(
'',
'product',
'class="pictofixedwidth"').$langs->trans(
"UseBarCodeForProducts").
'</td>';
177 print
'<td width="60" class="right">';
178 print ajax_constantonoff(
'BARCODE_USE_ON_PRODUCT', array(),
null, 0, 0, 1);
180 print
'<td> </td>';
186 print
'<tr class="oddeven">';
187 print
'<td>'.img_picto(
'',
'company',
'class="pictofixedwidth"').$langs->trans(
"UseBarCodeForThirdParties").
'</td>';
188 print
'<td width="60" class="right">';
189 print ajax_constantonoff(
'BARCODE_USE_ON_THIRDPARTY', array(),
null, 0, 0, 1);
191 print
'<td> </td>';
203$barcodelist = array();
209$dirbarcode = array_merge(array(
"/core/modules/barcode/doc/"), $conf->modules_parts[
'barcode']);
211foreach ($dirbarcode as $reldir) {
216 if (!is_dir($newdir)) {
220 $handle = @opendir($newdir);
221 if (is_resource($handle)) {
222 while (($file = readdir($handle)) !==
false) {
223 if (substr($file, 0, 1) !=
'.' && substr($file, 0, 3) !=
'CVS') {
224 if (is_readable($newdir.$file)) {
226 if (preg_match(
'/(.*)\.modules\.php$/i', $file, $reg)) {
230 require_once $newdir.$file;
231 $classname =
"mod".ucfirst($filebis);
232 $module =
new $classname($db);
234 '@phan-var-force ModeleBarCode $module';
237 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
240 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
244 if ($module->isEnabled()) {
245 $barcodelist[$filebis] = $module->info($langs);
253'@phan-var-force array<string,string> $barcodelist';
258 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"Product").
")",
'',
'product');
260 print
'<div class="div-table-responsive-no-min">';
261 print
'<table class="noborder centpercent">';
262 print
'<tr class="liste_titre">';
263 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
264 print
'<td>'.$langs->trans(
"Description").
'</td>';
265 print
'<td>'.$langs->trans(
"Example").
'</td>';
266 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
267 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
270 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
272 foreach ($dirbarcodenum as $dirroot) {
275 $handle = @opendir($dir);
276 if (is_resource($handle)) {
277 while (($file = readdir($handle)) !==
false) {
278 if (preg_match(
'/^mod_barcode_product_.*php$/', $file)) {
279 $file = substr($file, 0,
dol_strlen($file) - 4);
288 $modBarCode =
new $file();
289 '@phan-var-force ModeleNumRefBarCode $modBarCode';
291 print
'<tr class="oddeven">';
292 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
293 print $modBarCode->info($langs);
295 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
298 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproductoff&token='.
newToken().
'&value='.urlencode($file).
'">';
299 print
img_picto($langs->trans(
"Activated"),
'switch_on');
302 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproducton&token='.
newToken().
'&value='.urlencode($file).
'">';
303 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
306 print
'<td class="center">';
307 $s = $modBarCode->getToolTip($langs,
null, -1);
308 print $form->textwithpicto(
'', $s, 1);
318 print
dolButtonToOpenUrlInDialogPopup(
'barcodeinitproduct', $langs->trans(
"MassBarcodeInit"), $langs->trans(
"GoOnThisPageToInitBarCode").
' '.
img_picto(
'',
'url'),
'/barcode/codeinit.php',
'',
'small');
319 print
'<br><br><br>';
326 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"ThirdParty").
")",
'',
'company');
328 print
'<div class="div-table-responsive-no-min">';
329 print
'<table class="noborder centpercent">';
330 print
'<tr class="liste_titre">';
331 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
332 print
'<td>'.$langs->trans(
"Description").
'</td>';
333 print
'<td>'.$langs->trans(
"Example").
'</td>';
334 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
335 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
338 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
340 foreach ($dirbarcodenum as $dirroot) {
343 $handle = @opendir($dir);
344 if (is_resource($handle)) {
345 while (($file = readdir($handle)) !==
false) {
346 if (preg_match(
'/^mod_barcode_thirdparty_.*php$/', $file)) {
347 $file = substr($file, 0,
dol_strlen($file) - 4);
356 $modBarCode =
new $file();
358 '@phan-var-force ModeleNumRefBarCode $modBarCode';
360 print
'<tr class="oddeven">';
361 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
362 print $modBarCode->info($langs);
364 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
367 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyoff&token='.
newToken().
'&value='.urlencode($file).
'">';
368 print
img_picto($langs->trans(
"Activated"),
'switch_on');
371 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyon&token='.
newToken().
'&value='.urlencode($file).
'">';
372 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
375 print
'<td class="center">';
376 $s = $modBarCode->getToolTip($langs,
null, -1);
377 print $form->textwithpicto(
'', $s, 1);
387 print
dolButtonToOpenUrlInDialogPopup(
'barcodeinitthirdparty', $langs->trans(
"MassBarcodeInit"), $langs->trans(
"GoOnThisPageToInitBarCode").
' '.
img_picto(
'',
'url'),
'/barcode/codeinit.php',
'',
'small');
388 print
'<br><br><br>';
399 if (empty($conf->use_javascript_ajax)) {
400 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="form_engine">';
401 print
'<input type="hidden" name="token" value="'.newToken().
'">';
402 print
'<input type="hidden" name="action" value="updateengine">';
405 print
'<div class="div-table-responsive-no-min">';
406 print
'<table class="noborder centpercent">';
407 print
'<tr class="liste_titre">';
408 print
'<td>'.$langs->trans(
"Name").
'</td>';
409 print
'<td>'.$langs->trans(
"Description").
'</td>';
410 print
'<td width="200" class="center">'.$langs->trans(
"Example").
'</td>';
411 print
'<td class="center" width="60">'.$langs->trans(
"CodeBarGenerator").
'</td>';
414 $sql =
"SELECT rowid, code as encoding, libelle as label, coder, example";
415 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
416 $sql .=
" WHERE entity = ".$conf->entity;
417 $sql .=
" ORDER BY code";
420 $resql = $db->query($sql);
422 $num = $db->num_rows($resql);
426 $obj = $db->fetch_object($resql);
428 print
'<tr class="oddeven">';
429 print
'<td width="100">';
432 print $langs->trans(
'BarcodeDesc'.$obj->encoding);
439 print
'<td class="center">';
440 if ($obj->coder && $obj->coder != -1) {
443 foreach ($dirbarcode as $reldir) {
448 if (!is_dir($newdir)) {
452 $result = @include_once $newdir.$obj->coder.
'.modules.php';
458 $classname =
"mod".ucfirst($obj->coder);
459 if (class_exists($classname)) {
460 $module =
new $classname($db);
461 '@phan-var-force ModeleBarCode $module';
462 if ($module->encodingIsSupported($obj->encoding)) {
464 $result = $module->writeBarCode($obj->example, $obj->encoding,
'Y');
466 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).
'&code='.urlencode($obj->example).
'&encoding='.urlencode($obj->encoding);
468 print
'<img src="'.$url.
'" title="'.$obj->example.
'" border="0">';
470 print $langs->trans(
"FormatNotSupportedByGenerator");
473 print
'ErrorClassNotFoundInModule '.$classname.
' '.$obj->coder;
477 print
'<span class="opacitymedium">'.$langs->trans(
"ChooseABarCode").
'</span>';
481 print
'<td class="center">';
482 print $formbarcode->setBarcodeEncoder($obj->coder, $barcodelist, $obj->rowid,
'form'.$i);
483 print
"</td></tr>\n";
491 if (empty($conf->use_javascript_ajax)) {
492 print $form->buttonsSaveCancel(
"Save",
'');
505 print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
506 print
'<input type="hidden" name="token" value="'.newToken().
'">';
507 print
"<input type=\"hidden\" name=\"action\" value=\"update\">";
509 print
'<div class="div-table-responsive-no-min">';
510 print
'<table class="noborder centpercent">';
511 print
'<tr class="liste_titre">';
512 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
513 print
'<td width="60" class="center"></td>';
514 print
'<td> </td>';
518 if (!isset($_SERVER[
'WINDIR'])) {
519 print
'<tr class="oddeven">';
520 print
'<td>'.$langs->trans(
"GenbarcodeLocation").
'</td>';
521 print
'<td width="60" class="center">';
522 print
'<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.getDolGlobalString(
'GENBARCODE_LOCATION').
'">';
523 if (
getDolGlobalString(
'GENBARCODE_LOCATION') && !@file_exists($conf->global->GENBARCODE_LOCATION)) {
524 $langs->load(
"errors");
525 print
'<br><span class="error">'.$langs->trans(
"ErrorFileNotFound",
getDolGlobalString(
'GENBARCODE_LOCATION')).
'</span>';
528 print
'<td> </td>';
534 print
'<tr class="oddeven">';
535 print
'<td>'.img_picto(
'',
'product',
'class="pictofixedwidth"').$langs->trans(
"SetDefaultBarcodeTypeProducts").
'</td>';
536 print
'<td width="60" class="right">';
537 print $formbarcode->selectBarcodeType(
getDolGlobalInt(
'PRODUIT_DEFAULT_BARCODE_TYPE'),
"PRODUIT_DEFAULT_BARCODE_TYPE", 1);
539 print
'<td> </td>';
545 print
'<tr class="oddeven">';
546 print
'<td>'.img_picto(
'',
'company',
'class="pictofixedwidth"').$langs->trans(
"SetDefaultBarcodeTypeThirdParties").
'</td>';
547 print
'<td width="60" class="right">';
548 print $formbarcode->selectBarcodeType(
getDolGlobalInt(
'GENBARCODE_BARCODETYPE_THIRDPARTY'),
"GENBARCODE_BARCODETYPE_THIRDPARTY", 1);
550 print
'<td> </td>';
557 print
'<div class="tabsAction">';
558 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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
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.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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)
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_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.