class ExportCsv extends ModeleExports (View source)

Class to build export files with format CSV

Properties

string $name from  CommonDocGenerator
string $version

Dolibarr version of the loaded document

string $error from  ModeleExports
string[] $errors from  CommonDocGenerator
string[] $warnings from  CommonDocGenerator
protected DoliDB $db from  CommonDocGenerator
ExtraFields $extrafieldsCache from  CommonDocGenerator
int $update_main_doc_field from  CommonDocGenerator
string $scandir from  CommonDocGenerator
string $description from  CommonDocGenerator
array{0: float, 1: float} $format from  CommonDocGenerator
string $type from  CommonDocGenerator
float $page_hauteur from  CommonDocGenerator
float $page_largeur from  CommonDocGenerator
float $marge_gauche from  CommonDocGenerator
float $marge_droite from  CommonDocGenerator
float $marge_haute from  CommonDocGenerator
float $marge_basse from  CommonDocGenerator
int $corner_radius from  CommonDocGenerator
$option_logo from  CommonDocGenerator
int<0, 1> $option_tva from  CommonDocGenerator
int<0, 1> $option_multilang from  CommonDocGenerator
int<0, 1> $option_freetext from  CommonDocGenerator
int<0, 1> $option_draft_watermark from  CommonDocGenerator
string $watermark from  CommonDocGenerator
int<0, 1> $option_modereg from  CommonDocGenerator
int<0, 1> $option_condreg from  CommonDocGenerator
int<0, 1> $option_escompte from  CommonDocGenerator
int<0, 1> $option_credit_note from  CommonDocGenerator
array<string, float> $tva from  CommonDocGenerator
array<string, array{amount: float}> $tva_array from  CommonDocGenerator
array<int, array<string, float>> $localtax1

Local tax rates Array[tax_type][tax_rate]

from  CommonDocGenerator
array<int, array<string, float>> $localtax2

Local tax rates Array[tax_type][tax_rate]

from  CommonDocGenerator
int $tabTitleHeight from  CommonDocGenerator
array{align?: "R"|"C"|"L", padding?: array<float|int>} $defaultTitlesFieldsStyle from  CommonDocGenerator
array{align?: "R"|"C"|"L", padding?: array<float|int>} $defaultContentsFieldsStyle from  CommonDocGenerator
Societe $emetteur from  CommonDocGenerator
array{0: int, 1: int} $phpmin from  CommonDocGenerator
array<string, array{rank: int, width: float|false, status: bool|int<0, 1>, border-left?: bool, title: array{textkey: string, label?: string, align?: string, padding?: array{0: float, 1: float, 2: float, 3: float}}, content?: array{align?: string, padding?: array{0: float, 1: float, 2: float, 3: float}}}> $cols from  CommonDocGenerator
array<string, array{page: int, y: float|int}> $afterColsLinePositions from  CommonDocGenerator
array{fullpath: string} $result from  CommonDocGenerator
float $posxlabel from  CommonDocGenerator
float $posxup from  CommonDocGenerator
float $posxref from  CommonDocGenerator
float $posxpicture from  CommonDocGenerator
float $posxdesc from  CommonDocGenerator
float $posxqty from  CommonDocGenerator
float $posxpuht from  CommonDocGenerator
float $posxtva from  CommonDocGenerator
float|int $posxtotalht from  CommonDocGenerator
float $postotalht from  CommonDocGenerator
float $posxunit from  CommonDocGenerator
float $posxdiscount from  CommonDocGenerator
float $posxworkload from  CommonDocGenerator
float $posxtimespent from  CommonDocGenerator
float $posxprogress from  CommonDocGenerator
bool $atleastonephoto from  CommonDocGenerator
int<0, 1> $atleastoneratenotnull from  CommonDocGenerator
bool|int<0, 1> $atleastonediscount from  CommonDocGenerator
string $id from  ModeleExports
array<string, string> $driverlabel from  ModeleExports
array<string, string> $driverdesc from  ModeleExports
array<string, string> $driverversion from  ModeleExports
array<string, string> $liblabel from  ModeleExports
array<string, string> $libversion from  ModeleExports
string $picto from  ModeleExports
array<string, string> $pictos from  ModeleExports
string $desc from  ModeleExports
string $escape from  ModeleExports
string $enclosure from  ModeleExports
string $separator
int $col from  ModeleExports
int<0, 1> $disabled from  ModeleExports
string $label
string $extension
string $label_lib
string $version_lib
false|resource $handle

Methods

__construct($db)

Constructor

array<string, float|string>
get_substitutionarray_user(User $user, Translate $outputlangs)

Define array with couple substitution key => substitution value

array<string, float|string>
getSubstitutionarrayMember(Adherent $member, Translate $outputlangs)

Define array with couple substitution key => substitution value

array<string, mixed>
get_substitutionarray_mysoc(Societe $mysoc, Translate $outputlangs)

Define array with couple substitution key => substitution value

array<string, mixed>
get_substitutionarray_thirdparty(Societe $object, Translate $outputlangs, string $array_key = 'company')

Define array with couple substitution key => substitution value For example {company_name}, {company_name_alias}

array<string, mixed>
get_substitutionarray_contact(Contact $object, Translate $outputlangs, string $array_key = 'object')

Define array with couple substitution key => substitution value

array<string, mixed>
get_substitutionarray_other(Translate $outputlangs)

Define array with couple substitution key => substitution value

array<string, mixed>
get_substitutionarray_object(CommonObject $object, Translate $outputlangs, string $array_key = 'object')

Define array with couple substitution key => substitution value Note that vars into substitutions array are formatted.

get_substitutionarray_lines(CommonObjectLine $line, Translate $outputlangs, $linenumber = 0)

Define array with couple substitution key => substitution value Note that vars into substitutions array are formatted.

array<string, mixed>
get_substitutionarray_shipment(Expedition $object, Translate $outputlangs, string $array_key = 'object')

Define array with couple substitution key => substitution value Note that vars into substitutions array are formatted.

array<string, mixed>
get_substitutionarray_each_var_object(CommonObject|float|int|string>|CommonObject $object, Translate $outputlangs, bool|int $recursive = 1)

Define array with couple substitution key => substitution value

array<string, float|string>
fill_substitutionarray_with_extrafields(CommonObject $object, array<string, float|string> $array_to_fill, $extrafields, $array_key, $outputlangs)

Fill array with couple extrafield key => extrafield value Note that vars into substitutions array are formatted.

void
printRect(TCPDI|TCPDF $pdf, float $x, float $y, float $l, float $h, int<-1, 1> $hidetop = 0, int<0, 1> $hidebottom = 0)

Rect pdf

void
printRoundedRect(TCPDF $pdf, float $x, float $y, float $w, float $h, float $r, int<-1, 1> $hidetop = 0, int $hidebottom = 0, string $style = 'D')

Print a rounded rectangle on the PDF

false|array{page: int, y: float|int, col: string}
getMaxAfterColsLinePositionsData()

Get position in PDF after col display

void
resetAfterColsLinePositionsData(float $y, int $pageNumb)

Used for reset afterColsLinePositions var in start of a new pdf draw line loop

void
setAfterColsLinePositionsData(string $colId, float $y, int $pageNumb)

Used for to set afterColsLinePositions var in a pdf draw line loop

columnSort($a, array{rank?: int} $b)

uasort callback function to Sort columns fields

prepareArrayColumnField($object, Translate $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)

Prepare Array Column Field

float
getColumnContentWidth($colKey)

get column content width from column key

float
getColumnContentXStart($colKey)

get column content X (abscissa) left position from column key

int
getColumnRank($colKey)

get column position rank from column key

insertNewColumnDef($newColKey, array{rank?: int} $defArray, $targetCol = '', $insertAfterTarget = false)

get column position rank from column key

printStdColumnContent(TCPDI|TCPDF $pdf, $curY, $colKey, $columnText = '')

print standard column content

printColDescContent(TCPDI|TCPDF $pdf, $curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)

print description column content

getExtrafieldContent($object, string $extrafieldKey, $outputlangs = null)

get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note block

getExtrafieldsInHtml($object, Translate $outputlangs, $params = array())

display extrafields columns content

bool
getColumnStatus($colKey)

get column status from column key

float
pdfTabTitles(TCPDI|TCPDF $pdf, float $tab_top, float $tab_height, Translate $outputlangs, int $hidetop = 0)

Print standard column content

defineColumnExtrafield($object, Translate $outputlangs, $hidedetails = 0)

Define Array Column Field for extrafields

defineColumnField($object, Translate $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)

Define Array Column Field into $this->cols This method must be implemented by the module that generate the document with its own columns.

listOfAvailableExportFormat($db, int $maxfilenamelength = 0)

Load into memory list of available export format

string
getPictoForKey($key)

Return picto of export driver

string
getDriverLabelForKey($key)

Return label of driver export

string
getDriverDescForKey($key)

Renvoi le descriptif d'un driver export

string
getDriverVersionForKey($key)

Renvoi version d'un driver export

string
getLibLabelForKey($key)

Renvoi label of driver lib

string
getLibVersionForKey($key)

Return version of driver lib

write_record($array_selected_sorted, resource|object $objp, $outputlangs, $array_types)

Output record line into file

string
getDriverLabel()

getDriverLabel

string
getDriverDesc()

getDriverDesc

string
getDriverVersion()

getDriverVersion

string
getLibLabel()

getLibLabel

string
getLibVersion()

getLibVersion

string
getDriverExtension()

getDriverExtension

int
open_file($file, Translate $outputlangs)

Open output file

int
write_header($outputlangs)

Output header into file

write_title($array_export_fields_label, array<string, string> $array_selected_sorted, $outputlangs, $array_types)

Output title line into file

int
write_footer($outputlangs)

Output footer into file

close_file()

Close file handle

string
getDriverId()

getDriverId

Details

__construct($db)

Constructor

@param DoliDB $db Database handler

Parameters

$db

array<string, float|string> get_substitutionarray_user(User $user, Translate $outputlangs)

Define array with couple substitution key => substitution value

Parameters

User $user User
Translate $outputlangs

Language object for output

Return Value

array<string, float|string>

Array of substitution key->code

array<string, float|string> getSubstitutionarrayMember(Adherent $member, Translate $outputlangs)

Define array with couple substitution key => substitution value

Parameters

Adherent $member Member
Translate $outputlangs

Language object for output

Return Value

array<string, float|string>

Array of substitution key->code

array<string, mixed> get_substitutionarray_mysoc(Societe $mysoc, Translate $outputlangs)

Define array with couple substitution key => substitution value

Parameters

Societe $mysoc

Object thirdparty

Translate $outputlangs

Language object for output

Return Value

array<string, mixed>

Array of substitution key->code

array<string, mixed> get_substitutionarray_thirdparty(Societe $object, Translate $outputlangs, string $array_key = 'company')

Define array with couple substitution key => substitution value For example {company_name}, {company_name_alias}

Parameters

Societe $object Object
Translate $outputlangs

Language object for output

string $array_key

Name of the key for return array

Return Value

array<string, mixed>

Array of substitution key->code

array<string, mixed> get_substitutionarray_contact(Contact $object, Translate $outputlangs, string $array_key = 'object')

Define array with couple substitution key => substitution value

Parameters

Contact $object contact
Translate $outputlangs

object for output

string $array_key

Name of the key for return array

Return Value

array<string, mixed>

Array of substitution key->code

array<string, mixed> get_substitutionarray_other(Translate $outputlangs)

Define array with couple substitution key => substitution value

Parameters

Translate $outputlangs

Language object for output

Return Value

array<string, mixed>

Array of substitution key->code

array<string, mixed> get_substitutionarray_object(CommonObject $object, Translate $outputlangs, string $array_key = 'object')

Define array with couple substitution key => substitution value Note that vars into substitutions array are formatted.

Parameters

CommonObject $object

Main object to use as data source

Translate $outputlangs

Lang object to use for output

string $array_key

Name of the key for return array

Return Value

array<string, mixed>

Array of substitution

get_substitutionarray_lines(CommonObjectLine $line, Translate $outputlangs, $linenumber = 0)

Define array with couple substitution key => substitution value Note that vars into substitutions array are formatted.

Parameters

CommonObjectLine $line

Object line

Translate $outputlangs

Translate object to use for output @param int $linenumber The number of the line for the substitution of "object_line_pos" @return array<string,mixed> Return a substitution array

$linenumber

array<string, mixed> get_substitutionarray_shipment(Expedition $object, Translate $outputlangs, string $array_key = 'object')

Define array with couple substitution key => substitution value Note that vars into substitutions array are formatted.

Parameters

Expedition $object

Main object to use as data source

Translate $outputlangs

Lang object to use for output

string $array_key

Name of the key for return array

Return Value

array<string, mixed>

Array of substitution

array<string, mixed> get_substitutionarray_each_var_object(CommonObject|float|int|string>|CommonObject $object, Translate $outputlangs, bool|int $recursive = 1)

Define array with couple substitution key => substitution value

Parameters

CommonObject|float|int|string>|CommonObject $object

Dolibarr Object

Translate $outputlangs

Language object for output

bool|int $recursive

Want to fetch child array or child object.

Return Value

array<string, mixed>

Array of substitution key->code

array<string, float|string> fill_substitutionarray_with_extrafields(CommonObject $object, array<string, float|string> $array_to_fill, $extrafields, $array_key, $outputlangs)

Fill array with couple extrafield key => extrafield value Note that vars into substitutions array are formatted.

Parameters

CommonObject $object

Object with extrafields (must have $object->array_options filled)

array<string, float|string> $array_to_fill

Substitution array @param ExtraFields $extrafields ExtraFields object @param string $array_key Prefix for name of the keys into returned array @param Translate $outputlangs Lang object to use for output

$extrafields
$array_key
$outputlangs

Return Value

array<string, float|string>

Substitution array

void printRect(TCPDI|TCPDF $pdf, float $x, float $y, float $l, float $h, int<-1, 1> $hidetop = 0, int<0, 1> $hidebottom = 0)

Rect pdf

Parameters

TCPDI|TCPDF $pdf

Pdf object

float $x

Abscissa of first point

float $y

Ordinate of first point

float $l ??
float $h ??
int<-1, 1> $hidetop

1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title

int<0, 1> $hidebottom

Hide bottom

Return Value

void

void printRoundedRect(TCPDF $pdf, float $x, float $y, float $w, float $h, float $r, int<-1, 1> $hidetop = 0, int $hidebottom = 0, string $style = 'D')

Print a rounded rectangle on the PDF

Parameters

TCPDF $pdf

Object PDF

float $x

Abscissa of first point

float $y

Ordinate of first point

float $w

Width of the rectangle

float $h

Height of the rectangle

float $r

Corner radius (can be an array for different radii per corner)

int<-1, 1> $hidetop

1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title

int $hidebottom

Hide bottom

string $style

Draw style (e.g. 'D' for draw, 'F' for fill, 'DF' for both)

Return Value

void

false|array{page: int, y: float|int, col: string} getMaxAfterColsLinePositionsData()

Get position in PDF after col display

Return Value

false|array{page: int, y: float|int, col: string}

void resetAfterColsLinePositionsData(float $y, int $pageNumb)

Used for reset afterColsLinePositions var in start of a new pdf draw line loop

Parameters

float $y

the new $y position usually get by TCPDF::GetY()

int $pageNumb

the page number to reset at

Return Value

void

void setAfterColsLinePositionsData(string $colId, float $y, int $pageNumb)

Used for to set afterColsLinePositions var in a pdf draw line loop

Parameters

string $colId

the column id used as key in $this->cols or an unique id code like startLine or separateLine ....

float $y

the $y position usually get by TCPDF::GetY() where print data ended

int $pageNumb

the page number where print data ended

Return Value

void

columnSort($a, array{rank?: int} $b)

uasort callback function to Sort columns fields

@param array{rank?:int} $a PDF lines array fields configs

Parameters

$a
array{rank?: int} $b

PDF lines array fields configs @return int<-1,1> Return compare result

prepareArrayColumnField($object, Translate $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)

Prepare Array Column Field

@param  CommonObject    $object             common object

Parameters

$object
Translate $outputlangs

langs @param int<0,1> $hidedetails Do not show line details @param int<0,1> $hidedesc Do not show desc @param int<0,1> $hideref Do not show ref @return void

$hidedetails
$hidedesc
$hideref

float getColumnContentWidth($colKey)

get column content width from column key

@param string $colKey the column key

Parameters

$colKey

Return Value

float

width in mm

float getColumnContentXStart($colKey)

get column content X (abscissa) left position from column key

@param string $colKey the column key

Parameters

$colKey

Return Value

float

X position in mm

int getColumnRank($colKey)

get column position rank from column key

@param string $colKey the column key

Parameters

$colKey

Return Value

int

rank on success and -1 on error

insertNewColumnDef($newColKey, array{rank?: int} $defArray, $targetCol = '', $insertAfterTarget = false)

get column position rank from column key

@param string $newColKey the new column key

Parameters

$newColKey
array{rank?: int} $defArray

a single column definition array @param string $targetCol target column used to place the new column beside @param bool $insertAfterTarget insert before or after target column ? @return int new rank on success and -1 on error

$targetCol
$insertAfterTarget

printStdColumnContent(TCPDI|TCPDF $pdf, $curY, $colKey, $columnText = '')

print standard column content

Parameters

TCPDI|TCPDF $pdf

Pdf object @param float $curY current Y position @param string $colKey the column key @param string $columnText column text @return int Return integer <0 if KO, >= if OK

$curY
$colKey
$columnText

printColDescContent(TCPDI|TCPDF $pdf, $curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)

print description column content

Parameters

TCPDI|TCPDF $pdf

Pdf object @param float $curY current Y position @param string $colKey the column key @param CommonObject $object CommonObject @param int $i the $object->lines array key @param Translate $outputlangs Output language @param int<0,1> $hideref hide ref @param int<0,1> $hidedesc hide desc @param int<0,1> $issupplierline if object needx supplier product @return void

$curY
$colKey
$object
$i
$outputlangs
$hideref
$hidedesc
$issupplierline

getExtrafieldContent($object, string $extrafieldKey, $outputlangs = null)

get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note block

@param CommonObject $object Common object

Parameters

$object
string $extrafieldKey

The extrafield key @param Translate $outputlangs The output langs (if value is (XXX) we use it to translate it). @return string

$outputlangs

getExtrafieldsInHtml($object, Translate $outputlangs, $params = array())

display extrafields columns content

@param CommonObject|CommonObjectLine $object line of common object

Parameters

$object
Translate $outputlangs

Output language @param array<string,mixed> $params array of additional parameters @return string Html string

$params

bool getColumnStatus($colKey)

get column status from column key

@param string $colKey the column key

Parameters

$colKey

Return Value

bool

true if column on

float pdfTabTitles(TCPDI|TCPDF $pdf, float $tab_top, float $tab_height, Translate $outputlangs, int $hidetop = 0)

Print standard column content

Parameters

TCPDI|TCPDF $pdf

Pdf object

float $tab_top

Tab top position

float $tab_height

Default tab height

Translate $outputlangs

Output language

int $hidetop

Hide top

Return Value

float

Height of col tab titles

defineColumnExtrafield($object, Translate $outputlangs, $hidedetails = 0)

Define Array Column Field for extrafields

@param CommonObject $object common object det

Parameters

$object
Translate $outputlangs

langs @param int<0,1> $hidedetails Do not show line details @return int Return integer <0 if KO, >=0 if OK

$hidedetails

defineColumnField($object, Translate $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)

Define Array Column Field into $this->cols This method must be implemented by the module that generate the document with its own columns.

@param CommonObject $object Common object

Parameters

$object
Translate $outputlangs

Langs @param int<0,1> $hidedetails Do not show line details @param int<0,1> $hidedesc Do not show desc @param int<0,1> $hideref Do not show ref @return void

$hidedetails
$hidedesc
$hideref

listOfAvailableExportFormat($db, int $maxfilenamelength = 0)

Load into memory list of available export format

@param DoliDB $db Database handler

Parameters

$db
int $maxfilenamelength

Max length of value to show @return string[] List of templates (same content as array this->driverlabel)

string getPictoForKey($key)

Return picto of export driver

@param string $key Key of driver

Parameters

$key

Return Value

string

Picto string

string getDriverLabelForKey($key)

Return label of driver export

@param string $key Key of driver

Parameters

$key

Return Value

string Label

string getDriverDescForKey($key)

Renvoi le descriptif d'un driver export

@param string $key Key of driver

Parameters

$key

Return Value

string Description

string getDriverVersionForKey($key)

Renvoi version d'un driver export

@param string $key Key of driver

Parameters

$key

Return Value

string

Driver version

string getLibLabelForKey($key)

Renvoi label of driver lib

@param string $key Key of driver

Parameters

$key

Return Value

string

Label of library

string getLibVersionForKey($key)

Return version of driver lib

@param string $key Key of driver

Parameters

$key

Return Value

string

Version of library

write_record($array_selected_sorted, resource|object $objp, $outputlangs, $array_types)

Output record line into file

@param array<string,string> $array_selected_sorted Array with list of field to export

Parameters

$array_selected_sorted
resource|object $objp

A record from a fetch with all fields from select @param Translate $outputlangs Object lang to translate values @param array<string,string> $array_types Array with types of fields @return int Return integer <0 if KO, >0 if OK

$outputlangs
$array_types

string getDriverLabel()

getDriverLabel

Return Value

string

Return driver label

string getDriverDesc()

getDriverDesc

Return Value

string

string getDriverVersion()

getDriverVersion

Return Value

string

string getLibLabel()

getLibLabel

Return Value

string

string getLibVersion()

getLibVersion

Return Value

string

string getDriverExtension()

getDriverExtension

Return Value

string

int open_file($file, Translate $outputlangs)

Open output file

Parameters

$file
Translate $outputlangs

Output language object

Return Value

int

Return integer <0 if KO, >=0 if OK

int write_header($outputlangs)

Output header into file

@param      Translate   $outputlangs    Output language object

Parameters

$outputlangs

Return Value

int

Return integer <0 if KO, >0 if OK

write_title($array_export_fields_label, array<string, string> $array_selected_sorted, $outputlangs, $array_types)

Output title line into file

@param array<string,string> $array_export_fields_label Array with list of label of fields

Parameters

$array_export_fields_label
array<string, string> $array_selected_sorted

Array with list of field to export @param Translate $outputlangs Object lang to translate values @param array<string,string> $array_types Array with types of fields @return int Return integer <0 if KO, >0 if OK

$outputlangs
$array_types

Output footer into file

@param      Translate   $outputlangs    Output language object

Parameters

$outputlangs

Return Value

int

Return integer <0 if KO, >0 if OK

close_file()

Close file handle

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

string getDriverId()

getDriverId

Return Value

string