24 if (!defined(
'NOTOKENRENEWAL')) {
25 define(
'NOTOKENRENEWAL',
'1');
37 print
'<html><title>Build an import example file</title><body>';
48 print
'</body></html>';
52 require
'../main.inc.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
54 require_once DOL_DOCUMENT_ROOT.
'/imports/class/import.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/core/modules/import/modules_import.php';
57 $datatoimport =
GETPOST(
'datatoimport');
61 $langs->load(
"exports");
64 if (empty($datatoimport)) {
68 print
'<div class="error">Bad value for datatoimport.</div>';
74 $filename = $langs->trans(
"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];
83 if (isset($_GET[
"attachment"])) {
84 $attachment = $_GET[
"attachment"];
88 if (isset($_GET[
"contenttype"])) {
89 $contenttype = $_GET[
"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();
106 foreach ($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] :
'');
114 print $objimport->build_example_file($format, $headerlinefields, $contentlinevalues, $datatoimport);
llxFooter()
This file is a wrapper, so empty footer.
if(!defined('NOTOKENRENEWAL')) llxHeader()
This file is a wrapper, so empty header.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.