diff --git a/admin-dev/themes/default/template/content.tpl b/admin-dev/themes/default/template/content.tpl index e32da791e..eb075512c 100644 --- a/admin-dev/themes/default/template/content.tpl +++ b/admin-dev/themes/default/template/content.tpl @@ -22,7 +22,8 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - + +{* ajaxBox allows*} {if isset($content)} {if isset($show_page_header_toolbar) && $show_page_header_toolbar}
diff --git a/admin-dev/themes/default/template/controllers/access/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/access/helpers/form/form.tpl index 16c22b750..ce120f0d0 100644 --- a/admin-dev/themes/default/template/controllers/access/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/access/helpers/form/form.tpl @@ -172,7 +172,7 @@ {include file="toolbar.tpl" toolbar_btn=$toolbar_btn toolbar_scroll=$toolbar_scroll title=$title}
{block name="leadin"}{/block}
{/if} - +
{foreach $profiles as $profile} @@ -416,11 +416,14 @@
{else} -
- {l s='Administrator permissions cannot be modified.'} -
+
+
+ {l s='Administrator permissions cannot be modified.'} +
+
{/if}
{/foreach} - \ No newline at end of file + +
\ No newline at end of file diff --git a/admin-dev/themes/default/template/footer.tpl b/admin-dev/themes/default/template/footer.tpl index 9d1486477..078fe41ed 100644 --- a/admin-dev/themes/default/template/footer.tpl +++ b/admin-dev/themes/default/template/footer.tpl @@ -66,8 +66,6 @@ }); - -{* ajaxBox allows*} {/if} \ No newline at end of file diff --git a/admin-dev/themes/default/template/helpers/list/list_action_details.tpl b/admin-dev/themes/default/template/helpers/list/list_action_details.tpl index 79748ec37..73806fc67 100644 --- a/admin-dev/themes/default/template/helpers/list/list_action_details.tpl +++ b/admin-dev/themes/default/template/helpers/list/list_action_details.tpl @@ -23,6 +23,6 @@ * International Registered Trademark & Property of PrestaShop SA *} - - {$action} + + {$action} diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 5bcc9e662..229a3c197 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -1528,7 +1528,7 @@ class AdminControllerCore extends Controller $this->errors[] = Tools::displayError('You do not have permission to view this.'); return; } - + $this->getLanguages(); // toolbar (save, cancel, new, ..) $this->initToolbar(); @@ -1547,6 +1547,10 @@ class AdminControllerCore extends Controller $this->loadObject(true); $this->content .= $this->renderView(); } + elseif ($this->display == 'details') + { + $this->content .= $this->renderDetails(); + } elseif (!$this->ajax) { $this->content .= $this->renderModulesList(); @@ -1722,6 +1726,14 @@ class AdminControllerCore extends Controller return $view; } + /** + * Override to render the view page + */ + public function renderDetails() + { + return $this->renderList(); + } + /** * Function used to render the form for this controller */ @@ -2147,6 +2159,16 @@ class AdminControllerCore extends Controller else $this->errors[] = Tools::displayError('You do not have permission to view this.'); } + elseif (isset($_GET['details'.$this->table])) + { + if ($this->tabAccess['view'] === '1') + { + $this->display = 'details'; + $this->action = 'details'; + } + else + $this->errors[] = Tools::displayError('You do not have permission to view this.'); + } elseif (isset($_GET['export'.$this->table])) { if ($this->tabAccess['view'] === '1') diff --git a/classes/helper/HelperList.php b/classes/helper/HelperList.php index 46ab16b62..9248a75ea 100644 --- a/classes/helper/HelperList.php +++ b/classes/helper/HelperList.php @@ -388,6 +388,7 @@ class HelperListCore extends Helper $tpl->assign(array( 'id' => Tools::safeOutput($id), + 'href' => Tools::safeOutput($this->currentIndex.'&'.$this->identifier.'='.$id.'&details'.$this->table.'&token='.($token != null ? $token : $this->token)), 'controller' => str_replace('Controller', '', get_class($this->context->controller)), 'token' => Tools::safeOutput($token != null ? $token : $this->token), 'action' => self::$cache_lang['Details'], diff --git a/controllers/admin/AdminStockManagementController.php b/controllers/admin/AdminStockManagementController.php index bba5485b2..9f51ddc6b 100644 --- a/controllers/admin/AdminStockManagementController.php +++ b/controllers/admin/AdminStockManagementController.php @@ -34,6 +34,7 @@ class AdminStockManagementControllerCore extends AdminController $this->bootstrap = true; $this->context = Context::getContext(); $this->table = 'product'; + $this->list_id = 'product'; $this->className = 'Product'; $this->lang = true; $this->multishop_context = Shop::CONTEXT_ALL; @@ -41,17 +42,14 @@ class AdminStockManagementControllerCore extends AdminController $this->fields_list = array( 'reference' => array( 'title' => $this->l('Product reference'), - 'align' => 'center', 'filter_key' => 'a!reference' ), 'ean13' => array( 'title' => $this->l('EAN13'), - 'align' => 'center', 'filter_key' => 'a!ean13' ), 'upc' => array( 'title' => $this->l('UPC'), - 'align' => 'center', 'filter_key' => 'a!upc' ), 'name' => array( @@ -80,7 +78,15 @@ class AdminStockManagementControllerCore extends AdminController public function initPageHeaderToolbar() { - $this->page_header_toolbar_title = $this->l('Stock management'); + $this->page_header_toolbar_title = $this->l('Stock management'); + + if ($this->display == 'details') + $this->page_header_toolbar_btn['back_to_list'] = array( + 'href' => Context::getContext()->link->getAdminLink('AdminStockManagement'), + 'desc' => $this->l('Back to list'), + 'icon' => 'process-icon-back' + ); + parent::initPageHeaderToolbar(); } @@ -94,7 +100,9 @@ class AdminStockManagementControllerCore extends AdminController $this->addRowAction('details'); $this->addRowAction('addstock'); $this->addRowAction('removestock'); - $this->addRowAction('transferstock'); + + if (count(Warehouse::getWarehouses()) > 1) + $this->addRowAction('transferstock'); // no link on list rows $this->list_no_link = true; @@ -793,109 +801,76 @@ class AdminStockManagementControllerCore extends AdminController } } - public function renderView() + public function renderDetails() { - if (Tools::isSubmit('id')) + if (Tools::isSubmit('id_product')) { // override attributes $this->identifier = 'id_product_attribute'; - $this->display = 'list'; + $this->list_id = 'product_attribute'; $this->lang = false; $this->addRowAction('addstock'); $this->addRowAction('removestock'); - $this->addRowAction('transferstock'); + + if (count(Warehouse::getWarehouses()) > 1) + $this->addRowAction('transferstock'); + + // no link on list rows + $this->list_no_link = true; + + // inits toolbar + $this->toolbar_btn = array(); // get current lang id $lang_id = (int)$this->context->language->id; // Get product id - $product_id = (int)Tools::getValue('id'); + $product_id = (int)Tools::getValue('id_product'); // Load product attributes with sql override $this->table = 'product_attribute'; - + $this->list_id = 'product_attribute'; $this->_select = 'a.id_product_attribute as id, a.id_product, a.reference, a.ean13, a.upc'; - $this->_where = 'AND a.id_product = '.$product_id; $this->_group = 'GROUP BY a.id_product_attribute'; - // get list and force no limit clause in the request - $this->getList($this->context->language->id, null, null, 0, false); + $this->fields_list = array( + 'reference' => array( + 'title' => $this->l('Product reference'), + 'filter_key' => 'a!reference' + ), + 'ean13' => array( + 'title' => $this->l('EAN13'), + 'filter_key' => 'a!ean13' + ), + 'upc' => array( + 'title' => $this->l('UPC'), + 'filter_key' => 'a!upc' + ), + 'name' => array( + 'title' => $this->l('Name'), + 'orderby' => false, + 'filter' => false, + 'search' => false + ), + 'stock' => array( + 'title' => $this->l('Quantity'), + 'orderby' => false, + 'filter' => false, + 'search' => false, + 'class' => 'fixed-width-sm', + 'align' => 'center', + 'hint' => $this->l('Quantitity total for all warehouses.') + ), + ); - // Render list - $helper = new HelperList(); - $helper->bulk_actions = array(); - $helper->toolbar_scroll = $this->toolbar_scroll; - $helper->show_toolbar = false; - $helper->actions = $this->actions; - $helper->list_skip_actions = $this->list_skip_actions; - $helper->no_link = true; - $helper->shopLinkType = ''; - $helper->identifier = $this->identifier; - // Force render - no filter, form, js, sorting ... - $helper->simple_header = true; - $content = $helper->generateList($this->_list, $this->fields_list); - - return parent::renderView(); + self::$currentIndex = self::$currentIndex.'&id_product='.(int)$product_id.'&detailsproduct'; + $this->processFilter(); + return parent::renderList(); } } - /** - * method call when ajax request is made with the details row action - * @see AdminController::postProcess() - */ - public function ajaxProcess() - { - // test if an id is submit - if (Tools::isSubmit('id')) - { - // override attributes - $this->identifier = 'id_product_attribute'; - $this->display = 'list'; - $this->lang = false; - - $this->addRowAction('addstock'); - $this->addRowAction('removestock'); - $this->addRowAction('transferstock'); - - // get current lang id - $lang_id = (int)$this->context->language->id; - - // Get product id - $product_id = (int)Tools::getValue('id'); - - // Load product attributes with sql override - $this->table = 'product_attribute'; - - $this->_select = 'a.id_product_attribute as id, a.id_product, a.reference, a.ean13, a.upc'; - - $this->_where = 'AND a.id_product = '.$product_id; - $this->_group = 'GROUP BY a.id_product_attribute'; - - // get list and force no limit clause in the request - $this->getList($this->context->language->id, null, null, 0, false); - - // Render list - $helper = new HelperList(); - $helper->bulk_actions = array(); - $helper->toolbar_scroll = $this->toolbar_scroll; - $helper->show_toolbar = false; - $helper->actions = $this->actions; - $helper->list_skip_actions = $this->list_skip_actions; - $helper->no_link = true; - $helper->shopLinkType = ''; - $helper->identifier = $this->identifier; - // Force render - no filter, form, js, sorting ... - $helper->simple_header = true; - $content = $helper->generateList($this->_list, $this->fields_list); - - echo Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content)); - } - - die; - } - /** * AdminController::getList() override * @see AdminController::getList() @@ -904,54 +879,52 @@ class AdminStockManagementControllerCore extends AdminController { parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); - if ($this->display == 'list') + // Check each row to see if there are combinations and get the correct action in consequence + $nb_items = count($this->_list); + + for ($i = 0; $i < $nb_items; $i++) { - // Check each row to see if there are combinations and get the correct action in consequence - $nb_items = count($this->_list); + $item = &$this->_list[$i]; - for ($i = 0; $i < $nb_items; $i++) + // if it's an ajax request we have to consider manipulating a product variation + if (Tools::isSubmit('id_product')) { - $item = &$this->_list[$i]; + $item['name'] = Product::getProductName($item['id_product'], $item['id']); + // no details for this row + $this->addRowActionSkipList('details', array($item['id'])); - // if it's an ajax request we have to consider manipulating a product variation - if ($this->ajax == '1') - { - $item['name'] = Product::getProductName($item['id_product'], $item['id']); - // no details for this row - $this->addRowActionSkipList('details', array($item['id'])); + // specify actions in function of stock + $this->skipActionByStock($item, true); - // specify actions in function of stock - $this->skipActionByStock($item, true); - } - // If current product has variations - else if ((int)$item['variations'] > 0) - { - // we have to desactivate stock actions on current row - $this->addRowActionSkipList('addstock', array($item['id'])); - $this->addRowActionSkipList('removestock', array($item['id'])); - $this->addRowActionSkipList('transferstock', array($item['id'])); - - // does not display these informaions because this product has combinations - $item['reference'] = '--'; - $item['ean13'] = '--'; - $item['upc'] = '--'; - } - else - { - //there are no variations of current product, so we don't want to show details action - $this->addRowActionSkipList('details', array($item['id'])); - - // specify actions in function of stock - $this->skipActionByStock($item, false); - } - // Checks access - if (!($this->tabAccess['add'] === '1')) - $this->addRowActionSkipList('addstock', array($item['id'])); - if (!($this->tabAccess['delete'] === '1')) - $this->addRowActionSkipList('removestock', array($item['id'])); - if (!($this->tabAccess['edit'] === '1')) - $this->addRowActionSkipList('transferstock', array($item['id'])); } + // If current product has variations + else if (array_key_exists('variations', $item) && (int)$item['variations'] > 0) + { + // we have to desactivate stock actions on current row + $this->addRowActionSkipList('addstock', array($item['id'])); + $this->addRowActionSkipList('removestock', array($item['id'])); + $this->addRowActionSkipList('transferstock', array($item['id'])); + + // does not display these informaions because this product has combinations + $item['reference'] = '--'; + $item['ean13'] = '--'; + $item['upc'] = '--'; + } + else + { + //there are no variations of current product, so we don't want to show details action + $this->addRowActionSkipList('details', array($item['id'])); + + // specify actions in function of stock + $this->skipActionByStock($item, false); + } + // Checks access + if (!($this->tabAccess['add'] === '1')) + $this->addRowActionSkipList('addstock', array($item['id'])); + if (!($this->tabAccess['delete'] === '1')) + $this->addRowActionSkipList('removestock', array($item['id'])); + if (!($this->tabAccess['edit'] === '1')) + $this->addRowActionSkipList('transferstock', array($item['id'])); } } @@ -1115,7 +1088,7 @@ class AdminStockManagementControllerCore extends AdminController } else { - $this->display = 'list'; + //$this->display = 'list'; parent::initContent(); } } @@ -1190,6 +1163,17 @@ class AdminStockManagementControllerCore extends AdminController $this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You need to activate advanced stock management prior to using this feature.'); return false; } + + if (Tools::getIsset('detailsproduct')) + { + $this->list_id = 'product_attribute'; + + if (isset($_POST['submitReset'.$this->list_id])) + $this->processResetFilters(); + } + else + $this->list_id = 'product'; + parent::initProcess(); } }