NEW add parent category id or label in import category module

This commit is contained in:
VESSILLER 2019-10-09 16:00:14 +02:00
parent 16f44b0963
commit d77f7556d8
3 changed files with 27 additions and 5 deletions

View File

@ -459,10 +459,14 @@ class ImportCsv extends ModeleImports
$error++;
}*/
$param_array = array('', $newval, 0, $arrayrecord[0]['val']); // Param to fetch parent from account, in chart.
} elseif ($class == 'Categorie') {
if ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel') {
$param_array = array('', $newval, $arrayrecord[1]['val']);
}
}
call_user_func_array(array($classinstance, $method), $param_array);
// If not found, try the fetch from label
if (! ($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel')
if (! ($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' && $class!='Categorie')
{
$param_array = array('', '', $newval);
call_user_func_array(array($classinstance, $method), $param_array);

View File

@ -486,10 +486,14 @@ class ImportXlsx extends ModeleImports
$error++;
}*/
$param_array = array('', $newval, 0, $arrayrecord[0]['val']); // Param to fetch parent from account, in chart.
} elseif ($class == 'Categorie') {
if ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel') {
$param_array = array('', $newval, $arrayrecord[1]['val']);
}
}
call_user_func_array(array($classinstance, $method), $param_array);
// If not found, try the fetch from label
if (! ($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel')
if (! ($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' && $class!='Categorie')
{
$param_array = array('', '', $newval);
call_user_func_array(array($classinstance, $method), $param_array);

View File

@ -406,15 +406,29 @@ class modCategorie extends DolibarrModules
$this->import_icon[$r]=$this->picto;
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r]=array('ca'=>MAIN_DB_PREFIX.'categorie');
$this->import_fields_array[$r]=array('ca.label'=>"Label*",'ca.type'=>"Type*",'ca.description'=>"Description");
$this->import_fields_array[$r]=array(
'ca.label'=>"Label*",'ca.type'=>"Type*",'ca.description'=>"Description",
'ca.fk_parent' => 'Parent'
);
$this->import_regex_array[$r]=array('ca.type'=>'^[0|1|2|3]');
$this->import_convertvalue_array[$r] = array(
'ca.fk_parent' => array(
'rule' => 'fetchidfromcodeorlabel',
'classfile' => '/categories/class/categorie.class.php',
'class' => 'Categorie',
'method' => 'fetch',
'element' => 'category'
)
);
$typeexample="";
if ($conf->product->enabled) { $typeexample.=($typeexample?"/":"")."0=Product"; }
if ($conf->fournisseur->enabled) { $typeexample.=($typeexample?"/":"")."1=Supplier"; }
if ($conf->societe->enabled) { $typeexample.=($typeexample?"/":"")."2=Customer-Prospect"; }
if ($conf->adherent->enabled) { $typeexample.=($typeexample?"/":"")."3=Member"; }
$this->import_examplevalues_array[$r]=array('ca.label'=>"Supplier Category",'ca.type'=>$typeexample,'ca.description'=>"Imported category");
$this->import_examplevalues_array[$r] = array(
'ca.label'=>"Supplier Category",'ca.type'=>$typeexample,'ca.description'=>"Imported category",
'ca.fk_parent' => '0'
);
if (! empty($conf->product->enabled))
{