Work on import module
This commit is contained in:
parent
1af4674b5c
commit
8b12e7c07b
@ -18,18 +18,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/exports/export.class.php
|
* \file htdocs/exports/export.class.php
|
||||||
\ingroup export
|
* \ingroup export
|
||||||
\brief Fichier de la classe des exports
|
* \brief Fichier de la classe des exports
|
||||||
\version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class Export
|
* \class Export
|
||||||
\brief Classe permettant la gestion des exports
|
* \brief Classe permettant la gestion des exports
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Export
|
class Export
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
@ -71,10 +70,16 @@ class Export
|
|||||||
|
|
||||||
dol_syslog("Export::load_arrays user=".$user->id." filter=".$filter);
|
dol_syslog("Export::load_arrays user=".$user->id." filter=".$filter);
|
||||||
|
|
||||||
$dir=DOL_DOCUMENT_ROOT."/includes/modules";
|
//$dir=DOL_DOCUMENT_ROOT."/includes/modules";
|
||||||
|
foreach($conf->file->dol_document_root as $dirroot)
|
||||||
|
{
|
||||||
|
$dir = $dirroot.'/includes/modules';
|
||||||
$handle=opendir($dir);
|
$handle=opendir($dir);
|
||||||
|
|
||||||
// Recherche des exports disponibles
|
// Search available exports
|
||||||
|
$handle=@opendir($dir);
|
||||||
|
if ($handle)
|
||||||
|
{
|
||||||
$var=True;
|
$var=True;
|
||||||
$i=0;
|
$i=0;
|
||||||
while (($file = readdir($handle))!==false)
|
while (($file = readdir($handle))!==false)
|
||||||
@ -117,8 +122,8 @@ class Export
|
|||||||
//print $bool." $perm[0]"."<br>";
|
//print $bool." $perm[0]"."<br>";
|
||||||
|
|
||||||
// Permissions ok
|
// Permissions ok
|
||||||
// if ($bool)
|
// if ($bool)
|
||||||
// {
|
// {
|
||||||
// Charge fichier lang en rapport
|
// Charge fichier lang en rapport
|
||||||
$langtoload=$module->getLangFilesArray();
|
$langtoload=$module->getLangFilesArray();
|
||||||
if (is_array($langtoload))
|
if (is_array($langtoload))
|
||||||
@ -155,7 +160,8 @@ class Export
|
|||||||
|
|
||||||
dol_syslog("Export loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".sizeof($module->export_fields_code[$r]));
|
dol_syslog("Export loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".sizeof($module->export_fields_code[$r]));
|
||||||
$i++;
|
$i++;
|
||||||
// }
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,6 +169,7 @@ class Export
|
|||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Lance la generation du fichier
|
* \brief Lance la generation du fichier
|
||||||
|
|||||||
@ -18,11 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/exports/export.php
|
* \file htdocs/exports/export.php
|
||||||
\ingroup export
|
* \ingroup export
|
||||||
\brief Page d'edition d'un export
|
* \brief Page d'edition d'un export
|
||||||
\version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once("./pre.inc.php");
|
require_once("./pre.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
||||||
@ -699,7 +699,7 @@ if ($step == 4 && $datatoexport)
|
|||||||
$var=true;
|
$var=true;
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>'.$langs->trans("AvailableFormats").'</td>';
|
print '<td colspan="2">'.$langs->trans("AvailableFormats").'</td>';
|
||||||
print '<td>'.$langs->trans("LibraryUsed").'</td>';
|
print '<td>'.$langs->trans("LibraryUsed").'</td>';
|
||||||
print '<td>'.$langs->trans("LibraryVersion").'</td>';
|
print '<td>'.$langs->trans("LibraryVersion").'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -708,7 +708,9 @@ if ($step == 4 && $datatoexport)
|
|||||||
foreach($liste as $key)
|
foreach($liste as $key)
|
||||||
{
|
{
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td>'.$objmodelexport->getDriverLabel($key).'</td><td>'.$objmodelexport->getLibLabel($key).'</td><td>'.$objmodelexport->getLibVersion($key).'</td></tr>';
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td width="20">'.img_picto_common($key,$objmodelexport->getPicto($key)).'</td>';
|
||||||
|
print '<td>'.$objmodelexport->getDriverLabel($key).'</td><td>'.$objmodelexport->getLibLabel($key).'</td><td>'.$objmodelexport->getLibVersion($key).'</td></tr>';
|
||||||
}
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -50,9 +50,16 @@ class Import
|
|||||||
|
|
||||||
dol_syslog("Import::load_arrays user=".$user->id." filter=".$filter);
|
dol_syslog("Import::load_arrays user=".$user->id." filter=".$filter);
|
||||||
|
|
||||||
$dir=DOL_DOCUMENT_ROOT."/includes/modules";
|
//$dir=DOL_DOCUMENT_ROOT."/includes/modules";
|
||||||
|
foreach($conf->file->dol_document_root as $dirroot)
|
||||||
|
{
|
||||||
|
$dir = $dirroot.'/includes/modules';
|
||||||
$handle=opendir($dir);
|
$handle=opendir($dir);
|
||||||
|
|
||||||
|
// Search available exports
|
||||||
|
$handle=@opendir($dir);
|
||||||
|
if ($handle)
|
||||||
|
{
|
||||||
// Recherche des exports disponibles
|
// Recherche des exports disponibles
|
||||||
$var=True;
|
$var=True;
|
||||||
$i=0;
|
$i=0;
|
||||||
@ -75,14 +82,14 @@ class Import
|
|||||||
require_once($file);
|
require_once($file);
|
||||||
$module = new $classname($this->db);
|
$module = new $classname($this->db);
|
||||||
|
|
||||||
if (is_array($module->export_code))
|
if (is_array($module->import_code))
|
||||||
{
|
{
|
||||||
foreach($module->export_code as $r => $value)
|
foreach($module->import_code as $r => $value)
|
||||||
{
|
{
|
||||||
if ($filter && ($filter != $module->export_code[$r])) continue;
|
if ($filter && ($filter != $module->import_code[$r])) continue;
|
||||||
|
|
||||||
// Test si permissions ok \todo tester sur toutes permissions
|
// Test if permissions are ok
|
||||||
$perm=$module->export_permission[$r][0];
|
/*$perm=$module->import_permission[$r][0];
|
||||||
//print_r("$perm[0]-$perm[1]-$perm[2]<br>");
|
//print_r("$perm[0]-$perm[1]-$perm[2]<br>");
|
||||||
if ($perm[2])
|
if ($perm[2])
|
||||||
{
|
{
|
||||||
@ -94,10 +101,11 @@ class Import
|
|||||||
}
|
}
|
||||||
if ($perm[0]=='user' && $user->admin) $bool=true;
|
if ($perm[0]=='user' && $user->admin) $bool=true;
|
||||||
//print $bool." $perm[0]"."<br>";
|
//print $bool." $perm[0]"."<br>";
|
||||||
|
*/
|
||||||
|
|
||||||
// Permissions ok
|
// Permissions ok
|
||||||
// if ($bool)
|
// if ($bool)
|
||||||
// {
|
// {
|
||||||
// Charge fichier lang en rapport
|
// Charge fichier lang en rapport
|
||||||
$langtoload=$module->getLangFilesArray();
|
$langtoload=$module->getLangFilesArray();
|
||||||
if (is_array($langtoload))
|
if (is_array($langtoload))
|
||||||
@ -109,32 +117,34 @@ class Import
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Module
|
// Module
|
||||||
$this->array_export_module[$i]=$module;
|
$this->array_import_module[$i]=$module;
|
||||||
// Permission
|
// Permission
|
||||||
$this->array_export_perms[$i]=$bool;
|
$this->array_import_perms[$i]=$user->admin;
|
||||||
// Icon
|
// Icon
|
||||||
$this->array_export_icon[$i]=(isset($module->export_icon[$r])?$module->export_icon[$r]:$module->picto);
|
$this->array_import_icon[$i]=(isset($module->export_icon[$r])?$module->export_icon[$r]:$module->picto);
|
||||||
// Code du dataset export
|
// Code du dataset export
|
||||||
$this->array_export_code[$i]=$module->export_code[$r];
|
$this->array_import_code[$i]=$module->export_code[$r];
|
||||||
// Libelle du dataset export
|
// Libelle du dataset export
|
||||||
$this->array_export_label[$i]=$module->getDatasetLabel($r);
|
$this->array_import_label[$i]=$module->getDatasetLabel($r);
|
||||||
// Tableau des champ a exporter (cle=champ, valeur=libelle)
|
// Tableau des champ a exporter (cle=champ, valeur=libelle)
|
||||||
$this->array_export_fields[$i]=$module->export_fields_array[$r];
|
$this->array_import_fields[$i]=$module->export_fields_array[$r];
|
||||||
// Tableau des entites a exporter (cle=champ, valeur=entite)
|
// Tableau des entites a exporter (cle=champ, valeur=entite)
|
||||||
$this->array_export_entities[$i]=$module->export_entities_array[$r];
|
$this->array_import_entities[$i]=$module->export_entities_array[$r];
|
||||||
// Tableau des alias a exporter (cle=champ, valeur=alias)
|
// Tableau des alias a exporter (cle=champ, valeur=alias)
|
||||||
$this->array_export_alias[$i]=$module->export_alias_array[$r];
|
$this->array_import_alias[$i]=$module->export_alias_array[$r];
|
||||||
// Tableau des operations speciales sur champ
|
// Tableau des operations speciales sur champ
|
||||||
$this->array_export_special[$i]=$module->export_special_array[$r];
|
$this->array_import_special[$i]=$module->export_special_array[$r];
|
||||||
|
|
||||||
// Requete sql du dataset
|
// Requete sql du dataset
|
||||||
$this->array_export_sql_start[$i]=$module->export_sql_start[$r];
|
$this->array_import_sql_start[$i]=$module->export_sql_start[$r];
|
||||||
$this->array_export_sql_end[$i]=$module->export_sql_end[$r];
|
$this->array_import_sql_end[$i]=$module->export_sql_end[$r];
|
||||||
//$this->array_export_sql[$i]=$module->export_sql[$r];
|
//$this->array_import_sql[$i]=$module->export_sql[$r];
|
||||||
|
|
||||||
dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".sizeof($module->export_fields_code[$r]));
|
dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".sizeof($module->export_fields_code[$r]));
|
||||||
$i++;
|
$i++;
|
||||||
// }
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,48 +254,5 @@ class Import
|
|||||||
return $errno;
|
return $errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
\brief Cree le repertoire de backup
|
|
||||||
*/
|
|
||||||
function CreateBackupDir()
|
|
||||||
{
|
|
||||||
$time = time();
|
|
||||||
|
|
||||||
$upload_dir = DOL_DATA_ROOT."/import/";
|
|
||||||
|
|
||||||
if (! is_dir($upload_dir))
|
|
||||||
{
|
|
||||||
umask(0);
|
|
||||||
if (! mkdir($upload_dir, 0755))
|
|
||||||
{
|
|
||||||
dol_syslog("Import::ReadFile Impossible de creer $upload_dir",LOG_ERR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$upload_dir = DOL_DATA_ROOT."/import/".strftime("%Y",$time);
|
|
||||||
|
|
||||||
if (! is_dir($upload_dir))
|
|
||||||
{
|
|
||||||
umask(0);
|
|
||||||
if (! mkdir($upload_dir, 0755))
|
|
||||||
{
|
|
||||||
dol_syslog("Import::ReadFile Impossible de creer $upload_dir",LOG_ERR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$upload_dir = DOL_DATA_ROOT."/import/".strftime("%Y",$time)."/".strftime("%d-%m-%Y",$time);
|
|
||||||
|
|
||||||
if (! is_dir($upload_dir))
|
|
||||||
{
|
|
||||||
umask(0);
|
|
||||||
if (! mkdir($upload_dir, 0755))
|
|
||||||
{
|
|
||||||
dol_syslog("Import::ReadFile Impossible de creer $upload_dir",LOG_ERR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->upload_dir = DOL_DATA_ROOT."/import/".strftime("%Y",$time)."/".strftime("%d-%m-%Y",$time);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -34,7 +34,7 @@ $langs->load("exports");
|
|||||||
|
|
||||||
|
|
||||||
if (! $user->societe_id == 0)
|
if (! $user->societe_id == 0)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
$entitytoicon=array(
|
$entitytoicon=array(
|
||||||
'invoice'=>'bill','invoice_line'=>'bill',
|
'invoice'=>'bill','invoice_line'=>'bill',
|
||||||
@ -46,8 +46,8 @@ $entitytoicon=array(
|
|||||||
'payment'=>'payment',
|
'payment'=>'payment',
|
||||||
'product'=>'product','stock'=>'generic','warehouse'=>'stock',
|
'product'=>'product','stock'=>'generic','warehouse'=>'stock',
|
||||||
'category'=>'generic',
|
'category'=>'generic',
|
||||||
'other'=>'generic',
|
'other'=>'generic'
|
||||||
);
|
);
|
||||||
$entitytolang=array( // Translation code
|
$entitytolang=array( // Translation code
|
||||||
'user'=>'User',
|
'user'=>'User',
|
||||||
'company'=>'Company','contact'=>'Contact',
|
'company'=>'Company','contact'=>'Contact',
|
||||||
@ -61,7 +61,7 @@ $entitytolang=array( // Translation code
|
|||||||
'product'=>'Product','stock'=>'Stock','warehouse'=>'Warehouse',
|
'product'=>'Product','stock'=>'Stock','warehouse'=>'Warehouse',
|
||||||
'category'=>'Category',
|
'category'=>'Category',
|
||||||
'other'=>'Other'
|
'other'=>'Other'
|
||||||
);
|
);
|
||||||
|
|
||||||
$array_selected=isset($_SESSION["import_selected_fields"])?$_SESSION["import_selected_fields"]:array();
|
$array_selected=isset($_SESSION["import_selected_fields"])?$_SESSION["import_selected_fields"]:array();
|
||||||
$datatoimport=isset($_GET["datatoimport"])? $_GET["datatoimport"] : (isset($_POST["datatoimport"])?$_POST["datatoimport"]:'');
|
$datatoimport=isset($_GET["datatoimport"])? $_GET["datatoimport"] : (isset($_POST["datatoimport"])?$_POST["datatoimport"]:'');
|
||||||
@ -246,6 +246,8 @@ if ($step == 2 && $action == 'select_model')
|
|||||||
* Affichage Pages des Etapes
|
* Affichage Pages des Etapes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$objmodelimport=new ModeleImports();
|
||||||
|
|
||||||
|
|
||||||
if ($step == 1 || ! $datatoimport)
|
if ($step == 1 || ! $datatoimport)
|
||||||
{
|
{
|
||||||
@ -297,7 +299,7 @@ if ($step == 1 || ! $datatoimport)
|
|||||||
print '</td><td align="right">';
|
print '</td><td align="right">';
|
||||||
if ($objimport->array_import_perms[$key])
|
if ($objimport->array_import_perms[$key])
|
||||||
{
|
{
|
||||||
print '<a href="'.DOL_URL_ROOT.'/imports/import.php?step=2&datatoimprt='.$objimport->array_import_code[$key].'">'.img_picto($langs->trans("NewImport"),'filenew').'</a>';
|
print '<a href="'.DOL_URL_ROOT.'/imports/import.php?step=2&datatoimport='.$objimport->array_import_code[$key].'">'.img_picto($langs->trans("NewImport"),'filenew').'</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -324,7 +326,6 @@ if ($step == 2 && $datatoimport)
|
|||||||
{
|
{
|
||||||
llxHeader('',$langs->trans("NewImport"));
|
llxHeader('',$langs->trans("NewImport"));
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Affichage onglets
|
* Affichage onglets
|
||||||
*/
|
*/
|
||||||
@ -342,42 +343,6 @@ if ($step == 2 && $datatoimport)
|
|||||||
dol_fiche_head($head, $hselected, $langs->trans("NewImport"));
|
dol_fiche_head($head, $hselected, $langs->trans("NewImport"));
|
||||||
|
|
||||||
|
|
||||||
print '<form name="userfile" action="index.php" enctype="multipart/form-data" METHOD="POST">';
|
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
||||||
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"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
|
||||||
{
|
|
||||||
$imp = new DolibarrImport($db);
|
|
||||||
$imp->CreateBackupDir();
|
|
||||||
if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $imp->upload_dir . "/" . $_FILES['userfile']['name'],1) > 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
$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 <20>t<EFBFBD> t<>l<EFBFBD>charg<72>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
print '<table width="100%" class="border">';
|
print '<table width="100%" class="border">';
|
||||||
|
|
||||||
// Module
|
// Module
|
||||||
@ -397,8 +362,66 @@ if ($step == 2 && $datatoimport)
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
// Liste deroulante des modeles d'import
|
|
||||||
print '<form action="import.php" method="post">';
|
|
||||||
|
print '<form name="userfile" action="index.php" enctype="multipart/form-data" METHOD="POST">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
|
||||||
|
|
||||||
|
$var=true;
|
||||||
|
|
||||||
|
// Add help informations
|
||||||
|
print '<tr class="liste_titre"><td colspan="2">';
|
||||||
|
print $langs->trans("FileMustHaveOneOfFollowingFormat");
|
||||||
|
print '</td></tr>';
|
||||||
|
$liste=$objmodelimport->liste_modeles($db);
|
||||||
|
foreach($liste as $key)
|
||||||
|
{
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td width="20">'.img_picto_common($key,$objmodelimport->getPicto($key)).'</td>';
|
||||||
|
print '<td>'.$objmodelimport->getDriverLabel($key).'</td>';
|
||||||
|
//print '<td>'.$objmodelimport->getLibLabel($key).'</td><td>'.$objmodelimport->getLibVersion($key).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("FileWithDataToImport").'</td></tr>';
|
||||||
|
|
||||||
|
// Input file name box
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'><td colspan="2">';
|
||||||
|
print '<input type="file" name="userfile" size="20" maxlength="80"> ';
|
||||||
|
print '<input type="submit" class="button" 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"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||||
|
{
|
||||||
|
$imp = new DolibarrImport($db);
|
||||||
|
print "eee".$conf->import->dir_temp;
|
||||||
|
create_ext_dir($conf->import->dir_temp);
|
||||||
|
if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $imp->upload_dir . "/" . $_FILES['userfile']['name'],1) > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
$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 = "Files was not read";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List deroulante des modeles d'import
|
||||||
|
/* print '<form action="import.php" method="post">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="action" value="select_model">';
|
print '<input type="hidden" name="action" value="select_model">';
|
||||||
print '<input type="hidden" name="step" value="2">';
|
print '<input type="hidden" name="step" value="2">';
|
||||||
@ -427,13 +450,13 @@ if ($step == 2 && $datatoimport)
|
|||||||
// Champs importables
|
// Champs importables
|
||||||
$fieldsarray=$objimport->array_import_fields[0];
|
$fieldsarray=$objimport->array_import_fields[0];
|
||||||
|
|
||||||
# $this->array_import_module[0]=$module;
|
# $this->array_import_module[0]=$module;
|
||||||
# $this->array_import_code[0]=$module->import_code[$r];
|
# $this->array_import_code[0]=$module->import_code[$r];
|
||||||
# $this->array_import_label[0]=$module->import_label[$r];
|
# $this->array_import_label[0]=$module->import_label[$r];
|
||||||
# $this->array_import_sql[0]=$module->import_sql[$r];
|
# $this->array_import_sql[0]=$module->import_sql[$r];
|
||||||
# $this->array_import_fields[0]=$module->import_fields_array[$r];
|
# $this->array_import_fields[0]=$module->import_fields_array[$r];
|
||||||
# $this->array_import_entities[0]=$module->import_fields_entities[$r];
|
# $this->array_import_entities[0]=$module->import_fields_entities[$r];
|
||||||
# $this->array_import_alias[0]=$module->import_fields_alias[$r];
|
# $this->array_import_alias[0]=$module->import_fields_alias[$r];
|
||||||
|
|
||||||
$var=true;
|
$var=true;
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -472,6 +495,7 @@ if ($step == 2 && $datatoimport)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
*/
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,7 @@ class ExportCsv extends ModeleExports
|
|||||||
$this->id='csv'; // Same value then xxx in file name export_xxx.modules.php
|
$this->id='csv'; // Same value then xxx in file name export_xxx.modules.php
|
||||||
$this->label='Csv (Comma Separated Value)'; // Label of driver
|
$this->label='Csv (Comma Separated Value)'; // Label of driver
|
||||||
$this->extension='csv'; // Extension for generated file by this driver
|
$this->extension='csv'; // Extension for generated file by this driver
|
||||||
|
$this->picto='mime/other'; // Picto
|
||||||
$ver=split(' ','$Revision$');
|
$ver=split(' ','$Revision$');
|
||||||
$this->version=$ver[2]; // Driver version
|
$this->version=$ver[2]; // Driver version
|
||||||
|
|
||||||
|
|||||||
@ -64,6 +64,7 @@ class ExportExcel extends ModeleExports
|
|||||||
$this->id='excel'; // Same value then xxx in file name export_xxx.modules.php
|
$this->id='excel'; // Same value then xxx in file name export_xxx.modules.php
|
||||||
$this->label='Excel'; // Label of driver
|
$this->label='Excel'; // Label of driver
|
||||||
$this->extension='xls'; // Extension for generated file by this driver
|
$this->extension='xls'; // Extension for generated file by this driver
|
||||||
|
$this->picto='mime/xls'; // Picto
|
||||||
$ver=split(' ','$Revision$');
|
$ver=split(' ','$Revision$');
|
||||||
$this->version=$ver[2]; // Driver version
|
$this->version=$ver[2]; // Driver version
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,7 @@ class ExportTsv extends ModeleExports
|
|||||||
$this->id='tsv'; // Same value then xxx in file name export_xxx.modules.php
|
$this->id='tsv'; // Same value then xxx in file name export_xxx.modules.php
|
||||||
$this->label='Tsv (Tab Separated Value)'; // Label of driver
|
$this->label='Tsv (Tab Separated Value)'; // Label of driver
|
||||||
$this->extension='tsv'; // Extension for generated file by this driver
|
$this->extension='tsv'; // Extension for generated file by this driver
|
||||||
|
$this->picto='mime/other'; // Picto
|
||||||
$ver=split(' ','$Revision$');
|
$ver=split(' ','$Revision$');
|
||||||
$this->version=$ver[2]; // Driver version
|
$this->version=$ver[2]; // Driver version
|
||||||
|
|
||||||
|
|||||||
@ -77,6 +77,8 @@ class ModeleExports
|
|||||||
require_once($file);
|
require_once($file);
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
|
// Picto
|
||||||
|
$this->picto[$module->id]=$module->picto;
|
||||||
// Driver properties
|
// Driver properties
|
||||||
$this->driverlabel[$module->id]=$module->getDriverLabel();
|
$this->driverlabel[$module->id]=$module->getDriverLabel();
|
||||||
$this->driverversion[$module->id]=$module->getDriverVersion();
|
$this->driverversion[$module->id]=$module->getDriverVersion();
|
||||||
@ -92,6 +94,14 @@ class ModeleExports
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return picto of export driver
|
||||||
|
*/
|
||||||
|
function getPicto($key)
|
||||||
|
{
|
||||||
|
return $this->picto[$key];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoi libelle d'un driver export
|
* \brief Renvoi libelle d'un driver export
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -59,6 +59,7 @@ class ImportCsv extends ModeleImports
|
|||||||
$this->id='csv'; // Same value then xxx in file name export_xxx.modules.php
|
$this->id='csv'; // Same value then xxx in file name export_xxx.modules.php
|
||||||
$this->label='Csv (Comma Separated Value)'; // Label of driver
|
$this->label='Csv (Comma Separated Value)'; // Label of driver
|
||||||
$this->extension='csv'; // Extension for generated file by this driver
|
$this->extension='csv'; // Extension for generated file by this driver
|
||||||
|
$this->picto='mime/other'; // Picto
|
||||||
$ver=split(' ','$Revision$');
|
$ver=split(' ','$Revision$');
|
||||||
$this->version=$ver[2]; // Driver version
|
$this->version=$ver[2]; // Driver version
|
||||||
|
|
||||||
|
|||||||
@ -77,6 +77,8 @@ class ModeleImports
|
|||||||
require_once($file);
|
require_once($file);
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
|
// Picto
|
||||||
|
$this->picto[$module->id]=$module->picto;
|
||||||
// Driver properties
|
// Driver properties
|
||||||
$this->driverlabel[$module->id]=$module->getDriverLabel();
|
$this->driverlabel[$module->id]=$module->getDriverLabel();
|
||||||
$this->driverversion[$module->id]=$module->getDriverVersion();
|
$this->driverversion[$module->id]=$module->getDriverVersion();
|
||||||
@ -92,6 +94,14 @@ class ModeleImports
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return picto of import driver
|
||||||
|
*/
|
||||||
|
function getPicto($key)
|
||||||
|
{
|
||||||
|
return $this->picto[$key];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoi libelle d'un driver export
|
* \brief Renvoi libelle d'un driver export
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -78,18 +78,13 @@ class modImport extends DolibarrModules
|
|||||||
$this->rights = array();
|
$this->rights = array();
|
||||||
$this->rights_class = 'import';
|
$this->rights_class = 'import';
|
||||||
|
|
||||||
|
/*
|
||||||
$this->rights[1][0] = 1401;
|
$this->rights[1][0] = 1401;
|
||||||
$this->rights[1][1] = 'Lire les imports';
|
$this->rights[1][1] = 'Réaliser un import';
|
||||||
$this->rights[1][2] = 'r';
|
$this->rights[1][2] = 'r';
|
||||||
$this->rights[1][3] = 1;
|
$this->rights[1][3] = 1;
|
||||||
$this->rights[1][4] = 'lire';
|
$this->rights[1][4] = 'lire';
|
||||||
|
*/
|
||||||
$this->rights[2][0] = 1402;
|
|
||||||
$this->rights[2][1] = 'Creer/modifier un import';
|
|
||||||
$this->rights[2][2] = 'w';
|
|
||||||
$this->rights[2][3] = 0;
|
|
||||||
$this->rights[2][4] = 'creer';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -159,21 +159,12 @@ class modProduit extends DolibarrModules
|
|||||||
$r++;
|
$r++;
|
||||||
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||||
$this->import_label[$r]="ProductsOrServices"; // Translation key
|
$this->import_label[$r]="ProductsOrServices"; // Translation key
|
||||||
|
//$this->import_permission[$r]=array(array("societe","import"));
|
||||||
$this->import_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.envente'=>"OnSell",'p.duration'=>"Duration");
|
$this->import_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.envente'=>"OnSell",'p.duration'=>"Duration");
|
||||||
$this->import_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>'product','p.envente'=>"product",'p.duration'=>"product");
|
$this->import_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>'product','p.envente'=>"product",'p.duration'=>"product");
|
||||||
//$this->import_alias_array[$r]=array('p.rowid'=>"id",'p.ref'=>"ref",'p.fk_product_type'=>"type",'p.label'=>"label",'p.description'=>"description",'p.note'=>"note",'p.price'=>"price",'p.tva_tx'=>'vat','p.envente'=>"onsell",'p.duration'=>"duration");
|
|
||||||
|
|
||||||
if($conf->global->PRODUIT_MULTIPRICES)
|
|
||||||
{
|
|
||||||
$this->import_multiprices[$r]=array();
|
|
||||||
|
|
||||||
for($i=1;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
|
||||||
{
|
|
||||||
$this->import_multiprices[$r][$i]["price_ht"] = "SellingPriceHT ".$i;
|
|
||||||
$this->import_multiprices[$r][$i]["price_ttc"] = "SellingPriceTTC ".$i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$this->import_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'produit as s';
|
||||||
|
$this->import_sql_end[$r] .='';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,9 +21,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\defgroup societe Module societe
|
* \defgroup societe Module societe
|
||||||
\brief Module pour gerer les societes et contacts clients
|
* \brief Module to manage third parties (customers, prospects)
|
||||||
\version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,7 +187,7 @@ class modSociete extends DolibarrModules
|
|||||||
//--------
|
//--------
|
||||||
$r=0;
|
$r=0;
|
||||||
|
|
||||||
// Export liste des societes et attributs
|
// Export list of third parties and attributes
|
||||||
$r++;
|
$r++;
|
||||||
$this->export_code[$r]=$this->rights_class.'_'.$r;
|
$this->export_code[$r]=$this->rights_class.'_'.$r;
|
||||||
$this->export_label[$r]='ExportDataset_company_1';
|
$this->export_label[$r]='ExportDataset_company_1';
|
||||||
@ -204,7 +204,7 @@ class modSociete extends DolibarrModules
|
|||||||
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
|
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
|
||||||
$this->export_sql_end[$r] .=' WHERE s.entity = '.$conf->entity;
|
$this->export_sql_end[$r] .=' WHERE s.entity = '.$conf->entity;
|
||||||
|
|
||||||
// Export liste des contacts et attributs
|
// Export list of contacts and attributes
|
||||||
$r++;
|
$r++;
|
||||||
$this->export_code[$r]=$this->rights_class.'_'.$r;
|
$this->export_code[$r]=$this->rights_class.'_'.$r;
|
||||||
$this->export_label[$r]='ExportDataset_company_2';
|
$this->export_label[$r]='ExportDataset_company_2';
|
||||||
@ -219,6 +219,23 @@ class modSociete extends DolibarrModules
|
|||||||
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid';
|
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid';
|
||||||
$this->export_sql_end[$r] .=' WHERE c.fk_pays = p.rowid';
|
$this->export_sql_end[$r] .=' WHERE c.fk_pays = p.rowid';
|
||||||
$this->export_sql_end[$r] .=' AND c.entity = '.$conf->entity;
|
$this->export_sql_end[$r] .=' AND c.entity = '.$conf->entity;
|
||||||
|
|
||||||
|
|
||||||
|
// Imports
|
||||||
|
//--------
|
||||||
|
$r=0;
|
||||||
|
|
||||||
|
// Import list of third parties and attributes
|
||||||
|
$r++;
|
||||||
|
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||||
|
$this->import_label[$r]='ImportDataset_company_1';
|
||||||
|
//$this->import_permission[$r]=array(array("societe","export"));
|
||||||
|
$this->import_fields_array[$r]=array('s.rowid'=>"Id",'s.nom'=>"Name",'s.prefix_comm'=>"Prefix",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'p.libelle'=>"Country",'p.code'=>"CountryCode",'s.tel'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siret'=>"IdProf1",'s.siren'=>"IdProf2",'s.ape'=>"IdProf3",'s.idprof4'=>"IdProf4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note'=>"Note",'t.libelle'=>"ThirdPartyType",'ce.code'=>"Effectif","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','fk_stcomm'=>'ProspectStatus');
|
||||||
|
$this->import_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>"company",'s.prefix_comm'=>"company",'s.client'=>"company",'s.fournisseur'=>"company",'s.datec'=>"company",'s.tms'=>"company",'s.code_client'=>"company",'s.code_fournisseur'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"company",'p.libelle'=>"company",'p.code'=>"company",'s.tel'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note'=>"company",'t.libelle'=>"company",'ce.code'=>"company","cfj.libelle"=>"company",'s.fk_prospectlevel'=>'company','fk_stcomm'=>'company');
|
||||||
|
|
||||||
|
$this->import_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'societe as s';
|
||||||
|
$this->import_sql_end[$r] .='';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -52,5 +52,5 @@ LineTotalHT=Amount net of tax for line
|
|||||||
LineTotalTTC=Amount with tax for line
|
LineTotalTTC=Amount with tax for line
|
||||||
LineTotalVAT=Amount of VAT for line
|
LineTotalVAT=Amount of VAT for line
|
||||||
TypeOfLineServiceOrProduct=Type of line (0=product, 1=service)
|
TypeOfLineServiceOrProduct=Type of line (0=product, 1=service)
|
||||||
|
FileWithDataToImport=File with data to import
|
||||||
TypeOfLineServiceOrProduct=Type of line (0=product, 1=service)
|
FileMustHaveOneOfFollowingFormat=File to import must have one of following format
|
||||||
|
|||||||
@ -52,3 +52,5 @@ LineTotalHT=Montant HT de la ligne
|
|||||||
LineTotalTTC=Montant TTC de la ligne
|
LineTotalTTC=Montant TTC de la ligne
|
||||||
LineTotalVAT=Montant TVA de la ligne
|
LineTotalVAT=Montant TVA de la ligne
|
||||||
TypeOfLineServiceOrProduct=Type de ligne (0=produit, 1=service)
|
TypeOfLineServiceOrProduct=Type de ligne (0=produit, 1=service)
|
||||||
|
FileWithDataToImport=Fichier contenant les données à importer
|
||||||
|
FileMustHaveOneOfFollowingFormat=Le fichier à importer doit avoir un des formats suivants
|
||||||
@ -904,7 +904,7 @@ function img_object($alt, $object)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Show picto (generic function)
|
* \brief Show picto (generic function)
|
||||||
* \param alt Texte sur le alt de l'image
|
* \param alt Text on alt and title of image
|
||||||
* \param picto Nom de l'image a afficher (Si pas d'extension, on met '.png')
|
* \param picto Nom de l'image a afficher (Si pas d'extension, on met '.png')
|
||||||
* \param options Attribut supplementaire a la balise img
|
* \param options Attribut supplementaire a la balise img
|
||||||
* \param pictoisfullpath If 1, image path is a full path
|
* \param pictoisfullpath If 1, image path is a full path
|
||||||
@ -920,7 +920,7 @@ function img_picto($alt, $picto, $options='', $pictoisfullpath=0)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Show picto (generic function)
|
* \brief Show picto (generic function)
|
||||||
* \param alt Texte sur le alt de l'image
|
* \param alt Text on alt and title of image
|
||||||
* \param picto Nom de l'image a afficher (Si pas d'extension, on met '.png')
|
* \param picto Nom de l'image a afficher (Si pas d'extension, on met '.png')
|
||||||
* \param options Attribut supplementaire a la balise img
|
* \param options Attribut supplementaire a la balise img
|
||||||
* \param pictoisfullpath If 1, image path is a full path
|
* \param pictoisfullpath If 1, image path is a full path
|
||||||
@ -1305,6 +1305,11 @@ function img_allow($allow)
|
|||||||
function img_mime($file,$alt='')
|
function img_mime($file,$alt='')
|
||||||
{
|
{
|
||||||
$mime='other';
|
$mime='other';
|
||||||
|
|
||||||
|
if (eregi('\.xls',$file) || eregi('\.xlsx',$file)) { $mime='xls'; }
|
||||||
|
if (eregi('\.ppt',$file) || eregi('\.pptx',$file)) { $mime='ppt'; }
|
||||||
|
if (eregi('\.doc',$file) || eregi('\.docx',$file)) { $mime='doc'; }
|
||||||
|
|
||||||
if (eregi('\.pdf',$file)) { $mime='pdf'; }
|
if (eregi('\.pdf',$file)) { $mime='pdf'; }
|
||||||
if (eregi('\.(html|htm)',$file)) { $mime='html'; }
|
if (eregi('\.(html|htm)',$file)) { $mime='html'; }
|
||||||
if (eregi('\.txt',$file)) { $mime='other'; }
|
if (eregi('\.txt',$file)) { $mime='other'; }
|
||||||
@ -1357,7 +1362,6 @@ function info_admin($texte,$infoonimgalt=0)
|
|||||||
* \param feature2 Feature to check (second level of permission)
|
* \param feature2 Feature to check (second level of permission)
|
||||||
* \param dbt_keyfield Field name for socid foreign key if not fk_soc. (optionnal)
|
* \param dbt_keyfield Field name for socid foreign key if not fk_soc. (optionnal)
|
||||||
* \param dbt_select Field name for select if not rowid. (optionnal)
|
* \param dbt_select Field name for select if not rowid. (optionnal)
|
||||||
* \param dbt_tablename2 Secondary table name for compare keyfield. (optionnal)
|
|
||||||
*/
|
*/
|
||||||
function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
|
function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
|
||||||
{
|
{
|
||||||
@ -1529,7 +1533,7 @@ function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='',
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print $sql."<br>";
|
//print $sql."<br>";
|
||||||
if ($sql)
|
if ($sql)
|
||||||
{
|
{
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user