Work on import module
This commit is contained in:
parent
4af4a6629a
commit
8b7ca67ba3
@ -209,7 +209,7 @@ class InfoBox
|
|||||||
$part=split(':',$collist);
|
$part=split(':',$collist);
|
||||||
$colonne=$part[0];
|
$colonne=$part[0];
|
||||||
$list=$part[1];
|
$list=$part[1];
|
||||||
dol_syslog('InfoBox::saveboxorder colonne='.$colonne.' list='.$list);
|
dol_syslog('InfoBox::saveboxorder column='.$colonne.' list='.$list);
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
$listarray=split(',',$list);
|
$listarray=split(',',$list);
|
||||||
|
|||||||
61
htdocs/imports/ajaximport.php
Normal file
61
htdocs/imports/ajaximport.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
* Copyright (C) 2007-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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/ajaximport.php
|
||||||
|
* \brief File to return Ajax response on Fields move in import page
|
||||||
|
* \version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
|
||||||
|
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||||
|
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||||
|
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||||
|
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||||
|
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||||
|
|
||||||
|
// This is to make Dolibarr working with Plesk
|
||||||
|
set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
|
||||||
|
|
||||||
|
// Retrieve the entity in the cookie
|
||||||
|
$entityCookieName = "DOLENTITYID_dolibarr";
|
||||||
|
if (isset($_COOKIE[$entityCookieName])) $_SESSION["dol_entity"] = $_COOKIE[$entityCookieName];
|
||||||
|
|
||||||
|
require('../master.inc.php');
|
||||||
|
|
||||||
|
// Enregistrement de la position des champs
|
||||||
|
|
||||||
|
//$_SESSION["dol_array_match_file_to_database"]
|
||||||
|
dol_syslog("AjaxImport boxorder=".$_GET['boxorder']." userid=".$_GET['userid'], LOG_DEBUG);
|
||||||
|
|
||||||
|
$part=split(':',$collist);
|
||||||
|
$colonne=$part[0];
|
||||||
|
$list=$part[1];
|
||||||
|
dol_syslog('AjaxImport column='.$colonne.' list='.$list);
|
||||||
|
|
||||||
|
|
||||||
|
// We define array_match_file_to_database
|
||||||
|
$array_match_file_to_database=array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// We save new matching in session
|
||||||
|
$_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
|
||||||
|
|
||||||
|
?>
|
||||||
@ -20,7 +20,7 @@
|
|||||||
/**
|
/**
|
||||||
* \file htdocs/imports/import.php
|
* \file htdocs/imports/import.php
|
||||||
* \ingroup import
|
* \ingroup import
|
||||||
* \brief Page d'edition d'un import
|
* \brief Edit import page
|
||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -85,53 +85,6 @@ $sqlusedforimport='';
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
if ($action=='selectfield')
|
|
||||||
{
|
|
||||||
if ($_GET["field"]=='all')
|
|
||||||
{
|
|
||||||
$fieldsarray=$objimport->array_import_alias[0];
|
|
||||||
foreach($fieldsarray as $key=>$val)
|
|
||||||
{
|
|
||||||
if (! empty($array_match_file_to_database[$key])) continue; // If already selected, select next
|
|
||||||
$array_match_file_to_database[$key]=sizeof($array_match_file_to_database)+1;
|
|
||||||
//print_r($array_match_file_to_database);
|
|
||||||
$_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$array_match_file_to_database[$_GET["field"]]=sizeof($array_match_file_to_database)+1;
|
|
||||||
//print_r($array_match_file_to_database);
|
|
||||||
$_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if ($action=='unselectfield')
|
|
||||||
{
|
|
||||||
if ($_GET["field"]=='all')
|
|
||||||
{
|
|
||||||
$array_match_file_to_database=array();
|
|
||||||
$_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unset($array_match_file_to_database[$_GET["field"]]);
|
|
||||||
// Renumber fields of array_selected (from 1 to nb_elements)
|
|
||||||
asort($array_match_file_to_database);
|
|
||||||
$i=0;
|
|
||||||
$array_match_file_to_database_save=$array_match_file_to_database;
|
|
||||||
foreach($array_match_file_to_database as $code=>$value)
|
|
||||||
{
|
|
||||||
$i++;
|
|
||||||
$array_match_file_to_database[$code]=$i;
|
|
||||||
//print "x $code x $i y<br>";
|
|
||||||
}
|
|
||||||
$_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($action=='downfield' || $action=='upfield')
|
if ($action=='downfield' || $action=='upfield')
|
||||||
{
|
{
|
||||||
$pos=$array_match_file_to_database[$_GET["field"]];
|
$pos=$array_match_file_to_database[$_GET["field"]];
|
||||||
@ -180,9 +133,9 @@ if ($action == 'deleteprof')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save import config to file
|
||||||
if ($action == 'add_import_model')
|
if ($action == 'add_import_model')
|
||||||
{
|
{
|
||||||
// TODO Save a matching model
|
|
||||||
if ($import_name)
|
if ($import_name)
|
||||||
{
|
{
|
||||||
asort($array_match_file_to_database);
|
asort($array_match_file_to_database);
|
||||||
@ -222,7 +175,8 @@ if ($action == 'add_import_model')
|
|||||||
|
|
||||||
if ($step == 3 && $action == 'select_model')
|
if ($step == 3 && $action == 'select_model')
|
||||||
{
|
{
|
||||||
// TODO Use a matching model
|
// Load model from $importmodelid and set $array_match_file_to_database
|
||||||
|
// and $_SESSION["dol_array_match_file_to_database"]
|
||||||
$_SESSION["dol_array_match_file_to_database"]=array();
|
$_SESSION["dol_array_match_file_to_database"]=array();
|
||||||
$array_match_file_to_database=array();
|
$array_match_file_to_database=array();
|
||||||
$result = $objimport->fetch($importmodelid);
|
$result = $objimport->fetch($importmodelid);
|
||||||
@ -468,6 +422,7 @@ if ($step == 2 && $datatoimport)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Page to make matching between source file and database fields
|
||||||
if ($step == 3 && $datatoimport)
|
if ($step == 3 && $datatoimport)
|
||||||
{
|
{
|
||||||
// Load source fields in input file
|
// Load source fields in input file
|
||||||
@ -508,11 +463,9 @@ if ($step == 3 && $datatoimport)
|
|||||||
$_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
|
$_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
|
llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
|
||||||
|
|
||||||
/*
|
|
||||||
* Affichage onglets
|
|
||||||
*/
|
|
||||||
$h = 0;
|
$h = 0;
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=1';
|
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=1';
|
||||||
@ -705,7 +658,7 @@ if ($step == 3 && $datatoimport)
|
|||||||
print "\n";
|
print "\n";
|
||||||
print '<script type="text/javascript" language="javascript">';
|
print '<script type="text/javascript" language="javascript">';
|
||||||
print 'function updateOrder(){';
|
print 'function updateOrder(){';
|
||||||
print 'var left_list = cleanSerialize(Sortable.serialize(\'left\'));';
|
print 'var left_list = cleanSerialize(Sortable.serialize(\'left\'));';
|
||||||
//print 'var right_list = cleanSerialize(Sortable.serialize(\'right\'));';
|
//print 'var right_list = cleanSerialize(Sortable.serialize(\'right\'));';
|
||||||
print 'var boxorder = \'A:\' + left_list;';
|
print 'var boxorder = \'A:\' + left_list;';
|
||||||
//print 'var boxorder = \'A:\' + left_list + \'-B:\' + right_list;';
|
//print 'var boxorder = \'A:\' + left_list + \'-B:\' + right_list;';
|
||||||
@ -715,7 +668,7 @@ if ($step == 3 && $datatoimport)
|
|||||||
print 'o_options = new Object();';
|
print 'o_options = new Object();';
|
||||||
print 'o_options = {asynchronous:true,method: \'get\',parameters: \'boxorder=\' + boxorder + \'&userid=\' + userid};';
|
print 'o_options = {asynchronous:true,method: \'get\',parameters: \'boxorder=\' + boxorder + \'&userid=\' + userid};';
|
||||||
print 'var myAjax = new Ajax.Request(url, o_options);';
|
print 'var myAjax = new Ajax.Request(url, o_options);';
|
||||||
print '}';
|
print '}';
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
print '// <![CDATA['."\n";
|
print '// <![CDATA['."\n";
|
||||||
@ -959,11 +912,21 @@ function show_elem($fieldssource,$pos,$var,$key)
|
|||||||
print '<tr class="liste_total" height="20">';
|
print '<tr class="liste_total" height="20">';
|
||||||
if (empty($key))
|
if (empty($key))
|
||||||
{
|
{
|
||||||
print '<td class="nocellnopadding" colspan="2"> </td>';
|
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')
|
elseif ($key == 'none')
|
||||||
{
|
{
|
||||||
print '<td class="nocellnopadding" colspan="2" style="font-weight: normal">'.$langs->trans("NoDiscardedFields").'</td>';
|
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>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -974,7 +937,7 @@ function show_elem($fieldssource,$pos,$var,$key)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td style="font-weight: normal">';
|
print '<td style="font-weight: normal">';
|
||||||
print $langs->trans("Field").' '.$key.': ';
|
print $langs->trans("Field").' '.$key.': ';
|
||||||
print $fieldssource[$key]['name'].' ('.$fieldssource[$key]['example1'].')';
|
print '<b>'.$fieldssource[$key]['name'].'</b> ('.$fieldssource[$key]['example1'].')';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
@ -61,3 +61,4 @@ FileMustHaveOneOfFollowingFormat=File to import must have one of following forma
|
|||||||
ChooseFileToImport=Upload or choose file to import then click on picto %s ...
|
ChooseFileToImport=Upload or choose file to import then click on picto %s ...
|
||||||
FieldsInSourceFile=Fields in source file
|
FieldsInSourceFile=Fields in source file
|
||||||
FieldsInTargetDatabase=Target fields in Dolibarr database
|
FieldsInTargetDatabase=Target fields in Dolibarr database
|
||||||
|
NoFields=No fields
|
||||||
@ -60,4 +60,5 @@ FileToImport=Fichier source à importer
|
|||||||
FileMustHaveOneOfFollowingFormat=Le fichier à importer doit avoir un des formats suivants
|
FileMustHaveOneOfFollowingFormat=Le fichier à importer doit avoir un des formats suivants
|
||||||
ChooseFileToImport=Ajouter ou choisissez le fichier à importer puis cliquez sur le picto %s ...
|
ChooseFileToImport=Ajouter ou choisissez le fichier à importer puis cliquez sur le picto %s ...
|
||||||
FieldsInSourceFile=Champs dans le fichier source
|
FieldsInSourceFile=Champs dans le fichier source
|
||||||
FieldsInTargetDatabase=Champs cibles dans la base Dolibarr
|
FieldsInTargetDatabase=Champs cibles dans la base Dolibarr
|
||||||
|
NoFields=Aucun champ
|
||||||
Loading…
Reference in New Issue
Block a user