Work on import module
This commit is contained in:
parent
4483a7e261
commit
53b6d89edd
@ -62,7 +62,7 @@ class Export
|
||||
/**
|
||||
* \brief Load an exportable dataset
|
||||
* \param user Object user making export
|
||||
* \param filter Code export pour charger un lot de donnees particulier
|
||||
* \param filter Load a particular dataset only
|
||||
*/
|
||||
function load_arrays($user,$filter='')
|
||||
{
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
|
||||
/* 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
|
||||
@ -18,576 +17,75 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/imports/emptyexamples.php
|
||||
* \file htdocs/imports/emptyexample.php
|
||||
* \ingroup import
|
||||
* \brief Show examples of import file
|
||||
* \brief Show example of import file
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require_once("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/html.formother.class.php");
|
||||
// This is to make Dolibarr working with Plesk
|
||||
set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
|
||||
|
||||
$datatoimport=isset($_GET["datatoimport"])? $_GET["datatoimport"] : (isset($_POST["datatoimport"])?$_POST["datatoimport"]:'');
|
||||
$format=isset($_GET["format"])? $_GET["format"] : (isset($_POST["format"])?$_POST["format"]:'');
|
||||
|
||||
require("../master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/imports/import.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/import/modules_import.php');
|
||||
|
||||
$langs->load("exports");
|
||||
// C'est un wrapper, donc header vierge
|
||||
function llxHeader() { print '<html><title>Export agenda cal</title><body>'; }
|
||||
function llxFooter() { print '</body></html>'; }
|
||||
|
||||
// Check exportkey
|
||||
if (empty($datatoimport))
|
||||
{
|
||||
$user->getrights();
|
||||
|
||||
llxHeader();
|
||||
print '<div class="error">Bad value for datatoimport.</div>';
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
if (! $user->societe_id == 0)
|
||||
accessforbidden();
|
||||
|
||||
$array_match_file_to_database=isset($_SESSION["dol_array_match_file_to_database"])?$_SESSION["dol_array_match_file_to_database"]:array();
|
||||
$datatoimport=isset($_GET["datatoimport"])? $_GET["datatoimport"] : (isset($_POST["datatoimport"])?$_POST["datatoimport"]:'');
|
||||
$action=isset($_GET["action"]) ? $_GET["action"] : (isset($_POST["action"])?$_POST["action"]:'');
|
||||
$step=isset($_GET["step"])? $_GET["step"] : (isset($_POST["step"])?$_POST["step"]:1);
|
||||
$import_name=isset($_POST["import_name"])? $_POST["import_name"] : '';
|
||||
$hexa=isset($_POST["hexa"])? $_POST["hexa"] : '';
|
||||
$importmodelid=isset($_POST["importmodelid"])? $_POST["importmodelid"] : '';
|
||||
$filename=$langs->trans("ExampleOfImportFile").'_'.$datatoimport.'.'.$format;
|
||||
|
||||
$objimport=new Import($db);
|
||||
$objimport->load_arrays($user,$datatoimport);
|
||||
|
||||
$objmodelimport=new ModeleImports();
|
||||
$html = new Form($db);
|
||||
$htmlother = new FormOther($db);
|
||||
$formfile = new FormFile($db);
|
||||
$sqlusedforimport='';
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$objmodelimport=new ModeleImports();
|
||||
|
||||
|
||||
// Load source fields in input file
|
||||
$fieldssource=array(
|
||||
1=>array('name'=>'aa','example1'=>'val1','example2'=>'val2'),
|
||||
2=>array('name'=>'bb','example1'=>'valb1','example2'=>'valb2')
|
||||
);
|
||||
|
||||
// Load targets fields in database
|
||||
$fieldstarget=$objimport->array_import_fields[0];
|
||||
|
||||
$maxpos=max(sizeof($fieldssource),sizeof($fieldstarget));
|
||||
|
||||
if (sizeof($array_match_file_to_database) == 0)
|
||||
{
|
||||
// This is first input in screen, we need to define the $array_match_file_to_database array
|
||||
$pos=1;
|
||||
while ($pos <= sizeof($fieldssource))
|
||||
{
|
||||
if (sizeof($fieldssource) > 1 && $pos <= sizeof($fieldssource))
|
||||
{
|
||||
$posbis=1;
|
||||
foreach($fieldstarget as $key => $val)
|
||||
{
|
||||
if ($posbis < $pos)
|
||||
{
|
||||
$posbis++;
|
||||
continue;
|
||||
}
|
||||
// We found the key of targets that is at position pos
|
||||
$array_match_file_to_database[$pos]=$key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$pos++;
|
||||
}
|
||||
// Save the match array in session. We now will use the array in session.
|
||||
$_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
|
||||
}
|
||||
|
||||
// Now $array_match_file_to_database contains fieldnb(1,2,3...)=>fielddatabase(key in $array_match_file_to_database)
|
||||
|
||||
|
||||
llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
|
||||
|
||||
$param='step=3&datatoimport='.$datatoimport.'&filetoimport='.urlencode($_GET["filetoimport"]);
|
||||
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=1';
|
||||
$head[$h][1] = $langs->trans("Step")." 1";
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=2&datatoimport='.$datatoimport;
|
||||
$head[$h][1] = $langs->trans("Step")." 2";
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?'.$param;
|
||||
$head[$h][1] = $langs->trans("Step")." 3";
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("NewImport"));
|
||||
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
// Module
|
||||
print '<tr><td width="25%">'.$langs->trans("Module").'</td>';
|
||||
print '<td>';
|
||||
//print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_module[0]->picto).' ';
|
||||
print $objimport->array_import_module[0]->getName();
|
||||
print '</td></tr>';
|
||||
|
||||
// Lot de donnees a importer
|
||||
print '<tr><td width="25%">'.$langs->trans("DatasetToImport").'</td>';
|
||||
print '<td>';
|
||||
print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_icon[0]).' ';
|
||||
print $objimport->array_import_label[0];
|
||||
print '</td></tr>';
|
||||
|
||||
// Nbre champs importes
|
||||
print '<tr><td width="25%">'.$langs->trans("FileToImport").'</td>';
|
||||
print '<td>'.$_GET["filetoimport"].'</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Combo list of import models
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="select_model">';
|
||||
print '<input type="hidden" name="step" value="3">';
|
||||
print '<input type="hidden" name="datatoimport" value="'.$datatoimport.'">';
|
||||
print '<table><tr><td colspan="2">';
|
||||
print $langs->trans("SelectImportFields",img_picto('','uparrow','')).' ';
|
||||
$htmlother->select_import_model($importmodelid,'importmodelid',$datatoimport,1);
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Select").'">';
|
||||
print '</td></tr></table>';
|
||||
print '</form>';
|
||||
|
||||
// Title of array with fields
|
||||
print '<table class="nobordernopadding" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("FieldsInSourceFile").'</td>';
|
||||
print '<td>'.$langs->trans("FieldsInTargetDatabase").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr valign="top"><td width="50%">';
|
||||
|
||||
//var_dump($array_match_file_to_database);
|
||||
$pos=1;
|
||||
|
||||
print "\n<!-- Box left container -->\n";
|
||||
print '<div id="left">'."\n";
|
||||
|
||||
// List of source fields
|
||||
// print '<table width="100%" class="noborder">';
|
||||
$var=true;
|
||||
while ($pos <= $maxpos)
|
||||
{
|
||||
$var=!$var;
|
||||
|
||||
// print "<tr ".$bc[$var].' height="20">';
|
||||
// print '<td>';
|
||||
// Get name of database field at position $pos into $namefield
|
||||
$namefield='';
|
||||
$posbis=1;
|
||||
foreach($fieldstarget as $key => $val)
|
||||
{
|
||||
if ($posbis < $pos)
|
||||
{
|
||||
$posbis++;
|
||||
continue;
|
||||
}
|
||||
// We found the key of targets that is at position pos
|
||||
$namefield=$key;
|
||||
break;
|
||||
}
|
||||
// Now we check if there is a file field linked to this $namefield database field
|
||||
$keyfound='';
|
||||
foreach($fieldssource as $key => $val)
|
||||
{
|
||||
if (! empty($array_match_file_to_database[$key]) && $array_match_file_to_database[$key] == $namefield)
|
||||
{
|
||||
// print $langs->trans("Field").' '.$key.': ';
|
||||
// print $fieldssource[$key]['name'].' ('.$fieldssource[$key]['example1'].')';
|
||||
$keyfound=$key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// print '</td>';
|
||||
|
||||
show_elem($fieldssource,$pos,$var,$keyfound);
|
||||
|
||||
// Arrows
|
||||
// print '<td align="center"> ';
|
||||
if (sizeof($fieldssource) > 1 && $pos <= sizeof($fieldssource))
|
||||
{
|
||||
// if ($pos < $maxpos) print '<a href="'.$_SERVER["PHP_SELF"].'?step=3&datatoimport='.$datatoimport.'&action=downfield&fieldpos='.$pos.'&field='.$fieldssource[$pos]['name'].'&filetoimport='.urlencode($_GET["filetoimport"]).'">'.img_down().'</a>';
|
||||
// if ($pos > 1) print '<a href="'.$_SERVER["PHP_SELF"].'?step=3&datatoimport='.$datatoimport.'&action=upfield&fieldpos='.$pos.'&field='.$fieldssource[$pos]['name'].'&filetoimport='.urlencode($_GET["filetoimport"]).'">'.img_up().'</a>';
|
||||
}
|
||||
// print ' </td>';
|
||||
|
||||
// print '<td>';
|
||||
// if (sizeof($fieldssource) > 1 && $pos <= sizeof($fieldssource)) print ' -> ';
|
||||
// print '</td>';
|
||||
|
||||
// print '</tr>';
|
||||
|
||||
$pos++;
|
||||
|
||||
if ($pos > sizeof($fieldstarget)) break;
|
||||
}
|
||||
|
||||
// print '</table>';
|
||||
|
||||
print "</div>\n";
|
||||
print "<!-- End box container -->\n";
|
||||
|
||||
|
||||
print '</td><td width="50%">';
|
||||
|
||||
// List of targets fields
|
||||
$i = 0;
|
||||
$var=true;
|
||||
print '<table width="100%" class="nobordernopadding">';
|
||||
foreach($fieldstarget as $code=>$label)
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr class="liste_total" height="20">';
|
||||
|
||||
$i++;
|
||||
|
||||
$entity=$objimport->array_import_entities[0][$code];
|
||||
$entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity;
|
||||
$entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity;
|
||||
|
||||
print '<td nowrap="nowrap" style="font-weight: normal">'.img_object('',$entityicon).' '.$langs->trans($entitylang).'</td>';
|
||||
print '<td style="font-weight: normal">'.$langs->trans($label).' ('.$code.')</td>';
|
||||
|
||||
print '</tr>';
|
||||
$save_select.=$bit;
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// List of not imported fields
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("NotImportedFields").'</td></tr>';
|
||||
|
||||
print '<tr valign="top"><td width="50%">';
|
||||
|
||||
print "\n<!-- Box forget container -->\n";
|
||||
print '<div id="right">'."\n";
|
||||
|
||||
// Print all input fields discarded
|
||||
show_elem('','',$var,'');
|
||||
|
||||
print "</div>\n";
|
||||
print "<!-- End box container -->\n";
|
||||
|
||||
print '</td>';
|
||||
print '<td width="50%">';
|
||||
// Print empty cells
|
||||
show_elem('','',$var,'none');
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
print "\n";
|
||||
print '<script type="text/javascript" language="javascript">'."\n";
|
||||
print 'function updateOrder(){'."\n";
|
||||
print 'var left_list = cleanSerialize(Sortable.serialize(\'left\'));'."\n";
|
||||
//print 'var right_list = cleanSerialize(Sortable.serialize(\'right\'));'."\n";
|
||||
print 'var boxorder = \'A:\' + left_list;'."\n";
|
||||
//print 'var boxorder = \'A:\' + left_list + \'-B:\' + right_list;'."\n";
|
||||
//alert( \'boxorder=\' + boxorder )."\n";
|
||||
print 'var userid = \''.$user->id.'\';'."\n";
|
||||
print 'var url = "ajaximport.php";'."\n";
|
||||
print 'var datatoimport = "'.$datatoimport.'";'."\n";
|
||||
print 'o_options = new Object();'."\n";
|
||||
print 'o_options = {asynchronous:true,method: \'get\',parameters: \'step=3&boxorder=\' + boxorder + \'&userid=\' + userid + \'&datatoimport=\' + datatoimport};'."\n";
|
||||
print 'var myAjax = new Ajax.Request(url, o_options);'."\n";
|
||||
//print 'document.
|
||||
print '}'."\n";
|
||||
print "\n";
|
||||
|
||||
print '// <![CDATA['."\n";
|
||||
|
||||
print 'Sortable.create(\'left\', {'."\n";
|
||||
print 'tag:\'div\', '."\n";
|
||||
print 'containment:["left","right"], '."\n";
|
||||
print 'constraint:false, '."\n";
|
||||
print "handle: 'boxhandle',"."\n";
|
||||
print 'onUpdate:updateOrder';
|
||||
print "});\n";
|
||||
|
||||
print 'Sortable.create(\'right\', {'."\n";
|
||||
print 'tag:\'div\', '."\n";
|
||||
print 'containment:["right","left"], '."\n";
|
||||
print 'constraint:false, '."\n";
|
||||
print "handle: 'boxhandle',"."\n";
|
||||
print 'onUpdate:updateOrder';
|
||||
print "});\n";
|
||||
|
||||
print '// ]]>'."\n";
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
|
||||
if ($mesg) print $mesg;
|
||||
|
||||
/*
|
||||
* Barre d'action
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (sizeof($array_match_file_to_database))
|
||||
{
|
||||
print '<a class="butAction" href="import.php?step=4&datatoimport='.$datatoimport.'">'.$langs->trans("NextStep").'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
// Area for profils import
|
||||
if (sizeof($array_match_file_to_database))
|
||||
{
|
||||
print '<br>';
|
||||
print $langs->trans("SaveImportModel");
|
||||
|
||||
print '<form class="nocellnopadd" action="import.php" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add_import_model">';
|
||||
print '<input type="hidden" name="step" value="'.$step.'">';
|
||||
print '<input type="hidden" name="datatoimport" value="'.$datatoimport.'">';
|
||||
print '<input type="hidden" name="hexa" value="'.$hexa.'">';
|
||||
|
||||
print '<table summary="selectofimportprofil" class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("ImportModelName").'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
$var=false;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><input name="import_name" size="32" value=""></td><td align="right">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// List of existing import profils
|
||||
$sql = "SELECT rowid, label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."import_model";
|
||||
$sql.= " WHERE type = '".$datatoimport."'";
|
||||
$sql.= " ORDER BY rowid";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$var=false;
|
||||
while ($i < $num)
|
||||
{
|
||||
$var=!$var;
|
||||
$obj = $db->fetch_object($resql);
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print $obj->label;
|
||||
print '</td><td align="right">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?step='.$step.'&datatoimport='.$datatoimport.'&action=deleteprof&id='.$obj->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($step == 4 && $datatoimport)
|
||||
// Load arrays from descriptor module
|
||||
$entity=$objimport->array_import_entities[0][$code];
|
||||
$entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity;
|
||||
$entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity;
|
||||
$fieldstarget=$objimport->array_import_fields[0];
|
||||
$valuestarget=$objimport->array_import_examplevalues[0];
|
||||
|
||||
$attachment = true;
|
||||
if (isset($_GET["attachment"])) $attachment=$_GET["attachment"];
|
||||
//$attachment = false;
|
||||
$contenttype=dol_mimetype($format);
|
||||
if (isset($_GET["contenttype"])) $contenttype=$_GET["contenttype"];
|
||||
//$contenttype='text/plain';
|
||||
$outputencoding='UTF-8';
|
||||
//$contenttype='ISO-8859-1';
|
||||
|
||||
if ($contenttype) header('Content-Type: '.$contenttype.($outputencoding?'; charset='.$outputencoding:''));
|
||||
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
|
||||
|
||||
// List of targets fields
|
||||
$headerlinefields=array();
|
||||
$contentlinevalues=array();
|
||||
$i = 0;
|
||||
foreach($fieldstarget as $code=>$label)
|
||||
{
|
||||
asort($array_match_file_to_database);
|
||||
|
||||
llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=1';
|
||||
$head[$h][1] = $langs->trans("Step")." 1";
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=2&datatoimport='.$datatoimport;
|
||||
$head[$h][1] = $langs->trans("Step")." 2";
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=3&datatoimport='.$datatoimport;
|
||||
$head[$h][1] = $langs->trans("Step")." 3";
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=4&datatoimport='.$datatoimport;
|
||||
$head[$h][1] = $langs->trans("Step")." 4";
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("NewImport"));
|
||||
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
// Module
|
||||
print '<tr><td width="25%">'.$langs->trans("Module").'</td>';
|
||||
print '<td>';
|
||||
//print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_module[0]->picto).' ';
|
||||
print $objimport->array_import_module[0]->getName();
|
||||
print '</td></tr>';
|
||||
|
||||
// Lot de donnees a importer
|
||||
print '<tr><td width="25%">'.$langs->trans("DatasetToImport").'</td>';
|
||||
print '<td>';
|
||||
print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_icon[0]).' ';
|
||||
print $objimport->array_import_label[0];
|
||||
print '</td></tr>';
|
||||
|
||||
// Nbre champs importes
|
||||
print '<tr><td width="25%">'.$langs->trans("ImportedFields").'</td>';
|
||||
$list='';
|
||||
foreach($array_match_file_to_database as $code=>$label)
|
||||
{
|
||||
$list.=($list?',':'');
|
||||
$list.=$langs->trans($objimport->array_import_fields[0][$code]);
|
||||
}
|
||||
print '<td>'.$list.'</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
print $langs->trans("NowClickToGenerateToBuildImportFile").'<br>';
|
||||
|
||||
// Liste des formats d'imports disponibles
|
||||
$var=true;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="2">'.$langs->trans("AvailableFormats").'</td>';
|
||||
print '<td>'.$langs->trans("LibraryUsed").'</td>';
|
||||
print '<td alig="right">'.$langs->trans("LibraryVersion").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$liste=$objmodelimport->liste_modeles($db);
|
||||
foreach($liste as $key)
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
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>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<table width="100%">';
|
||||
if ($mesg)
|
||||
{
|
||||
print '<tr><td colspan="2">';
|
||||
print $mesg;
|
||||
print '</td></tr>';
|
||||
}
|
||||
if ($sqlusedforimport && $user->admin)
|
||||
{
|
||||
print '<tr><td>';
|
||||
print info_admin($langs->trans("SQLUsedForImport").':<br> '.$sqlusedforimport);
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
print '<table width="100%"><tr><td width="50%">';
|
||||
|
||||
if (! is_dir($conf->import->dir_temp)) create_exdir($conf->import->dir_temp);
|
||||
|
||||
// Affiche liste des documents
|
||||
// NB: La fonction show_documents rescanne les modules qd genallowed=1
|
||||
$formfile->show_documents('import','',$conf->import->dir_temp.'/'.$user->id,$_SERVER["PHP_SELF"].'?step=4&datatoimport='.$datatoimport,$liste,1,(! empty($_POST['model'])?$_POST['model']:'csv'),'',1);
|
||||
|
||||
print '</td><td width="50%"> </td></tr>';
|
||||
print '</table>';
|
||||
|
||||
// If external library PHPEXCELREADER is available
|
||||
// and defined by PHPEXCELREADER constant.
|
||||
if (file_exists(PHPEXCELREADER.'excelreader.php'))
|
||||
{
|
||||
// Test d'affichage du tableau excel et csv
|
||||
//print '<table width="100%"><tr><td>';
|
||||
//require_once(DOL_DOCUMENT_ROOT.'/lib/viewfiles.lib.php');
|
||||
//viewExcelFileContent($conf->import->dir_temp.'/1/import_member_1.xls',5,3);
|
||||
//viewCsvFileContent($conf->import->dir_temp.'/1/import_member_1.csv',5);
|
||||
//print '</td></tr></table>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
|
||||
|
||||
/*
|
||||
* Function to put the movable box of a source field
|
||||
*/
|
||||
function show_elem($fieldssource,$pos,$var,$key)
|
||||
{
|
||||
global $langs,$bc;
|
||||
|
||||
print "\n\n<!-- Box start -->\n";
|
||||
print '<div style="padding: 0px 0px 0px 0px;" id="boxto_'.$pos.'">'."\n";
|
||||
|
||||
print '<table summary="boxtable'.$pos.'" width="100%" class="nobordernopadding">'."\n";
|
||||
print '<tr class="liste_total" height="20">';
|
||||
if (empty($key))
|
||||
{
|
||||
print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
|
||||
print img_picto($langs->trans("MoveBox",$pos),'uparrow','class="boxhandle" style="cursor:move;"');
|
||||
print '</td>';
|
||||
print '<td style="font-weight: normal">';
|
||||
print $langs->trans("NoFields");
|
||||
print '</td>';
|
||||
}
|
||||
elseif ($key == 'none')
|
||||
{
|
||||
print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
print '<td style="font-weight: normal">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
//print '<td width="16">'.img_file('','').'</td>';
|
||||
print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
|
||||
// The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object
|
||||
print img_picto($langs->trans("MoveBox",$pos),'uparrow','class="boxhandle" style="cursor:move;"');
|
||||
print '</td>';
|
||||
print '<td style="font-weight: normal">';
|
||||
print $langs->trans("Field").' '.$key.': ';
|
||||
print '<b>'.$fieldssource[$key]['name'].'</b> ('.$fieldssource[$key]['example1'].')';
|
||||
print '</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
print "</div>\n";
|
||||
print "<!-- Box end -->\n\n";
|
||||
$headerlinefields[]=$fieldstarget[$code].' ('.$code.')';
|
||||
$contentlinevalues[]=$valuestarget[$code];
|
||||
}
|
||||
//var_dump($headerlinefields);
|
||||
//var_dump($contentlinevalues);
|
||||
|
||||
print $objimport->build_example_file($user,$format,$headerlinefields,$contentlinevalues);
|
||||
|
||||
?>
|
||||
|
||||
@ -40,16 +40,16 @@ class Import
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Load an importable dataset
|
||||
* \param user Object user making export
|
||||
* \param filter Code export pour charger un lot de donnees particulier
|
||||
*/
|
||||
function load_arrays($user,$filter='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
/**
|
||||
* \brief Load description of an importable dataset
|
||||
* \param user Object user making import
|
||||
* \param filter Load a particular dataset only
|
||||
*/
|
||||
function load_arrays($user,$filter='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
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";
|
||||
foreach($conf->file->dol_document_root as $dirroot)
|
||||
@ -60,199 +60,138 @@ class Import
|
||||
$handle=@opendir($dir);
|
||||
if ($handle)
|
||||
{
|
||||
// Recherche des exports disponibles
|
||||
$var=True;
|
||||
$i=0;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (eregi("^(mod.*)\.class\.php",$file,$reg))
|
||||
{
|
||||
$modulename=$reg[1];
|
||||
// Recherche des exports disponibles
|
||||
$var=True;
|
||||
$i=0;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (eregi("^(mod.*)\.class\.php",$file,$reg))
|
||||
{
|
||||
$modulename=$reg[1];
|
||||
|
||||
// Defined if module is enabled
|
||||
$enabled=true;
|
||||
$part=strtolower(eregi_replace('^mod','',$modulename));
|
||||
// Defined if module is enabled
|
||||
$enabled=true;
|
||||
$part=strtolower(eregi_replace('^mod','',$modulename));
|
||||
if (empty($conf->$part->enabled)) $enabled=false;
|
||||
|
||||
if ($enabled)
|
||||
{
|
||||
{
|
||||
// Chargement de la classe
|
||||
$file = $dir."/".$modulename.".class.php";
|
||||
$classname = $modulename;
|
||||
require_once($file);
|
||||
$module = new $classname($this->db);
|
||||
$file = $dir."/".$modulename.".class.php";
|
||||
$classname = $modulename;
|
||||
require_once($file);
|
||||
$module = new $classname($this->db);
|
||||
|
||||
if (is_array($module->import_code))
|
||||
{
|
||||
foreach($module->import_code as $r => $value)
|
||||
{
|
||||
if ($filter && ($filter != $module->import_code[$r])) continue;
|
||||
if (is_array($module->import_code))
|
||||
{
|
||||
foreach($module->import_code as $r => $value)
|
||||
{
|
||||
if ($filter && ($filter != $module->import_code[$r])) continue;
|
||||
|
||||
// Test if permissions are ok
|
||||
/*$perm=$module->import_permission[$r][0];
|
||||
//print_r("$perm[0]-$perm[1]-$perm[2]<br>");
|
||||
if ($perm[2])
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1]->$perm[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1];
|
||||
}
|
||||
if ($perm[0]=='user' && $user->admin) $bool=true;
|
||||
//print $bool." $perm[0]"."<br>";
|
||||
// Test if permissions are ok
|
||||
/*$perm=$module->import_permission[$r][0];
|
||||
//print_r("$perm[0]-$perm[1]-$perm[2]<br>");
|
||||
if ($perm[2])
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1]->$perm[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1];
|
||||
}
|
||||
if ($perm[0]=='user' && $user->admin) $bool=true;
|
||||
//print $bool." $perm[0]"."<br>";
|
||||
*/
|
||||
|
||||
// Permissions ok
|
||||
// if ($bool)
|
||||
// {
|
||||
// Charge fichier lang en rapport
|
||||
$langtoload=$module->getLangFilesArray();
|
||||
if (is_array($langtoload))
|
||||
{
|
||||
foreach($langtoload as $key)
|
||||
{
|
||||
$langs->load($key);
|
||||
}
|
||||
}
|
||||
// Permissions ok
|
||||
// if ($bool)
|
||||
// {
|
||||
// Charge fichier lang en rapport
|
||||
$langtoload=$module->getLangFilesArray();
|
||||
if (is_array($langtoload))
|
||||
{
|
||||
foreach($langtoload as $key)
|
||||
{
|
||||
$langs->load($key);
|
||||
}
|
||||
}
|
||||
|
||||
// Module
|
||||
$this->array_import_module[$i]=$module;
|
||||
// Permission
|
||||
$this->array_import_perms[$i]=$user->admin;
|
||||
// Icon
|
||||
$this->array_import_icon[$i]=(isset($module->import_icon[$r])?$module->import_icon[$r]:$module->picto);
|
||||
// Code du dataset export
|
||||
$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->import_fields_array[$r];
|
||||
// Tableau des entites a exporter (cle=champ, valeur=entite)
|
||||
$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->import_alias_array[$r];
|
||||
// Tableau des operations speciales sur champ
|
||||
$this->array_import_special[$i]=$module->import_special_array[$r];
|
||||
// Module
|
||||
$this->array_import_module[$i]=$module;
|
||||
// Permission
|
||||
$this->array_import_perms[$i]=$user->admin;
|
||||
// Icon
|
||||
$this->array_import_icon[$i]=(isset($module->import_icon[$r])?$module->import_icon[$r]:$module->picto);
|
||||
// Code du dataset export
|
||||
$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->import_fields_array[$r];
|
||||
// Tableau des entites a exporter (cle=champ, valeur=entite)
|
||||
$this->array_import_entities[$i]=$module->import_entities_array[$r];
|
||||
// Tableau des alias a exporter (cle=champ, valeur=alias)
|
||||
$this->array_import_examplevalues[$i]=$module->import_examplevalues_array[$r];
|
||||
// Requete sql du dataset
|
||||
$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->import_sql[$r];
|
||||
|
||||
// Requete sql du dataset
|
||||
$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->import_sql[$r];
|
||||
|
||||
dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->import_code[$r].", nb of fields=".sizeof($module->import_fields_code[$r]));
|
||||
$i++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->import_code[$r].", nb of fields=".sizeof($module->import_fields_code[$r]));
|
||||
$i++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* \brief Importe un fichier clients
|
||||
/**
|
||||
* \brief Lance la generation du fichier example
|
||||
* \param user User qui exporte
|
||||
* \param model Modele d'export
|
||||
* \param $headerlinefields Array of values for first line of example file
|
||||
* \param $contentlinevalues Array of values for content line of example file
|
||||
* \remarks Les tableaux array_export_xxx sont deja chargees pour le bon datatoexport
|
||||
* aussi le parametre datatoexport est inutilise
|
||||
*/
|
||||
function ImportClients($file)
|
||||
function build_example_file($user, $model, $headerlinefields, $contentlinevalues)
|
||||
{
|
||||
$this->nb_import_ok = 0;
|
||||
$this->nb_import_ko = 0;
|
||||
$this->nb_import = 0;
|
||||
global $conf,$langs;
|
||||
|
||||
dol_syslog("Import::ImportClients($file)", LOG_DEBUG);
|
||||
$indice=0;
|
||||
|
||||
$this->ReadFile($file);
|
||||
dol_syslog("Import::build_example_file ".$model);
|
||||
|
||||
foreach ($this->lines as $this->line)
|
||||
{
|
||||
$societe = new Societe($this->db);
|
||||
// Creation de la classe d'import du model Import_XXX
|
||||
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/import/";
|
||||
$file = "import_".$model.".modules.php";
|
||||
$classname = "Import".$model;
|
||||
require_once($dir.$file);
|
||||
$objmodel = new $classname($this->db);
|
||||
|
||||
$this->SetInfosTiers($societe);
|
||||
$outputlangs=$langs; // Lang for output
|
||||
$s='';
|
||||
|
||||
$societe->client = 1;
|
||||
$societe->tva_assuj = $this->line[12];
|
||||
$societe->code_client = $this->line[13];
|
||||
$societe->tva_intra = $this->line[14];
|
||||
// Genere en-tete
|
||||
$s.=$objmodel->write_header_example($outputlangs);
|
||||
|
||||
$this->nb_import++;
|
||||
// Genere ligne de titre
|
||||
$s.=$objmodel->write_title_example($outputlangs,$headerlinefields);
|
||||
|
||||
if ( $societe->create($user) == 0)
|
||||
{
|
||||
dol_syslog("Import::ImportClients ".$societe->nom." SUCCESS", LOG_DEBUG);
|
||||
$this->nb_import_ok++;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Import::ImportClients ".$societe->nom." ERROR", LOG_ERR);
|
||||
$this->nb_import_ko++;
|
||||
}
|
||||
}
|
||||
// Genere ligne de titre
|
||||
$s.=$objmodel->write_record_example($outputlangs,$contentlinevalues);
|
||||
|
||||
// Genere pied de page
|
||||
$s.=$objmodel->write_footer_example($outputlangs);
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
function SetInfosTiers(&$obj)
|
||||
{
|
||||
$obj->nom = $this->line[0];
|
||||
$obj->adresse = $this->line[1];
|
||||
|
||||
if (strlen(trim($this->line[2])) > 0)
|
||||
$obj->adresse .= "\n". trim($this->line[2]);
|
||||
|
||||
if (strlen(trim($this->line[3])) > 0)
|
||||
$obj->adresse .= "\n". trim($this->line[3]);
|
||||
|
||||
$obj->cp = $this->line[4];
|
||||
$obj->ville = $this->line[5];
|
||||
$obj->tel = $this->line[6];
|
||||
$obj->fax = $this->line[7];
|
||||
$obj->email = $this->line[8];
|
||||
$obj->url = $this->line[9];
|
||||
$obj->siren = $this->line[10];
|
||||
$obj->siret = $this->line[11];
|
||||
}
|
||||
|
||||
|
||||
function ReadFile($file)
|
||||
{
|
||||
$this->errno = 0;
|
||||
|
||||
if (is_readable($file))
|
||||
{
|
||||
dol_syslog("Import::ReadFile Lecture du fichier $file", LOG_DEBUG);
|
||||
|
||||
$line = 0;
|
||||
$hf = fopen ($file, "r");
|
||||
$line = 0;
|
||||
$i=0;
|
||||
|
||||
$this->lines = array();
|
||||
|
||||
|
||||
while (!feof($hf) )
|
||||
{
|
||||
$cont = fgets($hf, 1024);
|
||||
|
||||
if (strlen(trim($cont)) > 0)
|
||||
{
|
||||
$this->lines[$i] = explode(";", $cont);
|
||||
}
|
||||
$i++;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errno = -2;
|
||||
}
|
||||
|
||||
return $errno;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -199,8 +199,6 @@ if ($step == 3 && $action == 'select_model')
|
||||
* Affichage Pages des Etapes
|
||||
*/
|
||||
|
||||
$objmodelimport=new ModeleImports();
|
||||
|
||||
|
||||
if ($step == 1 || ! $datatoimport)
|
||||
{
|
||||
@ -338,7 +336,7 @@ if ($step == 2 && $datatoimport)
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td width="16">'.img_picto_common($key,$objmodelimport->getPicto($key)).'</td>';
|
||||
print '<td>'.$objmodelimport->getDriverLabel($key).'</td>';
|
||||
print '<td colspan="4" align="right"><a href="'.DOL_URL_ROOT.'/imports/emptyexample.php" target="_blank">'.$langs->trans("DownloadEmptyExample").'</a></td>';
|
||||
print '<td colspan="4" align="right"><a href="'.DOL_URL_ROOT.'/imports/emptyexample.php?format='.$key.'&datatoimport='.$datatoimport.'" target="_blank">'.$langs->trans("DownloadEmptyExample").'</a></td>';
|
||||
//print '<td>'.$objmodelimport->getLibLabel($key).'</td><td>'.$objmodelimport->getLibVersion($key).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
@ -432,6 +430,7 @@ if ($step == 3 && $datatoimport)
|
||||
2=>array('name'=>'bb','example1'=>'valb1','example2'=>'valb2')
|
||||
);
|
||||
|
||||
|
||||
// Load targets fields in database
|
||||
$fieldstarget=$objimport->array_import_fields[0];
|
||||
|
||||
@ -512,7 +511,7 @@ if ($step == 3 && $datatoimport)
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Combo list of import models
|
||||
// List of import models
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="select_model">';
|
||||
@ -919,7 +918,7 @@ function show_elem($fieldssource,$pos,$var,$key)
|
||||
if (empty($key))
|
||||
{
|
||||
print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
|
||||
print img_picto($langs->trans("MoveBox",$pos),'uparrow','class="boxhandle" style="cursor:move;"');
|
||||
print img_picto(($pos>0?$langs->trans("MoveField",$pos):''),'uparrow','class="boxhandle" style="cursor:move;"');
|
||||
print '</td>';
|
||||
print '<td style="font-weight: normal">';
|
||||
print $langs->trans("NoFields");
|
||||
@ -939,7 +938,7 @@ function show_elem($fieldssource,$pos,$var,$key)
|
||||
//print '<td width="16">'.img_file('','').'</td>';
|
||||
print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
|
||||
// The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object
|
||||
print img_picto($langs->trans("MoveBox",$pos),'uparrow','class="boxhandle" style="cursor:move;"');
|
||||
print img_picto($langs->trans("MoveField",$pos),'uparrow','class="boxhandle" style="cursor:move;"');
|
||||
print '</td>';
|
||||
print '<td style="font-weight: normal">';
|
||||
print $langs->trans("Field").' '.$key.': ';
|
||||
|
||||
@ -68,7 +68,7 @@ class ImportCsv extends ModeleImports
|
||||
$this->version_lib=DOL_VERSION;
|
||||
|
||||
$this->separator=',';
|
||||
if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
|
||||
if (! empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->IMPORT_CSV_SEPARATOR_TO_USE;
|
||||
}
|
||||
|
||||
function getDriverId()
|
||||
@ -102,6 +102,48 @@ class ImportCsv extends ModeleImports
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Output header of an example file for this format
|
||||
* \param langs Output language
|
||||
*/
|
||||
function write_header_example($outputlangs)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Output title line of an example file for this format
|
||||
* \param langs Output language
|
||||
*/
|
||||
function write_title_example($outputlangs,$headerlinefields)
|
||||
{
|
||||
$s='';
|
||||
$s.=join($this->separator,$headerlinefields);
|
||||
return $s."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Output record of an example file for this format
|
||||
* \param langs Output language
|
||||
*/
|
||||
function write_record_example($outputlangs,$contentlinevalues)
|
||||
{
|
||||
$s='';
|
||||
$s.=join($this->separator,$contentlinevalues);
|
||||
return $s."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Output footer of an example file for this format
|
||||
* \param langs Output language
|
||||
*/
|
||||
function write_footer_example($outputlangs)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Open output file
|
||||
* \param file Path of filename
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -24,7 +24,6 @@
|
||||
* \brief File of parent class for import file readers
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT.'/lib/functions.lib.php');
|
||||
|
||||
|
||||
|
||||
@ -155,6 +155,7 @@ class modProduit extends DolibarrModules
|
||||
//$this->import_permission[$r]=array(array("societe","import"));
|
||||
$this->import_fields_array[$r]=array('p.ref'=>"Ref",'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.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_examplevalues_array[$r]=array('p.ref'=>"PR123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.envente'=>"0 or 1",'p.duration'=>"1y");
|
||||
|
||||
$this->import_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'produit as s';
|
||||
$this->import_sql_end[$r] ='';
|
||||
|
||||
@ -191,6 +191,7 @@ class modSociete extends DolibarrModules
|
||||
$r++;
|
||||
$this->export_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->export_label[$r]='ExportDataset_company_1';
|
||||
$this->export_icon[$r]='company';
|
||||
$this->export_permission[$r]=array(array("societe","export"));
|
||||
$this->export_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->export_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');
|
||||
@ -229,9 +230,11 @@ class modSociete extends DolibarrModules
|
||||
$r++;
|
||||
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->import_label[$r]='ImportDataset_company_1';
|
||||
$this->import_icon[$r]='company';
|
||||
//$this->import_permission[$r]=array(array("societe","export"));
|
||||
$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_fields_array[$r]=array('s.nom'=>"Name",'s.prefix_comm'=>"Prefix",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'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",'s.fk_type'=>"ThirdPartyType",'s.fk_effectif'=>"Effectif","s.fk_status"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.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.code_client'=>"company",'s.code_fournisseur'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"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",'s.fk_type'=>"company",'s.fk_effectif'=>"company","s.fk_status"=>"company",'s.fk_prospectlevel'=>'company','s.fk_stcomm'=>'company');
|
||||
$this->import_examplevalues_array[$r]=array('s.nom'=>"A company",'s.prefix_comm'=>"comp",'s.client'=>'0 or 1','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(mktime(),'YYYY-MM-DD'),'s.code_client'=>"CU01-0001",'s.code_fournisseur'=>"SU01-0001",'s.address'=>"61 jump street",'s.cp'=>"123456",'s.ville'=>"Big town",'p.code'=>"US",'s.tel'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note'=>"This is an example of note for record",'s.fk_type'=>"XXX",'s.fk_effectif'=>"YYY","s.fk_status"=>"ZZZ",'s.fk_prospectlevel'=>'AAA','s.fk_stcomm'=>'BBB');
|
||||
|
||||
$this->import_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'societe as s';
|
||||
$this->import_sql_end[$r] ='';
|
||||
|
||||
@ -62,4 +62,5 @@ DownloadEmptyExample=Download example of empty source file
|
||||
ChooseFileToImport=Upload file then click on picto %s to select file as source import file...
|
||||
FieldsInSourceFile=Fields in source file
|
||||
FieldsInTargetDatabase=Target fields in Dolibarr database
|
||||
NoFields=No fields
|
||||
NoFields=No fields
|
||||
MoveField=Move field column number %s
|
||||
@ -62,4 +62,5 @@ ChooseFileToImport=Ajouter le fichier à importer puis cliquez sur le picto %s p
|
||||
DownloadEmptyExample=Télécharger fichier vierge exemple
|
||||
FieldsInSourceFile=Champs dans le fichier source
|
||||
FieldsInTargetDatabase=Champs cibles dans la base Dolibarr
|
||||
NoFields=Aucun champ
|
||||
NoFields=Aucun champ
|
||||
MoveField=Déplacer champ colonne numéro %s
|
||||
Loading…
Reference in New Issue
Block a user