// Stock: WebServices
This commit is contained in:
+37
-20
@@ -76,7 +76,41 @@ class ProductSupplierCore extends ObjectModel
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For a given product and supplier, get the product reference
|
* @see ObjectModel::$webserviceParameters
|
||||||
|
*/
|
||||||
|
protected $webserviceParameters = array(
|
||||||
|
'objectsNodeName' => 'product_suppliers',
|
||||||
|
'objectNodeName' => 'product_supplier',
|
||||||
|
'fields' => array(
|
||||||
|
'id_product' => array('xlink_resource' => 'products'),
|
||||||
|
'id_product_attribute' => array('xlink_resource' => 'combinations'),
|
||||||
|
'id_supplier' => array('xlink_resource' => 'suppliers'),
|
||||||
|
'id_currency' => array('xlink_resource' => 'currencies'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ObjectModel::delete()
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$res = parent::delete();
|
||||||
|
|
||||||
|
if ($res && $this->id_product_attribute == 0)
|
||||||
|
{
|
||||||
|
$items = self::getSupplierCollection($this->id_product, false);
|
||||||
|
foreach ($items as $item)
|
||||||
|
{
|
||||||
|
if ($item->id_product_attribute > 0)
|
||||||
|
$item->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For a given product and supplier, gets the product supplier reference
|
||||||
*
|
*
|
||||||
* @param int $id_product
|
* @param int $id_product
|
||||||
* @param int $id_product_attribute
|
* @param int $id_product_attribute
|
||||||
@@ -98,7 +132,7 @@ class ProductSupplierCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For a given product and supplier, get the product unit price
|
* For a given product and supplier, gets the product supplier unit price
|
||||||
*
|
*
|
||||||
* @param int $id_product
|
* @param int $id_product
|
||||||
* @param int $id_product_attribute
|
* @param int $id_product_attribute
|
||||||
@@ -120,7 +154,7 @@ class ProductSupplierCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For a given product and supplier, get the ProductSupplier corresponding ID
|
* For a given product and supplier, gets corresponding ProductSupplier ID
|
||||||
*
|
*
|
||||||
* @param int $id_product
|
* @param int $id_product
|
||||||
* @param int $id_product_attribute
|
* @param int $id_product_attribute
|
||||||
@@ -159,23 +193,6 @@ class ProductSupplierCore extends ObjectModel
|
|||||||
return $suppliers;
|
return $suppliers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete()
|
|
||||||
{
|
|
||||||
$res = parent::delete();
|
|
||||||
|
|
||||||
if ($res && $this->id_product_attribute == 0)
|
|
||||||
{
|
|
||||||
$items = self::getSupplierCollection($this->id_product, false);
|
|
||||||
foreach ($items as $item)
|
|
||||||
{
|
|
||||||
if ($item->id_product_attribute > 0)
|
|
||||||
$item->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For a given Supplier, Product, returns the purchased price
|
* For a given Supplier, Product, returns the purchased price
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class StockMvtReasonCore extends ObjectModel
|
|||||||
public $deleted = 0;
|
public $deleted = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @since 1.5.0
|
||||||
* @see ObjectModel::$definition
|
* @see ObjectModel::$definition
|
||||||
*/
|
*/
|
||||||
public static $definition = array(
|
public static $definition = array(
|
||||||
@@ -61,6 +62,9 @@ class StockMvtReasonCore extends ObjectModel
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ObjectModel::$webserviceParameters
|
||||||
|
*/
|
||||||
protected $webserviceParameters = array(
|
protected $webserviceParameters = array(
|
||||||
'objectsNodeName' => 'stock_movement_reasons',
|
'objectsNodeName' => 'stock_movement_reasons',
|
||||||
'objectNodeName' => 'stock_movement_reason',
|
'objectNodeName' => 'stock_movement_reason',
|
||||||
@@ -69,6 +73,13 @@ class StockMvtReasonCore extends ObjectModel
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets Stock Mvt Reasons
|
||||||
|
*
|
||||||
|
* @param int $id_lang
|
||||||
|
* @param int $sign Optionnal
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public static function getStockMvtReasons($id_lang, $sign = null)
|
public static function getStockMvtReasons($id_lang, $sign = null)
|
||||||
{
|
{
|
||||||
$query = new DbQuery();
|
$query = new DbQuery();
|
||||||
@@ -112,8 +123,9 @@ class StockMvtReasonCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 1.5.0
|
* For a given id_stock_mvt_reason, tells if it exists
|
||||||
*
|
*
|
||||||
|
* @since 1.5.0
|
||||||
* @param int $id_stock_mvt_reason
|
* @param int $id_stock_mvt_reason
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -152,6 +152,32 @@ class SupplyOrderCore extends ObjectModel
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ObjectModel::$webserviceParameters
|
||||||
|
*/
|
||||||
|
protected $webserviceParameters = array(
|
||||||
|
'fields' => array(
|
||||||
|
'id_supplier' => array('xlink_resource' => 'suppliers'),
|
||||||
|
'id_lang' => array('xlink_resource' => 'languages'),
|
||||||
|
'id_warehouse' => array('xlink_resource' => 'warehouses'),
|
||||||
|
'id_supply_order_state' => array('xlink_resource' => 'supply_order_states'),
|
||||||
|
'id_currency' => array('xlink_resource' => 'currencies'),
|
||||||
|
),
|
||||||
|
'hidden_fields' => array(
|
||||||
|
'id_ref_currency',
|
||||||
|
),
|
||||||
|
'associations' => array(
|
||||||
|
'supply_order_details' => array(
|
||||||
|
'resource' => 'supply_order_detail',
|
||||||
|
'fields' => array(
|
||||||
|
'id' => array(),
|
||||||
|
'supplier_reference' => array(),
|
||||||
|
'product_name' => array(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ObjectModel::update()
|
* @see ObjectModel::update()
|
||||||
*/
|
*/
|
||||||
@@ -403,4 +429,18 @@ class SupplyOrderCore extends ObjectModel
|
|||||||
return ($res > 0);
|
return ($res > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Webservice : gets the ids supply_order_detail associated to this order
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getWsSupplyOrderDetails()
|
||||||
|
{
|
||||||
|
$query = new DbQuery();
|
||||||
|
$query->select('sod.id_supply_order_detail as id, sod.name as product_name, supplier_reference');
|
||||||
|
$query->from('supply_order_detail', 'sod');
|
||||||
|
$query->where('id_supply_order = '.(int)$this->id);
|
||||||
|
|
||||||
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,6 +174,22 @@ class SupplyOrderDetailCore extends ObjectModel
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ObjectModel::$webserviceParameters
|
||||||
|
*/
|
||||||
|
protected $webserviceParameters = array(
|
||||||
|
'objectsNodeName' => 'supply_order_details',
|
||||||
|
'objectNodeName' => 'supply_order_detail',
|
||||||
|
'fields' => array(
|
||||||
|
'id_supply_order' => array('xlink_resource' => 'supply_orders'),
|
||||||
|
'id_product' => array('xlink_resource' => 'products'),
|
||||||
|
'id_product_attribute' => array('xlink_resource' => 'combinations'),
|
||||||
|
),
|
||||||
|
'hidden_fields' => array(
|
||||||
|
'id_currency',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ObjectModel::update()
|
* @see ObjectModel::update()
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -75,4 +75,18 @@ class SupplyOrderHistoryCore extends ObjectModel
|
|||||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true),
|
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* @see ObjectModel::$webserviceParameters
|
||||||
|
*/
|
||||||
|
protected $webserviceParameters = array(
|
||||||
|
'objectsNodeName' => 'supply_order_histories',
|
||||||
|
'objectNodeName' => 'supply_order_history',
|
||||||
|
'fields' => array(
|
||||||
|
'id_supply_order' => array('xlink_resource' => 'supply_orders'),
|
||||||
|
'id_employee' => array('xlink_resource' => 'employees'),
|
||||||
|
'id_state' => array('xlink_resource' => 'supply_order_states'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -81,4 +81,19 @@ class SupplyOrderReceiptHistoryCore extends ObjectModel
|
|||||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* @see ObjectModel::$webserviceParameters
|
||||||
|
*/
|
||||||
|
protected $webserviceParameters = array(
|
||||||
|
'objectsNodeName' => 'supply_order_receipt_histories',
|
||||||
|
'objectNodeName' => 'supply_order_receipt_history',
|
||||||
|
'fields' => array(
|
||||||
|
'id_supply_order_detail' => array('xlink_resource' => 'supply_order_details'),
|
||||||
|
'id_employee' => array('xlink_resource' => 'employees'),
|
||||||
|
'id_supply_order_state' => array('xlink_resource' => 'supply_order_states'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,12 +79,20 @@ class SupplyOrderStateCore extends ObjectModel
|
|||||||
'pending_receipt' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
'pending_receipt' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
'enclosed' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
'enclosed' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor'),
|
'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor'),
|
||||||
|
|
||||||
// Lang fields
|
|
||||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
|
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ObjectModel::$webserviceParameters
|
||||||
|
*/
|
||||||
|
protected $webserviceParameters = array(
|
||||||
|
'objectsNodeName' => 'supply_order_states',
|
||||||
|
'objectNodeName' => 'supply_order_state',
|
||||||
|
'fields' => array(
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list of supply order states
|
* Gets the list of supply order states
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -271,6 +271,12 @@ class WebserviceRequestCore
|
|||||||
'stocks' => array('description' => 'Stocks', 'class' => 'Stock', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
'stocks' => array('description' => 'Stocks', 'class' => 'Stock', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
||||||
'available_quantities' => array('description' => 'Available quantities', 'class' => 'StockAvailable', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
'available_quantities' => array('description' => 'Available quantities', 'class' => 'StockAvailable', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
||||||
'warehouse_product_locations' => array('description' => 'Location of products in warehouses', 'class' => 'WarehouseProductLocation', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
'warehouse_product_locations' => array('description' => 'Location of products in warehouses', 'class' => 'WarehouseProductLocation', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
||||||
|
'supply_orders' => array('description' => 'Supply Orders', 'class' => 'SupplyOrder', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
||||||
|
'supply_order_details' => array('description' => 'Supply Order Details', 'class' => 'SupplyOrderDetail', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
||||||
|
'supply_order_states' => array('description' => 'Supply Order States', 'class' => 'SupplyOrderState', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
||||||
|
'supply_order_histories' => array('description' => 'Supply Order Histories', 'class' => 'SupplyOrderHistory', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
||||||
|
'supply_order_receipt_histories' => array('description' => 'Supply Order Receipt Histories', 'class' => 'SupplyOrderReceiptHistory', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
||||||
|
'product_suppliers' => array('description' => 'Product Suppliers', 'class' => 'ProductSupplier', 'forbidden_method' => array('PUT', 'POST', 'DELETE')),
|
||||||
);
|
);
|
||||||
ksort($resources);
|
ksort($resources);
|
||||||
return $resources;
|
return $resources;
|
||||||
|
|||||||
Reference in New Issue
Block a user