48 print
'</body></html>';
52require
'../main.inc.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/imports/class/import.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/modules/import/modules_import.php';
57$datatoimport =
GETPOST(
'datatoimport');
61$langs->load(
"exports");
64if (empty($datatoimport)) {
68 print
'<div class="error">Bad value for datatoimport.</div>';
74$filename = $langs->transnoentitiesnoconv(
"ExampleOfImportFile").
'_'.$datatoimport.
'.'.$format;
76$objimport =
new Import($db);
77$objimport->load_arrays($user, $datatoimport);
79$fieldstarget = $objimport->array_import_fields[0];
80$valuestarget = $objimport->array_import_examplevalues[0];
83if (GETPOSTISSET(
"attachment")) {
84 $attachment =
GETPOST(
"attachment");
88if (GETPOSTISSET(
"contenttype")) {
89 $contenttype =
GETPOST(
"contenttype");
92$outputencoding =
'UTF-8';
95 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
98 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
103$headerlinefields = array();
104$contentlinevalues = array();
106foreach ($fieldstarget as $code => $label) {
107 $withoutstar = preg_replace(
'/\*/',
'', $fieldstarget[$code]);
108 $headerlinefields[] = $langs->transnoentities($withoutstar).($withoutstar != $fieldstarget[$code] ?
'*' :
'').
' ('.$code.
')';
109 $contentlinevalues[] = (isset($valuestarget[$code]) ? $valuestarget[$code] :
'');
114print $objimport->build_example_file($format, $headerlinefields, $contentlinevalues, $datatoimport);
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.