public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('report/purchased'); $this->loadModel('report/purchased'); //Prepare filter config $filter_params = array('date_start', 'date_end'); if (!$this->request->get['date_start']) { $this->request->get['date_start'] = dateInt2Display(strtotime('-30 day')); } if (!$this->request->get['date_end']) { $this->request->get['date_end'] = dateInt2Display(time()); } $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); $filter_grid = new AFilter(array('method' => 'post')); $data = array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()); $total = $this->model_report_purchased->getTotalOrderedProducts($data); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $results = $this->model_report_purchased->getProductPurchasedReport($data); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $i; $response->rows[$i]['cell'] = array($result['name'], $result['model'], $result['quantity'], $this->currency->format($result['total'], $this->config->get('config_currency'))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); //load available groups for settings $this->loadLanguage('setting/setting'); $this->loadModel('setting/setting'); //Prepare filter config $grid_filter_params = array('alias', 'group', 'key'); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $total = $this->model_setting_setting->getTotalSettings($filter_grid->getFilterData()); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $results = $this->model_setting_setting->getAllSettings($filter_grid->getFilterData()); $i = 0; foreach ($results as $result) { if (($result['value'] == '1' || $result['value'] == '0') && !is_int(strpos($result['key'], '_id')) && !is_int(strpos($result['key'], 'level'))) { $value = $this->html->buildCheckbox(array('name' => '', 'value' => $result['value'], 'style' => 'btn_switch', 'attr' => 'readonly="true"')); } else { $value = $result['value']; } $response->rows[$i]['id'] = $result['group'] . '-' . $result['key'] . '-' . $result['store_id']; $response->rows[$i]['cell'] = array($result['alias'], $result['group'], $result['key'], $value); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/download'); $this->loadModel('catalog/download'); //Prepare filter config $grid_filter_params = array('name'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params, 'additional_filter_string' => 'shared=1')); $filter_data = $filter->getFilterData(); $total = $this->model_catalog_download->getTotalDownloads($filter_data); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $response->userdata = new stdClass(); $results = $this->model_catalog_download->getDownloads($filter_data); $i = 0; foreach ($results as $result) { if (!is_file(DIR_RESOURCE . $result['filename'])) { $response->userdata->classes[$result['download_id']] = 'warning'; } $response->rows[$i]['id'] = $result['download_id']; $response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'name[' . $result['download_id'] . ']', 'value' => $result['name'], 'attr' => ' maxlength="64" ')), $this->html->buildCheckbox(array('name' => 'status[' . $result['download_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), $result['product_count']); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/manufacturer'); $this->loadModel('catalog/manufacturer'); $this->loadModel('tool/image'); //Prepare filter config $grid_filter_params = array('name'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $filter_data = $filter->getFilterData(); $total = $this->model_catalog_manufacturer->getTotalManufacturers($filter_data); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $results = $this->model_catalog_manufacturer->getManufacturers($filter_data); $resource = new AResource('image'); $i = 0; foreach ($results as $result) { $thumbnail = $resource->getMainThumb('manufacturers', $result['manufacturer_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true); $response->rows[$i]['id'] = $result['manufacturer_id']; $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $this->html->buildInput(array('name' => 'name[' . $result['manufacturer_id'] . ']', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'sort_order[' . $result['manufacturer_id'] . ']', 'value' => $result['sort_order']))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('localisation/language'); $this->loadModel('localisation/language'); //Prepare filter config $filter_params = array('name', 'status'); $grid_filter_params = array('name', 'code', 'sort_order'); $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $total = $this->model_localisation_language->getTotalLanguages(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData())); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $results = $this->model_localisation_language->getLanguages(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData())); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['language_id']; $response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'name[' . $result['language_id'] . ']', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'code[' . $result['language_id'] . ']', 'value' => $result['code'])), $this->html->buildInput(array('name' => 'sort_order[' . $result['language_id'] . ']', 'value' => $result['sort_order'])), $this->html->buildCheckbox(array('name' => 'status[' . $result['language_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch'))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/review'); $this->loadModel('catalog/review'); $this->loadModel('tool/image'); //Prepare filter config $filter_params = array('product_id', 'status'); $grid_filter_params = array('name', 'author'); $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $total = $this->model_catalog_review->getTotalReviews(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData())); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $results = $this->model_catalog_review->getReviews(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData())); $resource = new AResource('image'); $i = 0; foreach ($results as $result) { $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'), true); $response->rows[$i]['id'] = $result['review_id']; $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $result['name'], $result['author'], $result['rating'], $this->html->buildCheckbox(array('name' => 'status[' . $result['review_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), dateISO2Display($result['date_added'], $this->language->get('date_format_short'))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('banner_manager/banner_manager'); $this->loadModel('extension/banner_manager'); $filter_params = array('name', 'banner_group_name', 'type', 'cnt'); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $filter_params, 'additional_filter_string' => '')); $total = $this->model_extension_banner_manager->getBannersStat($filter_grid->getFilterData(), 'total_only'); if ($total > 0) { $total_pages = ceil($total / 10); } else { $total_pages = 0; } $response = new stdClass(); $response->page = $page; $response->total = $total_pages; $response->records = $total; $results = $this->model_extension_banner_manager->getBannersStat($filter_grid->getFilterData()); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $i; $response->rows[$i]['cell'] = array($result['name'], $result['banner_group_name'], $result['clicked'], $result['viewed'], $result['percent'], '<a class="btn_action btn_grid grid_action_expand" href="' . $this->html->getSecureURL('extension/banner_manager_stat/details', '&banner_id=' . $result['banner_id']) . '" title="' . $this->language->get('text_view') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_view.png" alt="' . $this->language->get('text_view') . '" /></a>'); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('localisation/location'); $this->loadModel('localisation/location'); //Prepare filter config $grid_filter_params = array('name'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $total = $this->model_localisation_location->getTotalLocations($filter->getFilterData()); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $results = $this->model_localisation_location->getLocations($filter->getFilterData()); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['location_id']; $response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'name[' . $result['location_id'] . ']', 'value' => $result['name']))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('sale/customer_group'); $this->loadModel('sale/customer_group'); //Prepare filter config $grid_filter_params = array('name', 'tax_exempt'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $total = $this->model_sale_customer_group->getTotalCustomerGroups($filter->getFilterData()); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $results = $this->model_sale_customer_group->getCustomerGroups($filter->getFilterData()); $i = 0; $yesno = array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no')); foreach ($results as $result) { $response->rows[$i]['id'] = $result['customer_group_id']; $response->rows[$i]['cell'] = array($result['name'] . ($result['customer_group_id'] == $this->config->get('config_customer_group_id') ? $this->language->get('text_default') : NULL), $yesno[(int) $result['tax_exempt']]); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('banner_manager/banner_manager'); $this->loadModel('extension/banner_manager'); $filter_params = array('name', 'banner_group_name', 'type', 'cnt'); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $filter_params, 'additional_filter_string' => '')); $total = $this->model_extension_banner_manager->getBannersStat($filter_grid->getFilterData(), 'total_only'); if ($total > 0) { $total_pages = ceil($total / 10); } else { $total_pages = 0; } $response = new stdClass(); $response->page = $page; $response->total = $total_pages; $response->records = $total; $results = $this->model_extension_banner_manager->getBannersStat($filter_grid->getFilterData()); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['banner_id']; $response->rows[$i]['cell'] = array($result['name'], $result['banner_group_name'], $result['clicked'], $result['viewed'], $result['percent']); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('localisation/country'); $this->loadModel('localisation/country'); //Prepare filter config $grid_filter_params = array('name' => 'cd.name', 'iso_code_2' => 'c.iso_code_2', 'iso_code_3' => 'c.iso_code_3'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $total = $this->model_localisation_country->getTotalCountries($filter->getFilterData()); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $results = $this->model_localisation_country->getCountries($filter->getFilterData()); $i = 0; $language_id = $this->language->getContentLanguageID(); foreach ($results as $result) { $response->rows[$i]['id'] = $result['country_id']; $response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'country_name[' . $result['country_id'] . '][' . $language_id . '][name]', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'iso_code_2[' . $result['country_id'] . ']', 'value' => $result['iso_code_2'])), $this->html->buildInput(array('name' => 'iso_code_3[' . $result['country_id'] . ']', 'value' => $result['iso_code_3'])), $this->html->buildCheckbox(array('name' => 'status[' . $result['country_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch'))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('localisation/language_definitions'); $this->loadModel('localisation/language_definitions'); //Prepare filter config $filter_params = array('language_key', 'section'); $grid_filter_params = array('name', 'language_key', 'language_value', 'block'); $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $filter_data = array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()); $total = $this->model_localisation_language_definitions->getTotalDefinitions($filter_data); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $response->userdata = new stdClass(); $results = $this->model_localisation_language_definitions->getLanguageDefinitions($filter_data); $i = 0; foreach ($results as $result) { if ($result['error']) { $response->userdata->classes[$result['language_definition_id']] = 'warning'; } $response->userdata->section[$result['language_definition_id']] = $result['section']; $response->rows[$i]['id'] = $result['language_definition_id']; $response->rows[$i]['cell'] = array($result['block'], $result['language_key'], $this->html->buildInput(array('name' => 'language_value[' . $result['language_definition_id'] . ']', 'value' => $result['language_value'])), dateISO2Display($result['date_modified'], $this->language->get('date_format_short'))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { $this->loadLanguage('forms_manager/forms_manager'); $this->loadModel('tool/forms_manager'); //Clean up parametres if needed if (isset($this->request->get['keyword']) && $this->request->get['keyword'] == $this->language->get('filter_form')) { unset($this->request->get['keyword']); } //Prepare filter config $filter_params = array('status', 'keyword', 'match'); $grid_filter_params = array('form_name', 'description', 'status'); $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $total = $this->model_tool_forms_manager->getTotalForms(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData())); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $results = $this->model_tool_forms_manager->getForms(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData())); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['form_id']; $response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'form_name[' . $result['form_id'] . ']', 'value' => $result['form_name'])), $this->html->buildInput(array('name' => 'form_description[' . $result['form_id'] . ']', 'value' => $result['description'])), $this->html->buildCheckbox(array('name' => 'form_status[' . $result['form_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch'))); $i++; } $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/category'); $this->loadModel('catalog/category'); $this->loadModel('catalog/product'); $this->loadModel('tool/image'); //Prepare filter config $grid_filter_params = array('name'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $filter_data = $filter->getFilterData(); //Add custom params $filter_data['parent_id'] = isset($this->request->get['parent_id']) ? $this->request->get['parent_id'] : 0; $new_level = 0; //get all leave categories $leafnodes = $this->model_catalog_category->getLeafCategories(); if ($this->request->post['nodeid']) { $sort = $filter_data['sort']; $order = $filter_data['order']; //reset filter to get only parent category $filter_data = array(); $filter_data['sort'] = $sort; $filter_data['order'] = $order; $filter_data['parent_id'] = (int) $this->request->post['nodeid']; $new_level = (int) $this->request->post["n_level"] + 1; } $total = $this->model_catalog_category->getTotalCategories($filter_data); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $response->userdata = new stdClass(); $results = $this->model_catalog_category->getCategoriesData($filter_data); $i = 0; $resource = new AResource('image'); foreach ($results as $result) { $thumbnail = $resource->getMainThumb('categories', $result['category_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true); $response->rows[$i]['id'] = $result['category_id']; $cnt = $this->model_catalog_category->getCategoriesData(array('parent_id' => $result['category_id']), 'total_only'); if (!$result['products_count']) { $products_count = $result['products_count']; } else { $products_count = $this->html->buildButton(array('name' => 'view products', 'text' => $result['products_count'], 'style' => 'button2', 'href' => $this->html->getSecureURL('catalog/product', '&category=' . $result['category_id']), 'title' => $this->language->get('text_view') . ' ' . $this->language->get('tab_product'), 'target' => '_blank')); } //tree grid structure if ($this->config->get('config_show_tree_data')) { $name_lable = '<label style="white-space: nowrap;">' . $result['basename'] . '</label>'; } else { $name_lable = '<label style="white-space: nowrap;">' . str_replace($result['basename'], '', $result['name']) . '</label>' . $this->html->buildInput(array('name' => 'category_description[' . $result['category_id'] . '][' . $this->session->data['content_language_id'] . '][name]', 'value' => $result['basename'], 'attr' => ' maxlength="32" ')); } $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $name_lable, $this->html->buildInput(array('name' => 'sort_order[' . $result['category_id'] . ']', 'value' => $result['sort_order'])), $this->html->buildCheckbox(array('name' => 'status[' . $result['category_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), $products_count, $cnt . ($cnt ? ' <a class="btn_action btn_grid grid_action_expand" href="#" rel="parent_id=' . $result['category_id'] . '" title="' . $this->language->get('text_view') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_expand.png" alt="' . $this->language->get('text_view') . '" /></a>' : ''), 'action', $new_level, $filter_data['parent_id'] ? $filter_data['parent_id'] : NULL, $result['category_id'] == $leafnodes[$result['category_id']] ? true : false, false); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('design/content'); $this->acm = new AContentManager(); //Prepare filter config $grid_filter_params = array('sort_order', 'id.title', 'status', 'nodeid'); //Build advanced filter $filter_data = array('method' => 'post', 'grid_filter_params' => $grid_filter_params); $filter_grid = new AFilter($filter_data); $filter_array = $filter_grid->getFilterData(); if ($this->request->post['nodeid']) { list($void, $parent_id) = explode('_', $this->request->post['nodeid']); $filter_array['parent_id'] = $parent_id; if ($filter_array['subsql_filter']) { $filter_array['subsql_filter'] .= " AND i.parent_content_id='" . (int) $filter_array['parent_id'] . "' "; } else { $filter_array['subsql_filter'] = " i.parent_content_id='" . (int) $filter_array['parent_id'] . "' "; } $new_level = (int) $this->request->post["n_level"] + 1; } else { //Add custom params $filter_array['parent_id'] = $new_level = 0; if ($this->config->get('config_show_tree_data')) { if ($filter_array['subsql_filter']) { $filter_array['subsql_filter'] .= " AND i.parent_content_id='0' "; } else { $filter_array['subsql_filter'] = " i.parent_content_id='0' "; } } } $leafnodes = $this->config->get('config_show_tree_data') ? $this->acm->getLeafContents() : array(); $total = $this->acm->getTotalContents($filter_array); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $response->userdata = (object) array(''); $results = $this->acm->getContents($filter_array); $results = !$results ? array() : $results; $i = 0; foreach ($results as $result) { if ($this->config->get('config_show_tree_data')) { $title_lable = '<label style="white-space: nowrap;">' . $result['title'] . '</label>'; } else { $title_lable = $result['title']; } $parent_content_id = current($result['parent_content_id']); $response->rows[$i]['id'] = $parent_content_id . '_' . $result['content_id']; $response->rows[$i]['cell'] = array($title_lable, $result['parent_name'], $this->html->buildCheckbox(array('name' => 'status[' . $parent_content_id . '_' . $result['content_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), $this->html->buildInput(array('name' => 'sort_order[' . $parent_content_id . '_' . $result['content_id'] . ']', 'value' => $result['sort_order'][$parent_content_id])), 'action', $new_level, $this->request->post['nodeid'] ? $this->request->post['nodeid'] : null, $result['content_id'] == $leafnodes[$result['content_id']] ? true : false, false); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('tool/message_manager'); if (!$this->user->canAccess('tool/message_manager')) { $response = new stdClass(); $response->userdata->error = sprintf($this->language->get('error_permission_access'), 'tool/message_manager'); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); return; } $this->loadModel('tool/message_manager'); //Prepare filter config $grid_filter_params = array('title', 'create_date', 'status'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $total = $this->model_tool_message_manager->getTotalMessages(); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $response->userdata = new stdClass(); $sort_array = $filter->getFilterData(); if ($sort_array['sort'] == 'sort_order') { $sort_array['sort'] = 'viewed'; } $results = $this->model_tool_message_manager->getMessages($sort_array); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['msg_id']; switch ($result['status']) { case 'E': $status = $this->language->get('entry_error'); $response->userdata->classes[$result['msg_id']] = 'warning'; break; case 'W': $status = $this->language->get('entry_warning'); $response->userdata->classes[$result['msg_id']] = 'attention'; break; case 'N': default: $status = $this->language->get('entry_notice'); $response->userdata->classes[$result['msg_id']] = 'success'; break; } $style = !$result['viewed'] ? 'style="font-weight: bold;"' : ''; $link = '<a href="JavaScript:void(0);" ' . $style . ' onclick="show_popup(' . $result['msg_id'] . ')">' . $result['title'] . '</a>'; $action = '<a class="btn_action" href="JavaScript:void(0);" onclick="show_popup(' . $result['msg_id'] . ')" title="' . $this->language->get('text_edit') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_view.png" alt="' . $this->language->get('text_edit') . '" /></a>'; $action .= '<a class="btn_action" href="JavaScript:void(0);" onclick="msg_id = ' . $result['msg_id'] . '; delete_msg();" title="' . $this->language->get('text_delete') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_delete.png" alt="' . $this->language->get('text_delete') . '" /></a>'; $response->rows[$i]['cell'] = array($status, $link, $result['create_date'], $action); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/product'); $this->loadModel('catalog/product'); $this->loadModel('tool/image'); //Clean up parametres if needed if (isset($this->request->get['keyword']) && $this->request->get['keyword'] == $this->language->get('filter_product')) { unset($this->request->get['keyword']); } if (isset($this->request->get['pfrom']) && $this->request->get['pfrom'] == 0) { unset($this->request->get['pfrom']); } if (isset($this->request->get['pto']) && $this->request->get['pto'] == $this->language->get('filter_price_max')) { unset($this->request->get['pto']); } //Prepare filter config $filter_params = array('category', 'status', 'keyword', 'match', 'pfrom', 'pto'); $grid_filter_params = array('name', 'sort_order', 'model'); $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $data = array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()); $total = $this->model_catalog_product->getTotalProducts($data); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $response->userdata = new stdClass(); $response->userdata->classes = array(); $results = $this->model_catalog_product->getProducts($data); $product_ids = array(); foreach ($results as $result) { $product_ids[] = (int) $result['product_id']; } $resource = new AResource('image'); $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height')); $i = 0; foreach ($results as $result) { $thumbnail = $thumbnails[$result['product_id']]; $response->rows[$i]['id'] = $result['product_id']; if (dateISO2Int($result['date_available']) > time()) { $response->userdata->classes[$result['product_id']] = 'warning'; } if ($result['call_to_order'] > 0) { $price = $this->language->get('text_call_to_order'); } else { $price = $this->html->buildInput(array('name' => 'price[' . $result['product_id'] . ']', 'value' => moneyDisplayFormat($result['price']))); } $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $this->html->buildInput(array('name' => 'product_description[' . $result['product_id'] . '][name]', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'model[' . $result['product_id'] . ']', 'value' => $result['model'])), $price, $this->html->buildInput(array('name' => 'quantity[' . $result['product_id'] . ']', 'value' => $result['quantity'])), $this->html->buildCheckbox(array('name' => 'status[' . $result['product_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch'))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('design/blocks'); $page = $this->request->post['page']; // get the requested page if ((int) $page < 0) { $page = 0; } $limit = $this->request->post['rows']; // get how many rows we want to have into the grid //process custom search form $grid_filter_params = array('block_txt_id', 'name'); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $layout = new ALayoutManager(); $total = $layout->getBlocksList($filter_grid->getFilterData(), 'total_only'); $blocks = $layout->getBlocksList($filter_grid->getFilterData()); $tmp = array(); // prepare block list (delete template duplicates) foreach ($blocks as $block) { // skip base custom blocks if (!$block['custom_block_id'] && in_array($block['block_txt_id'], array('html_block', 'listing_block'))) { continue; } $tmp[$block['block_id'] . '_' . $block['custom_block_id']] = $block; } $blocks = $tmp; if ($total > 0) { $total_pages = ceil($total / $limit); } else { $total_pages = 0; } $response = new stdClass(); $response->page = $page; $response->total = $total_pages; $response->records = $total; $response->userdata = new stdClass(); $i = 0; foreach ($blocks as $result) { $response->rows[$i]['id'] = $result['custom_block_id'] ? $result['block_id'] . '_' . $result['custom_block_id'] : $result['block_id']; $id = $response->rows[$i]['id']; if (!$result['custom_block_id']) { $response->userdata->classes[$id] = 'disable-edit disable-delete'; } $response->rows[$i]['cell'] = array($result['custom_block_id'] ? $result['block_id'] . '_' . $result['custom_block_id'] : $result['block_id'], $result['block_txt_id'], $result['block_name'], isset($result['status']) ? $this->html->buildCheckbox(array('name' => 'status[' . $id . ']', 'value' => $result['status'], 'style' => 'btn_switch', 'attr' => 'readonly="true"')) : '', $result['block_date_added']); $i++; } $this->data = $response; //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($this->data)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('tool/message_manager'); if (!$this->user->canAccess('tool/message_manager')) { $response = new stdClass(); $response->userdata->error = sprintf($this->language->get('error_permission_access'), 'tool/message_manager'); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); return null; } $this->loadModel('tool/message_manager'); //Prepare filter config $grid_filter_params = array('title', 'date_added', 'status'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $total = $this->model_tool_message_manager->getTotalMessages(); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $response->userdata = new stdClass(); $sort_array = $filter->getFilterData(); if ($sort_array['sort'] == 'sort_order') { $sort_array['sort'] = 'viewed'; } $results = $this->model_tool_message_manager->getMessages($sort_array); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['msg_id']; switch ($result['status']) { case 'E': $status = $this->language->get('entry_error'); $response->userdata->classes[$result['msg_id']] = 'warning'; break; case 'W': $status = $this->language->get('entry_warning'); $response->userdata->classes[$result['msg_id']] = 'attention'; break; case 'N': default: $status = $this->language->get('entry_notice'); $response->userdata->classes[$result['msg_id']] = 'success'; break; } $response->userdata->classes[$result['msg_id']] .= !$result['viewed'] ? ' new_message' : ''; $response->rows[$i]['cell'] = array($status, $result['title'], dateISO2Display($result['date_added'], $this->language->get('date_format_short') . ' H:s')); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function get() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('sale/customer'); $this->loadModel('sale/customer'); $approved = array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no')); $filter_params = array('loginname', 'firstname', 'lastname', 'email', 'telephone', 'fax', 'customer_group_id', 'approved'); //no keyword search here $grid_filter_params = array(); $filter_data = array('method' => 'get', 'filter_params' => $filter_params, 'grid_filter_params' => $grid_filter_params); $filter = new AFilter($filter_data); if (!$filter->getFilterParam('loginname') && !$filter->getFilterParam('lastname')) { $this->rest->setResponseData(array('Error' => 'Login name or last name is required for customers search')); $this->rest->sendResponse(200); return null; } if (!$filter->getFilterParam('loginname') && strlen($filter->getFilterParam('lastname')) < 3) { $this->rest->setResponseData(array('Error' => 'Minimum last name length for search is 3 characters')); $this->rest->sendResponse(200); return null; } $total = $this->model_sale_customer->getTotalCustomers($filter->getFilterData()); if ($total > 0) { $total_pages = ceil($total / $filter->getParam('rows')); } else { $total_pages = 0; } //Preserved jqGrid JSON interface $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $total_pages; $response->records = $total; $results = $this->model_sale_customer->getCustomers($filter->getFilterData()); $i = 0; if ($results) { foreach ($results as $result) { $response->rows[$i]['id'] = $result['customer_id']; $response->rows[$i]['cell']['loginname'] = $result['loginname']; $response->rows[$i]['cell']['name'] = $result['name']; $response->rows[$i]['cell']['email'] = $result['email']; $response->rows[$i]['cell']['customer_group'] = $result['customer_group']; $response->rows[$i]['cell']['status'] = $result['status']; $response->rows[$i]['cell']['approved'] = $result['approved']; $i++; } } $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->rest->setResponseData($response); $this->rest->sendResponse(200); }
public function get() { $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('catalog/product'); $filter_data = array('method' => 'get'); $filter = new AFilter($filter_data); $filters = $filter->getFilterData(); $results = $this->model_catalog_product->getLatestProducts($filters['limit']); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $total_pages; $response->records = $filters['limit']; $response->limit = $filters['limit']; $response->sidx = $filters['sort']; $response->sord = $filters['order']; $response->params = $filters; $i = 0; if ($results) { $product_ids = array(); foreach ($results as $result) { $product_ids[] = (int) $result['product_id']; } $resource = new AResource('image'); $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height')); foreach ($results as $result) { $thumbnail = $thumbnails[$result['product_id']]; $response->rows[$i]['id'] = $result['product_id']; $response->rows[$i]['cell']['thumb'] = $thumbnail['thumb_url']; $response->rows[$i]['cell']['name'] = $result['name']; $response->rows[$i]['cell']['description'] = $result['description']; $response->rows[$i]['cell']['model'] = $result['model']; $response->rows[$i]['cell']['price'] = $this->currency->convert($result['final_price'], $this->config->get('config_currency'), $this->currency->getCode()); $response->rows[$i]['cell']['currency_code'] = $this->currency->getCode(); $response->rows[$i]['cell']['rating'] = $result['rating']; $i++; } } $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->rest->setResponseData($response); $this->rest->sendResponse(200); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('user/user'); $this->loadModel('user/user'); $this->loadModel('user/user_group'); $user_groups = array('' => $this->language->get('text_select_group')); $results = $this->model_user_user_group->getUserGroups(); foreach ($results as $r) { $user_groups[$r['user_group_id']] = $r['name']; } //Prepare filter config $filter_params = array('status', 'user_group_id'); $grid_filter_params = array('username'); //Build query string based on GET params first $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); //Build final filter $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params, 'additional_filter_string' => $filter_form->getFilterString())); $total = $this->model_user_user->getTotalUsers($filter_grid->getFilterData()); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $results = $this->model_user_user->getUsers($filter_grid->getFilterData()); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['user_id']; $response->rows[$i]['cell'] = array($result['username'], $user_groups[$result['user_group_id']], $this->html->buildCheckbox(array('name' => 'status[' . $result['user_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), dateISO2Display($result['date_added'], $this->language->get('date_format_short'))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function get() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('catalog/product'); $filter_params = array('category_id', 'manufacturer_id', 'keyword', 'match', 'pfrom', 'pto'); $grid_filter_params = array('name', 'description', 'model', 'sku'); $filter_data = array('method' => 'get', 'filter_params' => $filter_params, 'grid_filter_params' => $grid_filter_params); $filter = new AFilter($filter_data); $filters = $filter->getFilterData(); $category_id = $filter->getFilterParam('category_id'); $manufacturer_id = $filter->getFilterParam('manufacturer_id'); $keyword = $filter->getFilterParam('keyword'); if (!$category_id && !$manufacturer_id && !$keyword) { $this->rest->setResponseData(array('Error' => 'Missing one of required product filter parameters')); $this->rest->sendResponse(200); return null; } //get total if ($keyword) { $total = $this->model_catalog_product->getTotalProducts($filters); } elseif ($category_id) { $total = $this->model_catalog_product->getTotalProductsByCategoryId($category_id); } elseif ($manufacturer_id) { $total = $this->model_catalog_product->getTotalProductsByManufacturerId($manufacturer_id); } if ($total > 0) { $total_pages = ceil($total / $filter->getParam('rows')); } else { $total_pages = 0; } //Preserved jqGrid JSON interface $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $total_pages; $response->records = $total; $response->limit = $filters['limit']; $response->sidx = $filters['sort']; $response->sord = $filters['order']; $response->params = $filters; $resource = new AResource('image'); if ($keyword) { $results = $this->model_catalog_product->getProducts($filters); } elseif ($category_id) { $results = $this->model_catalog_product->getProductsByCategoryId($category_id, $filters['sort'], $filters['order'], $filters['start'], $filters['limit']); } elseif ($manufacturer_id) { $results = $this->model_catalog_product->getProductsByManufacturerId($manufacturer_id, $filters['sort'], $filters['order'], $filters['start'], $filters['limit']); } $i = 0; if ($results) { foreach ($results as $result) { $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'), true); $response->rows[$i]['id'] = $result['product_id']; $response->rows[$i]['cell']['thumb'] = $thumbnail['thumb_url']; $response->rows[$i]['cell']['name'] = $result['name']; $response->rows[$i]['cell']['description'] = $result['description']; $response->rows[$i]['cell']['model'] = $result['model']; $response->rows[$i]['cell']['price'] = $this->currency->convert($result['final_price'], $this->config->get('config_currency'), $this->currency->getCode()); $response->rows[$i]['cell']['currency_code'] = $this->currency->getCode(); $response->rows[$i]['cell']['rating'] = $result['rating']; $i++; } } //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->rest->setResponseData($response); $this->rest->sendResponse(200); }
/** * @param array $data * @param int $language_id * @param null|int $attribute_parent_id * @param string $mode * @return array */ public function getAttributes($data = array(), $language_id = 0, $attribute_parent_id = null, $mode = 'default') { if (!$language_id) { $language_id = $this->session->data['content_language_id']; } //Prepare filter config $filter_params = array('attribute_parent_id', 'status'); if (!has_value($data['attribute_type_id'])) { $filter_params[] = 'attribute_type_id'; // to prevent ambigious fields in sql query } //Build query string based on GET params first $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); //Build final filter $grid_filter_params = array('name' => 'gad.name', 'type_name' => 'gatd.type_name'); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params, 'additional_filter_string' => $filter_form->getFilterString())); $filter_data = $filter_grid->getFilterData(); $data = array_merge($filter_data, $data); if ($mode == 'total_only') { $total_sql = 'count(*) as total'; } else { $total_sql = "ga.*, gad.name, gad.error_text, gatd.type_name "; } $sql = "SELECT " . $total_sql . "\n \tFROM `" . DB_PREFIX . "global_attributes` ga\n LEFT JOIN `" . DB_PREFIX . "global_attributes_descriptions` gad\n \tON ( ga.attribute_id = gad.attribute_id AND gad.language_id = '" . (int) $language_id . "' )\n\t\t\t\tLEFT JOIN `" . DB_PREFIX . "global_attributes_type_descriptions` gatd\n\t\t\t\t\tON ( gatd.attribute_type_id = ga.attribute_type_id AND gatd.language_id = '" . (int) $language_id . "' )\n\t\t\t\tWHERE 1=1 "; if (!empty($data['search'])) { $sql .= " AND " . $data['search']; } if (!empty($data['subsql_filter'])) { $sql .= " AND " . $data['subsql_filter']; } if (empty($data['search']) && !is_null($attribute_parent_id)) { $sql .= " AND ga.attribute_parent_id = '" . (int) $attribute_parent_id . "' "; } if (!empty($data['attribute_type_id'])) { $sql .= " AND ga.attribute_type_id = " . (int) $data['attribute_type_id']; } //If for total, we done bulding the query if ($mode == 'total_only') { $query = $this->db->query($sql); return $query->row['total']; } $sort_data = array('name' => 'gad.name', 'sort_order' => 'ga.sort_order', 'status' => 'ga.status', 'type_name' => 'gatd.type_name'); if (isset($data['sort']) && array_key_exists($data['sort'], $sort_data)) { $sql .= " ORDER BY " . $sort_data[$data['sort']]; } else { $sql .= " ORDER BY ga.sort_order, gad.name "; } if (isset($data['order']) && strtoupper($data['order']) == 'DESC') { $sql .= " DESC"; } else { $sql .= " ASC"; } if (has_value($data['start']) || has_value($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit']; } $query = $this->db->query($sql); return $query->rows; }
public function transactions() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('report/customer'); //Prepare filter config $filter_params = array('date_start', 'date_end'); $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); $filter_grid = new AFilter(array('method' => 'post')); $data = array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()); //add filters for custom processing $allowedFields = array('customer'); if (isset($this->request->post['_search']) && $this->request->post['_search'] == 'true') { $searchData = AJson::decode(htmlspecialchars_decode($this->request->post['filters']), true); foreach ($searchData['rules'] as $rule) { if (!in_array($rule['field'], $allowedFields)) { continue; } $data['filter'][$rule['field']] = $rule['data']; } } $total = $this->model_report_customer->getTotalCustomerTransactions($data); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $results = $this->model_report_customer->getCustomerTransactions($data); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['customer_transaction_id']; //mark inactive customers. if ($result['status'] != 1) { $response->userdata->classes[$result['customer_transaction_id']] = 'attention'; } $response->rows[$i]['cell'] = array($result['date_added'], $result['customer'], $this->currency->format($result['debit'], $this->config->get('config_currency')), $this->currency->format($result['credit'], $this->config->get('config_currency')), $result['transaction_type'], $result['created_by']); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function getBannerListData() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->load->library('json'); // json-response for jqgrid $this->loadLanguage('banner_manager/banner_manager'); $this->loadModel('tool/image'); $page = $this->request->post['page']; // get the requested page if ((int) $page < 0) { $page = 0; } $limit = $this->request->post['rows']; // get how many rows we want to have into the grid //sort $filter_params = array('name', 'banner_group_name'); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $filter_params, 'additional_filter_string' => '')); $this->loadModel('extension/banner_manager'); $total = $this->model_extension_banner_manager->getBanners($filter_grid->getFilterData(), 'total_only'); if ($total > 0) { $total_pages = ceil($total / $limit); } else { $total_pages = 0; } $results = $this->model_extension_banner_manager->getBanners($filter_grid->getFilterData()); $list = $this->session->data['listing_selected']; $id_list = array(); foreach ($list as $id => $row) { if ($row['status']) { $id_list[] = $id; } } $response = new stdClass(); $response->page = $page; $response->total = $total_pages; $response->records = $total; $ids = array(); foreach ($results as $result) { if ($result['banner_type'] == 1) { $ids[] = (int) $result['banner_id']; } } $resource = new AResource('image'); $thumbnails = $resource->getMainThumbList('banners', $ids, 27, 27); $i = 0; foreach ($results as $result) { if (in_array($result['banner_id'], $id_list)) { $response->userdata->selId[] = $result['banner_id']; } $action = '<a class="btn_action" href="JavaScript:void(0);" onclick="showPopup(\'' . $this->html->getSecureURL('extension/banner_manager/edit', '&banner_id=' . $result['banner_id']) . '\')" title="' . $this->language->get('text_view') . '">' . '<img height="27" src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_view.png" alt="' . $this->language->get('text_edit') . '" /></a>'; $response->rows[$i]['id'] = $result['banner_id']; if ($result['banner_type'] == 1) { $thumbnail = $thumbnails[$result['banner_id']]['thumb_html']; } else { $thumbnail = ''; } $response->rows[$i]['cell'] = array($thumbnail, $result['name'], $result['banner_group_name'], $result['banner_type'] == 1 ? $this->language->get('text_graphic_banner') : $this->language->get('text_text_banner'), $action); $i++; } $this->data['response'] = $response; //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($this->data['response'])); }
public function getCustomListListingGridData() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); // json-response for jqgrid $this->load->library('json'); // if datasource was switched $layout_manager = new ALayoutManager(); $custom_block_id = (int) $this->request->get['custom_block_id']; $listing_datasource = $this->request->post_or_get('listing_datasource'); $info = $layout_manager->getBlockDescriptions($custom_block_id); $info = is_array($info) ? current($info) : ''; $info = unserialize($info['content']); $custom_list = array(); $lm = new AListingManager($custom_block_id); $this->data['data_sources'] = $lm->getListingDataSources(); if ($info['listing_datasource'] == $listing_datasource) { $list = $lm->getCustomList(); if ($list) { foreach ($list as $row) { $custom_list[$row['id']] = $row['sort_order']; } } } //load data source language and model $this->loadLanguage($this->data['data_sources'][$listing_datasource]['language']); $this->loadModel($this->data['data_sources'][$listing_datasource]['model']); $this->loadModel('tool/image'); //Prepare filter config $grid_filter_params = array('name', 'sort_order', 'model'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $filter_data = $filter->getFilterData(); //call data source model total method to get total based on set filter $model = $this->{'model_' . str_replace('/', '_', $this->data['data_sources'][$listing_datasource]['model'])}; $total = call_user_func_array(array($model, $this->data['data_sources'][$listing_datasource]['total_method']), array($filter_data)); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $response->userdata = (object) array(''); //call data source model method to get all records based on set filter $model = $this->{'model_' . str_replace('/', '_', $this->data['data_sources'][$listing_datasource]['model'])}; $results = call_user_func_array(array($model, $this->data['data_sources'][$listing_datasource]['method']), array($filter_data)); $i = 0; $resource = new AResource('image'); $response->userdata = (object) array('page' => '', 'selId' => array()); $data_type = $this->data['data_sources'][$listing_datasource]['data_type']; //product_id, category_id etc $id_list = $custom_list ? array_keys($custom_list) : array(); if ($results) { foreach ($results as $result) { $list_item_id = $result[$data_type]; //for pre-select if (in_array($list_item_id, $id_list) || in_array($list_item_id, array_keys($this->session->data['listing_selected']))) { $response->userdata->selId[] = $list_item_id; } $thumbnail = $resource->getMainThumb($this->data['data_sources'][$listing_datasource]['rl_object_name'], $list_item_id, 36, 36, true); $response->rows[$i]['id'] = $list_item_id; $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $result['name']); if (strpos($listing_datasource, 'product') !== FALSE) { $response->rows[$i]['cell'][] = $result['model']; } if ($custom_list[$list_item_id]) { $value = $custom_list[$list_item_id]; } else { $value = $this->session->data['listing_selected'][$list_item_id]['sort_order']; } //TODO: need find solution to replace html hardcode in all response controllers $response->rows[$i]['cell'][] = '<a class="btn_action" href="JavaScript:void(0);" onclick="showPopup(\'' . $this->html->getSecureURL($this->data['data_sources'][$listing_datasource]['view_path'], '&' . $data_type . '=' . $list_item_id) . '\')" title="' . $this->language->get('text_view') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_view.png" alt="' . $this->language->get('text_edit') . '" /></a>'; $i++; } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($response)); }
public function tax_rates() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('localisation/tax_class'); $this->loadModel('localisation/tax_class'); //Prepare filter config $grid_filter_params = array('title'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $this->loadModel('localisation/location'); $this->loadModel('localisation/zone'); $results = $this->model_localisation_location->getLocations(); $zones = $locations = array(); $zones[0] = $this->language->get('text_tax_all_zones'); $tax_rates = $this->model_localisation_tax_class->getTaxRates($this->request->get['tax_class_id']); $total = sizeof($tax_rates); $rates = array(); foreach ($tax_rates as $rate) { $rates[] = $rate['location_id']; } foreach ($results as $c) { if (in_array($c['location_id'], $rates)) { $locations[$c['location_id']] = $c['name']; $tmp = $this->model_localisation_zone->getZonesByLocationId($c['location_id']); foreach ($tmp as $zone) { $zones[$zone['zone_id']] = $zone['name']; } } } unset($results, $tmp); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $response->userdata = (object) array(''); foreach ($tax_rates as $i => $tax_rate) { $response->rows[$i]['id'] = $tax_rate['tax_rate_id']; $response->rows[$i]['cell'] = array($locations[$tax_rate['location_id']], $zones[$tax_rate['zone_id']], $tax_rate['description'], $tax_rate['rate_prefix'] . $tax_rate['rate'], $tax_rate['priority']); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function coupons() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('report/sale/coupons'); $this->loadModel('report/sale'); //Prepare filter config $filter_params = array('date_start', 'date_end'); $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); $filter_grid = new AFilter(array('method' => 'post')); $data = array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()); $total = $this->model_report_sale->getCouponsReportTotal($data); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $results = $this->model_report_sale->getCouponsReport($data); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $i; $response->rows[$i]['cell'] = array($result['coupon_name'], $result['code'], $result['orders'], $this->currency->format($result['total'], $this->config->get('config_currency')), $this->currency->format($result['discount_total'], $this->config->get('config_currency'))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
/** * @param array $data * @param string $mode * @return array|int */ public function getCoupons($data = array(), $mode = 'default') { if (!empty($data['content_language_id'])) { $language_id = (int) $data['content_language_id']; } else { $language_id = (int) $this->config->get('storefront_language_id'); } //Prepare filter config $filter_params = array('status' => 'c.status'); //Build query string based on GET params first $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); //Build final filter $grid_filter_params = array('name' => 'cd.name', 'code' => 'c.code'); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params, 'additional_filter_string' => $filter_form->getFilterString())); $data = array_merge($filter_grid->getFilterData(), $data); if ($mode == 'total_only') { $total_sql = 'count(*) as total'; } else { $total_sql = "c.coupon_id, cd.name, c.code, c.discount, c.date_start, c.date_end, c.status "; } $sql = "SELECT " . $total_sql . " \n\t\t\t\tFROM " . $this->db->table("coupons") . " c\n\t\t\t\tJOIN " . $this->db->table("coupon_descriptions") . " cd\n\t\t\t\t\tON (c.coupon_id = cd.coupon_id AND cd.language_id = '" . $language_id . "')"; if (!empty($data['search'])) { $sql .= " AND " . $data['search']; } if (!empty($data['subsql_filter'])) { $sql .= " AND " . $data['subsql_filter']; } //If for total, we done bulding the query if ($mode == 'total_only') { $query = $this->db->query($sql); return $query->row['total']; } $sort_data = array('name' => 'cd.name', 'code' => 'c.code', 'discount' => 'c.discount', 'date_start' => 'c.date_start', 'date_end' => 'c.date_end', 'status' => 'c.status'); if (isset($data['sort']) && array_key_exists($data['sort'], $sort_data)) { $sql .= " ORDER BY " . $sort_data[$data['sort']]; } else { $sql .= " ORDER BY cd.name"; } if (isset($data['order']) && strtoupper($data['order']) == 'DESC') { $sql .= " DESC"; } else { $sql .= " ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit']; } $query = $this->db->query($sql); return $query->rows; }