Ejemplo n.º 1
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__);
 }
Ejemplo n.º 2
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__);
 }
Ejemplo n.º 3
0
 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__);
 }
Ejemplo n.º 4
0
 public function files()
 {
     $this->data = array();
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     if (has_value($this->session->data['error'])) {
         $this->data['error']['warning'] = $this->session->data['error'];
         unset($this->session->data['error']);
     }
     if (isset($this->request->get['order_id'])) {
         $order_id = $this->request->get['order_id'];
     } else {
         $order_id = 0;
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_validateForm()) {
         if (has_value($this->request->post['downloads'])) {
             $data = $this->request->post['downloads'];
             $this->loadModel('catalog/download');
             foreach ($data as $order_download_id => $item) {
                 if (isset($item['expire_date'])) {
                     $item['expire_date'] = $item['expire_date'] ? dateDisplay2ISO($item['expire_date'], $this->language->get('date_format_short')) : '';
                 }
                 $this->model_catalog_download->editOrderDownload($order_download_id, $item);
             }
         }
         //add download to order
         if (has_value($this->request->post['push'])) {
             $this->load->library('json');
             foreach ($this->request->post['push'] as $order_product_id => $items) {
                 $items = AJson::decode(html_entity_decode($items), true);
                 if ($items) {
                     foreach ($items as $download_id => $info) {
                         $download_info = $this->download->getDownloadInfo($download_id);
                         $download_info['attributes_data'] = serialize($this->download->getDownloadAttributesValues($download_id));
                         $this->download->addProductDownloadToOrder($order_product_id, $order_id, $download_info);
                     }
                 }
             }
         }
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']));
     }
     $order_info = $this->model_sale_order->getOrder($order_id);
     $this->data['order_info'] = $order_info;
     //set content language to order language ID.
     if ($this->language->getContentLanguageID() != $order_info['language_id']) {
         //reset content language
         $this->language->setCurrentContentLanguage($order_info['language_id']);
     }
     if (empty($order_info)) {
         $this->session->data['error'] = $this->language->get('error_order_load');
         $this->redirect($this->html->getSecureURL('sale/order'));
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']), 'text' => $this->language->get('heading_title') . ' #' . $order_info['order_id'], 'separator' => ' :: '));
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->data['heading_title'] = $this->language->get('heading_title') . ' #' . $order_info['order_id'];
     $this->data['token'] = $this->session->data['token'];
     $this->data['invoice'] = $this->html->getSecureURL('sale/invoice', '&order_id=' . (int) $this->request->get['order_id']);
     $this->data['button_invoice'] = $this->html->buildButton(array('name' => 'btn_invoice', 'text' => $this->language->get('text_invoice'), 'style' => 'button3'));
     $this->data['invoice_generate'] = $this->html->getSecureURL('sale/invoice/generate');
     $this->data['category_products'] = $this->html->getSecureURL('product/product/category');
     $this->data['product_update'] = $this->html->getSecureURL('catalog/product/update');
     $this->data['order_id'] = $this->request->get['order_id'];
     $this->data['action'] = $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']);
     $this->data['cancel'] = $this->html->getSecureURL('sale/order');
     $this->_initTabs('files');
     $this->loadModel('localisation/order_status');
     $status = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']);
     if ($status) {
         $this->data['order_status'] = $status['name'];
     } else {
         $this->data['order_status'] = '';
     }
     $this->loadModel('sale/customer_group');
     $customer_group_info = $this->model_sale_customer_group->getCustomerGroup($order_info['customer_group_id']);
     if ($customer_group_info) {
         $this->data['customer_group'] = $customer_group_info['name'];
     } else {
         $this->data['customer_group'] = '';
     }
     $this->data['form_title'] = $this->language->get('edit_title_files');
     $this->data['update'] = $this->html->getSecureURL('listing_grid/order/update_field', '&id=' . $this->request->get['order_id']);
     $form = new AForm('HS');
     $form->setForm(array('form_name' => 'orderFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'orderFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'orderFrm', 'attr' => 'confirm-exit="true"', 'action' => $this->data['action']));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
     $this->addChild('pages/sale/order_summary', 'summary_form', 'pages/sale/order_summary.tpl');
     /** ORDER DOWNLOADS */
     $this->data['downloads'] = array();
     $order_downloads = $this->model_sale_order->getOrderDownloads($this->request->get['order_id']);
     if ($order_downloads) {
         $rl = new AResource('image');
         if (!$this->registry->has('jqgrid_script')) {
             $locale = $this->session->data['language'];
             if (!file_exists(DIR_ROOT . '/' . RDIR_TEMPLATE . 'javascript/jqgrid/js/i18n/grid.locale-' . $locale . '.js')) {
                 $locale = 'en';
             }
             $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/i18n/grid.locale-' . $locale . '.js');
             $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/jquery.jqGrid.min.js');
             $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/plugins/jquery.grid.fluid.js');
             $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/jquery.ba-bbq.min.js');
             $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/grid.history.js');
             //set flag to not include scripts/css twice
             $this->registry->set('jqgrid_script', true);
         }
         $this->session->data['multivalue_excludes'] = array();
         $this->loadModel('catalog/download');
         foreach ($order_downloads as $product_id => $order_download) {
             $downloads = (array) $order_download['downloads'];
             $this->data['order_downloads'][$product_id]['product_name'] = $order_download['product_name'];
             $this->data['order_downloads'][$product_id]['product_thumbnail'] = $rl->getMainThumb('products', $product_id, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'));
             foreach ($downloads as $download_info) {
                 $download_info['order_status_id'] = $order_info['order_status_id'];
                 $attributes = $this->download->getDownloadAttributesValuesForDisplay($download_info['download_id']);
                 $order_product_id = $download_info['order_product_id'];
                 $is_file = $this->download->isFileAvailable($download_info['filename']);
                 foreach ($download_info['download_history'] as &$h) {
                     $h['time'] = dateISO2Display($h['time'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
                 }
                 unset($h);
                 $status_text = $this->model_catalog_download->getTextStatusForOrderDownload($download_info);
                 if ($status_text) {
                     $status = $status_text;
                 } else {
                     $status = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][status]', 'value' => $download_info['status'], 'style' => 'btn_switch'));
                 }
                 $this->data['order_downloads'][$product_id]['downloads'][] = array('name' => $download_info['name'], 'attributes' => $attributes, 'href' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $product_id . '&download_id=' . $download_info['download_id']), 'resource' => $download_info['filename'], 'is_file' => $is_file, 'mask' => $download_info['mask'], 'status' => $status, 'remaining' => $form->getFieldHtml(array('type' => 'input', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][remaining_count]', 'value' => $download_info['remaining_count'], 'placeholder' => '-', 'style' => 'small-field')), 'expire_date' => $form->getFieldHtml(array('type' => 'date', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][expire_date]', 'value' => $download_info['expire_date'] ? dateISO2Display($download_info['expire_date']) : '', 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'style' => 'medium-field')), 'download_history' => $download_info['download_history']);
                 // exclude downloads from multivalue list. why we need relate recursion?
                 $this->session->data['multivalue_excludes'][] = $download_info['download_id'];
             }
             $this->data['order_downloads'][$product_id]['push'] = $form->getFieldHtml(array('id' => 'popup' . $product_id, 'type' => 'multivalue', 'name' => 'popup' . $product_id, 'title' => $this->language->get('text_select_from_list'), 'selected_name' => 'push[' . $order_product_id . ']', 'selected' => "{}", 'content_url' => $this->html->getSecureUrl('catalog/download_listing', '&form_name=orderFrm&multivalue_hidden_id=popup' . $product_id), 'postvars' => '', 'return_to' => '', 'popup_height' => 708, 'text' => array('selected' => $this->language->get('text_count_selected'), 'edit' => $this->language->get('text_save_edit'), 'apply' => $this->language->get('text_apply'), 'save' => $this->language->get('text_add'), 'reset' => $this->language->get('button_reset'))));
         }
     }
     $this->view->batchAssign($this->data);
     $this->view->assign('help_url', $this->gen_help_url('order_files'));
     $this->processTemplate('pages/sale/order_files.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 5
0
 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');
 }
Ejemplo n.º 6
0
 public function getHtml()
 {
     if (!isset($this->default)) {
         $this->default = '';
     }
     if ($this->value == '' && !empty($this->default)) {
         $this->value = $this->default;
     }
     $this->element_id = preg_replace('/[\\[+\\]+]/', '_', $this->element_id);
     $this->view->batchAssign(array('name' => $this->name, 'id' => $this->element_id, 'type' => 'text', 'value' => str_replace('"', '&quot;', $this->value), 'default' => $this->default, 'attr' => 'aform_field_type="date" ' . $this->attr . ' data-aform-field-type="captcha"', 'required' => $this->required, 'style' => $this->style, 'dateformat' => $this->dateformat ? $this->dateformat : format4Datepicker($this->data['registry']->get('language')->get('date_format_short')), 'highlight' => $this->highlight));
     if (!empty($this->help_url)) {
         $this->view->assign('help_url', $this->help_url);
     }
     $return = $this->view->fetch('form/date.tpl');
     return $return;
 }
Ejemplo n.º 7
0
 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__);
 }
Ejemplo n.º 8
0
 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');
 }
Ejemplo n.º 9
0
 public function files()
 {
     $this->data = array();
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     if (has_value($this->session->data['error'])) {
         $this->data['error']['warning'] = $this->session->data['error'];
         unset($this->session->data['error']);
     }
     if (isset($this->request->get['order_id'])) {
         $order_id = $this->request->get['order_id'];
     } else {
         $order_id = 0;
     }
     if ($this->request->is_POST() && $this->_validateForm()) {
         if (has_value($this->request->post['downloads'])) {
             $data = $this->request->post['downloads'];
             $this->loadModel('catalog/download');
             foreach ($data as $order_download_id => $item) {
                 if (isset($item['expire_date'])) {
                     $item['expire_date'] = $item['expire_date'] ? dateDisplay2ISO($item['expire_date'], $this->language->get('date_format_short')) : '';
                 }
                 $this->model_catalog_download->editOrderDownload($order_download_id, $item);
             }
         }
         //add download to order
         if (has_value($this->request->post['push'])) {
             $this->load->library('json');
             foreach ($this->request->post['push'] as $order_product_id => $download_id) {
                 if ($download_id) {
                     $download_info = $this->download->getDownloadInfo($download_id);
                     $download_info['attributes_data'] = serialize($this->download->getDownloadAttributesValues($download_id));
                     $this->download->addProductDownloadToOrder($order_product_id, $order_id, $download_info);
                 }
             }
         }
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']));
     }
     $order_info = $this->model_sale_order->getOrder($order_id);
     $this->data['order_info'] = $order_info;
     //set content language to order language ID.
     if ($this->language->getContentLanguageID() != $order_info['language_id']) {
         //reset content language
         $this->language->setCurrentContentLanguage($order_info['language_id']);
     }
     if (empty($order_info)) {
         $this->session->data['error'] = $this->language->get('error_order_load');
         $this->redirect($this->html->getSecureURL('sale/order'));
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => false));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']), 'text' => $this->language->get('heading_title') . ' #' . $order_info['order_id'], 'separator' => ' :: ', '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['heading_title'] = $this->language->get('heading_title') . ' #' . $order_info['order_id'];
     $this->data['token'] = $this->session->data['token'];
     $this->data['invoice_url'] = $this->html->getSecureURL('sale/invoice', '&order_id=' . (int) $this->request->get['order_id']);
     $this->data['button_invoice'] = $this->html->buildButton(array('name' => 'btn_invoice', 'text' => $this->language->get('text_invoice')));
     $this->data['invoice_generate'] = $this->html->getSecureURL('sale/invoice/generate');
     $this->data['category_products'] = $this->html->getSecureURL('product/product/category');
     $this->data['product_update'] = $this->html->getSecureURL('catalog/product/update');
     $this->data['order_id'] = $this->request->get['order_id'];
     $this->data['action'] = $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']);
     $this->data['cancel'] = $this->html->getSecureURL('sale/order');
     $this->_initTabs('files');
     $this->loadModel('localisation/order_status');
     $status = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']);
     if ($status) {
         $this->data['order_status'] = $status['name'];
     } else {
         $this->data['order_status'] = '';
     }
     $this->loadModel('sale/customer_group');
     $customer_group_info = $this->model_sale_customer_group->getCustomerGroup($order_info['customer_group_id']);
     if ($customer_group_info) {
         $this->data['customer_group'] = $customer_group_info['name'];
     } else {
         $this->data['customer_group'] = '';
     }
     $this->data['form_title'] = $this->language->get('edit_title_files');
     $this->data['update'] = $this->html->getSecureURL('listing_grid/order/update_field', '&id=' . $this->request->get['order_id']);
     $form = new AForm('HS');
     $form->setForm(array('form_name' => 'orderFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'orderFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'orderFrm', 'attr' => '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->loadModel('catalog/download');
     $all_downloads = $this->model_catalog_download->getDownloads();
     $options = array('' => $this->language->get('text_push_download'));
     foreach ($all_downloads as $d) {
         $options[$d['download_id']] = $d['name'] . ' (' . $d['mask'] . ')';
     }
     $this->addChild('pages/sale/order_summary', 'summary_form', 'pages/sale/order_summary.tpl');
     /** ORDER DOWNLOADS */
     $this->data['downloads'] = array();
     $order_downloads = $this->model_sale_order->getOrderDownloads($this->request->get['order_id']);
     if ($order_downloads) {
         $rl = new AResource('image');
         $this->loadModel('catalog/download');
         foreach ($order_downloads as $product_id => $order_download) {
             $downloads = (array) $order_download['downloads'];
             $this->data['order_downloads'][$product_id]['product_name'] = $order_download['product_name'];
             $this->data['order_downloads'][$product_id]['product_thumbnail'] = $rl->getMainThumb('products', $product_id, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'));
             foreach ($downloads as $download_info) {
                 $download_info['order_status_id'] = $order_info['order_status_id'];
                 $attributes = $this->download->getDownloadAttributesValuesForDisplay($download_info['download_id']);
                 $order_product_id = $download_info['order_product_id'];
                 $is_file = $this->download->isFileAvailable($download_info['filename']);
                 foreach ($download_info['download_history'] as &$h) {
                     $h['time'] = dateISO2Display($h['time'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
                 }
                 unset($h);
                 $status_text = $this->model_catalog_download->getTextStatusForOrderDownload($download_info);
                 if ($status_text) {
                     $status = $status_text;
                 } else {
                     $status = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][status]', 'value' => $download_info['status'], 'style' => 'btn_switch'));
                 }
                 $this->data['order_downloads'][$product_id]['downloads'][] = array('name' => $download_info['name'], 'attributes' => $attributes, 'href' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $product_id . '&download_id=' . $download_info['download_id']), 'resource' => $download_info['filename'], 'is_file' => $is_file, 'mask' => $download_info['mask'], 'status' => $status, 'remaining' => $form->getFieldHtml(array('type' => 'input', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][remaining_count]', 'value' => $download_info['remaining_count'], 'placeholder' => '-', 'style' => 'small-field')), 'expire_date' => $form->getFieldHtml(array('type' => 'date', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][expire_date]', 'value' => $download_info['expire_date'] ? dateISO2Display($download_info['expire_date']) : '', 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'style' => 'medium-field')), 'download_history' => $download_info['download_history']);
                 $this->data['order_downloads'][$product_id]['push_download'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'push[' . (int) $download_info['order_download_id'] . ']', 'value' => '', 'options' => $options, 'style' => 'chosen no-save', 'placeholder' => $this->language->get('text_push_download')));
             }
         }
     } else {
         $this->redirect($this->html->getSecureURL('sale/order/details', '&order_id=' . $this->request->get['order_id']));
     }
     $this->view->batchAssign($this->data);
     $this->view->assign('help_url', $this->gen_help_url('order_files'));
     $this->processTemplate('pages/sale/order_files.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 10
0
 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');
 }
Ejemplo n.º 11
0
 private function _getForm()
 {
     if (isset($this->request->get['product_id']) && $this->request->is_GET()) {
         $product_id = $this->request->get['product_id'];
         $product_info = $this->model_catalog_product->getProduct($product_id);
         $product_info['featured'] = $product_info['featured'] ? 1 : 0;
     }
     $this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($product_id);
     $this->data['error'] = $this->error;
     $this->data['cancel'] = $this->html->getSecureURL('catalog/product');
     $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('catalog/product'), 'text' => $product_id ? $this->language->get('text_edit') . '&nbsp;' . $this->language->get('text_product') . ' - ' . $this->data['product_description'][$this->session->data['content_language_id']]['name'] : $this->language->get('text_insert'), 'separator' => ' :: ', 'current' => true));
     $this->loadModel('catalog/category');
     $this->data['categories'] = array();
     $results = $this->model_catalog_category->getCategories(0, $this->session->data['current_store_id']);
     foreach ($results as $r) {
         $this->data['categories'][$r['category_id']] = $r['name'];
     }
     $this->loadModel('setting/store');
     $this->data['stores'] = array(0 => $this->language->get('text_default'));
     $results = $this->model_setting_store->getStores();
     foreach ($results as $r) {
         $this->data['stores'][$r['store_id']] = $r['name'];
     }
     $this->loadModel('catalog/manufacturer');
     $this->data['manufacturers'] = array(0 => $this->language->get('text_none'));
     $results = $this->model_catalog_manufacturer->getManufacturers();
     foreach ($results as $r) {
         $this->data['manufacturers'][$r['manufacturer_id']] = $r['name'];
     }
     $this->loadModel('localisation/stock_status');
     $this->data['stock_statuses'] = array();
     $results = $this->model_localisation_stock_status->getStockStatuses();
     foreach ($results as $r) {
         $this->data['stock_statuses'][$r['stock_status_id']] = $r['name'];
     }
     $this->loadModel('localisation/tax_class');
     $this->data['tax_classes'] = array(0 => $this->language->get('text_none'));
     $results = $this->model_localisation_tax_class->getTaxClasses();
     foreach ($results as $r) {
         $this->data['tax_classes'][$r['tax_class_id']] = $r['title'];
     }
     $this->loadModel('localisation/weight_class');
     $this->data['weight_classes'] = array();
     $results = $this->model_localisation_weight_class->getWeightClasses();
     foreach ($results as $r) {
         $this->data['weight_classes'][$r['weight_class_id']] = $r['title'];
     }
     $this->loadModel('localisation/length_class');
     $this->data['length_classes'] = array();
     $results = $this->model_localisation_length_class->getLengthClasses();
     foreach ($results as $r) {
         $this->data['length_classes'][$r['length_class_id']] = $r['title'];
     }
     $fields = array('product_category', 'featured', 'product_store', 'model', 'call_to_order', 'sku', 'location', 'keyword', 'image', 'manufacturer_id', 'shipping', 'ship_individually', 'shipping_price', 'free_shipping', 'quantity', 'minimum', 'maximum', 'subtract', 'sort_order', 'stock_status_id', 'price', 'cost', 'status', 'tax_class_id', 'weight', 'weight_class_id', 'length', 'width', 'height');
     foreach ($fields as $f) {
         if (isset($this->request->post[$f])) {
             $this->data[$f] = $this->request->post[$f];
         } elseif (isset($product_info)) {
             $this->data[$f] = $product_info[$f];
         }
     }
     if (isset($this->request->post['product_category'])) {
         $this->data['product_category'] = $this->request->post['product_category'];
     } elseif (isset($product_info)) {
         $this->data['product_category'] = $this->model_catalog_product->getProductCategories($product_id);
     } else {
         $this->data['product_category'] = array();
     }
     if (isset($this->request->post['product_store'])) {
         $this->data['product_store'] = $this->request->post['product_store'];
     } elseif (isset($product_info)) {
         $this->data['product_store'] = $this->model_catalog_product->getProductStores($product_id);
     } else {
         $this->data['product_store'] = array(0);
     }
     if (isset($this->request->post['product_description'])) {
         $this->data['product_description'] = $this->request->post['product_description'];
     } elseif (isset($product_info)) {
         $this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($product_id, $this->session->data['content_language_id']);
     } else {
         $this->data['product_description'] = array();
     }
     if (isset($this->request->post['featured'])) {
         $this->data['featured'] = $this->request->post['featured'];
     } elseif (isset($product_info)) {
         $this->data['featured'] = $product_info['featured'];
     } else {
         $this->data['featured'] = 0;
     }
     if (isset($this->request->post['product_tags'])) {
         $this->data['product_tags'] = $this->request->post['product_tags'];
     } elseif (isset($product_info)) {
         $this->data['product_tags'] = $this->model_catalog_product->getProductTags($product_id, $this->session->data['content_language_id']);
     } else {
         $this->data['product_tags'] = '';
     }
     $this->loadModel('tool/image');
     if (isset($product_info) && $product_info['image'] && file_exists(DIR_IMAGE . $product_info['image'])) {
         $this->data['preview'] = $this->model_tool_image->resize($product_info['image'], 100, 100);
     } else {
         $this->data['preview'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);
     }
     if ($this->data['stock_status_id'] == '') {
         $this->data['stock_status_id'] = $this->config->get('config_stock_status_id');
     }
     if (isset($this->request->post['date_available'])) {
         $this->data['date_available'] = $this->request->post['date_available'];
     } elseif (isset($product_info)) {
         $this->data['date_available'] = $product_info['date_available'];
     } else {
         $this->data['date_available'] = dateInt2ISO(time() - 86400);
     }
     $weight_info = $this->model_localisation_weight_class->getWeightClassDescriptionByUnit($this->config->get('config_weight_class'));
     if (isset($this->request->post['weight_class_id'])) {
         $this->data['weight_class_id'] = $this->request->post['weight_class_id'];
     } elseif (isset($product_info)) {
         $this->data['weight_class_id'] = $product_info['weight_class_id'];
     } elseif (isset($weight_info)) {
         $this->data['weight_class_id'] = $weight_info['weight_class_id'];
     } else {
         $this->data['weight_class_id'] = '';
     }
     $length_info = $this->model_localisation_length_class->getLengthClassDescriptionByUnit($this->config->get('config_length_class'));
     if (isset($this->request->post['length_class_id'])) {
         $this->data['length_class_id'] = $this->request->post['length_class_id'];
     } elseif (isset($product_info)) {
         $this->data['length_class_id'] = $product_info['length_class_id'];
     } elseif (isset($length_info)) {
         $this->data['length_class_id'] = $length_info['length_class_id'];
     } else {
         $this->data['length_class_id'] = '';
     }
     if ($this->data['status'] == '') {
         $this->data['status'] = 1;
     }
     if ($this->data['quantity'] == '') {
         $this->data['quantity'] = 1;
     }
     if ($this->data['minimum'] == '') {
         $this->data['minimum'] = 1;
     }
     if ($this->data['sort_order'] == '') {
         $this->data['sort_order'] = 1;
     }
     $this->data['active'] = 'details';
     if (!isset($product_id)) {
         $this->data['action'] = $this->html->getSecureURL('catalog/product/insert');
         $this->data['form_title'] = $this->language->get('text_insert') . $this->language->get('text_product');
         $this->data['update'] = '';
         $form = new AForm('ST');
         $this->data['summary_form'] = '';
     } else {
         $this->data['action'] = $this->html->getSecureURL('catalog/product/update', '&product_id=' . $product_id);
         $this->data['form_title'] = $this->language->get('text_edit') . '&nbsp;' . $this->language->get('text_product');
         $this->data['update'] = $this->html->getSecureURL('listing_grid/product/update_field', '&id=' . $product_id);
         $form = new AForm('HS');
         $this->data['active'] = 'general';
         //load tabs controller
         $tabs_obj = $this->dispatch('pages/catalog/product_tabs', array($this->data));
         $this->data['product_tabs'] = $tabs_obj->dispatchGetOutput();
         unset($tabs_obj);
         $this->addChild('pages/catalog/product_summary', 'summary_form', 'pages/catalog/product_summary.tpl');
     }
     $form->setForm(array('form_name' => 'productFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'productFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'productFrm', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"'));
     $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']['general']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => $this->data['status'], 'style' => 'btn_switch btn-group-sm', 'help_url' => $this->gen_help_url('?p=62')));
     $this->data['form']['fields']['general']['featured'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'featured', 'value' => $this->data['featured'], 'style' => 'btn_switch btn-group-sm', 'help_url' => $this->gen_help_url('?p=62')));
     $this->data['form']['fields']['general']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'product_description[name]', 'value' => $this->data['product_description']['name'], 'required' => true, 'help_url' => $this->gen_help_url('?p=62')));
     $this->data['form']['fields']['general']['description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'product_description[description]', 'value' => $this->data['product_description']['description']));
     $this->data['form']['fields']['general']['meta_keywords'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'product_description[meta_keywords]', 'value' => $this->data['product_description']['meta_keywords'], 'help_url' => $this->gen_help_url('?p=62')));
     $this->data['form']['fields']['general']['meta_description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'product_description[meta_description]', 'value' => $this->data['product_description']['meta_description']));
     $this->data['form']['fields']['general']['blurb'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'product_description[blurb]', 'value' => $this->data['product_description']['blurb']));
     $this->data['form']['fields']['general']['tags'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'product_tags', 'value' => $this->data['product_tags']));
     $this->data['form']['fields']['general']['category'] = $form->getFieldHtml(array('type' => 'checkboxgroup', 'name' => 'product_category[]', 'value' => $this->data['product_category'], 'options' => $this->data['categories'], 'style' => 'chosen', 'placeholder' => $this->language->get('text_select_category')));
     $this->data['form']['fields']['general']['store'] = $form->getFieldHtml(array('type' => 'checkboxgroup', 'name' => 'product_store[]', 'value' => $this->data['product_store'], 'options' => $this->data['stores'], 'style' => 'chosen', 'placeholder' => $this->language->get('entry_store')));
     $this->data['form']['fields']['data']['manufacturer'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'manufacturer_id', 'value' => $this->data['manufacturer_id'], 'options' => $this->data['manufacturers'], 'style' => 'chosen', 'placeholder' => $this->language->get('entry_manufacturer')));
     $this->data['form']['fields']['data']['model'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'model', 'value' => $this->data['model'], 'required' => false));
     $this->data['form']['fields']['data']['call_to_order'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'call_to_order', 'value' => $this->data['call_to_order'], 'style' => 'btn_switch btn-group-sm', 'help_url' => $this->gen_help_url('?p=62')));
     $this->data['form']['fields']['data']['price'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'price', 'value' => moneyDisplayFormat($this->data['price']), 'style' => 'small-field'));
     $this->data['form']['fields']['data']['cost'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'cost', 'value' => moneyDisplayFormat($this->data['cost']), 'style' => 'small-field'));
     $this->data['form']['fields']['data']['tax_class'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'tax_class_id', 'value' => $this->data['tax_class_id'], 'options' => $this->data['tax_classes'], 'help_url' => $this->gen_help_url('?p=62'), 'style' => 'medium-field'));
     $this->data['form']['fields']['data']['subtract'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'subtract', 'value' => $this->data['subtract'], 'options' => array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no')), 'help_url' => $this->gen_help_url('?p=62'), 'style' => 'medium-field'));
     $this->data['form']['fields']['data']['quantity'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'quantity', 'value' => (int) $this->data['quantity'], 'style' => 'col-xs-1 small-field'));
     $this->data['form']['fields']['data']['minimum'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'minimum', 'value' => (int) $this->data['minimum'], 'style' => 'small-field'));
     $this->data['form']['fields']['data']['maximum'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'maximum', 'value' => (int) $this->data['maximum'], 'style' => 'small-field'));
     $this->data['form']['fields']['data']['stock_status'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'stock_status_id', 'value' => $this->data['stock_status_id'], 'options' => $this->data['stock_statuses'], 'style' => 'small-field'));
     $this->data['form']['fields']['data']['sku'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sku', 'value' => $this->data['sku'], 'help_url' => $this->gen_help_url('?p=62')));
     $this->data['form']['fields']['data']['location'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'location', 'value' => $this->data['location']));
     //prepend button to generate keyword
     $this->data['keyword_button'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'generate_seo_keyword', 'text' => $this->language->get('button_generate'), 'attr' => 'type="button"', 'style' => 'btn btn-info'));
     $this->data['generate_seo_url'] = $this->html->getSecureURL('common/common/getseokeyword', '&object_key_name=product_id&id=' . $product_id);
     $this->data['form']['fields']['data']['keyword'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'keyword', 'value' => $this->data['keyword'], 'help_url' => $this->gen_help_url('?p=62'), 'attr' => ' gen-value="' . SEOEncode($this->data['product_description']['name']) . '" '));
     $this->data['form']['fields']['data']['date_available'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'date_available', 'value' => dateISO2Display($this->data['date_available']), 'default' => dateNowDisplay(), 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'style' => 'small-field'));
     $this->data['form']['fields']['data']['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'value' => $this->data['sort_order'], 'style' => 'tiny-field'));
     $this->data['form']['fields']['data']['shipping'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'shipping', 'style' => 'btn_switch btn-group-sm', 'value' => isset($this->data['shipping']) ? $this->data['shipping'] : 1));
     $this->data['form']['fields']['data']['free_shipping'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'free_shipping', 'style' => 'btn_switch btn-group-sm', 'value' => isset($this->data['free_shipping']) ? $this->data['free_shipping'] : 0));
     $this->data['form']['fields']['data']['ship_individually'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'ship_individually', 'style' => 'btn_switch btn-group-sm', 'value' => isset($this->data['ship_individually']) ? $this->data['ship_individually'] : 0));
     $this->data['form']['fields']['data']['shipping_price'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'shipping_price', 'value' => moneyDisplayFormat($this->data['shipping_price']), 'style' => 'tiny-field'));
     $this->data['form']['fields']['data']['length'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'length', 'value' => $this->data['length'], 'style' => 'tiny-field'));
     $this->data['form']['fields']['data']['width'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'width', 'value' => $this->data['width'], 'attr' => ' autocomplete="false"', 'style' => 'tiny-field'));
     $this->data['form']['fields']['data']['height'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'height', 'value' => $this->data['height'], 'attr' => ' autocomplete="false"', 'style' => 'tiny-field'));
     if ($product_id && !$this->data['length_class_id']) {
         $this->data['length_classes'][0] = $this->language->get('text_none');
     }
     $this->data['form']['fields']['data']['length_class'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'length_class_id', 'value' => $this->data['length_class_id'], 'options' => $this->data['length_classes'], 'style' => 'small-field'));
     if ($product_id && $this->data['shipping'] && (!(double) $this->data['weight'] || !$this->data['weight_class_id']) && !(double) $this->data['shipping_price']) {
         if (!$this->data['weight_class_id']) {
             $this->data['error']['weight_class'] = $this->language->get('error_weight_class');
         }
         if (!(double) $this->data['weight']) {
             $this->data['error']['weight'] = $this->language->get('error_weight_value');
         }
     }
     if ($product_id && !$this->data['weight_class_id']) {
         $this->data['weight_classes'][0] = $this->language->get('text_none');
     }
     $this->data['form']['fields']['data']['weight'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'weight', 'value' => $this->data['weight'], 'attr' => ' autocomplete="false"', 'style' => 'tiny-field'));
     $this->data['form']['fields']['data']['weight_class'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'weight_class_id', 'value' => $this->data['weight_class_id'], 'options' => $this->data['weight_classes'], 'style' => 'small-field'));
     $this->data['product_id'] = $product_id;
     if ($product_id && $this->config->get('config_embed_status')) {
         $this->data['embed_url'] = $this->html->getSecureURL('common/do_embed/product', '&product_id=' . $product_id);
     }
     $this->data['text_clone'] = $this->language->get('text_clone');
     $this->data['clone_url'] = $this->html->getSecureURL('catalog/product/copy', '&product_id=' . $this->request->get['product_id']);
     $this->data['form_language_switch'] = $this->html->getContentLanguageSwitcher();
     $this->data['language_id'] = $this->session->data['content_language_id'];
     $this->data['language_code'] = $this->session->data['language'];
     $this->data['help_url'] = $this->gen_help_url('?p=62');
     $this->data['rl'] = $this->html->getSecureURL('common/resource_library', '&object_name=&object_id&type=image&mode=url');
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/catalog/product_form.tpl');
 }
 private function _getForm()
 {
     $view = new AView($this->registry, 0);
     $view->batchAssign($this->language->getASet('catalog/product'));
     $view->assign('error_warning', $this->error['warning']);
     $view->assign('success', $this->session->data['success']);
     if (isset($this->session->data['success'])) {
         unset($this->session->data['success']);
     }
     $this->data = array();
     $this->data['error'] = $this->error;
     $this->data['cancel'] = $this->html->getSecureURL('catalog/product_promotions', '&product_id=' . $this->request->get['product_id']);
     $this->data['active'] = 'promotions';
     $this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']);
     $this->data['heading_title'] = $this->language->get('text_edit') . '&nbsp;' . $this->language->get('text_product') . ' - ' . $this->data['product_description'][$this->session->data['content_language_id']]['name'];
     if (isset($this->request->get['product_discount_id']) && $this->request->is_GET()) {
         $discount_info = $this->model_catalog_product->getProductDiscount($this->request->get['product_discount_id']);
         if ($discount_info['date_start'] == '0000-00-00') {
             $discount_info['date_start'] = '';
         }
         if ($discount_info['date_end'] == '0000-00-00') {
             $discount_info['date_end'] = '';
         }
     }
     $this->loadModel('sale/customer_group');
     $results = $this->model_sale_customer_group->getCustomerGroups();
     $this->data['customer_groups'] = array();
     foreach ($results as $r) {
         $this->data['customer_groups'][$r['customer_group_id']] = $r['name'];
     }
     $fields = array('customer_group_id', 'quantity', 'priority', 'price', 'date_start', 'date_end');
     foreach ($fields as $f) {
         if (isset($this->request->post[$f])) {
             $this->data[$f] = $this->request->post[$f];
             if (in_array($f, array('date_start', 'date_end'))) {
                 $this->data[$f] = dateDisplay2ISO($this->data[$f], $this->language->get('date_format_short'));
             }
         } elseif (isset($discount_info)) {
             $this->data[$f] = $discount_info[$f];
         } else {
             $this->data[$f] = '';
         }
     }
     if (!isset($this->request->get['product_discount_id'])) {
         $this->data['action'] = $this->html->getSecureURL('catalog/product_promotions', '&product_id=' . $this->request->get['product_id']);
         $this->data['form_title'] = $this->language->get('text_insert') . '&nbsp;' . $this->language->get('entry_discount');
         $this->data['update'] = '';
         $form = new AForm('ST');
     } else {
         $this->data['action'] = $this->html->getSecureURL('catalog/product_promotions', '&product_id=' . $this->request->get['product_id'] . '&product_discount_id=' . $this->request->get['product_discount_id']);
         $this->data['form_title'] = $this->language->get('text_edit') . '&nbsp;' . $this->language->get('entry_discount');
         $this->data['update'] = $this->html->getSecureURL('listing_grid/product/update_discount_field', '&id=' . $this->request->get['product_discount_id']);
         $form = new AForm('HS');
     }
     $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['form_title'], 'separator' => ' :: '));
     $form->setForm(array('form_name' => 'productFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'productFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'productFrm', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true"  class="aform form-horizontal"')) . $form->getFieldHtml(array('type' => 'hidden', 'name' => 'promotion_type', 'value' => 'discount'));
     $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']['customer_group'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'customer_group_id', 'value' => $this->data['customer_group_id'], 'options' => $this->data['customer_groups']));
     $this->data['form']['fields']['quantity'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'quantity', 'value' => $this->data['quantity'], 'style' => 'small-field'));
     $this->data['form']['fields']['priority'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'priority', 'value' => $this->data['priority'], 'style' => 'small-field'));
     $this->data['form']['fields']['price'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'price', 'value' => moneyDisplayFormat($this->data['price']), 'style' => 'tiny-field'));
     $this->data['js_date_format'] = format4Datepicker($this->language->get('date_format_short'));
     $this->data['form']['fields']['date_start'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'date_start', 'value' => dateISO2Display($this->data['date_start'], $this->language->get('date_format_short')), 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'style' => 'small-field'));
     $this->data['form']['fields']['date_end'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'date_end', 'value' => dateISO2Display($this->data['date_end'], $this->language->get('date_format_short')), 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'style' => 'small-field'));
     $view->assign('help_url', $this->gen_help_url('product_discount_edit'));
     $view->batchAssign($this->data);
     $this->data['response'] = $view->fetch('responses/catalog/product_promotion_form.tpl');
     $this->response->setOutput($this->data['response']);
 }
Ejemplo n.º 13
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');
 }
Ejemplo n.º 14
0
 private function _getForm()
 {
     $this->view->assign('error_warning', $this->error['warning']);
     $this->view->assign('success', $this->session->data['success']);
     if (isset($this->session->data['success'])) {
         unset($this->session->data['success']);
     }
     $this->data = array();
     $this->data['error'] = $this->error;
     $this->data['cancel'] = $this->html->getSecureURL('catalog/product_promotions', '&product_id=' . $this->request->get['product_id']);
     $this->data['active'] = 'promotions';
     //load tabs controller
     $tabs_obj = $this->dispatch('pages/catalog/product_tabs', array($this->data));
     $this->data['product_tabs'] = $tabs_obj->dispatchGetOutput();
     unset($tabs_obj);
     $this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']);
     $this->data['heading_title'] = $this->language->get('text_edit') . '&nbsp;' . $this->language->get('text_product') . ' - ' . $this->data['product_description'][$this->session->data['content_language_id']]['name'];
     $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('catalog/product'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product/update', '&product_id=' . $this->request->get['product_id']), 'text' => $this->data['heading_title'], 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product_promotions', '&product_id=' . $this->request->get['product_id']), 'text' => $this->language->get('tab_promotions'), 'separator' => ' :: '));
     if (isset($this->request->get['product_discount_id']) && $this->request->server['REQUEST_METHOD'] != 'POST') {
         $discount_info = $this->model_catalog_product->getProductDiscount($this->request->get['product_discount_id']);
         if ($discount_info['date_start'] == '0000-00-00') {
             $discount_info['date_start'] = '';
         }
         if ($discount_info['date_end'] == '0000-00-00') {
             $discount_info['date_end'] = '';
         }
     }
     $this->loadModel('sale/customer_group');
     $results = $this->model_sale_customer_group->getCustomerGroups();
     $this->data['customer_groups'] = array();
     foreach ($results as $r) {
         $this->data['customer_groups'][$r['customer_group_id']] = $r['name'];
     }
     $fields = array('customer_group_id', 'quantity', 'priority', 'price', 'date_start', 'date_end');
     foreach ($fields as $f) {
         if (isset($this->request->post[$f])) {
             $this->data[$f] = $this->request->post[$f];
             if (in_array($f, array('date_start', 'date_end'))) {
                 $this->data[$f] = dateDisplay2ISO($this->data[$f], $this->language->get('date_format_short'));
             }
         } elseif (isset($discount_info)) {
             $this->data[$f] = $discount_info[$f];
         } else {
             $this->data[$f] = '';
         }
     }
     if (!isset($this->request->get['product_discount_id'])) {
         $this->data['action'] = $this->html->getSecureURL('catalog/product_discount/insert', '&product_id=' . $this->request->get['product_id']);
         $this->data['form_title'] = $this->language->get('text_insert') . '&nbsp;' . $this->language->get('entry_discount');
         $this->data['update'] = '';
         $form = new AForm('ST');
     } else {
         $this->data['action'] = $this->html->getSecureURL('catalog/product_discount/update', '&product_id=' . $this->request->get['product_id'] . '&product_discount_id=' . $this->request->get['product_discount_id']);
         $this->data['form_title'] = $this->language->get('text_edit') . '&nbsp;' . $this->language->get('entry_discount');
         $this->data['update'] = $this->html->getSecureURL('listing_grid/product/update_discount_field', '&id=' . $this->request->get['product_discount_id']);
         $form = new AForm('HS');
     }
     $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['form_title'], 'separator' => ' :: '));
     $form->setForm(array('form_name' => 'productFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'productFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'productFrm', 'action' => $this->data['action'], 'attr' => 'confirm-exit="true"'));
     $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']['customer_group'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'customer_group_id', 'value' => $this->data['customer_group_id'], 'options' => $this->data['customer_groups']));
     $this->data['form']['fields']['quantity'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'quantity', 'value' => $this->data['quantity'], 'style' => 'small-field'));
     $this->data['form']['fields']['priority'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'priority', 'value' => $this->data['priority'], 'style' => 'small-field'));
     $this->data['form']['fields']['price'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'price', 'value' => moneyDisplayFormat($this->data['price'])));
     $this->data['js_date_format'] = format4Datepicker($this->language->get('date_format_short'));
     $this->data['form']['fields']['date_start'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_start', 'value' => dateISO2Display($this->data['date_start'], $this->language->get('date_format_short')), 'style' => 'date'));
     $this->data['form']['fields']['date_end'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_end', 'value' => dateISO2Display($this->data['date_end'], $this->language->get('date_format_short')), 'style' => 'date'));
     $this->addChild('pages/catalog/product_summary', 'summary_form', 'pages/catalog/product_summary.tpl');
     $this->view->assign('help_url', $this->gen_help_url('product_discount_edit'));
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/catalog/product_discount_form.tpl');
 }