Work on import module

This commit is contained in:
Laurent Destailleur 2009-10-17 13:48:17 +00:00
parent c78d15363f
commit c5702c5528
4 changed files with 26 additions and 13 deletions

View File

@ -1464,20 +1464,23 @@ if ($step == 6 && $datatoimport)
$db->begin();
// Open input file
$nbok=0;
$pathfile=$conf->import->dir_temp.'/'.$filetoimport;
$result=$obj->import_open_file($pathfile,$langs);
if ($result > 0)
{
$sourcelinenb=0;
// Loop on each input file record
while ($arrayrecord=$obj->import_read_record())
while ($sourcelinenb < $nboflines)
{
$sourcelinenb++;
$arrayrecord=$obj->import_read_record();
if ($excludefirstline && $sourcelinenb == 1) continue;
$result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,sizeof($fieldssource),$importid);
if (sizeof($obj->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors;
if (sizeof($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings;
if (! sizeof($obj->errors) && ! sizeof($obj->warnings)) $nbok++;
}
// Close file
$obj->import_close_file();
@ -1491,8 +1494,9 @@ if ($step == 6 && $datatoimport)
print '</div>';
// If no errors and no warnings
if (! sizeof($arrayoferrors) && ! sizeof($arrayofwarnings)) print img_tick().' <b>'.$langs->trans("NoErrors").'</b><br>';
// Show OK
if (! sizeof($arrayoferrors) && ! sizeof($arrayofwarnings)) print img_tick().' <b>'.$langs->trans("NoErrors").'</b><br><br>';
else print $langs->trans("NbOfLinesOK",$nbok).'</b><br><br>';
// Show Errors
//var_dump($arrayoferrors);
@ -1789,20 +1793,22 @@ if ($step == 7 && $datatoimport)
$db->begin();
// Open input file
$nbok=0;
$pathfile=$conf->import->dir_temp.'/'.$filetoimport;
$result=$obj->import_open_file($pathfile,$langs);
if ($result > 0)
{
$sourcelinenb=0;
// Loop on each input file record
while ($arrayrecord=$obj->import_read_record())
while ($sourcelinenb < $nboflines)
{
$sourcelinenb++;
$arrayrecord=$obj->import_read_record();
if ($excludefirstline && $sourcelinenb == 1) continue;
$result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,sizeof($fieldssource),$importid);
if (sizeof($obj->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors;
if (sizeof($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings;
if (! sizeof($obj->errors) && ! sizeof($obj->warnings)) $nbok++;
}
// Close file
$obj->import_close_file();
@ -1817,10 +1823,10 @@ if ($step == 7 && $datatoimport)
print '</div>';
// Show result
print '<br>';
print '<center>';
print '<br>';
print $langs->trans("NbOfLinesImported",$nbok).'</b><br><br>';
print $langs->trans("FileWasImported",$importid).'<br>';
print $langs->trans("YouCanUseImportIdToFindRecord",$importid).'<br>';
print '</center>';

View File

@ -92,4 +92,5 @@ TooMuchWarnings=There is still <b>%s</b> other source lines with warnings but ou
EmptyLine=Empty line (will be discarded)
CorrectErrorBeforeRunningImport=You must first correct all errors before running definitive import.
YouCanUseImportIdToFindRecord=You can find all imported records in your database by filtering on field <b>import_key='%s'</b>.
NbOfLinesOK=Number of lines with no errors and no warnings: <b>%s</b>.
NbOfLinesImported=Number of lines successfully imported: <b>%s</b>.

View File

@ -93,3 +93,5 @@ EmptyLine=Ligne vide (sera ignorée)
CorrectErrorBeforeRunningImport=Vous devez d'abord corriger toutes les erreurs avant de pouvoir lancer l'import définitif.
FileWasImported=Le fichier a été importé sous le numéro d'import <b>%s</b>.
YouCanUseImportIdToFindRecord=Vous pourrez retrouver les enregistrements issus de cet import dans votre base par un filtrage sur le champ <b>import_key='%s'</b>.
NbOfLinesOK=Nombre de lignes sans erreurs ni warning: <b>%s</b>.
NbOfLinesImported=Nombre de lignes importées avec succès: <b>%s</b>.

View File

@ -811,11 +811,11 @@ class Product extends CommonObject
/**
* \brief Modifie le prix d'un produit/service
* \param id Id du produit/service a modifier
* \param newprice Nouveau prix
* \param newpricebase HT ou TTC
* \param user Objet utilisateur qui modifie le prix
* \brief Modify price of a product/Service
* \param id Id of product/service to change
* \param newprice New price
* \param newpricebase HT or TTC
* \param user Object user that make change
* \param newvat New VAT Rate
* \param newminprice New price min
* \param level 0=standard, >0 = level if multilevel prices
@ -827,6 +827,10 @@ class Product extends CommonObject
dol_syslog("Product::update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase." newminprice=".$newminprice." level=".$level, LOG_DEBUG);
// Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0;
// Check parameters
if ($newvat == '') $newvat=$this->tva_tx;
if ($newprice!='' || $newprice==0)