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

Class to manage products or services. More...

+ Inheritance diagram for Product:
+ Collaboration diagram for Product:

Public Member Functions

 __construct ($db)
 Constructor. More...
 
 check ()
 Check that ref and label are ok. More...
 
 create ($user, $notrigger=0)
 Insert product into database. More...
 
 verify ()
 Check properties of product are ok (like name, barcode, ...). More...
 
 check_barcode ($valuetotest, $typefortest)
 Check barcode. More...
 
 update ($id, $user, $notrigger=false, $action='update')
 Update a record into database. More...
 
 delete (User $user, $notrigger=0)
 Delete a product from database (if not used) More...
 
 setMultiLangs ($user)
 Update or add a translation for a product. More...
 
 delMultiLangs ($langtodelete, $user)
 Delete a language for this product. More...
 
 getMultiLangs ()
 Load array this->multilangs. More...
 
 _log_price ($user, $level=0)
 Insert a track that we changed a customer price. More...
 
 log_price_delete ($user, $rowid)
 Delete a price line. More...
 
 get_buyprice ($prodfournprice, $qty, $product_id=0, $fourn_ref='', $fk_soc=0)
 Read price used by a provider. More...
 
 updatePrice ($newprice, $newpricebase, $user, $newvat='', $newminprice='', $level=0, $newnpr=0, $newpbq=0, $ignore_autogen=0, $localtaxes_array=array(), $newdefaultvatcode='')
 Modify customer price of a product/Service. More...
 
 setPriceExpression ($expression_id)
 Sets the supplier price expression. More...
 
 fetch ($id='', $ref='', $ref_ext='', $ignore_expression=0)
 Load a product in memory from database. More...
 
 load_stats_propale ($socid=0)
 Charge tableau des stats propale pour le produit/service. More...
 
 load_stats_proposal_supplier ($socid=0)
 Charge tableau des stats propale pour le produit/service. More...
 
 load_stats_commande ($socid=0, $filtrestatut='', $forVirtualStock=0)
 Charge tableau des stats commande client pour le produit/service. More...
 
 load_stats_commande_fournisseur ($socid=0, $filtrestatut='', $forVirtualStock=0)
 Charge tableau des stats commande fournisseur pour le produit/service. More...
 
 load_stats_sending ($socid=0, $filtrestatut='', $forVirtualStock=0)
 Charge tableau des stats expedition client pour le produit/service. More...
 
 load_stats_reception ($socid=0, $filtrestatut='', $forVirtualStock=0)
 Charge tableau des stats réception fournisseur pour le produit/service. More...
 
 load_stats_contrat ($socid=0)
 Charge tableau des stats contrat pour le produit/service. More...
 
 load_stats_facture ($socid=0)
 Charge tableau des stats facture pour le produit/service. More...
 
 load_stats_facture_fournisseur ($socid=0)
 Charge tableau des stats facture pour le produit/service. More...
 
 _get_stats ($sql, $mode, $year=0)
 Return an array formated for showing graphs. More...
 
 get_nb_vente ($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='')
 Return nb of units or customers invoices in which product is included. More...
 
 get_nb_achat ($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='')
 Return nb of units or supplier invoices in which product is included. More...
 
 get_nb_propal ($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='')
 Return nb of units or proposals in which product is included. More...
 
 get_nb_propalsupplier ($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='')
 Return nb of units or proposals in which product is included. More...
 
 get_nb_order ($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='')
 Return nb of units or orders in which product is included. More...
 
 get_nb_ordersupplier ($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='')
 Return nb of units or orders in which product is included. More...
 
 add_sousproduit ($id_pere, $id_fils, $qty, $incdec=1)
 Link a product/service to a parent product/service. More...
 
 update_sousproduit ($id_pere, $id_fils, $qty, $incdec=1)
 Modify composed product. More...
 
 del_sousproduit ($fk_parent, $fk_child)
 Retire le lien entre un sousproduit et un produit/service. More...
 
 is_sousproduit ($fk_parent, $fk_child)
 Verifie si c'est un sous-produit. More...
 
 add_fournisseur ($user, $id_fourn, $ref_fourn, $quantity)
 Add a supplier price for the product. More...
 
 list_suppliers ()
 Renvoie la liste des fournisseurs du produit/service. More...
 
 clone_price ($fromId, $toId)
 Recopie les prix d'un produit/service sur un autre. More...
 
 clone_associations ($fromId, $toId)
 Clone links between products. More...
 
 clone_fournisseurs ($fromId, $toId)
 Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre. More...
 
 fetch_prod_arbo ($prod, $compl_path="", $multiply=1, $level=1, $id_parent=0)
 Fonction recursive uniquement utilisee par get_arbo_each_prod, recompose l'arborescence des sousproduits Define value of this->res. More...
 
 fetch_prods ($prod)
 fonction recursive uniquement utilisee par get_each_prod, ajoute chaque sousproduits dans le tableau res More...
 
 get_arbo_each_prod ($multiply=1)
 reconstruit l'arborescence des produits sous la forme d'un tableau More...
 
 get_each_prod ()
 Renvoie tous les sousproduits dans le tableau res, chaque ligne de res contient : id -> qty. More...
 
 hasFatherOrChild ()
 Return all parent products for current product (first level only) More...
 
 getFather ()
 Return all parent products for current product (first level only) More...
 
 getChildsArbo ($id, $firstlevelonly=0, $level=1)
 Return childs of product $id. More...
 
 get_sousproduits_arbo ()
 Return tree of all subproducts for product. More...
 
 getNomUrl ($withpicto=0, $option='', $maxlength=0, $save_lastsearch_value=-1)
 Return clicable link of object (with eventually picto) More...
 
 generateDocument ($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
 Create a document onto disk according to template module. More...
 
 getLibStatut ($mode=0, $type=0)
 Return label of status of object. More...
 
 LibStatut ($status, $mode=0, $type=0)
 Return label of a given status. More...
 
 getLibFinished ()
 Retourne le libelle du finished du produit. More...
 
 correct_stock ($user, $id_entrepot, $nbpiece, $movement, $label='', $price=0, $inventorycode='', $origin_element='', $origin_id=null)
 Adjust stock in a warehouse for product. More...
 
 correct_stock_batch ($user, $id_entrepot, $nbpiece, $movement, $label='', $price=0, $dlc='', $dluo='', $lot='', $inventorycode='', $origin_element='', $origin_id=null)
 Adjust stock in a warehouse for product with batch number. More...
 
 load_stock ($option='')
 Load information about stock of a product into ->stock_reel, ->stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products) This function need a lot of load. More...
 
 load_virtual_stock ()
 Load value ->stock_theorique of a product. More...
 
 loadBatchInfo ($batch)
 Load existing information about a serial. More...
 
 add_photo ($sdir, $file)
 Move an uploaded file described into $file array into target directory $sdir. More...
 
 is_photo_available ($sdir)
 Return if at least one photo is available. More...
 
 show_photos ($sdir, $size=0, $nbmax=0, $nbbyrow=5, $showfilename=0, $showaction=0, $maxHeight=120, $maxWidth=160, $nolink=0)
 Show photos of a product (nbmax maximum), into several columns TODO Move this into html.formproduct.class.php. More...
 
 liste_photos ($dir, $nbmax=0)
 Retourne tableau de toutes les photos du produit. More...
 
 delete_photo ($file)
 Efface la photo du produit et sa vignette. More...
 
 get_image_size ($file)
 Load size of image file. More...
 
 load_state_board ()
 Load indicators this->nb for the dashboard. More...
 
 isProduct ()
 Return if object is a product. More...
 
 isService ()
 Return if object is a product. More...
 
 get_barcode ($object, $type='')
 Get a barcode from the module to generate barcode values. More...
 
 initAsSpecimen ()
 Initialise an instance with random values. More...
 
 getLabelOfUnit ($type='long')
 Returns the text label from units dictionary. More...
 
 hasbatch ()
 Return if object has a sell-by date or eat-by date. More...
 
 min_recommended_price ()
 Return minimum product recommended price. More...
 
 setCategories ($categories)
 Sets object to supplied categories. More...
 
 generateMultiprices (User $user, $baseprice, $price_type, $price_vat, $npr, $psq)
 Generates prices for a product based on product multiprice generation rules. More...
 
 getRights ()
 Returns the rights used for this class. More...
 
 info ($id)
 Load information for tab info. More...
 
- Public Member Functions inherited from CommonObject
 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 replaceThirdparty (DoliDB $db, $origin_id, $dest_id)
 Function used to replace a thirdparty id with another one. More...
 
- Static Public Member Functions inherited from CommonObject
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

 $multiprices =array()
 Arrays for multiprices.
 
 $price_by_qty
 Price by quantity arrays.
 
 $default_vat_code
 Default VAT code for product (link to code into llx_c_tva but without foreign keys)
 
 $tva_tx
 Default VAT rate of product.
 
 $tva_npr =0
 French VAT NPR (0 or 1)
 
 $localtax1_tx
 Other local taxes.
 
 $pmp
 Average price value for product entry into stock (PMP)
 
 $desiredstock
 Ask for replenishment when $desiredstock < $stock_reel.
 
 $duration_unit
 Exoiration unit.
 
 $weight
 Unites de mesure.
 
 $imgWidth
 Taille de l'image.
 
 $product_fourn_id
 Id du fournisseur.
 
 $product_id_already_linked
 Product ID already linked to a reference supplier.
 
 $stock_warehouse =array()
 Contains detail of stock of product into each warehouse.
 
 $buyprice
 
 $ref_fourn
 
const TYPE_PRODUCT = 0
 Regular product.
 
const TYPE_SERVICE = 1
 Service.
 
const TYPE_ASSEMBLYKIT = 2
 Advanced feature: assembly kit.
 
const TYPE_STOCKKIT = 3
 Advanced feature: stock kit.
 
- Public Attributes inherited from CommonObject
 $projet
 
 $note
 

Protected Attributes

 $table_ref_field = 'ref'
 {}
 

Additional Inherited Members

- Protected Member Functions inherited from CommonObject
 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...
 

Detailed Description

Class to manage products or services.

Definition at line 44 of file product.class.php.

Constructor & Destructor Documentation

Product::__construct (   $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 330 of file product.class.php.

Member Function Documentation

Product::_get_stats (   $sql,
  $mode,
  $year = 0 
)

Return an array formated for showing graphs.

Parameters
string$sqlRequest to execute
string$mode'byunit'=number of unit, 'bynumber'=nb of entities
int$yearYear (0=current year)
Returns
array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

Definition at line 2551 of file product.class.php.

References $resql, dol_mktime(), dol_print_date(), dol_strlen(), and dol_trunc().

Referenced by get_nb_achat(), get_nb_order(), get_nb_ordersupplier(), get_nb_propal(), get_nb_propalsupplier(), and get_nb_vente().

Product::_log_price (   $user,
  $level = 0 
)

Insert a track that we changed a customer price.

Parameters
User$userUser making change
int$levelprice level to change
Returns
int <0 if KO, >0 if OK

Definition at line 1448 of file product.class.php.

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

Referenced by create(), and updatePrice().

Product::add_fournisseur (   $user,
  $id_fourn,
  $ref_fourn,
  $quantity 
)

Add a supplier price for the product.

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

Parameters
User$userUser that make link
int$id_fournSupplier id
string$ref_fournSupplier ref
float$quantityQuantity minimum for price
Returns
int < 0 if KO, 0 if link already exists for this product, > 0 if OK

Definition at line 2982 of file product.class.php.

References $ref_fourn, $resql, dol_now(), and dol_syslog().

Product::add_photo (   $sdir,
  $file 
)

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

Parameters
string$sdirTarget directory
string$fileArray of file info of file to upload: array('name'=>..., 'tmp_name'=>...)
Returns
int <0 if KO, >0 if OK

Definition at line 4015 of file product.class.php.

References CommonObject\addThumbs(), dol_mkdir(), dol_move_uploaded_file(), dol_osencode(), and get_exdir().

Product::add_sousproduit (   $id_pere,
  $id_fils,
  $qty,
  $incdec = 1 
)

Link a product/service to a parent product/service.

Parameters
int$id_pereId of parent product/service
int$id_filsId of child product/service
int$qtyQuantity
int$incdec1=Increase/decrease stock of child when parent stock increase/decrease
Returns
int < 0 if KO, > 0 if OK

Definition at line 2825 of file product.class.php.

References del_sousproduit(), and dol_print_error().

Product::check ( )

Check that ref and label are ok.

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

Definition at line 350 of file product.class.php.

References dol_sanitizeFileName(), and dol_strlen().

Product::check_barcode (   $valuetotest,
  $typefortest 
)

Check barcode.

Parameters
string$valuetotestValue to test
string$typefortestType of barcode (ISBN, EAN, ...)
Returns
int 0 if OK -1 ErrorBadBarCodeSyntax -2 ErrorBarCodeRequired -3 ErrorBarCodeAlreadyUsed

Definition at line 692 of file product.class.php.

References dol_include_once(), and dol_syslog().

Referenced by verify().

Product::clone_associations (   $fromId,
  $toId 
)

Clone links between products.

Parameters
int$fromIdProduct id
int$toIdProduct id
Returns
int <0 if KO, >0 if OK

Definition at line 3143 of file product.class.php.

References dol_syslog().

Product::clone_fournisseurs (   $fromId,
  $toId 
)

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

Parameters
int$fromIdId produit source
int$toIdId produit cible
Returns
int < 0 si erreur, > 0 si ok

Definition at line 3169 of file product.class.php.

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

Product::clone_price (   $fromId,
  $toId 
)

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

Parameters
int$fromIdId product source
int$toIdId product target
Returns
nt < 0 if KO, > 0 if OK

Definition at line 3115 of file product.class.php.

References dol_syslog().

Product::correct_stock (   $user,
  $id_entrepot,
  $nbpiece,
  $movement,
  $label = '',
  $price = 0,
  $inventorycode = '',
  $origin_element = '',
  $origin_id = null 
)

Adjust stock in a warehouse for product.

Parameters
User$useruser asking change
int$id_entrepotid of warehouse
double$nbpiecenb of units
int$movement0 = add, 1 = remove
string$labelLabel of stock movement
double$priceUnit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed.
string$inventorycodeInventory code
string$origin_elementOrigin element type
int$origin_idOrigin id of element
Returns
int <0 if KO, >0 if OK

Definition at line 3750 of file product.class.php.

Product::correct_stock_batch (   $user,
  $id_entrepot,
  $nbpiece,
  $movement,
  $label = '',
  $price = 0,
  $dlc = '',
  $dluo = '',
  $lot = '',
  $inventorycode = '',
  $origin_element = '',
  $origin_id = null 
)

Adjust stock in a warehouse for product with batch number.

Parameters
User$useruser asking change
int$id_entrepotid of warehouse
double$nbpiecenb of units
int$movement0 = add, 1 = remove
string$labelLabel of stock movement
double$pricePrice to use for stock eval
date$dlceat-by date
date$dluosell-by date
string$lotLot number
string$inventorycodeInventory code
string$origin_elementOrigin element type
int$origin_idOrigin id of element
Returns
int <0 if KO, >0 if OK

Definition at line 3798 of file product.class.php.

Product::create (   $user,
  $notrigger = 0 
)

Insert product into database.

Parameters
User$userUser making insert
int$notriggerDisable triggers
Returns
int Id of product/service if OK, < 0 if KO

Definition at line 378 of file product.class.php.

References _log_price(), CommonObject\call_trigger(), dol_include_once(), dol_now(), dol_string_nospecial(), dol_strlen(), dol_syslog(), get_barcode(), price(), price2num(), type, update(), and verify().

Product::del_sousproduit (   $fk_parent,
  $fk_child 
)

Retire le lien entre un sousproduit et un produit/service.

Parameters
int$fk_parentId du produit auquel ne sera plus lie le produit lie
int$fk_childId du produit a ne plus lie
Returns
int < 0 if KO, > 0 if OK

Definition at line 2913 of file product.class.php.

References dol_print_error(), and dol_syslog().

Referenced by add_sousproduit().

Product::delete ( User  $user,
  $notrigger = 0 
)

Delete a product from database (if not used)

Parameters
User$userProduct id (usage of this is deprecated, delete should be called without parameters on a fetched object)
int$notriggerDo not execute trigger
Returns
int < 0 if KO, 0 = Not possible, > 0 if OK

Definition at line 1033 of file product.class.php.

References CommonObject\call_trigger(), CommonObject\deleteExtraFields(), dol_delete_dir_recursive(), dol_sanitizeFileName(), dol_syslog(), fetch(), CommonObject\isObjectUsed(), type, TYPE_PRODUCT, and TYPE_SERVICE.

Product::delete_photo (   $file)

Efface la photo du produit et sa vignette.

Parameters
string$fileChemin de l'image
Returns
void

Definition at line 4348 of file product.class.php.

References dol_delete_file(), and dol_osencode().

Product::delMultiLangs (   $langtodelete,
  $user 
)

Delete a language for this product.

Parameters
string$langtodeleteLanguage code to delete
User$userObject user making delete
Returns
int <0 if KO, >0 if OK

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

References CommonObject\call_trigger(), and dol_syslog().

Product::fetch (   $id = '',
  $ref = '',
  $ref_ext = '',
  $ignore_expression = 0 
)

Load a product in memory from database.

Parameters
int$idId of product/service to load
string$refRef of product/service to load
string$ref_extRef ext of product/service to load
int$ignore_expressionIgnores the math expression for calculating price and uses the db value instead
Returns
int <0 if KO, 0 if not found, >0 if OK

French VAT NPR

Local taxes

Definition at line 1837 of file product.class.php.

References $resql, description, dol_print_error(), dol_strlen(), dol_syslog(), CommonObject\fetch_optionals(), getCountry(), getMultiLangs(), price(), price2num(), and type.

Referenced by delete(), and fetch_prod_arbo().

Product::fetch_prod_arbo (   $prod,
  $compl_path = "",
  $multiply = 1,
  $level = 1,
  $id_parent = 0 
)

Fonction recursive uniquement utilisee par get_arbo_each_prod, recompose l'arborescence des sousproduits Define value of this->res.

Parameters
array$prodProducts array
string$compl_pathDirectory path of parents to add before
int$multiplyBecause each sublevel must be multiplicated by parent nb
int$levelInit level
int$id_parentId parent
Returns
void

Definition at line 3220 of file product.class.php.

References fetch(), and load_stock().

Referenced by get_arbo_each_prod().

Product::fetch_prods (   $prod)

fonction recursive uniquement utilisee par get_each_prod, ajoute chaque sousproduits dans le tableau res

Parameters
array$prodProducts array
Returns
void

Definition at line 3274 of file product.class.php.

Referenced by get_each_prod().

Product::generateDocument (   $modele,
  $outputlangs,
  $hidedetails = 0,
  $hidedesc = 0,
  $hideref = 0 
)

Create a document onto disk according to template module.

Parameters
string$modeleForce model to use ('' to not force)
Translate$outputlangsObject langs to use for output
int$hidedetailsHide details of lines
int$hidedescHide description
int$hiderefHide ref
Returns
int 0 if KO, 1 if OK

Definition at line 3595 of file product.class.php.

References CommonObject\commonGenerateDocument(), and dol_strlen().

Product::generateMultiprices ( User  $user,
  $baseprice,
  $price_type,
  $price_vat,
  $npr,
  $psq 
)

Generates prices for a product based on product multiprice generation rules.

Parameters
User$userUser that updates the prices
float$basepriceBase price
string$price_typeBase price type
float$price_vatVAT % tax
int$nprNPR
string$psq¿?
Returns
int -1 KO, 1 OK

Definition at line 4691 of file product.class.php.

References updatePrice().

Referenced by updatePrice().

Product::get_arbo_each_prod (   $multiply = 1)

reconstruit l'arborescence des produits sous la forme d'un tableau

Parameters
int$multiplyBecause each sublevel must be multiplicated by parent nb
Returns
array $this->res

Definition at line 3295 of file product.class.php.

References fetch_prod_arbo().

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

Get a barcode from the module to generate barcode values.

Return value is stored into this->barcode

Parameters
Product$objectObject product or service
string$typeBarcode type (ean, isbn, ...)
Returns
void

Definition at line 4461 of file product.class.php.

References dol_include_once(), and dol_syslog().

Referenced by create(), and update().

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

Read price used by a provider.

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

Parameters
int$prodfournpriceId du tarif = rowid table product_fournisseur_price
double$qtyQuantity asked or -1 to get first entry found
int$product_idFilter on a particular product id
string$fourn_refFilter on a supplier price ref. 'none' to exclude ref in search.
int$fk_socIf of supplier
Returns
int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...)

Definition at line 1519 of file product.class.php.

References $resql, and dol_syslog().

Product::get_each_prod ( )

Renvoie tous les sousproduits dans le tableau res, chaque ligne de res contient : id -> qty.

Returns
array $this->res

Definition at line 3314 of file product.class.php.

References fetch_prods().

Product::get_image_size (   $file)

Load size of image file.

Parameters
string$filePath to file
Returns
void

Definition at line 4383 of file product.class.php.

References dol_osencode().

Product::get_nb_achat (   $socid,
  $mode,
  $filteronproducttype = -1,
  $year = 0,
  $morefilter = '' 
)

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

Parameters
int$socidLimit count on a particular third party id
string$mode'byunit'=number of unit, 'bynumber'=nb of entities
int$filteronproducttype0=To filter on product only, 1=To filter on services only
int$yearYear (0=last 12 month)
string$morefilterMore sql filters
Returns
array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

Definition at line 2653 of file product.class.php.

References _get_stats().

Product::get_nb_order (   $socid,
  $mode,
  $filteronproducttype = -1,
  $year = 0,
  $morefilter = '' 
)

Return nb of units or orders in which product is included.

Parameters
int$socidLimit count on a particular third party id
string$mode'byunit'=number of unit, 'bynumber'=nb of entities
int$filteronproducttype0=To filter on product only, 1=To filter on services only
int$yearYear (0=last 12 month)
string$morefilterMore sql filters
Returns
array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

Definition at line 2758 of file product.class.php.

References _get_stats().

Product::get_nb_ordersupplier (   $socid,
  $mode,
  $filteronproducttype = -1,
  $year = 0,
  $morefilter = '' 
)

Return nb of units or orders in which product is included.

Parameters
int$socidLimit count on a particular third party id
string$mode'byunit'=number of unit, 'bynumber'=nb of entities
int$filteronproducttype0=To filter on product only, 1=To filter on services only
int$yearYear (0=last 12 month)
string$morefilterMore sql filters
Returns
array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

Definition at line 2792 of file product.class.php.

References _get_stats().

Product::get_nb_propal (   $socid,
  $mode,
  $filteronproducttype = -1,
  $year = 0,
  $morefilter = '' 
)

Return nb of units or proposals in which product is included.

Parameters
int$socidLimit count on a particular third party id
string$mode'byunit'=number of unit, 'bynumber'=nb of entities
int$filteronproducttype0=To filter on product only, 1=To filter on services only
int$yearYear (0=last 12 month)
string$morefilterMore sql filters
Returns
array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

Definition at line 2688 of file product.class.php.

References _get_stats().

Product::get_nb_propalsupplier (   $socid,
  $mode,
  $filteronproducttype = -1,
  $year = 0,
  $morefilter = '' 
)

Return nb of units or proposals in which product is included.

Parameters
int$socidLimit count on a particular third party id
string$mode'byunit'=number of unit, 'bynumber'=nb of entities
int$filteronproducttype0=To filter on product only, 1=To filter on services only
int$yearYear (0=last 12 month)
string$morefilterMore sql filters
Returns
array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

Definition at line 2723 of file product.class.php.

References _get_stats().

Product::get_nb_vente (   $socid,
  $mode,
  $filteronproducttype = -1,
  $year = 0,
  $morefilter = '' 
)

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

Parameters
int$socidLimit count on a particular third party id
string$mode'byunit'=number of unit, 'bynumber'=nb of entities
int$filteronproducttype0=To filter on product only, 1=To filter on services only
int$yearYear (0=last 12 month)
string$morefilterMore sql filters
Returns
array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11

Definition at line 2617 of file product.class.php.

References _get_stats().

Product::get_sousproduits_arbo ( )

Return tree of all subproducts for product.

Tree contains id, name and quantity. Set this->sousprods

Returns
void

Definition at line 3464 of file product.class.php.

References getChildsArbo().

Product::getChildsArbo (   $id,
  $firstlevelonly = 0,
  $level = 1 
)

Return childs of product $id.

Parameters
int$idId of product to search childs of
int$firstlevelonlyReturn only direct child
int$levelLevel of recursing call (start to 1)
Returns
array Prod

Definition at line 3401 of file product.class.php.

References dol_print_error(), and dol_syslog().

Referenced by get_sousproduits_arbo().

Product::getFather ( )

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

Returns
array Array of product

Definition at line 3360 of file product.class.php.

References dol_print_error().

Referenced by load_stats_commande().

Product::getLabelOfUnit (   $type = 'long')

Returns the text label from units dictionary.

Parameters
string$typeLabel type (long or short)
Returns
string|int <0 if ko, label if ok

Definition at line 4536 of file product.class.php.

References $resql, and dol_syslog().

Product::getLibFinished ( )

Retourne le libelle du finished du produit.

Returns
string Libelle

Definition at line 3725 of file product.class.php.

Product::getLibStatut (   $mode = 0,
  $type = 0 
)

Return label of status of object.

Parameters
int$mode0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
int$type0=Sell, 1=Buy, 2=Batch Number management
Returns
string Label of status

Definition at line 3626 of file product.class.php.

References LibStatut().

Referenced by getNomUrl().

Product::getMultiLangs ( )

Load array this->multilangs.

Returns
int <0 if KO, >0 if OK

Definition at line 1404 of file product.class.php.

References description.

Referenced by fetch().

Product::getNomUrl (   $withpicto = 0,
  $option = '',
  $maxlength = 0,
  $save_lastsearch_value = -1 
)

Return clicable link of object (with eventually picto)

Parameters
int$withpictoAdd picto into link
string$optionWhere point the link ('stock', 'composition', 'category', 'supplier', '')
int$maxlengthMaxlength of ref
int$save_lastsearch_value-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
Returns
string String with URL

Definition at line 3487 of file product.class.php.

References dol_trunc(), getLibStatut(), img_object(), measuring_units_string(), show_photos(), type, TYPE_PRODUCT, and TYPE_SERVICE.

Product::getRights ( )

Returns the rights used for this class.

Returns
stdClass

Definition at line 4747 of file product.class.php.

References isProduct().

Product::hasbatch ( )

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

Returns
boolean True if it's has

Definition at line 4577 of file product.class.php.

Referenced by load_stock(), and update().

Product::hasFatherOrChild ( )

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

Returns
int Nb of father + child

Definition at line 3334 of file product.class.php.

References $resql.

Product::info (   $id)

Load information for tab info.

Parameters
int$idId of thirdparty to load
Returns
void

Definition at line 4764 of file product.class.php.

References dol_print_error().

Product::initAsSpecimen ( )

Initialise an instance with random values.

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

Returns
void

Definition at line 4491 of file product.class.php.

References description, and dol_now().

Product::is_photo_available (   $sdir)

Return if at least one photo is available.

Parameters
string$sdirDirectory to scan
Returns
boolean True if at least one photo is available, False if not

Definition at line 4055 of file product.class.php.

References dol_is_file(), dol_osencode(), get_exdir(), image_format_supported(), and utf8_check().

Product::is_sousproduit (   $fk_parent,
  $fk_child 
)

Verifie si c'est un sous-produit.

Parameters
int$fk_parentId du produit auquel le produit est lie
int$fk_childId du produit lie
Returns
int < 0 si erreur, > 0 si ok

Definition at line 2939 of file product.class.php.

References dol_print_error().

Product::isProduct ( )

Return if object is a product.

Returns
boolean True if it's a product

Definition at line 4438 of file product.class.php.

References type, and TYPE_PRODUCT.

Referenced by getRights().

Product::isService ( )

Return if object is a product.

Returns
boolean True if it's a service

Definition at line 4448 of file product.class.php.

References type, and TYPE_SERVICE.

Product::LibStatut (   $status,
  $mode = 0,
  $type = 0 
)

Return label of a given status.

Parameters
int$statusStatut
int$mode0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
int$type0=Status "to sell", 1=Status "to buy", 2=Status "to Batch"
Returns
string Label of status

Definition at line 3650 of file product.class.php.

References img_picto().

Referenced by getLibStatut().

Product::list_suppliers ( )

Renvoie la liste des fournisseurs du produit/service.

Returns
array Tableau des id de fournisseur

Definition at line 3081 of file product.class.php.

Product::liste_photos (   $dir,
  $nbmax = 0 
)

Retourne tableau de toutes les photos du produit.

Parameters
string$dirRepertoire a scanner
int$nbmaxNombre maximum de photos (0=pas de max)
Returns
array Tableau de photos

Definition at line 4294 of file product.class.php.

References dol_is_file(), dol_osencode(), image_format_supported(), and utf8_check().

Product::load_state_board ( )

Load indicators this->nb for the dashboard.

Returns
int <0 if KO, >0 if OK

Definition at line 4396 of file product.class.php.

References $resql, and dol_print_error().

Product::load_stats_commande (   $socid = 0,
  $filtrestatut = '',
  $forVirtualStock = 0 
)

Charge tableau des stats commande client pour le produit/service.

Parameters
int$socidId societe pour filtrer sur une societe
string$filtrestatutId statut pour filtrer sur un statut
int$forVirtualStockIgnore rights filter for virtual stock calculation.
Returns
array Array of stats (nb=nb of order, qty=qty ordered)

Definition at line 2225 of file product.class.php.

References getFather().

Referenced by load_virtual_stock().

Product::load_stats_commande_fournisseur (   $socid = 0,
  $filtrestatut = '',
  $forVirtualStock = 0 
)

Charge tableau des stats commande fournisseur pour le produit/service.

Parameters
int$socidId societe pour filtrer sur une societe
string$filtrestatutId des statuts pour filtrer sur des statuts
int$forVirtualStockIgnore rights filter for virtual stock calculation.
Returns
array Tableau des stats

Definition at line 2292 of file product.class.php.

Referenced by load_virtual_stock().

Product::load_stats_contrat (   $socid = 0)

Charge tableau des stats contrat pour le produit/service.

Parameters
int$socidId societe
Returns
array Tableau des stats

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

Product::load_stats_facture (   $socid = 0)

Charge tableau des stats facture pour le produit/service.

Parameters
int$socidId societe
Returns
array Tableau des stats

Definition at line 2465 of file product.class.php.

Product::load_stats_facture_fournisseur (   $socid = 0)

Charge tableau des stats facture pour le produit/service.

Parameters
int$socidId societe
Returns
array Tableau des stats

Definition at line 2507 of file product.class.php.

Product::load_stats_propale (   $socid = 0)

Charge tableau des stats propale pour le produit/service.

Parameters
int$socidId societe
Returns
array Tableau des stats

Definition at line 2137 of file product.class.php.

Product::load_stats_proposal_supplier (   $socid = 0)

Charge tableau des stats propale pour le produit/service.

Parameters
int$socidId thirdparty
Returns
array Tableau des stats

Definition at line 2180 of file product.class.php.

Product::load_stats_reception (   $socid = 0,
  $filtrestatut = '',
  $forVirtualStock = 0 
)

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

Parameters
int$socidId societe pour filtrer sur une societe
string$filtrestatutId statut pour filtrer sur un statut
int$forVirtualStockIgnore rights filter for virtual stock calculation.
Returns
array Tableau des stats

Definition at line 2382 of file product.class.php.

Referenced by load_virtual_stock().

Product::load_stats_sending (   $socid = 0,
  $filtrestatut = '',
  $forVirtualStock = 0 
)

Charge tableau des stats expedition client pour le produit/service.

Parameters
int$socidId societe pour filtrer sur une societe
string$filtrestatutId statut pour filtrer sur un statut
int$forVirtualStockIgnore rights filter for virtual stock calculation.
Returns
array Tableau des stats

Definition at line 2335 of file product.class.php.

Referenced by load_virtual_stock().

Product::load_stock (   $option = '')

Load information about stock of a product into ->stock_reel, ->stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products) This function need a lot of load.

If you use it on list, use a cache to execute it once for each product id. If ENTREPOT_EXTRA_STATUS set, filtering on warehouse status possible.

Parameters
string$option'' = Load all stock info, also from closed and internal warehouses, 'nobatch' = Do not load batch information, 'novirtual' = Do not load virtual stock, 'warehouseopen' = Load stock from open warehouses only, 'warehouseclosed' = Load stock from closed warehouses only, 'warehouseinternal' = Load stock from warehouses for internal correction/transfer only
Returns
int < 0 if KO, > 0 if OK
See also
load_virtual_stock, getBatchInfo

Definition at line 3843 of file product.class.php.

References dol_syslog(), Productbatch\findAll(), hasbatch(), load_virtual_stock(), Entrepot\STATUS_CLOSED, Entrepot\STATUS_OPEN_ALL, and Entrepot\STATUS_OPEN_INTERNAL.

Referenced by fetch_prod_arbo(), and update().

Product::load_virtual_stock ( )

Load value ->stock_theorique of a product.

Property this->id must be defined. This function need a lot of load. If you use it on list, use a cache to execute it one for each product id.

Returns
int < 0 if KO, > 0 if OK
See also
load_stock, getBatchInfo

Definition at line 3916 of file product.class.php.

References dol_print_error(), load_stats_commande(), load_stats_commande_fournisseur(), load_stats_reception(), and load_stats_sending().

Referenced by load_stock().

Product::loadBatchInfo (   $batch)

Load existing information about a serial.

Parameters
string$batchLot/serial number
Returns
array Array with record into product_batch
See also
load_stock, load_virtual_stock

Definition at line 3978 of file product.class.php.

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

Product::log_price_delete (   $user,
  $rowid 
)

Delete a price line.

Parameters
User$userObject user
int$rowidLine id to delete
Returns
int <0 if KO, >0 if OK

Definition at line 1486 of file product.class.php.

References $resql.

Product::min_recommended_price ( )

Return minimum product recommended price.

Returns
int Minimum recommanded price that is higher price among all suppliers * PRODUCT_MINIMUM_RECOMMENDED_PRICE

Definition at line 4588 of file product.class.php.

static Product::replaceThirdparty ( DoliDB  $db,
  $origin_id,
  $dest_id 
)
static

Function used to replace a thirdparty id with another one.

Parameters
DoliDB$dbDatabase handler
int$origin_idOld thirdparty id
int$dest_idNew thirdparty id
Returns
bool

Definition at line 4670 of file product.class.php.

References CommonObject\commonReplaceThirdparty().

Product::setCategories (   $categories)

Sets object to supplied categories.

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

Parameters
int[]|int$categories Category or categories IDs

Definition at line 4627 of file product.class.php.

Product::setMultiLangs (   $user)

Update or add a translation for a product.

Parameters
User$userObject user making update
Returns
int <0 if KO, >0 if OK

Definition at line 1204 of file product.class.php.

References CommonObject\call_trigger(), description, and dol_syslog().

Referenced by update().

Product::setPriceExpression (   $expression_id)

Sets the supplier price expression.

Parameters
int$expression_idExpression
Returns
int <0 if KO, >0 if OK
Deprecated:
Use Product::update instead

Definition at line 1819 of file product.class.php.

References update().

Product::show_photos (   $sdir,
  $size = 0,
  $nbmax = 0,
  $nbbyrow = 5,
  $showfilename = 0,
  $showaction = 0,
  $maxHeight = 120,
  $maxWidth = 160,
  $nolink = 0 
)

Show photos of a product (nbmax maximum), into several columns TODO Move this into html.formproduct.class.php.

Parameters
string$sdirDirectory to scan (full absolute path)
int$size0=original size, 1='small' use thumbnail if possible
int$nbmaxNombre maximum de photos (0=pas de max)
int$nbbyrowNumber of image per line or -1 to use div. Used only if size=1.
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
Returns
string Html code to show photo. Number of photos shown is saved in this->nbphoto

Definition at line 4100 of file product.class.php.

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

Referenced by getNomUrl().

Product::update (   $id,
  $user,
  $notrigger = false,
  $action = 'update' 
)

Update a record into database.

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

Parameters
int$idId of product
User$userObject user making update
int$notriggerDisable triggers
string$actionCurrent action for hookmanager ('add' or 'update')
Returns
int 1 if OK, -1 if ref already exists, -2 if other error

Definition at line 728 of file product.class.php.

References $localtax1_tx, $resql, $tva_npr, $tva_tx, CommonObject\call_trigger(), description, dol_print_error(), dol_sanitizeFileName(), dol_string_nospecial(), dol_syslog(), get_barcode(), hasbatch(), CommonObject\insertExtraFields(), load_stock(), measuring_units_cubed(), measuring_units_squared(), price2num(), setMultiLangs(), and verify().

Referenced by create(), and setPriceExpression().

Product::update_sousproduit (   $id_pere,
  $id_fils,
  $qty,
  $incdec = 1 
)

Modify composed product.

Parameters
int$id_pereId of parent product/service
int$id_filsId of child product/service
int$qtyQuantity
int$incdec1=Increase/decrease stock of child when parent stock increase/decrease
Returns
int < 0 if KO, > 0 if OK

Definition at line 2881 of file product.class.php.

References dol_print_error().

Product::updatePrice (   $newprice,
  $newpricebase,
  $user,
  $newvat = '',
  $newminprice = '',
  $level = 0,
  $newnpr = 0,
  $newpbq = 0,
  $ignore_autogen = 0,
  $localtaxes_array = array(),
  $newdefaultvatcode = '' 
)

Modify customer price of a product/Service.

Parameters
double$newpriceNew price
string$newpricebaseHT or TTC
User$userObject user that make change
double$newvatNew VAT Rate (For example 8.5. Should not be a string)
double$newminpriceNew price min
int$level0=standard, >0 = level if multilevel prices
int$newnpr0=Standard vat rate, 1=Special vat rate for French NPR VAT
int$newpbq1 if it has price by quantity
int$ignore_autogenUsed to avoid infinite loops
array$localtaxes_arrayArray with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
string$newdefaultvatcodeDefault vat code
Returns
int <0 if KO, >0 if OK

Definition at line 1652 of file product.class.php.

References $resql, $tva_tx, _log_price(), CommonObject\call_trigger(), dol_print_error(), dol_syslog(), generateMultiprices(), get_localtax(), price(), and price2num().

Referenced by generateMultiprices(), and ProductCombination\updateProperties().

Product::verify ( )

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

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

Returns
int 0 if OK, <0 if KO

Definition at line 646 of file product.class.php.

References check_barcode().

Referenced by create(), and update().

Member Data Documentation

Product::$buyprice
Deprecated:
See also
fourn_pu

Definition at line 282 of file product.class.php.

Referenced by ProductFournisseur\update_buyprice().

Product::$ref_fourn
Deprecated:
See also
ref_supplier

Definition at line 291 of file product.class.php.

Referenced by add_fournisseur(), and ProductFournisseur\update_buyprice().


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