NEW Add a profile to import product translations

This commit is contained in:
Laurent Destailleur 2017-11-06 12:59:58 +01:00
parent 8429de031f
commit 45fc5701ae
4 changed files with 100 additions and 84 deletions

View File

@ -308,7 +308,6 @@ class modProduct extends DolibarrModules
if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'NPR')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'NPR'));
if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
$this->import_convertvalue_array[$r]=array( $this->import_convertvalue_array[$r]=array(
'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'),
'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
@ -352,30 +351,19 @@ class modProduct extends DolibarrModules
if (! empty($conf->global->MAIN_MULTILANGS)) if (! empty($conf->global->MAIN_MULTILANGS))
{ {
$r++; $r++;
/* FIXME Must be a dedicated import profil. Not working yet $this->import_code[$r]=$this->rights_class.'_languages';
$this->import_code[$r]=$this->rights_class.'_multiprice'; $this->import_label[$r]="ProductsOrServicesTranslations";
$this->import_label[$r]="ProductTranslations";
$this->import_icon[$r]=$this->picto; $this->import_icon[$r]=$this->picto;
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r]['l']=MAIN_DB_PREFIX.'product_lang'; $this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang');
// multiline translation, one line per translation // multiline translation, one line per translation
$this->import_fields_array[$r]['l.lang']='Language'; $this->import_fields_array[$r]=array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
$this->import_fields_array[$r]['l.label']='TranslatedLabel'; //$this->import_fields_array[$r]['l.note']='TranslatedNote';
$this->import_fields_array[$r]['l.description']='TranslatedDescription'; $this->import_convertvalue_array[$r]=array(
$this->import_fields_array[$r]['l.note']='TranslatedNote'; 'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
$this->import_examplevalues_array[$r]['l.lang']='en_US'; );
*/ $this->import_examplevalues_array[$r]=array('l.fk_product'=>'MyProductRef','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US');
// single line translation, one column per translation $this->import_updatekeys_array[$r]=array('l.fk_product'=>'Ref','l.lang'=>'Language');
/*
foreach($langs as $l) {
$this->import_tables_array[$r][$l] = MAIN_DB_PREFIX.'product_lang';
$this->import_fields_array[$r][$l.'.label']=$l.'_label';
$this->import_fields_array[$r][$l.'.description']=$l.'_description';
$this->import_fields_array[$r][$l.'.note']=$l.'_note';
$this->import_fieldshidden_array[$r][$l.'.lang']="'$l'";
$this->import_fieldshidden_array[$r][$l.'.fk_product']='lastrowid-'.MAIN_DB_PREFIX.'product';
}
*/
} }
} }

View File

@ -133,8 +133,8 @@ class modService extends DolibarrModules
// Menus // Menus
//------- //-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager. $this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports // Exports
//-------- //--------
$r=0; $r=0;
@ -315,6 +315,24 @@ class modService extends DolibarrModules
'pr.tva_tx'=>'19.6', 'pr.tva_tx'=>'19.6',
'pr.date_price'=>'2013-04-10'); 'pr.date_price'=>'2013-04-10');
} }
if (! empty($conf->global->MAIN_MULTILANGS))
{
$r++;
$this->import_code[$r]=$this->rights_class.'_languages';
$this->import_label[$r]="ProductsOrServicesTranslations";
$this->import_icon[$r]=$this->picto;
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang');
// multiline translation, one line per translation
$this->import_fields_array[$r]=array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
//$this->import_fields_array[$r]['l.note']='TranslatedNote';
$this->import_convertvalue_array[$r]=array(
'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
);
$this->import_examplevalues_array[$r]=array('l.fk_product'=>'MyProductRef','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US');
$this->import_updatekeys_array[$r]=array('l.fk_product'=>'Ref','l.lang'=>'Language');
}
} }
} }

View File

@ -225,7 +225,7 @@ if ($step == 3 && $datatoimport)
$param='&datatoimport='.$datatoimport.'&format='.$format; $param='&datatoimport='.$datatoimport.'&format='.$format;
if ($excludefirstline) $param.='&excludefirstline='.$excludefirstline; if ($excludefirstline) $param.='&excludefirstline='.$excludefirstline;
if ($endatlinenb) $param.='&endatlinenb='.$endatlinenb; if ($endatlinenb) $param.='&endatlinenb='.$endatlinenb;
$file = $conf->import->dir_temp . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $conf->import->dir_temp . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file); $ret=dol_delete_file($file);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
@ -362,7 +362,7 @@ if ($step == 1 || ! $datatoimport)
print '<tr '.$bc[$val].'><td nospan="nospan">'; print '<tr '.$bc[$val].'><td nospan="nospan">';
$titleofmodule=$objimport->array_import_module[$key]->getName(); $titleofmodule=$objimport->array_import_module[$key]->getName();
// Special cas for import common to module/services // Special cas for import common to module/services
if (in_array($objimport->array_import_code[$key], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService"); if (in_array($objimport->array_import_code[$key], array('produit_supplierprices','produit_multiprice','produit_languages'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule; print $titleofmodule;
print '</td><td>'; print '</td><td>';
//print $value; //print $value;
@ -415,7 +415,7 @@ if ($step == 2 && $datatoimport)
print '<td>'; print '<td>';
$titleofmodule=$objimport->array_import_module[0]->getName(); $titleofmodule=$objimport->array_import_module[0]->getName();
// Special cas for import common to module/services // Special cas for import common to module/services
if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService"); if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice','produit_languages'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule; print $titleofmodule;
print '</td></tr>'; print '</td></tr>';
@ -429,9 +429,9 @@ if ($step == 2 && $datatoimport)
print '</table>'; print '</table>';
print '</div><br>'; print '</div><br>';
dol_fiche_end(); dol_fiche_end();
print '<form name="userfile" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data" METHOD="POST">'; print '<form name="userfile" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data" METHOD="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -450,7 +450,7 @@ if ($step == 2 && $datatoimport)
$liste=$objmodelimport->liste_modeles($db); $liste=$objmodelimport->liste_modeles($db);
foreach($liste as $key) foreach($liste as $key)
{ {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="16">'.img_picto_common($key,$objmodelimport->getPictoForKey($key)).'</td>'; print '<td width="16">'.img_picto_common($key,$objmodelimport->getPictoForKey($key)).'</td>';
$text=$objmodelimport->getDriverDescForKey($key); $text=$objmodelimport->getDriverDescForKey($key);
@ -495,7 +495,7 @@ if ($step == 3 && $datatoimport)
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
// Module // Module
@ -503,7 +503,7 @@ if ($step == 3 && $datatoimport)
print '<td>'; print '<td>';
$titleofmodule=$objimport->array_import_module[0]->getName(); $titleofmodule=$objimport->array_import_module[0]->getName();
// Special cas for import common to module/services // Special cas for import common to module/services
if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService"); if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice','produit_languages'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule; print $titleofmodule;
print '</td></tr>'; print '</td></tr>';
@ -516,11 +516,11 @@ if ($step == 3 && $datatoimport)
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<br>'; print '<br>';
print '<b>'.$langs->trans("InformationOnSourceFile").'</b>'; print '<b>'.$langs->trans("InformationOnSourceFile").'</b>';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
@ -537,15 +537,15 @@ if ($step == 3 && $datatoimport)
print '</table>'; print '</table>';
print '</div>'; print '</div>';
dol_fiche_end(); dol_fiche_end();
print '<br>'; print '<br>';
print '<form name="userfile" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data" METHOD="POST">'; print '<form name="userfile" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data" METHOD="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">'; print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
print '<input type="hidden" value="'.$step.'" name="step">'; print '<input type="hidden" value="'.$step.'" name="step">';
print '<input type="hidden" value="'.$format.'" name="format">'; print '<input type="hidden" value="'.$format.'" name="format">';
print '<input type="hidden" value="'.$excludefirstline.'" name="excludefirstline">'; print '<input type="hidden" value="'.$excludefirstline.'" name="excludefirstline">';
@ -553,7 +553,7 @@ if ($step == 3 && $datatoimport)
print '<input type="hidden" value="'.$separator.'" name="separator">'; print '<input type="hidden" value="'.$separator.'" name="separator">';
print '<input type="hidden" value="'.$enclosure.'" name="enclosure">'; print '<input type="hidden" value="'.$enclosure.'" name="enclosure">';
print '<input type="hidden" value="'.$datatoimport.'" name="datatoimport">'; print '<input type="hidden" value="'.$datatoimport.'" name="datatoimport">';
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">'; print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
$filetoimport=''; $filetoimport='';
@ -613,7 +613,7 @@ if ($step == 3 && $datatoimport)
$modulepart='import'; $modulepart='import';
$urlsource=$_SERVER["PHP_SELF"].'?step='.$step.$param.'&filetoimport='.urlencode($filetoimport); $urlsource=$_SERVER["PHP_SELF"].'?step='.$step.$param.'&filetoimport='.urlencode($filetoimport);
$relativepath=$file; $relativepath=$file;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="16">'.img_mime($file).'</td>'; print '<td width="16">'.img_mime($file).'</td>';
print '<td>'; print '<td>';
@ -665,9 +665,9 @@ if ($step == 4 && $datatoimport)
header("Location: ".$_SERVER["PHP_SELF"].'?step=3'.$param.'&filetoimport='.urlencode($relativepath)); header("Location: ".$_SERVER["PHP_SELF"].'?step=3'.$param.'&filetoimport='.urlencode($relativepath));
exit; exit;
} }
} }
if (GETPOST('update')) { if (GETPOST('update')) {
$array_match_file_to_database=array(); $array_match_file_to_database=array();
} }
@ -759,7 +759,7 @@ if ($step == 4 && $datatoimport)
print '<td>'; print '<td>';
$titleofmodule=$objimport->array_import_module[0]->getName(); $titleofmodule=$objimport->array_import_module[0]->getName();
// Special cas for import common to module/services // Special cas for import common to module/services
if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService"); if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice','produit_languages'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule; print $titleofmodule;
print '</td></tr>'; print '</td></tr>';
@ -772,9 +772,9 @@ if ($step == 4 && $datatoimport)
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<br>'; print '<br>';
print '<b>'.$langs->trans("InformationOnSourceFile").'</b>'; print '<b>'.$langs->trans("InformationOnSourceFile").'</b>';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">'; print '<div class="fichecenter">';
@ -820,9 +820,9 @@ if ($step == 4 && $datatoimport)
print '</table>'; print '</table>';
print '</div>'; print '</div>';
dol_fiche_end(); dol_fiche_end();
print '<br>'."\n"; print '<br>'."\n";
@ -873,7 +873,7 @@ if ($step == 4 && $datatoimport)
$lefti=1; $lefti=1;
foreach ($array_match_file_to_database as $key => $val) foreach ($array_match_file_to_database as $key => $val)
{ {
show_elem($fieldssource,$key,$val,$var); // key is field number in source file show_elem($fieldssource,$key,$val,$var); // key is field number in source file
//print '> '.$lefti.'-'.$key.'-'.$val; //print '> '.$lefti.'-'.$key.'-'.$val;
$listofkeys[$key]=1; $listofkeys[$key]=1;
@ -890,7 +890,7 @@ if ($step == 4 && $datatoimport)
$num=count($fieldssource); $num=count($fieldssource);
while ($lefti <= $num) while ($lefti <= $num)
{ {
$newkey=getnewkey($fieldssource,$listofkeys); $newkey=getnewkey($fieldssource,$listofkeys);
show_elem($fieldssource,$newkey,'',$var); // key start after field number in source file show_elem($fieldssource,$newkey,'',$var); // key start after field number in source file
//print '> '.$lefti.'-'.$newkey; //print '> '.$lefti.'-'.$newkey;
@ -913,7 +913,7 @@ if ($step == 4 && $datatoimport)
print '<table width="100%" class="nobordernopadding">'; print '<table width="100%" class="nobordernopadding">';
foreach($fieldstarget as $code=>$label) foreach($fieldstarget as $code=>$label)
{ {
print '<tr '.$bc[$var].' height="'.$height.'">'; print '<tr '.$bc[$var].' height="'.$height.'">';
$i++; $i++;
@ -1148,7 +1148,7 @@ if ($step == 4 && $datatoimport)
$var=false; $var=false;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $obj->label; print $obj->label;
@ -1213,16 +1213,16 @@ if ($step == 5 && $datatoimport)
if ($excludefirstline) $param.='&excludefirstline='.$excludefirstline; if ($excludefirstline) $param.='&excludefirstline='.$excludefirstline;
if ($endatlinenb) $param.='&endatlinenb='.$endatlinenb; if ($endatlinenb) $param.='&endatlinenb='.$endatlinenb;
if (!empty($updatekeys)) $param.='&updatekeys[]='.implode('&updatekeys[]=', $updatekeys); if (!empty($updatekeys)) $param.='&updatekeys[]='.implode('&updatekeys[]=', $updatekeys);
llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:M&oacute;dulo_Importaciones'); llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:M&oacute;dulo_Importaciones');
$head = import_prepare_head($param,5); $head = import_prepare_head($param,5);
print '<form action="'.$_SERVER["PHP_SELF"].'?'.$param2.'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'?'.$param2.'" method="POST">';
print '<input type="hidden" name="step" value="5">'; // step 5 print '<input type="hidden" name="step" value="5">'; // step 5
print '<input type="hidden" name="action" value="launchsimu">'; // step 5 print '<input type="hidden" name="action" value="launchsimu">'; // step 5
dol_fiche_head($head, 'step5', $langs->trans("NewImport"), -1); dol_fiche_head($head, 'step5', $langs->trans("NewImport"), -1);
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
@ -1235,7 +1235,7 @@ if ($step == 5 && $datatoimport)
print '<td>'; print '<td>';
$titleofmodule=$objimport->array_import_module[0]->getName(); $titleofmodule=$objimport->array_import_module[0]->getName();
// Special cas for import common to module/services // Special cas for import common to module/services
if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService"); if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice','produit_languages'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule; print $titleofmodule;
print '</td></tr>'; print '</td></tr>';
@ -1248,9 +1248,9 @@ if ($step == 5 && $datatoimport)
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<br>'; print '<br>';
print '<b>'.$langs->trans("InformationOnSourceFile").'</b>'; print '<b>'.$langs->trans("InformationOnSourceFile").'</b>';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">'; print '<div class="fichecenter">';
@ -1274,7 +1274,7 @@ if ($step == 5 && $datatoimport)
print htmlentities($enclosure); print htmlentities($enclosure);
print '</td></tr>'; print '</td></tr>';
} }
// File to import // File to import
print '<tr><td>'.$langs->trans("FileToImport").'</td>'; print '<tr><td>'.$langs->trans("FileToImport").'</td>';
print '<td>'; print '<td>';
@ -1326,7 +1326,7 @@ if ($step == 5 && $datatoimport)
if($action=='launchsimu') { if($action=='launchsimu') {
if (count($updatekeys)) if (count($updatekeys))
{ {
print $form->multiselectarray('updatekeysbis', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0, '', 1, '', 'disabled'); print $form->multiselectarray('updatekeysbis', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0, '', 1, '80%', 'disabled');
} }
else else
{ {
@ -1351,16 +1351,16 @@ if ($step == 5 && $datatoimport)
print_r($objimport->array_import_updatekeys); print_r($objimport->array_import_updatekeys);
echo '</pre>';*/ echo '</pre>';*/
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<br>'; print '<br>';
print '<b>'.$langs->trans("InformationOnTargetTables").'</b>'; print '<b>'.$langs->trans("InformationOnTargetTables").'</b>';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
//print '<tr><td colspan="2"><b>'.$langs->trans("InformationOnTargetTables").'</b></td></tr>'; //print '<tr><td colspan="2"><b>'.$langs->trans("InformationOnTargetTables").'</b></td></tr>';
@ -1426,7 +1426,7 @@ if ($step == 5 && $datatoimport)
print '</table>'; print '</table>';
print '</div>'; print '</div>';
dol_fiche_end(); dol_fiche_end();
@ -1488,10 +1488,10 @@ if ($step == 5 && $datatoimport)
} }
if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue; if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue;
if ($endatlinenb && ($sourcelinenb > $endatlinenb)) continue; if ($endatlinenb && ($sourcelinenb > $endatlinenb)) continue;
// Run import // Run import
$result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys); $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys);
if (count($obj->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors; if (count($obj->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors;
if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings; if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings;
if (! count($obj->errors) && ! count($obj->warnings)) $nbok++; if (! count($obj->errors) && ! count($obj->warnings)) $nbok++;
@ -1505,7 +1505,7 @@ if ($step == 5 && $datatoimport)
} }
$error=0; $error=0;
// Run the sql after import if defined // Run the sql after import if defined
//var_dump($objimport->array_import_run_sql_after[0]); //var_dump($objimport->array_import_run_sql_after[0]);
if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0]))
@ -1515,14 +1515,14 @@ if ($step == 5 && $datatoimport)
{ {
$i++; $i++;
$resqlafterimport=$db->query($sqlafterimport); $resqlafterimport=$db->query($sqlafterimport);
if (! $resqlafterimport) if (! $resqlafterimport)
{ {
$arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport)); $arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport));
$error++; $error++;
} }
} }
} }
$db->rollback(); // We force rollback because this was just a simulation. $db->rollback(); // We force rollback because this was just a simulation.
// Show OK // Show OK
@ -1613,7 +1613,7 @@ if ($step == 5 && $datatoimport)
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("RunImportFile").'</a>'; print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("RunImportFile").'</a>';
} }
print '</div>'; print '</div>';
} }
print '</form>'; print '</form>';
@ -1668,8 +1668,10 @@ if ($step == 6 && $datatoimport)
$head = import_prepare_head($param,6); $head = import_prepare_head($param,6);
dol_fiche_head($head, 'step6', $langs->trans("NewImport")); dol_fiche_head($head, 'step6', $langs->trans("NewImport"), -1);
print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">';
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
@ -1678,7 +1680,7 @@ if ($step == 6 && $datatoimport)
print '<td>'; print '<td>';
$titleofmodule=$objimport->array_import_module[0]->getName(); $titleofmodule=$objimport->array_import_module[0]->getName();
// Special cas for import common to module/services // Special cas for import common to module/services
if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService"); if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice','produit_languages'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule; print $titleofmodule;
print '</td></tr>'; print '</td></tr>';
@ -1690,10 +1692,13 @@ if ($step == 6 && $datatoimport)
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '</div>';
print '<br>'; print '<br>';
print '<b>'.$langs->trans("InformationOnSourceFile").'</b><hr>'; print '<b>'.$langs->trans("InformationOnSourceFile").'</b>';
print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">';
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
//print '<tr><td colspan="2"><b>'.$langs->trans("InformationOnSourceFile").'</b></td></tr>'; //print '<tr><td colspan="2"><b>'.$langs->trans("InformationOnSourceFile").'</b></td></tr>';
@ -1714,7 +1719,7 @@ if ($step == 6 && $datatoimport)
print htmlentities($enclosure); print htmlentities($enclosure);
print '</td></tr>'; print '</td></tr>';
} }
// File to import // File to import
print '<tr><td>'.$langs->trans("FileToImport").'</td>'; print '<tr><td>'.$langs->trans("FileToImport").'</td>';
print '<td>'; print '<td>';
@ -1745,12 +1750,15 @@ if ($step == 6 && $datatoimport)
print '</td><td>'; print '</td><td>';
print '<input type="text" size="4" name="endatlinenb" disabled="disabled" value="'.$endatlinenb.'">'; print '<input type="text" size="4" name="endatlinenb" disabled="disabled" value="'.$endatlinenb.'">';
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '</div>';
print '<br>'; print '<br>';
print '<b>'.$langs->trans("InformationOnTargetTables").'</b><hr>'; print '<b>'.$langs->trans("InformationOnTargetTables").'</b>';
print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">';
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
//print '<tr><td colspan="2"><b>'.$langs->trans("InformationOnTargetTables").'</b></td></tr>'; //print '<tr><td colspan="2"><b>'.$langs->trans("InformationOnTargetTables").'</b></td></tr>';
@ -1812,6 +1820,7 @@ if ($step == 6 && $datatoimport)
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '</div>';
// Launch import // Launch import
$arrayoferrors=array(); $arrayoferrors=array();
@ -1852,7 +1861,7 @@ if ($step == 6 && $datatoimport)
// Run import // Run import
$result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys); $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys);
if (count($obj->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors; if (count($obj->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors;
if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings; if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings;
if (! count($obj->errors) && ! count($obj->warnings)) $nbok++; if (! count($obj->errors) && ! count($obj->warnings)) $nbok++;
@ -1866,10 +1875,10 @@ if ($step == 6 && $datatoimport)
} }
if (count($arrayoferrors) > 0) $db->rollback(); // We force rollback because this was errors. if (count($arrayoferrors) > 0) $db->rollback(); // We force rollback because this was errors.
else else
{ {
$error=0; $error=0;
// Run the sql after import if defined // Run the sql after import if defined
//var_dump($objimport->array_import_run_sql_after[0]); //var_dump($objimport->array_import_run_sql_after[0]);
if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0]))
@ -1879,18 +1888,18 @@ if ($step == 6 && $datatoimport)
{ {
$i++; $i++;
$resqlafterimport=$db->query($sqlafterimport); $resqlafterimport=$db->query($sqlafterimport);
if (! $resqlafterimport) if (! $resqlafterimport)
{ {
$arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport)); $arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport));
$error++; $error++;
} }
} }
} }
if (! $error) $db->commit(); // We can commit if no errors. if (! $error) $db->commit(); // We can commit if no errors.
else $db->rollback(); else $db->rollback();
} }
dol_fiche_end(); dol_fiche_end();
@ -1930,7 +1939,7 @@ function show_elem($fieldssource,$pos,$key,$var,$nostyle='')
global $langs,$bc; global $langs,$bc;
$height='24'; $height='24';
print "\n\n<!-- Box ".$pos." start -->\n"; print "\n\n<!-- Box ".$pos." start -->\n";
print '<div class="box" style="padding: 0px 0px 0px 0px;" id="boxto_'.$pos.'">'."\n"; print '<div class="box" style="padding: 0px 0px 0px 0px;" id="boxto_'.$pos.'">'."\n";

View File

@ -271,6 +271,7 @@ WarningSelectOneDocument=Please select at least one document
DefaultUnitToShow=Unit DefaultUnitToShow=Unit
NbOfQtyInProposals=Qty in proposals NbOfQtyInProposals=Qty in proposals
ClinkOnALinkOfColumn=Click on a link of column %s to get a detailed view... ClinkOnALinkOfColumn=Click on a link of column %s to get a detailed view...
ProductsOrServicesTranslations=Products or services translation
TranslatedLabel=Translated label TranslatedLabel=Translated label
TranslatedDescription=Translated description TranslatedDescription=Translated description
TranslatedNote=Translated notes TranslatedNote=Translated notes