27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
32$langs->loadLangs(array(
'admin',
'members',
'errors',
'other'));
39$forbarcode =
GETPOST(
'forbarcode');
40$fk_barcode_type =
GETPOST(
'fk_barcode_type');
41$eraseallproductbarcode =
GETPOST(
'eraseallproductbarcode');
42$eraseallthirdpartybarcode =
GETPOST(
'eraseallthirdpartybarcode');
44$action =
GETPOST(
'action',
'aZ09');
47$thirdpartytmp =
new Societe($db);
49$modBarCodeProduct =
'';
50$modBarCodeThirdparty =
'';
52$maxperinit = !
getDolGlobalString(
'BARCODE_INIT_MAX') ? 1000 : $conf->global->BARCODE_INIT_MAX;
57if (!isModEnabled(
'barcode')) {
61if (empty($user->admin)) {
72 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
74 foreach ($dirbarcodenum as $dirroot) {
77 $handle = @opendir($dir);
78 if (is_resource($handle)) {
79 while (($file = readdir($handle)) !==
false) {
80 if (preg_match(
'/^mod_barcode_thirdparty_.*php$/', $file)) {
81 $file = substr($file, 0,
dol_strlen($file) - 4);
89 $modBarCodeThirdparty =
new $file();
90 '@phan-var-force ModeleNumRefBarCode $module';
99if ($action ==
'initbarcodethirdparties' && $user->hasRight(
'societe',
'lire')) {
100 if (!is_object($modBarCodeThirdparty)) {
102 setEventMessages($langs->trans(
"NoBarcodeNumberingTemplateDefined"),
null,
'errors');
106 $thirdpartystatic =
new Societe($db);
111 if (!empty($eraseallthirdpartybarcode)) {
112 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe";
113 $sql .=
" AND entity IN (".getEntity(
'societe').
")";
114 $sql .=
" SET barcode = NULL";
115 $resql = $db->query($sql);
123 $sql =
"SELECT rowid";
124 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe";
125 $sql .=
" WHERE barcode IS NULL or barcode = ''";
126 $sql .=
" AND entity IN (".getEntity(
'societe').
")";
127 $sql .= $db->order(
"datec",
"ASC");
128 $sql .= $db->plimit($maxperinit);
131 $resql = $db->query($sql);
133 $num = $db->num_rows($resql);
137 while ($i < min($num, $maxperinit)) {
138 $obj = $db->fetch_object($resql);
140 $thirdpartystatic->id = $obj->rowid;
141 $nextvalue = $modBarCodeThirdparty->getNextValue($thirdpartystatic,
'');
143 $result = $thirdpartystatic->setValueFrom(
'barcode', $nextvalue,
'',
'',
'text',
'', $user,
'THIRDPARTY_MODIFY');
176 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
178 foreach ($dirbarcodenum as $dirroot) {
181 $handle = @opendir($dir);
182 if (is_resource($handle)) {
183 while (($file = readdir($handle)) !==
false) {
184 if (preg_match(
'/^mod_barcode_product_.*php$/', $file)) {
185 $file = substr($file, 0,
dol_strlen($file) - 4);
194 $modBarCodeProduct =
new $file();
195 '@phan-var-force ModeleNumRefBarCode $module';
205if ($action ==
'initbarcodeproducts' && $user->hasRight(
'produit',
'lire')) {
206 if (!is_object($modBarCodeProduct)) {
208 setEventMessages($langs->trans(
"NoBarcodeNumberingTemplateDefined"),
null,
'errors');
212 $productstatic =
new Product($db);
217 if (!empty($eraseallproductbarcode)) {
218 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product";
219 $sql .=
" SET barcode = NULL";
220 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
221 $resql = $db->query($sql);
229 $sql =
"SELECT rowid, ref, fk_product_type";
230 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
231 $sql .=
" WHERE barcode IS NULL or barcode = ''";
232 $sql .=
" AND entity IN (".getEntity(
'product').
")";
233 $sql .= $db->order(
"datec",
"ASC");
234 $sql .= $db->plimit($maxperinit);
237 $resql = $db->query($sql);
239 $num = $db->num_rows($resql);
243 while ($i < min($num, $maxperinit)) {
244 $obj = $db->fetch_object($resql);
246 $productstatic->id = $obj->rowid;
247 $productstatic->ref = $obj->ref;
248 $productstatic->type = $obj->fk_product_type;
249 $nextvalue = $modBarCodeProduct->getNextValue($productstatic,
'');
252 $result = $productstatic->setValueFrom(
'barcode', $nextvalue,
'',
'',
'text',
'', $user,
'PRODUCT_MODIFY');
288$form =
new Form($db);
290llxHeader(
'', $langs->trans(
"MassBarcodeInit"),
'',
'', 0, 0,
'',
'',
'',
'mod-barcode page-codeinit');
292print
load_fiche_titre($langs->trans(
"MassBarcodeInit"),
'',
'title_setup.png');
295print
'<span class="opacitymedium">'.$langs->trans(
"MassBarcodeInitDesc").
'</span><br>';
306print
'<script type="text/javascript">
307function confirm_erase() {
308 return confirm("'.dol_escape_js($langs->trans(
"ConfirmEraseAllCurrentBarCode")).
'");
314if (isModEnabled(
'societe')) {
315 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
316 print
'<input type="hidden" name="mode" value="label">';
317 print
'<input type="hidden" name="action" value="initbarcodethirdparties">';
318 print
'<input type="hidden" name="token" value="'.newToken().
'">';
319 $nbthirdpartyno = $nbthirdpartytotal = 0;
321 print
load_fiche_titre($langs->trans(
"BarcodeInitForThirdparties"),
'',
'company');
324 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe where barcode IS NULL or barcode = ''";
325 $resql = $db->query($sql);
327 $obj = $db->fetch_object($resql);
328 $nbthirdpartyno = $obj->nb;
333 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe";
334 $sql .=
" WHERE entity IN (".getEntity(
'societe').
")";
335 $resql = $db->query($sql);
337 $obj = $db->fetch_object($resql);
338 $nbthirdpartytotal = $obj->nb;
343 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbthirdpartyno, $nbthirdpartytotal, $langs->transnoentitiesnoconv(
"ThirdParties")).
"\n";
345 $disabledthirdparty = $disabledthirdparty1 = 0;
347 if (is_object($modBarCodeThirdparty)) {
348 print
'<br>'.$langs->trans(
"BarCodeNumberManager").
": ";
349 $objthirdparty =
new Societe($db);
350 print
'<b>'.(isset($modBarCodeThirdparty->name) ? $modBarCodeThirdparty->name : $modBarCodeThirdparty->nom).
'</b> - '.$langs->trans(
"NextValue").
': <b>'.$modBarCodeThirdparty->getNextValue($objthirdparty).
'</b><br>';
351 $disabledthirdparty = 0;
354 $disabledthirdparty = 1;
355 $titleno = $langs->trans(
"NoBarcodeNumberingTemplateDefined");
356 print
'<div class="warning">'.$langs->trans(
"NoBarcodeNumberingTemplateDefined");
357 print
'<br><a href="'.DOL_URL_ROOT.
'/admin/barcode.php">'.$langs->trans(
"ToGenerateCodeDefineAutomaticRuleFirst").
'</a>';
360 if (empty($nbthirdpartyno)) {
361 $disabledthirdparty1 = 1;
364 $moretagsthirdparty1 = (($disabledthirdparty || $disabledthirdparty1) ?
' disabled title="'.
dol_escape_htmltag($titleno).
'"' :
'');
365 print
'<br><input class="button button-add" type="submit" id="submitformbarcodethirdpartygen" value="'.$langs->trans(
"InitEmptyBarCode", $nbthirdpartyno).
'"'.$moretagsthirdparty1.
'>';
366 $moretagsthirdparty2 = (($nbthirdpartyno == $nbthirdpartytotal) ?
' disabled' :
'');
368 print
'<input type="submit" class="button butActionDelete" name="eraseallthirdpartybarcode" id="eraseallthirdpartybarcode" value="'.$langs->trans(
"EraseAllCurrentBarCode").
'"'.$moretagsthirdparty2.
' onClick="return confirm_erase();">';
369 print
'<br><br><br><br>';
375if (isModEnabled(
'product') || isModEnabled(
'service')) {
376 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
377 print
'<input type="hidden" name="mode" value="label">';
378 print
'<input type="hidden" name="action" value="initbarcodeproducts">';
379 print
'<input type="hidden" name="token" value="'.newToken().
'">';
381 $nbproductno = $nbproducttotal = 0;
383 print
load_fiche_titre($langs->trans(
"BarcodeInitForProductsOrServices"),
'',
'product');
386 $sql =
"SELECT count(rowid) as nb, fk_product_type, datec";
387 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
388 $sql .=
" WHERE barcode IS NULL OR barcode = ''";
389 $sql .=
" AND entity IN (".getEntity(
'product').
")";
390 $sql .=
" GROUP BY fk_product_type, datec";
391 $sql .=
" ORDER BY datec";
392 $resql = $db->query($sql);
394 $num = $db->num_rows($resql);
398 $obj = $db->fetch_object($resql);
399 $nbproductno += $obj->nb;
407 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"product";
408 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
409 $resql = $db->query($sql);
411 $obj = $db->fetch_object($resql);
412 $nbproducttotal = $obj->nb;
417 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbproductno, $nbproducttotal, $langs->transnoentitiesnoconv(
"ProductsOrServices")).
"\n";
419 $disabledproduct = $disabledproduct1 = 0;
421 if (is_object($modBarCodeProduct)) {
422 print
'<br>'.$langs->trans(
"BarCodeNumberManager").
": ";
423 $objproduct =
new Product($db);
424 print
'<b>'.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).
'</b> - '.$langs->trans(
"NextValue").
': <b>'.$modBarCodeProduct->getNextValue($objproduct).
'</b><br>';
425 $disabledproduct = 0;
428 $disabledproduct = 1;
429 $titleno = $langs->trans(
"NoBarcodeNumberingTemplateDefined");
430 print
'<br><div class="warning">'.$langs->trans(
"NoBarcodeNumberingTemplateDefined");
431 print
'<br><a href="'.DOL_URL_ROOT.
'/admin/barcode.php">'.$langs->trans(
"ToGenerateCodeDefineAutomaticRuleFirst").
'</a>';
434 if (empty($nbproductno)) {
435 $disabledproduct1 = 1;
439 $moretagsproduct1 = (($disabledproduct || $disabledproduct1) ?
' disabled title="'.
dol_escape_htmltag($titleno).
'"' :
'');
440 print
'<input type="submit" class="button" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'.$langs->trans(
"InitEmptyBarCode", min($maxperinit, $nbproductno)).
'"'.$moretagsproduct1.
'>';
441 $moretagsproduct2 = (($nbproductno == $nbproducttotal) ?
' disabled' :
'');
443 print
'<input type="submit" class="button butActionDelete" name="eraseallproductbarcode" id="eraseallproductbarcode" value="'.$langs->trans(
"EraseAllCurrentBarCode").
'"'.$moretagsproduct2.
' onClick="return confirm_erase();">';
444 print
'<br><br><br><br>';
451print $langs->trans(
"ClickHereToGoTo").
' : <a href="'.DOL_URL_ROOT.
'/barcode/printsheet.php">'.$langs->trans(
"BarCodePrintsheet").
'</a>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.