2005-10-30 15:02:38 +01:00
< ? php
2018-12-16 13:36:51 +01:00
/* Copyright ( C ) 2005 - 2018 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2012-10-25 22:30:17 +02:00
* Copyright ( C ) 2012 Marcos GarcÃa < marcosgdf @ gmail . com >
* Copyright ( C ) 2012 Charles - Fr BENKE < charles . fr @ benke . fr >
2015-08-25 21:59:46 +02:00
* Copyright ( C ) 2015 Juanjo Menent < jmenent @ 2 byte . es >
2005-10-30 15:02:38 +01: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 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2005-10-30 15:02:38 +01: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
2011-08-01 01:45:11 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2005-10-30 15:02:38 +01:00
*/
/**
2009-05-19 02:14:27 +02:00
* \file htdocs / exports / export . php
* \ingroup export
2011-02-05 19:40:52 +01:00
* \brief Pages of export Wizard
2009-05-19 02:14:27 +02:00
*/
2009-03-03 01:42:40 +01:00
2012-08-22 23:11:24 +02:00
require_once '../main.inc.php' ;
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' ;
2012-10-29 10:36:26 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2006-01-22 17:14:33 +01:00
2018-05-26 20:51:17 +02:00
// Load translation files required by the page
$langs -> loadlangs ( array ( 'exports' , 'other' , 'users' , 'companies' , 'projects' ));
2005-10-30 15:02:38 +01:00
2009-05-22 17:57:47 +02:00
// Everybody should be able to go on this page
//if (! $user->admin)
// accessforbidden();
2005-10-30 15:02:38 +01:00
2012-08-16 13:07:12 +02:00
$entitytoicon = array (
'invoice' => 'bill' ,
'invoice_line' => 'bill' ,
'order' => 'order' ,
'order_line' => 'order' ,
'propal' => 'propal' ,
'propal_line' => 'propal' ,
'intervention' => 'intervention' ,
'inter_line' => 'intervention' ,
'member' => 'user' ,
'member_type' => 'group' ,
'subscription' => 'payment' ,
'payment' => 'payment' ,
'tax' => 'generic' ,
'tax_type' => 'generic' ,
'stock' => 'generic' ,
'other' => 'generic' ,
'account' => 'account' ,
'product' => 'product' ,
2017-01-29 21:25:29 +01:00
'virtualproduct' => 'product' ,
'subproduct' => 'product' ,
2018-05-23 17:48:18 +02:00
'product_supplier_ref' => 'product' ,
'warehouse' => 'stock' ,
2017-11-24 17:44:19 +01:00
'batch' => 'stock' ,
'stockbatch' => 'stock' ,
2012-08-16 13:07:12 +02:00
'category' => 'category' ,
2012-11-18 15:24:01 +01:00
'shipment' => 'sending' ,
2015-02-22 13:16:49 +01:00
'shipment_line' => 'sending' ,
2018-02-09 16:08:28 +01:00
'expensereport' => 'trip' ,
2015-08-25 21:59:46 +02:00
'expensereport_line' => 'trip' ,
2018-02-09 16:08:28 +01:00
'holiday' => 'holiday' ,
2016-02-22 17:42:41 +01:00
'contract_line' => 'contract' ,
'translation' => 'generic'
2012-08-16 13:07:12 +02:00
);
// Translation code
$entitytolang = array (
'user' => 'User' ,
'company' => 'Company' ,
'contact' => 'Contact' ,
'invoice' => 'Bill' ,
'invoice_line' => 'InvoiceLine' ,
'order' => 'Order' ,
'order_line' => 'OrderLine' ,
'propal' => 'Proposal' ,
'propal_line' => 'ProposalLine' ,
'intervention' => 'Intervention' ,
'inter_line' => 'InterLine' ,
'member' => 'Member' ,
'member_type' => 'MemberType' ,
'subscription' => 'Subscription' ,
'tax' => 'SocialContribution' ,
2014-02-05 17:53:30 +01:00
'tax_type' => 'DictionarySocialContributions' ,
2012-08-16 13:07:12 +02:00
'account' => 'BankTransactions' ,
'payment' => 'Payment' ,
'product' => 'Product' ,
2017-01-29 21:25:29 +01:00
'virtualproduct' => 'AssociatedProducts' ,
'subproduct' => 'SubProduct' ,
2018-05-23 17:48:18 +02:00
'product_supplier_ref' => 'SupplierPrices' ,
'service' => 'Service' ,
2012-08-16 13:07:12 +02:00
'stock' => 'Stock' ,
2017-10-20 14:52:01 +02:00
'movement' => 'StockMovement' ,
2017-11-24 17:44:19 +01:00
'batch' => 'Batch' ,
'stockbatch' => 'StockDetailPerBatch' ,
2015-04-08 18:40:10 +02:00
'warehouse' => 'Warehouse' ,
2012-08-16 13:07:12 +02:00
'category' => 'Category' ,
'other' => 'Other' ,
2012-11-18 15:24:01 +01:00
'trip' => 'TripsAndExpenses' ,
'shipment' => 'Shipments' ,
2014-02-25 04:18:13 +01:00
'shipment_line' => 'ShipmentLine' ,
'project' => 'Projects' ,
'projecttask' => 'Tasks' ,
2014-05-11 13:14:45 +02:00
'task_time' => 'TaskTimeSpent' ,
2015-03-26 11:20:39 +01:00
'action' => 'Event' ,
2015-02-22 13:16:49 +01:00
'expensereport' => 'ExpenseReport' ,
2015-08-26 21:01:01 +02:00
'expensereport_line' => 'ExpenseReportLine' ,
2018-02-09 16:08:28 +01:00
'holiday' => 'TitreRequestCP' ,
'contract' => 'Contract' ,
2016-02-22 17:42:41 +01:00
'contract_line' => 'ContractLine' ,
'translation' => 'Translation'
2012-08-16 13:07:12 +02:00
);
2006-02-25 15:26:29 +01:00
2006-01-08 18:08:20 +01:00
$array_selected = isset ( $_SESSION [ " export_selected_fields " ]) ? $_SESSION [ " export_selected_fields " ] : array ();
2015-06-24 18:29:29 +02:00
$array_filtervalue = isset ( $_SESSION [ " export_filtered_fields " ]) ? $_SESSION [ " export_filtered_fields " ] : array ();
2018-12-16 13:36:51 +01:00
$datatoexport = GETPOST ( " datatoexport " , " aZ09 " );
$action = GETPOST ( 'action' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$step = GETPOST ( " step " , " int " ) ? GETPOST ( " step " , " int " ) : 1 ;
$export_name = GETPOST ( " export_name " , " alphanohtml " );
$hexa = GETPOST ( " hexa " , " alpha " );
$exportmodelid = GETPOST ( " exportmodelid " , " int " );
$field = GETPOST ( " field " , " alpa " );
2005-10-30 15:02:38 +01:00
2006-01-22 17:14:33 +01:00
$objexport = new Export ( $db );
$objexport -> load_arrays ( $user , $datatoexport );
2015-07-29 12:10:04 +02:00
$objmodelexport = new ModeleExports ( $db );
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2008-10-25 19:27:15 +02:00
$htmlother = new FormOther ( $db );
2008-01-20 14:53:02 +01:00
$formfile = new FormFile ( $db );
2009-03-03 01:42:40 +01:00
$sqlusedforexport = '' ;
2005-10-30 15:02:38 +01:00
2012-10-29 10:36:26 +01:00
$upload_dir = $conf -> export -> dir_temp . '/' . $user -> id ;
2012-11-20 15:56:44 +01:00
//$usefilters=($conf->global->MAIN_FEATURES_LEVEL > 1);
$usefilters = 1 ;
2012-11-14 00:27:25 +01:00
2006-01-08 18:08:20 +01:00
/*
* Actions
*/
2009-03-03 01:42:40 +01:00
2017-02-17 00:19:28 +01:00
if ( $action == 'selectfield' ) // Selection of field at step 2
2009-03-03 01:42:40 +01:00
{
2012-07-24 16:19:46 +02:00
$fieldsarray = $objexport -> array_export_fields [ 0 ];
$fieldsentitiesarray = $objexport -> array_export_entities [ 0 ];
$fieldsdependenciesarray = $objexport -> array_export_dependencies [ 0 ];
if ( $field == 'all' )
2008-05-17 00:50:38 +02:00
{
foreach ( $fieldsarray as $key => $val )
{
2012-07-24 16:19:46 +02:00
if ( ! empty ( $array_selected [ $key ])) continue ; // If already selected, check next
2011-09-17 21:49:50 +02:00
$array_selected [ $key ] = count ( $array_selected ) + 1 ;
2008-05-17 00:50:38 +02:00
//print_r($array_selected);
$_SESSION [ " export_selected_fields " ] = $array_selected ;
}
}
else
{
2012-07-27 16:03:20 +02:00
$warnings = array ();
2012-07-24 16:19:46 +02:00
$array_selected [ $field ] = count ( $array_selected ) + 1 ; // We tag the key $field as "selected"
2017-06-13 18:50:31 +02:00
// We check if there is a dependency to activate
2017-02-17 00:19:28 +01:00
/* var_dump ( $field );
var_dump ( $fieldsentitiesarray [ $field ]);
var_dump ( $fieldsdependenciesarray ); */
$listofdependencies = array ();
2012-10-25 22:30:17 +02:00
if ( ! empty ( $fieldsentitiesarray [ $field ]) && ! empty ( $fieldsdependenciesarray [ $fieldsentitiesarray [ $field ]]))
2012-07-27 16:03:20 +02:00
{
2017-02-17 00:19:28 +01:00
// We found a dependency on the type of field
2012-07-27 16:03:20 +02:00
$tmp = $fieldsdependenciesarray [ $fieldsentitiesarray [ $field ]]; // $fieldsdependenciesarray=array('element'=>'fd.rowid') or array('element'=>array('fd.rowid','ab.rowid'))
if ( is_array ( $tmp )) $listofdependencies = $tmp ;
2012-07-30 18:43:49 +02:00
else $listofdependencies = array ( $tmp );
2017-02-17 00:19:28 +01:00
}
else if ( ! empty ( $field ) && ! empty ( $fieldsdependenciesarray [ $field ]))
{
// We found a dependency on a dedicated field
$tmp = $fieldsdependenciesarray [ $field ]; // $fieldsdependenciesarray=array('fd.fieldx'=>'fd.rowid') or array('fd.fieldx'=>array('fd.rowid','ab.rowid'))
if ( is_array ( $tmp )) $listofdependencies = $tmp ;
else $listofdependencies = array ( $tmp );
}
2017-06-13 18:50:31 +02:00
2017-02-17 00:19:28 +01:00
if ( count ( $listofdependencies ))
{
2012-07-27 16:03:20 +02:00
foreach ( $listofdependencies as $fieldid )
{
if ( empty ( $array_selected [ $fieldid ]))
{
$array_selected [ $fieldid ] = count ( $array_selected ) + 1 ; // We tag the key $fieldid as "selected"
$warnings [] = $langs -> trans ( " ExportFieldAutomaticallyAdded " , $langs -> transnoentitiesnoconv ( $fieldsarray [ $fieldid ]));
}
}
2012-07-24 16:19:46 +02:00
}
2008-05-17 00:50:38 +02:00
//print_r($array_selected);
$_SESSION [ " export_selected_fields " ] = $array_selected ;
2014-07-20 02:32:13 +02:00
2015-12-08 11:35:08 +01:00
setEventMessages ( $warnings , null , 'warnings' );
2008-05-17 00:50:38 +02:00
}
2009-03-03 01:42:40 +01:00
2006-01-08 18:08:20 +01:00
}
if ( $action == 'unselectfield' )
2009-03-03 01:42:40 +01:00
{
2008-05-17 00:50:38 +02:00
if ( $_GET [ " field " ] == 'all' )
2006-01-21 20:08:36 +01:00
{
2008-05-17 00:50:38 +02:00
$array_selected = array ();
2009-03-03 01:42:40 +01:00
$_SESSION [ " export_selected_fields " ] = $array_selected ;
2008-05-17 00:50:38 +02:00
}
else
2009-03-03 01:42:40 +01:00
{
2008-05-17 00:50:38 +02:00
unset ( $array_selected [ $_GET [ " field " ]]);
// Renumber fields of array_selected (from 1 to nb_elements)
asort ( $array_selected );
$i = 0 ;
$array_selected_save = $array_selected ;
foreach ( $array_selected as $code => $value )
{
$i ++ ;
$array_selected [ $code ] = $i ;
//print "x $code x $i y<br>";
}
$_SESSION [ " export_selected_fields " ] = $array_selected ;
2006-01-21 20:08:36 +01:00
}
}
2012-10-25 22:30:17 +02:00
2006-01-21 20:08:36 +01:00
if ( $action == 'downfield' || $action == 'upfield' )
2009-03-03 01:42:40 +01:00
{
2006-01-21 20:08:36 +01:00
$pos = $array_selected [ $_GET [ " field " ]];
if ( $action == 'downfield' ) $newpos = $pos + 1 ;
if ( $action == 'upfield' ) $newpos = $pos - 1 ;
2009-06-07 20:08:41 +02:00
// Recherche code avec qui switcher
2006-01-21 20:08:36 +01:00
$newcode = " " ;
foreach ( $array_selected as $code => $value )
{
if ( $value == $newpos )
{
$newcode = $code ;
break ;
}
}
//print("Switch pos=$pos (code=".$_GET["field"].") and newpos=$newpos (code=$newcode)");
2009-06-07 20:08:41 +02:00
if ( $newcode ) // Si newcode trouve (protection contre resoumission de page)
2006-01-22 18:41:25 +01:00
{
$array_selected [ $_GET [ " field " ]] = $newpos ;
$array_selected [ $newcode ] = $pos ;
$_SESSION [ " export_selected_fields " ] = $array_selected ;
}
2006-01-08 18:08:20 +01:00
}
2006-01-21 20:08:36 +01:00
2006-01-08 18:08:20 +01:00
if ( $step == 1 || $action == 'cleanselect' )
{
$_SESSION [ " export_selected_fields " ] = array ();
2012-10-25 22:30:17 +02:00
$_SESSION [ " export_filtered_fields " ] = array ();
2006-01-08 18:25:28 +01:00
$array_selected = array ();
2012-10-25 22:30:17 +02:00
$array_filtervalue = array ();
2006-01-08 18:08:20 +01:00
}
2005-11-19 23:09:12 +01:00
2006-01-21 20:08:36 +01:00
if ( $action == 'builddoc' )
{
2017-01-17 11:20:56 +01:00
$max_execution_time_for_export = ( empty ( $conf -> global -> EXPORT_MAX_EXECUTION_TIME ) ? 300 : $conf -> global -> EXPORT_MAX_EXECUTION_TIME ); // 5mn if not defined
$max_time = @ ini_get ( " max_execution_time " );
if ( $max_time && $max_time < $max_execution_time_for_export )
{
@ ini_set ( " max_execution_time " , $max_execution_time_for_export ); // This work only if safe mode is off. also web servers has timeout of 300
}
2017-06-13 18:50:31 +02:00
2008-03-30 17:36:19 +02:00
// Build export file
2013-09-06 13:25:45 +02:00
$result = $objexport -> build_file ( $user , GETPOST ( 'model' , 'alpha' ), $datatoexport , $array_selected , $array_filtervalue );
2006-01-22 17:14:33 +01:00
if ( $result < 0 )
{
2015-12-08 11:35:08 +01:00
setEventMessages ( $objexport -> error , $objexport -> errors , 'errors' );
2015-09-12 15:19:19 +02:00
$sqlusedforexport = $objexport -> sqlusedforexport ;
2006-01-22 17:14:33 +01:00
}
else
{
2015-12-08 11:35:08 +01:00
setEventMessages ( $langs -> trans ( " FileSuccessfullyBuilt " ), null , 'mesgs' );
2009-03-03 01:42:40 +01:00
$sqlusedforexport = $objexport -> sqlusedforexport ;
2006-01-22 17:14:33 +01:00
}
2006-01-21 20:08:36 +01:00
}
2012-10-29 10:36:26 +01:00
// Delete file
if ( $step == 5 && $action == 'confirm_deletefile' && $confirm == 'yes' )
{
$file = $upload_dir . " / " . GETPOST ( 'file' ); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret = dol_delete_file ( $file );
2015-12-10 16:14:37 +01:00
if ( $ret ) setEventMessages ( $langs -> trans ( " FileWasRemoved " , GETPOST ( 'file' )), null , 'mesgs' );
2015-12-08 11:35:08 +01:00
else setEventMessages ( $langs -> trans ( " ErrorFailToDeleteFile " , GETPOST ( 'file' )), null , 'errors' );
2012-10-29 10:36:26 +01:00
header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?step=' . $step . '&datatoexport=' . $datatoexport );
exit ;
}
2008-12-04 21:27:01 +01:00
if ( $action == 'deleteprof' )
{
if ( $_GET [ " id " ])
{
$objexport -> fetch ( $_GET [ " id " ]);
$result = $objexport -> delete ( $user );
}
}
2012-11-21 20:24:15 +01: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.
2007-03-24 17:46:02 +01:00
if ( $action == 'add_export_model' )
2007-03-23 18:58:06 +01:00
{
2007-03-24 17:46:02 +01:00
if ( $export_name )
{
asort ( $array_selected );
// Set save string
$hexa = '' ;
foreach ( $array_selected as $key => $val )
{
if ( $hexa ) $hexa .= ',' ;
$hexa .= $key ;
}
2012-10-25 22:30:17 +02:00
$hexafiltervalue = '' ;
2015-06-24 18:29:29 +02:00
if ( ! empty ( $array_filtervalue ) && is_array ( $array_filtervalue ))
2012-10-25 22:30:17 +02:00
{
2015-06-24 18:29:29 +02:00
foreach ( $array_filtervalue as $key => $val )
{
if ( $hexafiltervalue ) $hexafiltervalue .= ',' ;
$hexafiltervalue .= $key . '=' . $val ;
}
2012-10-25 22:30:17 +02:00
}
2015-07-29 12:10:04 +02:00
2007-03-24 17:46:02 +01:00
$objexport -> model_name = $export_name ;
$objexport -> datatoexport = $datatoexport ;
$objexport -> hexa = $hexa ;
2012-10-25 22:30:17 +02:00
$objexport -> hexafiltervalue = $hexafiltervalue ;
2009-03-03 01:42:40 +01:00
2007-03-24 17:46:02 +01:00
$result = $objexport -> create ( $user );
if ( $result >= 0 )
{
2015-12-08 11:35:08 +01:00
setEventMessages ( $langs -> trans ( " ExportModelSaved " , $objexport -> model_name ), null , 'mesgs' );
2007-03-24 17:46:02 +01:00
}
else
{
2008-12-04 21:27:01 +01:00
$langs -> load ( " errors " );
if ( $objexport -> errno == 'DB_ERROR_RECORD_ALREADY_EXISTS' )
2015-12-08 11:35:08 +01:00
setEventMessages ( $langs -> trans ( " ErrorExportDuplicateProfil " ), null , 'errors' );
2012-11-21 18:52:25 +01:00
else
2015-12-08 11:35:08 +01:00
setEventMessages ( $objexport -> error , $objexport -> errors , 'errors' );
2007-03-24 17:46:02 +01:00
}
}
else
{
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " ExportModelName " )), null , 'errors' );
2007-03-24 17:46:02 +01:00
}
2007-03-23 18:58:06 +01:00
}
2015-06-24 18:29:29 +02:00
// Reload an predefined export model
2007-03-23 18:58:06 +01:00
if ( $step == 2 && $action == 'select_model' )
2009-03-03 01:42:40 +01:00
{
2007-03-23 18:58:06 +01:00
$_SESSION [ " export_selected_fields " ] = array ();
2015-06-24 18:29:29 +02:00
$_SESSION [ " export_filtered_fields " ] = array ();
2012-10-25 22:30:17 +02:00
2007-03-23 18:58:06 +01:00
$array_selected = array ();
2012-10-25 22:30:17 +02:00
$array_filtervalue = array ();
2007-03-23 18:58:06 +01:00
$result = $objexport -> fetch ( $exportmodelid );
if ( $result > 0 )
{
2009-10-20 15:14:44 +02:00
$fieldsarray = explode ( ',' , $objexport -> hexa );
2007-03-24 17:46:02 +01:00
$i = 1 ;
foreach ( $fieldsarray as $val )
{
$array_selected [ $val ] = $i ;
$i ++ ;
}
$_SESSION [ " export_selected_fields " ] = $array_selected ;
2012-10-25 22:30:17 +02:00
$fieldsarrayvalue = explode ( ',' , $objexport -> hexafiltervalue );
$i = 1 ;
2015-06-24 18:29:29 +02:00
foreach ( $fieldsarrayvalue as $val )
2012-10-25 22:30:17 +02:00
{
2012-11-21 20:24:15 +01:00
$tmp = explode ( '=' , $val );
$array_filtervalue [ $tmp [ 0 ]] = $tmp [ 1 ];
2012-10-25 22:30:17 +02:00
$i ++ ;
}
2015-06-24 18:29:29 +02:00
$_SESSION [ " export_filtered_fields " ] = $array_filtervalue ;
2007-03-23 18:58:06 +01:00
}
}
2012-11-20 15:56:44 +01:00
// Get form with filters
2012-10-25 22:30:17 +02:00
if ( $step == 4 && $action == 'submitFormField' )
{
// on boucle sur les champs selectionne pour recuperer la valeur
if ( is_array ( $objexport -> array_export_TypeFields [ 0 ]))
{
2015-06-24 18:29:29 +02:00
$_SESSION [ " export_filtered_fields " ] = array ();
2012-11-20 15:56:44 +01:00
foreach ( $objexport -> array_export_TypeFields [ 0 ] as $code => $type ) // $code: s.fieldname $value: Text|Boolean|List:ccc
2012-10-25 22:30:17 +02:00
{
2012-11-20 15:56:44 +01:00
$newcode = ( string ) preg_replace ( '/\./' , '_' , $code );
//print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n<br>";
$filterqualified = 1 ;
if ( ! isset ( $_POST [ $newcode ]) || $_POST [ $newcode ] == '' ) $filterqualified = 0 ;
2012-11-21 18:51:49 +01:00
elseif ( preg_match ( '/^List/' , $type ) && ( is_numeric ( $_POST [ $newcode ]) && $_POST [ $newcode ] <= 0 )) $filterqualified = 0 ;
2012-11-20 15:56:44 +01:00
if ( $filterqualified )
2012-11-21 18:52:25 +01:00
{
2012-11-20 15:56:44 +01:00
//print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n";
$objexport -> array_export_FilterValue [ 0 ][ $code ] = $_POST [ $newcode ];
}
2012-10-25 22:30:17 +02:00
}
$array_filtervalue = ( ! empty ( $objexport -> array_export_FilterValue [ 0 ]) ? $objexport -> array_export_FilterValue [ 0 ] : '' );
2015-06-24 18:29:29 +02:00
$_SESSION [ " export_filtered_fields " ] = $array_filtervalue ;
2012-10-25 22:30:17 +02:00
}
}
2006-01-21 20:08:36 +01:00
/*
2009-08-12 14:59:14 +02:00
* View
2006-01-21 20:08:36 +01:00
*/
2005-11-19 23:09:12 +01:00
2006-01-08 18:08:20 +01:00
if ( $step == 1 || ! $datatoexport )
2005-11-19 23:09:12 +01:00
{
2009-08-12 14:59:14 +02:00
llxHeader ( '' , $langs -> trans ( " NewExport " ), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones' );
2006-01-08 18:08:20 +01:00
/*
* Affichage onglets
*/
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=1' ;
2006-04-01 04:51:20 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 1 " ;
2006-01-08 18:08:20 +01:00
$hselected = $h ;
$h ++ ;
/*
$head [ $h ][ 0 ] = '' ;
2006-04-01 04:51:20 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 2 " ;
2006-01-08 18:08:20 +01:00
$h ++ ;
*/
2009-03-03 01:42:40 +01:00
2017-05-09 16:52:03 +02:00
dol_fiche_head ( $head , $hselected , $langs -> trans ( " NewExport " ), - 1 );
2006-01-08 18:08:20 +01:00
2005-11-19 23:09:12 +01:00
print '<table class="notopnoleftnoright" width="100%">' ;
2018-01-03 14:46:18 +01:00
print '<div class="opacitymedium">' . $langs -> trans ( " SelectExportDataSet " ) . '</div><br>' ;
2009-03-03 01:42:40 +01:00
2005-11-19 23:09:12 +01:00
// Affiche les modules d'exports
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2007-10-29 12:54:02 +01:00
print '<td>' . $langs -> trans ( " Module " ) . '</td>' ;
2005-11-19 23:09:12 +01:00
print '<td>' . $langs -> trans ( " ExportableDatas " ) . '</td>' ;
print '<td> </td>' ;
print '</tr>' ;
$val = true ;
2011-09-17 21:49:50 +02:00
if ( count ( $objexport -> array_export_code ))
2005-11-19 23:09:12 +01:00
{
2006-01-22 17:14:33 +01:00
foreach ( $objexport -> array_export_code as $key => $value )
2005-11-19 23:09:12 +01:00
{
$val =! $val ;
2007-10-29 12:54:02 +01:00
print '<tr ' . $bc [ $val ] . '><td nospan="nospan">' ;
2008-12-05 12:15:05 +01:00
//print img_object($objexport->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' ';
2006-01-22 17:14:33 +01:00
print $objexport -> array_export_module [ $key ] -> getName ();
2005-11-19 23:09:12 +01:00
print '</td><td>' ;
2015-09-14 12:11:28 +02:00
$icon = preg_replace ( '/:.*$/' , '' , $objexport -> array_export_icon [ $key ]);
2011-02-05 19:40:52 +01:00
$label = $objexport -> array_export_label [ $key ];
//print $value.'-'.$icon.'-'.$label."<br>";
2015-09-14 12:11:28 +02:00
print img_object ( $objexport -> array_export_module [ $key ] -> getName (), $icon ) . ' ' ;
2011-02-05 19:40:52 +01:00
print $label ;
2006-01-08 18:08:20 +01:00
print '</td><td align="right">' ;
2008-12-08 15:31:47 +01:00
if ( $objexport -> array_export_perms [ $key ])
{
print '<a href="' . DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $objexport -> array_export_code [ $key ] . '">' . img_picto ( $langs -> trans ( " NewExport " ), 'filenew' ) . '</a>' ;
}
else
{
print $langs -> trans ( " NotEnoughPermissions " );
}
print '</td></tr>' ;
2005-11-19 23:09:12 +01:00
}
}
else
{
2009-03-25 22:26:15 +01:00
print '<tr><td ' . $bc [ false ] . ' colspan="3">' . $langs -> trans ( " NoExportableData " ) . '</td></tr>' ;
2005-11-19 23:09:12 +01:00
}
2009-03-03 01:42:40 +01:00
print '</table>' ;
2005-11-19 23:09:12 +01:00
print '</table>' ;
2009-03-03 01:42:40 +01:00
2006-08-19 17:50:48 +02:00
print '</div>' ;
2005-11-19 23:09:12 +01:00
}
2006-01-08 18:08:20 +01:00
if ( $step == 2 && $datatoexport )
2005-11-19 23:09:12 +01:00
{
2009-08-12 14:59:14 +02:00
llxHeader ( '' , $langs -> trans ( " NewExport " ), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones' );
2008-04-01 14:09:33 +02:00
2006-01-08 18:08:20 +01:00
/*
* Affichage onglets
*/
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=1' ;
2006-04-01 04:51:20 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 1 " ;
2006-01-08 18:08:20 +01:00
$h ++ ;
2006-06-24 14:41:30 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport ;
2006-04-01 04:51:20 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 2 " ;
2006-01-08 18:08:20 +01:00
$hselected = $h ;
$h ++ ;
2009-03-03 01:42:40 +01:00
2017-03-16 20:33:51 +01:00
dol_fiche_head ( $head , $hselected , $langs -> trans ( " NewExport " ), - 1 );
2006-01-08 18:08:20 +01:00
2017-03-16 20:33:51 +01:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2006-01-08 18:08:20 +01:00
print '<table width="100%" class="border">' ;
// Module
2017-03-16 20:33:51 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Module " ) . '</td>' ;
2006-01-08 18:08:20 +01:00
print '<td>' ;
2008-12-04 21:27:01 +01:00
//print img_object($objexport->array_export_module[0]->getName(),$objexport->array_export_module[0]->picto).' ';
2006-01-22 17:14:33 +01:00
print $objexport -> array_export_module [ 0 ] -> getName ();
2006-01-08 18:08:20 +01:00
print '</td></tr>' ;
2008-05-17 00:50:38 +02:00
// Lot de donnees a exporter
2017-03-16 20:33:51 +01:00
print '<tr><td>' . $langs -> trans ( " DatasetToExport " ) . '</td>' ;
2008-12-04 21:27:01 +01:00
print '<td>' ;
2015-09-14 12:11:28 +02:00
$icon = preg_replace ( '/:.*$/' , '' , $objexport -> array_export_icon [ 0 ]);
2011-02-05 19:40:52 +01:00
$label = $objexport -> array_export_label [ 0 ];
//print $value.'-'.$icon.'-'.$label."<br>";
2015-09-14 12:11:28 +02:00
print img_object ( $objexport -> array_export_module [ 0 ] -> getName (), $icon ) . ' ' ;
2011-02-05 19:40:52 +01:00
print $label ;
2008-12-04 21:27:01 +01:00
print '</td></tr>' ;
2009-03-03 01:42:40 +01:00
2007-03-24 17:46:02 +01:00
print '</table>' ;
2017-03-16 20:33:51 +01:00
print '</div>' ;
2017-06-13 18:50:31 +02:00
2017-03-16 20:33:51 +01:00
dol_fiche_end ();
2017-06-13 18:50:31 +02:00
2007-03-24 17:46:02 +01:00
print '<br>' ;
2009-03-03 01:42:40 +01:00
2009-09-03 01:46:55 +02:00
// Combo list of export models
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="post">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2007-03-23 18:58:06 +01:00
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 . '">' ;
2009-09-03 01:46:55 +02:00
print '<table><tr><td colspan="2">' ;
print $langs -> trans ( " SelectExportFields " ) . ' ' ;
2018-01-18 12:34:22 +01:00
if ( empty ( $conf -> global -> EXPORTS_SHARE_MODELS )) $htmlother -> select_export_model ( $exportmodelid , 'exportmodelid' , $datatoexport , 1 , $user -> id );
else $htmlother -> select_export_model ( $exportmodelid , 'exportmodelid' , $datatoexport , 1 );
2017-03-16 20:33:51 +01:00
print ' ' ;
2007-03-23 18:58:06 +01:00
print '<input type="submit" class="button" value="' . $langs -> trans ( " Select " ) . '">' ;
2007-03-24 17:46:02 +01:00
print '</td></tr></table>' ;
print '</form>' ;
2009-03-03 01:42:40 +01:00
2005-11-19 23:09:12 +01:00
2006-01-08 18:08:20 +01:00
print '<table class="noborder" width="100%">' ;
2006-02-25 15:26:29 +01:00
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Entities " ) . '</td>' ;
print '<td>' . $langs -> trans ( " ExportableFields " ) . '</td>' ;
2009-10-03 14:08:48 +02:00
print '<td width="100" align="center">' ;
2013-09-24 18:06:07 +02:00
print '<a class="liste_titre" title=' . $langs -> trans ( " All " ) . ' alt=' . $langs -> trans ( " All " ) . ' href="' . $_SERVER [ " PHP_SELF " ] . '?step=2&datatoexport=' . $datatoexport . '&action=selectfield&field=all">' . $langs -> trans ( " All " ) . " </a> " ;
2017-06-13 18:50:31 +02:00
print ' / ' ;
2013-09-24 18:06:07 +02:00
print '<a class="liste_titre" title=' . $langs -> trans ( " None " ) . ' alt=' . $langs -> trans ( " None " ) . ' href="' . $_SERVER [ " PHP_SELF " ] . '?step=2&datatoexport=' . $datatoexport . '&action=unselectfield&field=all">' . $langs -> trans ( " None " ) . " </a> " ;
2008-05-17 00:50:38 +02:00
print '</td>' ;
2007-07-02 21:42:46 +02:00
print '<td width="44%">' . $langs -> trans ( " ExportedFields " ) . '</td>' ;
2006-01-08 18:08:20 +01:00
print '</tr>' ;
// Champs exportables
2006-01-22 17:14:33 +01:00
$fieldsarray = $objexport -> array_export_fields [ 0 ];
2009-10-03 14:08:48 +02:00
// Select request if all fields are selected
2012-11-20 15:56:44 +01:00
$sqlmaxforexport = $objexport -> build_sql ( 0 , array (), array ());
2006-01-08 18:08:20 +01:00
2012-11-14 00:27:25 +01: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 01:42:40 +01:00
2007-03-23 18:58:06 +01:00
$i = 0 ;
2009-03-03 01:42:40 +01:00
2006-01-08 18:08:20 +01:00
foreach ( $fieldsarray as $code => $label )
{
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2007-03-23 18:58:06 +01:00
$i ++ ;
2007-03-24 17:46:02 +01:00
2009-11-08 20:28:44 +01:00
$entity = ( ! empty ( $objexport -> array_export_entities [ 0 ][ $code ]) ? $objexport -> array_export_entities [ 0 ][ $code ] : $objexport -> array_export_icon [ 0 ]);
2017-07-28 14:54:13 +02:00
$entityicon = strtolower ( ! empty ( $entitytoicon [ $entity ]) ? $entitytoicon [ $entity ] : $entity );
2012-10-25 22:30:17 +02:00
$entitylang = ( ! empty ( $entitytolang [ $entity ]) ? $entitytolang [ $entity ] : $entity );
2006-02-25 15:26:29 +01:00
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2011-02-05 19:40:52 +01:00
// If value of entityicon=entitylang='icon:Label'
2016-06-24 02:19:41 +02:00
//print $code.'-'.$label.'-'.$entity;
2017-06-13 18:50:31 +02:00
2011-02-05 19:40:52 +01:00
$tmparray = explode ( ':' , $entityicon );
2011-09-17 21:49:50 +02:00
if ( count ( $tmparray ) >= 2 )
2011-02-05 19:40:52 +01:00
{
$entityicon = $tmparray [ 0 ];
$entitylang = $tmparray [ 1 ];
}
print img_object ( '' , $entityicon ) . ' ' . $langs -> trans ( $entitylang );
print '</td>' ;
2017-06-13 18:50:31 +02:00
$text = ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '<i>' ) . $langs -> trans ( $label ) . ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '</i>' );
2009-11-08 20:28:44 +01:00
$tablename = getablenamefromfield ( $code , $sqlmaxforexport );
$htmltext = '<b>' . $langs -> trans ( " Name " ) . " :</b> " . $text . '<br>' ;
2017-05-09 16:52:03 +02:00
if ( ! empty ( $objexport -> array_export_special [ 0 ][ $code ]))
{
$htmltext .= '<b>' . $langs -> trans ( " ComputedField " ) . " -> " . $langs -> trans ( " Method " ) . " :</b> " . $objexport -> array_export_special [ 0 ][ $code ] . " <br> " ;
}
else
{
$htmltext .= '<b>' . $langs -> trans ( " Table " ) . " -> " . $langs -> trans ( " Field " ) . " :</b> " . $tablename . " -> " . preg_replace ( '/^.*\./' , '' , $code ) . " <br> " ;
}
2017-06-13 18:50:31 +02:00
if ( ! empty ( $objexport -> array_export_examplevalues [ 0 ][ $code ]))
2015-09-10 12:34:00 +02:00
{
$htmltext .= $langs -> trans ( " SourceExample " ) . ': <b>' . $objexport -> array_export_examplevalues [ 0 ][ $code ] . '</b><br>' ;
}
2017-06-13 18:50:31 +02:00
if ( ! empty ( $objexport -> array_export_TypeFields [ 0 ][ $code ]))
{
$htmltext .= $langs -> trans ( " Type " ) . ': <b>' . $objexport -> array_export_TypeFields [ 0 ][ $code ] . '</b><br>' ;
}
if ( isset ( $array_selected [ $code ]) && $array_selected [ $code ])
2006-01-08 18:08:20 +01:00
{
2008-05-17 00:50:38 +02:00
// Selected fields
2006-01-08 18:08:20 +01:00
print '<td> </td>' ;
2017-02-08 10:45:20 +01:00
print '<td align="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>' ;
2009-10-03 14:08:48 +02:00
print '<td>' ;
2011-02-05 19:40:52 +01:00
//print $text.'-'.$htmltext."<br>";
2016-03-25 15:24:57 +01:00
print $form -> textwithpicto ( $text , $htmltext );
2009-10-03 14:08:48 +02:00
//print ' ('.$code.')';
print '</td>' ;
2006-01-08 18:08:20 +01:00
}
else
{
2008-05-17 00:50:38 +02:00
// Fields not selected
2009-10-03 14:08:48 +02:00
print '<td>' ;
2011-02-05 19:40:52 +01:00
//print $text.'-'.$htmltext."<br>";
2016-03-25 15:24:57 +01:00
print $form -> textwithpicto ( $text , $htmltext );
2009-10-03 14:08:48 +02:00
//print ' ('.$code.')';
print '</td>' ;
2017-02-08 10:45:20 +01:00
print '<td align="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>' ;
2006-01-08 18:08:20 +01:00
print '<td> </td>' ;
}
print '</tr>' ;
}
2007-03-23 18:58:06 +01:00
2006-01-08 18:08:20 +01:00
print '</table>' ;
2017-06-13 18:50:31 +02:00
2006-01-08 18:08:20 +01:00
/*
* Barre d ' action
*/
2017-05-09 16:52:03 +02:00
print '<div class="tabsAction tabsActionNoBottom">' ;
2006-01-08 18:08:20 +01:00
2011-09-17 21:49:50 +02:00
if ( count ( $array_selected ))
2007-03-24 17:46:02 +01:00
{
2012-10-25 22:30:17 +02:00
// If filters exist
2012-11-14 00:27:25 +01:00
if ( $usefilters && isset ( $objexport -> array_export_TypeFields [ 0 ]) && is_array ( $objexport -> array_export_TypeFields [ 0 ]))
2012-10-25 22:30:17 +02:00
{
print '<a class="butAction" href="export.php?step=3&datatoexport=' . $datatoexport . '">' . $langs -> trans ( " NextStep " ) . '</a>' ;
}
else
{
print '<a class="butAction" href="export.php?step=4&datatoexport=' . $datatoexport . '">' . $langs -> trans ( " NextStep " ) . '</a>' ;
}
2008-05-17 00:50:38 +02:00
}
else
{
2009-10-03 14:08:48 +02:00
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " SelectAtLeastOneField " )) . '">' . $langs -> trans ( " NextStep " ) . '</a>' ;
2007-03-24 17:46:02 +01:00
}
2009-03-03 01:42:40 +01:00
2006-08-19 17:50:48 +02:00
print '</div>' ;
2007-03-24 17:46:02 +01:00
2006-01-08 18:08:20 +01:00
}
if ( $step == 3 && $datatoexport )
2012-10-25 22:30:17 +02:00
{
2016-07-15 14:14:55 +02:00
if ( count ( $array_selected ) < 1 ) // This occurs when going back to page after sessecion expired
{
// Switch to step 2
header ( " Location: " . DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport );
exit ;
}
llxHeader ( '' , $langs -> trans ( " NewExport " ), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones' );
2012-10-25 22:30:17 +02:00
/*
* Affichage onglets
*/
$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 " ;
$hselected = $h ;
$h ++ ;
2017-03-16 20:33:51 +01:00
dol_fiche_head ( $head , $hselected , $langs -> trans ( " NewExport " ), - 1 );
2012-10-25 22:30:17 +02:00
2017-03-16 20:33:51 +01:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2012-10-25 22:30:17 +02:00
print '<table width="100%" class="border">' ;
// Module
2017-03-16 20:33:51 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Module " ) . '</td>' ;
2012-10-25 22:30:17 +02: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>' ;
// Lot de donnees a exporter
2017-03-16 20:33:51 +01:00
print '<tr><td>' . $langs -> trans ( " DatasetToExport " ) . '</td>' ;
2012-10-25 22:30:17 +02:00
print '<td>' ;
2015-09-14 12:11:28 +02:00
$icon = preg_replace ( '/:.*$/' , '' , $objexport -> array_export_icon [ 0 ]);
2012-10-25 22:30:17 +02:00
$label = $objexport -> array_export_label [ 0 ];
//print $value.'-'.$icon.'-'.$label."<br>";
2015-09-14 12:11:28 +02:00
print img_object ( $objexport -> array_export_module [ 0 ] -> getName (), $icon ) . ' ' ;
2012-10-25 22:30:17 +02:00
print $label ;
print '</td></tr>' ;
// Nbre champs exportes
2017-03-16 20:33:51 +01:00
print '<tr><td>' . $langs -> trans ( " ExportedFields " ) . '</td>' ;
2012-10-25 22:30:17 +02:00
$list = '' ;
foreach ( $array_selected as $code => $value )
{
$list .= ( ! empty ( $list ) ? ', ' : '' );
$list .= ( isset ( $objexport -> array_export_fields [ 0 ][ $code ]) ? $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]) : '' );
}
print '<td>' . $list . '</td></tr>' ;
print '</table>' ;
2017-03-16 20:33:51 +01:00
print '</div>' ;
2017-06-13 18:50:31 +02:00
2012-10-25 22:30:17 +02:00
print '<br>' ;
// Combo list of export models
2012-11-14 00:27:25 +01:00
print $langs -> trans ( " SelectFilterFields " ) . '<br>' ;
2012-10-25 22:30:17 +02:00
// un formulaire en plus pour recuperer les filtres
2012-11-14 00:27:25 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '?step=4&action=submitFormField&datatoexport=' . $datatoexport . '" name="FilterField" method="post">' ;
2012-10-25 22:30:17 +02:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Entities " ) . '</td>' ;
2012-11-14 00:27:25 +01:00
//print '<td>'.$langs->trans("ExportableFields").'</td>';
//print '<td align="center"></td>';
print '<td>' . $langs -> trans ( " ExportableFields " ) . '</td>' ;
2012-10-25 22:30:17 +02:00
print '<td width="25%">' . $langs -> trans ( " FilteredFieldsValues " ) . '</td>' ;
print '</tr>' ;
// Champs exportables
$fieldsarray = $objexport -> array_export_fields [ 0 ];
// Champs filtrable
$Typefieldsarray = $objexport -> array_export_TypeFields [ 0 ];
// valeur des filtres
$ValueFiltersarray = ( ! empty ( $objexport -> array_export_FilterValue [ 0 ]) ? $objexport -> array_export_FilterValue [ 0 ] : '' );
// Select request if all fields are selected
2012-11-20 15:56:44 +01:00
$sqlmaxforexport = $objexport -> build_sql ( 0 , array (), array ());
2012-10-25 22:30:17 +02:00
$i = 0 ;
2012-11-14 00:27:25 +01:00
// on boucle sur les champs
foreach ( $fieldsarray as $code => $label )
2012-10-25 22:30:17 +02:00
{
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2012-10-25 22:30:17 +02:00
$i ++ ;
$entity = ( ! empty ( $objexport -> array_export_entities [ 0 ][ $code ]) ? $objexport -> array_export_entities [ 0 ][ $code ] : $objexport -> array_export_icon [ 0 ]);
2017-07-28 14:54:13 +02:00
$entityicon = strtolower ( ! empty ( $entitytoicon [ $entity ]) ? $entitytoicon [ $entity ] : $entity );
2012-10-25 22:30:17 +02:00
$entitylang = ( ! empty ( $entitytolang [ $entity ]) ? $entitytolang [ $entity ] : $entity );
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2012-10-25 22:30:17 +02:00
// If value of entityicon=entitylang='icon:Label'
$tmparray = explode ( ':' , $entityicon );
if ( count ( $tmparray ) >= 2 )
{
$entityicon = $tmparray [ 0 ];
$entitylang = $tmparray [ 1 ];
}
print img_object ( '' , $entityicon ) . ' ' . $langs -> trans ( $entitylang );
print '</td>' ;
2012-11-20 14:07:52 +01:00
// Field name
2012-10-25 22:30:17 +02:00
$labelName = ( ! empty ( $fieldsarray [ $code ]) ? $fieldsarray [ $code ] : '' );
$ValueFilter = ( ! empty ( $array_filtervalue [ $code ]) ? $array_filtervalue [ $code ] : '' );
2017-06-13 18:50:31 +02:00
$text = ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '<i>' ) . $langs -> trans ( $labelName ) . ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '</i>' );
2012-10-25 22:30:17 +02:00
$tablename = getablenamefromfield ( $code , $sqlmaxforexport );
2012-11-14 00:27:25 +01:00
$htmltext = '<b>' . $langs -> trans ( " Name " ) . ':</b> ' . $text . '<br>' ;
2017-06-13 18:50:31 +02:00
if ( ! empty ( $objexport -> array_export_special [ 0 ][ $code ]))
{
$htmltext .= '<b>' . $langs -> trans ( " ComputedField " ) . " -> " . $langs -> trans ( " Method " ) . " :</b> " . $objexport -> array_export_special [ 0 ][ $code ] . " <br> " ;
}
else
{
$htmltext .= '<b>' . $langs -> trans ( " Table " ) . " -> " . $langs -> trans ( " Field " ) . " :</b> " . $tablename . " -> " . preg_replace ( '/^.*\./' , '' , $code ) . " <br> " ;
}
2015-09-12 15:19:19 +02:00
if ( ! empty ( $objexport -> array_export_examplevalues [ 0 ][ $code ]))
{
$htmltext .= $langs -> trans ( " SourceExample " ) . ': <b>' . $objexport -> array_export_examplevalues [ 0 ][ $code ] . '</b><br>' ;
}
2017-06-13 18:50:31 +02:00
if ( ! empty ( $objexport -> array_export_TypeFields [ 0 ][ $code ]))
{
$htmltext .= $langs -> trans ( " Type " ) . ': <b>' . $objexport -> array_export_TypeFields [ 0 ][ $code ] . '</b><br>' ;
}
2012-11-14 00:27:25 +01:00
print '<td>' ;
2016-03-25 15:24:57 +01:00
print $form -> textwithpicto ( $text , $htmltext );
2012-11-14 00:27:25 +01:00
print '</td>' ;
2012-11-21 18:52:25 +01:00
2012-11-20 14:07:52 +01:00
// Filter value
2012-11-14 00:27:25 +01:00
print '<td>' ;
2014-08-10 13:37:39 +02:00
if ( ! empty ( $Typefieldsarray [ $code ])) // Example: Text, List:c_country:label:rowid, Number, Boolean
2012-10-25 22:30:17 +02:00
{
2012-11-14 00:27:25 +01:00
$szInfoFiltre = $objexport -> genDocFilter ( $Typefieldsarray [ $code ]);
2012-11-20 14:07:52 +01:00
if ( $szInfoFiltre ) // Is there an info help for this filter ?
2012-11-14 00:27:25 +01:00
{
$tmp = $objexport -> build_filterField ( $Typefieldsarray [ $code ], $code , $ValueFilter );
2016-03-25 15:24:57 +01:00
print $form -> textwithpicto ( $tmp , $szInfoFiltre );
2012-11-14 00:27:25 +01:00
}
2012-10-25 22:30:17 +02:00
else
2012-11-14 00:27:25 +01:00
{
print $objexport -> build_filterField ( $Typefieldsarray [ $code ], $code , $ValueFilter );
}
2012-10-25 22:30:17 +02:00
}
2012-11-14 00:27:25 +01:00
print '</td>' ;
2012-10-25 22:30:17 +02:00
print '</tr>' ;
}
print '</table>' ;
print '</div>' ;
/*
* Barre d ' action
2012-11-21 18:52:25 +01:00
*/
2017-05-09 16:52:03 +02:00
print '<div class="tabsAction tabsActionNoBottom">' ;
2012-10-25 22:30:17 +02:00
// il n'est pas obligatoire de filtrer les champs
print '<a class="butAction" href="javascript:FilterField.submit();">' . $langs -> trans ( " NextStep " ) . '</a>' ;
print '</div>' ;
}
if ( $step == 4 && $datatoexport )
2006-01-08 18:08:20 +01:00
{
2016-07-15 14:14:55 +02:00
if ( count ( $array_selected ) < 1 ) // This occurs when going back to page after sessecion expired
{
// Switch to step 2
header ( " Location: " . DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport );
exit ;
}
2017-06-13 18:50:31 +02:00
2006-01-21 20:08:36 +01:00
asort ( $array_selected );
2009-08-12 14:59:14 +02:00
llxHeader ( '' , $langs -> trans ( " NewExport " ), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones' );
2009-03-03 01:42:40 +01:00
2006-01-08 18:08:20 +01:00
/*
* Affichage onglets
*/
2012-11-14 00:27:25 +01:00
$stepoffset = 0 ;
2006-01-08 18:08:20 +01:00
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=1' ;
2006-04-01 04:51:20 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 1 " ;
2006-01-08 18:08:20 +01:00
$h ++ ;
2006-06-24 14:41:30 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport ;
2006-04-01 04:51:20 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 2 " ;
2006-01-08 18:08:20 +01:00
$h ++ ;
2012-10-25 22:30:17 +02:00
// If filters exist
2012-11-14 00:27:25 +01:00
if ( $usefilters && isset ( $objexport -> array_export_TypeFields [ 0 ]) && is_array ( $objexport -> array_export_TypeFields [ 0 ]))
2012-10-25 22:30:17 +02:00
{
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=3&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 3 " ;
$h ++ ;
2012-11-14 00:27:25 +01:00
$stepoffset ++ ;
2012-10-25 22:30:17 +02:00
}
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=4&datatoexport=' . $datatoexport ;
2012-11-14 00:27:25 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " " . ( 3 + $stepoffset );
2006-01-08 18:08:20 +01:00
$hselected = $h ;
$h ++ ;
2009-03-03 01:42:40 +01:00
2017-03-16 20:33:51 +01:00
dol_fiche_head ( $head , $hselected , $langs -> trans ( " NewExport " ), - 1 );
2006-01-08 18:08:20 +01:00
2017-03-16 20:33:51 +01:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2006-01-08 18:08:20 +01:00
print '<table width="100%" class="border">' ;
// Module
2017-05-09 16:52:03 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Module " ) . '</td>' ;
2006-01-08 18:08:20 +01:00
print '<td>' ;
2008-12-04 21:27:01 +01:00
//print img_object($objexport->array_export_module[0]->getName(),$objexport->array_export_module[0]->picto).' ';
2006-01-22 17:14:33 +01:00
print $objexport -> array_export_module [ 0 ] -> getName ();
2006-01-08 18:08:20 +01:00
print '</td></tr>' ;
2009-04-28 10:42:56 +02:00
// Lot de donnees a exporter
2017-05-09 16:52:03 +02:00
print '<tr><td>' . $langs -> trans ( " DatasetToExport " ) . '</td>' ;
2008-12-04 21:27:01 +01:00
print '<td>' ;
2015-09-14 12:11:28 +02:00
$icon = preg_replace ( '/:.*$/' , '' , $objexport -> array_export_icon [ 0 ]);
print img_object ( $objexport -> array_export_module [ 0 ] -> getName (), $icon ) . ' ' ;
2008-12-04 21:27:01 +01:00
print $objexport -> array_export_label [ 0 ];
print '</td></tr>' ;
2006-01-08 18:08:20 +01:00
2012-11-20 15:56:44 +01:00
// List of exported fields
2017-05-09 16:52:03 +02:00
print '<tr><td>' . $langs -> trans ( " ExportedFields " ) . '</td>' ;
2006-01-08 18:08:20 +01:00
$list = '' ;
2006-01-21 20:08:36 +01:00
foreach ( $array_selected as $code => $value )
2006-01-08 18:08:20 +01:00
{
2012-12-06 10:43:27 +01:00
$list .= ( ! empty ( $list ) ? ', ' : '' );
2006-01-22 17:14:33 +01:00
$list .= $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]);
2006-01-08 18:08:20 +01:00
}
2012-11-20 15:56:44 +01:00
print '<td>' . $list . '</td>' ;
print '</tr>' ;
2006-01-08 18:08:20 +01:00
2012-11-20 15:56:44 +01:00
// List of filtered fiels
2012-10-25 22:30:17 +02:00
if ( isset ( $objexport -> array_export_TypeFields [ 0 ]) && is_array ( $objexport -> array_export_TypeFields [ 0 ]))
{
print '<tr><td width="25%">' . $langs -> trans ( " FilteredFields " ) . '</td>' ;
$list = '' ;
2012-12-06 10:43:27 +01:00
if ( ! empty ( $array_filtervalue ))
2012-10-25 22:30:17 +02:00
{
2012-12-06 10:43:27 +01:00
foreach ( $array_filtervalue as $code => $value )
2012-11-20 15:56:44 +01:00
{
2012-12-06 10:43:27 +01:00
if ( isset ( $objexport -> array_export_fields [ 0 ][ $code ]))
{
$list .= ( $list ? ', ' : '' );
2014-08-29 20:25:54 +02:00
if ( isset ( $array_filtervalue [ $code ]) && preg_match ( '/^\s*[<>]/' , $array_filtervalue [ $code ])) $list .= $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]) . ( isset ( $array_filtervalue [ $code ]) ? $array_filtervalue [ $code ] : '' );
else $list .= $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]) . " =' " . ( isset ( $array_filtervalue [ $code ]) ? $array_filtervalue [ $code ] : '' ) . " ' " ;
2012-12-06 10:43:27 +01:00
}
2012-10-29 10:36:26 +01:00
}
2012-10-25 22:30:17 +02:00
}
2012-12-06 10:43:27 +01:00
print '<td>' . ( ! empty ( $list ) ? $list : $langs -> trans ( " None " )) . '</td>' ;
2012-11-20 15:56:44 +01:00
print '</tr>' ;
2012-10-25 22:30:17 +02:00
}
2006-01-08 18:08:20 +01:00
print '</table>' ;
2017-03-16 20:33:51 +01:00
print '</div>' ;
2017-06-13 18:50:31 +02:00
2005-11-19 23:09:12 +01:00
print '<br>' ;
2009-03-03 01:42:40 +01:00
2009-10-03 14:08:48 +02:00
// Select request if all fields are selected
2012-11-20 15:56:44 +01:00
$sqlmaxforexport = $objexport -> build_sql ( 0 , array (), array ());
2009-10-03 14:08:48 +02:00
2006-01-08 18:08:20 +01:00
print $langs -> trans ( " ChooseFieldsOrdersAndTitle " ) . '<br>' ;
2009-03-03 01:42:40 +01:00
2006-01-08 18:08:20 +01:00
print '<table class="noborder" width="100%">' ;
2006-02-25 15:26:29 +01:00
print '<tr class="liste_titre">' ;
2007-09-08 17:57:58 +02:00
print '<td>' . $langs -> trans ( " Entities " ) . '</td>' ;
2006-02-25 15:26:29 +01:00
print '<td>' . $langs -> trans ( " ExportedFields " ) . '</td>' ;
2006-01-21 20:08:36 +01:00
print '<td align="right" colspan="2">' . $langs -> trans ( " Position " ) . '</td>' ;
2009-10-03 14:08:48 +02:00
//print '<td> </td>';
//print '<td>'.$langs->trans("FieldsTitle").'</td>';
2005-11-19 23:09:12 +01:00
print '</tr>' ;
2006-01-08 18:08:20 +01:00
foreach ( $array_selected as $code => $value )
{
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2006-02-25 15:26:29 +01:00
2009-11-08 20:28:44 +01:00
$entity = ( ! empty ( $objexport -> array_export_entities [ 0 ][ $code ]) ? $objexport -> array_export_entities [ 0 ][ $code ] : $objexport -> array_export_icon [ 0 ]);
2017-07-28 14:54:13 +02:00
$entityicon = strtolower ( ! empty ( $entitytoicon [ $entity ]) ? $entitytoicon [ $entity ] : $entity );
2012-10-25 22:30:17 +02:00
$entitylang = ( ! empty ( $entitytolang [ $entity ]) ? $entitytolang [ $entity ] : $entity );
2006-02-25 15:26:29 +01:00
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2011-02-05 19:40:52 +01:00
// If value of entityicon=entitylang='icon:Label'
$tmparray = explode ( ':' , $entityicon );
2011-09-17 21:49:50 +02:00
if ( count ( $tmparray ) >= 2 )
2011-02-05 19:40:52 +01:00
{
$entityicon = $tmparray [ 0 ];
$entitylang = $tmparray [ 1 ];
}
print img_object ( '' , $entityicon ) . ' ' . $langs -> trans ( $entitylang );
print '</td>' ;
2009-03-03 01:42:40 +01:00
2017-06-13 18:50:31 +02:00
$labelName = $objexport -> array_export_fields [ 0 ][ $code ];
$text = ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '<i>' ) . $langs -> trans ( $labelName ) . ( empty ( $objexport -> array_export_special [ 0 ][ $code ]) ? '' : '</i>' );
2009-10-03 14:08:48 +02:00
$tablename = getablenamefromfield ( $code , $sqlmaxforexport );
2017-06-13 18:50:31 +02:00
$htmltext = '<b>' . $langs -> trans ( " Name " ) . ':</b> ' . $text . '<br>' ;
if ( ! empty ( $objexport -> array_export_special [ 0 ][ $code ]))
{
$htmltext .= '<b>' . $langs -> trans ( " ComputedField " ) . " -> " . $langs -> trans ( " Method " ) . " :</b> " . $objexport -> array_export_special [ 0 ][ $code ] . " <br> " ;
}
else
{
$htmltext .= '<b>' . $langs -> trans ( " Table " ) . " -> " . $langs -> trans ( " Field " ) . " :</b> " . $tablename . " -> " . preg_replace ( '/^.*\./' , '' , $code ) . " <br> " ;
}
if ( ! empty ( $objexport -> array_export_examplevalues [ 0 ][ $code ]))
{
$htmltext .= $langs -> trans ( " SourceExample " ) . ': <b>' . $objexport -> array_export_examplevalues [ 0 ][ $code ] . '</b><br>' ;
}
if ( ! empty ( $objexport -> array_export_TypeFields [ 0 ][ $code ]))
{
$htmltext .= $langs -> trans ( " Type " ) . ': <b>' . $objexport -> array_export_TypeFields [ 0 ][ $code ] . '</b><br>' ;
}
print '<td>' ;
2016-03-25 15:24:57 +01:00
print $form -> textwithpicto ( $text , $htmltext );
2009-10-03 14:08:48 +02:00
//print ' ('.$code.')';
print '</td>' ;
2006-01-08 18:08:20 +01:00
2006-01-21 20:08:36 +01:00
print '<td align="right" width="100">' ;
print $value . ' ' ;
print '</td><td align="center" width="20">' ;
2012-10-25 22:30:17 +02:00
if ( $value < count ( $array_selected )) print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?step=' . $step . '&datatoexport=' . $datatoexport . '&action=downfield&field=' . $code . '">' . img_down () . '</a>' ;
if ( $value > 1 ) print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?step=' . $step . '&datatoexport=' . $datatoexport . '&action=upfield&field=' . $code . '">' . img_up () . '</a>' ;
2006-01-08 18:08:20 +01:00
print '</td>' ;
2009-10-03 14:08:48 +02:00
//print '<td> </td>';
//print '<td>'.$langs->trans($objexport->array_export_fields[0][$code]).'</td>';
2006-01-08 18:08:20 +01:00
print '</tr>' ;
}
2007-03-24 17:46:02 +01:00
2006-01-08 18:08:20 +01:00
print '</table>' ;
2009-03-03 01:42:40 +01:00
2008-12-04 21:27:01 +01:00
print '</div>' ;
/*
* Barre d ' action
*
*/
print '<div class="tabsAction">' ;
2011-09-17 21:49:50 +02:00
if ( count ( $array_selected ))
2008-12-04 21:27:01 +01:00
{
2012-10-25 22:30:17 +02:00
print '<a class="butAction" href="export.php?step=' . ( $step + 1 ) . '&datatoexport=' . $datatoexport . '">' . $langs -> trans ( " NextStep " ) . '</a>' ;
2008-12-04 21:27:01 +01:00
}
print '</div>' ;
2009-03-03 01:42:40 +01:00
2008-12-04 21:27:01 +01:00
// Area for profils export
2011-09-17 21:49:50 +02:00
if ( count ( $array_selected ))
2007-03-24 17:46:02 +01:00
{
print '<br>' ;
print $langs -> trans ( " SaveExportModel " );
2009-03-03 01:42:40 +01:00
2007-03-24 17:46:02 +01:00
print '<form class="nocellnopadd" action="export.php" method="post">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2007-03-24 17:46:02 +01: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 . '">' ;
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " ExportModelName " ) . '</td>' ;
print '<td> </td>' ;
print '</tr>' ;
2018-06-18 10:12:19 +02:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2008-12-04 21:27:01 +01:00
print '<td><input name="export_name" size="32" value=""></td><td align="right">' ;
2007-03-24 17:46:02 +01:00
print '<input type="submit" class="button" value="' . $langs -> trans ( " Save " ) . '">' ;
print '</td></tr>' ;
2008-12-04 21:27:01 +01:00
// List of existing export profils
$sql = " SELECT rowid, label " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " export_model " ;
$sql .= " WHERE type = ' " . $datatoexport . " ' " ;
2018-01-18 12:34:22 +01:00
if ( empty ( $conf -> global -> EXPORTS_SHARE_MODELS )) $sql .= " AND fk_user= " . $user -> id ;
2008-12-04 21:27:01 +01:00
$sql .= " ORDER BY rowid " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
$i = 0 ;
while ( $i < $num )
{
$obj = $db -> fetch_object ( $resql );
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' ;
2008-12-04 21:27:01 +01:00
print $obj -> label ;
print '</td><td align="right">' ;
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?step=' . $step . '&datatoexport=' . $datatoexport . '&action=deleteprof&id=' . $obj -> rowid . '">' ;
print img_delete ();
print '</a>' ;
print '</tr>' ;
$i ++ ;
}
}
else {
2009-02-20 23:53:15 +01:00
dol_print_error ( $this -> db );
2008-12-04 21:27:01 +01:00
}
2009-03-03 01:42:40 +01:00
2007-03-24 17:46:02 +01:00
print '</table>' ;
print '</form>' ;
}
2006-01-08 18:08:20 +01:00
}
2012-10-25 22:30:17 +02:00
if ( $step == 5 && $datatoexport )
2006-01-08 18:08:20 +01:00
{
2016-07-15 14:14:55 +02:00
if ( count ( $array_selected ) < 1 ) // This occurs when going back to page after sessecion expired
{
// Switch to step 2
header ( " Location: " . DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport );
exit ;
}
2017-06-13 18:50:31 +02:00
2015-05-05 13:46:28 +02:00
asort ( $array_selected );
2006-01-21 20:08:36 +01:00
2009-08-12 14:59:14 +02:00
llxHeader ( '' , $langs -> trans ( " NewExport " ), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones' );
2009-03-03 01:42:40 +01:00
2006-01-08 18:08:20 +01:00
/*
* Affichage onglets
*/
$h = 0 ;
2012-11-14 00:27:25 +01:00
$stepoffset = 0 ;
2006-01-08 18:08:20 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=1' ;
2006-04-01 04:51:20 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 1 " ;
2006-01-08 18:08:20 +01:00
$h ++ ;
2006-06-24 14:41:30 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=2&datatoexport=' . $datatoexport ;
2006-04-01 04:51:20 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 2 " ;
2006-01-08 18:08:20 +01:00
$h ++ ;
2012-10-25 22:30:17 +02:00
// si le filtrage est parametre pour l'export ou pas
2012-11-14 00:27:25 +01:00
if ( $usefilters && isset ( $objexport -> array_export_TypeFields [ 0 ]) && is_array ( $objexport -> array_export_TypeFields [ 0 ]))
2012-10-25 22:30:17 +02:00
{
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=3&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " 3 " ;
$h ++ ;
2012-11-14 00:27:25 +01:00
$stepoffset ++ ;
2012-10-25 22:30:17 +02:00
}
2012-11-14 00:27:25 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=4&datatoexport=' . $datatoexport ;
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " " . ( 3 + $stepoffset );
2006-01-08 18:08:20 +01:00
$h ++ ;
2012-10-25 22:30:17 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/exports/export.php?step=5&datatoexport=' . $datatoexport ;
2012-11-14 00:27:25 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Step " ) . " " . ( 4 + $stepoffset );
2006-01-08 18:08:20 +01:00
$hselected = $h ;
$h ++ ;
2009-03-03 01:42:40 +01:00
2017-03-16 20:33:51 +01:00
dol_fiche_head ( $head , $hselected , $langs -> trans ( " NewExport " ), - 1 );
2006-01-08 18:08:20 +01:00
2012-10-29 10:36:26 +01:00
/*
* Confirmation suppression fichier
*/
if ( $action == 'remove_file' )
{
2016-03-25 15:53:44 +01: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 );
2014-05-03 02:15:33 +02:00
2012-10-29 10:36:26 +01:00
}
2017-03-16 20:33:51 +01:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2017-06-13 18:50:31 +02:00
2006-01-08 18:08:20 +01:00
print '<table width="100%" class="border">' ;
// Module
2017-03-16 20:33:51 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Module " ) . '</td>' ;
2006-01-08 18:08:20 +01:00
print '<td>' ;
2008-12-04 21:27:01 +01:00
//print img_object($objexport->array_export_module[0]->getName(),$objexport->array_export_module[0]->picto).' ';
2006-01-22 17:14:33 +01:00
print $objexport -> array_export_module [ 0 ] -> getName ();
2005-11-19 23:09:12 +01:00
print '</td></tr>' ;
2008-05-17 02:14:25 +02:00
// Lot de donnees a exporter
2017-03-16 20:33:51 +01:00
print '<tr><td>' . $langs -> trans ( " DatasetToExport " ) . '</td>' ;
2008-12-04 21:27:01 +01:00
print '<td>' ;
2015-09-14 12:11:28 +02:00
$icon = preg_replace ( '/:.*$/' , '' , $objexport -> array_export_icon [ 0 ]);
print img_object ( $objexport -> array_export_module [ 0 ] -> getName (), $icon ) . ' ' ;
2008-12-04 21:27:01 +01:00
print $objexport -> array_export_label [ 0 ];
print '</td></tr>' ;
2006-01-08 18:08:20 +01:00
2012-11-20 15:56:44 +01:00
// List of exported fields
2017-03-16 20:33:51 +01:00
print '<tr><td>' . $langs -> trans ( " ExportedFields " ) . '</td>' ;
2006-01-08 18:08:20 +01:00
$list = '' ;
foreach ( $array_selected as $code => $label )
{
2012-12-06 10:43:27 +01:00
$list .= ( ! empty ( $list ) ? ', ' : '' );
2006-01-22 17:14:33 +01:00
$list .= $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]);
2006-01-08 18:08:20 +01:00
}
print '<td>' . $list . '</td></tr>' ;
2012-11-20 15:56:44 +01:00
// List of filtered fiels
if ( isset ( $objexport -> array_export_TypeFields [ 0 ]) && is_array ( $objexport -> array_export_TypeFields [ 0 ]))
2012-10-25 22:30:17 +02:00
{
2017-03-16 20:33:51 +01:00
print '<tr><td>' . $langs -> trans ( " FilteredFields " ) . '</td>' ;
2012-10-25 22:30:17 +02:00
$list = '' ;
2012-12-06 10:43:27 +01:00
if ( ! empty ( $array_filtervalue ))
2012-10-25 22:30:17 +02:00
{
2012-12-06 10:43:27 +01:00
foreach ( $array_filtervalue as $code => $value )
2012-11-20 15:56:44 +01:00
{
2012-12-06 10:43:27 +01:00
if ( isset ( $objexport -> array_export_fields [ 0 ][ $code ]))
{
$list .= ( $list ? ', ' : '' );
2014-08-29 20:25:54 +02:00
if ( isset ( $array_filtervalue [ $code ]) && preg_match ( '/^\s*[<>]/' , $array_filtervalue [ $code ])) $list .= $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]) . ( isset ( $array_filtervalue [ $code ]) ? $array_filtervalue [ $code ] : '' );
else $list .= $langs -> trans ( $objexport -> array_export_fields [ 0 ][ $code ]) . " =' " . ( isset ( $array_filtervalue [ $code ]) ? $array_filtervalue [ $code ] : '' ) . " ' " ;
2012-12-06 10:43:27 +01:00
}
2012-10-29 10:36:26 +01:00
}
2012-10-25 22:30:17 +02:00
}
2012-12-06 10:43:27 +01:00
print '<td>' . ( ! empty ( $list ) ? $list : $langs -> trans ( " None " )) . '</td>' ;
2012-11-20 15:56:44 +01:00
print '</tr>' ;
2012-10-25 22:30:17 +02:00
}
2006-01-08 18:08:20 +01:00
print '</table>' ;
2017-03-16 20:33:51 +01:00
print '</div>' ;
2017-06-13 18:50:31 +02:00
2006-01-08 18:08:20 +01:00
print '<br>' ;
2009-03-03 01:42:40 +01:00
2006-01-08 18:08:20 +01:00
print $langs -> trans ( " NowClickToGenerateToBuildExportFile " ) . '<br>' ;
2009-03-03 01:42:40 +01:00
2018-06-18 10:12:19 +02:00
// List of available export formats
2006-01-08 18:08:20 +01:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2017-11-24 17:44:19 +01:00
print '<td class="titlefield">' . $langs -> trans ( " AvailableFormats " ) . '</td>' ;
2006-01-08 18:08:20 +01:00
print '<td>' . $langs -> trans ( " LibraryUsed " ) . '</td>' ;
2009-05-19 02:33:57 +02:00
print '<td align="right">' . $langs -> trans ( " LibraryVersion " ) . '</td>' ;
2009-09-28 22:06:15 +02:00
print '</tr>' . " \n " ;
2006-01-08 18:08:20 +01:00
2006-03-18 00:27:30 +01:00
$liste = $objmodelexport -> liste_modeles ( $db );
2014-05-03 02:15:33 +02:00
$listeall = $liste ;
foreach ( $listeall as $key => $val )
2006-01-08 18:08:20 +01:00
{
2014-05-03 02:15:33 +02:00
if ( preg_match ( '/__\(Disabled\)__/' , $listeall [ $key ]))
{
$listeall [ $key ] = preg_replace ( '/__\(Disabled\)__/' , '(' . $langs -> transnoentitiesnoconv ( " Disabled " ) . ')' , $listeall [ $key ]);
unset ( $liste [ $key ]);
}
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2017-11-24 17:44:19 +01:00
print '<td width="16">' . img_picto_common ( $key , $objmodelexport -> getPictoForKey ( $key )) . ' ' ;
2012-11-11 18:11:10 +01:00
$text = $objmodelexport -> getDriverDescForKey ( $key );
2014-05-03 02:15:33 +02:00
$label = $listeall [ $key ];
2017-11-24 17:44:19 +01:00
print $form -> textwithpicto ( $label , $text ) . '</td>' ;
print '<td>' . $objmodelexport -> getLibLabelForKey ( $key ) . '</td>' ;
print '<td align="right">' . $objmodelexport -> getLibVersionForKey ( $key ) . '</td>' ;
print '</tr>' . " \n " ;
2006-01-08 18:08:20 +01:00
}
2009-03-03 01:42:40 +01:00
print '</table>' ;
2006-01-08 18:08:20 +01:00
print '</div>' ;
2017-06-13 18:50:31 +02:00
2009-03-03 01:42:40 +01:00
print '<table width="100%">' ;
2012-11-21 18:52:25 +01:00
2009-03-03 01:42:40 +01:00
if ( $sqlusedforexport && $user -> admin )
{
print '<tr><td>' ;
print info_admin ( $langs -> trans ( " SQLUsedForExport " ) . ':<br> ' . $sqlusedforexport );
print '</td></tr>' ;
}
print '</table>' ;
2006-01-22 17:14:33 +01:00
2017-06-13 18:50:31 +02:00
2016-10-24 11:27:39 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
2006-01-08 18:08:20 +01:00
2011-08-11 21:12:37 +02:00
if ( ! is_dir ( $conf -> export -> dir_temp )) dol_mkdir ( $conf -> export -> dir_temp );
2006-01-08 18:08:20 +01:00
2006-01-22 17:14:33 +01:00
// Affiche liste des documents
2010-03-13 02:09:57 +01:00
// NB: La fonction show_documents rescanne les modules qd genallowed=1, sinon prend $liste
2016-10-24 11:27:39 +02:00
print $formfile -> showdocuments ( 'export' , '' , $upload_dir , $_SERVER [ " PHP_SELF " ] . '?step=5&datatoexport=' . $datatoexport , $liste , 1 ,( ! empty ( $_POST [ 'model' ]) ? $_POST [ 'model' ] : 'csv' ), 1 , 1 );
2015-05-05 13:46:28 +02:00
2016-10-24 11:27:39 +02:00
print '</div><div class="fichehalfright"><div class="ficheaddleft">' ;
2017-06-13 18:50:31 +02:00
2016-10-24 11:27:39 +02:00
print '</div></div></div>' ;
2005-11-19 23:09:12 +01:00
}
2005-10-30 15:02:38 +01:00
2011-08-27 16:24:16 +02:00
llxFooter ();
2009-10-03 14:08:48 +02:00
2012-12-01 15:45:05 +01:00
$db -> close ();
2012-11-20 15:56:44 +01:00
2015-05-05 13:46:28 +02: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
2009-10-03 14:08:48 +02:00
/**
2011-09-10 14:21:41 +02:00
* Return table name of an alias . For this , we look for the " tablename as alias " in sql string .
*
2012-01-08 00:52:07 +01:00
* @ param string $code Alias . Fieldname
* @ param string $sqlmaxforexport SQL request to parse
* @ return string Table name of field
2009-10-03 14:08:48 +02:00
*/
function getablenamefromfield ( $code , $sqlmaxforexport )
{
2016-06-24 02:19:41 +02:00
$alias = preg_replace ( '/\.(.*)$/i' , '' , $code ); // Keep only 'Alias' and remove '.Fieldname'
$regexstring = '/([a-zA-Z_]+) as ' . preg_quote ( $alias ) . '[, \)]/i' ;
2017-06-13 18:50:31 +02:00
2009-10-03 14:08:48 +02:00
$newsql = $sqlmaxforexport ;
2016-06-24 02:19:41 +02:00
$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 18:50:31 +02:00
2009-11-08 20:28:44 +01:00
if ( preg_match ( $regexstring , $newsql , $reg ))
2009-10-03 14:08:48 +02:00
{
2016-06-24 02:19:41 +02:00
return $reg [ 1 ]; // The tablename
2009-10-03 14:08:48 +02:00
}
else return '' ;
}