2005-10-30 14:02:38 +00:00
< ? php
2018-12-16 12:36:51 +00:00
/* Copyright ( C ) 2005 - 2018 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 12:43:12 +00:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2012-10-25 20:30:17 +00:00
* Copyright ( C ) 2012 Marcos GarcÃa < marcosgdf @ gmail . com >
* Copyright ( C ) 2012 Charles - Fr BENKE < charles . fr @ benke . fr >
2015-08-25 19:59:46 +00:00
* Copyright ( C ) 2015 Juanjo Menent < jmenent @ 2 byte . es >
2024-09-09 01:15:26 +00:00
* Copyright ( C ) 2024 Frédéric France < frederic . france @ free . fr >
2026-07-01 10:26:51 +00:00
* Copyright ( C ) 2024 - 2026 MDW < mdeweerd @ users . noreply . github . com >
2005-10-30 14:02:38 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 14:36:08 +00:00
* the Free Software Foundation ; either version 3 of the License , or
2005-10-30 14:02:38 +00:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2005-10-30 14:02:38 +00:00
*/
/**
2009-05-19 00:14:27 +00:00
* \file htdocs / exports / export . php
* \ingroup export
2026-07-01 10:26:51 +00:00
* \brief Export Wizard pages
2009-05-19 00:14:27 +00:00
*/
2009-03-03 00:42:40 +00:00
2012-08-22 21:11:24 +00:00
require_once '../main.inc.php' ;
2024-11-04 22:53:20 +00:00
/**
* @ var Conf $conf
* @ var DoliDB $db
* @ var HookManager $hookmanager
* @ var Translate $langs
* @ var User $user
*/
2026-02-07 12:21:53 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/exports/class/export.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/modules/export/modules_export.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2024-11-04 22:53:20 +00:00
2018-05-26 18:51:17 +00:00
// Load translation files required by the page
2020-02-18 11:22:25 +00:00
$langs -> loadlangs ( array ( 'admin' , 'exports' , 'other' , 'users' , 'companies' , 'projects' , 'suppliers' , 'products' , 'bank' , 'bills' ));
2005-10-30 14:02:38 +00:00
2009-05-22 15:57:47 +00:00
// Everybody should be able to go on this page
//if (! $user->admin)
2024-09-09 01:15:26 +00:00
// accessforbidden();
2005-10-30 14:02:38 +00:00
2024-09-09 01:15:26 +00:00
// Map icons, array duplicated in import.php, was not synchronized, TODO put it somewhere only once
2012-08-16 11:07:12 +00:00
$entitytoicon = array (
'invoice' => 'bill' ,
2020-10-31 13:32:18 +00:00
'invoice_line' => 'bill' ,
2012-08-16 11:07:12 +00:00
'order' => 'order' ,
2020-10-31 13:32:18 +00:00
'order_line' => 'order' ,
2012-08-16 11:07:12 +00:00
'propal' => 'propal' ,
2020-10-31 13:32:18 +00:00
'propal_line' => 'propal' ,
2012-08-16 11:07:12 +00:00
'intervention' => 'intervention' ,
2020-10-31 13:32:18 +00:00
'inter_line' => 'intervention' ,
2012-08-16 11:07:12 +00:00
'member' => 'user' ,
2020-10-31 13:32:18 +00:00
'member_type' => 'group' ,
'subscription' => 'payment' ,
'payment' => 'payment' ,
2012-08-16 11:07:12 +00:00
'tax' => 'generic' ,
2021-02-25 21:50:40 +00:00
'tax_type' => 'generic' ,
'other' => 'generic' ,
2012-08-16 11:07:12 +00:00
'account' => 'account' ,
'product' => 'product' ,
2024-04-23 00:19:03 +00:00
'virtualproduct' => 'product' ,
2017-01-29 20:25:29 +00:00
'subproduct' => 'product' ,
2018-05-23 15:48:18 +00:00
'product_supplier_ref' => 'product' ,
2021-02-25 21:50:40 +00:00
'stock' => 'stock' ,
2018-05-23 15:48:18 +00:00
'warehouse' => 'stock' ,
2017-11-24 16:44:19 +00:00
'batch' => 'stock' ,
'stockbatch' => 'stock' ,
2012-08-16 11:07:12 +00:00
'category' => 'category' ,
2024-04-23 00:19:03 +00:00
'securityevent' => 'generic' ,
2012-11-18 14:24:01 +00:00
'shipment' => 'sending' ,
2024-04-23 00:19:03 +00:00
'shipment_line' => 'sending' ,
'reception' => 'sending' ,
'reception_line' => 'sending' ,
'expensereport' => 'trip' ,
'expensereport_line' => 'trip' ,
2018-02-09 15:08:28 +00:00
'holiday' => 'holiday' ,
2020-10-31 13:32:18 +00:00
'contract_line' => 'contract' ,
'translation' => 'generic' ,
'bomm' => 'bom' ,
2023-05-10 11:09:44 +00:00
'bomline' => 'bom' ,
2024-09-23 13:04:16 +00:00
'conferenceorboothattendee' => 'contact' ,
2024-09-27 12:02:21 +00:00
'inventory_line' => 'inventory' ,
2026-02-07 12:21:53 +00:00
'mrp_line' => 'mrp' ,
'task_time' => 'clock' ,
2012-08-16 11:07:12 +00:00
);
2020-12-03 18:45:36 +00:00
// Translation code, array duplicated in import.php, was not synchronized, TODO put it somewhere only once
2012-08-16 11:07:12 +00:00
$entitytolang = array (
'user' => 'User' ,
'company' => 'Company' ,
2020-10-31 13:32:18 +00:00
'contact' => 'Contact' ,
2012-08-16 11:07:12 +00:00
'invoice' => 'Bill' ,
2020-10-31 13:32:18 +00:00
'invoice_line' => 'InvoiceLine' ,
2012-08-16 11:07:12 +00:00
'order' => 'Order' ,
2020-10-31 13:32:18 +00:00
'order_line' => 'OrderLine' ,
'propal' => 'Proposal' ,
'propal_line' => 'ProposalLine' ,
2012-08-16 11:07:12 +00:00
'intervention' => 'Intervention' ,
2020-10-31 13:32:18 +00:00
'inter_line' => 'InterLine' ,
2012-08-16 11:07:12 +00:00
'member' => 'Member' ,
2020-10-31 13:32:18 +00:00
'member_type' => 'MemberType' ,
'subscription' => 'Subscription' ,
2012-08-16 11:07:12 +00:00
'tax' => 'SocialContribution' ,
2020-10-31 13:32:18 +00:00
'tax_type' => 'DictionarySocialContributions' ,
2012-08-16 11:07:12 +00:00
'account' => 'BankTransactions' ,
'payment' => 'Payment' ,
'product' => 'Product' ,
2017-01-29 20:25:29 +00:00
'virtualproduct' => 'AssociatedProducts' ,
'subproduct' => 'SubProduct' ,
2018-05-23 15:48:18 +00:00
'product_supplier_ref' => 'SupplierPrices' ,
'service' => 'Service' ,
2020-10-31 13:32:18 +00:00
'stock' => 'Stock' ,
2017-10-20 12:52:01 +00:00
'movement' => 'StockMovement' ,
2017-11-24 16:44:19 +00:00
'batch' => 'Batch' ,
'stockbatch' => 'StockDetailPerBatch' ,
2015-04-08 16:40:10 +00:00
'warehouse' => 'Warehouse' ,
2012-08-16 11:07:12 +00:00
'category' => 'Category' ,
'other' => 'Other' ,
2020-10-31 13:32:18 +00:00
'trip' => 'TripsAndExpenses' ,
2024-04-23 00:19:03 +00:00
'securityevent' => 'SecurityEvent' ,
2020-10-31 13:32:18 +00:00
'shipment' => 'Shipments' ,
2024-04-23 00:19:03 +00:00
'shipment_line' => 'ShipmentLine' ,
2020-10-31 13:32:18 +00:00
'project' => 'Projects' ,
'projecttask' => 'Tasks' ,
2024-04-29 17:57:05 +00:00
'resource' => 'Resource' ,
2020-10-31 13:32:18 +00:00
'task_time' => 'TaskTimeSpent' ,
2015-03-26 10:20:39 +00:00
'action' => 'Event' ,
2024-04-23 00:19:03 +00:00
'expensereport' => 'ExpenseReport' ,
'expensereport_line' => 'ExpenseReportLine' ,
2018-02-09 15:08:28 +00:00
'holiday' => 'TitreRequestCP' ,
'contract' => 'Contract' ,
2024-04-23 00:19:03 +00:00
'contract_line' => 'ContractLine' ,
2020-10-31 13:32:18 +00:00
'translation' => 'Translation' ,
'bom' => 'BOM' ,
2023-05-10 11:09:44 +00:00
'bomline' => 'BOMLine' ,
2024-09-27 12:02:21 +00:00
'mrp' => 'ManufacturingOrder' ,
2024-09-27 13:33:30 +00:00
'mrp_line' => 'ManufacturingOrderLine' ,
2025-12-02 13:54:10 +00:00
'conferenceorbooth' => 'ConferenceOrBooth' ,
2024-07-17 22:45:23 +00:00
'conferenceorboothattendee' => 'Attendee' ,
2024-09-23 13:04:16 +00:00
'inventory' => 'Inventory' ,
'inventory_line' => 'InventoryLine'
2012-08-16 11:07:12 +00:00
);
2006-02-25 14:26:29 +00:00
2025-10-24 15:11:35 +00:00
2019-11-13 18:35:02 +00:00
$array_selected = isset ( $_SESSION [ " export_selected_fields " ]) ? $_SESSION [ " export_selected_fields " ] : array ();
$array_filtervalue = isset ( $_SESSION [ " export_filtered_fields " ]) ? $_SESSION [ " export_filtered_fields " ] : array ();
$datatoexport = GETPOST ( " datatoexport " , " aZ09 " );
2020-09-16 17:39:50 +00:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-11-13 18:35:02 +00:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
2024-04-23 00:19:03 +00:00
$step = GETPOSTINT ( " step " ) ? GETPOSTINT ( " step " ) : 1 ;
2019-11-13 18:35:02 +00:00
$export_name = GETPOST ( " export_name " , " alphanohtml " );
$hexa = GETPOST ( " hexa " , " alpha " );
2024-04-23 00:19:03 +00:00
$exportmodelid = GETPOSTINT ( " exportmodelid " );
2025-11-07 17:48:05 +00:00
$field = ( string ) GETPOST ( " field " , " alpha " );
2019-11-13 18:35:02 +00:00
$objexport = new Export ( $db );
2019-01-27 10:55:16 +00:00
$objexport -> load_arrays ( $user , $datatoexport );
2006-01-22 16:14:33 +00:00
2025-10-24 15:11:35 +00:00
2019-11-13 18:35:02 +00:00
$objmodelexport = new ModeleExports ( $db );
2011-11-08 09:18:45 +00:00
$form = new Form ( $db );
2008-10-25 17:27:15 +00:00
$htmlother = new FormOther ( $db );
2008-01-20 13:53:02 +00:00
$formfile = new FormFile ( $db );
2019-11-13 18:35:02 +00:00
$sqlusedforexport = '' ;
2005-10-30 14:02:38 +00:00
2020-02-11 09:38:09 +00:00
$head = array ();
2012-10-29 09:36:26 +00:00
$upload_dir = $conf -> export -> dir_temp . '/' . $user -> id ;
2019-11-13 18:35:02 +00:00
$usefilters = 1 ;
2012-11-13 23:27:25 +00:00
2021-03-20 18:30:08 +00:00
// Security check
$result = restrictedArea ( $user , 'export' );
2006-01-08 17:08:20 +00:00
/*
* Actions
*/
2009-03-03 00:42:40 +00:00
2026-07-01 10:26:51 +00:00
if ( $action == 'selectfield' && $user -> hasRight ( 'export' , 'creer' )) { // Select field at step 2
2019-11-13 18:35:02 +00:00
$fieldsarray = $objexport -> array_export_fields [ 0 ];
$fieldsentitiesarray = $objexport -> array_export_entities [ 0 ];
2020-10-31 13:32:18 +00:00
$fieldsdependenciesarray = $objexport -> array_export_dependencies [ 0 ];
2012-07-24 14:19:46 +00:00
2021-02-25 21:50:40 +00:00
if ( $field == 'all' ) {
foreach ( $fieldsarray as $key => $val ) {
if ( ! empty ( $array_selected [ $key ])) {
continue ; // If already selected, check next
}
2019-11-13 18:35:02 +00:00
$array_selected [ $key ] = count ( $array_selected ) + 1 ;
2020-10-31 13:32:18 +00:00
//print_r($array_selected);
$_SESSION [ " export_selected_fields " ] = $array_selected ;
2008-05-16 22:50:38 +00:00
}
2020-10-31 13:32:18 +00:00
} else {
$warnings = array ();
2012-07-27 14:03:20 +00:00
2020-10-31 13:32:18 +00:00
$array_selected [ $field ] = count ( $array_selected ) + 1 ; // We tag the key $field as "selected"
// We check if there is a dependency to activate
/* var_dump ( $field );
2024-04-23 00:19:03 +00:00
var_dump ( $fieldsentitiesarray [ $field ]);
var_dump ( $fieldsdependenciesarray ); */
2020-10-31 13:32:18 +00:00
$listofdependencies = array ();
2021-02-25 21:50:40 +00:00
if ( ! empty ( $fieldsentitiesarray [ $field ]) && ! empty ( $fieldsdependenciesarray [ $fieldsentitiesarray [ $field ]])) {
2026-07-01 10:26:51 +00:00
// Found a dependency on the field type
2020-10-31 13:32:18 +00:00
$tmp = $fieldsdependenciesarray [ $fieldsentitiesarray [ $field ]]; // $fieldsdependenciesarray=array('element'=>'fd.rowid') or array('element'=>array('fd.rowid','ab.rowid'))
2021-02-25 21:50:40 +00:00
if ( is_array ( $tmp )) {
$listofdependencies = $tmp ;
} else {
$listofdependencies = array ( $tmp );
}
} elseif ( ! empty ( $field ) && ! empty ( $fieldsdependenciesarray [ $field ])) {
2026-07-01 10:26:51 +00:00
// Found a dependency on a specific field
2020-10-31 13:32:18 +00:00
$tmp = $fieldsdependenciesarray [ $field ]; // $fieldsdependenciesarray=array('fd.fieldx'=>'fd.rowid') or array('fd.fieldx'=>array('fd.rowid','ab.rowid'))
2021-02-25 21:50:40 +00:00
if ( is_array ( $tmp )) {
$listofdependencies = $tmp ;
} else {
$listofdependencies = array ( $tmp );
}
2020-10-31 13:32:18 +00:00
}
2021-02-25 21:50:40 +00:00
if ( count ( $listofdependencies )) {
foreach ( $listofdependencies as $fieldid ) {
if ( empty ( $array_selected [ $fieldid ])) {
2020-10-31 13:32:18 +00:00
$array_selected [ $fieldid ] = count ( $array_selected ) + 1 ; // We tag the key $fieldid as "selected"
$warnings [] = $langs -> trans ( " ExportFieldAutomaticallyAdded " , $langs -> transnoentitiesnoconv ( $fieldsarray [ $fieldid ]));
}
}
}
//print_r($array_selected);
$_SESSION [ " export_selected_fields " ] = $array_selected ;
2024-09-09 01:15:26 +00:00
setEventMessages ( null , $warnings , 'warnings' );
2020-10-31 13:32:18 +00:00
}
2006-01-08 17:08:20 +00:00
}
2024-09-02 15:48:50 +00:00
if ( $action == 'unselectfield' && $user -> hasRight ( 'export' , 'creer' )) {
2024-04-23 00:19:03 +00:00
if ( GETPOST ( " field " ) == 'all' ) {
2019-11-13 18:35:02 +00:00
$array_selected = array ();
$_SESSION [ " export_selected_fields " ] = $array_selected ;
2020-10-31 13:32:18 +00:00
} else {
2024-04-23 00:19:03 +00:00
unset ( $array_selected [ GETPOST ( " field " )]);
2020-10-31 13:32:18 +00:00
// Renumber fields of array_selected (from 1 to nb_elements)
asort ( $array_selected );
$i = 0 ;
$array_selected_save = $array_selected ;
2021-02-25 21:50:40 +00:00
foreach ( $array_selected as $code => $value ) {
2020-10-31 13:32:18 +00:00
$i ++ ;
$array_selected [ $code ] = $i ;
//print "x $code x $i y<br>";
}
$_SESSION [ " export_selected_fields " ] = $array_selected ;
}
2006-01-21 19:08:36 +00:00
}
2012-10-25 20:30:17 +00:00
2024-09-09 01:15:26 +00:00
$newpos = - 1 ;
2024-09-02 15:48:50 +00:00
if (( $action == 'downfield' || $action == 'upfield' ) && $user -> hasRight ( 'export' , 'creer' )) {
2024-04-23 00:19:03 +00:00
$pos = $array_selected [ GETPOST ( " field " )];
2024-09-03 13:22:50 +00:00
if ( $action == 'downfield' ) { // Test on permission already done
2021-02-25 21:50:40 +00:00
$newpos = $pos + 1 ;
}
2024-09-03 13:22:50 +00:00
if ( $action == 'upfield' ) { // Test on permission already done
2021-02-25 21:50:40 +00:00
$newpos = $pos - 1 ;
}
2024-09-09 01:15:26 +00:00
// Lookup code to switch with
2020-10-31 13:32:18 +00:00
$newcode = " " ;
2021-02-25 21:50:40 +00:00
foreach ( $array_selected as $code => $value ) {
if ( $value == $newpos ) {
2020-10-31 13:32:18 +00:00
$newcode = $code ;
break ;
}
}
2024-04-23 00:19:03 +00:00
//print("Switch pos=$pos (code=".GETPOST("field").") and newpos=$newpos (code=$newcode)");
2021-02-25 21:50:40 +00:00
if ( $newcode ) { // Si newcode trouve (protection contre resoumission de page)
2024-04-23 00:19:03 +00:00
$array_selected [ GETPOST ( " field " )] = $newpos ;
2020-10-31 13:32:18 +00:00
$array_selected [ $newcode ] = $pos ;
$_SESSION [ " export_selected_fields " ] = $array_selected ;
}
2006-01-08 17:08:20 +00:00
}
2006-01-21 19:08:36 +00:00
2024-09-01 18:34:20 +00:00
if ( $step == 1 || $action == 'cleanselect' ) { // Test on permission here not required
2020-10-31 13:32:18 +00:00
$_SESSION [ " export_selected_fields " ] = array ();
$_SESSION [ " export_filtered_fields " ] = array ();
$array_selected = array ();
$array_filtervalue = array ();
2006-01-08 17:08:20 +00:00
}
2005-11-19 22:09:12 +00:00
2024-09-02 15:48:50 +00:00
if ( $action == 'builddoc' && $user -> hasRight ( 'export' , 'lire' )) {
2024-04-23 00:19:03 +00:00
// Check permission
if ( empty ( $objexport -> array_export_perms [ 0 ])) {
accessforbidden ();
}
2023-06-13 00:13:09 +00:00
$separator = GETPOST ( 'delimiter' , 'alpha' );
2024-09-09 12:30:06 +00:00
$max_execution_time_for_importexport = getDolGlobalInt ( 'EXPORT_MAX_EXECUTION_TIME' , 300 ); // 5mn if not defined
2020-10-31 13:32:18 +00:00
$max_time = @ ini_get ( " max_execution_time " );
2021-02-25 21:50:40 +00:00
if ( $max_time && $max_time < $max_execution_time_for_importexport ) {
2021-02-03 17:00:27 +00:00
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. " );
@ ini_set ( " max_execution_time " , $max_execution_time_for_importexport ); // This work only if safe mode is off. also web servers has timeout of 300
2020-10-31 13:32:18 +00:00
}
// Build export file
2023-06-13 00:13:09 +00:00
$result = $objexport -> build_file ( $user , GETPOST ( 'model' , 'alpha' ), $datatoexport , $array_selected , $array_filtervalue , '' , $separator );
2021-02-25 21:50:40 +00:00
if ( $result < 0 ) {
2015-12-08 10:35:08 +00:00
setEventMessages ( $objexport -> error , $objexport -> errors , 'errors' );
2019-11-13 18:35:02 +00:00
$sqlusedforexport = $objexport -> sqlusedforexport ;
2020-05-21 13:05:19 +00:00
} else {
2015-12-08 10:35:08 +00:00
setEventMessages ( $langs -> trans ( " FileSuccessfullyBuilt " ), null , 'mesgs' );
2020-10-31 13:32:18 +00:00
$sqlusedforexport = $objexport -> sqlusedforexport ;
}
2006-01-21 19:08:36 +00:00
}
2012-10-29 09:36:26 +00:00
// Delete file
2024-09-09 12:34:49 +00:00
if ( $step == 5 && $action == 'confirm_deletefile' && $confirm == 'yes' && $user -> hasRight ( 'export' , 'lire' )) {
2024-04-23 00:19:03 +00:00
// Check permission
if ( empty ( $objexport -> array_export_perms [ 0 ])) {
accessforbidden ();
}
$file = $upload_dir . " / " . GETPOST ( 'file' );
2012-10-29 09:36:26 +00:00
2026-07-29 11:20:28 +00:00
$ret = dol_delete_file ( $file , 1 );
2021-02-25 21:50:40 +00:00
if ( $ret ) {
setEventMessages ( $langs -> trans ( " FileWasRemoved " , GETPOST ( 'file' )), null , 'mesgs' );
} else {
setEventMessages ( $langs -> trans ( " ErrorFailToDeleteFile " , GETPOST ( 'file' )), null , 'errors' );
}
2012-10-29 09:36:26 +00:00
header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?step=' . $step . '&datatoexport=' . $datatoexport );
exit ;
}
2024-09-09 12:34:49 +00:00
if ( $action == 'deleteprof' && $user -> hasRight ( 'export' , 'lire' )) {
2024-04-23 00:19:03 +00:00
// Check permission
if ( empty ( $objexport -> array_export_perms [ 0 ])) {
accessforbidden ();
}
if ( GETPOSTINT ( " id " )) {
$objexport -> fetch ( GETPOSTINT ( 'id' ));
2019-11-13 18:35:02 +00:00
$result = $objexport -> delete ( $user );
2008-12-04 20:27:01 +00:00
}
}
2012-11-21 19:24:15 +00:00
// TODO The export for filter is not yet implemented (old code created conflicts with step 2). We must use same way of working and same combo list of predefined export than step 2.
2024-09-09 12:34:49 +00:00
if ( $action == 'add_export_model' && $user -> hasRight ( 'export' , 'lire' )) {
2024-04-23 00:19:03 +00:00
// Check permission
if ( empty ( $objexport -> array_export_perms [ 0 ])) {
accessforbidden ();
}
2021-02-25 21:50:40 +00:00
if ( $export_name ) {
2007-03-24 16:46:02 +00:00
asort ( $array_selected );
// Set save string
2019-11-13 18:35:02 +00:00
$hexa = '' ;
2021-02-25 21:50:40 +00:00
foreach ( $array_selected as $key => $val ) {
if ( $hexa ) {
$hexa .= ',' ;
}
2019-11-13 18:35:02 +00:00
$hexa .= $key ;
2007-03-24 16:46:02 +00:00
}
2019-11-13 18:35:02 +00:00
$hexafiltervalue = '' ;
2021-02-25 21:50:40 +00:00
if ( ! empty ( $array_filtervalue ) && is_array ( $array_filtervalue )) {
foreach ( $array_filtervalue as $key => $val ) {
if ( $hexafiltervalue ) {
$hexafiltervalue .= ',' ;
}
2019-11-13 18:35:02 +00:00
$hexafiltervalue .= $key . '=' . $val ;
2015-06-24 16:29:29 +00:00
}
2012-10-25 20:30:17 +00:00
}
2015-07-29 10:10:04 +00:00
2020-10-31 13:32:18 +00:00
$objexport -> model_name = $export_name ;
$objexport -> datatoexport = $datatoexport ;
$objexport -> hexa = $hexa ;
$objexport -> hexafiltervalue = $hexafiltervalue ;
2021-06-21 13:03:45 +00:00
$objexport -> fk_user = ( GETPOST ( 'visibility' , 'aZ09' ) == 'all' ? 0 : $user -> id );
2009-03-03 00:42:40 +00:00
2020-10-31 13:32:18 +00:00
$result = $objexport -> create ( $user );
2021-02-25 21:50:40 +00:00
if ( $result >= 0 ) {
2019-01-27 10:55:16 +00:00
setEventMessages ( $langs -> trans ( " ExportModelSaved " , $objexport -> model_name ), null , 'mesgs' );
2020-05-21 13:05:19 +00:00
} else {
2008-12-04 20:27:01 +00:00
$langs -> load ( " errors " );
2021-02-25 21:50:40 +00:00
if ( $objexport -> errno == 'DB_ERROR_RECORD_ALREADY_EXISTS' ) {
2015-12-08 10:35:08 +00:00
setEventMessages ( $langs -> trans ( " ErrorExportDuplicateProfil " ), null , 'errors' );
2021-02-25 21:50:40 +00:00
} else {
setEventMessages ( $objexport -> error , $objexport -> errors , 'errors' );
}
2007-03-24 16:46:02 +00:00
}
2020-05-21 13:05:19 +00:00
} else {
2015-10-17 15:09:34 +00:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " ExportModelName " )), null , 'errors' );
2007-03-24 16:46:02 +00:00
}
2007-03-23 17:58:06 +00:00
}
2019-06-21 11:25:40 +00:00
// Reload a predefined export model
2024-09-09 12:34:49 +00:00
if ( $step == 2 && $action == 'select_model' && $user -> hasRight ( 'export' , 'lire' )) {
2020-10-31 13:32:18 +00:00
$_SESSION [ " export_selected_fields " ] = array ();
$_SESSION [ " export_filtered_fields " ] = array ();
2012-10-25 20:30:17 +00:00
2020-10-31 13:32:18 +00:00
$array_selected = array ();
$array_filtervalue = array ();
2012-10-25 20:30:17 +00:00
2020-10-31 13:32:18 +00:00
$result = $objexport -> fetch ( $exportmodelid );
2021-02-25 21:50:40 +00:00
if ( $result > 0 ) {
2020-01-19 18:01:46 +00:00
$fieldsarray = preg_split ( " /,(?! [^(]* \ ))/ " , $objexport -> hexa );
2019-11-13 18:35:02 +00:00
$i = 1 ;
2021-02-25 21:50:40 +00:00
foreach ( $fieldsarray as $val ) {
2019-11-13 18:35:02 +00:00
$array_selected [ $val ] = $i ;
2007-03-24 16:46:02 +00:00
$i ++ ;
}
2019-11-13 18:35:02 +00:00
$_SESSION [ " export_selected_fields " ] = $array_selected ;
2012-10-25 20:30:17 +00:00
2019-11-13 18:35:02 +00:00
$fieldsarrayvalue = explode ( ',' , $objexport -> hexafiltervalue );
$i = 1 ;
2021-02-25 21:50:40 +00:00
foreach ( $fieldsarrayvalue as $val ) {
2019-11-13 18:35:02 +00:00
$tmp = explode ( '=' , $val );
$array_filtervalue [ $tmp [ 0 ]] = $tmp [ 1 ];
2012-10-25 20:30:17 +00:00
$i ++ ;
}
2019-11-13 18:35:02 +00:00
$_SESSION [ " export_filtered_fields " ] = $array_filtervalue ;
2020-10-31 13:32:18 +00:00
}
2007-03-23 17:58:06 +00:00
}
2012-11-20 14:56:44 +00:00
// Get form with filters
2024-09-09 12:34:49 +00:00
if ( $step == 4 && $action == 'submitFormField' && $user -> hasRight ( 'export' , 'lire' )) {
2024-04-23 00:19:03 +00:00
// Check permission
if ( empty ( $objexport -> array_export_perms [ 0 ])) {
accessforbidden ();
}
2026-07-01 10:26:51 +00:00
// loop over selected fields to retrieve the value
2021-02-25 21:50:40 +00:00
if ( is_array ( $objexport -> array_export_TypeFields [ 0 ])) {
2019-11-13 18:35:02 +00:00
$_SESSION [ " export_filtered_fields " ] = array ();
2021-02-25 21:50:40 +00:00
foreach ( $objexport -> array_export_TypeFields [ 0 ] as $code => $type ) { // $code: s.fieldname $value: Text|Boolean|List:ccc
2019-11-13 18:35:02 +00:00
$newcode = ( string ) preg_replace ( '/\./' , '_' , $code );
2022-02-22 22:44:56 +00:00
//print 'xxx '.$code."=".$newcode."=".$type."=".GETPOST($newcode)."\n<br>";
2022-01-26 11:53:06 +00:00
$check = 'alphanohtml' ;
2019-11-13 18:35:02 +00:00
$filterqualified = 1 ;
2022-01-26 11:53:06 +00:00
if ( ! GETPOSTISSET ( $newcode ) || GETPOST ( $newcode , $check ) == '' ) {
2021-02-25 21:50:40 +00:00
$filterqualified = 0 ;
2022-01-26 11:53:06 +00:00
} elseif ( preg_match ( '/^List/' , $type ) && ( is_numeric ( GETPOST ( $newcode , $check )) && GETPOST ( $newcode , $check ) <= 0 )) {
2021-02-25 21:50:40 +00:00
$filterqualified = 0 ;
}
if ( $filterqualified ) {
2022-01-26 11:53:06 +00:00
$objexport -> array_export_FilterValue [ 0 ][ $code ] = GETPOST ( $newcode , $check );
2012-11-20 14:56:44 +00:00
}
2012-10-25 20:30:17 +00:00
}
2019-11-13 18:35:02 +00:00
$array_filtervalue = ( ! empty ( $objexport -> array_export_FilterValue [ 0 ]) ? $objexport -> array_export_FilterValue [ 0 ] : '' );
$_SESSION [ " export_filtered_fields " ] = $array_filtervalue ;
2012-10-25 20:30:17 +00:00
}
}
2006-01-21 19:08:36 +00:00
/*
2009-08-12 12:59:14 +00:00
* View
2006-01-21 19:08:36 +00:00
*/
2005-11-19 22:09:12 +00:00
2021-02-25 21:50:40 +00:00
if ( $step == 1 || ! $datatoexport ) {
2024-06-09 09:49:18 +00:00
llxHeader ( '' , $langs -> trans ( " NewExport " ), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones' , '' , 0 , 0 , '' , '' , '' , 'mod-exports page-export action-step1' );
2020-10-31 13:32:18 +00:00
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=1' ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 1 " ;
2024-09-10 12:58:36 +00:00
$hselected = ( string ) $h ;
2020-10-31 13:32:18 +00:00
$h ++ ;
2025-06-23 01:36:27 +00:00
print dol_get_fiche_head ( $head , $hselected , 'Export' , - 1 , 'download' );
2020-10-31 13:32:18 +00:00
2025-08-20 15:47:24 +00:00
print '<div class="opacitymedium">' . $langs -> trans ( " SelectExportDataSet " ) . '</div>' ;
2020-10-31 13:32:18 +00:00
2025-08-20 15:57:08 +00:00
// Define $nbmodulesnotautoenabled - TODO This code is at different places
$nbmodulesnotautoenabled = count ( $conf -> modules );
2025-10-09 11:13:51 +00:00
$listofmodulesautoenabled = array ( 'user' , 'agenda' , 'fckeditor' , 'export' , 'import' );
2025-08-20 15:57:08 +00:00
foreach ( $listofmodulesautoenabled as $moduleautoenable ) {
if ( in_array ( $moduleautoenable , $conf -> modules )) {
$nbmodulesnotautoenabled -- ;
}
}
2025-10-09 11:13:51 +00:00
if ( $user -> admin && $nbmodulesnotautoenabled < getDolGlobalInt ( 'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING' , 1 )) { // If only minimal initial modules enabled
2025-08-20 15:47:24 +00:00
print info_admin ( $langs -> trans ( " WarningOnlyProfilesOfActivatedModules " ) . ' ' . $langs -> trans ( " YouCanEnableModulesFrom " ));
}
print '<br>' ;
// Show profiles for export
2024-04-23 00:19:03 +00:00
print '<div class="div-table-responsive-no-min">' ; // You can use div-table-responsive-no-min if you don't need reserved height for your table
2024-12-18 11:21:54 +00:00
print '<table class="noborder centpercent nomarginbottom">' ;
2020-10-31 13:32:18 +00:00
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Module " ) . '</td>' ;
print '<td>' . $langs -> trans ( " ExportableDatas " ) . '</td>' ;
print '<td> </td>' ;
print '</tr>' ;
2021-02-25 21:50:40 +00:00
if ( count ( $objexport -> array_export_module )) {
2020-12-13 15:27:44 +00:00
asort ( $objexport -> array_export_code_for_sort );
//var_dump($objexport->array_export_code_for_sort);
//$sortedarrayofmodules = dol_sort_array($objexport->array_export_module, 'module_position', 'asc', 0, 0, 1);
2021-02-25 21:50:40 +00:00
foreach ( $objexport -> array_export_code_for_sort as $key => $value ) {
2024-12-18 11:21:54 +00:00
$titleofmodule = $objexport -> array_export_module [ $key ] -> getName ();
print '<tr class="oddeven"><td class="tdoverflowmax200" title="' . dolPrintHTML ( $titleofmodule ) . '">' ;
print dolPrintHTML ( $titleofmodule );
2020-10-31 13:32:18 +00:00
print '</td><td>' ;
2020-12-03 18:45:36 +00:00
$entity = preg_replace ( '/:.*$/' , '' , $objexport -> array_export_icon [ $key ]);
$entityicon = strtolower ( ! empty ( $entitytoicon [ $entity ]) ? $entitytoicon [ $entity ] : $entity );
2019-11-13 18:35:02 +00:00
$label = $objexport -> array_export_label [ $key ];
2024-12-18 11:21:54 +00:00
print '<div class="twolinesmax-normallineheight minwidth200onall">' ;
print img_object ( $objexport -> array_export_module [ $key ] -> getName (), $entityicon , 'class="pictofixedwidth"' );
print dolPrintHTML ( $label );
print '</div>' ;
2020-10-31 13:32:18 +00:00
print '</td><td class="right">' ;
2020-12-13 15:27:44 +00:00
if ( $objexport -> array_export_perms [ $key ]) {
2022-09-01 08:54:20 +00:00
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>' ;
2020-10-31 13:32:18 +00:00
} else {
2021-03-20 18:16:44 +00:00
print '<span class="opacitymedium">' . $langs -> trans ( " NotEnoughPermissions " ) . '</span>' ;
2020-10-31 13:32:18 +00:00
}
2021-02-25 21:50:40 +00:00
print '</td></tr>' ;
2020-10-31 13:32:18 +00:00
}
} else {
print '<tr><td class="oddeven" colspan="3">' . $langs -> trans ( " NoExportableData " ) . '</td></tr>' ;
}
print '</table>' ;
print '</div>' ;
print '</div>' ;
2005-11-19 22:09:12 +00:00
}
2021-02-25 21:50:40 +00:00
if ( $step == 2 && $datatoexport ) {
2024-04-23 00:19:03 +00:00
// Check permission
if ( empty ( $objexport -> array_export_perms [ 0 ])) {
accessforbidden ();
}
2024-06-09 09:49:18 +00:00
llxHeader ( '' , $langs -> trans ( " NewExport " ), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones' , '' , 0 , 0 , '' , '' , '' , 'mod-exports page-export action-step2' );
2008-04-01 12:09:33 +00:00
2020-10-31 13:32:18 +00:00
$h = 0 ;
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=1' ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 1 " ;
$h ++ ;
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 2 " ;
2024-09-10 12:58:36 +00:00
$hselected = ( string ) $h ;
2020-10-31 13:32:18 +00:00
$h ++ ;
2009-03-03 00:42:40 +00:00
2025-06-23 01:36:27 +00:00
print dol_get_fiche_head ( $head , $hselected , 'Export' , - 2 , 'download' );
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2019-03-04 09:42:09 +00:00
2024-09-27 12:49:29 +00:00
print '<table class="border tableforfield centpercent">' ;
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
// Module
print '<tr><td class="titlefield">' . $langs -> trans ( " Module " ) . '</td>' ;
print '<td>' ;
print $objexport -> array_export_module [ 0 ] -> getName ();
print '</td></tr>' ;
2006-01-08 17:08:20 +00:00
2026-07-01 10:26:51 +00:00
// Dataset to export
2021-02-25 21:50:40 +00:00
print '<tr><td>' . $langs -> trans ( " DatasetToExport " ) . '</td>' ;
print '<td>' ;
$entity = preg_replace ( '/:.*$/' , '' , $objexport -> array_export_icon [ 0 ]);
$entityicon = strtolower ( ! empty ( $entitytoicon [ $entity ]) ? $entitytoicon [ $entity ] : $entity );
print img_object ( $objexport -> array_export_module [ 0 ] -> getName (), $entityicon ) . ' ' ;
print $objexport -> array_export_label [ 0 ];
print '</td></tr>' ;
2020-10-31 13:32:18 +00:00
print '</table>' ;
print '</div>' ;
print dol_get_fiche_end ();
print '<br>' ;
// Combo list of export models
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="post">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="select_model">' ;
print '<input type="hidden" name="step" value="2">' ;
print '<input type="hidden" name="datatoexport" value="' . $datatoexport . '">' ;
print '<div class="valignmiddle marginbottomonly">' ;
print '<span class="opacitymedium">' . $langs -> trans ( " SelectExportFields " ) . '</span> ' ;
2026-03-09 19:23:03 +00:00
$htmlother -> select_export_model (( string ) $exportmodelid , 'exportmodelid' , $datatoexport , 1 , $user -> id );
2020-10-31 13:32:18 +00:00
print ' ' ;
2026-03-09 19:23:03 +00:00
print '<input type="submit" name="applyprofile" id="applyprofile" class="button smallpaddingimp hidden" value="' . $langs -> trans ( " Apply " ) . '">' ;
// Add js to show button
if ( ! empty ( $conf -> use_javascript_ajax )) {
print ' < script >
$ ( document ) . ready ( function () {
// hide button
$ ( " #applyprofile " ) . hide ();
// follow change on list
$ ( " #exportmodelid " ) . change ( function () {
console . log ( " We select a new profile " );
2026-03-10 10:33:18 +00:00
if ( $ ( this ) . val () && $ ( this ) . val () != " -1 " ) {
2026-03-09 19:23:03 +00:00
$ ( " #applyprofile " ) . show ();
} else {
$ ( " #applyprofile " ) . hide ();
}
});
});
</ script >
' ;
}
2020-10-31 13:32:18 +00:00
print '</div>' ;
print '</form>' ;
2024-04-23 00:19:03 +00:00
print '<div class="div-table-responsive-no-min">' ; // You can use div-table-responsive-no-min if you don't need reserved height for your table
2020-10-31 13:32:18 +00:00
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre">' ;
2023-05-10 11:09:44 +00:00
print '<td>' . $langs -> trans ( " Object " ) . '</td>' ;
2020-10-31 13:32:18 +00:00
print '<td>' . $langs -> trans ( " ExportableFields " ) . '</td>' ;
print '<td width="100" class="center">' ;
2024-09-27 12:49:29 +00:00
$morecss = '' ;
$moretitle = '' ;
if ( ! $user -> hasRight ( 'export' , 'creer' )) {
$morecss = ' disabled' ;
$moretitle = $langs -> trans ( " NotAllowed " );
}
2026-03-09 18:57:55 +00:00
print '<a class="liste_titre button small nopaddingimp ' . $morecss ;
print '" title="' . $langs -> trans ( " All " ) . ( $moretitle ? ' - ' . $moretitle : '' ) . '" href="' . $_SERVER [ " PHP_SELF " ] . '?step=2&datatoexport=' . urlencode ( $datatoexport ) . '&action=selectfield&field=all&token=' . newToken () . '">' . $langs -> trans ( " All " );
print ' ' . img_right ( $moretitle , 0 , 'style="max-width: 20px"' );
print " </a> " ;
//print ' / ';
print '<a class="liste_titre button small nopaddingimp' . $morecss ;
print '" title="' . $langs -> trans ( " None " ) . ( $moretitle ? ' - ' . $moretitle : '' ) . '" href="' . $_SERVER [ " PHP_SELF " ] . '?step=2&datatoexport=' . urlencode ( $datatoexport ) . '&action=unselectfield&field=all&token=' . newToken () . '">' ;
print img_left ( $moretitle , 0 , 'style="max-width: 20px"' ) . ' ' ;
print $langs -> trans ( " None " ) . " </a> " ;
2020-10-31 13:32:18 +00:00
print '</td>' ;
print '<td width="44%">' . $langs -> trans ( " ExportedFields " ) . '</td>' ;
print '</tr>' ;
// Champs exportables
$fieldsarray = $objexport -> array_export_fields [ 0 ];
// Select request if all fields are selected
$sqlmaxforexport = $objexport -> build_sql ( 0 , array (), array ());
2006-01-08 17:08:20 +00:00
2012-11-13 23:27:25 +00:00
// $this->array_export_module[0]=$module;
// $this->array_export_code[0]=$module->export_code[$r];
// $this->array_export_label[0]=$module->export_label[$r];
// $this->array_export_sql[0]=$module->export_sql[$r];
// $this->array_export_fields[0]=$module->export_fields_array[$r];
// $this->array_export_entities[0]=$module->export_fields_entities[$r];
// $this->array_export_alias[0]=$module->export_fields_alias[$r];
2009-03-03 00:42:40 +00:00
2020-10-31 13:32:18 +00:00
$i = 0 ;
2021-02-25 21:50:40 +00:00
foreach ( $fieldsarray as $code => $label ) {
2020-10-31 13:32:18 +00:00
print '<tr class="oddeven">' ;
$i ++ ;
$entity = ( ! empty ( $objexport -> array_export_entities [ 0 ][ $code ]) ? $objexport -> array_export_entities [ 0 ][ $code ] : $objexport -> array_export_icon [ 0 ]);
$entityicon = strtolower ( ! empty ( $entitytoicon [ $entity ]) ? $entitytoicon [ $entity ] : $entity );
$entitylang = ( ! empty ( $entitytolang [ $entity ]) ? $entitytolang [ $entity ] : $entity );
2025-11-11 20:49:48 +00:00
print '<td class="nowraponall">' ;
2020-10-31 13:32:18 +00:00
// If value of entityicon=entitylang='icon:Label'
//print $code.'-'.$label.'-'.$entity;
$tmparray = explode ( ':' , $entityicon );
2021-02-25 21:50:40 +00:00
if ( count ( $tmparray ) >= 2 ) {
2020-10-31 13:32:18 +00:00
$entityicon = $tmparray [ 0 ];
$entitylang = $tmparray [ 1 ];
}
2025-02-01 14:53:36 +00:00
print img_object ( '' , $entityicon ) . ' ' . $langs -> trans (( string ) $entitylang );
2020-10-31 13:32:18 +00:00
print '</td>' ;
2024-09-27 12:49:29 +00:00
$text = ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '<i>' );
$tmplabelarray = explode ( ':' , $label );
if ( ! empty ( $tmplabelarray [ 1 ])) {
$text .= $langs -> trans ( $tmplabelarray [ 0 ]) . ' - ' . $langs -> trans ( $tmplabelarray [ 1 ]);
} else {
$text .= $langs -> trans ( $label );
}
2025-02-01 14:53:36 +00:00
$text .= ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '</i>' );
2020-10-31 13:32:18 +00:00
$tablename = getablenamefromfield ( $code , $sqlmaxforexport );
$htmltext = '<b>' . $langs -> trans ( " Name " ) . " :</b> " . $text . '<br>' ;
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_special [ 0 ][ $code ])) {
2026-07-03 00:22:39 +00:00
$htmltext .= '<b>' . $langs -> trans ( " ComputedField " ) . " -> " . $langs -> trans ( " Method " ) . " :</b> " ;
if ( isset ( $objexport -> array_export_special [ 0 ][ $code ][ 'method' ])) {
$htmltext .= $objexport -> array_export_special [ 0 ][ $code ][ 'method' ];
} elseif ( ! is_array ( $objexport -> array_export_special [ 0 ][ $code ])) {
$htmltext .= $objexport -> array_export_special [ 0 ][ $code ];
}
$htmltext .= " <br> " ;
2020-10-31 13:32:18 +00:00
} else {
$htmltext .= '<b>' . $langs -> trans ( " Table " ) . " -> " . $langs -> trans ( " Field " ) . " :</b> " . $tablename . " -> " . preg_replace ( '/^.*\./' , '' , $code ) . " <br> " ;
}
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_examplevalues [ 0 ][ $code ])) {
2020-10-31 13:32:18 +00:00
$htmltext .= '<b>' . $langs -> trans ( " SourceExample " ) . ':</b> ' . $objexport -> array_export_examplevalues [ 0 ][ $code ] . '<br>' ;
2015-09-10 10:34:00 +00:00
}
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_TypeFields [ 0 ][ $code ])) {
2020-10-31 13:32:18 +00:00
$htmltext .= '<b>' . $langs -> trans ( " Type " ) . ':</b> ' . $objexport -> array_export_TypeFields [ 0 ][ $code ] . '<br>' ;
2017-06-13 16:50:31 +00:00
}
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_help [ 0 ][ $code ])) {
2019-12-23 11:24:27 +00:00
$htmltext .= '<b>' . $langs -> trans ( " Help " ) . ':</b> ' . $langs -> trans ( $objexport -> array_export_help [ 0 ][ $code ]) . '<br>' ;
}
2017-06-13 16:50:31 +00:00
2021-02-25 21:50:40 +00:00
if ( isset ( $array_selected [ $code ]) && $array_selected [ $code ]) {
2020-10-31 13:32:18 +00:00
// Selected fields
print '<td> </td>' ;
2024-09-27 12:49:29 +00:00
print '<td class="center"><a class="reposition' . $morecss . '" href="' . $_SERVER [ " PHP_SELF " ] . '?step=2&datatoexport=' . urlencode ( $datatoexport ) . '&action=unselectfield&token=' . newToken () . '&field=' . urlencode ( $code ) . '">' . img_left ( $moretitle , 0 , 'style="max-width: 20px"' ) . '</a></td>' ;
2020-10-31 13:32:18 +00:00
print '<td>' ;
//print $text.'-'.$htmltext."<br>";
print $form -> textwithpicto ( $text , $htmltext );
2009-10-03 12:08:48 +00:00
//print ' ('.$code.')';
2020-10-31 13:32:18 +00:00
print '</td>' ;
} else {
// Fields not selected
print '<td>' ;
2011-02-05 18:40:52 +00:00
//print $text.'-'.$htmltext."<br>";
2019-01-27 10:55:16 +00:00
print $form -> textwithpicto ( $text , $htmltext );
2009-10-03 12:08:48 +00:00
//print ' ('.$code.')';
2020-10-31 13:32:18 +00:00
print '</td>' ;
2024-09-27 12:49:29 +00:00
print '<td class="center"><a class="reposition' . $morecss . '" href="' . $_SERVER [ " PHP_SELF " ] . '?step=2&datatoexport=' . urlencode ( $datatoexport ) . '&action=selectfield&token=' . newToken () . '&field=' . urlencode ( $code ) . '">' . img_right ( $moretitle , 0 , 'style="max-width: 20px"' ) . '</a></td>' ;
2020-10-31 13:32:18 +00:00
print '<td> </td>' ;
}
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
print '</tr>' ;
}
2007-03-23 17:58:06 +00:00
2020-10-31 13:32:18 +00:00
print '</table>' ;
print '</div>' ;
2017-06-13 16:50:31 +00:00
2020-10-31 13:32:18 +00:00
/*
2021-03-16 03:22:55 +00:00
* Action bar
2021-02-25 21:50:40 +00:00
*/
2020-10-31 13:32:18 +00:00
print '<div class="tabsAction tabsActionNoBottom">' ;
2006-01-08 17:08:20 +00:00
2021-02-25 21:50:40 +00:00
if ( count ( $array_selected )) {
2012-10-25 20:30:17 +00:00
// If filters exist
2021-02-25 21:50:40 +00:00
if ( $usefilters && isset ( $objexport -> array_export_TypeFields [ 0 ]) && is_array ( $objexport -> array_export_TypeFields [ 0 ])) {
2012-10-25 20:30:17 +00:00
print '<a class="butAction" href="export.php?step=3&datatoexport=' . $datatoexport . '">' . $langs -> trans ( " NextStep " ) . '</a>' ;
2020-05-21 13:05:19 +00:00
} else {
2012-10-25 20:30:17 +00:00
print '<a class="butAction" href="export.php?step=4&datatoexport=' . $datatoexport . '">' . $langs -> trans ( " NextStep " ) . '</a>' ;
}
2020-05-21 13:05:19 +00:00
} else {
2018-11-13 20:40:17 +00:00
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " SelectAtLeastOneField " )) . '">' . $langs -> trans ( " NextStep " ) . '</a>' ;
2007-03-24 16:46:02 +00:00
}
2009-03-03 00:42:40 +00:00
2020-10-31 13:32:18 +00:00
print '</div>' ;
2006-01-08 17:08:20 +00:00
}
2021-02-25 21:50:40 +00:00
if ( $step == 3 && $datatoexport ) {
if ( count ( $array_selected ) < 1 ) { // This occurs when going back to page after sessecion expired
2020-10-31 13:32:18 +00:00
// Switch to step 2
header ( " Location: " . DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport );
exit ;
}
2016-07-15 12:14:55 +00:00
2024-04-23 00:19:03 +00:00
// Check permission
if ( empty ( $objexport -> array_export_perms [ 0 ])) {
accessforbidden ();
}
2024-06-09 09:49:18 +00:00
llxHeader ( '' , $langs -> trans ( " NewExport " ), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones' , '' , 0 , 0 , '' , '' , '' , 'mod-exports page-export action-step3' );
2012-10-25 20:30:17 +00:00
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=1' ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 1 " ;
$h ++ ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 2 " ;
$h ++ ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=3&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 3 " ;
2024-09-10 12:58:36 +00:00
$hselected = ( string ) $h ;
2012-10-25 20:30:17 +00:00
$h ++ ;
2025-06-23 01:36:27 +00:00
print dol_get_fiche_head ( $head , $hselected , 'Export' , - 2 , 'download' );
2012-10-25 20:30:17 +00:00
2020-10-31 13:32:18 +00:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2024-11-04 17:31:23 +00:00
print '<table class="border tableforfield centpercent">' ;
2012-10-25 20:30:17 +00:00
// Module
2017-03-16 19:33:51 +00:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Module " ) . '</td>' ;
2012-10-25 20:30:17 +00:00
print '<td>' ;
//print img_object($objexport->array_export_module[0]->getName(),$objexport->array_export_module[0]->picto).' ';
print $objexport -> array_export_module [ 0 ] -> getName ();
print '</td></tr>' ;
2026-03-09 19:23:03 +00:00
// Dataset to export
2017-03-16 19:33:51 +00:00
print '<tr><td>' . $langs -> trans ( " DatasetToExport " ) . '</td>' ;
2012-10-25 20:30:17 +00:00
print '<td>' ;
2020-12-03 18:45:36 +00:00
$entity = preg_replace ( '/:.*$/' , '' , $objexport -> array_export_icon [ 0 ]);
$entityicon = strtolower ( ! empty ( $entitytoicon [ $entity ]) ? $entitytoicon [ $entity ] : $entity );
print img_object ( $objexport -> array_export_module [ 0 ] -> getName (), $entityicon ) . ' ' ;
print $objexport -> array_export_label [ 0 ];
2012-10-25 20:30:17 +00:00
print '</td></tr>' ;
2024-09-02 16:13:04 +00:00
// List of exported fields
2017-03-16 19:33:51 +00:00
print '<tr><td>' . $langs -> trans ( " ExportedFields " ) . '</td>' ;
2019-11-13 18:35:02 +00:00
$list = '' ;
2021-02-25 21:50:40 +00:00
foreach ( $array_selected as $code => $value ) {
2024-09-02 16:13:04 +00:00
if ( isset ( $objexport -> array_export_fields [ 0 ][ $code ])) {
$list .= ( ! empty ( $list ) ? ', ' : '' );
2024-09-27 12:49:29 +00:00
$tmplabelarray = explode ( ':' , $objexport -> array_export_fields [ 0 ][ $code ]);
if ( ! empty ( $tmplabelarray [ 1 ])) {
$list .= $langs -> trans ( $tmplabelarray [ 0 ]) . ' - ' . $langs -> trans ( $tmplabelarray [ 1 ]);
} else {
$list .= $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]);
}
2024-09-02 16:13:04 +00:00
}
2012-10-25 20:30:17 +00:00
}
2026-03-10 10:33:18 +00:00
print '<td><span class="small">' . $list . '</span></td>' ;
print '</tr>' ;
2012-10-25 20:30:17 +00:00
print '</table>' ;
2017-03-16 19:33:51 +00:00
print '</div>' ;
2017-06-13 16:50:31 +00:00
2024-11-04 17:31:23 +00:00
print '<br><br>' ;
2012-10-25 20:30:17 +00:00
// Combo list of export models
2026-03-09 19:23:03 +00:00
print '<span class="opacitymedium">' . $langs -> trans ( " SelectFilterFields " ) . '...</span><br><br>' ;
2012-11-13 23:27:25 +00:00
2012-10-25 20:30:17 +00:00
2026-07-01 10:26:51 +00:00
// An extra form to get the filters
2012-11-13 23:27:25 +00:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '?step=4&action=submitFormField&datatoexport=' . $datatoexport . '" name="FilterField" method="post">' ;
2019-12-18 22:12:31 +00:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-03-04 09:42:09 +00:00
2024-04-23 00:19:03 +00:00
print '<div class="div-table-responsive-no-min">' ; // You can use div-table-responsive-no-min if you don't need reserved height for your table
2019-03-07 13:13:38 +00:00
2020-10-31 13:32:18 +00:00
print '<table class="noborder centpercent">' ;
2012-10-25 20:30:17 +00:00
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Entities " ) . '</td>' ;
2012-11-13 23:27:25 +00:00
print '<td>' . $langs -> trans ( " ExportableFields " ) . '</td>' ;
2012-10-25 20:30:17 +00:00
print '<td width="25%">' . $langs -> trans ( " FilteredFieldsValues " ) . '</td>' ;
print '</tr>' ;
2026-01-29 18:21:34 +00:00
// Field we can export
2019-11-13 18:35:02 +00:00
$fieldsarray = $objexport -> array_export_fields [ 0 ];
2026-01-29 18:21:34 +00:00
// Field that can be filtered
2019-11-13 18:35:02 +00:00
$Typefieldsarray = $objexport -> array_export_TypeFields [ 0 ];
2026-01-29 18:21:34 +00:00
// Value of filters
2019-11-13 18:35:02 +00:00
$ValueFiltersarray = ( ! empty ( $objexport -> array_export_FilterValue [ 0 ]) ? $objexport -> array_export_FilterValue [ 0 ] : '' );
2012-10-25 20:30:17 +00:00
// Select request if all fields are selected
2019-11-13 18:35:02 +00:00
$sqlmaxforexport = $objexport -> build_sql ( 0 , array (), array ());
2012-10-25 20:30:17 +00:00
$i = 0 ;
2026-01-29 18:21:34 +00:00
// We loop on fields
2021-02-25 21:50:40 +00:00
foreach ( $fieldsarray as $code => $label ) {
2017-04-14 09:22:48 +00:00
print '<tr class="oddeven">' ;
2012-10-25 20:30:17 +00:00
$i ++ ;
2019-11-13 18:35:02 +00:00
$entity = ( ! empty ( $objexport -> array_export_entities [ 0 ][ $code ]) ? $objexport -> array_export_entities [ 0 ][ $code ] : $objexport -> array_export_icon [ 0 ]);
$entityicon = strtolower ( ! empty ( $entitytoicon [ $entity ]) ? $entitytoicon [ $entity ] : $entity );
$entitylang = ( ! empty ( $entitytolang [ $entity ]) ? $entitytolang [ $entity ] : $entity );
2012-10-25 20:30:17 +00:00
2013-04-24 23:13:13 +00:00
print '<td class="nowrap">' ;
2012-10-25 20:30:17 +00:00
// If value of entityicon=entitylang='icon:Label'
2019-11-13 18:35:02 +00:00
$tmparray = explode ( ':' , $entityicon );
2021-02-25 21:50:40 +00:00
if ( count ( $tmparray ) >= 2 ) {
2019-11-13 18:35:02 +00:00
$entityicon = $tmparray [ 0 ];
$entitylang = $tmparray [ 1 ];
2012-10-25 20:30:17 +00:00
}
2025-02-01 14:53:36 +00:00
print img_object ( '' , $entityicon ) . ' ' . $langs -> trans (( string ) $entitylang );
2012-10-25 20:30:17 +00:00
print '</td>' ;
2012-11-20 13:07:52 +00:00
// Field name
2019-11-13 18:35:02 +00:00
$labelName = ( ! empty ( $fieldsarray [ $code ]) ? $fieldsarray [ $code ] : '' );
$ValueFilter = ( ! empty ( $array_filtervalue [ $code ]) ? $array_filtervalue [ $code ] : '' );
2024-09-27 12:49:29 +00:00
$text = ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '<i>' );
$tmplabelarray = explode ( ':' , $label );
if ( ! empty ( $tmplabelarray [ 1 ])) {
$text .= $langs -> trans ( $tmplabelarray [ 0 ]) . ' - ' . $langs -> trans ( $tmplabelarray [ 1 ]);
} else {
$text .= $langs -> trans ( $label );
}
2025-02-01 14:53:36 +00:00
$text .= ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '</i>' );
2012-10-25 20:30:17 +00:00
2019-11-13 18:35:02 +00:00
$tablename = getablenamefromfield ( $code , $sqlmaxforexport );
$htmltext = '<b>' . $langs -> trans ( " Name " ) . ':</b> ' . $text . '<br>' ;
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_special [ 0 ][ $code ])) {
2026-07-03 00:22:39 +00:00
$htmltext .= '<b>' . $langs -> trans ( " ComputedField " ) . " -> " . $langs -> trans ( " Method " ) . " :</b> " ;
if ( isset ( $objexport -> array_export_special [ 0 ][ $code ][ 'method' ])) {
$htmltext .= $objexport -> array_export_special [ 0 ][ $code ][ 'method' ];
} elseif ( ! is_array ( $objexport -> array_export_special [ 0 ][ $code ])) {
$htmltext .= $objexport -> array_export_special [ 0 ][ $code ];
}
$htmltext .= " <br> " ;
2020-05-21 13:05:19 +00:00
} else {
2020-10-31 13:32:18 +00:00
$htmltext .= '<b>' . $langs -> trans ( " Table " ) . " -> " . $langs -> trans ( " Field " ) . " :</b> " . $tablename . " -> " . preg_replace ( '/^.*\./' , '' , $code ) . " <br> " ;
2017-06-13 16:50:31 +00:00
}
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_examplevalues [ 0 ][ $code ])) {
2020-10-31 13:32:18 +00:00
$htmltext .= '<b>' . $langs -> trans ( " SourceExample " ) . ':</b> ' . $objexport -> array_export_examplevalues [ 0 ][ $code ] . '<br>' ;
2015-09-12 13:19:19 +00:00
}
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_TypeFields [ 0 ][ $code ])) {
2020-10-31 13:32:18 +00:00
$htmltext .= '<b>' . $langs -> trans ( " Type " ) . ':</b> ' . $objexport -> array_export_TypeFields [ 0 ][ $code ] . '<br>' ;
2019-12-23 11:24:27 +00:00
}
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_help [ 0 ][ $code ])) {
2019-12-23 11:24:27 +00:00
$htmltext .= '<b>' . $langs -> trans ( " Help " ) . ':</b> ' . $langs -> trans ( $objexport -> array_export_help [ 0 ][ $code ]) . '<br>' ;
2017-06-13 16:50:31 +00:00
}
2012-11-13 23:27:25 +00:00
print '<td>' ;
2019-01-27 10:55:16 +00:00
print $form -> textwithpicto ( $text , $htmltext );
2012-11-13 23:27:25 +00:00
print '</td>' ;
2012-11-21 17:52:25 +00:00
2012-11-20 13:07:52 +00:00
// Filter value
2012-11-13 23:27:25 +00:00
print '<td>' ;
2021-02-25 21:50:40 +00:00
if ( ! empty ( $Typefieldsarray [ $code ])) { // Example: Text, List:c_country:label:rowid, Number, Boolean
2019-11-13 18:35:02 +00:00
$szInfoFiltre = $objexport -> genDocFilter ( $Typefieldsarray [ $code ]);
2021-02-25 21:50:40 +00:00
if ( $szInfoFiltre ) { // Is there an info help for this filter ?
2019-11-13 18:35:02 +00:00
$tmp = $objexport -> build_filterField ( $Typefieldsarray [ $code ], $code , $ValueFilter );
2016-03-25 14:24:57 +00:00
print $form -> textwithpicto ( $tmp , $szInfoFiltre );
2020-05-21 13:05:19 +00:00
} else {
2012-11-13 23:27:25 +00:00
print $objexport -> build_filterField ( $Typefieldsarray [ $code ], $code , $ValueFilter );
}
2012-10-25 20:30:17 +00:00
}
2012-11-13 23:27:25 +00:00
print '</td>' ;
2012-10-25 20:30:17 +00:00
print '</tr>' ;
}
print '</table>' ;
2020-10-31 13:32:18 +00:00
print '</div>' ;
2012-10-25 20:30:17 +00:00
print '</div>' ;
/*
2021-03-16 03:22:55 +00:00
* Action bar
2012-11-21 17:52:25 +00:00
*/
2017-05-09 14:52:03 +00:00
print '<div class="tabsAction tabsActionNoBottom">' ;
2012-10-25 20:30:17 +00:00
// il n'est pas obligatoire de filtrer les champs
print '<a class="butAction" href="javascript:FilterField.submit();">' . $langs -> trans ( " NextStep " ) . '</a>' ;
print '</div>' ;
}
2021-02-25 21:50:40 +00:00
if ( $step == 4 && $datatoexport ) {
if ( count ( $array_selected ) < 1 ) { // This occurs when going back to page after sessecion expired
2020-10-31 13:32:18 +00:00
// Switch to step 2
header ( " Location: " . DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport );
exit ;
}
2024-04-23 00:19:03 +00:00
// Check permission
if ( empty ( $objexport -> array_export_perms [ 0 ])) {
accessforbidden ();
}
2020-10-31 13:32:18 +00:00
asort ( $array_selected );
2024-06-09 09:49:18 +00:00
llxHeader ( '' , $langs -> trans ( " NewExport " ), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones' , '' , 0 , 0 , '' , '' , '' , 'mod-exports page-export action-step4' );
2020-10-31 13:32:18 +00:00
$stepoffset = 0 ;
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=1' ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 1 " ;
$h ++ ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 2 " ;
$h ++ ;
// If filters exist
2021-02-25 21:50:40 +00:00
if ( $usefilters && isset ( $objexport -> array_export_TypeFields [ 0 ]) && is_array ( $objexport -> array_export_TypeFields [ 0 ])) {
2020-10-31 13:32:18 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=3&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 3 " ;
$h ++ ;
$stepoffset ++ ;
}
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=4&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " " . ( 3 + $stepoffset );
2024-09-10 12:58:36 +00:00
$hselected = ( string ) $h ;
2020-10-31 13:32:18 +00:00
$h ++ ;
2026-03-10 10:33:18 +00:00
$titleofmodule = $objexport -> array_export_module [ 0 ] -> getName ();
2025-06-23 01:36:27 +00:00
print dol_get_fiche_head ( $head , $hselected , 'Export' , - 2 , 'download' );
2020-10-31 13:32:18 +00:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
print '<table width="100%" class="border tableforfield">' ;
// Module
print '<tr><td class="titlefield tableforfield">' . $langs -> trans ( " Module " ) . '</td>' ;
print '<td>' ;
2026-03-10 10:33:18 +00:00
print dolPrintHTML ( $titleofmodule );
2020-10-31 13:32:18 +00:00
print '</td></tr>' ;
2026-07-01 10:26:51 +00:00
// Dataset to export
2021-02-25 21:50:40 +00:00
print '<tr><td>' . $langs -> trans ( " DatasetToExport " ) . '</td>' ;
print '<td>' ;
2020-12-03 18:45:36 +00:00
$entity = preg_replace ( '/:.*$/' , '' , $objexport -> array_export_icon [ 0 ]);
$entityicon = strtolower ( ! empty ( $entitytoicon [ $entity ]) ? $entitytoicon [ $entity ] : $entity );
2021-02-25 21:50:40 +00:00
print img_object ( $objexport -> array_export_module [ 0 ] -> getName (), $entityicon ) . ' ' ;
print $objexport -> array_export_label [ 0 ];
print '</td></tr>' ;
2020-10-31 13:32:18 +00:00
// List of exported fields
print '<tr><td>' . $langs -> trans ( " ExportedFields " ) . '</td>' ;
$list = '' ;
2021-02-25 21:50:40 +00:00
foreach ( $array_selected as $code => $value ) {
2024-09-02 16:13:04 +00:00
if ( isset ( $objexport -> array_export_fields [ 0 ][ $code ])) {
$list .= ( ! empty ( $list ) ? ', ' : '' );
2024-09-27 12:49:29 +00:00
$tmplabelarray = explode ( ':' , $objexport -> array_export_fields [ 0 ][ $code ]);
if ( ! empty ( $tmplabelarray [ 1 ])) {
$list .= $langs -> trans ( $tmplabelarray [ 0 ]) . ' - ' . $langs -> trans ( $tmplabelarray [ 1 ]);
} else {
$list .= $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]);
}
2024-09-02 16:13:04 +00:00
}
2020-10-31 13:32:18 +00:00
}
2026-03-10 10:33:18 +00:00
print '<td><span class="small">' . $list . '</span></td>' ;
2020-10-31 13:32:18 +00:00
print '</tr>' ;
2022-05-16 22:50:59 +00:00
// List of filtered fields
2021-02-25 21:50:40 +00:00
if ( isset ( $objexport -> array_export_TypeFields [ 0 ]) && is_array ( $objexport -> array_export_TypeFields [ 0 ])) {
2020-10-31 13:32:18 +00:00
print '<tr><td>' . $langs -> trans ( " FilteredFields " ) . '</td>' ;
$list = '' ;
2021-02-25 21:50:40 +00:00
if ( ! empty ( $array_filtervalue )) {
foreach ( $array_filtervalue as $code => $value ) {
2022-05-16 22:50:59 +00:00
if ( preg_match ( '/^FormSelect:/' , $objexport -> array_export_TypeFields [ 0 ][ $code ])) {
// We discard this filter if it is a FromSelect field with a value of -1.
if ( $value == - 1 ) {
continue ;
}
}
2021-02-25 21:50:40 +00:00
if ( isset ( $objexport -> array_export_fields [ 0 ][ $code ])) {
2020-10-31 13:32:18 +00:00
$list .= ( $list ? ', ' : '' );
2021-02-25 21:50:40 +00:00
if ( isset ( $array_filtervalue [ $code ]) && preg_match ( '/^\s*[<>]/' , $array_filtervalue [ $code ])) {
2022-06-29 13:51:39 +00:00
$list .= '<span class="opacitymedium">' . $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]) . '</span>' . ( isset ( $array_filtervalue [ $code ]) ? $array_filtervalue [ $code ] : '' );
2021-02-25 21:50:40 +00:00
} else {
2022-06-29 13:51:39 +00:00
$list .= '<span class="opacitymedium">' . $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]) . " </span>=' " . ( isset ( $array_filtervalue [ $code ]) ? $array_filtervalue [ $code ] : '' ) . " ' " ;
2021-02-25 21:50:40 +00:00
}
2020-10-31 13:32:18 +00:00
}
}
}
print '<td>' . ( ! empty ( $list ) ? $list : '<span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span>' ) . '</td>' ;
print '</tr>' ;
}
print '</table>' ;
print '</div>' ;
print '<br>' ;
// Select request if all fields are selected
$sqlmaxforexport = $objexport -> build_sql ( 0 , array (), array ());
2025-12-02 14:04:14 +00:00
print '<br>' ;
2020-10-31 13:32:18 +00:00
print '<div class="marginbottomonly"><span class="opacitymedium">' . $langs -> trans ( " ChooseFieldsOrdersAndTitle " ) . '</span></div>' ;
2024-04-23 00:19:03 +00:00
print '<div class="div-table-responsive-no-min">' ; // You can use div-table-responsive-no-min if you don't need reserved height for your table
2020-10-31 13:32:18 +00:00
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Entities " ) . '</td>' ;
print '<td>' . $langs -> trans ( " ExportedFields " ) . '</td>' ;
print '<td class="right" colspan="2">' . $langs -> trans ( " Position " ) . '</td>' ;
//print '<td> </td>';
//print '<td>'.$langs->trans("FieldsTitle").'</td>';
print '</tr>' ;
2021-02-25 21:50:40 +00:00
foreach ( $array_selected as $code => $value ) {
2024-09-02 16:22:55 +00:00
if ( ! isset ( $objexport -> array_export_fields [ 0 ][ $code ])) { // For example when field was in predefined filter but not more active (localtax1 disabled by setup of country)
continue ;
}
2020-10-31 13:32:18 +00:00
print '<tr class="oddeven">' ;
$entity = ( ! empty ( $objexport -> array_export_entities [ 0 ][ $code ]) ? $objexport -> array_export_entities [ 0 ][ $code ] : $objexport -> array_export_icon [ 0 ]);
$entityicon = strtolower ( ! empty ( $entitytoicon [ $entity ]) ? $entitytoicon [ $entity ] : $entity );
$entitylang = ( ! empty ( $entitytolang [ $entity ]) ? $entitytolang [ $entity ] : $entity );
print '<td class="nowrap">' ;
// If value of entityicon=entitylang='icon:Label'
$tmparray = explode ( ':' , $entityicon );
2021-02-25 21:50:40 +00:00
if ( count ( $tmparray ) >= 2 ) {
2020-10-31 13:32:18 +00:00
$entityicon = $tmparray [ 0 ];
$entitylang = $tmparray [ 1 ];
}
2025-02-01 14:53:36 +00:00
print img_object ( '' , $entityicon ) . ' ' . $langs -> trans (( string ) $entitylang );
2020-10-31 13:32:18 +00:00
print '</td>' ;
$labelName = $objexport -> array_export_fields [ 0 ][ $code ];
2017-06-13 16:50:31 +00:00
2024-09-27 12:49:29 +00:00
$text = ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '<i>' );
$tmplabelarray = explode ( ':' , $labelName );
if ( ! empty ( $tmplabelarray [ 1 ])) {
$text .= $langs -> trans ( $tmplabelarray [ 0 ]) . ' - ' . $langs -> trans ( $tmplabelarray [ 1 ]);
} else {
$text .= $langs -> trans ( $labelName );
}
2025-02-01 14:53:36 +00:00
$text .= ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '</i>' );
2017-06-13 16:50:31 +00:00
2020-10-31 13:32:18 +00:00
$tablename = getablenamefromfield ( $code , $sqlmaxforexport );
$htmltext = '<b>' . $langs -> trans ( " Name " ) . ':</b> ' . $text . '<br>' ;
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_special [ 0 ][ $code ])) {
2026-07-03 00:22:39 +00:00
$htmltext .= '<b>' . $langs -> trans ( " ComputedField " ) . " -> " . $langs -> trans ( " Method " ) . " :</b> " ;
if ( isset ( $objexport -> array_export_special [ 0 ][ $code ][ 'method' ])) {
$htmltext .= $objexport -> array_export_special [ 0 ][ $code ][ 'method' ];
} elseif ( ! is_array ( $objexport -> array_export_special [ 0 ][ $code ])) {
$htmltext .= $objexport -> array_export_special [ 0 ][ $code ];
}
$htmltext .= " <br> " ;
2020-10-31 13:32:18 +00:00
} else {
$htmltext .= '<b>' . $langs -> trans ( " Table " ) . " -> " . $langs -> trans ( " Field " ) . " :</b> " . $tablename . " -> " . preg_replace ( '/^.*\./' , '' , $code ) . " <br> " ;
}
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_examplevalues [ 0 ][ $code ])) {
2020-10-31 13:32:18 +00:00
$htmltext .= '<b>' . $langs -> trans ( " SourceExample " ) . ':</b> ' . $objexport -> array_export_examplevalues [ 0 ][ $code ] . '<br>' ;
}
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_TypeFields [ 0 ][ $code ])) {
2020-10-31 13:32:18 +00:00
$htmltext .= '<b>' . $langs -> trans ( " Type " ) . ':</b> ' . $objexport -> array_export_TypeFields [ 0 ][ $code ] . '<br>' ;
}
2021-02-25 21:50:40 +00:00
if ( ! empty ( $objexport -> array_export_help [ 0 ][ $code ])) {
2020-10-31 13:32:18 +00:00
$htmltext .= '<b>' . $langs -> trans ( " Help " ) . ':</b> ' . $langs -> trans ( $objexport -> array_export_help [ 0 ][ $code ]) . '<br>' ;
}
print '<td>' ;
print $form -> textwithpicto ( $text , $htmltext );
2009-10-03 12:08:48 +00:00
//print ' ('.$code.')';
2020-10-31 13:32:18 +00:00
print '</td>' ;
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
print '<td class="right" width="100">' ;
print $value . ' ' ;
print '</td><td class="center nowraponall" width="40">' ;
2021-02-25 21:50:40 +00:00
if ( $value < count ( $array_selected )) {
2026-03-10 10:33:18 +00:00
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?step=' . $step . '&datatoexport=' . $datatoexport . '&action=downfield&field=' . $code . '" class="paddingleft paddingright">' . img_down () . '</a>' ;
2021-02-25 21:50:40 +00:00
}
if ( $value > 1 ) {
2026-03-10 10:33:18 +00:00
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?step=' . $step . '&datatoexport=' . $datatoexport . '&action=upfield&field=' . $code . '" class="paddingleft paddingright">' . img_up () . '</a>' ;
2021-02-25 21:50:40 +00:00
}
2020-10-31 13:32:18 +00:00
print '</td>' ;
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
//print '<td> </td>';
//print '<td>'.$langs->trans($objexport->array_export_fields[0][$code]).'</td>';
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
print '</tr>' ;
}
2007-03-24 16:46:02 +00:00
2020-10-31 13:32:18 +00:00
print '</table>' ;
print '</div>' ;
2009-03-03 00:42:40 +00:00
2020-10-31 13:32:18 +00:00
print '</div>' ;
2008-12-04 20:27:01 +00:00
2020-10-31 13:32:18 +00:00
/*
2021-03-16 03:22:55 +00:00
* Action bar
2021-02-25 21:50:40 +00:00
*/
2020-10-31 13:32:18 +00:00
print '<div class="tabsAction">' ;
2008-12-04 20:27:01 +00:00
2021-02-25 21:50:40 +00:00
if ( count ( $array_selected )) {
2020-10-31 13:32:18 +00:00
print '<a class="butAction" href="export.php?step=' . ( $step + 1 ) . '&datatoexport=' . $datatoexport . '">' . $langs -> trans ( " NextStep " ) . '</a>' ;
}
2008-12-04 20:27:01 +00:00
2020-10-31 13:32:18 +00:00
print '</div>' ;
2008-12-04 20:27:01 +00:00
2009-03-03 00:42:40 +00:00
2008-12-04 20:27:01 +00:00
// Area for profils export
2021-02-25 21:50:40 +00:00
if ( count ( $array_selected )) {
2007-03-24 16:46:02 +00:00
print '<br>' ;
2019-12-23 11:24:27 +00:00
print '<div class="marginbottomonly">' ;
2020-10-31 13:32:18 +00:00
print '<span class="opacitymedium">' . $langs -> trans ( " SaveExportModel " ) . '</span>' ;
print '</div>' ;
2009-03-03 00:42:40 +00:00
2007-03-24 16:46:02 +00:00
print '<form class="nocellnopadd" action="export.php" method="post">' ;
2019-12-18 22:12:31 +00:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2020-10-31 13:32:18 +00:00
print '<input type="hidden" name="action" value="add_export_model">' ;
print '<input type="hidden" name="step" value="' . $step . '">' ;
print '<input type="hidden" name="datatoexport" value="' . $datatoexport . '">' ;
print '<input type="hidden" name="hexa" value="' . $hexa . '">' ;
2026-03-10 10:33:18 +00:00
print '<input type="hidden" name="page_y" value="">' ;
2007-03-24 16:46:02 +00:00
2024-04-23 00:19:03 +00:00
print '<div class="div-table-responsive-no-min">' ; // You can use div-table-responsive-no-min if you don't need reserved height for your table
2020-10-31 13:32:18 +00:00
print '<table class="noborder centpercent">' ;
2007-03-24 16:46:02 +00:00
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " ExportModelName " ) . '</td>' ;
2021-06-21 13:03:45 +00:00
print '<td>' . $langs -> trans ( " Visibility " ) . '</td>' ;
print '<td></td>' ;
2007-03-24 16:46:02 +00:00
print '</tr>' ;
2018-06-18 08:12:19 +00:00
2026-03-10 10:33:18 +00:00
$nameofexportprofile = str_replace ( ' ' , '-' , $langs -> trans ( " ExportProfile " ) . ' ' . $titleofmodule . ' ' . dol_print_date ( dol_now ( 'gmt' ), 'dayxcard' ));
if ( GETPOST ( 'export_name' )) { // If we have submitted a form, we take value used for the update try
$nameofexportprofile = $export_name ;
}
2017-04-14 09:22:48 +00:00
print '<tr class="oddeven">' ;
2026-03-10 10:33:18 +00:00
print '<td><input name="export_name" class="minwidth300" value="' . $nameofexportprofile . '"></td>' ;
2021-06-21 13:03:45 +00:00
print '<td>' ;
2024-04-23 00:19:03 +00:00
$arrayvisibility = array ( 'private' => $langs -> trans ( " Private " ), 'all' => $langs -> trans ( " Everybody " ));
2021-06-21 13:03:45 +00:00
print $form -> selectarray ( 'visibility' , $arrayvisibility , 'private' );
print '</td>' ;
print '<td class="right">' ;
2026-03-10 10:33:18 +00:00
print '<input type="submit" class="button reposition button-save smallpaddingimp" value="' . $langs -> trans ( " Save " ) . '">' ;
2020-10-31 13:32:18 +00:00
print '</td></tr>' ;
2008-12-04 20:27:01 +00:00
2021-06-21 13:03:45 +00:00
$tmpuser = new User ( $db );
2020-10-31 13:32:18 +00:00
// List of existing export profils
2021-06-21 13:03:45 +00:00
$sql = " SELECT rowid, label, fk_user, entity " ;
2019-11-13 18:35:02 +00:00
$sql .= " FROM " . MAIN_DB_PREFIX . " export_model " ;
2020-09-20 00:30:53 +00:00
$sql .= " WHERE type = ' " . $db -> escape ( $datatoexport ) . " ' " ;
2023-11-27 10:41:05 +00:00
if ( ! getDolGlobalString ( 'EXPORTS_SHARE_MODELS' )) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner.
2021-06-21 13:03:45 +00:00
$sql .= " AND fk_user IN (0, " . (( int ) $user -> id ) . " ) " ;
2021-02-25 21:50:40 +00:00
}
2019-11-13 18:35:02 +00:00
$sql .= " ORDER BY rowid " ;
2008-12-04 20:27:01 +00:00
$resql = $db -> query ( $sql );
2021-02-25 21:50:40 +00:00
if ( $resql ) {
2008-12-04 20:27:01 +00:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2021-02-25 21:50:40 +00:00
while ( $i < $num ) {
2008-12-04 20:27:01 +00:00
$obj = $db -> fetch_object ( $resql );
2021-06-21 13:03:45 +00:00
2017-04-14 11:02:29 +00:00
print '<tr class="oddeven"><td>' ;
2008-12-04 20:27:01 +00:00
print $obj -> label ;
2021-06-21 13:03:45 +00:00
print '</td>' ;
print '<td>' ;
if ( empty ( $obj -> fk_user )) {
print $langs -> trans ( " Everybody " );
} else {
$tmpuser -> fetch ( $obj -> fk_user );
2026-03-10 10:33:18 +00:00
print $tmpuser -> getNomUrl ( - 1 );
2021-06-21 13:03:45 +00:00
}
print '</td>' ;
print '<td class="right">' ;
2020-09-30 16:39:23 +00:00
print '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?step=' . $step . '&datatoexport=' . $datatoexport . '&action=deleteprof&token=' . newToken () . '&id=' . $obj -> rowid . '">' ;
2008-12-04 20:27:01 +00:00
print img_delete ();
print '</a>' ;
print '</tr>' ;
$i ++ ;
}
2020-05-21 13:05:19 +00:00
} else {
2020-09-20 14:46:29 +00:00
dol_print_error ( $db );
2008-12-04 20:27:01 +00:00
}
2009-03-03 00:42:40 +00:00
2020-10-31 13:32:18 +00:00
print '</table>' ;
print '</div>' ;
2019-03-04 09:42:09 +00:00
2020-10-31 13:32:18 +00:00
print '</form>' ;
}
2006-01-08 17:08:20 +00:00
}
2021-02-25 21:50:40 +00:00
if ( $step == 5 && $datatoexport ) {
2023-12-11 00:37:45 +00:00
if ( count ( $array_selected ) < 1 ) { // This occurs when going back to page after session expired
2020-10-31 13:32:18 +00:00
// Switch to step 2
header ( " Location: " . DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport );
exit ;
}
2017-06-13 16:50:31 +00:00
2024-04-23 00:19:03 +00:00
// Check permission
if ( empty ( $objexport -> array_export_perms [ 0 ])) {
accessforbidden ();
}
2015-05-05 11:46:28 +00:00
asort ( $array_selected );
2006-01-21 19:08:36 +00:00
2024-06-09 09:49:18 +00:00
llxHeader ( '' , $langs -> trans ( " NewExport " ), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones' , '' , 0 , 0 , '' , '' , '' , 'mod-exports page-export action-step5' );
2009-03-03 00:42:40 +00:00
2020-10-31 13:32:18 +00:00
$h = 0 ;
$stepoffset = 0 ;
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=1' ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 1 " ;
$h ++ ;
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 2 " ;
$h ++ ;
2006-01-08 17:08:20 +00:00
2026-07-01 10:26:51 +00:00
// whether filtering is a parameter for the export or not
2021-02-25 21:50:40 +00:00
if ( $usefilters && isset ( $objexport -> array_export_TypeFields [ 0 ]) && is_array ( $objexport -> array_export_TypeFields [ 0 ])) {
2020-10-31 13:32:18 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=3&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 3 " ;
$h ++ ;
$stepoffset ++ ;
}
2012-10-25 20:30:17 +00:00
2020-10-31 13:32:18 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=4&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " " . ( 3 + $stepoffset );
$h ++ ;
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=5&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " " . ( 4 + $stepoffset );
2024-09-10 12:58:36 +00:00
$hselected = ( string ) $h ;
2020-10-31 13:32:18 +00:00
$h ++ ;
2009-03-03 00:42:40 +00:00
2025-06-23 01:36:27 +00:00
print dol_get_fiche_head ( $head , $hselected , 'Export' , - 2 , 'download' );
2006-01-08 17:08:20 +00:00
2020-10-31 13:32:18 +00:00
/*
2026-01-29 18:21:34 +00:00
* Confirmation of deletion of file
2021-02-25 21:50:40 +00:00
*/
if ( $action == 'remove_file' ) {
2020-10-31 13:32:18 +00:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?step=5&datatoexport=' . $datatoexport . '&file=' . urlencode ( GETPOST ( " file " )), $langs -> trans ( 'DeleteFile' ), $langs -> trans ( 'ConfirmDeleteFile' ), 'confirm_deletefile' , '' , 0 , 1 );
}
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2024-04-23 00:19:03 +00:00
print '<table class="border tableforfield centpercent">' ;
2020-10-31 13:32:18 +00:00
// Module
print '<tr><td class="titlefield">' . $langs -> trans ( " Module " ) . '</td>' ;
print '<td>' ;
//print img_object($objexport->array_export_module[0]->getName(),$objexport->array_export_module[0]->picto).' ';
print $objexport -> array_export_module [ 0 ] -> getName ();
print '</td></tr>' ;
2021-02-25 21:50:40 +00:00
// Dataset to export
print '<tr><td>' . $langs -> trans ( " DatasetToExport " ) . '</td>' ;
print '<td>' ;
$entity = preg_replace ( '/:.*$/' , '' , $objexport -> array_export_icon [ 0 ]);
$entityicon = strtolower ( ! empty ( $entitytoicon [ $entity ]) ? $entitytoicon [ $entity ] : $entity );
print img_object ( $objexport -> array_export_module [ 0 ] -> getName (), $entityicon ) . ' ' ;
print $objexport -> array_export_label [ 0 ];
print '</td></tr>' ;
2020-10-31 13:32:18 +00:00
// List of exported fields
print '<tr><td>' . $langs -> trans ( " ExportedFields " ) . '</td>' ;
$list = '' ;
2026-03-10 10:33:18 +00:00
foreach ( $array_selected as $code => $value ) {
2024-09-02 16:22:55 +00:00
if ( isset ( $objexport -> array_export_fields [ 0 ][ $code ])) {
$list .= ( ! empty ( $list ) ? ', ' : '' );
2024-09-27 12:49:29 +00:00
$tmplabelarray = explode ( ':' , $objexport -> array_export_fields [ 0 ][ $code ]);
if ( ! empty ( $tmplabelarray [ 1 ])) {
$list .= $langs -> trans ( $tmplabelarray [ 0 ]) . ' - ' . $langs -> trans ( $tmplabelarray [ 1 ]);
} else {
$list .= $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]);
}
2024-09-02 16:22:55 +00:00
}
2020-10-31 13:32:18 +00:00
}
2026-03-10 10:33:18 +00:00
print '<td><span class="small">' . $list . '</span></td>' ;
print '</tr>' ;
2020-10-31 13:32:18 +00:00
// List of filtered fields
2021-02-25 21:50:40 +00:00
if ( isset ( $objexport -> array_export_TypeFields [ 0 ]) && is_array ( $objexport -> array_export_TypeFields [ 0 ])) {
2020-10-31 13:32:18 +00:00
print '<tr><td>' . $langs -> trans ( " FilteredFields " ) . '</td>' ;
$list = '' ;
2021-02-25 21:50:40 +00:00
if ( ! empty ( $array_filtervalue )) {
foreach ( $array_filtervalue as $code => $value ) {
2022-05-16 22:50:59 +00:00
if ( preg_match ( '/^FormSelect:/' , $objexport -> array_export_TypeFields [ 0 ][ $code ])) {
// We discard this filter if it is a FromSelect field with a value of -1.
if ( $value == - 1 ) {
continue ;
}
}
2021-02-25 21:50:40 +00:00
if ( isset ( $objexport -> array_export_fields [ 0 ][ $code ])) {
2020-10-31 13:32:18 +00:00
$list .= ( $list ? ', ' : '' );
2021-02-25 21:50:40 +00:00
if ( isset ( $array_filtervalue [ $code ]) && preg_match ( '/^\s*[<>]/' , $array_filtervalue [ $code ])) {
2022-06-29 13:51:39 +00:00
$list .= '<span class="opacitymedium">' . $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]) . '</span>' . ( isset ( $array_filtervalue [ $code ]) ? $array_filtervalue [ $code ] : '' );
2021-02-25 21:50:40 +00:00
} else {
2022-06-29 13:51:39 +00:00
$list .= '<span class="opacitymedium">' . $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]) . " </span>=' " . ( isset ( $array_filtervalue [ $code ]) ? $array_filtervalue [ $code ] : '' ) . " ' " ;
2021-02-25 21:50:40 +00:00
}
2020-10-31 13:32:18 +00:00
}
}
}
print '<td>' . ( ! empty ( $list ) ? $list : '<span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span>' ) . '</td>' ;
print '</tr>' ;
}
print '</table>' ;
print '</div>' ;
print '<br>' ;
// List of available export formats
2023-03-28 21:30:26 +00:00
$htmltabloflibs = '<!-- Table with available export formats --><br>' ;
$htmltabloflibs .= '<table class="noborder centpercent nomarginbottom">' ;
2020-10-31 13:32:18 +00:00
$htmltabloflibs .= '<tr class="liste_titre">' ;
$htmltabloflibs .= '<td>' . $langs -> trans ( " AvailableFormats " ) . '</td>' ;
$htmltabloflibs .= '<td>' . $langs -> trans ( " LibraryUsed " ) . '</td>' ;
$htmltabloflibs .= '<td class="right">' . $langs -> trans ( " LibraryVersion " ) . '</td>' ;
$htmltabloflibs .= '</tr>' . " \n " ;
2022-12-31 16:08:10 +00:00
$liste = $objmodelexport -> listOfAvailableExportFormat ( $db );
2020-10-31 13:32:18 +00:00
$listeall = $liste ;
2021-02-25 21:50:40 +00:00
foreach ( $listeall as $key => $val ) {
if ( preg_match ( '/__\(Disabled\)__/' , $listeall [ $key ])) {
2020-10-31 13:32:18 +00:00
$listeall [ $key ] = preg_replace ( '/__\(Disabled\)__/' , '(' . $langs -> transnoentitiesnoconv ( " Disabled " ) . ')' , $listeall [ $key ]);
unset ( $liste [ $key ]);
}
$htmltabloflibs .= '<tr class="oddeven">' ;
$htmltabloflibs .= '<td>' . img_picto_common ( $key , $objmodelexport -> getPictoForKey ( $key )) . ' ' ;
$text = $objmodelexport -> getDriverDescForKey ( $key );
$label = $listeall [ $key ];
2024-04-23 00:19:03 +00:00
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
2020-10-31 13:32:18 +00:00
$htmltabloflibs .= $form -> textwithpicto ( $label , $text ) . '</td>' ;
$htmltabloflibs .= '<td>' . $objmodelexport -> getLibLabelForKey ( $key ) . '</td>' ;
$htmltabloflibs .= '<td class="right">' . $objmodelexport -> getLibVersionForKey ( $key ) . '</td>' ;
$htmltabloflibs .= '</tr>' . " \n " ;
}
2023-03-28 21:30:26 +00:00
$htmltabloflibs .= '</table><br>' ;
2020-10-31 13:32:18 +00:00
2025-12-02 14:04:14 +00:00
print '<br>' ;
2026-07-03 16:35:07 +00:00
print '<div class="info"><span class="">' . $form -> textwithpicto ( $langs -> trans ( " NowClickToGenerateToBuildExportFile " ), $htmltabloflibs , 1 , 'help' , '' , 0 , 2 , 'helphonformat' ) . '</span></div>' ;
2020-10-31 13:32:18 +00:00
//print $htmltabloflibs;
print '</div>' ;
2021-02-25 21:50:40 +00:00
if ( $sqlusedforexport && $user -> admin ) {
2026-07-03 16:35:07 +00:00
print info_admin ( $langs -> trans ( " SQLUsedForExport " ) . ':<br><span class="small">' . $sqlusedforexport . '</span>' , 0 , 0 , 'info' , '' , 'TechnicalInformation' ) . '<br>' ;
2025-12-02 14:04:14 +00:00
print '<br>' ;
2020-10-31 13:32:18 +00:00
}
2021-02-25 21:50:40 +00:00
if ( ! is_dir ( $conf -> export -> dir_temp )) {
dol_mkdir ( $conf -> export -> dir_temp );
}
2020-10-31 13:32:18 +00:00
// Show existing generated documents
2026-01-29 18:21:34 +00:00
// NB: The function show_documents rescan all modules when genallowed=1, else we take $liste
2022-02-22 22:44:56 +00:00
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' , '' , '' , '' );
2005-11-19 22:09:12 +00:00
}
2005-10-30 14:02:38 +00:00
2011-08-27 14:24:16 +00:00
llxFooter ();
2009-10-03 12:08:48 +00:00
2012-12-01 14:45:05 +00:00
$db -> close ();
2012-11-20 14:56:44 +00:00
2019-11-13 18:35:02 +00:00
exit ; // don't know why but apache hangs with php 5.3.10-1ubuntu3.12 and apache 2.2.2 if i remove this exit or replace with return
2015-05-05 11:46:28 +00:00
2009-10-03 12:08:48 +00:00
/**
2011-09-10 12:21:41 +00:00
* Return table name of an alias . For this , we look for the " tablename as alias " in sql string .
*
2012-01-07 23:52:07 +00:00
* @ param string $code Alias . Fieldname
* @ param string $sqlmaxforexport SQL request to parse
* @ return string Table name of field
2009-10-03 12:08:48 +00:00
*/
2019-01-27 14:20:16 +00:00
function getablenamefromfield ( $code , $sqlmaxforexport )
2009-10-03 12:08:48 +00:00
{
2019-11-13 18:35:02 +00:00
$alias = preg_replace ( '/\.(.*)$/i' , '' , $code ); // Keep only 'Alias' and remove '.Fieldname'
$regexstring = '/([a-zA-Z_]+) as ' . preg_quote ( $alias ) . '[, \)]/i' ;
2017-06-13 16:50:31 +00:00
2019-11-13 18:35:02 +00:00
$newsql = $sqlmaxforexport ;
$newsql = preg_replace ( '/^(.*) FROM /i' , '' , $newsql ); // Remove part before the FROM
$newsql = preg_replace ( '/WHERE (.*)$/i' , '' , $newsql ); // Remove part after the WHERE so we have now only list of table aliases in a string. We must keep the ' ' before WHERE
2017-06-13 16:50:31 +00:00
2025-06-23 01:36:27 +00:00
$reg = array ();
2021-02-25 21:50:40 +00:00
if ( preg_match ( $regexstring , $newsql , $reg )) {
2019-11-13 18:35:02 +00:00
return $reg [ 1 ]; // The tablename
2021-02-25 21:50:40 +00:00
} else {
return '' ;
}
2009-10-03 12:08:48 +00:00
}