2005-10-30 15:02:38 +01:00
|
|
|
<?php
|
2011-08-27 17:40:08 +02:00
|
|
|
/* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
2009-04-28 10:42:56 +02:00
|
|
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
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
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (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
|
|
|
|
2010-02-28 16:33:31 +01:00
|
|
|
require_once("../main.inc.php");
|
2010-05-03 10:43:32 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
|
2010-05-03 10:43:32 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
|
2010-04-28 14:13:27 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/exports/class/export.class.php");
|
2006-01-22 17:14:33 +01:00
|
|
|
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/export/modules_export.php');
|
|
|
|
|
|
2005-11-19 23:09:12 +01:00
|
|
|
$langs->load("exports");
|
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
|
|
|
|
2006-03-18 00:27:30 +01:00
|
|
|
$entitytoicon=array(
|
|
|
|
|
'invoice'=>'bill','invoice_line'=>'bill',
|
2007-05-21 22:39:08 +02:00
|
|
|
'order'=>'order' ,'order_line'=>'order',
|
2009-05-04 21:55:52 +02:00
|
|
|
'propal'=>'propal', 'propal_line'=>'propal',
|
2008-10-13 18:39:53 +02:00
|
|
|
'intervention'=>'intervention' ,'inter_line'=>'intervention',
|
2007-05-21 22:39:08 +02:00
|
|
|
'member'=>'user' ,'member_type'=>'group','subscription'=>'payment',
|
|
|
|
|
'tax'=>'generic' ,'tax_type'=>'generic',
|
2007-07-01 13:51:55 +02:00
|
|
|
'account'=>'account',
|
2007-08-08 04:20:32 +02:00
|
|
|
'payment'=>'payment',
|
2008-04-01 14:09:33 +02:00
|
|
|
'product'=>'product','stock'=>'generic','warehouse'=>'stock',
|
2009-11-08 20:28:44 +01:00
|
|
|
'category'=>'category',
|
2008-03-31 08:17:48 +02:00
|
|
|
'other'=>'generic',
|
|
|
|
|
);
|
2008-03-16 18:31:31 +01:00
|
|
|
$entitytolang=array( // Translation code
|
2006-03-18 00:27:30 +01:00
|
|
|
'user'=>'User',
|
|
|
|
|
'company'=>'Company','contact'=>'Contact',
|
|
|
|
|
'invoice'=>'Bill','invoice_line'=>'InvoiceLine',
|
2007-03-19 16:33:19 +01:00
|
|
|
'order'=>'Order','order_line'=>'OrderLine',
|
2009-05-04 21:55:52 +02:00
|
|
|
'propal'=>'Proposal','propal_line'=>'ProposalLine',
|
2008-10-13 18:39:53 +02:00
|
|
|
'intervention'=>'Intervention' ,'inter_line'=>'InterLine',
|
2007-05-21 22:39:08 +02:00
|
|
|
'member'=>'Member','member_type'=>'MemberType','subscription'=>'Subscription',
|
|
|
|
|
'tax'=>'SocialContribution','tax_type'=>'DictionnarySocialContributions',
|
2007-07-01 13:51:55 +02:00
|
|
|
'account'=>'BankTransactions',
|
2007-08-08 04:20:32 +02:00
|
|
|
'payment'=>'Payment',
|
2008-04-01 14:09:33 +02:00
|
|
|
'product'=>'Product','stock'=>'Stock','warehouse'=>'Warehouse',
|
2008-12-05 00:06:45 +01:00
|
|
|
'category'=>'Category',
|
2008-03-31 08:17:48 +02:00
|
|
|
'other'=>'Other'
|
|
|
|
|
);
|
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();
|
2007-03-23 18:58:06 +01:00
|
|
|
$datatoexport=isset($_GET["datatoexport"])? $_GET["datatoexport"] : (isset($_POST["datatoexport"])?$_POST["datatoexport"]:'');
|
2006-01-21 20:08:36 +01:00
|
|
|
$action=isset($_GET["action"]) ? $_GET["action"] : (isset($_POST["action"])?$_POST["action"]:'');
|
2007-03-23 18:58:06 +01:00
|
|
|
$step=isset($_GET["step"])? $_GET["step"] : (isset($_POST["step"])?$_POST["step"]:1);
|
|
|
|
|
$export_name=isset($_POST["export_name"])? $_POST["export_name"] : '';
|
|
|
|
|
$hexa=isset($_POST["hexa"])? $_POST["hexa"] : '';
|
|
|
|
|
$exportmodelid=isset($_POST["exportmodelid"])? $_POST["exportmodelid"] : '';
|
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);
|
|
|
|
|
|
2006-03-18 00:27:30 +01:00
|
|
|
$objmodelexport=new ModeleExports();
|
2007-03-23 18:58:06 +01:00
|
|
|
$html = 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
|
|
|
|
2006-01-08 18:08:20 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
2009-03-03 01:42:40 +01:00
|
|
|
|
2006-01-08 18:08:20 +01:00
|
|
|
if ($action=='selectfield')
|
2009-03-03 01:42:40 +01:00
|
|
|
{
|
2008-05-17 00:50:38 +02:00
|
|
|
if ($_GET["field"]=='all')
|
|
|
|
|
{
|
2011-02-02 21:41:54 +01:00
|
|
|
$fieldsarray=$objexport->array_export_fields[0];
|
2008-05-17 00:50:38 +02:00
|
|
|
foreach($fieldsarray as $key=>$val)
|
|
|
|
|
{
|
|
|
|
|
if (! empty($array_selected[$key])) continue; // If already selected, select 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
|
|
|
|
|
{
|
2011-09-17 21:49:50 +02:00
|
|
|
$array_selected[$_GET["field"]]=count($array_selected)+1;
|
2008-05-17 00:50:38 +02:00
|
|
|
//print_r($array_selected);
|
|
|
|
|
$_SESSION["export_selected_fields"]=$array_selected;
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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();
|
2006-01-08 18:25:28 +01:00
|
|
|
$array_selected=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')
|
|
|
|
|
{
|
2008-03-30 17:36:19 +02:00
|
|
|
// Build export file
|
2006-07-02 15:45:06 +02:00
|
|
|
$result=$objexport->build_file($user, $_POST['model'], $datatoexport, $array_selected);
|
2006-01-22 17:14:33 +01:00
|
|
|
if ($result < 0)
|
|
|
|
|
{
|
|
|
|
|
$mesg='<div class="error">'.$objexport->error.'</div>';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-01-10 23:21:18 +01:00
|
|
|
$mesg='<div class="ok">'.$langs->trans("FileSuccessfullyBuilt").'</div>';
|
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
|
|
|
}
|
|
|
|
|
|
2008-12-04 21:27:01 +01:00
|
|
|
if ($action == 'deleteprof')
|
|
|
|
|
{
|
|
|
|
|
if ($_GET["id"])
|
|
|
|
|
{
|
|
|
|
|
$objexport->fetch($_GET["id"]);
|
|
|
|
|
$result=$objexport->delete($user);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$objexport->model_name = $export_name;
|
|
|
|
|
$objexport->datatoexport = $datatoexport;
|
|
|
|
|
$objexport->hexa = $hexa;
|
2009-03-03 01:42:40 +01:00
|
|
|
|
2007-03-24 17:46:02 +01:00
|
|
|
$result = $objexport->create($user);
|
|
|
|
|
if ($result >= 0)
|
|
|
|
|
{
|
|
|
|
|
$mesg='<div class="ok">'.$langs->trans("ExportModelSaved",$objexport->model_name).'</div>';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-12-04 21:27:01 +01:00
|
|
|
$langs->load("errors");
|
|
|
|
|
if ($objexport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
|
|
|
|
{
|
2009-03-03 01:42:40 +01:00
|
|
|
$mesg='<div class="error">'.$langs->trans("ErrorExportDuplicateProfil").'</div>';
|
2008-12-04 21:27:01 +01:00
|
|
|
}
|
|
|
|
|
else $mesg='<div class="error">'.$objexport->error.'</div>';
|
2007-03-24 17:46:02 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("ExportModelName")).'</div>';
|
|
|
|
|
}
|
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();
|
|
|
|
|
$array_selected=array();
|
|
|
|
|
$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;
|
2007-03-23 18:58:06 +01: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
|
|
|
|
2009-03-03 01:42:40 +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
|
|
|
|
2009-02-20 23:53:15 +01:00
|
|
|
dol_fiche_head($head, $hselected, $langs->trans("NewExport"));
|
2006-01-08 18:08:20 +01:00
|
|
|
|
|
|
|
|
|
2005-11-19 23:09:12 +01:00
|
|
|
print '<table class="notopnoleftnoright" width="100%">';
|
|
|
|
|
|
|
|
|
|
print $langs->trans("SelectExportDataSet").'<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>';
|
2011-02-05 19:40:52 +01:00
|
|
|
$icon=$objexport->array_export_icon[$key];
|
|
|
|
|
$label=$objexport->array_export_label[$key];
|
|
|
|
|
//print $value.'-'.$icon.'-'.$label."<br>";
|
|
|
|
|
print img_object($objexport->array_export_module[$key]->getName(),$icon).' ';
|
|
|
|
|
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>';
|
2007-03-24 17:46:02 +01:00
|
|
|
|
|
|
|
|
if ($mesg) print $mesg;
|
|
|
|
|
|
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
|
|
|
|
2009-02-20 23:53:15 +01:00
|
|
|
dol_fiche_head($head, $hselected, $langs->trans("NewExport"));
|
2006-01-08 18:08:20 +01:00
|
|
|
|
|
|
|
|
print '<table width="100%" class="border">';
|
|
|
|
|
|
|
|
|
|
// Module
|
|
|
|
|
print '<tr><td width="25%">'.$langs->trans("Module").'</td>';
|
|
|
|
|
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
|
2006-01-08 18:08:20 +01:00
|
|
|
print '<tr><td width="25%">'.$langs->trans("DatasetToExport").'</td>';
|
2008-12-04 21:27:01 +01:00
|
|
|
print '<td>';
|
2011-02-05 19:40:52 +01:00
|
|
|
$icon=$objexport->array_export_icon[0];
|
|
|
|
|
$label=$objexport->array_export_label[0];
|
|
|
|
|
//print $value.'-'.$icon.'-'.$label."<br>";
|
|
|
|
|
print img_object($objexport->array_export_module[0]->getName(),$icon).' ';
|
|
|
|
|
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>';
|
|
|
|
|
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").' ';
|
2008-10-25 19:27:15 +02:00
|
|
|
$htmlother->select_export_model($exportmodelid,'exportmodelid',$datatoexport,1);
|
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">';
|
2008-05-17 00:50:38 +02:00
|
|
|
print '<a title='.$langs->trans("All").' alt='.$langs->trans("All").' href="'.$_SERVER["PHP_SELF"].'?step=2&datatoexport='.$datatoexport.'&action=selectfield&field=all">'.$langs->trans("All")."</a>";
|
|
|
|
|
print '/';
|
|
|
|
|
print '<a title='.$langs->trans("None").' alt='.$langs->trans("None").' href="'.$_SERVER["PHP_SELF"].'?step=2&datatoexport='.$datatoexport.'&action=unselectfield&field=all">'.$langs->trans("None")."</a>";
|
|
|
|
|
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
|
|
|
|
|
$sqlmaxforexport=$objexport->build_sql(0,array());
|
2006-01-08 18:08:20 +01:00
|
|
|
|
2011-09-20 12:30:56 +02: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
|
|
|
|
2006-01-08 18:08:20 +01:00
|
|
|
$var=true;
|
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)
|
|
|
|
|
{
|
|
|
|
|
$var=!$var;
|
|
|
|
|
print "<tr $bc[$var]>";
|
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]);
|
2006-02-25 15:26:29 +01:00
|
|
|
$entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity;
|
|
|
|
|
$entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity;
|
|
|
|
|
|
2011-02-05 19:40:52 +01:00
|
|
|
print '<td nowrap="nowrap">';
|
|
|
|
|
// 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-11-08 20:28:44 +01:00
|
|
|
$text=$langs->trans($label);
|
|
|
|
|
$tablename=getablenamefromfield($code,$sqlmaxforexport);
|
|
|
|
|
$htmltext ='<b>'.$langs->trans("Name").":</b> ".$text.'<br>';
|
|
|
|
|
$htmltext.='<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./','',$code)."<br>";
|
2007-03-24 17:46:02 +01:00
|
|
|
if ((isset($array_selected[$code]) && $array_selected[$code]) || $modelchoice == 1)
|
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>';
|
2008-05-17 00:50:38 +02:00
|
|
|
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?step=2&datatoexport='.$datatoexport.'&action=unselectfield&field='.$code.'">'.img_left().'</a></td>';
|
2009-10-03 14:08:48 +02:00
|
|
|
print '<td>';
|
2011-02-05 19:40:52 +01:00
|
|
|
//print $text.'-'.$htmltext."<br>";
|
2009-11-08 20:28:44 +01:00
|
|
|
print $html->textwithpicto($text,$htmltext);
|
2009-10-03 14:08:48 +02:00
|
|
|
//print ' ('.$code.')';
|
|
|
|
|
print '</td>';
|
2007-03-23 18:58:06 +01:00
|
|
|
$bit=1;
|
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>";
|
2009-10-03 14:08:48 +02:00
|
|
|
print $html->textwithpicto($text,$htmltext);
|
|
|
|
|
//print ' ('.$code.')';
|
|
|
|
|
print '</td>';
|
2008-05-17 00:50:38 +02:00
|
|
|
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?step=2&datatoexport='.$datatoexport.'&action=selectfield&field='.$code.'">'.img_right().'</a></td>';
|
2006-01-08 18:08:20 +01:00
|
|
|
print '<td> </td>';
|
2007-03-23 18:58:06 +01:00
|
|
|
$bit=0;
|
2006-01-08 18:08:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '</tr>';
|
2007-03-23 18:58:06 +01:00
|
|
|
$save_select.=$bit;
|
2006-01-08 18:08:20 +01:00
|
|
|
}
|
2007-03-23 18:58:06 +01:00
|
|
|
|
2006-01-08 18:08:20 +01:00
|
|
|
print '</table>';
|
|
|
|
|
|
|
|
|
|
print '</div>';
|
2007-03-24 17:46:02 +01:00
|
|
|
|
|
|
|
|
if ($mesg) print $mesg;
|
|
|
|
|
|
2006-01-08 18:08:20 +01:00
|
|
|
/*
|
|
|
|
|
* Barre d'action
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
print '<div class="tabsAction">';
|
|
|
|
|
|
2011-09-17 21:49:50 +02:00
|
|
|
if (count($array_selected))
|
2007-03-24 17:46:02 +01:00
|
|
|
{
|
|
|
|
|
print '<a class="butAction" href="export.php?step=3&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)
|
|
|
|
|
{
|
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
|
|
|
|
|
*/
|
|
|
|
|
$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++;
|
|
|
|
|
|
2006-06-24 14:41:30 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport;
|
2006-04-01 04:51:20 +02:00
|
|
|
$head[$h][1] = $langs->trans("Step")." 3";
|
2006-01-08 18:08:20 +01:00
|
|
|
$hselected=$h;
|
|
|
|
|
$h++;
|
2009-03-03 01:42:40 +01:00
|
|
|
|
2009-02-20 23:53:15 +01:00
|
|
|
dol_fiche_head($head, $hselected, $langs->trans("NewExport"));
|
2006-01-08 18:08:20 +01:00
|
|
|
|
|
|
|
|
print '<table width="100%" class="border">';
|
|
|
|
|
|
|
|
|
|
// Module
|
|
|
|
|
print '<tr><td width="25%">'.$langs->trans("Module").'</td>';
|
|
|
|
|
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
|
2006-01-08 18:08:20 +01:00
|
|
|
print '<tr><td width="25%">'.$langs->trans("DatasetToExport").'</td>';
|
2008-12-04 21:27:01 +01:00
|
|
|
print '<td>';
|
|
|
|
|
print img_object($objexport->array_export_module[0]->getName(),$objexport->array_export_icon[0]).' ';
|
|
|
|
|
print $objexport->array_export_label[0];
|
|
|
|
|
print '</td></tr>';
|
2006-01-08 18:08:20 +01:00
|
|
|
|
2009-04-28 10:42:56 +02:00
|
|
|
// Nbre champs exportes
|
2006-01-08 18:08:20 +01:00
|
|
|
print '<tr><td width="25%">'.$langs->trans("ExportedFields").'</td>';
|
|
|
|
|
$list='';
|
2006-01-21 20:08:36 +01:00
|
|
|
foreach($array_selected as $code=>$value)
|
2006-01-08 18:08:20 +01:00
|
|
|
{
|
2009-10-03 14:08:48 +02:00
|
|
|
$list.=($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>';
|
|
|
|
|
|
|
|
|
|
print '</table>';
|
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
|
|
|
|
|
$sqlmaxforexport=$objexport->build_sql(0,array());
|
|
|
|
|
|
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
|
|
|
$var=true;
|
|
|
|
|
foreach($array_selected as $code=>$value)
|
|
|
|
|
{
|
|
|
|
|
$var=!$var;
|
|
|
|
|
print "<tr $bc[$var]>";
|
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]);
|
2006-02-25 15:26:29 +01:00
|
|
|
$entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity;
|
|
|
|
|
$entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity;
|
|
|
|
|
|
2011-02-05 19:40:52 +01:00
|
|
|
print '<td nowrap="nowrap">';
|
|
|
|
|
// 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
|
|
|
|
2009-10-03 14:08:48 +02:00
|
|
|
print '<td>';
|
|
|
|
|
$text=$langs->trans($objexport->array_export_fields[0][$code]);
|
|
|
|
|
$tablename=getablenamefromfield($code,$sqlmaxforexport);
|
2009-11-08 20:28:44 +01:00
|
|
|
$htmltext ='<b>'.$langs->trans("Name").":</b> ".$text.'<br>';
|
|
|
|
|
$htmltext.='<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./','',$code)."<br>";
|
|
|
|
|
print $html->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">';
|
2011-09-17 21:49:50 +02:00
|
|
|
if ($value < count($array_selected)) print '<a href="'.$_SERVER["PHP_SELF"].'?step=3&datatoexport='.$datatoexport.'&action=downfield&field='.$code.'">'.img_down().'</a>';
|
2006-06-24 14:41:30 +02:00
|
|
|
if ($value > 1) print '<a href="'.$_SERVER["PHP_SELF"].'?step=3&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>';
|
|
|
|
|
|
|
|
|
|
if ($mesg) print $mesg;
|
2009-03-03 01:42:40 +01:00
|
|
|
|
2008-12-04 21:27:01 +01:00
|
|
|
/*
|
|
|
|
|
* 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
|
|
|
{
|
|
|
|
|
print '<a class="butAction" href="export.php?step=4&datatoexport='.$datatoexport.'">'.$langs->trans("NextStep").'</a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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>';
|
|
|
|
|
$var=false;
|
|
|
|
|
print '<tr '.$bc[$var].'>';
|
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."'";
|
|
|
|
|
$sql.= " ORDER BY rowid";
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql)
|
|
|
|
|
{
|
|
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
$i = 0;
|
|
|
|
|
$var=false;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$var=!$var;
|
|
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
|
|
print '<tr '.$bc[$var].'><td>';
|
|
|
|
|
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>';
|
|
|
|
|
}
|
2009-03-03 01:42:40 +01:00
|
|
|
|
2006-01-08 18:08:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($step == 4 && $datatoexport)
|
|
|
|
|
{
|
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
|
|
|
|
|
*/
|
|
|
|
|
$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++;
|
|
|
|
|
|
2006-06-24 14:41:30 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport;
|
2006-04-01 04:51:20 +02:00
|
|
|
$head[$h][1] = $langs->trans("Step")." 3";
|
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=4&datatoexport='.$datatoexport;
|
2006-04-01 04:51:20 +02:00
|
|
|
$head[$h][1] = $langs->trans("Step")." 4";
|
2006-01-08 18:08:20 +01:00
|
|
|
$hselected=$h;
|
|
|
|
|
$h++;
|
2009-03-03 01:42:40 +01:00
|
|
|
|
2009-02-20 23:53:15 +01:00
|
|
|
dol_fiche_head($head, $hselected, $langs->trans("NewExport"));
|
2006-01-08 18:08:20 +01:00
|
|
|
|
|
|
|
|
print '<table width="100%" class="border">';
|
|
|
|
|
|
|
|
|
|
// Module
|
|
|
|
|
print '<tr><td width="25%">'.$langs->trans("Module").'</td>';
|
|
|
|
|
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
|
2006-01-08 18:08:20 +01:00
|
|
|
print '<tr><td width="25%">'.$langs->trans("DatasetToExport").'</td>';
|
2008-12-04 21:27:01 +01:00
|
|
|
print '<td>';
|
|
|
|
|
print img_object($objexport->array_export_module[0]->getName(),$objexport->array_export_icon[0]).' ';
|
|
|
|
|
print $objexport->array_export_label[0];
|
|
|
|
|
print '</td></tr>';
|
2006-01-08 18:08:20 +01:00
|
|
|
|
2008-05-17 02:14:25 +02:00
|
|
|
// Nbre champs exportes
|
2006-01-08 18:08:20 +01:00
|
|
|
print '<tr><td width="25%">'.$langs->trans("ExportedFields").'</td>';
|
|
|
|
|
$list='';
|
|
|
|
|
foreach($array_selected as $code=>$label)
|
|
|
|
|
{
|
2009-10-03 14:08:48 +02:00
|
|
|
$list.=($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>';
|
|
|
|
|
|
|
|
|
|
print '</table>';
|
|
|
|
|
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
|
|
|
|
2006-01-08 18:08:20 +01:00
|
|
|
// Liste des formats d'exports disponibles
|
|
|
|
|
$var=true;
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre">';
|
2009-05-19 02:14:27 +02:00
|
|
|
print '<td colspan="2">'.$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);
|
2010-03-20 21:24:32 +01:00
|
|
|
foreach($liste as $key => $val)
|
2006-01-08 18:08:20 +01:00
|
|
|
{
|
|
|
|
|
$var=!$var;
|
2009-05-19 02:14:27 +02:00
|
|
|
print '<tr '.$bc[$var].'>';
|
2009-05-19 02:33:57 +02:00
|
|
|
print '<td width="16">'.img_picto_common($key,$objmodelexport->getPicto($key)).'</td>';
|
2009-09-28 22:06:15 +02:00
|
|
|
$text=$objmodelexport->getDriverDesc($key);
|
|
|
|
|
print '<td>'.$html->textwithpicto($objmodelexport->getDriverLabel($key),$text).'</td>';
|
|
|
|
|
print '<td>'.$objmodelexport->getLibLabel($key).'</td><td align="right">'.$objmodelexport->getLibVersion($key).'</td></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>';
|
|
|
|
|
|
2009-03-03 01:42:40 +01:00
|
|
|
print '<table width="100%">';
|
|
|
|
|
if ($mesg)
|
|
|
|
|
{
|
|
|
|
|
print '<tr><td colspan="2">';
|
|
|
|
|
print $mesg;
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2006-01-08 18:08:20 +01:00
|
|
|
print '<table width="100%"><tr><td width="50%">';
|
|
|
|
|
|
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
|
2010-03-27 01:33:28 +01:00
|
|
|
$formfile->show_documents('export','',$conf->export->dir_temp.'/'.$user->id,$_SERVER["PHP_SELF"].'?step=4&datatoexport='.$datatoexport,$liste,1,(! empty($_POST['model'])?$_POST['model']:'csv'),1,1);
|
2009-03-03 01:42:40 +01:00
|
|
|
|
2006-01-08 18:08:20 +01:00
|
|
|
print '</td><td width="50%"> </td></tr>';
|
2005-11-19 23:09:12 +01:00
|
|
|
print '</table>';
|
|
|
|
|
}
|
2005-10-30 15:02:38 +01:00
|
|
|
|
2009-03-03 01:42:40 +01:00
|
|
|
|
2006-08-19 17:50:48 +02:00
|
|
|
print '<br>';
|
2005-10-30 15:02:38 +01:00
|
|
|
|
2006-01-08 18:08:20 +01:00
|
|
|
|
2005-10-30 15:02:38 +01:00
|
|
|
$db->close();
|
|
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
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.
|
|
|
|
|
*
|
|
|
|
|
* @param code Alias.Fieldname
|
|
|
|
|
* @param sqlmaxforexport SQL request to parse
|
2009-10-03 14:08:48 +02:00
|
|
|
*/
|
|
|
|
|
function getablenamefromfield($code,$sqlmaxforexport)
|
|
|
|
|
{
|
|
|
|
|
$newsql=$sqlmaxforexport;
|
2009-10-21 15:09:42 +02:00
|
|
|
$newsql=preg_replace('/^(.*) FROM /i','',$newsql);
|
2009-11-08 20:28:44 +01:00
|
|
|
$newsql=preg_replace('/WHERE (.*)$/i','',$newsql); // We must keep the ' ' before WHERE
|
2009-10-21 15:09:42 +02:00
|
|
|
$alias=preg_replace('/\.(.*)$/i','',$code);
|
2009-10-03 14:08:48 +02:00
|
|
|
//print $newsql.' '.$alias;
|
2009-11-08 20:28:44 +01:00
|
|
|
$regexstring='/([a-zA-Z_]+) as '.$alias.'[, \)]/i';
|
|
|
|
|
if (preg_match($regexstring,$newsql,$reg))
|
2009-10-03 14:08:48 +02:00
|
|
|
{
|
|
|
|
|
return $reg[1];
|
|
|
|
|
}
|
|
|
|
|
else return '';
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-30 15:02:38 +01:00
|
|
|
?>
|