From 8b7ca67ba34c9a67e36e43f8873f2955fce04fa6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Aug 2009 21:56:03 +0000 Subject: [PATCH] Work on import module --- htdocs/boxes.php | 2 +- htdocs/imports/ajaximport.php | 61 +++++++++++++++++++++++++ htdocs/imports/import.php | 79 +++++++++------------------------ htdocs/langs/en_US/exports.lang | 1 + htdocs/langs/fr_FR/exports.lang | 3 +- 5 files changed, 86 insertions(+), 60 deletions(-) create mode 100644 htdocs/imports/ajaximport.php diff --git a/htdocs/boxes.php b/htdocs/boxes.php index 4d580f437d4..27e13388236 100644 --- a/htdocs/boxes.php +++ b/htdocs/boxes.php @@ -209,7 +209,7 @@ class InfoBox $part=split(':',$collist); $colonne=$part[0]; $list=$part[1]; - dol_syslog('InfoBox::saveboxorder colonne='.$colonne.' list='.$list); + dol_syslog('InfoBox::saveboxorder column='.$colonne.' list='.$list); $i=0; $listarray=split(',',$list); diff --git a/htdocs/imports/ajaximport.php b/htdocs/imports/ajaximport.php new file mode 100644 index 00000000000..c5bb91d8707 --- /dev/null +++ b/htdocs/imports/ajaximport.php @@ -0,0 +1,61 @@ + + * Copyright (C) 2007-2009 Laurent Destailleur + * + * 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; + +?> diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 5789e6c6c0f..9c9d8a55887 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -20,7 +20,7 @@ /** * \file htdocs/imports/import.php * \ingroup import - * \brief Page d'edition d'un import + * \brief Edit import page * \version $Id$ */ @@ -85,53 +85,6 @@ $sqlusedforimport=''; * 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
"; - } - $_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database; - } -} -*/ - if ($action=='downfield' || $action=='upfield') { $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') { - // TODO Save a matching model if ($import_name) { asort($array_match_file_to_database); @@ -222,7 +175,8 @@ if ($action == 'add_import_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(); $array_match_file_to_database=array(); $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) { // 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; } + 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'; @@ -705,7 +658,7 @@ if ($step == 3 && $datatoimport) print "\n"; print '