dolibarr  7.0.0-beta
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | List of all members
CommonObject Class Reference

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

+ Inheritance diagram for CommonObject:

Public Member Functions

 errorsToString ()
 Method to output saved errors. More...
 
 getFullName ($langs, $option=0, $nameorder=-1, $maxlen=0)
 Return full name (civility+' '+name+' '+lastname) More...
 
 getFullAddress ($withcountry=0, $sep="\n")
 Return full address of contact. More...
 
 getBannerAddress ($htmlkey, $object)
 Return full address for banner. More...
 
 getLastMainDocLink ($modulepart, $initsharekey=0)
 Return the link of last main doc file for direct public download. More...
 
 add_contact ($fk_socpeople, $type_contact, $source='external', $notrigger=0)
 Add a link between element $this->element and a contact. More...
 
 copy_linked_contact ($objFrom, $source='internal')
 Copy contact from one element to current. More...
 
 update_contact ($rowid, $statut, $type_contact_id=0, $fk_socpeople=0)
 Update a link to contact line. More...
 
 delete_contact ($rowid, $notrigger=0)
 Delete a link to contact line. More...
 
 delete_linked_contact ($source='', $code='')
 Delete all links between an object $this and all its contacts. More...
 
 liste_contact ($statut=-1, $source='external', $list=0, $code='')
 Get array of all contacts for an object. More...
 
 swapContactStatus ($rowid)
 Update status of a contact linked to object. More...
 
 liste_type_contact ($source='internal', $order='position', $option=0, $activeonly=0, $code='')
 Return array with list of possible values for type of contacts. More...
 
 getIdContact ($source, $code, $status=0)
 Return id of contacts for a source and a contact code. More...
 
 fetch_contact ($contactid=null)
 Load object contact with id=$this->contactid into $this->contact. More...
 
 fetch_thirdparty ($force_thirdparty_id=0)
 Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty. More...
 
 fetchOneLike ($ref)
 Looks for an object with ref matching the wildcard provided It does only work when $this->table_ref_field is set. More...
 
 fetch_barcode ()
 Load data for barcode into properties ->barcode_type* Properties ->barcode_type that is id of barcode. More...
 
 fetch_projet ()
 Charge le projet d'id $this->fk_project dans this->projet. More...
 
 fetch_user ($userid)
 Charge le user d'id userid dans this->user. More...
 
 fetch_origin ()
 Read linked origin object. More...
 
 fetchObjectFrom ($table, $field, $key)
 Load object from specific field. More...
 
 getValueFrom ($table, $id, $field)
 Getter generic. More...
 
 setValueFrom ($field, $value, $table='', $id=null, $format='', $id_field='', $fuser=null, $trigkey='')
 Setter generic. More...
 
 load_previous_next_ref ($filter, $fieldid, $nodbprefix=0)
 Load properties id_previous and id_next by comparing $fieldid with $this->ref. More...
 
 getListContactId ($source='external')
 Return list of id of contacts of project. More...
 
 setProject ($projectid)
 Link element with a project. More...
 
 setPaymentMethods ($id)
 Change the payments methods. More...
 
 setMulticurrencyCode ($code)
 Change the multicurrency code. More...
 
 setMulticurrencyRate ($rate, $mode=1)
 Change the multicurrency rate. More...
 
 setPaymentTerms ($id)
 Change the payments terms. More...
 
 setDeliveryAddress ($id)
 Define delivery address. More...
 
 setShippingMethod ($shipping_method_id)
 Change the shipping method. More...
 
 setWarehouse ($warehouse_id)
 Change the warehouse. More...
 
 setDocModel ($user, $modelpdf)
 Set last model used by doc generator. More...
 
 setBankAccount ($fk_account)
 Change the bank account. More...
 
 line_order ($renum=false, $rowidorder='ASC', $fk_parent_line=true)
 Save a new position (field rang) for details lines. More...
 
 getChildrenOfLine ($id)
 Get children of line. More...
 
 line_up ($rowid, $fk_parent_line=true)
 Update a line to have a lower rank. More...
 
 line_down ($rowid, $fk_parent_line=true)
 Update a line to have a higher rank. More...
 
 updateRangOfLine ($rowid, $rang)
 Update position of line (rang) More...
 
 line_ajaxorder ($rows)
 Update position of line with ajax (rang) More...
 
 updateLineUp ($rowid, $rang)
 Update position of line up (rang) More...
 
 updateLineDown ($rowid, $rang, $max)
 Update position of line down (rang) More...
 
 getRangOfLine ($rowid)
 Get position of line (rang) More...
 
 getIdOfLine ($rang)
 Get rowid of the line relative to its position. More...
 
 line_max ($fk_parent_line=0)
 Get max value used for position of line (rang) More...
 
 update_ref_ext ($ref_ext)
 Update external ref of element. More...
 
 update_note ($note, $suffix='')
 Update note of element. More...
 
 update_note_public ($note)
 Update public note (kept for backward compatibility) More...
 
 update_price ($exclspec=0, $roundingadjust='none', $nodatabaseupdate=0, $seller=null)
 Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines). More...
 
 add_object_linked ($origin=null, $origin_id=null)
 Add objects linked in llx_element_element. More...
 
 fetchObjectLinked ($sourceid=null, $sourcetype='', $targetid=null, $targettype='', $clause='OR', $alsosametype=1)
 Fetch array of objects linked to current object. More...
 
 updateObjectLinked ($sourceid=null, $sourcetype='', $targetid=null, $targettype='')
 Update object linked of a current object. More...
 
 deleteObjectLinked ($sourceid=null, $sourcetype='', $targetid=null, $targettype='', $rowid='')
 Delete all links between an object $this. More...
 
 setStatut ($status, $elementId=null, $elementType='')
 Set status of an object. More...
 
 getCanvas ($id=0, $ref='')
 Load type of canvas of an object if it exists. More...
 
 getSpecialCode ($lineid)
 Get special code of a line. More...
 
 isObjectUsed ($id=0)
 Function to check if an object is used by others. More...
 
 hasProductsOrServices ($predefined=-1)
 Function to say how many lines object contains. More...
 
 getTotalDiscount ()
 Function that returns the total amount HT of discounts applied for all lines. More...
 
 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. More...
 
 setExtraParameters ()
 Set extra parameters. More...
 
 display_incoterms ()
 Return incoterms informations TODO Use a cache for label get. More...
 
 getIncotermsForPDF ()
 Return incoterms informations for pdf display. More...
 
 setIncoterms ($id_incoterm, $location)
 Define incoterms values of current object. More...
 
 isInEEC ()
 Return if a country is inside the EEC (European Economic Community) More...
 
 formAddObjectLine ($dateSelector, $seller, $buyer)
 Show add free and predefined products/services form. More...
 
 printObjectLines ($action, $seller, $buyer, $selected=0, $dateSelector=0)
 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'st possible as we keep a method available on overloaded objects. More...
 
 printObjectLine ($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected=0, $extrafieldsline=0)
 Return HTML content of a detail line TODO Move this into an output class file (htmlline.class.php) More...
 
 printOriginLinesList ($restrictlist='')
 Return HTML table table of source object lines TODO Move this and previous function into output html class file (htmlline.class.php). More...
 
 printOriginLine ($line, $var, $restrictlist='')
 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). More...
 
 add_element_resource ($resource_id, $resource_type, $busy=0, $mandatory=0)
 Add resources to the current object : add entry into llx_element_resources Need $this->element & $this->id. More...
 
 delete_resource ($rowid, $element, $notrigger=0)
 Delete a link to resource line. More...
 
 __clone ()
 Overwrite magic function to solve problem of cloning object that are kept as references. More...
 
 addThumbs ($file)
 Build thumb. More...
 
 getDefaultCreateValueFor ($fieldname, $alternatevalue=null)
 Return the default value to use for a field when showing the create form of object. More...
 
 call_trigger ($trigger_name, $user)
 Call trigger based on this instance. More...
 
 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. More...
 
 deleteExtraFields ()
 Delete all extra fields values for the current object. More...
 
 insertExtraFields ($trigger='', $userused=null)
 Add/Update all extra fields values for the current object. More...
 
 updateExtraField ($key)
 Update an exta field value for the current object. More...
 
 showInputField ($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0)
 Return HTML string to put an input field into a page Code very similar with showInputField of extra fields. More...
 
 showOutputField ($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0)
 Return HTML string to show a field into a page Code very similar with showOutputField of extra fields. More...
 
 showOptionals ($extrafields, $mode='view', $params=null, $keysuffix='', $keyprefix='')
 Function to show lines of extrafields with output datas. More...
 
 getRights ()
 Returns the rights used for this class. More...
 
 defineBuyPrice ($unitPrice=0.0, $discountPercent=0.0, $fk_product=0)
 Get buy price to use for margin calculation. More...
 
 isDate ($info)
 Function test if type is date. More...
 
 isInt ($info)
 Function test if type is integer. More...
 
 isFloat ($info)
 Function test if type is float. More...
 
 isText ($info)
 Function test if type is text. More...
 
 createCommon (User $user, $notrigger=false)
 Create object into database. More...
 
 fetchCommon ($id, $ref=null)
 Load object in memory from the database. More...
 
 updateCommon (User $user, $notrigger=false)
 Update object into database. More...
 
 deleteCommon (User $user, $notrigger=false)
 Delete object in database. More...
 
 initAsSpecimenCommon ()
 Initialise object with example values Id must be 0 if object instance is a specimen. More...
 
 fetchComments ()
 Load comments linked with current task. More...
 
 getNbComments ()
 Return nb comments already posted. More...
 

Static Public Member Functions

static isExistingObject ($element, $id, $ref='', $ref_ext='')
 Check an object id/ref exists If you don't need/want to instantiate object and just need to know if object exists, use this method instead of fetch. More...
 
static commonReplaceThirdparty (DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
 Function used to replace a thirdparty id with another one. More...
 

Public Attributes

 $projet
 
 $note
 

Protected Member Functions

 commonGenerateDocument ($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
 Common function for all objects extending CommonObject for generating documents. More...
 
 isArray ($info)
 Function test if type is array. More...
 
 isNull ($info)
 Function test if type is null. More...
 
 isIndex ($info)
 Function test if is indexed. More...
 
 quote ($value, $fieldsentry)
 Add quote to field value if necessary. More...
 

Private Member Functions

 set_save_query ()
 Function to prepare the values to insert. More...
 
 setVarsFromFetchObj (&$obj)
 Function to load data from a SQL pointer into properties of current object $this. More...
 
 get_field_list ()
 Function to concat keys of fields. More...
 

Detailed Description

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

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

Member Function Documentation

CommonObject::__clone ( )

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

Returns
void

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

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 souce = 'internal') to link
int$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 <0 if KO, >0 if OK

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

Referenced by CommandeFournisseur\approve(), Facture\create(), Commande\create(), and Contrat\create().

CommonObject::add_element_resource (   $resource_id,
  $resource_type,
  $busy = 0,
  $mandatory = 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
Returns
int <=0 if KO, >0 if OK

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

CommonObject::add_object_linked (   $origin = null,
  $origin_id = null 
)

Add objects linked in llx_element_element.

Parameters
string$originLinked element type
int$origin_idLinked element id
Returns
int <=0 if KO, >0 if OK
See also
fetchObjectLinked, updateObjectLinked, deleteObjectLinked

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

Referenced by Livraison\create(), FactureRec\create(), Fichinter\create(), Expedition\create(), FactureFournisseur\create(), Facture\create(), Commande\create(), SupplierProposal\create(), Contrat\create(), Propal\create(), and CommandeFournisseur\create().

CommonObject::addThumbs (   $file)

Build thumb.

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

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

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

CommonObject::call_trigger (   $trigger_name,
  $user 
)

Call trigger based on this instance.

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

Parameters
string$trigger_nametrigger's name to execute
User$userObject user
Returns
int Result of run_triggers

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

Referenced by MouvementStock\_create(), ContratLigne\active_line(), Categorie\add_type(), Contrat\addline(), Tva\addPayment(), Paiement\addPaymentToBank(), UserGroup\addrights(), User\addrights(), Task\addTimeSpent(), CommandeFournisseur\approve(), Commande\availability(), Propal\availability(), Commande\cancel(), CommandeFournisseur\Cancel(), CommandeFournisseur\classifyBilled(), Propal\classifyBilled(), Commande\classifyBilled(), Commande\classifyUnBilled(), ContratLigne\close_line(), Commande\cloture(), SupplierProposal\cloture(), Propal\cloture(), CommandeFournisseur\commande(), Comment\create(), Localtax\create(), Link\create(), Subscription\create(), CompanyBankAccount\create(), Deplacement\create(), Tva\create(), PaymentDonation\create(), AdherentType\create(), Productlot\create(), Task\create(), MultiCurrency\create(), Opensurveysondage\create(), Holiday\create(), Project\create(), ExpenseReport\create(), Fichinter\create(), Contact\create(), Expedition\create(), ActionComm\create(), FactureFournisseur\create(), Facture\create(), Adherent\create(), Categorie\create(), PaymentVarious\create(), PaymentSalary\create(), Don\create(), Product\create(), Societe\create(), Account\create(), UserGroup\create(), Commande\create(), CurrencyRate\create(), SupplierProposal\create(), Contrat\create(), Propal\create(), User\create(), CommandeFournisseur\create(), User\create_from_contact(), ExpenseReport\createFromClone(), ActionComm\createFromClone(), Facture\createFromClone(), Commande\createFromClone(), SupplierProposal\createFromClone(), Fichinter\createFromClone(), CommandeFournisseur\createFromClone(), Categorie\del_type(), PaymentVarious\delete(), PaymentSalary\delete(), AdherentType\delete(), Subscription\delete(), Entrepot\delete(), Comment\delete(), CompanyBankAccount\delete(), Localtax\delete(), Tva\delete(), PaymentDonation\delete(), MultiCurrency\delete(), Link\delete(), Opensurveysondage\delete(), Task\delete(), Dolresource\delete(), Categorie\delete(), Don\delete(), UserGroup\delete(), Project\delete(), Livraison\delete(), Holiday\delete(), Adherent\delete(), ActionComm\delete(), Fichinter\delete(), Contact\delete(), CurrencyRate\delete(), FactureFournisseur\delete(), User\delete(), Product\delete(), Contrat\delete(), Expedition\delete(), Societe\delete(), FactureLigneRec\delete(), Facture\delete(), CommandeFournisseur\delete(), SupplierProposal\delete(), ExpeditionLigne\delete(), SupplierInvoiceLine\delete(), Propal\delete(), SupplierProposalLine\delete(), Commande\delete(), CommandeFournisseurLigne\delete(), OrderLine\delete(), PropaleLigne\delete(), FactureLigne\delete(), deleteCommon(), FichinterLigne\deleteline(), Contrat\deleteline(), Product\delMultiLangs(), UserGroup\delrights(), User\delrights(), Task\delTimeSpent(), Commande\demand_reason(), Propal\demand_reason(), CommandeFournisseur\dispatchProduct(), FichinterLigne\insert(), ExpeditionLigne\insert(), SupplierInvoiceLine\insert(), SupplierProposalLine\insert(), ContratLigne\insert(), CommandeFournisseurLigne\insert(), PropaleLigne\insert(), OrderLine\insert(), FactureLigne\insert(), CommandeFournisseur\Livraison(), CommandeFournisseur\refuse(), ProductFournisseur\remove_product_fournisseur_price(), User\RemoveFromGroup(), Contrat\reopen(), SupplierProposal\reopen(), Expedition\reOpen(), Propal\reopen(), Adherent\resiliate(), Propal\set_availability(), Expedition\set_billed(), ExpenseReport\set_cancel(), Facture\set_canceled(), Propal\set_date(), Commande\set_date(), Propal\set_date_livraison(), CommandeFournisseur\set_date_livraison(), Commande\set_date_livraison(), Propal\set_demand_reason(), Commande\set_draft(), FactureFournisseur\set_draft(), Facture\set_draft(), Propal\set_draft(), Propal\set_echeance(), CommandeFournisseur\set_id_projet(), ExpenseReport\set_paid(), FactureFournisseur\set_paid(), Facture\set_paid(), Facture\set_ref_client(), Propal\set_ref_client(), Commande\set_ref_client(), Commande\set_remise(), Facture\set_remise(), Commande\set_remise_absolue(), Propal\set_remise_absolue(), Facture\set_remise_absolue(), Propal\set_remise_percent(), Commande\set_reopen(), FactureFournisseur\set_unpaid(), ExpenseReport\set_unpaid(), Facture\set_unpaid(), ExpenseReport\setApproved(), Project\setClose(), Expedition\setClosed(), ExpenseReport\setDeny(), Facture\setFinal(), User\SetInGroup(), Product\setMultiLangs(), Categorie\setMultiLangs(), Adherent\setPassword(), User\setPassword(), User\setstatus(), Contact\setstatus(), CommandeFournisseur\setStatus(), Fichinter\setValid(), Project\setValid(), ExpenseReport\setValidate(), PaymentVarious\update(), PaymentSalary\update(), CompanyBankAccount\update(), Localtax\update(), Link\update(), Tva\update(), AdherentType\update(), Comment\update(), Subscription\update(), PaymentDonation\update(), Dolresource\update(), Project\update(), Productlot\update(), Contact\update(), Fichinter\update(), Task\update(), ExpenseReport\update(), Adherent\update(), Categorie\update(), Don\update(), Holiday\update(), Account\update(), UserGroup\update(), Product\update(), Societe\update(), FactureFournisseur\update(), ActionComm\update(), CurrencyRate\update(), Expedition\update(), User\update(), FichinterLigne\update(), Propal\update(), Facture\update(), FactureLigneRec\update(), ExpeditionLigne\update(), SupplierInvoiceLine\update(), ContratLigne\update(), SupplierProposalLine\update(), Commande\update(), CommandeFournisseurLigne\update(), PropaleLigne\update(), OrderLine\update(), FactureLigne\update(), ProductFournisseur\update_buyprice(), Dolresource\update_element_resource(), Contact\update_perso(), updateCommon(), Contrat\updateline(), Product\updatePrice(), Task\updateTimeSpent(), Commande\valid(), Livraison\valid(), CommandeFournisseur\valid(), Expedition\valid(), SupplierProposal\valid(), Propal\valid(), Don\valid_promesse(), Contrat\validate(), FactureFournisseur\validate(), Adherent\validate(), and Facture\validate().

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 obj->modelpdf or GETPOST('modelpdf') for example.
Translate$outputlangsOutput language to use
int$hidedetails1 to hide details. 0 by default
int$hidedesc1 to hide product description. 0 by default
int$hideref1 to hide product reference. 0 by default
null | array$moreparamsArray to provide more information
Returns
int >0 if OK, <0 if KO

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

Referenced by Fichinter\generateDocument(), PaiementFourn\generateDocument(), UserGroup\generateDocument(), Livraison\generateDocument(), Project\generateDocument(), Task\generateDocument(), Adherent\generateDocument(), ExpenseReport\generateDocument(), Expedition\generateDocument(), FactureFournisseur\generateDocument(), Contrat\generateDocument(), SupplierProposal\generateDocument(), CommandeFournisseur\generateDocument(), Product\generateDocument(), Propal\generateDocument(), Societe\generateDocument(), Commande\generateDocument(), and Facture\generateDocument().

static CommonObject::commonReplaceThirdparty ( DoliDB  $db,
  $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 appropiate tables Column name fk_soc MUST be used to identify thirdparties

Parameters
DoliDB$dbDatabase 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[]$tables Tables that need to be changed
int$ignoreerrorsIgnore 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

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

Referenced by LignePrelevement\replaceThirdparty(), Bookmark\replaceThirdparty(), ProductFournisseur\replaceThirdparty(), Livraison\replaceThirdparty(), Fichinter\replaceThirdparty(), FactureRec\replaceThirdparty(), Contact\replaceThirdparty(), ActionComm\replaceThirdparty(), Project\replaceThirdparty(), Categorie\replaceThirdparty(), Adherent\replaceThirdparty(), Expedition\replaceThirdparty(), FactureFournisseur\replaceThirdparty(), Contrat\replaceThirdparty(), SupplierProposal\replaceThirdparty(), CommandeFournisseur\replaceThirdparty(), User\replaceThirdparty(), Propal\replaceThirdparty(), Commande\replaceThirdparty(), Societe\replaceThirdparty(), Facture\replaceThirdparty(), and Product\replaceThirdparty().

CommonObject::copy_linked_contact (   $objFrom,
  $source = 'internal' 
)

Copy contact from one element to current.

Parameters
CommonObject$objFromSource element
string$sourceNature of contact ('internal' or 'external')
Returns
int >0 if OK, <0 if KO

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

Referenced by Facture\createFromClone().

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

Create object into database.

Parameters
User$userUser that creates
bool$notriggerfalse=launch triggers after, true=disable triggers
Returns
int <0 if KO, Id of created object if OK

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

Referenced by WebsitePage\create(), ActionCommReminder\create(), EmailSenderProfile\create(), MyObject\create(), WebsiteAccount\create(), and Inventory\create().

CommonObject::defineBuyPrice (   $unitPrice = 0.0,
  $discountPercent = 0.0,
  $fk_product = 0 
)

Get buy price to use for margin calculation.

This function is called when buy price is unknown. Set buy price = sell price if ForceBuyingPriceIfNull configured, else if calculation MARGIN_TYPE = 'costprice' and costprice is defined, use costprice as buyprice else if 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
Returns
float <0 if KO, buyprice if OK

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

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

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 809 of file commonobject.class.php.

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

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

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

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

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

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

Delete a link to resource line.

Parameters
int$rowidId of resource line to delete
int$elementelement name (for trigger) TODO: use $this->element into commonobject class
int$notriggerDisable all triggers
Returns
int >0 if OK, <0 if KO

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

CommonObject::deleteCommon ( User  $user,
  $notrigger = false 
)

Delete object in database.

Parameters
User$userUser that deletes
bool$notriggerfalse=launch triggers after, true=disable triggers
Returns
int <0 if KO, >0 if OK

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

References call_trigger().

Referenced by ActionCommReminder\delete(), EmailSenderProfile\delete(), MyObject\delete(), WebsiteAccount\delete(), Inventory\delete(), and WebsitePage\delete().

CommonObject::deleteExtraFields ( )
CommonObject::deleteObjectLinked (   $sourceid = null,
  $sourcetype = '',
  $targetid = null,
  $targettype = '',
  $rowid = '' 
)

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.
Returns
int >0 if OK, <0 if KO
See also
add_object_linked, updateObjectLinked, fetchObjectLinked

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

Referenced by FactureRec\delete(), Livraison\delete(), Fichinter\delete(), FactureFournisseur\delete(), Contrat\delete(), Expedition\delete(), Facture\delete(), CommandeFournisseur\delete(), SupplierProposal\delete(), Propal\delete(), and Commande\delete().

CommonObject::display_incoterms ( )

Return incoterms informations TODO Use a cache for label get.

Returns
string incoterms info

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

CommonObject::errorsToString ( )

Method to output saved errors.

Returns
string String with errors

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

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 <0 if KO, 0 if can't guess type of barcode (ISBN, EAN13...), >0 if OK (all barcode properties loaded)

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

CommonObject::fetch_contact (   $contactid = null)

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

Parameters
int$contactidId du contact. Use this->contactid if empty.
Returns
int <0 if KO, >0 if OK

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

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$optionsArrayArray resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters.
Returns
int <0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded

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

Referenced by ActionComm\createFromClone(), Facture\createFromCurrent(), UserGroup\fetch(), ProductStockEntrepot\fetch(), User\fetch(), Dolresource\fetch(), Productlot\fetch(), Task\fetch(), Categorie\fetch(), CommandeFournisseur\fetch(), Livraison\fetch(), FactureRec\fetch(), Fichinter\fetch(), Project\fetch(), Expedition\fetch(), FactureFournisseur\fetch(), MouvementStock\fetch(), Contrat\fetch(), Don\fetch(), Contact\fetch(), Account\fetch(), Adherent\fetch(), SupplierProposal\fetch(), Facture\fetch(), Propal\fetch(), Commande\fetch(), and Product\fetch().

CommonObject::fetch_origin ( )

Read linked origin object.

Returns
void

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

Referenced by Expedition\delete(), and Expedition\generateDocument().

CommonObject::fetch_projet ( )

Charge le projet d'id $this->fk_project dans this->projet.

Returns
int <0 if KO, >=0 if OK

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

CommonObject::fetch_thirdparty (   $force_thirdparty_id = 0)

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

Parameters
int$force_thirdparty_idForce thirdparty id
Returns
int <0 if KO, >0 if OK

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

Referenced by SupplierProposal\create(), Propal\create(), Expedition\fetch(), CommonInvoice\is_erasable(), Contrat\reopen(), Contrat\validate(), FactureFournisseur\validate(), and Facture\validate().

CommonObject::fetch_user (   $userid)

Charge le user d'id userid dans this->user.

Parameters
int$useridId du contact
Returns
int <0 if KO, >0 if OK

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

CommonObject::fetchComments ( )

Load comments linked with current task.

Returns
boolean 1 if ok

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

References Comment\fetchAllFor().

Referenced by Project\fetch().

CommonObject::fetchCommon (   $id,
  $ref = null 
)

Load object in memory from the database.

Parameters
int$idId object
string$refRef
Returns
int <0 if KO, 0 if not found, >0 if OK

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

References setVarsFromFetchObj().

Referenced by CoreObject\fetch(), ActionCommReminder\fetch(), EmailSenderProfile\fetch(), MyObject\fetch(), WebsiteAccount\fetch(), and Inventory\fetch().

CommonObject::fetchObjectFrom (   $table,
  $field,
  $key 
)

Load object from specific field.

Parameters
string$tableTable element or element line
string$fieldField selected
string$keyImport key
Returns
int <0 if KO, >0 if OK

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

mixed Array of linked objects Loaded by CommonObject::fetchObjectLinked (   $sourceid = null,
  $sourcetype = '',
  $targetid = null,
  $targettype = '',
  $clause = 'OR',
  $alsosametype = 1 
)

Fetch array of objects linked to current object.

Links are loaded into this->linkedObjects array and this->linkedObjectsIds 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 target list linked to source
  • target id+type -> will get source list linked to target
  • source id+type + target type -> will get target list of the type
  • target id+type + target source -> will get source list of the type
Parameters
int$sourceidObject source id (if not defined, id of object)
string$sourcetypeObject source type (if not defined, element name of object)
int$targetidObject target id (if not defined, id of object)
string$targettypeObject target type (if not defined, elemennt name of object)
string$clause'OR' or 'AND' clause used when both source id and target id are provided
int$alsosametype0=Return only links to object that differs from source. 1=Include also link to objects of same type.
Returns
void
See also
add_object_linked, updateObjectLinked, deleteObjectLinked

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

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

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 = OK, 0 = Not found or table_ref_field not defined, <0 = KO

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

CommonObject::formAddObjectLine (   $dateSelector,
  $seller,
  $buyer 
)

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

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

CommonObject::get_field_list ( )
private

Function to concat keys of fields.

Returns
string

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

CommonObject::getBannerAddress (   $htmlkey,
  $object 
)

Return full address for banner.

Parameters
string$htmlkeyHTML id to make banner content unique
Object$objectObject (thirdparty, thirdparty of contact for contact, null for a member)
Returns
string Full address string

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

References getFullAddress(), and getFullName().

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

Load type of canvas of an object if it exists.

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

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

CommonObject::getChildrenOfLine (   $id)

Get children of line.

Parameters
int$idId of parent line
Returns
array Array with list of children lines id

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

CommonObject::getDefaultCreateValueFor (   $fieldname,
  $alternatevalue = null 
)

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
Returns
string|string[] Default value (can be an array if the GETPOST return an array)

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

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

Return full address of contact.

Parameters
int$withcountry1=Add country into address string
string$sepSeparator to use to build string
Returns
string Full address string

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

References dol_format_address(), and getCountry().

Referenced by getBannerAddress().

CommonObject::getFullName (   $langs,
  $option = 0,
  $nameorder = -1,
  $maxlen = 0 
)

Return full name (civility+' '+name+' '+lastname)

Parameters
Translate$langsLanguage object for translation of civility (used only if option is 1)
int$option0=No option, 1=Add civility
int$nameorder-1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname
int$maxlenMaximum length
Returns
string String with full name

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

References dol_trunc(), dolGetFirstLastname(), and name.

Referenced by Contact\_load_ldap_info(), Adherent\_load_ldap_info(), User\_load_ldap_info(), User\create(), Societe\create_from_member(), getBannerAddress(), Contact\getNomUrl(), Adherent\getNomUrl(), User\getNomUrl(), and Adherent\makeSubstitution().

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
array List of id for such contacts

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

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

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 2199 of file commonobject.class.php.

CommonObject::getIncotermsForPDF ( )

Return incoterms informations for pdf display.

Returns
string incoterms info

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

CommonObject::getLastMainDocLink (   $modulepart,
  $initsharekey = 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
Returns
string Link or empty string if there is no download link

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

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

Return list of id of contacts of project.

Parameters
string$sourceSource of contact: external (llx_socpeople) or internal (llx_user) or thirdparty (llx_societe)
Returns
array Array of id of contacts (if source=external or internal) Array of id of third parties with at least one contact on project (if source=thirdparty)

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

CommonObject::getNbComments ( )

Return nb comments already posted.

Returns
int

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

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 2179 of file commonobject.class.php.

CommonObject::getRights ( )

Returns the rights used for this class.

Returns
stdClass

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

CommonObject::getSpecialCode (   $lineid)

Get special code of a line.

Parameters
int$lineidId of line
Returns
int Special code

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

CommonObject::getTotalDiscount ( )

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

Returns
float

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

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 array('weight'=>...,'volume'=>...)

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

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 <0 if KO, >0 if OK

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

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 <0 if KO, 0 if no predefined products, nb of lines with predefined products if found

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

CommonObject::initAsSpecimenCommon ( )

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

Returns
void

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

Referenced by ActionCommReminder\initAsSpecimen(), EmailSenderProfile\initAsSpecimen(), MyObject\initAsSpecimen(), Inventory\initAsSpecimen(), and WebsiteAccount\initAsSpecimen().

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)
User$userusedObject user
Returns
int -1=error, O=did nothing, 1=OK

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

Referenced by Dolresource\create(), Task\create(), Project\create(), ExpenseReport\create(), Fichinter\create(), Expedition\create(), ActionComm\create(), FactureFournisseur\create(), Facture\create(), Categorie\create(), Don\create(), Account\create(), UserGroup\create(), Commande\create(), SupplierProposal\create(), Contrat\create(), Propal\create(), CommandeFournisseur\create(), FichinterLigne\insert(), ExpeditionLigne\insert(), SupplierInvoiceLine\insert(), SupplierProposalLine\insert(), CommandeFournisseurLigne\insert(), PropaleLigne\insert(), OrderLine\insert(), FactureLigne\insert(), AdherentType\update(), Dolresource\update(), Project\update(), Contact\update(), Task\update(), Adherent\update(), Categorie\update(), Don\update(), Account\update(), UserGroup\update(), Product\update(), Societe\update(), ActionComm\update(), Contrat\update(), User\update(), FichinterLigne\update(), FactureLigneRec\update(), ExpeditionLigne\update(), SupplierInvoiceLine\update(), ContratLigne\update(), SupplierProposalLine\update(), CommandeFournisseurLigne\update(), PropaleLigne\update(), OrderLine\update(), and FactureLigne\update().

CommonObject::isArray (   $info)
protected

Function test if type is array.

Parameters
array$infocontent informations of field
Returns
bool

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

Referenced by CoreObject\init().

CommonObject::isDate (   $info)

Function test if type is date.

Parameters
array$infocontent informations of field
Returns
bool

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

Referenced by CoreObject\init().

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

Check an object id/ref exists If you don't need/want to instantiate object and just need to know if 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 <0 if KO, 0 if OK but not found, >0 if OK and exists

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

References $resql, dol_print_error(), and dol_syslog().

Referenced by SupplierInvoiceLine\insert(), and FactureLigne\insert().

CommonObject::isFloat (   $info)

Function test if type is float.

Parameters
array$infocontent informations of field
Returns
bool

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

Referenced by CoreObject\init().

CommonObject::isIndex (   $info)
protected

Function test if is indexed.

Parameters
array$infocontent informations of field
Returns
bool

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

CommonObject::isInEEC ( )

Return if a country is inside the EEC (European Economic Community)

Deprecated:
Returns
boolean true = country inside EEC, false = country outside EEC

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

CommonObject::isInt (   $info)

Function test if type is integer.

Parameters
array$infocontent informations of field
Returns
bool

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

Referenced by CoreObject\init().

CommonObject::isNull (   $info)
protected

Function test if type is null.

Parameters
array$infocontent informations of field
Returns
bool

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

CommonObject::isObjectUsed (   $id = 0)

Function to check if an object is used by others.

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

Parameters
int$idForce id of object
Returns
int <0 if KO, 0 if not used, >0 if already used

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

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

CommonObject::isText (   $info)

Function test if type is text.

Parameters
array$infocontent informations of field
Returns
bool

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

CommonObject::line_ajaxorder (   $rows)

Update position of line with ajax (rang)

Parameters
array$rowsArray of rows
Returns
void

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

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 2061 of file commonobject.class.php.

CommonObject::line_max (   $fk_parent_line = 0)

Get max value used for position of line (rang)

Parameters
int$fk_parent_lineParent line id
Returns
int Max value of rang in table of lines

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

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

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 <0 if KO, >0 if OK

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

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

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 2043 of file commonobject.class.php.

CommonObject::liste_contact (   $statut = -1,
  $source = 'external',
  $list = 0,
  $code = '' 
)

Get array of all contacts for an object.

Parameters
int$statutStatus of links to get (-1=all)
string$sourceSource of contact: external or thirdparty (llx_socpeople) or internal (llx_user)
int$list0:Return array contains all properties, 1:Return array contains just id
string$codeFilter on this code of contact type ('SHIPPING', 'BILLING', ...)
Returns
array Array of contacts

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

Referenced by commande_prepare_head(), contract_prepare_head(), Task\getListContactId(), Project\restrictedProjectArea(), and societe_prepare_head().

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

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

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 filter. Example: " AND (t.field1 = 'aa' OR t.field2 = 'bb')"
string$fieldidName of field to use for the select MAX and MIN
int$nodbprefixDo not include DB prefix to forge table name
Returns
int <0 if KO, >0 if OK

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

CommonObject::printObjectLine (   $action,
  $line,
  $var,
  $num,
  $i,
  $dateSelector,
  $seller,
  $buyer,
  $selected = 0,
  $extrafieldsline = 0 
)

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

Parameters
string$actionGET/POST action
CommonObjectLine$lineSelected object line to output
string$varIs it a an odd line (true)
int$numNumber of line (0)
int$iI
int$dateSelector1=Show also date range input fields
string$sellerObject of seller third party
string$buyerObject of buyer third party
int$selectedObject line selected
int$extrafieldslineObject of extrafield line attribute
Returns
void

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

CommonObject::printObjectLines (   $action,
  $seller,
  $buyer,
  $selected = 0,
  $dateSelector = 0 
)

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'st possible as we keep a method available on overloaded objects.

Parameters
string$actionAction code
string$sellerObject of seller third party
string$buyerObject of buyer third party
int$selectedObject line selected
int$dateSelector1=Show also date range input fields
Returns
void

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

CommonObject::printOriginLine (   $line,
  $var,
  $restrictlist = '' 
)

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, 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
CommonObjectLine$lineLine
string$varVar
string$restrictlist''=All lines, 'services'=Restrict to services only (strike line if not)
Returns
void

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

CommonObject::printOriginLinesList (   $restrictlist = '')

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
string$restrictlist''=All lines, 'services'=Restrict to services only
Returns
void

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

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

Add quote to field value if necessary.

Parameters
string | int$valueValue to protect
array$fieldsentryProperties of field
Returns
string

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

Referenced by updateCommon().

CommonObject::set_save_query ( )
private

Function to prepare the values to insert.

Note $this->${field} are set by the page that make the createCommon or the updateCommon.

Returns
array

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

Referenced by updateCommon().

CommonObject::setBankAccount (   $fk_account)

Change the bank account.

Parameters
int$fk_accountId of bank account
Returns
int 1 if OK, 0 if KO

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

CommonObject::setDeliveryAddress (   $id)

Define delivery address.

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

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

CommonObject::setDocModel (   $user,
  $modelpdf 
)

Set last model used by doc generator.

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

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

CommonObject::setExtraParameters ( )

Set extra parameters.

Returns
int <0 if KO, >0 if OK

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

CommonObject::setIncoterms (   $id_incoterm,
  $location 
)

Define incoterms values of current object.

Parameters
int$id_incotermId of incoterm to set or '' to remove
string$locationlocation of incoterm
Returns
int <0 if KO, >0 if OK

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

CommonObject::setMulticurrencyCode (   $code)

Change the multicurrency code.

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

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

CommonObject::setMulticurrencyRate (   $rate,
  $mode = 1 
)

Change the multicurrency rate.

Parameters
double$ratemulticurrency rate
int$modemode 1 : amounts in company currency will be recalculated, mode 2 : amounts in foreign currency
Returns
int >0 if OK, <0 if KO

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

CommonObject::setPaymentMethods (   $id)

Change the payments methods.

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

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

Referenced by Facture\demande_prelevement().

CommonObject::setPaymentTerms (   $id)

Change the payments terms.

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

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

CommonObject::setProject (   $projectid)

Link element with a project.

Parameters
int$projectidProject id to link element to
Returns
int <0 if KO, >0 if OK

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

CommonObject::setShippingMethod (   $shipping_method_id)

Change the shipping method.

Parameters
int$shipping_method_idId of shipping method
Returns
int 1 if OK, 0 if KO

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

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

Set status of an object.

Parameters
int$statusStatus to set
int$elementIdId of element to force (use this->id by default)
string$elementTypeType of element to force (use this->table_element by default)
Returns
int <0 if KO, >0 if OK

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

Referenced by Livraison\create(), and Expedition\valid().

CommonObject::setValueFrom (   $field,
  $value,
  $table = '',
  $id = null,
  $format = '',
  $id_field = '',
  $fuser = null,
  $trigkey = '' 
)

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', 'date'). 'text' is used if not defined
string$id_fieldTo force rowid field name. 'rowid' is used if not defined
User | string$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')
Returns
int <0 if KO, >0 if OK

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

CommonObject::setVarsFromFetchObj ( $obj)
private

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

Parameters
stdClass$objContain data of object from database

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

Referenced by fetchCommon().

CommonObject::setWarehouse (   $warehouse_id)

Change the warehouse.

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

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

CommonObject::showInputField (   $val,
  $key,
  $value,
  $moreparam = '',
  $keysuffix = '',
  $keyprefix = '',
  $showsize = 0 
)

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

Parameters
array$valArray of properties for field to show
string$keyKey of attribute
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)
string$moreparamTo add more parametes on html input tag
string$keysuffixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keyprefixSuffix string to add into name and id of field (can be used to avoid duplicate names)
string | int$showsizeValue for css to define size. May also be a numeric.
Returns
string

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

CommonObject::showOptionals (   $extrafields,
  $mode = 'view',
  $params = null,
  $keysuffix = '',
  $keyprefix = '' 
)

Function to show lines of extrafields with output datas.

Parameters
Extrafields$extrafieldsExtrafield Object
string$modeShow output (view) or input (edit) for extrafield
array$paramsOptional parameters
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)
Returns
string

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

CommonObject::showOutputField (   $val,
  $key,
  $value,
  $moreparam = '',
  $keysuffix = '',
  $keyprefix = '',
  $showsize = 0 
)

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

Parameters
array$valArray of properties of field to show
string$keyKey of attribute
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)
string$moreparamTo add more parametes on html input tag
string$keysuffixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keyprefixSuffix string to add into name and id of field (can be used to avoid duplicate names)
mixed$showsizeValue for css to define size. May also be a numeric.
Returns
string

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

CommonObject::swapContactStatus (   $rowid)

Update status of a contact linked to object.

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

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

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 <0 if KO, >= 0 if OK

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

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

Update note of element.

Parameters
string$noteNew value for note
string$suffix'', '_public' or '_private'
Returns
int <0 if KO, >0 if OK

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

CommonObject::update_note_public (   $note)

Update public note (kept for backward compatibility)

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

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

CommonObject::update_price (   $exclspec = 0,
  $roundingadjust = 'none',
  $nodatabaseupdate = 0,
  $seller = null 
)

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

Must be called at end of methods addline or updateline.

Parameters
int$exclspec>0 = Exclude special product (product_type=9)
string$roundingadjust'none'=Do nothing, '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$nodatabaseupdate1=Do not update database. Update only properties of object.
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.
Returns
int <0 if KO, >0 if OK

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

Referenced by SupplierProposal\addline(), Propal\addline(), FactureRec\addline(), Commande\addline(), FactureFournisseur\addline(), CommandeFournisseur\addline(), ExpenseReport\addline(), Facture\addline(), ExpenseReport\create(), FactureFournisseur\create(), Facture\create(), SupplierProposal\create(), Propal\create(), Livraison\deleteline(), SupplierProposal\deleteline(), Propal\deleteline(), FactureFournisseur\deleteline(), CommandeFournisseur\deleteline(), Commande\deleteline(), Facture\deleteline(), SupplierProposal\insert_discount(), Propal\insert_discount(), Facture\insert_discount(), Commande\insert_discount(), Commande\set_remise(), Facture\set_remise(), SupplierProposal\set_remise_absolue(), Commande\set_remise_absolue(), Propal\set_remise_absolue(), Facture\set_remise_absolue(), SupplierProposal\set_remise_percent(), Propal\set_remise_percent(), Facture\update_percent(), CommandeFournisseur\updateFromCommandeClient(), SupplierProposal\updateline(), Propal\updateline(), FactureRec\updateline(), FactureFournisseur\updateline(), CommandeFournisseur\updateline(), Facture\updateline(), Commande\updateline(), and Facture\validate().

CommonObject::update_ref_ext (   $ref_ext)

Update external ref of element.

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

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

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

Update object into database.

Parameters
User$userUser that modifies
bool$notriggerfalse=launch triggers after, true=disable triggers
Returns
int <0 if KO, >0 if OK

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

References call_trigger(), dol_now(), quote(), and set_save_query().

Referenced by ActionCommReminder\update(), EmailSenderProfile\update(), MyObject\update(), WebsiteAccount\update(), Inventory\update(), and WebsitePage\update().

CommonObject::updateExtraField (   $key)

Update an exta field value 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 delte record with all extrafields and insert them again from the array $this->array_options.

Parameters
string$keyKey of the extrafield
Returns
int -1=error, O=did nothing, 1=OK

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

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

Update position of line down (rang)

Parameters
int$rowidId of line
int$rangPosition
int$maxMax
Returns
void

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

CommonObject::updateLineUp (   $rowid,
  $rang 
)

Update position of line up (rang)

Parameters
int$rowidId of line
int$rangPosition
Returns
void

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

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

Update object linked of a current object.

Parameters
int$sourceidObject source id
string$sourcetypeObject source type
int$targetidObject target id
string$targettypeObject target type
Returns
int >0 if OK, <0 if KO
See also
add_object_linked, fetObjectLinked, deleteObjectLinked

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

CommonObject::updateRangOfLine (   $rowid,
  $rang 
)

Update position of line (rang)

Parameters
int$rowidId of line
int$rangPosition
Returns
void

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

Member Data Documentation

CommonObject::$note
CommonObject::$projet
Deprecated:
See also
project

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

Referenced by Contrat\update().


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