Suite fonction import
This commit is contained in:
parent
f3d40e41a3
commit
7a31109acc
87
htdocs/admin/import/import.php
Normal file
87
htdocs/admin/import/import.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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 "<br>";
|
||||
|
||||
print '<form name="userfile" action="index.php" enctype="multipart/form-data" METHOD="POST">';
|
||||
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||
|
||||
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<tr class="liste_titre"><td>Importer un fichier clients</td></tr>';
|
||||
|
||||
print "<tr $bc[1]><td>";
|
||||
print '<input type="file" name="userfile" size="20" maxlength="80"><br />';
|
||||
print '<input type="submit" value="'.$langs->trans("Upload").'" name="sendit"> ';
|
||||
print '<input type="submit" value="'.$langs->trans("Cancel").'" name="cancelit"><br>';
|
||||
|
||||
print "</tr>\n";
|
||||
print '</table></form>';
|
||||
|
||||
|
||||
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."<br>";
|
||||
print "Imports corrects : ".$imp->nb_import_ok."<br>";
|
||||
print "Imports erreurs : ".$imp->nb_import_ko."<br>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = "Le fichier n'a pas été téléchargé";
|
||||
}
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
/* Copyright (C) 2005-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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 "<br>";
|
||||
print_fiche_titre($langs->trans("ImportArea"));
|
||||
|
||||
print '<form name="userfile" action="index.php" enctype="multipart/form-data" METHOD="POST">';
|
||||
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||
print $langs->trans("FormatedImportDesc1").'<br>';
|
||||
print $langs->trans("FormatedImportDesc2").'<br>';
|
||||
print '<br>';
|
||||
|
||||
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<tr class="liste_titre"><td>Importer un fichier clients</td></tr>';
|
||||
print '<table class="notopnoleftnoright" width="100%">';
|
||||
|
||||
print "<tr $bc[1]><td>";
|
||||
print '<input type="file" name="userfile" size="20" maxlength="80"><br />';
|
||||
print '<input type="submit" value="'.$langs->trans("Upload").'" name="sendit"> ';
|
||||
print '<input type="submit" value="'.$langs->trans("Cancel").'" name="cancelit"><br>';
|
||||
|
||||
print "</tr>\n";
|
||||
print '</table></form>';
|
||||
print '<tr><td valign="top" width="30%" class="notopnoleft">';
|
||||
|
||||
|
||||
if ( $_POST["sendit"] && $conf->upload != 0)
|
||||
// Liste des formats d'exports disponibles
|
||||
$var=true;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("AvailableFormats").'</td>';
|
||||
print '<td>'.$langs->trans("LibraryUsed").'</td>';
|
||||
print '<td>'.$langs->trans("LibraryVersion").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
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."<br>";
|
||||
print "Imports corrects : ".$imp->nb_import_ok."<br>";
|
||||
print "Imports erreurs : ".$imp->nb_import_ko."<br>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = "Le fichier n'a pas été téléchargé";
|
||||
}
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$model->getDriverLabel($key).'</td>';
|
||||
print '<td>'.$model->getLibLabel($key).'</td>';
|
||||
print '<td nowrap="nowrap" align="center">'.$model->getLibVersion($key).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
|
||||
|
||||
|
||||
// Affiche les modules d'exports
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Module").'</td>';
|
||||
print '<td>'.$langs->trans("ImportableDatas").'</td>';
|
||||
//print '<td> </td>';
|
||||
print '</tr>';
|
||||
$val=true;
|
||||
if (sizeof($export->array_export_code))
|
||||
{
|
||||
foreach ($export->array_export_code as $key => $value)
|
||||
{
|
||||
$val=!$val;
|
||||
print '<tr '.$bc[$val].'><td>';
|
||||
print img_object($export->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' ';
|
||||
print $export->array_export_module[$key]->getName();
|
||||
print '</td><td>';
|
||||
$string=$langs->trans($export->array_export_label[$key]);
|
||||
print ($string!=$export->array_export_label[$key]?$string:$export->array_export_label[$key]);
|
||||
print '</td>';
|
||||
// print '<td width="24">';
|
||||
// print '<a href="'.DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$export->array_export_code[$key].'&action=cleanselect">'.img_picto($langs->trans("NewExport"),'filenew').'</a>';
|
||||
// print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
}
|
||||
|
||||
print '<tr class="total"><td class="total" colspan="2" align="center"><form action="'.DOL_URL_ROOT.'/admin/import.php?leftmenu=import"><input type="submit" class="button" value="'.$langs->trans("NewExport").'"></form></td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td '.$bc[false].' colspan="2">'.$langs->trans("NoImportableData").'</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
|
||||
// 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 '<br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="2">'.$langs->trans("ExportProfiles").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Public").'</td></tr>';
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
if ($num > 0)
|
||||
{
|
||||
$var = true;
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num )
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.$obj->label.'</td>';
|
||||
print '<td align="center">'.$yn($obj->public).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
}
|
||||
|
||||
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
|
||||
?>
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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
|
||||
Sheet=Sheet
|
||||
NoImportableData=No importable data (no module with definitions to allow data imports)
|
||||
@ -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
|
||||
Sheet=Feuille
|
||||
NoImportableData=Pas de type de données importable (aucun module contenant des définitions de données importable n'est actif)
|
||||
Loading…
Reference in New Issue
Block a user