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');
96 $coder_id =
GETPOST(
'PRODUIT_DEFAULT_BARCODE_TYPE',
'alpha');
98 $coder_id =
GETPOST(
'GENBARCODE_BARCODETYPE_THIRDPARTY',
'alpha');
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="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
152print
load_fiche_titre($langs->trans(
"BarcodeSetup"), $linkback,
'title_setup');
155$barcodelist = array();
161$dirbarcode = array_merge(array(
"/core/modules/barcode/doc/"),
$conf->modules_parts[
'barcode']);
163foreach ($dirbarcode as $reldir) {
168 if (!is_dir($newdir)) {
172 $handle = @opendir($newdir);
173 if (is_resource($handle)) {
174 while (($file = readdir($handle)) !==
false) {
175 if (substr($file, 0, 1) !=
'.' && substr($file, 0, 3) !=
'CVS') {
176 if (is_readable($newdir.$file)) {
177 if (preg_match(
'/(.*)\.modules\.php$/i', $file, $reg)) {
181 require_once $newdir.$file;
182 $classname =
"mod".ucfirst($filebis);
183 $module =
new $classname($db);
185 '@phan-var-force ModeleBarCode $module';
188 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
191 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
195 if ($module->isEnabled()) {
196 $barcodelist[$filebis] = $module->info($langs);
204'@phan-var-force array<string,string> $barcodelist';
208if (isModEnabled(
'product')) {
209 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"Product").
")",
'',
'');
211 print
'<div class="div-table-responsive-no-min">';
212 print
'<table class="noborder centpercent">';
213 print
'<tr class="liste_titre">';
214 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
215 print
'<td>'.$langs->trans(
"Description").
'</td>';
216 print
'<td>'.$langs->trans(
"Example").
'</td>';
217 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
218 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
221 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'),
$conf->modules_parts[
'barcode']);
223 foreach ($dirbarcodenum as $dirroot) {
226 $handle = @opendir($dir);
227 if (is_resource($handle)) {
228 while (($file = readdir($handle)) !==
false) {
229 if (preg_match(
'/^mod_barcode_product_.*php$/', $file)) {
230 $file = substr($file, 0,
dol_strlen($file) - 4);
238 $modBarCode =
new $file();
239 '@phan-var-force ModeleNumRefBarCode $modBarCode';
241 print
'<tr class="oddeven">';
242 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
243 print $modBarCode->info($langs);
245 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
248 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproductoff&token='.
newToken().
'&value='.urlencode($file).
'">';
249 print
img_picto($langs->trans(
"Activated"),
'switch_on');
252 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproducton&token='.
newToken().
'&value='.urlencode($file).
'">';
253 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
256 print
'<td class="center">';
257 $s = $modBarCode->getToolTip($langs,
null, -1);
258 print $form->textwithpicto(
'', $s, 1);
271if (isModEnabled(
'societe')) {
272 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"ThirdParty").
")",
'',
'');
274 print
'<div class="div-table-responsive-no-min">';
275 print
'<table class="noborder centpercent">';
276 print
'<tr class="liste_titre">';
277 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
278 print
'<td>'.$langs->trans(
"Description").
'</td>';
279 print
'<td>'.$langs->trans(
"Example").
'</td>';
280 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
281 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
284 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'),
$conf->modules_parts[
'barcode']);
286 foreach ($dirbarcodenum as $dirroot) {
289 $handle = @opendir($dir);
290 if (is_resource($handle)) {
291 while (($file = readdir($handle)) !==
false) {
292 if (preg_match(
'/^mod_barcode_thirdparty_.*php$/', $file)) {
293 $file = substr($file, 0,
dol_strlen($file) - 4);
301 $modBarCode =
new $file();
303 '@phan-var-force ModeleNumRefBarCode $modBarCode';
305 print
'<tr class="oddeven">';
306 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
307 print $modBarCode->info($langs);
309 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
311 if (
getDolGlobalString(
'BARCODE_THIRDPARTY_ADDON_NUM') &&
$conf->global->BARCODE_THIRDPARTY_ADDON_NUM ==
"$file") {
312 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyoff&token='.
newToken().
'&value='.urlencode($file).
'">';
313 print
img_picto($langs->trans(
"Activated"),
'switch_on');
316 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyon&token='.
newToken().
'&value='.urlencode($file).
'">';
317 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
320 print
'<td class="center">';
321 $s = $modBarCode->getToolTip($langs,
null, -1);
322 print $form->textwithpicto(
'', $s, 1);
341if (empty(
$conf->use_javascript_ajax)) {
342 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="form_engine">';
343 print
'<input type="hidden" name="token" value="'.newToken().
'">';
344 print
'<input type="hidden" name="action" value="updateengine">';
347print
'<div class="div-table-responsive-no-min">';
348print
'<table class="noborder centpercent">';
349print
'<tr class="liste_titre">';
350print
'<td>'.$langs->trans(
"Name").
'</td>';
351print
'<td>'.$langs->trans(
"Description").
'</td>';
352print
'<td width="200" class="center">'.$langs->trans(
"Example").
'</td>';
353print
'<td class="center" width="60">'.$langs->trans(
"CodeBarGenerator").
'</td>';
356$sql =
"SELECT rowid, code as encoding, libelle as label, coder, example";
357$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
358$sql .=
" WHERE entity = ".$conf->entity;
359$sql .=
" ORDER BY code";
362$resql = $db->query($sql);
364 $num = $db->num_rows($resql);
368 $obj = $db->fetch_object($resql);
370 print
'<tr class="oddeven">';
371 print
'<td width="100">';
374 print $langs->trans(
'BarcodeDesc'.$obj->encoding);
381 print
'<td class="center">';
382 if ($obj->coder && $obj->coder != -1) {
385 foreach ($dirbarcode as $reldir) {
390 if (!is_dir($newdir)) {
394 $result = @include_once $newdir.$obj->coder.
'.modules.php';
400 $classname =
"mod".ucfirst($obj->coder);
401 if (class_exists($classname)) {
402 $module =
new $classname($db);
403 '@phan-var-force ModeleBarCode $module';
404 if ($module->encodingIsSupported($obj->encoding)) {
406 $result = $module->writeBarCode($obj->example, $obj->encoding,
'Y');
408 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).
'&code='.urlencode($obj->example).
'&encoding='.urlencode($obj->encoding);
410 print
'<img src="'.$url.
'" title="'.$obj->example.
'" border="0">';
412 print $langs->trans(
"FormatNotSupportedByGenerator");
415 print
'ErrorClassNotFoundInModule '.$classname.
' '.$obj->coder;
419 print
'<span class="opacitymedium">'.$langs->trans(
"ChooseABarCode").
'</span>';
423 print
'<td class="center">';
424 print $formbarcode->setBarcodeEncoder($obj->coder, $barcodelist, $obj->rowid,
'form'.$i);
425 print
"</td></tr>\n";
433if (empty(
$conf->use_javascript_ajax)) {
434 print $form->buttonsSaveCancel(
"Save",
'');
445print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
446print
'<input type="hidden" name="token" value="'.newToken().
'">';
447print
"<input type=\"hidden\" name=\"action\" value=\"update\">";
449print
'<div class="div-table-responsive-no-min">';
450print
'<table class="noborder centpercent">';
451print
'<tr class="liste_titre">';
452print
'<td>'.$langs->trans(
"Parameter").
'</td>';
453print
'<td width="60" class="center">'.$langs->trans(
"Value").
'</td>';
454print
'<td> </td>';
458if (!isset($_SERVER[
'WINDIR'])) {
459 print
'<tr class="oddeven">';
460 print
'<td>'.$langs->trans(
"GenbarcodeLocation").
'</td>';
461 print
'<td width="60" class="center">';
462 print
'<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.getDolGlobalString(
'GENBARCODE_LOCATION').
'">';
464 $langs->load(
"errors");
465 print
'<br><span class="error">'.$langs->trans(
"ErrorFileNotFound",
getDolGlobalString(
'GENBARCODE_LOCATION')).
'</span>';
468 print
'<td> </td>';
473if (isModEnabled(
'product')) {
474 print
'<tr class="oddeven">';
475 print
'<td>'.$langs->trans(
"SetDefaultBarcodeTypeProducts").
'</td>';
476 print
'<td width="60" class="right">';
477 print $formbarcode->selectBarcodeType(
getDolGlobalString(
'PRODUIT_DEFAULT_BARCODE_TYPE'),
"PRODUIT_DEFAULT_BARCODE_TYPE", 1);
479 print
'<td> </td>';
484if (isModEnabled(
'societe')) {
485 print
'<tr class="oddeven">';
486 print
'<td>'.$langs->trans(
"SetDefaultBarcodeTypeThirdParties").
'</td>';
487 print
'<td width="60" class="right">';
488 print $formbarcode->selectBarcodeType(
getDolGlobalString(
'GENBARCODE_BARCODETYPE_THIRDPARTY'),
"GENBARCODE_BARCODETYPE_THIRDPARTY", 1);
490 print
'<td> </td>';
497print
'<div class="tabsAction">';
498print
'<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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.