28if (!empty($_POST[
'mode']) && $_POST[
'mode'] ===
'label') {
29 if (!defined(
'NOTOKENRENEWAL')) {
30 define(
'NOTOKENRENEWAL',
'1');
35require
'../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/modules/printsheet/modules_labels.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
42$langs->loadLangs(array(
'admin',
'members',
'errors'));
49$forbarcode =
GETPOST(
'forbarcode',
'alphanohtml');
50$fk_barcode_type =
GETPOSTINT(
'fk_barcode_type');
52$modellabel =
GETPOST(
"modellabel",
'aZ09');
53$numberofsticker =
GETPOSTINT(
'numberofsticker');
57$action =
GETPOST(
'action',
'aZ09');
60$thirdpartytmp =
new Societe($db);
65if (!isModEnabled(
'barcode')) {
68if (!$user->hasRight(
'barcode',
'read')) {
74$hookmanager->initHooks(array(
'printsheettools'));
79$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
92 $result = $producttmp->fetch(
GETPOSTINT(
'productid'));
96 $forbarcode = $producttmp->barcode;
97 $fk_barcode_type = $producttmp->barcode_type;
103 if (empty($forbarcode) || empty($fk_barcode_type)) {
104 setEventMessages($langs->trans(
"DefinitionOfBarCodeForProductNotComplete", $producttmp->getNomUrl()),
null,
'warnings');
112 $forbarcode = $thirdpartytmp->barcode;
113 $fk_barcode_type = $thirdpartytmp->barcode_type_code;
115 if (empty($fk_barcode_type) &&
getDolGlobalString(
'GENBARCODE_BARCODETYPE_THIRDPARTY')) {
119 if (empty($forbarcode) || empty($fk_barcode_type)) {
120 setEventMessages($langs->trans(
"DefinitionOfBarCodeForThirdpartyNotComplete", $thirdpartytmp->getNomUrl()),
null,
'warnings');
125 if ($action ==
'builddoc' && $user->hasRight(
'barcode',
'read')) {
129 if (empty($forbarcode)) {
130 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BarcodeValue")),
null,
'errors');
135 setEventMessages($langs->trans(
"ErrorFieldTooLong", $langs->transnoentitiesnoconv(
"BarcodeValue")).
' ('.$langs->trans(
"RequireXStringMax", $MAXLENGTH).
')',
null,
'errors');
138 if (empty($fk_barcode_type)) {
139 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BarcodeType")),
null,
'errors');
146 $stdobject->barcode_type = $fk_barcode_type;
147 $result = $stdobject->fetch_barcode();
150 setEventMessages(
'Failed to get bar code type information '.$stdobject->error, $stdobject->errors,
'errors');
156 $generator = $stdobject->barcode_type_coder;
157 $encoding = strtoupper($stdobject->barcode_type_code);
159 $diroutput = $conf->barcode->dir_temp;
163 $dirbarcode = array_merge(array(
"/core/modules/barcode/doc/"), $conf->modules_parts[
'barcode']);
165 foreach ($dirbarcode as $reldir) {
170 if (!is_dir($newdir)) {
174 $result = @include_once $newdir.$generator.
'.modules.php';
181 $classname =
"mod".ucfirst($generator);
182 $module =
new $classname($db);
183 '@phan-var-force ModeleBarCode $module';
184 if ($generator !=
'tcpdfbarcode') {
186 $template =
'standardlabel';
188 if ($module->encodingIsSupported($encoding)) {
189 $barcodeimage = $conf->barcode->dir_temp.
'/barcode_'.$code.
'_'.$encoding.
'.png';
192 $result = $module->writeBarCode($code, $encoding,
'Y', 4, 1);
195 setEventMessages(
'Failed to generate image file of barcode for code='.$code.
' encoding='.$encoding.
' file='.basename($barcodeimage),
null,
'errors');
200 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');
203 $template =
'tcpdflabel';
204 $encoding = $module->getTcpdfEncodingType($encoding);
205 $is2d = $module->is2d;
211 $substitutionarray = array(
212 '%LOGIN%' => $user->login,
213 '%COMPANY%' => $mysoc->name,
214 '%ADDRESS%' => $mysoc->address,
215 '%ZIP%' => $mysoc->zip,
216 '%TOWN%' => $mysoc->town,
217 '%COUNTRY%' => $mysoc->country,
218 '%COUNTRY_CODE%' => $mysoc->country_code,
219 '%EMAIL%' => $mysoc->email,
223 '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT,
224 '%SERVER%' =>
"http://".$_SERVER[
"SERVER_NAME"].
"/",
228 $arrayofrecords = array();
230 if ($mode ==
'label') {
231 $txtforsticker =
"%PHOTO%";
240 if ($numberofsticker <= $MAXSTICKERS) {
241 for ($i = 0; $i < $numberofsticker; $i++) {
242 $arrayofrecords[] = array(
243 'textleft' => $textleft,
244 'textheader' => $textheader,
245 'textfooter' => $textfooter,
246 'textright' => $textright,
248 'encoding' => $encoding,
250 'photo' => !empty($barcodeimage) ? $barcodeimage :
''
254 $mesg = $langs->trans(
"ErrorQuantityIsLimitedTo", $MAXSTICKERS);
260 if (!$error && $mode ==
'label') {
261 if (!count($arrayofrecords)) {
262 $mesg = $langs->trans(
"ErrorRecordNotFound");
264 if (empty($modellabel) || $modellabel ==
'-1') {
265 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_ETIQUETTE_TYPE"));
271 $outputlangs = $langs;
274 $conf->global->TCPDF_THROW_ERRORS_INSTEAD_OF_DIE = 1;
281 $mesg = $langs->trans(
'ErrorGeneratingBarcode');
284 $conf->global->TCPDF_THROW_ERRORS_INSTEAD_OF_DIE = $previousConf;
288 if ($result <= 0 || $mesg || $error) {
290 $mesg =
'Error '.$result;
307$form =
new Form($db);
309llxHeader(
'', $langs->trans(
"BarCodePrintsheet"),
'',
'', 0, 0,
'',
'',
'',
'mod-barcode page-printsheet');
314print
'<span class="opacitymedium">'.$langs->trans(
"PageToGenerateBarCodeSheets", $langs->transnoentitiesnoconv(
"BuildPageToPrint")).
'</span><br>';
320print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
321print
'<input type="hidden" name="mode" value="label">';
322print
'<input type="hidden" name="action" value="builddoc">';
323print
'<input type="hidden" name="token" value="'.currentToken().
'">';
325print
'<div class="tagtable">';
328print
' <div class="tagtr">';
329print
' <div class="tagtd">';
330print $langs->trans(
"DescADHERENT_ETIQUETTE_TYPE").
' ';
331print
'</div><div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;">';
333$arrayoflabels = array();
334foreach (array_keys($_Avery_Labels) as $codecards) {
335 $labeltoshow = $_Avery_Labels[$codecards][
'name'];
337 $arrayoflabels[$codecards] = $labeltoshow;
339asort($arrayoflabels);
340print $form->selectarray(
'modellabel', $arrayoflabels, (
GETPOST(
'modellabel') ?
GETPOST(
'modellabel') :
getDolGlobalString(
'ADHERENT_ETIQUETTE_TYPE')), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
344print
' <div class="tagtr">';
345print
' <div class="tagtd">';
346print $langs->trans(
"NumberOfStickers").
' ';
347print
'</div><div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;">';
348print
'<input size="4" type="text" name="numberofsticker" value="'.(GETPOST(
'numberofsticker') ?
GETPOSTINT(
'numberofsticker') : 10).
'">';
358print
'<script type="text/javascript">
359jQuery(document).ready(function() {
360 function init_selectors()
362 if (jQuery("#fillmanually:checked").val() == "fillmanually")
364 jQuery("#submitproduct").prop("disabled", true);
365 jQuery("#submitthirdparty").prop("disabled", true);
366 jQuery("#search_productid").prop("disabled", true);
367 jQuery("#socid").prop("disabled", true);
368 jQuery(".showforproductselector").hide();
369 jQuery(".showforthirdpartyselector").hide();
371 if (jQuery("#fillfromproduct:checked").val() == "fillfromproduct")
373 jQuery("#submitproduct").removeAttr("disabled");
374 jQuery("#submitthirdparty").prop("disabled", true);
375 jQuery("#search_productid").removeAttr("disabled");
376 jQuery("#socid").prop("disabled", true);
377 jQuery(".showforproductselector").show();
378 jQuery(".showforthirdpartyselector").hide();
380 if (jQuery("#fillfromthirdparty:checked").val() == "fillfromthirdparty")
382 jQuery("#submitproduct").prop("disabled", true);
383 jQuery("#submitthirdparty").removeAttr("disabled");
384 jQuery("#search_productid").prop("disabled", true);
385 jQuery("#socid").removeAttr("disabled");
386 jQuery(".showforproductselector").hide();
387 jQuery(".showforthirdpartyselector").show();
391 jQuery(".radiobarcodeselect").click(function() {
395 function init_gendoc_button()
397 if (jQuery("#select_fk_barcode_type").val() > 0 && jQuery("#forbarcode").val())
399 jQuery("#submitformbarcodegen").removeAttr("disabled");
403 jQuery("#submitformbarcodegen").prop("disabled", true);
406 init_gendoc_button();
407 jQuery("#select_fk_barcode_type").change(function() {
408 init_gendoc_button();
410 jQuery("#forbarcode").keyup(function() {
417print
'<input id="fillmanually" type="radio" '.((!
GETPOST(
"selectorforbarcode") ||
GETPOST(
"selectorforbarcode") ==
'fillmanually') ?
'checked ' :
'').
'name="selectorforbarcode" value="fillmanually" class="radiobarcodeselect"><label for="fillmanually"> '.$langs->trans(
"FillBarCodeTypeAndValueManually").
'</label>';
420if ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire')) {
421 print
'<input id="fillfromproduct" type="radio" '.((GETPOST(
"selectorforbarcode") ==
'fillfromproduct') ?
'checked ' :
'').
'name="selectorforbarcode" value="fillfromproduct" class="radiobarcodeselect"><label for="fillfromproduct"> '.$langs->trans(
"FillBarCodeTypeAndValueFromProduct").
'</label>';
423 print
'<div class="showforproductselector">';
424 $form->select_produits(
GETPOSTINT(
'productid'),
'productid',
'',
'', 0, -1, 2,
'', 0, array(), 0,
'1', 0,
'minwidth400imp', 1);
425 print
' <input type="submit" class="button small" id="submitproduct" name="submitproduct" value="'.(dol_escape_htmltag($langs->trans(
"GetBarCode"))).
'">';
429if ($user->hasRight(
'societe',
'lire')) {
430 print
'<input id="fillfromthirdparty" type="radio" '.((GETPOST(
"selectorforbarcode") ==
'fillfromthirdparty') ?
'checked ' :
'').
'name="selectorforbarcode" value="fillfromthirdparty" class="radiobarcodeselect"><label for="fillfromthirdparty"> '.$langs->trans(
"FillBarCodeTypeAndValueFromThirdParty").
'</label>';
432 print
'<div class="showforthirdpartyselector">';
433 print $form->select_company(
GETPOSTINT(
'socid'),
'socid',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
434 print
' <input type="submit" id="submitthirdparty" name="submitthirdparty" class="button showforthirdpartyselector small" value="'.(dol_escape_htmltag($langs->trans(
"GetBarCode"))).
'">';
440if ($producttmp->id > 0) {
441 print $langs->trans(
"BarCodeDataForProduct",
'').
' '.$producttmp->getNomUrl(1).
'<br>';
443if ($thirdpartytmp->id > 0) {
444 print $langs->trans(
"BarCodeDataForThirdparty",
'').
' '.$thirdpartytmp->getNomUrl(1).
'<br>';
447print
'<div class="tagtable">';
450print
' <div class="tagtr">';
451print
' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
452print $langs->trans(
"BarcodeType").
' ';
453print
'</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
454require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
456print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
460print
' <div class="tagtr">';
461print
' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
462print $langs->trans(
"BarcodeValue").
' ';
463print
'</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
464print
'<input size="16" type="text" name="forbarcode" id="forbarcode" value="'.$forbarcode.
'">';
476print
'<br><input type="submit" class="button" id="submitformbarcodegen" '.((GETPOST(
"selectorforbarcode") &&
GETPOST(
"selectorforbarcode")) ?
'' :
'disabled ').
'value="'.$langs->trans(
"BuildPageToPrint").
'">';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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...)
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($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages 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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.