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 'shipment' =>
'sending',
70 'shipment_line'=>
'sending',
71 'reception'=>
'sending',
72 'reception_line'=>
'sending',
73 'expensereport'=>
'trip',
74 'expensereport_line'=>
'trip',
75 'holiday' =>
'holiday',
76 'contract_line' =>
'contract',
77 'translation' =>
'generic',
80 'conferenceorboothattendee' =>
'contact'
86 'company' =>
'Company',
87 'contact' =>
'Contact',
89 'invoice_line' =>
'InvoiceLine',
91 'order_line' =>
'OrderLine',
92 'propal' =>
'Proposal',
93 'propal_line' =>
'ProposalLine',
94 'intervention' =>
'Intervention',
95 'inter_line' =>
'InterLine',
97 'member_type' =>
'MemberType',
98 'subscription' =>
'Subscription',
99 'tax' =>
'SocialContribution',
100 'tax_type' =>
'DictionarySocialContributions',
101 'account' =>
'BankTransactions',
102 'payment' =>
'Payment',
103 'product' =>
'Product',
104 'virtualproduct' =>
'AssociatedProducts',
105 'subproduct' =>
'SubProduct',
106 'product_supplier_ref' =>
'SupplierPrices',
107 'service' =>
'Service',
109 'movement' =>
'StockMovement',
111 'stockbatch' =>
'StockDetailPerBatch',
112 'warehouse' =>
'Warehouse',
113 'category' =>
'Category',
115 'trip' =>
'TripsAndExpenses',
116 'shipment' =>
'Shipments',
117 'shipment_line'=>
'ShipmentLine',
118 'project' =>
'Projects',
119 'projecttask' =>
'Tasks',
120 'task_time' =>
'TaskTimeSpent',
122 'expensereport'=>
'ExpenseReport',
123 'expensereport_line'=>
'ExpenseReportLine',
124 'holiday' =>
'TitreRequestCP',
125 'contract' =>
'Contract',
126 'contract_line'=>
'ContractLine',
127 'translation' =>
'Translation',
129 'bomline' =>
'BOMLine',
130 'conferenceorboothattendee' =>
'Attendee'
133$array_selected = isset($_SESSION[
"export_selected_fields"]) ? $_SESSION[
"export_selected_fields"] : array();
134$array_filtervalue = isset($_SESSION[
"export_filtered_fields"]) ? $_SESSION[
"export_filtered_fields"] : array();
135$datatoexport =
GETPOST(
"datatoexport",
"aZ09");
136$action =
GETPOST(
'action',
'aZ09');
137$confirm =
GETPOST(
'confirm',
'alpha');
139$export_name =
GETPOST(
"export_name",
"alphanohtml");
140$hexa =
GETPOST(
"hexa",
"alpha");
141$exportmodelid =
GETPOST(
"exportmodelid",
"int");
142$field =
GETPOST(
"field",
"alpa");
144$objexport =
new Export($db);
145$objexport->load_arrays($user, $datatoexport);
148$form =
new Form($db);
151$sqlusedforexport =
'';
154$upload_dir = $conf->export->dir_temp.
'/'.$user->id;
166if ($action ==
'selectfield') {
167 $fieldsarray = $objexport->array_export_fields[0];
168 $fieldsentitiesarray = $objexport->array_export_entities[0];
169 $fieldsdependenciesarray = $objexport->array_export_dependencies[0];
171 if ($field ==
'all') {
172 foreach ($fieldsarray as $key => $val) {
173 if (!empty($array_selected[$key])) {
176 $array_selected[$key] = count($array_selected) + 1;
178 $_SESSION[
"export_selected_fields"] = $array_selected;
183 $array_selected[$field] = count($array_selected) + 1;
188 $listofdependencies = array();
189 if (!empty($fieldsentitiesarray[$field]) && !empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]])) {
191 $tmp = $fieldsdependenciesarray[$fieldsentitiesarray[$field]];
192 if (is_array($tmp)) {
193 $listofdependencies = $tmp;
195 $listofdependencies = array($tmp);
197 } elseif (!empty($field) && !empty($fieldsdependenciesarray[$field])) {
199 $tmp = $fieldsdependenciesarray[$field];
200 if (is_array($tmp)) {
201 $listofdependencies = $tmp;
203 $listofdependencies = array($tmp);
207 if (count($listofdependencies)) {
208 foreach ($listofdependencies as $fieldid) {
209 if (empty($array_selected[$fieldid])) {
210 $array_selected[$fieldid] = count($array_selected) + 1;
211 $warnings[] = $langs->trans(
"ExportFieldAutomaticallyAdded", $langs->transnoentitiesnoconv($fieldsarray[$fieldid]));
216 $_SESSION[
"export_selected_fields"] = $array_selected;
221if ($action ==
'unselectfield') {
222 if ($_GET[
"field"] ==
'all') {
223 $array_selected = array();
224 $_SESSION[
"export_selected_fields"] = $array_selected;
226 unset($array_selected[$_GET[
"field"]]);
228 asort($array_selected);
230 $array_selected_save = $array_selected;
231 foreach ($array_selected as $code => $value) {
233 $array_selected[$code] = $i;
236 $_SESSION[
"export_selected_fields"] = $array_selected;
240if ($action ==
'downfield' || $action ==
'upfield') {
241 $pos = $array_selected[$_GET[
"field"]];
242 if ($action ==
'downfield') {
245 if ($action ==
'upfield') {
250 foreach ($array_selected as $code => $value) {
251 if ($value == $newpos) {
258 $array_selected[$_GET[
"field"]] = $newpos;
259 $array_selected[$newcode] = $pos;
260 $_SESSION[
"export_selected_fields"] = $array_selected;
264if ($step == 1 || $action ==
'cleanselect') {
265 $_SESSION[
"export_selected_fields"] = array();
266 $_SESSION[
"export_filtered_fields"] = array();
267 $array_selected = array();
268 $array_filtervalue = array();
271if ($action ==
'builddoc') {
272 $max_execution_time_for_importexport = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME);
273 $max_time = @ini_get(
"max_execution_time");
274 if ($max_time && $max_time < $max_execution_time_for_importexport) {
275 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.");
276 @ini_set(
"max_execution_time", $max_execution_time_for_importexport);
280 $result = $objexport->build_file($user,
GETPOST(
'model',
'alpha'), $datatoexport, $array_selected, $array_filtervalue);
283 $sqlusedforexport = $objexport->sqlusedforexport;
286 $sqlusedforexport = $objexport->sqlusedforexport;
291if ($step == 5 && $action ==
'confirm_deletefile' && $confirm ==
'yes') {
292 $file = $upload_dir.
"/".
GETPOST(
'file');
300 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport);
304if ($action ==
'deleteprof') {
306 $objexport->fetch(
GETPOST(
'id',
'int'));
307 $result = $objexport->delete($user);
312if ($action ==
'add_export_model') {
314 asort($array_selected);
318 foreach ($array_selected as $key => $val) {
325 $hexafiltervalue =
'';
326 if (!empty($array_filtervalue) && is_array($array_filtervalue)) {
327 foreach ($array_filtervalue as $key => $val) {
328 if ($hexafiltervalue) {
329 $hexafiltervalue .=
',';
331 $hexafiltervalue .= $key.
'='.$val;
335 $objexport->model_name = $export_name;
336 $objexport->datatoexport = $datatoexport;
337 $objexport->hexa = $hexa;
338 $objexport->hexafiltervalue = $hexafiltervalue;
339 $objexport->fk_user = (
GETPOST(
'visibility',
'aZ09') ==
'all' ? 0 : $user->id);
341 $result = $objexport->create($user);
343 setEventMessages($langs->trans(
"ExportModelSaved", $objexport->model_name),
null,
'mesgs');
345 $langs->load(
"errors");
346 if ($objexport->errno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
347 setEventMessages($langs->trans(
"ErrorExportDuplicateProfil"),
null,
'errors');
353 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ExportModelName")),
null,
'errors');
358if ($step == 2 && $action ==
'select_model') {
359 $_SESSION[
"export_selected_fields"] = array();
360 $_SESSION[
"export_filtered_fields"] = array();
362 $array_selected = array();
363 $array_filtervalue = array();
365 $result = $objexport->fetch($exportmodelid);
367 $fieldsarray = preg_split(
"/,(?! [^(]*\))/", $objexport->hexa);
369 foreach ($fieldsarray as $val) {
370 $array_selected[$val] = $i;
373 $_SESSION[
"export_selected_fields"] = $array_selected;
375 $fieldsarrayvalue = explode(
',', $objexport->hexafiltervalue);
377 foreach ($fieldsarrayvalue as $val) {
378 $tmp = explode(
'=', $val);
379 $array_filtervalue[$tmp[0]] = $tmp[1];
382 $_SESSION[
"export_filtered_fields"] = $array_filtervalue;
387if ($step == 4 && $action ==
'submitFormField') {
389 if (is_array($objexport->array_export_TypeFields[0])) {
390 $_SESSION[
"export_filtered_fields"] = array();
391 foreach ($objexport->array_export_TypeFields[0] as $code => $type) {
392 $newcode = (string) preg_replace(
'/\./',
'_', $code);
394 $check =
'alphanohtml';
395 $filterqualified = 1;
396 if (!GETPOSTISSET($newcode) ||
GETPOST($newcode, $check) ==
'') {
397 $filterqualified = 0;
398 } elseif (preg_match(
'/^List/', $type) && (is_numeric(
GETPOST($newcode, $check)) &&
GETPOST($newcode, $check) <= 0)) {
399 $filterqualified = 0;
401 if ($filterqualified) {
403 $objexport->array_export_FilterValue[0][$code] =
GETPOST($newcode, $check);
406 $array_filtervalue = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] :
'');
407 $_SESSION[
"export_filtered_fields"] = $array_filtervalue;
416if ($step == 1 || !$datatoexport) {
417 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
421 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
422 $head[$h][1] = $langs->trans(
"Step").
" 1";
428 print
'<div class="opacitymedium">'.$langs->trans(
"SelectExportDataSet").
'</div><br>';
431 print
'<div class="div-table-responsive-no-min">';
432 print
'<table class="noborder centpercent">';
433 print
'<tr class="liste_titre">';
434 print
'<td>'.$langs->trans(
"Module").
'</td>';
435 print
'<td>'.$langs->trans(
"ExportableDatas").
'</td>';
436 print
'<td> </td>';
439 if (count($objexport->array_export_module)) {
440 asort($objexport->array_export_code_for_sort);
443 foreach ($objexport->array_export_code_for_sort as $key => $value) {
444 print
'<tr class="oddeven"><td nospan="nospan">';
446 print $objexport->array_export_module[$key]->getName();
448 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[$key]);
449 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
450 $label = $objexport->array_export_label[$key];
452 print
img_object($objexport->array_export_module[$key]->getName(), $entityicon).
' ';
454 print
'</td><td class="right">';
455 if ($objexport->array_export_perms[$key]) {
456 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>';
458 print
'<span class="opacitymedium">'.$langs->trans(
"NotEnoughPermissions").
'</span>';
463 print
'<tr><td class="oddeven" colspan="3">'.$langs->trans(
"NoExportableData").
'</td></tr>';
471if ($step == 2 && $datatoexport) {
472 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
476 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
477 $head[$h][1] = $langs->trans(
"Step").
" 1";
480 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
481 $head[$h][1] = $langs->trans(
"Step").
" 2";
487 print
'<div class="fichecenter">';
488 print
'<div class="underbanner clearboth"></div>';
490 print
'<table width="100%" class="border tableforfield">';
493 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
495 print $objexport->array_export_module[0]->getName();
499 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
501 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
502 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
503 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
504 print $objexport->array_export_label[0];
515 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
516 print
'<input type="hidden" name="token" value="'.newToken().
'">';
517 print
'<input type="hidden" name="action" value="select_model">';
518 print
'<input type="hidden" name="step" value="2">';
519 print
'<input type="hidden" name="datatoexport" value="'.$datatoexport.
'">';
520 print
'<div class="valignmiddle marginbottomonly">';
521 print
'<span class="opacitymedium">'.$langs->trans(
"SelectExportFields").
'</span> ';
522 $htmlother->select_export_model($exportmodelid,
'exportmodelid', $datatoexport, 1, $user->id);
524 print
'<input type="submit" class="button small" value="'.$langs->trans(
"Select").
'">';
529 print
'<div class="div-table-responsive-no-min">';
530 print
'<table class="noborder centpercent">';
531 print
'<tr class="liste_titre">';
532 print
'<td>'.$langs->trans(
"Object").
'</td>';
533 print
'<td>'.$langs->trans(
"ExportableFields").
'</td>';
534 print
'<td width="100" class="center">';
535 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>";
537 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>";
539 print
'<td width="44%">'.$langs->trans(
"ExportedFields").
'</td>';
543 $fieldsarray = $objexport->array_export_fields[0];
545 $sqlmaxforexport = $objexport->build_sql(0, array(), array());
557 foreach ($fieldsarray as $code => $label) {
558 print
'<tr class="oddeven">';
562 $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
563 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
564 $entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
566 print
'<td class="nowrap">';
570 $tmparray = explode(
':', $entityicon);
571 if (count($tmparray) >= 2) {
572 $entityicon = $tmparray[0];
573 $entitylang = $tmparray[1];
575 print
img_object(
'', $entityicon).
' '.$langs->trans($entitylang);
578 $text = (empty($objexport->array_export_special[0][$code]) ?
'' :
'<i>').$langs->trans($label).(empty($objexport->array_export_special[0][$code]) ?
'' :
'</i>');
581 $htmltext =
'<b>'.$langs->trans(
"Name").
":</b> ".$text.
'<br>';
582 if (!empty($objexport->array_export_special[0][$code])) {
583 $htmltext .=
'<b>'.$langs->trans(
"ComputedField").
" -> ".$langs->trans(
"Method").
" :</b> ".$objexport->array_export_special[0][$code].
"<br>";
585 $htmltext .=
'<b>'.$langs->trans(
"Table").
" -> ".$langs->trans(
"Field").
":</b> ".$tablename.
" -> ".preg_replace(
'/^.*\./',
'', $code).
"<br>";
587 if (!empty($objexport->array_export_examplevalues[0][$code])) {
588 $htmltext .=
'<b>'.$langs->trans(
"SourceExample").
':</b> '.$objexport->array_export_examplevalues[0][$code].
'<br>';
590 if (!empty($objexport->array_export_TypeFields[0][$code])) {
591 $htmltext .=
'<b>'.$langs->trans(
"Type").
':</b> '.$objexport->array_export_TypeFields[0][$code].
'<br>';
593 if (!empty($objexport->array_export_help[0][$code])) {
594 $htmltext .=
'<b>'.$langs->trans(
"Help").
':</b> '.$langs->trans($objexport->array_export_help[0][$code]).
'<br>';
597 if (isset($array_selected[$code]) && $array_selected[$code]) {
599 print
'<td> </td>';
600 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>';
603 print $form->textwithpicto($text, $htmltext);
610 print $form->textwithpicto($text, $htmltext);
613 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>';
614 print
'<td> </td>';
626 print
'<div class="tabsAction tabsActionNoBottom">';
628 if (count($array_selected)) {
630 if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
631 print
'<a class="butAction" href="export.php?step=3&datatoexport='.$datatoexport.
'">'.$langs->trans(
"NextStep").
'</a>';
633 print
'<a class="butAction" href="export.php?step=4&datatoexport='.$datatoexport.
'">'.$langs->trans(
"NextStep").
'</a>';
636 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"SelectAtLeastOneField")).
'">'.$langs->trans(
"NextStep").
'</a>';
642if ($step == 3 && $datatoexport) {
643 if (count($array_selected) < 1) {
645 header(
"Location: ".DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport);
649 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
653 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
654 $head[$h][1] = $langs->trans(
"Step").
" 1";
657 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
658 $head[$h][1] = $langs->trans(
"Step").
" 2";
661 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=3&datatoexport='.$datatoexport;
662 $head[$h][1] = $langs->trans(
"Step").
" 3";
668 print
'<div class="fichecenter">';
669 print
'<div class="underbanner clearboth"></div>';
670 print
'<table width="100%" class="border tableforfield">';
673 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
676 print $objexport->array_export_module[0]->getName();
680 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
682 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
683 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
684 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
685 print $objexport->array_export_label[0];
689 print
'<tr><td>'.$langs->trans(
"ExportedFields").
'</td>';
691 foreach ($array_selected as $code => $value) {
692 $list .= (!empty($list) ?
', ' :
'');
693 $list .= (isset($objexport->array_export_fields[0][$code]) ? $langs->trans($objexport->array_export_fields[0][$code]) :
'');
695 print
'<td>'.$list.
'</td></tr>';
703 print
'<span class="opacitymedium">'.$langs->trans(
"SelectFilterFields").
'</span><br><br>';
707 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?step=4&action=submitFormField&datatoexport='.$datatoexport.
'" name="FilterField" method="post">';
708 print
'<input type="hidden" name="token" value="'.newToken().
'">';
710 print
'<div class="div-table-responsive-no-min">';
712 print
'<table class="noborder centpercent">';
713 print
'<tr class="liste_titre">';
714 print
'<td>'.$langs->trans(
"Entities").
'</td>';
717 print
'<td>'.$langs->trans(
"ExportableFields").
'</td>';
718 print
'<td width="25%">'.$langs->trans(
"FilteredFieldsValues").
'</td>';
722 $fieldsarray = $objexport->array_export_fields[0];
724 $Typefieldsarray = $objexport->array_export_TypeFields[0];
726 $ValueFiltersarray = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] :
'');
728 $sqlmaxforexport = $objexport->build_sql(0, array(), array());
732 foreach ($fieldsarray as $code => $label) {
733 print
'<tr class="oddeven">';
736 $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
737 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
738 $entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
740 print
'<td class="nowrap">';
742 $tmparray = explode(
':', $entityicon);
743 if (count($tmparray) >= 2) {
744 $entityicon = $tmparray[0];
745 $entitylang = $tmparray[1];
747 print
img_object(
'', $entityicon).
' '.$langs->trans($entitylang);
751 $labelName = (!empty($fieldsarray[$code]) ? $fieldsarray[$code] :
'');
752 $ValueFilter = (!empty($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'');
753 $text = (empty($objexport->array_export_special[0][$code]) ?
'' :
'<i>').$langs->trans($labelName).(empty($objexport->array_export_special[0][$code]) ?
'' :
'</i>');
756 $htmltext =
'<b>'.$langs->trans(
"Name").
':</b> '.$text.
'<br>';
757 if (!empty($objexport->array_export_special[0][$code])) {
758 $htmltext .=
'<b>'.$langs->trans(
"ComputedField").
" -> ".$langs->trans(
"Method").
" :</b> ".$objexport->array_export_special[0][$code].
"<br>";
760 $htmltext .=
'<b>'.$langs->trans(
"Table").
" -> ".$langs->trans(
"Field").
":</b> ".$tablename.
" -> ".preg_replace(
'/^.*\./',
'', $code).
"<br>";
762 if (!empty($objexport->array_export_examplevalues[0][$code])) {
763 $htmltext .=
'<b>'.$langs->trans(
"SourceExample").
':</b> '.$objexport->array_export_examplevalues[0][$code].
'<br>';
765 if (!empty($objexport->array_export_TypeFields[0][$code])) {
766 $htmltext .=
'<b>'.$langs->trans(
"Type").
':</b> '.$objexport->array_export_TypeFields[0][$code].
'<br>';
768 if (!empty($objexport->array_export_help[0][$code])) {
769 $htmltext .=
'<b>'.$langs->trans(
"Help").
':</b> '.$langs->trans($objexport->array_export_help[0][$code]).
'<br>';
773 print $form->textwithpicto($text, $htmltext);
778 if (!empty($Typefieldsarray[$code])) {
779 $szInfoFiltre = $objexport->genDocFilter($Typefieldsarray[$code]);
781 $tmp = $objexport->build_filterField($Typefieldsarray[$code], $code, $ValueFilter);
782 print $form->textwithpicto($tmp, $szInfoFiltre);
784 print $objexport->build_filterField($Typefieldsarray[$code], $code, $ValueFilter);
800 print
'<div class="tabsAction tabsActionNoBottom">';
802 print
'<a class="butAction" href="javascript:FilterField.submit();">'.$langs->trans(
"NextStep").
'</a>';
806if ($step == 4 && $datatoexport) {
807 if (count($array_selected) < 1) {
809 header(
"Location: ".DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport);
813 asort($array_selected);
815 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
820 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
821 $head[$h][1] = $langs->trans(
"Step").
" 1";
824 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
825 $head[$h][1] = $langs->trans(
"Step").
" 2";
829 if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
830 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=3&datatoexport='.$datatoexport;
831 $head[$h][1] = $langs->trans(
"Step").
" 3";
836 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=4&datatoexport='.$datatoexport;
837 $head[$h][1] = $langs->trans(
"Step").
" ".(3 + $stepoffset);
843 print
'<div class="fichecenter">';
844 print
'<div class="underbanner clearboth"></div>';
845 print
'<table width="100%" class="border tableforfield">';
848 print
'<tr><td class="titlefield tableforfield">'.$langs->trans(
"Module").
'</td>';
851 print $objexport->array_export_module[0]->getName();
855 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
857 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
858 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
859 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
860 print $objexport->array_export_label[0];
864 print
'<tr><td>'.$langs->trans(
"ExportedFields").
'</td>';
866 foreach ($array_selected as $code => $value) {
867 $list .= (!empty($list) ?
', ' :
'');
868 $list .= $langs->trans($objexport->array_export_fields[0][$code]);
870 print
'<td>'.$list.
'</td>';
874 if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
875 print
'<tr><td>'.$langs->trans(
"FilteredFields").
'</td>';
877 if (!empty($array_filtervalue)) {
878 foreach ($array_filtervalue as $code => $value) {
879 if (preg_match(
'/^FormSelect:/', $objexport->array_export_TypeFields[0][$code])) {
885 if (isset($objexport->array_export_fields[0][$code])) {
886 $list .= ($list ?
', ' :
'');
887 if (isset($array_filtervalue[$code]) && preg_match(
'/^\s*[<>]/', $array_filtervalue[$code])) {
888 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
'</span>'.(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'');
890 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
"</span>='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'').
"'";
895 print
'<td>'.(!empty($list) ? $list :
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>').
'</td>';
905 $sqlmaxforexport = $objexport->build_sql(0, array(), array());
907 print
'<div class="marginbottomonly"><span class="opacitymedium">'.$langs->trans(
"ChooseFieldsOrdersAndTitle").
'</span></div>';
909 print
'<div class="div-table-responsive-no-min">';
910 print
'<table class="noborder centpercent">';
911 print
'<tr class="liste_titre">';
912 print
'<td>'.$langs->trans(
"Entities").
'</td>';
913 print
'<td>'.$langs->trans(
"ExportedFields").
'</td>';
914 print
'<td class="right" colspan="2">'.$langs->trans(
"Position").
'</td>';
919 foreach ($array_selected as $code => $value) {
920 print
'<tr class="oddeven">';
922 $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
923 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
924 $entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
926 print
'<td class="nowrap">';
928 $tmparray = explode(
':', $entityicon);
929 if (count($tmparray) >= 2) {
930 $entityicon = $tmparray[0];
931 $entitylang = $tmparray[1];
933 print
img_object(
'', $entityicon).
' '.$langs->trans($entitylang);
936 $labelName = $objexport->array_export_fields[0][$code];
938 $text = (empty($objexport->array_export_special[0][$code]) ?
'' :
'<i>').$langs->trans($labelName).(empty($objexport->array_export_special[0][$code]) ?
'' :
'</i>');
941 $htmltext =
'<b>'.$langs->trans(
"Name").
':</b> '.$text.
'<br>';
942 if (!empty($objexport->array_export_special[0][$code])) {
943 $htmltext .=
'<b>'.$langs->trans(
"ComputedField").
" -> ".$langs->trans(
"Method").
" :</b> ".$objexport->array_export_special[0][$code].
"<br>";
945 $htmltext .=
'<b>'.$langs->trans(
"Table").
" -> ".$langs->trans(
"Field").
":</b> ".$tablename.
" -> ".preg_replace(
'/^.*\./',
'', $code).
"<br>";
947 if (!empty($objexport->array_export_examplevalues[0][$code])) {
948 $htmltext .=
'<b>'.$langs->trans(
"SourceExample").
':</b> '.$objexport->array_export_examplevalues[0][$code].
'<br>';
950 if (!empty($objexport->array_export_TypeFields[0][$code])) {
951 $htmltext .=
'<b>'.$langs->trans(
"Type").
':</b> '.$objexport->array_export_TypeFields[0][$code].
'<br>';
953 if (!empty($objexport->array_export_help[0][$code])) {
954 $htmltext .=
'<b>'.$langs->trans(
"Help").
':</b> '.$langs->trans($objexport->array_export_help[0][$code]).
'<br>';
958 print $form->textwithpicto($text, $htmltext);
962 print
'<td class="right" width="100">';
964 print
'</td><td class="center nowraponall" width="40">';
965 if ($value < count($array_selected)) {
966 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport.
'&action=downfield&field='.$code.
'">'.
img_down().
'</a>';
969 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport.
'&action=upfield&field='.$code.
'">'.
img_up().
'</a>';
987 print
'<div class="tabsAction">';
989 if (count($array_selected)) {
990 print
'<a class="butAction" href="export.php?step='.($step + 1).
'&datatoexport='.$datatoexport.
'">'.$langs->trans(
"NextStep").
'</a>';
997 if (count($array_selected)) {
1000 print
'<div class="marginbottomonly">';
1001 print
'<span class="opacitymedium">'.$langs->trans(
"SaveExportModel").
'</span>';
1004 print
'<form class="nocellnopadd" action="export.php" method="post">';
1005 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1006 print
'<input type="hidden" name="action" value="add_export_model">';
1007 print
'<input type="hidden" name="step" value="'.$step.
'">';
1008 print
'<input type="hidden" name="datatoexport" value="'.$datatoexport.
'">';
1009 print
'<input type="hidden" name="hexa" value="'.$hexa.
'">';
1011 print
'<div class="div-table-responsive-no-min">';
1012 print
'<table class="noborder centpercent">';
1013 print
'<tr class="liste_titre">';
1014 print
'<td>'.$langs->trans(
"ExportModelName").
'</td>';
1015 print
'<td>'.$langs->trans(
"Visibility").
'</td>';
1019 print
'<tr class="oddeven">';
1020 print
'<td><input name="export_name" value=""></td>';
1022 $arrayvisibility = array(
'private'=>$langs->trans(
"Private"),
'all'=>$langs->trans(
"Everybody"));
1023 print $form->selectarray(
'visibility', $arrayvisibility,
'private');
1025 print
'<td class="right">';
1026 print
'<input type="submit" class="button reposition button-save small" value="'.$langs->trans(
"Save").
'">';
1029 $tmpuser =
new User($db);
1032 $sql =
"SELECT rowid, label, fk_user, entity";
1033 $sql .=
" FROM ".MAIN_DB_PREFIX.
"export_model";
1034 $sql .=
" WHERE type = '".$db->escape($datatoexport).
"'";
1035 if (empty($conf->global->EXPORTS_SHARE_MODELS)) {
1036 $sql .=
" AND fk_user IN (0, ".((int) $user->id).
")";
1038 $sql .=
" ORDER BY rowid";
1039 $resql = $db->query($sql);
1041 $num = $db->num_rows($resql);
1044 $obj = $db->fetch_object($resql);
1046 print
'<tr class="oddeven"><td>';
1050 if (empty($obj->fk_user)) {
1051 print $langs->trans(
"Everybody");
1053 $tmpuser->fetch($obj->fk_user);
1054 print $tmpuser->getNomUrl(1);
1057 print
'<td class="right">';
1058 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport.
'&action=deleteprof&token='.newToken().
'&id='.$obj->rowid.
'">';
1075if ($step == 5 && $datatoexport) {
1076 if (count($array_selected) < 1) {
1078 header(
"Location: ".DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport);
1082 asort($array_selected);
1084 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
1089 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
1090 $head[$h][1] = $langs->trans(
"Step").
" 1";
1093 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
1094 $head[$h][1] = $langs->trans(
"Step").
" 2";
1098 if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
1099 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=3&datatoexport='.$datatoexport;
1100 $head[$h][1] = $langs->trans(
"Step").
" 3";
1105 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=4&datatoexport='.$datatoexport;
1106 $head[$h][1] = $langs->trans(
"Step").
" ".(3 + $stepoffset);
1109 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=5&datatoexport='.$datatoexport;
1110 $head[$h][1] = $langs->trans(
"Step").
" ".(4 + $stepoffset);
1119 if ($action ==
'remove_file') {
1120 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?step=5&datatoexport='.$datatoexport.
'&file='.urlencode(
GETPOST(
"file")), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'', 0, 1);
1123 print
'<div class="fichecenter">';
1124 print
'<div class="underbanner clearboth"></div>';
1126 print
'<table width="100%" class="border tableforfield">';
1129 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
1132 print $objexport->array_export_module[0]->getName();
1136 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
1138 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
1139 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
1140 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
1141 print $objexport->array_export_label[0];
1145 print
'<tr><td>'.$langs->trans(
"ExportedFields").
'</td>';
1147 foreach ($array_selected as $code => $label) {
1148 $list .= (!empty($list) ?
', ' :
'');
1149 $list .= $langs->trans($objexport->array_export_fields[0][$code]);
1151 print
'<td>'.$list.
'</td></tr>';
1154 if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
1155 print
'<tr><td>'.$langs->trans(
"FilteredFields").
'</td>';
1157 if (!empty($array_filtervalue)) {
1158 foreach ($array_filtervalue as $code => $value) {
1159 if (preg_match(
'/^FormSelect:/', $objexport->array_export_TypeFields[0][$code])) {
1165 if (isset($objexport->array_export_fields[0][$code])) {
1166 $list .= ($list ?
', ' :
'');
1167 if (isset($array_filtervalue[$code]) && preg_match(
'/^\s*[<>]/', $array_filtervalue[$code])) {
1168 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
'</span>'.(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'');
1170 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
"</span>='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'').
"'";
1175 print
'<td>'.(!empty($list) ? $list :
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>').
'</td>';
1185 $htmltabloflibs =
'<!-- Table with available export formats --><br>';
1186 $htmltabloflibs .=
'<table class="noborder centpercent nomarginbottom">';
1187 $htmltabloflibs .=
'<tr class="liste_titre">';
1188 $htmltabloflibs .=
'<td>'.$langs->trans(
"AvailableFormats").
'</td>';
1189 $htmltabloflibs .=
'<td>'.$langs->trans(
"LibraryUsed").
'</td>';
1190 $htmltabloflibs .=
'<td class="right">'.$langs->trans(
"LibraryVersion").
'</td>';
1191 $htmltabloflibs .=
'</tr>'.
"\n";
1193 $liste = $objmodelexport->listOfAvailableExportFormat($db);
1195 foreach ($listeall as $key => $val) {
1196 if (preg_match(
'/__\(Disabled\)__/', $listeall[$key])) {
1197 $listeall[$key] = preg_replace(
'/__\(Disabled\)__/',
'('.$langs->transnoentitiesnoconv(
"Disabled").
')', $listeall[$key]);
1198 unset($liste[$key]);
1201 $htmltabloflibs .=
'<tr class="oddeven">';
1202 $htmltabloflibs .=
'<td>'.img_picto_common($key, $objmodelexport->getPictoForKey($key)).
' ';
1203 $text = $objmodelexport->getDriverDescForKey($key);
1204 $label = $listeall[$key];
1205 $htmltabloflibs .= $form->textwithpicto($label, $text).
'</td>';
1206 $htmltabloflibs .=
'<td>'.$objmodelexport->getLibLabelForKey($key).
'</td>';
1207 $htmltabloflibs .=
'<td class="right">'.$objmodelexport->getLibVersionForKey($key).
'</td>';
1208 $htmltabloflibs .=
'</tr>'.
"\n";
1210 $htmltabloflibs .=
'</table><br>';
1212 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NowClickToGenerateToBuildExportFile"), $htmltabloflibs, 1,
'help',
'', 0, 2,
'helphonformat').
'</span>';
1219 if ($sqlusedforexport && $user->admin) {
1220 print
info_admin($langs->trans(
"SQLUsedForExport").
':<br> '.$sqlusedforexport, 0, 0, 1,
'',
'TechnicalInformation');
1224 if (!is_dir($conf->export->dir_temp)) {
1230 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',
'',
'',
'');
1249 $alias = preg_replace(
'/\.(.*)$/i',
'', $code);
1250 $regexstring =
'/([a-zA-Z_]+) as '.preg_quote($alias).
'[, \)]/i';
1252 $newsql = $sqlmaxforexport;
1253 $newsql = preg_replace(
'/^(.*) FROM /i',
'', $newsql);
1254 $newsql = preg_replace(
'/WHERE (.*)$/i',
'', $newsql);
1256 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.
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.
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.