From c5702c5528c09f948aab2f3fa289c78a11cf4a46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Sat, 17 Oct 2009 13:48:17 +0000 Subject: [PATCH] Work on import module --- htdocs/imports/import.php | 20 +++++++++++++------- htdocs/langs/en_US/exports.lang | 3 ++- htdocs/langs/fr_FR/exports.lang | 2 ++ htdocs/product.class.php | 14 +++++++++----- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index c5f00ca11fc..5fbb113a05d 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -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>'; diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index a341b9c519d..1d45579e791 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -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>. diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 2a26d978606..4996b5add43 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -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>. \ No newline at end of file diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 34ebab31ace..af48ee90878 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -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) -- GitLab