dolibarr 24.0.0-beta
product.lib.php File Reference

Set of functions for the module product and service. More...

Go to the source code of this file.

Functions

 product_prepare_head ($object)
 Prepare array with list of tabs.
 
 productlot_prepare_head ($object)
 Prepare array with list of tabs.
 
 product_admin_prepare_head ()
 Return array head with list of tabs to view object information.
 
 product_lot_admin_prepare_head ()
 Return array head with list of tabs to view object information.
 
 show_stats_for_company ($product, $socid)
 Show stats for a product.
 
 show_stats_for_batch ($batch, $socid)
 Show stats for product batch.
 
 measuring_units_string ($unitscale=null, $measuring_style='', $unitid=0, $use_short_label=0, $outputlangs=null)
 Return translation label of a unit key.
 
 measuringUnitString ($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
 Return translation label of a unit key.
 
 measuring_units_squared ($unitscale)
 Transform a given unit scale into the square of that unit, if known.
 
 measuring_units_cubed ($unit)
 Transform a given unit scale into the cube of that unit, if known.
 
 getProductForEmailTemplate ($id)
 Retrieve and return product for mail template.
 

Detailed Description

Set of functions for the module product and service.

Definition in file product.lib.php.

Function Documentation

◆ getProductForEmailTemplate()

getProductForEmailTemplate ( $id)

Retrieve and return product for mail template.

Parameters
int$idThe ID of the product to retrieve.
Returns
array<string,mixed>|int<-1,-1> Return array if OK, -1 if KO

Definition at line 1081 of file product.lib.php.

References $conf, $db, $id, $object, and dol_print_error().

◆ measuring_units_cubed()

measuring_units_cubed ( $unit)

Transform a given unit scale into the cube of that unit, if known.

Parameters
int$unitUnit scale key (-3,-2,-1,0,98,99...)
Returns
int Cubed unit key (-9,-6,-3,0,88,89...)
See also
formproduct->selectMeasuringUnits

Definition at line 1063 of file product.lib.php.

Referenced by Product\update().

◆ measuring_units_squared()

measuring_units_squared ( $unitscale)

Transform a given unit scale into the square of that unit, if known.

Parameters
int$unitscaleUnit scale key (-3,-2,-1,0,98,99...)
Returns
int Squared unit key (-6,-4,-2,0,98,99...)
See also
formproduct->selectMeasuringUnits

Definition at line 1043 of file product.lib.php.

Referenced by Product\update().

◆ measuring_units_string()

measuring_units_string ( $unitscale = null,
$measuring_style = '',
$unitid = 0,
$use_short_label = 0,
$outputlangs = null )

Return translation label of a unit key.

Function kept for backward compatibility.

Parameters
?int$unitscaleScale of unit: '0', '-3', '6', ...
string$measuring_styleStyle of unit: weight, volume,...
int$unitidID of unit (rowid in llx_c_units table)
int<0,1>$use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
?Translate$outputlangsLanguage object
Returns
string Unit string
See also
measuringUnitString() formproduct->selectMeasuringUnits()

Definition at line 965 of file product.lib.php.

References measuringUnitString().

◆ measuringUnitString()

measuringUnitString ( $unitid,
$measuring_style = '',
$unitscale = null,
$use_short_label = 0,
$outputlangs = null )

Return translation label of a unit key.

Parameters
int$unitidID of unit (rowid in llx_c_units table)
string$measuring_styleStyle of unit: 'weight', 'volume', ..., '' = 'net_measure' for option PRODUCT_ADD_NET_MEASURE
?int$unitscaleScale of unit: '0', '-3', '6', ...
int<0,2>$use_short_label 1=Use very short label ('g' instead of 'gram'), not translated. 2=Use translated short label.
?Translate$outputlangsLanguage object
Returns
string|-1 Unit string if OK, -1 if KO
See also
formproduct->selectMeasuringUnits()

Definition at line 981 of file product.lib.php.

References $db.

Referenced by pdf_espadon\_tableau_tot(), ActionsCardProduct\assign_values(), Form\constructProductListOption(), CommonDocGenerator\get_substitutionarray_lines(), CommonDocGenerator\get_substitutionarray_shipment(), ProductFournisseur\getNomUrl(), Product\getTooltipContentArray(), measuring_units_string(), Form\select_produits_fournisseurs_list(), pdf_eagle\write_file(), pdf_espadon\write_file(), pdf_rouget\write_file(), pdf_squille\write_file(), and pdf_standard\write_file().

◆ product_admin_prepare_head()

product_admin_prepare_head ( )

Return array head with list of tabs to view object information.

Returns
array<array{0:string,1:string,2:string}> Array of tabs to show

Definition at line 384 of file product.lib.php.

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

◆ product_lot_admin_prepare_head()

product_lot_admin_prepare_head ( )

Return array head with list of tabs to view object information.

Returns
array<array{0:string,1:string,2:string}> Array of tabs to show

Definition at line 484 of file product.lib.php.

References $conf, complete_head_from_modules(), and dolBuildUrl().

◆ product_prepare_head()

product_prepare_head ( $object)

Prepare array with list of tabs.

Parameters
Product$objectObject related to tabs
Returns
array<array{0:string,1:string,2:string}> Array of tabs to show

Definition at line 40 of file product.lib.php.

References $conf, $db, $object, complete_head_from_modules(), Link\count(), dol_dir_list(), dol_getcache(), dol_sanitizeFileName(), dol_setcache(), dol_syslog(), dolBuildUrl(), get_exdir(), getDolGlobalInt(), getDolGlobalString(), isModEnabled(), Product\TYPE_PRODUCT, and Product\TYPE_SERVICE.

Referenced by ActionsCardProduct\assign_values(), and ActionsCardService\assign_values().

◆ productlot_prepare_head()

productlot_prepare_head ( $object)

Prepare array with list of tabs.

Parameters
ProductLot$objectObject related to tabs
Returns
array<array{0:string,1:string,2:string}> Array of tabs to show

Definition at line 306 of file product.lib.php.

References $conf, $db, $object, complete_head_from_modules(), Link\count(), dol_dir_list(), dol_sanitizeFileName(), dolBuildUrl(), and getDolGlobalString().

◆ show_stats_for_batch()

show_stats_for_batch ( $batch,
$socid )

Show stats for product batch.

Parameters
Productlot$batchProduct batch object
int$socidThirdparty id
Returns
integer NB of lines shown into array

Definition at line 840 of file product.lib.php.

References $conf, $db, dol_print_error(), img_object(), isModEnabled(), and setEventMessages().

◆ show_stats_for_company()

show_stats_for_company ( $product,
$socid )

Show stats for a product.

Parameters
Product$productProduct object
int$socidThirdparty id
Returns
integer NB of lines shown into array

Definition at line 527 of file product.lib.php.

References $db, dol_print_error(), getDolGlobalString(), img_object(), isModEnabled(), price(), setEventMessage(), and setEventMessages().