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").
")",
'',
'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);
268 print
dolButtonToOpenUrlInDialogPopup(
'barcodeinitproduct', $langs->trans(
"MassBarcodeInit"), $langs->trans(
"GoOnThisPageToInitBarCode").
' '.
img_picto(
'',
'url'),
'/barcode/codeinit.php',
'',
'small');
269 print
'<br><br><br>';
275if (isModEnabled(
'societe')) {
276 print
load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"ThirdParty").
")",
'',
'company');
278 print
'<div class="div-table-responsive-no-min">';
279 print
'<table class="noborder centpercent">';
280 print
'<tr class="liste_titre">';
281 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
282 print
'<td>'.$langs->trans(
"Description").
'</td>';
283 print
'<td>'.$langs->trans(
"Example").
'</td>';
284 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
285 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
288 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'),
$conf->modules_parts[
'barcode']);
290 foreach ($dirbarcodenum as $dirroot) {
293 $handle = @opendir($dir);
294 if (is_resource($handle)) {
295 while (($file = readdir($handle)) !==
false) {
296 if (preg_match(
'/^mod_barcode_thirdparty_.*php$/', $file)) {
297 $file = substr($file, 0,
dol_strlen($file) - 4);
305 $modBarCode =
new $file();
307 '@phan-var-force ModeleNumRefBarCode $modBarCode';
309 print
'<tr class="oddeven">';
310 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
311 print $modBarCode->info($langs);
313 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
316 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyoff&token='.
newToken().
'&value='.urlencode($file).
'">';
317 print
img_picto($langs->trans(
"Activated"),
'switch_on');
320 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodethirdpartyon&token='.
newToken().
'&value='.urlencode($file).
'">';
321 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
324 print
'<td class="center">';
325 $s = $modBarCode->getToolTip($langs,
null, -1);
326 print $form->textwithpicto(
'', $s, 1);
336 print
dolButtonToOpenUrlInDialogPopup(
'barcodeinitthirdparty', $langs->trans(
"MassBarcodeInit"), $langs->trans(
"GoOnThisPageToInitBarCode").
' '.
img_picto(
'',
'url'),
'/barcode/codeinit.php',
'',
'small');
337 print
'<br><br><br>';
348if (empty(
$conf->use_javascript_ajax)) {
349 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="form_engine">';
350 print
'<input type="hidden" name="token" value="'.newToken().
'">';
351 print
'<input type="hidden" name="action" value="updateengine">';
354print
'<div class="div-table-responsive-no-min">';
355print
'<table class="noborder centpercent">';
356print
'<tr class="liste_titre">';
357print
'<td>'.$langs->trans(
"Name").
'</td>';
358print
'<td>'.$langs->trans(
"Description").
'</td>';
359print
'<td width="200" class="center">'.$langs->trans(
"Example").
'</td>';
360print
'<td class="center" width="60">'.$langs->trans(
"CodeBarGenerator").
'</td>';
363$sql =
"SELECT rowid, code as encoding, libelle as label, coder, example";
364$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
365$sql .=
" WHERE entity = ".$conf->entity;
366$sql .=
" ORDER BY code";
369$resql = $db->query($sql);
371 $num = $db->num_rows($resql);
375 $obj = $db->fetch_object($resql);
377 print
'<tr class="oddeven">';
378 print
'<td width="100">';
381 print $langs->trans(
'BarcodeDesc'.$obj->encoding);
388 print
'<td class="center">';
389 if ($obj->coder && $obj->coder != -1) {
392 foreach ($dirbarcode as $reldir) {
397 if (!is_dir($newdir)) {
401 $result = @include_once $newdir.$obj->coder.
'.modules.php';
407 $classname =
"mod".ucfirst($obj->coder);
408 if (class_exists($classname)) {
409 $module =
new $classname($db);
410 '@phan-var-force ModeleBarCode $module';
411 if ($module->encodingIsSupported($obj->encoding)) {
413 $result = $module->writeBarCode($obj->example, $obj->encoding,
'Y');
415 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).
'&code='.urlencode($obj->example).
'&encoding='.urlencode($obj->encoding);
417 print
'<img src="'.$url.
'" title="'.$obj->example.
'" border="0">';
419 print $langs->trans(
"FormatNotSupportedByGenerator");
422 print
'ErrorClassNotFoundInModule '.$classname.
' '.$obj->coder;
426 print
'<span class="opacitymedium">'.$langs->trans(
"ChooseABarCode").
'</span>';
430 print
'<td class="center">';
431 print $formbarcode->setBarcodeEncoder($obj->coder, $barcodelist, $obj->rowid,
'form'.$i);
432 print
"</td></tr>\n";
440if (empty(
$conf->use_javascript_ajax)) {
441 print $form->buttonsSaveCancel(
"Save",
'');
452print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
453print
'<input type="hidden" name="token" value="'.newToken().
'">';
454print
"<input type=\"hidden\" name=\"action\" value=\"update\">";
456print
'<div class="div-table-responsive-no-min">';
457print
'<table class="noborder centpercent">';
458print
'<tr class="liste_titre">';
459print
'<td>'.$langs->trans(
"Parameter").
'</td>';
460print
'<td width="60" class="center"></td>';
461print
'<td> </td>';
465if (!isset($_SERVER[
'WINDIR'])) {
466 print
'<tr class="oddeven">';
467 print
'<td>'.$langs->trans(
"GenbarcodeLocation").
'</td>';
468 print
'<td width="60" class="center">';
469 print
'<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.getDolGlobalString(
'GENBARCODE_LOCATION').
'">';
471 $langs->load(
"errors");
472 print
'<br><span class="error">'.$langs->trans(
"ErrorFileNotFound",
getDolGlobalString(
'GENBARCODE_LOCATION')).
'</span>';
475 print
'<td> </td>';
480if (isModEnabled(
'product')) {
481 print
'<tr class="oddeven">';
482 print
'<td>'.img_picto(
'',
'product',
'class="pictofixedwidth"').$langs->trans(
"SetDefaultBarcodeTypeProducts").
'</td>';
483 print
'<td width="60" class="right">';
484 print $formbarcode->selectBarcodeType(
getDolGlobalInt(
'PRODUIT_DEFAULT_BARCODE_TYPE'),
"PRODUIT_DEFAULT_BARCODE_TYPE", 1);
486 print
'<td> </td>';
491if (isModEnabled(
'societe')) {
492 print
'<tr class="oddeven">';
493 print
'<td>'.img_picto(
'',
'company',
'class="pictofixedwidth"').$langs->trans(
"SetDefaultBarcodeTypeThirdParties").
'</td>';
494 print
'<td width="60" class="right">';
495 print $formbarcode->selectBarcodeType(
getDolGlobalInt(
'GENBARCODE_BARCODETYPE_THIRDPARTY'),
"GENBARCODE_BARCODETYPE_THIRDPARTY", 1);
497 print
'<td> </td>';
504print
'<div class="tabsAction">';
505print
'<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.
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, $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...
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.