28 require_once
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/exports/class/export.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/modules/export/modules_export.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
36 $langs->loadlangs(array(
'admin',
'exports',
'other',
'users',
'companies',
'projects',
'suppliers',
'products',
'bank',
'bills'));
43 $entitytoicon = array(
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',
83 $entitytolang = array(
85 'company' =>
'Company',
86 'contact' =>
'Contact',
88 'invoice_line' =>
'InvoiceLine',
90 'order_line' =>
'OrderLine',
91 'propal' =>
'Proposal',
92 'propal_line' =>
'ProposalLine',
93 'intervention' =>
'Intervention',
94 'inter_line' =>
'InterLine',
96 'member_type' =>
'MemberType',
97 'subscription' =>
'Subscription',
98 'tax' =>
'SocialContribution',
99 'tax_type' =>
'DictionarySocialContributions',
100 'account' =>
'BankTransactions',
101 'payment' =>
'Payment',
102 'product' =>
'Product',
103 'virtualproduct' =>
'AssociatedProducts',
104 'subproduct' =>
'SubProduct',
105 'product_supplier_ref' =>
'SupplierPrices',
106 'service' =>
'Service',
108 'movement' =>
'StockMovement',
110 'stockbatch' =>
'StockDetailPerBatch',
111 'warehouse' =>
'Warehouse',
112 'category' =>
'Category',
114 'trip' =>
'TripsAndExpenses',
115 'shipment' =>
'Shipments',
116 'shipment_line'=>
'ShipmentLine',
117 'project' =>
'Projects',
118 'projecttask' =>
'Tasks',
119 'task_time' =>
'TaskTimeSpent',
121 'expensereport'=>
'ExpenseReport',
122 'expensereport_line'=>
'ExpenseReportLine',
123 'holiday' =>
'TitreRequestCP',
124 'contract' =>
'Contract',
125 'contract_line'=>
'ContractLine',
126 'translation' =>
'Translation',
128 'bomline' =>
'BOMLine'
131 $array_selected = isset($_SESSION[
"export_selected_fields"]) ? $_SESSION[
"export_selected_fields"] : array();
132 $array_filtervalue = isset($_SESSION[
"export_filtered_fields"]) ? $_SESSION[
"export_filtered_fields"] : array();
133 $datatoexport =
GETPOST(
"datatoexport",
"aZ09");
134 $action =
GETPOST(
'action',
'aZ09');
135 $confirm =
GETPOST(
'confirm',
'alpha');
137 $export_name =
GETPOST(
"export_name",
"alphanohtml");
138 $hexa =
GETPOST(
"hexa",
"alpha");
139 $exportmodelid =
GETPOST(
"exportmodelid",
"int");
140 $field =
GETPOST(
"field",
"alpa");
142 $objexport =
new Export($db);
143 $objexport->load_arrays($user, $datatoexport);
149 $sqlusedforexport =
'';
152 $upload_dir = $conf->export->dir_temp.
'/'.$user->id;
164 if ($action ==
'selectfield') {
165 $fieldsarray = $objexport->array_export_fields[0];
166 $fieldsentitiesarray = $objexport->array_export_entities[0];
167 $fieldsdependenciesarray = $objexport->array_export_dependencies[0];
169 if ($field ==
'all') {
170 foreach ($fieldsarray as $key => $val) {
171 if (!empty($array_selected[$key])) {
174 $array_selected[$key] = count($array_selected) + 1;
176 $_SESSION[
"export_selected_fields"] = $array_selected;
181 $array_selected[$field] = count($array_selected) + 1;
186 $listofdependencies = array();
187 if (!empty($fieldsentitiesarray[$field]) && !empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]])) {
189 $tmp = $fieldsdependenciesarray[$fieldsentitiesarray[$field]];
190 if (is_array($tmp)) {
191 $listofdependencies = $tmp;
193 $listofdependencies = array($tmp);
195 } elseif (!empty($field) && !empty($fieldsdependenciesarray[$field])) {
197 $tmp = $fieldsdependenciesarray[$field];
198 if (is_array($tmp)) {
199 $listofdependencies = $tmp;
201 $listofdependencies = array($tmp);
205 if (count($listofdependencies)) {
206 foreach ($listofdependencies as $fieldid) {
207 if (empty($array_selected[$fieldid])) {
208 $array_selected[$fieldid] = count($array_selected) + 1;
209 $warnings[] = $langs->trans(
"ExportFieldAutomaticallyAdded", $langs->transnoentitiesnoconv($fieldsarray[$fieldid]));
214 $_SESSION[
"export_selected_fields"] = $array_selected;
219 if ($action ==
'unselectfield') {
220 if ($_GET[
"field"] ==
'all') {
221 $array_selected = array();
222 $_SESSION[
"export_selected_fields"] = $array_selected;
224 unset($array_selected[$_GET[
"field"]]);
226 asort($array_selected);
228 $array_selected_save = $array_selected;
229 foreach ($array_selected as $code => $value) {
231 $array_selected[$code] = $i;
234 $_SESSION[
"export_selected_fields"] = $array_selected;
238 if ($action ==
'downfield' || $action ==
'upfield') {
239 $pos = $array_selected[$_GET[
"field"]];
240 if ($action ==
'downfield') {
243 if ($action ==
'upfield') {
248 foreach ($array_selected as $code => $value) {
249 if ($value == $newpos) {
256 $array_selected[$_GET[
"field"]] = $newpos;
257 $array_selected[$newcode] = $pos;
258 $_SESSION[
"export_selected_fields"] = $array_selected;
262 if ($step == 1 || $action ==
'cleanselect') {
263 $_SESSION[
"export_selected_fields"] = array();
264 $_SESSION[
"export_filtered_fields"] = array();
265 $array_selected = array();
266 $array_filtervalue = array();
269 if ($action ==
'builddoc') {
270 $max_execution_time_for_importexport = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME);
271 $max_time = @ini_get(
"max_execution_time");
272 if ($max_time && $max_time < $max_execution_time_for_importexport) {
273 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.");
274 @ini_set(
"max_execution_time", $max_execution_time_for_importexport);
278 $result = $objexport->build_file($user,
GETPOST(
'model',
'alpha'), $datatoexport, $array_selected, $array_filtervalue);
281 $sqlusedforexport = $objexport->sqlusedforexport;
284 $sqlusedforexport = $objexport->sqlusedforexport;
289 if ($step == 5 && $action ==
'confirm_deletefile' && $confirm ==
'yes') {
290 $file = $upload_dir.
"/".
GETPOST(
'file');
298 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport);
302 if ($action ==
'deleteprof') {
304 $objexport->fetch(
GETPOST(
'id',
'int'));
305 $result = $objexport->delete($user);
310 if ($action ==
'add_export_model') {
312 asort($array_selected);
316 foreach ($array_selected as $key => $val) {
323 $hexafiltervalue =
'';
324 if (!empty($array_filtervalue) && is_array($array_filtervalue)) {
325 foreach ($array_filtervalue as $key => $val) {
326 if ($hexafiltervalue) {
327 $hexafiltervalue .=
',';
329 $hexafiltervalue .= $key.
'='.$val;
333 $objexport->model_name = $export_name;
334 $objexport->datatoexport = $datatoexport;
335 $objexport->hexa = $hexa;
336 $objexport->hexafiltervalue = $hexafiltervalue;
337 $objexport->fk_user = (
GETPOST(
'visibility',
'aZ09') ==
'all' ? 0 : $user->id);
339 $result = $objexport->create($user);
341 setEventMessages($langs->trans(
"ExportModelSaved", $objexport->model_name),
null,
'mesgs');
343 $langs->load(
"errors");
344 if ($objexport->errno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
345 setEventMessages($langs->trans(
"ErrorExportDuplicateProfil"),
null,
'errors');
351 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ExportModelName")),
null,
'errors');
356 if ($step == 2 && $action ==
'select_model') {
357 $_SESSION[
"export_selected_fields"] = array();
358 $_SESSION[
"export_filtered_fields"] = array();
360 $array_selected = array();
361 $array_filtervalue = array();
363 $result = $objexport->fetch($exportmodelid);
365 $fieldsarray = preg_split(
"/,(?! [^(]*\))/", $objexport->hexa);
367 foreach ($fieldsarray as $val) {
368 $array_selected[$val] = $i;
371 $_SESSION[
"export_selected_fields"] = $array_selected;
373 $fieldsarrayvalue = explode(
',', $objexport->hexafiltervalue);
375 foreach ($fieldsarrayvalue as $val) {
376 $tmp = explode(
'=', $val);
377 $array_filtervalue[$tmp[0]] = $tmp[1];
380 $_SESSION[
"export_filtered_fields"] = $array_filtervalue;
385 if ($step == 4 && $action ==
'submitFormField') {
387 if (is_array($objexport->array_export_TypeFields[0])) {
388 $_SESSION[
"export_filtered_fields"] = array();
389 foreach ($objexport->array_export_TypeFields[0] as $code => $type) {
390 $newcode = (string) preg_replace(
'/\./',
'_', $code);
392 $check =
'alphanohtml';
393 $filterqualified = 1;
395 $filterqualified = 0;
396 } elseif (preg_match(
'/^List/', $type) && (is_numeric(
GETPOST($newcode, $check)) &&
GETPOST($newcode, $check) <= 0)) {
397 $filterqualified = 0;
399 if ($filterqualified) {
401 $objexport->array_export_FilterValue[0][$code] =
GETPOST($newcode, $check);
404 $array_filtervalue = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] :
'');
405 $_SESSION[
"export_filtered_fields"] = $array_filtervalue;
414 if ($step == 1 || !$datatoexport) {
415 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
419 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
420 $head[$h][1] = $langs->trans(
"Step").
" 1";
426 print
'<div class="opacitymedium">'.$langs->trans(
"SelectExportDataSet").
'</div><br>';
429 print
'<div class="div-table-responsive-no-min">';
430 print
'<table class="noborder centpercent">';
431 print
'<tr class="liste_titre">';
432 print
'<td>'.$langs->trans(
"Module").
'</td>';
433 print
'<td>'.$langs->trans(
"ExportableDatas").
'</td>';
434 print
'<td> </td>';
437 if (count($objexport->array_export_module)) {
438 asort($objexport->array_export_code_for_sort);
441 foreach ($objexport->array_export_code_for_sort as $key => $value) {
442 print
'<tr class="oddeven"><td nospan="nospan">';
444 print $objexport->array_export_module[$key]->getName();
446 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[$key]);
447 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
448 $label = $objexport->array_export_label[$key];
450 print
img_object($objexport->array_export_module[$key]->getName(), $entityicon).
' ';
452 print
'</td><td class="right">';
453 if ($objexport->array_export_perms[$key]) {
454 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>';
456 print
'<span class="opacitymedium">'.$langs->trans(
"NotEnoughPermissions").
'</span>';
461 print
'<tr><td class="oddeven" colspan="3">'.$langs->trans(
"NoExportableData").
'</td></tr>';
469 if ($step == 2 && $datatoexport) {
470 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
474 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
475 $head[$h][1] = $langs->trans(
"Step").
" 1";
478 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
479 $head[$h][1] = $langs->trans(
"Step").
" 2";
485 print
'<div class="fichecenter">';
486 print
'<div class="underbanner clearboth"></div>';
488 print
'<table width="100%" class="border tableforfield">';
491 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
493 print $objexport->array_export_module[0]->getName();
497 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
499 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
500 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
501 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
502 print $objexport->array_export_label[0];
513 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
514 print
'<input type="hidden" name="token" value="'.newToken().
'">';
515 print
'<input type="hidden" name="action" value="select_model">';
516 print
'<input type="hidden" name="step" value="2">';
517 print
'<input type="hidden" name="datatoexport" value="'.$datatoexport.
'">';
518 print
'<div class="valignmiddle marginbottomonly">';
519 print
'<span class="opacitymedium">'.$langs->trans(
"SelectExportFields").
'</span> ';
520 $htmlother->select_export_model($exportmodelid,
'exportmodelid', $datatoexport, 1, $user->id);
522 print
'<input type="submit" class="button small" value="'.$langs->trans(
"Select").
'">';
527 print
'<div class="div-table-responsive-no-min">';
528 print
'<table class="noborder centpercent">';
529 print
'<tr class="liste_titre">';
530 print
'<td>'.$langs->trans(
"Entities").
'</td>';
531 print
'<td>'.$langs->trans(
"ExportableFields").
'</td>';
532 print
'<td width="100" class="center">';
533 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>";
535 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>";
537 print
'<td width="44%">'.$langs->trans(
"ExportedFields").
'</td>';
541 $fieldsarray = $objexport->array_export_fields[0];
543 $sqlmaxforexport = $objexport->build_sql(0, array(), array());
555 foreach ($fieldsarray as $code => $label) {
556 print
'<tr class="oddeven">';
560 $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
561 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
562 $entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
564 print
'<td class="nowrap">';
568 $tmparray = explode(
':', $entityicon);
569 if (count($tmparray) >= 2) {
570 $entityicon = $tmparray[0];
571 $entitylang = $tmparray[1];
573 print
img_object(
'', $entityicon).
' '.$langs->trans($entitylang);
576 $text = (empty($objexport->array_export_special[0][$code]) ?
'' :
'<i>').$langs->trans($label).(empty($objexport->array_export_special[0][$code]) ?
'' :
'</i>');
579 $htmltext =
'<b>'.$langs->trans(
"Name").
":</b> ".$text.
'<br>';
580 if (!empty($objexport->array_export_special[0][$code])) {
581 $htmltext .=
'<b>'.$langs->trans(
"ComputedField").
" -> ".$langs->trans(
"Method").
" :</b> ".$objexport->array_export_special[0][$code].
"<br>";
583 $htmltext .=
'<b>'.$langs->trans(
"Table").
" -> ".$langs->trans(
"Field").
":</b> ".$tablename.
" -> ".preg_replace(
'/^.*\./',
'', $code).
"<br>";
585 if (!empty($objexport->array_export_examplevalues[0][$code])) {
586 $htmltext .=
'<b>'.$langs->trans(
"SourceExample").
':</b> '.$objexport->array_export_examplevalues[0][$code].
'<br>';
588 if (!empty($objexport->array_export_TypeFields[0][$code])) {
589 $htmltext .=
'<b>'.$langs->trans(
"Type").
':</b> '.$objexport->array_export_TypeFields[0][$code].
'<br>';
591 if (!empty($objexport->array_export_help[0][$code])) {
592 $htmltext .=
'<b>'.$langs->trans(
"Help").
':</b> '.$langs->trans($objexport->array_export_help[0][$code]).
'<br>';
595 if (isset($array_selected[$code]) && $array_selected[$code]) {
597 print
'<td> </td>';
598 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>';
601 print
$form->textwithpicto($text, $htmltext);
608 print
$form->textwithpicto($text, $htmltext);
611 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>';
612 print
'<td> </td>';
624 print
'<div class="tabsAction tabsActionNoBottom">';
626 if (count($array_selected)) {
628 if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
629 print
'<a class="butAction" href="export.php?step=3&datatoexport='.$datatoexport.
'">'.$langs->trans(
"NextStep").
'</a>';
631 print
'<a class="butAction" href="export.php?step=4&datatoexport='.$datatoexport.
'">'.$langs->trans(
"NextStep").
'</a>';
634 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"SelectAtLeastOneField")).
'">'.$langs->trans(
"NextStep").
'</a>';
640 if ($step == 3 && $datatoexport) {
641 if (count($array_selected) < 1) {
643 header(
"Location: ".DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport);
647 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
651 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
652 $head[$h][1] = $langs->trans(
"Step").
" 1";
655 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
656 $head[$h][1] = $langs->trans(
"Step").
" 2";
659 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=3&datatoexport='.$datatoexport;
660 $head[$h][1] = $langs->trans(
"Step").
" 3";
666 print
'<div class="fichecenter">';
667 print
'<div class="underbanner clearboth"></div>';
668 print
'<table width="100%" class="border tableforfield">';
671 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
674 print $objexport->array_export_module[0]->getName();
678 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
680 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
681 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
682 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
683 print $objexport->array_export_label[0];
687 print
'<tr><td>'.$langs->trans(
"ExportedFields").
'</td>';
689 foreach ($array_selected as $code => $value) {
690 $list .= (!empty($list) ?
', ' :
'');
691 $list .= (isset($objexport->array_export_fields[0][$code]) ? $langs->trans($objexport->array_export_fields[0][$code]) :
'');
693 print
'<td>'.$list.
'</td></tr>';
701 print
'<span class="opacitymedium">'.$langs->trans(
"SelectFilterFields").
'</span><br><br>';
705 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?step=4&action=submitFormField&datatoexport='.$datatoexport.
'" name="FilterField" method="post">';
706 print
'<input type="hidden" name="token" value="'.newToken().
'">';
708 print
'<div class="div-table-responsive-no-min">';
710 print
'<table class="noborder centpercent">';
711 print
'<tr class="liste_titre">';
712 print
'<td>'.$langs->trans(
"Entities").
'</td>';
715 print
'<td>'.$langs->trans(
"ExportableFields").
'</td>';
716 print
'<td width="25%">'.$langs->trans(
"FilteredFieldsValues").
'</td>';
720 $fieldsarray = $objexport->array_export_fields[0];
722 $Typefieldsarray = $objexport->array_export_TypeFields[0];
724 $ValueFiltersarray = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] :
'');
726 $sqlmaxforexport = $objexport->build_sql(0, array(), array());
730 foreach ($fieldsarray as $code => $label) {
731 print
'<tr class="oddeven">';
734 $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
735 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
736 $entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
738 print
'<td class="nowrap">';
740 $tmparray = explode(
':', $entityicon);
741 if (count($tmparray) >= 2) {
742 $entityicon = $tmparray[0];
743 $entitylang = $tmparray[1];
745 print
img_object(
'', $entityicon).
' '.$langs->trans($entitylang);
749 $labelName = (!empty($fieldsarray[$code]) ? $fieldsarray[$code] :
'');
750 $ValueFilter = (!empty($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'');
751 $text = (empty($objexport->array_export_special[0][$code]) ?
'' :
'<i>').$langs->trans($labelName).(empty($objexport->array_export_special[0][$code]) ?
'' :
'</i>');
754 $htmltext =
'<b>'.$langs->trans(
"Name").
':</b> '.$text.
'<br>';
755 if (!empty($objexport->array_export_special[0][$code])) {
756 $htmltext .=
'<b>'.$langs->trans(
"ComputedField").
" -> ".$langs->trans(
"Method").
" :</b> ".$objexport->array_export_special[0][$code].
"<br>";
758 $htmltext .=
'<b>'.$langs->trans(
"Table").
" -> ".$langs->trans(
"Field").
":</b> ".$tablename.
" -> ".preg_replace(
'/^.*\./',
'', $code).
"<br>";
760 if (!empty($objexport->array_export_examplevalues[0][$code])) {
761 $htmltext .=
'<b>'.$langs->trans(
"SourceExample").
':</b> '.$objexport->array_export_examplevalues[0][$code].
'<br>';
763 if (!empty($objexport->array_export_TypeFields[0][$code])) {
764 $htmltext .=
'<b>'.$langs->trans(
"Type").
':</b> '.$objexport->array_export_TypeFields[0][$code].
'<br>';
766 if (!empty($objexport->array_export_help[0][$code])) {
767 $htmltext .=
'<b>'.$langs->trans(
"Help").
':</b> '.$langs->trans($objexport->array_export_help[0][$code]).
'<br>';
771 print
$form->textwithpicto($text, $htmltext);
776 if (!empty($Typefieldsarray[$code])) {
777 $szInfoFiltre = $objexport->genDocFilter($Typefieldsarray[$code]);
779 $tmp = $objexport->build_filterField($Typefieldsarray[$code], $code, $ValueFilter);
780 print
$form->textwithpicto($tmp, $szInfoFiltre);
782 print $objexport->build_filterField($Typefieldsarray[$code], $code, $ValueFilter);
798 print
'<div class="tabsAction tabsActionNoBottom">';
800 print
'<a class="butAction" href="javascript:FilterField.submit();">'.$langs->trans(
"NextStep").
'</a>';
804 if ($step == 4 && $datatoexport) {
805 if (count($array_selected) < 1) {
807 header(
"Location: ".DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport);
811 asort($array_selected);
813 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
818 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
819 $head[$h][1] = $langs->trans(
"Step").
" 1";
822 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
823 $head[$h][1] = $langs->trans(
"Step").
" 2";
827 if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
828 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=3&datatoexport='.$datatoexport;
829 $head[$h][1] = $langs->trans(
"Step").
" 3";
834 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=4&datatoexport='.$datatoexport;
835 $head[$h][1] = $langs->trans(
"Step").
" ".(3 + $stepoffset);
841 print
'<div class="fichecenter">';
842 print
'<div class="underbanner clearboth"></div>';
843 print
'<table width="100%" class="border tableforfield">';
846 print
'<tr><td class="titlefield tableforfield">'.$langs->trans(
"Module").
'</td>';
849 print $objexport->array_export_module[0]->getName();
853 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
855 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
856 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
857 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
858 print $objexport->array_export_label[0];
862 print
'<tr><td>'.$langs->trans(
"ExportedFields").
'</td>';
864 foreach ($array_selected as $code => $value) {
865 $list .= (!empty($list) ?
', ' :
'');
866 $list .= $langs->trans($objexport->array_export_fields[0][$code]);
868 print
'<td>'.$list.
'</td>';
872 if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
873 print
'<tr><td>'.$langs->trans(
"FilteredFields").
'</td>';
875 if (!empty($array_filtervalue)) {
876 foreach ($array_filtervalue as $code => $value) {
877 if (preg_match(
'/^FormSelect:/', $objexport->array_export_TypeFields[0][$code])) {
883 if (isset($objexport->array_export_fields[0][$code])) {
884 $list .= ($list ?
', ' :
'');
885 if (isset($array_filtervalue[$code]) && preg_match(
'/^\s*[<>]/', $array_filtervalue[$code])) {
886 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
'</span>'.(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'');
888 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
"</span>='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'').
"'";
893 print
'<td>'.(!empty($list) ? $list :
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>').
'</td>';
903 $sqlmaxforexport = $objexport->build_sql(0, array(), array());
905 print
'<div class="marginbottomonly"><span class="opacitymedium">'.$langs->trans(
"ChooseFieldsOrdersAndTitle").
'</span></div>';
907 print
'<div class="div-table-responsive-no-min">';
908 print
'<table class="noborder centpercent">';
909 print
'<tr class="liste_titre">';
910 print
'<td>'.$langs->trans(
"Entities").
'</td>';
911 print
'<td>'.$langs->trans(
"ExportedFields").
'</td>';
912 print
'<td class="right" colspan="2">'.$langs->trans(
"Position").
'</td>';
917 foreach ($array_selected as $code => $value) {
918 print
'<tr class="oddeven">';
920 $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
921 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
922 $entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
924 print
'<td class="nowrap">';
926 $tmparray = explode(
':', $entityicon);
927 if (count($tmparray) >= 2) {
928 $entityicon = $tmparray[0];
929 $entitylang = $tmparray[1];
931 print
img_object(
'', $entityicon).
' '.$langs->trans($entitylang);
934 $labelName = $objexport->array_export_fields[0][$code];
936 $text = (empty($objexport->array_export_special[0][$code]) ?
'' :
'<i>').$langs->trans($labelName).(empty($objexport->array_export_special[0][$code]) ?
'' :
'</i>');
939 $htmltext =
'<b>'.$langs->trans(
"Name").
':</b> '.$text.
'<br>';
940 if (!empty($objexport->array_export_special[0][$code])) {
941 $htmltext .=
'<b>'.$langs->trans(
"ComputedField").
" -> ".$langs->trans(
"Method").
" :</b> ".$objexport->array_export_special[0][$code].
"<br>";
943 $htmltext .=
'<b>'.$langs->trans(
"Table").
" -> ".$langs->trans(
"Field").
":</b> ".$tablename.
" -> ".preg_replace(
'/^.*\./',
'', $code).
"<br>";
945 if (!empty($objexport->array_export_examplevalues[0][$code])) {
946 $htmltext .=
'<b>'.$langs->trans(
"SourceExample").
':</b> '.$objexport->array_export_examplevalues[0][$code].
'<br>';
948 if (!empty($objexport->array_export_TypeFields[0][$code])) {
949 $htmltext .=
'<b>'.$langs->trans(
"Type").
':</b> '.$objexport->array_export_TypeFields[0][$code].
'<br>';
951 if (!empty($objexport->array_export_help[0][$code])) {
952 $htmltext .=
'<b>'.$langs->trans(
"Help").
':</b> '.$langs->trans($objexport->array_export_help[0][$code]).
'<br>';
956 print
$form->textwithpicto($text, $htmltext);
960 print
'<td class="right" width="100">';
962 print
'</td><td class="center nowraponall" width="40">';
963 if ($value < count($array_selected)) {
964 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport.
'&action=downfield&field='.$code.
'">'.
img_down().
'</a>';
967 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport.
'&action=upfield&field='.$code.
'">'.
img_up().
'</a>';
985 print
'<div class="tabsAction">';
987 if (count($array_selected)) {
988 print
'<a class="butAction" href="export.php?step='.($step + 1).
'&datatoexport='.$datatoexport.
'">'.$langs->trans(
"NextStep").
'</a>';
995 if (count($array_selected)) {
998 print
'<div class="marginbottomonly">';
999 print
'<span class="opacitymedium">'.$langs->trans(
"SaveExportModel").
'</span>';
1002 print
'<form class="nocellnopadd" action="export.php" method="post">';
1003 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1004 print
'<input type="hidden" name="action" value="add_export_model">';
1005 print
'<input type="hidden" name="step" value="'.$step.
'">';
1006 print
'<input type="hidden" name="datatoexport" value="'.$datatoexport.
'">';
1007 print
'<input type="hidden" name="hexa" value="'.$hexa.
'">';
1009 print
'<div class="div-table-responsive-no-min">';
1010 print
'<table class="noborder centpercent">';
1011 print
'<tr class="liste_titre">';
1012 print
'<td>'.$langs->trans(
"ExportModelName").
'</td>';
1013 print
'<td>'.$langs->trans(
"Visibility").
'</td>';
1017 print
'<tr class="oddeven">';
1018 print
'<td><input name="export_name" value=""></td>';
1020 $arrayvisibility = array(
'private'=>$langs->trans(
"Private"),
'all'=>$langs->trans(
"Everybody"));
1021 print
$form->selectarray(
'visibility', $arrayvisibility,
'private');
1023 print
'<td class="right">';
1024 print
'<input type="submit" class="button reposition button-save small" value="'.$langs->trans(
"Save").
'">';
1027 $tmpuser =
new User($db);
1030 $sql =
"SELECT rowid, label, fk_user, entity";
1031 $sql .=
" FROM ".MAIN_DB_PREFIX.
"export_model";
1032 $sql .=
" WHERE type = '".$db->escape($datatoexport).
"'";
1033 if (empty($conf->global->EXPORTS_SHARE_MODELS)) {
1034 $sql .=
" AND fk_user IN (0, ".((int) $user->id).
")";
1036 $sql .=
" ORDER BY rowid";
1037 $resql = $db->query($sql);
1039 $num = $db->num_rows(
$resql);
1042 $obj = $db->fetch_object(
$resql);
1044 print
'<tr class="oddeven"><td>';
1048 if (empty($obj->fk_user)) {
1049 print $langs->trans(
"Everybody");
1051 $tmpuser->fetch($obj->fk_user);
1052 print $tmpuser->getNomUrl(1);
1055 print
'<td class="right">';
1056 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?step='.$step.
'&datatoexport='.$datatoexport.
'&action=deleteprof&token='.
newToken().
'&id='.$obj->rowid.
'">';
1073 if ($step == 5 && $datatoexport) {
1074 if (count($array_selected) < 1) {
1076 header(
"Location: ".DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport);
1080 asort($array_selected);
1082 llxHeader(
'', $langs->trans(
"NewExport"),
'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
1087 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=1';
1088 $head[$h][1] = $langs->trans(
"Step").
" 1";
1091 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=2&datatoexport='.$datatoexport;
1092 $head[$h][1] = $langs->trans(
"Step").
" 2";
1096 if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
1097 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=3&datatoexport='.$datatoexport;
1098 $head[$h][1] = $langs->trans(
"Step").
" 3";
1103 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=4&datatoexport='.$datatoexport;
1104 $head[$h][1] = $langs->trans(
"Step").
" ".(3 + $stepoffset);
1107 $head[$h][0] = DOL_URL_ROOT.
'/exports/export.php?step=5&datatoexport='.$datatoexport;
1108 $head[$h][1] = $langs->trans(
"Step").
" ".(4 + $stepoffset);
1117 if ($action ==
'remove_file') {
1118 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?step=5&datatoexport='.$datatoexport.
'&file='.urlencode(
GETPOST(
"file")), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'', 0, 1);
1121 print
'<div class="fichecenter">';
1122 print
'<div class="underbanner clearboth"></div>';
1124 print
'<table width="100%" class="border tableforfield">';
1127 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
1130 print $objexport->array_export_module[0]->getName();
1134 print
'<tr><td>'.$langs->trans(
"DatasetToExport").
'</td>';
1136 $entity = preg_replace(
'/:.*$/',
'', $objexport->array_export_icon[0]);
1137 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
1138 print
img_object($objexport->array_export_module[0]->getName(), $entityicon).
' ';
1139 print $objexport->array_export_label[0];
1143 print
'<tr><td>'.$langs->trans(
"ExportedFields").
'</td>';
1145 foreach ($array_selected as $code => $label) {
1146 $list .= (!empty($list) ?
', ' :
'');
1147 $list .= $langs->trans($objexport->array_export_fields[0][$code]);
1149 print
'<td>'.$list.
'</td></tr>';
1152 if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
1153 print
'<tr><td>'.$langs->trans(
"FilteredFields").
'</td>';
1155 if (!empty($array_filtervalue)) {
1156 foreach ($array_filtervalue as $code => $value) {
1157 if (preg_match(
'/^FormSelect:/', $objexport->array_export_TypeFields[0][$code])) {
1163 if (isset($objexport->array_export_fields[0][$code])) {
1164 $list .= ($list ?
', ' :
'');
1165 if (isset($array_filtervalue[$code]) && preg_match(
'/^\s*[<>]/', $array_filtervalue[$code])) {
1166 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
'</span>'.(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'');
1168 $list .=
'<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).
"</span>='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] :
'').
"'";
1173 print
'<td>'.(!empty($list) ? $list :
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>').
'</td>';
1183 $htmltabloflibs =
'<table class="noborder centpercent">';
1184 $htmltabloflibs .=
'<tr class="liste_titre">';
1185 $htmltabloflibs .=
'<td>'.$langs->trans(
"AvailableFormats").
'</td>';
1186 $htmltabloflibs .=
'<td>'.$langs->trans(
"LibraryUsed").
'</td>';
1187 $htmltabloflibs .=
'<td class="right">'.$langs->trans(
"LibraryVersion").
'</td>';
1188 $htmltabloflibs .=
'</tr>'.
"\n";
1190 $liste = $objmodelexport->listOfAvailableExportFormat($db);
1192 foreach ($listeall as $key => $val) {
1193 if (preg_match(
'/__\(Disabled\)__/', $listeall[$key])) {
1194 $listeall[$key] = preg_replace(
'/__\(Disabled\)__/',
'('.$langs->transnoentitiesnoconv(
"Disabled").
')', $listeall[$key]);
1195 unset($liste[$key]);
1198 $htmltabloflibs .=
'<tr class="oddeven">';
1199 $htmltabloflibs .=
'<td>'.img_picto_common($key, $objmodelexport->getPictoForKey($key)).
' ';
1200 $text = $objmodelexport->getDriverDescForKey($key);
1201 $label = $listeall[$key];
1202 $htmltabloflibs .=
$form->textwithpicto($label, $text).
'</td>';
1203 $htmltabloflibs .=
'<td>'.$objmodelexport->getLibLabelForKey($key).
'</td>';
1204 $htmltabloflibs .=
'<td class="right">'.$objmodelexport->getLibVersionForKey($key).
'</td>';
1205 $htmltabloflibs .=
'</tr>'.
"\n";
1207 $htmltabloflibs .=
'</table>';
1209 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NowClickToGenerateToBuildExportFile"), $htmltabloflibs, 1,
'help',
'', 0, 2,
'helphonformat').
'</span>';
1216 if ($sqlusedforexport && $user->admin) {
1217 print
info_admin($langs->trans(
"SQLUsedForExport").
':<br> '.$sqlusedforexport, 0, 0, 1,
'',
'TechnicalInformation');
1221 if (!is_dir($conf->export->dir_temp)) {
1227 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',
'',
'',
'');
1246 $alias = preg_replace(
'/\.(.*)$/i',
'', $code);
1247 $regexstring =
'/([a-zA-Z_]+) as '.preg_quote($alias).
'[, \)]/i';
1249 $newsql = $sqlmaxforexport;
1250 $newsql = preg_replace(
'/^(.*) FROM /i',
'', $newsql);
1251 $newsql = preg_replace(
'/WHERE (.*)$/i',
'', $newsql);
1253 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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_left($titlealt='default', $selected=0, $moreatt='')
Show left arrow logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.