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 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() { $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/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('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__); $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('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('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('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() { //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__); //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/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('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() { $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 Main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->load->library('json'); $response_type = $this->request->get['response_type']; $form_name = isset($this->request->get['form_name']) ? $this->request->get['form_name'] : 'productFrm'; $multivalue_hidden_id = isset($this->request->get['multivalue_hidden_id']) ? $this->request->get['multivalue_hidden_id'] : 'popup'; if ($response_type != 'json') { $this->loadLanguage('catalog/product'); //remember selected rows for response if (isset($this->request->post['selected'])) { $this->session->data['listing_selected'] = AJson::decode(html_entity_decode($this->request->post['selected']), true); } $grid_settings = array('table_id' => 'product_grid', 'url' => $this->html->getSecureURL('catalog/product_listing', '&response_type=json'), 'editurl' => '', 'sortname' => 'name', 'sortorder' => 'asc', 'actions' => array(), 'multiselect_noselectbox' => true); $grid_settings['colNames'] = array($this->language->get('column_image'), $this->language->get('column_name')); $grid_settings['colNames'][] = $this->language->get('column_model'); $grid_settings['colNames'][] = $this->language->get('column_action'); $grid_settings['colModel'] = array(array('name' => 'image', 'index' => 'image', 'align' => 'center', 'width' => 50, 'sortable' => false, 'search' => false), array('name' => 'name', 'index' => 'name', 'align' => 'left', 'width' => 200), array('name' => 'model', 'index' => 'model', 'align' => 'center', 'width' => 60, 'sortable' => false), array('name' => 'action', 'index' => 'action', 'align' => 'center', 'width' => 30, 'sortable' => false, 'search' => false)); $form = new AForm(); $form->setForm(array('form_name' => 'product_listing_search')); $grid_search_form = array(); $grid_search_form['id'] = 'product_listing_search'; $grid_search_form['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'product_grid_search', 'action' => '')); $grid_search_form['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_go'), 'style' => 'button1')); $grid_search_form['reset'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'reset', 'text' => $this->language->get('button_reset'), 'style' => 'button2')); $grid_search_form['fields']['keyword'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'keyword', 'value' => '')); $grid_search_form['fields']['match'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'match', 'options' => array('any' => $this->language->get('filter_any_word'), 'all' => $this->language->get('filter_all_words'), 'exact' => $this->language->get('filter_exact_match')))); $grid_search_form['fields']['pfrom'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'pfrom', 'value' => '')); $grid_search_form['fields']['pto'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'pto', 'value' => '')); $this->loadModel('catalog/category'); $categories = array('' => $this->language->get('text_select_category')); $results = $this->model_catalog_category->getCategories(0); foreach ($results as $r) { $categories[$r['category_id']] = $r['name']; } $grid_search_form['fields']['category'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'category', 'options' => $categories, 'style' => 'medium-field')); $grid_settings['search_form'] = true; $grid = $this->dispatch('common/listing_grid', array($grid_settings)); $listing_grid = $grid->dispatchGetOutput(); unset($grid); // add js-scripts for grid rows selecting (redeclare onSelectRow event for grid) $view = new AView($this->registry, 0); $view->batchAssign(array('id' => $multivalue_hidden_id, 'form_name' => $form_name . '_' . $multivalue_hidden_id, 'table_id' => $grid_settings['table_id'], 'search_form' => $grid_search_form, 'listing_grid' => $listing_grid, 'filter_product' => $this->language->get('filter_product'), 'filter_price_max' => $this->language->get('filter_price_max'))); $this->data['response'] = $view->fetch('responses/catalog/product_listing.tpl'); } else { // json-response for jqgrid $this->loadLanguage('catalog/product'); $this->loadModel('catalog/product'); $this->loadModel('tool/image'); //Prepare filter config //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)); $total = $this->model_catalog_product->getTotalProducts(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_product->getProducts(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData())); $i = 0; $resource = new AResource('image'); $response->userdata = (object) array('page' => $page); $data_type = 'product_id'; $list = $this->session->data['listing_selected']; $id_list = array(); foreach ($list as $id => $row) { if ($id == $this->session->data['multivalue_excludes']['product_id']) { continue; } if ($row['status']) { $id_list[] = $id; } } if ($results) { foreach ($results as $result) { if ($result[$data_type] == $this->session->data['multivalue_excludes']['product_id']) { continue; } if (in_array($result[$data_type], $id_list)) { $response->userdata->selId[] = $result[$data_type]; } $thumbnail = $resource->getMainThumb('products', $result[$data_type], 27, 27, true); $response->rows[$i]['id'] = $result[$data_type]; $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $result['name'], $result['model'], '<a class="btn_action" href="JavaScript:void(0);" onclick="showPopup(\'' . $this->html->getSecureURL('catalog/product/update', '&' . $data_type . '=' . $result[$data_type]) . '\')" 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>'); $i++; } } $this->data['response'] = $response; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); if ($response_type == 'json') { $this->data['response'] = AJson::encode($this->data['response']); } $this->response->setOutput($this->data['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); }
private function _json_response() { // json-response for jqgrid $this->loadLanguage('catalog/download'); $this->loadModel('catalog/download'); $excludes = $this->session->data['multivalue_excludes']; $grid_filter_params = array('name'); // if need to show all downloads of product if ($this->request->get['product_id']) { $additional_filter_string = sizeof($excludes) ? "AND p2d.download_id NOT IN (" . implode(', ', $excludes) . ")" : ''; if (isset($this->request->get['shared_only'])) { $additional_filter_string .= 'AND shared=1'; } $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params, 'additional_filter_string' => $additional_filter_string)); $results = $this->model_catalog_download->getProductDownloadsDetails($this->request->get['product_id'], $filter_grid->getFilterData()); $total = sizeof($results); } else { //Prepare filter config $additional_filter_string = sizeof($excludes) ? " d.download_id NOT IN (" . implode(', ', $excludes) . ")" : ''; if (isset($this->request->get['shared_only'])) { $additional_filter_string .= 'AND shared=1'; } $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params, 'additional_filter_string' => $additional_filter_string)); $total = $this->model_catalog_download->getTotalDownloads($filter_grid->getFilterData()); $results = $this->model_catalog_download->getDownloads($filter_grid->getFilterData()); } $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $i = 0; $response->userdata = (object) array('page' => $page); $data_type = 'download_id'; $rl = new AResource('download'); $rl_dir = $rl->getTypeDir(); if ($results) { foreach ($results as $result) { $resource_id = $rl->getIdFromHexPath(str_replace($rl_dir, '', $result['filename'])); $resource_info = $rl->getResource($resource_id); $thumbnail = $rl->getResourceThumb($resource_id, 27, 27); if ($resource_info['resource_path']) { $thumbnail = $this->html->buildResourceImage(array('url' => $thumbnail, 'width' => 27, 'height' => 27, 'attr' => 'alt="' . $resource_info['title'] . '"')); } else { $thumbnail = $resource_info['resource_code']; } $response->rows[$i]['id'] = $result['download_id']; $response->rows[$i]['cell'] = array($thumbnail, $result['name'], '<a class="btn_action" href="JavaScript:void(0);" onclick="showPopup(\'' . $this->html->getSecureURL('catalog/download/update', '&' . $data_type . '=' . $result[$data_type]) . '\')" 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>'); $i++; } } $this->data['response'] = AJson::encode($response); }
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 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)); }
public function Main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->load->library('json'); $response_type = $this->request->get['response_type']; $form_name = isset($this->request->get['form_name']) ? $this->request->get['form_name'] : 'productFrm'; $multivalue_hidden_id = isset($this->request->get['multivalue_hidden_id']) ? $this->request->get['multivalue_hidden_id'] : 'popup'; if ($response_type != 'json') { $this->loadLanguage('catalog/category'); //remember selected rows for response if (isset($this->request->post['selected'])) { $this->session->data['listing_selected'] = AJson::decode(html_entity_decode($this->request->post['selected']), true); } $grid_settings = array('table_id' => 'category_grid', 'url' => $this->html->getSecureURL('catalog/category_listing', '&response_type=json'), 'editurl' => '', 'sortname' => 'name', 'sortorder' => 'asc', 'actions' => array(), 'multiselect_noselectbox' => true); $grid_settings['colNames'] = array($this->language->get('column_image'), $this->language->get('column_name')); $grid_settings['colNames'][] = $this->language->get('column_action'); $grid_settings['colModel'] = array(array('name' => 'image', 'index' => 'image', 'align' => 'center', 'width' => 50, 'sortable' => false, 'search' => false), array('name' => 'name', 'index' => 'name', 'align' => 'left', 'sortable' => false, 'width' => 200), array('name' => 'action', 'index' => 'action', 'align' => 'center', 'width' => 30, 'sortable' => false, 'search' => false)); $grid_settings['search_form'] = true; $grid = $this->dispatch('common/listing_grid', array($grid_settings)); $this->data['response'] = $grid->dispatchGetOutput(); unset($grid); // add js-scripts for grid rows selecting (redeclare onSelectRow event for grid) $view = new AView($this->registry, 0); $view->batchAssign(array('id' => $multivalue_hidden_id, 'form_name' => $form_name . '_' . $multivalue_hidden_id, 'table_id' => $grid_settings['table_id'])); $this->data['response'] .= $view->fetch('responses/catalog/category_listing.tpl'); } else { // json-response for jqgrid $this->loadLanguage('catalog/category'); $this->loadModel('catalog/category'); $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 if (!$filter_data['subsql_filter']) { // without search $parent_id = isset($this->request->get['parent_id']) ? $this->request->get['parent_id'] : 0; $results = $this->model_catalog_category->getCategories($parent_id); $total = sizeof($results); $results = array_slice($results, $filter_data['start'], $filter_data['limit']); } else { $total = $this->model_catalog_category->getTotalCategories($filter_data); $results = $this->model_catalog_category->getCategoriesData($filter_data); } $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $resource = new AResource('image'); $i = 0; $response->userdata = (object) array('page' => $this->request->post['page']); $data_type = 'category_id'; $list = $this->session->data['listing_selected']; $id_list = array(); foreach ($list as $id => $row) { if ($row['status']) { $id_list[] = $id; } } if ($results) { foreach ($results as $result) { if (in_array($result[$data_type], $id_list)) { $response->userdata->selId[] = $result[$data_type]; } $thumbnail = $resource->getMainThumb('categories', $result[$data_type], 36, 36, true); $response->rows[$i]['id'] = $result[$data_type]; $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $result['name'], '<a class="btn_action" href="JavaScript:void(0);" onclick="showPopup(\'' . $this->html->getSecureURL('catalog/category/update', '&' . $data_type . '=' . $result[$data_type]) . '\')" title="' . $this->language->get('text_view') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_view.png" alt="' . $this->language->get('text_edit') . '" /></a>'); $i++; } } $this->data['response'] = $response; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); if ($response_type == 'json') { $this->data['response'] = AJson::encode($this->data['response']); } $this->response->setOutput($this->data['response']); }