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);
176 '@phan-var-force ModeleBarCode $module';
179 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
182 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
186 if ($module->isEnabled()) {
187 $barcodelist[$filebis] = $module->info($langs);
195'@phan-var-force array<string,string> $barcodelist';
199if (isModEnabled(
'product')) {
200 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"Product").
")",
'',
'');
202 print
'<div class="div-table-responsive-no-min">';
203 print
'<table class="noborder centpercent">';
204 print
'<tr class="liste_titre">';
205 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
206 print
'<td>'.$langs->trans(
"Description").
'</td>';
207 print
'<td>'.$langs->trans(
"Example").
'</td>';
208 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
209 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
212 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
214 foreach ($dirbarcodenum as $dirroot) {
217 $handle = @opendir($dir);
218 if (is_resource($handle)) {
219 while (($file = readdir($handle)) !==
false) {
220 if (preg_match(
'/^mod_barcode_product_.*php$/', $file)) {
221 $file = substr($file, 0,
dol_strlen($file) - 4);
229 $modBarCode =
new $file();
230 '@phan-var-force ModeleNumRefBarCode $modBarCode';
232 print
'<tr class="oddeven">';
233 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
234 print $modBarCode->info($langs);
236 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
239 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproductoff&token='.
newToken().
'&value='.urlencode($file).
'">';
240 print
img_picto($langs->trans(
"Activated"),
'switch_on');
243 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproducton&token='.
newToken().
'&value='.urlencode($file).
'">';
244 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
247 print
'<td class="center">';
248 $s = $modBarCode->getToolTip($langs,
null, -1);
249 print $form->textwithpicto(
'', $s, 1);
262if (isModEnabled(
'societe')) {
263 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"ThirdParty").
")",
'',
'');
265 print
'<div class="div-table-responsive-no-min">';
266 print
'<table class="noborder centpercent">';
267 print
'<tr class="liste_titre">';
268 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
269 print
'<td>'.$langs->trans(
"Description").
'</td>';
270 print
'<td>'.$langs->trans(
"Example").
'</td>';
271 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
272 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
275 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
277 foreach ($dirbarcodenum as $dirroot) {
280 $handle = @opendir($dir);
281 if (is_resource($handle)) {
282 while (($file = readdir($handle)) !==
false) {
283 if (preg_match(
'/^mod_barcode_thirdparty_.*php$/', $file)) {
284 $file = substr($file, 0,
dol_strlen($file) - 4);
292 $modBarCode =
new $file();
294 '@phan-var-force ModeleNumRefBarCode $modBarCode';
296 print
'<tr class="oddeven">';
297 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
298 print $modBarCode->info($langs);
300 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
302 if (
getDolGlobalString(
'BARCODE_THIRDPARTY_ADDON_NUM') && $conf->global->BARCODE_THIRDPARTY_ADDON_NUM ==
"$file") {
303 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyoff&token='.
newToken().
'&value='.urlencode($file).
'">';
304 print
img_picto($langs->trans(
"Activated"),
'switch_on');
307 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyon&token='.
newToken().
'&value='.urlencode($file).
'">';
308 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
311 print
'<td class="center">';
312 $s = $modBarCode->getToolTip($langs,
null, -1);
313 print $form->textwithpicto(
'', $s, 1);
332if (empty($conf->use_javascript_ajax)) {
333 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="form_engine">';
334 print
'<input type="hidden" name="token" value="'.newToken().
'">';
335 print
'<input type="hidden" name="action" value="updateengine">';
338print
'<div class="div-table-responsive-no-min">';
339print
'<table class="noborder centpercent">';
340print
'<tr class="liste_titre">';
341print
'<td>'.$langs->trans(
"Name").
'</td>';
342print
'<td>'.$langs->trans(
"Description").
'</td>';
343print
'<td width="200" class="center">'.$langs->trans(
"Example").
'</td>';
344print
'<td class="center" width="60">'.$langs->trans(
"CodeBarGenerator").
'</td>';
347$sql =
"SELECT rowid, code as encoding, libelle as label, coder, example";
348$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
349$sql .=
" WHERE entity = ".$conf->entity;
350$sql .=
" ORDER BY code";
353$resql = $db->query($sql);
355 $num = $db->num_rows($resql);
359 $obj = $db->fetch_object($resql);
361 print
'<tr class="oddeven">';
362 print
'<td width="100">';
365 print $langs->trans(
'BarcodeDesc'.$obj->encoding);
372 print
'<td class="center">';
373 if ($obj->coder && $obj->coder != -1) {
376 foreach ($dirbarcode as $reldir) {
381 if (!is_dir($newdir)) {
385 $result = @include_once $newdir.$obj->coder.
'.modules.php';
391 $classname =
"mod".ucfirst($obj->coder);
392 if (class_exists($classname)) {
393 $module =
new $classname($db);
394 '@phan-var-force ModeleBarCode $module';
395 if ($module->encodingIsSupported($obj->encoding)) {
397 $result = $module->writeBarCode($obj->example, $obj->encoding,
'Y');
399 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).
'&code='.urlencode($obj->example).
'&encoding='.urlencode($obj->encoding);
401 print
'<img src="'.$url.
'" title="'.$obj->example.
'" border="0">';
403 print $langs->trans(
"FormatNotSupportedByGenerator");
406 print
'ErrorClassNotFoundInModule '.$classname.
' '.$obj->coder;
410 print
'<span class="opacitymedium">'.$langs->trans(
"ChooseABarCode").
'</span>';
414 print
'<td class="center">';
415 print $formbarcode->setBarcodeEncoder($obj->coder, $barcodelist, $obj->rowid,
'form'.$i);
416 print
"</td></tr>\n";
424if (empty($conf->use_javascript_ajax)) {
425 print $form->buttonsSaveCancel(
"Save",
'');
436print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
437print
'<input type="hidden" name="token" value="'.newToken().
'">';
438print
"<input type=\"hidden\" name=\"action\" value=\"update\">";
440print
'<div class="div-table-responsive-no-min">';
441print
'<table class="noborder centpercent">';
442print
'<tr class="liste_titre">';
443print
'<td>'.$langs->trans(
"Parameter").
'</td>';
444print
'<td width="60" class="center">'.$langs->trans(
"Value").
'</td>';
445print
'<td> </td>';
449if (!isset($_SERVER[
'WINDIR'])) {
450 print
'<tr class="oddeven">';
451 print
'<td>'.$langs->trans(
"GenbarcodeLocation").
'</td>';
452 print
'<td width="60" class="center">';
453 print
'<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.getDolGlobalString(
'GENBARCODE_LOCATION').
'">';
454 if (
getDolGlobalString(
'GENBARCODE_LOCATION') && !@file_exists($conf->global->GENBARCODE_LOCATION)) {
455 $langs->load(
"errors");
456 print
'<br><span class="error">'.$langs->trans(
"ErrorFileNotFound",
getDolGlobalString(
'GENBARCODE_LOCATION')).
'</span>';
459 print
'<td> </td>';
464if (isModEnabled(
'product')) {
465 print
'<tr class="oddeven">';
466 print
'<td>'.$langs->trans(
"SetDefaultBarcodeTypeProducts").
'</td>';
467 print
'<td width="60" class="right">';
468 print $formbarcode->selectBarcodeType(
getDolGlobalString(
'PRODUIT_DEFAULT_BARCODE_TYPE'),
"PRODUIT_DEFAULT_BARCODE_TYPE", 1);
470 print
'<td> </td>';
475if (isModEnabled(
'societe')) {
476 print
'<tr class="oddeven">';
477 print
'<td>'.$langs->trans(
"SetDefaultBarcodeTypeThirdParties").
'</td>';
478 print
'<td width="60" class="right">';
479 print $formbarcode->selectBarcodeType(
getDolGlobalString(
'GENBARCODE_BARCODETYPE_THIRDPARTY'),
"GENBARCODE_BARCODETYPE_THIRDPARTY", 1);
481 print
'<td> </td>';
488print
'<div class="tabsAction">';
489print
'<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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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.
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 a 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.