26 if (!empty($_POST[
'mode']) && $_POST[
'mode'] ===
'label') {
27 if (!defined(
'NOTOKENRENEWAL')) {
28 define(
'NOTOKENRENEWAL',
'1');
33 require
'../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/modules/printsheet/modules_labels.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
40 $langs->loadLangs(array(
'admin',
'members',
'errors'));
47 $forbarcode =
GETPOST(
'forbarcode',
'alphanohtml');
48 $fk_barcode_type =
GETPOST(
'fk_barcode_type',
'int');
49 $mode =
GETPOST(
'mode',
'aZ09');
50 $modellabel =
GETPOST(
"modellabel",
'aZ09');
51 $numberofsticker =
GETPOST(
'numberofsticker',
'int');
55 $action =
GETPOST(
'action',
'aZ09');
58 $thirdpartytmp =
new Societe($db);
66 if (!$user->hasRight(
'barcode',
'read')) {
78 if (
GETPOST(
'productid',
'int') > 0) {
79 $result = $producttmp->fetch(
GETPOST(
'productid',
'int'));
83 $forbarcode = $producttmp->barcode;
84 $fk_barcode_type = $producttmp->barcode_type;
86 if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) {
87 $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
90 if (empty($forbarcode) || empty($fk_barcode_type)) {
91 setEventMessages($langs->trans(
"DefinitionOfBarCodeForProductNotComplete", $producttmp->getNomUrl()),
null,
'warnings');
97 if (
GETPOST(
'socid',
'int') > 0) {
98 $thirdpartytmp->fetch(
GETPOST(
'socid',
'int'));
99 $forbarcode = $thirdpartytmp->barcode;
100 $fk_barcode_type = $thirdpartytmp->barcode_type_code;
102 if (empty($fk_barcode_type) && !empty($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY)) {
103 $fk_barcode_type = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY;
106 if (empty($forbarcode) || empty($fk_barcode_type)) {
107 setEventMessages($langs->trans(
"DefinitionOfBarCodeForThirdpartyNotComplete", $thirdpartytmp->getNomUrl()),
null,
'warnings');
112 if ($action ==
'builddoc') {
113 $result = 0; $error = 0;
115 if (empty($forbarcode)) {
116 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BarcodeValue")),
null,
'errors');
119 if (empty($fk_barcode_type)) {
120 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BarcodeType")),
null,
'errors');
127 $stdobject->barcode_type = $fk_barcode_type;
128 $result = $stdobject->fetch_barcode();
131 setEventMessages(
'Failed to get bar code type information '.$stdobject->error, $stdobject->errors,
'errors');
137 $generator = $stdobject->barcode_type_coder;
138 $encoding = strtoupper($stdobject->barcode_type_code);
140 $diroutput = $conf->barcode->dir_temp;
144 $dirbarcode = array_merge(array(
"/core/modules/barcode/doc/"), $conf->modules_parts[
'barcode']);
146 foreach ($dirbarcode as $reldir) {
151 if (!is_dir($newdir)) {
155 $result = @include_once $newdir.$generator.
'.modules.php';
162 $classname =
"mod".ucfirst($generator);
163 $module =
new $classname($db);
164 if ($generator !=
'tcpdfbarcode') {
166 $template =
'standardlabel';
168 if ($module->encodingIsSupported($encoding)) {
169 $barcodeimage = $conf->barcode->dir_temp.
'/barcode_'.$code.
'_'.$encoding.
'.png';
172 $result = $module->writeBarCode($code, $encoding,
'Y', 4, 1);
175 setEventMessages(
'Failed to generate image file of barcode for code='.$code.
' encoding='.$encoding.
' file='.basename($barcodeimage),
null,
'errors');
180 setEventMessages(
"Error, encoding ".$encoding.
" is not supported by encoder ".$generator.
'. You must choose another barcode type or install a barcode generation engine that support '.$encoding,
null,
'errors');
183 $template =
'tcpdflabel';
184 $encoding = $module->getTcpdfEncodingType($encoding);
185 $is2d = $module->is2d;
191 $substitutionarray = array(
192 '%LOGIN%' => $user->login,
193 '%COMPANY%' => $mysoc->name,
194 '%ADDRESS%' => $mysoc->address,
195 '%ZIP%' => $mysoc->zip,
196 '%TOWN%' => $mysoc->town,
197 '%COUNTRY%' => $mysoc->country,
198 '%COUNTRY_CODE%' => $mysoc->country_code,
199 '%EMAIL%' => $mysoc->email,
203 '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT,
204 '%SERVER%' =>
"http://".$_SERVER[
"SERVER_NAME"].
"/",
209 if ($mode ==
'label') {
210 $txtforsticker =
"%PHOTO%";
211 $textleft =
make_substitutions((empty($conf->global->BARCODE_LABEL_LEFT_TEXT) ? $txtforsticker : $conf->global->BARCODE_LABEL_LEFT_TEXT), $substitutionarray);
212 $textheader =
make_substitutions((empty($conf->global->BARCODE_LABEL_HEADER_TEXT) ?
'' : $conf->global->BARCODE_LABEL_HEADER_TEXT), $substitutionarray);
213 $textfooter =
make_substitutions((empty($conf->global->BARCODE_LABEL_FOOTER_TEXT) ?
'' : $conf->global->BARCODE_LABEL_FOOTER_TEXT), $substitutionarray);
214 $textright =
make_substitutions((empty($conf->global->BARCODE_LABEL_RIGHT_TEXT) ?
'' : $conf->global->BARCODE_LABEL_RIGHT_TEXT), $substitutionarray);
215 $forceimgscalewidth = (empty($conf->global->BARCODE_FORCEIMGSCALEWIDTH) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEWIDTH);
216 $forceimgscaleheight = (empty($conf->global->BARCODE_FORCEIMGSCALEHEIGHT) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEHEIGHT);
219 if ($numberofsticker <= $MAXSTICKERS) {
220 for ($i = 0; $i < $numberofsticker; $i++) {
221 $arrayofrecords[] = array(
222 'textleft'=>$textleft,
223 'textheader'=>$textheader,
224 'textfooter'=>$textfooter,
225 'textright'=>$textright,
227 'encoding'=>$encoding,
229 'photo'=>$barcodeimage
233 $mesg = $langs->trans(
"ErrorQuantityIsLimitedTo", $MAXSTICKERS);
241 if (!$error && $mode ==
'label') {
242 if (!count($arrayofrecords)) {
243 $mesg = $langs->trans(
"ErrorRecordNotFound");
245 if (empty($modellabel) || $modellabel ==
'-1') {
246 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_ETIQUETTE_TYPE"));
252 $outputlangs = $langs;
260 if ($result <= 0 || $mesg || $error) {
262 $mesg =
'Error '.$result;
280 llxHeader(
'', $langs->trans(
"BarCodePrintsheet"));
285 print
'<span class="opacitymedium">'.$langs->trans(
"PageToGenerateBarCodeSheets", $langs->transnoentitiesnoconv(
"BuildPageToPrint")).
'</span><br>';
291 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
292 print
'<input type="hidden" name="mode" value="label">';
293 print
'<input type="hidden" name="action" value="builddoc">';
294 print
'<input type="hidden" name="token" value="'.currentToken().
'">';
296 print
'<div class="tagtable">';
299 print
' <div class="tagtr">';
300 print
' <div class="tagtd">';
301 print $langs->trans(
"DescADHERENT_ETIQUETTE_TYPE").
' ';
302 print
'</div><div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;">';
304 $arrayoflabels = array();
305 foreach (array_keys($_Avery_Labels) as $codecards) {
306 $labeltoshow = $_Avery_Labels[$codecards][
'name'];
308 $arrayoflabels[$codecards] = $labeltoshow;
310 asort($arrayoflabels);
311 print
$form->selectarray(
'modellabel', $arrayoflabels, (
GETPOST(
'modellabel') ?
GETPOST(
'modellabel') : $conf->global->ADHERENT_ETIQUETTE_TYPE), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
312 print
'</div></div>';
315 print
' <div class="tagtr">';
316 print
' <div class="tagtd">';
317 print $langs->trans(
"NumberOfStickers").
' ';
318 print
'</div><div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;">';
319 print
'<input size="4" type="text" name="numberofsticker" value="'.(GETPOST(
'numberofsticker') ?
GETPOST(
'numberofsticker',
'int') : 10).
'">';
320 print
'</div></div>';
329 print
'<script type="text/javascript">
330 jQuery(document).ready(function() {
331 function init_selectors()
333 if (jQuery("#fillmanually:checked").val() == "fillmanually")
335 jQuery("#submitproduct").prop("disabled", true);
336 jQuery("#submitthirdparty").prop("disabled", true);
337 jQuery("#search_productid").prop("disabled", true);
338 jQuery("#socid").prop("disabled", true);
339 jQuery(".showforproductselector").hide();
340 jQuery(".showforthirdpartyselector").hide();
342 if (jQuery("#fillfromproduct:checked").val() == "fillfromproduct")
344 jQuery("#submitproduct").removeAttr("disabled");
345 jQuery("#submitthirdparty").prop("disabled", true);
346 jQuery("#search_productid").removeAttr("disabled");
347 jQuery("#socid").prop("disabled", true);
348 jQuery(".showforproductselector").show();
349 jQuery(".showforthirdpartyselector").hide();
351 if (jQuery("#fillfromthirdparty:checked").val() == "fillfromthirdparty")
353 jQuery("#submitproduct").prop("disabled", true);
354 jQuery("#submitthirdparty").removeAttr("disabled");
355 jQuery("#search_productid").prop("disabled", true);
356 jQuery("#socid").removeAttr("disabled");
357 jQuery(".showforproductselector").hide();
358 jQuery(".showforthirdpartyselector").show();
362 jQuery(".radiobarcodeselect").click(function() {
366 function init_gendoc_button()
368 if (jQuery("#select_fk_barcode_type").val() > 0 && jQuery("#forbarcode").val())
370 jQuery("#submitformbarcodegen").removeAttr("disabled");
374 jQuery("#submitformbarcodegen").prop("disabled", true);
377 init_gendoc_button();
378 jQuery("#select_fk_barcode_type").change(function() {
379 init_gendoc_button();
381 jQuery("#forbarcode").keyup(function() {
388 print
'<input id="fillmanually" type="radio" '.((!
GETPOST(
"selectorforbarcode") ||
GETPOST(
"selectorforbarcode") ==
'fillmanually') ?
'checked ' :
'').
'name="selectorforbarcode" value="fillmanually" class="radiobarcodeselect"><label for="fillmanually"> '.$langs->trans(
"FillBarCodeTypeAndValueManually").
'</label>';
391 if (!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)) {
392 print
'<input id="fillfromproduct" type="radio" '.((GETPOST(
"selectorforbarcode") ==
'fillfromproduct') ?
'checked ' :
'').
'name="selectorforbarcode" value="fillfromproduct" class="radiobarcodeselect"><label for="fillfromproduct"> '.$langs->trans(
"FillBarCodeTypeAndValueFromProduct").
'</label>';
394 print
'<div class="showforproductselector">';
395 $form->select_produits(
GETPOST(
'productid',
'int'),
'productid',
'',
'', 0, -1, 2,
'', 0, array(), 0,
'1', 0,
'minwidth400imp', 1);
396 print
' <input type="submit" class="button small" id="submitproduct" name="submitproduct" value="'.(dol_escape_htmltag($langs->trans(
"GetBarCode"))).
'">';
400 if ($user->hasRight(
'societe',
'lire')) {
401 print
'<input id="fillfromthirdparty" type="radio" '.((GETPOST(
"selectorforbarcode") ==
'fillfromthirdparty') ?
'checked ' :
'').
'name="selectorforbarcode" value="fillfromthirdparty" class="radiobarcodeselect"><label for="fillfromthirdparty"> '.$langs->trans(
"FillBarCodeTypeAndValueFromThirdParty").
'</label>';
403 print
'<div class="showforthirdpartyselector">';
404 print
$form->select_company(
GETPOST(
'socid',
'int'),
'socid',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
405 print
' <input type="submit" id="submitthirdparty" name="submitthirdparty" class="button showforthirdpartyselector small" value="'.(dol_escape_htmltag($langs->trans(
"GetBarCode"))).
'">';
411 if ($producttmp->id > 0) {
412 print $langs->trans(
"BarCodeDataForProduct",
'').
' '.$producttmp->getNomUrl(1).
'<br>';
414 if ($thirdpartytmp->id > 0) {
415 print $langs->trans(
"BarCodeDataForThirdparty",
'').
' '.$thirdpartytmp->getNomUrl(1).
'<br>';
418 print
'<div class="tagtable">';
421 print
' <div class="tagtr">';
422 print
' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
423 print $langs->trans(
"BarcodeType").
' ';
424 print
'</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
425 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
427 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
428 print
'</div></div>';
431 print
' <div class="tagtr">';
432 print
' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
433 print $langs->trans(
"BarcodeValue").
' ';
434 print
'</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
435 print
'<input size="16" type="text" name="forbarcode" id="forbarcode" value="'.$forbarcode.
'">';
436 print
'</div></div>';
447 print
'<br><input type="submit" class="button" id="submitformbarcodegen" '.((GETPOST(
"selectorforbarcode") &&
GETPOST(
"selectorforbarcode")) ?
'' :
'disabled ').
'value="'.$langs->trans(
"BuildPageToPrint").
'">';
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class of a generic business object.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_is_file($pathoffile)
Return if path is a file.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
isModEnabled($module)
Is Dolibarr module enabled.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outputdir='', $template='standardlabel', $filename='tmp_address_sheet.pdf')
Create a document onto disk according to template module.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.