class ProductFournisseur extends Product (View source)

Class to manage predefined suppliers products

Traits

Class for handling deprecated properties and methods

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

Constants

SELL_OR_EAT_BY_MANDATORY_ID_NONE

Const sell or eat by mandatory id

SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY

SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY

SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT

TYPE_PRODUCT

Regular product

TYPE_SERVICE

Service

DISABLED_STOCK

Stockable product

ENABLED_STOCK

STATUS_OPEN

STATUS_CANCELED

Properties

DoliDB $db
string $error
string[] $errors from  CommonTrigger
string $TRIGGER_PREFIX
string $module from  CommonObject
int $id
?int $entity from  CommonObject
string $errorhidden from  CommonObject
string[] $warnings from  CommonObject
string $element from  Product
string $fk_element from  Product
string $element_for_permission from  CommonObject
string $table_element from  Product
?string $table_rowid from  CommonObject
string $table_element_line from  CommonObject
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 from  Product
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} from  Product
int $restrictiononfksoc from  CommonObject
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
?int $status

Status indicates whether the product is on sale '1' or not '0'

from  Product
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  Product
string $barcode_type_code from  Product
$barcode_type_label from  CommonObject
$barcode_type_coder from  CommonObject
?int $mode_reglement_id from  CommonObject
?int $cond_reglement_id from  CommonObject
?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
$fk_bank from  CommonObject
?int $fk_account from  CommonObject
?string $note_public from  CommonObject
?string $note_private from  CommonObject
$note from  CommonObject
?float $total_ht from  CommonObject
?float $total_tva from  CommonObject
?float $total_localtax1 from  CommonObject
?float $total_localtax2 from  CommonObject
?float $total_ttc from  CommonObject
CommonObjectLine[]|CommonObject[]|stdClass[] $lines from  CommonObject
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|null deprecated $fk_user_modif from  CommonObject
string $next_prev_filter from  CommonObject
int<0, 1> $specimen from  CommonObject
int[] $sendtoid from  CommonObject
$alreadypaid from  CommonObject
$totalpaid from  CommonObject
$totalpaid_multicurrency from  CommonObject
array<int, string> $labelStatus
array<int, string> $labelStatusShort
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

Number of pictures

from  Product
string $output from  CommonObject
array<string, string>|string $extraparams from  CommonObject
protected array<string, string[]> $childtables from  Product
protected string[] $childtablesoncascade from  CommonObject
int $cond_reglement_supplier_id from  CommonObject
float|string $deposit_percent from  CommonObject
int $retained_warranty_fk_cond_reglement from  CommonObject
int $warehouse_id from  CommonObject
int<0, 1> $isextrafieldmanaged from  CommonObject
string $picto

Label of the pictogram used for this object ('product' or 'service')

from  Product
$regeximgext from  Product
$libelle from  Product
string $label

Product label

from  Product
string $description

Product description

from  Product
string $other

Product other fields PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION

from  Product
int $type

Check TYPE constants

from  Product
float $price

Selling price without tax

from  Product
string $price_formated from  Product
float $price_ttc

Selling price with tax

from  Product
string $price_ttc_formated from  Product
float $price_min

Minimum price net

from  Product
float $price_min_ttc

Minimum price with tax

from  Product
string $price_base_type

Base price ('TTC' for price including tax or 'HT' for net price)

from  Product
string $price_label from  Product
array<int, float> $multiprices from  Product
array<int, float> $multiprices_ttc from  Product
array<int, string> $multiprices_base_type from  Product
array<int, string> $multiprices_default_vat_code from  Product
array<int, float> $multiprices_min from  Product
array<int, float> $multiprices_min_ttc from  Product
array<int, null|int|float|string> $multiprices_tva_tx from  Product
array<int, int> $multiprices_recuperableonly from  Product
int<0, 0>|float $price_by_qty from  Product
array<int, float> $prices_by_qty from  Product
array<int, float> $prices_by_qty_id from  Product
array<int, array<array{rowid: int, price_base_type: string, unitprice: string}>> $prices_by_qty_list from  Product
int $level from  Product
?array<string, array{label: string, description: string, note?: string, other?: string}> $multilangs from  Product
string $default_vat_code from  Product
string|int|float $tva_tx from  Product
int<0, 1> $tva_npr from  Product
string $remise_percent from  Product
string|int|float $localtax1_tx from  Product
string|int|float $localtax2_tx from  Product
string $localtax1_type from  Product
string $localtax2_type from  Product
string $desc_supplier
string $vatrate_supplier
string $default_vat_code_supplier from  Product
int|float|string|null $fourn_multicurrency_price
int|float|string $fourn_multicurrency_unitprice
int|float|string|null $fourn_multicurrency_tx
int $fourn_multicurrency_id
?string $fourn_multicurrency_code
?float $packaging from  Product
int|null $lifetime

Lifetime (in seconds)

from  Product
int|null $qc_frequency

Quality control frequency (in days ?)

from  Product
float $stock_reel

Stock real (denormalized data)

from  Product
float $stock_theorique

Stock virtual

from  Product
?float $cost_price

Cost price

from  Product
?float $pmp

Average price value for product entry into stock (PMP)

from  Product
?float $seuil_stock_alerte

Stock alert

from  Product
?float $desiredstock from  Product
?int $duration_value from  Product
string $duration_unit from  Product
string $duration from  Product
int $fk_default_workstation from  Product
$tosell

Status indicates whether the product is on sale '1' or not '0'

from  Product
?int $status_buy

Status indicate whether the product is available for purchase '1' or not '0'

from  Product
$tobuy

Status indicate whether the product is available for purchase '1' or not '0'

from  Product
?int $finished

Status indicates whether the product is a finished product '1' or a raw material '0'

from  Product
?int $fk_default_bom

fk_default_bom indicates the default bom

from  Product
int $product_fourn_price_id
float $buyprice

buyprice indicates buy price off the product

from  Product
int $tobatch

for backward compatibility

from  Product
int $status_batch

We must manage lot/batch number, sell-by date and so on : '0':no, '1':yes, '2": yes with unique serial number

from  Product
int $sell_or_eat_by_mandatory

Make sell-by or eat-by date mandatory

from  Product
string $batch_mask

If allowed, we can edit batch or serial number mask for each product

from  Product
string $customcode

Customs code

from  Product
string $url

Product URL

from  Product
float|string $weight from  Product
?int $weight_units from  Product
float|string $length from  Product
?int $length_units from  Product
float|string $width from  Product
?int $width_units from  Product
float|string|null $height from  Product
?int $height_units from  Product
float|string|null $surface from  Product
?int $surface_units from  Product
float|string|null $volume from  Product
?int $volume_units from  Product
float|string|null $net_measure from  Product
?int $net_measure_units from  Product
?string $accountancy_code_sell from  Product
?string $accountancy_code_sell_intra from  Product
?string $accountancy_code_sell_export from  Product
?string $accountancy_code_buy from  Product
?string $accountancy_code_buy_intra from  Product
?string $accountancy_code_buy_export from  Product
string|int $barcode from  Product
array{}|array{customers: int, nb: int, rows: int, qty: float} $stats_propale from  Product
array{}|array{customers: int, nb: int, rows: int, qty: float} $stats_commande from  Product
array{}|array{customers: int, nb: int, rows: int, qty: float} $stats_contrat from  Product
array{}|array{customers: int, nb: int, rows: int, qty: float} $stats_facture from  Product
array{}|array{suppliers: int, nb: int, rows: int, qty: float} $stats_proposal_supplier from  Product
array{}|array{suppliers: int, nb: int, rows: int, qty: float} $stats_commande_fournisseur from  Product
array{}|array{customers: int, nb: int, rows: int, qty: float} $stats_expedition from  Product
array{}|array{suppliers: int, nb: int, rows: int, qty: float} $stats_reception from  Product
array{}|array{customers_toconsume: int, nb_toconsume: int, qty_toconsume: float, customers_consumed: int, nb_consumed: int, qty_consumed: float, customers_toproduce: int, nb_toproduce: int, qty_toproduce: float, customers_produced: int, nb_produced: int, qty_produced: float} $stats_mo from  Product
array{}|array{nb_toproduce: int, nb_toconsume: int, qty_toproduce: float, qty_toconsume: float} $stats_bom from  Product
array{}|array{customers: int, nb: int, rows: int, qty: float} $stats_mrptoconsume from  Product
array{}|array{customers: int, nb: int, rows: int, qty: float} $stats_mrptoproduce from  Product
array{}|array{customers: int, nb: int, rows: int, qty: float} $stats_facturerec from  Product
array{}|array{suppliers: int, nb: int, rows: int, qty: float} $stats_facture_fournisseur from  Product
array{}|array{suppliers: int, nb: int, rows: int, qty: float} $stats_facturefournrec from  Product
int|string $imgWidth from  Product
int|string $imgHeight from  Product
int $product_fourn_id
int $product_id_already_linked

Product ID already linked to a reference supplier

from  Product
stdClass> $stock_warehouse from  Product
int $fk_default_warehouse from  Product
int $fk_price_expression from  Product
float $fourn_qty
float $fourn_pu
"HT"|"TTC" $fourn_price_base_type

Supplier price found : VAT type

from  Product
int $fourn_socid from  Product
$ref_fourn from  Product
string $ref_supplier
int|null $fk_unit from  Product
int $price_autogen

Price is generated using multiprice rules

from  Product
null|array<string, array<int, array{0: int, 1: float, 2: int, 3: string, 4: int, 5: string}>> $sousprods

Array with list of sub-products for Kits

from  Product
CommonObject}> $res from  Product
bool $is_object_used

Property set to save result of isObjectUsed(). Used for example by Product API.

from  Product
float $is_sousproduit_qty

If this Product is within a kit: Quantity of this Product within this kit

from  Product
int<0, 1> $is_sousproduit_incdec

If this Product is within a kit: 1 = modify the stock of this child Product upon modification of the stock of its parent Product ("incdec" stands for increase/decrease)

from  Product
int $mandatory_period from  Product
int $stockable_product

0=This service or product is not managed in stock, 1=This service or product is managed in stock

from  Product
$fourn_ref
int $delivery_time_days
$fk_product
int $product_id
string $product_ref
int $fourn_id
string $fourn_name
?float $fourn_price
?float $fourn_remise_percent
float $fourn_remise
?float $fourn_charges
string $product_fourn_entity
float $product_fourn_packaging
int $user_id
int $fk_availability
int|string $fourn_unitprice
float|int $fourn_unitprice_with_discount
string $fourn_tva_tx
int<0, 1> $fourn_tva_npr
int $fk_supplier_price_expression
string $supplier_reputation
string[] $reputations
$fourn_barcode
string $supplier_barcode
$fourn_fk_barcode_type
string $supplier_fk_barcode_type

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

from  Product
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

from  Product
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.

__construct(DoliDB $db)

Constructor

int
check()

Check that ref and label are ok

from  Product
int
create(User $user, int $notrigger = 0)

Insert product into database

from  Product
int
verify()

Check properties of product are ok (like name, barcode, ...).

from  Product
int
check_barcode(string $valuetotest, string $typefortest)

Check barcode

from  Product
int
update(int $id, User $user, int $notrigger = 0, string $action = 'update', bool $updatetype = false)

Update a record into database.

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

Delete a product from database (if not used)

from  Product
static array{0: string, 1: string, 2: string, 3: string}
getSellOrEatByMandatoryList()

Get the array of labels of Sell by or Eat by all mandatory flags for each status

from  Product
string
getSellOrEatByMandatoryLabel()

Get the label for sell by or eat by mandatory flag of the current product

from  Product
int
setMultiLangs(User $user)

Update or add a translation for a product

from  Product
int
delMultiLangs(string $langtodelete, User $user)

Delete a language for this product

from  Product
int
setAccountancyCode(string $type, string $value)

Sets an accountancy code for a product.

from  Product
int
getMultiLangs()

Load array this->multilangs

from  Product
int
log_price_delete(User $user, int $rowid)

Delete a price line

from  Product
getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0)

Return price of sell of a product for a seller/buyer/product.

from  Product
get_buyprice($prodfournprice, $qty, $product_id = 0, $fourn_ref = '', $fk_soc = 0)

Read price used by a provider.

from  Product
int<-1, 1>
updatePrice(float $newprice, string $newpricebase, User $user, ?float $newvat = null, float|int $newminprice = 0, int $level = 0, int<0, 1> $newnpr = 0, int<0, 1> $newpbq = 0, int<0, 1> $ignore_autogen = 0, array{}|array{0: string, 1: int|string, 2: string, 3: string}|array{0: string, 1: int|string, 2: string, 3: int|string, 4: string, 5: string} $localtaxes_array = array(), string $newdefaultvatcode = '', string $price_label = '', int $notrigger = 0)

Modify customer price of a product/Service for a given level

from  Product
int
setPriceExpression(int $expression_id) deprecated

Sets the supplier price expression

from  Product
int
fetch(int $id = 0, string $ref = '', string $ref_ext = '', string $barcode = '', int $ignore_expression = 0, int $ignore_price_load = 0, int $ignore_lang_load = 0)

Load a product in memory from database

from  Product
int
load_stats_mo(int $socid = 0)

Charge tableau des stats OF pour le produit/service

from  Product
int
load_stats_bom(int $socid = 0)

Charge tableau des stats OF pour le produit/service

from  Product
int
load_stats_propale(int $socid = 0)

Charge tableau des stats propale pour le produit/service

from  Product
int
load_stats_proposal_supplier(int $socid = 0)

Charge tableau des stats propale pour le produit/service

from  Product
int
load_stats_commande(int $socid = 0, string $filtrestatut = '', int $forVirtualStock = 0)

Charge tableau des stats commande client pour le produit/service

from  Product
int
load_stats_commande_fournisseur(int $socid = 0, string $filtrestatut = '', int $forVirtualStock = 0, int $dateofvirtualstock = null)

Charge tableau des stats commande fournisseur pour le produit/service

from  Product
int
load_stats_sending(int $socid = 0, string $filtrestatut = '', int $forVirtualStock = 0, string $filterShipmentStatus = '')

Charge tableau des stats expedition client pour le produit/service

from  Product
int
load_stats_reception(int $socid = 0, string $filtrestatut = '', int $forVirtualStock = 0, int $dateofvirtualstock = null)

Charge tableau des stats réception fournisseur pour le produit/service

from  Product
int
load_stats_inproduction(int $socid = 0, string $filtrestatut = '', int $forVirtualStock = 0, int $dateofvirtualstock = null, int $warehouseid = 0)

Charge tableau des stats production pour le produit/service

from  Product
int
load_stats_contrat(int $socid = 0)

Charge tableau des stats contrat pour le produit/service

from  Product
int
load_stats_facture(int $socid = 0)

Charge tableau des stats facture pour le produit/service

from  Product
int
load_stats_facturerec(int $socid = 0)

Load array of statistics for recurring invoice for product/service

from  Product
int
load_stats_facture_fournisseur(int $socid = 0)

Load array of statistics for vendor invoice for product/service

from  Product
int
load_stats_facturefournrec($socid = 0)

Load array of statistics for recurring supplier invoice for product/service

from  Product
array<int<0, 11>, array<int, int|float>>|int<-1, -1>
get_nb_vente(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units or customers invoices in which product is included

from  Product
array<int<0, 11>, array<int, int|float>>|int<-1, -1>
get_nb_achat(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units or supplier invoices in which product is included

from  Product
array<int<0, 11>, array<int, int|float>>|int<-1, -1>
get_nb_propal(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in proposals in which product is included

from  Product
array<int<0, 11>, array<int, int|float>>|int<-1, -1>
get_nb_propalsupplier(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in proposals in which product is included

from  Product
array<int<0, 11>, array<int, int|float>>|int<-1, -1>
get_nb_order(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in orders in which product is included

from  Product
array<int<0, 11>, array<int, int|float>>|int<-1, -1>
get_nb_ordersupplier(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in orders in which product is included

from  Product
array<int<0, 11>, array<int, int|float>>|int<-1, -1>
get_nb_contract(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in orders in which product is included

from  Product
array<int<0, 11>, array<int, int|float>>|int<-1, -1>
get_nb_mos(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in orders in which product is included

from  Product
int
add_sousproduit(int $id_pere, int $id_fils, float $qty, int $incdec = 1, int $notrigger = 0)

Link a product/service to a parent product/service

from  Product
int
update_sousproduit(int $id_pere, int $id_fils, float $qty, int $incdec = 1, int $notrigger = 0)

Modify composed product

from  Product
int
del_sousproduit(int $fk_parent, int $fk_child, int $notrigger = 0)

Remove a link between a subproduct and a parent product/service

from  Product
int<-1, 1>
is_sousproduit(int $fk_parent, int $fk_child)

Check if it is a sub-product into a kit

from  Product
int<-3, 1>
add_fournisseur(User $user, int $id_fourn, string $ref_fourn, float $quantity)

Add a supplier price for the product.

from  Product
int[]
list_suppliers()

Return list of suppliers providing the product or service

from  Product
int
clone_price(int $fromId, int $toId)

Recopie les prix d'un produit/service sur un autre

from  Product
int
clone_associations(int $fromId, int $toId)

Clone links between products

from  Product
int
clone_fournisseurs(int $fromId, int $toId)

Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre

from  Product
void
fetch_prod_arbo(array<int, array{0: int, 1: float, 2: int, 3: string, 4: int, 5: string}> $prod, string $compl_path = '', int|float $multiply = 1, int $level = 1, int $id_parent = 0, int<0, 1> $ignore_stock_load = 0)

Function recursive, used only by get_arbo_each_prod(), to build tree of subproducts into ->res Define value of this->res

from  Product
CommonObject}>
get_arbo_each_prod(int|float $multiply = 1, int<0, 1> $ignore_stock_load = 0)

Build the tree of subproducts and return it.

from  Product
hasFatherOrChild($mode = 0)

Count all parent and children products for current product (first level only)

from  Product
int
hasVariants()

Return if a product has variants or not

from  Product
bool|int
isVariant()

Return if loaded product is a variant

from  Product
array<int, array{id: int, ref: string, label: string, qty: float, incdec: int<0, 1>, fk_product_type: int, entity: int, status: int, status_buy: int}>|int<-1, -1>
getFather()

Return all parent products for current product (first level only)

from  Product
array<int, array{0: int, 1: float, 2: int, 3: string, 4: int, 5: string}>|array{}|int<-1, -1>
getChildsArbo(int $id, int $firstlevelonly = 0, int $level = 1, int[] $parents = array())

Return children of product $id

from  Product
void
get_sousproduits_arbo()

Return tree of all subproducts for product. Tree contains array of array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref) Set this->sousprods

from  Product
string
getNomUrl(int $withpicto = 0, string $option = '', int $maxlength = 0, int $save_lastsearch_value = -1, int $notooltip = 0, string $morecss = '', int $add_label = 0, string $sep = ' - ')

Return a link to the object card (with optionally the picto).

int
generateDocument(string $modele, Translate $outputlangs, int $hidedetails = 0, int $hidedesc = 0, int $hideref = 0)

Create a document onto disk according to template module.

from  Product
string
getLibStatut(int<0, 6> $mode = 0, int<0, 2> $type = 0)

Return the label of the status

string
LibStatut(int $status, int<0, 6> $mode = 0, int<0, 2> $type = 0)

Return the status

string|int
getLibFinished()

Retour label of nature of product

from  Product
int
correct_stock(User $user, int $id_entrepot, float $nbpiece, int<0, 1> $movement, string $label = '', int|float $price = 0, string $inventorycode = '', string $origin_element = '', ?int $origin_id = null, int $disablestockchangeforsubproduct = 0, ExtraFields $extrafields = null)

Adjust stock in a warehouse for product

from  Product
int
correct_stock_batch(User $user, int $id_entrepot, float $nbpiece, int<0, 1> $movement, string $label = '', int|float $price = 0, int|""|null $dlc = '', int|""|null $dluo = '', string|null $lot = '', string $inventorycode = '', string $origin_element = '', ?int $origin_id = null, int $disablestockchangeforsubproduct = 0, ExtraFields $extrafields = null, bool $force_update_batch = false)

Adjust stock in a warehouse for product with batch number

from  Product
load_stock($option = '', $includedraftpoforvirtual = null, $dateofvirtualstock = null)

Load information about stock of a product into ->stock_reel, ->stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products) This function need a lot of load. If you use it on list, use a cache to execute it once for each product id.

from  Product
load_virtual_stock(int $includedraftpoforvirtual = null, $dateofvirtualstock = null)

Load value ->stock_theorique of a product. Property this->id must be defined.

from  Product
int
loadStockForVirtualProduct(string $option = '', int|float $qtyWish = 1)

Load stock for components of virtual product (first level only)

from  Product
loadBatchInfo($batch)

Load existing information about a serial

from  Product
int
add_photo(string $sdir, array{name: string, tmp_name: string} $file)

Move an uploaded file described into $file array into target directory $sdir.

from  Product
bool
is_photo_available(string $sdir)

Return if at least one photo is available

from  Product
array<array{photo: string, photo_vignette: string}>
liste_photos(string $dir, int $nbmax = 0)

Return an array with all photos of product found on disk. There is no sorting criteria.

from  Product
void
delete_photo(string $file)

Delete a photo and its thumbs

from  Product
void
get_image_size(string $file)

Load size of image file

from  Product
int
loadStateBoard()

Load indicators this->nb for the dashboard

from  Product
bool
isProduct()

Return if the object is a product.

from  Product
bool
isService()

Return if the object is a service.

from  Product
bool
isStockManaged()

Return if the object is managed in stock.

from  Product
bool
isMandatoryPeriod()

Return if the object has a constraint on mandatory_period

from  Product
bool
hasbatch()

Return if the object has a sell-by or eat-by date.

from  Product
string
get_barcode(Product $object, string $type = '')

Get a barcode from the module to generate barcode values.

from  Product
int
initAsSpecimen()

Initialise an instance with random values.

from  Product
string|int
getLabelOfUnit(string $type = 'long', Translate|null $outputlangs = null, int $noentities = 0)

Reads the units dictionary to return the translation code of a unit (if type='code'), or translated long label (if type='long') or short label (if type='short').

from  Product
int
min_recommended_price()

Return minimum product recommended price

from  Product
int
setCategories(int[]|int $categories)

Sets object to supplied categories.

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

Function used to replace a thirdparty id with another one.

int
generateMultiprices(User $user, float $baseprice, string $price_type, float $price_vat, int $npr, int<0, 1> $psq)

Generates prices for a product based on product multiprice generation rules

from  Product
void
info(int $id)

Load information for tab info

from  Product
float|-1
getProductDurationHours()

Return the duration of a service in hours (for a service based on duration fields)

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

Return clickable link of object (with eventually picto)

from  Product
int
remove_fournisseur($id_fourn)

Remove all prices for this couple supplier-product

int
remove_product_fournisseur_price($rowid)

Remove a price for a couple supplier-product

update_buyprice($qty, float $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = 0, $options = array())

Modify the purchase price for a supplier

fetch_product_fournisseur_price($rowid, int $ignore_expression = 0)

Loads the price information of a provider

list_product_fournisseur_price($prodid, string $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0)

List all supplier prices of a product

find_min_price_product_fournisseur($prodid, float $qty = 0, $socid = 0)

Load properties for minimum price

int
setSupplierPriceExpression($expression_id)

Sets the supplier price expression

string
getSocNomUrl(int $withpicto = 0, string $option = 'supplier', int $maxlen = 0, $notooltip = 0)

Display supplier of product

display_price_product_fournisseur($showunitprice = 1, int<0, 1> $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array())

Display price of product

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

Function used to replace a product id with another one.

listProductFournisseurPriceLog($product_fourn_price_id, string $sortfield = '', $sortorder = '', $limit = 0, $offset = 0)

List supplier prices log of a supplier price

string
displayPriceProductFournisseurLog($productFournLogList = array())

Display log price of product supplier price

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

__construct(DoliDB $db)

Constructor

@param DoliDB $db Database handler

Parameters

DoliDB $db

Database handler

int check()

Check that ref and label are ok

Return Value

int

1 if OK, <=0 if KO

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

Insert product into database

Parameters

User $user

User making insert

int $notrigger

Disable triggers

Return Value

int

Id of product/service if OK, < 0 if KO

int verify()

Check properties of product are ok (like name, barcode, ...).

All properties must be already loaded on object (this->barcode, this->barcode_type_code, ...).

Return Value

int

0 if OK, <0 if KO

int check_barcode(string $valuetotest, string $typefortest)

Check barcode

Parameters

string $valuetotest

Value to test

string $typefortest

Type of barcode (ISBN, EAN, ...)

Return Value

int

0 if OK -1 ErrorBadBarCodeSyntax -2 ErrorBarCodeRequired -3 ErrorBarCodeAlreadyUsed

int update(int $id, User $user, int $notrigger = 0, string $action = 'update', bool $updatetype = false)

Update a record into database.

If batch flag is set to on, we create records into llx_product_batch

Parameters

int $id

Id of product

User $user

Object user making update

int $notrigger

Disable triggers

string $action

Current action for hookmanager ('add' or 'update')

bool $updatetype

Update product type

Return Value

int

1 if OK, -1 if ref already exists, -2 if other error

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

Delete a product from database (if not used)

Parameters

User $user

User (object) deleting product

int $notrigger

Do not execute trigger

Return Value

int

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

static array{0: string, 1: string, 2: string, 3: string} getSellOrEatByMandatoryList()

Get the array of labels of Sell by or Eat by all mandatory flags for each status

Return Value

array{0: string, 1: string, 2: string, 3: string}

Array of labels of Sell by or Eat by all mandatory flags

string getSellOrEatByMandatoryLabel()

Get the label for sell by or eat by mandatory flag of the current product

Return Value

string

Sell or eat by mandatory label

int setMultiLangs(User $user)

Update or add a translation for a product

Parameters

User $user

Object user making update

Return Value

int

Return integer <0 if KO, >0 if OK

int delMultiLangs(string $langtodelete, User $user)

Delete a language for this product

Parameters

string $langtodelete

Language code to delete

User $user

Object user making delete

Return Value

int

Return integer <0 if KO, >0 if OK

int setAccountancyCode(string $type, string $value)

Sets an accountancy code for a product.

Also calls PRODUCT_MODIFY trigger when modified

Parameters

string $type

It can be 'buy', 'buy_intra', 'buy_export', 'sell', 'sell_intra' or 'sell_export'

string $value

Accountancy code

Return Value

int

Return integer <0 KO >0 OK

int getMultiLangs()

Load array this->multilangs

Return Value

int

Return integer <0 if KO, >0 if OK

int log_price_delete(User $user, int $rowid)

Delete a price line

Parameters

User $user

Object user

int $rowid

Line id to delete

Return Value

int

Return integer <0 if KO, >0 if OK

getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0)

Return price of sell of a product for a seller/buyer/product.

Parameters

$thirdparty_seller
$thirdparty_buyer
$pqp

get_buyprice($prodfournprice, $qty, $product_id = 0, $fourn_ref = '', $fk_soc = 0)

Read price used by a provider.

We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref. This also set some properties on product like ->buyprice, ->fourn_pu, ...

Parameters

$prodfournprice
$qty
$product_id
$fourn_ref
$fk_soc

int<-1, 1> updatePrice(float $newprice, string $newpricebase, User $user, ?float $newvat = null, float|int $newminprice = 0, int $level = 0, int<0, 1> $newnpr = 0, int<0, 1> $newpbq = 0, int<0, 1> $ignore_autogen = 0, array{}|array{0: string, 1: int|string, 2: string, 3: string}|array{0: string, 1: int|string, 2: string, 3: int|string, 4: string, 5: string} $localtaxes_array = array(), string $newdefaultvatcode = '', string $price_label = '', int $notrigger = 0)

Modify customer price of a product/Service for a given level

Parameters

float $newprice

New price

string $newpricebase

HT or TTC

User $user

Object user that make change

?float $newvat

New VAT Rate (For example 8.5. Should not be a string)

float|int $newminprice

New price min

int $level

0=standard, >0 = level if multilevel prices

int<0, 1> $newnpr

0=Standard vat rate, 1=Special vat rate for French NPR VAT

int<0, 1> $newpbq

1 if it has price by quantity

int<0, 1> $ignore_autogen

Used to avoid infinite loops

array{}|array{0: string, 1: int|string, 2: string, 3: string}|array{0: string, 1: int|string, 2: string, 3: int|string, 4: string, 5: string} $localtaxes_array

Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).

string $newdefaultvatcode

Default vat code

string $price_label

Price Label

int $notrigger

Disable triggers

Return Value

int<-1, 1>

Return integer <0 if KO, >0 if OK

int setPriceExpression(int $expression_id) deprecated

deprecated Use Product::update instead

Sets the supplier price expression

Parameters

int $expression_id Expression

Return Value

int

Return integer <0 if KO, >0 if OK

int fetch(int $id = 0, string $ref = '', string $ref_ext = '', string $barcode = '', int $ignore_expression = 0, int $ignore_price_load = 0, int $ignore_lang_load = 0)

Load a product in memory from database

Parameters

int $id

Id of product/service to load

string $ref

Ref of product/service to load

string $ref_ext

Ref ext of product/service to load

string $barcode

Barcode of product/service to load

int $ignore_expression

When module dynamicprices is on, ignores the math expression for calculating price and uses the db value instead

int $ignore_price_load

Load product without loading $this->multiprices... array (when we are sure we don't need them)

int $ignore_lang_load

Load product without loading $this->multilangs language arrays (when we are sure we don't need them)

Return Value

int

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

int load_stats_mo(int $socid = 0)

Charge tableau des stats OF pour le produit/service

Parameters

int $socid

Id societe

Return Value

int

Array of stats in $this->stats_mo, <0 if ko or >0 if ok

int load_stats_bom(int $socid = 0)

Charge tableau des stats OF pour le produit/service

Parameters

int $socid

Id societe

Return Value

int

Array of stats in $this->stats_bom, <0 if ko or >0 if ok

int load_stats_propale(int $socid = 0)

Charge tableau des stats propale pour le produit/service

Parameters

int $socid

Id societe

Return Value

int

Array of stats in $this->stats_propale, <0 if ko or >0 if ok

int load_stats_proposal_supplier(int $socid = 0)

Charge tableau des stats propale pour le produit/service

Parameters

int $socid

Id thirdparty

Return Value

int

Array of stats in $this->stats_proposal_supplier, <0 if ko or >0 if ok

int load_stats_commande(int $socid = 0, string $filtrestatut = '', int $forVirtualStock = 0)

Charge tableau des stats commande client pour le produit/service

Parameters

int $socid

Id thirdparty to filter on a thirdparty

string $filtrestatut

Id status to filter on a status

int $forVirtualStock

Ignore rights filter for virtual stock calculation. Set when load_stats_commande is used for virtual stock calculation.

Return Value

int

Array of stats in $this->stats_commande (nb=nb of order, qty=qty ordered), <0 if ko or >0 if ok

int load_stats_commande_fournisseur(int $socid = 0, string $filtrestatut = '', int $forVirtualStock = 0, int $dateofvirtualstock = null)

Charge tableau des stats commande fournisseur pour le produit/service

Parameters

int $socid

Id thirdparty to filter on a thirdparty

string $filtrestatut

Id of status to filter on status

int $forVirtualStock

Ignore rights filter for virtual stock calculation.

int $dateofvirtualstock

Date of virtual stock

Return Value

int

Array of stats in $this->stats_commande_fournisseur, <0 if ko or >0 if ok

int load_stats_sending(int $socid = 0, string $filtrestatut = '', int $forVirtualStock = 0, string $filterShipmentStatus = '')

Charge tableau des stats expedition client pour le produit/service

Parameters

int $socid

Id thirdparty to filter on a thirdparty

string $filtrestatut

[=''] Ids order status separated by comma

int $forVirtualStock

Ignore rights filter for virtual stock calculation.

string $filterShipmentStatus

[=''] Ids shipment status separated by comma

Return Value

int

Array of stats in $this->stats_expedition, <0 if ko or >0 if ok

int load_stats_reception(int $socid = 0, string $filtrestatut = '', int $forVirtualStock = 0, int $dateofvirtualstock = null)

Charge tableau des stats réception fournisseur pour le produit/service

Parameters

int $socid

Id thirdparty to filter on a thirdparty

string $filtrestatut

Id status to filter on a status

int $forVirtualStock

Ignore rights filter for virtual stock calculation.

int $dateofvirtualstock

Date of virtual stock

Return Value

int

Array of stats in $this->stats_reception, <0 if ko or >0 if ok

int load_stats_inproduction(int $socid = 0, string $filtrestatut = '', int $forVirtualStock = 0, int $dateofvirtualstock = null, int $warehouseid = 0)

Charge tableau des stats production pour le produit/service

Parameters

int $socid

Id thirdparty to filter on a thirdparty

string $filtrestatut

Id status to filter on a status

int $forVirtualStock

Ignore rights filter for virtual stock calculation.

int $dateofvirtualstock

Date of virtual stock

int $warehouseid

Filter by a warehouse. Warning: When a filter on a warehouse is set, it is not possible to calculate an accurate virtual stock because we can't know in which warehouse will be done virtual stock changes.

Return Value

int

Array of stats in $this->stats_mrptoproduce (nb=nb of order, qty=qty ordered), <0 if ko or >0 if ok

int load_stats_contrat(int $socid = 0)

Charge tableau des stats contrat pour le produit/service

Parameters

int $socid

Id societe

Return Value

int

Array of stats in $this->stats_contrat, <0 if ko or >0 if ok

int load_stats_facture(int $socid = 0)

Charge tableau des stats facture pour le produit/service

Parameters

int $socid

Id societe

Return Value

int

Array of stats in $this->stats_facture, <0 if ko or >0 if ok

int load_stats_facturerec(int $socid = 0)

Load array of statistics for recurring invoice for product/service

Parameters

int $socid

Id societe

Return Value

int

Array of stats in $this->stats_facturerec, <0 if ko or >0 if ok

int load_stats_facture_fournisseur(int $socid = 0)

Load array of statistics for vendor invoice for product/service

Parameters

int $socid

Id societe

Return Value

int

Array of stats in $this->stats_facture_fournisseur, <0 if ko or >0 if ok

int load_stats_facturefournrec($socid = 0)

Load array of statistics for recurring supplier invoice for product/service

@param  int $socid  Id societe

Parameters

$socid

Return Value

int

Array of stats in $this->stats_facturefournrec, <0 if ko or >0 if ok

array<int<0, 11>, array<int, int|float>>|int<-1, -1> get_nb_vente(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units or customers invoices in which product is included

Parameters

int $socid

Limit count on a particular third party id

string $mode

'byunit'=number of unit, 'bynumber'=nb of entities

int $filteronproducttype

0=To filter on product only, 1=To filter on services only

int $year

Year (0=last 12 month, -1=all years)

string $morefilter

More sql filters

Return Value

array<int<0, 11>, array<int, int|float>>|int<-1, -1>

Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

array<int<0, 11>, array<int, int|float>>|int<-1, -1> get_nb_achat(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units or supplier invoices in which product is included

Parameters

int $socid

Limit count on a particular third party id

string $mode

'byunit'=number of unit, 'bynumber'=nb of entities

int $filteronproducttype

0=To filter on product only, 1=To filter on services only

int $year

Year (0=last 12 month, -1=all years)

string $morefilter

More sql filters

Return Value

array<int<0, 11>, array<int, int|float>>|int<-1, -1>

Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

array<int<0, 11>, array<int, int|float>>|int<-1, -1> get_nb_propal(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in proposals in which product is included

Parameters

int $socid

Limit count on a particular third party id

string $mode

'byunit'=number of unit, 'bynumber'=nb of entities, 'byamount'=amount

int $filteronproducttype

0=To filter on product only, 1=To filter on services only

int $year

Year (0=last 12 month, -1=all years)

string $morefilter

More sql filters

Return Value

array<int<0, 11>, array<int, int|float>>|int<-1, -1>

Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

array<int<0, 11>, array<int, int|float>>|int<-1, -1> get_nb_propalsupplier(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in proposals in which product is included

Parameters

int $socid

Limit count on a particular third party id

string $mode

'byunit'=number of unit, 'bynumber'=nb of entities

int $filteronproducttype

0=To filter on product only, 1=To filter on services only

int $year

Year (0=last 12 month, -1=all years)

string $morefilter

More sql filters

Return Value

array<int<0, 11>, array<int, int|float>>|int<-1, -1>

Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

array<int<0, 11>, array<int, int|float>>|int<-1, -1> get_nb_order(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in orders in which product is included

Parameters

int $socid

Limit count on a particular third party id

string $mode

'byunit'=number of unit, 'bynumber'=nb of entities

int $filteronproducttype

0=To filter on product only, 1=To filter on services only

int $year

Year (0=last 12 month, -1=all years)

string $morefilter

More sql filters

Return Value

array<int<0, 11>, array<int, int|float>>|int<-1, -1>

Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

array<int<0, 11>, array<int, int|float>>|int<-1, -1> get_nb_ordersupplier(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in orders in which product is included

Parameters

int $socid

Limit count on a particular third party id

string $mode

'byunit'=number of unit, 'bynumber'=nb of entities

int $filteronproducttype

0=To filter on product only, 1=To filter on services only

int $year

Year (0=last 12 month, -1=all years)

string $morefilter

More sql filters

Return Value

array<int<0, 11>, array<int, int|float>>|int<-1, -1>

Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

array<int<0, 11>, array<int, int|float>>|int<-1, -1> get_nb_contract(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in orders in which product is included

Parameters

int $socid

Limit count on a particular third party id

string $mode

'byunit'=number of unit, 'bynumber'=nb of entities

int $filteronproducttype

0=To filter on product only, 1=To filter on services only

int $year

Year (0=last 12 month, -1=all years)

string $morefilter

More sql filters

Return Value

array<int<0, 11>, array<int, int|float>>|int<-1, -1>

Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

array<int<0, 11>, array<int, int|float>>|int<-1, -1> get_nb_mos(int $socid, string $mode, int $filteronproducttype = -1, int $year = 0, string $morefilter = '')

Return nb of units in orders in which product is included

Parameters

int $socid

Limit count on a particular third party id

string $mode

'byunit'=number of unit, 'bynumber'=nb of entities

int $filteronproducttype

0=To filter on product only, 1=To filter on services only

int $year

Year (0=last 12 month, -1=all years)

string $morefilter

More sql filters

Return Value

array<int<0, 11>, array<int, int|float>>|int<-1, -1>

Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

int add_sousproduit(int $id_pere, int $id_fils, float $qty, int $incdec = 1, int $notrigger = 0)

Link a product/service to a parent product/service

Parameters

int $id_pere

Id of parent product/service

int $id_fils

Id of child product/service

float $qty Quantity
int $incdec

1=Increase/decrease stock of child when parent stock increase/decrease

int $notrigger

Disable triggers

Return Value

int

Return integer < 0 if KO, > 0 if OK

int update_sousproduit(int $id_pere, int $id_fils, float $qty, int $incdec = 1, int $notrigger = 0)

Modify composed product

Parameters

int $id_pere

Id of parent product/service

int $id_fils

Id of child product/service

float $qty Quantity
int $incdec

1=Increase/decrease stock of child when parent stock increase/decrease

int $notrigger

Disable triggers

Return Value

int

Return integer < 0 if KO, > 0 if OK

int del_sousproduit(int $fk_parent, int $fk_child, int $notrigger = 0)

Remove a link between a subproduct and a parent product/service

Parameters

int $fk_parent

Id of parent product (child will no more be linked to it)

int $fk_child

Id of child product

int $notrigger

Disable triggers

Return Value

int

Return integer < 0 if KO, > 0 if OK

int<-1, 1> is_sousproduit(int $fk_parent, int $fk_child)

Check if it is a sub-product into a kit

Parameters

int $fk_parent

Id of parent kit product

int $fk_child

Id of child product

Return Value

int<-1, 1>

Return 1 or 0; -1 if error

int<-3, 1> add_fournisseur(User $user, int $id_fourn, string $ref_fourn, float $quantity)

Add a supplier price for the product.

Note: Duplicate ref is accepted for different quantity only, or for different companies.

Parameters

User $user

User that make link

int $id_fourn

Supplier id

string $ref_fourn

Supplier ref

float $quantity

Quantity minimum for price

Return Value

int<-3, 1>

Return integer < 0 if KO, 0 if link already exists for this product, > 0 if OK

int[] list_suppliers()

Return list of suppliers providing the product or service

Return Value

int[]

Array of vendor ids

int clone_price(int $fromId, int $toId)

Recopie les prix d'un produit/service sur un autre

Parameters

int $fromId

Id product source

int $toId

Id product target

Return Value

int

Return integer < 0 if KO, > 0 if OK

int clone_associations(int $fromId, int $toId)

Clone links between products

Parameters

int $fromId

Product id

int $toId

Product id

Return Value

int

Return integer <0 if KO, >0 if OK

int clone_fournisseurs(int $fromId, int $toId)

Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre

Parameters

int $fromId

Id produit source

int $toId

Id produit cible

Return Value

int

Return integer < 0 si erreur, > 0 si ok

void fetch_prod_arbo(array<int, array{0: int, 1: float, 2: int, 3: string, 4: int, 5: string}> $prod, string $compl_path = '', int|float $multiply = 1, int $level = 1, int $id_parent = 0, int<0, 1> $ignore_stock_load = 0)

Function recursive, used only by get_arbo_each_prod(), to build tree of subproducts into ->res Define value of this->res

Parameters

array<int, array{0: int, 1: float, 2: int, 3: string, 4: int, 5: string}> $prod

Products array

string $compl_path

Directory path of parents to add before

int|float $multiply

Because each sublevel must be multiplicated by parent nb

int $level

Init level

int $id_parent

Id parent

int<0, 1> $ignore_stock_load

Ignore stock load

Return Value

void

CommonObject}> get_arbo_each_prod(int|float $multiply = 1, int<0, 1> $ignore_stock_load = 0)

Build the tree of subproducts and return it.

this->sousprods must have been loaded by this->get_sousproduits_arbo()

Parameters

int|float $multiply

Because each sublevel must be multiplicated by parent nb

int<0, 1> $ignore_stock_load

Ignore stock load

Return Value

CommonObject}>

Array with tree

hasFatherOrChild($mode = 0)

Count all parent and children products for current product (first level only)

Parameters

$mode

int hasVariants()

Return if a product has variants or not

Return Value

int

Number of variants

bool|int isVariant()

Return if loaded product is a variant

Return Value

bool|int

Return true if the product is a variant, false if not, -1 if error

array<int, array{id: int, ref: string, label: string, qty: float, incdec: int<0, 1>, fk_product_type: int, entity: int, status: int, status_buy: int}>|int<-1, -1> getFather()

Return all parent products for current product (first level only)

Return Value

array<int, array{id: int, ref: string, label: string, qty: float, incdec: int<0, 1>, fk_product_type: int, entity: int, status: int, status_buy: int}>|int<-1, -1>

Array of product

See also

hasFatherOrChild()

array<int, array{0: int, 1: float, 2: int, 3: string, 4: int, 5: string}>|array{}|int<-1, -1> getChildsArbo(int $id, int $firstlevelonly = 0, int $level = 1, int[] $parents = array())

Return children of product $id

Parameters

int $id

Id of product to search children of

int $firstlevelonly

Return only direct child

int $level

Level of recursing call (start to 1)

int[] $parents

Array of all parents of $id

Return Value

array<int, array{0: int, 1: float, 2: int, 3: string, 4: int, 5: string}>|array{}|int<-1, -1>

Return array(prodid=>array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref,6:int,7:int)

void get_sousproduits_arbo()

Return tree of all subproducts for product. Tree contains array of array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref) Set this->sousprods

Return Value

void

string getNomUrl(int $withpicto = 0, string $option = '', int $maxlength = 0, int $save_lastsearch_value = -1, int $notooltip = 0, string $morecss = '', int $add_label = 0, string $sep = ' - ')

Return a link to the object card (with optionally the picto).

Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl().

Parameters

int $withpicto

Add picto into link

string $option

Where point the link ('stock', 'composition', 'category', 'supplier', '')

int $maxlength

Maxlength of ref

int $save_lastsearch_value

-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values when clicking

int $notooltip

No tooltip

string $morecss

''=Add more css on link

int $add_label

0=Default, 1=Add label into string, >1=Add first chars into string

string $sep

' - '=Separator between ref and label if option 'add_label' is set

Return Value

string

String with URL

int generateDocument(string $modele, Translate $outputlangs, int $hidedetails = 0, int $hidedesc = 0, int $hideref = 0)

Create a document onto disk according to template module.

Parameters

string $modele

Force model to use ('' to not force)

Translate $outputlangs

Object langs to use for output

int $hidedetails

Hide details of lines

int $hidedesc

Hide description

int $hideref

Hide ref

Return Value

int

0 if KO, 1 if OK

string getLibStatut(int<0, 6> $mode = 0, int<0, 2> $type = 0)

Return the label of the 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

int<0, 6> $mode

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

int<0, 2> $type

0=Sell, 1=Buy, 2=Batch Number management

Return Value

string

Label of status

string LibStatut(int $status, int<0, 6> $mode = 0, int<0, 2> $type = 0)

Return the status

@param int $status Id status

Parameters

int $status 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<0, 2> $type

0=Status "to sell", 1=Status "to buy", 2=Status "to Batch"

Return Value

string

Label of status

string|int getLibFinished()

Retour label of nature of product

Return Value

string|int

Return label or ''. -1 if error

int correct_stock(User $user, int $id_entrepot, float $nbpiece, int<0, 1> $movement, string $label = '', int|float $price = 0, string $inventorycode = '', string $origin_element = '', ?int $origin_id = null, int $disablestockchangeforsubproduct = 0, ExtraFields $extrafields = null)

Adjust stock in a warehouse for product

Parameters

User $user

user asking change

int $id_entrepot

id of warehouse

float $nbpiece

nb of units (should be always positive, use $movement to decide if we add or remove)

int<0, 1> $movement

0 = add, 1 = remove

string $label

Label of stock movement

int|float $price

Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed.

string $inventorycode

Inventory code

string $origin_element

Origin element type

?int $origin_id

Origin id of element

int $disablestockchangeforsubproduct

Disable stock change for sub-products of kit (useful only if product is a subproduct)

ExtraFields $extrafields

Array of extrafields

Return Value

int

Return integer <0 if KO, >0 if OK

int correct_stock_batch(User $user, int $id_entrepot, float $nbpiece, int<0, 1> $movement, string $label = '', int|float $price = 0, int|""|null $dlc = '', int|""|null $dluo = '', string|null $lot = '', string $inventorycode = '', string $origin_element = '', ?int $origin_id = null, int $disablestockchangeforsubproduct = 0, ExtraFields $extrafields = null, bool $force_update_batch = false)

Adjust stock in a warehouse for product with batch number

Parameters

User $user

User asking change

int $id_entrepot

Id of warehouse

float $nbpiece

Nb of units (should be always positive, use $movement to decide if we add or remove)

int<0, 1> $movement

0 = add, 1 = remove

string $label

Label of stock movement

int|float $price

Price to use for stock eval

int|""|null $dlc

eat-by date

int|""|null $dluo

sell-by date

string|null $lot

Lot number

string $inventorycode

Inventory code

string $origin_element

Origin element type

?int $origin_id

Origin id of element

int $disablestockchangeforsubproduct

Disable stock change for sub-products of kit (useful only if product is a subproduct)

ExtraFields $extrafields

Array of extrafields

bool $force_update_batch

Force update batch

Return Value

int

Return integer <0 if KO, >0 if OK

load_stock($option = '', $includedraftpoforvirtual = null, $dateofvirtualstock = null)

Load information about stock of a product into ->stock_reel, ->stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products) This function need a lot of load. If you use it on list, use a cache to execute it once for each product id.

If ENTREPOT_EXTRA_STATUS is set, filtering on warehouse status is possible.

Parameters

$option
$includedraftpoforvirtual
$dateofvirtualstock

load_virtual_stock(int $includedraftpoforvirtual = null, $dateofvirtualstock = null)

Load value ->stock_theorique of a product. Property this->id must be defined.

This function need a lot of load. If you use it on list, use a cache to execute it one for each product id.

Parameters

int $includedraftpoforvirtual

Include draft status and not yet approved Purchase Orders for virtual stock calculation @param int $dateofvirtualstock Date of virtual stock @return int Return integer < 0 if KO, > 0 if OK @see load_stock(), loadBatchInfo()

$dateofvirtualstock

int loadStockForVirtualProduct(string $option = '', int|float $qtyWish = 1)

Load stock for components of virtual product (first level only)

Parameters

string $option

'' = Load all stock info, also from closed and internal warehouses, 'nobatch' = do not load batch detail, 'novirtual' = do no load virtual detail

int|float $qtyWish

[=1] Default quantity wish for the virtual product (1 by default or put qty ordered)

Return Value

int

Return integer < 0 if KO, > 0 if OK

loadBatchInfo($batch)

Load existing information about a serial

Parameters

$batch

int add_photo(string $sdir, array{name: string, tmp_name: string} $file)

Move an uploaded file described into $file array into target directory $sdir.

Parameters

string $sdir

Target directory

array{name: string, tmp_name: string} $file

Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...)

Return Value

int

Return integer <0 if KO, >0 if OK

bool is_photo_available(string $sdir)

Return if at least one photo is available

Parameters

string $sdir

Directory to scan

Return Value

bool

True if at least one photo is available, False if not

array<array{photo: string, photo_vignette: string}> liste_photos(string $dir, int $nbmax = 0)

Return an array with all photos of product found on disk. There is no sorting criteria.

Parameters

string $dir

Directory to scan

int $nbmax

Number maximum of photos (0=no maximum)

Return Value

array<array{photo: string, photo_vignette: string}>

Array of photos

void delete_photo(string $file)

Delete a photo and its thumbs

Parameters

string $file

Path to image file

Return Value

void

void get_image_size(string $file)

Load size of image file

Parameters

string $file

Path to file

Return Value

void

int loadStateBoard()

Load indicators this->nb for the dashboard

Return Value

int

Return integer <0 if KO, >0 if OK

bool isProduct()

Return if the object is a product.

Return Value

bool

True if the object is a product, false otherwise.

bool isService()

Return if the object is a service.

Return Value

bool

True if the object is a service, false otherwise.

bool isStockManaged()

Return if the object is managed in stock.

Return Value

bool

True if the object is managed in stock, false otherwise.

bool isMandatoryPeriod()

Return if the object has a constraint on mandatory_period

Return Value

bool

True if mandatory_period is set to 1, false otherwise.

bool hasbatch()

Return if the object has a sell-by or eat-by date.

Return Value

bool

True if the object has a sell-by or eat-by date, false otherwise.

string get_barcode(Product $object, string $type = '')

Get a barcode from the module to generate barcode values.

Return value is stored into this->barcode

Parameters

Product $object

Object product or service

string $type

Barcode type (ean, isbn, ...)

Return Value

string

int initAsSpecimen()

Initialise an instance with random values.

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

Return Value

int

string|int getLabelOfUnit(string $type = 'long', Translate|null $outputlangs = null, int $noentities = 0)

Reads the units dictionary to return the translation code of a unit (if type='code'), or translated long label (if type='long') or short label (if type='short').

TODO Duplicate of getLabelOfUnit() in commonobjectline.class.php

Parameters

string $type

Code type ('code', 'long' or 'short')

Translate|null $outputlangs

Language to use for long label translation

int $noentities

No entities

Return Value

string|int

Return integer <0 if KO, code or label of unit if OK.

Return minimum product recommended price

Return Value

int

Minimum recommended price that is higher price among all suppliers * PRODUCT_MINIMUM_RECOMMENDED_PRICE

int setCategories(int[]|int $categories)

Sets object to supplied categories.

Deletes object from existing categories not supplied. 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

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

Function used to replace a thirdparty id with another one.

Parameters

DoliDB $dbs

Database handler

int $origin_id

Old thirdparty id

int $dest_id

New thirdparty id

Return Value

bool

int generateMultiprices(User $user, float $baseprice, string $price_type, float $price_vat, int $npr, int<0, 1> $psq)

Generates prices for a product based on product multiprice generation rules

Parameters

User $user

User that updates the prices

float $baseprice

Base price

string $price_type

Base price type

float $price_vat

VAT % tax

int $npr NPR
int<0, 1> $psq

1 if it has price by quantity

Return Value

int

-1 KO, 1 OK

void info(int $id)

Load information for tab info

Parameters

int $id

Id of thirdparty to load

Return Value

void

float|-1 getProductDurationHours()

Return the duration of a service in hours (for a service based on duration fields)

Return Value

float|-1

Duration in hours if OK, -1 if KO

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

int remove_fournisseur($id_fourn)

Remove all prices for this couple supplier-product

@param int $id_fourn Supplier Id

Parameters

$id_fourn

Return Value

int

Return integer < 0 if error, > 0 if ok

int remove_product_fournisseur_price($rowid)

Remove a price for a couple supplier-product

@param  int     $rowid      Line id of price

Parameters

$rowid

Return Value

int

Return integer <0 if KO, >0 if OK

update_buyprice($qty, float $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = 0, $options = array())

Modify the purchase price for a supplier

@param float $qty Min quantity for which price is valid

Parameters

$qty
float $buyprice

Purchase price for the quantity min @param User $user Object user user made changes @param string $price_base_type HT or TTC @param Societe $fourn Supplier @param int $availability Product availability @param string $ref_fourn Supplier ref @param float $tva_tx New VAT Rate (For example 8.5. Should NOT be a string) @param string|float $charges costs affering to product @param float $remise_percent Discount regarding qty (percent) @param float $remise Discount regarding qty (amount) @param int $newnpr Set NPR or not @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) @param array{0:string,1:float|int,2:string,3:float|int}|array} $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). @param string $newdefaultvatcode Default vat code @param float $multicurrency_buyprice Purchase price for the quantity min in currency @param string $multicurrency_price_base_type HT or TTC in currency @param float $multicurrency_tx Rate currency @param string $multicurrency_code Currency code @param string $desc_fourn Custom description for product_fourn_price @param string $barcode Barcode @param int $fk_barcode_type Barcode type @param array<string,mixed> $options Extrafields of product fourn price @return int Return integer <0 if KO, >=0 if OK

$user
$price_base_type
$fourn
$availability
$ref_fourn
$tva_tx
$charges
$remise_percent
$remise
$newnpr
$delivery_time_days
$supplier_reputation
$localtaxes_array
$newdefaultvatcode
$multicurrency_buyprice
$multicurrency_price_base_type
$multicurrency_tx
$multicurrency_code
$desc_fourn
$barcode
$fk_barcode_type
$options

fetch_product_fournisseur_price($rowid, int $ignore_expression = 0)

Loads the price information of a provider

@param int $rowid Line id in product_fournisseur_price

Parameters

$rowid
int $ignore_expression

Ignores the math expression for calculating price and uses the db value instead @return int Return integer < 0 if KO, 0 if OK but not found, > 0 if OK

list_product_fournisseur_price($prodid, string $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0)

List all supplier prices of a product

@param int $prodid Id of product

Parameters

$prodid
string $sortfield

Sort field @param string $sortorder Sort order @param int $limit Limit @param int $offset Offset @param int $socid Filter on a third party id @return ProductFournisseur[]|int<-1,-1> Array of ProductFournisseur with new properties to define supplier price find_min_price_product_fournisseur()

$sortorder
$limit
$offset
$socid

find_min_price_product_fournisseur($prodid, float $qty = 0, $socid = 0)

Load properties for minimum price

@param int $prodid Product id

Parameters

$prodid
float $qty

Minimum quantity @param int $socid Load min price for this specific supplier @return int Return integer <0 if KO, 0=Not found of no product id provided, >0 if OK list_product_fournisseur_price()

$socid

int setSupplierPriceExpression($expression_id)

Sets the supplier price expression

@param int $expression_id Expression

Parameters

$expression_id

Return Value

int

Return integer <0 if KO, >0 if OK

string getSocNomUrl(int $withpicto = 0, string $option = 'supplier', int $maxlen = 0, $notooltip = 0)

Display supplier of product

Parameters

int $withpicto

Add picto

string $option

Target of link ('', 'customer', 'prospect', 'supplier')

int $maxlen

Max length of name @param integer $notooltip 1=Disable tooltip

$notooltip

Return Value

string

String with supplier price TODO Remove this method. Use getNomUrl directly.

display_price_product_fournisseur($showunitprice = 1, int<0, 1> $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array())

Display price of product

@param int<0,1> $showunitprice Show "Unit price" into output string

Parameters

$showunitprice
int<0, 1> $showsuptitle

Show "Supplier" into output string @param int $maxlen Max length of name @param int<0,1> $notooltip 1=Disable tooltip @param ProductFournisseur[] $productFournList list of ProductFournisseur objects to display in table format. @return string String with supplier price

$maxlen
$notooltip
$productFournList

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

Function used to replace a product 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

listProductFournisseurPriceLog($product_fourn_price_id, string $sortfield = '', $sortorder = '', $limit = 0, $offset = 0)

List supplier prices log of a supplier price

@param int $product_fourn_price_id Id of supplier price

Parameters

$product_fourn_price_id
string $sortfield

Sort field @param string $sortorder Sort order @param int $limit Limit @param int $offset Offset @return array<array{rowid:int,supplier_ref:int,datec:int,lastname:string,price:float,quantity:float,fk_multicurrency:int,multicurrency_code:string,multicurrency_tx:string,multicurrency_price:string,multicurrency_unitprice:string}>|int<-1,-1> Array of Log prices

$sortorder
$limit
$offset

string displayPriceProductFournisseurLog($productFournLogList = array())

Display log price of product supplier price

@param array<array{rowid:int,supplier_ref:int,datec:int,lastname:string,price:float,quantity:float,fk_multicurrency:int,multicurrency_code:string,multicurrency_tx:string,multicurrency_price:string,multicurrency_unitprice:string}>|int<-1,-1> $productFournLogList list of ProductFournisseur price log objects to display in table format.

Parameters

$productFournLogList

Return Value

string

HTML String with supplier price