// AdminWarehousesController : added informations on the shops associated to a warehouse on the 'view' action

This commit is contained in:
bMancone
2011-11-15 09:28:54 +00:00
parent cff17ab35d
commit 2fa5234c37
3 changed files with 26 additions and 10 deletions
@@ -70,6 +70,23 @@
</table>
</fieldset>
</div>
<div style="margin-top: 30px">
<fieldset>
<legend><img src="/img/t/AdminShop.gif" alt="" /> {l s='Shops'}</legend>
{l s='The following are the shops associated to this warehouse.'}
<table style="width: 400px; margin-top:20px" classe="table">
<tr>
<th>{l s='ID'}</th>
<th>{l s='Name'}</th>
{foreach $shops as $shop}
<tr>
<td>{$shop.id_shop}</td>
<td>{$shop.name}</td>
</tr>
{/foreach}
</table>
</fieldset>
</div>
<div style="margin-top: 30px">
<fieldset>
<legend><img src="/img/t/AdminStock.gif" alt="" /> {l s='Stock'}</legend>
+3 -9
View File
@@ -107,20 +107,14 @@ class WarehouseCore extends ObjectModel
*/
public function getShops()
{
$ids_shop = array();
$query = new DbQuery();
$query->select('ws.id_shop');
$query->select('ws.id_shop, s.name');
$query->from('warehouse_shop ws');
$query->leftJoin('shop s ON (s.id_shop = ws.id_shop)');
$query->where($this->identifier.' = '.(int)$this->id);
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
foreach ($res as $shops)
foreach ($shops as $shop)
$ids_shop[] = $shop;
return $ids_shop;
return $res;
}
/**
@@ -338,6 +338,9 @@ class AdminWarehousesControllerCore extends AdminController
// loads current shops associated with this warehouse
$shops = $obj->getShops();
$ids_shop = array();
foreach ($shops as $shop)
$ids_shop[] = $shop['id_shop'];
// loads current carriers associated with this warehouse
$carriers = $obj->getCarriers();
@@ -356,7 +359,7 @@ class AdminWarehousesControllerCore extends AdminController
);
else
$this->fields_value['id_address'] = 0;
$this->fields_value['ids_shops[]'] = $shops;
$this->fields_value['ids_shops[]'] = $ids_shop;
$this->fields_value['ids_carriers[]'] = $carriers;
return parent::initForm();
@@ -451,6 +454,7 @@ class AdminWarehousesControllerCore extends AdminController
$employee = new Employee($warehouse->id_employee);
$currency = new Currency($warehouse->id_currency);
$address = new Address($warehouse->id_address);
$shops = $warehouse->getShops();
if (!Validate::isLoadedObject($warehouse) ||
!Validate::isLoadedObject($employee) ||
@@ -462,6 +466,7 @@ class AdminWarehousesControllerCore extends AdminController
'employee' => $employee,
'currency' => $currency,
'address' => $address,
'shops' => $shops,
'warehouse_num_products' => $warehouse->getNumberOfProducts(),
'warehouse_value' => Tools::ps_round($warehouse->getStockValue(), 2),
'warehouse_quantities' => $warehouse->getQuantitiesofProducts(),