dolibarr 18.0.6
FormProduct Class Reference

Class with static methods for building HTML components related to products Only components common to products and services must be here. More...

Public Member Functions

 __construct ($db)
 Constructor.
 
 loadWarehouses ($fk_product=0, $batch='', $status='', $sumStock=true, $exclude=array(), $stockMin=false, $orderBy='e.ref')
 Load in cache array list of warehouses If fk_product is not 0, we do not use cache.
 
 loadWorkstations ($fk_product=0, $exclude=array(), $orderBy='w.ref')
 Load in cache array list of workstations If fk_product is not 0, we do not use cache.
 
 selectWarehouses ($selected='', $htmlname='idwarehouse', $filterstatus='', $empty=0, $disabled=0, $fk_product=0, $empty_label='', $showstock=0, $forcecombo=0, $events=array(), $morecss='minwidth200', $exclude=array(), $showfullpath=1, $stockMin=false, $orderBy='e.ref', $multiselect=0)
 Return list of warehouses.
 
 selectWorkstations ($selected='', $htmlname='idworkstations', $empty=0, $disabled=0, $fk_product=0, $empty_label='', $forcecombo=0, $events=array(), $morecss='minwidth200', $exclude=array(), $showfullpath=1, $orderBy='e.ref')
 Return list of workstations.
 
 formSelectWarehouses ($page, $selected='', $htmlname='warehouse_id', $addempty=0)
 Display form to select warehouse.
 
 select_measuring_units ($name='measuring_units', $measuring_style='', $default='0', $adddefault=0, $mode=0)
 Output a combo box with list of units pour l'instant on ne definit pas les unites dans la base.
 
 selectMeasuringUnits ($name='measuring_units', $measuring_style='', $default='0', $adddefault=0, $mode=0, $morecss='maxwidth125')
 Return a combo box with list of units Units labels are defined in llx_c_units.
 
 selectProductNature ($name='finished', $selected='', $mode=0, $showempty=1)
 Return a combo box with list of units NAture of product labels are defined in llx_c_product_nature.
 
 selectLotStock ($selected='', $htmlname='batch_id', $filterstatus='', $empty=0, $disabled=0, $fk_product=0, $fk_entrepot=0, $objectLines=array(), $empty_label='', $forcecombo=0, $events=array(), $morecss='minwidth200')
 Return list of lot numbers (stock from product_batch) with stock location and stock qty.
 
 selectLotDataList ($htmlname='batch_id', $empty=0, $fk_product=0, $fk_entrepot=0, $objectLines=array())
 Return list of lot numbers (stock from product_batch) for product and warehouse.
 

Private Member Functions

 get_parent_path ($tab, $final_label='')
 Return full path to current warehouse in $tab (recursive function)
 
 loadLotStock ($productIdArray=array())
 Load in cache array list of lot available in stock from a given list of products.
 

Detailed Description

Class with static methods for building HTML components related to products Only components common to products and services must be here.

Definition at line 30 of file html.formproduct.class.php.

Constructor & Destructor Documentation

◆ __construct()

FormProduct::__construct ( $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 53 of file html.formproduct.class.php.

Member Function Documentation

◆ formSelectWarehouses()

FormProduct::formSelectWarehouses ( $page,
$selected = '',
$htmlname = 'warehouse_id',
$addempty = 0 )

Display form to select warehouse.

Parameters
string$pagePage
int$selectedId of warehouse
string$htmlnameName of select html field
int$addempty1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries.
Returns
void

Definition at line 499 of file html.formproduct.class.php.

References selectWarehouses().

◆ get_parent_path()

FormProduct::get_parent_path ( $tab,
$final_label = '' )
private

Return full path to current warehouse in $tab (recursive function)

Parameters
array$tabwarehouse data in $this->cache_warehouses line
String$final_labelfull label with all parents, separated by ' >> ' (completed on each call)
Returns
String full label with all parents, separated by ' >> '

Definition at line 241 of file html.formproduct.class.php.

References get_parent_path().

Referenced by get_parent_path(), and loadWarehouses().

◆ loadLotStock()

FormProduct::loadLotStock ( $productIdArray = array())
private

Load in cache array list of lot available in stock from a given list of products.

Parameters
array$productIdArrayarray of product id's from who to get lot numbers. A
Returns
int Nb of loaded lines, 0 if nothing loaded, <0 if KO

Definition at line 848 of file html.formproduct.class.php.

References dol_print_error(), dol_syslog(), and getEntity().

Referenced by selectLotDataList(), and selectLotStock().

◆ loadWarehouses()

FormProduct::loadWarehouses ( $fk_product = 0,
$batch = '',
$status = '',
$sumStock = true,
$exclude = array(),
$stockMin = false,
$orderBy = 'e.ref' )

Load in cache array list of warehouses If fk_product is not 0, we do not use cache.

Parameters
int$fk_productAdd quantity of stock in label for product with id fk_product. Nothing if 0.
string$batchAdd quantity of batch stock in label for product with batch name batch, batch name precedes batch_id. Nothing if ''.
string$statuswarehouse status filter, following comma separated filter options can be used 'warehouseopen' = select products from open warehouses, 'warehouseclosed' = select products from closed warehouses, 'warehouseinternal' = select products from warehouses for internal correct/transfer only
boolean$sumStocksum total stock of a warehouse, default true
array$excludewarehouses ids to exclude
bool | int$stockMin[=false] Value of minimum stock to filter or false not not filter by minimum stock
string$orderBy[='e.ref'] Order by
Returns
int Nb of loaded lines, 0 if already loaded, <0 if KO
Exceptions
Exception

Definition at line 76 of file html.formproduct.class.php.

References dol_print_error(), dol_syslog(), get_parent_path(), price2num(), Entrepot\STATUS_CLOSED, Entrepot\STATUS_OPEN_ALL, and Entrepot\STATUS_OPEN_INTERNAL.

Referenced by selectWarehouses().

◆ loadWorkstations()

FormProduct::loadWorkstations ( $fk_product = 0,
$exclude = array(),
$orderBy = 'w.ref' )

Load in cache array list of workstations If fk_product is not 0, we do not use cache.

Parameters
int$fk_productAdd quantity of stock in label for product with id fk_product. Nothing if 0.
array$excludewarehouses ids to exclude
string$orderBy[='e.ref'] Order by
Returns
int Nb of loaded lines, 0 if already loaded, <0 if KO
Exceptions
Exception

Definition at line 186 of file html.formproduct.class.php.

References dol_print_error(), and dol_syslog().

Referenced by selectWorkstations().

◆ select_measuring_units()

FormProduct::select_measuring_units ( $name = 'measuring_units',
$measuring_style = '',
$default = '0',
$adddefault = 0,
$mode = 0 )

Output a combo box with list of units pour l'instant on ne definit pas les unites dans la base.

Parameters
string$nameName of HTML field
string$measuring_styleUnit to show: weight, size, surface, volume, time
string$defaultPreselected value
int$adddefaultAdd empty unit called "Default"
int$mode1=Use short label as value, 0=Use rowid
Returns
void
Deprecated

Definition at line 537 of file html.formproduct.class.php.

References selectMeasuringUnits().

◆ selectLotDataList()

FormProduct::selectLotDataList ( $htmlname = 'batch_id',
$empty = 0,
$fk_product = 0,
$fk_entrepot = 0,
$objectLines = array() )

Return list of lot numbers (stock from product_batch) for product and warehouse.

Parameters
string$htmlnameName of key that is inside attribute "list" of an input text field.
int$empty1=Can be empty, 0 if not
int$fk_productshow lot numbers of product with id fk_product. All from objectLines if 0.
int$fk_entrepotfilter lot numbers for warehouse with id fk_entrepot. All if 0.
array$objectLinesOnly cache lot numbers for products in lines of object. If no lines only for fk_product. If no fk_product, all.
Returns
string HTML datalist

Definition at line 792 of file html.formproduct.class.php.

References dol_syslog(), and loadLotStock().

◆ selectLotStock()

FormProduct::selectLotStock ( $selected = '',
$htmlname = 'batch_id',
$filterstatus = '',
$empty = 0,
$disabled = 0,
$fk_product = 0,
$fk_entrepot = 0,
$objectLines = array(),
$empty_label = '',
$forcecombo = 0,
$events = array(),
$morecss = 'minwidth200' )

Return list of lot numbers (stock from product_batch) with stock location and stock qty.

Parameters
int$selectedId of preselected lot stock id ('' for no value, 'ifone'=select value if one value otherwise no value)
string$htmlnameName of html select html
string$filterstatuslot status filter, following comma separated filter options can be used
int$empty1=Can be empty, 0 if not
int$disabled1=Select is disabled
int$fk_productshow lot numbers of product with id fk_product. All from objectLines if 0.
int$fk_entrepotfilter lot numbers for warehouse with id fk_entrepot. All if 0.
array$objectLinesOnly cache lot numbers for products in lines of object. If no lines only for fk_product. If no fk_product, all.
string$empty_labelEmpty label if needed (only if $empty=1)
int$forcecombo1=Force combo iso ajax select2
array$eventsEvents to add to select2
string$morecssAdd more css classes to HTML select
Returns
string HTML select

Definition at line 709 of file html.formproduct.class.php.

References ajax_combobox(), dol_syslog(), and loadLotStock().

◆ selectMeasuringUnits()

FormProduct::selectMeasuringUnits ( $name = 'measuring_units',
$measuring_style = '',
$default = '0',
$adddefault = 0,
$mode = 0,
$morecss = 'maxwidth125' )

Return a combo box with list of units Units labels are defined in llx_c_units.

Parameters
string$nameName of HTML field
string$measuring_styleUnit to show: weight, size, surface, volume, time
string$defaultPreselected value
int | string$adddefault1=Add empty unit called "Default", ''=Add empty value
int$mode1=Use short label as value, 0=Use rowid, 2=Use scale (power)
string$morecssMore CSS
Returns
string

Definition at line 555 of file html.formproduct.class.php.

References ajax_combobox(), and dol_print_error().

Referenced by select_measuring_units().

◆ selectProductNature()

FormProduct::selectProductNature ( $name = 'finished',
$selected = '',
$mode = 0,
$showempty = 1 )

Return a combo box with list of units NAture of product labels are defined in llx_c_product_nature.

Parameters
string$nameName of HTML field
string$selectedPreselected value
int$mode1=Use label as value, 0=Use code
int$showempty1=show empty value, 0= no
Returns
string

Definition at line 632 of file html.formproduct.class.php.

References ajax_combobox(), and dol_print_error().

◆ selectWarehouses()

FormProduct::selectWarehouses ( $selected = '',
$htmlname = 'idwarehouse',
$filterstatus = '',
$empty = 0,
$disabled = 0,
$fk_product = 0,
$empty_label = '',
$showstock = 0,
$forcecombo = 0,
$events = array(),
$morecss = 'minwidth200',
$exclude = array(),
$showfullpath = 1,
$stockMin = false,
$orderBy = 'e.ref',
$multiselect = 0 )

Return list of warehouses.

Parameters
string | int | array$selectedId of preselected warehouse ('' or '-1' for no value, 'ifone' and 'ifonenodefault' = select value if one value otherwise no value, '-2' to use the default value from setup)
string$htmlnameName of html select html
string$filterstatuswarehouse status filter, following comma separated filter options can be used 'warehouseopen' = select products from open warehouses, 'warehouseclosed' = select products from closed warehouses, 'warehouseinternal' = select products from warehouses for internal correct/transfer only
int$empty1=Can be empty, 0 if not
int$disabled1=Select is disabled
int$fk_productAdd quantity of stock in label for product with id fk_product. Nothing if 0.
string$empty_labelEmpty label if needed (only if $empty=1)
int$showstock1=Show stock count
int$forcecombo1=Force combo iso ajax select2
array$eventsEvents to add to select2
string$morecssAdd more css classes to HTML select
array$excludeWarehouses ids to exclude
int$showfullpath1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse
bool | int$stockMin[=false] Value of minimum stock to filter or false not not filter by minimum stock
string$orderBy[='e.ref'] Order by
int$multiselect1=Allow multiselect
Returns
string HTML select
Exceptions
Exception

Definition at line 286 of file html.formproduct.class.php.

References ajax_combobox(), dol_syslog(), and loadWarehouses().

Referenced by formSelectWarehouses().

◆ selectWorkstations()

FormProduct::selectWorkstations ( $selected = '',
$htmlname = 'idworkstations',
$empty = 0,
$disabled = 0,
$fk_product = 0,
$empty_label = '',
$forcecombo = 0,
$events = array(),
$morecss = 'minwidth200',
$exclude = array(),
$showfullpath = 1,
$orderBy = 'e.ref' )

Return list of workstations.

Parameters
string | int$selectedId of preselected warehouse ('' or '-1' for no value, 'ifone' and 'ifonenodefault' = select value if one value otherwise no value, '-2' to use the default value from setup)
string$htmlnameName of html select html
int$empty1=Can be empty, 0 if not
int$disabled1=Select is disabled
int$fk_productAdd quantity of stock in label for product with id fk_product. Nothing if 0.
string$empty_labelEmpty label if needed (only if $empty=1)
int$forcecombo1=Force combo iso ajax select2
array$eventsEvents to add to select2
string$morecssAdd more css classes to HTML select
array$excludeWarehouses ids to exclude
int$showfullpath1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse
string$orderBy[='e.ref'] Order by
Returns
string HTML select
Exceptions
Exception

Definition at line 410 of file html.formproduct.class.php.

References ajax_combobox(), dol_syslog(), and loadWorkstations().


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