28require_once
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/exports/class/export.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/modules/export/modules_export.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
36$langs->loadlangs(array(
'admin',
'exports',
'other',
'users',
'companies',
'projects',
'suppliers',
'products',
'bank',
'bills'));
45 'invoice_line' =>
'bill',
47 'order_line' =>
'order',
49 'propal_line' =>
'propal',
50 'intervention' =>
'intervention',
51 'inter_line' =>
'intervention',
53 'member_type' =>
'group',
54 'subscription' =>
'payment',
55 'payment' =>
'payment',
57 'tax_type' =>
'generic',
59 'account' =>
'account',
60 'product' =>
'product',
61 'virtualproduct' =>
'product',
62 'subproduct' =>
'product',
63 'product_supplier_ref' =>
'product',
65 'warehouse' =>
'stock',
67 'stockbatch' =>
'stock',
68 'category' =>
'category',
69 'securityevent' =>
'generic',
70 'shipment' =>
'sending',
71 'shipment_line' =>
'sending',
72 'reception' =>
'sending',
73 'reception_line' =>
'sending',
74 'expensereport' =>
'trip',
75 'expensereport_line' =>
'trip',
76 'holiday' =>
'holiday',
77 'contract_line' =>
'contract',
78 'translation' =>
'generic',
81 'conferenceorboothattendee' =>
'contact'
87 'company' =>
'Company',
88 'contact' =>
'Contact',
90 'invoice_line' =>
'InvoiceLine',
92 'order_line' =>
'OrderLine',
93 'propal' =>
'Proposal',
94 'propal_line' =>
'ProposalLine',
95 'intervention' =>
'Intervention',
96 'inter_line' =>
'InterLine',
98 'member_type' =>
'MemberType',
99 'subscription' =>
'Subscription',
100 'tax' =>
'SocialContribution',
101 'tax_type' =>
'DictionarySocialContributions',
102 'account' =>
'BankTransactions',
103 'payment' =>
'Payment',
104 'product' =>
'Product',
105 'virtualproduct' =>
'AssociatedProducts',
106 'subproduct' =>
'SubProduct',
107 'product_supplier_ref' =>
'SupplierPrices',
108 'service' =>
'Service',
110 'movement' =>
'StockMovement',
112 'stockbatch' =>
'StockDetailPerBatch',
113 'warehouse' =>
'Warehouse',
114 'category' =>
'Category',
116 'trip' =>
'TripsAndExpenses',
117 'securityevent' =>
'SecurityEvent',
118 'shipment' =>
'Shipments',
119 'shipment_line' =>
'ShipmentLine',
120 'project' =>
'Projects',
121 'projecttask' =>
'Tasks',
122 'resource' =>
'Resource',
123 'task_time' =>
'TaskTimeSpent',
125 'expensereport' =>
'ExpenseReport',
126 'expensereport_line' =>
'ExpenseReportLine',
127 'holiday' =>
'TitreRequestCP',
128 'contract' =>
'Contract',
129 'contract_line' =>
'ContractLine',
130 'translation' =>
'Translation',
132 'bomline' =>
'BOMLine',
133 'conferenceorboothattendee' =>
'Attendee'
136$array_selected = isset($_SESSION[
"export_selected_fields"]) ? $_SESSION[
"export_selected_fields"] : array();
137$array_filtervalue = isset($_SESSION[
"export_filtered_fields"]) ? $_SESSION[
"export_filtered_fields"] : array();
138$datatoexport =
GETPOST(
"datatoexport",
"aZ09");
139$action =
GETPOST(
'action',
'aZ09');
140$confirm =
GETPOST(
'confirm',
'alpha');
142$export_name =
GETPOST(
"export_name",
"alphanohtml");
143$hexa =
GETPOST(
"hexa",
"alpha");
145$field =
GETPOST(
"field",
"alpha");
147$objexport =
new Export($db);
148$objexport->load_arrays($user, $datatoexport);
151$form =
new Form($db);
154$sqlusedforexport =
'';
157$upload_dir = $conf->export->dir_temp.
'/'.$user->id;
169if ($action ==
'selectfield') {
170 $fieldsarray = $objexport->array_export_fields[0];
171 $fieldsentitiesarray = $objexport->array_export_entities[0];
172 $fieldsdependenciesarray = $objexport->array_export_dependencies[0];
174 if ($field ==
'all') {
175 foreach ($fieldsarray as $key => $val) {
176 if (!empty($array_selected[$key])) {
179 $array_selected[$key] = count($array_selected) + 1;
181 $_SESSION[
"export_selected_fields"] = $array_selected;
186 $array_selected[$field] = count($array_selected) + 1;
191 $listofdependencies = array();
192 if (!empty($fieldsentitiesarray[$field]) && !empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]])) {
194 $tmp = $fieldsdependenciesarray[$fieldsentitiesarray[$field]];
195 if (is_array($tmp)) {
196 $listofdependencies = $tmp;
198 $listofdependencies = array($tmp);
200 } elseif (!empty($field) && !empty($fieldsdependenciesarray[$field])) {
202 $tmp = $fieldsdependenciesarray[$field];
203 if (is_array($tmp)) {
204 $listofdependencies = $tmp;
206 $listofdependencies = array($tmp);
210 if (count($listofdependencies)) {
211 foreach ($listofdependencies as $fieldid) {
212 if (empty($array_selected[$fieldid])) {
213 $array_selected[$fieldid] = count($array_selected) + 1;
214 $warnings[] = $langs->trans(
"ExportFieldAutomaticallyAdded", $langs->transnoentitiesnoconv($fieldsarray[$fieldid]));
219 $_SESSION[
"export_selected_fields"] = $array_selected;
224if ($action ==
'unselectfield') {
225 if (
GETPOST(
"field") ==
'all') {
226 $array_selected = array();
227 $_SESSION[
"export_selected_fields"] = $array_selected;
229 unset($array_selected[
GETPOST(
"field")]);
231 asort($array_selected);
233 $array_selected_save = $array_selected;
234 foreach ($array_selected as $code => $value) {
236 $array_selected[$code] = $i;
239 $_SESSION[
"export_selected_fields"] = $array_selected;
243if ($action ==
'downfield' || $action ==
'upfield') {
244 $pos = $array_selected[
GETPOST(
"field")];
245 if ($action ==
'downfield') {
248 if ($action ==
'upfield') {
253 foreach ($array_selected as $code => $value) {
254 if ($value == $newpos) {
261 $array_selected[
GETPOST(
"field")] = $newpos;
262 $array_selected[$newcode] = $pos;
263 $_SESSION[
"export_selected_fields"] = $array_selected;
267if ($step == 1 || $action ==
'cleanselect') {
268 $_SESSION[
"export_selected_fields"] = array();
269 $_SESSION[
"export_filtered_fields"] = array();
270 $array_selected = array();
271 $array_filtervalue = array();
274if ($action ==
'builddoc') {
276 if (empty($objexport->array_export_perms[0])) {
280 $separator =
GETPOST(
'delimiter',
'alpha');
281 $max_execution_time_for_importexport = (!
getDolGlobalString(
'EXPORT_MAX_EXECUTION_TIME') ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME);
282 $max_time = @ini_get(
"max_execution_time");
283 if ($max_time && $max_time < $max_execution_time_for_importexport) {
284 dol_syslog(
"max_execution_time=".$max_time.
" is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.
". We try to increase it dynamically.");
285 @ini_set(
"max_execution_time", $max_execution_time_for_importexport);
289 $result = $objexport->build_file($user,
GETPOST(
'model',
'alpha'), $datatoexport, $array_selected, $array_filtervalue,
'', $separator);
292 $sqlusedforexport = $objexport->sqlusedforexport;
295 $sqlusedforexport = $objexport->sqlusedforexport;
300if ($step == 5 && $action ==
'confirm_deletefile' && $confirm ==
'yes') {
302 if (empty($objexport->array_export_perms[0])) {
306 $file = $upload_dir.
"/".
GETPOST(
'file');
314 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport);
318if ($action ==
'deleteprof') {
320 if (empty($objexport->array_export_perms[0])) {
326 $result = $objexport->delete($user);
331if ($action ==
'add_export_model') {
333 if (empty($objexport->array_export_perms[0])) {
338 asort($array_selected);
342 foreach ($array_selected as $key => $val) {
349 $hexafiltervalue =
'';
350 if (!empty($array_filtervalue) && is_array($array_filtervalue)) {
351 foreach ($array_filtervalue as $key => $val) {
352 if ($hexafiltervalue) {
353 $hexafiltervalue .=
',';
355 $hexafiltervalue .= $key.
'='.$val;
359 $objexport->model_name = $export_name;
360 $objexport->datatoexport = $datatoexport;
361 $objexport->hexa = $hexa;
362 $objexport->hexafiltervalue = $hexafiltervalue;
363 $objexport->fk_user = (
GETPOST(
'visibility',
'aZ09') ==
'all' ? 0 : $user->id);
365 $result = $objexport->create($user);
367 setEventMessages($langs->trans(
"ExportModelSaved", $objexport->model_name),
null,
'mesgs');
369 $langs->load(
"errors");
370 if ($objexport->errno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
371 setEventMessages($langs->trans(
"ErrorExportDuplicateProfil"),
null,
'errors');
377 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ExportModelName")),
null,
'errors');
382if ($step == 2 && $action ==
'select_model') {
383 $_SESSION[
"export_selected_fields"] = array();
384 $_SESSION[
"export_filtered_fields"] = array();
386 $array_selected = array();
387 $array_filtervalue = array();
389 $result = $objexport->fetch($exportmodelid);
391 $fieldsarray = preg_split(
"/,(?! [^(]*\))/", $objexport->hexa);
393 foreach ($fieldsarray as $val) {
394 $array_selected[$val] = $i;
397 $_SESSION[
"export_selected_fields"] = $array_selected;
399 $fieldsarrayvalue = explode(
',', $objexport->hexafiltervalue);
401 foreach ($fieldsarrayvalue as $val) {
402 $tmp = explode(
'=', $val);
403 $array_filtervalue[$tmp[0]] = $tmp[1];
406 $_SESSION[
"export_filtered_fields"] = $array_filtervalue;
411if ($step == 4 && $action ==
'submitFormField') {
413 if (empty($objexport->array_export_perms[0])) {
418 if (is_array($objexport->array_export_TypeFields[0])) {
419 $_SESSION[
"export_filtered_fields"] = array();
420 foreach ($objexport->array_export_TypeFields[0] as $code => $type) {
421 $newcode = (string) preg_replace(
'/\./',
'_', $code);
423 $check =
'alphanohtml';
424 $filterqualified = 1;
425 if (!GETPOSTISSET($newcode) ||
GETPOST($newcode, $check) ==
'') {
426 $filterqualified = 0;
427 } elseif (preg_match(
'/^List/', $type) && (is_numeric(
GETPOST($newcode, $check)) &&
GETPOST($newcode, $check) <= 0)) {
428 $filterqualified = 0;
430 if ($filterqualified) {
431 $objexport->array_export_FilterValue[0][$code] =
GETPOST($newcode, $check);
434 $array_filtervalue = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] :
'');
435 $_SESSION[
"export_filtered_fields"] = $array_filtervalue;
444if ($step == 1 || !$datatoexport) {
445 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
449 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
450 $head[$h][1] = $langs->trans(
"Step").
" 1";
456 print
'<div class="opacitymedium">'.$langs->trans(
"SelectExportDataSet").
'</div><br>';
459 print
'<div class="div-table-responsive-no-min">';
460 print
'<table class="noborder centpercent">';
461 print
'<tr class="liste_titre">';
462 print
'<td>'.$langs->trans(
"Module").
'</td>';
463 print
'<td>'.$langs->trans(
"ExportableDatas").
'</td>';
464 print
'<td> </td>';
467 if (count($objexport->array_export_module)) {
468 asort($objexport->array_export_code_for_sort);
471 foreach ($objexport->array_export_code_for_sort as $key => $value) {
472 print
'<tr class="oddeven"><td nospan="nospan">';
474 print $objexport->array_export_module[$key]->getName();
476 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[$key]);
477 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
478 $label = $objexport->array_export_label[$key];
480 print
img_object($objexport->array_export_module[$key]->getName(), $entityicon).
' ';
482 print
'</td><td class="right">';
483 if ($objexport->array_export_perms[$key]) {
484 print
'<a href="'.DOL_URL_ROOT.
'/exports/export.php?step=2&module_position='.$objexport->array_export_module[$key]->module_position.
'&datatoexport='.$objexport->array_export_code[$key].
'">'.
img_picto($langs->trans(
"NewExport"),
'next',
'class="fa-15"').
'</a>';
486 print
'<span class="opacitymedium">'.$langs->trans(
"NotEnoughPermissions").
'</span>';
491 print
'<tr><td class="oddeven" colspan="3">'.$langs->trans(
"NoExportableData").
'</td></tr>';
499if ($step == 2 && $datatoexport) {
501 if (empty($objexport->array_export_perms[0])) {
505 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
509 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
510 $head[$h][1] = $langs->trans(
"Step").
" 1";
513 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
514 $head[$h][1] = $langs->trans(
"Step").
" 2";
520 print
'<div class="fichecenter">';
521 print
'<div class="underbanner clearboth"></div>';
523 print
'<table width="100%" class="border tableforfield">';
526 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
528 print $objexport->array_export_module[0]->getName();
532 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
534 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
535 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
536 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
537 print $objexport->array_export_label[0];
548 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
549 print
'<input type="hidden" name="token" value="'.newToken().
'">';
550 print
'<input type="hidden" name="action" value="select_model">';
551 print
'<input type="hidden" name="step" value="2">';
552 print
'<input type="hidden" name="datatoexport" value="'.$datatoexport.
'">';
553 print
'<div class="valignmiddle marginbottomonly">';
554 print
'<span class="opacitymedium">'.$langs->trans(
"SelectExportFields").
'</span> ';
555 $htmlother->select_export_model($exportmodelid,
'exportmodelid', $datatoexport, 1, $user->id);
557 print
'<input type="submit" class="button small" value="'.$langs->trans(
"Select").
'">';
562 print
'<div class="div-table-responsive-no-min">';
563 print
'<table class="noborder centpercent">';
564 print
'<tr class="liste_titre">';
565 print
'<td>'.$langs->trans(
"Object").
'</td>';
566 print
'<td>'.$langs->trans(
"ExportableFields").
'</td>';
567 print
'<td width="100" class="center">';
568 print
'<a class="liste_titre commonlink" title='.$langs->trans(
"All").
' alt='.$langs->trans(
"All").
' href="'.$_SERVER[
"PHP_SELF"].
'?step=2&datatoexport='.$datatoexport.
'&action=selectfield&field=all">'.$langs->trans(
"All").
"</a>";
570 print
'<a class="liste_titre commonlink" title='.$langs->trans(
"None").
' alt='.$langs->trans(
"None").
' href="'.$_SERVER[
"PHP_SELF"].
'?step=2&datatoexport='.$datatoexport.
'&action=unselectfield&field=all">'.$langs->trans(
"None").
"</a>";
572 print
'<td width="44%">'.$langs->trans(
"ExportedFields").
'</td>';
576 $fieldsarray = $objexport->array_export_fields[0];
578 $sqlmaxforexport = $objexport->build_sql(0, array(), array());
590 foreach ($fieldsarray as $code => $label) {
591 print
'<tr class="oddeven">';
595 $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
596 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
597 $entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
599 print
'<td class="nowrap">';
603 $tmparray = explode(
':', $entityicon);
604 if (count($tmparray) >= 2) {
605 $entityicon = $tmparray[0];
606 $entitylang = $tmparray[1];
608 print
img_object(
'', $entityicon).
' '.$langs->trans($entitylang);
611 $text = (empty($objexport->array_export_special[0][$code]) ?
'' :
'<i>').$langs->trans($label).(empty($objexport->array_export_special[0][$code]) ?
'' :
'</i>');
614 $htmltext =
'<b>'.$langs->trans(
"Name").
":</b> ".$text.
'<br>';
615 if (!empty($objexport->array_export_special[0][$code])) {
616 $htmltext .=
'<b>'.$langs->trans(
"ComputedField").
" -> ".$langs->trans(
"Method").
" :</b> ".$objexport->array_export_special[0][$code].
"<br>";
618 $htmltext .=
'<b>'.$langs->trans(
"Table").
" -> ".$langs->trans(
"Field").
":</b> ".$tablename.
" -> ".preg_replace(
'/^.*\./',
'', $code).
"<br>";
620 if (!empty($objexport->array_export_examplevalues[0][$code])) {
621 $htmltext .=
'<b>'.$langs->trans(
"SourceExample").
':</b> '.$objexport->array_export_examplevalues[0][$code].
'<br>';
623 if (!empty($objexport->array_export_TypeFields[0][$code])) {
624 $htmltext .=
'<b>'.$langs->trans(
"Type").
':</b> '.$objexport->array_export_TypeFields[0][$code].
'<br>';
626 if (!empty($objexport->array_export_help[0][$code])) {
627 $htmltext .=
'<b>'.$langs->trans(
"Help").
':</b> '.$langs->trans($objexport->array_export_help[0][$code]).
'<br>';
630 if (isset($array_selected[$code]) && $array_selected[$code]) {
632 print
'<td> </td>';
633 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?step=2&datatoexport='.$datatoexport.
'&action=unselectfield&field='.$code.
'">'.
img_left(
'default', 0,
'style="max-width: 20px"').
'</a></td>';
636 print $form->textwithpicto($text, $htmltext);
643 print $form->textwithpicto($text, $htmltext);
646 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?step=2&datatoexport='.$datatoexport.
'&action=selectfield&field='.$code.
'">'.
img_right(
'default', 0,
'style="max-width: 20px"').
'</a></td>';
647 print
'<td> </td>';
659 print
'<div class="tabsAction tabsActionNoBottom">';
661 if (count($array_selected)) {
663 if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
664 print
'<a class="butAction" href="export.php?step=3&datatoexport='.$datatoexport.
'">'.$langs->trans(
"NextStep").
'</a>';
666 print
'<a class="butAction" href="export.php?step=4&datatoexport='.$datatoexport.
'">'.$langs->trans(
"NextStep").
'</a>';
669 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"SelectAtLeastOneField")).
'">'.$langs->trans(
"NextStep").
'</a>';
675if ($step == 3 && $datatoexport) {
676 if (count($array_selected) < 1) {
678 header(
"Location: ".DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport);
683 if (empty($objexport->array_export_perms[0])) {
687 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
691 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
692 $head[$h][1] = $langs->trans(
"Step").
" 1";
695 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
696 $head[$h][1] = $langs->trans(
"Step").
" 2";
699 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=3&datatoexport='.$datatoexport;
700 $head[$h][1] = $langs->trans(
"Step").
" 3";
706 print
'<div class="fichecenter">';
707 print
'<div class="underbanner clearboth"></div>';
708 print
'<table width="100%" class="border tableforfield">';
711 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
714 print $objexport->array_export_module[0]->getName();
718 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
720 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
721 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
722 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
723 print $objexport->array_export_label[0];
727 print
'<tr><td>'.$langs->trans(
"ExportedFields").
'</td>';
729 foreach ($array_selected as $code => $value) {
730 $list .= (!empty($list) ?
', ' :
'');
731 $list .= (isset($objexport->array_export_fields[0][$code]) ? $langs->trans($objexport->array_export_fields[0][$code]) :
'');
733 print
'<td>'.$list.
'</td></tr>';
741 print
'<span class="opacitymedium">'.$langs->trans(
"SelectFilterFields").
'</span><br><br>';
745 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?step=4&action=submitFormField&datatoexport='.$datatoexport.
'" name="FilterField" method="post">';
746 print
'<input type="hidden" name="token" value="'.newToken().
'">';
748 print
'<div class="div-table-responsive-no-min">';
750 print
'<table class="noborder centpercent">';
751 print
'<tr class="liste_titre">';
752 print
'<td>'.$langs->trans(
"Entities").
'</td>';
755 print
'<td>'.$langs->trans(
"ExportableFields").
'</td>';
756 print
'<td width="25%">'.$langs->trans(
"FilteredFieldsValues").
'</td>';
760 $fieldsarray = $objexport->array_export_fields[0];
762 $Typefieldsarray = $objexport->array_export_TypeFields[0];
764 $ValueFiltersarray = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] :
'');
766 $sqlmaxforexport = $objexport->build_sql(0, array(), array());
770 foreach ($fieldsarray as $code => $label) {
771 print
'<tr class="oddeven">';
774 $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
775 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
776 $entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
778 print
'<td class="nowrap">';
780 $tmparray = explode(
':', $entityicon);
781 if (count($tmparray) >= 2) {
782 $entityicon = $tmparray[0];
783 $entitylang = $tmparray[1];
785 print
img_object(
'', $entityicon).
' '.$langs->trans($entitylang);
789 $labelName = (!empty($fieldsarray[$code]) ? $fieldsarray[$code] :
'');
790 $ValueFilter = (!empty($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'');
791 $text = (empty($objexport->array_export_special[0][$code]) ?
'' :
'<i>').$langs->trans($labelName).(empty($objexport->array_export_special[0][$code]) ?
'' :
'</i>');
794 $htmltext =
'<b>'.$langs->trans(
"Name").
':</b> '.$text.
'<br>';
795 if (!empty($objexport->array_export_special[0][$code])) {
796 $htmltext .=
'<b>'.$langs->trans(
"ComputedField").
" -> ".$langs->trans(
"Method").
" :</b> ".$objexport->array_export_special[0][$code].
"<br>";
798 $htmltext .=
'<b>'.$langs->trans(
"Table").
" -> ".$langs->trans(
"Field").
":</b> ".$tablename.
" -> ".preg_replace(
'/^.*\./',
'', $code).
"<br>";
800 if (!empty($objexport->array_export_examplevalues[0][$code])) {
801 $htmltext .=
'<b>'.$langs->trans(
"SourceExample").
':</b> '.$objexport->array_export_examplevalues[0][$code].
'<br>';
803 if (!empty($objexport->array_export_TypeFields[0][$code])) {
804 $htmltext .=
'<b>'.$langs->trans(
"Type").
':</b> '.$objexport->array_export_TypeFields[0][$code].
'<br>';
806 if (!empty($objexport->array_export_help[0][$code])) {
807 $htmltext .=
'<b>'.$langs->trans(
"Help").
':</b> '.$langs->trans($objexport->array_export_help[0][$code]).
'<br>';
811 print $form->textwithpicto($text, $htmltext);
816 if (!empty($Typefieldsarray[$code])) {
817 $szInfoFiltre = $objexport->genDocFilter($Typefieldsarray[$code]);
819 $tmp = $objexport->build_filterField($Typefieldsarray[$code], $code, $ValueFilter);
820 print $form->textwithpicto($tmp, $szInfoFiltre);
822 print $objexport->build_filterField($Typefieldsarray[$code], $code, $ValueFilter);
838 print
'<div class="tabsAction tabsActionNoBottom">';
840 print
'<a class="butAction" href="javascript:FilterField.submit();">'.$langs->trans(
"NextStep").
'</a>';
844if ($step == 4 && $datatoexport) {
845 if (count($array_selected) < 1) {
847 header(
"Location: ".DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport);
852 if (empty($objexport->array_export_perms[0])) {
856 asort($array_selected);
858 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
863 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
864 $head[$h][1] = $langs->trans(
"Step").
" 1";
867 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
868 $head[$h][1] = $langs->trans(
"Step").
" 2";
872 if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
873 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=3&datatoexport='.$datatoexport;
874 $head[$h][1] = $langs->trans(
"Step").
" 3";
879 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=4&datatoexport='.$datatoexport;
880 $head[$h][1] = $langs->trans(
"Step").
" ".(3 + $stepoffset);
886 print
'<div class="fichecenter">';
887 print
'<div class="underbanner clearboth"></div>';
888 print
'<table width="100%" class="border tableforfield">';
891 print
'<tr><td class="titlefield tableforfield">'.$langs->trans(
"Module").
'</td>';
894 print $objexport->array_export_module[0]->getName();
898 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
900 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
901 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
902 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
903 print $objexport->array_export_label[0];
907 print
'<tr><td>'.$langs->trans(
"ExportedFields").
'</td>';
909 foreach ($array_selected as $code => $value) {
910 $list .= (!empty($list) ?
', ' :
'');
911 $list .= $langs->trans($objexport->array_export_fields[0][$code]);
913 print
'<td>'.$list.
'</td>';
917 if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
918 print
'<tr><td>'.$langs->trans(
"FilteredFields").
'</td>';
920 if (!empty($array_filtervalue)) {
921 foreach ($array_filtervalue as $code => $value) {
922 if (preg_match(
'/^FormSelect:/', $objexport->array_export_TypeFields[0][$code])) {
928 if (isset($objexport->array_export_fields[0][$code])) {
929 $list .= ($list ?
', ' :
'');
930 if (isset($array_filtervalue[$code]) && preg_match(
'/^\s*[<>]/', $array_filtervalue[$code])) {
931 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
'</span>'.(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'');
933 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
"</span>='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'').
"'";
938 print
'<td>'.(!empty($list) ? $list :
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>').
'</td>';
948 $sqlmaxforexport = $objexport->build_sql(0, array(), array());
950 print
'<div class="marginbottomonly"><span class="opacitymedium">'.$langs->trans(
"ChooseFieldsOrdersAndTitle").
'</span></div>';
952 print
'<div class="div-table-responsive-no-min">';
953 print
'<table class="noborder centpercent">';
954 print
'<tr class="liste_titre">';
955 print
'<td>'.$langs->trans(
"Entities").
'</td>';
956 print
'<td>'.$langs->trans(
"ExportedFields").
'</td>';
957 print
'<td class="right" colspan="2">'.$langs->trans(
"Position").
'</td>';
962 foreach ($array_selected as $code => $value) {
963 print
'<tr class="oddeven">';
965 $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
966 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
967 $entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
969 print
'<td class="nowrap">';
971 $tmparray = explode(
':', $entityicon);
972 if (count($tmparray) >= 2) {
973 $entityicon = $tmparray[0];
974 $entitylang = $tmparray[1];
976 print
img_object(
'', $entityicon).
' '.$langs->trans($entitylang);
979 $labelName = $objexport->array_export_fields[0][$code];
981 $text = (empty($objexport->array_export_special[0][$code]) ?
'' :
'<i>').$langs->trans($labelName).(empty($objexport->array_export_special[0][$code]) ?
'' :
'</i>');
984 $htmltext =
'<b>'.$langs->trans(
"Name").
':</b> '.$text.
'<br>';
985 if (!empty($objexport->array_export_special[0][$code])) {
986 $htmltext .=
'<b>'.$langs->trans(
"ComputedField").
" -> ".$langs->trans(
"Method").
" :</b> ".$objexport->array_export_special[0][$code].
"<br>";
988 $htmltext .=
'<b>'.$langs->trans(
"Table").
" -> ".$langs->trans(
"Field").
":</b> ".$tablename.
" -> ".preg_replace(
'/^.*\./',
'', $code).
"<br>";
990 if (!empty($objexport->array_export_examplevalues[0][$code])) {
991 $htmltext .=
'<b>'.$langs->trans(
"SourceExample").
':</b> '.$objexport->array_export_examplevalues[0][$code].
'<br>';
993 if (!empty($objexport->array_export_TypeFields[0][$code])) {
994 $htmltext .=
'<b>'.$langs->trans(
"Type").
':</b> '.$objexport->array_export_TypeFields[0][$code].
'<br>';
996 if (!empty($objexport->array_export_help[0][$code])) {
997 $htmltext .=
'<b>'.$langs->trans(
"Help").
':</b> '.$langs->trans($objexport->array_export_help[0][$code]).
'<br>';
1001 print $form->textwithpicto($text, $htmltext);
1005 print
'<td class="right" width="100">';
1007 print
'</td><td class="center nowraponall" width="40">';
1008 if ($value < count($array_selected)) {
1009 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport.
'&action=downfield&field='.$code.
'">'.
img_down().
'</a>';
1012 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport.
'&action=upfield&field='.$code.
'">'.
img_up().
'</a>';
1030 print
'<div class="tabsAction">';
1032 if (count($array_selected)) {
1033 print
'<a class="butAction" href="export.php?step='.($step + 1).
'&datatoexport='.$datatoexport.
'">'.$langs->trans(
"NextStep").
'</a>';
1040 if (count($array_selected)) {
1043 print
'<div class="marginbottomonly">';
1044 print
'<span class="opacitymedium">'.$langs->trans(
"SaveExportModel").
'</span>';
1047 print
'<form class="nocellnopadd" action="export.php" method="post">';
1048 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1049 print
'<input type="hidden" name="action" value="add_export_model">';
1050 print
'<input type="hidden" name="step" value="'.$step.
'">';
1051 print
'<input type="hidden" name="datatoexport" value="'.$datatoexport.
'">';
1052 print
'<input type="hidden" name="hexa" value="'.$hexa.
'">';
1054 print
'<div class="div-table-responsive-no-min">';
1055 print
'<table class="noborder centpercent">';
1056 print
'<tr class="liste_titre">';
1057 print
'<td>'.$langs->trans(
"ExportModelName").
'</td>';
1058 print
'<td>'.$langs->trans(
"Visibility").
'</td>';
1062 print
'<tr class="oddeven">';
1063 print
'<td><input name="export_name" value=""></td>';
1065 $arrayvisibility = array(
'private' => $langs->trans(
"Private"),
'all' => $langs->trans(
"Everybody"));
1066 print $form->selectarray(
'visibility', $arrayvisibility,
'private');
1068 print
'<td class="right">';
1069 print
'<input type="submit" class="button reposition button-save small" value="'.$langs->trans(
"Save").
'">';
1072 $tmpuser =
new User($db);
1075 $sql =
"SELECT rowid, label, fk_user, entity";
1076 $sql .=
" FROM ".MAIN_DB_PREFIX.
"export_model";
1077 $sql .=
" WHERE type = '".$db->escape($datatoexport).
"'";
1079 $sql .=
" AND fk_user IN (0, ".((int) $user->id).
")";
1081 $sql .=
" ORDER BY rowid";
1082 $resql = $db->query($sql);
1084 $num = $db->num_rows($resql);
1087 $obj = $db->fetch_object($resql);
1089 print
'<tr class="oddeven"><td>';
1093 if (empty($obj->fk_user)) {
1094 print $langs->trans(
"Everybody");
1096 $tmpuser->fetch($obj->fk_user);
1097 print $tmpuser->getNomUrl(1);
1100 print
'<td class="right">';
1101 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport.
'&action=deleteprof&token='.newToken().
'&id='.$obj->rowid.
'">';
1118if ($step == 5 && $datatoexport) {
1119 if (count($array_selected) < 1) {
1121 header(
"Location: ".DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport);
1126 if (empty($objexport->array_export_perms[0])) {
1130 asort($array_selected);
1132 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
1137 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
1138 $head[$h][1] = $langs->trans(
"Step").
" 1";
1141 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
1142 $head[$h][1] = $langs->trans(
"Step").
" 2";
1146 if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
1147 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=3&datatoexport='.$datatoexport;
1148 $head[$h][1] = $langs->trans(
"Step").
" 3";
1153 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=4&datatoexport='.$datatoexport;
1154 $head[$h][1] = $langs->trans(
"Step").
" ".(3 + $stepoffset);
1157 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=5&datatoexport='.$datatoexport;
1158 $head[$h][1] = $langs->trans(
"Step").
" ".(4 + $stepoffset);
1167 if ($action ==
'remove_file') {
1168 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?step=5&datatoexport='.$datatoexport.
'&file='.urlencode(
GETPOST(
"file")), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'', 0, 1);
1171 print
'<div class="fichecenter">';
1172 print
'<div class="underbanner clearboth"></div>';
1174 print
'<table class="border tableforfield centpercent">';
1177 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
1180 print $objexport->array_export_module[0]->getName();
1184 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
1186 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
1187 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
1188 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
1189 print $objexport->array_export_label[0];
1193 print
'<tr><td>'.$langs->trans(
"ExportedFields").
'</td>';
1195 foreach ($array_selected as $code => $label) {
1196 $list .= (!empty($list) ?
', ' :
'');
1197 $list .= $langs->trans($objexport->array_export_fields[0][$code]);
1199 print
'<td>'.$list.
'</td></tr>';
1202 if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
1203 print
'<tr><td>'.$langs->trans(
"FilteredFields").
'</td>';
1205 if (!empty($array_filtervalue)) {
1206 foreach ($array_filtervalue as $code => $value) {
1207 if (preg_match(
'/^FormSelect:/', $objexport->array_export_TypeFields[0][$code])) {
1213 if (isset($objexport->array_export_fields[0][$code])) {
1214 $list .= ($list ?
', ' :
'');
1215 if (isset($array_filtervalue[$code]) && preg_match(
'/^\s*[<>]/', $array_filtervalue[$code])) {
1216 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
'</span>'.(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'');
1218 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
"</span>='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'').
"'";
1223 print
'<td>'.(!empty($list) ? $list :
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>').
'</td>';
1233 $htmltabloflibs =
'<!-- Table with available export formats --><br>';
1234 $htmltabloflibs .=
'<table class="noborder centpercent nomarginbottom">';
1235 $htmltabloflibs .=
'<tr class="liste_titre">';
1236 $htmltabloflibs .=
'<td>'.$langs->trans(
"AvailableFormats").
'</td>';
1237 $htmltabloflibs .=
'<td>'.$langs->trans(
"LibraryUsed").
'</td>';
1238 $htmltabloflibs .=
'<td class="right">'.$langs->trans(
"LibraryVersion").
'</td>';
1239 $htmltabloflibs .=
'</tr>'.
"\n";
1241 $liste = $objmodelexport->listOfAvailableExportFormat($db);
1243 foreach ($listeall as $key => $val) {
1244 if (preg_match(
'/__\(Disabled\)__/', $listeall[$key])) {
1245 $listeall[$key] = preg_replace(
'/__\(Disabled\)__/',
'('.$langs->transnoentitiesnoconv(
"Disabled").
')', $listeall[$key]);
1246 unset($liste[$key]);
1249 $htmltabloflibs .=
'<tr class="oddeven">';
1250 $htmltabloflibs .=
'<td>'.img_picto_common($key, $objmodelexport->getPictoForKey($key)).
' ';
1251 $text = $objmodelexport->getDriverDescForKey($key);
1252 $label = $listeall[$key];
1254 $htmltabloflibs .= $form->textwithpicto($label, $text).
'</td>';
1255 $htmltabloflibs .=
'<td>'.$objmodelexport->getLibLabelForKey($key).
'</td>';
1256 $htmltabloflibs .=
'<td class="right">'.$objmodelexport->getLibVersionForKey($key).
'</td>';
1257 $htmltabloflibs .=
'</tr>'.
"\n";
1259 $htmltabloflibs .=
'</table><br>';
1261 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NowClickToGenerateToBuildExportFile"), $htmltabloflibs, 1,
'help',
'', 0, 2,
'helphonformat').
'</span>';
1268 if ($sqlusedforexport && $user->admin) {
1269 print
info_admin($langs->trans(
"SQLUsedForExport").
':<br> '.$sqlusedforexport, 0, 0, 1,
'',
'TechnicalInformation');
1273 if (!is_dir($conf->export->dir_temp)) {
1279 print $formfile->showdocuments(
'export',
'', $upload_dir, $_SERVER[
"PHP_SELF"].
'?step=5&datatoexport='.$datatoexport, $liste, 1, (
GETPOST(
'model') ?
GETPOST(
'model') :
'csv'), 1, 1, 0, 0, 0,
'',
'none',
'',
'',
'');
1298 $alias = preg_replace(
'/\.(.*)$/i',
'', $code);
1299 $regexstring =
'/([a-zA-Z_]+) as '.preg_quote($alias).
'[, \)]/i';
1301 $newsql = $sqlmaxforexport;
1302 $newsql = preg_replace(
'/^(.*) FROM /i',
'', $newsql);
1303 $newsql = preg_replace(
'/WHERE (.*)$/i',
'', $newsql);
1305 if (preg_match($regexstring, $newsql, $reg)) {
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Parent class for export modules.
Class to manage Dolibarr users.
getablenamefromfield($code, $sqlmaxforexport)
Return table name of an alias.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
img_right($titlealt='default', $selected=0, $moreatt='')
Show right arrow logo.
img_left($titlealt='default', $selected=0, $moreatt='')
Show left arrow logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.