24 require
'../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
26 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
29 $langs->loadLangs(array(
'admin',
'members',
'errors',
'other'));
36 $forbarcode =
GETPOST(
'forbarcode');
37 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
38 $eraseallbarcode =
GETPOST(
'eraseallbarcode');
40 $action =
GETPOST(
'action',
'aZ09');
43 $thirdpartytmp =
new Societe($db);
45 $modBarCodeProduct =
'';
55 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)
63 $handle = @opendir($dir);
64 if (is_resource($handle))
66 while (($file = readdir($handle)) !==
false)
68 if (preg_match(
'/^mod_barcode_product_.*php$/', $file))
70 $file = substr($file, 0,
dol_strlen($file) - 4);
79 $modBarCodeProduct =
new $file();
88 if ($action ==
'initbarcodeproducts')
90 if (!is_object($modBarCodeProduct))
93 setEventMessages($langs->trans(
"NoBarcodeNumberingTemplateDefined"), null,
'errors');
98 $productstatic =
new Product($db);
103 if (!empty($eraseallbarcode))
105 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product";
106 $sql .=
" SET barcode = NULL";
107 $resql = $db->query($sql);
116 $sql =
"SELECT rowid, ref, fk_product_type";
117 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
118 $sql .=
" WHERE barcode IS NULL or barcode = ''";
119 $sql .= $db->order(
"datec",
"ASC");
120 $sql .= $db->plimit($maxperinit);
123 $resql = $db->query($sql);
126 $num = $db->num_rows(
$resql);
128 $i = 0; $nbok = $nbtry = 0;
129 while ($i < min($num, $maxperinit))
131 $obj = $db->fetch_object(
$resql);
134 $productstatic->id = $obj->rowid;
135 $productstatic->ref = $obj->ref;
136 $productstatic->type = $obj->fk_product_type;
137 $nextvalue = $modBarCodeProduct->getNextValue($productstatic,
'');
140 $result = $productstatic->setValueFrom(
'barcode', $nextvalue,
'',
'',
'text',
'', $user,
'PRODUCT_MODIFY');
143 if ($result > 0) $nbok++;
180 $form =
new Form($db);
182 llxHeader(
'', $langs->trans(
"MassBarcodeInit"));
187 print
'<span class="opacitymedium">'.$langs->trans(
"MassBarcodeInitDesc").
'</span><br>';
193 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
194 print
'<input type="hidden" name="mode" value="label">';
195 print
'<input type="hidden" name="action" value="initbarcodeproducts">';
196 print
'<input type="hidden" name="token" value="'.newToken().
'">';
201 if ($conf->societe->enabled)
203 $nbno = $nbtotal = 0;
205 print
load_fiche_titre($langs->trans(
"BarcodeInitForThirdparties"),
'',
'company');
208 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe where barcode IS NULL or barcode = ''";
209 $resql = $db->query($sql);
212 $obj = $db->fetch_object(
$resql);
216 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"societe";
217 $resql = $db->query($sql);
220 $obj = $db->fetch_object(
$resql);
224 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv(
"ThirdParties")).
'<br>'.
"\n";
226 print
'<br><input class="button" type="submit" id="submitformbarcodethirdpartygen" '.((GETPOST(
"selectorforbarcode") &&
GETPOST(
"selectorforbarcode")) ?
'' :
'disabled ').
'value="'.$langs->trans(
"InitEmptyBarCode", $nbno).
'"';
227 print
' title="'.dol_escape_htmltag($langs->trans(
"FeatureNotYetAvailable")).
'" disabled';
229 print
'<br><br><br><br>';
234 if ($conf->product->enabled || $conf->product->service)
237 print
'<script type="text/javascript" language="javascript">
238 function confirm_erase() {
239 return confirm("'.dol_escape_js($langs->trans(
"ConfirmEraseAllCurrentBarCode")).
'");
243 $nbno = $nbtotal = 0;
245 print
load_fiche_titre($langs->trans(
"BarcodeInitForProductsOrServices"),
'',
'product');
248 $sql =
"SELECT count(rowid) as nb, fk_product_type, datec";
249 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
250 $sql .=
" WHERE barcode IS NULL OR barcode = ''";
251 $sql .=
" GROUP BY fk_product_type, datec";
252 $sql .=
" ORDER BY datec";
253 $resql = $db->query($sql);
256 $num = $db->num_rows(
$resql);
261 $obj = $db->fetch_object(
$resql);
268 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"product";
269 $resql = $db->query($sql);
272 $obj = $db->fetch_object(
$resql);
276 print $langs->trans(
"CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv(
"ProductsOrServices")).
'<br>'.
"\n";
278 if (is_object($modBarCodeProduct))
280 print $langs->trans(
"BarCodeNumberManager").
": ";
281 $objproduct =
new Product($db);
282 print
'<b>'.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).
'</b> - '.$langs->trans(
"NextValue").
': <b>'.$modBarCodeProduct->getNextValue($objproduct).
'</b><br>';
286 $titleno = $langs->trans(
"NoBarcodeNumberingTemplateDefined");
287 print
'<font class="warning">'.$langs->trans(
"NoBarcodeNumberingTemplateDefined").
'</font> (<a href="'.DOL_URL_ROOT.
'/admin/barcode.php">'.$langs->trans(
"ToGenerateCodeDefineAutomaticRuleFirst").
'</a>)<br>';
296 $moretags1 = (($disabled || $disabled1) ?
' disabled title="'.
dol_escape_htmltag($titleno).
'"' :
'');
297 print
'<input class="button" type="submit" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'.$langs->trans(
"InitEmptyBarCode", min($maxperinit, $nbno)).
'"'.$moretags1.
'>';
298 $moretags2 = (($nbno == $nbtotal) ?
' disabled' :
'');
300 print
'<input class="button" type="submit" name="eraseallbarcode" id="eraseallbarcode" value="'.$langs->trans(
"EraseAllCurrentBarCode").
'"'.$moretags2.
' onClick="return confirm_erase();">';
301 print
'<br><br><br><br>';
307 print $langs->trans(
"ClickHereToGoTo").
' : <a href="'.DOL_URL_ROOT.
'/barcode/printsheet.php">'.$langs->trans(
"BarCodePrintsheet").
'</a>';
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.
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
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 ...
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...