Work on import module
This commit is contained in:
parent
6ec90ac436
commit
b0e3b124e0
@ -361,15 +361,14 @@ if ($step == 2 && $datatoexport)
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
// Liste deroulante des modeles d'export
|
||||
print '<form action="export.php" method="post">';
|
||||
// Combo list of export 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="2">';
|
||||
print '<input type="hidden" name="datatoexport" value="'.$datatoexport.'">';
|
||||
print '<table><tr><td>';
|
||||
print $langs->trans("SelectExportFields");
|
||||
print '</td><td>';
|
||||
print '<table><tr><td colspan="2">';
|
||||
print $langs->trans("SelectExportFields").' ';
|
||||
$htmlother->select_export_model($exportmodelid,'exportmodelid',$datatoexport,1);
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Select").'">';
|
||||
print '</td></tr></table>';
|
||||
|
||||
@ -102,6 +102,53 @@ class FormOther
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne la liste des modeles d'import
|
||||
* \param selected Id modele pre-selectionne
|
||||
* \param htmlname Nom de la zone select
|
||||
* \param type Type des modeles recherches
|
||||
* \param useempty Affiche valeur vide dans liste
|
||||
*/
|
||||
function select_import_model($selected='',$htmlname='importmodelid',$type='',$useempty=0)
|
||||
{
|
||||
$sql = "SELECT rowid, label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."import_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " ORDER BY rowid";
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
if ($useempty)
|
||||
{
|
||||
print '<option value="-1"> </option>';
|
||||
}
|
||||
|
||||
$num = $this->db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
if ($selected == $obj->rowid)
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'" selected="true">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'">';
|
||||
}
|
||||
print $obj->label;
|
||||
print '</option>';
|
||||
$i++;
|
||||
}
|
||||
print "</select>";
|
||||
}
|
||||
else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne la liste des ecotaxes avec tooltip sur le libelle
|
||||
* \param selected code ecotaxes pre-selectionne
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/ajaximport.php
|
||||
* \file htdocs/imports/ajaximport.php
|
||||
* \brief File to return Ajax response on Fields move in import page
|
||||
* \version $Id$
|
||||
*/
|
||||
@ -28,7 +28,6 @@ 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');
|
||||
@ -38,24 +37,55 @@ $entityCookieName = "DOLENTITYID_dolibarr";
|
||||
if (isset($_COOKIE[$entityCookieName])) $_SESSION["dol_entity"] = $_COOKIE[$entityCookieName];
|
||||
|
||||
require('../master.inc.php');
|
||||
require_once(DOL_DOCUMENT_ROOT."/imports/import.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/import/modules_import.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);
|
||||
dol_syslog("AjaxImport boxorder=".$_GET['boxorder']." userid=".$_GET['userid']." datatoimport=".$_GET["datatoimport"], LOG_DEBUG);
|
||||
$part=split(':',$_GET['boxorder']);
|
||||
$colonne=$part[0];
|
||||
$list=$part[1];
|
||||
dol_syslog('AjaxImport column='.$colonne.' list='.$list);
|
||||
|
||||
// Init object $objimport that describe the predefined import
|
||||
$fuser->id=$_GET['userid'];
|
||||
$fuser->fetch();
|
||||
$objimport=new Import($db);
|
||||
$datatoimport=isset($_GET["datatoimport"])? $_GET["datatoimport"] : (isset($_POST["datatoimport"])?$_POST["datatoimport"]:'');
|
||||
$objimport->load_arrays($fuser,$datatoimport);
|
||||
|
||||
// We define array_match_file_to_database
|
||||
// Init targets fields array
|
||||
$fieldstarget=$objimport->array_import_fields[0];
|
||||
|
||||
// We redefine array_match_file_to_database
|
||||
$array_match_file_to_database=array();
|
||||
$listelem=split(',',$list);
|
||||
$pos=0;
|
||||
foreach($listelem as $fieldnb)
|
||||
{
|
||||
//dol_syslog("Fieldnb in file=".$fieldnb." => keynb in targets=".$pos);
|
||||
|
||||
// Get name of database field at position $pos into $namefield
|
||||
$posbis=0;$namefield='';
|
||||
foreach($fieldstarget as $key => $val)
|
||||
{
|
||||
if ($posbis < $pos)
|
||||
{
|
||||
$posbis++;
|
||||
continue;
|
||||
}
|
||||
// We found the key of targets that is at position pos
|
||||
$namefield=$key;
|
||||
break;
|
||||
}
|
||||
|
||||
if (! empty($fieldnb)) $array_match_file_to_database[$fieldnb]=$namefield;
|
||||
|
||||
$pos++;
|
||||
}
|
||||
|
||||
// We save new matching in session
|
||||
$_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
|
||||
|
||||
dol_syslog('AjaxImport dol_array_match_file_to_database='.var_export($array_match_file_to_database,true));
|
||||
?>
|
||||
|
||||
@ -327,7 +327,7 @@ if ($step == 2 && $datatoimport)
|
||||
$fullpathfiletoimport='';
|
||||
$var=true;
|
||||
|
||||
// Add help informations
|
||||
// Add format informations and link to download example
|
||||
print '<tr class="liste_titre"><td colspan="6">';
|
||||
print $langs->trans("FileMustHaveOneOfFollowingFormat");
|
||||
print '</td></tr>';
|
||||
@ -337,7 +337,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>'.$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>'.$objmodelimport->getLibLabel($key).'</td><td>'.$objmodelimport->getLibVersion($key).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
@ -463,9 +464,13 @@ if ($step == 3 && $datatoimport)
|
||||
$_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';
|
||||
@ -476,7 +481,7 @@ if ($step == 3 && $datatoimport)
|
||||
$head[$h][1] = $langs->trans("Step")." 2";
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=3&datatoimport='.$datatoimport.'&filetoimport='.urlencode($_GET["filetoimport"]);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?'.$param;
|
||||
$head[$h][1] = $langs->trans("Step")." 3";
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
@ -507,7 +512,18 @@ if ($step == 3 && $datatoimport)
|
||||
print '<br>';
|
||||
|
||||
|
||||
print $langs->trans("SelectImportFields",img_picto('','uparrow',''));
|
||||
// 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%">';
|
||||
@ -616,36 +632,24 @@ if ($step == 3 && $datatoimport)
|
||||
|
||||
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 colspan="2">';
|
||||
print '<tr valign="top"><td width="50%">';
|
||||
|
||||
print "\n<!-- Box forget container -->\n";
|
||||
print '<div id="right">'."\n";
|
||||
|
||||
// Print all input fields discarded
|
||||
if ($pos <= $maxpos)
|
||||
{
|
||||
while ($pos <= $maxpos)
|
||||
{
|
||||
print '<table summary="" width="100%" class="nobordernopadding">'."\n";
|
||||
print '<tr class="liste_total" height="20">';
|
||||
print '<td class="nocellnopadding" colspan="2"> </td>';
|
||||
print '</tr>';
|
||||
print "</table>\n";
|
||||
|
||||
$pos++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
show_elem('','',$var,'none');
|
||||
}
|
||||
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>';
|
||||
@ -656,19 +660,21 @@ if ($step == 3 && $datatoimport)
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
print "\n";
|
||||
print '<script type="text/javascript" language="javascript">';
|
||||
print 'function updateOrder(){';
|
||||
print 'var left_list = cleanSerialize(Sortable.serialize(\'left\'));';
|
||||
//print 'var right_list = cleanSerialize(Sortable.serialize(\'right\'));';
|
||||
print 'var boxorder = \'A:\' + left_list;';
|
||||
//print 'var boxorder = \'A:\' + left_list + \'-B:\' + right_list;';
|
||||
//alert( \'boxorder=\' + boxorder );
|
||||
print 'var userid = \''.$user->id.'\';';
|
||||
print 'var url = "ajaximport.php";';
|
||||
print 'o_options = new Object();';
|
||||
print 'o_options = {asynchronous:true,method: \'get\',parameters: \'boxorder=\' + boxorder + \'&userid=\' + userid};';
|
||||
print 'var myAjax = new Ajax.Request(url, o_options);';
|
||||
print '}';
|
||||
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";
|
||||
@ -922,10 +928,10 @@ function show_elem($fieldssource,$pos,$var,$key)
|
||||
elseif ($key == 'none')
|
||||
{
|
||||
print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
|
||||
print img_picto($langs->trans("MoveBox",$pos),'uparrow','class="boxhandle" style="cursor:move;"');
|
||||
print ' ';
|
||||
print '</td>';
|
||||
print '<td style="font-weight: normal">';
|
||||
print $langs->trans("NoFields");
|
||||
print ' ';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
|
||||
@ -58,7 +58,8 @@ TypeOfLineServiceOrProduct=Type of line (0=product, 1=service)
|
||||
FileWithDataToImport=File with data to import
|
||||
FileToImport=Source file to import
|
||||
FileMustHaveOneOfFollowingFormat=File to import must have one of following format
|
||||
ChooseFileToImport=Upload or choose file to import then click on picto %s ...
|
||||
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
|
||||
@ -58,7 +58,8 @@ TypeOfLineServiceOrProduct=Type de ligne (0=produit, 1=service)
|
||||
FileWithDataToImport=Fichier contenant les données à importer
|
||||
FileToImport=Fichier source à importer
|
||||
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 le fichier à importer puis cliquez sur le picto %s pour le sélectionner comme fichier source d'import...
|
||||
DownloadEmptyExample=Télécharger fichier vierge exemple
|
||||
FieldsInSourceFile=Champs dans le fichier source
|
||||
FieldsInTargetDatabase=Champs cibles dans la base Dolibarr
|
||||
NoFields=Aucun champ
|
||||
@ -27,6 +27,7 @@
|
||||
* \file htdocs/master.inc.php
|
||||
* \ingroup core
|
||||
* \brief File that defines environment for all Dolibarr process (pages or scripts)
|
||||
* This script reads the conf.php file, init $lang, $db and empty $user
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user