diff --git a/controllers/admin/AdminStockCoverController.php b/controllers/admin/AdminStockCoverController.php index f0ab8edb0..c6a51f1f1 100644 --- a/controllers/admin/AdminStockCoverController.php +++ b/controllers/admin/AdminStockCoverController.php @@ -263,7 +263,7 @@ class AdminStockCoverControllerCore extends AdminController } else { - $item['stock'] = 'See details'; + $item['stock'] = $this->l('See details'); $item['reference'] = '--'; $item['ean13'] = '--'; $item['upc'] = '--'; diff --git a/controllers/admin/AdminStockManagementController.php b/controllers/admin/AdminStockManagementController.php index 617b0eb4b..67f44fef5 100644 --- a/controllers/admin/AdminStockManagementController.php +++ b/controllers/admin/AdminStockManagementController.php @@ -109,7 +109,6 @@ class AdminStockManagementControllerCore extends AdminController $this->displayInformation($this->l('Through this interface, you can increase quantities (add) and decrease quantities (delete) of products for a given warehouse.')); $this->displayInformation($this->l('Furthermore, you can move quantities (transfer) of products between warehouses, or within one warehouse.').'
'); $this->displayInformation($this->l('Note that if you want to increase quantities of multiple products at once, you can use the supply orders tab.').'
'); - $this->displayInformation($this->l('Finally, you will be asked to specify the state of the quantity you will add : ')); $this->displayInformation($this->l('usable for sale means that this quantity will be available in shop(s),')); $this->displayInformation($this->l('otherwise it will be considered reserved (i.e. for other purposes).')); @@ -148,6 +147,7 @@ class AdminStockManagementControllerCore extends AdminController $last_sm_quantity_is_usable = -1; $last_sm = StockMvt::getLastPositiveStockMvt($id_product, $id_product_attribute); + // if there is a stock mvt if ($last_sm != false) { $last_sm_currency = new Currency((int)$last_sm['id_currency']); @@ -577,7 +577,7 @@ class AdminStockManagementControllerCore extends AdminController $this->errors[] = Tools::displayError('The selected product is not valid.'); // get quantity and check that the post value is really an integer - // If it's not, we have to do nothing. + // If it's not, we have nothing to do $quantity = Tools::getValue('quantity', 0); if (!is_numeric($quantity) || (int)$quantity <= 0) $this->errors[] = Tools::displayError('The quantity value is not valid.'); @@ -700,7 +700,7 @@ class AdminStockManagementControllerCore extends AdminController $this->errors[] = Tools::displayError('You have to specify if the product quantity is usable for sale on shops in destination warehouse.'); $usable_to = (bool)$usable_to; - // if all is ok, transfer stock + // if we can process stock transfers if (count($this->errors) == 0) { // transfer stock diff --git a/controllers/admin/AdminWarehousesController.php b/controllers/admin/AdminWarehousesController.php index 2f8891cbe..903225fcc 100644 --- a/controllers/admin/AdminWarehousesController.php +++ b/controllers/admin/AdminWarehousesController.php @@ -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.').'
'); $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.').'
'); - $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, ...').'

'); - + $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, ...') + .'

'); $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);