Skip to content
Snippets Groups Projects
Commit d3e951e1 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Merge remote-tracking branch 'origin/3.4' into 3.5

parents 212deb9e 9cd7f68a
Branches
Tags
No related merge requests found
...@@ -250,7 +250,7 @@ class ImportCsv extends ModeleImports ...@@ -250,7 +250,7 @@ class ImportCsv extends ModeleImports
/** /**
* Return array of next record in input file. * Return array of next record in input file.
* *
* @return Array Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string) * @return Array Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string)
*/ */
function import_read_record() function import_read_record()
{ {
...@@ -383,7 +383,7 @@ class ImportCsv extends ModeleImports ...@@ -383,7 +383,7 @@ class ImportCsv extends ModeleImports
{ {
// Set $newval with value to insert and set $listvalues with sql request part for insert // Set $newval with value to insert and set $listvalues with sql request part for insert
$newval=''; $newval='';
if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val']; // If type of field is not null or '' but string if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value
// Make some tests on $newval // Make some tests on $newval
...@@ -447,6 +447,7 @@ class ImportCsv extends ModeleImports ...@@ -447,6 +447,7 @@ class ImportCsv extends ModeleImports
{ {
$this->thirpartyobject->get_codeclient(0,0); $this->thirpartyobject->get_codeclient(0,0);
$newval=$this->thirpartyobject->code_client; $newval=$this->thirpartyobject->code_client;
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
//print 'code_client='.$newval; //print 'code_client='.$newval;
} }
} }
...@@ -456,6 +457,7 @@ class ImportCsv extends ModeleImports ...@@ -456,6 +457,7 @@ class ImportCsv extends ModeleImports
{ {
$newval=$this->thirpartyobject->get_codefournisseur(0,1); $newval=$this->thirpartyobject->get_codefournisseur(0,1);
$newval=$this->thirpartyobject->code_fournisseur; $newval=$this->thirpartyobject->code_fournisseur;
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
//print 'code_fournisseur='.$newval; //print 'code_fournisseur='.$newval;
} }
} }
...@@ -465,6 +467,7 @@ class ImportCsv extends ModeleImports ...@@ -465,6 +467,7 @@ class ImportCsv extends ModeleImports
{ {
$this->thirpartyobject->get_codecompta('customer'); $this->thirpartyobject->get_codecompta('customer');
$newval=$this->thirpartyobject->code_compta; $newval=$this->thirpartyobject->code_compta;
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
//print 'code_compta='.$newval; //print 'code_compta='.$newval;
} }
} }
...@@ -474,6 +477,7 @@ class ImportCsv extends ModeleImports ...@@ -474,6 +477,7 @@ class ImportCsv extends ModeleImports
{ {
$this->thirpartyobject->get_codecompta('supplier'); $this->thirpartyobject->get_codecompta('supplier');
$newval=$this->thirpartyobject->code_compta_fournisseur; $newval=$this->thirpartyobject->code_compta_fournisseur;
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
//print 'code_compta_fournisseur='.$newval; //print 'code_compta_fournisseur='.$newval;
} }
} }
...@@ -540,6 +544,7 @@ class ImportCsv extends ModeleImports ...@@ -540,6 +544,7 @@ class ImportCsv extends ModeleImports
if ($listfields) { $listfields.=', '; $listvalues.=', '; } if ($listfields) { $listfields.=', '; $listvalues.=', '; }
$listfields.=$fieldname; $listfields.=$fieldname;
// Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert
if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues.=($newval=='0'?$newval:"null"); if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues.=($newval=='0'?$newval:"null");
elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues.="''"; elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues.="''";
else $listvalues.="'".$this->db->escape($newval)."'"; else $listvalues.="'".$this->db->escape($newval)."'";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment