28require
'../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
40$langs->loadLangs(array(
'admin',
'members',
'errors',
'other'));
47$eraseallproductbarcode =
GETPOST(
'eraseallproductbarcode');
48$eraseallthirdpartybarcode =
GETPOST(
'eraseallthirdpartybarcode');
50$action =
GETPOST(
'action',
'aZ09');
52$modBarCodeProduct =
'';
53$modBarCodeThirdparty =
'';
64if (empty($user->admin)) {
77 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'),
$conf->modules_parts[
'barcode']);
79 foreach ($dirbarcodenum as $dirroot) {
82 $handle = @opendir($dir);
83 if (is_resource($handle)) {
84 while (($file = readdir($handle)) !==
false) {
85 if (preg_match(
'/^mod_barcode_thirdparty_.*php$/', $file)) {
86 $file = substr($file, 0,
dol_strlen($file) - 4);
94 $modBarCodeThirdparty =
new $file();
95 '@phan-var-force ModeleNumRefBarCode $modBarCodeThirdparty';
104if ($action ==
'initbarcodethirdparties' && $user->hasRight(
'societe',
'lire')) {
105 if (!is_object($modBarCodeThirdparty)) {
107 setEventMessages($langs->trans(
"NoBarcodeNumberingTemplateDefined"),
null,
'errors');
116 if (!empty($eraseallthirdpartybarcode)) {
117 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe";
118 $sql .=
" SET barcode = NULL";
119 $sql .=
" WHERE barcode IS NOT NULL";
120 $sql .=
" AND entity IN (".getEntity(
'societe').
")";
121 $resql =
$db->query($sql);
129 $sql =
"SELECT rowid";
130 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe";
131 $sql .=
" WHERE barcode IS NULL or barcode = ''";
132 $sql .=
" AND entity IN (".getEntity(
'societe').
")";
133 $sql .=
$db->order(
"datec",
"ASC");
134 $sql .=
$db->plimit($maxperinit);
137 $resql =
$db->query($sql);
139 $num =
$db->num_rows($resql);
143 while ($i < min($num, $maxperinit)) {
144 $obj =
$db->fetch_object($resql);
146 $thirdpartystatic->id = $obj->rowid;
147 $nextvalue = $modBarCodeThirdparty->getNextValue($thirdpartystatic,
'');
149 $result = $thirdpartystatic->setValueFrom(
'barcode', $nextvalue,
'',
null,
'text',
'', $user,
'THIRDPARTY_MODIFY');
182 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'),
$conf->modules_parts[
'barcode']);
184 foreach ($dirbarcodenum as $dirroot) {
187 $handle = @opendir($dir);
188 if (is_resource($handle)) {
189 while (($file = readdir($handle)) !==
false) {
190 if (preg_match(
'/^mod_barcode_product_.*php$/', $file)) {
191 $file = substr($file, 0,
dol_strlen($file) - 4);
200 $modBarCodeProduct =
new $file();
201 '@phan-var-force ModeleNumRefBarCode $modBarCodeProduct';
211if ($action ==
'initbarcodeproducts' && $user->hasRight(
'produit',
'lire')) {
212 if (!is_object($modBarCodeProduct)) {
214 setEventMessages($langs->trans(
"NoBarcodeNumberingTemplateDefined"),
null,
'errors');
223 if (!empty($eraseallproductbarcode)) {
224 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product";
225 $sql .=
" SET barcode = NULL";
226 $sql .=
" WHERE barcode IS NOT NULL AND entity IN (".getEntity(
'product').
")";
227 $resql =
$db->query($sql);
235 $sql =
"SELECT rowid, ref, fk_product_type";
236 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
237 $sql .=
" WHERE barcode IS NULL or barcode = ''";
238 $sql .=
" AND entity IN (".getEntity(
'product').
")";
239 $sql .=
$db->order(
"datec",
"ASC");
240 $sql .=
$db->plimit($maxperinit);
243 $resql =
$db->query($sql);
245 $num =
$db->num_rows($resql);
249 while ($i < min($num, $maxperinit)) {
250 $obj =
$db->fetch_object($resql);
252 $productstatic->id = $obj->rowid;
253 $productstatic->ref = $obj->ref;
254 $productstatic->type = $obj->fk_product_type;
255 $nextvalue = $modBarCodeProduct->getNextValue($productstatic,
'');
258 $result = $productstatic->setValueFrom(
'barcode', $nextvalue,
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
294llxHeader(
'', $langs->trans(
"MassBarcodeInit"),
'',
'', 0, 0,
'',
'',
'',
'mod-barcode page-codeinit');
296if (!
GETPOST(
'dol_openinpopup',
'aZ')) {
297 print
load_fiche_titre($langs->trans(
"MassBarcodeInit"),
'',
'title_setup');
301print
'<span class="opacitymedium">'.$langs->trans(
"MassBarcodeInitDesc").
'</span><br>';
307print
'<script type="text/javascript">
308function confirm_erase() {
309 return confirm("'.dol_escape_js($langs->trans(
"ConfirmEraseAllCurrentBarCode")).
'");
316 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
317 print
'<input type="hidden" name="mode" value="label">';
318 print
'<input type="hidden" name="action" value="initbarcodeproducts">';
319 print
'<input type="hidden" name="token" value="'.newToken().
'">';
320 print
'<input type="hidden" name="dol_openinpopup" value="'.GETPOST(
'dol_openinpopup',
'aZ').
'">';
322 $nbproductno = $nbproducttotal = 0;
324 print
'<div class="divsection">';
326 print
load_fiche_titre($langs->trans(
"BarcodeInitForProductsOrServices"),
'',
'product');
328 $sql =
"SELECT count(rowid) as nb, fk_product_type, datec";
329 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
330 $sql .=
" WHERE barcode IS NULL OR barcode = ''";
331 $sql .=
" AND entity IN (".getEntity(
'product').
")";
332 $sql .=
" GROUP BY fk_product_type, datec";
333 $sql .=
" ORDER BY datec";
334 $resql =
$db->query($sql);
336 $num =
$db->num_rows($resql);
340 $obj =
$db->fetch_object($resql);
341 $nbproductno += $obj->nb;
349 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"product";
350 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
351 $resql =
$db->query($sql);
353 $obj =
$db->fetch_object($resql);
354 $nbproducttotal = $obj->nb;
359 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbproductno, $nbproducttotal, $langs->transnoentitiesnoconv(
"ProductsOrServices")).
"\n";
361 $disabledproduct = $disabledproduct1 = 0;
364 if (is_object($modBarCodeProduct)) {
365 print
'<br>'.$langs->trans(
"BarCodeNumberManager").
": ";
367 print
'<b>'.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).
'</b> - '.$langs->trans(
"NextValue").
': <b>'.$modBarCodeProduct->getNextValue($objproduct).
'</b><br>';
368 $disabledproduct = 0;
371 $disabledproduct = 1;
372 $titleno = $langs->trans(
"NoBarcodeNumberingTemplateDefined");
373 print
'<br><div class="warning">'.$langs->trans(
"NoBarcodeNumberingTemplateDefined");
374 print
'<br><a href="'.DOL_URL_ROOT.
'/admin/barcode.php">'.$langs->trans(
"ToGenerateCodeDefineAutomaticRuleFirst").
'</a>';
377 if (empty($nbproductno)) {
378 $disabledproduct1 = 1;
382 $moretagsproduct1 = (($disabledproduct || $disabledproduct1) ?
' disabled title="'.
dol_escape_htmltag($titleno).
'"' :
'');
383 print
'<input type="submit" class="button" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'.$langs->trans(
"InitEmptyBarCode", min($maxperinit, $nbproductno)).
'"'.$moretagsproduct1.
'>';
384 $moretagsproduct2 = (($nbproductno == $nbproducttotal) ?
' disabled' :
'');
386 print
'<input type="submit" class="button butActionDelete" name="eraseallproductbarcode" id="eraseallproductbarcode" value="'.$langs->trans(
"EraseAllCurrentBarCode").
'"'.$moretagsproduct2.
' onClick="return confirm_erase();">';
397 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
398 print
'<input type="hidden" name="mode" value="label">';
399 print
'<input type="hidden" name="action" value="initbarcodethirdparties">';
400 print
'<input type="hidden" name="token" value="'.newToken().
'">';
401 print
'<input type="hidden" name="dol_openinpopup" value="'.GETPOST(
'dol_openinpopup',
'aZ').
'">';
403 $nbthirdpartyno = $nbthirdpartytotal = 0;
405 print
'<div class="divsection">';
407 print
load_fiche_titre($langs->trans(
"BarcodeInitForThirdparties"),
'',
'company');
409 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe where barcode IS NULL or barcode = ''";
410 $resql =
$db->query($sql);
412 $obj =
$db->fetch_object($resql);
413 $nbthirdpartyno = $obj->nb;
418 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe";
419 $sql .=
" WHERE entity IN (".getEntity(
'societe').
")";
420 $resql =
$db->query($sql);
422 $obj =
$db->fetch_object($resql);
423 $nbthirdpartytotal = $obj->nb;
428 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbthirdpartyno, $nbthirdpartytotal, $langs->transnoentitiesnoconv(
"ThirdParties")).
"\n";
430 $disabledthirdparty = $disabledthirdparty1 = 0;
433 if (is_object($modBarCodeThirdparty)) {
434 print
'<br>'.$langs->trans(
"BarCodeNumberManager").
": ";
436 print
'<b>'.(isset($modBarCodeThirdparty->name) ? $modBarCodeThirdparty->name : $modBarCodeThirdparty->nom).
'</b> - '.$langs->trans(
"NextValue").
': <b>'.$modBarCodeThirdparty->getNextValue($objthirdparty).
'</b><br>';
437 $disabledthirdparty = 0;
440 $disabledthirdparty = 1;
441 $titleno = $langs->trans(
"NoBarcodeNumberingTemplateDefined");
442 print
'<div class="warning">'.$langs->trans(
"NoBarcodeNumberingTemplateDefined");
443 print
'<br><a href="'.DOL_URL_ROOT.
'/admin/barcode.php">'.$langs->trans(
"ToGenerateCodeDefineAutomaticRuleFirst").
'</a>';
446 if (empty($nbthirdpartyno)) {
447 $disabledthirdparty1 = 1;
450 $moretagsthirdparty1 = (($disabledthirdparty || $disabledthirdparty1) ?
' disabled title="'.
dol_escape_htmltag($titleno).
'"' :
'');
451 print
'<input class="button button-add" type="submit" id="submitformbarcodethirdpartygen" value="'.$langs->trans(
"InitEmptyBarCode", $nbthirdpartyno).
'"'.$moretagsthirdparty1.
'>';
452 $moretagsthirdparty2 = (($nbthirdpartyno == $nbthirdpartytotal) ?
' disabled' :
'');
454 print
'<input type="submit" class="button butActionDelete" name="eraseallthirdpartybarcode" id="eraseallthirdpartybarcode" value="'.$langs->trans(
"EraseAllCurrentBarCode").
'"'.$moretagsthirdparty2.
' onClick="return confirm_erase();">';
462print
'<div class="divsection">';
465print $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.
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, $nodefault=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).
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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.