26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
31$langs->loadLangs(array(
'admin',
'members',
'errors',
'other'));
38$forbarcode =
GETPOST(
'forbarcode');
39$fk_barcode_type =
GETPOST(
'fk_barcode_type');
40$eraseallproductbarcode =
GETPOST(
'eraseallproductbarcode');
41$eraseallthirdpartybarcode =
GETPOST(
'eraseallthirdpartybarcode');
43$action =
GETPOST(
'action',
'aZ09');
46$thirdpartytmp =
new Societe($db);
48$modBarCodeProduct =
'';
49$modBarCodeThirdparty =
'';
51$maxperinit = !
getDolGlobalString(
'BARCODE_INIT_MAX') ? 1000 : $conf->global->BARCODE_INIT_MAX;
56if (!isModEnabled(
'barcode')) {
60if (empty($user->admin)) {
71 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
73 foreach ($dirbarcodenum as $dirroot) {
76 $handle = @opendir($dir);
77 if (is_resource($handle)) {
78 while (($file = readdir($handle)) !==
false) {
79 if (preg_match(
'/^mod_barcode_thirdparty_.*php$/', $file)) {
80 $file = substr($file, 0,
dol_strlen($file) - 4);
88 $modBarCodeThirdparty =
new $file();
97if ($action ==
'initbarcodethirdparties') {
98 if (!is_object($modBarCodeThirdparty)) {
100 setEventMessages($langs->trans(
"NoBarcodeNumberingTemplateDefined"),
null,
'errors');
104 $thirdpartystatic =
new Societe($db);
109 if (!empty($eraseallthirdpartybarcode)) {
110 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe";
111 $sql .=
" AND entity IN (".getEntity(
'societe').
")";
112 $sql .=
" SET barcode = NULL";
113 $resql = $db->query($sql);
121 $sql =
"SELECT rowid";
122 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe";
123 $sql .=
" WHERE barcode IS NULL or barcode = ''";
124 $sql .=
" AND entity IN (".getEntity(
'societe').
")";
125 $sql .= $db->order(
"datec",
"ASC");
126 $sql .= $db->plimit($maxperinit);
129 $resql = $db->query($sql);
131 $num = $db->num_rows($resql);
135 while ($i < min($num, $maxperinit)) {
136 $obj = $db->fetch_object($resql);
138 $thirdpartystatic->id = $obj->rowid;
139 $nextvalue = $modBarCodeThirdparty->getNextValue($thirdpartystatic,
'');
141 $result = $thirdpartystatic->setValueFrom(
'barcode', $nextvalue,
'',
'',
'text',
'', $user,
'THIRDPARTY_MODIFY');
174 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
176 foreach ($dirbarcodenum as $dirroot) {
179 $handle = @opendir($dir);
180 if (is_resource($handle)) {
181 while (($file = readdir($handle)) !==
false) {
182 if (preg_match(
'/^mod_barcode_product_.*php$/', $file)) {
183 $file = substr($file, 0,
dol_strlen($file) - 4);
185 if ($file == $conf->global->BARCODE_PRODUCT_ADDON_NUM) {
192 $modBarCodeProduct =
new $file();
202if ($action ==
'initbarcodeproducts') {
203 if (!is_object($modBarCodeProduct)) {
205 setEventMessages($langs->trans(
"NoBarcodeNumberingTemplateDefined"),
null,
'errors');
209 $productstatic =
new Product($db);
214 if (!empty($eraseallproductbarcode)) {
215 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product";
216 $sql .=
" SET barcode = NULL";
217 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
218 $resql = $db->query($sql);
226 $sql =
"SELECT rowid, ref, fk_product_type";
227 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
228 $sql .=
" WHERE barcode IS NULL or barcode = ''";
229 $sql .=
" AND entity IN (".getEntity(
'product').
")";
230 $sql .= $db->order(
"datec",
"ASC");
231 $sql .= $db->plimit($maxperinit);
234 $resql = $db->query($sql);
236 $num = $db->num_rows($resql);
240 while ($i < min($num, $maxperinit)) {
241 $obj = $db->fetch_object($resql);
243 $productstatic->id = $obj->rowid;
244 $productstatic->ref = $obj->ref;
245 $productstatic->type = $obj->fk_product_type;
246 $nextvalue = $modBarCodeProduct->getNextValue($productstatic,
'');
249 $result = $productstatic->setValueFrom(
'barcode', $nextvalue,
'',
'',
'text',
'', $user,
'PRODUCT_MODIFY');
285$form =
new Form($db);
287llxHeader(
'', $langs->trans(
"MassBarcodeInit"));
289print
load_fiche_titre($langs->trans(
"MassBarcodeInit"),
'',
'title_setup.png');
292print
'<span class="opacitymedium">'.$langs->trans(
"MassBarcodeInitDesc").
'</span><br>';
303print
'<script type="text/javascript">
304function confirm_erase() {
305 return confirm("'.dol_escape_js($langs->trans(
"ConfirmEraseAllCurrentBarCode")).
'");
311if (isModEnabled(
'societe')) {
312 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
313 print
'<input type="hidden" name="mode" value="label">';
314 print
'<input type="hidden" name="action" value="initbarcodethirdparties">';
315 print
'<input type="hidden" name="token" value="'.newToken().
'">';
316 $nbthirdpartyno = $nbthirdpartytotal = 0;
318 print
load_fiche_titre($langs->trans(
"BarcodeInitForThirdparties"),
'',
'company');
321 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe where barcode IS NULL or barcode = ''";
322 $resql = $db->query($sql);
324 $obj = $db->fetch_object($resql);
325 $nbthirdpartyno = $obj->nb;
330 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe";
331 $sql .=
" WHERE entity IN (".getEntity(
'societe').
")";
332 $resql = $db->query($sql);
334 $obj = $db->fetch_object($resql);
335 $nbthirdpartytotal = $obj->nb;
340 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbthirdpartyno, $nbthirdpartytotal, $langs->transnoentitiesnoconv(
"ThirdParties")).
"\n";
342 $disabledthirdparty = $disabledthirdparty1 = 0;
344 if (is_object($modBarCodeThirdparty)) {
345 print
'<br>'.$langs->trans(
"BarCodeNumberManager").
": ";
346 $objthirdparty =
new Societe($db);
347 print
'<b>'.(isset($modBarCodeThirdparty->name) ? $modBarCodeThirdparty->name : $modBarCodeThirdparty->nom).
'</b> - '.$langs->trans(
"NextValue").
': <b>'.$modBarCodeThirdparty->getNextValue($objthirdparty).
'</b><br>';
348 $disabledthirdparty = 0;
351 $disabledthirdparty = 1;
352 $titleno = $langs->trans(
"NoBarcodeNumberingTemplateDefined");
353 print
'<div class="warning">'.$langs->trans(
"NoBarcodeNumberingTemplateDefined");
354 print
'<br><a href="'.DOL_URL_ROOT.
'/admin/barcode.php">'.$langs->trans(
"ToGenerateCodeDefineAutomaticRuleFirst").
'</a>';
357 if (empty($nbthirdpartyno)) {
358 $disabledthirdparty1 = 1;
361 $moretagsthirdparty1 = (($disabledthirdparty || $disabledthirdparty1) ?
' disabled title="'.
dol_escape_htmltag($titleno).
'"' :
'');
362 print
'<br><input class="button button-add" type="submit" id="submitformbarcodethirdpartygen" value="'.$langs->trans(
"InitEmptyBarCode", $nbthirdpartyno).
'"'.$moretagsthirdparty1.
'>';
363 $moretagsthirdparty2 = (($nbthirdpartyno == $nbthirdpartytotal) ?
' disabled' :
'');
365 print
'<input type="submit" class="button butActionDelete" name="eraseallthirdpartybarcode" id="eraseallthirdpartybarcode" value="'.$langs->trans(
"EraseAllCurrentBarCode").
'"'.$moretagsthirdparty2.
' onClick="return confirm_erase();">';
366 print
'<br><br><br><br>';
372if (isModEnabled(
'product') || isModEnabled(
'service')) {
373 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
374 print
'<input type="hidden" name="mode" value="label">';
375 print
'<input type="hidden" name="action" value="initbarcodeproducts">';
376 print
'<input type="hidden" name="token" value="'.newToken().
'">';
378 $nbproductno = $nbproducttotal = 0;
380 print
load_fiche_titre($langs->trans(
"BarcodeInitForProductsOrServices"),
'',
'product');
383 $sql =
"SELECT count(rowid) as nb, fk_product_type, datec";
384 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
385 $sql .=
" WHERE barcode IS NULL OR barcode = ''";
386 $sql .=
" AND entity IN (".getEntity(
'product').
")";
387 $sql .=
" GROUP BY fk_product_type, datec";
388 $sql .=
" ORDER BY datec";
389 $resql = $db->query($sql);
391 $num = $db->num_rows($resql);
395 $obj = $db->fetch_object($resql);
396 $nbproductno += $obj->nb;
404 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"product";
405 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
406 $resql = $db->query($sql);
408 $obj = $db->fetch_object($resql);
409 $nbproducttotal = $obj->nb;
414 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbproductno, $nbproducttotal, $langs->transnoentitiesnoconv(
"ProductsOrServices")).
"\n";
416 $disabledproduct = $disabledproduct1 = 0;
418 if (is_object($modBarCodeProduct)) {
419 print
'<br>'.$langs->trans(
"BarCodeNumberManager").
": ";
420 $objproduct =
new Product($db);
421 print
'<b>'.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).
'</b> - '.$langs->trans(
"NextValue").
': <b>'.$modBarCodeProduct->getNextValue($objproduct).
'</b><br>';
422 $disabledproduct = 0;
425 $disabledproduct = 1;
426 $titleno = $langs->trans(
"NoBarcodeNumberingTemplateDefined");
427 print
'<br><div class="warning">'.$langs->trans(
"NoBarcodeNumberingTemplateDefined");
428 print
'<br><a href="'.DOL_URL_ROOT.
'/admin/barcode.php">'.$langs->trans(
"ToGenerateCodeDefineAutomaticRuleFirst").
'</a>';
431 if (empty($nbproductno)) {
432 $disabledproduct1 = 1;
436 $moretagsproduct1 = (($disabledproduct || $disabledproduct1) ?
' disabled title="'.
dol_escape_htmltag($titleno).
'"' :
'');
437 print
'<input type="submit" class="button" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'.$langs->trans(
"InitEmptyBarCode", min($maxperinit, $nbproductno)).
'"'.$moretagsproduct1.
'>';
438 $moretagsproduct2 = (($nbproductno == $nbproducttotal) ?
' disabled' :
'');
440 print
'<input type="submit" class="button butActionDelete" name="eraseallproductbarcode" id="eraseallproductbarcode" value="'.$langs->trans(
"EraseAllCurrentBarCode").
'"'.$moretagsproduct2.
' onClick="return confirm_erase();">';
441 print
'<br><br><br><br>';
448print $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($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
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.
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.