From a08b09aef2ee2547cc677951e694cb6c41e7357e Mon Sep 17 00:00:00 2001 From: bMancone Date: Wed, 26 Oct 2011 16:24:36 +0000 Subject: [PATCH] // Stock : added supplier order classes --- classes/stock/SupplierOrder.php | 176 +++++++++++++++++ classes/stock/SupplierOrderDetail.php | 186 ++++++++++++++++++ classes/stock/SupplierOrderHistory.php | 88 +++++++++ classes/stock/SupplierOrderReceiptHistory.php | 96 +++++++++ classes/stock/SupplierOrderState.php | 88 +++++++++ 5 files changed, 634 insertions(+) create mode 100755 classes/stock/SupplierOrder.php create mode 100755 classes/stock/SupplierOrderDetail.php create mode 100755 classes/stock/SupplierOrderHistory.php create mode 100755 classes/stock/SupplierOrderReceiptHistory.php create mode 100755 classes/stock/SupplierOrderState.php diff --git a/classes/stock/SupplierOrder.php b/classes/stock/SupplierOrder.php new file mode 100755 index 000000000..932102d07 --- /dev/null +++ b/classes/stock/SupplierOrder.php @@ -0,0 +1,176 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +/** + * @since 1.5.0 + */ +class SupplierOrderCore extends ObjectModel +{ + /** + * @var int Supplier + */ + public $id_supplier; + + /** + * @var int Employee who initiated the order + */ + public $id_employee; + + /** + * @var int Warehouse where products will be delivered + */ + public $id_warehouse; + + /** + * @var int State of the order + */ + public $id_state; + + /** + * @var int Currency used for the order + */ + public $id_currency; + + /** + * @var int Currency used by default in main global configuration (i.e. by default for all shops) + */ + public $id_ref_currency; + + /** + * @var string Reference of the order + */ + public $reference; + + /** + * @var string Date when added + */ + public $date_add; + + /** + * @var string Date when updated + */ + public $date_upd; + + /** + * @var string Expected delivery date + */ + public $date_delivery_expected; + + /** + * @var float Total price without tax + */ + public $total_te; + + /** + * @var float Total price after discount, without tax + */ + public $total_with_discount_te; + + /** + * @var float Total price with tax + */ + public $total_ti; + + /** + * @var float Supplier discount rate (for the whole order) + */ + public $discount_rate; + + /** + * @var float Supplier discount value without tax (for the whole order) + */ + public $discount_value_te; + + protected $fieldsRequired = array( + 'id_supplier', + 'id_employee', + 'id_warehouse', + 'id_state', + 'id_currency', + 'id_ref_currency', + 'reference', + 'date_add', + 'date_upd', + 'date_delivery_expected', + 'total_te', + 'total_with_discount_te', + 'total_ti', + 'discount_rate', + 'discount_value_te' + ); + + protected $fieldsValidate = array( + 'id_supplier' => 'isUnsignedId', + 'id_employee' => 'isUnsignedId', + 'id_warehouse' => 'isUnsignedId', + 'id_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', + 'discount_rate' => 'isFloat', + 'discount_value_te' => 'isPrice' + ); + + /** + * @var string Database table name + */ + protected $table = 'supplier_order'; + + /** + * @var string Database ID name + */ + protected $identifier = 'id_supplier_order'; + + public function getFields() + { + $this->validateFields(); + + $fields['id_supplier'] = (int)$this->id_supplier; + $fields['id_employee'] = (int)$this->id_employee; + $fields['id_warehouse'] = (int)$this->id_warehouse; + $fields['id_state'] = (int)$this->id_state; + $fields['id_currency'] = (int)$this->id_currency; + $fields['id_ref_currency'] = (int)$this->id_ref_currency; + $fields['reference'] = pSQL($this->reference); + $fields['date_add'] = pSQL($this->date_add); + $fields['date_upd'] = pSQL($this->date_upd); + $fields['date_delivery_expected'] = pSQL($this->delivery_date_expected); + $fields['total_te'] = (float)$this->total_te; + $fields['total_with_discount_te'] = (float)$this->total_with_discount_te; + $fields['total_ti'] = (float)$this->total_ti; + $fields['discount_rate'] = (float)$this->order_discount_rate; + $fields['discount_value'] = (float)$this->order_discount_value; + + return $fields; + } +} \ No newline at end of file diff --git a/classes/stock/SupplierOrderDetail.php b/classes/stock/SupplierOrderDetail.php new file mode 100755 index 000000000..69ba74c4f --- /dev/null +++ b/classes/stock/SupplierOrderDetail.php @@ -0,0 +1,186 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +/** + * @since 1.5.0 + */ +class SupplierOrderDetailCore extends ObjectModel +{ + /** + * @var int Supplier order + */ + public $id_supplier_order; + + /** + * @var int Product ordered + */ + public $id_product; + + /** + * @var int Product attribute ordered + */ + public $id_product_attribute; + + /** + * @var int Currency used to buy this particular product + */ + public $id_currency; + + /** + * @var float Exchange rate between $id_currency and SupplierOrder::$id_ref_currency, at the time + */ + public $exchange_rate; + + /** + * @var float Unit price without discount, without tax + */ + public $unit_price_te; + + /** + * @var int Quantity ordered + */ + public $quantity; + + /** + * @var float This defines the price of the product, considering the number of units to buy. + * ($unit_price_te * $quantity), without discount, without tax + */ + public $price_te; + + /** + * @var float Supplier discount rate for a given product + */ + public $discount_rate; + + /** + * @var float Supplier discount value (($discount_rate / 100) * $price_te), without tax + */ + public $discount_value_te; + + /** + * @var float ($price_te - $discount_value_te), with discount, without tax + */ + public $price_with_discount_te; + + /** + * @var int Tax rate for the given product + */ + public $tax_rate; + + /** + * @var float Tax value for the given product + */ + public $tax_value; + + /** + * @var float ($price_with_discount_te + $tax_value) + */ + public $price_ti; + + /** + * @var float Tax value of the given product after applying the global order discount (i.e. if SupplierOrder::discount_rate is set) + */ + public $tax_value_with_order_discount; + + /** + * @var float This is like $price_with_discount_te, considering the global order discount. + * (i.e. if SupplierOrder::discount_rate is set) + */ + public $price_with_order_discount_te; + + protected $fieldsRequired = array( + 'id_supplier_order', + 'id_product', + 'id_product_attribute', + 'id_currency', + 'excange_rate', + 'unit_price_te', + 'quantity', + '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_supplier_order' => 'isUnsignedId', + 'id_product' => 'isUnsignedId', + 'id_product_attribute' => 'isUnsignedId', + 'id_currency' => 'isUnsignedId', + 'exchange_rate' => 'isFloat', + 'unit_price_te' => 'isPrice', + 'quantity' => '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', + ); + + /** + * @var string Database table name + */ + protected $table = 'supplier_order_detail'; + + /** + * @var string Database ID name + */ + protected $identifier = 'id_supplier_order_detail'; + + public function getFields() + { + $this->validateFields(); + + $fields['id_supplier_order'] = (int)$this->id_supplier; + $fields['id_product'] = (int)$this->id_employee; + $fields['id_product_attribute'] = (int)$this->id_warehouse; + $fields['id_currency'] = (int)$this->id_currency; + $fields['exchange_rate'] = (float)$this->exchange_rate; + $fields['unit_price_te'] = (float)$this->unit_price_te; + $fields['quantity'] = (int)$this->id_state; + $fields['price_te'] = (float)$this->price_te; + $fields['discount_rate'] = (float)$this->discount_rate; + $fields['discount_value_te'] = (float)$this->discount_value_te; + $fields['price_with_discount_te'] = (float)$this->price_with_discount_te; + $fields['tax_rate'] = (float)$this->tax_rate; + $fields['tax_value'] = (float)$this->tax_value; + $fields['price_ti'] = (float)$this->price_ti; + $fields['tax_value_with_order_discount'] = (float)$this->tax_value_with_order_discount; + $fields['price_with_order_discount_te'] = (float)$this->price_with_order_discount_te; + + return $fields; + } +} \ No newline at end of file diff --git a/classes/stock/SupplierOrderHistory.php b/classes/stock/SupplierOrderHistory.php new file mode 100755 index 000000000..977deb064 --- /dev/null +++ b/classes/stock/SupplierOrderHistory.php @@ -0,0 +1,88 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +/** + * @since 1.5.0 + */ +class SupplierOrderHistoryCore extends ObjectModel +{ + /** + * @var int Supplier order + */ + public $id_supplier_order; + + /** + * @var int Employee + */ + public $id_employee; + + /** + * @var int State + */ + public $id_state; + + /** + * @var string Date + */ + public $date_add; + + protected $fieldsRequired = array( + 'id_supplier_order', + 'id_employee', + 'id_state', + 'date_add' + ); + + protected $fieldsValidate = array( + 'id_supplier_order' => 'isUnsignedId', + 'id_employee' => 'isUnsignedId', + 'id_state' => 'isUnsignedId', + 'date_add' => 'isDate' + ); + + /** + * @var string Database table name + */ + protected $table = 'supplier_order_history'; + + /** + * @var string Database ID name + */ + protected $identifier = 'id_supplier_order_history'; + + public function getFields() + { + $this->validateFields(); + + $fields['id_supplier_order'] = (int)$this->id_supplier_order; + $fields['id_employee'] = (int)$this->id_employee; + $fields['id_state'] = (int)$this->id_state; + $fields['date_add'] = pSQL($this->date_add); + + return $fields; + } +} \ No newline at end of file diff --git a/classes/stock/SupplierOrderReceiptHistory.php b/classes/stock/SupplierOrderReceiptHistory.php new file mode 100755 index 000000000..4090b265b --- /dev/null +++ b/classes/stock/SupplierOrderReceiptHistory.php @@ -0,0 +1,96 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +/** + * @since 1.5.0 + */ +class SupplierOrderReceiptHistoryCore extends ObjectModel +{ + /** + * @var int Detail of the supplier order + */ + public $id_supplier_order_detail; + + /** + * @var int Employee + */ + public $id_employee; + + /** + * @var int State + */ + public $id_state; + + /** + * @var int Quantity delivered + */ + public $quantity; + + /** + * @var string Date of delivery + */ + public $date_add; + + protected $fieldsRequired = array( + 'id_supplier_order_detail', + 'id_state', + 'id_employee', + 'quantity', + 'date_add' + ); + + protected $fieldsValidate = array( + 'id_supplier_order_detail' => 'isUnsignedId', + 'id_state' => 'isUnsignedId', + 'id_employee' => 'isUnsignedId', + 'quantity' => 'isUnsignedInt', + 'date_add' => 'isDate' + ); + + /** + * @var string Database table name + */ + protected $table = 'supplier_order_receipt_history'; + + /** + * @var string Database ID name + */ + protected $identifier = 'id_supplier_order_receipt_history'; + + public function getFields() + { + $this->validateFields(); + + $fields['id_supplier_order_detail'] = (int)$this->id_supplier_order_detail; + $fields['id_state'] = (int)$this->id_state; + $fields['id_employee'] = (int)$this->id_employee; + $fields['quantity'] = (int)$this->quantity; + $fields['date_add'] = pSQL($this->date_add); + + return $fields; + } +} \ No newline at end of file diff --git a/classes/stock/SupplierOrderState.php b/classes/stock/SupplierOrderState.php new file mode 100755 index 000000000..410e78626 --- /dev/null +++ b/classes/stock/SupplierOrderState.php @@ -0,0 +1,88 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +/** + * @since 1.5.0 + */ +class SupplierOrderStateCore extends ObjectModel +{ + /** + * @var string Name of the state + */ + public $name; + + /** + * @var bool Tells if a delivery note can be issued (i.e. the order has been validated) + */ + public $delivery_note; + + /** + * @var bool Tells if the order is still editable by an employee + */ + public $editable; + + /** + * @var bool Tells if the the order has been delivered + */ + public $receipt_state; + + protected $fieldsValidate = array( + 'delivery_note' => 'isBool', + 'editable' => 'isBool', + 'receipt_state' => 'isBool' + ); + + protected $fieldsRequiredLang = array('name'); + protected $fieldsSizeLang = array('name' => 128); + protected $fieldsValidateLang = array('name' => 'isGenericName'); + + /** + * @var string Database table name + */ + protected $table = 'supplier_order_state'; + + /** + * @var string Database ID name + */ + protected $identifier = 'id_supplier_order_state'; + + public function getFields() + { + $this->validateFields(); + $fields['delivery_note'] = (int)$this->delivery_note; + $fields['editable'] = (int)$this->editable; + $fields['receipt_state'] = (int)$this->receipt_state; + + return $fields; + } + + public function getTranslationsFieldsChild() + { + $this->validateFieldsLang(); + return $this->getTranslationsFields(array('name')); + } +} \ No newline at end of file