public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('report/purchased');
     $this->loadModel('report/purchased');
     //Prepare filter config
     $filter_params = array('date_start', 'date_end');
     if (!$this->request->get['date_start']) {
         $this->request->get['date_start'] = dateInt2Display(strtotime('-30 day'));
     }
     if (!$this->request->get['date_end']) {
         $this->request->get['date_end'] = dateInt2Display(time());
     }
     $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params));
     $filter_grid = new AFilter(array('method' => 'post'));
     $data = array_merge($filter_form->getFilterData(), $filter_grid->getFilterData());
     $total = $this->model_report_purchased->getTotalOrderedProducts($data);
     $response = new stdClass();
     $response->page = $filter_grid->getParam('page');
     $response->total = $filter_grid->calcTotalPages($total);
     $response->records = $total;
     $results = $this->model_report_purchased->getProductPurchasedReport($data);
     $i = 0;
     foreach ($results as $result) {
         $response->rows[$i]['id'] = $i;
         $response->rows[$i]['cell'] = array($result['name'], $result['model'], $result['quantity'], $this->currency->format($result['total'], $this->config->get('config_currency')));
         $i++;
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->setOutput(AJson::encode($response));
 }
 private function getWishList()
 {
     $cart_rt = 'checkout/cart';
     //is this an embed mode
     if ($this->config->get('embed_mode') == true) {
         $cart_rt = 'r/checkout/cart/embed';
     }
     $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/wishlist'), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator')));
     $whishlist = $this->customer->getWishList();
     if ($whishlist) {
         $this->loadModel('tool/seo_url');
         $this->loadModel('catalog/product');
         $products = array();
         $resource = new AResource('image');
         foreach ($whishlist as $product_id => $timestamp) {
             $product_info = $this->model_catalog_product->getProduct($product_id);
             $thumbnail = $resource->getMainThumb('products', $product_id, (int) $this->config->get('config_image_cart_width'), (int) $this->config->get('config_image_cart_height'), true);
             $options = $this->model_catalog_product->getProductOptions($product_id);
             if ($options) {
                 $add = $this->html->getSEOURL('product/product', '&product_id=' . $product_id, '&encode');
             } else {
                 $add = $this->html->getSecureURL($cart_rt, '&product_id=' . $product_id, '&encode');
             }
             $products[] = array('product_id' => $product_id, 'name' => $product_info['name'], 'model' => $product_info['model'], 'thumb' => $thumbnail, 'added' => dateInt2Display($timestamp), 'price' => $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))), 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $product_id, true), 'call_to_order' => $product_info['call_to_order'], 'add' => $add);
         }
         $this->data['products'] = $products;
         if (isset($this->session->data['redirect'])) {
             $this->data['continue'] = str_replace('&', '&', $this->session->data['redirect']);
             unset($this->session->data['redirect']);
         } else {
             $this->data['continue'] = $this->html->getURL('index/home');
         }
         $this->view->assign('error', '');
         if ($this->session->data['error']) {
             $this->view->assign('error', $this->session->data['error']);
             unset($this->session->data['error']);
         }
         if ($this->config->get('config_customer_price')) {
             $display_price = TRUE;
         } elseif ($this->customer->isLogged()) {
             $display_price = TRUE;
         } else {
             $display_price = FALSE;
         }
         $this->data['display_price'] = $display_price;
         $this->view->setTemplate('pages/account/wishlist.tpl');
     } else {
         $this->data['heading_title'] = $this->language->get('heading_title');
         $this->data['text_error'] = $this->language->get('text_empty_wishlist');
         $this->data['button_continue'] = HtmlElementFactory::create(array('name' => 'continue', 'type' => 'button', 'text' => $this->language->get('button_continue'), 'href' => $this->html->getURL('index/home'), 'style' => 'button'));
         $this->view->setTemplate('pages/error/not_found.tpl');
     }
     $this->data['cart'] = $this->html->getSecureURL($cart_rt);
     $this->view->batchAssign($this->data);
     $this->processTemplate();
 }
示例#3
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $grid_settings = array('table_id' => 'report_sales_grid', 'url' => $this->html->getSecureURL('listing_grid/report_sale'), 'sortname' => 'date_end', 'columns_search' => false, 'multiselect' => 'false');
     $form = new AForm();
     $form->setForm(array('form_name' => 'report_sales_grid_search'));
     $this->data['grid_search_form'] = array();
     $this->data['grid_search_form']['id'] = 'report_sales_grid_search';
     $this->data['grid_search_form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'report_sales_grid_search', 'action' => ''));
     $this->data['grid_search_form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_go'), 'style' => 'button1'));
     $this->data['grid_search_form']['reset'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'reset', 'text' => $this->language->get('button_reset'), 'style' => 'button2'));
     $this->view->assign('js_date_format', format4Datepicker($this->language->get('date_format_short')));
     $this->data['grid_search_form']['fields']['date_start'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_start', 'default' => dateInt2Display(strtotime('-7 day'))));
     $this->data['grid_search_form']['fields']['date_end'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_end', 'default' => dateInt2Display(time())));
     $groups = array();
     $groups['year'] = $this->language->get('text_year');
     $groups['month'] = $this->language->get('text_month');
     $groups['week'] = $this->language->get('text_week');
     $groups['day'] = $this->language->get('text_day');
     $this->data['grid_search_form']['fields']['status'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'group', 'options' => $groups, 'value' => "week"));
     $grid_settings['search_form'] = true;
     $grid_settings['colNames'] = array($this->language->get('column_date_start'), $this->language->get('column_date_end'), $this->language->get('column_orders'), $this->language->get('column_total'));
     $grid_settings['colModel'] = array(array('name' => 'date_start', 'index' => 'date_start', 'width' => 100, 'align' => 'center', 'sorttype' => 'string'), array('name' => 'date_end', 'index' => 'date_end', 'width' => 100, 'align' => 'center', 'sorttype' => 'string'), array('name' => 'orders', 'index' => 'orders', 'width' => 100, 'align' => 'center', 'sorttype' => 'string'), array('name' => 'total', 'index' => 'total', 'width' => 110, 'align' => 'right'));
     $grid = $this->dispatch('common/listing_grid', array($grid_settings));
     $this->view->assign('listing_grid', $grid->dispatchGetOutput());
     $this->view->assign('search_form', $this->data['grid_search_form']);
     $this->document->setTitle($this->language->get('heading_title'));
     $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('report/viewed'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->document->addScript(RDIR_TEMPLATE . 'javascript/jquery/ui/jquery.ui.datepicker.js');
     $this->processTemplate('pages/report/sale.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
示例#4
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $grid_settings = array('table_id' => 'report_purchased_grid', 'url' => $this->html->getSecureURL('listing_grid/report_purchased'), 'sortname' => 'quantity', 'columns_search' => false, 'multiselect' => 'false', 'search_form' => true);
     $grid_settings['colNames'] = array($this->language->get('column_name'), $this->language->get('column_model'), $this->language->get('column_quantity'), $this->language->get('column_total'));
     $grid_settings['colModel'] = array(array('name' => 'name', 'index' => 'name', 'width' => 300, 'align' => 'left', 'sortable' => false), array('name' => 'model', 'index' => 'model', 'width' => 80, 'align' => 'center', 'sortable' => false), array('name' => 'quantity', 'index' => 'quantity', 'width' => 50, 'align' => 'center', 'sortable' => false), array('name' => 'total', 'index' => 'total', 'width' => 90, 'align' => 'center', 'sortable' => false));
     $grid = $this->dispatch('common/listing_grid', array($grid_settings));
     $this->view->assign('listing_grid', $grid->dispatchGetOutput());
     //prepare the filter form
     //Note: External search form needs to be named [grid_name]_search
     //		In this case it will be auto submited to filter grid
     $form = new AForm();
     $form->setForm(array('form_name' => 'report_purchased_grid_search'));
     $this->data['grid_search_form'] = array();
     $this->data['grid_search_form']['id'] = 'report_purchased_grid_search';
     $this->data['grid_search_form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'report_purchased_grid_search', 'action' => ''));
     $this->data['grid_search_form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_go'), 'style' => 'button1'));
     $this->view->assign('js_date_format', format4Datepicker($this->language->get('date_format_short')));
     $this->data['grid_search_form']['fields']['date_start'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_start', 'default' => dateInt2Display(strtotime('-30 day'))));
     $this->data['grid_search_form']['fields']['date_end'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_end', 'default' => dateInt2Display(time())));
     $this->view->assign('search_form', $this->data['grid_search_form']);
     $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('report/purchased'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ', 'current' => true));
     $this->document->setTitle($this->language->get('heading_title'));
     $this->processTemplate('pages/report/purchased.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $grid_settings = array('table_id' => 'report_shipping_grid', 'url' => $this->html->getSecureURL('listing_grid/report_sale/shipping'), 'sortname' => 'date_end', 'columns_search' => false, 'multiselect' => 'false');
     $form = new AForm();
     $form->setForm(array('form_name' => 'report_shipping_grid_search'));
     $this->data['grid_search_form'] = array();
     $this->data['grid_search_form']['id'] = 'report_shipping_grid_search';
     $this->data['grid_search_form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'report_shipping_grid_search', 'action' => ''));
     $this->data['grid_search_form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_go'), 'style' => 'button1'));
     $this->view->assign('js_date_format', format4Datepicker($this->language->get('date_format_short')));
     $this->data['grid_search_form']['fields']['date_start'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_start', 'default' => dateInt2Display(strtotime('-7 day'))));
     $this->data['grid_search_form']['fields']['date_end'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_end', 'default' => dateInt2Display(time())));
     $groups = array();
     $groups['year'] = $this->language->get('text_year');
     $groups['month'] = $this->language->get('text_month');
     $groups['week'] = $this->language->get('text_week');
     $groups['day'] = $this->language->get('text_day');
     $this->data['grid_search_form']['fields']['group'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'group', 'options' => $groups, 'value' => "week"));
     $this->loadModel('localisation/order_status');
     $results = $this->model_localisation_order_status->getOrderStatuses();
     $statuses = array('' => $this->language->get('text_all_orders'));
     foreach ($results as $item) {
         $statuses[$item['order_status_id']] = $item['name'];
     }
     $this->data['grid_search_form']['fields']['status'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'order_status', 'options' => $statuses, 'placeholder' => $this->language->get('text_select_status')));
     $grid_settings['search_form'] = true;
     $grid_settings['colNames'] = array($this->language->get('column_date_start'), $this->language->get('column_date_end'), $this->language->get('column_orders'), $this->language->get('column_total'));
     $grid_settings['colModel'] = array(array('name' => 'date_start', 'index' => 'date_start', 'width' => 100, 'align' => 'center', 'sorttype' => 'string'), array('name' => 'date_end', 'index' => 'date_end', 'width' => 100, 'align' => 'center', 'sorttype' => 'string'), array('name' => 'orders', 'index' => 'orders', 'width' => 100, 'align' => 'center'), array('name' => 'total', 'index' => 'total', 'width' => 110, 'align' => 'center'));
     $grid = $this->dispatch('common/listing_grid', array($grid_settings));
     $this->view->assign('listing_grid', $grid->dispatchGetOutput());
     $this->view->assign('search_form', $this->data['grid_search_form']);
     $this->document->setTitle($this->language->get('heading_title'));
     $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('report/sale/shipping'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ', 'current' => true));
     $this->processTemplate('pages/report/sale/shipping.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('sale/customer');
     $this->loadModel('sale/customer_transaction');
     $this->loadModel('sale/customer');
     $customer_info = $this->model_sale_customer->getCustomer($this->request->get['customer_id']);
     $this->document->setTitle($this->language->get('heading_title_transactions'));
     $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/customer'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/customer/update', '&customer_id=' . $this->request->get['customer_id']), 'text' => $this->language->get('text_edit') . ' ' . $this->language->get('text_customer') . ' - ' . $customer_info['firstname'] . ' ' . $customer_info['lastname'], 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/customer_transaction', '&customer_id=' . $this->request->get['customer_id']), 'text' => $this->language->get('heading_title_transactions'), 'separator' => ' :: '));
     if (isset($this->session->data['error'])) {
         $this->data['error_warning'] = $this->session->data['error'];
         unset($this->session->data['error']);
     } elseif (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->data['grid_settings'] = array('table_id' => 'transactions_grid', 'url' => $this->html->getSecureURL('listing_grid/customer_transaction', '&customer_id=' . $this->request->get['customer_id']), 'sortname' => 'create_date', 'sortorder' => 'desc', 'multiselect' => 'false', 'actions' => array('view' => array('text' => $this->language->get('button_view'), 'href' => 'Javascript:void(0);')));
     $this->data['grid_settings']['colNames'] = array($this->language->get('column_create_date'), $this->language->get('column_created_by'), $this->language->get('column_debit'), $this->language->get('column_credit'), $this->language->get('column_transaction_type'));
     $this->data['grid_settings']['colModel'] = array(array('name' => 'create_date', 'index' => 'create_date', 'width' => 120, 'align' => 'center', 'search' => false), array('name' => 'user', 'index' => 'user', 'width' => 140, 'align' => 'left'), array('name' => 'debit', 'index' => 'debit', 'width' => 50, 'align' => 'center'), array('name' => 'credit', 'index' => 'credit', 'width' => 50, 'align' => 'center'), array('name' => 'transaction_type', 'index' => 'transaction_type', 'width' => 110, 'align' => 'center'));
     $form = new AForm();
     $form->setForm(array('form_name' => 'transactions_grid_search'));
     $this->data['grid_search_form'] = array();
     $this->data['grid_search_form']['id'] = 'transactions_grid_search';
     $this->data['grid_search_form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'transactions_grid_search', 'action' => ''));
     $this->data['grid_search_form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_go'), 'style' => 'button1'));
     $this->data['grid_search_form']['reset'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'reset', 'text' => $this->language->get('button_reset'), 'style' => 'button2'));
     $this->data['js_date_format'] = format4Datepicker($this->language->get('date_format_short'));
     $this->data['grid_search_form']['fields']['date_start'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_start', 'default' => dateInt2Display(time())));
     $this->data['grid_search_form']['fields']['date_end'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_end', 'default' => dateInt2Display(time())));
     $this->data['grid_settings']['search_form'] = true;
     $grid = $this->dispatch('common/listing_grid', array($this->data['grid_settings']));
     $this->view->assign('listing_grid', $grid->dispatchGetOutput());
     $this->view->assign('search_form', $this->data['grid_search_form']);
     $this->document->setTitle($this->language->get('heading_title_transactions'));
     $this->view->assign('popup_action', $this->html->getSecureURL('listing_grid/customer_transaction/get_transaction_info'));
     $this->view->assign('popup_action_save', $this->html->getSecureURL('listing_grid/customer_transaction/savetransaction'));
     $form = new AForm('HT');
     $form->setForm(array('form_name' => 'transaction_form'));
     $this->data['ajax_form_open'] = (string) $form->getFieldHtml(array('type' => 'form', 'name' => 'transaction_form', 'action' => $this->html->getSecureURL('listing_grid/customer_transaction/savetransaction', '&customer_id=' . $this->request->get['customer_id'])));
     $this->view->assign('help_url', $this->gen_help_url('customer_transactions_listing'));
     $balance = $this->model_sale_customer_transaction->getBalance($this->request->get['customer_id']);
     $currency = $this->currency->getCurrency($this->config->get('config_currency'));
     $this->data['balance'] = $this->language->get('text_balance') . ' ' . $currency['symbol_left'] . round($balance, 2) . $currency['symbol_right'];
     $this->data['button_actas'] = $this->html->buildButton(array('text' => $this->language->get('button_actas'), 'style' => 'button1', 'href' => $this->html->getSecureURL('sale/customer/actonbehalf', '&customer_id=' . $this->request->get['customer_id']), 'target' => 'new'));
     if (has_value($customer_info['orders_count']) && $this->request->get['customer_id']) {
         $this->data['button_orders_count'] = $this->html->buildButton(array('name' => 'view orders', 'text' => $this->language->get('text_order') . ': ' . $customer_info['orders_count'], 'style' => 'button2', 'href' => $this->html->getSecureURL('sale/order', '&customer_id=' . $this->request->get['customer_id']), 'title' => $this->language->get('text_view') . ' ' . $this->language->get('tab_history')));
     }
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/sale/customer_transaction.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 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');
 }