29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
42$action =
GETPOST(
'action',
'aZ09');
43$modulepart =
GETPOST(
'modulepart',
'aZ09');
50include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
52if ($action ==
'setbarcodeproducton') {
53 $barcodenumberingmodule =
GETPOST(
'value',
'alpha');
54 $res =
dolibarr_set_const($db,
"BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule,
'chaine', 0,
'', $conf->entity);
55 if ($barcodenumberingmodule ==
'mod_barcode_product_standard' && !
getDolGlobalString(
'BARCODE_STANDARD_PRODUCT_MASK')) {
56 $res =
dolibarr_set_const($db,
"BARCODE_STANDARD_PRODUCT_MASK",
'04{0000000000}',
'chaine', 0,
'', $conf->entity);
58} elseif ($action ==
'setbarcodeproductoff') {
62if ($action ==
'setbarcodethirdpartyon') {
63 $barcodenumberingmodule =
GETPOST(
'value',
'alpha');
64 $res =
dolibarr_set_const($db,
"BARCODE_THIRDPARTY_ADDON_NUM", $barcodenumberingmodule,
'chaine', 0,
'', $conf->entity);
65 if ($barcodenumberingmodule ==
'mod_barcode_thirdparty_standard' && !
getDolGlobalString(
'BARCODE_STANDARD_THIRDPARTY_MASK')) {
66 $res =
dolibarr_set_const($db,
"BARCODE_STANDARD_THIRDPARTY_MASK",
'04{0000000000}',
'chaine', 0,
'', $conf->entity);
68} elseif ($action ==
'setbarcodethirdpartyoff') {
72if ($action ==
'setcoder') {
73 $coder =
GETPOST(
'coder',
'alpha');
75 $sqlp =
"UPDATE ".MAIN_DB_PREFIX.
"c_barcode_type";
76 $sqlp .=
" SET coder = '".$db->escape($coder).
"'";
77 $sqlp .=
" WHERE rowid = ".((int) $code_id);
78 $sqlp .=
" AND entity = ".$conf->entity;
80 $resql = $db->query($sqlp);
84} elseif ($action ==
'update') {
85 $location =
GETPOST(
'GENBARCODE_LOCATION',
'alpha');
86 $res =
dolibarr_set_const($db,
"GENBARCODE_LOCATION", $location,
'chaine', 0,
'', $conf->entity);
87 $coder_id =
GETPOST(
'PRODUIT_DEFAULT_BARCODE_TYPE',
'alpha');
88 $res =
dolibarr_set_const($db,
"PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,
'chaine', 0,
'', $conf->entity);
89 $coder_id =
GETPOST(
'GENBARCODE_BARCODETYPE_THIRDPARTY',
'alpha');
90 $res =
dolibarr_set_const($db,
"GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,
'chaine', 0,
'', $conf->entity);
97} elseif ($action ==
'updateengine') {
98 $sql =
"SELECT rowid, coder";
99 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
100 $sql .=
" WHERE entity = ".$conf->entity;
101 $sql .=
" ORDER BY code";
103 $resql = $db->query($sql);
105 $num = $db->num_rows($resql);
109 $obj = $db->fetch_object($resql);
111 if (
GETPOST(
'coder'.$obj->rowid,
'alpha')) {
112 $coder =
GETPOST(
'coder'.$obj->rowid,
'alpha');
113 $code_id = $obj->rowid;
115 $sqlp =
"UPDATE ".MAIN_DB_PREFIX.
"c_barcode_type";
116 $sqlp .=
" SET coder = '".$db->escape($coder).
"'";
117 $sqlp .=
" WHERE rowid = ".((int) $code_id);
118 $sqlp .=
" AND entity = ".$conf->entity;
120 $upsql = $db->query($sqlp);
136$form =
new Form($db);
139$help_url =
'EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra|DE:Modul_Barcode';
140llxHeader(
'', $langs->trans(
"BarcodeSetup"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-admin page-barcode');
142$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
143print
load_fiche_titre($langs->trans(
"BarcodeSetup"), $linkback,
'title_setup');
146$barcodelist = array();
152$dirbarcode = array_merge(array(
"/core/modules/barcode/doc/"), $conf->modules_parts[
'barcode']);
154foreach ($dirbarcode as $reldir) {
159 if (!is_dir($newdir)) {
163 $handle = @opendir($newdir);
164 if (is_resource($handle)) {
165 while (($file = readdir($handle)) !==
false) {
166 if (substr($file, 0, 1) !=
'.' && substr($file, 0, 3) !=
'CVS') {
167 if (is_readable($newdir.$file)) {
168 if (preg_match(
'/(.*)\.modules\.php$/i', $file, $reg)) {
172 require_once $newdir.$file;
173 $classname =
"mod".ucfirst($filebis);
174 $module =
new $classname($db);
177 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
180 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
184 if ($module->isEnabled()) {
185 $barcodelist[$filebis] = $module->info($langs);
193'@phan-var-force array<string,ModeleBarCode> $barcodelist';
197if (isModEnabled(
'product')) {
198 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"Product").
")",
'',
'');
200 print
'<div class="div-table-responsive-no-min">';
201 print
'<table class="noborder centpercent">';
202 print
'<tr class="liste_titre">';
203 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
204 print
'<td>'.$langs->trans(
"Description").
'</td>';
205 print
'<td>'.$langs->trans(
"Example").
'</td>';
206 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
207 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
210 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
212 foreach ($dirbarcodenum as $dirroot) {
215 $handle = @opendir($dir);
216 if (is_resource($handle)) {
217 while (($file = readdir($handle)) !==
false) {
218 if (preg_match(
'/^mod_barcode_product_.*php$/', $file)) {
219 $file = substr($file, 0,
dol_strlen($file) - 4);
227 $modBarCode =
new $file();
228 '@phan-var-force ModeleNumRefBarCode $modBarCode';
230 print
'<tr class="oddeven">';
231 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
232 print $modBarCode->info($langs);
234 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
237 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproductoff&token='.
newToken().
'&value='.urlencode($file).
'">';
238 print
img_picto($langs->trans(
"Activated"),
'switch_on');
241 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproducton&token='.
newToken().
'&value='.urlencode($file).
'">';
242 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
245 print
'<td class="center">';
246 $s = $modBarCode->getToolTip($langs,
null, -1);
247 print $form->textwithpicto(
'', $s, 1);
260if (isModEnabled(
'societe')) {
261 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"ThirdParty").
")",
'',
'');
263 print
'<div class="div-table-responsive-no-min">';
264 print
'<table class="noborder centpercent">';
265 print
'<tr class="liste_titre">';
266 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
267 print
'<td>'.$langs->trans(
"Description").
'</td>';
268 print
'<td>'.$langs->trans(
"Example").
'</td>';
269 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
270 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
273 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
275 foreach ($dirbarcodenum as $dirroot) {
278 $handle = @opendir($dir);
279 if (is_resource($handle)) {
280 while (($file = readdir($handle)) !==
false) {
281 if (preg_match(
'/^mod_barcode_thirdparty_.*php$/', $file)) {
282 $file = substr($file, 0,
dol_strlen($file) - 4);
290 $modBarCode =
new $file();
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";
297 if (
getDolGlobalString(
'BARCODE_THIRDPARTY_ADDON_NUM') && $conf->global->BARCODE_THIRDPARTY_ADDON_NUM ==
"$file") {
298 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyoff&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=setbarcodethirdpartyon&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);
327if (empty($conf->use_javascript_ajax)) {
328 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="form_engine">';
329 print
'<input type="hidden" name="token" value="'.newToken().
'">';
330 print
'<input type="hidden" name="action" value="updateengine">';
333print
'<div class="div-table-responsive-no-min">';
334print
'<table class="noborder centpercent">';
335print
'<tr class="liste_titre">';
336print
'<td>'.$langs->trans(
"Name").
'</td>';
337print
'<td>'.$langs->trans(
"Description").
'</td>';
338print
'<td width="200" class="center">'.$langs->trans(
"Example").
'</td>';
339print
'<td class="center" width="60">'.$langs->trans(
"CodeBarGenerator").
'</td>';
342$sql =
"SELECT rowid, code as encoding, libelle as label, coder, example";
343$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
344$sql .=
" WHERE entity = ".$conf->entity;
345$sql .=
" ORDER BY code";
348$resql = $db->query($sql);
350 $num = $db->num_rows($resql);
354 $obj = $db->fetch_object($resql);
356 print
'<tr class="oddeven">';
357 print
'<td width="100">';
360 print $langs->trans(
'BarcodeDesc'.$obj->encoding);
367 print
'<td class="center">';
368 if ($obj->coder && $obj->coder != -1) {
371 foreach ($dirbarcode as $reldir) {
376 if (!is_dir($newdir)) {
380 $result = @include_once $newdir.$obj->coder.
'.modules.php';
386 $classname =
"mod".ucfirst($obj->coder);
387 if (class_exists($classname)) {
388 $module =
new $classname($db);
389 if ($module->encodingIsSupported($obj->encoding)) {
391 $result = $module->writeBarCode($obj->example, $obj->encoding,
'Y');
393 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).
'&code='.urlencode($obj->example).
'&encoding='.urlencode($obj->encoding);
395 print
'<img src="'.$url.
'" title="'.$obj->example.
'" border="0">';
397 print $langs->trans(
"FormatNotSupportedByGenerator");
400 print
'ErrorClassNotFoundInModule '.$classname.
' '.$obj->coder;
404 print
'<span class="opacitymedium">'.$langs->trans(
"ChooseABarCode").
'</span>';
408 print
'<td class="center">';
409 print $formbarcode->setBarcodeEncoder($obj->coder, $barcodelist, $obj->rowid,
'form'.$i);
410 print
"</td></tr>\n";
418if (empty($conf->use_javascript_ajax)) {
419 print $form->buttonsSaveCancel(
"Save",
'');
430print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
431print
'<input type="hidden" name="token" value="'.newToken().
'">';
432print
"<input type=\"hidden\" name=\"action\" value=\"update\">";
434print
'<div class="div-table-responsive-no-min">';
435print
'<table class="noborder centpercent">';
436print
'<tr class="liste_titre">';
437print
'<td>'.$langs->trans(
"Parameter").
'</td>';
438print
'<td width="60" class="center">'.$langs->trans(
"Value").
'</td>';
439print
'<td> </td>';
443if (!isset($_SERVER[
'WINDIR'])) {
444 print
'<tr class="oddeven">';
445 print
'<td>'.$langs->trans(
"GenbarcodeLocation").
'</td>';
446 print
'<td width="60" class="center">';
447 print
'<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.getDolGlobalString(
'GENBARCODE_LOCATION').
'">';
448 if (
getDolGlobalString(
'GENBARCODE_LOCATION') && !@file_exists($conf->global->GENBARCODE_LOCATION)) {
449 $langs->load(
"errors");
450 print
'<br><span class="error">'.$langs->trans(
"ErrorFileNotFound",
getDolGlobalString(
'GENBARCODE_LOCATION')).
'</span>';
453 print
'<td> </td>';
458if (isModEnabled(
'product')) {
459 print
'<tr class="oddeven">';
460 print
'<td>'.$langs->trans(
"SetDefaultBarcodeTypeProducts").
'</td>';
461 print
'<td width="60" class="right">';
462 print $formbarcode->selectBarcodeType(
getDolGlobalString(
'PRODUIT_DEFAULT_BARCODE_TYPE'),
"PRODUIT_DEFAULT_BARCODE_TYPE", 1);
464 print
'<td> </td>';
469if (isModEnabled(
'societe')) {
470 print
'<tr class="oddeven">';
471 print
'<td>'.$langs->trans(
"SetDefaultBarcodeTypeThirdParties").
'</td>';
472 print
'<td width="60" class="right">';
473 print $formbarcode->selectBarcodeType(
getDolGlobalString(
'GENBARCODE_BARCODETYPE_THIRDPARTY'),
"GENBARCODE_BARCODETYPE_THIRDPARTY", 1);
475 print
'<td> </td>';
482print
'<div class="tabsAction">';
483print
'<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.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.