28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
33 $langs->load(
"admin");
41 $action =
GETPOST(
'action',
'aZ09');
42 $modulepart =
GETPOST(
'modulepart',
'aZ09');
49 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
51 if ($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",
'020{000000000}',
'chaine', 0,
'', $conf->entity);
57 } elseif ($action ==
'setbarcodeproductoff') {
61 if ($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",
'020{000000000}',
'chaine', 0,
'', $conf->entity);
67 } elseif ($action ==
'setbarcodethirdpartyoff') {
71 if ($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);
138 $help_url =
'EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra|DE:Modul_Barcode';
141 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
142 print
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']);
153 foreach ($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();
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);
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);
325 if (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">';
331 print
'<div class="div-table-responsive-no-min">';
332 print
'<table class="noborder centpercent">';
333 print
'<tr class="liste_titre">';
334 print
'<td>'.$langs->trans(
"Name").
'</td>';
335 print
'<td>'.$langs->trans(
"Description").
'</td>';
336 print
'<td width="200" class="center">'.$langs->trans(
"Example").
'</td>';
337 print
'<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";
416 if (empty($conf->use_javascript_ajax)) {
417 print
$form->buttonsSaveCancel(
"Save",
'');
428 print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
429 print
'<input type="hidden" name="token" value="'.newToken().
'">';
430 print
"<input type=\"hidden\" name=\"action\" value=\"update\">";
432 print
'<div class="div-table-responsive-no-min">';
433 print
'<table class="noborder centpercent">';
434 print
'<tr class="liste_titre">';
435 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
436 print
'<td width="60" class="center">'.$langs->trans(
"Value").
'</td>';
437 print
'<td> </td>';
441 if (!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>';
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>';
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>';
480 print
'<div class="tabsAction">';
481 print
'<input type="submit" class="button" name="submit_GENBARCODE_BARCODETYPE_THIRDPARTY" value="'.$langs->trans(
"Modify").
'">';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.