class ModeleImports (View source)

Parent class for import file readers

Properties

DoliDB $db
string $datatoimport
string $error
string[]|array<int, array<string, string>> $errors
string[]|array<int, array<string, string>> $warnings
string $id
string $label
string $extension
string $version

Dolibarr version of driver

array{0: int, 1: int} $phpmin

PHP minimal version required by driver

string $label_lib

Label of external lib used by driver

string $version_lib

Version of external lib used by driver

array<string, string> $driverlabel
array<string, string> $driverdesc
array<string, string> $driverversion
array<string, string> $drivererror
array<string, string> $liblabel
array<string, string> $libversion
string $charset
array<string, string>|string $picto
string $desc
string $escape
string $enclosure
Societe $thirdpartyobject
static array<string, string> $mapTableToElement

Methods

__construct()

Constructor

string
getDriverId()

getDriverId

string
getDriverLabel()

getDriverLabel

string
getDriverDesc()

getDriverDesc

string
getDriverExtension()

getDriverExtension

string
getDriverVersion()

getDriverVersion

string
getLibLabel()

getDriverLabel

string
getLibVersion()

getLibVersion

listOfAvailableImportFormat($db, int $maxfilenamelength = 0)

Load into memory list of available import format

string
getPictoForKey(string $key)

Return picto of import driver

string
getDriverLabelForKey(string $key)

Return label of driver import

string
getDriverDescForKey(string $key)

Return description of import drivervoi la description d'un driver import

string
getDriverVersionForKey(string $key)

Renvoi version d'un driver import

string
getLibLabelForKey(string $key)

Renvoi libelle de librairie externe du driver

string
getLibVersionForKey(string $key)

Renvoi version de librairie externe du driver

string
getElementFromTableWithPrefix(string $tableNameWithPrefix)

Get element from table name with prefix

import_open_file(string $file)

Open input file

import_get_nb_of_lines(string $file)

Return nb of records. File must be closed.

import_read_header()

Input header line from file

import_read_record()

Return array of next record in input file.

import_close_file()

Close file handle

int
import_insert(array<string, array{val: mixed, type: int<-1, 1>}>|bool $arrayrecord, array<int|string, string> $array_match_file_to_database, object $objimport, int $maxfields, string $importid, string[] $updatekeys)

Insert a record into database

string
write_header_example($outputlangs)

Output header of an example file for this format

write_title_example($outputlangs, string[] $headerlinefields)

Output title line of an example file for this format

write_record_example($outputlangs, mixed[] $contentlinevalues)

Output record of an example file for this format

string
write_footer_example($outputlangs)

Output footer of an example file for this format

Details

__construct()

Constructor

string getDriverId()

getDriverId

Return Value

string

Code of driver

string getDriverLabel()

getDriverLabel

Return Value

string Label

string getDriverDesc()

getDriverDesc

Return Value

string Description

string getDriverExtension()

getDriverExtension

Return Value

string

Driver suffix

string getDriverVersion()

getDriverVersion

Return Value

string

Driver version

string getLibLabel()

getDriverLabel

Return Value

string

Label of external lib

string getLibVersion()

getLibVersion

Return Value

string

Version of external lib

listOfAvailableImportFormat($db, int $maxfilenamelength = 0)

Load into memory list of available import format

@param DoliDB $db Database handler

Parameters

$db
int $maxfilenamelength

Max length of value to show @return array<int,string> List of templates

string getPictoForKey(string $key)

Return picto of import driver

Parameters

string $key Key

Return Value

string

string getDriverLabelForKey(string $key)

Return label of driver import

Parameters

string $key Key

Return Value

string

string getDriverDescForKey(string $key)

Return description of import drivervoi la description d'un driver import

Parameters

string $key Key

Return Value

string

string getDriverVersionForKey(string $key)

Renvoi version d'un driver import

Parameters

string $key Key

Return Value

string

string getLibLabelForKey(string $key)

Renvoi libelle de librairie externe du driver

Parameters

string $key Key

Return Value

string

string getLibVersionForKey(string $key)

Renvoi version de librairie externe du driver

Parameters

string $key Key

Return Value

string

string getElementFromTableWithPrefix(string $tableNameWithPrefix)

Get element from table name with prefix

Parameters

string $tableNameWithPrefix

Table name with prefix

Return Value

string

Element name or table element as default

import_open_file(string $file)

Open input file

Parameters

string $file

Path of filename @return int Return integer <0 if KO, >=0 if OK

import_get_nb_of_lines(string $file)

Return nb of records. File must be closed.

Parameters

string $file

Path of filename @return int Return integer <0 if KO, >=0 if OK

import_read_header()

Input header line from file

@return int Return integer <0 if KO, >=0 if OK

import_read_record()

Return array of next record in input file.

@return array<string,array{val:mixed,type:int<-1,1>}>|boolean Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string)

import_close_file()

Close file handle

@return int

int import_insert(array<string, array{val: mixed, type: int<-1, 1>}>|bool $arrayrecord, array<int|string, string> $array_match_file_to_database, object $objimport, int $maxfields, string $importid, string[] $updatekeys)

Insert a record into database

Parameters

array<string, array{val: mixed, type: int<-1, 1>}>|bool $arrayrecord

Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...

array<int|string, string> $array_match_file_to_database

Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]...

object $objimport

Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...)

int $maxfields

Max number of fields to use

string $importid

Import key

string[] $updatekeys

Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor.

Return Value

int

Return integer <0 if KO, >0 if OK

string write_header_example($outputlangs)

Output header of an example file for this format

@param  Translate   $outputlangs        Output language

Parameters

$outputlangs

Return Value

string

Empty string

write_title_example($outputlangs, string[] $headerlinefields)

Output title line of an example file for this format

@param  Translate   $outputlangs        Output language

Parameters

$outputlangs
string[] $headerlinefields

Array of fields name @return string String output

write_record_example($outputlangs, mixed[] $contentlinevalues)

Output record of an example file for this format

@param  Translate   $outputlangs        Output language

Parameters

$outputlangs
mixed[] $contentlinevalues

Array of lines @return string Empty string

Output footer of an example file for this format

@param  Translate   $outputlangs        Output language

Parameters

$outputlangs

Return Value

string

String output