24 if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL',
'1');
35 print '<html><title>Build an import example file</title><body>';
46 print '</body></html>';
49 require
'../main.inc.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
51 require_once DOL_DOCUMENT_ROOT.
'/imports/class/import.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/modules/import/modules_import.php';
54 $datatoimport =
GETPOST(
'datatoimport');
58 $langs->load(
"exports");
61 if (empty($datatoimport))
66 print '<div class="error">Bad value for datatoimport.</div>';
72 $filename = $langs->trans(
"ExampleOfImportFile").
'_'.$datatoimport.
'.'.$format;
74 $objimport =
new Import($db);
75 $objimport->load_arrays($user, $datatoimport);
77 $entity = $objimport->array_import_entities[0][$code];
78 $entityicon = $entitytoicon[$entity] ? $entitytoicon[$entity] : $entity;
79 $entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $entity;
80 $fieldstarget = $objimport->array_import_fields[0];
81 $valuestarget = $objimport->array_import_examplevalues[0];
84 if (isset($_GET[
"attachment"])) $attachment = $_GET[
"attachment"];
87 if (isset($_GET[
"contenttype"])) $contenttype = $_GET[
"contenttype"];
89 $outputencoding =
'UTF-8';
91 if ($contenttype) header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
92 if ($attachment) header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
96 $headerlinefields = array();
97 $contentlinevalues = array();
99 foreach ($fieldstarget as $code=>$label)
101 $withoutstar = preg_replace(
'/\*/',
'', $fieldstarget[$code]);
102 $headerlinefields[] = $langs->transnoentities($withoutstar).($withoutstar != $fieldstarget[$code] ?
'*' :
'').
' ('.$code.
')';
103 $contentlinevalues[] = $valuestarget[$code];
108 print $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.
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return mime type of a file.
print
Draft customers invoices.