diff --git a/htdocs/exports/export.class.php b/htdocs/exports/export.class.php
new file mode 100644
index 00000000000..9a11eaa21c5
--- /dev/null
+++ b/htdocs/exports/export.class.php
@@ -0,0 +1,121 @@
+
+ *
+ *
+ * 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
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ * $Source$
+ */
+
+/**
+ \file htdocs/exports/export.class.php
+ \ingroup core
+ \brief Fichier de la classe des exports
+ \version $Revision$
+*/
+
+
+/**
+ \class Export
+ \brief Classe permettant la gestion des exports
+*/
+
+class Export
+{
+ var $array_export_code=array();
+ var $array_export_module=array();
+ var $array_export_label=array();
+ var $array_export_fields_code=array();
+ var $array_export_fields_label=array();
+ var $array_export_sql=array();
+
+
+ /**
+ * \brief Constructeur de la classe
+ * \param DB Handler accès base de données
+ */
+ function Export($DB)
+ {
+ $this->db=$DB;
+ }
+
+
+ /**
+ * \brief Charge les lots de données exportables
+ * \param user Objet utilisateur qui exporte
+ * \param filter Code export pour charger un lot de données particulier
+ */
+ function load_arrays($user,$filter)
+ {
+ dolibarr_syslog("Export::load_arrays user=$user filter=$filter");
+
+ $dir=DOL_DOCUMENT_ROOT."/includes/modules";
+ $handle=opendir($dir);
+
+ // Recherche des exports disponibles
+ $var=True;
+ $i=0;
+ while (($file = readdir($handle))!==false)
+ {
+ if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
+ {
+ if (eregi("^(mod.*)\.class\.php",$file,$reg))
+ {
+ $modulename=$reg[1];
+
+ // Chargement de la classe
+ $file = $dir."/".$modulename.".class.php";
+ $classname = $modulename;
+ require_once($file);
+ $module = new $classname($db);
+
+ if (is_array($module->export_code))
+ {
+ foreach($module->export_code as $r => $value)
+ {
+ if ($filter && $filter != $module->export_code[$r]) next;
+ // Test si permissions ok \todo tester sur toutes permissions
+ $perm=$module->export_permission[$r][0];
+ if (strlen($perms[2]) > 0)
+ {
+ $bool=$user->rights->$perm[0]->$perm[1]->$perm[2];
+ }
+ else
+ {
+ $bool=$user->rights->$perm[0]->$perm[1];
+ }
+ if ($bool) // Permissions ok
+ {
+ dolibarr_syslog("Export chargé pour le module ".$modulename." en index ".$i);
+ $this->array_export_module[$i]=$module;
+ $this->array_export_code[$i]=$module->export_code[$r];
+ $this->array_export_label[$i]=$module->export_label[$r];
+ $this->array_export_fields_code[$i]=$module->export_fields_code[$r];
+ $this->array_export_fields_label[$i]=$module->export_fields_label[$r];
+ $this->array_export_sql[$i]=$module->export_sql[$r];
+ $i++;
+ }
+ }
+ }
+ }
+ }
+ }
+ closedir($handle);
+ }
+
+}
+
+?>
diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php
index a25f8a05566..23bc1d63621 100644
--- a/htdocs/exports/export.php
+++ b/htdocs/exports/export.php
@@ -26,10 +26,10 @@
\version $Revision$
*/
-require("./pre.inc.php");
+require_once("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/exports/export.class.php");
-$langs->load("commercial");
-$langs->load("orders");
+$langs->load("exports");
$user->getrights();
@@ -38,22 +38,89 @@ if (! $user->societe_id == 0)
+$export=new Export($db);
+$export->load_arrays($user,isset($datatoexport)?$datatoexport:'');
-
-llxHeader('',$langs->trans("NewExport"));
+if (! isset($datatoexport))
+{
+ llxHeader('',$langs->trans("NewExport"));
+
+ print_fiche_titre($langs->trans("NewExport"));
+
+ print '
';
-print_fiche_titre($langs->trans("NewExport"));
+ print $langs->trans("SelectExportDataSet").'
';
+ print '
';
+
+ // Affiche les modules d'exports
+ print '';
+ print '';
+ print '| '.$langs->trans("Module").' | ';
+ print ''.$langs->trans("ExportableDatas").' | ';
+ print ' | ';
+ print '
';
+ $val=true;
+ if (sizeof($export->array_export_code))
+ {
+ foreach ($export->array_export_code as $key => $value)
+ {
+ $val=!$val;
+ print '| ';
+ print img_object($export->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' ';
+ print $export->array_export_module[$key]->getName();
+ print ' | ';
+ print $export->array_export_label[$key];
+ print ' | ';
+ print ''.img_picto($langs->trans("NewExport"),'filenew').'';
+ print ' |
';
+ }
+ }
+ else
+ {
+ print '| '.$langs->trans("NoExportableData").' |
';
+ }
+ print '
';
-print '';
+}
+if (isset($datatoexport))
+{
+ llxHeader('',$langs->trans("NewExport"));
+
+ print_fiche_titre($langs->trans("NewExport")." - ".$export->array_export_label[0]);
+
+ print '';
+ print $langs->trans("SelectExportFields").'
';
+ print '
';
+
+ print '';
+ print '| '.$langs->trans("ExportableFields").' | ';
+ print ' | ';
+ print ''.$langs->trans("ExportedFields").' | ';
+ print '
';
+
+ print '| ';
+
+ // Champs exportables
+ $fieldscode=split(',',$export->array_export_fields_code);
+ $fieldslib=split(',',$export->array_export_fields_lib);
+ foreach($fieldscode as $i=>$code)
+ {
+
+
+ }
+
+ print ' |
';
+
+ print '
';
+}
-print '
';
$db->close();
-
llxFooter('$Date$ - $Revision$');
?>
diff --git a/htdocs/exports/index.php b/htdocs/exports/index.php
index 1033c856d89..fc0df1f2346 100644
--- a/htdocs/exports/index.php
+++ b/htdocs/exports/index.php
@@ -26,71 +26,20 @@
\version $Revision$
*/
-require("./pre.inc.php");
+require_once("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/exports/export.class.php");
-$langs->load("commercial");
-$langs->load("orders");
+$langs->load("exports");
$user->getrights();
if (! $user->societe_id == 0)
accessforbidden();
+
-
-$dir=DOL_DOCUMENT_ROOT."/includes/modules";
-$handle=opendir($dir);
-
-// Recherche des exports disponibles
-$array_export_code=array();
-$var=True;
-$i=0;
-while (($file = readdir($handle))!==false)
-{
- if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
- {
- if (eregi("^(mod.*)\.class\.php",$file,$reg))
- {
- $modulename=$reg[1];
-
- // Chargement de la classe
- $file = $dir."/".$modulename.".class.php";
- $classname = $modulename;
- require_once($file);
- $module = new $classname($db);
-
- if (is_array($module->export_code))
- {
- foreach($module->export_code as $r => $value)
- {
- dolibarr_syslog("Exports trouvés pour le module ".$modulename);
- $perm=$module->export_permission[$r][0];
- if (strlen($perms[2]) > 0)
- {
- $bool=$user->rights->$perm[0]->$perm[1]->$perm[2];
- }
- else
- {
- $bool=$user->rights->$perm[0]->$perm[1];
- }
- if ($bool)
- {
- $array_export_module[$i]=$module;
- $array_export_code[$i]=$module->export_code[$r];
- $array_export_label[$i]=$module->export_label[$r];
- $array_export_fields_code[$i]=$module->export_fields_code[$r];
- $array_export_fields_label[$i]=$module->export_fields_label[$r];
- $array_export_sql[$i]=$module->export_sql[$r];
- $i++;
- }
- }
- }
- }
- }
-}
-closedir($handle);
-
-
+$export=new Export($db);
+$export->load_arrays($user);
llxHeader('',$langs->trans("ExportsArea"));
@@ -127,22 +76,24 @@ print '';
// Affiche les modules d'exports
print '';
print '';
-print '| '.$langs->trans("Module").' | ';
+print ''.$langs->trans("Module").' | ';
print ''.$langs->trans("ExportableDatas").' | ';
+print ' | ';
print ' ';
$val=true;
-if (sizeof($array_export_code))
+if (sizeof($export->array_export_code))
{
- foreach ($array_export_code as $key => $value)
+ foreach ($export->array_export_code as $key => $value)
{
$val=!$val;
print '| ';
- print img_object($array_export_module[$key]->getName(),$array_export_module[$key]->picto).' ';
- print $array_export_module[$key]->getName();
+ print img_object($export->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' ';
+ print $export->array_export_module[$key]->getName();
print ' | ';
- print $array_export_label[$key];
+ print $export->array_export_label[$key];
+ print ' | ';
+ print ''.img_picto($langs->trans("NewExport"),'filenew').'';
print ' | ';
-
}
}
else
|