Skip to content

Latest commit

 

History

History
1681 lines (860 loc) · 39.4 KB

class.WarehouseCore.md

File metadata and controls

1681 lines (860 loc) · 39.4 KB

Class WarehouseCore

Holds Stock

Contents

Properties

Methods

Properties

$definition

public mixed $definition = array('table' => 'warehouse', 'primary' => 'id_warehouse', 'fields' => array('id_address' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'reference' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 45), 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 45), 'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'management_type' => array('type' => self::TYPE_STRING, 'validate' => 'isStockManagement', 'required' => true), 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'deleted' => array('type' => self::TYPE_BOOL)))

$deleted

public boolean $deleted

$id

public integer $id

$id_address

public integer $id_address

$id_currency

public integer $id_currency

$id_employee

public integer $id_employee

$management_type

public \enum $management_type

Describes the way a Warehouse is managed

$name

public string $name

$reference

public string $reference

$webserviceParameters

protected mixed $webserviceParameters = array('fields' => array('id_address' => array('xlink_resource' => 'addresses'), 'id_employee' => array('xlink_resource' => 'employees'), 'id_currency' => array('xlink_resource' => 'currencies'), 'valuation' => array('getter' => 'getWsStockValue', 'setter' => false), 'deleted' => array()), 'associations' => array('stocks' => array('resource' => 'stock', 'fields' => array('id' => array())), 'carriers' => array('resource' => 'carrier', 'fields' => array('id' => array())), 'shops' => array('resource' => 'shop', 'fields' => array('id' => array(), 'name' => array()))))

$def

protected array $def

$fieldsRequired

protected mixed $fieldsRequired = array()

$fieldsRequiredDatabase

protected mixed $fieldsRequiredDatabase = null

$fieldsRequiredLang

protected mixed $fieldsRequiredLang = array()

$fieldsSize

protected mixed $fieldsSize = array()

$fieldsSizeLang

protected mixed $fieldsSizeLang = array()

$fieldsValidate

protected mixed $fieldsValidate = array()

$fieldsValidateLang

protected mixed $fieldsValidateLang = array()

$id_lang

protected integer $id_lang = null

$id_shop

protected mixed $id_shop = null

$identifier

protected mixed $identifier

$image_dir

protected string $image_dir = null

$image_format

protected string $image_format = 'jpg'

$table

protected mixed $table

$tables

protected mixed $tables = array()

Methods

__construct

mixed ObjectModelCore::__construct(integer $id, integer $id_lang, integer $id_shop)

Build object

Arguments

  • $id integer - Existing object id in order to load object (optional)
  • $id_lang integer - Required if object is multilingual (optional)
  • $id_shop integer - ID shop for objects with multishop on langs

add

boolean ObjectModelCore::add(boolean $autodate, boolean $null_values)

Add current object to database

Arguments

  • $autodate boolean
  • $null_values boolean

addFieldsRequiredDatabase

mixed ObjectModelCore::addFieldsRequiredDatabase($fields)

Arguments

  • $fields mixed

associateTo

boolean ObjectModelCore::associateTo(integer|array $id_shops, string $type)

This function associate an item to its context

Arguments

  • $id_shops integer|array
  • $type string

clearCache

mixed ObjectModelCore::clearCache($all)

Arguments

  • $all mixed

delete

boolean ObjectModelCore::delete()

Delete current object from database

deleteImage

boolean ObjectModelCore::deleteImage()

Delete images associated with the object

deleteSelection

boolean ObjectModelCore::deleteSelection(array $selection)

Delete several objects from database

Arguments

  • $selection array

displayFieldName

mixed ObjectModelCore::displayFieldName($field, $className, $htmlentities, \Context $context)

Arguments

  • $field mixed
  • $className mixed
  • $htmlentities mixed
  • $context Context

duplicateShops

mixed ObjectModelCore::duplicateShops($id)

Arguments

  • $id mixed

exists

boolean WarehouseCore::exists(integer $id_warehouse)

Checks if the given warehouse exists

Arguments

  • $id_warehouse integer

existsInDatabase

boolean ObjectModelCore::existsInDatabase(integer $id_entity, string $table)

Specify if an ObjectModel is already in database

Arguments

  • $id_entity integer
  • $table string

formatFields

array ObjectModelCore::formatFields(integer $id_lang)

Arguments

  • $id_lang integer - If this parameter is given, only take lang fields

formatValue

mixed ObjectModelCore::formatValue(mixed $value, integer $type, $with_quotes)

Format a data

Arguments

  • $value mixed
  • $type integer
  • $with_quotes mixed

getCarriers

array WarehouseCore::getCarriers()

Gets the carriers associated to the current warehouse

getDefinition

mixed ObjectModelCore::getDefinition($class, $field)

Arguments

  • $class mixed
  • $field mixed

getEntity

mixed ObjectModelCore::getEntity($entity)

Arguments

  • $entity mixed

getFields

array ObjectModelCore::getFields()

Prepare fields for ObjectModel class (add, update) All fields are verified (pSQL, intval.

..)

getFieldsLang

array ObjectModelCore::getFieldsLang()

Prepare multilang fields

getFieldsRequiredDatabase

mixed ObjectModelCore::getFieldsRequiredDatabase($all)

Arguments

  • $all mixed

getNumberOfProducts

integer WarehouseCore::getNumberOfProducts()

Gets the number of products in the current warehouse

getProductLocation

string WarehouseCore::getProductLocation(integer $id_product, integer $id_product_attribute, integer $id_warehouse)

For a given {product, product attribute} gets its location in the given warehouse

Arguments

  • $id_product integer
  • $id_product_attribute integer
  • $id_warehouse integer

getProductWarehouseList

array WarehouseCore::getProductWarehouseList(integer $id_product, integer $id_product_attribute, integer $id_shop)

For a given {product, product attribute} gets warehouse list

Arguments

  • $id_product integer
  • $id_product_attribute integer
  • $id_shop integer

getQuantitiesOfProducts

integer WarehouseCore::getQuantitiesOfProducts()

Gets the number of quantities - for all products - in the current warehouse

getShops

array WarehouseCore::getShops()

Gets the shops (id and name) associated to the current warehouse

getStockValue

integer WarehouseCore::getStockValue()

Gets the value of the stock in the current warehouse

getTranslationsFields

mixed ObjectModelCore::getTranslationsFields($fieldsArray)

Arguments

  • $fieldsArray mixed

getValidationRules

array ObjectModelCore::getValidationRules(string $className)

Returns object validation rules (fields validity)

Arguments

  • $className string - Child class name for static use (optional)

getWarehouseNameById

string WarehouseCore::getWarehouseNameById(integer $id_warehouse)

For a given $id_warehouse, returns its name

Arguments

  • $id_warehouse integer

getWarehouses

array WarehouseCore::getWarehouses(boolean $ignore_shop, integer $id_shop)

Gets available warehouses It is possible via ignore_shop and id_shop to filter the list with shop id

Arguments

  • $ignore_shop boolean - false by default
  • $id_shop integer - null by default

getWarehousesByEmployee

array WarehouseCore::getWarehousesByEmployee(integer $id_employee)

For a given employee, gets the warehouse(s) he manages

Arguments

  • $id_employee integer

getWarehousesByProductId

array WarehouseCore::getWarehousesByProductId(integer $id_product, integer $id_product_attribute)

For a given product, returns the warehouses it is stored in

Arguments

  • $id_product integer
  • $id_product_attribute integer

getWarehousesGroupedByShops

array WarehouseCore::getWarehousesGroupedByShops()

Gets ids of warehouses, grouped by ids of shops

getWebserviceObjectList

mixed ObjectModelCore::getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit)

Arguments

  • $sql_join mixed
  • $sql_filter mixed
  • $sql_sort mixed
  • $sql_limit mixed

getWebserviceParameters

mixed ObjectModelCore::getWebserviceParameters($wsParamsAttributeName)

Arguments

  • $wsParamsAttributeName mixed

getWsCarriers

array WarehouseCore::getWsCarriers()

Webservice : gets the ids carriers associated to this warehouse

getWsShops

array WarehouseCore::getWsShops()

Webservice : gets the ids shops associated to this warehouse

getWsStockValue

integer WarehouseCore::getWsStockValue()

Webservice : gets the value of the warehouse

getWsStocks

array WarehouseCore::getWsStocks()

Webservice : gets the ids stock associated to this warehouse

hydrate

mixed ObjectModelCore::hydrate(array $data, integer $id_lang)

Fill an object with given data. Data must be an array with this syntax: array(objProperty => value, objProperty2 => value, etc.)

Arguments

  • $data array
  • $id_lang integer

hydrateCollection

array ObjectModelCore::hydrateCollection(string $class, array $datas, integer $id_lang)

Fill (hydrate) a list of objects in order to get a collection of these objects

Arguments

  • $class string - Class of objects to hydrate
  • $datas array - List of data (multi-dimensional array)
  • $id_lang integer

isAssociatedToGroupShop

boolean ObjectModelCore::isAssociatedToGroupShop(integer $id_group_shop)

Check if current object is associated to a group shop

Arguments

  • $id_group_shop integer

isAssociatedToShop

boolean ObjectModelCore::isAssociatedToShop(integer $id_shop)

Check if current object is associated to a shop

Arguments

  • $id_shop integer

isCurrentlyUsed

boolean ObjectModelCore::isCurrentlyUsed(string $table, boolean $has_active_column)

This method is allow to know if a entity is currently used

Arguments

  • $table string - name of table linked to entity
  • $has_active_column boolean - true if the table has an active column

isEmpty

boolean WarehouseCore::isEmpty()

Checks if a warehouse is empty - i.e. holds no stock

isLangMultishop

mixed ObjectModelCore::isLangMultishop()

makeTranslationFields

mixed ObjectModelCore::makeTranslationFields($fields, $fieldsArray, $id_language)

Arguments

  • $fields mixed
  • $fieldsArray mixed
  • $id_language mixed

removeCarrier

mixed WarehouseCore::removeCarrier(integer $id_carrier, integer $id_warehouse)

For a given carrier, removes it from the warehouse/carrier association If $id_warehouse is set, it only removes the carrier for this warehouse

Arguments

  • $id_carrier integer
  • $id_warehouse integer - optional

resetProductsLocations

mixed WarehouseCore::resetProductsLocations()

Reset all product locations for this warehouse

save

boolean ObjectModelCore::save(boolean $null_values, boolean $autodate)

Save current object to database (add or update)

Arguments

  • $null_values boolean
  • $autodate boolean

setCarriers

mixed WarehouseCore::setCarriers(array $ids_carriers)

Sets the carriers associated to the current warehouse

Arguments

  • $ids_carriers array

setDefinitionRetrocompatibility

mixed ObjectModelCore::setDefinitionRetrocompatibility()

Retrocompatibility for classes without $definition static Remove this in 1.6 !

setProductLocation

boolean WarehouseCore::setProductLocation(integer $id_product, integer $id_product_attribute, integer $id_warehouse, string $location)

For a given {product, product attribute} sets its location in the given warehouse

Arguments

  • $id_product integer
  • $id_product_attribute integer
  • $id_warehouse integer
  • $location string

setShops

mixed WarehouseCore::setShops(array $ids_shop)

Sets the shops associated to the current warehouse

Arguments

  • $ids_shop array

toggleStatus

boolean ObjectModelCore::toggleStatus()

Toggle object status in database

update

boolean ObjectModelCore::update(boolean $null_values)

Update current object to database

Arguments

  • $null_values boolean

validateControler

mixed ObjectModelCore::validateControler($htmlentities)

TODO: refactor rename all calls to this to validateController

Arguments

  • $htmlentities mixed

validateController

mixed ObjectModelCore::validateController($htmlentities)

Arguments

  • $htmlentities mixed

validateField

boolean|string ObjectModelCore::validateField(string $field, mixed $value, integer $id_lang)

Validate a single field

Arguments

  • $field string - Field name
  • $value mixed - Field value
  • $id_lang integer

validateFields

boolean|string ObjectModelCore::validateFields(boolean $die, boolean $error_return)

Check for fields validity before database interaction

Arguments

  • $die boolean
  • $error_return boolean

validateFieldsLang

boolean|string ObjectModelCore::validateFieldsLang(boolean $die, boolean $error_return)

Check for multilingual fields validity before database interaction

Arguments

  • $die boolean
  • $error_return boolean