class Export (View source)

Class to manage exports

Properties

DoliDB $db
int $id
string[] $array_export_icon
bool[] $array_export_perms
string $error
string $errno
string[] $errors
array<int, string> $array_export_code
string[] $array_export_code_for_sort
DolibarrModules[] $array_export_module
string[] $array_export_label
string[] $array_export_sql_start
string[] $array_export_sql_end
string[] $array_export_sql_order
array<int, array<string, string>> $array_export_fields
array<int, array<string, string>> $array_export_TypeFields
array<int, array<string, string>> $array_export_FilterValue
array<int, array<string, string>> $array_export_entities
array<int, array<string, string>> $array_export_dependencies
array<array<array{rule: string, file: string, classfile: string, class: string, method: string, method_params: string[]}>> $array_export_special
array<array<string, string>> $array_export_examplevalues
array<int, array<string, string>|""> $array_export_help
string $hexa
string $hexafiltervalue
string $datatoexport
string $model_name
int $fk_user
string $sqlusedforexport

Methods

__construct($db)

Constructor

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

Load an exportable dataset

build_sql(int $indice, $array_selected, $array_filterValue)

Build the sql export request.

build_filterQuery($TypeField, string $NameField, $ValueField)

Build the conditional string from filter the query

conditionDate($Field, string $Value, $Sens)

conditionDate

build_filterField($TypeField, string $NameField, $ValueField)

Build an input field used to filter the query

string
genDocFilter($TypeField)

Build an input field used to filter the query

build_file(User $user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '', $separator = '')

Build export file.

int
create($user)

Save an export model in database

int
fetch($id)

Load an export profil from database

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

Delete object in database

void
list_export_model()

Output list all export models --TODO Move this into a class htmlxxx.class.php--

Details

__construct($db)

Constructor

@param DoliDB $db Database handler

Parameters

$db

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

Load an exportable dataset

@param User $user Object user making export

Parameters

$user
string $filter

Load a particular dataset only @return int Return integer <0 if KO, >0 if OK

build_sql(int $indice, $array_selected, $array_filterValue)

Build the sql export request.

Arrays this->array_export_xxx are already loaded for required datatoexport

Parameters

int $indice

Indice of export @param array<string,string> $array_selected Filter fields on array of fields to export @param array<string,string> $array_filterValue Filter records on array of value for fields @return string SQL String. Example "select s.rowid as r_rowid, s.status as s_status from ..."

$array_selected
$array_filterValue

build_filterQuery($TypeField, string $NameField, $ValueField)

Build the conditional string from filter the query

@param string $TypeField Type of Field to filter

Parameters

$TypeField
string $NameField

Name of the field to filter @param string $ValueField Value of the field for filter. Must not be '' @return string SQL string of then field ex : "field='xxx'"

$ValueField

conditionDate($Field, string $Value, $Sens)

conditionDate

@param string $Field Field operand 1

Parameters

$Field
string $Value

Value operand 2 @param string $Sens Comparison operator @return string

$Sens

build_filterField($TypeField, string $NameField, $ValueField)

Build an input field used to filter the query

@param string $TypeField Type of Field to filter. Example: Text, Date, List:c_country:label:rowid, List:c_stcom:label:code, Numeric or Number, Boolean

Parameters

$TypeField
string $NameField

Name of the field to filter @param string $ValueField Initial value of the field to filter @return string html string of the input field ex : ""

$ValueField

string genDocFilter($TypeField)

Build an input field used to filter the query

@param string $TypeField Type of Field to filter

Parameters

$TypeField

Return Value

string

html string of the input field ex : ""

build_file(User $user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '', $separator = '')

Build export file.

File is built into directory $conf->export->dir_temp.'/'.$user->id Arrays this->array_export_xxx are already loaded for required datatoexport

Parameters

User $user

User that export @param string $model Export format @param string $datatoexport Name of dataset to export @param array<string,string> $array_selected Filter on array of fields to export @param array<string,string> $array_filterValue Filter on array of fields with a filter @param string $sqlquery If set, transmit the sql request for select (otherwise, sql request is generated from arrays) @param string $separator separator to fill $objmodel->separator with the new separator @return int Return integer <0 if KO, >0 if OK

$model
$datatoexport
$array_selected
$array_filterValue
$sqlquery
$separator

int create($user)

Save an export 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 export 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 $notrigger 0=launch triggers after, 1=disable triggers

$notrigger

Return Value

int

Return integer <0 if KO, >0 if OK

void list_export_model()

Output list all export models --TODO Move this into a class htmlxxx.class.php--

Return Value

void