From a306e44d55ab3d217ded05284fa80132b7b1101b Mon Sep 17 00:00:00 2001 From: bMancone Date: Mon, 28 Nov 2011 15:44:06 +0000 Subject: [PATCH] // CRUD for StockMvtLabels & SupplyOrderStatus are now in AdminStockConfigurationController --- .../AdminStockConfigurationController.php | 552 ++++++++++++++++++ controllers/admin/AdminStockMvtController.php | 249 +------- .../admin/AdminSupplyOrdersController.php | 392 ++----------- img/t/AdminStockConfiguration.gif | Bin 0 -> 416 bytes install-dev/sql/db_settings_lite.sql | 19 +- 5 files changed, 650 insertions(+), 562 deletions(-) create mode 100644 controllers/admin/AdminStockConfigurationController.php create mode 100755 img/t/AdminStockConfiguration.gif diff --git a/controllers/admin/AdminStockConfigurationController.php b/controllers/admin/AdminStockConfigurationController.php new file mode 100644 index 000000000..d5d297514 --- /dev/null +++ b/controllers/admin/AdminStockConfigurationController.php @@ -0,0 +1,552 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +/** + * @since 1.5.0 + */ +class AdminStockConfigurationController extends AdminController +{ + /* + * By default, we use StockMvtReason as the table / className + */ + public function __construct() + { + $this->context = Context::getContext(); + $this->table = 'stock_mvt_reason'; + $this->className = 'StockMvtReason'; + $this->lang = true; + + // defines fields + $this->fieldsDisplay = array( + 'id_stock_mvt_reason' => array( + 'title' => $this->l('ID'), + 'align' => 'center', + 'width' => 40, + 'search' => false, + ), + 'sign' => array( + 'title' => $this->l('Sign'), + 'width' => 100, + 'align' => 'center', + 'type' => 'select', + 'filter_key' => 'a!sign', + 'list' => array( + '1' => $this->l('Increment'), + '-1' => $this->l('Decrement'), + ), + 'icon' => array( + -1 => 'remove_stock.png', + 1 => 'add_stock.png' + ), + 'orderby' => false + ), + 'name' => array( + 'title' => $this->l('Name'), + 'filter_key' => 'b!name', + 'width' => 250 + ), + ); + + // loads labels (incremenation) + $reasons_inc = StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id, + array(Configuration::get('PS_STOCK_MVT_TRANSFER_TO')), 1); + // loads labaels (decremenation) + $reasons_dec = StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id, + array(Configuration::get('PS_STOCK_MVT_TRANSFER_FROM')), -1); + + // defines options for StockMvt + $this->options = array( + 'general' => array( + 'title' => $this->l('Options'), + 'fields' => array( + 'PS_STOCK_MVT_INC_REASON_DEFAULT' => array( + 'title' => $this->l('Default label when incrementing stock:'), + 'cast' => 'intval', + 'type' => 'select', + 'list' => $reasons_inc, + 'identifier' => 'id_stock_mvt_reason', + 'visibility' => Shop::CONTEXT_ALL + ), + 'PS_STOCK_MVT_DEC_REASON_DEFAULT' => array( + 'title' => $this->l('Default label when decrementing stock:'), + 'cast' => 'intval', + 'type' => 'select', + 'list' => $reasons_dec, + 'identifier' => 'id_stock_mvt_reason', + 'visibility' => Shop::CONTEXT_ALL + ), + 'PS_STOCK_CUSTOMER_ORDER_REASON' => array( + 'title' => $this->l('Default label when decrementing stock when a customer order is shipped:'), + 'cast' => 'intval', + 'type' => 'select', + 'list' => $reasons_dec, + 'identifier' => 'id_stock_mvt_reason', + 'visibility' => Shop::CONTEXT_ALL + ), + 'PS_STOCK_MVT_SUPPLY_ORDER' => array( + 'title' => $this->l('Default label when incrementing stock when a supply order is received:'), + 'cast' => 'intval', + 'type' => 'select', + 'list' => $reasons_inc, + 'identifier' => 'id_stock_mvt_reason', + 'visibility' => Shop::CONTEXT_ALL + ), + ), + 'submit' => array(), + ) + ); + + parent::__construct(); + } + + public function init() + { + // if we are managing the second list (i.e. supply order state) + if (Tools::isSubmit('addsupply_order_state') || + Tools::isSubmit('updatesupply_order_state') || + Tools::isSubmit('deletesupply_order_state')) + { + $this->table = 'supply_order_state'; + $this->className = 'SupplyOrderState'; + $this->identifier = 'id_supply_order_state'; + $this->display = 'edit'; + } + return parent::init(); + } + + /** + * AdminController::initForm() override + * @see AdminController::initForm() + */ + public function initForm() + { + // if we are managing StockMvtReason + if (Tools::isSubmit('addstock_mvt_reason') || Tools::isSubmit('updatestock_mvt_reason')) + { + $this->toolbar_title = $this->l('Stock : Add stock movement label'); + + $this->fields_form = array( + 'legend' => array( + 'title' => $this->l('Stock Movement Label'), + 'image' => '../img/admin/edit.gif' + ), + 'input' => array( + array( + 'type' => 'text', + 'lang' => true, + 'label' => $this->l('Name:'), + 'name' => 'name', + 'size' => 50, + 'required' => true + ), + array( + 'type' => 'select', + 'label' => $this->l('Action:'), + 'name' => 'sign', + 'required' => true, + 'options' => array( + 'query' => array( + array( + 'id' => '1', + 'name' => $this->l('Increase stock') + ), + array( + 'id' => '-1', + 'name' => $this->l('Decrease stock') + ), + ), + 'id' => 'id', + 'name' => 'name' + ), + 'desc' => $this->l('Select the corresponding action : increments or decrements stock.') + ), + ), + 'submit' => array( + 'title' => $this->l(' Save '), + 'class' => 'button' + ) + ); + } + // else, if we are managing Supply Order State + else if (Tools::isSubmit('addsupply_order_state') || + Tools::isSubmit('updatesupply_order_state') || + Tools::isSubmit('submitAddsupply_order_state') || + Tools::isSubmit('submitUpdatesupply_order_state')) + { + $this->fields_form = array( + 'legend' => array( + 'title' => $this->l('Supply Order Status'), + 'image' => '../img/admin/edit.gif' + ), + 'input' => array( + array( + 'type' => 'text', + 'lang' => true, + 'label' => $this->l('Status:'), + 'name' => 'name', + 'size' => 50, + 'required' => true + ), + array( + 'type' => 'color', + 'label' => $this->l('Color:'), + 'name' => 'color', + 'size' => 20, + 'desc' => $this->l('Back office background will be displayed in this color. HTML colors only.'), + ), + array( + 'type' => 'radio', + 'label' => $this->l('Editable:'), + 'name' => 'editable', + 'required' => true, + 'class' => 't', + 'is_bool' => true, + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + 'label' => $this->l('Yes') + ), + array( + 'id' => 'active_off', + 'value' => 0, + 'label' => $this->l('No') + ) + ), + 'desc' => $this->l('For this status, you have to define if it is possible to edit the order. + An editable order is an order not valid to send to the supplier.') + ), + array( + 'type' => 'radio', + 'label' => $this->l('Delivery note:'), + 'name' => 'delivery_note', + 'required' => true, + 'class' => 't', + 'is_bool' => true, + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + 'label' => $this->l('Yes') + ), + array( + 'id' => 'active_off', + 'value' => 0, + 'label' => $this->l('No') + ) + ), + 'desc' => $this->l('For this status, you have to define if it is possible to generate the delivery note of the order.') + ), + array( + 'type' => 'radio', + 'label' => $this->l('Delivery state:'), + 'name' => 'receipt_state', + 'required' => true, + 'class' => 't', + 'is_bool' => true, + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + 'label' => $this->l('Yes') + ), + array( + 'id' => 'active_off', + 'value' => 0, + 'label' => $this->l('No') + ) + ), + 'desc' => $this->l('For this status, you have to define if products have been partially/completely received. + This allows to know if the products ordered have to be added to the corresponding warehouse.'), + ), + array( + 'type' => 'radio', + 'label' => $this->l('Pending receipt:'), + 'name' => 'pending_receipt', + 'required' => true, + 'class' => 't', + 'is_bool' => true, + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + 'label' => $this->l('Yes') + ), + array( + 'id' => 'active_off', + 'value' => 0, + 'label' => $this->l('No') + ) + ), + 'desc' => $this->l('Does this status mean that you are waiting for the delivery ?') + ), + ), + 'submit' => array( + 'title' => $this->l(' Save '), + 'class' => 'button' + ) + ); + + if (Tools::isSubmit('addsupply_order_state')) + $this->toolbar_title = $this->l('Stock : Add supply order status'); + else + { + $this->toolbar_title = $this->l('Stock : Update Supply order status'); + + $id_supply_order_state = Tools::getValue('id_supply_order_state', 0); + + // only some fields are editable for initial states + if (in_array($id_supply_order_state, array(1, 2, 3, 4, 5, 6))) + { + $this->fields_form = array( + 'legend' => array( + 'title' => $this->l('Supply Order status'), + 'image' => '../img/admin/edit.gif' + ), + 'input' => array( + array( + 'type' => 'text', + 'lang' => true, + 'label' => $this->l('Status:'), + 'name' => 'name', + 'size' => 50, + 'required' => true + ), + array( + 'type' => 'color', + 'label' => $this->l('Back office color:'), + 'name' => 'color', + 'size' => 20, + 'desc' => $this->l('Back office background will be displayed in this color. HTML colors only'), + ), + ), + 'submit' => array( + 'title' => $this->l(' Save '), + 'class' => 'button' + ) + ); + } + + if (!($obj = new SupplyOrderState((int)$id_supply_order_state))) + return; + + $this->fields_value = array( + 'color' => $obj->color, + 'editable' => $obj->editable, + 'delivery_note' => $obj->delivery_note, + 'receipt_state' => $obj->receipt_state, + 'pending_receipt' => $obj->pending_receipt, + ); + foreach ($this->getLanguages() as $language) + $this->fields_value['name'][$language['id_lang']] = $this->getFieldValue($obj, 'name', $language['id_lang']); + } + } + + return parent::initForm(); + } + + /** + * AdminController::initList() override + * @see AdminController::initList() + */ + public function initList() + { + /** + * General messages displayed for all lists + */ + $this->displayInformation($this->l('This interface allows you to configure your supply orders status and stock movements labels.').'
'); + + // Checks access + if (!($this->tabAccess['add'] === '1')) + unset($this->toolbar_btn['new']); + + /** + * First list + * Stock Mvt Labels/Reasons + */ + $first_list = null; + $this->list_no_link = true; + $this->addRowAction('edit'); + $this->addRowAction('delete'); + $this->addRowActionSkipList('edit', array(1, 2, 3, 4, 5, 6, 7, 8)); + $this->addRowActionSkipList('delete', array(1, 2, 3, 4, 5, 6, 7, 8)); + $this->_where = ' AND a.deleted = 0'; + + $this->toolbar_title = $this->l('Stock : Stock movements labels'); + $first_list = parent::initList(); + + /** + * Second list + * Supply Order Status/State + */ + $second_list = null; + unset($this->_select, $this->_where, $this->_join, $this->_group, $this->_filterHaving, $this->_filter, $this->list_skip_actions['delete'], $this->list_skip_actions['edit']); + + // generates the actual second list + $second_list = $this->initSupplyOrderStatusList(); + + // resets default table and className for options list management + $this->table = 'stock_mvt_reason'; + $this->className = 'StockMvtReason'; + + // returns the final list + return $second_list.$first_list; + } + + /* + * Help function for AdminStockConfigurationController::initList() + * @see AdminStockConfigurationController::initList() + */ + public function initSupplyOrderStatusList() + { + $this->table = 'supply_order_state'; + $this->className = 'SupplyOrderState'; + $this->identifier = 'id_supply_order_state'; + $this->_defaultOrderBy = 'id_supply_order_state'; + $this->lang = true; + $this->list_no_link = true; + $this->addRowActionSkipList('delete', array(1, 2, 3, 4, 5, 6)); + $this->toolbar_title = $this->l('Stock : Supply Order status'); + $this->initToolbar(); + + $this->fieldsDisplay = array( + 'name' => array( + 'title' => $this->l('Name'), + 'color' => 'color', + ), + 'editable' => array( + 'title' => $this->l('Editable?'), + 'align' => 'center', + 'icon' => array( + '1' => 'enabled.gif', + '0' => 'disabled.gif' + ), + 'type' => 'bool', + 'width' => 170, + 'orderby' => false + ), + 'delivery_note' => array( + 'title' => $this->l('Delivery note available?'), + 'align' => 'center', + 'icon' => array( + '1' => 'enabled.gif', + '0' => 'disabled.gif' + ), + 'type' => 'bool', + 'width' => 170, + 'orderby' => false + ), + 'pending_receipt' => array( + 'title' => $this->l('Is a pending receipt state?'), + 'align' => 'center', + 'icon' => array( + '1' => 'enabled.gif', + '0' => 'disabled.gif' + ), + 'type' => 'bool', + 'width' => 170, + 'orderby' => false + ), + 'receipt_state' => array( + 'title' => $this->l('Is a delivery state?'), + 'align' => 'center', + 'icon' => array( + '1' => 'enabled.gif', + '0' => 'disabled.gif' + ), + 'type' => 'bool', + 'width' => 170, + 'orderby' => false + ), + 'enclosed' => array( + 'title' => $this->l('Is an enclosed order state?'), + 'align' => 'center', + 'icon' => array( + '1' => 'enabled.gif', + '0' => 'disabled.gif' + ), + 'type' => 'bool', + 'width' => 170, + 'orderby' => false + ), + ); + + return parent::initList(); + } + + /** + * AdminController::postProcess() override + * @see AdminController::postProcess() + */ + public function postProcess() + { + // StockMvtReason + if (Tools::isSubmit('delete'.$this->table)) + $this->deleted = true; + + // SupplyOrderState + if (Tools::isSubmit('submitAddsupply_order_state') || + Tools::isSubmit('deletesupply_order_state') || + Tools::isSubmit('submitUpdatesupply_order_state')) + { + if (Tools::isSubmit('deletesupply_order_state')) + $this->action = 'delete'; + else + $this->action = 'save'; + $this->table = 'supply_order_state'; + $this->className = 'SupplyOrderState'; + $this->identifier = 'id_supply_order_state'; + $this->_defaultOrderBy = 'id_supply_order_state'; + } + + return parent::postProcess(); + } + + /** + * AdminController::getList() override + * @see AdminController::getList() + */ + public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) + { + parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); + + //If there is a field product_name in the list, check if this field is null and display standard message + foreach ($this->fieldsDisplay as $key => $value) + if ($key == 'product_name') + { + $nb_items = count($this->_list); + + for ($i = 0; $i < $nb_items; ++$i) + { + $item = &$this->_list[$i]; + + if (empty($item['product_name'])) + $item['product_name'] = $this->l('The name of this product is not available. Maybe it has been deleted from the system.'); + } + } + } +} \ No newline at end of file diff --git a/controllers/admin/AdminStockMvtController.php b/controllers/admin/AdminStockMvtController.php index 184d603d0..489443e41 100644 --- a/controllers/admin/AdminStockMvtController.php +++ b/controllers/admin/AdminStockMvtController.php @@ -33,205 +33,15 @@ class AdminStockMvtControllerCore extends AdminController public function __construct() { $this->context = Context::getContext(); - $this->table = 'stock_mvt_reason'; - $this->className = 'StockMvtReason'; - $this->lang = true; - - $this->fieldsDisplay = array( - 'id_stock_mvt_reason' => array( - 'title' => $this->l('ID'), - 'align' => 'center', - 'width' => 40, - 'search' => false, - ), - 'sign' => array( - 'title' => $this->l('Sign'), - 'width' => 100, - 'align' => 'center', - 'type' => 'select', - 'filter_key' => 'a!sign', - 'list' => array( - '1' => $this->l('Increment'), - '-1' => $this->l('Decrement'), - ), - 'icon' => array( - -1 => 'remove_stock.png', - 1 => 'add_stock.png' - ), - 'orderby' => false - ), - 'name' => array( - 'title' => $this->l('Name'), - 'filter_key' => 'b!name', - 'width' => 500 - ), - ); - - $reasons_inc = StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id, - array(Configuration::get('PS_STOCK_MVT_TRANSFER_TO')), 1); - $reasons_dec = StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id, - array(Configuration::get('PS_STOCK_MVT_TRANSFER_FROM')), -1); - - $this->options = array( - 'general' => array( - 'title' => $this->l('Options'), - 'fields' => array( - 'PS_STOCK_MVT_INC_REASON_DEFAULT' => array( - 'title' => $this->l('Default label when incrementing stock:'), - 'cast' => 'intval', - 'type' => 'select', - 'list' => $reasons_inc, - 'identifier' => 'id_stock_mvt_reason', - 'visibility' => Shop::CONTEXT_ALL - ), - 'PS_STOCK_MVT_DEC_REASON_DEFAULT' => array( - 'title' => $this->l('Default label when decrementing stock:'), - 'cast' => 'intval', - 'type' => 'select', - 'list' => $reasons_dec, - 'identifier' => 'id_stock_mvt_reason', - 'visibility' => Shop::CONTEXT_ALL - ), - 'PS_STOCK_CUSTOMER_ORDER_REASON' => array( - 'title' => $this->l('Default label when decrementing stock when a customer order is shipped:'), - 'cast' => 'intval', - 'type' => 'select', - 'list' => $reasons_dec, - 'identifier' => 'id_stock_mvt_reason', - 'visibility' => Shop::CONTEXT_ALL - ), - 'PS_STOCK_MVT_SUPPLY_ORDER' => array( - 'title' => $this->l('Default label when incrementing stock when a supply order is received:'), - 'cast' => 'intval', - 'type' => 'select', - 'list' => $reasons_inc, - 'identifier' => 'id_stock_mvt_reason', - 'visibility' => Shop::CONTEXT_ALL - ), - ), - 'submit' => array(), - ) - ); - - $this->tpl_list_vars['list_warehouses'] = array(); - - $this->_where = ' AND a.deleted = 0'; - - parent::__construct(); - } - - /** - * AdminController::initForm() override - * @see AdminController::initForm() - */ - public function initForm() - { - $this->toolbar_title = $this->l('Stock : Add Stock movement label'); - - $this->fields_form = array( - 'legend' => array( - 'title' => $this->l('Stock Movement Label'), - 'image' => '../img/admin/edit.gif' - ), - 'input' => array( - array( - 'type' => 'text', - 'lang' => true, - 'label' => $this->l('Name:'), - 'name' => 'name', - 'size' => 50, - 'required' => true - ), - array( - 'type' => 'select', - 'label' => $this->l('Action:'), - 'name' => 'sign', - 'required' => true, - 'options' => array( - 'query' => array( - array( - 'id' => '1', - 'name' => $this->l('Increase stock') - ), - array( - 'id' => '-1', - 'name' => $this->l('Decrease stock') - ), - ), - 'id' => 'id', - 'name' => 'name' - ), - 'desc' => $this->l('Select the corresponding action : increments or decrements stock.') - ), - ), - 'submit' => array( - 'title' => $this->l(' Save '), - 'class' => 'button' - ) - ); - - return parent::initForm(); - } - - /** - * AdminController::initList() override - * @see AdminController::initList() - */ - public function initList() - { - $this->displayInformation($this->l('This interface allows you to display the stock movements for a selected warehouse.').'
'); - $this->displayInformation($this->l('Also, it allows you to add and edit your own stock movement labels.')); - - // access - if (!($this->tabAccess['add'] === '1')) - unset($this->toolbar_btn['new']); - - //no link on list rows - $this->list_no_link = true; - - /* - * Manage default list - */ - $this->addRowAction('edit'); - $this->addRowAction('delete'); - $this->addRowActionSkipList('edit', array(1, 2, 3, 4, 5, 6, 7, 8)); - $this->addRowActionSkipList('delete', array(1, 2, 3, 4, 5, 6, 7, 8)); - - $this->toolbar_title = $this->l('Stock : Stock movements labels'); - $first_list = parent::initList(); - - /* - * Manage second list - */ - $warehouses = Warehouse::getWarehouses(true); - array_unshift($warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses'))); - $this->tpl_list_vars['list_warehouses'] = $warehouses; - $this->tpl_list_vars['current_warehouse'] = $this->getCurrentWarehouseId(); - - // reset actions, toolbar and query vars - $this->actions = array(); - $this->toolbar_btn = array(); - $this->toolbar_title = $this->l('Stock : Stock movements'); - unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter); - - // override table, land, className and identifier for the current controller - $this->deleted = false; $this->table = 'stock_mvt'; $this->className = 'StockMvt'; $this->identifier = 'id_stock_mvt'; $this->lang = false; - // test if a filter is applied for this list - if (Tools::isSubmit('submitFilter'.$this->table) || $this->context->cookie->{'submitFilter'.$this->table} !== false) - $this->filter = true; + $this->list_no_link = true; + $this->displayInformation($this->l('This interface allows you to display the stock movements for a selected warehouse.').'
'); + $this->displayInformation($this->l('Also, it allows you to add and edit your own stock movement labels.')); - // test if a filter reset request is required for this list - if (isset($_POST['submitReset'.$this->table])) - $this->action = 'reset_filters'; - else - $this->action = ''; - - // redifine fields display $this->fieldsDisplay = array( 'product_reference' => array( 'title' => $this->l('Reference'), @@ -299,8 +109,19 @@ class AdminStockMvtControllerCore extends AdminController ), ); - // make new query - unset ($this->_where); + parent::__construct(); + } + + /** + * AdminController::initList() override + * @see AdminController::initList() + */ + public function initList() + { + // removes toolbar btn + $this->toolbar_btn = array(); + + // overrides select $this->_select = ' CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) product_name, CONCAT(a.employee_lastname, \' \', a.employee_firstname) AS employee, @@ -310,6 +131,7 @@ class AdminStockMvtControllerCore extends AdminController stock.upc AS product_upc, w.id_currency AS id_currency'; + // overrides join $this->_join = 'INNER JOIN '._DB_PREFIX_.'stock stock ON a.id_stock = stock.id_stock LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON ( stock.id_product = pl.id_product @@ -325,29 +147,23 @@ class AdminStockMvtControllerCore extends AdminController al.id_attribute = pac.id_attribute AND al.id_lang = '.(int)$this->context->language->id.' )'; + // overrides group $this->_group = 'GROUP BY a.id_stock_mvt'; + // overrides where depending on the warehouse $id_warehouse = $this->getCurrentWarehouseId(); if ($id_warehouse > 0) $this->_where = ' AND w.id_warehouse = '.$id_warehouse; - // call postProcess() for take care about actions and filters - $this->postProcess(); - - // generate the second list - $second_list = parent::initList(); - - // reset all query vars - unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter); - - // reset default table and className for options list management - $this->table = 'stock_mvt_reason'; - $this->className = 'StockMvtReason'; - - // return the two lists - return $second_list.$first_list; + // sets the current warehouse + $this->tpl_list_vars['current_warehouse'] = $this->getCurrentWarehouseId(); + // sets the list of warehouses + $warehouses = Warehouse::getWarehouses(true); + array_unshift($warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses'))); + $this->tpl_list_vars['list_warehouses'] = $warehouses; + return parent::initList(); } /** @@ -369,19 +185,6 @@ class AdminStockMvtControllerCore extends AdminController return $warehouse; } - /** - * AdminController::postProcess() override - * @see AdminController::postProcess() - */ - public function postProcess() - { - //when deleting a movement reason, enable deleted flag for parent postProcess and no remove the corresponding row from the database - if (Tools::isSubmit('delete'.$this->table)) - $this->deleted = true; - - return parent::postProcess(); - } - /** * AdminController::getList() override * @see AdminController::getList() diff --git a/controllers/admin/AdminSupplyOrdersController.php b/controllers/admin/AdminSupplyOrdersController.php index 3e686839a..c9a00e85f 100644 --- a/controllers/admin/AdminSupplyOrdersController.php +++ b/controllers/admin/AdminSupplyOrdersController.php @@ -33,69 +33,70 @@ class AdminSupplyOrdersControllerCore extends AdminController public function __construct() { $this->context = Context::getContext(); - $this->table = 'supply_order_state'; - $this->className = 'SupplyOrderState'; - $this->lang = true; + $this->table = 'supply_order'; + $this->className = 'SupplyOrder'; + $this->identifier = 'id_supply_order'; + $this->lang = false; + + $this->addRowAction('updatereceipt'); + $this->addRowAction('changestate'); + $this->addRowAction('edit'); + $this->addRowAction('view'); + $this->addRowAction('details'); + $this->list_no_link = true; $this->fieldsDisplay = array( - 'name' => array( - 'title' => $this->l('Name'), + 'reference' => array( + 'title' => $this->l('Reference'), + 'width' => 130, + 'havingFilter' => true + ), + 'supplier' => array( + 'title' => $this->l('Supplier'), + 'width' => 130, + 'filter_key' => 's!name' + ), + 'warehouse' => array( + 'title' => $this->l('Warehouse'), + 'width' => 130, + 'filter_key' => 'w!name' + ), + 'state' => array( + 'title' => $this->l('Status'), + 'width' => 200, + 'filter_key' => 'stl!name', 'color' => 'color', ), - 'editable' => array( - 'title' => $this->l('Editable?'), - 'align' => 'center', - 'icon' => array( - '1' => 'enabled.gif', - '0' => 'disabled.gif' - ), - 'type' => 'bool', - 'width' => 170, - 'orderby' => false + 'date_add' => array( + 'title' => $this->l('Creation'), + 'width' => 150, + 'align' => 'right', + 'type' => 'date', + 'havingFilter' => true, + 'filter_key' => 'a!date_add' ), - 'delivery_note' => array( - 'title' => $this->l('Delivery note available?'), - 'align' => 'center', - 'icon' => array( - '1' => 'enabled.gif', - '0' => 'disabled.gif' - ), - 'type' => 'bool', - 'width' => 170, - 'orderby' => false + 'date_upd' => array( + 'title' => $this->l('Last modification'), + 'width' => 150, + 'align' => 'right', + 'type' => 'date', + 'havingFilter' => true, + 'filter_key' => 'a!date_upd' ), - 'pending_receipt' => array( - 'title' => $this->l('Is a pending receipt state?'), - 'align' => 'center', - 'icon' => array( - '1' => 'enabled.gif', - '0' => 'disabled.gif' - ), - 'type' => 'bool', - 'width' => 170, - 'orderby' => false + 'date_delivery_expected' => array( + 'title' => $this->l('Delivery (expected)'), + 'width' => 150, + 'align' => 'right', + 'type' => 'date', + 'havingFilter' => true, + 'filter_key' => 'a!date_delivery_expected' ), - 'receipt_state' => array( - 'title' => $this->l('Is a delivery state?'), - 'align' => 'center', - 'icon' => array( - '1' => 'enabled.gif', - '0' => 'disabled.gif' - ), - 'type' => 'bool', - 'width' => 170, - 'orderby' => false - ), - 'enclosed' => array( - 'title' => $this->l('Is an enclosed order state?'), - 'align' => 'center', - 'icon' => array( - '1' => 'enabled.gif', - '0' => 'disabled.gif' - ), - 'type' => 'bool', - 'width' => 170, - 'orderby' => false + 'id_pdf' => array( + 'title' => $this->l('PDF'), + 'width' => 80, + 'callback' => 'printPDFIcons', + 'orderby' => false, + 'search' => false ), ); @@ -146,169 +147,6 @@ class AdminSupplyOrdersControllerCore extends AdminController */ public function initForm() { - if (Tools::isSubmit('addsupply_order_state') || - Tools::isSubmit('updatesupply_order_state') || - Tools::isSubmit('submitAddsupply_order_state') || - Tools::isSubmit('submitUpdatesupply_order_state')) - { - $this->fields_form = array( - 'legend' => array( - 'title' => $this->l('Supply Order Status'), - 'image' => '../img/admin/edit.gif' - ), - 'input' => array( - array( - 'type' => 'text', - 'lang' => true, - 'label' => $this->l('Status:'), - 'name' => 'name', - 'size' => 50, - 'required' => true - ), - array( - 'type' => 'color', - 'label' => $this->l('Color:'), - 'name' => 'color', - 'size' => 20, - 'desc' => $this->l('Back office background will be displayed in this color. HTML colors only.'), - ), - array( - 'type' => 'radio', - 'label' => $this->l('Editable:'), - 'name' => 'editable', - 'required' => true, - 'class' => 't', - 'is_bool' => true, - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Yes') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('No') - ) - ), - 'desc' => $this->l('For this status, you have to define if it is possible to edit the order. - An editable order is an order not valid to send to the supplier.') - ), - array( - 'type' => 'radio', - 'label' => $this->l('Delivery note:'), - 'name' => 'delivery_note', - 'required' => true, - 'class' => 't', - 'is_bool' => true, - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Yes') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('No') - ) - ), - 'desc' => $this->l('For this status, you have to define if it is possible to generate the delivery note of the order.') - ), - array( - 'type' => 'radio', - 'label' => $this->l('Delivery state:'), - 'name' => 'receipt_state', - 'required' => true, - 'class' => 't', - 'is_bool' => true, - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Yes') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('No') - ) - ), - 'desc' => $this->l('For this status, you have to define if products have been partially/completely received. - This allows to know if the products ordered have to be added to the corresponding warehouse.'), - ), - array( - 'type' => 'radio', - 'label' => $this->l('Pending receipt:'), - 'name' => 'pending_receipt', - 'required' => true, - 'class' => 't', - 'is_bool' => true, - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Yes') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('No') - ) - ), - 'desc' => $this->l('Does this status mean that you are waiting for the delivery ?') - ), - ), - 'submit' => array( - 'title' => $this->l(' Save '), - 'class' => 'button' - ) - ); - - if (Tools::isSubmit('addsupply_order_state')) - $this->toolbar_title = $this->l('Stock : Add supply order status'); - else - { - $this->toolbar_title = $this->l('Stock : Update Supply order status'); - - $id_supply_order_state = Tools::getValue('id_supply_order_state', 0); - - // only some fields are editable for initial states - if (in_array($id_supply_order_state, array(1, 2, 3, 4, 5, 6))) - { - $this->fields_form = array( - 'legend' => array( - 'title' => $this->l('Supply Order status'), - 'image' => '../img/admin/edit.gif' - ), - 'input' => array( - array( - 'type' => 'text', - 'lang' => true, - 'label' => $this->l('Status:'), - 'name' => 'name', - 'size' => 50, - 'required' => true - ), - array( - 'type' => 'color', - 'label' => $this->l('Back office color:'), - 'name' => 'color', - 'size' => 20, - 'desc' => $this->l('Back office background will be displayed in this color. HTML colors only'), - ), - ), - 'submit' => array( - 'title' => $this->l(' Save '), - 'class' => 'button' - ) - ); - } - } - - return parent::initForm(); - } - if (Tools::isSubmit('addsupply_order') || Tools::isSubmit('updatesupply_order') || Tools::isSubmit('submitAddsupply_order') || @@ -462,114 +300,12 @@ class AdminSupplyOrdersControllerCore extends AdminController public function initList() { $this->displayInformation($this->l('This interface allows you to manage supply orders.').'
'); - $this->displayInformation($this->l('Also, it allows you to add and edit your own supply order status.')); // access if (!($this->tabAccess['add'] === '1')) unset($this->toolbar_btn['new']); - //no link on list rows - $this->list_no_link = true; - - /* - * Manage default list - */ - $this->addRowAction('edit'); - $this->addRowAction('delete'); - $this->addRowActionSkipList('delete', array(1, 2, 3, 4, 5, 6)); - - $this->toolbar_title = $this->l('Stock : Suppliers Orders status'); - $first_list = parent::initList(); - - /* - * Manage second list - */ - // reset actions, toolbar and query vars - $this->actions = array(); - $this->list_skip_actions = array(); - $this->toolbar_btn = array(); - $this->toolbar_title = ''; - unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter); - - // override table, land, className and identifier for the current controller - $this->table = 'supply_order'; - $this->className = 'SupplyOrder'; - $this->identifier = 'id_supply_order'; - $this->lang = false; - - $this->addRowAction('updatereceipt'); - $this->addRowAction('changestate'); - $this->addRowAction('edit'); - $this->addRowAction('view'); - $this->addRowAction('details'); - - // test if a filter is applied for this list - if (Tools::isSubmit('submitFilter'.$this->table) || $this->context->cookie->{'submitFilter'.$this->table} !== false) - $this->filter = true; - - // test if a filter reset request is required for this list - if (isset($_POST['submitReset'.$this->table])) - $this->action = 'reset_filters'; - else - $this->action = ''; - - // redifine fields display - $this->fieldsDisplay = array( - 'reference' => array( - 'title' => $this->l('Reference'), - 'width' => 130, - 'havingFilter' => true - ), - 'supplier' => array( - 'title' => $this->l('Supplier'), - 'width' => 130, - 'filter_key' => 's!name' - ), - 'warehouse' => array( - 'title' => $this->l('Warehouse'), - 'width' => 130, - 'filter_key' => 'w!name' - ), - 'state' => array( - 'title' => $this->l('Status'), - 'width' => 200, - 'filter_key' => 'stl!name', - 'color' => 'color', - ), - 'date_add' => array( - 'title' => $this->l('Creation'), - 'width' => 150, - 'align' => 'right', - 'type' => 'date', - 'havingFilter' => true, - 'filter_key' => 'a!date_add' - ), - 'date_upd' => array( - 'title' => $this->l('Last modification'), - 'width' => 150, - 'align' => 'right', - 'type' => 'date', - 'havingFilter' => true, - 'filter_key' => 'a!date_upd' - ), - 'date_delivery_expected' => array( - 'title' => $this->l('Delivery (expected)'), - 'width' => 150, - 'align' => 'right', - 'type' => 'date', - 'havingFilter' => true, - 'filter_key' => 'a!date_delivery_expected' - ), - 'id_pdf' => array( - 'title' => $this->l('PDF'), - 'width' => 80, - 'callback' => 'printPDFIcons', - 'orderby' => false, - 'search' => false - ), - ); - - // make new query + // overrides query $this->_select = ' s.name AS supplier, w.name AS warehouse, @@ -591,17 +327,7 @@ class AdminSupplyOrdersControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'supplier` s ON a.id_supplier = s.id_supplier LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = a.id_warehouse)'; - // init the toolbar according to the current list - $this->initToolbar(); - - // generate the second list - $second_list = parent::initList(); - - // reset all query vars - unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter); - - // return the two lists - return $second_list.$first_list; + return parent::initList(); } /** diff --git a/img/t/AdminStockConfiguration.gif b/img/t/AdminStockConfiguration.gif new file mode 100755 index 0000000000000000000000000000000000000000..1186f6030dc7f42d29a1acefb9af3411ab9c1313 GIT binary patch literal 416 zcmV;R0bl+{Nk%w1VGsZi0Hr?wOiWBrP*7Auz*?Ck9A?d|mR z^#A|=A^r(dbZ=v8AWe3303rDV0SW*=04x9i000mG5C8xMu)v>i*eP~~$fU;S(ob{rSSv3hLJtpbC>sxi z8z^yw4LdL#}%a