--- /tmp/dsg/dolibarr/htdocs/barcode/github_19.0.3_codeinit.php +++ /tmp/dsg/dolibarr/htdocs/barcode/client_codeinit.php @@ -2 +2 @@ -/* Copyright (C) 2014-2022 Laurent Destailleur +/* Copyright (C) 2014-2015 Laurent Destailleur @@ -24,2 +23,0 @@ - -// Load Dolibarr environment @@ -40,2 +38 @@ -$eraseallproductbarcode = GETPOST('eraseallproductbarcode'); -$eraseallthirdpartybarcode = GETPOST('eraseallthirdpartybarcode'); +$eraseallbarcode = GETPOST('eraseallbarcode'); @@ -49,14 +46,2 @@ -$modBarCodeThirdparty = ''; - -$maxperinit = !getDolGlobalString('BARCODE_INIT_MAX') ? 1000 : $conf->global->BARCODE_INIT_MAX; - -// Security check (enable the most restrictive one) -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -if (!isModEnabled('barcode')) { - accessforbidden('Module not enabled'); -} -//restrictedArea($user, 'barcode'); -if (empty($user->admin)) { - accessforbidden('Must be admin'); -} + +$maxperinit = 1000; @@ -69,2 +54,3 @@ -// Define barcode template for third-party -if (getDolGlobalString('BARCODE_THIRDPARTY_ADDON_NUM')) { +// Define barcode template for products +if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) +{ @@ -73 +59,2 @@ - foreach ($dirbarcodenum as $dirroot) { + foreach ($dirbarcodenum as $dirroot) + { @@ -77,3 +64,6 @@ - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - if (preg_match('/^mod_barcode_thirdparty_.*php$/', $file)) { + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/^mod_barcode_product_.*php$/', $file)) + { @@ -84 +74,3 @@ - } catch (Exception $e) { + } + catch (Exception $e) + { @@ -88 +80 @@ - $modBarCodeThirdparty = new $file(); + $modBarCodeProduct = new $file(); @@ -97,2 +89,4 @@ -if ($action == 'initbarcodethirdparties') { - if (!is_object($modBarCodeThirdparty)) { +if ($action == 'initbarcodeproducts') +{ + if (!is_object($modBarCodeProduct)) + { @@ -103,2 +97,3 @@ - if (!$error) { - $thirdpartystatic = new Societe($db); + if (!$error) + { + $productstatic = new Product($db); @@ -109,3 +104,3 @@ - if (!empty($eraseallthirdpartybarcode)) { - $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql .= " AND entity IN (".getEntity('societe').")"; + if (!empty($eraseallbarcode)) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."product"; @@ -114 +109,2 @@ - if ($resql) { + if ($resql) + { @@ -116 +112,3 @@ - } else { + } + else + { @@ -120,106 +118,3 @@ - } else { - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe"; - $sql .= " WHERE barcode IS NULL or barcode = ''"; - $sql .= " AND entity IN (".getEntity('societe').")"; - $sql .= $db->order("datec", "ASC"); - $sql .= $db->plimit($maxperinit); - - dol_syslog("codeinit", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - $i = 0; - $nbok = $nbtry = 0; - while ($i < min($num, $maxperinit)) { - $obj = $db->fetch_object($resql); - if ($obj) { - $thirdpartystatic->id = $obj->rowid; - $nextvalue = $modBarCodeThirdparty->getNextValue($thirdpartystatic, ''); - - $result = $thirdpartystatic->setValueFrom('barcode', $nextvalue, '', '', 'text', '', $user, 'THIRDPARTY_MODIFY'); - - $nbtry++; - if ($result > 0) { - $nbok++; - } - } - - $i++; - } - } else { - $error++; - dol_print_error($db); - } - - if (!$error) { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } - } - - if (!$error) { - //$db->rollback(); - $db->commit(); - } else { - $db->rollback(); - } - } - - $action = ''; -} - -// Define barcode template for products -if (getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM')) { - $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); - - foreach ($dirbarcodenum as $dirroot) { - $dir = dol_buildpath($dirroot, 0); - - $handle = @opendir($dir); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - if (preg_match('/^mod_barcode_product_.*php$/', $file)) { - $file = substr($file, 0, dol_strlen($file) - 4); - - if ($file == $conf->global->BARCODE_PRODUCT_ADDON_NUM) { - try { - dol_include_once($dirroot.$file.'.php'); - } catch (Exception $e) { - dol_syslog($e->getMessage(), LOG_ERR); - } - - $modBarCodeProduct = new $file(); - break; - } - } - } - closedir($handle); - } - } -} - -if ($action == 'initbarcodeproducts') { - if (!is_object($modBarCodeProduct)) { - $error++; - setEventMessages($langs->trans("NoBarcodeNumberingTemplateDefined"), null, 'errors'); - } - - if (!$error) { - $productstatic = new Product($db); - - $db->begin(); - - $nbok = 0; - if (!empty($eraseallproductbarcode)) { - $sql = "UPDATE ".MAIN_DB_PREFIX."product"; - $sql .= " SET barcode = NULL"; - $sql .= " WHERE entity IN (".getEntity('product').")"; - $resql = $db->query($sql); - if ($resql) { - setEventMessages($langs->trans("AllBarcodeReset"), null, 'mesgs'); - } else { - $error++; - dol_print_error($db); - } - } else { + } + else + { @@ -229 +123,0 @@ - $sql .= " AND entity IN (".getEntity('product').")"; @@ -235 +129,2 @@ - if ($resql) { + if ($resql) + { @@ -238,3 +133,3 @@ - $i = 0; - $nbok = $nbtry = 0; - while ($i < min($num, $maxperinit)) { + $i = 0; $nbok = $nbtry = 0; + while ($i < min($num, $maxperinit)) + { @@ -242 +137,2 @@ - if ($obj) { + if ($obj) + { @@ -252,3 +148 @@ - if ($result > 0) { - $nbok++; - } + if ($result > 0) $nbok++; @@ -259 +153,3 @@ - } else { + } + else + { @@ -264 +160,2 @@ - if (!$error) { + if (!$error) + { @@ -269 +166,2 @@ - if (!$error) { + if (!$error) + { @@ -272 +170,3 @@ - } else { + } + else + { @@ -278,0 +179 @@ + @@ -284,0 +186,3 @@ +if (!$user->admin) accessforbidden(); +if (empty($conf->barcode->enabled)) accessforbidden(); + @@ -297,0 +202,5 @@ +print '
'; +print ''; +print ''; +print ''; + @@ -300,10 +208,0 @@ - - -// Example 1 : Adding jquery code -print ''; - - @@ -311,6 +210,3 @@ -if (isModEnabled('societe')) { - print ''; - print ''; - print ''; - print ''; - $nbthirdpartyno = $nbthirdpartytotal = 0; +if ($conf->societe->enabled) +{ + $nbno = $nbtotal = 0; @@ -323 +219,2 @@ - if ($resql) { + if ($resql) + { @@ -325,4 +222,3 @@ - $nbthirdpartyno = $obj->nb; - } else { - dol_print_error($db); - } + $nbno = $obj->nb; + } + else dol_print_error($db); @@ -331 +226,0 @@ - $sql .= " WHERE entity IN (".getEntity('societe').")"; @@ -333 +228,2 @@ - if ($resql) { + if ($resql) + { @@ -335,31 +231,9 @@ - $nbthirdpartytotal = $obj->nb; - } else { - dol_print_error($db); - } - - print $langs->trans("CurrentlyNWithoutBarCode", $nbthirdpartyno, $nbthirdpartytotal, $langs->transnoentitiesnoconv("ThirdParties"))."\n"; - - $disabledthirdparty = $disabledthirdparty1 = 0; - - if (is_object($modBarCodeThirdparty)) { - print '
'.$langs->trans("BarCodeNumberManager").": "; - $objthirdparty = new Societe($db); - print ''.(isset($modBarCodeThirdparty->name) ? $modBarCodeThirdparty->name : $modBarCodeThirdparty->nom).' - '.$langs->trans("NextValue").': '.$modBarCodeThirdparty->getNextValue($objthirdparty).'
'; - $disabledthirdparty = 0; - print '
'; - } else { - $disabledthirdparty = 1; - $titleno = $langs->trans("NoBarcodeNumberingTemplateDefined"); - print '
'.$langs->trans("NoBarcodeNumberingTemplateDefined"); - print '
'.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").''; - print '
'; - } - if (empty($nbthirdpartyno)) { - $disabledthirdparty1 = 1; - } - - $moretagsthirdparty1 = (($disabledthirdparty || $disabledthirdparty1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : ''); - print '
'; - $moretagsthirdparty2 = (($nbthirdpartyno == $nbthirdpartytotal) ? ' disabled' : ''); - print '   '; - print ''; + $nbtotal = $obj->nb; + } + else dol_print_error($db); + + print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("ThirdParties")).'
'."\n"; + + print '
'; @@ -367 +240,0 @@ - print '
'; @@ -372,7 +245,10 @@ -if (isModEnabled('product') || isModEnabled('service')) { - print '
'; - print ''; - print ''; - print ''; - - $nbproductno = $nbproducttotal = 0; +if ($conf->product->enabled || $conf->product->service) +{ + // Example 1 : Adding jquery code + print ''; + + $nbno = $nbtotal = 0; @@ -386 +261,0 @@ - $sql .= " AND entity IN (".getEntity('product').")"; @@ -390 +265,2 @@ - if ($resql) { + if ($resql) + { @@ -394 +270,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -396 +273 @@ - $nbproductno += $obj->nb; + $nbno += $obj->nb; @@ -400,3 +277,2 @@ - } else { - dol_print_error($db); - } + } + else dol_print_error($db); @@ -405 +280,0 @@ - $sql .= " WHERE entity IN (".getEntity('product').")"; @@ -407 +282,2 @@ - if ($resql) { + if ($resql) + { @@ -409,11 +285,9 @@ - $nbproducttotal = $obj->nb; - } else { - dol_print_error($db); - } - - print $langs->trans("CurrentlyNWithoutBarCode", $nbproductno, $nbproducttotal, $langs->transnoentitiesnoconv("ProductsOrServices"))."\n"; - - $disabledproduct = $disabledproduct1 = 0; - - if (is_object($modBarCodeProduct)) { - print '
'.$langs->trans("BarCodeNumberManager").": "; + $nbtotal = $obj->nb; + } + else dol_print_error($db); + + print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("ProductsOrServices")).'
'."\n"; + + if (is_object($modBarCodeProduct)) + { + print $langs->trans("BarCodeNumberManager").": "; @@ -422,4 +296,5 @@ - $disabledproduct = 0; - print '
'; - } else { - $disabledproduct = 1; + $disabled = 0; + } + else + { + $disabled = 1; @@ -427,8 +302,8 @@ - print '
'.$langs->trans("NoBarcodeNumberingTemplateDefined"); - print '
'.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").''; - print '
'; - } - if (empty($nbproductno)) { - $disabledproduct1 = 1; - } - + print ''.$langs->trans("NoBarcodeNumberingTemplateDefined").' ('.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").')
'; + } + if (empty($nbno)) + { + $disabled1 = 1; + } + + print '
'; @@ -436,3 +311,3 @@ - $moretagsproduct1 = (($disabledproduct || $disabledproduct1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : ''); - print ''; - $moretagsproduct2 = (($nbproductno == $nbproducttotal) ? ' disabled' : ''); + $moretags1 = (($disabled || $disabled1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : ''); + print ''; + $moretags2 = (($nbno == $nbtotal) ? ' disabled' : ''); @@ -440 +315 @@ - print ''; + print ''; @@ -442 +316,0 @@ - print '
'; @@ -451,0 +326 @@ +print ''; --- /tmp/dsg/dolibarr/htdocs/barcode/github_19.0.3_printsheet.php +++ /tmp/dsg/dolibarr/htdocs/barcode/client_printsheet.php @@ -25,8 +24,0 @@ - -if (!empty($_POST['mode']) && $_POST['mode'] === 'label') { // Page is called to build a PDF and output, we must not renew the token. - if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) - } -} - -// Load Dolibarr environment @@ -47,4 +39,4 @@ -$forbarcode = GETPOST('forbarcode', 'alphanohtml'); -$fk_barcode_type = GETPOST('fk_barcode_type', 'int'); -$mode = GETPOST('mode', 'aZ09'); -$modellabel = GETPOST("modellabel", 'aZ09'); // Doc template to use +$forbarcode = GETPOST('forbarcode'); +$fk_barcode_type = GETPOST('fk_barcode_type'); +$mode = GETPOST('mode'); +$modellabel = GETPOST("modellabel"); // Doc template to use @@ -59,11 +50,0 @@ - -// Security check (enable the most restrictive one) -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -if (!isModEnabled('barcode')) { - accessforbidden('Module not enabled'); -} -if (!$user->hasRight('barcode', 'read')) { - accessforbidden(); -} -restrictedArea($user, 'barcode'); @@ -76 +57,2 @@ -if (GETPOST('submitproduct') && GETPOST('submitproduct')) { +if (GETPOST('submitproduct') && GETPOST('submitproduct')) +{ @@ -78,5 +60,3 @@ - if (GETPOST('productid', 'int') > 0) { - $result = $producttmp->fetch(GETPOST('productid', 'int')); - if ($result < 0) { - setEventMessage($producttmp->error, 'errors'); - } + if (GETPOST('productid') > 0) + { + $producttmp->fetch(GETPOST('productid')); @@ -86,5 +66,4 @@ - if (empty($fk_barcode_type) && getDolGlobalString('PRODUIT_DEFAULT_BARCODE_TYPE')) { - $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; - } - - if (empty($forbarcode) || empty($fk_barcode_type)) { + if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; + + if (empty($forbarcode) || empty($fk_barcode_type)) + { @@ -95 +74,2 @@ -if (GETPOST('submitthirdparty') && GETPOST('submitthirdparty')) { +if (GETPOST('submitthirdparty') && GETPOST('submitthirdparty')) +{ @@ -97,2 +77,3 @@ - if (GETPOST('socid', 'int') > 0) { - $thirdpartytmp->fetch(GETPOST('socid', 'int')); + if (GETPOST('socid') > 0) + { + $thirdpartytmp->fetch(GETPOST('socid')); @@ -102,5 +83,4 @@ - if (empty($fk_barcode_type) && getDolGlobalString('GENBARCODE_BARCODETYPE_THIRDPARTY')) { - $fk_barcode_type = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY; - } - - if (empty($forbarcode) || empty($fk_barcode_type)) { + if (empty($fk_barcode_type) && !empty($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY)) $fk_barcode_type = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY; + + if (empty($forbarcode) || empty($fk_barcode_type)) + { @@ -112,5 +92,6 @@ -if ($action == 'builddoc') { - $result = 0; - $error = 0; - - if (empty($forbarcode)) { // barcode value +if ($action == 'builddoc') +{ + $result = 0; $error = 0; + + if (empty($forbarcode)) // barcode value + { @@ -120,6 +101,2 @@ - $MAXLENGTH = 51200; // Limit set to 50Ko - if (dol_strlen($forbarcode) > $MAXLENGTH) { // barcode value - setEventMessages($langs->trans("ErrorFieldTooLong", $langs->transnoentitiesnoconv("BarcodeValue")).' ('.$langs->trans("RequireXStringMax", $MAXLENGTH).')', null, 'errors'); - $error++; - } - if (empty($fk_barcode_type)) { // barcode type = barcode encoding + if (empty($fk_barcode_type)) // barcode type = barcode encoding + { @@ -130 +107,2 @@ - if (!$error) { + if (!$error) + { @@ -135 +113,2 @@ - if ($result <= 0) { + if ($result <= 0) + { @@ -141 +120,2 @@ - if (!$error) { + if (!$error) + { @@ -152 +132,2 @@ - foreach ($dirbarcode as $reldir) { + foreach ($dirbarcode as $reldir) + { @@ -157,3 +138 @@ - if (!is_dir($newdir)) { - continue; - } + if (!is_dir($newdir)) continue; @@ -162,3 +141 @@ - if ($result) { - break; - } + if ($result) break; @@ -170,2 +147,3 @@ - if ($generator != 'tcpdfbarcode') { - // May be phpbarcode + if ($generator != 'tcpdfbarcode') + { + // May be phpbarcode @@ -174 +152,2 @@ - if ($module->encodingIsSupported($encoding)) { + if ($module->encodingIsSupported($encoding)) + { @@ -179 +158,2 @@ - if ($result <= 0 || !dol_is_file($barcodeimage)) { + if ($result <= 0 || !dol_is_file($barcodeimage)) + { @@ -184 +164,3 @@ - } else { + } + else + { @@ -195 +177,2 @@ - if (!$error) { + if (!$error) + { @@ -198,13 +181,13 @@ - '%LOGIN%' => $user->login, - '%COMPANY%' => $mysoc->name, - '%ADDRESS%' => $mysoc->address, - '%ZIP%' => $mysoc->zip, - '%TOWN%' => $mysoc->town, - '%COUNTRY%' => $mysoc->country, - '%COUNTRY_CODE%' => $mysoc->country_code, - '%EMAIL%' => $mysoc->email, - '%YEAR%' => $year, - '%MONTH%' => $month, - '%DAY%' => $day, - '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, - '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/", + '%LOGIN%' => $user->login, + '%COMPANY%' => $mysoc->name, + '%ADDRESS%' => $mysoc->address, + '%ZIP%' => $mysoc->zip, + '%TOWN%' => $mysoc->town, + '%COUNTRY%' => $mysoc->country, + '%COUNTRY_CODE%' => $mysoc->country_code, + '%EMAIL%' => $mysoc->email, + '%YEAR%' => $year, + '%MONTH%' => $month, + '%DAY%' => $day, + '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, + '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/", @@ -215 +198,2 @@ - if ($mode == 'label') { + if ($mode == 'label') + { @@ -217,24 +201,19 @@ - $textleft = make_substitutions((!getDolGlobalString('BARCODE_LABEL_LEFT_TEXT') ? $txtforsticker : $conf->global->BARCODE_LABEL_LEFT_TEXT), $substitutionarray); - $textheader = make_substitutions((!getDolGlobalString('BARCODE_LABEL_HEADER_TEXT') ? '' : $conf->global->BARCODE_LABEL_HEADER_TEXT), $substitutionarray); - $textfooter = make_substitutions((!getDolGlobalString('BARCODE_LABEL_FOOTER_TEXT') ? '' : $conf->global->BARCODE_LABEL_FOOTER_TEXT), $substitutionarray); - $textright = make_substitutions((!getDolGlobalString('BARCODE_LABEL_RIGHT_TEXT') ? '' : $conf->global->BARCODE_LABEL_RIGHT_TEXT), $substitutionarray); - $forceimgscalewidth = (!getDolGlobalString('BARCODE_FORCEIMGSCALEWIDTH') ? 1 : $conf->global->BARCODE_FORCEIMGSCALEWIDTH); - $forceimgscaleheight = (!getDolGlobalString('BARCODE_FORCEIMGSCALEHEIGHT') ? 1 : $conf->global->BARCODE_FORCEIMGSCALEHEIGHT); - - $MAXSTICKERS = 1000; - if ($numberofsticker <= $MAXSTICKERS) { - for ($i = 0; $i < $numberofsticker; $i++) { - $arrayofrecords[] = array( - 'textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'code'=>$code, - 'encoding'=>$encoding, - 'is2d'=>$is2d, - 'photo'=>!empty($barcodeimage) ? $barcodeimage : '' // Photo must be a file that exists with format supported by TCPDF - ); - } - } else { - $mesg = $langs->trans("ErrorQuantityIsLimitedTo", $MAXSTICKERS); - $error++; + $textleft = make_substitutions((empty($conf->global->BARCODE_LABEL_LEFT_TEXT) ? $txtforsticker : $conf->global->BARCODE_LABEL_LEFT_TEXT), $substitutionarray); + $textheader = make_substitutions((empty($conf->global->BARCODE_LABEL_HEADER_TEXT) ? '' : $conf->global->BARCODE_LABEL_HEADER_TEXT), $substitutionarray); + $textfooter = make_substitutions((empty($conf->global->BARCODE_LABEL_FOOTER_TEXT) ? '' : $conf->global->BARCODE_LABEL_FOOTER_TEXT), $substitutionarray); + $textright = make_substitutions((empty($conf->global->BARCODE_LABEL_RIGHT_TEXT) ? '' : $conf->global->BARCODE_LABEL_RIGHT_TEXT), $substitutionarray); + $forceimgscalewidth = (empty($conf->global->BARCODE_FORCEIMGSCALEWIDTH) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEWIDTH); + $forceimgscaleheight = (empty($conf->global->BARCODE_FORCEIMGSCALEHEIGHT) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEHEIGHT); + + for ($i = 0; $i < $numberofsticker; $i++) + { + $arrayofrecords[] = array( + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'code'=>$code, + 'encoding'=>$encoding, + 'is2d'=>$is2d, + 'photo'=>$barcodeimage // Photo must be a file that exists with format supported by TCPDF + ); @@ -244,0 +224 @@ + $mesg = ''; @@ -247,2 +227,4 @@ - if (!$error && $mode == 'label') { - if (!count($arrayofrecords)) { + if ($mode == 'label') + { + if (!count($arrayofrecords)) + { @@ -251 +233,2 @@ - if (empty($modellabel) || $modellabel == '-1') { + if (empty($modellabel) || $modellabel == '-1') + { @@ -257,24 +240,10 @@ - if (!$mesg) { - $outputlangs = $langs; - $previousConf = getDolGlobalInt('TCPDF_THROW_ERRORS_INSTEAD_OF_DIE'); - $conf->global->TCPDF_THROW_ERRORS_INSTEAD_OF_DIE = 1; - - - // This generates and send PDF to output - // TODO Move - try { - $result = doc_label_pdf_create($db, $arrayofrecords, $modellabel, $outputlangs, $diroutput, $template, dol_sanitizeFileName($outfile)); - } catch (Exception $e) { - $mesg = $langs->trans('ErrorGeneratingBarcode'); - } - $conf->global->TCPDF_THROW_ERRORS_INSTEAD_OF_DIE = $previousConf; - } - } - - if ($result <= 0 || $mesg || $error) { - if (empty($mesg)) { - $mesg = 'Error '.$result; - } - - setEventMessages($mesg, null, 'errors'); - } else { + if (!$mesg) $result = doc_label_pdf_create($db, $arrayofrecords, $modellabel, $outputlangs, $diroutput, $template, dol_sanitizeFileName($outfile)); + } + + if ($result <= 0) + { + dol_print_error('', $result); + } + + if (!$mesg) + { @@ -291,0 +261,2 @@ +if (empty($conf->barcode->enabled)) accessforbidden(); + @@ -300,0 +272,2 @@ + +dol_htmloutput_errors($mesg); @@ -305 +278 @@ -print '
'; // The target is for brothers that open the file instead of downloading it +print ''; @@ -308 +281 @@ -print ''; // The page will not renew the token but force download of a file, so we must use here currentToken +print ''; @@ -314 +287 @@ -print '
'; +print '
'; @@ -319,3 +292,4 @@ -foreach (array_keys($_Avery_Labels) as $codecards) { - $labeltoshow = $_Avery_Labels[$codecards]['name']; - //$labeltoshow.=' ('.$_Avery_Labels[$row['code']]['paper-size'].')'; +foreach (array_keys($_Avery_Labels) as $codecards) +{ + $labeltoshow = $_Avery_Labels[$codecards]['name']; + //$labeltoshow.=' ('.$_Avery_Labels[$row['code']]['paper-size'].')'; @@ -325 +299 @@ -print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel') ? GETPOST('modellabel') : getDolGlobalString('ADHERENT_ETIQUETTE_TYPE')), 1, 0, 0, '', 0, 0, 0, '', '', 1); +print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel') ?GETPOST('modellabel') : $conf->global->ADHERENT_ETIQUETTE_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1); @@ -330 +304 @@ -print '
'; +print '
'; @@ -333 +307 @@ -print ''; +print ''; @@ -343 +317 @@ -print '