27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
32 $langs->load(
"admin");
36 $action =
GETPOST(
'action',
'aZ09');
43 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
45 if ($action ==
'setbarcodeproducton')
47 $barcodenumberingmodule =
GETPOST(
'value',
'alpha');
48 $res =
dolibarr_set_const($db,
"BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule,
'chaine', 0,
'', $conf->entity);
49 if ($barcodenumberingmodule ==
'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))
51 $res =
dolibarr_set_const($db,
"BARCODE_STANDARD_PRODUCT_MASK",
'020{000000000}',
'chaine', 0,
'', $conf->entity);
53 } elseif ($action ==
'setbarcodeproductoff')
58 if ($action ==
'setcoder')
60 $coder =
GETPOST(
'coder',
'alpha');
61 $code_id =
GETPOST(
'code_id',
'int');
62 $sqlp =
"UPDATE ".MAIN_DB_PREFIX.
"c_barcode_type";
63 $sqlp .=
" SET coder = '".$db->escape($coder).
"'";
64 $sqlp .=
" WHERE rowid = ".((int) $code_id);
65 $sqlp .=
" AND entity = ".$conf->entity;
67 $resql = $db->query($sqlp);
69 } elseif ($action ==
'update')
71 $location =
GETPOST(
'GENBARCODE_LOCATION',
'alpha');
72 $res =
dolibarr_set_const($db,
"GENBARCODE_LOCATION", $location,
'chaine', 0,
'', $conf->entity);
73 $coder_id =
GETPOST(
'PRODUIT_DEFAULT_BARCODE_TYPE',
'alpha');
74 $res =
dolibarr_set_const($db,
"PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,
'chaine', 0,
'', $conf->entity);
75 $coder_id =
GETPOST(
'GENBARCODE_BARCODETYPE_THIRDPARTY',
'alpha');
76 $res =
dolibarr_set_const($db,
"GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,
'chaine', 0,
'', $conf->entity);
84 } elseif ($action ==
'updateengine')
86 $sql =
"SELECT rowid, coder";
87 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
88 $sql .=
" WHERE entity = ".$conf->entity;
89 $sql .=
" ORDER BY code";
94 $num = $db->num_rows(
$resql);
99 $obj = $db->fetch_object(
$resql);
101 if (
GETPOST(
'coder'.$obj->rowid,
'alpha'))
103 $coder =
GETPOST(
'coder'.$obj->rowid,
'alpha');
104 $code_id = $obj->rowid;
106 $sqlp =
"UPDATE ".MAIN_DB_PREFIX.
"c_barcode_type";
107 $sqlp .=
" SET coder = '".$db->escape($coder).
"'";
108 $sqlp .=
" WHERE rowid = ".((int) $code_id);
109 $sqlp .=
" AND entity = ".$conf->entity;
111 $upsql = $db->query($sqlp);
125 $form =
new Form($db);
128 $help_url =
'EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra';
129 llxHeader(
'', $langs->trans(
"BarcodeSetup"), $help_url);
131 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
135 $barcodelist = array();
141 $dirbarcode = array_merge(array(
"/core/modules/barcode/doc/"), $conf->modules_parts[
'barcode']);
143 foreach ($dirbarcode as $reldir)
149 if (!is_dir($newdir))
continue;
151 $handle = @opendir($newdir);
152 if (is_resource($handle))
154 while (($file = readdir($handle)) !==
false)
156 if (substr($file, 0, 1) <>
'.' && substr($file, 0, 3) <>
'CVS')
158 if (is_readable($newdir.$file))
160 if (preg_match(
'/(.*)\.modules\.php$/i', $file, $reg))
165 require_once $newdir.$file;
166 $classname =
"mod".ucfirst($filebis);
167 $module =
new $classname($db);
170 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
171 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
173 if ($module->isEnabled())
175 $barcodelist[$filebis] = $module->info();
191 if (empty($conf->use_javascript_ajax))
193 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="form_engine">';
194 print '<input type="hidden" name="token" value="'.newToken().
'">';
195 print '<input type="hidden" name="action" value="updateengine">';
198 print '<table class="noborder centpercent">';
199 print '<tr class="liste_titre">';
200 print '<td>'.$langs->trans(
"Name").
'</td>';
201 print '<td>'.$langs->trans(
"Description").
'</td>';
202 print '<td width="200" class="center">'.$langs->trans(
"Example").
'</td>';
203 print '<td class="center" width="60">'.$langs->trans(
"CodeBarGenerator").
'</td>';
206 $sql =
"SELECT rowid, code as encoding, libelle as label, coder, example";
207 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_barcode_type";
208 $sql .=
" WHERE entity = ".$conf->entity;
209 $sql .=
" ORDER BY code";
212 $resql = $db->query($sql);
215 $num = $db->num_rows(
$resql);
220 $obj = $db->fetch_object(
$resql);
222 print '<tr class="oddeven"><td width="100">';
225 print $langs->trans(
'BarcodeDesc'.$obj->encoding);
232 print '<td class="center">';
233 if ($obj->coder && $obj->coder != -1)
237 foreach ($dirbarcode as $reldir)
243 if (!is_dir($newdir))
continue;
245 $result = @include_once $newdir.$obj->coder.
'.modules.php';
250 $classname =
"mod".ucfirst($obj->coder);
251 if (class_exists($classname))
253 $module =
new $classname($db);
254 if ($module->encodingIsSupported($obj->encoding))
257 $result = $module->writeBarCode($obj->example, $obj->encoding,
'Y');
259 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).
'&code='.urlencode($obj->example).
'&encoding='.urlencode($obj->encoding);
261 print '<img src="'.$url.
'" title="'.$obj->example.
'" border="0">';
263 print $langs->trans(
"FormatNotSupportedByGenerator");
266 print 'ErrorClassNotFoundInModule '.$classname.
' '.$obj->coder;
270 print $langs->trans(
"ChooseABarCode");
274 print '<td class="center">';
275 print $formbarcode->setBarcodeEncoder($obj->coder, $barcodelist, $obj->rowid,
'form'.$i);
276 print "</td></tr>\n";
283 if (empty($conf->use_javascript_ajax))
285 print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans(
"Save").
'"></div>';
297 print "<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
298 print '<input type="hidden" name="token" value="'.newToken().
'">';
299 print "<input type=\"hidden\" name=\"action\" value=\"update\">";
301 print '<table class="noborder centpercent">';
302 print '<tr class="liste_titre">';
303 print '<td>'.$langs->trans(
"Parameter").
'</td>';
304 print '<td width="60" class="center">'.$langs->trans(
"Value").
'</td>';
305 print '<td> </td>';
311 print '<tr class="oddeven">';
312 print '<td>'.$langs->trans(
"GenbarcodeLocation").
'</td>';
313 print '<td width="60" class="center">';
314 print '<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.$conf->global->GENBARCODE_LOCATION.
'">';
315 if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION))
317 $langs->load(
"errors");
318 print '<br><font class="error">'.$langs->trans(
"ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).
'</font>';
324 if (!empty($conf->product->enabled))
326 print '<tr class="oddeven">';
327 print '<td>'.$langs->trans(
"SetDefaultBarcodeTypeProducts").
'</td>';
328 print '<td width="60" class="right">';
329 print $formbarcode->selectBarcodeType($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE,
"PRODUIT_DEFAULT_BARCODE_TYPE", 1);
334 if (!empty($conf->societe->enabled))
336 print '<tr class="oddeven">';
337 print '<td>'.$langs->trans(
"SetDefaultBarcodeTypeThirdParties").
'</td>';
338 print '<td width="60" class="right">';
339 print $formbarcode->selectBarcodeType($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY,
"GENBARCODE_BARCODETYPE_THIRDPARTY", 1);
344 print '<div class="tabsAction">';
345 print '<input type="submit" class="button" name="submit_GENBARCODE_BARCODETYPE_THIRDPARTY" value="'.$langs->trans(
"Modify").
'">';
354 if ($conf->product->enabled)
356 print load_fiche_titre($langs->trans(
"BarCodeNumberManager").
" (".$langs->trans(
"Product").
")",
'',
'');
358 print '<table class="noborder centpercent">';
359 print
'<tr class="liste_titre">';
360 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
361 print
'<td>'.$langs->trans(
"Description").
'</td>';
362 print
'<td>'.$langs->trans(
"Example").
'</td>';
363 print
'<td class="center" width="80">'.$langs->trans(
"Status").
'</td>';
364 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
367 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
369 foreach ($dirbarcodenum as $dirroot)
373 $handle = @opendir($dir);
374 if (is_resource($handle))
376 while (($file = readdir($handle)) !==
false)
378 if (preg_match(
'/^mod_barcode_product_.*php$/', $file))
380 $file = substr($file, 0,
dol_strlen($file) - 4);
389 $modBarCode =
new $file();
391 print
'<tr class="oddeven">';
392 print
'<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom).
"</td><td>\n";
393 print $modBarCode->info($langs);
395 print
'<td class="nowrap">'.$modBarCode->getExample($langs).
"</td>\n";
397 if ($conf->global->BARCODE_PRODUCT_ADDON_NUM ==
"$file")
399 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproductoff&token='.
newToken().
'&value='.urlencode($file).
'">';
400 print
img_picto($langs->trans(
"Activated"),
'switch_on');
403 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setbarcodeproducton&token='.
newToken().
'&value='.urlencode($file).
'">';
404 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
407 print
'<td class="center">';
408 $s = $modBarCode->getToolTip($langs, null, -1);
409 print $form->textwithpicto(
'', $s, 1);
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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).
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.