Work on import module
This commit is contained in:
parent
cfe31513f2
commit
a687f859d5
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2009 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
|
||||
@ -122,21 +123,21 @@ class Import
|
||||
// Icon
|
||||
$this->array_import_icon[$i]=(isset($module->export_icon[$r])?$module->export_icon[$r]:$module->picto);
|
||||
// Code du dataset export
|
||||
$this->array_import_code[$i]=$module->export_code[$r];
|
||||
$this->array_import_code[$i]=$module->import_code[$r];
|
||||
// Libelle du dataset export
|
||||
$this->array_import_label[$i]=$module->getDatasetLabel($r);
|
||||
// Tableau des champ a exporter (cle=champ, valeur=libelle)
|
||||
$this->array_import_fields[$i]=$module->export_fields_array[$r];
|
||||
$this->array_import_fields[$i]=$module->import_fields_array[$r];
|
||||
// Tableau des entites a exporter (cle=champ, valeur=entite)
|
||||
$this->array_import_entities[$i]=$module->export_entities_array[$r];
|
||||
$this->array_import_entities[$i]=$module->import_entities_array[$r];
|
||||
// Tableau des alias a exporter (cle=champ, valeur=alias)
|
||||
$this->array_import_alias[$i]=$module->export_alias_array[$r];
|
||||
$this->array_import_alias[$i]=$module->import_alias_array[$r];
|
||||
// Tableau des operations speciales sur champ
|
||||
$this->array_import_special[$i]=$module->export_special_array[$r];
|
||||
$this->array_import_special[$i]=$module->import_special_array[$r];
|
||||
|
||||
// Requete sql du dataset
|
||||
$this->array_import_sql_start[$i]=$module->export_sql_start[$r];
|
||||
$this->array_import_sql_end[$i]=$module->export_sql_end[$r];
|
||||
$this->array_import_sql_start[$i]=$module->import_sql_start[$r];
|
||||
$this->array_import_sql_end[$i]=$module->import_sql_end[$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]));
|
||||
|
||||
@ -383,8 +383,8 @@ if ($step == 2 && $datatoimport)
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td width="16">'.img_picto_common($key,$objmodelimport->getPicto($key)).'</td>';
|
||||
print '<td colspan="5">'.$objmodelimport->getDriverLabel($key).'</td>';
|
||||
print '<td width="16">'.img_picto_common($key,$objmodelimport->getPicto($key)).'</td>';
|
||||
print '<td colspan="5">'.$objmodelimport->getDriverLabel($key).'</td>';
|
||||
//print '<td>'.$objmodelimport->getLibLabel($key).'</td><td>'.$objmodelimport->getLibVersion($key).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
@ -427,20 +427,20 @@ if ($step == 2 && $datatoimport)
|
||||
$handle=@opendir($dir);
|
||||
if ($handle)
|
||||
{
|
||||
//print '<tr><td colspan="4">';
|
||||
//print '<tr><td colspan="4">';
|
||||
//print '<table class="noborder" width="100%">';
|
||||
|
||||
// Search available files to import
|
||||
$i=0;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (eregi('^\.',$file)) continue;
|
||||
$i=0;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (eregi('^\.',$file)) continue;
|
||||
|
||||
$modulepart='import';
|
||||
$urlsource=$_SERVER["PHP_SELF"].'?step='.$step.'&datatoimport='.$datatoimport;
|
||||
$relativepath=$file;
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
$modulepart='import';
|
||||
$urlsource=$_SERVER["PHP_SELF"].'?step='.$step.'&datatoimport='.$datatoimport;
|
||||
$relativepath=$file;
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td width="16">'.img_mime($file).'</td>';
|
||||
print '<td>'.$file.'</td>';
|
||||
// Affiche taille fichier
|
||||
@ -456,8 +456,8 @@ if ($step == 2 && $datatoimport)
|
||||
print '<a href="'.DOL_URL_ROOT.'/imports/import.php?step=3&datatoimport='.$datatoimport.'&filetoimport='.urlencode($relativepath).'">'.img_picto($langs->trans("NewImport"),'filenew').'</a>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
//print '</table></td></tr>';
|
||||
}
|
||||
//print '</table></td></tr>';
|
||||
}
|
||||
|
||||
print '</table></form>';
|
||||
@ -518,98 +518,91 @@ if ($step == 3 && $datatoimport)
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Load source fields
|
||||
$fieldssource=array(
|
||||
1=>array('name'=>'aa','example1'=>'val1','example2'=>'val2'),
|
||||
2=>array('name'=>'bb','example1'=>'valb1','example2'=>'valb2')
|
||||
);
|
||||
|
||||
// Load targets fileds in database
|
||||
$fieldstarget=$objimport->array_import_fields[0];
|
||||
|
||||
$maxpos=max(sizeof($fieldssource),sizeof($fieldstarget));
|
||||
|
||||
|
||||
print $langs->trans("SelectImportFields");
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<table class="nobordernopadding" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("FieldsTitle").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td>'.$langs->trans("Entities").'</td>';
|
||||
print '<td>'.$langs->trans("ImportedFields").'</td>';
|
||||
print '<td align="right" colspan="2">'.$langs->trans("Position").'</td>';
|
||||
print '<td>'.$langs->trans("FieldsInSourceFile").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td>'.$langs->trans("FieldsInTargetDatabase").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr valign="top"><td width="48%">';
|
||||
|
||||
// Champs importables
|
||||
$fieldsarray=$objimport->array_import_fields[0];
|
||||
|
||||
# $this->array_import_module[0]=$module;
|
||||
# $this->array_import_code[0]=$module->import_code[$r];
|
||||
# $this->array_import_label[0]=$module->import_label[$r];
|
||||
# $this->array_import_sql[0]=$module->import_sql[$r];
|
||||
# $this->array_import_fields[0]=$module->import_fields_array[$r];
|
||||
# $this->array_import_entities[0]=$module->import_fields_entities[$r];
|
||||
# $this->array_import_alias[0]=$module->import_fields_alias[$r];
|
||||
|
||||
// List of source fields
|
||||
print '<table width="100%" class="noborder">';
|
||||
$pos=1;
|
||||
$var=true;
|
||||
$i = 0;
|
||||
|
||||
foreach($fieldsarray as $code=>$label)
|
||||
while($pos <= $maxpos)
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
$i++;
|
||||
|
||||
$entity=$objimport->array_import_entities[0][$code];
|
||||
$entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity;
|
||||
$entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity;
|
||||
|
||||
print '<td nowrap="nowrap">'.img_object('',$entityicon).' '.$langs->trans($entitylang).'</td>';
|
||||
if ((isset($array_selected[$code]) && $array_selected[$code]) || $modelchoice == 1)
|
||||
{
|
||||
// Selected fields
|
||||
print '<td> </td>';
|
||||
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?step=2&datatoimport='.$datatoimport.'&action=unselectfield&field='.$code.'">'.img_left().'</a></td>';
|
||||
print '<td>'.$langs->trans($label).' ('.$code.')</td>';
|
||||
$bit=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fields not selected
|
||||
print '<td>'.$langs->trans($label).' ('.$code.')</td>';
|
||||
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?step=2&datatoimport='.$datatoimport.'&action=selectfield&field='.$code.'">'.img_right().'</a></td>';
|
||||
print '<td> </td>';
|
||||
$bit=0;
|
||||
}
|
||||
|
||||
print '</tr>';
|
||||
$save_select.=$bit;
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].' height="20">';
|
||||
print '<td>';
|
||||
if (! empty($fieldssource[$pos]['name'])) print $fieldssource[$pos]['name'].' ('.$fieldssource[$pos]['example1'].')';
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$pos++;
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '</td><td width="4%">';
|
||||
// Arrows
|
||||
print '<table width="100%" class="noborder">';
|
||||
$pos=1;
|
||||
$var=true;
|
||||
foreach($array_selected as $code=>$value)
|
||||
while ($pos <= $maxpos)
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<tr ".$bc[$var].' height="20">';
|
||||
print '<td align="center"> ';
|
||||
if ($pos <= sizeof($fieldssource)) print img_right();
|
||||
print ' </td>';
|
||||
print '</tr>';
|
||||
$pos++;
|
||||
}
|
||||
print '</table>';
|
||||
print '</td><td width="48%">';
|
||||
|
||||
$i = 0;
|
||||
$var=true;
|
||||
print '<table width="100%" class="noborder">';
|
||||
foreach($fieldstarget as $code=>$label)
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].' height="20">';
|
||||
|
||||
$i++;
|
||||
|
||||
$entity=$objimport->array_import_entities[0][$code];
|
||||
$entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity;
|
||||
$entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity;
|
||||
|
||||
print '<td>'.img_object('',$entityicon).' '.$langs->trans($entitylang).'</td>';
|
||||
|
||||
print '<td>'.$langs->trans($objimport->array_import_fields[0][$code]).' ('.$code.')</td>';
|
||||
|
||||
print '<td align="right" width="100">';
|
||||
print $value.' ';
|
||||
print '</td><td align="center" width="20">';
|
||||
if ($value < sizeof($array_selected)) print '<a href="'.$_SERVER["PHP_SELF"].'?step=3&datatoimport='.$datatoimport.'&action=downfield&field='.$code.'">'.img_down().'</a>';
|
||||
if ($value > 1) print '<a href="'.$_SERVER["PHP_SELF"].'?step=3&datatoimport='.$datatoimport.'&action=upfield&field='.$code.'">'.img_up().'</a>';
|
||||
print '</td>';
|
||||
|
||||
print '<td> </td>';
|
||||
|
||||
print '<td>'.$langs->trans($objimport->array_import_fields[0][$code]).'</td>';
|
||||
print '<td nowrap="nowrap">'.img_object('',$entityicon).' '.$langs->trans($entitylang).'</td>';
|
||||
print '<td>'.$langs->trans($label).' ('.$code.')</td>';
|
||||
|
||||
print '</tr>';
|
||||
$save_select.=$bit;
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
@ -763,7 +756,7 @@ if ($step == 4 && $datatoimport)
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td width="16">'.img_picto_common($key,$objmodelimport->getPicto($key)).'</td>';
|
||||
print '<td width="16">'.img_picto_common($key,$objmodelimport->getPicto($key)).'</td>';
|
||||
print '<td>'.$objmodelimport->getDriverLabel($key).'</td><td>'.$objmodelimport->getLibLabel($key).'</td><td align="right">'.$objmodelimport->getLibVersion($key).'</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
@ -160,8 +160,8 @@ class modProduit extends DolibarrModules
|
||||
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||
$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_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_fields_array[$r]=array('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.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_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'produit as s';
|
||||
$this->import_sql_end[$r] .='';
|
||||
|
||||
@ -230,8 +230,8 @@ class modSociete extends DolibarrModules
|
||||
$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_fields_array[$r]=array('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.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] .='';
|
||||
|
||||
@ -56,4 +56,6 @@ TypeOfLineServiceOrProduct=Type of line (0=product, 1=service)
|
||||
FileWithDataToImport=File with data to import
|
||||
FileToImport=File to import
|
||||
FileMustHaveOneOfFollowingFormat=File to import must have one of following format
|
||||
ChooseFileToImport=Choose file to import...
|
||||
ChooseFileToImport=Choose file to import...
|
||||
FieldsInSourceFile=Fields in source file
|
||||
FieldsInTargetDatabase=Target fields in Dolibarr database
|
||||
|
||||
@ -56,4 +56,6 @@ TypeOfLineServiceOrProduct=Type de ligne (0=produit, 1=service)
|
||||
FileWithDataToImport=Fichier contenant les données à importer
|
||||
FileToImport=Fichier à importer
|
||||
FileMustHaveOneOfFollowingFormat=Le fichier à importer doit avoir un des formats suivants
|
||||
ChooseFileToImport=Choisissez le fichier à importer...
|
||||
ChooseFileToImport=Choisissez le fichier à importer...
|
||||
FieldsInSourceFile=Champs dans le fichier source
|
||||
FieldsInTargetDatabase=Champs cibles dans la base Dolibarr
|
||||
Loading…
Reference in New Issue
Block a user