class Facture extends CommonInvoice (View source)

Class to manage invoices

Traits

Trait CommonSubtotal

Trait for incoterm classes

Class for handling deprecated properties and methods

Parent class of all other business classes (invoices, contracts, proposals, orders, ...)

Constants

TYPE_STANDARD

Standard invoice

TYPE_REPLACEMENT

Replacement invoice

TYPE_CREDIT_NOTE

Credit note invoice

TYPE_DEPOSIT

Deposit invoice

TYPE_PROFORMA

Proforma invoice (should not be used. a proforma is an order)

TYPE_SITUATION

Situation invoice

STATUS_DRAFT

Draft status

STATUS_VALIDATED

Validated (need to be paid)

STATUS_CLOSED

Classified paid.

If paid partially, $this->close_code can be:

  • CLOSECODE_DISCOUNTVAT
  • CLOSECODE_BADDEBT If paid completely, this->close_code will be null

STATUS_ABANDONED

Classified abandoned and no payment done.

$this->close_code can be:

  • CLOSECODE_BADDEBT
  • CLOSECODE_ABANDONED
  • CLOSECODE_REPLACED

CLOSECODE_DISCOUNTVAT

CLOSECODE_BADDEBT

CLOSECODE_BANKCHARGE

CLOSECODE_WITHHOLDINGTAX

CLOSECODE_OTHER

CLOSECODE_ABANDONED

CLOSECODE_REPLACED

Properties

DoliDB $db from  CommonTrigger
$error from  CommonTrigger
string[] $errors from  CommonTrigger
string $TRIGGER_PREFIX from  CommonTrigger
string $module from  CommonObject
int $id from  CommonIncoterm
?int $entity from  CommonObject
string $errorhidden from  CommonObject
string[] $warnings from  CommonObject
string $element
string $fk_element
string $element_for_permission from  CommonObject
string $table_element
?string $table_rowid from  CommonObject
string $table_element_line
int<0, 1>|string|null $ismultientitymanaged from  CommonObject
?string $import_key from  CommonObject
array<string, mixed> $array_options from  CommonObject
array<string, array{type: string, label: string, langfile?: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int<-6, 6>|string, alwayseditable?: int<0, 1>|string, noteditable?: int<0, 1>, default?: string, index?: int, foreignkey?: string, searchall?: int<0, 1>, isameasure?: int<0, 1>, css?: string, cssview?: string, csslist?: string, help?: string, showoncombobox?: int<0, 4>|string, disabled?: int<0, 1>, arrayofkeyval?: array<int|string, string>, autofocusoncreate?: int<0, 1>, comment?: string, copytoclipboard?: int<1, 2>, validate?: int<0, 1>, showonheader?: int<0, 1>, searchmulti?: int<0, 1>}> $fields
array<string, array<string, string>> $array_languages from  CommonObject
array<int, array{parentId: int, source: string, socid: int, id: int, nom: string, civility: string, lastname: string, firstname: string, email: string, login: string, photo: string, statuscontact: int, rowid: int, code: string, libelle: string, status: int, fk_c_type_contact: int}> $contacts_ids from  CommonObject
array<int, array{parentId: int, source: string, socid: int, id: int, nom: string, civility: string, lastname: string, firstname: string, email: string, login: string, photo: string, statuscontact: int, rowid: int, code: string, libelle: string, status: int, fk_c_type_contact: int}> $contacts_ids_internal from  CommonObject
mixed $linked_objects from  CommonObject
array<string, array<int, int>> $linkedObjectsIds from  CommonObject
CommonObject[]> $linkedObjects from  CommonObject
?static $oldcopy from  CommonObject
string $oldref from  CommonObject
protected $table_ref_field {@inheritdoc}
int $restrictiononfksoc

0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user

array<string, mixed> $context from  CommonObject
string $actionmsg from  CommonObject
string $actionmsg2 from  CommonObject
string $canvas from  CommonObject
Project|null $project from  CommonObject
$fk_project from  CommonObject
$fk_projet from  CommonObject
Contact|null $contact from  CommonObject
int $contact_id from  CommonObject
Societe $thirdparty from  CommonObject
User $user from  CommonObject
Product $product from  CommonObject
string $origin_type from  CommonObject
int $origin_id from  CommonObject
CommonObject $origin_object from  CommonObject
CommonObject|string|null deprecated $origin from  CommonObject
?string $ref from  CommonObject
?string $ref_ext from  CommonObject
string $ref_previous from  CommonObject
string $ref_next from  CommonObject
?string $newref from  CommonObject
$statut from  CommonObject
null|int|array<int, string> $status from  CommonObject
string $country from  CommonObject
$country_id from  CommonObject
$country_code from  CommonObject
?string $state from  CommonObject
$state_id from  CommonObject
$state_code from  CommonObject
$region_id from  CommonObject
$region_code from  CommonObject
$region from  CommonObject
int $barcode_type from  CommonObject
$barcode_type_code from  CommonObject
$barcode_type_label from  CommonObject
$barcode_type_coder from  CommonObject
?int $mode_reglement_id from  CommonInvoice
?int $cond_reglement_id from  CommonInvoice
?int $demand_reason_id from  CommonObject
int $transport_mode_id from  CommonObject
protected int|string $depr_cond_reglement from  CommonObject
?int deprecated $fk_delivery_address from  CommonObject
?int $shipping_method_id from  CommonObject
?string $shipping_method from  CommonObject
int $fk_multicurrency from  CommonObject
string|string[] $multicurrency_code from  CommonObject
null|float|float[] $multicurrency_tx from  CommonObject
float $multicurrency_total_ht from  CommonObject
float $multicurrency_total_tva from  CommonObject
float|string $multicurrency_total_localtax1 from  CommonObject
float|string $multicurrency_total_localtax2 from  CommonObject
float $multicurrency_total_ttc from  CommonObject
?string $model_pdf from  CommonObject
string $last_main_doc from  CommonObject
int $fk_bank
?int $fk_account from  CommonObject
?string $note_public from  CommonObject
?string $note_private from  CommonObject
$note from  CommonObject
float $total_ht from  CommonInvoice
float $total_tva from  CommonInvoice
float $total_localtax1 from  CommonInvoice
float $total_localtax2 from  CommonInvoice
float $total_ttc from  CommonInvoice
CommonInvoiceLine[] $lines
string $actiontypecode from  CommonObject
mixed $comments from  CommonObject
?string $name from  CommonObject
?string $lastname from  CommonObject
?string $firstname from  CommonObject
string deprecated $civility_id from  CommonObject
string $civility_code from  CommonObject
int|""|null $date_creation from  CommonObject
int|""|null $date_validation from  CommonObject
int|""|null $date_modification from  CommonObject
int deprecated $tms

Update timestamp record (tms)

from  CommonObject
int|""|null $date_cloture from  CommonObject
int|null $user_creation_id from  CommonObject
int|null $user_validation_id from  CommonObject
int|null $user_closing_id from  CommonObject
int|null $user_modification_id from  CommonObject
int|null deprecated $fk_user_creat from  CommonObject
int deprecated $fk_user_modif
string $next_prev_filter from  CommonObject
int<0, 1> $specimen from  CommonObject
int[] $sendtoid from  CommonObject
$alreadypaid from  CommonObject
float $totalpaid from  CommonInvoice
$totalpaid_multicurrency from  CommonObject
array<int, string> $labelStatus from  CommonObject
array<int, string> $labelStatusShort from  CommonObject
array<string, int|float|string|null> $tpl from  CommonObject
int $showphoto_on_popup from  CommonObject
array{actionscomm?: int, banklines?: int, cheques?: int, contacts?: int, contracts?: int, customers?: int, dolresource?: int, donations?: int, expensereports?: int, holidays?: int, interventions?: int, invoices?: int, members?: int, orders?: int, products?: int, projects?: int, proposals?: int, prospects?: int, services?: int, supplier_invoices?: int, supplier_orders?: int, supplier_proposals?: int, suppliers?: int, tasks?: int, ticket?: int, users?: int} $nb from  CommonObject
int $nbphoto from  CommonObject
string $output from  CommonObject
array<string, string> $extraparams
protected string[]|array<string, string[]|array{parent: string, parentkey: string}> $childtables from  CommonObject
protected string[] $childtablesoncascade from  CommonObject
int $cond_reglement_supplier_id from  CommonObject
float|string $deposit_percent from  CommonObject
int $retained_warranty_fk_cond_reglement
int $warehouse_id from  CommonObject
int<0, 1> $isextrafieldmanaged from  CommonObject
int $fk_incoterms from  CommonIncoterm
string $label_incoterms from  CommonIncoterm
string $location_incoterms from  CommonIncoterm
string $title from  CommonInvoice
int $type from  CommonInvoice
?int $subtype from  CommonInvoice
$fk_soc from  CommonInvoice
int $socid from  CommonInvoice
int<0, 1> deprecated $paye
int $date

Invoice date (date)

from  CommonInvoice
int $date_lim_reglement from  CommonInvoice
string|int $cond_reglement_code from  CommonInvoice
string $cond_reglement_label from  CommonInvoice
string $cond_reglement_doc from  CommonInvoice
string $mode_reglement_code from  CommonInvoice
string $mode_reglement from  CommonInvoice
float|null $revenuestamp from  CommonInvoice
int|float $totaldeposits from  CommonInvoice
int|float $totalcreditnotes from  CommonInvoice
int|float|string $remaintopay from  CommonInvoice
int $nbofopendirectdebitorcredittransfer from  CommonInvoice
int[] $creditnote_ids from  CommonInvoice
int $stripechargedone from  CommonInvoice
int $stripechargeerror from  CommonInvoice
string $payment_reference from  CommonInvoice
int $dispute_status from  CommonInvoice
string $description

Payment description

from  CommonInvoice
$ref_client
int $situation_cycle_ref
string $close_code

! Closing after partial payment: CLOSECODE_DISCOUNTVAT, CLOSECODE_BADDEBT, CLOSECODE_BANKCHARGE, CLOSECODE_OTHER ! Closing when no payment: CLOSECODE_ABANDONED, CLOSECODE_REPLACED

from  CommonInvoice
string $close_note

! Comment if paid without full payment

from  CommonInvoice
string[] $postactionmessages

! Populated by payment modules like Stripe

from  CommonInvoice
static int $PRODUCT_TYPE from  CommonSubtotal
static string[] $TITLE_OPTIONS from  CommonSubtotal
static string[] $SUBTOTAL_OPTIONS from  CommonSubtotal
static string[] $ALLOWED_TYPES from  CommonSubtotal
string $class_element_line
string $picto
int|null deprecated $fk_user_author
int|null deprecated $fk_user_valid
string $datem
null|int|"" $delivery_date
?string $ref_customer
float|string $resteapayer
?string $module_source
?string $pos_source
int $pos_print_counter
int $email_sent_counter
int $fk_fac_rec_source
int $fk_facture_source
FactureLigne $line
int $fac_rec
?int $date_pointoftax
?int $situation_counter
int $situation_final
Facture[] $tab_previous_situation_invoice
Facture[] $tab_next_situation_invoice
float $retained_warranty
int $retained_warranty_date_limit
int $availability_id
string $date_closing
?int $source
float deprecated $remise_percent
string $online_payment_url
string $ip

Methods

mixed
__get(string $name)

Get deprecated property

void
__set(string $name, mixed $value)

Set deprecated property

void
__unset(string $name)

Unset deprecated property

void
__isset(string $name)

Test if deprecated property is set

mixed
__call(string $name, mixed[] $arguments)

Call deprecated method

array<string, string>
deprecatedProperties()

Provide list of deprecated properties

array<string, string>
deprecatedMethods()

Provide list of deprecated methods

static string
getCallerInfoString()

Get caller info

int
call_trigger(string $triggerName, User $user)

Call trigger based on this instance.

static 
isExistingObject($element, int $id, $ref = '', $ref_ext = '')

Check if an object id or ref exists If you don't need or want to instantiate the object and just need to know if the object exists, use this method instead of fetch

bool
isEmpty()

isEmpty We consider CommonObject isEmpty if this->id is empty

void
setErrorsFromObject(CommonObject|HookManager $object)

setErrorsFromObject

getTooltipContentArray($params)

getTooltipContentArray

getTooltipContent($params)

getTooltipContent

string
errorsToString()

Method to output saved errors

string
getFormatedCustomerRef(string $objref)

Return customer ref for screen output.

string
getFormatedSupplierRef(string $objref)

Return supplier ref for screen output.

string
getFullAddress($withcountry = 0, string $sep = "\n", $withregion = 0, $extralangcode = '')

Return full address of contact

string|-1
getLastMainDocLink(string $modulepart, int $initsharekey = 0, int $relativelink = 0)

Return the link of last main doc file for direct public download.

add_contact($fk_socpeople, int|string $type_contact, $source = 'external', $notrigger = 0)

Add a link between element $this->element and a contact

copy_linked_contact($objFrom, "internal"|"external" $source = 'internal')

Copy contact from one element to current

update_contact($rowid, int $statut, $type_contact_id = 0, $fk_socpeople = 0)

Update a link to contact line

delete_contact($rowid, int $notrigger = 0)

Delete a link to contact line

delete_linked_contact($source = '', string $code = '')

Delete all links between an object $this and all its contacts in llx_element_contact

liste_contact($statusoflink = -1, "external"|"thirdparty"|"internal" $source = 'external', $list = 0, $code = '', $status = -1, $arrayoftcids = array())

Get array of all contacts for an object

int
swapContactStatus($rowid)

Update status of a contact linked to object

liste_type_contact($source = 'internal', string $order = 'position', $option = 0, $activeonly = 0, $code = '')

Return array with list of possible values for type of contacts

listeTypeContacts($source = 'internal', int<0, 1> $option = 0, $activeonly = 0, $code = '', $element = '', $excludeelement = '')

Return array with list of possible values for type of contacts

getIdContact(string $source, $code, $status = 0)

Return id of contacts for a source and a contact code.

int<-1, 1>
fetch_contact($contactid = null)

Load object contact with id=$this->contact_id into $this->contact

int<-1, 1>
fetch_thirdparty($force_thirdparty_id = 0)

Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty

int<-1, 1>
fetchOneLike(string $ref)

Looks for an object with ref matching the wildcard provided It does only work when $this->table_ref_field is set

int<-1, 1>
fetch_barcode()

Load data for barcode into properties ->barcode_type* Properties ->barcode_type that is id of barcode. Type is used to find other properties, but if it is not defined, ->element must be defined to know default barcode type.

int<-1, 1>
fetchBarCode()

Load data for barcode into properties ->barcode_type* Properties ->barcode_type that is id of barcode. Type is used to find other properties, but if it is not defined, ->element must be defined to know default barcode type.

fetchProject()

Load the project with id $this->fk_project into this->project

fetch_project() deprecated

Load the project with id $this->fk_project into this->project

fetch_projet() deprecated

Load the project with id $this->fk_project into this->project

int<-1, 1>
fetch_product()

Load the product with id $this->fk_product into this->product

int<-1, 1>
fetch_user(int $userid)

Load the user with id $userid into this->user

void
fetch_origin()

Read linked origin object.

int<-1, 1>|false
fetchObjectFrom($table, string $field, $key, $element = null)

Load object from specific field

int<-1, 1>
getValueFrom(string $table, int $id, string $field)

Getter generic. Load value from a specific field

int<-2, 1>
setValueFrom(string $field, mixed $value, string $table = '', ?int $id = null, string $format = '', string $id_field = '', User|string|null $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif')

Setter generic. Update a specific field into database.

load_previous_next_ref($filter, string $fieldid, $nodbprefix = 0)

Load properties id_previous and id_next by comparing $fieldid with $this->ref

int[]
getListContactId($source = 'external')

Return list of id of contacts of object

int<-1, 1>
setProject(int $projectid, $notrigger = 0)

Link element with a project

int
setPaymentMethods($id)

Change the payments methods

int
setMulticurrencyCode($code)

Change the multicurrency code

setMulticurrencyRate($rate, int $mode = 1)

Change the multicurrency rate

setPaymentTerms($id, float $deposit_percent = null)

Change the payments terms

int
setTransportMode($id)

Change the transport mode methods

int
setRetainedWarrantyPaymentTerms($id)

Change the retained warranty payments terms

int
setDeliveryAddress(int $id)

Define delivery address

setShippingMethod($shipping_method_id, int $notrigger = 0, $userused = null)

Change the shipping method

int
setWarehouse($warehouse_id)

Change the warehouse

setDocModel($user, string $modelpdf)

Set last model used by doc generator

setBankAccount($fk_account, int $notrigger = 0, $userused = null)

Change the bank account

line_order(bool $renum = false, $rowidorder = 'ASC', $fk_parent_line = true)

Save a new position (field rang) for details lines.

getChildrenOfLine($id, int<0, 1001> $includealltree = 0)

Get children of line

line_up($rowid, bool $fk_parent_line = true)

Update a line to have a lower rank

line_down($rowid, bool $fk_parent_line = true)

Update a line to have a higher rank

updateRangOfLine($rowid, int $rang)

Update position of line (rang)

void
line_ajaxorder($rows)

Update position of line with ajax (rang)

updateLineUp($rowid, int $rang)

Update position of line up (rang)

updateLineDown($rowid, int $rang, $max)

Update position of line down (rang)

int
getRangOfLine($rowid)

Get position of line (rang)

int
getIdOfLine($rang)

Get rowid of the line relative to its position

int
line_max($fk_parent_line = 0)

Get max value used for position of line (rang)

int
update_ref_ext($ref_ext)

Update external ref of element

update_note($note, string $suffix = '', $notrigger = 0)

Update note of element

int
update_note_public(string $note) deprecated

Update public note (kept for backward compatibility)

int<-1, 1>
update_price(int $exclspec = 0, $roundingadjust = 'auto', $nodatabaseupdate = 0, $seller = null)

Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines).

add_object_linked($origin = null, $origin_id = null, $f_user = null, $notrigger = 0)

Add an object link into llx_element_element.

string
getElementType()

Return an element type string formatted like element_element target_type and source_type

int<-1, 1>
fetchObjectLinked(?int $sourceid = null, string $sourcetype = '', ?int $targetid = null, string $targettype = '', string $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1)

Fetch array of objects linked to current object (object of enabled modules only). Links are loaded into this->linkedObjectsIds array + this->linkedObjects array if $loadalsoobjects = 1 or $loadalsoobjects = type Possible usage for parameters:

  • all parameters empty -> we look all link to current object (current object can be source or target)
  • source id+type -> will get list of targets linked to source
  • target id+type -> will get list of sources linked to target
  • source id+type + target type -> will get list of targets of the type linked to source
  • target id+type + source type -> will get list of sources of the type linked to target

int
clearObjectLinkedCache()

Clear the cache saying that all linked object were already loaded. So next fetchObjectLinked will reload all links.

updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $f_user = null, $notrigger = 0)

Update object linked of a current object

deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = 0, $f_user = null, $notrigger = 0)

Delete all links between an object $this

static array|int
getAllItemsLinkedByObjectID(int $fk_object_where, string $field_select, string $field_where, string $table_element)

Function used to get an array with all items linked to an object id in association table

static array|int
getCountOfItemsLinkedByObjectID(int $fk_object_where, string $field_where, string $table_element)

Count items linked to an object id in association table

static int
deleteAllItemsLinkedByObjectID(int $fk_object_where, string $field_where, string $table_element)

Function used to remove all items linked to an object id in association table

setStatut($status, ?int $elementId = null, $elementType = '', $trigkey = '', $fieldstatus = '')

Set status of an object.

getCanvas($id = 0, string $ref = '')

Load type of canvas of an object if it exists

int
getSpecialCode($lineid)

Get special code of a line

isObjectUsed(int $id = 0, $entity = 0)

Function to check if an object is used by others (by children).

hasProductsOrServices(int $predefined = -1)

Function to say how many lines object contains

float|null
getTotalDiscount()

Function that returns the total amount HT of discounts applied for all lines.

array{weight: int|float, volume: int|float, ordered: int|float, toship: int|float}|array{}
getTotalWeightVolume()

Return into unit=0, the calculated total of weight and volume of all lines * qty Calculate by adding weight and volume of each product line, so properties ->volume/volume_units/weight/weight_units must be loaded on line.

int
setExtraParameters()

Set extra parameters

void
formAddObjectLine($dateSelector, Societe $seller, $buyer, $defaulttpldir = '/core/tpl')

Show add free and predefined products/services form

void
printObjectLines(string $action, Societe $seller, Societe $buyer, int<0, max> $selected = 0, int $dateSelector = 0, $defaulttpldir = '/core/tpl')

Return HTML table for object lines TODO Move this into an output class file (htmlline.class.php) If lines are into a template, title must also be into a template But for the moment we don't know if it's possible as we keep a method available on overloaded objects.

void
printObjectLine(string $action, CommonObjectLine $line, "" $var, int $num, int $i, int $dateSelector, Societe $seller, Societe $buyer, int<0, max> $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl')

Return HTML content of a detail line TODO Move this into an output class file (htmlline.class.php)

printOriginLinesList(""|"services" $restrictlist = '', $selectedLines = array())

Return HTML table table of source object lines TODO Move this and previous function into output html class file (htmlline.class.php).

printOriginLine(CommonObjectLine $line, $var, string $restrictlist = '', $defaulttpldir = '/core/tpl', $selectedLines = array())

Return HTML with a line of table array of source object lines TODO Move this and previous function into output html class file (htmlline.class.php).

int
add_element_resource(int $resource_id, string $resource_type, int $busy = 0, int $mandatory = 0, $notrigger = 0)

Add resources to the current object : add entry into llx_element_resources Need $this->element & $this->id

delete_resource($rowid, string $element = '', $notrigger = 0)

Delete a link to resource line

void
__clone()

Overwrite magic function to solve problem of cloning object that are kept as references

int<-1, 1>
commonGenerateDocument(string $modelspath, string $modele, Translate $outputlangs, int<0, 1> $hidedetails, int<0, 1> $hidedesc, int<0, 1> $hideref, ?array<string, mixed> $moreparams = null)

Common function for all objects extending CommonObject for generating documents

int
indexFile(string $destfull, int $update_main_doc_field)

Index a file into the ECM database

void
addThumbs(string $file, $quality = 50)

Build thumb

void
delThumbs(string $file)

Delete thumbs

string|string[]
getDefaultCreateValueFor(string $fieldname, string $alternatevalue = null, string $type = 'alphanohtml')

Return the default value to use for a field when showing the create form of object.

int<-1, 1>
fetchValuesForExtraLanguages()

Function to get alternative languages of a data into $this->array_languages This method is NOT called by method fetch of objects but must be called separately.

int<-1, 1>
setValuesForExtraLanguages(string $onlykey = '')

Fill array_options property of object by extrafields value (using for data sent by forms) Used for example when PDF_USE_ALSO_LANGUAGE_CODE is set to a language for the name of a thirdparty.

int<-1, 1>
fetchNoCompute(int $id)

Function to make a fetch but set environment to avoid to load computed values before.

fetch_optionals($rowid = null, array{}|array{label: array<string, string>, type: array<string, string>, size: array<string, string>, default: array<string, string>, computed: array<string, string>, unique: array<string, int>, required: array<string, int>, param: array<string, mixed>, perms: array<string, mixed[]>, list: array<string, int>|array<string, string>, pos: array<string, int>, totalizable: array<string, int>, help: array<string, string>, printable: array<string, int>, enabled: array<string, int>, langfile: array<string, string>, css: array<string, string>, csslist: array<string, string>, hidden: array<string, int>, mandatoryfieldsofotherentities?: array<string, string>, loaded?: int, count: int} $optionsArray = null)

Function to get extra fields of an object into $this->array_options This method is in most cases called by method fetch of objects but you can call it separately.

deleteExtraFields()

Delete all extra fields values for the current object.

insertExtraFields(string $trigger = '', $userused = null)

Add/Update all extra fields values for the current object.

insertExtraLanguages(string $trigger = '', $userused = null)

Add/Update all extra languages values for the current object.

updateExtraField(string $key, $trigger = null, $userused = null)

Update 1 extra field value for the current object. Keep other fields unchanged.

mixed|null
getExtraField(string $key)

Convenience method for retrieving the value of an extrafield without actually fetching it from the database.

void
setExtraField(string $key, mixed $value)

Convenience method for setting the value of an extrafield without actually updating it in the database.

updateExtraLanguages(string $key, $trigger = null, $userused = null)

Update an extra language value for the current object.

string
showInputField(?array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $val, string $key, string|string[] $value, string $moreparam = '', string $keysuffix = '', string $keyprefix = '', string|int $morecss = 0, int<0, 1> $nonewbutton = 0)

Return HTML string to put an input field into a page Code very similar with showInputField of extra fields

string
showOutputField(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $val, string $key, string $value, string $moreparam = '', string $keysuffix = '', string $keyprefix = '', mixed $morecss = '')

Return HTML string to show a field into a page Code very similar with showOutputField of extra fields

void
clearFieldError(string $fieldKey)

clear validation message result for a field

void
setFieldError(string $fieldKey, string $msg = '')

set validation error message a field

string
getFieldError(string $fieldKey)

get field error message

bool
validateField(array<string, array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int<-2, 5>|string, alwayseditable?: int<0, 1>, noteditable?: int<0, 1>, default?: string, index?: int, foreignkey?: string, searchall?: int<0, 1>, isameasure?: int<0, 1>, css?: string, csslist?: string, help?: string, showoncombobox?: int<0, 2>, disabled?: int<0, 1>, arrayofkeyval?: array<int, string>, autofocusoncreate?: int<0, 1>, comment?: string, copytoclipboard?: int<1, 2>, validate?: int<0, 1>}> $fields, string $fieldKey, string $fieldValue)

Return validation test result for a field

string
showOptionals(ExtraFields $extrafields, string $mode = 'view', array<string, mixed> $params = null, string $keysuffix = '', string $keyprefix = '', string $onetrtd = '', string $display_type = 'card')

Function to show lines of extrafields with output data.

string
getJSListDependancies(string $type = '_extra')

No description

null|int|stdClass
getRights()

Returns the rights used for this class

static bool
commonReplaceThirdparty(DoliDB $dbs, int $origin_id, int $dest_id, array $tables, int<0, 1> $ignoreerrors = 0)

Function used to replace a thirdparty id with another one.

static bool
commonReplaceProduct(DoliDB $dbs, int $origin_id, int $dest_id, array $tables, int<0, 1> $ignoreerrors = 0)

Function used to replace a product id with another one.

float|int<-2, -1>
defineBuyPrice(float $unitPrice = 0.0, float $discountPercent = 0.0, int $fk_product = 0)

Get buy price to use for margin calculation. This function is called when buy price is unknown.

array{dir: string, file: string, originalfile: string, altfile: string, email: string, capture: string}
getDataToShowPhoto(string $modulepart, string $imagesize)

Function used to get the logos or photos of an object

show_photos($modulepart, string $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $overwritetitle = 0, $usesharelink = 0, $cache = '', $addphotorefcss = 'photoref')

Show photos of an object (nbmax maximum), into several columns

bool
isArray(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is array

bool
isDate(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is date

bool
isDuration(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is duration

bool
isInt(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is integer

bool
isFloat(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is float

bool
isText(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is text

bool
canBeNull(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if field can be null

bool
isForcedToNullIfZero(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if field is forced to null if zero or empty

bool
isIndex(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if is indexed

array<string, null|int|float|string>
setSaveQuery()

Function to return the array of data key-value from the ->fields and all the ->properties of an object.

void
setVarsFromFetchObj(stdClass $obj)

Function to load data from a SQL pointer into properties of current object $this

void
emtpyObjectVars()

Sets all object fields to null. Useful for example in lists, when printing multiple lines and a different object os fetched for each line.

string
getFieldList(string $alias = '', string[] $excludefields = array())

Function to concat keys of fields

string|int
quote(string|int $value, array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $fieldsentry)

Add quote to field value if necessary

int<-1, max>
createCommon(User $user, int<0, 1> $notrigger = 0)

Create object in the database

int<-4, 1>
fetchCommon(int $id, ?string $ref = null, string $morewhere = '', int<0, 1> $noextrafields = 0)

Load object in memory from the database. This does not load line. This is done by parent fetch() that call fetchCommon

int<-1, 1>
fetchLinesCommon(string $morewhere = '', int<0, 1> $noextrafields = 0)

Load object in memory from the database

int<-1, 1>
updateCommon(User $user, int<0, 1> $notrigger = 0)

Update object into database

int<-1, 1>
deleteCommon(User $user, int<0, 1> $notrigger = 0, int<0, 1> $forcechilddeletion = 0)

Delete object in database

int
deleteByParentField(int $parentId = 0, string $parentField = '', string $filter = '', string $filtermode = "AND")

Delete all child object from a parent ID

deleteLineCommon(User $user, $idline, $notrigger = 0)

Delete a line of object in database

int
setStatusCommon(User $user, $status, $notrigger = 0, $triggercode = '')

Set to a status

int
initAsSpecimenCommon()

Initialise object with example values Id must be 0 if object instance is a specimen

int<0, max>|-1
fetchComments()

Load comments linked with current task

int
getNbComments()

Return nb comments already posted

void
trimParameters(string[] $parameters)

Trim object parameters

int[]|int
getCategoriesCommon(string $type_categ)

Sets object to given categories.

int
setCategoriesCommon(int[]|int $categories, string $type_categ = '', bool $remove_existing = true)

Sets object to given categories.

int
cloneCategories(int $fromId, int $toId, string $type = '')

Copy related categories to another object

bool
deleteEcmFiles(int $mode = 0)

Delete related files of object in database

bool
checkActiveProductInLines(string $status = 'onsale')

Check if all products have the right status (on sale, on buy) called during validation of propal, order, supplier proposal, supplier order

void
setErrorWithoutLog(string $message)

Set the error message for the object without logging it.

void
setErrorWithLog(string $message, int<0, 7> $loglevel = LOG_ERR)

Set the error message for the object and log it.

display_incoterms()

Return incoterms information TODO Use a cache for label get

getIncotermsForPDF()

Return incoterms information for pdf display

setIncoterms($id_incoterm, string $location)

Define incoterms values of current object

float|string
getRemainToPay(int $multicurrency = 0)

Return remain amount to pay. Property ->id and ->total_ttc must be set.

float|int|array{alreadypaid: float, alreadypaid_multicurrency: float}
getSommePaiement(int<-1, 1> $multicurrency = 0)

Return amount of payments already done. This must include ONLY the record into the payment table.

getSumDepositsUsed($multicurrency = 0)

Return amount (with tax) of all deposits invoices used by invoice.

getSumCreditNotesUsed($multicurrency = 0)

Return amount (with tax) of all credit notes invoices + excess received used by invoice

float
getSumFromThisCreditNotesNotUsed($multicurrency = 0)

Return amount (with tax) of all converted amount for this credit note

int[]
getListIdAvoirFromInvoice()

Returns array of credit note ids from the invoice

int
getIdReplacingInvoice(string $option = '')

Returns the id of the invoice that replaces it

array<array{id: int, invoiceid: int, date: ""|int, amount: float}>
getListOfOpenDirectDebitOrCreditTransfer($type)

Return list of open direct debit or credit transfer

getListOfPayments(string $filtertype = '', $multicurrency = 0, $mode = 0)

Return list of payments

int
isEditable()

Return if an invoice can be set back to draft.

is_erasable()

Return if an invoice can be deleted Rule is: If invoice is draft and has a temporary ref -> yes (1) If hidden option INVOICE_CAN_NEVER_BE_REMOVED is 1 -> no (0) If invoice is transferred in bookkeeping -> no (-1) If invoice has a definitive ref, is not last in ref -> no (-2) If invoice has a definitive ref, is not last in a situation cycle -> no (-3) If there is one payment -> no (-4) If already sent by email -> no (-5) If already printed -> no (-6) If running a LNE version and customer invoice was validated -> no (-7) Other value (may be returned by a hook -10, -11, ...) Otherwise -> yes (2)

int
getVentilExportCompta(int $mode = 0)

Return if an invoice was transferred into accountnancy.

string
getNextNumRef(Societe $soc, string $mode = 'next')

Return next reference of customer invoice not already used (or last reference) according to numbering module defined into constant FACTURE_ADDON

string
getLibType(int $withbadge = 0)

Return label of type of invoice

string|int
getSubtypeLabel($table = '')

Return label of invoice subtype

array<int, string>|array<string, int>
getArrayOfInvoiceSubtypes($mode = 0)

Retrieve a list of invoice subtype labels or codes.

getLibStatut($mode = 0, int|float $alreadypaid = -1)

Return label of object status

string
LibStatut(int $paye, int $status, int<0, 6> $mode = 0, int|float $alreadypaid = -1, int $type = -1, $moreparams = array())

Return label of a status

calculate_date_lim_reglement(int $cond_reglement = 0)

Returns an invoice payment deadline based on the invoice settlement conditions and billing date.

demande_prelevement(User $fuser, float $amount = 0, string $type = 'direct-debit', string $sourcetype = 'facture', int $checkduplicateamongall = 0, int $ribId = 0)

Create a withdrawal request for a direct debit order or a credit transfer order.

int
makeStripeCardRequest(User $fuser, $id, $sourcetype = 'facture')

Create a payment with Stripe card Must take amount using Stripe and record an event into llx_actioncomm Record bank payment Send email to customer ?

int
makeStripeSepaRequest(User $fuser, $did, $type = 'direct-debit', $sourcetype = 'facture', $service = '', $forcestripe = '')

Create a direct debit order into prelevement_bons for a given prelevement_request, then Send the payment order to the service (for a direct debit order or a credit transfer order) and record an event in llx_actioncomm.

demande_prelevement_delete($fuser, int $did)

Remove a direct debit request or a credit transfer request

string
buildEPCQrCodeString()

Build string for EPC QR Code

string
buildZATCAQRString()

Build string for ZATCA QR Code (Arabi Saudia)

string
buildSwitzerlandQRString()

Build string for QR-Bill (Switzerland)

int
addSubtotalLine(Translate $langs, string $desc, int $depth, array<string, string>|string $options = array(), int $parent_line = 0)

Adds a subtotals line to a document.

int
deleteSubtotalLine(Translate $langs, int $id, bool $correspondingstline = false, User $user = null)

Deletes a subtotal or a title line from a document.

int
updateSubtotalLine(Translate $langs, int $lineid, string $desc, int $depth, array<string, string>|string $options)

Updates a subtotal line of a document.

int
updateSubtotalLineBlockLines(Translate $langs, int $linerang, string $mode, int $value)

Updates a block of lines of a document.

string
getSubtotalLineAmount(object $line)

Return the total_ht of lines that are above the current line (excluded) and that are not a subtotal line until a title line of the same level is found

string
getSubtotalLineMulticurrencyAmount(object $line)

Return the multicurrency_total_ht of lines that are above the current line (excluded) and that are not a subtotal line until a title line of the same level is found

string|null
getSubtotalColors(int|float $level)

Retrieve the background color associated with a specific subtotal level.

array<string, string>
getPossibleTitles()

Retrieve current object possible titles to choose from

array<int, string>
getPossibleLevels(Translate $langs)

Retrieve the current object possible levels (defined in admin page)

int[]
getDisabledShippmentSubtotalLines()

Returns an array with the IDs of the line that we don't need to show to avoid empty blocks

__construct(DoliDB $db)

Constructor

int
create(User $user, int $notrigger = 0, $forceduedate = 0, $updatecurrencyrate = 0)

Create invoice in database.

int<-1, 1>
createFromCurrent(User $user, int<0, 1> $invertdetail = 0)

Create a new invoice in database from current invoice

createFromClone(User $user, $fromid = 0)

Load an object from its id and create a new one in database

int<-1, 1>
createFromOrder(Commande $object, User $user)

Load an object from an order and create a new invoice into database

createFromContract($object, User $user, $lines = array())

Load an object from a contract and create a new invoice into database

static Facture
createDepositFromOrigin(CommonObject $origin, int $date, int $payment_terms_id, User $user, int<0, 1> $notrigger = 0, bool $autoValidateDeposit = false, array<string, int|float|string> $overrideFields = array())

Creates a deposit from a proposal or an order by grouping lines by VAT rates

getNomUrl($withpicto = 0, string $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1, $target = '')

Return clickable link of object (with eventually picto)

int
fetch(int $rowid, $ref = '', $ref_ext = '', $notused = 0, $fetch_situation = false)

Get object from database. Get also lines.

int
fetch_lines(int|string $only_type_product = '', int $loadalsotranslation = 0)

Load all detailed lines into this->lines

void
fetchPreviousNextSituationInvoice()

Fetch previous and next situations invoices.

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

Update database

int
insert_discount($idremise)

Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount)

int
set_ref_client(string $ref_client, $notrigger = 0)

Set customer ref

setInputReason($inputReasonId, int $notrigger = 0)

Update invoice input reason

int
delete(User $user, int $notrigger = 0, int $idwarehouse = -1)

Delete invoice

set_paid($user, string $close_code = '', string $close_note = '') deprecated

Tag the invoice as paid completely (if close_code is filled) => this->fk_statut=2, this->paye=1 or partially (if close_code filled) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0

setPaid($user, string $close_code = '', string $close_note = '')

Tag the invoice as :

  • paid completely (if close_code is not filled) => this->fk_statut=2, this->paye=1
  • or partially (if close_code filled) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0

set_unpaid($user) deprecated

Tags the invoice as incompletely paid and call the trigger BILL_UNPAYED This method is used when a direct debit (fr:prelevement) is refused or when a canceled invoice is reopened.

int
setUnpaid($user)

Tag the invoice as incompletely paid and call the trigger BILL_UNPAYED This method is used when a direct debit (fr:prelevement) is refused or when a canceled invoice is reopened.

int
set_canceled(User $user, string $close_code = '', string $close_note = '') deprecated

Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because of no payment even if merchandises were sent).

int
setCanceled(User $user, string $close_code = '', string $close_note = '')

Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because of no payment even if merchandises were sent).

int
validate(User $user, string $force_number = '', int $idwarehouse = 0, int $notrigger = 0, int $batch_rule = 0)

Tag invoice as validated + call trigger BILL_VALIDATE Object must have lines loaded with fetch_lines This may rename files on disk because ref is modified but it does not generate any document.

bool
updatePriceNextInvoice(Translate $langs)

Update price of next invoice

int
setDraft(User $user, int $idwarehouse = -1)

Set draft status

addline(string $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $fk_code_ventilation = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = array(), $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0, $ref_ext = '', $noupdateafterinsertline = 0)

Add an invoice line into database (linked to product/service or not).

updateline($rowid, string $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = array(), $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0)

Update a detail line

bool
checkProgressLine(int $idline, float $situation_percent)

Check if the percent edited is lower of next invoice line

void
update_percent(FactureLigne $line, int|float $percent, bool $update_price = true)

Update invoice line with percentage

int
deleteLine(int $rowid, $id = 0)

Delete line in database

int
set_remise(User $user, float $remise, $notrigger = 0)

Set percent discount

int
setDiscount(User $user, float $remise, $notrigger = 0)

Set percent discount

int
setCategories(int[]|int $categories)

Sets object to given categories.

void
info(int $id)

Load miscellaneous information for tab "Info"

array<int, string>|array<array{id: int, ref: string, name: string}>|int<-1, -1>
liste_array($shortlist = 0, int $draft = 0, $excluser = null, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC')

Return list of invoices (eventually filtered on a user) into an array

int<-1, -1>|array<int, array{id: int, ref: string, status: int, paid: int<0, 1>, alreadypaid: int<0, 1>}>
list_replacable_invoices(int $socid = 0)

Return list of invoices qualified to be replaced by another invoice.

array<int, array{ref: string, status: int, type: int, paye: int<0, 1>, paymentornot: int<0, 1>}>|int<-1, -1>
list_qualified_avoir_invoices(int $socid = 0)

Return list of invoices qualified to be corrected by a credit note.

load_board(User $user)

Load indicators for dashboard (this->nbtodo and this->nbtodolate)

int[]
getIdBillingContact()

Retourne id des contacts clients de facturation

int[]
getIdShippingContact()

Retourne id des contacts clients de livraison

initAsSpecimen(string $option = '')

Initialise an instance with random values.

loadStateBoard()

Load indicators for dashboard (this->nbtodo and this->nbtodolate)

getLinesArray()

Create an array of invoice lines

int<-1, 1>
generateDocument(string $modele, Translate $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)

Create a document onto disk according to template module.

int
newCycle()

Gets the smallest reference available for a new cycle

bool
is_first()

Checks if the invoice is the first of a cycle

Facture[]|int<-1, -1>
get_prev_sits()

Returns an array containing the previous situations as Facture objects

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

Sets the invoice as a final situation

bool
is_last_in_cycle()

Checks if the invoice is the last in its cycle

static bool
replaceThirdparty(DoliDB $dbs, int $origin_id, int $dest_id)

Replace a thirdparty id with another one.

static bool
replaceProduct(DoliDB $db, int $origin_id, int $dest_id)

Replace a product id with another one.

bool
hasDelay()

Is the customer invoice delayed?

int
isSituationInvoice()

Check if an invoice is a situation invoice

bool
displayRetainedWarranty()

Currently used for documents generation : to know if retained warranty need to be displayed

float
getRetainedWarrantyAmount(int $rounding = -1)

No description

int
setRetainedWarranty($value)

Change the retained warranty

setRetainedWarrantyDateLimit($timestamp, string $dateYmd = '')

Change the retained_warranty_date_limit

sendEmailsRemindersOnInvoiceDueDate(int $nbdays = 0, $paymentmode = 'all', $template = '', $datetouse = 'duedate', $forcerecipient = '')

Send reminders by emails for invoices validated that are due.

array{0?: bool, 1?: string}
willBeLastOfSameType(bool $allow_validated_drafts = false)

See if current invoice date is posterior to the last invoice date among validated invoices of same type.

getKanbanView(string $option = '', $arraydata = null)

Return clickable link of object (with eventually picto)

Details

mixed __get(string $name)

Get deprecated property

Parameters

string $name

Name of property

Return Value

mixed

Value for replacement property

void __set(string $name, mixed $value)

Set deprecated property

Parameters

string $name

Name of property

mixed $value

Value of property

Return Value

void

void __unset(string $name)

Unset deprecated property

Parameters

string $name

Name of property

Return Value

void

void __isset(string $name)

Test if deprecated property is set

Parameters

string $name

Name of property

Return Value

void

mixed __call(string $name, mixed[] $arguments)

Call deprecated method

Parameters

string $name

Name of method

mixed[] $arguments

Method arguments

Return Value

mixed

protected array<string, string> deprecatedProperties()

Provide list of deprecated properties

Override this method in subclasses

Return Value

array<string, string>

Mapping of deprecated properties

protected array<string, string> deprecatedMethods()

Provide list of deprecated methods

Override this method in subclasses

Return Value

array<string, string>

Mapping of deprecated methods

final static protected string getCallerInfoString()

Get caller info

Return Value

string

int call_trigger(string $triggerName, User $user)

Call trigger based on this instance.

Some context information may also be provided into array property this->context. NB: Error from trigger are stacked in interface->errors NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction.

Parameters

string $triggerName

Trigger's name to execute

User $user

Object user

Return Value

int

Result of run_triggers

static isExistingObject($element, int $id, $ref = '', $ref_ext = '')

Check if an object id or ref exists If you don't need or want to instantiate the object and just need to know if the object exists, use this method instead of fetch

@param string $element String of element ('product', 'facture', ...)

Parameters

$element
int $id

Id of object @param string $ref Ref of object to check @param string $ref_ext Ref ext of object to check @return int Return integer <0 if KO, 0 if OK but not found, >0 if OK and exists

$ref
$ref_ext

bool isEmpty()

isEmpty We consider CommonObject isEmpty if this->id is empty

Return Value

bool

void setErrorsFromObject(CommonObject|HookManager $object)

setErrorsFromObject

Parameters

CommonObject|HookManager $object

commonobject or HookManager

Return Value

void

getTooltipContentArray($params)

getTooltipContentArray

Parameters

$params

getTooltipContent($params)

getTooltipContent

Parameters

$params

string errorsToString()

Method to output saved errors

Return Value

string

String with errors

string getFormatedCustomerRef(string $objref)

Return customer ref for screen output.

Parameters

string $objref

Customer ref

Return Value

string

Customer ref formatted

string getFormatedSupplierRef(string $objref)

Return supplier ref for screen output.

Parameters

string $objref

Supplier ref

Return Value

string

Supplier ref formatted

string getFullAddress($withcountry = 0, string $sep = "\n", $withregion = 0, $extralangcode = '')

Return full address of contact

@param      int<0,1>    $withcountry        1=Add country into address string

Parameters

$withcountry
string $sep

Separator to use to build string @param int<0,1> $withregion 1=Add region into address string @param string $extralangcode User extralanguages as value

$withregion
$extralangcode

Return Value

string

Full address string

Return the link of last main doc file for direct public download.

Parameters

string $modulepart

Module related to document

int $initsharekey

Init the share key if it was not yet defined

int $relativelink

0=Return full external link, 1=Return link relative to root of file

Return Value

string|-1

Returns the link, or an empty string if no link was found, or -1 if error.

add_contact($fk_socpeople, int|string $type_contact, $source = 'external', $notrigger = 0)

Add a link between element $this->element and a contact

@param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if source = 'internal') to link

Parameters

$fk_socpeople
int|string $type_contact

Type of contact (code or id). Must be id or code found into table llx_c_type_contact. For example: SALESREPFOLL @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) @param int $notrigger Disable all triggers @return int Return integer <0 if KO, 0 if already added or code not valid, >0 if OK

$source
$notrigger

copy_linked_contact($objFrom, "internal"|"external" $source = 'internal')

Copy contact from one element to current

@param CommonObject $objFrom Source element

Parameters

$objFrom
"internal"|"external" $source

Nature of contact ('internal' or 'external') @return int >0 if OK, <0 if KO

update_contact($rowid, int $statut, $type_contact_id = 0, $fk_socpeople = 0)

Update a link to contact line

@param int $rowid Id of line contact-element

Parameters

$rowid
int $statut

New status of link @param int $type_contact_id Id of contact type (not modified if 0) @param int $fk_socpeople Id of soc_people to update (not modified if 0) @return int Return integer <0 if KO, >= 0 if OK

$type_contact_id
$fk_socpeople

delete_contact($rowid, int $notrigger = 0)

Delete a link to contact line

@param int $rowid Id of contact link line to delete

Parameters

$rowid
int $notrigger

Disable all triggers @return int >0 if OK, <0 if KO

delete_linked_contact($source = '', string $code = '')

Delete all links between an object $this and all its contacts in llx_element_contact

@param string $source '' or 'internal' or 'external'

Parameters

$source
string $code

Type of contact (code or id) @return int Return integer <0 if KO, 0=Nothing done, >0 if OK

liste_contact($statusoflink = -1, "external"|"thirdparty"|"internal" $source = 'external', $list = 0, $code = '', $status = -1, $arrayoftcids = array())

Get array of all contacts for an object

@param int $statusoflink Status of links to get (-1=all). Not used.

Parameters

$statusoflink
"external"|"thirdparty"|"internal" $source

Source of contact: 'external' or 'thirdparty' (llx_socpeople) or 'internal' (llx_user) @param int<0,1> $list 0:Returned array contains all properties, 1:Return array contains just id @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) @param int $status Status of user or company @param int[] $arrayoftcids Array with ID of type of contacts. If we provide this, we can filter on ec.fk_c_type_contact IN ($arrayoftcids) to avoid a link on c_type_contact table (faster). @return array<int,array{parentId:int,source:string,socid:int,id:int,nom:string,civility:string,lastname:string,firstname:string,email:string,login:string,photo:string,gender:string,statuscontact:int,rowid:int,code:string,libelle:string,status:int,fk_c_type_contact:int}>|int<-1,-1> Array of contacts, -1 if error

$list
$code
$status
$arrayoftcids

int swapContactStatus($rowid)

Update status of a contact linked to object

@param  int     $rowid      Id of link between object and contact

Parameters

$rowid

Return Value

int

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

liste_type_contact($source = 'internal', string $order = 'position', $option = 0, $activeonly = 0, $code = '')

Return array with list of possible values for type of contacts

@param 'internal'|'external'|'all' $source 'internal', 'external' or 'all'

Parameters

$source
string $order

Sort order by : 'position', 'code', 'rowid'... @param int<0,1> $option 0=Return array id->label, 1=Return array code->label, 2=Return complete array @param int<0,1> $activeonly 0=all status of contact, 1=only the active @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') @return array<int,string>|array<string,string>|array<int,array{id:int,code:string,label:string}>|null Array list of type of contacts (id->label if option=0, code->label if option=1), or null if error

$option
$activeonly
$code

listeTypeContacts($source = 'internal', int<0, 1> $option = 0, $activeonly = 0, $code = '', $element = '', $excludeelement = '')

Return array with list of possible values for type of contacts

@param string $source 'internal', 'external' or 'all'

Parameters

$source
int<0, 1> $option

0=Return array id->label, 1=Return array code->label @param int<0,1> $activeonly 0=all status of contact, 1=only the active @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') @param string $element Filter on 1 element type @param string $excludeelement Exclude 1 element type. Example: 'agenda' @return array<int,string>|array<string,string>|null Array list of type of contacts (id->label if option=0, code->label if option=1), or null if error

$activeonly
$code
$element
$excludeelement

getIdContact(string $source, $code, $status = 0)

Return id of contacts for a source and a contact code.

Example: contact client de facturation ('external', 'BILLING') Example: contact client de livraison ('external', 'SHIPPING') Example: contact interne suivi paiement ('internal', 'SALESREPFOLL')

Parameters

string $source

'external' or 'internal' @param string $code 'BILLING', 'SHIPPING', 'SALESREPFOLL', ... @param int $status limited to a certain status @return int[]|null List of id for such contacts, or null if error

$code
$status

int<-1, 1> fetch_contact($contactid = null)

Load object contact with id=$this->contact_id into $this->contact

@param  ?int        $contactid  Id du contact. Use this->contact_id if empty.

Parameters

$contactid

Return Value

int<-1, 1>

Return integer <0 if KO, >0 if OK

int<-1, 1> fetch_thirdparty($force_thirdparty_id = 0)

Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty

@param      int<0,1>    $force_thirdparty_id    Force thirdparty id

Parameters

$force_thirdparty_id

Return Value

int<-1, 1>

Return integer <0 if KO, >0 if OK @phan-suppress PhanUndeclaredProperty

int<-1, 1> fetchOneLike(string $ref)

Looks for an object with ref matching the wildcard provided It does only work when $this->table_ref_field is set

Parameters

string $ref Wildcard

Return Value

int<-1, 1>

1 = OK, 0 = Not found or table_ref_field not defined, <0 = KO

int<-1, 1> fetch_barcode()

Load data for barcode into properties ->barcode_type* Properties ->barcode_type that is id of barcode. Type is used to find other properties, but if it is not defined, ->element must be defined to know default barcode type.

Return Value

int<-1, 1>

Return integer <0 if KO, 0 if can't guess type of barcode (ISBN, EAN13...), >0 if OK (all barcode properties loaded) @deprecated Use fetchBarCode()

int<-1, 1> fetchBarCode()

Load data for barcode into properties ->barcode_type* Properties ->barcode_type that is id of barcode. Type is used to find other properties, but if it is not defined, ->element must be defined to know default barcode type.

Return Value

int<-1, 1>

Return integer <0 if KO, 0 if can't guess type of barcode (ISBN, EAN13...), >0 if OK (all barcode properties loaded)

fetchProject()

Load the project with id $this->fk_project into this->project

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

fetch_project() deprecated

deprecated @see fetchProject()

Load the project with id $this->fk_project into this->project

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

fetch_projet() deprecated

deprecated @see fetchProject()

Load the project with id $this->fk_project into this->project

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

int<-1, 1> fetch_product()

Load the product with id $this->fk_product into this->product

Return Value

int<-1, 1>

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

int<-1, 1> fetch_user(int $userid)

Load the user with id $userid into this->user

Parameters

int $userid

Id du contact

Return Value

int<-1, 1>

Return integer <0 if KO, >0 if OK

void fetch_origin()

Read linked origin object.

Set ->origin_object

Return Value

void

int<-1, 1>|false fetchObjectFrom($table, string $field, $key, $element = null)

Load object from specific field

@param string $table Table element or element line

Parameters

$table
string $field

Field selected @param string $key Import key @param string $element Element name

$key
$element

Return Value

int<-1, 1>|false

Return -1 or false if KO, >0 if OK

int<-1, 1> getValueFrom(string $table, int $id, string $field)

Getter generic. Load value from a specific field

Parameters

string $table

Table of element or element line

int $id

Element id

string $field

Field selected

Return Value

int<-1, 1>

Return integer <0 if KO, >0 if OK

int<-2, 1> setValueFrom(string $field, mixed $value, string $table = '', ?int $id = null, string $format = '', string $id_field = '', User|string|null $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif')

Setter generic. Update a specific field into database.

Warning: Trigger is run only if param trigkey is provided.

Parameters

string $field

Field to update

mixed $value

New value

string $table

To force other table element or element line (should not be used)

?int $id

To force other object id (should not be used)

string $format

Data format ('text', 'int', 'date'). 'text' is used if not defined

string $id_field

To force rowid field name. 'rowid' is used if not defined

User|string|null $fuser

Update the user of last update field with this user. If not provided, current user is used except if value is 'none' @param string $trigkey Trigger key to run (in most cases something like 'XXX_MODIFY') @param string $fk_user_field Name of field to save user id making change

$trigkey
$fk_user_field

Return Value

int<-2, 1>

Return integer <0 if KO, >0 if OK updateExtraField()

load_previous_next_ref($filter, string $fieldid, $nodbprefix = 0)

Load properties id_previous and id_next by comparing $fieldid with $this->ref

@param string $filter Optional SQL filter. Use SQL or Universal Search Filter. Example: "(t.field1 = 'aa' OR t.field2 = 'bb')". Do not allow user input data here with this syntax. Example: "((t.field1:=:'aa') OR (t.field2:=:'bb'))".

Parameters

$filter
string $fieldid

Name of field to use for the select MAX and MIN @param int<0,1> $nodbprefix Do not include DB prefix to forge table name @return int<-2,1> Return integer <0 if KO, >0 if OK

$nodbprefix

int[] getListContactId($source = 'external')

Return list of id of contacts of object

@param string $source Source of contact: external (llx_socpeople) or internal (llx_user) or thirdparty (llx_societe)

Parameters

$source

Return Value

int[]

Array of id of contacts (if source=external or internal) Array of id of third parties with at least one contact on object (if source=thirdparty)

int<-1, 1> setProject(int $projectid, $notrigger = 0)

Link element with a project

Parameters

int $projectid

Project id to link element to @param int<0,1> $notrigger Disable the trigger

$notrigger

Return Value

int<-1, 1>

Return integer <0 if KO, >0 if OK

int setPaymentMethods($id)

Change the payments methods

@param int $id Id of new payment method

Parameters

$id

Return Value

int

0 if OK, <0 if KO

int setMulticurrencyCode($code)

Change the multicurrency code

@param string $code multicurrency code

Parameters

$code

Return Value

int

0 if OK, <0 if KO

setMulticurrencyRate($rate, int $mode = 1)

Change the multicurrency rate

@param double $rate multicurrency rate

Parameters

$rate
int $mode

mode 1 : amounts in company currency will be recalculated, mode 2 : amounts in foreign currency will be recalculated @return int >0 if OK, <0 if KO

setPaymentTerms($id, float $deposit_percent = null)

Change the payments terms

@param int $id Id of new payment terms

Parameters

$id
float $deposit_percent

% of deposit if needed by payment terms @return int >0 if OK, <0 if KO

int setTransportMode($id)

Change the transport mode methods

@param int $id Id of transport mode

Parameters

$id

Return Value

int

0 if OK, <0 if KO

int setRetainedWarrantyPaymentTerms($id)

Change the retained warranty payments terms

@param int $id Id of new payment terms

Parameters

$id

Return Value

int

0 if OK, <0 if KO

int setDeliveryAddress(int $id)

Define delivery address

@deprecated

Parameters

int $id

Address id

Return Value

int

Return integer <0 si ko, >0 si ok

setShippingMethod($shipping_method_id, int $notrigger = 0, $userused = null)

Change the shipping method

@param int $shipping_method_id Id of shipping method

Parameters

$shipping_method_id
int $notrigger

0=launch triggers after, 1=disable triggers @param User $userused Object user @return int 1 if OK, 0 if KO

$userused

int setWarehouse($warehouse_id)

Change the warehouse

@param int $warehouse_id Id of warehouse

Parameters

$warehouse_id

Return Value

int

1 if OK, 0 if KO

setDocModel($user, string $modelpdf)

Set last model used by doc generator

@param      User    $user       User object that make change

Parameters

$user
string $modelpdf

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

setBankAccount($fk_account, int $notrigger = 0, $userused = null)

Change the bank account

@param int $fk_account Id of bank account

Parameters

$fk_account
int $notrigger

0=launch triggers after, 1=disable triggers @param User $userused Object user @return int 1 if OK, 0 if KO

$userused

line_order(bool $renum = false, $rowidorder = 'ASC', $fk_parent_line = true)

Save a new position (field rang) for details lines.

You can choose to set position for lines with already a position or lines without any position defined.

Parameters

bool $renum

True to renum all already ordered lines, false to renum only not already ordered lines. @param string $rowidorder ASC or DESC @param boolean $fk_parent_line Table with fk_parent_line field or not @return int Return integer <0 if KO, >0 if OK

$rowidorder
$fk_parent_line

getChildrenOfLine($id, int<0, 1001> $includealltree = 0)

Get children of line

@param  int         $id             Id of parent line

Parameters

$id
int<0, 1001> $includealltree

0 = 1st level child, 1 = All level child, 2-1001: internal use @return int[] Array with list of children lines id

line_up($rowid, bool $fk_parent_line = true)

Update a line to have a lower rank

@param  int         $rowid              Id of line

Parameters

$rowid
bool $fk_parent_line

Table with fk_parent_line field or not @return void

line_down($rowid, bool $fk_parent_line = true)

Update a line to have a higher rank

@param  int         $rowid              Id of line

Parameters

$rowid
bool $fk_parent_line

Table with fk_parent_line field or not @return void

updateRangOfLine($rowid, int $rang)

Update position of line (rang)

@param  int     $rowid      Id of line

Parameters

$rowid
int $rang

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

void line_ajaxorder($rows)

Update position of line with ajax (rang)

@param  int[]   $rows   Array of rows

Parameters

$rows

Return Value

void

updateLineUp($rowid, int $rang)

Update position of line up (rang)

@param  int     $rowid      Id of line

Parameters

$rowid
int $rang

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

updateLineDown($rowid, int $rang, $max)

Update position of line down (rang)

@param  int     $rowid      Id of line

Parameters

$rowid
int $rang

Position @param int $max Max @return int<-1,1> Return integer <0 if KO, >0 if OK

$max

int getRangOfLine($rowid)

Get position of line (rang)

@param      int     $rowid      Id of line

Parameters

$rowid

Return Value

int

Value of rang in table of lines

int getIdOfLine($rang)

Get rowid of the line relative to its position

@param      int     $rang       Rang value

Parameters

$rang

Return Value

int

Rowid of the line

int line_max($fk_parent_line = 0)

Get max value used for position of line (rang)

@param      int     $fk_parent_line     Parent line id

Parameters

$fk_parent_line

Return Value

int

Max value of rang in table of lines

int update_ref_ext($ref_ext)

Update external ref of element

@param string $ref_ext Update field ref_ext

Parameters

$ref_ext

Return Value

int

Return integer <0 if KO, >0 if OK

update_note($note, string $suffix = '', $notrigger = 0)

Update note of element

@param string $note New value for note

Parameters

$note
string $suffix

'', '_public' or '_private' @param int $notrigger 1=Does not execute triggers, 0=execute triggers @return int Return integer <0 if KO, >0 if OK

$notrigger

int update_note_public(string $note) deprecated

deprecated

Update public note (kept for backward compatibility)

Parameters

string $note

New value for note

Return Value

int

Return integer <0 if KO, >0 if OK

See also

update_note()

int<-1, 1> update_price(int $exclspec = 0, $roundingadjust = 'auto', $nodatabaseupdate = 0, $seller = null)

Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines).

Must be called at end of methods addline or updateline.

Parameters

int $exclspec

Use >0 = Exclude special product (product_type=9) @param 'none'|'auto'|'0'|'1' $roundingadjust 'none'=Do nothing (when properties are already correctly set), 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force mode Total of rounding, '1'=Force mode Rounding of total @param int<0,1> $nodatabaseupdate 1=Do not update database total fields of the main object. Update only properties in memory. Can be used to save SQL when this method is called several times, so we can do it only once at end. @param ?Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object (used to analyze lines to check corrupted data).

$roundingadjust
$nodatabaseupdate
$seller

Return Value

int<-1, 1>

Return integer <0 if KO, >0 if OK

add_object_linked($origin = null, $origin_id = null, $f_user = null, $notrigger = 0)

Add an object link into llx_element_element.

Parameters

$origin
$origin_id
$f_user
$notrigger

string getElementType()

Return an element type string formatted like element_element target_type and source_type

Return Value

string

int<-1, 1> fetchObjectLinked(?int $sourceid = null, string $sourcetype = '', ?int $targetid = null, string $targettype = '', string $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1)

Fetch array of objects linked to current object (object of enabled modules only). Links are loaded into this->linkedObjectsIds array + this->linkedObjects array if $loadalsoobjects = 1 or $loadalsoobjects = type Possible usage for parameters:

  • all parameters empty -> we look all link to current object (current object can be source or target)
  • source id+type -> will get list of targets linked to source
  • target id+type -> will get list of sources linked to target
  • source id+type + target type -> will get list of targets of the type linked to source
  • target id+type + source type -> will get list of sources of the type linked to target

Parameters

?int $sourceid

Object source id (if not defined, $this->id)

string $sourcetype

Object source type (if not defined, $this->element)

?int $targetid

Object target id (if not defined, $this->id)

string $targettype

Object target type (if not defined, $this->element)

string $clause

'OR' or 'AND' clause used when both source id and target id are provided @param int<0,1> $alsosametype 0=Return only links to object that differs from source type. 1=Include also link to objects of same type. @param string $orderby SQL 'ORDER BY' clause @param int<0,1>|string $loadalsoobjects Load also the array $this->linkedObjects. Use 0 to not load (increase performances), Use 1 to load all, Use value of type ('facture', 'facturerec', ...) to load only a type of object.

$alsosametype
$orderby
$loadalsoobjects

Return Value

int<-1, 1>

Return integer <0 if KO, >0 if OK @see add_object_linked(), updateObjectLinked(), deleteObjectLinked()

int clearObjectLinkedCache()

Clear the cache saying that all linked object were already loaded. So next fetchObjectLinked will reload all links.

Return Value

int

Return integer <0 if KO, >0 if OK @see fetchObjectLinked()

updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $f_user = null, $notrigger = 0)

Update object linked of a current object

Parameters

$sourceid
$sourcetype
$targetid
$targettype
$f_user
$notrigger

deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = 0, $f_user = null, $notrigger = 0)

Delete all links between an object $this

Parameters

$sourceid
$sourcetype
$targetid
$targettype
$rowid
$f_user
$notrigger

static array|int getAllItemsLinkedByObjectID(int $fk_object_where, string $field_select, string $field_where, string $table_element)

Function used to get an array with all items linked to an object id in association table

Parameters

int $fk_object_where

id of object we need to get linked items

string $field_select

name of field we need to get a list

string $field_where

name of field of object we need to get linked items

string $table_element

name of association table

Return Value

array|int

Array of record, -1 if empty

static array|int getCountOfItemsLinkedByObjectID(int $fk_object_where, string $field_where, string $table_element)

Count items linked to an object id in association table

Parameters

int $fk_object_where

id of object we need to get linked items

string $field_where

name of field of object we need to get linked items

string $table_element

name of association table

Return Value

array|int

Array of record, -1 if empty

static int deleteAllItemsLinkedByObjectID(int $fk_object_where, string $field_where, string $table_element)

Function used to remove all items linked to an object id in association table

Parameters

int $fk_object_where

id of object we need to remove linked items

string $field_where

name of field of object we need to delete linked items

string $table_element

name of association table

Return Value

int

Return integer <0 if KO, 0 if nothing done, >0 if OK and something done

setStatut($status, ?int $elementId = null, $elementType = '', $trigkey = '', $fieldstatus = '')

Set status of an object.

@param int $status Status to set

Parameters

$status
?int $elementId

Id of element to force (use this->id by default if null) @param string $elementType Type of element to force (use this->table_element by default) @param string $trigkey Trigger key to use for trigger, or 'none' or use '' means automatic but it is not recommended and is deprecated. @param string $fieldstatus Name of status field to update (commonly field 'status' or 'fk_statut' in this->table_element) @return int Return integer <0 if KO, >0 if OK setStatusCommon()

$elementType
$trigkey
$fieldstatus

getCanvas($id = 0, string $ref = '')

Load type of canvas of an object if it exists

@param int $id Record id

Parameters

$id
string $ref

Record ref @return int Return integer <0 if KO, 0 if nothing done, >0 if OK

int getSpecialCode($lineid)

Get special code of a line

@param  int     $lineid     Id of line

Parameters

$lineid

Return Value

int

Special code

isObjectUsed(int $id = 0, $entity = 0)

Function to check if an object is used by others (by children).

Check is done into this->childtables. There is no check into llx_element_element.

Parameters

int $id

Force id of object @param int $entity Force entity to check @return int Return integer <0 if KO, 0 if not used, >0 if already used

$entity

hasProductsOrServices(int $predefined = -1)

Function to say how many lines object contains

Parameters

int $predefined

-1=All, 0=Count free product/service only, 1=Count predefined product/service only, 2=Count predefined product, 3=Count predefined service @return int Return integer <0 if KO, 0 if no predefined products, nb of lines with predefined products if found

float|null getTotalDiscount()

Function that returns the total amount HT of discounts applied for all lines.

Return Value

float|null

Total amount of discount, or null if $table_element_line is empty

array{weight: int|float, volume: int|float, ordered: int|float, toship: int|float}|array{} getTotalWeightVolume()

Return into unit=0, the calculated total of weight and volume of all lines * qty Calculate by adding weight and volume of each product line, so properties ->volume/volume_units/weight/weight_units must be loaded on line.

Return Value

array{weight: int|float, volume: int|float, ordered: int|float, toship: int|float}|array{} array('weight'=>...,'volume'=>...)

int setExtraParameters()

Set extra parameters

Return Value

int

Return integer <0 if KO, >0 if OK

void formAddObjectLine($dateSelector, Societe $seller, $buyer, $defaulttpldir = '/core/tpl')

Show add free and predefined products/services form

@param int $dateSelector 1=Show also date range input fields

Parameters

$dateSelector
Societe $seller

Object thirdparty who sell @param ?Societe $buyer Object thirdparty who buy @param string $defaulttpldir Directory where to find the template

$buyer
$defaulttpldir

Return Value

void

void printObjectLines(string $action, Societe $seller, Societe $buyer, int<0, max> $selected = 0, int $dateSelector = 0, $defaulttpldir = '/core/tpl')

Return HTML table for object lines TODO Move this into an output class file (htmlline.class.php) If lines are into a template, title must also be into a template But for the moment we don't know if it's possible as we keep a method available on overloaded objects.

Parameters

string $action

Action code

Societe $seller

Object of seller third party

Societe $buyer

Object of buyer third party

int<0, max> $selected

ID line selected

int $dateSelector

1=Show also date range input fields @param string $defaulttpldir Directory where to find the template

$defaulttpldir

Return Value

void

void printObjectLine(string $action, CommonObjectLine $line, "" $var, int $num, int $i, int $dateSelector, Societe $seller, Societe $buyer, int<0, max> $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl')

Return HTML content of a detail line TODO Move this into an output class file (htmlline.class.php)

Parameters

string $action

GET/POST action

CommonObjectLine $line

Selected object line to output

"" $var

Not used

int $num

Number of line (0)

int $i I
int $dateSelector

1=Show also date range input fields

Societe $seller

Object of seller third party

Societe $buyer

Object of buyer third party

int<0, max> $selected

ID line selected @param ?ExtraFields $extrafields Object of extrafields @param string $defaulttpldir Directory where to find the template (deprecated)

$extrafields
$defaulttpldir

Return Value

void

printOriginLinesList(""|"services" $restrictlist = '', $selectedLines = array())

Return HTML table table of source object lines TODO Move this and previous function into output html class file (htmlline.class.php).

If lines are into a template, title must also be into a template But for the moment we don't know if it's possible, so we keep the method available on overloaded objects.

Parameters

""|"services" $restrictlist

''=All lines, 'services'=Restrict to services only @param int[] $selectedLines Array of lines id for selected lines @return void

$selectedLines

printOriginLine(CommonObjectLine $line, $var, string $restrictlist = '', $defaulttpldir = '/core/tpl', $selectedLines = array())

Return HTML with a line of table array of source object lines TODO Move this and previous function into output html class file (htmlline.class.php).

If lines are into a template, titles must also be into a template But for the moment we don't know if it's possible as we keep a method available on overloaded objects.

Parameters

CommonObjectLine $line

Line @param string $var Not used

$var
string $restrictlist

''=All lines, 'services'=Restrict to services only (strike line if not) @param string $defaulttpldir Directory where to find the template @param int[] $selectedLines Array of lines id for selected lines @return void

$defaulttpldir
$selectedLines

int add_element_resource(int $resource_id, string $resource_type, int $busy = 0, int $mandatory = 0, $notrigger = 0)

Add resources to the current object : add entry into llx_element_resources Need $this->element & $this->id

Parameters

int $resource_id

Resource id

string $resource_type 'resource'
int $busy

Busy or not

int $mandatory

Mandatory or not @param int $notrigger Disable all triggers

$notrigger

Return Value

int

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

delete_resource($rowid, string $element = '', $notrigger = 0)

Delete a link to resource line

@param int $rowid Id of resource line to delete

Parameters

$rowid
string $element

element name (for trigger) replaced by $this->TRIGGER_PREFIX @param int $notrigger Disable all triggers @return int >0 if OK, <0 if KO

$notrigger

void __clone()

Overwrite magic function to solve problem of cloning object that are kept as references

Return Value

void

protected int<-1, 1> commonGenerateDocument(string $modelspath, string $modele, Translate $outputlangs, int<0, 1> $hidedetails, int<0, 1> $hidedesc, int<0, 1> $hideref, ?array<string, mixed> $moreparams = null)

Common function for all objects extending CommonObject for generating documents

Parameters

string $modelspath

Relative folder where generators are placed

string $modele

Generator to use. Caller must set it to from obj->model_pdf or from GETPOST for example.

Translate $outputlangs

Output language to use

int<0, 1> $hidedetails

1 to hide details. 0 by default

int<0, 1> $hidedesc

1 to hide product description. 0 by default

int<0, 1> $hideref

1 to hide product reference. 0 by default

?array<string, mixed> $moreparams

Array to provide more information

Return Value

int<-1, 1>

0 if OK, <0 if KO

See also

addFileIntoDatabaseIndex()

int indexFile(string $destfull, int $update_main_doc_field)

Index a file into the ECM database

Parameters

string $destfull

Full path of file to index

int $update_main_doc_field

Update field main_doc field into the table of the object. This param is set when called for a document generation if document generator hase ->update_main_doc_field set and returns ->result['fullpath'].

Return Value

int

Return integer <0 if KO, >0 if OK

void addThumbs(string $file, $quality = 50)

Build thumb

@todo Move this into files.lib.php

Parameters

string $file

Path file in UTF8 to original file to create thumbs from. @param int $quality Quality after compression (0=worst so better compression, 100=best so low or no compression). For thumbs, we force quality to 50 by default.

$quality

Return Value

void

void delThumbs(string $file)

Delete thumbs

@todo Move this into files.lib.php

Parameters

string $file

Path file in UTF8 to original file to delete thumbs.

Return Value

void

string|string[] getDefaultCreateValueFor(string $fieldname, string $alternatevalue = null, string $type = 'alphanohtml')

Return the default value to use for a field when showing the create form of object.

Return values in this order: 1) If parameter is available into POST, we return it first. 2) If not but an alternate value was provided as parameter of function, we return it. 3) If not but a constant $conf->global->OBJECTELEMENT_FIELDNAME is set, we return it (It is better to use the dedicated table). 4) Return value found into database (TODO No yet implemented)

Parameters

string $fieldname

Name of field

string $alternatevalue

Alternate value to use

string $type

Type of data

Return Value

string|string[]

Default value (can be an array if the GETPOST return an array)

int<-1, 1> fetchValuesForExtraLanguages()

Function to get alternative languages of a data into $this->array_languages This method is NOT called by method fetch of objects but must be called separately.

Used for example when PDF_USE_ALSO_LANGUAGE_CODE is set to a language for the name of a thirdparty.

Return Value

int<-1, 1>

Return integer <0 if error, 0 if no values of alternative languages to find nor found, 1 if a value was found and loaded fetch_optionnals()

int<-1, 1> setValuesForExtraLanguages(string $onlykey = '')

Fill array_options property of object by extrafields value (using for data sent by forms) Used for example when PDF_USE_ALSO_LANGUAGE_CODE is set to a language for the name of a thirdparty.

Parameters

string $onlykey

Only the following key is filled. When we make update of only one language field ($action = 'update_languages'), calling page must set this to avoid to have other languages being reset.

Return Value

int<-1, 1>

1 if array_options set, 0 if no value, -1 if error (field required missing for example)

int<-1, 1> fetchNoCompute(int $id)

Function to make a fetch but set environment to avoid to load computed values before.

Parameters

int $id

ID of object

Return Value

int<-1, 1>

0 if OK, 0 if not found, <0 if KO

fetch_optionals($rowid = null, array{}|array{label: array<string, string>, type: array<string, string>, size: array<string, string>, default: array<string, string>, computed: array<string, string>, unique: array<string, int>, required: array<string, int>, param: array<string, mixed>, perms: array<string, mixed[]>, list: array<string, int>|array<string, string>, pos: array<string, int>, totalizable: array<string, int>, help: array<string, string>, printable: array<string, int>, enabled: array<string, int>, langfile: array<string, string>, css: array<string, string>, csslist: array<string, string>, hidden: array<string, int>, mandatoryfieldsofotherentities?: array<string, string>, loaded?: int, count: int} $optionsArray = null)

Function to get extra fields of an object into $this->array_options This method is in most cases called by method fetch of objects but you can call it separately.

@param int $rowid Id of line. Use the id of object if not defined. Deprecated. Function must be called without parameters.

Parameters

$rowid
array{}|array{label: array<string, string>, type: array<string, string>, size: array<string, string>, default: array<string, string>, computed: array<string, string>, unique: array<string, int>, required: array<string, int>, param: array<string, mixed>, perms: array<string, mixed[]>, list: array<string, int>|array<string, string>, pos: array<string, int>, totalizable: array<string, int>, help: array<string, string>, printable: array<string, int>, enabled: array<string, int>, langfile: array<string, string>, css: array<string, string>, csslist: array<string, string>, hidden: array<string, int>, mandatoryfieldsofotherentities?: array<string, string>, loaded?: int, count: int} $optionsArray

Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters. @return int<-1,1> Return integer <0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded fetchValuesForExtraLanguages()

deleteExtraFields()

Delete all extra fields values for the current object.

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

insertExtraFields(string $trigger = '', $userused = null)

Add/Update all extra fields values for the current object.

Data to describe values to insert/update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) This function delete record with all extrafields and insert them again from the array $this->array_options.

Parameters

string $trigger

If defined, call also the trigger (for example COMPANY_MODIFY). Must be used for action 'update_extras'. For other actions, trigger is called explicitly by caller. @param User $userused Object user @return int<-1,1> -1=error, O=did nothing, 1=OK insertExtraLanguages(), updateExtraField(), deleteExtraField(), setValueFrom()

$userused

insertExtraLanguages(string $trigger = '', $userused = null)

Add/Update all extra languages values for the current object.

Data to describe values to insert/update are stored into $this->array_languages=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) This function delete record with all languages and insert them again from the array $this->array_languages. Used for example when PDF_USE_ALSO_LANGUAGE_CODE is set to a language for the name of a thirdparty.

Parameters

string $trigger

If defined, call also the trigger (for example COMPANY_MODIFY) @param User $userused Object user @return int<-1,1> -1=error, O=did nothing, 1=OK insertExtraFields(), updateExtraField(), setValueFrom()

$userused

updateExtraField(string $key, $trigger = null, $userused = null)

Update 1 extra field value for the current object. Keep other fields unchanged.

Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)

Parameters

string $key

Key of the extrafield to update (without starting 'options_') @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY) @param User $userused Object user @return int<-1,1> -1=error, O=did nothing, 1=OK updateExtraLanguages(), insertExtraFields(), deleteExtraFields(), setValueFrom()

$trigger
$userused

mixed|null getExtraField(string $key)

Convenience method for retrieving the value of an extrafield without actually fetching it from the database.

Parameters

string $key

Name of the extrafield

Return Value

mixed|null

void setExtraField(string $key, mixed $value)

Convenience method for setting the value of an extrafield without actually updating it in the database.

Parameters

string $key

Name of the extrafield

mixed $value

Value to be assigned to the extrafield

Return Value

void

updateExtraLanguages(string $key, $trigger = null, $userused = null)

Update an extra language value for the current object.

Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)

Parameters

string $key

Key of the extrafield (without starting 'options_') @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY) @param User $userused Object user @return int -1=error, O=did nothing, 1=OK updateExtraField(), insertExtraLanguages()

$trigger
$userused

string showInputField(?array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $val, string $key, string|string[] $value, string $moreparam = '', string $keysuffix = '', string $keyprefix = '', string|int $morecss = 0, int<0, 1> $nonewbutton = 0)

Return HTML string to put an input field into a page Code very similar with showInputField of extra fields

Parameters

?array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $val

Array of properties for field to show (used only if ->fields not defined, so try to keep this null)

string $key

Key of attribute

string|string[] $value

Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value, for array type must be array)

string $moreparam

To add more parameters on html input tag

string $keysuffix

Suffix string to add into name and id of field (can be used to avoid duplicate names)

string $keyprefix

Prefix string to add into name and id of field (can be used to avoid duplicate names)

string|int $morecss

Value for css to define style/length of field. May also be a numeric.

int<0, 1> $nonewbutton

Force to not show the new button on field that are links to object

Return Value

string

string showOutputField(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $val, string $key, string $value, string $moreparam = '', string $keysuffix = '', string $keyprefix = '', mixed $morecss = '')

Return HTML string to show a field into a page Code very similar with showOutputField of extra fields

Parameters

array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $val

Array of properties of field to show

string $key

Key of attribute

string $value

Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)

string $moreparam

To add more parameters on html tag

string $keysuffix

Prefix string to add into name and id of field (can be used to avoid duplicate names)

string $keyprefix

Suffix string to add into name and id of field (can be used to avoid duplicate names)

mixed $morecss

Value for CSS to use (Old usage: May also be a numeric to define a size).

Return Value

string

void clearFieldError(string $fieldKey)

clear validation message result for a field

Parameters

string $fieldKey

Key of attribute to clear

Return Value

void

void setFieldError(string $fieldKey, string $msg = '')

set validation error message a field

Parameters

string $fieldKey

Key of attribute

string $msg

the field error message

Return Value

void

string getFieldError(string $fieldKey)

get field error message

Parameters

string $fieldKey

Key of attribute

Return Value

string

Error message of validation ('' if no error)

bool validateField(array<string, array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int<-2, 5>|string, alwayseditable?: int<0, 1>, noteditable?: int<0, 1>, default?: string, index?: int, foreignkey?: string, searchall?: int<0, 1>, isameasure?: int<0, 1>, css?: string, csslist?: string, help?: string, showoncombobox?: int<0, 2>, disabled?: int<0, 1>, arrayofkeyval?: array<int, string>, autofocusoncreate?: int<0, 1>, comment?: string, copytoclipboard?: int<1, 2>, validate?: int<0, 1>}> $fields, string $fieldKey, string $fieldValue)

Return validation test result for a field

Parameters

array<string, array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int<-2, 5>|string, alwayseditable?: int<0, 1>, noteditable?: int<0, 1>, default?: string, index?: int, foreignkey?: string, searchall?: int<0, 1>, isameasure?: int<0, 1>, css?: string, csslist?: string, help?: string, showoncombobox?: int<0, 2>, disabled?: int<0, 1>, arrayofkeyval?: array<int, string>, autofocusoncreate?: int<0, 1>, comment?: string, copytoclipboard?: int<1, 2>, validate?: int<0, 1>}> $fields

Array of properties of field to show

string $fieldKey

Key of attribute

string $fieldValue

Value of attribute

Return Value

bool

Return false if fail true on success, see $this->error for error message

string showOptionals(ExtraFields $extrafields, string $mode = 'view', array<string, mixed> $params = null, string $keysuffix = '', string $keyprefix = '', string $onetrtd = '', string $display_type = 'card')

Function to show lines of extrafields with output data.

This function is responsible to output the and according to correct number of columns received into $params['colspan'] or

according to $display_type

Parameters

ExtraFields $extrafields

Extrafield Object

string $mode

Show output ('view') or input ('create' or 'edit') for extrafield

array<string, mixed> $params

Optional parameters. Example: array('style'=>'class="oddeven"', 'colspan'=>$colspan)

string $keysuffix

Suffix string to add after name and id of field (can be used to avoid duplicate names)

string $keyprefix

Prefix string to add before name and id of field (can be used to avoid duplicate names)

string $onetrtd

All fields in same tr td. Used by objectline_create.tpl.php for example.

string $display_type

"card" for form display, "line" for document line display (extrafields on propal line, order line, etc...)

Return Value

string

String with html content to show

string getJSListDependancies(string $type = '_extra')

No description

Parameters

string $type

Type for prefix

Return Value

string

JavaScript code to manage dependency

null|int|stdClass getRights()

Returns the rights used for this class

Return Value

null|int|stdClass

Object of permission for the module

static bool commonReplaceThirdparty(DoliDB $dbs, int $origin_id, int $dest_id, array $tables, int<0, 1> $ignoreerrors = 0)

Function used to replace a thirdparty id with another one.

This function is meant to be called from replaceThirdparty with the appropriate tables Column name fk_soc MUST exist.

Parameters

DoliDB $dbs

Database handler

int $origin_id

Old thirdparty id (the thirdparty to delete)

int $dest_id

New thirdparty id (the thirdparty that will received element of the other)

array $tables

Tables that need to be changed

int<0, 1> $ignoreerrors

Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old thirdparty may already exists on new one)

Return Value

bool

True if success, False if error

static bool commonReplaceProduct(DoliDB $dbs, int $origin_id, int $dest_id, array $tables, int<0, 1> $ignoreerrors = 0)

Function used to replace a product id with another one.

This function is meant to be called from replaceProduct with the appropriate tables Column name fk_product MUST be used to identify products

Parameters

DoliDB $dbs

Database handler

int $origin_id

Old product id (the product to delete)

int $dest_id

New product id (the product that will received element of the other)

array $tables

Tables that need to be changed

int<0, 1> $ignoreerrors

Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old product may already exists on new one)

Return Value

bool

True if success, False if error

float|int<-2, -1> defineBuyPrice(float $unitPrice = 0.0, float $discountPercent = 0.0, int $fk_product = 0)

Get buy price to use for margin calculation. This function is called when buy price is unknown.

Set buy price = sell price if ForceBuyingPriceIfNull configured, elseif calculation MARGIN_TYPE = 'costprice' and costprice is defined, use costprice as buyprice elseif calculation MARGIN_TYPE = 'pmp' and pmp is calculated, use pmp as buyprice else set min buy price as buy price

Parameters

float $unitPrice

Product unit price

float $discountPercent

Line discount percent

int $fk_product

Product id

Return Value

float|int<-2, -1>

Return buy price if OK, integer <0 if KO

array{dir: string, file: string, originalfile: string, altfile: string, email: string, capture: string} getDataToShowPhoto(string $modulepart, string $imagesize)

Function used to get the logos or photos of an object

Parameters

string $modulepart

Module part

string $imagesize

Image size ('', 'mini' or 'small')

Return Value

array{dir: string, file: string, originalfile: string, altfile: string, email: string, capture: string}

Array of data to show photo

show_photos($modulepart, string $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $overwritetitle = 0, $usesharelink = 0, $cache = '', $addphotorefcss = 'photoref')

Show photos of an object (nbmax maximum), into several columns

@param string $modulepart 'product', 'ticket', ...

Parameters

$modulepart
string $sdir

Directory to scan (full absolute path) @param int<0,1>|''|'small' $size 0 or ''=original size, 1 or 'small'=use thumbnail if possible @param int $nbmax Nombre maximum de photos (0=pas de max) @param int $nbbyrow Number of image per line or -1 to use div separator or 0 to use no separator. Used only if size=1 or 'small'. @param int $showfilename 1=Show filename @param int $showaction 1=Show icon with action links (resize, delete) @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image. @param int $maxWidth Max width of original image when size='small' @param int $nolink Do not add a href link to view enlarged imaged into a new tab @param int|string $overwritetitle Do not add title tag on image @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead) @param string $cache A string if we want to use a cached version of image @param string $addphotorefcss Add CSS to img of photos @return string Html code to show photo. Number of photos shown is saved in this->nbphoto

$size
$nbmax
$nbbyrow
$showfilename
$showaction
$maxHeight
$maxWidth
$nolink
$overwritetitle
$usesharelink
$cache
$addphotorefcss

protected bool isArray(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is array

Parameters

array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info

content information of field

Return Value

bool

true if array

bool isDate(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is date

Parameters

array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info

content information of field

Return Value

bool

true if date

bool isDuration(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is duration

Parameters

array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info

content information of field

Return Value

bool

true if field of type duration

bool isInt(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is integer

Parameters

array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info

Properties of field

Return Value

bool

true if integer

bool isFloat(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is float

Parameters

array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info

content information of field

Return Value

bool

true if float

bool isText(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if type is text

Parameters

array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info

Properties of field

Return Value

bool

true if type text

protected bool canBeNull(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if field can be null

Parameters

array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info

content information of field

Return Value

bool

true if it can be null

protected bool isForcedToNullIfZero(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if field is forced to null if zero or empty

Parameters

array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info

content information of field

Return Value

bool

true if forced to null

protected bool isIndex(array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info)

Function test if is indexed

Parameters

array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $info

content information of field

Return Value

bool

protected array<string, null|int|float|string> setSaveQuery()

Function to return the array of data key-value from the ->fields and all the ->properties of an object.

Note: $this->${field} are set by the page that make the createCommon() or the updateCommon(). $this->${field} should be a clean and string value (so date are formatted for SQL insert).

Return Value

array<string, null|int|float|string>

Array with all values of each property to update

void setVarsFromFetchObj(stdClass $obj)

Function to load data from a SQL pointer into properties of current object $this

Parameters

stdClass $obj

Contain data of object from database

Return Value

void

void emtpyObjectVars()

Sets all object fields to null. Useful for example in lists, when printing multiple lines and a different object os fetched for each line.

Return Value

void

string getFieldList(string $alias = '', string[] $excludefields = array())

Function to concat keys of fields

Parameters

string $alias

String of alias of table for fields. For example 't'. It is recommended to use '' and set alias into fields definition.

string[] $excludefields

Array of fields to exclude

Return Value

string

List of alias fields

protected string|int quote(string|int $value, array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $fieldsentry)

Add quote to field value if necessary

Parameters

string|int $value

Value to protect

array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int, noteditable?: int, default?: string, index?: int, foreignkey?: string, searchall?: int, isameasure?: int, css?: string, csslist?: string, help?: string, showoncombobox?: int, disabled?: int, arrayofkeyval?: array<int, string>, comment?: string} $fieldsentry

Properties of field

Return Value

string|int

int<-1, max> createCommon(User $user, int<0, 1> $notrigger = 0)

Create object in the database

Parameters

User $user

User that creates

int<0, 1> $notrigger

0=launch triggers after, 1=disable triggers

Return Value

int<-1, max>

Return integer <0 if KO, Id of created object if OK

int<-4, 1> fetchCommon(int $id, ?string $ref = null, string $morewhere = '', int<0, 1> $noextrafields = 0)

Load object in memory from the database. This does not load line. This is done by parent fetch() that call fetchCommon

Parameters

int $id

Id object

?string $ref Ref
string $morewhere

More SQL filters (' AND ...')

int<0, 1> $noextrafields

0=Default to load extrafields, 1=No extrafields

Return Value

int<-4, 1>

Return integer <0 if KO, 0 if not found, >0 if OK

int<-1, 1> fetchLinesCommon(string $morewhere = '', int<0, 1> $noextrafields = 0)

Load object in memory from the database

Parameters

string $morewhere

More SQL filters (' AND ...'). No user coming from user input are allowed here. Only hard coded values.

int<0, 1> $noextrafields

0=Default to load extrafields, 1=No extrafields

Return Value

int<-1, 1>

Return integer <0 if KO, 0 if not found, >0 if OK

int<-1, 1> updateCommon(User $user, int<0, 1> $notrigger = 0)

Update object into database

Parameters

User $user

User that modifies

int<0, 1> $notrigger

0=launch triggers after, 1=disable triggers

Return Value

int<-1, 1>

Return integer <0 if KO, >0 if OK

int<-1, 1> deleteCommon(User $user, int<0, 1> $notrigger = 0, int<0, 1> $forcechilddeletion = 0)

Delete object in database

Parameters

User $user

User that deletes

int<0, 1> $notrigger

0=launch triggers after, 1=disable triggers

int<0, 1> $forcechilddeletion

0=no, 1=Force deletion of children

Return Value

int<-1, 1>

Return integer <0 if KO, 0=Nothing done because object has child, >0 if OK

int deleteByParentField(int $parentId = 0, string $parentField = '', string $filter = '', string $filtermode = "AND")

Delete all child object from a parent ID

Parameters

int $parentId

Parent Id

string $parentField

Name of Foreign key parent column

string $filter

Filter as an Universal Search string. Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'

string $filtermode

No more used

Return Value

int

Return integer <0 if KO, >0 if OK

Exceptions

Exception

deleteLineCommon(User $user, $idline, $notrigger = 0)

Delete a line of object in database

Parameters

User $user

User that delete @param int $idline Id of line to delete @param int $notrigger 0=launch triggers after, 1=disable triggers @return int >0 if OK, <0 if KO

$idline
$notrigger

int setStatusCommon(User $user, $status, $notrigger = 0, $triggercode = '')

Set to a status

Parameters

User $user

Object user that modify @param int $status New status to set (often a constant like self::STATUS_XXX) @param int $notrigger 1=Does not execute triggers, 0=Execute triggers @param string $triggercode Trigger code to use

$status
$notrigger
$triggercode

Return Value

int

Return integer <0 if KO, >0 if OK setStatut()

int initAsSpecimenCommon()

Initialise object with example values Id must be 0 if object instance is a specimen

Return Value

int

int<0, max>|-1 fetchComments()

Load comments linked with current task

Return Value

int<0, max>|-1

Returns the number of comments if OK, -1 if error

int getNbComments()

Return nb comments already posted

Return Value

int

void trimParameters(string[] $parameters)

Trim object parameters

Parameters

string[] $parameters

array of parameters to trim

Return Value

void

int[]|int getCategoriesCommon(string $type_categ)

Sets object to given categories.

Deletes object from existing categories not supplied. Adds it to non existing supplied categories. Existing categories are left untouch.

Parameters

string $type_categ

Category type ('customer', 'supplier', 'website_page', ...)

Return Value

int[]|int

Array of category IDs or < 0 if KO

int setCategoriesCommon(int[]|int $categories, string $type_categ = '', bool $remove_existing = true)

Sets object to given categories.

Assign the object to all categories not yet assigned. Unasign object from existing categories not supplied in $categories (if remove_existing==true). If remove_existing is false, existing categories are left untouch.

Parameters

int[]|int $categories

Category ID or array of Categories IDs

string $type_categ

Category type ('customer', 'supplier', 'website_page', ...) defined into const class Categorie type

bool $remove_existing

True: Remove existings categories from Object if not supplies by $categories, False: let them

Return Value

int

Return integer <0 if KO, >0 if OK

int cloneCategories(int $fromId, int $toId, string $type = '')

Copy related categories to another object

Parameters

int $fromId

Id object source

int $toId

Id object cible

string $type

Type of category ('product', ...)

Return Value

int

Return integer < 0 if error, > 0 if ok

bool deleteEcmFiles(int $mode = 0)

Delete related files of object in database

Parameters

int $mode

0=Use path to find record, 1=Use src_object_xxx fields (Mode 1 is recommended for new objects)

Return Value

bool

True if OK, False if KO

bool checkActiveProductInLines(string $status = 'onsale')

Check if all products have the right status (on sale, on buy) called during validation of propal, order, supplier proposal, supplier order

Parameters

string $status

onsale or onbuy

Return Value

bool

void setErrorWithoutLog(string $message)

Set the error message for the object without logging it.

Parameters

string $message

the error message

Return Value

void

void setErrorWithLog(string $message, int<0, 7> $loglevel = LOG_ERR)

Set the error message for the object and log it.

Parameters

string $message

the error message

int<0, 7> $loglevel

the log level

Return Value

void

display_incoterms()

Return incoterms information TODO Use a cache for label get

@return string incoterms info

getIncotermsForPDF()

Return incoterms information for pdf display

@return string|boolean Incoterms info or false

setIncoterms($id_incoterm, string $location)

Define incoterms values of current object

@param int $id_incoterm Id of incoterm to set or '' to remove

Parameters

$id_incoterm
string $location

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

float|string getRemainToPay(int $multicurrency = 0)

Return remain amount to pay. Property ->id and ->total_ttc must be set.

This does not include open direct debit requests.

Parameters

int $multicurrency

Return multicurrency_amount instead of amount

Return Value

float|string

Remain of amount to pay

float|int|array{alreadypaid: float, alreadypaid_multicurrency: float} getSommePaiement(int<-1, 1> $multicurrency = 0)

Return amount of payments already done. This must include ONLY the record into the payment table.

Payments done using discounts, credit notes, etc are not included. This also set ->totalpaid and ->totalpaid_multicurrency

Parameters

int<-1, 1> $multicurrency

Return multicurrency_amount instead of amount. -1=Return both.

Return Value

float|int|array{alreadypaid: float, alreadypaid_multicurrency: float}

Amount of payment already done, <0 and set ->error if KO getSumDepositsUsed(), getSumCreditNotesUsed()

getSumDepositsUsed($multicurrency = 0)

Return amount (with tax) of all deposits invoices used by invoice.

Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on for sale invoices (not recommended), of FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS is on for purchase invoices (not recommended).

Parameters

$multicurrency

getSumCreditNotesUsed($multicurrency = 0)

Return amount (with tax) of all credit notes invoices + excess received used by invoice

@param      int     $multicurrency      Return multicurrency_amount instead of amount

Parameters

$multicurrency

float getSumFromThisCreditNotesNotUsed($multicurrency = 0)

Return amount (with tax) of all converted amount for this credit note

@param      int     $multicurrency  Return multicurrency_amount instead of amount

Parameters

$multicurrency

Return Value

float

Return integer <0 if KO, Sum of credit notes and deposits amount otherwise

int[] getListIdAvoirFromInvoice()

Returns array of credit note ids from the invoice

Return Value

int[]

Array of credit note ids

int getIdReplacingInvoice(string $option = '')

Returns the id of the invoice that replaces it

Parameters

string $option

status filter ('', 'validated', ...)

Return Value

int

Return integer <0 si KO, 0 if no invoice replaces it, id of invoice otherwise

array<array{id: int, invoiceid: int, date: ""|int, amount: float}> getListOfOpenDirectDebitOrCreditTransfer($type)

Return list of open direct debit or credit transfer

@param 'bank-transfer'|'direct-debit' $type 'bank-transfer' or 'direct-debit'

Parameters

$type

Return Value

array<array{id: int, invoiceid: int, date: ""|int, amount: float}>

Array with list of payments

getListOfPayments(string $filtertype = '', $multicurrency = 0, $mode = 0)

Return list of payments

$error Empty string '' if no error.

Parameters

string $filtertype

1 to filter on type of payment == 'PRE' for the payment lines @param int $multicurrency Return multicurrency_amount instead of amount @param int $mode 0=payments + discount, 1=payments only @return array<array{amount:int|float,date:int,num:string,ref:string,ref_ext?:string,fk_bank_line?:int,type:string}> Array with list of payments

$multicurrency
$mode

int isEditable()

Return if an invoice can be set back to draft.

Rule is: If invoice is draft and has a temporary ref -> yes (1) If hidden option INVOICE_CAN_NEVER_BE_REMOVED is 1 -> no (0) If invoice is transferred in bookkeeping -> no (-1) If invoice has a definitive ref, is not last in ref -> no (-2) If invoice has a definitive ref, is not last in a situation cycle -> no (-3) If there is one payment -> no (-4) If already sent by email -> no (-5) If already printed -> no (-6) If running a LNE version and customer invoice was validated -> no (-7) Otherwise -> yes (2)

Return Value

int

Return integer <=0 if no, >0 if yes

is_erasable()

Return if an invoice can be deleted Rule is: If invoice is draft and has a temporary ref -> yes (1) If hidden option INVOICE_CAN_NEVER_BE_REMOVED is 1 -> no (0) If invoice is transferred in bookkeeping -> no (-1) If invoice has a definitive ref, is not last in ref -> no (-2) If invoice has a definitive ref, is not last in a situation cycle -> no (-3) If there is one payment -> no (-4) If already sent by email -> no (-5) If already printed -> no (-6) If running a LNE version and customer invoice was validated -> no (-7) Other value (may be returned by a hook -10, -11, ...) Otherwise -> yes (2)

@return int Return integer <=0 if no, >0 if yes

int getVentilExportCompta(int $mode = 0)

Return if an invoice was transferred into accountnancy.

This is true if at least on line was transferred into table accounting_bookkeeping

Parameters

int $mode

0=Return nb of record, 1=return the transaction ID (piece_num)

Return Value

int

Return integer <0 if KO, 0=no, nb transaction=yes or ID transaction

string getNextNumRef(Societe $soc, string $mode = 'next')

Return next reference of customer invoice not already used (or last reference) according to numbering module defined into constant FACTURE_ADDON

@param Societe $soc object company

Parameters

Societe $soc

Thirdparty object

string $mode

'next' for next value or 'last' for last value

Return Value

string

free ref or last ref

string getLibType(int $withbadge = 0)

Return label of type of invoice

Parameters

int $withbadge

1=Add span for badge css, 2=Add span and show short label

Return Value

string

Label of type of invoice

string|int getSubtypeLabel($table = '')

Return label of invoice subtype

@param string $table table of invoice

Parameters

$table

Return Value

string|int

Label of invoice subtype or -1 if error

array<int, string>|array<string, int> getArrayOfInvoiceSubtypes($mode = 0)

Retrieve a list of invoice subtype labels or codes.

@param  int<0,1>    $mode       0=Return id+label, 1=Return code+id

Parameters

$mode

Return Value

array<int, string>|array<string, int>

Array of subtypes

getLibStatut($mode = 0, int|float $alreadypaid = -1)

Return label of object status

@param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto

Parameters

$mode
int|float $alreadypaid

0=No payment already done, >0=Some payments were already done (we recommend to put here float amount paid if you have it, 1 otherwise) @return string Label of status

string LibStatut(int $paye, int $status, int<0, 6> $mode = 0, int|float $alreadypaid = -1, int $type = -1, $moreparams = array())

Return label of a status

Parameters

int $paye

Field to 1 if invoice is closed (TODO Detect this using $status instead of using this param).

int $status

ID status

int<0, 6> $mode

0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto

int|float $alreadypaid

0=No payment already done, >0=Some payments were already done (we recommend to put here float amount paid if you have it, -1 otherwise)

int $type

Type invoice. If -1, we use $this->type @param int|array<string,int|string> $moreparams More params. Example: array('nbofopendirectdebitorcredittransfer' => x) for nb of open direct debit or credit transfer

$moreparams

Return Value

string

Label of status

calculate_date_lim_reglement(int $cond_reglement = 0)

Returns an invoice payment deadline based on the invoice settlement conditions and billing date.

Parameters

int $cond_reglement

Condition of payment (code or id) to use. If 0, we use current condition. @return int|string Date limit of payment if OK, <0 or string if KO

demande_prelevement(User $fuser, float $amount = 0, string $type = 'direct-debit', string $sourcetype = 'facture', int $checkduplicateamongall = 0, int $ribId = 0)

Create a withdrawal request for a direct debit order or a credit transfer order.

Use the remain to pay excluding all existing open direct debit requests.

Parameters

User $fuser

User asking the direct debit transfer @param float $amount Amount we request direct debit for @param string $type 'direct-debit' or 'bank-transfer' @param string $sourcetype Source ('facture' or 'supplier_invoice') @param int $checkduplicateamongall 0=Default (check among open requests only to find if request already exists). 1=Check also among requests completely processed and cancel if at least 1 request exists whatever is its status. @param int $ribId If defined, will use this ID to get the RIB. Otherwise, the default RIB will be taken. @return int Return integer <0 if KO, 0 if a request already exists, >0 if OK

float $amount
string $type
string $sourcetype
int $checkduplicateamongall
int $ribId

int makeStripeCardRequest(User $fuser, $id, $sourcetype = 'facture')

Create a payment with Stripe card Must take amount using Stripe and record an event into llx_actioncomm Record bank payment Send email to customer ?

Parameters

User $fuser

User asking the direct debit transfer @param int $id Invoice ID with remain to pay @param string $sourcetype Source ('facture' or 'supplier_invoice')

$id
$sourcetype

Return Value

int

Return integer <0 if KO, >0 if OK

int makeStripeSepaRequest(User $fuser, $did, $type = 'direct-debit', $sourcetype = 'facture', $service = '', $forcestripe = '')

Create a direct debit order into prelevement_bons for a given prelevement_request, then Send the payment order to the service (for a direct debit order or a credit transfer order) and record an event in llx_actioncomm.

Parameters

User $fuser

User asking the direct debit transfer @param int $did ID of unitary payment request to pay @param string $type 'direct-debit' or 'bank-transfer' @param string $sourcetype Source ('facture' or 'supplier_invoice') @param string $service 'StripeTest', 'StripeLive', ... @param string $forcestripe To force another stripe env: 'cusaccount@pk...:sk_...'

$did
$type
$sourcetype
$service
$forcestripe

Return Value

int

Return integer <0 if KO, >0 if OK

demande_prelevement_delete($fuser, int $did)

Remove a direct debit request or a credit transfer request

@param User $fuser User making delete

Parameters

$fuser
int $did

ID of request to delete @return int Return integer <0 if OK, >0 if KO

string buildEPCQrCodeString()

Build string for EPC QR Code

Return Value

string

String for EPC QR Code

string buildZATCAQRString()

Build string for ZATCA QR Code (Arabi Saudia)

Return Value

string

String for ZATCA QR Code

string buildSwitzerlandQRString()

Build string for QR-Bill (Switzerland)

Return Value

string

String for Switzerland QR Code if QR-Bill

int addSubtotalLine(Translate $langs, string $desc, int $depth, array<string, string>|string $options = array(), int $parent_line = 0)

Adds a subtotals line to a document.

This function inserts a subtotal line based on the given parameters.

Parameters

Translate $langs Translation.
string $desc

Description of the line.

int $depth

Level of the line (>0 for title lines, <0 for subtotal lines)

array<string, string>|string $options

Subtotal options for pdf view

int $parent_line

ID of the parent line for shipments

Return Value

int

ID of the added line if successful, 0 on warning, -1 on error

int deleteSubtotalLine(Translate $langs, int $id, bool $correspondingstline = false, User $user = null)

Deletes a subtotal or a title line from a document.

If the corresponding subtotal line exists and second parameter true, it will also be deleted.

Parameters

Translate $langs Translation.
int $id

ID of the line to delete

bool $correspondingstline

If true, also deletes the corresponding subtotal line

User $user

performing the deletion (used for permissions in some modules)

Return Value

int

ID of deleted line if successful, -1 on error

int updateSubtotalLine(Translate $langs, int $lineid, string $desc, int $depth, array<string, string>|string $options)

Updates a subtotal line of a document.

This function updates a subtotals line based on its id and the given parameters. Updating a title line updates the corresponding subtotal line except options.

Parameters

Translate $langs Translation.
int $lineid

ID of the line to update.

string $desc

Description of the line.

int $depth

Level of the line (>0 for title lines, <0 for subtotal lines)

array<string, string>|string $options

Subtotal options for pdf view

Return Value

int

ID of the added line if successful, 0 on warning, -1 on error

int updateSubtotalLineBlockLines(Translate $langs, int $linerang, string $mode, int $value)

Updates a block of lines of a document.

Parameters

Translate $langs Translation.
int $linerang

Rang of the line to start from.

string $mode

Column to change (discount or vat).

int $value

Value of the change.

Return Value

int

Return integer < 0 if KO, 1 if OK

string getSubtotalLineAmount(object $line)

Return the total_ht of lines that are above the current line (excluded) and that are not a subtotal line until a title line of the same level is found

Parameters

object $line

Line that needs the subtotal amount.

Return Value

string $total_ht

string getSubtotalLineMulticurrencyAmount(object $line)

Return the multicurrency_total_ht of lines that are above the current line (excluded) and that are not a subtotal line until a title line of the same level is found

Parameters

object $line

Line that needs the subtotal amount with multicurrency mod activated.

Return Value

string $total_ht

string|null getSubtotalColors(int|float $level)

Retrieve the background color associated with a specific subtotal level.

Parameters

int|float $level

The level of the subtotal for which the color is requested.

Return Value

string|null

The background color in hexadecimal format or null if not set.

array<string, string> getPossibleTitles()

Retrieve current object possible titles to choose from

Return Value

array<string, string>

The set of titles, empty if no title line set.

array<int, string> getPossibleLevels(Translate $langs)

Retrieve the current object possible levels (defined in admin page)

Parameters

Translate $langs Translations.

Return Value

array<int, string>

The set of possible levels, empty if not defined correctly.

int[] getDisabledShippmentSubtotalLines()

Returns an array with the IDs of the line that we don't need to show to avoid empty blocks

Return Value

int[] $total_ht

__construct(DoliDB $db)

Constructor

@param  DoliDB      $db         Database handler

Parameters

DoliDB $db

int create(User $user, int $notrigger = 0, $forceduedate = 0, $updatecurrencyrate = 0)

Create invoice in database.

Note: this->ref can be set or empty. If empty, we will use "(PROV999)" Note: this->fac_rec must be set to create invoice from a recurring invoice

Parameters

User $user

Object user that create

int $notrigger

1=Does not execute triggers, 0 otherwise @param int $forceduedate If set, do not recalculate due date from payment condition but force it with value @param int $updatecurrencyrate Update currency rate when generation done from template invoice

$forceduedate
$updatecurrencyrate

Return Value

int

Return integer <0 if KO, >0 if OK

int<-1, 1> createFromCurrent(User $user, int<0, 1> $invertdetail = 0)

Create a new invoice in database from current invoice

Parameters

User $user

Object user that ask creation

int<0, 1> $invertdetail

Reverse sign of amounts for lines

Return Value

int<-1, 1>

Return integer <0 if KO, >0 if OK

createFromClone(User $user, $fromid = 0)

Load an object from its id and create a new one in database

Parameters

User $user

User that clone @param int $fromid Id of object to clone @return int New id of clone

$fromid

int<-1, 1> createFromOrder(Commande $object, User $user)

Load an object from an order and create a new invoice into database

Parameters

Commande $object

Object source

User $user

Object user

Return Value

int<-1, 1>

Return integer <0 if KO, 0 if nothing done, 1 if OK

createFromContract($object, User $user, $lines = array())

Load an object from a contract and create a new invoice into database

@param Contrat $object Object source

Parameters

$object
User $user

Object user @param int[] $lines Ids of lines to use for invoice. If empty, all lines will be used. @return int Return integer <0 if KO, 0 if nothing done, 1 if OK

$lines

static Facture createDepositFromOrigin(CommonObject $origin, int $date, int $payment_terms_id, User $user, int<0, 1> $notrigger = 0, bool $autoValidateDeposit = false, array<string, int|float|string> $overrideFields = array())

Creates a deposit from a proposal or an order by grouping lines by VAT rates

Parameters

CommonObject $origin

The original proposal or order

int $date

Invoice date

int $payment_terms_id

Invoice payment terms

User $user

Object user

int<0, 1> $notrigger

1=Does not execute triggers, 0= execute triggers

bool $autoValidateDeposit

Whether to automatically validate the deposit created

array<string, int|float|string> $overrideFields

Array of fields to force values

Return Value

Facture

The deposit created, or null if error (populates $origin->error in this case)

getNomUrl($withpicto = 0, string $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1, $target = '')

Return clickable link of object (with eventually picto)

@param int $withpicto Add picto into link

Parameters

$withpicto
string $option

Where point the link @param int $max Maxlength of ref @param int $short 1=Return just URL @param string $moretitle Add more text to title tooltip @param int $notooltip 1=Disable tooltip @param int $addlinktonotes 1=Add link to notes @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking @param string $target Target of link ('', '_self', '_blank', '_parent', '_backoffice', ...) @return string String with URL

$max
$short
$moretitle
$notooltip
$addlinktonotes
$save_lastsearch_value
$target

int fetch(int $rowid, $ref = '', $ref_ext = '', $notused = 0, $fetch_situation = false)

Get object from database. Get also lines.

Parameters

int $rowid

Id of object to load @param string $ref Reference of invoice @param string $ref_ext External reference of invoice @param int $notused Not used @param bool $fetch_situation Load also the previous and next situation invoice into $tab_previous_situation_invoice and $tab_next_situation_invoice

$ref
$ref_ext
$notused
$fetch_situation

Return Value

int

0 if OK, <0 if KO, 0 if not found

int fetch_lines(int|string $only_type_product = '', int $loadalsotranslation = 0)

Load all detailed lines into this->lines

Parameters

int|string $only_type_product

Return only for type products

int $loadalsotranslation

Return translation for products

Return Value

int

1 if OK, < 0 if KO

void fetchPreviousNextSituationInvoice()

Fetch previous and next situations invoices.

Return all previous and next invoices (both standard and credit notes).

Return Value

void

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

Update database

@param User $user User that modify

Parameters

User $user
int $notrigger

0=launch triggers after, 1=disable triggers @return int Return integer <0 if KO, >0 if OK

int insert_discount($idremise)

Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount)

@param int $idremise Id of absolute discount from table llx_societe_remise_except

Parameters

$idremise

Return Value

int

0 if OK, <0 if KO

int set_ref_client(string $ref_client, $notrigger = 0)

Set customer ref

Parameters

string $ref_client

Customer ref @param int $notrigger 1=Does not execute triggers, 0= execute triggers

$notrigger

Return Value

int

Return integer <0 if KO, >0 if OK

setInputReason($inputReasonId, int $notrigger = 0)

Update invoice input reason

@param int $inputReasonId Input reason id or 0 to set to null

Parameters

$inputReasonId
int $notrigger

1=Does not execute triggers, 0= execute triggers @return int Return integer <0 if KO, 0 do nothing, >0 if OK

int delete(User $user, int $notrigger = 0, int $idwarehouse = -1)

Delete invoice

Parameters

User $user

User making the deletion.

int $notrigger

1=Does not execute triggers, 0= execute triggers

int $idwarehouse

Id warehouse to use for stock change.

Return Value

int

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

set_paid($user, string $close_code = '', string $close_note = '') deprecated

deprecated @see setPaid() @param User $user Object user that modify

Tag the invoice as paid completely (if close_code is filled) => this->fk_statut=2, this->paye=1 or partially (if close_code filled) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0

Parameters

$user
string $close_code

Code set when forcing to set the invoice as fully paid while in practice it is incomplete (because of a discount (fr:escompte) for instance)

string $close_note

Comment set when forcing to set the invoice as fully paid while in practice it is incomplete (because of a discount (fr:escompte) for instance) @return int Return integer <0 if KO, >0 if OK

setPaid($user, string $close_code = '', string $close_note = '')

Tag the invoice as :

  • paid completely (if close_code is not filled) => this->fk_statut=2, this->paye=1
  • or partially (if close_code filled) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0

@param User $user Object user that modify

Parameters

$user
string $close_code

Code set when forcing to set the invoice as fully paid while in practice it is incomplete (because of a discount (fr:escompte) for instance)

string $close_note

Comment set when forcing to set the invoice as fully paid while in practice it is incomplete (because of a discount (fr:escompte) for instance) @return int Return integer <0 if KO, >0 if OK

set_unpaid($user) deprecated

deprecated @see setUnpaid() @param User $user Object user that change status @return int Return integer <0 if KO, >0 if OK

Tags the invoice as incompletely paid and call the trigger BILL_UNPAYED This method is used when a direct debit (fr:prelevement) is refused or when a canceled invoice is reopened.

Parameters

$user

int setUnpaid($user)

Tag the invoice as incompletely paid and call the trigger BILL_UNPAYED This method is used when a direct debit (fr:prelevement) is refused or when a canceled invoice is reopened.

@param User $user Object user that change status

Parameters

$user

Return Value

int

Return integer <0 if KO, >0 if OK

int set_canceled(User $user, string $close_code = '', string $close_note = '') deprecated

deprecated @see setCanceled()

Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because of no payment even if merchandises were sent).

Parameters

User $user

Object user making change

string $close_code

Code of closing invoice (CLOSECODEREPLACED, CLOSECODE...)

string $close_note Comment

Return Value

int

Return integer <0 if KO, >0 if OK

int setCanceled(User $user, string $close_code = '', string $close_note = '')

Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because of no payment even if merchandises were sent).

Parameters

User $user

Object user making change

string $close_code

Code of closing invoice (CLOSECODEREPLACED, CLOSECODE...)

string $close_note Comment

Return Value

int

Return integer <0 if KO, >0 if OK

int validate(User $user, string $force_number = '', int $idwarehouse = 0, int $notrigger = 0, int $batch_rule = 0)

Tag invoice as validated + call trigger BILL_VALIDATE Object must have lines loaded with fetch_lines This may rename files on disk because ref is modified but it does not generate any document.

Parameters

User $user

Object user that validate

string $force_number

Reference to force on invoice

int $idwarehouse

Id of warehouse to use for stock decrease if option to decrease on stock is on (0=no decrease)

int $notrigger

1=Does not execute triggers, 0= execute triggers

int $batch_rule

0=do not decrement batch, else batch rule to use: 1=take lot/serial ordered by sellby and eatby dates

Return Value

int

Return integer <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK

bool updatePriceNextInvoice(Translate $langs)

Update price of next invoice

Parameters

Translate $langs

Translate object

Return Value

bool

false if KO, true if OK

int setDraft(User $user, int $idwarehouse = -1)

Set draft status

Parameters

User $user

Object user that modify

int $idwarehouse

Id warehouse to use for stock change.

Return Value

int

Return integer <0 if KO, >0 if OK

addline(string $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $fk_code_ventilation = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = array(), $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0, $ref_ext = '', $noupdateafterinsertline = 0)

Add an invoice line into database (linked to product/service or not).

Note: ->thirdparty must be defined. Les parameters sont deja cense etre juste et avec valeurs finales a l'appel de cette method. Aussi, pour le taux tva, il doit deja avoir ete defini par l'appelant par la method get_default_tva(societe_vendeuse,societe_acheteuse,produit) et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)

Parameters

string $desc

Description of line @param float $pu_ht Unit price without tax (> 0 even for credit note) @param float $qty Quantity @param float|string $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') @param float $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) @param int $fk_product Id of predefined product/service @param float $remise_percent Percent of discount on line @param int|'' $date_start Date start of service @param int|'' $date_end Date end of service @param int $fk_code_ventilation Code of dispatching into accountancy @param int $info_bits Bits of type of lines @param int $fk_remise_except Id discount used @param string $price_base_type 'HT' or 'TTC' @param float $pu_ttc Unit price with tax (> 0 even for credit note) @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. @param int $rang Position of line (-1 means last value + 1) @param int $special_code Special code (also used by externals modules!) @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id @param int $fk_parent_line Id of parent line @param int|string $fk_fournprice Supplier price id (to calculate margin) or a string @param float|'' $pa_ht Buying price of line (to calculate margin) (Can be '' to keep AWP unchanged or a float value) @param string $label Label of the line (deprecated, do not use) @param array<string,mixed> $array_options Extrafields array @param float $situation_percent Situation advance percentage @param int $fk_prev_id Previous situation line id reference @param int|null $fk_unit Code of the unit to use. Null to use the default one @param float $pu_ht_devise Unit price in foreign currency @param string $ref_ext External reference of the line @param int $noupdateafterinsertline No update after insert of line @return int Return integer <0 if KO, Id of line if OK

$pu_ht
$qty
$txtva
$txlocaltax1
$txlocaltax2
$fk_product
$remise_percent
$date_start
$date_end
$fk_code_ventilation
$info_bits
$fk_remise_except
$price_base_type
$pu_ttc
$type
$rang
$special_code
$origin
$origin_id
$fk_parent_line
$fk_fournprice
$pa_ht
$label
$array_options
$situation_percent
$fk_prev_id
$fk_unit
$pu_ht_devise
$ref_ext
$noupdateafterinsertline

updateline($rowid, string $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = array(), $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0)

Update a detail line

@param int $rowid Id of line to update

Parameters

$rowid
string $desc

Description of line @param float $pu Prix unitaire (HT ou TTC selon price_base_type) (> 0 even for credit note lines) @param float $qty Quantity @param float $remise_percent Percentage discount of the line @param int|'' $date_start Date de debut de validite du service @param int|'' $date_end Date de fin de validite du service @param float|string $txtva VAT Rate (Can be '8.5', '8.5 (ABC)') @param float $txlocaltax1 Local tax 1 rate @param float $txlocaltax2 Local tax 2 rate @param string $price_base_type HT or TTC @param int $info_bits Miscellaneous information @param int $type Type of line (0=product, 1=service) @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) @param int $fk_fournprice Id of origin supplier price @param float|string $pa_ht Price (without tax) of product when it was bought (Can be '' to keep AWP unchanged or a float value) @param string $label Label of the line (deprecated, do not use) @param int $special_code Special code (also used by externals modules!) @param array<string,mixed> $array_options extrafields array @param float $situation_percent Situation advance percentage @param ?int $fk_unit Code of the unit to use. Null to use the default one @param float $pu_ht_devise Unit price in currency @param int<0,1> $notrigger disable line update trigger @param string $ref_ext External reference of the line @param integer $rang rank of line @return int Return integer < 0 if KO, > 0 if OK

$pu
$qty
$remise_percent
$date_start
$date_end
$txtva
$txlocaltax1
$txlocaltax2
$price_base_type
$info_bits
$type
$fk_parent_line
$skip_update_total
$fk_fournprice
$pa_ht
$label
$special_code
$array_options
$situation_percent
$fk_unit
$pu_ht_devise
$notrigger
$ref_ext
$rang

bool checkProgressLine(int $idline, float $situation_percent)

Check if the percent edited is lower of next invoice line

Parameters

int $idline

id of line to check

float $situation_percent

progress percentage need to be test

Return Value

bool

false if KO, true if OK

void update_percent(FactureLigne $line, int|float $percent, bool $update_price = true)

Update invoice line with percentage

Parameters

FactureLigne $line

Invoice line

int|float $percent Percentage
bool $update_price

Update object price

Return Value

void

int deleteLine(int $rowid, $id = 0)

Delete line in database

Parameters

int $rowid

Id of line to delete @param int $id Id of object (for a check)

$id

Return Value

int

Return integer <0 if KO, >0 if OK

int set_remise(User $user, float $remise, $notrigger = 0)

Set percent discount

@deprecated

Parameters

User $user

User that set discount

float $remise

Discount @param int $notrigger 1=Does not execute triggers, 0= execute triggers

$notrigger

Return Value

int

Return integer <0 if KO, >0 if OK

See also

setDiscount()

int setDiscount(User $user, float $remise, $notrigger = 0)

Set percent discount

Parameters

User $user

User that set discount

float $remise

Discount @param int $notrigger 1=Does not execute triggers, 0= execute triggers

$notrigger

Return Value

int

Return integer <0 if KO, >0 if OK

int setCategories(int[]|int $categories)

Sets object to given categories.

Adds it to non existing supplied categories. Existing categories are left untouch.

Parameters

int[]|int $categories

Category or categories IDs

Return Value

int

Return integer <0 if KO, >0 if OK

void info(int $id)

Load miscellaneous information for tab "Info"

Parameters

int $id

Id of object to load

Return Value

void

array<int, string>|array<array{id: int, ref: string, name: string}>|int<-1, -1> liste_array($shortlist = 0, int $draft = 0, $excluser = null, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC')

Return list of invoices (eventually filtered on a user) into an array

@param int<0,1> $shortlist 0=Return array[id]=ref, 1=Return array

Parameters

$shortlist
int $draft

0=not draft, 1=draft @param ?User $excluser Object user to exclude @param int $socid Id third party @param int $limit For pagination @param int $offset For pagination @param string $sortfield Sort criteria @param string $sortorder Sort order

$excluser
$socid
$limit
$offset
$sortfield
$sortorder

Return Value

array<int, string>|array<array{id: int, ref: string, name: string}>|int<-1, -1>

Array with result if OK, -1 if KO,

int<-1, -1>|array<int, array{id: int, ref: string, status: int, paid: int<0, 1>, alreadypaid: int<0, 1>}> list_replacable_invoices(int $socid = 0)

Return list of invoices qualified to be replaced by another invoice.

Invoices matching the following rules are returned: (Status validated or abandoned for a reason 'other') + not paid + no payment at all + not already replaced

Parameters

int $socid

Id thirdparty

Return Value

int<-1, -1>|array<int, array{id: int, ref: string, status: int, paid: int<0, 1>, alreadypaid: int<0, 1>}>

Array of invoices ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1)

array<int, array{ref: string, status: int, type: int, paye: int<0, 1>, paymentornot: int<0, 1>}>|int<-1, -1> list_qualified_avoir_invoices(int $socid = 0)

Return list of invoices qualified to be corrected by a credit note.

Invoices matching the following rules are returned: (validated + payment on process) or classified (paid completely or paid partiely) + not already replaced + not already a credit note

Parameters

int $socid

Id thirdparty

Return Value

array<int, array{ref: string, status: int, type: int, paye: int<0, 1>, paymentornot: int<0, 1>}>|int<-1, -1>

Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>)

WorkboardResponse|int load_board(User $user)

Load indicators for dashboard (this->nbtodo and this->nbtodolate)

Parameters

User $user

Object user

Return Value

WorkboardResponse|int

Return integer <0 if KO, WorkboardResponse if OK

int[] getIdBillingContact()

Retourne id des contacts clients de facturation

Return Value

int[]

Liste des id contacts facturation

int[] getIdShippingContact()

Retourne id des contacts clients de livraison

Return Value

int[]

Liste des id contacts livraison

initAsSpecimen(string $option = '')

Initialise an instance with random values.

Used to build previews or test instances. id must be 0 if object instance is a specimen.

Parameters

string $option

''=Create a specimen invoice with lines, 'nolines'=No lines, 'takepos'=Specimen for takepos module @return int

loadStateBoard()

Load indicators for dashboard (this->nbtodo and this->nbtodolate)

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

getLinesArray()

Create an array of invoice lines

@return int<-1,1>   >0 if OK, <0 if KO

int<-1, 1> generateDocument(string $modele, Translate $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)

Create a document onto disk according to template module.

Parameters

string $modele

Generator to use. Caller must set it to obj->model_pdf or GETPOST('model','alpha') for example.

Translate $outputlangs

Object lang to use for translation @param int<0,1> $hidedetails Hide details of lines @param int<0,1> $hidedesc Hide description @param int<0,1> $hideref Hide ref @param ?array<string,mixed> $moreparams Array to provide more information

$hidedetails
$hidedesc
$hideref
$moreparams

Return Value

int<-1, 1>

Return integer <0 if KO, >0 if OK

int newCycle()

Gets the smallest reference available for a new cycle

Return Value

int

= 1 if OK, -1 if error

bool is_first()

Checks if the invoice is the first of a cycle

Return Value

bool

Facture[]|int<-1, -1> get_prev_sits()

Returns an array containing the previous situations as Facture objects

Return Value

Facture[]|int<-1, -1>

-1 if error, array of previous situations

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

Sets the invoice as a final situation

@param User $user Object user

Parameters

User $user
int $notrigger

1=Does not execute triggers, 0= execute triggers

Return Value

int

Return integer <0 if KO, >0 if OK

bool is_last_in_cycle()

Checks if the invoice is the last in its cycle

Return Value

bool

Last of the cycle status

static bool replaceThirdparty(DoliDB $dbs, int $origin_id, int $dest_id)

Replace a thirdparty id with another one.

Parameters

DoliDB $dbs

Database handler, because function is static we name it $dbs not $db to avoid breaking coding test

int $origin_id

Old thirdparty id

int $dest_id

New thirdparty id

Return Value

bool

static bool replaceProduct(DoliDB $db, int $origin_id, int $dest_id)

Replace a product id with another one.

Parameters

DoliDB $db

Database handler

int $origin_id

Old product id

int $dest_id

New product id

Return Value

bool

bool hasDelay()

Is the customer invoice delayed?

Return Value

bool

int isSituationInvoice()

Check if an invoice is a situation invoice

Return Value

int

Return a value if invoice is a situation invoice

bool displayRetainedWarranty()

Currently used for documents generation : to know if retained warranty need to be displayed

Return Value

bool

float getRetainedWarrantyAmount(int $rounding = -1)

No description

Parameters

int $rounding

Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT)

Return Value

float

or -1 if not available

int setRetainedWarranty($value)

Change the retained warranty

@param float $value value of retained warranty

Parameters

$value

Return Value

int

0 if OK, <0 if KO

setRetainedWarrantyDateLimit($timestamp, string $dateYmd = '')

Change the retained_warranty_date_limit

@param int $timestamp date limit of retained warranty in timestamp format

Parameters

$timestamp
string $dateYmd

date limit of retained warranty in Y m d format @return int >0 if OK, <0 if KO

sendEmailsRemindersOnInvoiceDueDate(int $nbdays = 0, $paymentmode = 'all', $template = '', $datetouse = 'duedate', $forcerecipient = '')

Send reminders by emails for invoices validated that are due.

CAN BE A CRON TASK

Parameters

int $nbdays

Delay before due date (or after if delay is negative) @param string $paymentmode '' or 'all' by default (no filter), or 'LIQ', 'CHQ', CB', ... @param int|string $template Name (or id) of email template (Must be a template of type 'facture_send') @param string $datetouse 'duedate' (default) or 'invoicedate' @param string $forcerecipient Force email of recipient (for example to send the email to an accountant supervisor instead of the customer) @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)

$paymentmode
$template
$datetouse
$forcerecipient

array{0?: bool, 1?: string} willBeLastOfSameType(bool $allow_validated_drafts = false)

See if current invoice date is posterior to the last invoice date among validated invoices of same type.

Parameters

bool $allow_validated_drafts

return true if the invoice has been validated before returning to DRAFT state.

Return Value

array{0?: bool, 1?: string}

return array

getKanbanView(string $option = '', $arraydata = null)

Return clickable link of object (with eventually picto)

Parameters

string $option

Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) @param ?array<string,mixed> $arraydata Array of data @return string HTML Code for Kanban thumb.

$arraydata