public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('tool/files'); if (!$this->user->canAccess('tool/file_uploads')) { $response = new stdClass(); $response->userdata->error = sprintf($this->language->get('error_permission_access'), 'tool/file_uploads'); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); return null; } $this->loadModel('tool/file_uploads'); $page = $this->request->post['page']; // get the requested page $limit = $this->request->post['rows']; // get how many rows we want to have into the grid $sidx = $this->request->post['sidx']; // get index row - i.e. user click to sort $sord = $this->request->post['sord']; // get the direction $filter = array(); //process custom search form $allowedSearchFilter = array('date_added', 'section'); if (isset($this->request->post['filters']) && $this->request->post['filters'] != '') { $this->request->post['filters'] = json_decode(html_entity_decode($this->request->post['filters'])); $filter['value'] = $this->request->post['filters']->rules[0]->data; } // process jGrid search parameter $data = array('sort' => $sidx . ":" . $sord, 'offset' => ($page - 1) * $limit, 'limit' => $limit, 'filter' => $filter); $total = $this->model_tool_file_uploads->getTotalRows($filter); if ($total > 0) { $total_pages = ceil($total / $limit); } else { $total_pages = 0; } if ($page > $total_pages) { $page = $total_pages; $data['offset'] = ($page - 1) * $limit; } $response = new stdClass(); $response->page = $page; $response->total = $total_pages; $response->records = $total; $results = (array) $this->model_tool_file_uploads->getLog($data); $i = 0; foreach ($results as $k => $result) { $k++; $response->rows[$i]['id'] = $k; $response->rows[$i]['cell'] = array($k, $result['date_added'], $result['section'], is_file($result['path']) ? '<a target="_blank" title="' . $this->language->get('text_download') . '" href="' . $this->html->getSecureUrl('tool/files/download', '&filename=' . urlencode($result['name'])) . '&attribute_type=' . $result['section'] . '&attribute_id=' . $result['section_id'] . '">' . $result['name'] . '</a>' : ''); $i++; } $this->data = $response; // for hook access //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('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('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 test() { $this->registry->set('force_skip_errors', true); $this->loadLanguage('default_twilio/default_twilio'); $this->loadModel('setting/setting'); include_once DIR_EXT . 'default_twilio/core/lib/Services/Twilio.php'; $cfg = $this->model_setting_setting->getSetting('default_twilio', (int) $this->session->data['current_store_id']); $AccountSid = $cfg['default_twilio_username']; $AuthToken = $cfg['default_twilio_token']; $sender = new Services_Twilio($AccountSid, $AuthToken); if ($this->config->get('default_twilio_test')) { //sandbox number without errors from api $from = '+15005550006'; } else { $from = $this->config->get('default_twilio_sender_phone'); $from = '+' . ltrim($from, '+'); } $error_message = ''; try { $sender->account->sms_messages->create($from, "+15005550006", 'test message', array()); } catch (Exception $e) { $error_message = $e->getMessage(); } $this->registry->set('force_skip_errors', false); $json = array(); if (!$error_message) { $json['message'] = $this->language->get('text_connection_success'); $json['error'] = false; } else { $json['message'] = "Connection to Twilio server can not be established.<br>" . $error_message . ".<br>Check your server configuration or contact your hosting provider."; $json['error'] = true; } $this->load->library('json'); $this->response->setOutput(AJson::encode($json)); }
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 static function encode($data) { if (function_exists('json_encode')) { return json_encode($data); } else { switch (gettype($data)) { case 'boolean': return $data ? 'true' : 'false'; case 'integer': case 'double': return $data; case 'resource': case 'string': return '"' . str_replace(array("\r", "\n", "<", ">", "&"), array('\\r', '\\n', '\\x3c', '\\x3e', '\\x26'), addslashes($data)) . '"'; case 'array': if (empty($data) || array_keys($data) === range(0, sizeof($data) - 1)) { $stdout = array(); foreach ($data as $value) { $stdout[] = AJson::encode($value); } return '[ ' . implode(', ', $stdout) . ' ]'; } case 'object': $stdout = array(); foreach ($data as $key => $value) { $stdout[] = AJson::encode(strval($key)) . ': ' . AJson::encode($value); } return '{ ' . implode(', ', $stdout) . ' }'; default: return 'null'; } } }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $page = $this->request->post['page']; // get the requested page $limit = $this->request->post['rows']; // get how many rows we want to have into the grid $sidx = $this->request->post['sidx']; // get index row - i.e. user click to sort $sord = $this->request->post['sord']; // get the direction $data = array('sort' => $sidx, 'order' => $sord, 'start' => ($page - 1) * $limit, 'limit' => $limit, 'language_id' => $this->session->data['content_language_id']); $total = $this->attribute_manager->getTotalAttributeGroups(); 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; $results = $this->attribute_manager->getAttributeGroups($data); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['attribute_group_id']; $response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'name[' . $result['attribute_group_id'] . ']', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'sort_order[' . $result['attribute_group_id'] . ']', 'value' => $result['sort_order'])), $this->html->buildCheckbox(array('name' => 'status[' . $result['attribute_group_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/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__); //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/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('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 save() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $output = array(); $this->loadLanguage('tool/rl_manager'); $this->document->setTitle($this->language->get('heading_title')); if ($this->request->is_POST() && $this->_validateRLTypeForm($this->request->post)) { $post_data = $this->request->post; $rm = new AResourceManager(); if ($rm->updateResourceType($post_data)) { $output['result_text'] = $this->language->get('text_success'); $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($output)); } else { $error = new AError(''); $err_data = array('error_text' => 'Unable to save resource type'); return $error->toJSONResponse('VALIDATION_ERROR_406', $err_data); } } else { $error = new AError(''); $err_data = array('error_text' => $this->error); return $error->toJSONResponse('VALIDATION_ERROR_406', $err_data); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * post-trigger of task */ public function complete() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $task_id = (int) $this->request->post['task_id']; if ($task_id) { $tm = new ATaskManager(); $tm->deleteTask($task_id); $install_upgrade_history = new ADataset('install_upgrade_history', 'admin'); $backup_name = $this->request->get_or_post('backup_name'); $backup_name = !$backup_name ? 'manual_backup' : $backup_name; $display_name = ''; if (is_file(DIR_BACKUP . $backup_name . '.tar.gz')) { $display_name = $backup_name . '.tar.gz'; $result_text = $this->html->convertLinks($this->language->get('backup_complete_text_file')); } elseif (is_dir(DIR_BACKUP . $backup_name)) { $display_name = $backup_name . '/...'; $result_text = sprintf($this->language->get('backup_complete_text_dir'), DIR_BACKUP . $backup_name); } $install_upgrade_history->addRows(array('date_added' => date("Y-m-d H:i:s", time()), 'name' => 'Manual Backup', 'version' => VERSION, 'backup_file' => $display_name, 'backup_date' => date("Y-m-d H:i:s", time()), 'type' => 'backup', 'user' => $this->user->getUsername())); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode(array('result' => true, 'result_text' => $result_text))); }
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('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/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('localisation/zone'); $this->loadModel('localisation/zone'); $page = $this->request->post['page']; // get the requested page $limit = $this->request->post['rows']; // get how many rows we want to have into the grid $sidx = $this->request->post['sidx']; // get index row - i.e. user click to sort $sord = $this->request->post['sord']; // get the direction $this->loadModel('localisation/country'); $template_data['countries'] = $this->model_localisation_country->getCountries(); $countries = array('' => $this->language->get('text_select_country')); foreach ($template_data['countries'] as $c) { $countries[$c['country_id']] = $c['name']; } $search_str = ''; //process custom search form $allowedSearchFilter = array('country_id'); $search_param = array(); foreach ($allowedSearchFilter as $filter) { if (isset($this->request->get[$filter]) && $this->request->get[$filter] != '') { $search_param[] = " z.`" . $filter . "` = '" . $this->db->escape($this->request->get[$filter]) . "' "; } } if (!empty($search_param)) { $search_str = implode(" AND ", $search_param); } $data = array('sort' => $sidx, 'order' => strtoupper($sord), 'start' => ($page - 1) * $limit, 'limit' => $limit, 'search' => $search_str); $total = $this->model_localisation_zone->getTotalZones($data); if ($total > 0) { $total_pages = ceil($total / $limit); } else { $total_pages = 0; } if ($page > $total_pages) { $page = $total_pages; $data['start'] = ($page - 1) * $limit; } $response = new stdClass(); $response->page = $page; $response->total = $total_pages; $response->records = $total; $results = $this->model_localisation_zone->getZones($data); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['zone_id']; $response->rows[$i]['cell'] = array($result['country'], $this->html->buildInput(array('name' => 'zone_name[' . $result['zone_id'] . '][' . $this->session->data['content_language_id'] . '][name]', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'code[' . $result['zone_id'] . ']', 'value' => $result['code'])), $this->html->buildCheckbox(array('name' => 'status[' . $result['zone_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/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 api_confirm() { $data = array(); $this->confirm(); $data['success'] = 'completed'; $this->load->library('json'); $this->response->setOutput(AJson::encode($data)); }
public function get_fields_list() { $this->loadModel('tool/forms_manager'); $fields = $this->model_tool_forms_manager->getFields($this->request->get['form_id']); $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($fields)); }
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('sale/customer'); $this->loadModel('sale/customer'); $this->load->library('json'); $approved = array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no')); $page = $this->request->post['page']; // get the requested page $limit = $this->request->post['rows']; // get how many rows we want to have into the grid $sidx = $this->request->post['sidx']; // get index row - i.e. user click to sort $sord = $this->request->post['sord']; // get the direction $data = array('sort' => $sidx, 'order' => $sord, 'start' => ($page - 1) * $limit, 'limit' => $limit); if (has_value($this->request->get['customer_group'])) { $data['filter']['customer_group_id'] = $this->request->get['customer_group']; } if (has_value($this->request->get['status'])) { $data['filter']['status'] = $this->request->get['status']; } if (has_value($this->request->get['approved'])) { $data['filter']['approved'] = $this->request->get['approved']; } $allowedFields = array('name', 'email'); 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_sale_customer->getTotalCustomers($data); 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; $results = $this->model_sale_customer->getCustomers($data); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['customer_id']; $response->rows[$i]['cell'] = array($result['name'], '<a href="' . $this->html->getSecureURL('sale/contact', '&email[]=' . $result['email']) . '">' . $result['email'] . '</a>', $result['customer_group'], $this->html->buildCheckbox(array('name' => 'status[' . $result['customer_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), $this->html->buildSelectbox(array('name' => 'approved[' . $result['customer_id'] . ']', 'value' => $result['approved'], 'options' => $approved)), $result['orders_count'] > 0 ? $this->html->buildButton(array('name' => 'view orders', 'text' => $result['orders_count'], 'style' => 'button2', 'href' => $this->html->getSecureURL('sale/order', '&customer_id=' . $result['customer_id']), 'title' => $this->language->get('text_view') . ' ' . $this->language->get('tab_history'), 'target' => '_blank')) : 0); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $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 api_confirm() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->confirm(); $this->data['success'] = 'completed'; $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($this->data)); }
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 get_attribute_type() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $am = new AAttribute_Manager(); $this->data['attribute_info'] = $am->getAttribute($this->request->get['attribute_id']); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($this->data['attribute_info']['attribute_type_id'])); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('localisation/zone'); if (isset($this->request->get['country_id'])) { $results = $this->model_localisation_zone->getZonesByCountryId($this->request->get['country_id']); } elseif ($this->request->get['location_id']) { $results = $this->model_localisation_zone->getZonesByLocationId($this->request->get['location_id']); } $json = array('options' => array()); $selected_name = ''; if (!empty($this->request->get['type'])) { $json['type'] = $this->request->get['type']; } else { if (!$results) { $json['options']['0']['value'] = array($this->language->get('text_none')); } } if (!$this->request->get['zone_id']) { $json['options'][0] = array('value' => $this->language->get('text_none'), 'selected' => TRUE); } else { $json['options'][0]['value'] = $this->language->get('text_none'); } // options for zones foreach ($results as $result) { $selected = FALSE; if (isset($this->request->get['zone_name']) && $this->request->get['zone_name'] == $result['name'] || isset($this->request->get['zone_id']) && $this->request->get['zone_id'] == $result['zone_id']) { $selected = TRUE; $selected_name = $result['name']; } $json['options'][$result['zone_id']]['value'] = $result['name']; if ($selected) { $json['options'][$result['zone_id']]['selected'] = $selected; } } if (!$results) { if (!$this->request->get['zone_id']) { $json['options'][0] = array('value' => $this->language->get('text_none'), 'selected' => TRUE); } else { $json['options'][0]['value'] = $this->language->get('text_none'); } } if (!empty($this->request->get['type'])) { $json['type'] = $this->request->get['type']; $json['selected_name'] = $selected_name; } $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($json), $this->config->get('config_compression')); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
private function _no_match() { $result = array(); $result['message'] = $this->language->get('text_possible_commands'); //load all possible commands from language definitions. foreach ($this->commands as $command) { $result['commands'][] = $command; } $this->load->library('json'); $this->response->setOutput(AJson::encode($result)); return null; }