Clean code
This commit is contained in:
parent
279a8c9df5
commit
2b7797fa75
@ -613,18 +613,7 @@ class ImportCsv extends ModeleImports
|
|||||||
}
|
}
|
||||||
$classinstance = new $class($this->db);
|
$classinstance = new $class($this->db);
|
||||||
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
|
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
|
||||||
if ($res < 0) {
|
$newval = $res; // We get new value computed.
|
||||||
if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) {
|
|
||||||
$this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
|
|
||||||
} else {
|
|
||||||
$this->errors[$error]['lib'] = 'ErrorFieldValueNotIn';
|
|
||||||
}
|
|
||||||
$this->errors[$error]['type'] = 'FOREIGNKEY';
|
|
||||||
$errorforthistable++;
|
|
||||||
$error++;
|
|
||||||
} else {
|
|
||||||
$newval = $arrayrecord[($key - 1)]['val']; //We get new value computed.
|
|
||||||
}
|
|
||||||
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') {
|
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') {
|
||||||
$newval = price2num($newval);
|
$newval = price2num($newval);
|
||||||
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') {
|
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') {
|
||||||
@ -751,14 +740,9 @@ class ImportCsv extends ModeleImports
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$classinstance = new $class($this->db);
|
$classinstance = new $class($this->db);
|
||||||
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $fieldname, &$listfields, &$listvalues));
|
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $fieldname));
|
||||||
if ($res < 0) {
|
$listfields[] = $fieldname;
|
||||||
if (!empty($objimport->array_import_convertvalue[0][$fieldname]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, end($listvalues), 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$fieldname]['dict']));
|
$listvalues[] = $res;
|
||||||
else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn';
|
|
||||||
$this->errors[$error]['type'] = 'FOREIGNKEY';
|
|
||||||
$errorforthistable++;
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -654,18 +654,7 @@ class ImportXlsx extends ModeleImports
|
|||||||
}
|
}
|
||||||
$classinstance = new $class($this->db);
|
$classinstance = new $class($this->db);
|
||||||
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
|
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
|
||||||
if ($res < 0) {
|
$newval = $res; // We get new value computed.
|
||||||
if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) {
|
|
||||||
$this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
|
|
||||||
} else {
|
|
||||||
$this->errors[$error]['lib'] = 'ErrorFieldValueNotIn';
|
|
||||||
}
|
|
||||||
$this->errors[$error]['type'] = 'FOREIGNKEY';
|
|
||||||
$errorforthistable++;
|
|
||||||
$error++;
|
|
||||||
} else {
|
|
||||||
$newval = $arrayrecord[($key)]['val']; //We get new value computed.
|
|
||||||
}
|
|
||||||
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') {
|
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') {
|
||||||
$newval = price2num($newval);
|
$newval = price2num($newval);
|
||||||
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') {
|
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') {
|
||||||
@ -793,13 +782,8 @@ class ImportXlsx extends ModeleImports
|
|||||||
}
|
}
|
||||||
$classinstance = new $class($this->db);
|
$classinstance = new $class($this->db);
|
||||||
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $fieldname, &$listfields, &$listvalues));
|
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $fieldname, &$listfields, &$listvalues));
|
||||||
if ($res < 0) {
|
$listfields[] = $fieldname;
|
||||||
if (!empty($objimport->array_import_convertvalue[0][$fieldname]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, end($listvalues), 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$fieldname]['dict']));
|
$listvalues[] = $res;
|
||||||
else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn';
|
|
||||||
$this->errors[$error]['type'] = 'FOREIGNKEY';
|
|
||||||
$errorforthistable++;
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user