From 7a31109acc3d0a2f84ca601489b97598f8c68cda Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Oct 2007 18:03:54 +0000 Subject: [PATCH] Suite fonction import --- htdocs/admin/import/import.php | 87 +++++++++ htdocs/admin/import/index.php | 169 +++++++++++++----- .../menus/barre_left/eldy_backoffice.php | 7 + htdocs/langs/en_US/exports.lang | 11 +- htdocs/langs/fr_FR/exports.lang | 9 +- 5 files changed, 235 insertions(+), 48 deletions(-) create mode 100644 htdocs/admin/import/import.php diff --git a/htdocs/admin/import/import.php b/htdocs/admin/import/import.php new file mode 100644 index 00000000000..438504dff34 --- /dev/null +++ b/htdocs/admin/import/import.php @@ -0,0 +1,87 @@ + + * + * 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/admin/index.php + \brief Page d'import de donnee + \version $Revision$ +*/ + +require("./pre.inc.php"); + +require(DOL_DOCUMENT_ROOT.'/admin/import/dolibarrimport.class.php'); + +$langs->load("admin"); +$langs->load("companies"); + +if (!$user->admin) + accessforbidden(); + +/* + * Affichage page + */ +llxHeader(); + +$form = new Form($db); + +print_fiche_titre($langs->trans("ImportArea"),'','setup'); + +print "
"; + +print '
'; +print ''; + +print ''; +print ''; + +print "\n"; +print '
Importer un fichier clients
"; +print '
'; +print '   '; +print '
'; + +print "
'; + + +if ( $_POST["sendit"] && $conf->upload != 0) +{ + $imp = new DolibarrImport($db); + $imp->CreateBackupDir(); + if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $imp->upload_dir . "/" . $_FILES['userfile']['name'])) + { + + $imp->ImportClients($imp->upload_dir . "/" . $_FILES['userfile']['name']); + + print "Imports : ".$imp->nb_import."
"; + print "Imports corrects : ".$imp->nb_import_ok."
"; + print "Imports erreurs : ".$imp->nb_import_ko."
"; + + } + else + { + $mesg = "Le fichier n'a pas été téléchargé"; + } +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/admin/import/index.php b/htdocs/admin/import/index.php index 438504dff34..ed1d6aba147 100644 --- a/htdocs/admin/import/index.php +++ b/htdocs/admin/import/index.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2007 Laurent Destailleur * * 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 @@ -20,68 +20,147 @@ */ /** - \file htdocs/admin/index.php - \brief Page d'import de donnee - \version $Revision$ + \file htdocs/imports/index.php + \ingroup core + \brief Page accueil de la zone import + \version $Revision$ */ + +require_once("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/admin/import/dolibarrimport.class.php"); -require("./pre.inc.php"); +$langs->load("exports"); -require(DOL_DOCUMENT_ROOT.'/admin/import/dolibarrimport.class.php'); +$user->getrights(); -$langs->load("admin"); -$langs->load("companies"); - -if (!$user->admin) +if (! $user->societe_id == 0) accessforbidden(); -/* - * Affichage page - */ -llxHeader(); + -$form = new Form($db); +$export=new DolibarrImport($db); +//$export->load_arrays($user); -print_fiche_titre($langs->trans("ImportArea"),'','setup'); + +llxHeader('',$langs->trans("ImportArea")); -print "
"; +print_fiche_titre($langs->trans("ImportArea")); -print '
'; -print ''; +print $langs->trans("FormatedImportDesc1").'
'; +print $langs->trans("FormatedImportDesc2").'
'; +print '
'; -print ''; -print ''; +print '
Importer un fichier clients
'; -print "\n"; -print '
"; -print '
'; -print '   '; -print '
'; - -print "
'; +print ''; -if ( $_POST["sendit"] && $conf->upload != 0) +// Liste des formats d'exports disponibles +$var=true; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +include_once(DOL_DOCUMENT_ROOT.'/includes/modules/export/modules_export.php'); +$model=new ModeleExports(); +$liste=$model->liste_modeles($db); + +foreach($liste as $key) { - $imp = new DolibarrImport($db); - $imp->CreateBackupDir(); - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $imp->upload_dir . "/" . $_FILES['userfile']['name'])) - { - - $imp->ImportClients($imp->upload_dir . "/" . $_FILES['userfile']['name']); - - print "Imports : ".$imp->nb_import."
"; - print "Imports corrects : ".$imp->nb_import_ok."
"; - print "Imports erreurs : ".$imp->nb_import_ko."
"; - - } - else - { - $mesg = "Le fichier n'a pas été téléchargé"; - } + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''; } +print '
'.$langs->trans("AvailableFormats").''.$langs->trans("LibraryUsed").''.$langs->trans("LibraryVersion").'
'.$model->getDriverLabel($key).''.$model->getLibLabel($key).''.$model->getLibVersion($key).'
'; + + +print ''; + + +// Affiche les modules d'exports +print ''; +print ''; +print ''; +print ''; +//print ''; +print ''; +$val=true; +if (sizeof($export->array_export_code)) +{ + foreach ($export->array_export_code as $key => $value) + { + $val=!$val; + print ''; +// print ''; + print ''; + + } + + print ''; +} +else +{ + print ''; +} +print '
'.$langs->trans("Module").''.$langs->trans("ImportableDatas").' 
'; + print img_object($export->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' '; + print $export->array_export_module[$key]->getName(); + print ''; + $string=$langs->trans($export->array_export_label[$key]); + print ($string!=$export->array_export_label[$key]?$string:$export->array_export_label[$key]); + print ''; +// print ''.img_picto($langs->trans("NewExport"),'filenew').''; +// print '
'.$langs->trans("NoImportableData").'
'; + + +// Affiche les profils d'exports +$sql = "SELECT rowid, label, public, fk_user, ".$db->pdate("datec"); +$sql .= " FROM ".MAIN_DB_PREFIX."export as e"; +$result=$db->query($sql); +if ($result) +{ + print '
'; + print ''; + print ''; + print ''; + print ''; + + $num = $db->num_rows($result); + if ($num > 0) + { + $var = true; + $i = 0; + + while ($i < $num ) + { + $obj = $db->fetch_object($result); + $var=!$var; + + print ""; + print ''; + print ''; + print ''; + $i++; + } + } + + print "
'.$langs->trans("ExportProfiles").''.$langs->trans("Public").'
'.$obj->label.''.$yn($obj->public).'
"; +} + + +print ''; +print ''; + $db->close(); + llxFooter('$Date$ - $Revision$'); + ?> diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php index b52cab8fd4f..43d14d2d7da 100644 --- a/htdocs/includes/menus/barre_left/eldy_backoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php @@ -727,6 +727,13 @@ class MenuLeft { $newmenu->add_submenu(DOL_URL_ROOT."/exports/export.php?leftmenu=export",$langs->trans("NewExport"),1, $user->rights->export->creer); } + if ($conf->global->MAIN_MODULE_IMPORT) + { + $langs->load("exports"); + $newmenu->add_submenu(DOL_URL_ROOT."/admin/import/index.php?leftmenu=import",$langs->trans("FormatedImport"),0, $user->rights->import->lire); + $newmenu->add_submenu(DOL_URL_ROOT."/admin/import/import.php?leftmenu=import",$langs->trans("NewImport"),1, $user->rights->import->creer); + } + if ($conf->global->MAIN_MODULE_DOMAIN) { $langs->load("domains"); diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index adad260cf75..667cf6629ce 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -1,7 +1,10 @@ # Dolibarr language file - en_US - exports ExportsArea=Exports area +ImportArea=Import area NewExport=New export +NewImport=New import ExportableDatas=Exportable dataset +ImportableDatas=Importable dataset SelectExportDataSet=Choose dataset you want to export... SelectExportFields=Choose fields you want to export, or select a predefined export profil SaveExportModel=Save this export profile if you plan to reuse it later... @@ -20,8 +23,12 @@ AvailableFormats=Formats disponibles LibraryUsed=Librairie LibraryVersion=Version Step=Step +FormatedImport=Import assistant +FormatedImportDesc1=This area allows to import personalized data, using an assistant to help you in process without technical knowledge. +FormatedImportDesc2=First step is to choose a king of data you want to load, then file to load, then to choose which fields you want to load. FormatedExport=Export assistant -FormatedExportDesc1=This area allows to export personalized data using an assistant to help in process without technical knowledge. +FormatedExportDesc1=This area allows to export personalized data, using an assistant to help you in process without technical knowledge. FormatedExportDesc2=First step is to choose a predefined dataset, then to choose which fields you want in your result files, and which order. FormatedExportDesc3=When data to export are selected, you can define output file format you want to export your data to. -Sheet=Sheet \ No newline at end of file +Sheet=Sheet +NoImportableData=No importable data (no module with definitions to allow data imports) \ No newline at end of file diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 22965070212..dbda4536257 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -1,7 +1,10 @@ # Dolibarr language file - fr_FR - exports ExportsArea=Espace exports +ImportArea=Espace import NewExport=Nouvel export +NewImport=Nouvel import ExportableDatas=Lot de données exportables +ImportableDatas=Lot de données importables SelectExportDataSet=Choisissez un lot prédéfini de données que vous désirez exporter... SelectExportFields=Choisissez les champs à exporter, ou choisissez un profil d'export prédéfini SaveExportModel=Enregistrer ce profil d'export si vous désirez le réutiliser ultérieurement... @@ -20,8 +23,12 @@ AvailableFormats=Formats dispo. LibraryUsed=Librairie utilisée LibraryVersion=Version Step=Etape +FormatedImport=Assistant import +FormatedImportDesc1=Cet espace permet de réaliser des imports personalisés des données via un assistant qui évite d'avoir des connaissances techniques de Dolibarr. +FormatedImportDesc2=La première étape est de choisir le type de donnée à importer, puis le fichier, ensuite de choisir les champs que vous voulez importer. FormatedExport=Assistant export FormatedExportDesc1=Cet espace permet de réaliser des exports personalisés des données via un assistant qui évite d'avoir des connaissances techniques de Dolibarr. FormatedExportDesc2=La première étape est de choisir un des lots de données prédéfinis, ensuite de choisir les champs que vous voulez dans votre fichier résultat, et dans quel ordre. FormatedExportDesc3=Une fois les données sélectionnées, il est possible de choisir le format du fichier export généré. -Sheet=Feuille \ No newline at end of file +Sheet=Feuille +NoImportableData=Pas de type de données importable (aucun module contenant des définitions de données importable n'est actif) \ No newline at end of file