Error management + show nb insert/update + langs
This commit is contained in:
parent
5b9acef10c
commit
578cab9a70
@ -54,6 +54,9 @@ class ImportCsv extends ModeleImports
|
||||
|
||||
var $cacheconvert=array(); // Array to cache list of value found after a convertion
|
||||
var $cachefieldtable=array(); // Array to cache list of value found into fields@tables
|
||||
|
||||
var $nbinsert = 0; // # of insert done during the import
|
||||
var $nbupdate = 0; // # of update done during the import
|
||||
|
||||
|
||||
/**
|
||||
@ -578,17 +581,18 @@ class ImportCsv extends ModeleImports
|
||||
// Run update request
|
||||
$resql=$this->db->query($sql);
|
||||
if($resql) {
|
||||
echo $sql;
|
||||
echo '<pre>';
|
||||
//print_r($this->db);
|
||||
//print_r($this->db->db);
|
||||
echo '</pre>';
|
||||
echo '<b>'.var_dump($this->db->db->affected_rows).'</b>';
|
||||
if($this->db->db->affected_rows > 0) {
|
||||
$this->nbupdate++;
|
||||
$updatedone = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//print 'E';
|
||||
$this->errors[$error]['lib']=$this->db->lasterror();
|
||||
$this->errors[$error]['type']='SQL';
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
// Update not done, we do insert
|
||||
@ -605,7 +609,6 @@ class ImportCsv extends ModeleImports
|
||||
$sqlend.=', '.$user->id;
|
||||
}
|
||||
$sql = $sqlstart.$sqlend.')';
|
||||
echo $sql;
|
||||
dol_syslog("import_csv.modules", LOG_DEBUG);
|
||||
|
||||
// Run insert request
|
||||
|
||||
@ -1461,7 +1461,11 @@ if ($step == 5 && $datatoimport)
|
||||
$db->rollback(); // We force rollback because this was just a simulation.
|
||||
|
||||
// Show OK
|
||||
if (! count($arrayoferrors) && ! count($arrayofwarnings)) print img_picto($langs->trans("OK"),'tick').' <b>'.$langs->trans("NoError").'</b><br><br>';
|
||||
if (! count($arrayoferrors) && ! count($arrayofwarnings)) {
|
||||
print img_picto($langs->trans("OK"),'tick').' <b>'.$langs->trans("NoError").'</b><br>';
|
||||
print $langs->trans("NbInsert", $obj->nbinsert).'<br>';
|
||||
print $langs->trans("NbUpdate", $obj->nbupdate).'<br><br>';
|
||||
}
|
||||
else print $langs->trans("NbOfLinesOK",$nbok).'</b><br><br>';
|
||||
|
||||
// Show Errors
|
||||
@ -1768,7 +1772,7 @@ if ($step == 6 && $datatoimport)
|
||||
if ($endatlinenb && ($sourcelinenb > $endatlinenb)) continue;
|
||||
|
||||
// Run import
|
||||
$result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid);
|
||||
$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->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings;
|
||||
|
||||
@ -122,3 +122,7 @@ SelectFilterFields=If you want to filter on some values, just input values here.
|
||||
FilteredFields=Filtered fields
|
||||
FilteredFieldsValues=Value for filter
|
||||
FormatControlRule=Format control rule
|
||||
## imports updates
|
||||
KeysToUseForUpdates=Key to use for updating data
|
||||
NbInsert=Number of inserted lines: %s
|
||||
NbUpdate=Number of updated lines: %s
|
||||
Loading…
Reference in New Issue
Block a user