// Warehouse: it is not possible to delete a warehouse of it has pending supply orders.
This commit is contained in:
@@ -174,9 +174,9 @@ class StockMvtCore extends ObjectModel
|
||||
$fields['id_stock_mvt_reason'] = (int)$this->id_stock_mvt_reason;
|
||||
$fields['id_order'] = (int)$this->id_order;
|
||||
$fields['sign'] = (int)$this->sign;
|
||||
$fields['last_wa'] = (float)round($this->last_wa, 6);
|
||||
$fields['current_wa'] = (float)round($this->current_wa, 6);
|
||||
$fields['price_te'] = (float)round($this->price_te, 6);
|
||||
$fields['last_wa'] = (float)Tools::ps_round($this->last_wa, 6);
|
||||
$fields['current_wa'] = (float)Tools::ps_round($this->current_wa, 6);
|
||||
$fields['price_te'] = (float)Tools::ps_round($this->price_te, 6);
|
||||
$fields['referer'] = (int)$this->referer;
|
||||
return $fields;
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ class SupplyOrderCore extends ObjectModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Historizes
|
||||
* Historizes the order : its id, its state, and the employee responsible for the current action
|
||||
*/
|
||||
protected function addHistory()
|
||||
{
|
||||
@@ -381,7 +381,7 @@ class SupplyOrderCore extends ObjectModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all products ordered
|
||||
* Removes all products from the order
|
||||
*/
|
||||
public function resetProducts()
|
||||
{
|
||||
@@ -390,4 +390,27 @@ class SupplyOrderCore extends ObjectModel
|
||||
foreach ($products as $p)
|
||||
$p->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given $id_warehouse, tells if it has pending supply orders
|
||||
*
|
||||
* @param int $id_warehouse
|
||||
* @return bool
|
||||
*/
|
||||
public static function warehouseHasPendingOrders($id_warehouse)
|
||||
{
|
||||
if (!$id_warehouse)
|
||||
return false;
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('COUNT(so.id_supply_order) as supply_orders');
|
||||
$query->from('supply_order so');
|
||||
$query->leftJoin('supply_order_state sos ON (so.id_supply_order_state = sos.id_supply_order_state)');
|
||||
$query->where('sos.enclosed != 1');
|
||||
$query->where('so.id_warehouse = '.(int)$id_warehouse);
|
||||
|
||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
|
||||
return ($res > 0);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user