Fournisseur
class Fournisseur extends Societe (View source)
Class to manage suppliers
Traits
Trait for incoterm classes
Superclass for social networks
Support class for third parties, contacts, members, users or resources
Class for handling deprecated properties and methods
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
Constants
| STATUS_CEASED |
|
| STATUS_INACTIVITY |
|
| NO_CUSTOMER |
Third party type is no customer |
| CUSTOMER |
Third party type is a customer |
| PROSPECT |
Third party type is a prospect |
| CUSTOMER_AND_PROSPECT |
Third party type is a customer and a prospect |
| NO_SUPPLIER |
Third party supplier flag is not supplier |
| SUPPLIER |
Third party supplier flag is a supplier |
Properties
| DoliDB | $db | from CommonTrigger | |
| $error | from CommonTrigger | ||
| string[] | $errors | from CommonTrigger | |
| string | $TRIGGER_PREFIX | from CommonTrigger | |
| string | $module | from Societe | |
| int | $id | from CommonPeople | |
| ?int | $entity | from CommonObject | |
| $errorhidden | from CommonObject | ||
| string[] | $warnings | from CommonObject | |
| string | $element | from CommonPeople | |
| string | $fk_element | from Societe | |
| string | $element_for_permission | from CommonObject | |
| string | $table_element | from CommonIncoterm | |
| ?string | $table_rowid | from CommonObject | |
| string | $table_element_line | from CommonObject | |
| int<0, 1>|string|null | $ismultientitymanaged | from CommonObject | |
| string | $import_key | Import key. |
from Societe |
| 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 Societe | |
| 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 string | $table_ref_field | from CommonObject | |
| int<0, 1> | $restrictiononfksoc | 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user |
from Societe |
| 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 CommonPeople | |
| 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 Societe | |
| string | $ref_ext | External user reference. |
from Societe |
| string | $ref_previous | from CommonObject | |
| string | $ref_next | from CommonObject | |
| ?string | $newref | from CommonObject | |
| $statut | from CommonObject | ||
| int | $status | Thirdparty status : 0=activity ceased, 1= in activity |
from Societe |
| string | $country | from CommonObject | |
| int | $country_id | from Societe | |
| string | $country_code | from CommonPeople | |
| ?string | $state | from CommonPeople | |
| int | $state_id | from CommonPeople | |
| string | $state_code | from CommonPeople | |
| $region_id | from CommonObject | ||
| string | $region_code | from Societe | |
| string | $region | from CommonPeople | |
| int | $barcode_type | from CommonObject | |
| $barcode_type_code | from CommonObject | ||
| $barcode_type_label | from CommonObject | ||
| $barcode_type_coder | from CommonObject | ||
| ?int | $mode_reglement_id | from Societe | |
| ?int | $cond_reglement_id | from Societe | |
| ?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 Societe | |
| string | $multicurrency_code | from Societe | |
| 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 | Public note |
from Societe |
| ?string | $note_private | Private note |
from Societe |
| $note | from Societe | ||
| ?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 CommonPeople | |
| string | $lastname | from CommonPeople | |
| string | $firstname | from CommonPeople | |
| string deprecated | $civility_id | from CommonObject | |
| string | $civility_code | from CommonPeople | |
| 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 | |
| $next_prev_filter | |||
| int<0, 1> | $specimen | from CommonObject | |
| int[] | $sendtoid | from CommonObject | |
| $alreadypaid | from CommonObject | ||
| $totalpaid | from CommonObject | ||
| $totalpaid_multicurrency | from CommonObject | ||
| array<int, string> | $labelStatus | from CommonObject | |
| array<int, string> | $labelStatusShort | from CommonObject | |
| array<string, int|float|string|null> | $tpl | from CommonObject | |
| int | $showphoto_on_popup | from CommonObject | |
| array{actionscomm?: int, banklines?: int, cheques?: int, contacts?: int, contracts?: int, customers?: int, dolresource?: int, donations?: int, expensereports?: int, holidays?: int, interventions?: int, invoices?: int, members?: int, orders?: int, products?: int, projects?: int, proposals?: int, prospects?: int, services?: int, supplier_invoices?: int, supplier_orders?: int, supplier_proposals?: int, suppliers?: int, tasks?: int, ticket?: int, users?: int} | $nb | from CommonObject | |
| int | $nbphoto | from CommonObject | |
| string | $output | from CommonObject | |
| array<string, string>|string | $extraparams | from CommonObject | |
| protected array<string, array{name: string}> | $childtables | from Societe | |
| protected string[] | $childtablesoncascade | from Societe | |
| int | $cond_reglement_supplier_id | from Societe | |
| string|float | $deposit_percent | from Societe | |
| int | $retained_warranty_fk_cond_reglement | from CommonObject | |
| int | $warehouse_id | from CommonObject | |
| int<0, 1> | $isextrafieldmanaged | from CommonObject | |
| int | $fk_incoterms | from CommonIncoterm | |
| string | $label_incoterms | from CommonIncoterm | |
| string | $location_incoterms | from CommonIncoterm | |
| array<string, string> | $socialnetworks | from CommonPeople | |
| ?string | $address | from CommonPeople | |
| ?string | $zip | from CommonPeople | |
| ?string | $town | from CommonPeople | |
| ?string | from CommonPeople | ||
| ?string | $url | from CommonPeople | |
| int | $fk_soc | from CommonPeople | |
| string | $name_alias | from CommonPeople | |
| string | $nom | from CommonPeople | |
| string | $company | from CommonPeople | |
| string | $personal_email | from CommonPeople | |
| string | $fax | from CommonPeople | |
| string | $office_fax | from CommonPeople | |
| string | $office_phone | from CommonPeople | |
| string | $phone | from CommonPeople | |
| string | $phone_perso | from CommonPeople | |
| string | $phone_pro | from CommonPeople | |
| string | $phone_mobile | from CommonPeople | |
| string | $user_mobile | from CommonPeople | |
| string | $fieldsforcombobox | from Societe | |
| string | $picto | from Societe | |
| string[] | $SupplierCategories | array of supplier categories |
from Societe |
| int | $prefixCustomerIsRequired | prefixCustomerIsRequired | from Societe |
| int | $particulier | from Societe | |
| $departement_code | from Societe | ||
| $departement | from Societe | ||
| $pays | from Societe | ||
| int | $no_email | No Email |
from Societe |
| string deprecated | $skype | Skype username |
from Societe |
| string deprecated | Twitter username |
from Societe | |
| string deprecated | Facebook username |
from Societe | |
| string deprecated | LinkedIn username |
from Societe | |
| string | $barcode | Barcode value |
from Societe |
| ?string | $idprof1 | Professional ID 1 (Ex: Siren in France) |
from Societe |
| $siren | from Societe | ||
| ?string | $idprof2 | Professional ID 2 (Ex: Siret in France) |
from Societe |
| $siret | from Societe | ||
| ?string | $idprof3 | Professional ID 3 (Ex: Ape in France) |
from Societe |
| $ape | from Societe | ||
| ?string | $idprof4 | Professional ID 4 (Ex: RCS in France) |
from Societe |
| ?string | $idprof5 | Professional ID 5 |
from Societe |
| ?string | $idprof6 | Professional ID 6 |
from Societe |
| ?string | $idprof7 | Professional ID 7 |
from Societe |
| ?string | $idprof8 | Professional ID 8 |
from Societe |
| ?string | $idprof9 | Professional ID 9 |
from Societe |
| ?string | $idprof10 | Professional ID 10 |
from Societe |
| string | $socialobject | Social object of the company |
from Societe |
| string | $prefix_comm | from Societe | |
| int | $tva_assuj | from Societe | |
| ?string | $tva_intra | from Societe | |
| int<0, 1> | $vat_reverse_charge | from Societe | |
| int | $localtax1_assuj | from Societe | |
| string | $localtax1_value | from Societe | |
| int | $localtax2_assuj | from Societe | |
| string | $localtax2_value | from Societe | |
| string | $managers | from Societe | |
| null|float|"" | $capital | from Societe | |
| int | $typent_id | from Societe | |
| string | $typent_code | from Societe | |
| int | $effectif | from Societe | |
| int | $effectif_id | from Societe | |
| int | $forme_juridique_code | from Societe | |
| string | $forme_juridique | from Societe | |
| int|null | $birth | from Societe | |
| string | $remise_percent | from Societe | |
| string | $remise_supplier_percent | from Societe | |
| int | $mode_reglement_supplier_id | from Societe | |
| int | $transport_mode_supplier_id | from Societe | |
| string | $fk_prospectlevel | from Societe | |
| string | $name_bis | from Societe | |
| User deprecated | $user_modification | User that made last update |
from Societe |
| User deprecated | $user_creation | User that created the thirdparty |
from Societe |
| int | $client | 0=no customer, 1=customer, 2=prospect, 3=customer and prospect |
from Societe |
| int | $prospect | 0=no prospect, 1=prospect |
from Societe |
| int | $fournisseur | 0=no supplier, 1=supplier |
from Societe |
| ?string | $code_client | Client code. E.g: CU2014-003 |
from Societe |
| ?string | $code_fournisseur | Supplier code. E.g: SU2014-003 |
from Societe |
| ?string | $code_compta_client | Accounting code for client |
from Societe |
| ?string | $accountancy_code_customer_general | Accounting general account for customer |
from Societe |
| ?string | $accountancy_code_customer | Accounting auxiliary account for customer |
from Societe |
| ?string | $code_compta_fournisseur | Accounting code for supplier |
from Societe |
| ?string | $accountancy_code_supplier_general | Accounting general account for supplier |
from Societe |
| ?string | $accountancy_code_supplier | Accounting auxiliary account for supplier |
from Societe |
| string | $code_compta_product | Accounting code for product (for level 3 of suggestion of product accounting account) |
from Societe |
| ?int | $stcomm_id | Status prospect id |
from Societe |
| string | $stcomm_picto | Status prospect picto |
from Societe |
| int | $status_prospect_label | Status prospect label |
from Societe |
| int | $price_level | Assigned price level |
from Societe |
| string | $outstanding_limit | from Societe | |
| string | $order_min_amount | from Societe | |
| string | $supplier_order_min_amount | from Societe | |
| int | $commercial_id | Id of sales representative to link (used for thirdparty creation). Not filled by a fetch, because we can have several sales representatives. |
from Societe |
| int | $parent | Id of parent thirdparty (if one) |
from Societe |
| string | $default_lang | Default language code of thirdparty (en_US, ...) |
from Societe |
| string | $ip | from Societe | |
| string | $webservices_url | Supplier WebServices URL |
from Societe |
| string | $webservices_key | Supplier WebServices Key |
from Societe |
| string | $logo | from Societe | |
| string | $logo_small | from Societe | |
| string | $logo_mini | from Societe | |
| string | $logo_squarred | from Societe | |
| string | $logo_squarred_small | from Societe | |
| string | $logo_squarred_mini | from Societe | |
| string | $accountancy_code_sell | from Societe | |
| string | $accountancy_code_buy | from Societe | |
| string | $currency_code | from Societe | |
| ?int | $fk_warehouse | from Societe | |
| string | $termsofsale | from Societe | |
| mixed[][] | $partnerships | from Societe | |
| null|Account|string | $bank_account | from Societe | |
| ?string deprecated | $code_compta | from Societe |
Methods
Provide list of deprecated properties
Provide list of deprecated methods
Call trigger based on this instance.
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
Return customer ref for screen output.
Return supplier ref for screen output.
Return full address of contact
Return the link of last main doc file for direct public download.
Add a link between element $this->element and a contact
Copy contact from one element to current
Update a link to contact line
Delete all links between an object $this and all its contacts in llx_element_contact
Get array of all contacts for an object
Return array with list of possible values for type of contacts
Return array with list of possible values for type of contacts
Return id of contacts for a source and a contact code.
Load object contact with id=$this->contact_id into $this->contact
Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty
Looks for an object with ref matching the wildcard provided It does only work when $this->table_ref_field is set
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.
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.
Load the product with id $this->fk_product into this->product
Load object from specific field
Getter generic. Load value from a specific field
Setter generic. Update a specific field into database.
Load properties id_previous and id_next by comparing $fieldid with $this->ref
Return list of id of contacts of object
Change the retained warranty payments terms
Change the shipping method
Change the bank account
Save a new position (field rang) for details lines.
Update a line to have a higher rank
Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines).
Add an object link into llx_element_element.
Return an element type string formatted like element_element target_type and source_type
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
Clear the cache saying that all linked object were already loaded. So next fetchObjectLinked will reload all links.
Update object linked of a current object
Delete all links between an object $this
Function used to get an array with all items linked to an object id in association table
Count items linked to an object id in association table
Function used to remove all items linked to an object id in association table
Set status of an object.
Load type of canvas of an object if it exists
Function to check if an object is used by others (by children).
Function to say how many lines object contains
Function that returns the total amount HT of discounts applied for all lines.
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.
Show add free and predefined products/services form
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.
Return HTML content of a detail line TODO Move this into an output class file (htmlline.class.php)
Return HTML table table of source object lines TODO Move this and previous function into output html class file (htmlline.class.php).
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).
Add resources to the current object : add entry into llx_element_resources Need $this->element & $this->id
Delete a link to resource line
Overwrite magic function to solve problem of cloning object that are kept as references
Common function for all objects extending CommonObject for generating documents
Index a file into the ECM database
Return the default value to use for a field when showing the create form of object.
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.
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.
Function to make a fetch but set environment to avoid to load computed values before.
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.
Add/Update all extra fields values for the current object.
Add/Update all extra languages values for the current object.
Update 1 extra field value for the current object. Keep other fields unchanged.
Convenience method for retrieving the value of an extrafield without actually fetching it from the database.
Convenience method for setting the value of an extrafield without actually updating it in the database.
Update an extra language value for the current object.
Return HTML string to put an input field into a page Code very similar with showInputField of extra fields
Return HTML string to show a field into a page Code very similar with showOutputField of extra fields
clear validation message result for a field
set validation error message a field
Return validation test result for a field
Function to show lines of extrafields with output data.
Function used to replace a thirdparty id with another one.
Function used to replace a product id with another one.
Get buy price to use for margin calculation. This function is called when buy price is unknown.
Function used to get the logos or photos of an object
Show photos of an object (nbmax maximum), into several columns
Function test if type is array
Function test if type is date
Function test if type is duration
Function test if type is integer
Function test if type is float
Function test if type is text
Function test if field can be null
Function test if field is forced to null if zero or empty
Function test if is indexed
Function to return the array of data key-value from the ->fields and all the ->properties of an object.
Function to load data from a SQL pointer into properties of current object $this
Sets all object fields to null. Useful for example in lists, when printing multiple lines and a different object os fetched for each line.
Function to concat keys of fields
Add quote to field value if necessary
Load object in memory from the database. This does not load line. This is done by parent fetch() that call fetchCommon
Load object in memory from the database
Delete object in database
Delete all child object from a parent ID
Initialise object with example values Id must be 0 if object instance is a specimen
Sets object to given categories.
Sets object to given categories.
Copy related categories to another object
Check if all products have the right status (on sale, on buy) called during validation of propal, order, supplier proposal, supplier order
Set the error message for the object without logging it.
Set the error message for the object and log it.
Define incoterms values of current object
Show social network part if the module is enabled with hiding functionality
Return full name (civility+' '+name+' '+lastname)
Constructor
Create a contact/address from thirdparty
Check properties of third party are ok (like name, third party codes, ...) Used before an add or update.
Update parameters of third party
Load a third party from database into memory
Search the thirdparty that match the most the provided parameters.
Delete a third party from database and all its dependencies (contacts, rib...)
Add a discount for third party
Returns amount of included taxes of the current discounts/credits available from the company
Return amount (with tax) of discounts currently available for a company, user or other criteria
Return array of sales representatives
Return a link on thirdparty (with picto)
Return link(s) on type of thirdparty (with picto)
Return list of contacts emails existing for third party
Return list of contacts mobile phone existing for third party
Return list of contacts emails or mobile existing for third party
Return bank number property of thirdparty (label or rum)
Assigns a customer code from the code control module.
Assigns a vendor code from the code control module.
Check if a client code is editable based on the parameters of the code control module.
Check if a vendor code is editable in the code control module configuration
Assigns a accounting code from the accounting code module.
Check if a thirdparty $idchild is or not inside the parents (or grand parents) of another thirdparty id $idparent.
Get parents for company
Verify if a profid exists into database for others thirds
Check the validity of a professional identifier according to the country of the company (siren, siret, ...)
Return an url to check online a professional id or empty string
Return number of mass Emailing received by this contacts with its email
Create a third party into database from a member object
Check if we must use localtax feature or not according to country (country of $mysoc in most cases).
Check if we must use NPR Vat (french stupid rule) or not according to country (country of $mysoc in most cases).
Check if we must use revenue stamps feature or not according to country (country of $mysoc in most cases).
Return label of a given status
Return amount of proposal not yet paid and total an dlist of all proposals
Return amount of order not yet paid and total and list of all orders
Return amount of bill not yet paid and total of all invoices
Create a document onto disk according to template module.
Sets object to supplied categories.
Sets sales representatives of the thirdparty
Function used to replace a thirdparty id with another one.
Sets an accountancy code for a thirdparty.
Return clickable link of object (with optional picto)
Get array of all contacts for a society (stored in societe_contacts instead of element_contacts for all other objects)
Merge a company with current one, deleting the given company $soc_origin_id.
Return nb of orders
Returns number of ref prices (not number of products) for current supplier
Load statistics indicators
Create a supplier category
Return the suppliers list
Details
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
protected array<string, string>
deprecatedProperties()
Provide list of deprecated properties
Override this method in subclasses
protected array<string, string>
deprecatedMethods()
Provide list of deprecated methods
Override this method in subclasses
final static protected string
getCallerInfoString()
Get caller info
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.
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', ...)
bool
isEmpty()
isEmpty We consider CommonObject isEmpty if this->id is empty
void
setErrorsFromObject(CommonObject|HookManager $object)
setErrorsFromObject
getTooltipContentArray($params)
getTooltipContentArray
getTooltipContent($params)
getTooltipContent
string
errorsToString()
Method to output saved errors
string
getFormatedCustomerRef(string $objref)
Return customer ref for screen output.
string
getFormatedSupplierRef(string $objref)
Return supplier ref for screen output.
abstract
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
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
@param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if source = 'internal') to link
copy_linked_contact($objFrom, "internal"|"external" $source = 'internal')
Copy contact from one element to current
@param CommonObject $objFrom Source element
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
delete_contact($rowid, int $notrigger = 0)
Delete a link to contact line
@param int $rowid Id of contact link line to delete
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'
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.
int
swapContactStatus($rowid)
Update status of a contact linked to object
@param int $rowid Id of link between object and contact
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'
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'
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')
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.
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
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
@return int<-1,1> Return integer <0 if KO, >=0 if OK
fetch_project()
deprecated
deprecated
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
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
int<-1, 1>
fetch_user(int $userid)
Load the user with id $userid into this->user
void
fetch_origin()
Read linked origin object.
Set ->origin_object
int<-1, 1>|false
fetchObjectFrom($table, string $field, $key, $element = null)
Load object from specific field
@param string $table Table element or element line
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.
Warning: Trigger is run only if param trigkey is provided.
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'))".
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)
int<-1, 1>
setProject(int $projectid, $notrigger = 0)
Link element with a project
int
setPaymentMethods($id)
Change the payments methods
@param int $id Id of new payment method
int
setMulticurrencyCode($code)
Change the multicurrency code
@param string $code multicurrency code
setMulticurrencyRate($rate, int $mode = 1)
Change the multicurrency rate
@param double $rate multicurrency rate
setPaymentTerms($id, float $deposit_percent = null)
Change the payments terms
@param int $id Id of new payment terms
int
setTransportMode($id)
Change the transport mode methods
@param int $id Id of transport mode
int
setRetainedWarrantyPaymentTerms($id)
Change the retained warranty payments terms
@param int $id Id of new payment terms
int
setDeliveryAddress(int $id)
Define delivery address
@deprecated
setShippingMethod($shipping_method_id, int $notrigger = 0, $userused = null)
Change the shipping method
@param int $shipping_method_id Id of shipping method
int
setWarehouse($warehouse_id)
Change the warehouse
@param int $warehouse_id Id of warehouse
setDocModel($user, string $modelpdf)
Set last model used by doc generator
@param User $user User object that make change
setBankAccount($fk_account, int $notrigger = 0, $userused = null)
Change the bank account
@param int $fk_account Id of bank account
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.
getChildrenOfLine($id, int<0, 1001> $includealltree = 0)
Get children of line
@param int $id Id of parent line
line_up($rowid, bool $fk_parent_line = true)
Update a line to have a lower rank
@param int $rowid Id of line
line_down($rowid, bool $fk_parent_line = true)
Update a line to have a higher rank
@param int $rowid Id of line
updateRangOfLine($rowid, int $rang)
Update position of line (rang)
@param int $rowid Id of line
void
line_ajaxorder($rows)
Update position of line with ajax (rang)
@param int[] $rows Array of rows
updateLineUp($rowid, int $rang)
Update position of line up (rang)
@param int $rowid Id of line
updateLineDown($rowid, int $rang, $max)
Update position of line down (rang)
@param int $rowid Id of line
int
getRangOfLine($rowid)
Get position of line (rang)
@param int $rowid Id of line
int
getIdOfLine($rang)
Get rowid of the line relative to its position
@param int $rang Rang value
int
line_max($fk_parent_line = 0)
Get max value used for position of line (rang)
@param int $fk_parent_line Parent line id
int
update_ref_ext($ref_ext)
Update external ref of element
@param string $ref_ext Update field ref_ext
update_note($note, string $suffix = '', $notrigger = 0)
Update note of element
@param string $note New value for note
int
update_note_public(string $note)
deprecated
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).
Must be called at end of methods addline or updateline.
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.
@param int $status Status to set
getCanvas($id = 0, string $ref = '')
Load type of canvas of an object if it exists
@param int $id Record id
int
getSpecialCode($lineid)
Get special code of a line
@param int $lineid Id of line
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.
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
@param int $dateSelector 1=Show also date range input fields
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).
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.
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.
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
@param int $rowid Id of resource line to delete
void
__clone()
Overwrite magic function to solve problem of cloning object that are kept as references
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
int
indexFile(string $destfull, int $update_main_doc_field)
Index a file into the ECM database
void
addThumbs(string $file, $quality = 50)
Build thumb
@todo Move this into files.lib.php
void
delThumbs(string $file)
Delete thumbs
@todo Move this into files.lib.php
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)
abstract
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.
@return 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
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.
@param int $rowid Id of line. Use the id of object if not defined. Deprecated. Function must be called without parameters.
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.
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.
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', ...)
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.
Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
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.
This function is responsible to output the
string
getJSListDependancies(string $type = '_extra')
No description
null|int|stdClass
getRights()
Returns the rights used for this class
static bool
commonReplaceThirdparty(DoliDB $dbs, int $origin_id, int $dest_id, array $tables, int<0, 1> $ignoreerrors = 0)
Function used to replace a thirdparty id with another one.
This function is meant to be called from replaceThirdparty with the appropriate tables Column name fk_soc MUST exist.
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
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
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
@param string $modulepart 'product', 'ticket', ...
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
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
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
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
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
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).
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
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
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.
Deletes object from existing categories not supplied. Adds it to non existing supplied categories. Existing categories are left untouch.
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.
int
cloneCategories(int $fromId, int $toId, string $type = '')
Copy related categories to another object
bool
deleteEcmFiles(int $mode = 0)
Delete related files of object in database
bool
checkActiveProductInLines(string $status = 'onsale')
Check if all products have the right status (on sale, on buy) called during validation of propal, order, supplier proposal, supplier order
void
setErrorWithoutLog(string $message)
Set the error message for the object without logging it.
void
setErrorWithLog(string $message, int<0, 7> $loglevel = LOG_ERR)
Set the error message for the object and log it.
display_incoterms()
Return incoterms information TODO Use a cache for label get
@return string incoterms info
getIncotermsForPDF()
Return incoterms information for pdf display
@return string|boolean Incoterms info or false
setIncoterms($id_incoterm, string $location)
Define incoterms values of current object
@param int $id_incoterm Id of incoterm to set or '' to remove
void
showSocialNetwork(array<string, array{active: int<0, 1>, icon: string, label: string}> $socialnetworks, int $colspan = 4)
Show social network part if the module is enabled with hiding functionality
getFullName(Translate $langs, int<0, 1> $option = 0, $nameorder = -1, $maxlen = 0)
Return full name (civility+' '+name+' '+lastname)
getCivilityLabel()
Return civility label of object
@return string Translated name of civility
string
getBannerAddress($htmlkey, CommonObject $object)
Return full address for banner
@param string $htmlkey HTML id to make banner content unique
void
setUpperOrLowerCase()
Set to upper or ucwords/lower if needed
__construct($db)
Constructor
@param DoliDB $db Database handler
create(User $user, $notrigger = 0)
Create third party in database.
$this->code_client = -1 and $this->code_fournisseur = -1 means automatic assignment.
int<-1, 1>
create_individual(User $user, int<0, 1> $no_email = 0, string[] $tags = array(), int<0, 1> $notrigger = 0)
Create a contact/address from thirdparty
verify()
Check properties of third party are ok (like name, third party codes, ...) Used before an add or update.
@return int 0 if OK, <0 if KO
update($id, User $user, $call_trigger = 1, $allowmodcodeclient = 0, $allowmodcodefournisseur = 0, $action = 'update', $nosyncmember = 1)
Update parameters of third party
@param int $id Id of company (deprecated, use 0 here and call update on an object loaded by a fetch)
fetch($rowid, string $ref = '', $ref_ext = '', $barcode = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '', $is_client = 0, $is_supplier = 1)
Load a third party from database into memory
@param int $rowid Id of third party to load
findNearest(int $rowid = 0, $ref = '', $ref_ext = '', $barcode = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '', $is_client = 0, $is_supplier = 0)
Search the thirdparty that match the most the provided parameters.
Searching rules try to find the existing third party.
delete($id, User $fuser = null, $call_trigger = 1)
Delete a third party from database and all its dependencies (contacts, rib...)
@param int $id Id of third party to delete
int
set_as_client()
Define third party as a customer
int
setAsCustomer()
Define third party as a customer
int
set_remise_client($remise, string $note, User $user)
Defines the company as a customer
@param float $remise Value in % of the discount
int
set_remise_supplier($remise, string $note, User $user)
Defines the company as a customer
@param float $remise Value in % of the discount
set_remise_except($remise, User $user, $desc, $vatrate = '', $discount_type = 0, $price_base_type = 'HT')
Add a discount for third party
@param float $remise Amount of discount
float|int<-1, -1>
getAvailableDiscounts(User $user = null, $filter = '', $maxvalue = 0, $discount_type = 0)
Returns amount of included taxes of the current discounts/credits available from the company
int
getOpenCreditNotesNotYetConvertedIntoDiscount($discount_type = 0)
Return amount (with tax) of discounts currently available for a company, user or other criteria
@param int<0,1> $discount_type 0 => customer discount, 1 => supplier discount
int<-1, -1>|int[]|array<array{id: int, lastname: string, firstname: string, email: string, phone: string, office_phone: string, office_fax: string, user_mobile: string, personal_mobile: string, job: string, statut: int, status: int, entity: int, login: string, photo: string, gender: string}>
getSalesRepresentatives(User $user, int<0, 1> $mode = 0, $sortfield = null, $sortorder = null)
Return array of sales representatives
@param User $user Object user (not used)
int
setPriceLevel(int $price_level, User $user)
Set the price level
int
add_commercial(User $user, int $commid)
Add link to sales representative
int
del_commercial(User $user, int $commid)
Add link to sales representative
getNomUrl($withpicto = 0, string $option = '', $maxlen = 0, $notooltip = 0, $save_lastsearch_value = -1, $noaliasinname = 0, $target = '', $morecss = '')
Return a link on thirdparty (with picto)
@param int<0,2> $withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only)
getTypeUrl($withpicto = 0, string $option = '', $notooltip = 0, $tag = 'a')
Return link(s) on type of thirdparty (with picto)
@param int $withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only)
string
getLibStatut(int<0, 6> $mode = 0)
Return label of status (activity, closed)
LibStatut($status, int<0, 6> $mode = 0)
Return the label of a given status
@param int $status Status id
array<"thirdparty"|int, string>
thirdparty_and_contact_email_array(int<0, 2> $addthirdparty = 0)
Return list of contacts emails existing for third party
array<"thirdparty"|int, string>
thirdparty_and_contact_phone_array()
Return list of contacts mobile phone existing for third party
contact_property_array($mode = 'email', int<0, 1> $hidedisabled = 0)
Return list of contacts emails or mobile existing for third party
@param 'email'|'mobile' $mode 'email' or 'mobile'
string[]
contact_array()
Return the contact list of this company
Contact[]
contact_array_objects()
Return the contact list of this company
contact_get_property($rowid, string $mode)
Return property of contact from its id
@param int $rowid id of contact
display_rib(string $mode = 'label')
Return bank number property of thirdparty (label or rum)
CompanyBankAccount[]|int
get_all_rib()
Return Array of RIB
int
getDefaultRib()
No description
get_codeclient(Societe $objsoc = null, int $type = 0)
Assigns a customer code from the code control module.
Return value is stored into this->code_client
get_codefournisseur(Societe $objsoc = null, int $type = 1)
Assigns a vendor code from the code control module.
Return value is stored into this->code_fournisseur
codeclient_modifiable()
Check if a client code is editable based on the parameters of the code control module.
@return int 0=No, 1=Yes
codefournisseur_modifiable()
Check if a vendor code is editable in the code control module configuration
@return int 0=No, 1=Yes
check_codeclient()
Check customer code
@return int 0 if OK -1 ErrorBadCustomerCodeSyntax -2 ErrorCustomerCodeRequired -3 ErrorCustomerCodeAlreadyUsed -4 ErrorPrefixRequired -5 NotConfigured - Setup empty so any value may be ok or not -6 Other (see this->error)
check_codefournisseur()
Check supplier code
@return int 0 if OK -1 ErrorBadCustomerCodeSyntax -2 ErrorCustomerCodeRequired -3 ErrorCustomerCodeAlreadyUsed -4 ErrorPrefixRequired -5 NotConfigured - Setup empty so any value may be ok or not -6 Other (see this->error)
get_codecompta(string $type)
Assigns a accounting code from the accounting code module.
Computed value is stored into this->code_compta_client or this->code_compta_fournisseur according to $type. May be identical to the one entered or generated automatically. Currently, only the automatic generation is implemented.
int
setParent($id)
Define parent company of current company
@param int $id Id of thirdparty to set or '' to remove
validateFamilyTree($idparent, int $idchild, $counter = 0)
Check if a thirdparty $idchild is or not inside the parents (or grand parents) of another thirdparty id $idparent.
@param int $idparent Id of thirdparty to check
int[]
getParentsForCompany(int $company_id, int[] $parents = array())
Get parents for company
bool
id_prof_verifiable($idprof)
Returns if a profid should be verified to be unique
@param int $idprof 1,2,3,4,5,6 (Example: 1=siren, 2=siret, 3=naf, 4=rcs/rm, 5=eori, 6=idprof6)
id_prof_exists($idprof, string $value, $socid = 0)
Verify if a profid exists into database for others thirds
@param string $idprof 'idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','email' (Example: idprof1=siren, idprof2=siret, idprof3=naf, idprof4=rcs/rm)
id_prof_check($idprof, Societe $soc)
Check the validity of a professional identifier according to the country of the company (siren, siret, ...)
@param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm)
id_prof_url($idprof, Societe $thirdparty)
Return an url to check online a professional id or empty string
@param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm)
has_projects()
Indicates if the company has projects
@return bool true if the company has projects, false otherwise
void
info($id)
Load information for tab info
@param int $id Id of thirdparty to load
isACompany()
Check if third party is a company (Business) or an end user (Consumer)
@return int if a company > 0, if an individual = 0
isInEEC()
Return if a company is inside the EEC (European Economic Community)
@return boolean true = country inside EEC, false = country outside EEC
isInSEPA()
Return if a company is inside the SEPA zone (Single Euro Payment Area)
@return boolean true = country inside SEPA, false = country outside SEPA
LoadSupplierCateg()
Load the list of provider categories
@return int 0 if success, <> 0 if error
AddFournisseurInCategory(int $categorie_id)
Insert link supplier - category
getNbOfEMailings()
Return number of mass Emailing received by this contacts with its email
@return int Number of EMailings
setNoEmail($no_email, string $unsubscribegroup = '')
Set "blacklist" mailing status
@param int $no_email 1=Do not send mailing, 0=Ok to receive mailing
getNoEmail()
get "blacklist" mailing status set no_email attribute to 1 or 0
@return int Return integer <0 if KO, >0 if OK
create_from_member(Adherent $member, string $socname = '', string $socalias = '', $customercode = '')
Create a third party into database from a member object
@param Adherent $member Object member
void
setMysoc(Conf $conf)
Set properties with value into $conf
@param Conf $conf Conf object (possibility to use another entity)
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.
useLocalTax(int<-1, 2> $localTaxNum = 0, $mode = 0, $thirdparty = null)
Check if we must use localtax feature or not according to country (country of $mysoc in most cases).
useNPR()
Check if we must use NPR Vat (french stupid rule) or not according to country (country of $mysoc in most cases).
@return boolean true or false
bool
useRevenueStamp()
Check if we must use revenue stamps feature or not according to country (country of $mysoc in most cases).
Table c_revenuestamp contains the country and value of stamp per invoice.
getLibProspLevel()
Return prostect level
@return string Label of prospect status
string
LibProspLevel($fk_prospectlevel)
Return label of prospect level
@param string $fk_prospectlevel Prospect level
getLibProspCommStatut($mode = 0, string $label = '')
Return status of prospect
@param int $mode 0=label long, 1=label short, 2=Picto + Label short, 3=Picto, 4=Picto + Label long
LibProspCommStatut($status, int $mode = 0, $label = '', string $picto = '')
Return label of a given status
@param int|string $status Id or code for prospection status
array{opened: float, total_ht: float, total_ttc: float}|array{}
getOutstandingProposals($mode = 'customer')
Return amount of proposal not yet paid and total an dlist of all proposals
@param 'customer'|'supplier' $mode 'customer' or 'supplier'
array{opened: float, total_ht: float, total_ttc: float}|array{}
getOutstandingOrders($mode = 'customer')
Return amount of order not yet paid and total and list of all orders
@param 'customer'|'supplier'|'' $mode 'customer' or 'supplier'
getOutstandingBills($mode = 'customer', int<0, 1> $late = 0)
Return amount of bill not yet paid and total of all invoices
@param 'customer'|'supplier'|'' $mode 'customer' or 'supplier'
string
getLibCustProspStatut()
Return label of status customer is prospect/customer
string
LibCustProspStatut($status)
Return the label of the customer/prospect status
@param int $status Id of prospection status
int
generateDocument(string $modele, Translate $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
Create a document onto disk according to template module.
int
setCategories(int[]|int $categories, string $type_categ, bool $remove_existing = true)
Sets object to supplied 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.
int<-1, 1>
setSalesRep(int[]|int $salesrep, bool $onlyAdd = false)
Sets sales representatives of the thirdparty
int
setThirdpartyType($typent_id)
Define third-party type of current company
@param int $typent_id third party type rowid in llx_c_typent
static bool
replaceThirdparty(DoliDB $dbs, int $origin_id, int $dest_id)
Function used to replace a thirdparty id with another one.
int
setAccountancyCode(string $type, string $value)
Sets an accountancy code for a thirdparty.
Also calls COMPANY_MODIFY trigger when modified
int
fetchPartnerships($mode)
Function to get partnerships array
@param string $mode 'member' or 'thirdparty'
getKanbanView(string $option = '', $arraydata = array())
Return clickable link of object (with optional picto)
getContacts($list = 0, string $code = '', $element = '')
Get array of all contacts for a society (stored in societe_contacts instead of element_contacts for all other objects)
@param int $list 0:Return array contains all properties, 1:Return array contains just id
mergeCompany(int $soc_origin_id)
Merge a company with current one, deleting the given company $soc_origin_id.
The company given in parameter will be removed. This is called for example by the societe/card.php file. It calls the method replaceThirdparty() of each object with relation with thirdparties, including hook 'replaceThirdparty' for external modules.
int
getNbOfOrders()
Return nb of orders
int
nbOfProductRefs()
Returns number of ref prices (not number of products) for current supplier
int
loadStateBoard()
Load statistics indicators
CreateCategory($user, string $name)
Create a supplier category
@param User $user User asking creation
array<int, string>
ListArray()
Return the suppliers list