dolibarr 25.0.0-alpha
CommonObject Class Reference
Inheritance diagram for CommonObject:

Public Member Functions

 setErrorsFromObject ($object)
 setErrorsFromObject
 
 getTooltipContentArray ($params)
 Return array of data to show into a tooltip.
 
 getTooltipContent ($params)
 getTooltipContent
 
 errorsToString ()
 Method to output saved errors.
 
 getFormatedCustomerRef ($objref)
 Return customer ref for screen output.
 
 getFormatedSupplierRef ($objref)
 Return supplier ref for screen output.
 
 getFullAddress ($withcountry=0, $sep="\n", $withregion=0, $extralangcode='')
 Return full address of contact.
 
 getLastMainDocLink ($modulepart, $initsharekey=0, $relativelink=0)
 Return the link of last main doc file for direct public download.
 
 add_contact ($fk_socpeople, $type_contact, $source='external', $notrigger=0)
 Add a link between element $this->element and a contact.
 
 copy_linked_contact ($objFrom, $source='internal')
 Copy contact from one element to current.
 
 update_contact ($rowid, $statut, $type_contact_id=0, $fk_socpeople=0)
 Update a link to contact line.
 
 delete_contact ($rowid, $notrigger=0)
 Delete a link to contact line.
 
 delete_linked_contact ($source='', $code='')
 Delete all links between an object $this and all its contacts in llx_element_contact.
 
 liste_contact ($statusoflink=-1, $source='external', $list=0, $code='', $status=-1, $arrayoftcids=array())
 Get array of all contacts for an object.
 
 swapContactStatus ($rowid)
 Update status of a contact linked to object.
 
 liste_type_contact ($source='internal', $order='position', $option=0, $activeonly=0, $code='')
 Return array with list of possible values for type of contacts.
 
 listeTypeContacts ($source='internal', $option=0, $activeonly=0, $code='', $element='', $excludeelement='')
 Return array with list of possible values for type of contacts.
 
 getIdContact ($source, $code, $status=0)
 Return id of contacts for a source and a contact code.
 
 fetch_contact ($contactid=null)
 Load object contact with id=$this->contact_id into $this->contact.
 
 fetch_thirdparty ($force_thirdparty_id=0)
 Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty.
 
 fetchOneLike ($ref)
 Looks for an object with ref matching the wildcard provided It does only work when $this->table_ref_field is set.
 
 fetch_barcode ()
 Load data for barcode into properties ->barcode_type* Properties ->barcode_type that is id of barcode.
 
 fetchBarCode ()
 Load data for barcode into properties ->barcode_type* Properties ->barcode_type that is id of barcode.
 
 fetchProject ()
 Load the project with id $this->fk_project into this->project.
 
 fetch_project ()
 Load the project with id $this->fk_project into this->project.
 
 fetch_projet ()
 Load the project with id $this->fk_project into this->project.
 
 fetch_product ()
 Load the product with id $this->fk_product into this->product.
 
 fetchWarehouse ($force_warehouse_id=0)
 Load the warehouse of object, from id $this->warehouse_id or $this->fk_warehouse, into this->warehouse.
 
 fetch_user ($userid)
 Load the user with id $userid into this->user.
 
 fetch_origin ()
 Read linked origin object.
 
 fetchObjectFrom ($table, $field, $key, $element=null)
 Load object from specific field.
 
 getValueFrom ($table, $id, $field)
 Getter generic.
 
 setFieldValue (User $user, $fieldKey, $value, $byPassUserPermission=false)
 Set a value for a dynamic field on the current object.
 
 getFieldUiValue ($field)
 Return the value of a field of $fields, read in the property holding it (see getFieldPropertyName()).
 
 updateFieldFromUi (User $user, $field, $value)
 Update a field from the user interface (ajax edition of cards...) and save it into database.
 
 getFieldValueFromAjaxPost ($field)
 Return the value of a field posted by the user interface (ajax edition of fields).
 
 ajaxOutputField ($field)
 Return the output html of a field for the user interface (ajax edition of fields).
 
 ajaxInputField ($field)
 Return the input html of a field for the user interface (ajax edition of fields).
 
 setValueFrom ($field, $value, $table='', $id=null, $format='', $id_field='', $fuser=null, $trigkey='', $fk_user_field='fk_user_modif')
 Setter generic.
 
 load_previous_next_ref ($filter, $fieldid, $nodbprefix=0)
 Load properties id_previous and id_next by comparing $fieldid with $this->ref.
 
 getListContactId ($source='external')
 Return list of id of contacts of object.
 
 setProject ($projectid, $notrigger=0)
 Link element with a project.
 
 setPaymentMethods ($id)
 Change the payments methods.
 
 setMulticurrencyCode ($code)
 Change the multicurrency code.
 
 setPaymentTerms ($id, $deposit_percent=null)
 Change the payments terms.
 
 setTransportMode ($id)
 Change the transport mode methods.
 
 setDeliveryAddress ($id)
 Define delivery address.
 
 setShippingMethod ($shipping_method_id, $notrigger=0, $userused=null)
 Change the shipping method.
 
 setWarehouse ($warehouse_id)
 Change the warehouse.
 
 setDocModel ($user, $modelpdf)
 Set last model used by doc generator.
 
 setBankAccount ($fk_account, $notrigger=0, $userused=null)
 Change the bank account.
 
 line_order ($renum=false, $rowidorder='ASC', $fk_parent_line=true)
 Save a new position (field rang) for details lines.
 
 getChildrenOfLine ($id, $includealltree=0)
 Get children of line.
 
 line_up ($rowid, $fk_parent_line=true)
 Update a line to have a lower rank.
 
 line_down ($rowid, $fk_parent_line=true)
 Update a line to have a higher rank.
 
 updateRangOfLine ($rowid, $rang)
 Update position of line (rang)
 
 line_ajaxorder ($rows)
 Update position of line with ajax (rang)
 
 updateLineUp ($rowid, $rang)
 Update position of line up (rang)
 
 updateLineDown ($rowid, $rang, $max)
 Update position of line down (rang)
 
 getRangOfLine ($rowid)
 Get position of line (rang)
 
 getIdOfLine ($rang)
 Get rowid of the line relative to its position.
 
 roundQtyToPackaging ($qty, $packaging)
 Round a quantity up to the next multiple of a packaging quantity (options PRODUCT_USE_CUSTOMER_PACKAGING and PRODUCT_USE_SUPPLIER_PACKAGING).
 
 line_max ($fk_parent_line=0)
 Get max value used for position of line (rang)
 
 update_ref_ext ($ref_ext)
 Update external ref of element.
 
 update_note ($note, $suffix='', $notrigger=0)
 Update note of element.
 
 update_note_public ($note)
 Update public note (kept for backward compatibility)
 
 update_price ($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.
 
 getElementType ()
 Return an element type string formatted like element_element target_type and source_type.
 
 fetchObjectLinked ($sourceid=null, $sourcetype='', $targetid=null, $targettype='', $clause='OR', $alsosametype=1, $orderby='sourcetype', $loadalsoobjects=1)
 Fetch array of objects linked to current object (object of enabled modules only).
 
 clearObjectLinkedCache ()
 Clear the cache saying that all linked object were already loaded.
 
 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.
 
 setStatut ($status, $elementId=null, $elementType='', $trigkey='', $fieldstatus='')
 Set status of an object.
 
 getCanvas ($id=0, $ref='')
 Load type of canvas of an object if it exists.
 
 getSpecialCode ($lineid)
 Get special code of a line.
 
 isObjectUsed ($id=0, $entity=0)
 Function to check if an object is used by others (by children).
 
 hasProductsOrServices ($predefined=-1)
 Function to say how many lines object contains.
 
 getTotalDiscount ()
 Function that returns the total amount HT of discounts applied for all lines.
 
 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.
 
 setExtraParameters ()
 Set extra parameters.
 
 formAddObjectLine ($dateSelector, $seller, $buyer, $defaulttpldir='/core/tpl')
 Show add free and predefined products/services form.
 
 printObjectLines ($action, $seller, $buyer, $selected=0, $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.
 
 getObjectLinesDisplayContext ()
 Return the display context of the lines, as defined by the card of the object before printObjectLines() and formAddObjectLine().
 
 initObjectLinesDisplay ()
 Init the display of the lines: set the global variables used by the line templates (objectline_xxx.tpl.php) from getObjectLinesDisplayContext() To call in the card before printObjectLines() and formAddObjectLine().
 
 getObjectLineHtml ($lineid, $action='')
 Return the HTML of a line as printed in the card by printObjectLines(), hooks printObjectLine and printObjectSubLine included.
 
 printObjectLine ($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $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 ($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 ($line, $var, $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).
 
 add_element_resource ($resource_id, $resource_type, $busy=0, $mandatory=0, $notrigger=0)
 Add resources to the current object : add entry into llx_element_resources Need $this->element & $this->id.
 
 delete_resource ($rowid, $element='', $notrigger=0)
 Delete a link to resource line.
 
 __clone ()
 Overwrite magic function to solve problem of cloning object that are kept as references.
 
 indexFile ($destfull, $update_main_doc_field)
 Index a file into the ECM database.
 
 addThumbs ($file, $quality=50)
 Build thumb.
 
 delThumbs ($file)
 Delete thumbs.
 
 getDefaultCreateValueFor ($fieldname, $alternatevalue=null, $type='alphanohtml')
 Return the default value to use for a field when showing the create form of object.
 
 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.
 
 setValuesForExtraLanguages ($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.
 
 fetchNoCompute ($id)
 Function to make a fetch but set environment to avoid to load computed values before.
 
 fetch_optionals ($rowid=null, $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 ($trigger='', $userused=null)
 Add/Update all extra fields values for the current object.
 
 insertExtraLanguages ($trigger='', $userused=null)
 Add/Update all extra languages values for the current object.
 
 updateExtraField ($key, $trigger=null, $userused=null)
 Update 1 extra field value for the current object.
 
 getExtraField ($key)
 Convenience method for retrieving the value of an extrafield without actually fetching it from the database.
 
 setExtraField ($key, $value)
 Convenience method for setting the value of an extrafield without actually updating it in the database.
 
 updateExtraLanguages ($key, $trigger=null, $userused=null)
 Update an extra language value for the current object.
 
 showInputField ($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $morecss=0, $nonewbutton=0)
 Return HTML string to put an input field into a page Code very similar with showInputField of extra fields.
 
 clearFieldError ($fieldKey)
 clear validation message result for a field
 
 setFieldError ($fieldKey, $msg='')
 set validation error message a field
 
 getFieldError ($fieldKey)
 get field error message
 
 validateField ($fields, $fieldKey, $fieldValue)
 Return validation test result for a field.
 
 showOptionals ($extrafields, $mode='view', $params=null, $keysuffix='', $keyprefix='', $onetrtd='', $display_type='card')
 Function to show lines of extrafields with output data.
 
 getJSListDependancies ($type='_extra')
 
 getRights ()
 Returns the rights used for this class.
 
 getRightsForUser (User $user)
 Returns the rights used for this class for a specific user.
 
 hasUserPermission (User $user, $mode='write')
 Check if user has a permission on this type of object.
 
 hasUserWritePermissionOnField (User $user, $field)
 Check if user has write permission on a field of this object.
 
 hasUserPermissionOnField (User $user, $field, $mode='write')
 Check if user has a permission on a field of this object.
 
 isFieldEditAllowed (User $user, $field, $byPassUserPermission=false)
 Check whether a given field is allowed to be edited on the current object.
 
 isFieldEditableFromUi (User $user, $field)
 Check whether a field can be edited from the user interface with generic tools (ajax edition of cards...), where the user chooses the field to modify.
 
 isFieldReadableFromUi (User $user, $field)
 Check whether the value of a field can be read from the user interface with generic tools (ajax refresh of the values displayed on a card...), by a user allowed to read the object.
 
 defineBuyPrice ($unitPrice=0.0, $discountPercent=0.0, $fk_product=0, $qty=0)
 Get buy price to use for margin calculation.
 
 getLinkedBuyPriceDocuments ($user, $lineid, $oldbuyprice=null)
 Return the linked proposals, orders and invoices having, for the product of a line of this object, a cost price different from the one saved on the line (for a purchase order, the average net unit price of the product on the ordered purchase orders linked to the same documents, weighted by the quantities).
 
 updateLinkedBuyPrice ($user, $lineid, $elements)
 Apply the cost price of a line of this object to the lines of the same product of some linked documents.
 
 getDataToShowPhoto ($modulepart, $imagesize)
 Function used to get the logos or photos of an object.
 
 show_photos ($modulepart, $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.
 
 isDate ($info)
 Function test if type is date.
 
 isDuration ($info)
 Function test if type is duration.
 
 isInt ($info)
 Function test if type is integer.
 
 isFloat ($info)
 Function test if type is float.
 
 isText ($info)
 Function test if type is text.
 
 setVarsFromFetchObj (&$obj)
 Function to load data from a SQL pointer into properties of current object $this.
 
 emtpyObjectVars ()
 Sets all object fields to null.
 
 getFieldList ($alias='', $excludefields=array())
 Function to concat keys of fields.
 
 createCommon (User $user, $notrigger=0)
 Create object in the database.
 
 fetchCommon ($id, $ref=null, $morewhere='', $noextrafields=0)
 Load object in memory from the database.
 
 fetchLinesCommon ($morewhere='', $noextrafields=0)
 Load object in memory from the database.
 
 updateCommon (User $user, $notrigger=0)
 Update object into database.
 
 deleteCommon (User $user, $notrigger=0, $forcechilddeletion=0)
 Delete object in database.
 
 deleteByParentField ($parentId=0, $parentField='', $filter='', $filtermode="AND")
 Delete all child object from a parent ID.
 
 isLineOfObject ($lineid)
 Check that a line belongs to this object, using $this->table_element_line and $this->fk_element.
 
 deleteLineCommon (User $user, $idline, $notrigger=0)
 Delete a line of object in database.
 
 setStatusCommon ($user, $status, $notrigger=0, $triggercode='')
 Set to a status.
 
 initAsSpecimenCommon ()
 Initialise object with example values Id must be 0 if object instance is a specimen.
 
 fetchComments ()
 Load comments linked with current task.
 
 getNbComments ()
 Return nb comments already posted.
 
 trimParameters ($parameters)
 Trim object parameters.
 
 getCategoriesCommon ($type_categ)
 Sets object to given categories.
 
 setCategoriesCommon ($categories, $type_categ='', $remove_existing=true)
 Sets object to given categories.
 
 cloneCategories ($fromId, $toId, $type='')
 Copy related categories to another object.
 
 deleteEcmFiles ($mode=0)
 Delete related files of object in database.
 
 checkActiveProductInLines ($status='onsale')
 Check if all products have the right status (on sale, on buy) called during validation of propal, order, supplier proposal, supplier order.
 
 setErrorWithoutLog ($message)
 Set the error message for the object without logging it.
 
 setErrorWithLog ($message, $loglevel=LOG_ERR)
 Set the error message for the object and logs it, including the file name and line number.
 
 showLastFilePreview ($rootdir='', $relativepath='')
 Show preview link of the element (last generate or *<ref>*.pdf) if found and authorized to show the preview (file type)
 

Static Public Member Functions

static isExistingObject ($element, $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.
 
static getAllItemsLinkedByObjectID ($fk_object_where, $field_select, $field_where, $table_element)
 Function used to get an array with all items linked to an object id in association table.
 
static getCountOfItemsLinkedByObjectID ($fk_object_where, $field_where, $table_element)
 Count items linked to an object id in association table.
 
static deleteAllItemsLinkedByObjectID ($fk_object_where, $field_where, $table_element)
 Function used to remove all items linked to an object id in association table.
 
static commonReplaceThirdparty (DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
 Function used to replace a thirdparty id with another one.
 
static commonReplaceProduct (DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
 Function used to replace a product id with another one.
 
static commonReplaceContact (DoliDB $dbs, $origin_id, $dest_id, array $tables, $fieldname='fk_socpeople', $ignoreerrors=0)
 Function used to replace a contact id with another one.
 

Public Attributes

 $origin_object
 

Protected Member Functions

 deprecatedProperties ()
 Provide list of deprecated properties and replacements.
 
 onFieldValueChanged ($fieldKey, $value)
 Hook called by setFieldValue() after a field has been successfully assigned.
 
 getFieldPropertyName ($field)
 Return the name of the property of the object holding the value of a field of $fields.
 
 persistFieldValue (User $user, $field)
 Save into database the current value of one field, called by updateFieldFromUi().
 
 prepareObjectLinesDisplay ()
 Prepare the display of the lines: global $usemargins and line extrafields used by the line templates (objectline_xxx.tpl.php) Used by printObjectLines() and getObjectLineHtml()
 
 printObjectLineWithHooks ($action, $line, $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafields, $defaulttpldir)
 Print a line of the lines table: hooks printObjectLine or printObjectSubLine, then printObjectLine() if no hook replaced it Used by printObjectLines() and getObjectLineHtml()
 
 commonGenerateDocument ($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
 Common function for all objects extending CommonObject for generating documents.
 
 isFieldDefined ($field)
 Check if the field is defined in the object's field metadata.
 
 isFieldDisabled ($field)
 Check if the field is explicitly marked as disabled.
 
 isFieldValidationRequired ($field)
 Check if the field requires validation.
 
 isFieldEnabled ($field)
 Check if the field is enabled.
 
 isFieldMarkedNotEditable ($field)
 Check if the field is explicitly marked as not editable.
 
 isFieldBlockedByObjectState ($field)
 Check if the field is blocked by the current object state.
 
 isArray ($info)
 Function test if type is array.
 
 canBeNull ($info)
 Function test if field can be null.
 
 isForcedToNullIfZero ($info)
 Function test if field is forced to null if zero or empty.
 
 isIndex ($info)
 Function test if is indexed.
 
 setSaveQuery ()
 Function to return the array of data key-value from the ->fields and all the ->properties of an object.
 
 quote ($value, $fieldsentry)
 Add quote to field value if necessary.
 

Detailed Description

Definition at line 59 of file commonobject.class.php.

Member Function Documentation

◆ __clone()

CommonObject::__clone ( )

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

Returns
void

Definition at line 6676 of file commonobject.class.php.

◆ add_contact()

CommonObject::add_contact ( $fk_socpeople,
$type_contact,
$source = 'external',
$notrigger = 0 )

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

Parameters
int$fk_socpeopleId of thirdparty contact (if source = 'external') or id of user (if source = 'internal') to link
int | string$type_contactType of contact (code or id). Must be id or code found into table llx_c_type_contact. For example: SALESREPFOLL
string$sourceexternal=Contact extern (llx_socpeople), internal=Contact intern (llx_user)
int$notriggerDisable all triggers
Returns
int Return integer <0 if KO, 0 if already added or code not valid, >0 if OK

Definition at line 1330 of file commonobject.class.php.

References dol_now(), dol_syslog(), and liste_contact().

Referenced by CommandeFournisseur\approve(), copy_linked_contact(), Commande\create(), Expedition\create(), Facture\create(), Ticket\create(), Fichinter\createFromClone(), Task\mergeContactTask(), and SupplierProposal\valid().

◆ add_element_resource()

CommonObject::add_element_resource ( $resource_id,
$resource_type,
$busy = 0,
$mandatory = 0,
$notrigger = 0 )

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

Parameters
int$resource_idResource id
string$resource_type'resource'
int$busyBusy or not
int$mandatoryMandatory or not
int$notriggerDisable all triggers
Returns
int Return integer <=0 if KO, >0 if OK

Definition at line 6591 of file commonobject.class.php.

References dol_syslog().

◆ add_object_linked()

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

Add an object link into llx_element_element.

Parameters
string$originLinked element type
int$origin_idLinked element id
User$f_userUser that create
int$notrigger1=Does not execute triggers, 0=execute triggers
Returns
int Return integer <=0 if KO, >0 if OK
See also
fetchObjectLinked(), updateObjectLinked(), deleteObjectLinked()

Definition at line 4800 of file commonobject.class.php.

References dol_syslog().

Referenced by Asset\create(), Commande\create(), CommandeFournisseur\create(), Delivery\create(), Expedition\create(), Facture\create(), FactureFournisseur\create(), FactureFournisseurRec\create(), FactureRec\create(), Fichinter\create(), Propal\create(), Reception\create(), Subscription\create(), SupplierProposal\create(), and Asset\dispose().

◆ addThumbs()

CommonObject::addThumbs ( $file,
$quality = 50 )

Build thumb.

Parameters
string$filePath file in UTF8 to original file to create thumbs from.
int$qualityQuality after compression (0=worst so better compression, 100=best so low or no compression). For thumbs, we force quality to 50 by default.
Returns
void

Definition at line 7068 of file commonobject.class.php.

References dol_osencode(), getDefaultImageSizes(), and vignette().

Referenced by Categorie\add_photo(), and Product\add_photo().

◆ ajaxInputField()

CommonObject::ajaxInputField ( $field)

Return the input html of a field for the user interface (ajax edition of fields).

Inputs are named with the prefix 'ajaxfield_', so they are read back by getFieldValueFromAjaxPost(). By default, it is the input of showInputField(), and the notes use the same editor as the notes of the card. Override in child classes together with getFieldValueFromAjaxPost() when the input of a field is not the default one.

Parameters
string$fieldField name, already checked with isFieldEditableFromUi()
Returns
string Input html

Definition at line 2679 of file commonobject.class.php.

References getDolGlobalString(), getFieldUiValue(), isModEnabled(), and showInputField().

◆ ajaxOutputField()

CommonObject::ajaxOutputField ( $field)

Return the output html of a field for the user interface (ajax edition of fields).

By default, it is the output of showOutputField(). Override in child classes only for fields the card does not show with showOutputField(), so a refreshed value always looks like the displayed one.

Parameters
string$fieldField name, already checked with isFieldReadableFromUi()
Returns
string Output html

Reimplemented in Project.

Definition at line 2660 of file commonobject.class.php.

References getFieldUiValue().

◆ canBeNull()

CommonObject::canBeNull ( $info)
protected

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
Returns
bool true if it can be null

Definition at line 11653 of file commonobject.class.php.

◆ checkActiveProductInLines()

CommonObject::checkActiveProductInLines ( $status = 'onsale')

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

@global object $langs

Parameters
string$statusonsale or onbuy
Returns
bool

Definition at line 13089 of file commonobject.class.php.

References isModEnabled().

Referenced by Commande\valid(), CommandeFournisseur\valid(), Propal\valid(), and SupplierProposal\valid().

◆ clearFieldError()

CommonObject::clearFieldError ( $fieldKey)

clear validation message result for a field

Parameters
string$fieldKeyKey of attribute to clear
Returns
void

Definition at line 9890 of file commonobject.class.php.

◆ clearObjectLinkedCache()

CommonObject::clearObjectLinkedCache ( )

Clear the cache saying that all linked object were already loaded.

So next fetchObjectLinked will reload all links.

Returns
int Return integer <0 if KO, >0 if OK
See also
fetchObjectLinked()

Definition at line 5145 of file commonobject.class.php.

◆ cloneCategories()

CommonObject::cloneCategories ( $fromId,
$toId,
$type = '' )

Copy related categories to another object.

Parameters
int$fromIdId object source
int$toIdId object cible
string$typeType of category ('product', ...)
Returns
int Return integer < 0 if error, > 0 if ok

Reimplemented in User.

Definition at line 12955 of file commonobject.class.php.

Referenced by ActionComm\createFromClone().

◆ commonGenerateDocument()

CommonObject::commonGenerateDocument ( $modelspath,
$modele,
$outputlangs,
$hidedetails,
$hidedesc,
$hideref,
$moreparams = null )
protected

Common function for all objects extending CommonObject for generating documents.

Parameters
string$modelspathRelative folder where generators are placed
string$modeleGenerator to use. Caller must set it to from obj->model_pdf or from GETPOST for example.
Translate$outputlangsOutput 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
Returns
int<-1,1> >0 if OK, <0 if KO
See also
addFileIntoDatabaseIndex()

Definition at line 6702 of file commonobject.class.php.

References $conf, dol_buildpath(), dol_delete_preview(), dol_dir_list(), dol_is_file(), dol_meta_create(), dol_sanitizeFileName(), dol_sanitizePathName(), dol_syslog(), and getDolGlobalString().

Referenced by Adherent\generateDocument(), Asset\generateDocument(), BOM\generateDocument(), Commande\generateDocument(), CommandeFournisseur\generateDocument(), ConferenceOrBooth\generateDocument(), ConferenceOrBoothAttendee\generateDocument(), Contrat\generateDocument(), Delivery\generateDocument(), Entrepot\generateDocument(), Evaluation\generateDocument(), Expedition\generateDocument(), ExpenseReport\generateDocument(), Facture\generateDocument(), FactureFournisseur\generateDocument(), Fichinter\generateDocument(), Inventory\generateDocument(), Job\generateDocument(), KnowledgeRecord\generateDocument(), Mo\generateDocument(), MouvementStock\generateDocument(), MyObject\generateDocument(), PaiementFourn\generateDocument(), Partnership\generateDocument(), Position\generateDocument(), Product\generateDocument(), ProductFournisseurPrice\generateDocument(), Productlot\generateDocument(), Project\generateDocument(), Propal\generateDocument(), Reception\generateDocument(), RecruitmentCandidature\generateDocument(), RecruitmentJobPosition\generateDocument(), RemiseCheque\generateDocument(), Skill\generateDocument(), Skilldet\generateDocument(), SkillRank\generateDocument(), Societe\generateDocument(), StockTransfer\generateDocument(), StockTransferLine\generateDocument(), SupplierProposal\generateDocument(), Target\generateDocument(), Task\generateDocument(), TimeSpent\generateDocument(), User\generateDocument(), UserGroup\generateDocument(), and Workstation\generateDocument().

◆ commonReplaceContact()

static CommonObject::commonReplaceContact ( DoliDB $dbs,
$origin_id,
$dest_id,
array $tables,
$fieldname = 'fk_socpeople',
$ignoreerrors = 0 )
static

Function used to replace a contact id with another one.

This function is meant to be called from replaceContact with the appropriate tables. The column storing the contact id is 'fk_socpeople' on some tables and 'fk_contact' on others, hence the $fieldname parameter.

Parameters
DoliDB$dbsDatabase handler
int$origin_idOld contact id (the contact to delete)
int$dest_idNew contact id (the contact that will receive elements of the other)
string[]$tablesTables that need to be changed
string$fieldnameName of the column storing the contact id ('fk_socpeople' or 'fk_contact')
int<0,1>$ignoreerrors Ignore errors. Return true even if errors.
Returns
bool True if success, False if error

Definition at line 10978 of file commonobject.class.php.

References dol_syslog(), Database\query(), and DoliDB\sanitize().

Referenced by Contact\mergeContactOptionalTables(), ActionComm\replaceContact(), Contact\replaceContact(), and User\replaceContact().

◆ commonReplaceProduct()

static CommonObject::commonReplaceProduct ( DoliDB $dbs,
$origin_id,
$dest_id,
array $tables,
$ignoreerrors = 0 )
static

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$dbsDatabase handler
int$origin_idOld product id (the product to delete)
int$dest_idNew product id (the product that will received element of the other)
string[]$tablesTables 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)
Returns
bool True if success, False if error

Definition at line 10947 of file commonobject.class.php.

References Database\query().

Referenced by BOM\replaceProduct(), Commande\replaceProduct(), CommandeFournisseur\replaceProduct(), Contrat\replaceProduct(), Delivery\replaceProduct(), Expedition\replaceProduct(), Facture\replaceProduct(), FactureFournisseur\replaceProduct(), FactureRec\replaceProduct(), FichinterRec\replaceProduct(), Mo\replaceProduct(), ProductFournisseur\replaceProduct(), Propal\replaceProduct(), Reception\replaceProduct(), SupplierProposal\replaceProduct(), and TimeSpent\replaceProduct().

◆ commonReplaceThirdparty()

static CommonObject::commonReplaceThirdparty ( DoliDB $dbs,
$origin_id,
$dest_id,
array $tables,
$ignoreerrors = 0 )
static

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$dbsDatabase handler
int$origin_idOld thirdparty id (the thirdparty to delete)
int$dest_idNew thirdparty id (the thirdparty that will received element of the other)
string[]$tablesTables 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)
Returns
bool True if success, False if error

Definition at line 10904 of file commonobject.class.php.

References Database\query().

Referenced by ActionComm\replaceThirdparty(), Adherent\replaceThirdparty(), Categorie\replaceThirdparty(), Commande\replaceThirdparty(), CommandeFournisseur\replaceThirdparty(), ConferenceOrBoothAttendee\replaceThirdparty(), Contact\replaceThirdparty(), Contrat\replaceThirdparty(), Delivery\replaceThirdparty(), Don\replaceThirdparty(), Expedition\replaceThirdparty(), Facture\replaceThirdparty(), FactureFournisseur\replaceThirdparty(), FactureFournisseurRec\replaceThirdparty(), FactureRec\replaceThirdparty(), Fichinter\replaceThirdparty(), FichinterRec\replaceThirdparty(), Fournisseur\replaceThirdparty(), LignePrelevement\replaceThirdparty(), Mo\replaceThirdparty(), Partnership\replaceThirdparty(), Product\replaceThirdparty(), ProductFournisseur\replaceThirdparty(), Project\replaceThirdparty(), Propal\replaceThirdparty(), Reception\replaceThirdparty(), Societe\replaceThirdparty(), SupplierProposal\replaceThirdparty(), Ticket\replaceThirdparty(), and User\replaceThirdparty().

◆ copy_linked_contact()

◆ createCommon()

CommonObject::createCommon ( User $user,
$notrigger = 0 )

Create object in the database.

Parameters
User$userUser that creates
int<0,1>$notrigger 0=launch triggers after, 1=disable triggers
Returns
int<-1,max> Return integer <0 if KO, Id of created object if OK

Definition at line 11904 of file commonobject.class.php.

References $conf, $id, dol_hash(), dol_now(), dol_string_nospecial(), dol_syslog(), getDolGlobalString(), and ref.

Referenced by ActionCommReminder\create(), Asset\create(), AssetModel\create(), Availabilities\create(), BOM\create(), BOMLine\create(), BookkeepingTemplate\create(), BookkeepingTemplateLine\create(), Calendar\create(), CompanyPaymentMode\create(), ConferenceOrBoothAttendee\create(), CTicketCategory\create(), DefaultValues\create(), EmailCollector\create(), EmailCollectorAction\create(), EmailCollectorFilter\create(), EmailSenderProfile\create(), Evaluation\create(), EvaluationLine\create(), ExpenseReportIk\create(), ExpenseReportRule\create(), Hook\create(), IntracommReport\create(), Inventory\create(), InventoryLine\create(), Job\create(), KnowledgeRecord\create(), Memo\create(), Mo\create(), MoLine\create(), MyObject\create(), Partnership\create(), PartnershipType\create(), Position\create(), ProductFournisseurPrice\create(), RecruitmentCandidature\create(), RecruitmentJobPosition\create(), Skill\create(), Skilldet\create(), SkillRank\create(), SocieteAccount\create(), StockTransfer\create(), StockTransferLine\create(), Target\create(), TimeSpent\create(), TriggerHistory\create(), UserGroup\create(), Workstation\create(), and AssetDepreciationOptions\updateDeprecationOptions().

◆ defineBuyPrice()

CommonObject::defineBuyPrice ( $unitPrice = 0.0,
$discountPercent = 0.0,
$fk_product = 0,
$qty = 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$unitPriceProduct unit price
float$discountPercentLine discount percent
int$fk_productProduct id
float$qtyLine quantity, to select the matching supplier price quantity range (0 = ignore quantity ranges)
Returns
float|int<-2,-1> Return buy price if OK, integer <0 if KO

Definition at line 11039 of file commonobject.class.php.

References $conf, getDolGlobalInt(), and getDolGlobalString().

Referenced by Contrat\addline(), Propal\createFromClone(), FactureLigne\insert(), OrderLine\insert(), PropaleLigne\insert(), SupplierProposalLine\insert(), ContratLigne\update(), FactureLigne\update(), OrderLine\update(), PropaleLigne\update(), SupplierProposalLine\update(), and Contrat\updateline().

◆ delete_contact()

CommonObject::delete_contact ( $rowid,
$notrigger = 0 )

Delete a link to contact line.

Parameters
int$rowidId of contact link line to delete
int$notriggerDisable all triggers
Returns
int >0 if OK, <0 if KO

Definition at line 1528 of file commonobject.class.php.

References dol_syslog().

◆ delete_linked_contact()

CommonObject::delete_linked_contact ( $source = '',
$code = '' )

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

Parameters
string$source'' or 'internal' or 'external'
string$codeType of contact (code or id)
Returns
int Return integer <0 if KO, 0=Nothing done, >0 if OK

Definition at line 1591 of file commonobject.class.php.

References dol_syslog(), and liste_type_contact().

Referenced by Commande\delete(), Contrat\delete(), Expedition\delete(), ExpenseReport\delete(), Facture\delete(), Fichinter\delete(), Project\delete(), Propal\delete(), and Task\delete().

◆ delete_resource()

CommonObject::delete_resource ( $rowid,
$element = '',
$notrigger = 0 )

Delete a link to resource line.

Parameters
int$rowidId of resource line to delete
string$elementelement name (for trigger) replaced by $this->TRIGGER_PREFIX
int$notriggerDisable all triggers
Returns
int >0 if OK, <0 if KO

Definition at line 6640 of file commonobject.class.php.

References dol_syslog().

◆ deleteAllItemsLinkedByObjectID()

static CommonObject::deleteAllItemsLinkedByObjectID ( $fk_object_where,
$field_where,
$table_element )
static

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

Parameters
int$fk_object_whereid of object we need to remove linked items
string$field_wherename of field of object we need to delete linked items
string$table_elementname of association table
Returns
int Return integer <0 if KO, 0 if nothing done, >0 if OK and something done

Definition at line 5380 of file commonobject.class.php.

◆ deleteByParentField()

CommonObject::deleteByParentField ( $parentId = 0,
$parentField = '',
$filter = '',
$filtermode = "AND" )

Delete all child object from a parent ID.

Parameters
int$parentIdParent Id
string$parentFieldName of Foreign key parent column
string$filterFilter as an Universal Search string. Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a')'
string$filtermodeNo more used
Returns
int Return integer <0 if KO, >0 if OK
Exceptions
Exception

Definition at line 12521 of file commonobject.class.php.

References dol_syslog(), and forgeSQLFromUniversalSearchCriteria().

◆ deleteCommon()

CommonObject::deleteCommon ( User $user,
$notrigger = 0,
$forcechilddeletion = 0 )

Delete object in database.

Parameters
User$userUser that deletes
int<0,1>$notrigger 0=launch triggers after, 1=disable triggers
int<0,1>$forcechilddeletion 0=no, 1=Force deletion of children
Returns
int<-1,1> Return integer <0 if KO, 0=Nothing done because object has child, >0 if OK

Definition at line 12366 of file commonobject.class.php.

References dol_delete_dir_recursive(), dol_include_once(), dol_is_dir(), dol_sanitizeFileName(), dol_syslog(), getMultidirOutput(), and ref.

Referenced by ActionCommReminder\delete(), Asset\delete(), AssetAccountancyCodes\delete(), AssetAccountancyCodesFiscal\delete(), AssetModel\delete(), Availabilities\delete(), BOM\delete(), BOMLine\delete(), BookkeepingTemplateLine\delete(), Calendar\delete(), CashControl\delete(), CompanyPaymentMode\delete(), ConferenceOrBoothAttendee\delete(), CTicketCategory\delete(), DefaultValues\delete(), EmailCollector\delete(), EmailCollectorAction\delete(), EmailCollectorFilter\delete(), EmailSenderProfile\delete(), Evaluation\delete(), EvaluationLine\delete(), ExpenseReportIk\delete(), ExpenseReportRule\delete(), Hook\delete(), IntracommReport\delete(), Inventory\delete(), InventoryLine\delete(), Job\delete(), KnowledgeRecord\delete(), Mo\delete(), MoLine\delete(), MouvementStock\delete(), MyObject\delete(), Partnership\delete(), PartnershipType\delete(), Position\delete(), ProductFournisseurPrice\delete(), RecruitmentCandidature\delete(), RecruitmentJobPosition\delete(), Salary\delete(), Skill\delete(), Skilldet\delete(), SkillRank\delete(), SocieteAccount\delete(), StockTransfer\delete(), StockTransferLine\delete(), Target\delete(), TimeSpent\delete(), TriggerHistory\delete(), UserGroup\delete(), Website\delete(), and Workstation\delete().

◆ deleteEcmFiles()

CommonObject::deleteEcmFiles ( $mode = 0)

Delete related files of object in database.

Parameters
integer$mode0=Use path to find record, 1=Use src_object_xxx fields (Mode 1 is recommended for new objects)
Returns
bool True if OK, False if KO

Definition at line 12989 of file commonobject.class.php.

References $conf, and ref.

Referenced by Commande\delete(), CommandeFournisseur\delete(), Contact\delete(), Contrat\delete(), Don\delete(), Expedition\delete(), ExpenseReport\delete(), Facture\delete(), FactureFournisseur\delete(), Fichinter\delete(), Product\delete(), Propal\delete(), and SupplierProposal\delete().

◆ deleteExtraFields()

◆ deleteLineCommon()

◆ deleteObjectLinked()

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

Delete all links between an object $this.

Parameters
?int$sourceidObject source id
string$sourcetypeObject source type
?int$targetidObject target id
string$targettypeObject target type
int$rowidRow id of line to delete. If defined, other parameters are not used.
?User$f_userUser that create
int<0,1>$notrigger 1=Does not execute triggers, 0= execute triggers
Returns
int >0 if OK, <0 if KO
See also
add_object_linked(), updateObjectLinked(), fetchObjectLinked()

Definition at line 5238 of file commonobject.class.php.

References $id, and dol_syslog().

Referenced by Commande\delete(), CommandeFournisseur\delete(), Contact\delete(), Contrat\delete(), Delivery\delete(), Expedition\delete(), ExpenseReport\delete(), Facture\delete(), FactureFournisseur\delete(), FactureFournisseurRec\delete(), FactureRec\delete(), Fichinter\delete(), Propal\delete(), SupplierInvoiceLine\delete(), SupplierProposal\delete(), and Asset\reopen().

◆ delThumbs()

CommonObject::delThumbs ( $file)

Delete thumbs.

Parameters
string$filePath file in UTF8 to original file to delete thumbs.
Returns
void

Definition at line 7099 of file commonobject.class.php.

References dol_delete_file(), and getImageFileNameForSize().

◆ deprecatedProperties()

CommonObject::deprecatedProperties ( )
protected

Provide list of deprecated properties and replacements.

Returns
array<string,string>

Reimplemented in Societe.

Definition at line 974 of file commonobject.class.php.

Referenced by setFieldValue().

◆ emtpyObjectVars()

CommonObject::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.

Returns
void

Definition at line 11837 of file commonobject.class.php.

◆ errorsToString()

◆ fetch_barcode()

CommonObject::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.

Returns
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()

Definition at line 2106 of file commonobject.class.php.

References fetchBarCode().

◆ fetch_contact()

CommonObject::fetch_contact ( $contactid = null)

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

Parameters
?int$contactidId du contact. Use this->contact_id if empty.
Returns
int<-1,1> Return integer <0 if KO, >0 if OK

Definition at line 2002 of file commonobject.class.php.

◆ fetch_optionals()

CommonObject::fetch_optionals ( $rowid = null,
$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.

Parameters
int$rowidId of line. Use the id of object if not defined. Deprecated. Function must be called without parameters.
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.
Returns
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
See also
fetchValuesForExtraLanguages()

We are in a situation where the current object has no values in its extra fields. We want to initialize all the values to null so that the array_option is accessible in other contexts (especially in document generation).

Definition at line 7355 of file commonobject.class.php.

References $conf, $id, dol_clone(), dol_eval(), dol_syslog(), and dolDecrypt().

Referenced by ActionComm\createFromClone(), Facture\createFromCurrent(), Account\fetch(), ActionComm\fetch(), Adherent\fetch(), AdherentType\fetch(), Categorie\fetch(), Commande\fetch(), CommandeFournisseur\fetch(), CommandeFournisseurLigne\fetch(), Contact\fetch(), Contrat\fetch(), ContratLigne\fetch(), Delivery\fetch(), Dolresource\fetch(), Don\fetch(), EcmDirectory\fetch(), EcmFiles\fetch(), Entrepot\fetch(), Expedition\fetch(), Facture\fetch(), FactureFournisseur\fetch(), FactureFournisseurRec\fetch(), FactureLigne\fetch(), FactureRec\fetch(), Fichinter\fetch(), FichinterLigne\fetch(), Holiday\fetch(), Link\fetch(), MouvementStock\fetch(), OrderLine\fetch(), Paiement\fetch(), Partnership\fetch(), PaymentVarious\fetch(), Product\fetch(), ProductAttribute\fetch(), ProductAttributeValue\fetch(), Productlot\fetch(), ProductStockEntrepot\fetch(), Project\fetch(), Propal\fetch(), PropaleLigne\fetch(), Reception\fetch(), ReceptionLineBatch\fetch(), Salary\fetch(), Societe\fetch(), SupplierInvoiceLine\fetch(), SupplierProposal\fetch(), Task\fetch(), Ticket\fetch(), and User\fetch().

◆ fetch_origin()

CommonObject::fetch_origin ( )

Read linked origin object.

Set ->origin_object

Returns
void

Definition at line 2294 of file commonobject.class.php.

Referenced by Expedition\delete(), Expedition\generateDocument(), Reception\generateDocument(), Reception\getStatusDispatch(), and Reception\setDraft().

◆ fetch_product()

CommonObject::fetch_product ( )

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

Returns
int<-1,1> Return integer <0 if KO, >=0 if OK
See also
fetch_product()

Definition at line 2218 of file commonobject.class.php.

Referenced by Productlot\checkSellOrEatByMandatory(), BOM\validate(), and Mo\validate().

◆ fetch_project()

CommonObject::fetch_project ( )

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

Returns
int<-1,1> Return integer <0 if KO, >=0 if OK
Deprecated
See also
fetchProject()

Definition at line 2192 of file commonobject.class.php.

References fetchProject().

◆ fetch_projet()

CommonObject::fetch_projet ( )

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

Returns
int Return integer <0 if KO, >=0 if OK
Deprecated
See also
fetchProject()

Reimplemented in ConferenceOrBoothAttendee.

Definition at line 2206 of file commonobject.class.php.

References fetchProject().

◆ fetch_thirdparty()

◆ fetch_user()

CommonObject::fetch_user ( $userid)

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

Parameters
int$useridId du contact
Returns
int<-1,1> Return integer <0 if KO, >0 if OK

Definition at line 2278 of file commonobject.class.php.

References user.

◆ fetchBarCode()

CommonObject::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.

Returns
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)

Definition at line 2119 of file commonobject.class.php.

References dol_syslog(), and getDolGlobalString().

Referenced by fetch_barcode().

◆ fetchComments()

CommonObject::fetchComments ( )

Load comments linked with current task.

Returns
int<0,max>|-1 Returns the number of comments if OK, -1 if error

Definition at line 12802 of file commonobject.class.php.

◆ fetchCommon()

CommonObject::fetchCommon ( $id,
$ref = null,
$morewhere = '',
$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$idId object
?string$refRef
string$morewhereMore SQL filters (' AND ...')
int<0,1>$noextrafields 0=Default to load extrafields, 1=No extrafields
Returns
int<-4,1> Return integer <0 if KO, 0 if not found, >0 if OK

Definition at line 12112 of file commonobject.class.php.

References $id.

Referenced by ActionCommReminder\fetch(), Asset\fetch(), AssetAccountancyCodes\fetch(), AssetAccountancyCodesFiscal\fetch(), AssetModel\fetch(), Availabilities\fetch(), BOM\fetch(), BOMLine\fetch(), BookkeepingTemplate\fetch(), BookkeepingTemplateLine\fetch(), Calendar\fetch(), CashControl\fetch(), CEmailTemplate\fetch(), CompanyPaymentMode\fetch(), ConferenceOrBoothAttendee\fetch(), CTicketCategory\fetch(), DefaultValues\fetch(), EmailCollector\fetch(), EmailCollectorAction\fetch(), EmailCollectorFilter\fetch(), EmailSenderProfile\fetch(), Evaluation\fetch(), EvaluationLine\fetch(), ExpenseReportIk\fetch(), ExpenseReportRule\fetch(), Hook\fetch(), IntracommReport\fetch(), Inventory\fetch(), InventoryLine\fetch(), Job\fetch(), KnowledgeRecord\fetch(), Memo\fetch(), Mo\fetch(), MoLine\fetch(), MyObject\fetch(), PartnershipType\fetch(), Position\fetch(), ProductFournisseurPrice\fetch(), RecruitmentCandidature\fetch(), RecruitmentJobPosition\fetch(), Skill\fetch(), Skilldet\fetch(), SkillRank\fetch(), SocieteAccount\fetch(), StockTransfer\fetch(), StockTransferLine\fetch(), Target\fetch(), TimeSpent\fetch(), TriggerHistory\fetch(), UserGroup\fetch(), Workstation\fetch(), AssetDepreciationOptions\fetchDeprecationOptions(), and setValueFrom().

◆ fetchLinesCommon()

CommonObject::fetchLinesCommon ( $morewhere = '',
$noextrafields = 0 )

Load object in memory from the database.

Parameters
string$morewhereMore 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
Returns
int<-1,1> Return integer <0 if KO, 0 if not found, >0 if OK

Definition at line 12176 of file commonobject.class.php.

Referenced by Availabilities\fetchLines(), BOM\fetchLines(), Calendar\fetchLines(), ConferenceOrBoothAttendee\fetchLines(), CTicketCategory\fetchLines(), Evaluation\fetchLines(), Job\fetchLines(), KnowledgeRecord\fetchLines(), Memo\fetchLines(), Mo\fetchLines(), MyObject\fetchLines(), Partnership\fetchLines(), Position\fetchLines(), RecruitmentCandidature\fetchLines(), RecruitmentJobPosition\fetchLines(), Skilldet\fetchLines(), SkillRank\fetchLines(), StockTransfer\fetchLines(), StockTransferLine\fetchLines(), Target\fetchLines(), TriggerHistory\fetchLines(), and Workstation\fetchLines().

◆ fetchNoCompute()

CommonObject::fetchNoCompute ( $id)

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

Parameters
int$idID of object
Returns
int<-1,1> >0 if OK, 0 if not found, <0 if KO

Definition at line 7331 of file commonobject.class.php.

References $conf, and $id.

◆ fetchObjectFrom()

CommonObject::fetchObjectFrom ( $table,
$field,
$key,
$element = null )

Load object from specific field.

Parameters
string$tableTable element or element line
string$fieldField selected
string$keyImport key
string$elementElement name
Returns
int<-1,1>|false Return -1 or false if KO, >0 if OK

Definition at line 2326 of file commonobject.class.php.

References $conf, and dol_syslog().

◆ fetchObjectLinked()

CommonObject::fetchObjectLinked ( $sourceid = null,
$sourcetype = '',
$targetid = null,
$targettype = '',
$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$sourceidObject source id (if not defined, $this->id)
string$sourcetypeObject source type (if not defined, $this->element)
?int$targetidObject target id (if not defined, $this->id)
string$targettypeObject target type (if not defined, $this->element)
string$clause'OR' or 'AND' clause used when both source id and target id are provided
int<0,1>$alsosametype 0=Return only links to object that differs from source type. 1=Include also link to objects of same type.
string$orderbySQL 'ORDER BY' clause
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.
Returns
int<-1,1> Return integer <0 if KO, >0 if OK
See also
add_object_linked(), updateObjectLinked(), deleteObjectLinked()

Definition at line 4973 of file commonobject.class.php.

References $id, $module, $object, dol_include_once(), dol_syslog(), getElementProperties(), and isModEnabled().

Referenced by Facture\createFromCurrent(), CommandeFournisseur\delete(), Expedition\delete(), Delivery\getRemainingDelivered(), and Propal\InvoiceArrayList().

◆ fetchOneLike()

CommonObject::fetchOneLike ( $ref)

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

Parameters
string$refWildcard
Returns
int<-1,1> >1 = OK, 0 = Not found or table_ref_field not defined, <0 = KO

Definition at line 2069 of file commonobject.class.php.

References dol_syslog().

◆ fetchProject()

CommonObject::fetchProject ( )

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

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

Definition at line 2163 of file commonobject.class.php.

Referenced by fetch_project(), fetch_projet(), Commande\getTooltipContentArray(), Contrat\getTooltipContentArray(), Facture\getTooltipContentArray(), and Propal\getTooltipContentArray().

◆ fetchValuesForExtraLanguages()

CommonObject::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.

Returns
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
See also
fetch_optionnals()

Definition at line 7179 of file commonobject.class.php.

Referenced by WebPortalMember\getBannerAddressForWebPortal().

◆ fetchWarehouse()

CommonObject::fetchWarehouse ( $force_warehouse_id = 0)

Load the warehouse of object, from id $this->warehouse_id or $this->fk_warehouse, into this->warehouse.

Parameters
int<0,1>$force_warehouse_id Force warehouse id
Returns
int<-1,1> Return integer <0 if KO, >0 if OK

Definition at line 2242 of file commonobject.class.php.

Referenced by User\fetch().

◆ formAddObjectLine()

CommonObject::formAddObjectLine ( $dateSelector,
$seller,
$buyer,
$defaulttpldir = '/core/tpl' )

Show add free and predefined products/services form.

Parameters
int$dateSelector1=Show also date range input fields
Societe$sellerObject thirdparty who sell
?Societe$buyerObject thirdparty who buy
string$defaulttpldirDirectory where to find the template
Returns
void

Reimplemented in ProductAttribute.

Definition at line 5929 of file commonobject.class.php.

References $conf, $module, $object, and dol_buildpath().

◆ getAllItemsLinkedByObjectID()

static CommonObject::getAllItemsLinkedByObjectID ( $fk_object_where,
$field_select,
$field_where,
$table_element )
static

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

Parameters
int$fk_object_whereid of object we need to get linked items
string$field_selectname of field we need to get a list
string$field_wherename of field of object we need to get linked items
string$table_elementname of association table
Returns
string[]|int Array of record, -1 if empty

Definition at line 5319 of file commonobject.class.php.

References dol_syslog().

◆ getCanvas()

CommonObject::getCanvas ( $id = 0,
$ref = '' )

Load type of canvas of an object if it exists.

Parameters
int$idRecord id
string$refRecord ref
Returns
int Return integer <0 if KO, 0 if nothing done, >0 if OK

Definition at line 5557 of file commonobject.class.php.

References $id, and getDolGlobalString().

◆ getCategoriesCommon()

CommonObject::getCategoriesCommon ( $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_categCategory type ('customer', 'supplier', 'website_page', ...)
Returns
int[]|int Array of category IDs or < 0 if KO

Definition at line 12857 of file commonobject.class.php.

References $c.

◆ getChildrenOfLine()

CommonObject::getChildrenOfLine ( $id,
$includealltree = 0 )

Get children of line.

Parameters
int$idId of parent line
int<0,1001>$includealltree 0 = 1st level child, 1 = All level child, 2-1001: internal use
Returns
int[] Array with list of children lines id

Definition at line 3984 of file commonobject.class.php.

References dol_syslog(), and getChildrenOfLine().

Referenced by getChildrenOfLine(), and line_order().

◆ getCountOfItemsLinkedByObjectID()

static CommonObject::getCountOfItemsLinkedByObjectID ( $fk_object_where,
$field_where,
$table_element )
static

Count items linked to an object id in association table.

Parameters
int$fk_object_whereid of object we need to get linked items
string$field_wherename of field of object we need to get linked items
string$table_elementname of association table
Returns
int<-1,max> Array of records, -1 if empty argument

Definition at line 5351 of file commonobject.class.php.

◆ getDataToShowPhoto()

CommonObject::getDataToShowPhoto ( $modulepart,
$imagesize )

Function used to get the logos or photos of an object.

Parameters
string$modulepartModule part
string$imagesizeImage size ('', 'mini' or 'small')
Returns
array{dir:string,file:string,originalfile:string,altfile:string,email:string,capture:string} Array of data to show photo

Definition at line 11224 of file commonobject.class.php.

◆ getDefaultCreateValueFor()

CommonObject::getDefaultCreateValueFor ( $fieldname,
$alternatevalue = null,
$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$fieldnameName of field
string$alternatevalueAlternate value to use
string$typeType of data
Returns
string|string[] Default value (can be an array if the GETPOST return an array)

Definition at line 7125 of file commonobject.class.php.

References dol_syslog(), getDolGlobalString(), GETPOST(), and GETPOSTISSET().

◆ getElementType()

CommonObject::getElementType ( )

Return an element type string formatted like element_element target_type and source_type.

Returns
string

Definition at line 4941 of file commonobject.class.php.

◆ getExtraField()

CommonObject::getExtraField ( $key)

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

Parameters
string$keyName of the extrafield
Returns
mixed|null

Definition at line 8362 of file commonobject.class.php.

◆ getFieldError()

CommonObject::getFieldError ( $fieldKey)

get field error message

Parameters
string$fieldKeyKey of attribute
Returns
string Error message of validation ('' if no error)

Definition at line 9919 of file commonobject.class.php.

Referenced by updateFieldFromUi().

◆ getFieldList()

◆ getFieldPropertyName()

CommonObject::getFieldPropertyName ( $field)
protected

Return the name of the property of the object holding the value of a field of $fields.

Some classes keep a field in a property with another name than the field (ex: the field fk_opp_status of a project is in the property opp_status). Override in child classes for their own fields, and return the result of the parent for the others.

Parameters
string$fieldField name
Returns
string Property name

Reimplemented in Project.

Definition at line 2522 of file commonobject.class.php.

Referenced by getFieldUiValue(), setFieldValue(), and updateFieldFromUi().

◆ getFieldUiValue()

CommonObject::getFieldUiValue ( $field)

Return the value of a field of $fields, read in the property holding it (see getFieldPropertyName()).

Use it instead of $object->$field when the field name comes from $fields (generic tools of the user interface...).

Parameters
string$fieldField name
Returns
mixed Value, null if the object has no property for this field

Definition at line 2534 of file commonobject.class.php.

References getFieldPropertyName().

Referenced by ajaxInputField(), ajaxOutputField(), persistFieldValue(), and updateFieldFromUi().

◆ getFieldValueFromAjaxPost()

CommonObject::getFieldValueFromAjaxPost ( $field)

Return the value of a field posted by the user interface (ajax edition of fields).

Inputs are named with the prefix 'ajaxfield_' followed by the field name, like the names generated by showInputField() with this key prefix (ex: ajaxfield_note_public, or ajaxfield_date_livraisonday... for a date). Override in child classes when the input of a field is not the default one (several inputs, other names...) or to check the range of a value.

Parameters
string$fieldField name, already checked with isFieldEditableFromUi()
Returns
mixed Value to save, null if the input is not posted (a missing input must never empty a field) or if the type of field is not supported

Reimplemented in EvaluationLine.

Definition at line 2625 of file commonobject.class.php.

References dol_html_entity_decode(), GETPOST(), GETPOSTDATE(), GETPOSTINT(), and GETPOSTISSET().

◆ getFormatedCustomerRef()

CommonObject::getFormatedCustomerRef ( $objref)

Return customer ref for screen output.

Parameters
string$objrefCustomer ref
Returns
string Customer ref formatted

Definition at line 1165 of file commonobject.class.php.

◆ getFormatedSupplierRef()

CommonObject::getFormatedSupplierRef ( $objref)

Return supplier ref for screen output.

Parameters
string$objrefSupplier ref
Returns
string Supplier ref formatted

Definition at line 1184 of file commonobject.class.php.

◆ getFullAddress()

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

Return full address of contact.

Parameters
int<0,1>$withcountry 1=Add country into address string
string$sepSeparator to use to build string
int<0,1>$withregion 1=Add region into address string
string$extralangcodeUser extralanguages as value
Returns
string Full address string

Definition at line 1206 of file commonobject.class.php.

References dol_format_address(), getCountry(), and getState().

Referenced by Account\getBannerAddress(), and WebPortalMember\getBannerAddressForWebPortal().

◆ getIdContact()

CommonObject::getIdContact ( $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'
string$code'BILLING', 'SHIPPING', 'SALESREPFOLL', ...
int$statuslimited to a certain status
Returns
int[]|null List of id for such contacts, or null if error

Definition at line 1936 of file commonobject.class.php.

References dol_syslog(), and getDolGlobalInt().

Referenced by Contrat\getIdBillingContact(), Facture\getIdBillingContact(), Contrat\getIdServiceContact(), and Facture\getIdShippingContact().

◆ getIdOfLine()

CommonObject::getIdOfLine ( $rang)

Get rowid of the line relative to its position.

Parameters
int$rangRang value
Returns
int Rowid of the line

Definition at line 4212 of file commonobject.class.php.

◆ getJSListDependancies()

CommonObject::getJSListDependancies ( $type = '_extra')
Parameters
string$typeType for prefix
Returns
string JavaScript code to manage dependency

Definition at line 10505 of file commonobject.class.php.

◆ getLastMainDocLink()

CommonObject::getLastMainDocLink ( $modulepart,
$initsharekey = 0,
$relativelink = 0 )

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

Parameters
string$modulepartModule related to document
int$initsharekeyInit the share key if it was not yet defined
int$relativelink0=Return full external link, 1=Return link relative to root of file
Returns
string|-1 Returns the link, or an empty string if no link was found, or -1 if error.

Definition at line 1236 of file commonobject.class.php.

References $dolibarr_main_url_root, and getRandomPassword().

◆ getLinkedBuyPriceDocuments()

CommonObject::getLinkedBuyPriceDocuments ( $user,
$lineid,
$oldbuyprice = null )

Return the linked proposals, orders and invoices having, for the product of a line of this object, a cost price different from the one saved on the line (for a purchase order, the average net unit price of the product on the ordered purchase orders linked to the same documents, weighted by the quantities).

Nothing is returned if the option MARGIN_CAN_UPDATE_BUYINGPRICE_ON_LINKED_DOCUMENTS is off, if the user can not change cost prices, and documents that the user can not edit or access (rights, restriction on thirdparties) are ignored.

Parameters
User$userUser making change
int$lineidId of the line of this object
float | null$oldbuypriceIf set, nothing is returned when the cost price saved on the line is still this one
Returns
array<string,array{refs:string[],lineids:int[],buyprice:float}> Documents by element ('propal', 'commande', 'facture')

Definition at line 11110 of file commonobject.class.php.

References $id, getDolGlobalString(), getEntity(), price2num(), and restrictedArea().

◆ getListContactId()

CommonObject::getListContactId ( $source = 'external')

Return list of id of contacts of object.

Parameters
string$sourceSource of contact: external (llx_socpeople) or internal (llx_user) or thirdparty (llx_societe)
Returns
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)

Reimplemented in Task.

Definition at line 3112 of file commonobject.class.php.

References liste_contact().

◆ getNbComments()

CommonObject::getNbComments ( )

Return nb comments already posted.

Returns
int

Definition at line 12822 of file commonobject.class.php.

◆ getObjectLineHtml()

CommonObject::getObjectLineHtml ( $lineid,
$action = '' )

Return the HTML of a line as printed in the card by printObjectLines(), hooks printObjectLine and printObjectSubLine included.

Used to reload a line with ajax. The line is always in view mode. The lines must be loaded into $this->lines (for example with getLinesArray()). Note: the caller must init the hook contexts of the page that printed the lines (ex: propalcard), so modules hooking them render the line as in this page. The global variables of the caller used for the rendering ($object, $form, ...) are restored at the end.

Parameters
int$lineidId of the line
string$actionAction code
Returns
string HTML of the line (

), empty string if line not found (error in $this->error)

Definition at line 6155 of file commonobject.class.php.

References $context, and $object.

◆ getObjectLinesDisplayContext()

CommonObject::getObjectLinesDisplayContext ( )

Return the display context of the lines, as defined by the card of the object before printObjectLines() and formAddObjectLine().

Override it in child classes when the card uses other values.

Returns
array{seller:Societe,buyer:?Societe,dateSelector:int,forceall:int,senderissupplier:int,inputalsopricewithtax:int} Seller and buyer third parties, $dateSelector, and values of the global variables used by the line templates (objectline_xxx.tpl.php)

Reimplemented in Commande, CommandeFournisseur, Facture, FactureFournisseur, Propal, and SupplierProposal.

Definition at line 6110 of file commonobject.class.php.

References $mysoc.

◆ getRangOfLine()

CommonObject::getRangOfLine ( $rowid)

Get position of line (rang)

Parameters
int$rowidId of line
Returns
int Value of rang in table of lines

Definition at line 4186 of file commonobject.class.php.

References dol_syslog().

Referenced by line_down(), line_max(), and line_up().

◆ getRights()

CommonObject::getRights ( )

Returns the rights used for this class.

Returns
null|int|stdClass Object of permission for the module
Deprecated
Use instead hasUserPermission()

Definition at line 10582 of file commonobject.class.php.

◆ getRightsForUser()

CommonObject::getRightsForUser ( User $user)

Returns the rights used for this class for a specific user.

This is called by getRights() and hasUserPermission()

Parameters
User$userUser to check rights
Returns
null|int|stdClass Object of permission for the module

Definition at line 10595 of file commonobject.class.php.

References $module.

◆ getSpecialCode()

CommonObject::getSpecialCode ( $lineid)

Get special code of a line.

Parameters
int$lineidId of line
Returns
int Special code

Definition at line 5601 of file commonobject.class.php.

◆ getTooltipContent()

CommonObject::getTooltipContent ( $params)

getTooltipContent

Parameters
array<string,mixed>$params params
Since
v18
Returns
string

Definition at line 1071 of file commonobject.class.php.

References dol_eval(), getDolGlobalInt(), and getTooltipContentArray().

Referenced by CommandeFournisseur\getNomUrl(), FactureFournisseur\getNomUrl(), Paiement\getNomUrl(), PaiementFourn\getNomUrl(), Reception\getNomUrl(), and SupplierProposal\getNomUrl().

◆ getTooltipContentArray()

CommonObject::getTooltipContentArray ( $params)

◆ getTotalDiscount()

CommonObject::getTotalDiscount ( )

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

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

Definition at line 5752 of file commonobject.class.php.

References dol_syslog(), and price2num().

◆ getTotalWeightVolume()

CommonObject::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.

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

Definition at line 5794 of file commonobject.class.php.

◆ getValueFrom()

CommonObject::getValueFrom ( $table,
$id,
$field )

Getter generic.

Load value from a specific field

Parameters
string$tableTable of element or element line
int$idElement id
string$fieldField selected
Returns
int<-1,1> Return integer <0 if KO, >0 if OK

Definition at line 2368 of file commonobject.class.php.

References dol_syslog().

◆ hasProductsOrServices()

CommonObject::hasProductsOrServices ( $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
Returns
int Return integer <0 if KO, 0 if no predefined products, nb of lines with predefined products if found

Definition at line 5718 of file commonobject.class.php.

References dol_syslog().

◆ hasUserPermission()

CommonObject::hasUserPermission ( User $user,
$mode = 'write' )

Check if user has a permission on this type of object.

Generic check based on getRightsForUser(), accepting core ("lire", "creer", "supprimer") and ModuleBuilder ("read", "write", "delete") names. Child classes using other permissions must override it.

Parameters
User$userUser to check rights
string$modePermission to check: 'read', 'write' or 'delete'
Returns
bool True if user has the permission, false otherwise

Reimplemented in CommandeFournisseur, EvaluationLine, FactureFournisseur, FactureFournisseurRec, FactureRec, Product, and Project.

Definition at line 10623 of file commonobject.class.php.

◆ hasUserPermissionOnField()

CommonObject::hasUserPermissionOnField ( User $user,
$field,
$mode = 'write' )

Check if user has a permission on a field of this object.

Generic check based on hasUserPermission(). Child classes needing per field rules must override it.

Parameters
User$userUser to check rights
string$fieldField name to check
string$modePermission to check: 'read', 'write' or 'delete'
Returns
bool True if user has the permission on this field, false otherwise

Definition at line 10671 of file commonobject.class.php.

◆ hasUserWritePermissionOnField()

CommonObject::hasUserWritePermissionOnField ( User $user,
$field )

Check if user has write permission on a field of this object.

Parameters
User$userUser to check rights
string$fieldField name to check
Returns
bool True if current user have right to write for this field, false otherwise
Deprecated
Use instead hasUserPermissionOnField($user, $field, 'write')

Definition at line 10656 of file commonobject.class.php.

◆ indexFile()

CommonObject::indexFile ( $destfull,
$update_main_doc_field )

Index a file into the ECM database.

Parameters
string$destfullFull path of file to index
int$update_main_doc_fieldUpdate 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'].
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 6943 of file commonobject.class.php.

References $conf, $id, dol_osencode(), getDolGlobalInt(), and getRandomPassword().

Referenced by Salary\generateDocument().

◆ initAsSpecimenCommon()

◆ initObjectLinesDisplay()

CommonObject::initObjectLinesDisplay ( )

Init the display of the lines: set the global variables used by the line templates (objectline_xxx.tpl.php) from getObjectLinesDisplayContext() To call in the card before printObjectLines() and formAddObjectLine().

Returns
array{seller:Societe,buyer:?Societe,dateSelector:int,forceall:int,senderissupplier:int,inputalsopricewithtax:int} Display context, see getObjectLinesDisplayContext()

Definition at line 6130 of file commonobject.class.php.

References $context.

◆ insertExtraFields()

CommonObject::insertExtraFields ( $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$triggerIf 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.
User$userusedObject user
Returns
int<-1,1> -1=error, O=did nothing, 1=OK
See also
insertExtraLanguages(), updateExtraField(), deleteExtraField(), setValueFrom()
Parameters
string$key
Returns
string

Definition at line 7523 of file commonobject.class.php.

References $id, $object, dol_eval(), dol_hash(), dol_include_once(), dol_syslog(), dolEncrypt(), getDolGlobalString(), ExtraFields\isEmptyValue(), and price2num().

Referenced by Account\create(), ActionComm\create(), Categorie\create(), Commande\create(), CommandeFournisseur\create(), Dolresource\create(), Don\create(), Entrepot\create(), Expedition\create(), ExpenseReport\create(), Facture\create(), FactureFournisseur\create(), FactureFournisseurRec\create(), FactureRec\create(), Fichinter\create(), Holiday\create(), Link\create(), PaymentVarious\create(), ProductAttribute\create(), ProductAttributeValue\create(), Productlot\create(), Project\create(), Propal\create(), Reception\create(), ReceptionLineBatch\create(), Salary\create(), SupplierProposal\create(), Task\create(), Ticket\create(), CommandeFournisseurLigne\insert(), ContratLigne\insert(), ExpeditionLigne\insert(), FactureLigne\insert(), FichinterLigne\insert(), OrderLine\insert(), PropaleLigne\insert(), ReceptionLineBatch\insert(), SupplierInvoiceLine\insert(), SupplierProposalLine\insert(), Account\update(), ActionComm\update(), Adherent\update(), AdherentType\update(), Categorie\update(), Commande\update(), CommandeFournisseur\update(), CommandeFournisseurLigne\update(), Contact\update(), Contrat\update(), ContratLigne\update(), Dolresource\update(), Don\update(), EcmFiles\update(), Entrepot\update(), Expedition\update(), ExpeditionLigne\update(), ExpenseReport\update(), Facture\update(), FactureFournisseur\update(), FactureFournisseurLigneRec\update(), FactureFournisseurRec\update(), FactureLigne\update(), FactureLigneRec\update(), FactureRec\update(), Fichinter\update(), FichinterLigne\update(), Holiday\update(), Link\update(), OrderLine\update(), PaymentVarious\update(), Product\update(), ProductAttribute\update(), ProductAttributeValue\update(), Productlot\update(), Project\update(), Propal\update(), PropaleLigne\update(), ReceptionLineBatch\update(), Salary\update(), Societe\update(), SupplierInvoiceLine\update(), SupplierProposal\update(), SupplierProposalLine\update(), Task\update(), and User\update().

◆ insertExtraLanguages()

CommonObject::insertExtraLanguages ( $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$triggerIf defined, call also the trigger (for example COMPANY_MODIFY)
User$userusedObject user
Returns
int<-1,1> -1=error, O=did nothing, 1=OK
See also
insertExtraFields(), updateExtraField(), setValueFrom()

Definition at line 7915 of file commonobject.class.php.

References dol_syslog(), getDolGlobalString(), and price2num().

Referenced by Societe\update().

◆ isArray()

CommonObject::isArray ( $info)
protected

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
Returns
bool true if array

Definition at line 11547 of file commonobject.class.php.

◆ isDate()

CommonObject::isDate ( $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
Returns
bool true if date

Definition at line 11565 of file commonobject.class.php.

◆ isDuration()

CommonObject::isDuration ( $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
Returns
bool true if field of type duration

Definition at line 11579 of file commonobject.class.php.

◆ isExistingObject()

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

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.

Parameters
string$elementString of element ('product', 'facture', ...)
int$idId of object
string$refRef of object to check
string$ref_extRef ext of object to check
Returns
int Return integer <0 if KO, 0 if OK but not found, >0 if OK and exists

Definition at line 1000 of file commonobject.class.php.

References $conf, and dol_syslog().

Referenced by CEmailTemplate\create(), Commande\create(), Fichinter\create(), Propal\create(), SupplierProposal\create(), FactureLigne\insert(), and SupplierInvoiceLine\insert().

◆ isFieldBlockedByObjectState()

CommonObject::isFieldBlockedByObjectState ( $field)
protected

Check if the field is blocked by the current object state.

For objects having a draft status (class constant STATUS_DRAFT), fields are locked when the object is not in draft, unless "alwayseditable" is set. Objects without STATUS_DRAFT (ex: Product, Societe) have no status meaning "draft", so their fields are never blocked by state here. Override in child classes for specific rules.

Note: This method is kept generic for CommonObject compatibility. Both status and statut are checked because child classes may use either.

Parameters
string$fieldField name to check
Returns
bool True if the field is blocked by object state, false otherwise

Reimplemented in EvaluationLine.

Definition at line 10876 of file commonobject.class.php.

References status.

◆ isFieldDefined()

CommonObject::isFieldDefined ( $field)
protected

Check if the field is defined in the object's field metadata.

Parameters
string$fieldField name to check
Returns
bool True if the field exists in the object definition, false otherwise

Definition at line 10808 of file commonobject.class.php.

Referenced by setFieldValue().

◆ isFieldDisabled()

CommonObject::isFieldDisabled ( $field)
protected

Check if the field is explicitly marked as disabled.

Parameters
string$fieldField name to check
Returns
bool True if the field is disabled, false otherwise

Definition at line 10821 of file commonobject.class.php.

◆ isFieldEditableFromUi()

CommonObject::isFieldEditableFromUi ( User $user,
$field )

Check whether a field can be edited from the user interface with generic tools (ajax edition of cards...), where the user chooses the field to modify.

isFieldEditAllowed() is a generic rule for PHP code and allows any field not marked as "noteditable", including computed or technical fields (ref, status, totals...). Exposing it to the user interface would let a user change them, so the user interface requires an explicit opt-in on each field with the "uieditable" attribute, in addition to all rules of isFieldEditAllowed(). The private note is always hidden to external users, so it is never editable by them.

Parameters
User$userUser to check rights
string$fieldField name to check
Returns
bool True if the field can be edited from the user interface, false otherwise

Definition at line 10749 of file commonobject.class.php.

Referenced by updateFieldFromUi().

◆ isFieldEditAllowed()

CommonObject::isFieldEditAllowed ( User $user,
$field,
$byPassUserPermission = false )

Check whether a given field is allowed to be edited on the current object.

This method combines:

  • user rights check
  • field configuration constraints
  • object state constraints (status/statut) Note: This method is defined in CommonObject, so it must remain generic. Some child classes use status, others use statut, hence both are checked.
Parameters
User$userUser to check rights
string$fieldField name to check
bool$byPassUserPermissionset to true to skip user permission check and force value. Only user rights are skipped, field and object state checks still apply. When passing true, label it at call site with an inline block comment holding the parameter name (see CommonObjectTest).
Returns
bool True if the field is editable, false otherwise

Definition at line 10697 of file commonobject.class.php.

Referenced by setFieldValue().

◆ isFieldEnabled()

CommonObject::isFieldEnabled ( $field)
protected

Check if the field is enabled.

A field is considered enabled by default if the "enabled" flag is not set.

Parameters
string$fieldField name to check
Returns
bool True if the field is enabled, false otherwise

Definition at line 10846 of file commonobject.class.php.

References dol_eval().

◆ isFieldMarkedNotEditable()

CommonObject::isFieldMarkedNotEditable ( $field)
protected

Check if the field is explicitly marked as not editable.

Parameters
string$fieldField name to check
Returns
bool True if the field is not editable, false otherwise

Definition at line 10857 of file commonobject.class.php.

◆ isFieldReadableFromUi()

CommonObject::isFieldReadableFromUi ( User $user,
$field )

Check whether the value of a field can be read from the user interface with generic tools (ajax refresh of the values displayed on a card...), by a user allowed to read the object.

The field must be enabled and visible on the card (visible 1, 3, 4 or 5, or an expression giving one of these values), or editable from the user interface (fields like notes are hidden from generic forms but shown by their own block of the card). Password fields are never readable, and the private note is always hidden to external users.

Parameters
User$userUser to check rights
string$fieldField name to check
Returns
bool True if the value of the field can be read from the user interface, false otherwise

Definition at line 10775 of file commonobject.class.php.

References dol_eval().

◆ isFieldValidationRequired()

CommonObject::isFieldValidationRequired ( $field)
protected

Check if the field requires validation.

Parameters
string$fieldField name to check
Returns
bool True if validation is required, false otherwise

Definition at line 10832 of file commonobject.class.php.

Referenced by setFieldValue().

◆ isFloat()

CommonObject::isFloat ( $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
Returns
bool true if float

Definition at line 11617 of file commonobject.class.php.

◆ isForcedToNullIfZero()

CommonObject::isForcedToNullIfZero ( $info)
protected

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
Returns
bool true if forced to null

Definition at line 11671 of file commonobject.class.php.

◆ isIndex()

CommonObject::isIndex ( $info)
protected

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
Returns
bool

Definition at line 11689 of file commonobject.class.php.

◆ isInt()

CommonObject::isInt ( $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
Returns
bool true if integer

Definition at line 11598 of file commonobject.class.php.

◆ isLineOfObject()

CommonObject::isLineOfObject ( $lineid)

Check that a line belongs to this object, using $this->table_element_line and $this->fk_element.

Returns true when the object is not loaded or does not define them.

Parameters
int$lineidId of the line
Returns
bool True if the line is a line of this object

Definition at line 12606 of file commonobject.class.php.

Referenced by BOM\updateLine(), ProductAttribute\updateLine(), Commande\updateline(), CommandeFournisseur\updateline(), Contrat\updateline(), ExpenseReport\updateline(), Facture\updateline(), FactureFournisseur\updateline(), FactureFournisseurRec\updateline(), FactureRec\updateline(), Propal\updateline(), and SupplierProposal\updateline().

◆ isObjectUsed()

CommonObject::isObjectUsed ( $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$idForce id of object
int$entityForce entity to check
Returns
int Return integer <0 if KO, 0 if not used, >0 if already used

Definition at line 5622 of file commonobject.class.php.

References $id, and dol_eval().

Referenced by Product\delete(), Societe\delete(), and Task\delete().

◆ isText()

CommonObject::isText ( $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
Returns
bool true if type text

Definition at line 11635 of file commonobject.class.php.

◆ line_ajaxorder()

CommonObject::line_ajaxorder ( $rows)

Update position of line with ajax (rang)

Parameters
int[]$rowsArray of rows
Returns
void

Reimplemented in Expedition.

Definition at line 4098 of file commonobject.class.php.

References updateRangOfLine().

◆ line_down()

CommonObject::line_down ( $rowid,
$fk_parent_line = true )

Update a line to have a higher rank.

Parameters
int$rowidId of line
boolean$fk_parent_lineTable with fk_parent_line field or not
Returns
void

Definition at line 4042 of file commonobject.class.php.

References getRangOfLine(), line_max(), line_order(), and updateLineDown().

◆ line_max()

◆ line_order()

CommonObject::line_order ( $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
boolean$renumTrue to renum all already ordered lines, false to renum only not already ordered lines.
string$rowidorderASC or DESC
boolean$fk_parent_lineTable with fk_parent_line field or not
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 3896 of file commonobject.class.php.

References dol_syslog(), getChildrenOfLine(), getDolGlobalInt(), and updateRangOfLine().

Referenced by Commande\addline(), CommandeFournisseur\addline(), Facture\addline(), FactureFournisseur\addline(), Propal\addline(), SupplierProposal\addline(), Expedition\addlinefree(), Contrat\deleteLine(), StockTransfer\deleteLine(), line_down(), line_up(), Commande\updateline(), Facture\updateline(), Propal\updateline(), SupplierProposal\updateline(), and Expedition\updatelinefree().

◆ line_up()

CommonObject::line_up ( $rowid,
$fk_parent_line = true )

Update a line to have a lower rank.

Parameters
int$rowidId of line
boolean$fk_parent_lineTable with fk_parent_line field or not
Returns
void

Definition at line 4022 of file commonobject.class.php.

References getRangOfLine(), line_order(), and updateLineUp().

◆ liste_contact()

CommonObject::liste_contact ( $statusoflink = -1,
$source = 'external',
$list = 0,
$code = '',
$status = -1,
$arrayoftcids = array() )

Get array of all contacts for an object.

Parameters
int$statusoflinkStatus of links to get (-1=all). Not used.
'external'|'thirdparty'|'internal'$source Source of contact: 'external' or 'thirdparty' (llx_socpeople) or 'internal' (llx_user)
int<0,1>$list 0:Returned array contains all properties, 1:Return array contains just id
string$codeFilter on this code of contact type ('SHIPPING', 'BILLING', ...)
int$statusStatus of user or company
int[]$arrayoftcidsArray 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).
Returns
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

Definition at line 1636 of file commonobject.class.php.

References dol_syslog().

Referenced by add_contact(), getListContactId(), Task\getListContactId(), and Project\restrictedProjectArea().

◆ liste_type_contact()

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

Return array with list of possible values for type of contacts.

Parameters
'internal'|'external'|'all'$source 'internal', 'external' or 'all'
string$orderSort order by : 'position', 'code', 'rowid'...
int<0,1>$option 0=Return array id->label, 1=Return array code->label, 2=Return complete array
int<0,1>$activeonly 0=all status of contact, 1=only the active
string$codeType of contact (Example: 'CUSTOMER', 'SERVICE')
Returns
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

Definition at line 1785 of file commonobject.class.php.

Referenced by delete_linked_contact().

◆ listeTypeContacts()

CommonObject::listeTypeContacts ( $source = 'internal',
$option = 0,
$activeonly = 0,
$code = '',
$element = '',
$excludeelement = '' )

Return array with list of possible values for type of contacts.

Parameters
string$source'internal', 'external' or 'all'
int<0,1>$option 0=Return array id->label, 1=Return array code->label
int<0,1>$activeonly 0=all status of contact, 1=only the active
string$codeType of contact (Example: 'CUSTOMER', 'SERVICE')
string$elementFilter on 1 element type
string$excludeelementExclude 1 element type. Example: 'agenda'
Returns
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

Definition at line 1854 of file commonobject.class.php.

References dol_syslog(), and isModEnabled().

◆ load_previous_next_ref()

CommonObject::load_previous_next_ref ( $filter,
$fieldid,
$nodbprefix = 0 )

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

Parameters
string$filterOptional 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'))".
string$fieldidName of field to use for the select MAX and MIN
int<0,1>$nodbprefix Do not include DB prefix to forge table name
Returns
int<-2,1> Return integer <0 if KO, >0 if OK

Definition at line 2890 of file commonobject.class.php.

References $conf, forgeSQLFromUniversalSearchCriteria(), getDolGlobalInt(), getEntity(), and ref.

◆ onFieldValueChanged()

CommonObject::onFieldValueChanged ( $fieldKey,
$value )
protected

Hook called by setFieldValue() after a field has been successfully assigned.

Override in child classes to recompute fields that depend on the one that just changed (for example recalculating total_ttc when subprice or tva_tx changes on a line).

Warning: to avoid infinite recursion, dependent fields should be assigned directly (ex: $this->total_ttc = ...) rather than through a recursive call to setFieldValue(). setFieldValue() also guards against re-entrant calls on the same field as a safety net.

Parameters
string$fieldKeyThe name of the field that was just modified.
mixed$valueThe new value that was assigned to the field.
Returns
void

Definition at line 2508 of file commonobject.class.php.

Referenced by setFieldValue().

◆ persistFieldValue()

CommonObject::persistFieldValue ( User $user,
$field )
protected

Save into database the current value of one field, called by updateFieldFromUi().

By default, notes are saved with update_note() and other fields with setValueFrom(), with the trigger XXX_MODIFY. Override in child classes to use a dedicated method holding business rules (ex: set_ref_client()).

Parameters
User$userUser making the change
string$fieldField name
Returns
int Return integer <0 if KO, >0 if OK

Reimplemented in Commande, Facture, and Propal.

Definition at line 2550 of file commonobject.class.php.

References getFieldUiValue(), setValueFrom(), and update_note().

Referenced by updateFieldFromUi().

◆ prepareObjectLinesDisplay()

CommonObject::prepareObjectLinesDisplay ( )
protected

Prepare the display of the lines: global $usemargins and line extrafields used by the line templates (objectline_xxx.tpl.php) Used by printObjectLines() and getObjectLineHtml()

Returns
void

Definition at line 6042 of file commonobject.class.php.

References isModEnabled().

◆ printObjectLine()

CommonObject::printObjectLine ( $action,
$line,
$var,
$num,
$i,
$dateSelector,
$seller,
$buyer,
$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$actionGET/POST action
CommonObjectLine | CommonObject | stdClass$lineSelected object line to output
''$var Not used
int$numNumber of line (0)
int$iI
int$dateSelector1=Show also date range input fields
Societe$sellerObject of seller third party
?Societe$buyerObject of buyer third party
int<0,max>$selected ID line selected
?ExtraFields$extrafieldsObject of extrafields
string$defaulttpldirDirectory where to find the template (deprecated)
Returns
void

Reimplemented in ProductAttribute.

Definition at line 6219 of file commonobject.class.php.

References $conf, $module, $object, dol_buildpath(), dol_htmlentitiesbr(), getDolGlobalInt(), getDolGlobalString(), GETPOST(), price2num(), and status.

◆ printObjectLines()

CommonObject::printObjectLines ( $action,
$seller,
$buyer,
$selected = 0,
$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$actionAction code
Societe$sellerObject of seller third party
?Societe$buyerObject of buyer third party
int<0,max>$selected ID line selected
int$dateSelector1=Show also date range input fields
string$defaulttpldirDirectory where to find the template
Returns
void

Definition at line 5981 of file commonobject.class.php.

References $conf, $module, $object, and dol_buildpath().

◆ printObjectLineWithHooks()

CommonObject::printObjectLineWithHooks ( $action,
$line,
$num,
$i,
$dateSelector,
$seller,
$buyer,
$selected,
$extrafields,
$defaulttpldir )
protected

Print a line of the lines table: hooks printObjectLine or printObjectSubLine, then printObjectLine() if no hook replaced it Used by printObjectLines() and getObjectLineHtml()

Parameters
string$actionAction code
CommonObjectLine | CommonObject | stdClass$lineLine to print
int$numNumber of lines
int$iIndex of the line in $this->lines
int$dateSelector1=Show also date range input fields
Societe$sellerObject of seller third party
?Societe$buyerObject of buyer third party
int<0,max>$selected ID line selected
?ExtraFields$extrafieldsObject of extrafields
string$defaulttpldirDirectory where to find the template
Returns
void

Definition at line 6081 of file commonobject.class.php.

◆ printOriginLine()

CommonObject::printOriginLine ( $line,
$var,
$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 | CommonObject | stdClass$lineLine
string$varNot used
string$restrictlist''=All lines, 'services'=Restrict to services only (strike line if not)
string$defaulttpldirDirectory where to find the template
int[]$selectedLinesArray of lines id for selected lines
Returns
void

Reimplemented in Mo.

Definition at line 6429 of file commonobject.class.php.

References $conf, $date_start, $module, dol_buildpath(), dol_trunc(), get_date_range(), getDolGlobalInt(), price(), Product\TYPE_SERVICE, and vatrate().

◆ printOriginLinesList()

CommonObject::printOriginLinesList ( $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
int[]$selectedLinesArray of lines id for selected lines
Returns
void

Reimplemented in Mo.

Definition at line 6371 of file commonobject.class.php.

References getDolGlobalInt(), and isModEnabled().

◆ quote()

CommonObject::quote ( $value,
$fieldsentry )
protected

Add quote to field value if necessary.

Parameters
string | int$valueValue 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
Returns
string|int

Definition at line 11877 of file commonobject.class.php.

References price2num().

◆ roundQtyToPackaging()

CommonObject::roundQtyToPackaging ( $qty,
$packaging )

Round a quantity up to the next multiple of a packaging quantity (options PRODUCT_USE_CUSTOMER_PACKAGING and PRODUCT_USE_SUPPLIER_PACKAGING).

The rounding is done on the absolute value, so a negative quantity stays negative.

Parameters
float | string$qtyQuantity
float | string | null$packagingPackaging quantity. Nothing is done if it is empty or not > 0.
Returns
float|string Quantity rounded to the packaging, or $qty if no rounding is needed

Definition at line 4240 of file commonobject.class.php.

References price2num().

Referenced by Commande\addline(), CommandeFournisseur\addline(), Facture\addline(), Propal\addline(), SupplierProposal\addline(), Commande\updateline(), CommandeFournisseur\updateline(), Facture\updateline(), Propal\updateline(), and SupplierProposal\updateline().

◆ setBankAccount()

CommonObject::setBankAccount ( $fk_account,
$notrigger = 0,
$userused = null )

Change the bank account.

Parameters
int$fk_accountId of bank account
int$notrigger0=launch triggers after, 1=disable triggers
User$userusedObject user
Returns
int 1 if OK, 0 if KO

Reimplemented in Societe.

Definition at line 3830 of file commonobject.class.php.

References dol_syslog().

◆ setCategoriesCommon()

CommonObject::setCategoriesCommon ( $categories,
$type_categ = '',
$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$categoriesCategory ID or array of Categories IDs
string$type_categCategory type ('customer', 'supplier', 'website_page', ...) defined into const class Categorie type
boolean$remove_existingTrue: Remove existings categories from Object if not supplies by $categories, False: let them
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 12880 of file commonobject.class.php.

References $c, and dol_syslog().

◆ setDeliveryAddress()

CommonObject::setDeliveryAddress ( $id)

Define delivery address.

Deprecated
Parameters
int$idAddress id
Returns
int Return integer <0 si ko, >0 si ok

Definition at line 3676 of file commonobject.class.php.

References $id, and dol_syslog().

◆ setDocModel()

CommonObject::setDocModel ( $user,
$modelpdf )

Set last model used by doc generator.

Parameters
User$userUser object that make change
string$modelpdfModele name
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 3797 of file commonobject.class.php.

References dol_syslog(), and dol_trunc().

◆ setErrorsFromObject()

CommonObject::setErrorsFromObject ( $object)

setErrorsFromObject

Parameters
CommonObject | HookManager$objectcommonobject or HookManager
Returns
void

Definition at line 1042 of file commonobject.class.php.

References $object.

Referenced by MouvementStock\_create(), Contrat\activateAll(), BOM\addLine(), Account\addline(), Commande\addline(), CommandeFournisseur\addline(), Contrat\addline(), Propal\addline(), Reception\addline(), SupplierProposal\addline(), Expedition\addline_batch(), PaymentSocialContribution\addPaymentToBank(), Commande\cancel(), Expedition\checkLineStockRequirements(), Product\correct_stock(), Account\create(), Facture\create(), Reception\create(), Expedition\create_delivery(), Societe\create_individual(), Expedition\create_line(), MouvementStock\createBatch(), ActionComm\createFromClone(), AssetModel\createFromClone(), Availabilities\createFromClone(), BOM\createFromClone(), BookkeepingTemplate\createFromClone(), Calendar\createFromClone(), Commande\createFromClone(), CommandeFournisseur\createFromClone(), ConferenceOrBoothAttendee\createFromClone(), CTicketCategory\createFromClone(), DefaultValues\createFromClone(), EmailCollector\createFromClone(), Evaluation\createFromClone(), ExpenseReport\createFromClone(), Facture\createFromClone(), FactureFournisseur\createFromClone(), Fichinter\createFromClone(), Hook\createFromClone(), Inventory\createFromClone(), Job\createFromClone(), Mailing\createFromClone(), Memo\createFromClone(), MyObject\createFromClone(), Partnership\createFromClone(), PaymentDonation\createFromClone(), PaymentSocialContribution\createFromClone(), Position\createFromClone(), Productbatch\createFromClone(), ProductCustomerPrice\createFromClone(), ProductFournisseurPrice\createFromClone(), Propal\createFromClone(), ReceptionLineBatch\createFromClone(), RecruitmentCandidature\createFromClone(), RecruitmentJobPosition\createFromClone(), Skill\createFromClone(), Skilldet\createFromClone(), SkillRank\createFromClone(), StockTransfer\createFromClone(), StockTransferLine\createFromClone(), SupplierProposal\createFromClone(), Target\createFromClone(), Website\createFromClone(), Workstation\createFromClone(), Facture\createFromContract(), Facture\createFromOrder(), Commande\createFromProposal(), Mo\createProduction(), FactureFournisseurRec\createRecurringInvoices(), FactureRec\createRecurringInvoices(), PaymentSalary\delete(), Subscription\delete(), BOM\deleteLine(), Commande\deleteLine(), CommandeFournisseur\deleteLine(), Mo\deleteLine(), Propal\deleteLine(), StockTransferLine\doStockMovement(), BookkeepingTemplate\fetchLines(), Skill\fetchLines(), Availabilities\getLinesArray(), BookkeepingTemplate\getLinesArray(), Calendar\getLinesArray(), Evaluation\getLinesArray(), Job\getLinesArray(), MyObject\getLinesArray(), Position\getLinesArray(), RecruitmentCandidature\getLinesArray(), Skill\getLinesArray(), TriggerHistory\getLinesArray(), Reception\getStatusDispatch(), Commande\insert_discount(), Propal\insert_discount(), SupplierProposal\insert_discount(), Expedition\manageStockMvtOnEvt(), Adherent\mergeMembers(), Expedition\reOpen(), Commande\setDraft(), Facture\setDraft(), FactureFournisseur\setDraft(), Adherent\subscription(), Adherent\subscriptionComplementaryActions(), Societe\update(), ProductFournisseur\update_buyprice(), BOM\updateLine(), Commande\updateline(), FactureFournisseur\updateline(), Propal\updateline(), Expedition\updatelinefree(), CommandeFournisseur\updateProductBuyPrices(), Commande\valid(), Reception\valid(), Facture\validate(), and FactureFournisseur\validate().

◆ setErrorWithLog()

CommonObject::setErrorWithLog ( $message,
$loglevel = LOG_ERR )

Set the error message for the object and logs it, including the file name and line number.

Parameters
string$messagethe error message
int<0,7>$loglevel the log level
Returns
void

Definition at line 13139 of file commonobject.class.php.

References dol_syslog().

◆ setErrorWithoutLog()

CommonObject::setErrorWithoutLog ( $message)

Set the error message for the object without logging it.

Parameters
string$messagethe error message
Returns
void

Definition at line 13126 of file commonobject.class.php.

◆ setExtraField()

CommonObject::setExtraField ( $key,
$value )

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

Parameters
string$keyName of the extrafield
mixed$valueValue to be assigned to the extrafield
Returns
void

Definition at line 8374 of file commonobject.class.php.

◆ setExtraParameters()

CommonObject::setExtraParameters ( )

Set extra parameters.

Returns
int Return integer <0 if KO, >0 if OK

Definition at line 5890 of file commonobject.class.php.

References dol_syslog(), and dol_trunc().

◆ setFieldError()

CommonObject::setFieldError ( $fieldKey,
$msg = '' )

set validation error message a field

Parameters
string$fieldKeyKey of attribute
string$msgthe field error message
Returns
void

Definition at line 9903 of file commonobject.class.php.

Referenced by setFieldValue().

◆ setFieldValue()

CommonObject::setFieldValue ( User $user,
$fieldKey,
$value,
$byPassUserPermission = false )

Set a value for a dynamic field on the current object.

Used to detect and break infinite recursion that could be caused by onFieldValueChanged() side effects calling setFieldValue() back.

This method performs multiple safety checks before assigning the value:

  • verifies that the field is defined
  • checks if the user is allowed to edit the field
  • optionally validates the value if validation is required

If all checks pass, the value is assigned dynamically to the property, and onFieldValueChanged() is called so child classes can recompute dependent fields (for example recalculating a TTC amount when the HT amount of a line changes).

Parameters
User$userThe user attempting to modify the field.
string$fieldKeyThe name of the field to modify.
mixed$valueThe value to assign to the field.
bool$byPassUserPermissionset to true to skip user permission check and force value. Only user rights are skipped, field and object state checks still apply. When passing true, label it at call site with an inline block comment holding the parameter name (see CommonObjectTest).
Returns
bool Returns true if the value was successfully set, false otherwise.

Definition at line 2423 of file commonobject.class.php.

References deprecatedProperties(), dol_syslog(), getFieldPropertyName(), isFieldDefined(), isFieldEditAllowed(), isFieldValidationRequired(), onFieldValueChanged(), setFieldError(), and validateField().

Referenced by updateFieldFromUi().

◆ setMulticurrencyCode()

CommonObject::setMulticurrencyCode ( $code)

Change the multicurrency code.

Parameters
string$codemulticurrency code
Returns
int >0 if OK, <0 if KO

Definition at line 3282 of file commonobject.class.php.

References dol_syslog(), MultiCurrency\getIdAndTxFromCode(), and status.

◆ setPaymentMethods()

CommonObject::setPaymentMethods ( $id)

Change the payments methods.

Can be used on invoice, supplier invoice, salary, company, vat, ...

Parameters
int$idId of new payment method
Returns
int >0 if OK, <0 if KO

Reimplemented in Societe.

Definition at line 3209 of file commonobject.class.php.

References dol_clone(), dol_syslog(), and status.

Referenced by CommonInvoice\demande_prelevement(), and Salary\demande_prelevement().

◆ setPaymentTerms()

CommonObject::setPaymentTerms ( $id,
$deposit_percent = null )

Change the payments terms.

Parameters
int$idId of new payment terms
float$deposit_percent% of deposit if needed by payment terms
Returns
int >0 if OK, <0 if KO

Reimplemented in Societe.

Definition at line 3580 of file commonobject.class.php.

References dol_syslog(), formatLogObject(), getDictionaryValue(), and status.

◆ setProject()

CommonObject::setProject ( $projectid,
$notrigger = 0 )

Link element with a project.

Parameters
int$projectidProject id to link element to
int<0,1>$notrigger Disable the trigger
Returns
int<-1,1> Return integer <0 if KO, >0 if OK

Definition at line 3137 of file commonobject.class.php.

References dol_syslog().

◆ setSaveQuery()

CommonObject::setSaveQuery ( )
protected

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 makes the createCommon() or the updateCommon().
  • $this->${field} should be a clean and string value (so date are formatted for SQL insert).
Returns
array<string,null|int|float|string> Array with all values of each property to update - caller is responsible for escaping

Definition at line 11711 of file commonobject.class.php.

References $conf.

◆ setShippingMethod()

CommonObject::setShippingMethod ( $shipping_method_id,
$notrigger = 0,
$userused = null )

Change the shipping method.

Parameters
int$shipping_method_idId of shipping method
int$notrigger0=launch triggers after, 1=disable triggers
User$userusedObject user
Returns
int 1 if OK, 0 if KO

Definition at line 3705 of file commonobject.class.php.

References dol_syslog().

◆ setStatusCommon()

CommonObject::setStatusCommon ( $user,
$status,
$notrigger = 0,
$triggercode = '' )

Set to a status.

Parameters
User$userObject user that modify
int$statusNew status to set (often a constant like self\STATUS_XXX)
int$notrigger1=Does not execute triggers, 0=Execute triggers
string$triggercodeTrigger code to use
Returns
int Return integer <0 if KO, >0 if OK
See also
setStatut()

Reimplemented in Mo.

Definition at line 12700 of file commonobject.class.php.

References status.

Referenced by AssetModel\cancel(), Availabilities\cancel(), BOM\cancel(), Calendar\cancel(), ConferenceOrBooth\cancel(), ConferenceOrBoothAttendee\cancel(), Evaluation\cancel(), Job\cancel(), KnowledgeRecord\cancel(), MyObject\cancel(), Partnership\cancel(), Position\cancel(), ProductFournisseurPrice\cancel(), RecruitmentCandidature\cancel(), RecruitmentJobPosition\cancel(), Skill\cancel(), Skilldet\cancel(), SkillRank\cancel(), StockTransfer\cancel(), StockTransferLine\cancel(), Target\cancel(), TimeSpent\cancel(), TriggerHistory\cancel(), Asset\dispose(), Asset\reopen(), AssetModel\reopen(), Availabilities\reopen(), BOM\reopen(), Calendar\reopen(), ConferenceOrBooth\reopen(), ConferenceOrBoothAttendee\reopen(), Don\reopen(), Evaluation\reopen(), Job\reopen(), KnowledgeRecord\reopen(), MyObject\reopen(), Partnership\reopen(), Position\reopen(), ProductFournisseurPrice\reopen(), RecruitmentCandidature\reopen(), RecruitmentJobPosition\reopen(), Skill\reopen(), Skilldet\reopen(), SkillRank\reopen(), StockTransfer\reopen(), StockTransferLine\reopen(), Target\reopen(), TimeSpent\reopen(), TriggerHistory\reopen(), Workstation\setDisabled(), Asset\setDraft(), AssetModel\setDraft(), Availabilities\setDraft(), BOM\setDraft(), Calendar\setDraft(), ConferenceOrBooth\setDraft(), ConferenceOrBoothAttendee\setDraft(), Evaluation\setDraft(), Expedition\setDraft(), Job\setDraft(), KnowledgeRecord\setDraft(), MyObject\setDraft(), Partnership\setDraft(), Position\setDraft(), ProductFournisseurPrice\setDraft(), RecruitmentCandidature\setDraft(), RecruitmentJobPosition\setDraft(), Skill\setDraft(), Skilldet\setDraft(), SkillRank\setDraft(), StockTransfer\setDraft(), StockTransferLine\setDraft(), Target\setDraft(), TimeSpent\setDraft(), TriggerHistory\setDraft(), and Workstation\setEnabled().

◆ setStatut()

CommonObject::setStatut ( $status,
$elementId = null,
$elementType = '',
$trigkey = '',
$fieldstatus = '' )

Set status of an object.

Parameters
int$statusStatus to set
?int$elementIdId of element to force (use this->id by default if null)
string$elementTypeType of element to force (use this->table_element by default)
string$trigkeyTrigger key to use for trigger, or 'none' or use '' means automatic but it is not recommended and is deprecated.
string$fieldstatusName of status field to update (commonly field 'status' or 'fk_statut' in this->table_element)
Returns
int Return integer <0 if KO, >0 if OK
See also
setStatusCommon()

Reimplemented in Mo.

Definition at line 5409 of file commonobject.class.php.

References $id, dol_clone(), dol_now(), dol_syslog(), and status.

Referenced by Delivery\create(), Inventory\setCanceled(), Inventory\setDraft(), Inventory\setRecorded(), Expedition\valid(), Reception\valid(), and Inventory\validate().

◆ setTransportMode()

CommonObject::setTransportMode ( $id)

Change the transport mode methods.

Parameters
int$idId of transport mode
Returns
int >0 if OK, <0 if KO

Definition at line 3634 of file commonobject.class.php.

References dol_syslog(), and status.

◆ setValueFrom()

CommonObject::setValueFrom ( $field,
$value,
$table = '',
$id = null,
$format = '',
$id_field = '',
$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$fieldField to update
mixed$valueNew value
string$tableTo force other table element or element line (should not be used)
?int$idTo force other object id (should not be used)
string$formatData format ('text', 'int', 'date'). 'text' is used if not defined
string$id_fieldTo force rowid field name. 'rowid' is used if not defined
User | string | null$fuserUpdate the user of last update field with this user. If not provided, current user is used except if value is 'none'
string$trigkeyTrigger key to run (in most cases something like 'XXX_MODIFY')
string$fk_user_fieldName of field to save user id making change
Returns
int<-2,1> Return integer <0 if KO, >0 if OK
See also
updateExtraField()

Definition at line 2716 of file commonobject.class.php.

References $id, dol_syslog(), and fetchCommon().

Referenced by persistFieldValue(), FactureRec\setNextDate(), and Societe\setThirdpartyType().

◆ setValuesForExtraLanguages()

CommonObject::setValuesForExtraLanguages ( $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$onlykeyOnly 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.
Returns
int<-1,1> 1 if array_options set, 0 if no value, -1 if error (field required missing for example)

Definition at line 7248 of file commonobject.class.php.

References dol_eval(), dol_mktime(), GETPOST(), GETPOSTINT(), and price2num().

◆ setVarsFromFetchObj()

CommonObject::setVarsFromFetchObj ( & $obj)

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

Parameters
stdClass$objContain data of object from database
Returns
void

Definition at line 11779 of file commonobject.class.php.

References ref.

◆ setWarehouse()

CommonObject::setWarehouse ( $warehouse_id)

Change the warehouse.

Parameters
int$warehouse_idId of warehouse
Returns
int 1 if OK, 0 if KO

Definition at line 3764 of file commonobject.class.php.

References dol_syslog().

◆ show_photos()

CommonObject::show_photos ( $modulepart,
$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.

Parameters
string$modulepart'product', 'ticket', ...
string$sdirDirectory to scan (full absolute path)
int<0,1>|''|'small'$size 0 or ''=original size, 1 or 'small'=use thumbnail if possible
int$nbmaxMaximum number of photos (0=no max)
int$nbbyrowNumber of image per line or -1 to use div separator or 0 to use no separator. Used only if size=1 or 'small'.
int$showfilename1=Show filename
int$showaction1=Show icon with action links (resize, delete)
int$maxHeightMax height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image.
int$maxWidthMax width of original image when size='small'
int$nolinkDo not add a href link to view enlarged imaged into a new tab
int | string$overwritetitleDo not add title tag on image
int$usesharelinkUse the public shared link of image (if not available, the 'nophoto' image will be shown instead)
string$cacheA string if we want to use a cached version of image
string$addphotorefcssAdd CSS to img of photos
Returns
string Html code to show photo. Number of photos shown is saved in this->nbphoto

Definition at line 11251 of file commonobject.class.php.

References completeFileArrayWithDatabaseInfo(), dol_dir_list(), dol_escape_htmltag(), dol_getImageSize(), dol_is_file(), dol_sort_array(), get_exdir(), getAdvancedPreviewUrl(), getDolGlobalInt(), getImageFileNameForSize(), image_format_supported(), and newToken().

Referenced by Product\getKanbanView(), ProductFournisseur\getNomUrl(), and Product\getTooltipContentArray().

◆ showInputField()

CommonObject::showInputField ( $val,
$key,
$value,
$moreparam = '',
$keysuffix = '',
$keyprefix = '',
$morecss = 0,
$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$keyKey of attribute
string | string[]$valuePreselected 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$moreparamTo add more parameters on html input tag
string$keysuffixSuffix string to add into name and id of field (can be used to avoid duplicate names)
string$keyprefixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string | int$morecssValue 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
Returns
string

Reimplemented in Position.

Definition at line 8421 of file commonobject.class.php.

References $conf, $id, ajax_combobox(), dol_escape_htmltag(), dol_syslog(), dol_trunc(), forgeSQLFromUniversalSearchCriteria(), getDolGlobalInt(), getDolGlobalString(), isModEnabled(), and price().

Referenced by ajaxInputField().

◆ showLastFilePreview()

CommonObject::showLastFilePreview ( $rootdir = '',
$relativepath = '' )

Show preview link of the element (last generate or *<ref>*.pdf) if found and authorized to show the preview (file type)

See also
dolIsAllowedForPreview()
Parameters
string$rootdirRoot directory of the file
string$relativepathRelative directory of the file (from the root directory)
Returns
string Output string with HTML

Definition at line 13159 of file commonobject.class.php.

References $conf, completeFileArrayWithDatabaseInfo(), dol_dir_list(), dol_is_dir(), dol_is_file(), dol_sanitizeFileName(), dol_sort_array(), dolIsAllowedForPreview(), and ref.

◆ showOptionals()

CommonObject::showOptionals ( $extrafields,
$mode = 'view',
$params = null,
$keysuffix = '',
$keyprefix = '',
$onetrtd = '',
$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$extrafieldsExtrafield Object
string$modeShow output ('view') or input ('create' or 'edit') for extrafield
array<string,mixed>$params Optional parameters. Example: array('style'=>'class="oddeven"', 'colspan'=>$colspan)
string$keysuffixSuffix string to add after name and id of field (can be used to avoid duplicate names)
string$keyprefixPrefix string to add before name and id of field (can be used to avoid duplicate names)
string$onetrtdAll 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...)
Returns
string String with html content to show

Definition at line 10153 of file commonobject.class.php.

References $conf, $id, dol_eval(), dol_mktime(), dol_syslog(), getDolGlobalInt(), getDolGlobalString(), getPictoForType(), GETPOST(), GETPOSTINT(), GETPOSTISSET(), and price2num().

◆ swapContactStatus()

CommonObject::swapContactStatus ( $rowid)

Update status of a contact linked to object.

Parameters
int$rowidId of link between object and contact
Returns
int Return integer <0 if KO, >=0 if OK

Definition at line 1750 of file commonobject.class.php.

References dol_syslog(), and update_contact().

◆ trimParameters()

CommonObject::trimParameters ( $parameters)

Trim object parameters.

Parameters
string[]$parametersarray of parameters to trim
Returns
void

Definition at line 12833 of file commonobject.class.php.

◆ update_contact()

CommonObject::update_contact ( $rowid,
$statut,
$type_contact_id = 0,
$fk_socpeople = 0 )

Update a link to contact line.

Parameters
int$rowidId of line contact-element
int$statutNew status of link
int$type_contact_idId of contact type (not modified if 0)
int$fk_socpeopleId of soc_people to update (not modified if 0)
Returns
int Return integer <0 if KO, >= 0 if OK

Definition at line 1497 of file commonobject.class.php.

Referenced by swapContactStatus().

◆ update_note()

CommonObject::update_note ( $note,
$suffix = '',
$notrigger = 0 )

Update note of element.

Parameters
string$noteNew value for note
string$suffix'', '_public' or '_private'
int$notrigger1=Does not execute triggers, 0=execute triggers
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 4338 of file commonobject.class.php.

References dol_syslog().

Referenced by persistFieldValue(), and update_note_public().

◆ update_note_public()

CommonObject::update_note_public ( $note)

Update public note (kept for backward compatibility)

Parameters
string$noteNew value for note
Returns
int Return integer <0 if KO, >0 if OK
Deprecated
See also
update_note()

Definition at line 4424 of file commonobject.class.php.

References update_note().

◆ update_price()

CommonObject::update_price ( $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$exclspecUse >0 = Exclude special product (product_type=9)
'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
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.
?Societe$sellerIf 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).
Returns
int<-1,1> Return integer <0 if KO, >0 if OK

Definition at line 4441 of file commonobject.class.php.

References $conf, getDolGlobalString(), and isModEnabled().

Referenced by Commande\addline(), CommandeFournisseur\addline(), ExpenseReport\addline(), Facture\addline(), FactureFournisseur\addline(), FactureFournisseurRec\addline(), FactureRec\addline(), Propal\addline(), SupplierProposal\addline(), Commande\create(), ExpenseReport\create(), Facture\create(), FactureFournisseur\create(), Propal\create(), SupplierProposal\create(), Commande\deleteLine(), CommandeFournisseur\deleteLine(), Delivery\deleteLine(), ExpenseReport\deleteLine(), Facture\deleteLine(), FactureFournisseur\deleteLine(), Propal\deleteLine(), SupplierProposal\deleteLine(), Commande\insert_discount(), Facture\insert_discount(), FactureFournisseur\insert_discount(), Propal\insert_discount(), SupplierProposal\insert_discount(), Commande\setDiscount(), Facture\setDiscount(), Facture\update_percent(), CommandeFournisseur\updateFromCommandeClient(), Commande\updateline(), CommandeFournisseur\updateline(), Facture\updateline(), FactureFournisseur\updateline(), FactureFournisseurRec\updateline(), FactureRec\updateline(), Propal\updateline(), SupplierProposal\updateline(), and Facture\validate().

◆ update_ref_ext()

CommonObject::update_ref_ext ( $ref_ext)

Update external ref of element.

Parameters
string$ref_extUpdate field ref_ext
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 4306 of file commonobject.class.php.

References dol_syslog().

◆ updateCommon()

CommonObject::updateCommon ( User $user,
$notrigger = 0 )

Update object into database.

Parameters
User$userUser that modifies
int<0,1>$notrigger 0=launch triggers after, 1=disable triggers
Returns
int<-1,1> Return integer <0 if KO, >0 if OK

Definition at line 12234 of file commonobject.class.php.

References $id, dol_hash(), dol_now(), dol_string_nospecial(), dol_syslog(), and getDolGlobalString().

Referenced by ActionCommReminder\update(), Asset\update(), AssetModel\update(), Availabilities\update(), BOM\update(), BOMLine\update(), BonPrelevement\update(), BookkeepingTemplate\update(), BookkeepingTemplateLine\update(), Calendar\update(), CashControl\update(), CompanyPaymentMode\update(), ConferenceOrBoothAttendee\update(), CTicketCategory\update(), DefaultValues\update(), EmailCollector\update(), EmailCollectorAction\update(), EmailCollectorFilter\update(), EmailSenderProfile\update(), Evaluation\update(), EvaluationLine\update(), ExpenseReportIk\update(), ExpenseReportRule\update(), Hook\update(), Inventory\update(), InventoryLine\update(), Job\update(), KnowledgeRecord\update(), Memo\update(), Mo\update(), MoLine\update(), MyObject\update(), Partnership\update(), PartnershipType\update(), Position\update(), ProductFournisseurPrice\update(), RecruitmentCandidature\update(), RecruitmentJobPosition\update(), Skill\update(), Skilldet\update(), SkillRank\update(), SocieteAccount\update(), StockTransfer\update(), StockTransferLine\update(), Target\update(), TimeSpent\update(), TriggerHistory\update(), UserGroup\update(), and Workstation\update().

◆ updateExtraField()

CommonObject::updateExtraField ( $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$keyKey of the extrafield to update (without starting 'options_')
string$triggerIf defined, call also the trigger (for example COMPANY_MODIFY)
User$userusedObject user
Returns
int<-1,1> -1=error, O=did nothing, 1=OK
See also
updateExtraLanguages(), insertExtraFields(), deleteExtraFields(), setValueFrom()

Definition at line 8033 of file commonobject.class.php.

References $id, dol_eval(), dol_hash(), dol_syslog(), dolEncrypt(), getDolGlobalString(), and price2num().

◆ updateExtraLanguages()

CommonObject::updateExtraLanguages ( $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$keyKey of the extrafield (without starting 'options_')
string$triggerIf defined, call also the trigger (for example COMPANY_MODIFY)
User$userusedObject user
Returns
int -1=error, O=did nothing, 1=OK
See also
updateExtraField(), insertExtraLanguages()

Definition at line 8389 of file commonobject.class.php.

References getDolGlobalString().

◆ updateFieldFromUi()

CommonObject::updateFieldFromUi ( User $user,
$field,
$value )

Update a field from the user interface (ajax edition of cards...) and save it into database.

The field must be allowed by isFieldEditableFromUi(), the value is checked and set by setFieldValue(), then only this field is saved by persistFieldValue().

Parameters
User$userUser making the change
string$fieldField name
mixed$valueNew value
Returns
int Return integer <0 if KO (error into $this->error and $this->errors), >0 if OK

Definition at line 2579 of file commonobject.class.php.

References getFieldError(), getFieldPropertyName(), getFieldUiValue(), isFieldEditableFromUi(), persistFieldValue(), and setFieldValue().

◆ updateLineDown()

CommonObject::updateLineDown ( $rowid,
$rang,
$max )

Update position of line down (rang)

Parameters
int$rowidId of line
int$rangPosition
int$maxMax
Returns
int<-1,1> Return integer <0 if KO, >0 if OK

Definition at line 4151 of file commonobject.class.php.

Referenced by line_down().

◆ updateLineUp()

CommonObject::updateLineUp ( $rowid,
$rang )

Update position of line up (rang)

Parameters
int$rowidId of line
int$rangPosition
Returns
int<-1,1> Return integer <0 if KO, >0 if OK

Definition at line 4114 of file commonobject.class.php.

Referenced by line_up().

◆ updateLinkedBuyPrice()

CommonObject::updateLinkedBuyPrice ( $user,
$lineid,
$elements )

Apply the cost price of a line of this object to the lines of the same product of some linked documents.

Parameters
User$userUser making change
int$lineidId of the line of this object
array<string,mixed>$elements Elements ('propal', 'commande', 'facture') to update, when their value is not empty
Returns
int Return integer <0 if KO, number of lines updated if OK

Definition at line 11194 of file commonobject.class.php.

◆ updateObjectLinked()

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

Update object linked of a current object.

Parameters
int$sourceidObject source id
string$sourcetypeObject source type
int$targetidObject target id
string$targettypeObject target type
User$f_userUser that create
int$notrigger1=Does not execute triggers, 0= execute triggers
Returns
int >0 if OK, <0 if KO
See also
add_object_linked(), fetObjectLinked(), deleteObjectLinked()

Definition at line 5166 of file commonobject.class.php.

References dol_syslog().

◆ updateRangOfLine()

CommonObject::updateRangOfLine ( $rowid,
$rang )

◆ validateField()

CommonObject::validateField ( $fields,
$fieldKey,
$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$fieldKeyKey of attribute
string$fieldValueValue of attribute
Returns
bool Return false if fail true on success, see $this->error for error message

Reimplemented in MyObject, Productlot, and TriggerHistory.

Definition at line 9935 of file commonobject.class.php.

Referenced by AssetDepreciationOptions\setDeprecationOptionsFromPost(), and setFieldValue().

Member Data Documentation

◆ $origin_object

CommonObject::$origin_object
See also
fetch_origin()

Definition at line 405 of file commonobject.class.php.

Referenced by Expedition\delete(), and Reception\getStatusDispatch().


The documentation for this class was generated from the following file: