private function _displayFormApplicationCriterion() { include_once dirname(__FILE__) . '/ProductCommentCriterion.php'; $criterions = ProductCommentCriterion::getCriterions($this->context->language->id, false, true); $id_criterion = (int) Tools::getValue('updateCriterion'); if ($id_criterion) { $criterion = new ProductCommentCriterion((int) $id_criterion); if ($criterion->id_product_comment_criterion_type == 2) { $categories = Category::getSimpleCategories($this->context->language->id); $criterion_categories = $criterion->getCategories(); } else { if ($criterion->id_product_comment_criterion_type == 3) { $criterion_products = $criterion->getProducts(); $products = Product::getSimpleProducts($this->context->language->id); } } } foreach ($criterions as $key => $foo) { if ($foo['id_product_comment_criterion_type'] == 1) { unset($criterions[$key]); } } if (count($criterions)) { $this->_html .= ' <fieldset class="width2"> <legend><img src="' . $this->_path . 'img/note_go.png" alt="" title="" />' . $this->l('Manage criterions scope') . '</legend> <p style="margin-bottom: 15px;">' . $this->l('Only criterions restricted to categories or products can be configured below:') . '</p> <form action="' . Tools::safeOutput($this->_baseUrl) . '" method="post" name="product_criterion_form"> <label>' . $this->l('Criterion') . '</label> <div class="margin-form"> "> <select name="id_product_comment_criterion" id="id_product_comment_criterion" onchange="window.location=\'' . Tools::safeOutput($this->_baseUrl) . '&updateCriterion=\'+$(\'#id_product_comment_criterion option:selected\').val()"> <option value="--">-- ' . $this->l('Choose a criterion') . ' --</option>'; foreach ($criterions as $foo) { $this->_html .= '<option value="' . (int) $foo['id_product_comment_criterion'] . '" ' . ($foo['id_product_comment_criterion'] == $id_criterion ? 'selected="selected"' : '') . '>' . $foo['name'] . '</option>'; } $this->_html .= '</select> </div> </form>'; if ($id_criterion && $criterion->id_product_comment_criterion_type != 1) { $this->_html .= '<label for="id_product_comment_criterion">' . ($criterion->id_product_comment_criterion_type == 3 ? $this->l('Products') : $this->l('Categories')) . '</label> <form action="' . Tools::safeOutput($this->_baseUrl) . '" method="post" name="comment_form"> <div id="product_criterions" class="margin-form"> <input type="hidden" name="id_criterion" id="id_criterion" value="' . (int) $id_criterion . '" /> <br /><table class="table" border="0" cellspacing="0" cellpadding="0"> <thead> <tr> <th><input class="noborder" type="checkbox" name="id_product[]" onclick="checkDelBoxes(this.form, \'id_product[]\', this.checked);" /></th> <th style="width: 30px;">' . $this->l('ID') . '</th> <th style="width: 550px;">' . ($criterion->id_product_comment_criterion_type == 3 ? $this->l('Product Name') : $this->l('Category Name')) . '</th> </tr> </thead> <tbody>'; if ($criterion->id_product_comment_criterion_type == 3) { foreach ($products as $product) { $this->_html .= '<tr><td><input class="noborder" type="checkbox" value="' . (int) $product['id_product'] . '" name="id_product[]" ' . (in_array($product['id_product'], $criterion_products) ? 'checked="checked"' : '') . ' /></td> <td>' . (int) $product['id_product'] . '</td><td>' . $product['name'] . '</td></tr>'; } } else { if ($criterion->id_product_comment_criterion_type == 2) { foreach ($categories as $category) { $this->_html .= '<tr><td><input class="noborder" type="checkbox" value="' . (int) $category['id_category'] . '" name="id_product[]" ' . (in_array($category['id_category'], $criterion_categories) ? 'checked="checked"' : '') . ' /></td> <td>' . (int) $category['id_category'] . '</td><td>' . $category['name'] . '</td></tr>'; } } } $this->_html .= '</tbody> </table> </div> <div class="margin-form clear"> <input type="submit" name="submitApplicationCriterion" value="' . $this->l('Save') . '" class="button" /> </div> </form>'; } $this->_html .= '</fieldset>'; } }
public function renderCriterionList() { include_once dirname(__FILE__) . '/ProductCommentCriterion.php'; $criterions = ProductCommentCriterion::getCriterions($this->context->language->id, false, false); $fields_list = array('id_product_comment_criterion' => array('title' => $this->l('ID'), 'type' => 'text'), 'name' => array('title' => $this->l('Name'), 'type' => 'text'), 'type_name' => array('title' => $this->l('Type'), 'type' => 'text'), 'active' => array('title' => $this->l('Status'), 'active' => 'status', 'type' => 'bool')); $helper = new HelperList(); $helper->shopLinkType = ''; $helper->simple_header = false; $helper->actions = array('edit', 'delete'); $helper->show_toolbar = true; $helper->toolbar_btn['new'] = array('href' => $this->context->link->getAdminLink('AdminModules') . '&configure=' . $this->name . '&module_name=' . $this->name . '&updateproductcommentscriterion', 'desc' => $this->l('Add New Criterion', null, null, false)); $helper->module = $this; $helper->identifier = 'id_product_comment_criterion'; $helper->title = $this->l('Review Criteria'); $helper->table = $this->name . 'criterion'; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name; //$helper->tpl_vars = array('priority' => array($this->l('High'), $this->l('Medium'), $this->l('Low'))); return $helper->generateList($criterions, $fields_list); }