Exemple #1
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));
 }
Exemple #2
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('catalog/product');
     $this->loadModel('catalog/product');
     $this->loadModel('tool/image');
     //Clean up parametres if needed
     if (isset($this->request->get['keyword']) && $this->request->get['keyword'] == $this->language->get('filter_product')) {
         unset($this->request->get['keyword']);
     }
     if (isset($this->request->get['pfrom']) && $this->request->get['pfrom'] == 0) {
         unset($this->request->get['pfrom']);
     }
     if (isset($this->request->get['pto']) && $this->request->get['pto'] == $this->language->get('filter_price_max')) {
         unset($this->request->get['pto']);
     }
     //Prepare filter config
     $filter_params = array('category', 'status', 'keyword', 'match', 'pfrom', 'pto');
     $grid_filter_params = array('name', 'sort_order', 'model');
     $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params));
     $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
     $data = array_merge($filter_form->getFilterData(), $filter_grid->getFilterData());
     $total = $this->model_catalog_product->getTotalProducts($data);
     $response = new stdClass();
     $response->page = $filter_grid->getParam('page');
     $response->total = $filter_grid->calcTotalPages($total);
     $response->records = $total;
     $response->userdata = new stdClass();
     $response->userdata->classes = array();
     $results = $this->model_catalog_product->getProducts($data);
     $product_ids = array();
     foreach ($results as $result) {
         $product_ids[] = (int) $result['product_id'];
     }
     $resource = new AResource('image');
     $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'));
     $i = 0;
     foreach ($results as $result) {
         $thumbnail = $thumbnails[$result['product_id']];
         $response->rows[$i]['id'] = $result['product_id'];
         if (dateISO2Int($result['date_available']) > time()) {
             $response->userdata->classes[$result['product_id']] = 'warning';
         }
         if ($result['call_to_order'] > 0) {
             $price = $this->language->get('text_call_to_order');
         } else {
             $price = $this->html->buildInput(array('name' => 'price[' . $result['product_id'] . ']', 'value' => moneyDisplayFormat($result['price'])));
         }
         $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $this->html->buildInput(array('name' => 'product_description[' . $result['product_id'] . '][name]', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'model[' . $result['product_id'] . ']', 'value' => $result['model'])), $price, $this->html->buildInput(array('name' => 'quantity[' . $result['product_id'] . ']', 'value' => $result['quantity'])), $this->html->buildCheckbox(array('name' => 'status[' . $result['product_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')));
         $i++;
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->setOutput(AJson::encode($response));
 }
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('banner_manager/banner_manager');
     $page = $this->request->post['page'];
     // get the requested page
     if ((int) $page < 0) {
         $page = 0;
     }
     $limit = $this->request->post['rows'];
     // get how many rows we want to have into the grid
     //sort
     $filter_params = array('name', 'banner_group_name', 'banner_type', 'status', 'date_modified');
     $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $filter_params, 'additional_filter_string' => ''));
     $this->loadModel('extension/banner_manager');
     $total = $this->model_extension_banner_manager->getBanners($filter_grid->getFilterData(), 'total_only');
     if ($total > 0) {
         $total_pages = ceil($total / $limit);
     } else {
         $total_pages = 0;
     }
     $results = $this->model_extension_banner_manager->getBanners($filter_grid->getFilterData());
     $response = new stdClass();
     $response->page = $page;
     $response->total = $total_pages;
     $response->records = $total;
     $ids = array();
     foreach ($results as $result) {
         $ids[] = (int) $result['banner_id'];
     }
     $resource = new AResource('image');
     $thumbnails = $resource->getMainThumbList('banners', $ids, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'));
     $i = 0;
     foreach ($results as $result) {
         $response->rows[$i]['id'] = $result['banner_id'];
         $thumbnail = $thumbnails[$result['banner_id']]['thumb_html'];
         //check if banner is active based on dates and update status
         $now = time();
         if (dateISO2Int($result['start_date']) > $now) {
             $result['status'] = 0;
         }
         $stop = dateISO2Int($result['end_date']);
         if ($stop > 0 && $stop < $now) {
             $result['status'] = 0;
         }
         $response->rows[$i]['cell'] = array($result['banner_id'], $thumbnail, $result['name'], $result['banner_group_name'], $result['banner_type'] == 1 ? $this->language->get('text_graphic_banner') : $this->language->get('text_text_banner'), $this->html->buildCheckbox(array('name' => 'status[' . $result['banner_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), $result['date_modified']);
         $i++;
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->setOutput(AJson::encode($response));
 }
    public function main()
    {
        //init controller data
        $this->extensions->hk_InitData($this, __FUNCTION__);
        $this->loadLanguage('banner_manager/banner_manager');
        $page = $this->request->post['page'];
        // get the requested page
        if ((int) $page < 0) {
            $page = 0;
        }
        $limit = $this->request->post['rows'];
        // get how many rows we want to have into the grid
        //sort
        $filter_params = array('name', 'banner_group_name', 'banner_type', 'status', 'update_date');
        $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $filter_params, 'additional_filter_string' => ''));
        $this->loadModel('extension/banner_manager');
        $total = $this->model_extension_banner_manager->getBanners($filter_grid->getFilterData(), 'total_only');
        if ($total > 0) {
            $total_pages = ceil($total / $limit);
        } else {
            $total_pages = 0;
        }
        $results = $this->model_extension_banner_manager->getBanners($filter_grid->getFilterData());
        $response = new stdClass();
        $response->page = $page;
        $response->total = $total_pages;
        $response->records = $total;
        $resource = new AResource('image');
        $i = 0;
        foreach ($results as $result) {
            $action = '<a id="action_edit_' . $result['banner_id'] . '" class="btn_action" href="' . $this->html->getSecureURL('extension/banner_manager/edit', '&banner_id=' . $result['banner_id']) . '"
								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/banner_manager/delete', '&banner_id=' . $result['banner_id']) . '"
			 	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>';
            $response->rows[$i]['id'] = $result['banner_id'];
            $thumbnail = $resource->getMainThumb('banners', $result['banner_id'], $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'), true);
            $thumbnail = $thumbnail['thumb_html'];
            //check if banner is active based on dates and update status
            $now = time();
            if (dateISO2Int($result['start_date']) > $now || dateISO2Int($result['end_date']) < $now) {
                $result['status'] = 0;
            }
            $response->rows[$i]['cell'] = array($result['banner_id'], $thumbnail, $result['name'], $result['banner_group_name'], $result['banner_type'] == 1 ? $this->language->get('text_graphic_banner') : $this->language->get('text_text_banner'), $this->html->buildCheckbox(array('name' => 'status[' . $result['banner_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), $result['update_date'], $action);
            $i++;
        }
        //update controller data
        $this->extensions->hk_UpdateData($this, __FUNCTION__);
        $this->load->library('json');
        $this->response->setOutput(AJson::encode($response));
    }
 public function runTask($task_id)
 {
     $this->toLog('Tried to run task #' . $task_id . '.');
     $task_id = (int) $task_id;
     $task = $this->_getScheduledTasks($task_id);
     //check interval and skip task
     if ($task['interval'] > 0 && (time() - dateISO2Int($task['last_time_run']) >= $task['interval'] || is_null($task['last_time_run']))) {
         $this->toLog('task #' . $task_id . ' skipped.');
         return false;
     }
     $task_settings = unserialize($task['settings']);
     $this->_run_steps($task['task_id'], $task_settings);
     $this->toLog('task #' . $task_id . ' finished.');
     return true;
 }
function dateISO2Display($iso_date, $format = '')
{
    if (empty($format)) {
        $registry = Registry::getInstance();
        $format = $registry->get('language')->get('date_format_short');
    }
    $empties = array('0000-00-00', '0000-00-00 00:00:00', '1970-01-01', '1970-01-01 00:00:00');
    if ($iso_date && !in_array($iso_date, $empties)) {
        return date($format, dateISO2Int($iso_date));
    } else {
        return '';
    }
}
 /**
  * @param $download_info
  * @return string
  */
 public function getTextStatusForOrderDownload($download_info)
 {
     $text_status = array();
     if (dateISO2Int($download_info['expire_date']) < time()) {
         $text_status[] = $this->language->get('text_download_expired');
     }
     if ($download_info['remaining_count'] == '0') {
         $text_status[] = $this->language->get('text_download_remaining_count') . ': 0';
     }
     if ((int) $download_info['activate_order_status_id'] > 0) {
         if ((int) $download_info['activate_order_status_id'] != (int) $download_info['order_status_id']) {
             $this->load->model('localisation/order_status');
             $order_status_info = $this->model_localisation_order_status->getOrderStatus($download_info['activate_order_status_id']);
             $text_status[] = sprintf($this->language->get('text_order_status_required'), $order_status_info['name']);
         }
     }
     //2. check is file exists
     $download_info['filename'] = trim($download_info['filename']);
     if (!$this->download->isFileAvailable($download_info['filename'])) {
         $text_status[] = $this->language->get('text_missing_file');
     }
     return $text_status;
 }
 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');
 }
 public function details()
 {
     $this->data = array();
     $fields = array('email', 'telephone', 'shipping_method', 'payment_method');
     //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']);
     }
     $order_id = (int) $this->request->get['order_id'];
     if ($this->request->is_POST() && $this->_validateForm()) {
         $this->model_sale_order->editOrder($order_id, $this->request->post);
         if (has_value($this->request->post['downloads'])) {
             $data = $this->request->post['downloads'];
             $this->loadModel('catalog/download');
             foreach ($data as $order_download_id => $item) {
                 if ($item['expire_date']) {
                     $item['expire_date'] = dateDisplay2ISO($item['expire_date'], $this->language->get('date_format_short'));
                 } else {
                     $item['expire_date'] = '';
                 }
                 $this->model_catalog_download->editOrderDownload($order_download_id, $item);
             }
         } else {
             //NOTE: Totals will be recalculated if forced so skip array is not needed.
             if ($this->request->post['force_recalc']) {
                 $this->session->data['attention'] = $this->language->get('attention_check_total');
                 $this->redirect($this->html->getSecureURL('sale/order/recalc', '&order_id=' . $order_id));
             } else {
                 if ($this->request->post['force_recalc_single']) {
                     //recalc single only
                     $skip_recalc = array();
                     foreach ($this->request->post['totals'] as $key => $value) {
                         if (has_value($value)) {
                             $skip_recalc[] = $key;
                         }
                     }
                     $this->redirect($this->html->getSecureURL('sale/order/recalc', '&order_id=' . $order_id . '&skip_recalc=' . serialize($skip_recalc)));
                 } else {
                     //we just save with no reculculation
                     $this->model_sale_order->editOrder($order_id, $this->request->post);
                 }
             }
         }
     }
     $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/details', '&order_id=' . $order_id), 'text' => $this->language->get('heading_title') . ' #' . $order_id, 'separator' => ' :: ', 'current' => true));
     if (isset($this->session->data['attention'])) {
         $this->data['attention'] = $this->session->data['attention'];
         unset($this->session->data['attention']);
     } else {
         $this->data['attention'] = '';
     }
     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_id;
     $this->data['token'] = $this->session->data['token'];
     $this->data['invoice_url'] = $this->html->getSecureURL('sale/invoice', '&order_id=' . $order_id);
     $this->data['button_invoice'] = $this->html->buildElement(array('type' => 'button', 'name' => 'generate_invoice', 'text' => $this->language->get('button_generate')));
     $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'] = $order_id;
     $this->data['action'] = $this->html->getSecureURL('sale/order/details', '&order_id=' . $order_id);
     $this->data['cancel'] = $this->html->getSecureURL('sale/order');
     $this->_initTabs('order_details');
     // These only change for insert, not edit. To be added later
     $this->data['ip'] = $order_info['ip'];
     $this->data['history'] = $this->html->getSecureURL('sale/order/history', '&order_id=' . $order_id);
     $this->data['store_name'] = $order_info['store_name'];
     $this->data['store_url'] = $order_info['store_url'];
     $this->data['comment'] = nl2br($order_info['comment']);
     $this->data['firstname'] = $order_info['firstname'];
     $this->data['lastname'] = $order_info['lastname'];
     $this->data['lastname'] = $order_info['lastname'];
     $this->data['total'] = $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value']);
     $this->data['date_added'] = dateISO2Display($order_info['date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
     if ($order_info['customer_id']) {
         $this->data['customer_url'] = $this->html->getSecureURL('sale/customer/update', '&customer_id=' . $order_info['customer_id']);
     }
     $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'] = '';
     }
     if ($order_info['invoice_id']) {
         $this->data['invoice_id'] = $order_info['invoice_prefix'] . $order_info['invoice_id'];
     } else {
         $this->data['invoice_id'] = '';
     }
     foreach ($fields as $f) {
         if (isset($this->request->post[$f])) {
             $this->data[$f] = $this->request->post[$f];
         } elseif (isset($order_info[$f])) {
             $this->data[$f] = $order_info[$f];
         } else {
             $this->data[$f] = '';
         }
     }
     $this->data['email'] = $this->html->buildInput(array('name' => 'email', 'value' => $order_info['email']));
     $this->data['telephone'] = $this->html->buildInput(array('name' => 'telephone', 'value' => $order_info['telephone']));
     $this->loadModel('catalog/product');
     $this->loadModel('catalog/category');
     $this->data['categories'] = $this->model_catalog_category->getCategories(0);
     $this->data['order_products'] = array();
     $order_products = $this->model_sale_order->getOrderProducts($order_id);
     foreach ($order_products as $order_product) {
         $option_data = array();
         $options = $this->model_sale_order->getOrderOptions($order_id, $order_product['order_product_id']);
         foreach ($options as $option) {
             $value = $option['value'];
             //generate link to download uploaded files
             if ($option['element_type'] == 'U') {
                 $file_settings = unserialize($option['settings']);
                 $filename = $value;
                 if (has_value($file_settings['directory'])) {
                     $file = DIR_APP_SECTION . 'system/uploads/' . $file_settings['directory'] . '/' . $filename;
                 } else {
                     $file = DIR_APP_SECTION . 'system/uploads/' . $filename;
                 }
                 if (is_file($file)) {
                     $value = '<a href="' . $this->html->getSecureURL('tool/files/download', '&filename=' . urlencode($filename) . '&order_option_id=' . (int) $option['order_option_id']) . '" title=" to download file" target="_blank">' . $value . '</a>';
                 } else {
                     $value = '<span title="file ' . $file . ' is unavailable">' . $value . '</span>';
                 }
             } elseif ($option['element_type'] == 'C' && $value == 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' => nl2br($value), 'title' => $title);
         }
         //check if this product product is still available, so we can use reculculation against the cart
         $product = $this->model_catalog_product->getProduct($order_product['product_id']);
         if (empty($product) || !$product['status'] || $product['call_to_order']) {
             $this->data['no_recalc_allowed'] = true;
             $product['status'] = 0;
         } else {
             if (dateISO2Int($product['date_available']) > time()) {
                 $this->data['no_recalc_allowed'] = true;
                 $product['status'] = 0;
             }
         }
         $this->data['order_products'][] = array('order_product_id' => $order_product['order_product_id'], 'product_id' => $order_product['product_id'], 'product_status' => $product['status'], 'name' => $order_product['name'], 'model' => $order_product['model'], 'option' => $option_data, 'quantity' => $order_product['quantity'], 'price' => $this->currency->format($order_product['price'], $order_info['currency'], $order_info['value']), 'total' => $this->currency->format($order_product['total'], $order_info['currency'], $order_info['value']), 'href' => $this->html->getSecureURL('catalog/product/update', '&product_id=' . $order_product['product_id']));
     }
     $this->data['currency'] = $this->currency->getCurrency($order_info['currency']);
     $this->data['totals'] = $this->model_sale_order->getOrderTotals($order_id);
     //add enabled but not present totals such as dicount and fee.
     $add_missing = array('low_order_fee', 'handling', 'coupon', 'shipping', 'tax');
     $this->loadModel('setting/extension');
     $new_totals = array();
     $total_ext = $this->extensions->getExtensionsList(array('filter' => 'total'));
     if ($total_ext->rows) {
         foreach ($total_ext->rows as $row) {
             $match = false;
             if (!$row['status'] || !in_array($row['key'], $add_missing)) {
                 continue;
             }
             foreach ($this->data['totals'] as $total) {
                 if ($row['key'] == $total['key']) {
                     $match = true;
                     break;
                 }
             }
             if (!$match) {
                 $new_totals[$row['key']] = $row['key'];
                 $this->data['totals_add'][] = array('key' => $row['key'], 'type' => $this->config->get($row['key'] . '_total_type'), 'order_id' => $order_id, 'title' => $row['key'], 'text' => '', 'value' => '', 'sort_order' => $this->config->get($row['key'] . '_sort_order'));
             }
         }
     }
     //check which totals we allow to edit (disable edit for missing and disabled totals.
     foreach ($this->data['totals'] as &$ototal) {
         $ototal['unavailable'] = true;
         //is order prior to 1.2.2 upgrade? do not allow recalc
         if (empty($ototal['key'])) {
             $this->data['no_recalc_allowed'] = true;
             continue;
         }
         if ($total_ext->rows) {
             foreach ($total_ext->rows as $extn) {
                 if (!$extn['status']) {
                     //is total in this order missing? do not allow resulculate
                     if (str_replace('_', '', $ototal['key']) == str_replace('_', '', $extn['key'])) {
                         $this->data['no_recalc_allowed'] = true;
                     }
                     continue;
                 }
                 if (str_replace('_', '', $ototal['key']) == str_replace('_', '', $extn['key'])) {
                     //all good, total is available
                     $ototal['unavailable'] = false;
                 }
             }
         }
     }
     $this->data['form_title'] = $this->language->get('edit_title_details');
     $this->data['update'] = $this->html->getSecureURL('listing_grid/order/update_field', '&id=' . $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' => '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['new_total'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'new_total', 'value' => $this->data['new_total'], 'options' => $new_totals));
     //if virtual product (no shippment);
     if (!$this->data['shipping_method']) {
         $this->data['form']['fields']['shipping_method'] = $this->language->get('text_not_applicable');
     } else {
         $this->data['form']['fields']['shipping_method'] = $this->data['shipping_method'];
     }
     // no payment
     if (!$this->data['payment_method']) {
         $this->data['form']['fields']['payment_method'] = $this->language->get('text_not_applicable');
     } else {
         $this->data['form']['fields']['payment_method'] = $this->data['payment_method'];
     }
     $this->data['add_product'] = $this->html->buildElement(array('type' => 'multiselectbox', 'name' => 'add_product', 'value' => '', 'options' => array(), 'style' => 'aform_noaction chosen', 'ajax_url' => $this->html->getSecureURL('r/product/product/products', '&currency_code=' . $this->data['currency']['code']), 'placeholder' => $this->language->get('text_select_from_lookup'), 'option_attr' => array('price')));
     $this->data['add_product_url'] = $this->html->getSecureURL('r/product/product/orderProductForm', '&order_id=' . $order_id);
     $this->data['edit_order_total'] = $this->html->getSecureURL('sale/order/recalc', '&order_id=' . $order_id);
     $this->data['delete_order_total'] = $this->html->getSecureURL('sale/order/delete_total', '&order_id=' . $order_id);
     $this->addChild('pages/sale/order_summary', 'summary_form', 'pages/sale/order_summary.tpl');
     $this->view->batchAssign($this->data);
     $this->view->assign('help_url', $this->gen_help_url('order_details'));
     $this->processTemplate('pages/sale/order_details.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Exemple #10
0
 public function incompleted()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('user/user');
     $this->data = $this->language->getASet('sale/contact');
     $tm = new ATaskManager();
     $incompleted = $tm->getTasks(array('filter' => array('name' => 'send_now')));
     $k = 0;
     foreach ($incompleted as $incm_task) {
         //show all incompleted tasks for Top Administrator user group
         if ($this->user->getUserGroupId() != 1) {
             if ($incm_task['starter'] != $this->user->getId()) {
                 continue;
             }
         }
         //define incompleted tasks by last time run
         $max_exec_time = (int) $incm_task['max_execution_time'];
         if (!$max_exec_time) {
             //if no limitations for execution time for task - think it's 2 hours
             //$max_exec_time = 7200;
             $max_exec_time = 7200;
         }
         if (time() - dateISO2Int($incm_task['last_time_run']) > $max_exec_time) {
             //get some info about task, for ex message-text and subject
             $steps = $tm->getTaskSteps($incm_task['task_id']);
             if (!$steps) {
                 $tm->deleteTask($incm_task['task_id']);
             }
             $user_info = $this->model_user_user->getUser($incm_task['starter']);
             $incm_task['starter_name'] = $user_info['username'] . ' ' . $user_info['firstname'] . ' ' . $user_info['lastname'];
             $step = current($steps);
             $step_settings = $step['settings'];
             if ($step_settings['subject']) {
                 $incm_task['subject'] = $step_settings['subject'];
             }
             $incm_task['message'] = mb_substr($step_settings['message'], 0, 300);
             $incm_task['date_added'] = dateISO2Display($incm_task['date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
             $incm_task['last_time_run'] = dateISO2Display($incm_task['last_time_run'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
             $incm_task['was_sent'] = sprintf($this->language->get('text_was_sent'), $incm_task['settings']['sent'], $incm_task['settings']['recipients_count']);
             $this->data['tasks'][$k] = $incm_task;
         }
         $k++;
     }
     $this->data['restart_task_url'] = $this->html->getSecureURL('r/sale/contact/restartTask');
     $this->data['complete_task_url'] = $this->html->getSecureURL('r/sale/contact/complete');
     $this->data['abort_task_url'] = $this->html->getSecureURL('r/sale/contact/abort');
     $this->view->batchAssign($this->data);
     $this->processTemplate('responses/sale/contact_incompleted.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Exemple #11
0
 private function _getForm()
 {
     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->data['token'] = $this->session->data['token'];
     $this->data['cancel'] = $this->html->getSecureURL('sale/coupon');
     $this->data['error'] = $this->error;
     $this->view->assign('category_products', $this->html->getSecureURL('product/product/category'));
     $this->view->assign('products_list', $this->html->getSecureURL('product/product/products'));
     $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 (isset($this->request->get['coupon_id']) && !$this->request->server['REQUEST_METHOD'] != 'POST') {
         $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();
         }
     }
     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'] = date('Y-m-d', strtotime($coupon_info['date_start']));
     } else {
         $this->data['date_start'] = date('Y-m-d', time());
     }
     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'] = date('Y-m-d', strtotime($coupon_info['date_end']));
     } 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 (isset($this->data['status']) && $this->data['status'] == '') {
         $this->data['status'] = 1;
     }
     //check if coupon is active based on dates and update status
     $now = time();
     if (dateISO2Int($this->data['date_start']) > $now || dateISO2Int($this->data['date_end']) < $now) {
         $this->data['status'] = 0;
     }
     if (!isset($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'][$this->session->data['content_language_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' => ' :: '));
     $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' => '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->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[' . $this->session->data['content_language_id'] . '][name]', 'value' => $this->data['coupon_description'][$this->session->data['content_language_id']]['name'], 'required' => true, 'style' => 'large-field'));
     $this->data['form']['fields']['description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'coupon_description[' . $this->session->data['content_language_id'] . '][description]', 'value' => $this->data['coupon_description'][$this->session->data['content_language_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' => dateISO2Display($this->data['date_start']), 'default' => dateNowDisplay(), 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'required' => true, 'style' => 'medium-field'));
     $this->data['form']['fields']['date_end'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'date_end', 'value' => dateISO2Display($this->data['date_end']), 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'pased', 'required' => true, 'style' => 'medium-field'));
     $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'] = (int) $total;
     }
     $this->load->library('json');
     $listing_data = array();
     if ($this->data['coupon_product']) {
         $this->loadModel('catalog/product');
         foreach ($this->data['coupon_product'] as $product_id) {
             $product_info = $this->model_catalog_product->getProduct($product_id);
             $listing_data[$product_id] = array('id' => $product_id, 'name' => html_entity_decode($product_info['name'] . ' (' . $product_info['model'] . ')'), 'status' => 1);
         }
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         $listing_data = AJson::decode(html_entity_decode($this->request->post['selected'][0]), true);
     }
     $this->data['form']['fields']['product'] = $form->getFieldHtml(array('id' => 'coupon_products_list', 'type' => 'multivaluelist', 'name' => 'coupon_products', 'content_url' => $this->html->getSecureUrl('listing_grid/coupon/products'), 'edit_url' => '', 'multivalue_hidden_id' => 'popup', 'values' => $listing_data, 'return_to' => 'couponFrm_popup_item_count', 'text' => array('delete' => $this->language->get('button_delete'), 'delete_confirm' => $this->language->get('text_delete_confirm'))));
     $this->data['form']['fields']['list'] = $form->getFieldHtml(array('id' => 'popup', 'type' => 'multivalue', 'name' => 'popup', 'title' => $this->language->get('text_select_from_list'), 'selected' => $listing_data ? AJson::encode($listing_data) : "{}", 'content_url' => $this->html->getSecureUrl('catalog/product_listing', '&form_name=couponFrm&multivalue_hidden_id=popup'), 'postvars' => '', 'return_to' => '', 'popup_height' => 708, 'js' => array('apply' => "couponFrm_coupon_products_buildList();", 'cancel' => 'couponFrm_coupon_products_buildList();'), '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('button_save'), 'reset' => $this->language->get('button_reset'))));
     $this->view->assign('help_url', $this->gen_help_url('coupon_edit'));
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/sale/coupon_form.tpl');
 }
Exemple #12
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (!has_value($this->data['protocol'])) {
         $this->data['protocol'] = 'email';
     }
     $this->document->setTitle($this->language->get('text_send_' . $this->data['protocol']));
     $this->loadModel('sale/customer');
     $this->data['token'] = $this->session->data['token'];
     if (isset($this->error)) {
         $this->data['error_warning'] = '';
         foreach ($this->error as $message) {
             $this->data['error_warning'] .= $message . '<br/>';
         }
     } else {
         $this->data['error_warning'] = '';
     }
     if (isset($this->error['subject'])) {
         $this->data['error_subject'] = $this->error['subject'];
     } else {
         $this->data['error_subject'] = '';
     }
     if (isset($this->error['message'])) {
         $this->data['error_message'] = $this->error['message'];
     } else {
         $this->data['error_message'] = '';
     }
     if (isset($this->error['recipient'])) {
         $this->data['error_recipient'] = $this->error['recipient'];
     } else {
         $this->data['error_recipient'] = '';
     }
     $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/contact'), 'text' => $this->language->get('text_send_' . $this->data['protocol']), 'separator' => ' :: ', 'current' => true));
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->data['action'] = $this->html->getSecureURL('sale/contact');
     $this->data['cancel'] = $this->html->getSecureURL('sale/contact');
     //get store from main switcher and current config
     $this->data['store_id'] = (int) $this->session->data['current_store_id'];
     $this->data['customers'] = array();
     $this->data['products'] = array();
     $this->loadModel('catalog/product');
     $customer_ids = $this->request->get_or_post('to');
     if (!$customer_ids && has_value($this->session->data['sale_contact_presave']['to'])) {
         $customer_ids = $this->session->data['sale_contact_presave']['to'];
     }
     $product_ids = $this->request->get_or_post('products');
     if (!$product_ids && has_value($this->session->data['sale_contact_presave']['products'])) {
         $product_ids = $this->session->data['sale_contact_presave']['products'];
     }
     //process list of customer or product IDs to be notified
     if (isset($customer_ids) && is_array($customer_ids)) {
         foreach ($customer_ids as $customer_id) {
             $customer_info = $this->model_sale_customer->getCustomer($customer_id);
             if ($customer_info) {
                 $this->data['customers'][$customer_info['customer_id']] = $customer_info['firstname'] . ' ' . $customer_info['lastname'] . ' (' . $customer_info['email'] . ')';
             }
         }
     }
     if (isset($product_ids) && is_array($product_ids)) {
         //get thumbnails by one pass
         $resource = new AResource('image');
         $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'));
         foreach ($product_ids as $product_id) {
             $product_info = $this->model_catalog_product->getProduct($product_id);
             if ($product_info) {
                 $thumbnail = $thumbnails[$product_id];
                 $this->data['products'][$product_id] = array('name' => $product_info['name'], 'image' => $thumbnail['thumb_html']);
             }
         }
     }
     foreach (array('recipient', 'subject', 'message') as $n) {
         $this->data[$n] = $this->request->post_or_get($n);
         if (!$this->data[$n] && has_value($this->session->data['sale_contact_presave'][$n])) {
             $this->data[$n] = $this->session->data['sale_contact_presave'][$n];
         }
     }
     $form = new AForm('ST');
     $form->setForm(array('form_name' => 'sendFrm', 'update' => $this->data['update']));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'sendFrm', 'action' => '', 'attr' => 'data-confirm-exit="true" class="form-horizontal"'));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_send'), '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']['protocol'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'protocol', 'value' => $this->data['protocol']));
     $this->data['form']['build_task_url'] = $this->html->getSecureURL('r/sale/contact/buildTask');
     $this->data['form']['complete_task_url'] = $this->html->getSecureURL('r/sale/contact/complete');
     $this->data['form']['abort_task_url'] = $this->html->getSecureURL('r/sale/contact/abort');
     //set store selector
     $this->view->assign('form_store_switch', $this->html->getStoreSwitcher());
     //build recipient filter
     $options = array('' => $this->language->get('text_custom_send'));
     $db_filter = array('status' => 1, 'approved' => 1);
     if ($this->data['protocol'] == 'sms') {
         $db_filter['filter']['only_with_mobile_phones'] = 1;
     }
     $newsletter_dbfilter = $db_filter;
     $newsletter_dbfilter['filter']['newsletter_protocol'] = $this->data['protocol'];
     $all_subscribers_count = $this->model_sale_customer->getTotalAllSubscribers($newsletter_dbfilter);
     if ($all_subscribers_count) {
         $options['all_subscribers'] = $this->language->get('text_all_subscribers') . ' ' . sprintf($this->language->get('text_total_to_be_sent'), $all_subscribers_count);
     }
     $only_subscribers_count = $this->model_sale_customer->getTotalOnlyNewsletterSubscribers($newsletter_dbfilter);
     if ($only_subscribers_count) {
         $options['only_subscribers'] = $this->language->get('text_subscribers_only') . ' ' . sprintf($this->language->get('text_total_to_be_sent'), $only_subscribers_count);
     }
     $only_customers_count = $this->model_sale_customer->getTotalOnlyCustomers($db_filter);
     if ($only_customers_count) {
         $options['only_customers'] = $this->language->get('text_customers_only') . ' ' . sprintf($this->language->get('text_total_to_be_sent'), $only_customers_count);
     }
     if (sizeof($options) == 1) {
         $this->data['error_warning'] = $this->language->get('error_' . $this->data['protocol'] . '_no_recipients');
     }
     $options['ordered'] = $this->language->get('text_customers_who_ordered');
     $this->data['form']['fields']['to'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'recipient', 'value' => $this->data['recipient'], 'options' => $options, 'required' => true));
     $this->data['recipients_count_url'] = $this->html->getSecureURL('r/sale/contact/getRecipientsCount');
     $this->data['form']['fields']['customers'] = $form->getFieldHtml(array('type' => 'multiselectbox', 'name' => 'to[]', 'value' => $customer_ids, 'options' => $this->data['customers'], 'style' => 'chosen', 'ajax_url' => $this->html->getSecureURL('r/listing_grid/customer/customers'), 'placeholder' => $this->language->get('text_customers_from_lookup')));
     $this->data['form']['fields']['product'] = $form->getFieldHtml(array('type' => 'multiselectbox', 'name' => 'products[]', 'value' => $product_ids, 'options' => $this->data['products'], 'style' => 'chosen', 'ajax_url' => $this->html->getSecureURL('r/product/product/products'), 'placeholder' => $this->language->get('text_products_from_lookup')));
     if ($this->data['protocol'] == 'email') {
         $this->data['form']['fields']['subject'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'subject', 'value' => $this->data['subject'], 'required' => true));
     }
     $this->data['form']['fields']['message'] = $form->getFieldHtml(array('type' => $this->data['protocol'] == 'email' ? 'texteditor' : 'textarea', 'name' => 'message', 'value' => $this->data['message'], 'style' => 'ml_ckeditor', 'required' => true));
     //if email address given
     if (has_value($this->request->get['email'])) {
         $this->data['emails'] = (array) $this->request->get['email'];
     }
     $this->data['category_products'] = $this->html->getSecureURL('product/product/category');
     $this->data['customers_list'] = $this->html->getSecureURL('user/customers');
     $this->data['presave_url'] = $this->html->getSecureURL('r/sale/contact/presave');
     $this->data['help_url'] = $this->gen_help_url('send_mail');
     if ($this->data['protocol'] == 'email') {
         $resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'contact', 'object_id' => '', 'types' => array('image')));
         $this->data['resources_scripts'] = $resources_scripts->dispatchGetOutput();
         $this->data['rl'] = $this->html->getSecureURL('common/resource_library', '&action=list_library&object_name=&object_id&type=image&mode=single');
     }
     //load tabs controller
     if ($this->data['protocol'] == 'email' || !has_value($this->data['protocol'])) {
         $this->data['active'] = 'email';
     } elseif ($this->data['protocol'] == 'sms') {
         $this->data['active'] = 'sms';
     }
     $this->data['protocols'] = array();
     $this->data['protocols']['email'] = array('title' => $this->language->get('text_email'), 'href' => $this->html->getSecureURL('sale/contact/email'), 'icon' => 'mail');
     $driver = $this->config->get('config_sms_driver');
     //if sms driver not set or disabled - redirect
     if ($driver && $this->config->get($driver . '_status')) {
         $this->data['protocols']['sms'] = array('title' => $this->language->get('text_sms'), 'href' => $this->html->getSecureURL('sale/contact/sms'));
     }
     //check for incompleted tasks
     $tm = new ATaskManager();
     $incompleted = $tm->getTasks(array('filter' => array('name' => 'send_now')));
     foreach ($incompleted as $incm_task) {
         //show all incompleted tasks for Top Administrator user group
         if ($this->user->getUserGroupId() != 1) {
             if ($incm_task['starter'] != $this->user->getId()) {
                 continue;
             }
             //rename task to prevent colission with new
             if ($incm_task['name'] == 'send_now') {
                 $tm->updateTask($incm_task['task_id'], array('name' => 'send_now_' . date('YmdHis')));
             }
         }
         //define incompleted tasks by last time run
         $max_exec_time = (int) $incm_task['max_execution_time'];
         if (!$max_exec_time) {
             //if no limitations for execution time for task - think it's 2 hours
             $max_exec_time = 7200;
         }
         if (time() - dateISO2Int($incm_task['last_time_run']) > $max_exec_time) {
             $this->data['incomplete_tasks_url'] = $this->html->getSecureURL('r/sale/contact/incompleted');
             break;
         }
     }
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/sale/contact.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Exemple #13
0
 public function restart()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->addJSONHeader();
     if (has_value($this->request->post_or_get('task_id'))) {
         $tm = new ATaskManager();
         $task = $tm->getTaskById($this->request->post_or_get('task_id'));
         //check
         if ($task && $task['status'] == 2 && time() - dateISO2Int($task['start_time']) > 1800) {
             foreach ($task['steps'] as $step) {
                 $tm->updateStep($step['step_id'], array('status' => 1));
             }
             $tm->updateTask($task['task_id'], array('status' => 1, 'start_time' => date('Y-m-d H:i:s'), 'last_result' => 2));
         }
         $this->_run_task();
     } else {
         $this->response->setOutput(AJson::encode(array('result' => false)));
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 public function getTextStatusForOrderDownload($download_info)
 {
     $this->load->language('account/download');
     $text_status = '';
     if ($download_info['status'] == 0) {
         $text_status = $this->language->get('text_pending');
     } elseif (dateISO2Int($download_info['expire_date']) < time()) {
         $text_status = $this->language->get('text_expired');
     } elseif ($download_info['remaining_count'] == '0') {
         $text_status = $this->language->get('text_reached_limit');
     }
     if ((int) $download_info['activate_order_status_id'] > 0) {
         if ((int) $download_info['activate_order_status_id'] != (int) $download_info['order_status_id']) {
             $text_status = $this->language->get('text_pending');
         }
     }
     //2. check is file exists
     $download_info['filename'] = trim($download_info['filename']);
     if (!$this->isFileAvailable($download_info['filename'])) {
         $err = new AError('Error: file "' . $download_info['filename'] . '" (download_id = ' . $download_info['order_id'] . ') of order #' . $download_info['order_id'] . ' is unavailable for download!');
         $err->toLog()->toDebug()->toMessages();
         $text_status = $this->language->get('text_unavailable');
     }
     return $text_status;
 }
Exemple #15
0
 /**
  * function checks if product will be displayed on storefront and returns array with messages about causes
  * @param $product_id
  * @return array
  */
 public function getProductCondition($product_id)
 {
     $product_id = (int) $product_id;
     if (!$product_id) {
         return array();
     }
     $sql = "SELECT p.*, p.quantity as base_quantity, p.subtract as base_subtract, pov.*\n\t\t\t\tFROM " . $this->db->table('products') . " p\n\t\t\t\tLEFT JOIN " . $this->db->table('product_option_values') . " pov ON pov.product_id = p.product_id\n\t\t\t\tWHERE p.product_id = " . $product_id;
     $result = $this->db->query($sql);
     // id product disabled do not run other checks
     if (!$result->row['status']) {
         return array($this->language->get('text_product_disabled'));
     }
     $output = array();
     // check is product available
     if (dateISO2Int($result->row['date_available']) > time()) {
         $output[] = $this->language->get('text_product_unavailable');
     }
     //check is stock track enabled and product quantity more than 0
     if ($result->row['base_subtract'] && $result->row['base_quantity'] <= 0) {
         $output[] = $this->language->get('text_product_out_of_stock');
     }
     foreach ($result->rows as $row) {
         if ($row['subtract'] && $row['quantity'] <= 0) {
             $output[] = $this->language->get('text_product_option_out_of_stock');
             break;
         }
     }
     return $output;
 }
 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');
 }
 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');
     $this->document->addScript(RDIR_TEMPLATE . 'javascript/ckeditor/ckeditor.js');
     if (!isset($this->request->get['banner_id'])) {
         $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['detail_link'] = $this->html->getSecureUrl('extension/banner_manager_stat/details', '&banner_id=' . $this->request->get['banner_id']);
         $this->data['text_view_stat'] = $this->language->get('text_view_stat');
         $this->data['button_details'] = $this->html->buildButton(array('name' => 'btn_details', 'text' => $this->language->get('text_view_stat'), 'style' => 'button1'));
     }
     $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['form_title'], 'separator' => ' :: '));
     $form->setForm(array('form_name' => 'BannerFrm', 'update' => $this->data['update']));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'BannerFrm', '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'));
     //check if banner is active based on dates and update status
     $now = time();
     if (dateISO2Int($this->data['start_date']) > $now || dateISO2Int($this->data['end_date']) < $now) {
         $this->data['status'] = 0;
     }
     $this->data['form']['fields']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => 1, 'checked' => $this->data['status'] ? true : false, 'style' => 'btn_switch'));
     $this->data['form']['text']['status'] = $this->language->get('banner_manager_status');
     $this->data['form']['fields']['type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'banner_type', 'options' => array('1' => $this->language->get('text_graphic_banner'), '2' => $this->language->get('text_text_banner')), 'value' => $this->data['banner_type'], 'style' => 'no-save'));
     $this->data['form']['text']['type'] = $this->language->get('column_banner_type');
     $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'];
         }
     }
     $this->data['form']['fields']['banner_group_name'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'banner_group_name[0]', 'options' => $groups, 'value' => $this->data['banner_group_name'][0], 'required' => true, 'style' => 'no-save'));
     $this->data['form']['text']['banner_group_name'] = $this->language->get('entry_banner_group_name');
     if (in_array($this->data['banner_group_name'][0], $groups) || !$this->data['banner_group_name'][0]) {
         $display = ' style="display:none;" ';
     }
     $this->data['form']['fields']['banner_group_name'] .= '<br><br>' . $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] : '', 'default' => $this->language->get('text_put_new_group'), 'attr' => $display, 'style' => ''));
     $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');
     $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']));
     $this->data['form']['text']['blank'] = $this->language->get('entry_banner_blank');
     $this->data['form']['fields']['daterange'] .= $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' => 'medium-field'));
     $this->data['form']['fields']['daterange'] .= '&nbsp;&nbsp;-&nbsp;&nbsp;';
     $this->data['form']['fields']['daterange'] .= $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' => 'medium-field'));
     $this->data['form']['text']['daterange'] = $this->language->get('entry_banner_daterange');
     $this->data['banner_id'] = $this->request->get['banner_id'] ? $this->request->get['banner_id'] : '-1';
     $this->addChild('responses/common/resource_library/get_resources_html', 'resources_html', 'responses/common/resource_library_scripts.tpl');
     //pathes for js function
     $this->data['rl_unmap_path'] = $this->html->getSecureURL('common/resource_library/unmap', '&object_name=banners');
     $this->data['rl_rl_path'] = $this->html->getSecureURL('common/resource_library', '&object_name=banners&object_title=' . ($this->data['name'] ? $this->data['name'] : $this->language->get('text_banner')));
     $this->data['rl_resources_path'] = $this->html->getSecureURL('common/resource_library/resources', '&object_name=banners');
     $resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'banners', 'object_id' => $this->data['banner_id'], 'types' => 'image'));
     $this->data['resources_scripts'] = $resources_scripts->dispatchGetOutput();
     $this->data['subform_url'] = $this->html->getSecureURL('listing_grid/banner_manager/getsubform', '&banner_id=' . $this->data['banner_id']);
     $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->view->assign('rl', $this->html->getSecureURL('common/resource_library', '&object_name=banners&type=image&mode=url'));
     $this->processTemplate('pages/extension/banner_manager_form.tpl');
 }