28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
56 $type =
'members_labels';
59 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
80 function doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outputdir =
'', $template =
'standardlabel', $filename =
'tmp_address_sheet.pdf')
84 $langs->load(
"members");
89 $err = error_reporting();
92 error_reporting($err);
95 $srctemplatepath =
'';
100 if (!empty($conf->global->ADHERENT_ETIQUETTE_TYPE))
102 $code = $conf->global->ADHERENT_ETIQUETTE_TYPE;
106 }
else $code = $modele;
109 $tmp = explode(
':', $template, 2);
113 $srctemplatepath = $tmp[1];
114 }
else $srctemplatepath = $code;
116 dol_syslog(
"modele=".$modele.
" outputdir=".$outputdir.
" template=".$template.
" code=".$code.
" srctemplatepath=".$srctemplatepath.
" filename=".$filename, LOG_DEBUG);
119 $file =
''; $classname =
''; $filefound = 0;
120 $dirmodels = array(
'/');
121 if (is_array($conf->modules_parts[
'models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts[
'models']);
122 foreach ($dirmodels as $reldir)
124 foreach (array(
'doc',
'pdf') as $prefix)
126 $file = $prefix.
"_".$template.
".class.php";
129 $file =
dol_buildpath($reldir.
"core/modules/printsheet/doc/".$file, 0);
130 if (file_exists($file))
133 $classname = $prefix.
'_'.$template;
137 if ($filefound)
break;
145 $obj =
new $classname($db);
149 $sav_charset_output = $outputlangs->charset_output;
150 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)) $attachment =
false;
164 if ($type) header(
'Content-Type: '.$type);
165 if ($attachment) header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
166 else header(
'Content-Disposition: inline; filename="'.$filename.
'"');
169 header(
'Cache-Control: Public, must-revalidate');
170 header(
'Pragma: public');
176 $outputlangs->charset_output = $sav_charset_output;
181 dol_print_error(
'', $langs->trans(
"Error").
" ".$langs->trans(
"ErrorFileDoesNotExists", $file));
Parent class of document generator for address sheet.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return mime type of a file.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
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.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getListOfModels($db, $type, $maxfilenamelength=0)
Return list of activated modules usable for document generation.