class Import (View source)

Class to manage imports

Properties

DoliDB $db
string $error
string[] $errors
string $errno
DolibarrModules}> $array_import_module
int[] $array_import_perms
string[] $array_import_icon
string[] $array_import_code
string[] $array_import_label
string[][] $array_import_tables
array<""|array<string, string>> $array_import_tables_creator
array<array<string, string>> $array_import_fields
array<""|array<string, string>> $array_import_fieldshidden
array<""|array<string, string>> $array_import_entities
array<""|array<string, string>> $array_import_regex
array<""|array<string, string>> $array_import_updatekeys
array<""|array<string, string>> $array_import_preselected_updatekeys
array<""|array<string, string>> $array_import_examplevalues
array<""|array<array{rule: string, file: string, class: string, method: string}>> $array_import_convertvalue
array<""|array<string, string>> $array_import_run_sql_after
int $id
string $hexa
string $datatoimport
string $model_name
int $fk_user

Methods

__construct($db)

Constructor

load_arrays($user, string $filter = '')

Load description int this->array_import_module, this->array_import_fields, ... of an importable dataset

build_example_file(string $model, $headerlinefields, $contentlinevalues, $datatoimport)

Build an import example file.

int
create($user)

Save an import model in database

int
fetch($id)

Load an import profil from database

int
delete(User $user, $notrigger = 0)

Delete object in database

Details

__construct($db)

Constructor

@param DoliDB $db Database handler

Parameters

$db

load_arrays($user, string $filter = '')

Load description int this->array_import_module, this->array_import_fields, ... of an importable dataset

@param User $user Object user making import

Parameters

$user
string $filter

Load a particular dataset only. Index will start to 0. @return int Return integer <0 if KO, >0 if OK

build_example_file(string $model, $headerlinefields, $contentlinevalues, $datatoimport)

Build an import example file.

Arrays this->array_export_xxx are already loaded for required datatoexport

Parameters

string $model

Name of import engine ('csv', ...) @param string[] $headerlinefields Array of values for first line of example file @param string[] $contentlinevalues Array of values for content line of example file @param string $datatoimport Dataset to import @return string Return integer <0 if KO, >0 if OK

$headerlinefields
$contentlinevalues
$datatoimport

int create($user)

Save an import model in database

@param User $user Object user that save

Parameters

$user

Return Value

int

Return integer <0 if KO, >0 if OK

int fetch($id)

Load an import profil from database

@param int $id Id of profil to load

Parameters

$id

Return Value

int

Return integer <0 if KO, >0 if OK

int delete(User $user, $notrigger = 0)

Delete object in database

Parameters

User $user

User that delete @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers

$notrigger

Return Value

int

Return integer <0 if KO, >0 if OK