28require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
54 $type =
'members_labels';
57 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
78function doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outputdir =
'', $template =
'standardlabel', $filename =
'tmp_address_sheet.pdf')
82 $langs->load(
"members");
87 $err = error_reporting();
90 error_reporting($err);
93 $srctemplatepath =
'';
97 if (!empty($conf->global->ADHERENT_ETIQUETTE_TYPE)) {
98 $code = $conf->global->ADHERENT_ETIQUETTE_TYPE;
107 $tmp = explode(
':', $template, 2);
108 if (!empty($tmp[1])) {
110 $srctemplatepath = $tmp[1];
112 $srctemplatepath = $code;
115 dol_syslog(
"modele=".$modele.
" outputdir=".$outputdir.
" template=".$template.
" code=".$code.
" srctemplatepath=".$srctemplatepath.
" filename=".$filename, LOG_DEBUG);
121 $dirmodels = array(
'/');
122 if (is_array($conf->modules_parts[
'models'])) {
123 $dirmodels = array_merge($dirmodels, $conf->modules_parts[
'models']);
125 foreach ($dirmodels as $reldir) {
126 foreach (array(
'doc',
'pdf') as $prefix) {
127 $file = $prefix.
"_".$template.
".class.php";
130 $file =
dol_buildpath($reldir.
"core/modules/printsheet/doc/".$file, 0);
131 if (file_exists($file)) {
133 $classname = $prefix.
'_'.$template;
146 $obj =
new $classname($db);
150 $sav_charset_output = $outputlangs->charset_output;
151 if ($obj->write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir, $filename) > 0) {
152 $outputlangs->charset_output = $sav_charset_output;
154 $fullpath = $obj->result[
'fullpath'];
160 if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) {
167 header(
'Content-Type: '.$type);
170 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
172 header(
'Content-Disposition: inline; filename="'.$filename.
'"');
176 header(
'Cache-Control: Public, must-revalidate');
177 header(
'Pragma: public');
183 $outputlangs->charset_output = $sav_charset_output;
188 dol_print_error(
'', $langs->trans(
"Error").
" ".$langs->trans(
"ErrorFileDoesNotExists", $file));
Parent class of document generator for address sheet.
liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
getListOfModels($db, $type, $maxfilenamelength=0)
Return list of activated modules usable for document generation.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.