28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
41$action =
GETPOST(
'action',
'aZ09');
42$modulepart =
GETPOST(
'modulepart',
'aZ09');
49include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
51if ($action ==
'setbarcodeproducton') {
52 $barcodenumberingmodule =
GETPOST(
'value',
'alpha');
53 $res =
dolibarr_set_const($db,
"BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule,
'chaine', 0,
'', $conf->entity);
54 if ($barcodenumberingmodule ==
'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) {
55 $res =
dolibarr_set_const($db,
"BARCODE_STANDARD_PRODUCT_MASK",
'04{0000000000}',
'chaine', 0,
'', $conf->entity);
57} elseif ($action ==
'setbarcodeproductoff') {
61if ($action ==
'setbarcodethirdpartyon') {
62 $barcodenumberingmodule =
GETPOST(
'value',
'alpha');
63 $res =
dolibarr_set_const($db,
"BARCODE_THIRDPARTY_ADDON_NUM", $barcodenumberingmodule,
'chaine', 0,
'', $conf->entity);
64 if ($barcodenumberingmodule ==
'mod_barcode_thirdparty_standard' && empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK)) {
65 $res =
dolibarr_set_const($db,
"BARCODE_STANDARD_THIRDPARTY_MASK",
'04{0000000000}',
'chaine', 0,
'', $conf->entity);
67} elseif ($action ==
'setbarcodethirdpartyoff') {
71if ($action ==
'setcoder') {
72 $coder =
GETPOST(
'coder',
'alpha');
73 $code_id =
GETPOST(
'code_id',
'int');
74 $sqlp =
"UPDATE ".MAIN_DB_PREFIX.
"c_barcode_type";
75 $sqlp .=
" SET coder = '".$db->escape($coder).
"'";
76 $sqlp .=
" WHERE rowid = ".((int) $code_id);
77 $sqlp .=
" AND entity = ".$conf->entity;
79 $resql = $db->query($sqlp);
83} elseif ($action ==
'update') {
84 $location =
GETPOST(
'GENBARCODE_LOCATION',
'alpha');
85 $res =
dolibarr_set_const($db,
"GENBARCODE_LOCATION", $location,
'chaine', 0,
'', $conf->entity);
86 $coder_id =
GETPOST(
'PRODUIT_DEFAULT_BARCODE_TYPE',
'alpha');
87 $res =
dolibarr_set_const($db,
"PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,
'chaine', 0,
'', $conf->entity);
88 $coder_id =
GETPOST(
'GENBARCODE_BARCODETYPE_THIRDPARTY',
'alpha');
89 $res =
dolibarr_set_const($db,
"GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,
'chaine', 0,
'', $conf->entity);
96} elseif ($action ==
'updateengine') {
97 $sql =
"SELECT rowid, coder";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
99 $sql .=
" WHERE entity = ".$conf->entity;
100 $sql .=
" ORDER BY code";
102 $resql = $db->query($sql);
104 $num = $db->num_rows($resql);
108 $obj = $db->fetch_object($resql);
110 if (
GETPOST(
'coder'.$obj->rowid,
'alpha')) {
111 $coder =
GETPOST(
'coder'.$obj->rowid,
'alpha');
112 $code_id = $obj->rowid;
114 $sqlp =
"UPDATE ".MAIN_DB_PREFIX.
"c_barcode_type";
115 $sqlp .=
" SET coder = '".$db->escape($coder).
"'";
116 $sqlp .=
" WHERE rowid = ".((int) $code_id);
117 $sqlp .=
" AND entity = ".$conf->entity;
119 $upsql = $db->query($sqlp);
135$form =
new Form($db);
138$help_url =
'EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra|DE:Modul_Barcode';
139llxHeader(
'', $langs->trans(
"BarcodeSetup"), $help_url);
141$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
142print
load_fiche_titre($langs->trans(
"BarcodeSetup"), $linkback,
'title_setup');
145$barcodelist = array();
151$dirbarcode = array_merge(array(
"/core/modules/barcode/doc/"), $conf->modules_parts[
'barcode']);
153foreach ($dirbarcode as $reldir) {
158 if (!is_dir($newdir)) {
162 $handle = @opendir($newdir);
163 if (is_resource($handle)) {
164 while (($file = readdir($handle)) !==
false) {
165 if (substr($file, 0, 1) <>
'.' && substr($file, 0, 3) <>
'CVS') {
166 if (is_readable($newdir.$file)) {
167 if (preg_match(
'/(.*)\.modules\.php$/i', $file, $reg)) {
171 require_once $newdir.$file;
172 $classname =
"mod".ucfirst($filebis);
173 $module =
new $classname($db);
176 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
179 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
183 if ($module->isEnabled()) {
184 $barcodelist[$filebis] = $module->info();
196if (isModEnabled(
'product')) {
197 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"Product").
")",
'',
'');
199 print
'<div class="div-table-responsive-no-min">';
200 print
'<table class="noborder centpercent">';
201 print
'<tr class="liste_titre">';
202 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
203 print
'<td>'.$langs->trans(
"Description").
'</td>';
204 print
'<td>'.$langs->trans(
"Example").
'</td>';
205 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
206 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
209 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
211 foreach ($dirbarcodenum as $dirroot) {
214 $handle = @opendir($dir);
215 if (is_resource($handle)) {
216 while (($file = readdir($handle)) !==
false) {
217 if (preg_match(
'/^mod_barcode_product_.*php$/', $file)) {
218 $file = substr($file, 0,
dol_strlen($file) - 4);
226 $modBarCode =
new $file();
228 print
'<tr class="oddeven">';
229 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
230 print $modBarCode->info($langs);
232 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
234 if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM) && $conf->global->BARCODE_PRODUCT_ADDON_NUM ==
"$file") {
235 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproductoff&token='.newToken().
'&value='.urlencode($file).
'">';
236 print
img_picto($langs->trans(
"Activated"),
'switch_on');
239 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproducton&token='.newToken().
'&value='.urlencode($file).
'">';
240 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
243 print
'<td class="center">';
244 $s = $modBarCode->getToolTip($langs,
null, -1);
245 print $form->textwithpicto(
'', $s, 1);
258if (isModEnabled(
'societe')) {
259 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"ThirdParty").
")",
'',
'');
261 print
'<div class="div-table-responsive-no-min">';
262 print
'<table class="noborder centpercent">';
263 print
'<tr class="liste_titre">';
264 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
265 print
'<td>'.$langs->trans(
"Description").
'</td>';
266 print
'<td>'.$langs->trans(
"Example").
'</td>';
267 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
268 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
271 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
273 foreach ($dirbarcodenum as $dirroot) {
276 $handle = @opendir($dir);
277 if (is_resource($handle)) {
278 while (($file = readdir($handle)) !==
false) {
279 if (preg_match(
'/^mod_barcode_thirdparty_.*php$/', $file)) {
280 $file = substr($file, 0,
dol_strlen($file) - 4);
288 $modBarCode =
new $file();
289 print
'<tr class="oddeven">';
290 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
291 print $modBarCode->info($langs);
293 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
295 if (!empty($conf->global->BARCODE_THIRDPARTY_ADDON_NUM) && $conf->global->BARCODE_THIRDPARTY_ADDON_NUM ==
"$file") {
296 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyoff&token='.newToken().
'&value='.urlencode($file).
'">';
297 print
img_picto($langs->trans(
"Activated"),
'switch_on');
300 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyon&token='.newToken().
'&value='.urlencode($file).
'">';
301 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
304 print
'<td class="center">';
305 $s = $modBarCode->getToolTip($langs,
null, -1);
306 print $form->textwithpicto(
'', $s, 1);
325if (empty($conf->use_javascript_ajax)) {
326 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="form_engine">';
327 print
'<input type="hidden" name="token" value="'.newToken().
'">';
328 print
'<input type="hidden" name="action" value="updateengine">';
331print
'<div class="div-table-responsive-no-min">';
332print
'<table class="noborder centpercent">';
333print
'<tr class="liste_titre">';
334print
'<td>'.$langs->trans(
"Name").
'</td>';
335print
'<td>'.$langs->trans(
"Description").
'</td>';
336print
'<td width="200" class="center">'.$langs->trans(
"Example").
'</td>';
337print
'<td class="center" width="60">'.$langs->trans(
"CodeBarGenerator").
'</td>';
340$sql =
"SELECT rowid, code as encoding, libelle as label, coder, example";
341$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
342$sql .=
" WHERE entity = ".$conf->entity;
343$sql .=
" ORDER BY code";
346$resql = $db->query($sql);
348 $num = $db->num_rows($resql);
352 $obj = $db->fetch_object($resql);
354 print
'<tr class="oddeven">';
355 print
'<td width="100">';
358 print $langs->trans(
'BarcodeDesc'.$obj->encoding);
365 print
'<td class="center">';
366 if ($obj->coder && $obj->coder != -1) {
369 foreach ($dirbarcode as $reldir) {
374 if (!is_dir($newdir)) {
378 $result = @include_once $newdir.$obj->coder.
'.modules.php';
384 $classname =
"mod".ucfirst($obj->coder);
385 if (class_exists($classname)) {
386 $module =
new $classname($db);
387 if ($module->encodingIsSupported($obj->encoding)) {
389 $result = $module->writeBarCode($obj->example, $obj->encoding,
'Y');
391 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).
'&code='.urlencode($obj->example).
'&encoding='.urlencode($obj->encoding);
393 print
'<img src="'.$url.
'" title="'.$obj->example.
'" border="0">';
395 print $langs->trans(
"FormatNotSupportedByGenerator");
398 print
'ErrorClassNotFoundInModule '.$classname.
' '.$obj->coder;
402 print
'<span class="opacitymedium">'.$langs->trans(
"ChooseABarCode").
'</span>';
406 print
'<td class="center">';
407 print $formbarcode->setBarcodeEncoder($obj->coder, $barcodelist, $obj->rowid,
'form'.$i);
408 print
"</td></tr>\n";
416if (empty($conf->use_javascript_ajax)) {
417 print $form->buttonsSaveCancel(
"Save",
'');
428print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
429print
'<input type="hidden" name="token" value="'.newToken().
'">';
430print
"<input type=\"hidden\" name=\"action\" value=\"update\">";
432print
'<div class="div-table-responsive-no-min">';
433print
'<table class="noborder centpercent">';
434print
'<tr class="liste_titre">';
435print
'<td>'.$langs->trans(
"Parameter").
'</td>';
436print
'<td width="60" class="center">'.$langs->trans(
"Value").
'</td>';
437print
'<td> </td>';
441if (!isset($_SERVER[
'WINDIR'])) {
442 print
'<tr class="oddeven">';
443 print
'<td>'.$langs->trans(
"GenbarcodeLocation").
'</td>';
444 print
'<td width="60" class="center">';
445 print
'<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.getDolGlobalString(
'GENBARCODE_LOCATION').
'">';
446 if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION)) {
447 $langs->load(
"errors");
448 print
'<br><span class="error">'.$langs->trans(
"ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).
'</span>';
451 print
'<td> </td>';
456if (isModEnabled(
'product')) {
457 print
'<tr class="oddeven">';
458 print
'<td>'.$langs->trans(
"SetDefaultBarcodeTypeProducts").
'</td>';
459 print
'<td width="60" class="right">';
460 print $formbarcode->selectBarcodeType($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE,
"PRODUIT_DEFAULT_BARCODE_TYPE", 1);
462 print
'<td> </td>';
467if (isModEnabled(
'societe')) {
468 print
'<tr class="oddeven">';
469 print
'<td>'.$langs->trans(
"SetDefaultBarcodeTypeThirdParties").
'</td>';
470 print
'<td width="60" class="right">';
471 print $formbarcode->selectBarcodeType($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY,
"GENBARCODE_BARCODETYPE_THIRDPARTY", 1);
473 print
'<td> </td>';
480print
'<div class="tabsAction">';
481print
'<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($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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_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.