Work on import module
This commit is contained in:
parent
c78d15363f
commit
c5702c5528
@ -1464,20 +1464,23 @@ if ($step == 6 && $datatoimport)
|
|||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
// Open input file
|
// Open input file
|
||||||
|
$nbok=0;
|
||||||
$pathfile=$conf->import->dir_temp.'/'.$filetoimport;
|
$pathfile=$conf->import->dir_temp.'/'.$filetoimport;
|
||||||
$result=$obj->import_open_file($pathfile,$langs);
|
$result=$obj->import_open_file($pathfile,$langs);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$sourcelinenb=0;
|
$sourcelinenb=0;
|
||||||
// Loop on each input file record
|
// Loop on each input file record
|
||||||
while ($arrayrecord=$obj->import_read_record())
|
while ($sourcelinenb < $nboflines)
|
||||||
{
|
{
|
||||||
$sourcelinenb++;
|
$sourcelinenb++;
|
||||||
|
$arrayrecord=$obj->import_read_record();
|
||||||
if ($excludefirstline && $sourcelinenb == 1) continue;
|
if ($excludefirstline && $sourcelinenb == 1) continue;
|
||||||
|
|
||||||
$result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,sizeof($fieldssource),$importid);
|
$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->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors;
|
||||||
if (sizeof($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings;
|
if (sizeof($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings;
|
||||||
|
if (! sizeof($obj->errors) && ! sizeof($obj->warnings)) $nbok++;
|
||||||
}
|
}
|
||||||
// Close file
|
// Close file
|
||||||
$obj->import_close_file();
|
$obj->import_close_file();
|
||||||
@ -1491,8 +1494,9 @@ if ($step == 6 && $datatoimport)
|
|||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
// If no errors and no warnings
|
// Show OK
|
||||||
if (! sizeof($arrayoferrors) && ! sizeof($arrayofwarnings)) print img_tick().' <b>'.$langs->trans("NoErrors").'</b><br>';
|
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
|
// Show Errors
|
||||||
//var_dump($arrayoferrors);
|
//var_dump($arrayoferrors);
|
||||||
@ -1789,20 +1793,22 @@ if ($step == 7 && $datatoimport)
|
|||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
// Open input file
|
// Open input file
|
||||||
|
$nbok=0;
|
||||||
$pathfile=$conf->import->dir_temp.'/'.$filetoimport;
|
$pathfile=$conf->import->dir_temp.'/'.$filetoimport;
|
||||||
$result=$obj->import_open_file($pathfile,$langs);
|
$result=$obj->import_open_file($pathfile,$langs);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$sourcelinenb=0;
|
$sourcelinenb=0;
|
||||||
// Loop on each input file record
|
while ($sourcelinenb < $nboflines)
|
||||||
while ($arrayrecord=$obj->import_read_record())
|
|
||||||
{
|
{
|
||||||
$sourcelinenb++;
|
$sourcelinenb++;
|
||||||
|
$arrayrecord=$obj->import_read_record();
|
||||||
if ($excludefirstline && $sourcelinenb == 1) continue;
|
if ($excludefirstline && $sourcelinenb == 1) continue;
|
||||||
|
|
||||||
$result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,sizeof($fieldssource),$importid);
|
$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->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors;
|
||||||
if (sizeof($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings;
|
if (sizeof($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings;
|
||||||
|
if (! sizeof($obj->errors) && ! sizeof($obj->warnings)) $nbok++;
|
||||||
}
|
}
|
||||||
// Close file
|
// Close file
|
||||||
$obj->import_close_file();
|
$obj->import_close_file();
|
||||||
@ -1817,10 +1823,10 @@ if ($step == 7 && $datatoimport)
|
|||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|
||||||
// Show result
|
// Show result
|
||||||
print '<br>';
|
|
||||||
print '<center>';
|
print '<center>';
|
||||||
|
print '<br>';
|
||||||
|
print $langs->trans("NbOfLinesImported",$nbok).'</b><br><br>';
|
||||||
print $langs->trans("FileWasImported",$importid).'<br>';
|
print $langs->trans("FileWasImported",$importid).'<br>';
|
||||||
print $langs->trans("YouCanUseImportIdToFindRecord",$importid).'<br>';
|
print $langs->trans("YouCanUseImportIdToFindRecord",$importid).'<br>';
|
||||||
print '</center>';
|
print '</center>';
|
||||||
|
|||||||
@ -92,4 +92,5 @@ TooMuchWarnings=There is still <b>%s</b> other source lines with warnings but ou
|
|||||||
EmptyLine=Empty line (will be discarded)
|
EmptyLine=Empty line (will be discarded)
|
||||||
CorrectErrorBeforeRunningImport=You must first correct all errors before running definitive import.
|
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>.
|
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>.
|
||||||
|
|||||||
@ -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.
|
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>.
|
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>.
|
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>.
|
||||||
@ -811,11 +811,11 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Modifie le prix d'un produit/service
|
* \brief Modify price of a product/Service
|
||||||
* \param id Id du produit/service a modifier
|
* \param id Id of product/service to change
|
||||||
* \param newprice Nouveau prix
|
* \param newprice New price
|
||||||
* \param newpricebase HT ou TTC
|
* \param newpricebase HT or TTC
|
||||||
* \param user Objet utilisateur qui modifie le prix
|
* \param user Object user that make change
|
||||||
* \param newvat New VAT Rate
|
* \param newvat New VAT Rate
|
||||||
* \param newminprice New price min
|
* \param newminprice New price min
|
||||||
* \param level 0=standard, >0 = level if multilevel prices
|
* \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);
|
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 ($newvat == '') $newvat=$this->tva_tx;
|
||||||
|
|
||||||
if ($newprice!='' || $newprice==0)
|
if ($newprice!='' || $newprice==0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user