28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
41$langs->loadLangs(array(
'admin',
'members',
'errors',
'other'));
48$eraseallproductbarcode =
GETPOST(
'eraseallproductbarcode');
49$eraseallthirdpartybarcode =
GETPOST(
'eraseallthirdpartybarcode');
51$action =
GETPOST(
'action',
'aZ09');
53$modBarCodeProduct =
'';
54$modBarCodeThirdparty =
'';
65if (empty($user->admin)) {
78 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
80 foreach ($dirbarcodenum as $dirroot) {
83 $handle = @opendir($dir);
84 if (is_resource($handle)) {
85 while (($file = readdir($handle)) !==
false) {
86 if (preg_match(
'/^mod_barcode_thirdparty_.*php$/', $file)) {
87 $file = substr($file, 0,
dol_strlen($file) - 4);
95 $modBarCodeThirdparty =
new $file();
96 '@phan-var-force ModeleNumRefBarCode $modBarCodeThirdparty';
105if ($action ==
'initbarcodethirdparties' && $user->hasRight(
'societe',
'lire')) {
106 if (!is_object($modBarCodeThirdparty)) {
108 setEventMessages($langs->trans(
"NoBarcodeNumberingTemplateDefined"),
null,
'errors');
112 $thirdpartystatic =
new Societe($db);
117 if (!empty($eraseallthirdpartybarcode)) {
118 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe";
119 $sql .=
" SET barcode = NULL";
120 $sql .=
" WHERE barcode IS NOT NULL";
121 $sql .=
" AND entity IN (".getEntity(
'societe').
")";
122 $resql = $db->query($sql);
130 $sql =
"SELECT rowid";
131 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe";
132 $sql .=
" WHERE barcode IS NULL or barcode = ''";
133 $sql .=
" AND entity IN (".getEntity(
'societe').
")";
134 $sql .= $db->order(
"datec",
"ASC");
135 $sql .= $db->plimit($maxperinit);
138 $resql = $db->query($sql);
140 $num = $db->num_rows($resql);
144 while ($i < min($num, $maxperinit)) {
145 $obj = $db->fetch_object($resql);
147 $thirdpartystatic->id = $obj->rowid;
148 $nextvalue = $modBarCodeThirdparty->getNextValue($thirdpartystatic,
'');
150 $result = $thirdpartystatic->setValueFrom(
'barcode', $nextvalue,
'',
null,
'text',
'', $user,
'THIRDPARTY_MODIFY');
183 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
185 foreach ($dirbarcodenum as $dirroot) {
188 $handle = @opendir($dir);
189 if (is_resource($handle)) {
190 while (($file = readdir($handle)) !==
false) {
191 if (preg_match(
'/^mod_barcode_product_.*php$/', $file)) {
192 $file = substr($file, 0,
dol_strlen($file) - 4);
201 $modBarCodeProduct =
new $file();
202 '@phan-var-force ModeleNumRefBarCode $modBarCodeProduct';
212if ($action ==
'initbarcodeproducts' && $user->hasRight(
'produit',
'lire')) {
213 if (!is_object($modBarCodeProduct)) {
215 setEventMessages($langs->trans(
"NoBarcodeNumberingTemplateDefined"),
null,
'errors');
219 $productstatic =
new Product($db);
224 if (!empty($eraseallproductbarcode)) {
225 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product";
226 $sql .=
" SET barcode = NULL";
227 $sql .=
" WHERE barcode IS NOT NULL AND entity IN (".getEntity(
'product').
")";
228 $resql = $db->query($sql);
236 $sql =
"SELECT rowid, ref, fk_product_type";
237 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
238 $sql .=
" WHERE barcode IS NULL or barcode = ''";
239 $sql .=
" AND entity IN (".getEntity(
'product').
")";
240 $sql .= $db->order(
"datec",
"ASC");
241 $sql .= $db->plimit($maxperinit);
244 $resql = $db->query($sql);
246 $num = $db->num_rows($resql);
250 while ($i < min($num, $maxperinit)) {
251 $obj = $db->fetch_object($resql);
253 $productstatic->id = $obj->rowid;
254 $productstatic->ref = $obj->ref;
255 $productstatic->type = $obj->fk_product_type;
256 $nextvalue = $modBarCodeProduct->getNextValue($productstatic,
'');
259 $result = $productstatic->setValueFrom(
'barcode', $nextvalue,
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
295llxHeader(
'', $langs->trans(
"MassBarcodeInit"),
'',
'', 0, 0,
'',
'',
'',
'mod-barcode page-codeinit');
297if (!
GETPOST(
'dol_openinpopup',
'aZ')) {
298 print
load_fiche_titre($langs->trans(
"MassBarcodeInit"),
'',
'title_setup');
302print
'<span class="opacitymedium">'.$langs->trans(
"MassBarcodeInitDesc").
'</span><br>';
308print
'<script type="text/javascript">
309function confirm_erase() {
310 return confirm("'.dol_escape_js($langs->trans(
"ConfirmEraseAllCurrentBarCode")).
'");
317 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
318 print
'<input type="hidden" name="mode" value="label">';
319 print
'<input type="hidden" name="action" value="initbarcodeproducts">';
320 print
'<input type="hidden" name="token" value="'.newToken().
'">';
321 print
'<input type="hidden" name="dol_openinpopup" value="'.GETPOST(
'dol_openinpopup',
'aZ').
'">';
323 $nbproductno = $nbproducttotal = 0;
325 print
'<div class="divsection">';
327 print
load_fiche_titre($langs->trans(
"BarcodeInitForProductsOrServices"),
'',
'product');
329 $sql =
"SELECT count(rowid) as nb, fk_product_type, datec";
330 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
331 $sql .=
" WHERE barcode IS NULL OR barcode = ''";
332 $sql .=
" AND entity IN (".getEntity(
'product').
")";
333 $sql .=
" GROUP BY fk_product_type, datec";
334 $sql .=
" ORDER BY datec";
335 $resql = $db->query($sql);
337 $num = $db->num_rows($resql);
341 $obj = $db->fetch_object($resql);
342 $nbproductno += $obj->nb;
350 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"product";
351 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
352 $resql = $db->query($sql);
354 $obj = $db->fetch_object($resql);
355 $nbproducttotal = $obj->nb;
360 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbproductno, $nbproducttotal, $langs->transnoentitiesnoconv(
"ProductsOrServices")).
"\n";
362 $disabledproduct = $disabledproduct1 = 0;
365 if (is_object($modBarCodeProduct)) {
366 print
'<br>'.$langs->trans(
"BarCodeNumberManager").
": ";
367 $objproduct =
new Product($db);
368 print
'<b>'.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).
'</b> - '.$langs->trans(
"NextValue").
': <b>'.$modBarCodeProduct->getNextValue($objproduct).
'</b><br>';
369 $disabledproduct = 0;
372 $disabledproduct = 1;
373 $titleno = $langs->trans(
"NoBarcodeNumberingTemplateDefined");
374 print
'<br><div class="warning">'.$langs->trans(
"NoBarcodeNumberingTemplateDefined");
375 print
'<br><a href="'.DOL_URL_ROOT.
'/admin/barcode.php">'.$langs->trans(
"ToGenerateCodeDefineAutomaticRuleFirst").
'</a>';
378 if (empty($nbproductno)) {
379 $disabledproduct1 = 1;
383 $moretagsproduct1 = (($disabledproduct || $disabledproduct1) ?
' disabled title="'.
dol_escape_htmltag($titleno).
'"' :
'');
384 print
'<input type="submit" class="button" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'.$langs->trans(
"InitEmptyBarCode", min($maxperinit, $nbproductno)).
'"'.$moretagsproduct1.
'>';
385 $moretagsproduct2 = (($nbproductno == $nbproducttotal) ?
' disabled' :
'');
387 print
'<input type="submit" class="button butActionDelete" name="eraseallproductbarcode" id="eraseallproductbarcode" value="'.$langs->trans(
"EraseAllCurrentBarCode").
'"'.$moretagsproduct2.
' onClick="return confirm_erase();">';
398 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
399 print
'<input type="hidden" name="mode" value="label">';
400 print
'<input type="hidden" name="action" value="initbarcodethirdparties">';
401 print
'<input type="hidden" name="token" value="'.newToken().
'">';
402 print
'<input type="hidden" name="dol_openinpopup" value="'.GETPOST(
'dol_openinpopup',
'aZ').
'">';
404 $nbthirdpartyno = $nbthirdpartytotal = 0;
406 print
'<div class="divsection">';
408 print
load_fiche_titre($langs->trans(
"BarcodeInitForThirdparties"),
'',
'company');
410 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe where barcode IS NULL or barcode = ''";
411 $resql = $db->query($sql);
413 $obj = $db->fetch_object($resql);
414 $nbthirdpartyno = $obj->nb;
419 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe";
420 $sql .=
" WHERE entity IN (".getEntity(
'societe').
")";
421 $resql = $db->query($sql);
423 $obj = $db->fetch_object($resql);
424 $nbthirdpartytotal = $obj->nb;
429 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbthirdpartyno, $nbthirdpartytotal, $langs->transnoentitiesnoconv(
"ThirdParties")).
"\n";
431 $disabledthirdparty = $disabledthirdparty1 = 0;
434 if (is_object($modBarCodeThirdparty)) {
435 print
'<br>'.$langs->trans(
"BarCodeNumberManager").
": ";
436 $objthirdparty =
new Societe($db);
437 print
'<b>'.(isset($modBarCodeThirdparty->name) ? $modBarCodeThirdparty->name : $modBarCodeThirdparty->nom).
'</b> - '.$langs->trans(
"NextValue").
': <b>'.$modBarCodeThirdparty->getNextValue($objthirdparty).
'</b><br>';
438 $disabledthirdparty = 0;
441 $disabledthirdparty = 1;
442 $titleno = $langs->trans(
"NoBarcodeNumberingTemplateDefined");
443 print
'<div class="warning">'.$langs->trans(
"NoBarcodeNumberingTemplateDefined");
444 print
'<br><a href="'.DOL_URL_ROOT.
'/admin/barcode.php">'.$langs->trans(
"ToGenerateCodeDefineAutomaticRuleFirst").
'</a>';
447 if (empty($nbthirdpartyno)) {
448 $disabledthirdparty1 = 1;
451 $moretagsthirdparty1 = (($disabledthirdparty || $disabledthirdparty1) ?
' disabled title="'.
dol_escape_htmltag($titleno).
'"' :
'');
452 print
'<input class="button button-add" type="submit" id="submitformbarcodethirdpartygen" value="'.$langs->trans(
"InitEmptyBarCode", $nbthirdpartyno).
'"'.$moretagsthirdparty1.
'>';
453 $moretagsthirdparty2 = (($nbthirdpartyno == $nbthirdpartytotal) ?
' disabled' :
'');
455 print
'<input type="submit" class="button butActionDelete" name="eraseallthirdpartybarcode" id="eraseallthirdpartybarcode" value="'.$langs->trans(
"EraseAllCurrentBarCode").
'"'.$moretagsthirdparty2.
' onClick="return confirm_erase();">';
463print
'<div class="divsection">';
466print $langs->trans(
"ClickHereToGoTo").
' : <a href="'.DOL_URL_ROOT.
'/barcode/printsheet.php">'.$langs->trans(
"BarCodePrintsheet").
'</a>';
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.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.