[*] Classes: Remove $fieldsRequired, $fieldsSize and $fieldsValidate (and lang properties) properties, use $definition instead

This commit is contained in:
rMalie
2011-12-12 18:10:38 +00:00
parent fddae46d56
commit 48baf36558
92 changed files with 1495 additions and 854 deletions
+18 -20
View File
@@ -59,34 +59,32 @@ class StockCore extends ObjectModel
/** @var int the unit price without tax forthe current product */
public $price_te;
protected $fieldsRequired = array(
'id_warehouse',
'id_product',
'id_product_attribute',
'physical_quantity',
'usable_quantity',
'price_te',
);
protected $fieldsSize = array();
protected $fieldsValidate = array(
'id_warehouse' => 'isUnsignedId',
'id_product' => 'isUnsignedId',
'id_product_attribute' => 'isUnsignedId',
'reference' => 'isReference',
'ean13' => 'isEan13',
'upc' => 'isUpc',
'physical_quantity' => 'isUnsignedInt',
'usable_quantity' => 'isInt',
'price_te' => 'isPrice',
);
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'stock',
'primary' => 'id_stock',
'fields' => array(
'id_warehouse' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_product_attribute' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'reference' => array('type' => 'FILL_ME', 'validate' => 'isReference'),
'ean13' => array('type' => 'FILL_ME', 'validate' => 'isEan13'),
'upc' => array('type' => 'FILL_ME', 'validate' => 'isUpc'),
'physical_quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true),
'usable_quantity' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true),
'price_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
),
);
public function getFields()
{
$this->validateFields();
+16 -17
View File
@@ -54,31 +54,30 @@ class StockAvailableCore extends ObjectModel
/** @var bool determine if a product is out of stock - it was previously in Product class */
public $out_of_stock = 0;
protected $fieldsRequired = array(
'id_product',
'id_product_attribute',
'quantity',
'depends_on_stock',
'out_of_stock'
);
protected $fieldsSize = array();
protected $fieldsValidate = array(
'id_product' => 'isUnsignedId',
'id_product_attribute' => 'isUnsignedId',
'id_shop' => 'isUnsignedId',
'id_group_shop' => 'isUnsignedId',
'quantity' => 'isInt',
'depends_on_stock' => 'isBool',
'out_of_stock' => 'isInt'
);
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'stock_available',
'primary' => 'id_stock_available',
'fields' => array(
'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_product_attribute' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
'id_group_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
'quantity' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true),
'depends_on_stock' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true),
'out_of_stock' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true),
),
);
public function getFields()
{
$this->validateFields();
+22 -25
View File
@@ -122,37 +122,34 @@ class StockMvtCore extends ObjectModel
*/
public $quantity;
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'stock_mvt',
'primary' => 'id_stock_mvt',
'fields' => array(
'date_add' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true),
'id_employee' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'employee_firstname' => array('type' => 'FILL_ME', 'validate' => 'isName'),
'employee_lastname' => array('type' => 'FILL_ME', 'validate' => 'isName'),
'id_stock' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'physical_quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true),
'id_stock_mvt_reason' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
'id_supply_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
'sign' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true),
'last_wa' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'current_wa' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'price_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'referer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
),
);
protected $fieldsRequired = array(
'date_add',
'id_employee',
'id_stock',
'physical_quantity',
'id_stock_mvt_reason',
'sign',
'price_te'
);
protected $fieldsValidate = array(
'date_add' => 'isDate',
'id_employee' => 'isUnsignedId',
'employee_firstname' => 'isName',
'employee_lastname' => 'isName',
'id_stock' => 'isUnsignedId',
'physical_quantity' => 'isUnsignedInt',
'id_stock_mvt_reason' => 'isUnsignedId',
'id_order' => 'isUnsignedId',
'id_supply_order' => 'isUnsignedId',
'sign' => 'isInt',
'last_wa' => 'isPrice',
'current_wa' => 'isPrice',
'price_te' => 'isPrice',
'referer' => 'isUnsignedId'
);
protected $webserviceParameters = array(
'objectsNodeName' => 'stock_movements',
+10 -3
View File
@@ -45,15 +45,22 @@ class StockMvtReasonCore extends ObjectModel
/** @var boolean True if the movement reason has been deleted (staying in database as deleted) */
public $deleted = 0;
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'stock_mvt_reason',
'primary' => 'id_stock_mvt_reason',
'multilang' => true,
'fields' => array(
'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255),
),
);
protected $fieldsRequiredLang = array('name');
protected $fieldsSizeLang = array('name' => 255);
protected $fieldsValidateLang = array('name' => 'isGenericName');
protected $webserviceParameters = array(
'objectsNodeName' => 'stock_movement_reasons',
+28 -34
View File
@@ -120,49 +120,43 @@ class SupplyOrderCore extends ObjectModel
*/
public $is_template = 0;
protected $fieldsRequired = array(
'id_supplier',
'supplier_name',
'id_lang',
'id_warehouse',
'id_supply_order_state',
'id_currency',
'id_ref_currency',
'reference',
'discount_rate',
'date_delivery_expected'
);
protected $fieldsValidate = array(
'id_supplier' => 'isUnsignedId',
'supplier_name' => 'isCatalogName',
'id_lang' => 'isUnsignedId',
'id_warehouse' => 'isUnsignedId',
'id_supply_order_state' => 'isUnsignedId',
'id_currency' => 'isUnsignedId',
'id_ref_currency' => 'isUnsignedId',
'reference' => 'isGenericName',
'date_add' => 'isDate',
'date_upd' => 'isDate',
'date_delivery_expected' => 'isDate',
'total_te' => 'isPrice',
'total_with_discount_te' => 'isPrice',
'total_ti' => 'isPrice',
'total_tax' => 'isPrice',
'discount_rate' => 'isFloat',
'discount_value_te' => 'isPrice',
'is_template' => 'isBool',
);
/**
* @var array Contains object definition
* @see ObjectModel::definition
*/
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'supply_order',
'primary' => 'id_supply_order',
'table' => 'supply_order',
'primary' => 'id_supply_order',
'fields' => array(
'id_supplier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'supplier_name' => array('type' => 'FILL_ME', 'validate' => 'isCatalogName', 'required' => true),
'id_lang' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_warehouse' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_supply_order_state' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_ref_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'reference' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true),
'date_add' => array('type' => 'FILL_ME', 'validate' => 'isDate'),
'date_upd' => array('type' => 'FILL_ME', 'validate' => 'isDate'),
'date_delivery_expected' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true),
'total_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_with_discount_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_ti' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_tax' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'discount_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true),
'discount_value_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'is_template' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
),
);
public function getFields()
{
$this->validateFields();
+30 -43
View File
@@ -142,56 +142,43 @@ class SupplyOrderDetailCore extends ObjectModel
*/
public $price_with_order_discount_te = 0;
protected $fieldsRequired = array(
'id_supply_order',
'id_product',
'id_product_attribute',
'name',
'id_currency',
'exchange_rate',
'unit_price_te',
'quantity_expected',
'price_te',
'discount_rate',
'discount_value_te',
'price_with_discount_te',
'tax_rate',
'tax_value',
'price_ti',
'tax_value_with_order_discount',
'price_with_order_discount_te'
);
protected $fieldsValidate = array(
'id_supply_order' => 'isUnsignedId',
'id_product' => 'isUnsignedId',
'id_product_attribute' => 'isUnsignedId',
'reference' => 'isReference',
'supplier_reference' => 'isReference',
'name' => 'isGenericName',
'ean13' => 'isEan13',
'upc' => 'isUpc',
'id_currency' => 'isUnsignedId',
'exchange_rate' => 'isFloat',
'unit_price_te' => 'isPrice',
'quantity_expected' => 'isUnsignedInt',
'quantity_received' => 'isUnsignedInt',
'price_te' => 'isPrice',
'discount_rate' => 'isFloat',
'discount_value_te' => 'isPrice',
'price_with_discount_te' => 'isPrice',
'tax_rate' => 'isFloat',
'tax_value' => 'isPrice',
'price_ti' => 'isPrice',
'tax_value_with_order_discount' => 'isFloat',
'price_with_order_discount_te' => 'isPrice',
);
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'supply_order_detail',
'primary' => 'id_supply_order_detail',
'fields' => array(
'id_supply_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_product_attribute' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'reference' => array('type' => 'FILL_ME', 'validate' => 'isReference'),
'supplier_reference' => array('type' => 'FILL_ME', 'validate' => 'isReference'),
'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true),
'ean13' => array('type' => 'FILL_ME', 'validate' => 'isEan13'),
'upc' => array('type' => 'FILL_ME', 'validate' => 'isUpc'),
'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'exchange_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true),
'unit_price_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'quantity_expected' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true),
'quantity_received' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'),
'price_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'discount_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true),
'discount_value_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'price_with_discount_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'tax_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true),
'tax_value' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'price_ti' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'tax_value_with_order_discount' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true),
'price_with_order_discount_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
),
);
/**
* @see ObjectModel::getFields()
*/
+14 -14
View File
@@ -60,27 +60,27 @@ class SupplyOrderHistoryCore extends ObjectModel
*/
public $date_add;
protected $fieldsRequired = array(
'id_supply_order',
'id_employee',
'id_state',
'date_add'
);
protected $fieldsValidate = array(
'id_supply_order' => 'isUnsignedId',
'id_employee' => 'isUnsignedId',
'employee_firstname' => 'isName',
'employee_lastname' => 'isName',
'id_state' => 'isUnsignedId',
'date_add' => 'isDate'
);
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'supply_order_history',
'primary' => 'id_supply_order_history',
'fields' => array(
'id_supply_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_employee' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'employee_firstname' => array('type' => 'FILL_ME', 'validate' => 'isName'),
'employee_lastname' => array('type' => 'FILL_ME', 'validate' => 'isName'),
'id_state' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'date_add' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true),
),
);
public function getFields()
{
$this->validateFields();
+15 -15
View File
@@ -65,28 +65,28 @@ class SupplyOrderReceiptHistoryCore extends ObjectModel
*/
public $date_add;
protected $fieldsRequired = array(
'id_supply_order_detail',
'id_supply_order_state',
'id_employee',
'quantity'
);
protected $fieldsValidate = array(
'id_supply_order_detail' => 'isUnsignedId',
'id_supply_order_state' => 'isUnsignedId',
'id_employee' => 'isUnsignedId',
'employee_firstname' => 'isName',
'employee_lastname' => 'isName',
'quantity' => 'isUnsignedInt',
'date_add' => 'isDate'
);
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'supply_order_receipt_history',
'primary' => 'id_supply_order_receipt_history',
'fields' => array(
'id_supply_order_detail' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_supply_order_state' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_employee' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'employee_firstname' => array('type' => 'FILL_ME', 'validate' => 'isName'),
'employee_lastname' => array('type' => 'FILL_ME', 'validate' => 'isName'),
'quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true),
'date_add' => array('type' => 'FILL_ME', 'validate' => 'isDate'),
),
);
public function getFields()
{
$this->validateFields();
+17 -11
View File
@@ -65,25 +65,31 @@ class SupplyOrderStateCore extends ObjectModel
*/
public $color;
protected $fieldsValidate = array(
'delivery_note' => 'isBool',
'editable' => 'isBool',
'receipt_state' => 'isBool',
'pending_receipt' => 'isBool',
'enclosed' => 'isBool',
'color' => 'isColor'
);
protected $fieldsRequiredLang = array('name');
protected $fieldsSizeLang = array('name' => 128);
protected $fieldsValidateLang = array('name' => 'isGenericName');
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'supply_order_state',
'primary' => 'id_supply_order_state',
'multilang' => true,
'fields' => array(
'delivery_note' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
'editable' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
'receipt_state' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
'pending_receipt' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
'enclosed' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
'color' => array('type' => 'FILL_ME', 'validate' => 'isColor'),
'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
),
);
/**
* @see ObjectModel::getFields()
*/
+16 -21
View File
@@ -59,35 +59,30 @@ class WarehouseCore extends ObjectModel
*/
public $management_type;
protected $fieldsRequired = array(
'id_address',
'reference',
'name',
'id_employee',
'management_type',
'id_currency'
);
protected $fieldsSize = array(
'stock_management' => 32,
'reference' => 45,
'name' => 45
);
protected $fieldsValidate = array(
'id_address' => 'isUnsignedId',
'reference' => 'isString',
'name' => 'isName',
'id_employee' => 'isUnsignedId',
'management_type' => 'isStockManagement', /* @see Validate::isStockManagement() */
'id_currency' => 'isUnsignedId'
);
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'warehouse',
'primary' => 'id_warehouse',
'fields' => array(
'id_address' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'reference' => array('type' => 'FILL_ME', 'validate' => 'isString', 'required' => true, 'size' => 45),
'name' => array('type' => 'FILL_ME', 'validate' => 'isName', 'required' => true, 'size' => 45),
'id_employee' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'management_type' => array('type' => 'FILL_ME', 'validate' => 'isStockManagement', 'required' => true),
'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'stock_management' => array('type' => 'FILL_ME', 'size' => 32),
),
);
public function getFields()
{
$this->validateFields();
+13 -8
View File
@@ -49,20 +49,25 @@ class WarehouseProductLocationCore extends ObjectModel
* */
public $location;
protected $fieldsRequired = array('id_product', 'id_product_attribute', 'id_warehouse');
protected $fieldsSize = array('location' => 64);
protected $fieldsValidate = array(
'location' => 'isReference',
'id_product' => 'isUnsignedId',
'id_product_attribute' => 'isUnsignedId',
'id_warehouse' => 'isUnsignedId',
);
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'warehouse_product_location',
'primary' => 'id_warehouse_product_location',
'fields' => array(
'location' => array('type' => 'FILL_ME', 'validate' => 'isReference', 'size' => 64),
'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_product_attribute' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_warehouse' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
),
);
public function getFields()
{
$this->validateFields();