// norm & translations

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13933 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
bMancone
2012-03-07 15:48:54 +00:00
parent 8faf31d00d
commit fbd17ef3bf
3 changed files with 32 additions and 19 deletions
+28 -15
View File
@@ -34,7 +34,6 @@ class AdminWarehousesControllerCore extends AdminController
{
$this->table = 'warehouse';
$this->className = 'Warehouse';
$this->context = Context::getContext();
$this->deleted = true;
$this->lang = false;
@@ -113,8 +112,8 @@ class AdminWarehousesControllerCore extends AdminController
$this->displayInformation($this->l('Before adding stock in your warehouses, you should check the general default currency used.').'<br />');
$this->displayInformation($this->l('Futhermore, for each warehouse, you have to check :'));
$this->displayInformation($this->l('the management type (according to the law in your country), the valuation currency, its associated carriers and shops.').'<br />');
$this->displayInformation($this->l('Finally, you can see detailed informations on your stock per warehouse, such as its valuation, the number of products and quantities stored, ...').'<br /><br />');
$this->displayInformation($this->l('Finally, you can see detailed informations on your stock per warehouse, such as its valuation, the number of products and quantities stored, ...')
.'<br /><br />');
$this->displayInformation($this->l('Be careful, products from different warehouses will need to be shipped in different packages.'));
return parent::renderList();
@@ -274,9 +273,10 @@ class AdminWarehousesControllerCore extends AdminController
);
}
// It is not possible to change currency valuation and management type
// if it is still possible to change currency valuation and management type
if (Tools::isSubmit('addwarehouse') || Tools::isSubmit('submitAddwarehouse'))
{
// adds input management type
$this->fields_form['input'][] = array(
'type' => 'select',
'label' => $this->l('Management type:'),
@@ -311,6 +311,7 @@ class AdminWarehousesControllerCore extends AdminController
if ($default_currency)
$currencies = array_merge(array($default_currency, '-'), $currencies);
// adds input valuation currency
$this->fields_form['input'][] = array(
'type' => 'select',
'label' => $this->l('Stock valuation currency:'),
@@ -324,7 +325,7 @@ class AdminWarehousesControllerCore extends AdminController
)
);
}
else
else // else hide input
{
$this->fields_form['input'][] = array(
'type' => 'hidden',
@@ -356,7 +357,7 @@ class AdminWarehousesControllerCore extends AdminController
// loads current carriers associated with this warehouse
$carriers = $obj->getCarriers();
// force specific fields values
// if an address is available : force specific fields values
if ($address != null)
$this->fields_value = array(
'id_address' => $address->id,
@@ -368,11 +369,13 @@ class AdminWarehousesControllerCore extends AdminController
'id_country' => $address->id_country,
'id_state' => $address->id_state,
);
else
else // loads default country
$this->fields_value = array(
'id_address' => 0,
'id_country' => Configuration::get('PS_COUNTRY_DEFAULT')
);
// loads shops and carriers
$this->fields_value['ids_shops[]'] = $ids_shop;
$this->fields_value['ids_carriers[]'] = $carriers;
@@ -384,8 +387,7 @@ class AdminWarehousesControllerCore extends AdminController
*/
public function renderView()
{
$this->displayInformation($this->l('This interface allows you to display detailed informations on your warehouse.'));
// gets necessary objects
$id_warehouse = (int)Tools::getValue('id_warehouse');
$warehouse = new Warehouse($id_warehouse);
$employee = new Employee($warehouse->id_employee);
@@ -393,11 +395,14 @@ class AdminWarehousesControllerCore extends AdminController
$address = new Address($warehouse->id_address);
$shops = $warehouse->getShops();
// checks objects
if (!Validate::isLoadedObject($warehouse) ||
!Validate::isLoadedObject($employee) ||
!Validate::isLoadedObject($currency))
!Validate::isLoadedObject($currency) ||
!Validate::isLoadedObject($address))
return parent::renderView();
// assigns to our view
$this->tpl_view_vars = array(
'warehouse' => $warehouse,
'employee' => $employee,
@@ -414,9 +419,12 @@ class AdminWarehousesControllerCore extends AdminController
/**
* @see AdminController::afterAdd()
* Called once $object is set.
* Used to process the associations with address/shops/carriers
*/
protected function afterAdd($object)
{
// handles address association
$address = new Address($object->id_address);
if (Validate::isLoadedObject($address))
{
@@ -443,9 +451,11 @@ class AdminWarehousesControllerCore extends AdminController
{
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
// foreach item in the list to render
$nb_items = count($this->_list);
for ($i = 0; $i < $nb_items; ++$i)
{
// depending on the management type, translates the management type
$item = &$this->_list[$i];
switch ($item['management_type'])
{
@@ -492,6 +502,7 @@ class AdminWarehousesControllerCore extends AdminController
else
$address = new Address(); // creates address
// sets the address
$address->alias = Tools::getValue('reference', null);
$address->lastname = 'warehouse'; // skip problem with numeric characters in warehouse name
$address->firstname = 'warehouse'; // skip problem with numeric characters in warehouse name
@@ -503,16 +514,17 @@ class AdminWarehousesControllerCore extends AdminController
$address->id_state = Tools::getValue('id_state', null);
$address->city = Tools::getValue('city', null);
// validates the address
$validation = $address->validateController();
// checks address validity
if (count($validation) > 0)
if (count($validation) > 0) // if not valid
{
foreach ($validation as $item)
$this->errors[] = $item;
$this->errors[] = Tools::displayError('The address is not correct. Check if all required fields are filled.');
}
else
else // valid
{
if (Tools::isSubmit('id_address') && Tools::getValue('id_address') > 0)
$address->update();
@@ -549,13 +561,14 @@ class AdminWarehousesControllerCore extends AdminController
{
if (Tools::isSubmit('delete'.$this->table))
{
// check if the warehouse exists and can be deleted
if (!($obj = $this->loadObject(true)))
return;
else if ($obj->getQuantitiesOfProducts() > 0)
else if ($obj->getQuantitiesOfProducts() > 0) // not possible : products
$this->errors[] = $this->l('It is not possible to delete a Warehouse when there are products in it.');
else if (SupplyOrder::warehouseHasPendingOrders($obj->id))
else if (SupplyOrder::warehouseHasPendingOrders($obj->id)) // not possible : supply orders
$this->errors[] = $this->l('It is not possible to delete a Warehouse if it has pending supply orders.');
else
else // can be deleted
{
// sets the address of the warehouse as deleted
$address = new Address($obj->id_address);