Beispiel #1
0
 public function review()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('product/product');
     $this->loadModel('catalog/review');
     $this->view->assign('text_no_reviews', $this->language->get('text_no_reviews'));
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $reviews = array();
     $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5);
     foreach ($results as $result) {
         $reviews[] = array('author' => $result['author'], 'rating' => $result['rating'], 'text' => strip_tags($result['text']), 'stars' => sprintf($this->language->get('text_stars'), $result['rating']), 'date_added' => dateISO2Display($result['date_added'], $this->language->get('date_format_short')));
     }
     $this->data['reviews'] = $reviews;
     $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
     $this->data['pagination_bootstrap'] = HtmlElementFactory::create(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => $review_total, 'page' => $page, 'limit' => 5, 'url' => $this->html->getURL('product/review/review', '&product_id=' . $this->request->get['product_id'] . '&page={page}'), 'style' => 'pagination'));
     $this->view->batchAssign($this->data);
     $this->processTemplate('responses/product/review.tpl');
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 public function online()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('report/customer');
     //Prepare filter config
     $grid_filter_params = array('customer' => 'c.lastname', 'ip' => 'co.ip', 'url' => 'co.url', 'time' => 'co.date_added');
     $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
     $total = $this->model_report_customer->getTotalOnlineCustomers($filter_grid->getFilterData());
     $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_report_customer->getOnlineCustomers($filter_grid->getFilterData());
     $i = 0;
     foreach ($results as $result) {
         $response->rows[$i]['id'] = $result['customer_id'];
         //mark inactive customers.
         if ($result['status'] != 1) {
             $response->userdata->classes[$result['customer_id']] = 'attention';
         }
         $response->rows[$i]['cell'] = array($result['customer'], $result['ip'], dateISO2Display($result['date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format')), $result['url']);
         $i++;
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->setOutput(AJson::encode($response));
 }
 public function main()
 {
     //Load input arguments for gid settings
     $this->data = func_get_arg(0);
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('extension/extensions');
     $extension = $this->request->get['extension'];
     if ($extension && !$this->data['extension_info']) {
         $this->data['extension_info'] = $this->extensions->getExtensionInfo($extension);
     }
     $icon_ext_img_url = HTTP_CATALOG . 'extensions/' . $extension . '/image/icon.png';
     $icon_ext_dir = DIR_EXT . $extension . '/image/icon.png';
     $icon = is_file($icon_ext_dir) ? $icon_ext_img_url : RDIR_TEMPLATE . 'image/default_extension.png';
     $this->data['extension_info']['icon'] = $icon;
     $this->data['extension_info']['name'] = $this->language->get($extension . '_name');
     $datetime_format = $this->language->get('date_format_short') . ' ' . $this->language->get('time_format');
     if ($this->data['extension_info']['date_installed']) {
         $this->data['extension_info']['installed'] = dateISO2Display($this->data['extension_info']['date_installed'], $datetime_format);
     }
     if ($this->data['extension_info']['date_added']) {
         $this->data['extension_info']['date_added'] = dateISO2Display($this->data['extension_info']['date_added'], $datetime_format);
     }
     if (isset($this->session->data['extension_updates'][$extension])) {
         $this->data['upgrade_button'] = $this->html->buildElement(array('type' => 'button', 'name' => 'btn_upgrade', 'id' => 'upgradenow', 'href' => AEncryption::addEncoded_stid($this->session->data['extension_updates'][$extension]['url']), 'text' => $this->language->get('button_upgrade')));
     }
     $this->data['extension_info']['license'] = $this->data['extension_info']['license_key'];
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/extension/extension_summary.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 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('sale/order');
     $this->loadModel('sale/order');
     if (isset($this->request->get['order_id'])) {
         $order_id = $this->request->get['order_id'];
     } else {
         $order_id = 0;
     }
     $order_info = $this->model_sale_order->getOrder($order_id);
     if (empty($order_info)) {
         $this->data['error'] = $this->language->get('error_order_load');
     } else {
         $this->data['order'] = array('order_id' => '#' . $order_info['order_id'], 'name' => $order_info['firstname'] . ' ' . $order_info['lastname'], 'email' => $order_info['email'], 'telephone' => $order_info['telephone'], 'date_added' => dateISO2Display($order_info['date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format')), 'total' => $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value']), 'order_status' => $order_info['order_status_id'], 'shipping_method' => $order_info['shipping_method'], 'payment_method' => $order_info['payment_method']);
         if ($order_info['customer_id']) {
             $this->data['order']['name'] = '<a href="' . $this->html->getSecureURL('sale/customer/update', '&customer_id=' . $order_info['customer_id']) . '">' . $this->data['order']['name'] . '</a>';
         }
         $this->loadModel('localisation/order_status');
         $status = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']);
         if ($status) {
             $this->data['order']['order_status'] = $status['name'];
         }
     }
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/sale/order_summary.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Beispiel #6
0
 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));
 }
Beispiel #7
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('sale/coupon');
     $this->loadModel('sale/coupon');
     $limit = $this->request->post['rows'];
     // get how many rows we want to have into the grid
     $total = $this->model_sale_coupon->getTotalCoupons(array());
     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_coupon->getCoupons(array());
     $i = 0;
     $now = time();
     foreach ($results as $result) {
         // check daterange
         if (dateISO2Int($result['date_start']) > $now || dateISO2Int($result['date_end']) < $now) {
             $result['status'] = 0;
         }
         $response->rows[$i]['id'] = $result['coupon_id'];
         $response->rows[$i]['cell'] = array($result['name'], $result['code'], moneyDisplayFormat($result['discount']), dateISO2Display($result['date_start'], $this->language->get('date_format_short')), dateISO2Display($result['date_end'], $this->language->get('date_format_short')), $this->html->buildCheckbox(array('name' => 'status[' . $result['coupon_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));
 }
Beispiel #8
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('common/header');
     $this->loadLanguage('common/home');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE, 'current' => true));
     $this->view->assign('token', $this->session->data['token']);
     $this->loadModel('sale/order');
     $this->view->assign('total_sale', $this->currency->format($this->model_sale_order->getTotalSales(), $this->config->get('config_currency')));
     $this->view->assign('total_sale_year', $this->currency->format($this->model_sale_order->getTotalSalesByYear(date('Y')), $this->config->get('config_currency')));
     $this->view->assign('total_order', $this->model_sale_order->getTotalOrders());
     $this->loadModel('sale/customer');
     $this->view->assign('total_customer', $this->model_sale_customer->getTotalCustomers());
     $this->view->assign('total_customer_approval', $this->model_sale_customer->getTotalCustomersAwaitingApproval());
     $this->loadModel('catalog/product');
     $this->view->assign('total_product', $this->model_catalog_product->getTotalProducts());
     $this->loadModel('catalog/review');
     $this->view->assign('total_review', $this->model_catalog_review->getTotalReviews());
     $this->view->assign('total_review_approval', $this->model_catalog_review->getTotalReviewsAwaitingApproval());
     $this->view->assign('shortcut_heading', $this->language->get('text_dashboard'));
     $this->view->assign('shortcut', array(array('href' => $this->html->getSecureURL('catalog/category'), 'text' => $this->language->get('text_category'), 'icon' => 'categories_icon.png'), array('href' => $this->html->getSecureURL('catalog/product'), 'text' => $this->language->get('text_product'), 'icon' => 'products_icon.png'), array('href' => $this->html->getSecureURL('catalog/manufacturer'), 'text' => $this->language->get('text_manufacturer'), 'icon' => 'brands_icon.png'), array('href' => $this->html->getSecureURL('catalog/review'), 'text' => $this->language->get('text_review'), 'icon' => 'icon_manage3.png'), array('href' => $this->html->getSecureURL('sale/customer'), 'text' => $this->language->get('text_customer'), 'icon' => 'customers_icon.png'), array('href' => $this->html->getSecureURL('sale/order'), 'text' => $this->language->get('text_order_short'), 'icon' => 'orders_icon.png'), array('href' => $this->html->getSecureURL('extension/extensions/extensions'), 'text' => $this->language->get('text_extensions_short'), 'icon' => 'extensions_icon.png'), array('href' => $this->html->getSecureURL('localisation/language'), 'text' => $this->language->get('text_language'), 'icon' => 'languages_icon.png'), array('href' => $this->html->getSecureURL('design/content'), 'text' => $this->language->get('text_content'), 'icon' => 'content_manager_icon.png'), array('href' => $this->html->getSecureURL('setting/setting'), 'text' => $this->language->get('text_setting'), 'icon' => 'settings_icon.png'), array('href' => $this->html->getSecureURL('tool/message_manager'), 'text' => $this->language->get('text_messages'), 'icon' => 'icon_messages.png'), array('href' => $this->html->getSecureURL('design/layout'), 'text' => $this->language->get('text_layout'), 'icon' => 'icon_layouts.png')));
     //10 new orders and customers
     $filter = array('sort' => 'c.date_added', 'order' => 'DESC', 'start' => 0, 'limit' => 10);
     $top_customers = $this->model_sale_customer->getCustomers($filter);
     foreach ($top_customers as $indx => $customer) {
         $action = array();
         $action[] = array('text' => $this->language->get('text_edit'), 'href' => $this->html->getSecureURL('sale/customer/update', '&customer_id=' . $customer['customer_id']));
         $top_customers[$indx]['action'] = $action;
     }
     $this->view->assign('customers', $top_customers);
     $this->view->assign('customers_url', $this->html->getSecureURL('sale/customer'));
     $orders = array();
     $filter = array('sort' => 'o.date_added', 'order' => 'DESC', 'start' => 0, 'limit' => 10);
     $this->view->assign('orders_url', $this->html->getSecureURL('sale/order'));
     $this->view->assign('orders_text', $this->language->get('text_order'));
     $results = $this->model_sale_order->getOrders($filter);
     foreach ($results as $result) {
         $action = array();
         $action[] = array('text' => $this->language->get('text_edit'), 'href' => $this->html->getSecureURL('sale/order/update', '&order_id=' . $result['order_id']));
         $orders[] = array('order_id' => $result['order_id'], 'name' => $result['name'], 'status' => $result['status'], 'date_added' => dateISO2Display($result['date_added'], $this->language->get('date_format_short')), 'total' => $this->currency->format($result['total'], $result['currency'], $result['value']), 'action' => $action);
     }
     $this->view->assign('orders', $orders);
     if ($this->config->get('config_currency_auto')) {
         $this->loadModel('localisation/currency');
         $this->model_localisation_currency->updateCurrencies();
     }
     $this->view->assign('chart_url', $this->html->getSecureURL('index/chart'));
     $this->processTemplate('pages/index/home.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Beispiel #9
0
 /**
  * Main controller function to show order hitory
  */
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (!$this->customer->isLogged()) {
         $this->session->data['redirect'] = $this->html->getSecureURL('account/history');
         $this->redirect($this->html->getSecureURL('account/login'));
     }
     $this->document->setTitle($this->language->get('heading_title'));
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator')));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/history'), 'text' => $this->language->get('text_history'), 'separator' => $this->language->get('text_separator')));
     $this->loadModel('account/order');
     $order_total = $this->model_account_order->getTotalOrders();
     if ($order_total) {
         $this->data['action'] = $this->html->getURL('account/history');
         if (isset($this->request->get['page'])) {
             $page = $this->request->get['page'];
         } else {
             $page = 1;
         }
         if (isset($this->request->get['limit'])) {
             $limit = (int) $this->request->get['limit'];
             $limit = $limit > 50 ? 50 : $limit;
         } else {
             $limit = $this->config->get('config_catalog_limit');
         }
         $orders = array();
         $results = $this->model_account_order->getOrders(($page - 1) * $limit, $limit);
         foreach ($results as $result) {
             $product_total = $this->model_account_order->getTotalOrderProductsByOrderId($result['order_id']);
             $button = HtmlElementFactory::create(array('type' => 'button', 'name' => 'button_edit', 'text' => $this->language->get('button_view'), 'style' => 'btn-default', 'icon' => 'fa fa-info', 'attr' => ' onclick = "viewOrder(' . $result['order_id'] . ');" '));
             $orders[] = array('order_id' => $result['order_id'], 'name' => $result['firstname'] . ' ' . $result['lastname'], 'status' => $result['status'], 'date_added' => dateISO2Display($result['date_added'], $this->language->get('date_format_short')), 'products' => $product_total, 'total' => $this->currency->format($result['total'], $result['currency'], $result['value']), 'href' => $this->html->getSecureURL('account/invoice', '&order_id=' . $result['order_id']), 'button' => $button->getHtml());
         }
         $this->data['order_url'] = $this->html->getSecureURL('account/invoice');
         $this->data['orders'] = $orders;
         $this->data['pagination_bootstrap'] = HtmlElementFactory::create(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => $order_total, 'page' => $page, 'limit' => $limit, 'url' => $this->html->getURL('account/history', '&limit=' . $limit . '&page={page}'), 'style' => 'pagination'));
         $this->data['continue'] = $this->html->getSecureURL('account/account');
         $this->view->setTemplate('pages/account/history.tpl');
     } else {
         $this->data['continue'] = $this->html->getSecureURL('account/account');
         $this->view->setTemplate('pages/error/not_found.tpl');
     }
     $this->data['button_continue'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button'));
     $this->view->batchAssign($this->data);
     $this->processTemplate();
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Beispiel #10
0
 /**
  * Main Controller function to show transaction hitory. 
  * Note: Regular orders are considered in the transactions. 
  */
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (!$this->customer->isLogged()) {
         $this->session->data['redirect'] = $this->html->getSecureURL('account/transactions');
         $this->redirect($this->html->getSecureURL('account/login'));
     }
     $this->document->setTitle($this->language->get('heading_title'));
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator')));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/transactions'), 'text' => $this->language->get('text_transactions'), 'separator' => $this->language->get('text_separator')));
     $this->loadModel('account/customer');
     $trans_total = $this->model_account_customer->getTotalTransactions();
     $balance = $this->customer->getBalance();
     $this->data['balance_amount'] = $this->currency->format($balance);
     if ($trans_total) {
         $this->data['action'] = $this->html->getURL('account/transactions');
         if (isset($this->request->get['page'])) {
             $page = $this->request->get['page'];
         } else {
             $page = 1;
         }
         if (isset($this->request->get['limit'])) {
             $limit = (int) $this->request->get['limit'];
             $limit = $limit > 50 ? 50 : $limit;
         } else {
             $limit = $this->config->get('config_catalog_limit');
         }
         $trans = array();
         $results = $this->model_account_customer->getTransactions(($page - 1) * $limit, $limit);
         foreach ($results as $result) {
             $trans[] = array('customer_transaction_id' => $result['customer_transaction_id'], 'order_id' => $result['order_id'], 'section' => $result['section'], 'credit' => $this->currency->format($result['credit']), 'debit' => $this->currency->format($result['debit']), 'transaction_type' => $result['transaction_type'], 'description' => $result['description'], 'create_date' => dateISO2Display($result['create_date'], $this->language->get('date_format_short')));
         }
         $this->data['transactions'] = $trans;
         $this->data['pagination_bootstrap'] = HtmlElementFactory::create(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => $trans_total, 'page' => $page, 'limit' => $limit, 'url' => $this->html->getURL('account/transactions', '&limit=' . $limit . '&page={page}'), 'style' => 'pagination'));
         $this->data['continue'] = $this->html->getSecureURL('account/account');
         $this->view->setTemplate('pages/account/transactions.tpl');
     } else {
         $this->data['continue'] = $this->html->getSecureURL('account/account');
         $this->view->setTemplate('pages/account/transactions.tpl');
     }
     $this->data['button_continue'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button'));
     $this->view->batchAssign($this->data);
     $this->processTemplate();
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Beispiel #11
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('report/sale');
     $this->loadModel('report/sale');
     $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);
     //process custom search form
     $allowedSearchFilter = array('date_start', 'date_end', 'group');
     foreach ($allowedSearchFilter as $filter) {
         if (isset($this->request->get[$filter]) && $this->request->get[$filter] != '') {
             $data[$filter] = $this->request->get[$filter];
         }
     }
     $total = $this->model_report_sale->getSaleReportTotal($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_report_sale->getSaleReport($data);
     $i = 0;
     foreach ($results as $result) {
         $response->rows[$i]['id'] = $i;
         $response->rows[$i]['cell'] = array(dateISO2Display($result['date_start'], $this->language->get('date_format_short')), dateISO2Display($result['date_end'], $this->language->get('date_format_short')), $result['orders'], $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('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/location');
     $this->loadModel('localisation/zone');
     $this->loadModel('localisation/country');
     $data = array('location_id' => $this->request->get['location_id'], 'sort' => $sidx, 'order' => strtoupper($sord), 'start' => ($page - 1) * $limit, 'limit' => $limit);
     $zone_to_locations = $this->model_localisation_location->getZoneToLocations($data);
     $total = $this->model_localisation_location->getTotalZoneToLocationsByLocationID($this->request->get['location_id']);
     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;
     $i = 0;
     foreach ($zone_to_locations as $result) {
         $response->rows[$i]['id'] = $result['zone_to_location_id'];
         $response->rows[$i]['cell'] = array($result['country_name'], $result['name'], 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));
 }
Beispiel #13
0
 public function get()
 {
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $product_id = $this->request->get['product_id'];
     if (!$product_id) {
         $this->rest->setResponseData(array('Error' => 'Missing product ID as a required parameter'));
         $this->rest->sendResponse(200);
         return null;
     }
     if (!$this->config->get('enable_reviews')) {
         $this->rest->setResponseData(array('Error' => 'Reviews for products are disabled'));
         $this->rest->sendResponse(200);
         return null;
     }
     $this->loadModel('catalog/review');
     $total_reviews = $this->model_catalog_review->getTotalReviewsByProductId($product_id);
     $average = $this->model_catalog_review->getAverageRating($product_id);
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     if (isset($this->request->get['rows'])) {
         $rows = $this->request->get['rows'];
     } else {
         $rows = 5;
     }
     if ($total_reviews > 0 && $rows > 0) {
         $total_pages = ceil($total_reviews / $rows);
     } else {
         $total_pages = 0;
     }
     $reviews = array();
     $results = $this->model_catalog_review->getReviewsByProductId($product_id, ($page - 1) * $rows, $rows);
     foreach ($results as $result) {
         $reviews[] = array('author' => $result['author'], 'rating' => $result['rating'], 'text' => strip_tags($result['text']), 'date_added' => dateISO2Display($result['date_added'], $this->language->get('date_format_short')));
     }
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->rest->setResponseData(array('average' => $average, 'records' => $total_reviews, 'page' => $page, 'total' => $total_pages, 'rows' => $reviews));
     $this->rest->sendResponse(200);
 }
Beispiel #14
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('localisation/currency');
     $this->loadModel('localisation/currency');
     $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' => strtoupper($sord), 'start' => ($page - 1) * $limit, 'limit' => $limit);
     $total = $this->model_localisation_currency->getTotalCurrencies();
     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_currency->getCurrencies($data);
     $i = 0;
     foreach ($results as $result) {
         $response->rows[$i]['id'] = $result['currency_id'];
         $response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'title[' . $result['currency_id'] . ']', 'value' => $result['title'])), $this->html->buildInput(array('name' => 'code[' . $result['currency_id'] . ']', 'value' => $result['code'])), $this->html->buildInput(array('name' => 'value[' . $result['currency_id'] . ']', 'value' => $result['value'])), dateISO2Display($result['date_modified'], $this->language->get('date_format_short')), $this->html->buildCheckbox(array('name' => 'status[' . $result['currency_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 post()
 {
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $request_data = $this->rest->getRequestParams();
     if (!$this->customer->isLoggedWithToken($request_data['token'])) {
         $this->rest->setResponseData(array('error' => 'Not logged in or Login attempt failed!'));
         $this->rest->sendResponse(401);
         return null;
     }
     $this->loadModel('account/order');
     $this->loadLanguage('account/history');
     $order_total = $this->model_account_order->getTotalOrders();
     if ($order_total) {
         if (isset($request_data['page'])) {
             $page = $request_data['page'];
         } else {
             $page = 1;
         }
         $this->data['limit'] = $this->config->get('config_catalog_limit');
         $orders = array();
         $results = $this->model_account_order->getOrders(($page - 1) * $this->data['limit'], $this->data['limit']);
         foreach ($results as $result) {
             $product_total = $this->model_account_order->getTotalOrderProductsByOrderId($result['order_id']);
             $orders[] = array('order_id' => $result['order_id'], 'name' => $result['firstname'] . ' ' . $result['lastname'], 'status' => $result['status'], 'date_added' => dateISO2Display($result['date_added'], $this->language->get('date_format_short')), 'products' => $product_total, 'total' => $this->currency->format($result['total'], $result['currency'], $result['value']));
         }
         $this->data['orders'] = $orders;
         $this->data['total_orders'] = $order_total;
         $this->data['page'] = $page;
     } else {
         $this->data['orders'] = array();
         $this->data['total_orders'] = 0;
     }
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->rest->setResponseData($this->data);
     $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));
 }
Beispiel #17
0
 /**
  * @param int $order_id
  * @param int $order_status_id
  * @param string $comment
  * @param bool $notify
  */
 public function update($order_id, $order_status_id, $comment = '', $notify = FALSE)
 {
     $order_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t FROM `" . $this->db->table("orders") . "` o\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN " . $this->db->table("languages") . " l ON (o.language_id = l.language_id)\n\t\t\t\t\t\t\t\t\t\t WHERE o.order_id = '" . (int) $order_id . "' AND o.order_status_id > '0'");
     if ($order_query->num_rows) {
         $order_row = $this->dcrypt->decrypt_data($order_query->row, 'orders');
         $this->db->query("UPDATE `" . $this->db->table("orders") . "`\n\t\t\t\t\t\t\t\tSET order_status_id = '" . (int) $order_status_id . "',\n\t\t\t\t\t\t\t\t\tdate_modified = NOW()\n\t\t\t\t\t\t\t\tWHERE order_id = '" . (int) $order_id . "'");
         $this->db->query("INSERT INTO " . $this->db->table("order_history") . "\n\t\t\t\t\t\t\t\tSET order_id = '" . (int) $order_id . "',\n\t\t\t\t\t\t\t\t\torder_status_id = '" . (int) $order_status_id . "',\n\t\t\t\t\t\t\t\t\tnotify = '" . (int) $notify . "',\n\t\t\t\t\t\t\t\t\tcomment = '" . $this->db->escape($comment) . "',\n\t\t\t\t\t\t\t\t\tdate_added = NOW()");
         if ($notify) {
             $language = new ALanguage($this->registry, $order_row['code']);
             $language->load($order_row['filename']);
             $language->load('mail/order_update');
             $subject = sprintf($language->get('text_subject'), html_entity_decode($order_row['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
             $message = $language->get('text_order') . ' ' . $order_id . "\n";
             $message .= $language->get('text_date_added') . ' ' . dateISO2Display($order_row['date_added'], $language->get('date_format_short')) . "\n\n";
             $order_status_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("order_statuses") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE order_status_id = '" . (int) $order_status_id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND language_id = '" . (int) $order_row['language_id'] . "'");
             if ($order_status_query->num_rows) {
                 $message .= $language->get('text_order_status') . "\n\n";
                 $message .= $order_status_query->row['name'] . "\n\n";
             }
             $message .= $language->get('text_invoice') . "\n";
             $message .= $order_row['store_url'] . 'index.php?rt=account/invoice&order_id=' . $order_id . "\n\n";
             if ($comment) {
                 $message .= $language->get('text_comment') . "\n\n";
                 $message .= $comment . "\n\n";
             }
             $message .= $language->get('text_footer');
             $mail = new AMail($this->config);
             $mail->setTo($order_row['email']);
             $mail->setFrom($this->config->get('store_main_email'));
             $mail->setSender($order_row['store_name']);
             $mail->setSubject($subject);
             $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
             $mail->send();
         }
     }
 }
Beispiel #18
0
    public function main()
    {
        //init controller data
        $this->extensions->hk_InitData($this, __FUNCTION__);
        $this->loadLanguage('extension/extensions');
        $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
        $sidx = $this->request->post['sidx'];
        // get index row - i.e. user click to sort
        $sord = $this->request->post['sord'];
        // get the direction
        $search_str = '';
        if (isset($this->request->post['_search']) && $this->request->post['_search'] == 'true') {
            $searchData = json_decode(htmlspecialchars_decode($this->request->post['filters']), true);
            $search_str = $searchData['rules'][0]['data'];
        }
        $store_id = (int) $this->config->get('config_store_id');
        if ($this->request->get_or_post('store_id')) {
            $store_id = $this->request->get_or_post('store_id');
        }
        //sort
        $allowedSort = array(1 => 'key', 'name', 'category', 'update_date', 'status', 'store_name');
        if (!in_array($sidx, $allowedSort)) {
            $sidx = 'update_date';
        }
        $allowedDirection = array(SORT_ASC => 'asc', SORT_DESC => 'desc');
        if (!in_array($sord, $allowedDirection)) {
            $sord = 'asc';
        }
        //extensions that has record in DB but missing files
        $missing_extensions = $this->extensions->getMissingExtensions();
        $data = array('store_id' => $store_id, 'search' => $search_str, 'filter' => $this->session->data['extension_filter'], 'sort_order' => array($sidx, $sord));
        if ($this->config->get('config_store_id')) {
            $data['store_id'] = (int) $this->config->get('config_store_id');
        }
        //extensions list
        $extensions = $this->extension_manager->getExtensionsList($data);
        $total = $extensions->total;
        if ($total > 0) {
            $total_pages = ceil($total / $limit);
        } else {
            $total_pages = 0;
        }
        $response = new stdClass();
        $response->rows = array();
        $response->page = $page;
        $response->total = $total_pages;
        $response->records = $total;
        $response->userdata = new stdClass();
        $i = 0;
        $push = array();
        // get extensions for install
        $ready_to_install = $this->session->data['ready_to_install'];
        $to_install = $to_inst_keys = array();
        if (!has_value($this->session->data['extension_filter']) || $this->session->data['extension_filter'] == 'extensions') {
            if ($ready_to_install && is_array($ready_to_install)) {
                foreach ($ready_to_install as $pack) {
                    $to_install[$pack['extension_name']] = array('remote_install' => true, 'key' => $pack['extension_name'], 'name' => $pack['download_name'], 'extension_version' => $pack['extension_version'], 'installation_key' => $pack['installation_key'], 'update_date' => $pack['update_date']);
                    $to_inst_keys[] = $pack['extension_name'];
                }
            }
        }
        //filter already installed from remote list (ignores new versions too)
        foreach ($extensions->rows as $row) {
            if (in_array($row['key'], $to_inst_keys)) {
                unset($to_install[$row['key']]);
            }
        }
        $rows = array_merge($to_install, $extensions->rows);
        foreach ($rows as $row) {
            $extension = $row['key'];
            $name = !isset($row['name']) ? trim($this->extensions->getExtensionName($extension)) : $row['name'];
            //for new extensions
            if ($row['remote_install']) {
                $action = '<a class="btn_action"
							  href="' . $this->html->getSecureURL('tool/package_installer/download', '&extension_key=' . $row['installation_key']) . '"
							  title="' . $this->language->get('text_install') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_install.png" alt="' . $this->language->get('text_install') . '" /></a>';
                $icon = '<img src="' . RDIR_TEMPLATE . 'image/default_extension.png' . '" alt="" border="0" />';
                $category = '';
                $status = 'Ready to install';
                $response->userdata->classes[$extension . '_' . $row['store_id']] = 'success';
            } elseif (in_array($extension, $missing_extensions)) {
                $action = '<a class="btn_action" href="' . $this->html->getSecureURL('extension/extensions/delete', $this->data['url'] . '&extension=' . $extension) . '"
			 	onclick="return confirm(\'' . $this->language->get('text_delete_confirm') . '\')" title="' . $this->language->get('text_delete') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_delete.png" alt="' . $this->language->get('text_delete') . '" />' . '</a>';
                $icon = '<img src="' . RDIR_TEMPLATE . 'image/default_extension.png' . '" alt="" border="0" />';
                $name = str_replace('%EXT%', $extension, $this->language->get('text_missing_extension'));
                $category = '';
                $status = '';
                $row['update_date'] = date('Y-m-d H:i:s', time());
                // change it for show it in list first by default sorting
                $response->userdata->classes[$extension . '_' . $row['store_id']] = 'warning';
            } elseif (!file_exists(DIR_EXT . $extension . '/main.php') || !file_exists(DIR_EXT . $extension . '/config.xml')) {
                $action = '<a class="btn_action" href="' . $this->html->getSecureURL('extension/extensions/delete', $this->data['url'] . '&extension=' . $extension) . '"
			 	onclick="return confirm(\'' . $this->language->get('text_delete_confirm') . '\')" title="' . $this->language->get('text_delete') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_delete.png" alt="' . $this->language->get('text_delete') . '" />' . '</a>';
                $icon = '<img src="' . RDIR_TEMPLATE . 'image/default_extension.png' . '" alt="" border="0" />';
                $name = str_replace('%EXT%', $extension, $this->language->get('text_broken_extension'));
                $category = '';
                $status = '';
                $row['update_date'] = date('Y-m-d H:i:s', time());
                // change it for show it in list first by default sorting
                $response->userdata->classes[$extension . '_' . $row['store_id']] = 'warning';
            } else {
                if (!$this->config->has($extension . '_status')) {
                    $action = '<a class="btn_action"
								onclick="show_popup(\'' . $extension . '\', \'' . $this->html->getSecureURL('extension/extensions/install', $this->data['url'] . '&extension=' . $extension) . '\')"
					title="' . $this->language->get('text_install') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_install.png" alt="' . $this->language->get('text_install') . '" />' . '</a>' . '<a class="btn_action" href="' . $this->html->getSecureURL('extension/extensions/delete', $this->data['url'] . '&extension=' . $extension) . '"
						  onclick="return confirm(\'' . $this->language->get('text_delete_confirm') . '\')" title="' . $this->language->get('text_delete') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_delete.png" alt="' . $this->language->get('text_delete') . '" />' . '</a>';
                    $status = $this->language->get('text_not_installed');
                } else {
                    $action = '<a id="action_edit_' . $extension . '" class="btn_action" href="' . $this->html->getSecureURL('extension/extensions/edit', $this->data['url'] . '&store_id=' . (int) $row['store_id'] . '&extension=' . $extension) . '"
						title="' . $this->language->get('text_edit') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_edit.png" alt="' . $this->language->get('text_edit') . '" />' . '</a>' . '<a class="btn_action" href="' . $this->html->getSecureURL('extension/extensions/uninstall', $this->data['url'] . '&extension=' . $extension) . '"
						  onclick="return confirm(\'' . str_replace('%extension%', $name, $this->language->get('text_uninstall_confirm')) . '\')"
						  title="' . $this->language->get('text_uninstall') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_uninstall.png" alt="' . $this->language->get('text_uninstall') . '" />' . '</a>';
                    $status = $this->html->buildCheckbox(array('name' => $extension . '[' . $extension . '_status]', 'value' => $row['status'], 'style' => 'btn_switch'));
                }
                $icon_ext_img_url = HTTP_CATALOG . 'extensions/' . $extension . '/image/icon.png';
                $icon_ext_dir = DIR_EXT . $extension . '/image/icon.png';
                $icon = is_file($icon_ext_dir) ? $icon_ext_img_url : RDIR_TEMPLATE . 'image/default_extension.png';
                if (!$this->config->has($extension . '_status')) {
                    $icon = '<img src="' . $icon . '" alt="" border="0" />';
                } else {
                    $icon = '<a href="' . $this->html->getSecureURL('extension/extensions/edit', $this->data['url'] . '&extension=' . $extension) . '"><img src="' . $icon . '" alt="" border="0" /></a>';
                }
                $category = $row['category'];
                // if update available
                if ($this->session->data['extension_updates']) {
                    if (in_array($extension, array_keys($this->session->data['extension_updates']))) {
                        $name = '<p class="warning">' . $name . '<br>' . str_replace('%NEWVERSION%', $this->session->data['extension_updates'][$extension]['new_version'], $this->language->get('text_update_it')) . '</p>';
                        $push[] = $i;
                    }
                }
            }
            $response->rows[$i]['id'] = $extension . '_' . $row['store_id'];
            $response->rows[$i]['cell'] = array($icon, $extension, $name, $category, dateISO2Display($row['update_date'], $this->language->get('date_format_short')));
            if (!$this->config->get('config_store_id')) {
                $response->rows[$i]['cell'][] = $row['store_name'] ? $row['store_name'] : $this->language->get('text_default');
            }
            $response->rows[$i]['cell'][] = $status;
            $response->rows[$i]['cell'][] = $action;
            if ($push) {
                if (in_array($i, $push)) {
                    $for_push[] = $response->rows[$i];
                    unset($response->rows[$i]);
                }
            }
            $i++;
        }
        if ($push) {
            foreach ($for_push as $ext) {
                array_unshift($response->rows, $ext);
            }
        }
        $response->rows = array_slice($response->rows, (int) ($page - 1) * $limit, $limit);
        //update controller data
        $this->extensions->hk_UpdateData($this, __FUNCTION__);
        $this->load->library('json');
        $this->response->setOutput(AJson::encode($response));
    }
 private function _getForm()
 {
     $this->data['token'] = $this->session->data['token'];
     $this->data['cancel'] = $this->html->getSecureURL('sale/coupon');
     $this->data['error'] = $this->error;
     $cont_lang_id = $this->language->getContentLanguageID();
     $this->view->assign('category_products_url', $this->html->getSecureURL('r/product/product/category', '&language_id=' . $cont_lang_id));
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/coupon'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     if (has_value($this->request->get['coupon_id']) && $this->request->is_GET()) {
         $coupon_info = $this->model_sale_coupon->getCouponByID($this->request->get['coupon_id']);
     }
     $this->data['languages'] = $this->language->getAvailableLanguages();
     foreach ($this->fields as $f) {
         if (isset($this->request->post[$f])) {
             $this->data[$f] = $this->request->post[$f];
         } elseif (isset($coupon_info) && isset($coupon_info[$f])) {
             $this->data[$f] = $coupon_info[$f];
         } else {
             $this->data[$f] = '';
         }
     }
     if (!is_array($this->data['coupon_description'])) {
         if (isset($this->request->get['coupon_id'])) {
             $this->data['coupon_description'] = $this->model_sale_coupon->getCouponDescriptions($this->request->get['coupon_id']);
         } else {
             $this->data['coupon_description'] = array();
         }
     }
     if (!is_array($this->data['coupon_product'])) {
         if (isset($coupon_info)) {
             $this->data['coupon_product'] = $this->model_sale_coupon->getCouponProducts($this->request->get['coupon_id']);
         } else {
             $this->data['coupon_product'] = array();
         }
     }
     //check if coupon is active based on dates and update status
     $now = time();
     if ($this->data['date_start'] && dateISO2Int($this->data['date_start']) > $now || $this->data['date_end'] && dateISO2Int($this->data['date_end']) < $now) {
         $this->data['status'] = 0;
     }
     if (isset($this->request->post['date_start'])) {
         $this->data['date_start'] = dateDisplay2ISO($this->request->post['date_start'], $this->language->get('date_format_short'));
     } elseif (isset($coupon_info)) {
         $this->data['date_start'] = dateISO2Display($coupon_info['date_start'], $this->language->get('date_format_short'));
     } else {
         $this->data['date_start'] = dateInt2Display(time(), $this->language->get('date_format_short'));
     }
     if (isset($this->request->post['date_end'])) {
         $this->data['date_end'] = dateDisplay2ISO($this->request->post['date_end'], $this->language->get('date_format_short'));
     } elseif (isset($coupon_info)) {
         $this->data['date_end'] = dateISO2Display($coupon_info['date_end'], $this->language->get('date_format_short'));
     } else {
         $this->data['date_end'] = '';
     }
     if (isset($this->data['uses_total']) && $this->data['uses_total'] == -1) {
         $this->data['uses_total'] = '';
     } elseif (isset($this->data['uses_total']) && $this->data['uses_total'] == '') {
         $this->data['uses_total'] = 1;
     }
     if (isset($this->data['uses_customer']) && $this->data['uses_customer'] == -1) {
         $this->data['uses_customer'] = '';
     } elseif (isset($this->data['uses_customer']) && $this->data['uses_customer'] == '') {
         $this->data['uses_customer'] = 1;
     }
     if (!has_value($this->data['status'])) {
         $this->data['status'] = 1;
     }
     if (!has_value($this->request->get['coupon_id'])) {
         $this->data['action'] = $this->html->getSecureURL('sale/coupon/insert');
         $this->data['heading_title'] = $this->language->get('text_insert') . ' ' . $this->language->get('text_coupon');
         $this->data['update'] = '';
         $form = new AForm('ST');
     } else {
         $this->data['action'] = $this->html->getSecureURL('sale/coupon/update', '&coupon_id=' . $this->request->get['coupon_id']);
         $this->data['heading_title'] = $this->language->get('text_edit') . ' ' . $this->language->get('text_coupon') . ' - ' . $this->data['coupon_description'][$cont_lang_id]['name'];
         $this->data['update'] = $this->html->getSecureURL('listing_grid/coupon/update_field', '&id=' . $this->request->get['coupon_id']);
         $form = new AForm('HS');
     }
     $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['heading_title'], 'separator' => ' :: ', 'current' => true));
     $form->setForm(array('form_name' => 'couponFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'couponFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'couponFrm', 'attr' => 'data-confirm-exit="true"  class="aform form-horizontal"', 'action' => $this->data['action']));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
     $this->data['form']['fields']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => $this->data['status'], 'style' => 'btn_switch'));
     $this->data['form']['fields']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'coupon_description[' . $cont_lang_id . '][name]', 'value' => $this->data['coupon_description'][$cont_lang_id]['name'], 'required' => true, 'style' => 'large-field'));
     $this->data['form']['fields']['description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'coupon_description[' . $cont_lang_id . '][description]', 'value' => $this->data['coupon_description'][$cont_lang_id]['description'], 'required' => true, 'style' => 'large-field'));
     $this->data['form']['fields']['code'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'code', 'value' => $this->data['code'], 'required' => true));
     $this->data['form']['fields']['type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'type', 'value' => $this->data['type'], 'options' => array('P' => $this->language->get('text_percent'), 'F' => $this->language->get('text_amount'))));
     $this->data['form']['fields']['discount'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'discount', 'value' => moneyDisplayFormat($this->data['discount'])));
     $this->data['form']['fields']['total'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'total', 'value' => moneyDisplayFormat($this->data['total'])));
     $this->data['form']['fields']['logged'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'logged', 'value' => $this->data['logged'], 'options' => array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no'))));
     $this->data['form']['fields']['shipping'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'shipping', 'value' => $this->data['shipping'], 'options' => array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no'))));
     $this->data['form']['fields']['date_start'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'date_start', 'value' => $this->data['date_start'], 'default' => dateNowDisplay(), 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'required' => true));
     $this->data['form']['fields']['date_end'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'date_end', 'value' => $this->data['date_end'], 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'pased', 'required' => true));
     $this->data['form']['fields']['uses_total'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'uses_total', 'value' => $this->data['uses_total']));
     $this->data['form']['fields']['uses_customer'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'uses_customer', 'value' => $this->data['uses_customer']));
     if ($this->request->get['coupon_id']) {
         $this->loadModel('sale/order');
         $total = $this->model_sale_order->getTotalOrders(array('filter_coupon_id' => $this->request->get['coupon_id']));
         $this->data['form']['fields']['total_coupon_usage'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'total_coupon_usage', 'value' => (int) $total, 'attr' => 'disabled'));
     }
     //load only prior saved products
     $resource = new AResource('image');
     $this->data['products'] = array();
     if (count($this->data['coupon_product'])) {
         $this->loadModel('catalog/product');
         $filter = array('subsql_filter' => 'p.product_id in (' . implode(',', $this->data['coupon_product']) . ')');
         $results = $this->model_catalog_product->getProducts($filter);
         foreach ($results as $r) {
             $thumbnail = $resource->getMainThumb('products', $r['product_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true);
             $this->data['products'][$r['product_id']]['name'] = $r['name'] . " (" . $r['model'] . ")";
             $this->data['products'][$r['product_id']]['image'] = $thumbnail['thumb_html'];
         }
     }
     $this->data['form']['fields']['product'] = $form->getFieldHtml(array('type' => 'multiselectbox', 'name' => 'coupon_product[]', 'value' => $this->data['coupon_product'], 'options' => $this->data['products'], 'style' => 'chosen', 'ajax_url' => $this->html->getSecureURL('r/product/product/products'), 'placeholder' => $this->language->get('text_select_from_lookup')));
     $this->view->assign('help_url', $this->gen_help_url('coupon_edit'));
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/sale/coupon_form.tpl');
 }
Beispiel #20
0
 public function files()
 {
     $this->data = array();
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     if (has_value($this->session->data['error'])) {
         $this->data['error']['warning'] = $this->session->data['error'];
         unset($this->session->data['error']);
     }
     if (isset($this->request->get['order_id'])) {
         $order_id = $this->request->get['order_id'];
     } else {
         $order_id = 0;
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_validateForm()) {
         if (has_value($this->request->post['downloads'])) {
             $data = $this->request->post['downloads'];
             $this->loadModel('catalog/download');
             foreach ($data as $order_download_id => $item) {
                 if (isset($item['expire_date'])) {
                     $item['expire_date'] = $item['expire_date'] ? dateDisplay2ISO($item['expire_date'], $this->language->get('date_format_short')) : '';
                 }
                 $this->model_catalog_download->editOrderDownload($order_download_id, $item);
             }
         }
         //add download to order
         if (has_value($this->request->post['push'])) {
             $this->load->library('json');
             foreach ($this->request->post['push'] as $order_product_id => $items) {
                 $items = AJson::decode(html_entity_decode($items), true);
                 if ($items) {
                     foreach ($items as $download_id => $info) {
                         $download_info = $this->download->getDownloadInfo($download_id);
                         $download_info['attributes_data'] = serialize($this->download->getDownloadAttributesValues($download_id));
                         $this->download->addProductDownloadToOrder($order_product_id, $order_id, $download_info);
                     }
                 }
             }
         }
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']));
     }
     $order_info = $this->model_sale_order->getOrder($order_id);
     $this->data['order_info'] = $order_info;
     //set content language to order language ID.
     if ($this->language->getContentLanguageID() != $order_info['language_id']) {
         //reset content language
         $this->language->setCurrentContentLanguage($order_info['language_id']);
     }
     if (empty($order_info)) {
         $this->session->data['error'] = $this->language->get('error_order_load');
         $this->redirect($this->html->getSecureURL('sale/order'));
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']), 'text' => $this->language->get('heading_title') . ' #' . $order_info['order_id'], 'separator' => ' :: '));
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->data['heading_title'] = $this->language->get('heading_title') . ' #' . $order_info['order_id'];
     $this->data['token'] = $this->session->data['token'];
     $this->data['invoice'] = $this->html->getSecureURL('sale/invoice', '&order_id=' . (int) $this->request->get['order_id']);
     $this->data['button_invoice'] = $this->html->buildButton(array('name' => 'btn_invoice', 'text' => $this->language->get('text_invoice'), 'style' => 'button3'));
     $this->data['invoice_generate'] = $this->html->getSecureURL('sale/invoice/generate');
     $this->data['category_products'] = $this->html->getSecureURL('product/product/category');
     $this->data['product_update'] = $this->html->getSecureURL('catalog/product/update');
     $this->data['order_id'] = $this->request->get['order_id'];
     $this->data['action'] = $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']);
     $this->data['cancel'] = $this->html->getSecureURL('sale/order');
     $this->_initTabs('files');
     $this->loadModel('localisation/order_status');
     $status = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']);
     if ($status) {
         $this->data['order_status'] = $status['name'];
     } else {
         $this->data['order_status'] = '';
     }
     $this->loadModel('sale/customer_group');
     $customer_group_info = $this->model_sale_customer_group->getCustomerGroup($order_info['customer_group_id']);
     if ($customer_group_info) {
         $this->data['customer_group'] = $customer_group_info['name'];
     } else {
         $this->data['customer_group'] = '';
     }
     $this->data['form_title'] = $this->language->get('edit_title_files');
     $this->data['update'] = $this->html->getSecureURL('listing_grid/order/update_field', '&id=' . $this->request->get['order_id']);
     $form = new AForm('HS');
     $form->setForm(array('form_name' => 'orderFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'orderFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'orderFrm', 'attr' => 'confirm-exit="true"', 'action' => $this->data['action']));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
     $this->addChild('pages/sale/order_summary', 'summary_form', 'pages/sale/order_summary.tpl');
     /** ORDER DOWNLOADS */
     $this->data['downloads'] = array();
     $order_downloads = $this->model_sale_order->getOrderDownloads($this->request->get['order_id']);
     if ($order_downloads) {
         $rl = new AResource('image');
         if (!$this->registry->has('jqgrid_script')) {
             $locale = $this->session->data['language'];
             if (!file_exists(DIR_ROOT . '/' . RDIR_TEMPLATE . 'javascript/jqgrid/js/i18n/grid.locale-' . $locale . '.js')) {
                 $locale = 'en';
             }
             $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/i18n/grid.locale-' . $locale . '.js');
             $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/jquery.jqGrid.min.js');
             $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/plugins/jquery.grid.fluid.js');
             $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/jquery.ba-bbq.min.js');
             $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/grid.history.js');
             //set flag to not include scripts/css twice
             $this->registry->set('jqgrid_script', true);
         }
         $this->session->data['multivalue_excludes'] = array();
         $this->loadModel('catalog/download');
         foreach ($order_downloads as $product_id => $order_download) {
             $downloads = (array) $order_download['downloads'];
             $this->data['order_downloads'][$product_id]['product_name'] = $order_download['product_name'];
             $this->data['order_downloads'][$product_id]['product_thumbnail'] = $rl->getMainThumb('products', $product_id, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'));
             foreach ($downloads as $download_info) {
                 $download_info['order_status_id'] = $order_info['order_status_id'];
                 $attributes = $this->download->getDownloadAttributesValuesForDisplay($download_info['download_id']);
                 $order_product_id = $download_info['order_product_id'];
                 $is_file = $this->download->isFileAvailable($download_info['filename']);
                 foreach ($download_info['download_history'] as &$h) {
                     $h['time'] = dateISO2Display($h['time'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
                 }
                 unset($h);
                 $status_text = $this->model_catalog_download->getTextStatusForOrderDownload($download_info);
                 if ($status_text) {
                     $status = $status_text;
                 } else {
                     $status = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][status]', 'value' => $download_info['status'], 'style' => 'btn_switch'));
                 }
                 $this->data['order_downloads'][$product_id]['downloads'][] = array('name' => $download_info['name'], 'attributes' => $attributes, 'href' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $product_id . '&download_id=' . $download_info['download_id']), 'resource' => $download_info['filename'], 'is_file' => $is_file, 'mask' => $download_info['mask'], 'status' => $status, 'remaining' => $form->getFieldHtml(array('type' => 'input', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][remaining_count]', 'value' => $download_info['remaining_count'], 'placeholder' => '-', 'style' => 'small-field')), 'expire_date' => $form->getFieldHtml(array('type' => 'date', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][expire_date]', 'value' => $download_info['expire_date'] ? dateISO2Display($download_info['expire_date']) : '', 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'style' => 'medium-field')), 'download_history' => $download_info['download_history']);
                 // exclude downloads from multivalue list. why we need relate recursion?
                 $this->session->data['multivalue_excludes'][] = $download_info['download_id'];
             }
             $this->data['order_downloads'][$product_id]['push'] = $form->getFieldHtml(array('id' => 'popup' . $product_id, 'type' => 'multivalue', 'name' => 'popup' . $product_id, 'title' => $this->language->get('text_select_from_list'), 'selected_name' => 'push[' . $order_product_id . ']', 'selected' => "{}", 'content_url' => $this->html->getSecureUrl('catalog/download_listing', '&form_name=orderFrm&multivalue_hidden_id=popup' . $product_id), 'postvars' => '', 'return_to' => '', 'popup_height' => 708, 'text' => array('selected' => $this->language->get('text_count_selected'), 'edit' => $this->language->get('text_save_edit'), 'apply' => $this->language->get('text_apply'), 'save' => $this->language->get('text_add'), 'reset' => $this->language->get('button_reset'))));
         }
     }
     $this->view->batchAssign($this->data);
     $this->view->assign('help_url', $this->gen_help_url('order_files'));
     $this->processTemplate('pages/sale/order_files.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Beispiel #21
0
 public function summary()
 {
     //update controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('sale/order');
     $this->loadModel('sale/order');
     $response = new stdClass();
     if (isset($this->request->get['order_id'])) {
         $order_id = $this->request->get['order_id'];
     } else {
         $order_id = 0;
     }
     $order_info = $this->model_sale_order->getOrder($order_id);
     if (empty($order_info)) {
         $response->error = $this->language->get('error_order_load');
     } else {
         $response->order = array('order_id' => '#' . $order_info['order_id'], 'name' => $order_info['firstname'] . '' . $order_info['lastname'], 'email' => $order_info['email'], 'telephone' => $order_info['telephone'], 'date_added' => dateISO2Display($order_info['date_added'], $this->language->get('date_format_short')), 'total' => $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value']), 'order_status' => $order_info['order_status_id'], 'shipping_method' => $order_info['shipping_method'], 'payment_method' => $order_info['payment_method']);
         if ($order_info['customer_id']) {
             $response->order['name'] = '<a href="' . $this->html->getSecureURL('sale/customer/update', '&customer_id=' . $order_info['customer_id']) . '">' . $response->order['name'] . '</a>';
         }
         $this->loadModel('localisation/order_status');
         $status = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']);
         if ($status) {
             $response->order['order_status'] = $status['name'];
         }
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->setOutput(AJson::encode($response));
 }
Beispiel #22
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (isset($this->request->get['order_id'])) {
         $order_id = (int) $this->request->get['order_id'];
     } else {
         $order_id = 0;
     }
     $this->loadModel('account/order');
     $guest = false;
     if (isset($this->request->get['ot']) && $this->config->get('config_guest_checkout')) {
         //try to decrypt order token
         $ot = $this->request->get['ot'];
         $decrypted = AEncryption::mcrypt_decode($ot);
         list($order_id, $email) = explode('~~~', $decrypted);
         $order_id = (int) $order_id;
         if (!$decrypted || !$order_id || !$email) {
             if ($order_id) {
                 $this->session->data['redirect'] = $this->html->getSecureURL('account/invoice', '&order_id=' . $order_id);
             }
             $this->redirect($this->html->getSecureURL('account/login'));
         }
         $order_info = $this->model_account_order->getOrder($order_id, '', 'view');
         //compare emails
         if ($order_info['email'] != $email) {
             $this->redirect($this->html->getSecureURL('account/login'));
         }
         $guest = true;
     }
     if ($this->request->is_POST() && $this->_validate()) {
         $guest = true;
         $order_id = $this->request->post['order_id'];
         $email = $this->request->post['email'];
         $ot = AEncryption::mcrypt_encode($order_id . '~~~' . $email);
         $order_info = $this->model_account_order->getOrder($order_id, '', 'view');
         //compare emails
         if ($order_info['email'] != $email) {
             unset($order_info, $order_id, $email);
         }
     }
     $this->view->assign('error', $this->error);
     if (!$this->customer->isLogged() && !$guest) {
         $this->session->data['redirect'] = $this->html->getSecureURL('account/invoice', '&order_id=' . $order_id);
         $this->getForm();
         return null;
     }
     if (!$order_id && $this->customer->isLogged()) {
         $this->redirect($this->html->getSecureURL('account/history'));
     }
     //get info for registered customers
     if (!$order_info) {
         $order_info = $this->model_account_order->getOrder($order_id);
     }
     $this->document->setTitle($this->language->get('heading_title'));
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => false));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator')));
     if (!$guest) {
         $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/history'), 'text' => $this->language->get('text_history'), 'separator' => $this->language->get('text_separator')));
     }
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/invoice', '&order_id=' . $order_id), 'text' => $this->language->get('text_invoice'), 'separator' => $this->language->get('text_separator')));
     $this->data['success'] = '';
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     }
     if ($order_info) {
         $this->data['order_id'] = $order_id;
         $this->data['invoice_id'] = $order_info['invoice_id'] ? $order_info['invoice_prefix'] . $order_info['invoice_id'] : '';
         $this->data['email'] = $order_info['email'];
         $this->data['telephone'] = $order_info['telephone'];
         $this->data['fax'] = $order_info['fax'];
         $this->data['status'] = $this->model_account_order->getOrderStatus($order_id);
         $shipping_data = array('firstname' => $order_info['shipping_firstname'], 'lastname' => $order_info['shipping_lastname'], 'company' => $order_info['shipping_company'], 'address_1' => $order_info['shipping_address_1'], 'address_2' => $order_info['shipping_address_2'], 'city' => $order_info['shipping_city'], 'postcode' => $order_info['shipping_postcode'], 'zone' => $order_info['shipping_zone'], 'zone_code' => $order_info['shipping_zone_code'], 'country' => $order_info['shipping_country']);
         $this->data['shipping_address'] = $this->customer->getFormattedAddress($shipping_data, $order_info['shipping_address_format']);
         $this->data['shipping_method'] = $order_info['shipping_method'];
         $payment_data = array('firstname' => $order_info['payment_firstname'], 'lastname' => $order_info['payment_lastname'], 'company' => $order_info['payment_company'], 'address_1' => $order_info['payment_address_1'], 'address_2' => $order_info['payment_address_2'], 'city' => $order_info['payment_city'], 'postcode' => $order_info['payment_postcode'], 'zone' => $order_info['payment_zone'], 'zone_code' => $order_info['payment_zone_code'], 'country' => $order_info['payment_country']);
         $this->data['payment_address'] = $this->customer->getFormattedAddress($payment_data, $order_info['payment_address_format']);
         $this->data['payment_method'] = $order_info['payment_method'];
         $products = array();
         $order_products = $this->model_account_order->getOrderProducts($order_id);
         $product_ids = array();
         foreach ($order_products as $product) {
             $product_ids[] = (int) $product['product_id'];
         }
         //get thumbnails by one pass
         $resource = new AResource('image');
         $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_width'), false);
         foreach ($order_products as $product) {
             $options = $this->model_account_order->getOrderOptions($order_id, $product['order_product_id']);
             $thumbnail = $thumbnails[$product['product_id']];
             $option_data = array();
             foreach ($options as $option) {
                 if ($option['element_type'] == 'H') {
                     continue;
                 }
                 //hide hidden options
                 $value = $option['value'];
                 $title = '';
                 // hide binary value for checkbox
                 if ($option['element_type'] == 'C' && in_array($value, array(0, 1))) {
                     $value = '';
                 }
                 // strip long textarea value
                 if ($option['element_type'] == 'T') {
                     $title = strip_tags($value);
                     $title = str_replace('\\r\\n', "\n", $title);
                     $value = str_replace('\\r\\n', "\n", $value);
                     if (mb_strlen($value) > 64) {
                         $value = mb_substr($value, 0, 64) . '...';
                     }
                 }
                 $option_data[] = array('name' => $option['name'], 'value' => $value, 'title' => $title);
             }
             $products[] = array('id' => $product['product_id'], 'thumbnail' => $thumbnail, 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $this->currency->format($product['price'], $order_info['currency'], $order_info['value']), 'total' => $this->currency->format($product['total'], $order_info['currency'], $order_info['value']));
         }
         $this->data['products'] = $products;
         $this->data['totals'] = $this->model_account_order->getOrderTotals($order_id);
         $this->data['comment'] = $order_info['comment'];
         $this->data['product_link'] = $this->html->getSecureURL('product/product', '&product_id=%ID%');
         $historys = array();
         $results = $this->model_account_order->getOrderHistories($order_id);
         foreach ($results as $result) {
             $historys[] = array('date_added' => dateISO2Display($result['date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format')), 'status' => $result['status'], 'comment' => nl2br($result['comment']));
         }
         $this->data['historys'] = $historys;
         if ($guest) {
             $this->data['continue'] = $this->html->getSecureURL('index/home');
         } else {
             $this->data['continue'] = $this->html->getSecureURL('account/history');
         }
         $this->data['button_print'] = $this->html->buildElement(array('type' => 'button', 'name' => 'print_button', 'text' => $this->language->get('button_print'), 'icon' => 'fa fa-print', 'style' => 'button'));
         //button for order cancelation
         if ($this->config->get('config_customer_cancelation_order_status_id')) {
             $order_cancel_ids = unserialize($this->config->get('config_customer_cancelation_order_status_id'));
             if (in_array($order_info['order_status_id'], $order_cancel_ids)) {
                 $this->data['button_order_cancel'] = $this->html->buildElement(array('type' => 'button', 'name' => 'button_order_cancelation', 'text' => $this->language->get('text_order_cancelation'), 'icon' => 'fa fa-ban', 'style' => 'button'));
                 if (!$guest) {
                     $this->data['order_cancelation_url'] = $this->html->getSecureURL('account/invoice/CancelOrder', '&order_id=' . $order_id);
                 } else {
                     $this->data['order_cancelation_url'] = $this->html->getSecureURL('account/invoice/CancelOrder', '&ot=' . $ot);
                 }
             }
         }
         $this->view->setTemplate('pages/account/invoice.tpl');
     } else {
         if ($guest) {
             $this->data['continue'] = $this->html->getSecureURL('index/home');
         } else {
             $this->data['continue'] = $this->html->getSecureURL('account/account');
         }
         $this->view->setTemplate('pages/error/not_found.tpl');
     }
     $this->data['button_continue'] = $this->html->buildElement(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'icon' => 'fa fa-arrow-right', 'style' => 'button'));
     $this->view->batchAssign($this->data);
     $this->processTemplate();
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Beispiel #23
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (!$this->customer->isLogged()) {
         $this->session->data['redirect'] = $this->html->getSecureURL('account/download');
         $this->redirect($this->html->getSecureURL('account/login'));
     }
     //if disabled downloads redirect to
     if (!$this->config->get('config_download')) {
         $this->redirect($this->html->getSecureURL('account/account'));
     }
     $this->document->setTitle($this->language->get('heading_title'));
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator')));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('account/download'), 'text' => $this->language->get('text_downloads'), 'separator' => $this->language->get('text_separator')));
     if (isset($this->request->get['limit'])) {
         $limit = (int) $this->request->get['limit'];
         $limit = $limit > 50 ? 50 : $limit;
     } else {
         $limit = $this->config->get('config_catalog_limit');
     }
     if ($this->config->get('config_download')) {
         if (isset($this->request->get['page'])) {
             $page = $this->request->get['page'];
         } else {
             $page = 1;
         }
         $downloads = array();
         //get only enabled, not expired, which have remaining count > 0 and available
         $customer_downloads = $this->download->getCustomerDownloads(($page - 1) * $limit, $limit);
         $resource = new AResource('image');
         foreach ($customer_downloads as $download_info) {
             $text_status = $this->download->getTextStatusForOrderDownload($download_info);
             $size = filesize(DIR_RESOURCE . $download_info['filename']);
             $i = 0;
             $suffix = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
             while ($size / 1024 > 1) {
                 $size = $size / 1024;
                 $i++;
             }
             if (!$text_status) {
                 $link = HtmlElementFactory::create(array('type' => 'button', 'name' => 'download_button_' . $download_info['order_download_id'], 'title' => $this->language->get('text_download'), 'text' => $this->language->get('text_download'), 'style' => 'button', 'href' => $this->html->getSecureURL('account/download/startdownload', '&order_download_id=' . $download_info['order_download_id']), 'icon' => 'icon-download-alt'));
             } else {
                 $link = $text_status;
             }
             $thumbnail = $resource->getMainThumb('products', $download_info['product_id'], $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'), false);
             $attributes = $this->download->getDownloadAttributesValuesForCustomer($download_info['download_id']);
             $downloads[] = array('thumbnail' => $thumbnail, 'attributes' => $attributes, 'order_id' => $download_info['order_id'], 'date_added' => dateISO2Display($download_info['date_added'], $this->language->get('date_format_short')), 'name' => $download_info['name'], 'remaining' => $download_info['remaining_count'], 'size' => round(substr($size, 0, strpos($size, '.') + 4), 2) . $suffix[$i], 'link' => $link, 'expire_date' => dateISO2Display($download_info['expire_date'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format_short')));
         }
         $this->data['downloads'] = $downloads;
         $this->data['pagination_bootstrap'] = HtmlElementFactory::create(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => sizeof($downloads), 'page' => $page, 'limit' => $limit, 'url' => $this->html->getURL('account/download&page={page}', '&encode'), 'style' => 'pagination'));
         if ($downloads) {
             $template = 'pages/account/download.tpl';
         } else {
             $template = 'pages/error/not_found.tpl';
         }
     } else {
         $template = 'pages/error/not_found.tpl';
     }
     $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button', 'icon' => 'icon-arrow-right', 'href' => $this->html->getSecureURL('account/account')));
     $this->data['button_continue'] = $continue;
     $this->view->batchAssign($this->data);
     $this->processTemplate($template);
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 public function transaction()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->load->library('json');
     $this->loadLanguage('sale/customer');
     $this->loadModel('sale/customer_transaction');
     if (!$this->user->canAccess('listing_grid/customer_transaction')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_access'), 'listing_grid/customer_transaction'), 'reset_value' => true));
     }
     $transaction_id = (int) $this->request->get['customer_transaction_id'];
     $this->data['customer_transaction_id'] = $transaction_id;
     if ($transaction_id) {
         $info = $this->model_sale_customer_transaction->getCustomerTransaction($this->request->get['customer_transaction_id']);
         $this->data['text_title'] = $this->language->get('popup_title_info');
         $readonly = true;
     } else {
         $this->data['text_title'] = $this->language->get('popup_title_insert');
         $readonly = false;
     }
     $form = new AForm();
     $form->setForm(array('form_name' => 'transaction_form'));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'tFrm', 'action' => $this->html->getSecureURL('listing_grid/customer_transaction/addtransaction', '&customer_id=' . $this->request->get['customer_id']), 'attr' => 'data-confirm-exit="true" class="form-horizontal"'));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save')));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel')));
     $this->data['form']['fields']['credit'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'credit', 'value' => $info['credit'], 'attr' => $readonly ? 'disabled="disabled"' : ''));
     $this->data['form']['fields']['debit'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'debit', 'value' => $info['debit'], 'attr' => $readonly ? 'disabled="disabled"' : ''));
     $types = $this->model_sale_customer_transaction->getTransactionTypes();
     $types[''] = $this->language->get('text_option_other_type');
     reset($types);
     $this->data['form']['fields']['transaction_type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'transaction_type[0]', 'options' => $types, 'value' => $info['transaction_type'] == '' ? current($types) : $info['transaction_type'], 'attr' => $readonly ? 'disabled="disabled"' : ''));
     $this->data['form']['fields']['other_type'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'transaction_type[1]', 'value' => !in_array($info['transaction_type'], $types) ? $info['transaction_type'] : '', 'attr' => $readonly ? 'disabled="disabled"' : ''));
     $this->data['form']['fields']['transaction_comment'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'comment', 'value' => $info['comment'], 'attr' => $readonly ? 'disabled="disabled"' : ''));
     $this->data['form']['fields']['transaction_description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'description', 'value' => $info['description'], 'attr' => $readonly ? 'disabled="disabled"' : ''));
     if ($readonly) {
         $this->data['form']['fields']['date_added'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_added', 'value' => dateISO2Display($info['date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format')), 'attr' => 'disabled="disabled"'));
         $this->data['form']['fields']['date_modified'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_modified', 'value' => dateISO2Display($info['date_modified'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format')), 'attr' => 'disabled="disabled"'));
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->view->assign('help_url', $this->gen_help_url('customer_transaction_edit'));
     $this->view->batchAssign($this->data);
     $this->processTemplate('responses/sale/customer_transaction_form.tpl');
 }
 public function block_info()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('design/blocks');
     //load specific template/page/layout
     $template = $this->request->get['template'];
     $page_id = $this->request->get['page_id'];
     $layout_id = $this->request->get['layout_id'];
     $lm = new ALayoutManager($template, $page_id, $layout_id);
     //acccept 2 type of ids. Number based and custom [block]_[custom_block]
     $custom_block_id = $this->request->get['block_id'];
     if (preg_match("/(\\d+)_(\\d+)/", $custom_block_id, $match)) {
         //take last postion of id for custom block
         $block_id = $match[1];
         $custom_block_id = $match[2];
     } else {
         if (is_numeric($custom_block_id)) {
             $block_id = $custom_block_id;
             $custom_block_id = 0;
         } else {
             //error
             $this->load->library('json');
             $this->response->addJSONHeader();
             $this->response->setOutput(AJson::encode(array('error' => 'Incorrect Block ID')));
             return null;
         }
     }
     $info = $lm->getBlockInfo((int) $block_id);
     foreach ($info as &$i) {
         $i['block_date_added'] = dateISO2Display($i['block_date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
     }
     //expect only 1 block details per layout
     $this->data = array_merge($info[0], $this->data);
     $this->data['block_info'] = $info;
     //get specific description
     if ($custom_block_id > 0) {
         $descr = $lm->getBlockDescriptions((int) $custom_block_id);
         $language_id = $this->language->getContentLanguageID();
         $this->data['title'] = $descr[$language_id]['title'];
         $this->data['description'] = $descr[$language_id]['description'];
         //detect edit URL and build button
         if ($this->data['block_txt_id'] == 'html_block' || $this->data['block_txt_id'] == 'listing_block') {
             $edit_url = $this->html->getSecureURL('design/blocks/edit', '&custom_block_id=' . $custom_block_id);
         } else {
             if ($this->data['block_txt_id'] == 'banner_block') {
                 $edit_url = $this->html->getSecureURL('extension/banner_manager/edit_block', '&custom_block_id=' . $custom_block_id);
             } else {
                 //just list all
                 $edit_url = $this->html->getSecureURL('design/blocks');
             }
         }
         $this->data['block_edit'] = $edit_url;
         $this->data['allow_edit'] = 'true';
     } else {
         //get details from language for static blocks from storefront
         $alang = new ALanguage($this->registry, $this->language->getContentLanguageCode(), 0);
         $alang->load($this->data['controller'], 'silent');
         $this->data['title'] = $alang->get('heading_title');
         $this->data['title'] = $this->data['title'] == 'heading_title' ? $this->data['block_txt_id'] : $this->data['title'];
     }
     $this->data['blocks_layouts'] = $lm->getBlocksLayouts($block_id, $custom_block_id);
     $this->data['text_edit'] = $this->language->get('text_edit');
     $this->data['text_close'] = $this->language->get('text_close');
     //update controller data
     $this->view->batchAssign($this->data);
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->processTemplate('responses/design/block_details.tpl');
 }
Beispiel #26
0
 public function shipping()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('report/sale/shipping');
     $this->loadModel('report/sale');
     //Prepare filter config
     $filter_params = array('date_start', 'date_end', 'group', 'order_status');
     $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->getShippingReportTotal($data);
     $response = new stdClass();
     $response->page = $filter_grid->getParam('page');
     $response->total = $filter_grid->calcTotalPages($total);
     $response->records = $total;
     $results = $this->model_report_sale->getShippingReport($data);
     $i = 0;
     foreach ($results as $result) {
         $response->rows[$i]['id'] = $i;
         $response->rows[$i]['cell'] = array(dateISO2Display($result['date_start'], $this->language->get('date_format_short')), dateISO2Display($result['date_end'], $this->language->get('date_format_short')), $result['orders'], $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));
 }
 private function _getForm()
 {
     if (isset($this->session->data['warning'])) {
         $this->data['error_warning'] = $this->session->data['warning'];
         $this->session->data['warning'] = '';
     } else {
         $this->data['error_warning'] = '';
     }
     $this->view->assign('success', $this->session->data['success']);
     if (isset($this->session->data['success'])) {
         unset($this->session->data['success']);
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('extension/banner_manager'), 'text' => $this->language->get('banner_manager_name'), 'separator' => ' :: '));
     $this->data['cancel'] = $this->html->getSecureURL('extension/banner_manager');
     $banner_type = 1;
     if (!isset($this->request->get['banner_id'])) {
         if ($this->request->get['banner_type']) {
             $banner_type = $this->request->get['banner_type'];
         } elseif ($this->request->post['banner_type']) {
             $banner_type = $this->request->post['banner_type'];
         }
         $this->data['action'] = $this->html->getSecureURL('extension/banner_manager/insert');
         $this->data['form_title'] = $this->language->get('text_create');
         $this->data['update'] = '';
         $form = new AForm('ST');
     } else {
         $this->data['action'] = $this->html->getSecureURL('extension/banner_manager/edit', '&banner_id=' . $this->request->get['banner_id']);
         $this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->data['name'];
         $this->data['update'] = $this->html->getSecureURL('listing_grid/banner_manager/update_field', '&banner_id=' . $this->request->get['banner_id']);
         $form = new AForm('HS');
         $this->data['button_details'] = $this->html->buildElement(array('type' => 'button', 'name' => 'btn_details', 'href' => $this->html->getSecureUrl('extension/banner_manager_stat/details', '&banner_id=' . $this->request->get['banner_id']), 'text' => $this->language->get('text_view_stat')));
         $banner_type = $this->data['banner_type'];
     }
     if ($banner_type == 1) {
         $this->data['banner_types'] = array('text' => $this->language->get('text_graphic_banner'), 'icon' => '<i class="fa fa-file-image-o fa-fw"></i>');
     } else {
         $this->data['banner_types'] = array('text' => $this->language->get('text_text_banner'), 'icon' => '<i class="fa fa-file-text-o fa-fw"></i>');
     }
     $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['form_title'], 'separator' => ' :: ', 'current' => true));
     $form->setForm(array('form_name' => 'BannerFrm', 'update' => $this->data['update']));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'BannerFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $this->data['action']));
     $this->data['form']['hidden_fields']['type'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'banner_type', 'value' => $banner_type));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save')));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel')));
     //check if banner is active based on dates and update status
     $now = time();
     if (dateISO2Int($this->data['start_date']) > $now) {
         $this->data['status'] = 0;
     }
     $stop = dateISO2Int($this->data['end_date']);
     if ($stop > 0 && $stop < $now) {
         $this->data['status'] = 0;
     }
     $this->data['form']['fields']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => $this->data['status'], 'style' => 'btn_switch'));
     $this->data['form']['text']['status'] = $this->language->get('entry_banner_status');
     $this->data['form']['fields']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'name', 'value' => $this->data['name'], 'required' => true));
     $this->data['form']['text']['name'] = $this->language->get('entry_banner_name');
     // groups of banners
     $this->loadModel('extension/banner_manager');
     $result = $this->model_extension_banner_manager->getBannerGroups();
     $groups = array('0' => $this->language->get('text_select'), 'new' => $this->language->get('text_add_new_group'));
     if ($result) {
         foreach ($result as $row) {
             $groups[$row['banner_group_name']] = $row['banner_group_name'];
         }
     }
     $value = $this->data['banner_group_name'][0];
     if (!$value && sizeof($groups) == 2) {
         $value = 'new';
     }
     $this->data['form']['fields']['banner_group_name'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'banner_group_name[0]', 'options' => $groups, 'value' => $value, 'required' => true, 'style' => 'no-save'));
     $this->data['form']['text']['banner_group_name'] = $this->language->get('entry_banner_group_name');
     $this->data['form']['fields']['new_banner_group'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'banner_group_name[1]', 'value' => !in_array($this->data['banner_group_name'][1], $groups) ? $this->data['banner_group_name'][1] : '', 'placeholder' => $this->language->get('text_put_new_group'), 'style' => 'no-save'));
     $this->data['new_group_hint'] = $this->language->get('text_put_new_group');
     $this->data['form']['fields']['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'value' => $this->data['sort_order'], 'style' => 'small-field', ''));
     $this->data['form']['text']['sort_order'] = $this->language->get('entry_banner_sort_order');
     if ($banner_type == 1) {
         $this->data['form']['fields']['url'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'target_url', 'value' => $this->data['target_url'], 'required' => true));
         $this->data['form']['text']['url'] = $this->language->get('entry_banner_url');
         $this->data['form']['fields']['blank'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'blank', 'value' => $this->data['blank'], 'style' => 'btn_switch'));
         $this->data['form']['text']['blank'] = $this->language->get('entry_banner_blank');
     }
     $this->data['form']['fields']['date_start'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'start_date', 'value' => dateISO2Display($this->data['start_date']), 'default' => dateNowDisplay(), 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'style' => 'small-field'));
     $this->data['form']['text']['date_start'] = $this->language->get('entry_banner_date_start');
     $this->data['form']['fields']['date_end'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'end_date', 'value' => dateISO2Display($this->data['end_date']), 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'pased', 'style' => 'small-field'));
     $this->data['form']['text']['date_end'] = $this->language->get('entry_banner_date_end');
     $this->data['banner_id'] = $this->request->get['banner_id'] ? $this->request->get['banner_id'] : '-1';
     if ($banner_type == 1) {
         $this->data['form']['fields']['meta'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'meta', 'value' => $this->data['meta'], 'attr' => ' style="height: 50px;"'));
         $this->data['form']['text']['meta'] = $this->language->get('entry_banner_meta');
         $this->addChild('responses/common/resource_library/get_resources_html', 'resources_html', 'responses/common/resource_library_scripts.tpl');
         $resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'banners', 'object_id' => $this->data['banner_id'], 'types' => array('image')));
         $this->view->assign('current_url', $this->html->currentURL());
         $this->view->assign('resources_scripts', $resources_scripts->dispatchGetOutput());
         $this->view->assign('rl', $this->html->getSecureURL('common/resource_library', '&object_name=banners&type=image'));
     } else {
         $this->data['form']['fields']['description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'description', 'value' => $this->data['description'], 'attr' => ''));
         $this->data['form']['text']['description'] = $this->language->get('entry_banner_html');
     }
     $this->view->batchAssign($this->language->getASet());
     $this->view->batchAssign($this->data);
     $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher());
     $this->view->assign('language_code', $this->session->data['language']);
     $this->view->assign('help_url', $this->gen_help_url('banner_edit'));
     $this->processTemplate('pages/extension/banner_manager_form.tpl');
 }
Beispiel #28
0
 /**
  * @param int $order_id
  * @param array $data
  * @throws AException
  */
 public function addOrderHistory($order_id, $data)
 {
     $this->db->query("UPDATE `" . $this->db->table("orders") . "`\n\t\t\t\t\t\t\tSET order_status_id = '" . (int) $data['order_status_id'] . "',\n\t\t\t\t\t\t\t\tdate_modified = NOW()\n\t\t\t\t\t\t\tWHERE order_id = '" . (int) $order_id . "'");
     if ($data['append']) {
         $this->db->query("INSERT INTO " . $this->db->table("order_history") . "\n      \t\t                    SET order_id = '" . (int) $order_id . "',\n      \t\t                        order_status_id = '" . (int) $data['order_status_id'] . "',\n      \t\t                        notify = '" . (isset($data['notify']) ? (int) $data['notify'] : 0) . "',\n      \t\t                        comment = '" . $this->db->escape(strip_tags($data['comment'])) . "',\n      \t\t                        date_added = NOW()");
     }
     if ($data['notify']) {
         $order_query = $this->db->query("SELECT *, os.name AS status\n        \t                                FROM `" . $this->db->table("orders") . "` o\n        \t                                LEFT JOIN " . $this->db->table("order_statuses") . " os ON (o.order_status_id = os.order_status_id AND os.language_id = o.language_id)\n        \t                                LEFT JOIN " . $this->db->table("languages") . " l ON (o.language_id = l.language_id)\n        \t                                WHERE o.order_id = '" . (int) $order_id . "'");
         if ($order_query->num_rows) {
             //load language specific for the order in admin section
             $language = new ALanguage(Registry::getInstance(), $order_query->row['code'], 1);
             $language->load($order_query->row['filename']);
             $language->load('mail/order');
             $this->load->model('setting/store');
             $subject = sprintf($language->get('text_subject'), $order_query->row['store_name'], $order_id);
             $message = $language->get('text_order') . ' ' . $order_id . "\n";
             $message .= $language->get('text_date_added') . ' ' . dateISO2Display($order_query->row['date_added'], $language->get('date_format_short')) . "\n\n";
             $message .= $language->get('text_order_status') . "\n\n";
             $message .= $order_query->row['status'] . "\n\n";
             $message .= $language->get('text_invoice') . "\n";
             $message .= html_entity_decode($order_query->row['store_url'] . 'index.php?rt=account/invoice&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\n\n";
             if ($data['comment']) {
                 $message .= $language->get('text_comment') . "\n\n";
                 $message .= strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "\n\n";
             }
             $message .= $language->get('text_footer');
             if ($this->dcrypt->active) {
                 $customer_email = $this->dcrypt->decrypt_field($order_query->row['email'], $order_query->row['key_id']);
             } else {
                 $customer_email = $order_query->row['email'];
             }
             $mail = new AMail($this->config);
             $mail->setTo($customer_email);
             $mail->setFrom($this->config->get('store_main_email'));
             $mail->setSender($order_query->row['store_name']);
             $mail->setSubject($subject);
             $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
             $mail->send();
         }
     }
 }
Beispiel #29
0
 /**
  * @param AForm $form
  * @param int $download_id
  * @param int $product_id
  */
 private function _buildGeneralSubform($form, $download_id, $product_id)
 {
     if ($download_id) {
         $file_data = $this->model_catalog_download->getDownload($download_id);
         $this->_validateDownloadForm($file_data);
         $this->data['error'] = $this->error;
     } else {
         $file_data = array();
         $file_data['status'] = 1;
         //set status ON for new download by default
     }
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'downloadFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $this->data['action']));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => (int) $download_id ? $this->language->get('button_save') : $this->language->get('text_add'), 'style' => 'button1'));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'href' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $product_id), 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
     $order_statuses = $this->model_localisation_order_status->getOrderStatuses();
     $this->data['date_added'] = dateISO2Display($file_data['date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
     $this->data['date_modified'] = dateISO2Display($file_data['date_modified'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
     $this->data['action'] = $this->html->getSecureURL('r/product/product/processDownloadForm', '&product_id=' . $product_id);
     $resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'downloads', 'object_id' => '', 'types' => array('download')));
     $this->data['resources_scripts'] = $resources_scripts->dispatchGetOutput();
     $this->data['form']['fields']['general']['resource'] = $form->getFieldHtml($props[] = array('type' => 'resource', 'name' => 'filename', 'resource_path' => htmlspecialchars($file_data['filename'], ENT_COMPAT, 'UTF-8'), 'rl_type' => 'download'));
     $rl = new AResource('download');
     $rl_dir = $rl->getTypeDir();
     $resource_id = $rl->getIdFromHexPath(str_replace($rl_dir, '', $file_data['filename']));
     if ($resource_id) {
         $this->data['preview']['href'] = $this->html->getSecureURL('common/resource_library/get_resource_preview', '&resource_id=' . $resource_id, true);
         $this->data['preview']['path'] = 'resources/' . $file_data['filename'];
     }
     $this->data['form']['fields']['general']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => 1, 'checked' => $file_data['status'] ? true : false, 'style' => 'btn_switch'));
     //check is download already shared
     if ($download_id) {
         $this->data['map_list'] = array();
         $file_data['map_list'] = (array) $this->model_catalog_download->getDownloadMapList($download_id);
         foreach ($file_data['map_list'] as $map_id => $map_name) {
             if ($map_id == $product_id) {
                 continue;
             }
             $this->data['map_list'][] = array('href' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $map_id . '&download_id=' . $this->data['download_id'], true), 'text' => $map_name);
         }
         if (!sizeof($this->data['map_list'])) {
             $this->data['already_shared'] = false;
         } else {
             $this->data['already_shared'] = true;
         }
     }
     $this->data['delete_unmap_href'] = $this->html->getSecureURL('catalog/product_files', '&act=' . ($file_data['shared'] ? 'unmap' : 'delete') . '&product_id=' . $product_id . '&download_id=' . $this->data['download_id'], true);
     if ($product_id) {
         $this->data['form']['fields']['general']['shared'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'shared', 'value' => 1, 'checked' => $file_data['shared'] ? true : false, 'style' => 'btn_switch ' . ($this->data['already_shared'] ? 'disabled' : '')));
     }
     if ($file_data['shared']) {
         $this->data['text_attention_shared'] = $this->language->get('attention_shared');
     }
     $this->data['form']['fields']['general']['download_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'download_id', 'value' => $this->data['download_id']));
     $this->data['form']['fields']['general']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'name', 'value' => $file_data['name'], 'attr' => ' maxlength="64" '));
     $this->data['form']['fields']['general']['mask'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'mask', 'value' => $file_data['mask']));
     $this->data['form']['fields']['general']['activate'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'activate', 'value' => $file_data['activate'], 'options' => array('' => $this->language->get('text_select'), 'before_order' => $this->language->get('text_before_order'), 'immediately' => $this->language->get('text_immediately'), 'order_status' => $this->language->get('text_on_order_status'), 'manually' => $this->language->get('text_manually')), 'required' => true, 'style' => 'download_activate no-save'));
     $options = array('' => $this->language->get('text_select'));
     foreach ($order_statuses as $order_status) {
         $options[$order_status['order_status_id']] = $order_status['name'];
     }
     $this->data['form']['fields']['general']['activate'] .= $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'activate_order_status_id', 'value' => $file_data['activate_order_status_id'], 'options' => $options, 'required' => true, 'style' => ' no-save '));
     $this->data['form']['fields']['general']['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'style' => 'small-field', 'value' => $file_data['sort_order']));
     $this->data['form']['fields']['general']['max_downloads'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'max_downloads', 'value' => $file_data['max_downloads'], 'style' => 'small-field'));
     $this->data['form']['fields']['general']['expire_days'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'expire_days', 'style' => 'small-field', 'value' => $file_data['expire_days']));
 }
 /**
  * @throws AException
  */
 public function list_library()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $language_id = $this->language->getContentLanguageID();
     $this->data['sort'] = $this->request->get['sort'];
     $this->data['order'] = $this->request->get['order'];
     $rm = new AResourceManager();
     $rm->setType($this->data['type']);
     //Build request URI and filter params
     $uri = '&object_name=' . $this->data['object_name'] . '&object_id=' . $this->data['object_id'];
     $uri .= '&type=' . $this->data['type'] . '&mode=' . $this->data['mode'] . '&language_id=' . $language_id . '&action=' . $this->data['action'];
     $filter_data = array('type_id' => $rm->getTypeId(), 'language_id' => $language_id, 'limit' => 12);
     if (!empty($this->request->get['keyword'])) {
         $filter_data['keyword'] = $this->request->get['keyword'];
         $uri .= '&keyword=' . $this->request->get['keyword'];
     }
     if (!empty($this->data['object_name']) && $this->data['action'] == 'list_object') {
         $filter_data['object_name'] = $this->data['object_name'];
     }
     if (!empty($this->data['object_id']) && $this->data['action'] == 'list_object') {
         $filter_data['object_id'] = $this->data['object_id'];
     }
     if ($this->data['sort']) {
         $filter_data['sort'] = $this->data['sort'];
     }
     if ($this->data['order']) {
         $filter_data['order'] = $this->data['order'];
     } elseif (!$this->data['sort'] && $this->data['action'] == 'list_object') {
         $filter_data['sort'] = 'sort_order';
     } else {
         $filter_data['sort'] = 'date_added';
         $filter_data['order'] = 'DESC';
     }
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
         if ((int) $page < 1) {
             $page = 1;
         }
         $filter_data['start'] = ($page - 1) * $filter_data['limit'];
     }
     $resources_total = $rm->getTotalResources($filter_data);
     $result = $rm->getResourcesList($filter_data);
     foreach ($result as $key => $item) {
         if ($item['date_added']) {
             $result[$key]['date_added'] = dateISO2Display($item['date_added']);
         }
         $result[$key]['thumbnail_url'] = $rm->getResourceThumb($item['resource_id'], $this->thumb_sizes['width'], $this->thumb_sizes['height'], $language_id);
         $result[$key]['url'] = $rm->buildResourceURL($item['resource_path'], 'full');
         $result[$key]['relative_url'] = $rm->buildResourceURL($item['resource_path'], 'relative');
         $result[$key]['mapped_to_current'] = $rm->isMapped($item['resource_id'], $this->data['object_name'], $this->data['object_id']);
     }
     $sort_order = '&sort=' . $this->data['sort'] . '&order=' . $this->data['order'];
     $this->data['current_url'] = $this->html->getSecureURL('common/resource_library', $uri . $sort_order . '&page={page}', '&encode');
     $this->data['no_sort_url'] = $this->html->getSecureURL('common/resource_library', $uri, '&encode');
     if ($resources_total > 12) {
         $this->data['pagination_bootstrap'] = HtmlElementFactory::create(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => $resources_total, 'page' => $page, 'limit' => 12, 'url' => $this->data['current_url'], 'size_class' => 'sm', 'no_perpage' => true, 'style' => 'pagination'));
     }
     $this->data['rls'] = $result;
     $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher());
     $this->view->assign('help_url', $this->gen_help_url('resource_library'));
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->view->batchAssign($this->data);
     $this->processTemplate('responses/common/resource_library.tpl');
 }