Go to the documentation of this file.
25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
30 $langs->loadLangs(array(
'admin',
'members',
'errors',
'other'));
37 $forbarcode =
GETPOST(
'forbarcode');
38 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
39 $eraseallbarcode =
GETPOST(
'eraseallbarcode');
41 $action =
GETPOST(
'action',
'aZ09');
44 $thirdpartytmp =
new Societe($db);
46 $modBarCodeProduct =
'';
48 $maxperinit = empty($conf->global->BARCODE_INIT_MAX) ? 1000 : $conf->global->BARCODE_INIT_MAX;
56 if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) {
57 $dirbarcodenum = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
59 foreach ($dirbarcodenum as $dirroot) {
62 $handle = @opendir($dir);
63 if (is_resource($handle)) {
64 while (($file = readdir($handle)) !==
false) {
65 if (preg_match(
'/^mod_barcode_product_.*php$/', $file)) {
66 $file = substr($file, 0,
dol_strlen($file) - 4);
68 if ($file == $conf->global->BARCODE_PRODUCT_ADDON_NUM) {
75 $modBarCodeProduct =
new $file();
85 if ($action ==
'initbarcodeproducts') {
86 if (!is_object($modBarCodeProduct)) {
88 setEventMessages($langs->trans(
"NoBarcodeNumberingTemplateDefined"),
null,
'errors');
92 $productstatic =
new Product($db);
97 if (!empty($eraseallbarcode)) {
98 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product";
99 $sql .=
" SET barcode = NULL";
100 $resql = $db->query($sql);
108 $sql =
"SELECT rowid, ref, fk_product_type";
109 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
110 $sql .=
" WHERE barcode IS NULL or barcode = ''";
111 $sql .= $db->order(
"datec",
"ASC");
112 $sql .= $db->plimit($maxperinit);
115 $resql = $db->query($sql);
117 $num = $db->num_rows(
$resql);
119 $i = 0; $nbok = $nbtry = 0;
120 while ($i < min($num, $maxperinit)) {
121 $obj = $db->fetch_object(
$resql);
123 $productstatic->id = $obj->rowid;
124 $productstatic->ref = $obj->ref;
125 $productstatic->type = $obj->fk_product_type;
126 $nextvalue = $modBarCodeProduct->getNextValue($productstatic,
'');
129 $result = $productstatic->setValueFrom(
'barcode', $nextvalue,
'',
'',
'text',
'', $user,
'PRODUCT_MODIFY');
169 if (empty($conf->barcode->enabled)) {
175 llxHeader(
'', $langs->trans(
"MassBarcodeInit"));
177 print
load_fiche_titre($langs->trans(
"MassBarcodeInit"),
'',
'title_setup.png');
180 print
'<span class="opacitymedium">'.$langs->trans(
"MassBarcodeInitDesc").
'</span><br>';
186 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
187 print
'<input type="hidden" name="mode" value="label">';
188 print
'<input type="hidden" name="action" value="initbarcodeproducts">';
189 print
'<input type="hidden" name="token" value="'.newToken().
'">';
195 $nbno = $nbtotal = 0;
197 print
load_fiche_titre($langs->trans(
"BarcodeInitForThirdparties"),
'',
'company');
200 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe where barcode IS NULL or barcode = ''";
201 $resql = $db->query($sql);
203 $obj = $db->fetch_object(
$resql);
209 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe";
210 $resql = $db->query($sql);
212 $obj = $db->fetch_object(
$resql);
218 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv(
"ThirdParties")).
'<br>'.
"\n";
220 print
'<br><input class="button button-add" type="submit" id="submitformbarcodethirdpartygen" '.((GETPOST(
"selectorforbarcode") &&
GETPOST(
"selectorforbarcode")) ?
'' :
'disabled ').
'value="'.$langs->trans(
"InitEmptyBarCode", $nbno).
'"';
221 print
' title="'.dol_escape_htmltag($langs->trans(
"FeatureNotYetAvailable")).
'" disabled';
223 print
'<br><br><br><br>';
228 if ($conf->product->enabled || $conf->product->service) {
230 print
'<script type="text/javascript">
231 function confirm_erase() {
232 return confirm("'.dol_escape_js($langs->trans(
"ConfirmEraseAllCurrentBarCode")).
'");
236 $nbno = $nbtotal = 0;
238 print
load_fiche_titre($langs->trans(
"BarcodeInitForProductsOrServices"),
'',
'product');
241 $sql =
"SELECT count(rowid) as nb, fk_product_type, datec";
242 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
243 $sql .=
" WHERE barcode IS NULL OR barcode = ''";
244 $sql .=
" GROUP BY fk_product_type, datec";
245 $sql .=
" ORDER BY datec";
246 $resql = $db->query($sql);
248 $num = $db->num_rows(
$resql);
252 $obj = $db->fetch_object(
$resql);
261 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"product";
262 $resql = $db->query($sql);
264 $obj = $db->fetch_object(
$resql);
270 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv(
"ProductsOrServices")).
"\n";
272 if (is_object($modBarCodeProduct)) {
273 print $langs->trans(
"BarCodeNumberManager").
": ";
274 $objproduct =
new Product($db);
275 print
'<b>'.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).
'</b> - '.$langs->trans(
"NextValue").
': <b>'.$modBarCodeProduct->getNextValue($objproduct).
'</b><br>';
280 $titleno = $langs->trans(
"NoBarcodeNumberingTemplateDefined");
281 print
'<br><div class="warning">'.$langs->trans(
"NoBarcodeNumberingTemplateDefined");
282 print
'<br><a href="'.DOL_URL_ROOT.
'/admin/barcode.php">'.$langs->trans(
"ToGenerateCodeDefineAutomaticRuleFirst").
'</a>';
290 $moretags1 = (($disabled || $disabled1) ?
' disabled title="'.
dol_escape_htmltag($titleno).
'"' :
'');
291 print
'<input type="submit" class="button" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'.$langs->trans(
"InitEmptyBarCode", min($maxperinit, $nbno)).
'"'.$moretags1.
'>';
292 $moretags2 = (($nbno == $nbtotal) ?
' disabled' :
'');
294 print
'<input type="submit" class="button butActionDelete" name="eraseallbarcode" id="eraseallbarcode" value="'.$langs->trans(
"EraseAllCurrentBarCode").
'"'.$moretags2.
' onClick="return confirm_erase();">';
295 print
'<br><br><br><br>';
301 print $langs->trans(
"ClickHereToGoTo").
' : <a href="'.DOL_URL_ROOT.
'/barcode/printsheet.php">'.$langs->trans(
"BarCodePrintsheet").
'</a>';
Class to manage third parties objects (customers, suppliers, prospects...)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage products or services.
dol_now($mode='auto')
Return date for now.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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 ...
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.