コード例 #1
0
ファイル: product.php プロジェクト: vglide/abantecart-src
 /**
  * Form to edit product from order
  */
 public function orderProductForm()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('catalog/product');
     $this->loadModel('sale/order');
     $this->loadLanguage('catalog/product');
     $this->loadLanguage('sale/order');
     $this->load->library('json');
     $elements_with_options = HtmlElementFactory::getElementsWithOptions();
     $order_product_id = (int) $this->request->get['order_product_id'];
     $order_id = (int) $this->request->get['order_id'];
     $order_info = $this->model_sale_order->getOrder($order_id);
     $tax = new ATax($this->registry);
     $tax->setZone($order_info['country_id'], $order_info['zone_id']);
     $product_id = (int) $this->request->get['product_id'];
     $preset_values = array();
     if ($order_product_id) {
         //if unknown product_id but order_product_id we know
         $order_product_info = $this->model_sale_order->getOrderProducts($order_id, $order_product_id);
         $preset_values['price'] = $this->currency->format($order_product_info[0]['price'], $order_info['currency'], $order_info['value'], false);
         $preset_values['total'] = $this->currency->format($order_product_info[0]['price'] * $order_product_info[0]['quantity'], $order_info['currency'], $order_info['value'], false);
         $preset_values['quantity'] = $order_product_info[0]['quantity'];
         if (!$product_id) {
             $product_id = $order_product_info[0]['product_id'];
         }
         $product_info = $this->model_catalog_product->getProduct($product_id);
         $order_product_options = $this->model_sale_order->getOrderOptions($order_id, $order_product_id);
         foreach ($order_product_options as $v) {
             if ($v['element_type'] == 'R') {
                 $preset_values[$v['product_option_id']] = $v['product_option_value_id'];
             } elseif (in_array($v['element_type'], $elements_with_options)) {
                 $preset_values[$v['product_option_id']][] = $v['product_option_value_id'];
             } else {
                 $preset_values[$v['product_option_id']] = $v['value'];
             }
         }
         $this->data['text_title'] = $this->language->get('text_edit_order_product');
         $form_action = $this->html->getSecureURL('sale/order/update', '&order_id=' . $order_id . '&order_product_id=' . $order_product_id);
     } else {
         $product_info = $this->model_catalog_product->getProduct($product_id);
         $this->data['text_title'] = sprintf($this->language->get('text_add_product_to_order'), $order_id);
         $preset_values['quantity'] = $product_info['minimum'] ? $product_info['minimum'] : 1;
         $preset_values['price'] = $this->currency->format($product_info['price'], $order_info['currency'], $order_info['value'], false);
         $preset_values['total'] = $this->currency->format($product_info['price'] * $preset_values['quantity'], $order_info['currency'], $order_info['value'], false);
         $form_action = $this->html->getSecureURL('sale/order/update', '&order_id=' . $order_id . '&product_id=' . $product_id);
     }
     $this->data['product_href'] = $this->html->getSecureURL('catalog/product/update', '&product_id=' . $product_id);
     $form = new AForm('HT');
     $form->setForm(array('form_name' => 'orderProductFrm'));
     $this->data['form']['id'] = 'orderProductFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'orderProductFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $form_action));
     $this->data['text_title'] .= ' - ' . $product_info['name'];
     // Prepare options and values for display
     $product_options = $this->model_catalog_product->getOrderProductOptions($product_id);
     $option_values_prices = array();
     foreach ($product_options as $option) {
         if (in_array($option['element_type'], array('U'))) {
             continue;
         }
         //skip files for now. TODO: add edit file-option in the future
         $values = $prices = array();
         $price = $preset_value = $default_value = '';
         foreach ($option['option_value'] as $option_value) {
             //default value
             $default_value = $option_value['default'] && !$order_product_id ? $option_value['product_option_value_id'] : $default_value;
             //early saved value
             $preset_value = $preset_values[$option['product_option_id']];
             //when adds new product in the order
             if (!$order_product_id) {
                 if ($option_value['default'] == 1) {
                     $preset_value = $option_value['product_option_value_id'];
                 } elseif (!in_array($option['element_type'], $elements_with_options)) {
                     $preset_value = $option_value['name'];
                 }
             }
             //Apply option price modifier
             if ($option_value['prefix'] == '%') {
                 $price = $tax->calculate($product_info['price'] * $option_value['price'] / 100, $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
             } else {
                 $price = $tax->calculate($option_value['price'], $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
             }
             if ($price != 0) {
                 $price = $this->currency->format($price);
             } else {
                 $price = '';
             }
             //Check stock and status
             $opt_stock_message = '';
             if ($option_value['subtract']) {
                 if ($option_value['quantity'] <= 0) {
                     //show out of stock message
                     $opt_stock_message = ' (' . $this->language->get('text_product_out_of_stock') . ')';
                 } else {
                     if ($this->config->get('config_stock_display')) {
                         $opt_stock_message = ' (' . $option_value['quantity'] . " " . $this->language->get('text_product_in_stock') . ')';
                     }
                 }
             }
             $values[$option_value['product_option_value_id']] = $option_value['name'] . ' ' . $price . ' ' . $opt_stock_message;
         }
         //if not values are build, nothing to show
         if (count($values)) {
             //add price to option name if it is not element with options
             if (!in_array($option['element_type'], $elements_with_options)) {
                 $option['name'] .= ' <small>' . $price . '</small>';
                 if ($opt_stock_message) {
                     $option['name'] .= '<br />' . $opt_stock_message;
                 }
             }
             //set default selection is nothing selected
             if (!has_value($preset_value) && $option['element_type'] != 'C') {
                 if (has_value($default_value)) {
                     $preset_value = $default_value;
                 }
             }
             //show hidden option for admin
             if ($option['html_type'] == 'hidden') {
                 $option['html_type'] = 'input';
             }
             $value = $preset_value;
             //for checkbox with empty value
             if ($value == '' && $option['element_type'] == 'C') {
                 $value = $default_value;
                 $value = $value == '' ? 1 : $value;
             }
             $option_data = array('type' => $option['html_type'], 'name' => !in_array($option['element_type'], HtmlElementFactory::getMultivalueElements()) ? 'product[0][option][' . $option['product_option_id'] . ']' : 'product[0][option][' . $option['product_option_id'] . '][]', 'value' => $value, 'options' => $values, 'placeholder' => $option['option_placeholder'], 'regexp_pattern' => $option['regexp_pattern'], 'error_text' => $option['error_text'], 'attr' => ' data-option-id ="' . $option['product_option_id'] . '"');
             if ($option['element_type'] == 'C') {
                 // note: 0 and 1 must be stirng to prevent collision with 'yes'. (in php 'yes'==1) ;-)
                 $option_data['label_text'] = !in_array($value, array('0', '1')) ? $value : '';
                 $option_data['checked'] = $preset_value ? true : false;
             }
             $options[] = array('name' => $option['name'], 'html' => $form->getFieldHtml($option_data));
         }
     }
     $this->data['options'] = $options;
     // main product image
     $resource = new AResource('image');
     $thumbnail = $resource->getMainThumb('products', $product_id, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'), true);
     $this->data['image'] = $thumbnail;
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $order_product_id ? $this->language->get('button_save') : $this->language->get('button_add')));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel')));
     $this->data['form']['fields']['price'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'product[0][price]', 'value' => $preset_values['price'], 'attr' => ' readonly'));
     if (!$options && $product_info['subtract']) {
         if ($product_info['quantity']) {
             $this->data['column_quantity'] = $this->language->get('column_quantity') . ' (' . $this->language->get('text_product_in_stock') . ': ' . $product_info['quantity'] . ')';
         } else {
             $this->data['column_quantity'] = $this->language->get('column_quantity') . ' (' . $this->language->get('text_product_out_of_stock') . ')';
         }
     }
     $this->data['form']['fields']['quantity'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'product[0][quantity]', 'value' => $preset_values['quantity'], 'attr' => ' size="4"'));
     $this->data['form']['fields']['total'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'product[0][total]', 'value' => $preset_values['total'], 'attr' => 'readonly'));
     $this->data['form']['fields']['product_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'product_id', 'value' => $product_id));
     $this->data['form']['fields']['order_product_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'order_product_id', 'value' => (int) $order_product_id));
     //url to storefront response controller. Note: if admin under ssl - use https for url and otherwise
     $order_store_id = $order_info['store_id'];
     $this->loadModel('setting/store');
     $store_info = $this->model_setting_store->getStore($order_store_id);
     if (HTTPS === true && $store_info['config_ssl_url']) {
         $total_calc_url = $store_info['config_ssl_url'] . 'index.php?rt=r/product/product/calculateTotal';
     } elseif (HTTPS === true && !$store_info['config_ssl_url']) {
         $total_calc_url = str_replace('http://', 'https://', $store_info['config_url']) . 'index.php?rt=r/product/product/calculateTotal';
     } else {
         $total_calc_url = $store_info['config_url'] . 'index.php?rt=r/product/product/calculateTotal';
     }
     $this->data['total_calc_url'] = $total_calc_url;
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->view->batchAssign($this->data);
     $this->processTemplate('responses/product/product_form.tpl');
 }
コード例 #2
0
 /**
  * method for validation of data based on global attributes requirements
  * @param array $data - usually it's a $_POST
  * @return array - array with error text for each of invalid field data
  */
 public function validateAttributeData($data = array())
 {
     $errors = array();
     $this->load->language('catalog/attribute');
     // load language for file upload text errors
     foreach ($this->attributes as $attribute_info) {
         // for multivalue required fields
         if (in_array($attribute_info['element_type'], HtmlElementFactory::getMultivalueElements()) && !sizeof($data[$attribute_info['attribute_id']]) && $attribute_info['required'] == '1') {
             $errors[$attribute_info['attribute_id']] = $this->language->get('entry_required') . ' ' . $attribute_info['name'];
         }
         // for required string values
         if ($attribute_info['required'] == '1' && !in_array($attribute_info['element_type'], array('K', 'U'))) {
             if (!is_array($data[$attribute_info['attribute_id']])) {
                 $data[$attribute_info['attribute_id']] = trim($data[$attribute_info['attribute_id']]);
                 if ($data[$attribute_info['attribute_id']] == '') {
                     //if empty string!
                     $errors[$attribute_info['attribute_id']] = $this->language->get('entry_required') . ' ' . $attribute_info['name'];
                 }
             } else {
                 if (!$data[$attribute_info['attribute_id']]) {
                     // if empty array
                     $errors[$attribute_info['attribute_id']] = $this->language->get('entry_required') . ' ' . $attribute_info['name'];
                 }
             }
         }
         // check by regexp
         if (has_value($attribute_info['regexp_pattern'])) {
             if (!is_array($data[$attribute_info['attribute_id']])) {
                 //for string value
                 if (!preg_match($attribute_info['regexp_pattern'], $data[$attribute_info['attribute_id']])) {
                     $errors[$attribute_info['attribute_id']] .= ' ' . $attribute_info['error_text'];
                 }
             } else {
                 // for array's values
                 foreach ($data[$attribute_info['attribute_id']] as $dd) {
                     if (!preg_match($attribute_info['regexp_pattern'], $dd)) {
                         $errors[$attribute_info['attribute_id']] .= ' ' . $attribute_info['error_text'];
                         break;
                     }
                 }
             }
         }
         //for captcha
         if ($attribute_info['element_type'] == 'K' && (!isset($this->session->data['captcha']) || $this->session->data['captcha'] != $data[$attribute_info['attribute_id']])) {
             $errors[$attribute_info['attribute_id']] = $this->language->get('error_captcha');
         }
         // for file
         if ($attribute_info['element_type'] == 'U' && ($this->request->files[$attribute_info['attribute_id']]['tmp_name'] || $attribute_info['required'] == '1')) {
             $fm = new AFile();
             $file_path_info = $fm->getUploadFilePath($data['settings']['directory'], $this->request->files[$attribute_info['attribute_id']]['name']);
             $file_data = array('name' => $file_path_info['name'], 'path' => $file_path_info['path'], 'type' => $this->request->files[$attribute_info['attribute_id']]['type'], 'tmp_name' => $this->request->files[$attribute_info['attribute_id']]['tmp_name'], 'error' => $this->request->files[$attribute_info['attribute_id']]['error'], 'size' => $this->request->files[$attribute_info['attribute_id']]['size']);
             $file_errors = $fm->validateFileOption($attribute_info['settings'], $file_data);
             if ($file_errors) {
                 $errors[$attribute_info['attribute_id']] .= implode(' ', $file_errors);
             }
         }
     }
     return $errors;
 }
コード例 #3
0
ファイル: product.php プロジェクト: vglide/abantecart-src
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->loadModel('tool/seo_url');
     $this->loadModel('catalog/category');
     if (isset($this->request->get['path'])) {
         $path = '';
         foreach (explode('_', $this->request->get['path']) as $path_id) {
             $category_info = $this->model_catalog_category->getCategory($path_id);
             if (!$path) {
                 $path = $path_id;
             } else {
                 $path .= '_' . $path_id;
             }
             if ($category_info) {
                 $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('product/category', '&path=' . $path, '&encode'), 'text' => $category_info['name'], 'separator' => $this->language->get('text_separator')));
             }
         }
     }
     $this->loadModel('catalog/manufacturer');
     if (isset($this->request->get['manufacturer_id'])) {
         $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
         if ($manufacturer_info) {
             $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $this->request->get['manufacturer_id'], '&encode'), 'text' => $manufacturer_info['name'], 'separator' => $this->language->get('text_separator')));
         }
     }
     if (isset($this->request->get['keyword'])) {
         $url = '';
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         $this->document->addBreadcrumb(array('href' => $this->html->getURL('product/search', '&keyword=' . $this->request->get['keyword'] . $url, '&encode'), 'text' => $this->language->get('text_search'), 'separator' => $this->language->get('text_separator')));
     }
     $key = array();
     //key of product from cart
     if (has_value($this->request->get['key'])) {
         $key = explode(':', $this->request->get['key']);
         $product_id = (int) $key[0];
     } elseif (has_value($this->request->get['product_id'])) {
         $product_id = (int) $this->request->get['product_id'];
     } else {
         $product_id = 0;
     }
     $urls = array('is_group_option' => $this->html->getURL('r/product/product/is_group_option', '&product_id=' . $product_id, '&encode'));
     $this->view->assign('urls', $urls);
     $this->loadModel('catalog/product');
     $promoton = new APromotion();
     $product_info = $this->model_catalog_product->getProduct($product_id);
     //can not locate product? get out
     if (!$product_info) {
         $this->_product_not_found($product_id);
         return null;
     }
     $url = $this->_build_url();
     $this->view->assign('error', '');
     if (isset($this->session->data['error'])) {
         $this->view->assign('error', $this->session->data['error']);
         unset($this->session->data['error']);
     }
     $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('product/product', $url . '&product_id=' . $product_id, '&encode'), 'text' => $product_info['name'], 'separator' => $this->language->get('text_separator')));
     $this->document->setTitle($product_info['name']);
     $this->document->setKeywords($product_info['meta_keywords']);
     $this->document->setDescription($product_info['meta_description']);
     $this->document->addLink(array('href' => $this->html->getSEOURL('product/product', '&product_id=' . $product_id, '&encode'), 'rel' => 'canonical'));
     $this->data['heading_title'] = $product_info['name'];
     $this->data['minimum'] = $product_info['minimum'];
     $this->data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);
     $this->data['maximum'] = $product_info['maximum'];
     $this->data['text_maximum'] = sprintf($this->language->get('text_maximum'), $product_info['maximum']);
     $this->data['option_resources_url'] = $this->html->getURL('r/product/product/get_option_resources');
     $this->data['calc_total_url'] = $this->html->getURL('r/product/product/calculateTotal');
     $this->data['product_review_url'] = $this->html->getURL('product/review/review', '&product_id=' . $product_id);
     $this->data['product_review_write_url'] = $this->html->getURL('product/review/write', '&product_id=' . $product_id);
     $this->data['product_wishlist_add_url'] = $this->html->getURL('product/wishlist/add', '&product_id=' . $product_id);
     $this->data['product_wishlist_remove_url'] = $this->html->getURL('product/wishlist/remove', '&product_id=' . $product_id);
     $this->data['captcha_url'] = $this->html->getURL('common/captcha');
     $this->loadModel('catalog/review');
     $this->data['tab_review'] = sprintf($this->language->get('tab_review'), $this->model_catalog_review->getTotalReviewsByProductId($product_id));
     if ($this->config->get('enable_reviews')) {
         $average = $this->model_catalog_review->getAverageRating($product_id);
     } else {
         $average = false;
     }
     $this->data['review_status'] = $this->config->get('enable_reviews');
     $this->data['text_stars'] = sprintf($this->language->get('text_stars'), $average);
     $this->data['rating_element'] = HtmlElementFactory::create(array('type' => 'rating', 'name' => 'rating', 'value' => '', 'options' => array(1 => 1, 2, 3, 4, 5), 'pack' => true));
     $this->data['review_name'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'name'));
     $this->data['review_text'] = HtmlElementFactory::create(array('type' => 'textarea', 'name' => 'text', 'attr' => ' rows="8" cols="50" '));
     $this->data['review_captcha'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'captcha', 'attr' => ''));
     $this->data['review_button'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'review_submit', 'text' => $this->language->get('button_submit'), 'style' => 'btn-primary', 'icon' => 'fa fa-comment'));
     $this->data['product_info'] = $product_info;
     $form = new AForm();
     $form->setForm(array('form_name' => 'product'));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'product', 'action' => $this->html->getSecureURL('checkout/cart')));
     $product_price = $product_info['price'];
     $discount = $promoton->getProductDiscount($product_id);
     if ($discount) {
         $product_price = $discount;
         $this->data['price_num'] = $this->tax->calculate($discount, $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
         $this->data['special'] = FALSE;
     } else {
         $this->data['price_num'] = $this->tax->calculate($product_info['price'], $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
         $special = $promoton->getProductSpecial($product_id);
         if ($special) {
             $product_price = $special;
             $this->data['special_num'] = $this->tax->calculate($special, $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
         } else {
             $this->data['special'] = FALSE;
         }
     }
     $this->data['price'] = $this->currency->format($this->data['price_num']);
     if (isset($this->data['special_num'])) {
         $this->data['special'] = $this->currency->format($this->data['special_num']);
     }
     $product_discounts = $promoton->getProductDiscounts($product_id);
     $discounts = array();
     foreach ($product_discounts as $discount) {
         $discounts[] = array('quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], (bool) $this->config->get('config_tax'))));
     }
     $this->data['discounts'] = $discounts;
     $this->data['product_price'] = $product_price;
     $this->data['tax_class_id'] = $product_info['tax_class_id'];
     if (!$product_info['call_to_order']) {
         $this->data['form']['minimum'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'quantity', 'value' => $product_info['minimum'] ? (int) $product_info['minimum'] : 1, 'style' => 'short', 'attr' => ' size="3" '));
         $this->data['form']['add_to_cart'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'add_to_cart', 'text' => $this->language->get('button_add_to_cart'), 'style' => 'button1'));
     }
     $this->data['form']['product_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'product_id', 'value' => $product_id));
     $this->data['form']['redirect'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'redirect', 'value' => $this->html->getURL('product/product', $url . '&product_id=' . $product_id, '&encode')));
     $this->data['model'] = $product_info['model'];
     $this->data['manufacturer'] = $product_info['manufacturer'];
     $this->data['manufacturers'] = $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $product_info['manufacturer_id'], '&encode');
     $this->data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
     $this->data['product_id'] = $product_id;
     $this->data['average'] = $average;
     $resource = new AResource('image');
     $thumbnail = $resource->getMainThumb('manufacturers', $product_info['manufacturer_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true);
     if (!preg_match('/no_image/', $thumbnail['thumb_url'])) {
         $this->data['manufacturer_icon'] = $thumbnail['thumb_url'];
     }
     // Preapare options and values for display
     $elements_with_options = HtmlElementFactory::getElementsWithOptions();
     $options = array();
     $product_options = $this->model_catalog_product->getProductOptions($product_id);
     //get info from cart if key presents
     $cart_product_info = array();
     if ($key) {
         $cart_product_info = $this->cart->getProduct($this->request->get['key']);
     }
     foreach ($product_options as $option) {
         $values = array();
         $name = $price = '';
         $default_value = $cart_product_info['options'][$option['product_option_id']];
         if ($option['element_type'] == 'R') {
             $default_value = is_array($default_value) ? current($default_value) : (string) $default_value;
         }
         $preset_value = $default_value;
         foreach ($option['option_value'] as $option_value) {
             $default_value = $option_value['default'] && !$default_value ? $option_value['product_option_value_id'] : $default_value;
             // for case when trying to add to cart withot required options. we get option-array back inside _GET
             if (has_value($this->request->get['option'][$option['product_option_id']])) {
                 $default_value = $this->request->get['option'][$option['product_option_id']];
             }
             $name = $option_value['name'];
             //check if we disable options based on out of stock setting
             if ($option_value['subtract'] && $this->config->get('config_nostock_autodisable') && $option_value['quantity'] <= 0) {
                 continue;
             }
             //Apply option price modifier
             if ($option_value['prefix'] == '%') {
                 $price = $this->tax->calculate($product_price * $option_value['price'] / 100, $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
                 if ($price != 0) {
                     $price = $this->currency->format($price);
                 } else {
                     $price = '';
                 }
             } else {
                 $price = $this->tax->calculate($option_value['price'], $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
                 if ($price != 0) {
                     $price = $this->currency->format($price);
                 } else {
                     $price = '';
                 }
             }
             //Check stock and status
             $opt_stock_message = '';
             if ($option_value['subtract']) {
                 if ($option_value['quantity'] <= 0) {
                     //show out of stock message
                     $opt_stock_message = $product_info['stock_status'];
                 } else {
                     if ($this->config->get('config_stock_display')) {
                         $opt_stock_message = $option_value['quantity'] . " " . $this->language->get('text_instock');
                     }
                 }
             }
             $values[$option_value['product_option_value_id']] = $option_value['name'] . ' ' . $price . ' ' . $opt_stock_message;
         }
         //if not values are build, nothing to show
         if (count($values)) {
             $value = '';
             //add price to option name if it is not element with options
             if (!in_array($option['element_type'], $elements_with_options)) {
                 $option['name'] .= ' <small>' . $price . '</small>';
                 if ($opt_stock_message) {
                     $option['name'] .= '<br />' . $opt_stock_message;
                 }
                 $value = $default_value ? $default_value : $name;
             }
             //set default selection is nothing selected
             if (!has_value($value)) {
                 if (has_value($default_value)) {
                     $value = $default_value;
                 } else {
                     if (in_array($option['element_type'], $elements_with_options) && $option['element_type'] != 'S') {
                         //set first from the list to default
                         reset($values);
                         $value = key($values);
                     }
                 }
             }
             //for checkbox with empty value
             if ($value == '' && $option['element_type'] == 'C') {
                 $value = 1;
             }
             $option_data = array('type' => $option['html_type'], 'name' => !in_array($option['element_type'], HtmlElementFactory::getMultivalueElements()) ? 'option[' . $option['product_option_id'] . ']' : 'option[' . $option['product_option_id'] . '][]', 'value' => $value, 'options' => $values, 'required' => $option['required'], 'placeholder' => $option['option_placeholder'], 'regexp_pattern' => $option['regexp_pattern'], 'error_text' => $option['error_text']);
             if ($option['element_type'] == 'C') {
                 if (!in_array($value, array('0', '1'))) {
                     $option_data['label_text'] = $value;
                 }
                 $option_data['checked'] = $preset_value ? true : false;
             }
             $options[] = array('name' => $option['name'], 'html' => $this->html->buildElement($option_data));
         }
     }
     $this->data['options'] = $options;
     //handle stock messages
     // if track stock is off. no messages needed.
     if ($this->model_catalog_product->isStockTrackable($product_id)) {
         $total_quantity = $this->model_catalog_product->hasAnyStock($product_id);
         $this->data['track_stock'] = true;
         //out of stock if no quantity and no stick checkout is disabled
         if ($total_quantity <= 0 && !$this->config->get('config_stock_checkout')) {
             $this->data['in_stock'] = false;
             //show out of stock message
             $this->data['stock'] = $product_info['stock_status'];
         } else {
             $this->data['in_stock'] = true;
             if ($this->config->get('config_stock_display')) {
                 $this->data['stock'] = $product_info['quantity'];
             } else {
                 $this->data['stock'] = $this->language->get('text_instock');
             }
         }
         //check if we need to disable product for no stock
         if ($this->config->get('config_nostock_autodisable') && $total_quantity <= 0) {
             //set available data
             $pd_identifiers = "ID: " . $product_id;
             $pd_identifiers .= empty($product_info['model']) ? '' : " Model: " . $product_info['model'];
             $pd_identifiers .= empty($product_info['sku']) ? '' : " SKU: " . $product_info['sku'];
             $message_ttl = sprintf($this->language->get('notice_out_of_stock_ttl'), $product_info['name']);
             $message_txt = sprintf($this->language->get('notice_out_of_stock_body'), $product_info['name'], $pd_identifiers);
             //record to message box
             $msg = new AMessage();
             $msg->saveNotice($message_ttl, $message_txt);
             $this->model_catalog_product->updateStatus($product_id, 0);
             $this->redirect($this->html->getSEOURL('product/product', '&product_id=' . $product_info['product_id'], '&encode'));
         }
     }
     // main product image
     $sizes = array('main' => array('width' => $this->config->get('config_image_popup_width'), 'height' => $this->config->get('config_image_popup_height')), 'thumb' => array('width' => $this->config->get('config_image_thumb_width'), 'height' => $this->config->get('config_image_thumb_height')));
     $this->data['image_main'] = $resource->getResourceAllObjects('products', $product_id, $sizes, 1, false);
     if ($this->data['image_main']) {
         $this->data['image_main']['sizes'] = $sizes;
     }
     // additional images
     $sizes = array('main' => array('width' => $this->config->get('config_image_popup_width'), 'height' => $this->config->get('config_image_popup_height')), 'thumb' => array('width' => $this->config->get('config_image_additional_width'), 'height' => $this->config->get('config_image_additional_height')));
     $this->data['images'] = $resource->getResourceAllObjects('products', $product_id, $sizes, 0, false);
     $products = array();
     $results = $this->model_catalog_product->getProductRelated($product_id);
     foreach ($results as $result) {
         // related product image
         $sizes = array('main' => array('width' => $this->config->get('config_image_related_width'), 'height' => $this->config->get('config_image_related_height')), 'thumb' => array('width' => $this->config->get('config_image_related_width'), 'height' => $this->config->get('config_image_related_height')));
         $image = $resource->getResourceAllObjects('products', $result['product_id'], $sizes, 1);
         if ($this->config->get('enable_reviews')) {
             $rating = $this->model_catalog_review->getAverageRating($result['product_id']);
         } else {
             $rating = false;
         }
         $special = FALSE;
         $discount = $promoton->getProductDiscount($result['product_id']);
         if ($discount) {
             $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], (bool) $this->config->get('config_tax')));
         } else {
             $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], (bool) $this->config->get('config_tax')));
             $special = $promoton->getProductSpecial($result['product_id']);
             if ($special) {
                 $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], (bool) $this->config->get('config_tax')));
             }
         }
         $options = $this->model_catalog_product->getProductOptions($result['product_id']);
         if ($options) {
             $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode');
         } else {
             if ($this->config->get('config_cart_ajax')) {
                 $add = '#';
             } else {
                 $add = $this->html->getSecureURL('checkout/cart', '&product_id=' . $result['product_id'], '&encode');
             }
         }
         $products[] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'image' => $image, 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'), 'add' => $add);
     }
     $this->data['related_products'] = $products;
     if ($this->config->get('config_customer_price')) {
         $display_price = TRUE;
     } elseif ($this->customer->isLogged()) {
         $display_price = TRUE;
     } else {
         $display_price = FALSE;
     }
     $this->data['display_price'] = $display_price;
     $this->model_catalog_product->updateViewed($product_id);
     $tags = array();
     $results = $this->model_catalog_product->getProductTags($product_id);
     foreach ($results as $result) {
         if ($result['tag']) {
             $tags[] = array('tag' => $result['tag'], 'href' => $this->html->getURL('product/search', '&keyword=' . $result['tag'], '&encode'));
         }
     }
     $this->data['tags'] = $tags;
     //downloads before order if allowed
     if ($this->config->get('config_download')) {
         $dwn = new ADownload();
         $download_list = $dwn->getDownloadsBeforeOrder($product_id);
         if ($download_list) {
             foreach ($download_list as $download) {
                 $href = $this->html->getURL('account/download/startdownload', '&download_id=' . $download['download_id']);
                 $download['attributes'] = $this->download->getDownloadAttributesValuesForCustomer($download['download_id']);
                 $download['button'] = $form->getFieldHtml(array('type' => 'button', 'id' => 'download_' . $download['download_id'], 'href' => $href, 'title' => $this->language->get('text_start_download'), 'text' => $this->language->get('text_start_download')));
                 $downloads[] = $download;
             }
             $this->data['downloads'] = $downloads;
         }
     }
     #check if product is in a wishlist
     $this->data['is_customer'] = false;
     if ($this->customer->isLogged() || $this->customer->isUnauthCustomer()) {
         $this->data['is_customer'] = true;
         $whishlist = $this->customer->getWishList();
         if ($whishlist[$product_id]) {
             $this->data['in_wishlist'] = true;
         }
     }
     $this->view->setTemplate('pages/product/product.tpl');
     $this->view->batchAssign($this->data);
     $this->processTemplate();
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
コード例 #4
0
 /**
  * method for validation of data based on form fields requirements
  * @param array $data - usually it's a $_POST
  * @return array - array with error text for each of invalid field data
  */
 public function validateFormData($data = array())
 {
     $errors = array();
     $this->_loadFields();
     $this->load->language('checkout/cart');
     // load language for file upload text errors
     foreach ($this->fields as $field) {
         // for multivalue required fields
         if (in_array($field['element_type'], HtmlElementFactory::getMultivalueElements()) && !sizeof($data[$field['field_name']]) && $field['required'] == 'Y') {
             $errors[$field['field_name']] = $field['name'] . ' ' . $this->language->get('text_field_required');
         }
         // for required string values
         if ($field['required'] == 'Y' && !in_array($field['element_type'], array('K', 'J', 'U'))) {
             if (!is_array($data[$field['field_name']])) {
                 $data[$field['field_name']] = trim($data[$field['field_name']]);
                 //if empty string!
                 if ($data[$field['field_name']] == '') {
                     $errors[$field['field_name']] = $field['name'] . ' ' . $this->language->get('text_field_required');
                 }
             } else {
                 // if empty array
                 if (!$data[$field['field_name']]) {
                     $errors[$field['field_name']] = $field['name'] . ' ' . $this->language->get('text_field_required');
                 }
             }
         }
         // check by regexp
         if (has_value($field['regexp_pattern'])) {
             if (!is_array($data[$field['field_name']])) {
                 //for string value
                 if (!preg_match($field['regexp_pattern'], $data[$field['field_name']])) {
                     // show error only for field with value or required
                     if ($data[$field['field_name']] && $field['required'] != 'Y' || $field['required'] == 'Y') {
                         $errors[$field['field_name']] .= ' ' . $field['error_text'];
                     }
                 }
             } else {
                 // for array's values
                 foreach ($data[$field['field_name']] as $dd) {
                     if (!preg_match($field['regexp_pattern'], $dd)) {
                         if ($dd && $field['required'] != 'Y' || $field['required'] == 'Y') {
                             $errors[$field['field_name']] .= ' ' . $field['error_text'];
                         }
                         break;
                     }
                 }
             }
         }
         //for captcha or recaptcha
         if ($field['element_type'] == 'K' || $field['element_type'] == 'J') {
             if ($this->config->get('config_recaptcha_secret_key')) {
                 require_once DIR_VENDORS . '/google_recaptcha/autoload.php';
                 $recaptcha = new \ReCaptcha\ReCaptcha($this->config->get('config_recaptcha_secret_key'));
                 $resp = $recaptcha->verify($data['g-recaptcha-response'], $this->request->server['REMOTE_ADDR']);
                 if (!$resp->isSuccess() && $resp->getErrorCodes()) {
                     $errors[$field['field_name']] = $this->language->get('error_captcha');
                 }
             } else {
                 if (!isset($this->session->data['captcha']) || $this->session->data['captcha'] != $data[$field['field_name']]) {
                     $errors[$field['field_name']] = $this->language->get('error_captcha');
                 }
             }
         }
         // for file
         if ($field['element_type'] == 'U' && ($this->request->files[$field['field_name']]['tmp_name'] || $field['required'] == 'Y')) {
             $fm = new AFile();
             $file_path_info = $fm->getUploadFilePath($data['settings']['directory'], $this->request->files[$field['field_name']]['name']);
             $file_data = array('name' => $file_path_info['name'], 'path' => $file_path_info['path'], 'type' => $this->request->files[$field['field_name']]['type'], 'tmp_name' => $this->request->files[$field['field_name']]['tmp_name'], 'error' => $this->request->files[$field['field_name']]['error'], 'size' => $this->request->files[$field['field_name']]['size']);
             $file_errors = $fm->validateFileOption($field['settings'], $file_data);
             if ($file_errors) {
                 $errors[$field['field_name']] .= implode(' ', $file_errors);
             }
         }
     }
     return $errors;
 }
コード例 #5
0
ファイル: product.php プロジェクト: harshzalavadiya/fatak
 /**
  * @param array $file_data
  * @param string $tpl
  */
 public function buildDownloadForm($file_data, $tpl)
 {
     $this->data = array();
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('catalog/files');
     $this->loadModel('localisation/order_status');
     $this->loadModel('catalog/download');
     $product_id = $file_data['product_id'];
     $order_statuses = $this->model_localisation_order_status->getOrderStatuses();
     $this->data['date_added'] = dateISO2Display($file_data['date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
     $this->data['date_modified'] = dateISO2Display($file_data['date_modified'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
     $this->data['action'] = $this->html->getSecureURL('r/product/product/processDownloadForm', '&product_id=' . $product_id);
     $this->data['form_title'] = $this->language->get('text_edit') . '&nbsp;' . $this->language->get('text_product');
     $this->data['download_id'] = (int) $file_data['download_id'];
     if ($this->data['download_id']) {
         $form = new AForm('HS');
         $this->data['update'] = $this->html->getSecureURL('listing_grid/download/update_field', '&id=' . $this->data['download_id']);
     } else {
         $form = new AForm('HT');
     }
     $form->setForm(array('form_name' => 'downloadFrm' . $file_data['download_id'], 'update' => $this->data['update']));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'downloadFrm' . $file_data['download_id'], 'attr' => 'confirm-exit="true"', 'action' => $this->data['action']));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => (int) $this->data['download_id'] ? $this->language->get('button_save') : $this->language->get('text_add'), 'style' => 'button1'));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'href' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $product_id), 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
     $rl = new AResource('download');
     $rl_dir = $rl->getTypeDir();
     $resource_id = $rl->getIdFromHexPath(str_replace($rl_dir, '', $file_data['filename']));
     $resource_info = $rl->getResource($resource_id);
     $thumbnail = $rl->getResourceThumb($resource_id, 30, 30);
     if ($resource_info['resource_path']) {
         $this->data['icon'] = $this->html->buildResourceImage(array('url' => $thumbnail, 'width' => 30, 'height' => 30, 'attr' => 'alt="' . $resource_info['title'] . '"'));
     } else {
         $this->data['icon'] = $resource_info['resource_code'];
     }
     if ($resource_id) {
         $this->data['preview']['href'] = $this->html->getSecureURL('common/resource_library/get_resource_preview', '&resource_id=' . $resource_id, true);
         $this->data['preview']['path'] = 'resources/' . $file_data['filename'];
     }
     $r = $this->dispatch('responses/common/resource_library/get_resource_html_single', array('type' => 'download', 'wrapper_id' => 'download_' . (int) $this->data['download_id'], 'resource_id' => $resource_id, 'field' => 'download_rl_path_' . $this->data['download_id']));
     $this->data['resource'] = $r->dispatchGetOutput();
     $resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'downloads', 'object_id' => (int) $this->data['download_id'], 'types' => 'download', 'mode' => 'url'));
     $this->data['resources_scripts'] = $resources_scripts->dispatchGetOutput();
     $this->data['form']['fields']['download_rl_path'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'download_rl_path_' . $this->data['download_id'], 'value' => htmlspecialchars($file_data['filename'], ENT_COMPAT, 'UTF-8')));
     $this->data['form']['fields']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => 1, 'checked' => $file_data['status'] ? true : false, 'style' => 'btn_switch'));
     $orders_count = $this->model_catalog_download->getTotalOrdersWithProduct($product_id);
     if ($orders_count) {
         $this->data['push_to_customers'] = $this->html->buildElement(array('type' => 'button', 'name' => 'push_to_customers', 'title' => sprintf($this->language->get('text_push_to_orders'), $orders_count), 'text' => $this->language->get('text_push'), 'href' => $this->html->getSecureURL('r/product/product/pushToCustomers', '&product_id=' . $product_id . '&download_id=' . $this->data['download_id']), 'style' => 'button2', 'attr' => 'data-orders-count="' . $orders_count . '"'));
     }
     $this->data['maplist'] = array();
     $file_data['map_list'] = (array) $file_data['map_list'];
     foreach ($file_data['map_list'] as $map_id => $map_name) {
         if ($map_id == $product_id) {
             continue;
         }
         $this->data['maplist'][] = array('href' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $map_id . '&download_id=' . $this->data['download_id'], true), 'text' => $map_name);
     }
     if (!sizeof($this->data['maplist'])) {
         $this->data['already_shared'] = false;
     } else {
         $this->data['already_shared'] = true;
     }
     $this->data['delete_unmap_href'] = $this->html->getSecureURL('catalog/product_files', '&act=' . ($file_data['shared'] ? 'unmap' : 'delete') . '&product_id=' . $product_id . '&download_id=' . $this->data['download_id'], true);
     $this->data['form']['fields']['shared'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'shared', 'value' => $file_data['shared'], 'attr' => $this->data['already_shared'] ? ' disabled=disabled' : ''));
     if ($file_data['shared']) {
         $this->data['text_attention_shared'] = $this->language->get('attention_shared');
     }
     $this->data['form']['fields']['download_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'download_id', 'value' => $this->data['download_id']));
     $this->data['form']['fields']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'name', 'value' => $file_data['name'], 'attr' => ' maxlength="64" '));
     $this->data['form']['fields']['mask'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'mask', 'value' => $file_data['mask']));
     $this->data['form']['fields']['max_downloads'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'max_downloads', 'value' => $file_data['max_downloads'], 'style' => 'small-field'));
     $this->data['form']['fields']['activate'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'activate', 'value' => $file_data['activate'], 'options' => array('' => $this->language->get('text_select'), 'before_order' => $this->language->get('text_before_order'), 'immediately' => $this->language->get('text_immediately'), 'order_status' => $this->language->get('text_on_order_status'), 'manually' => $this->language->get('text_manually')), 'required' => true, 'style' => 'download_activate no-save'));
     $options = array('' => $this->language->get('text_select'));
     foreach ($order_statuses as $order_status) {
         $options[$order_status['order_status_id']] = $order_status['name'];
     }
     $this->data['form']['fields']['order_statuses'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'activate_order_status_id', 'value' => $file_data['activate_order_status_id'], 'options' => $options, 'required' => true, 'style' => 'no-save'));
     $this->data['form']['fields']['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'style' => 'small-field', 'value' => $file_data['sort_order']));
     $this->data['form']['fields']['expire_days'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'expire_days', 'style' => 'small-field', 'value' => $file_data['expire_days']));
     /*
      * DOWNLOAD ATTRIBUTES PIECE OF FORM
      * */
     $attributes = $this->model_catalog_download->getDownloadAttributes($this->data['download_id']);
     $elements = HtmlElementFactory::getAvailableElements();
     $html_multivalue_elements = HtmlElementFactory::getMultivalueElements();
     $html_elements_with_options = HtmlElementFactory::getElementsWithOptions();
     if (!$attributes) {
         $attr_mng = new AAttribute_Manager('download_attribute');
         $attr_type_id = $attr_mng->getAttributeTypeID('download_attribute');
         $this->data['text_no_download_attributes_yet'] = sprintf($this->language->get('text_no_download_attributes_yet'), $this->html->getSecureURL('catalog/attribute/insert', '&attribute_type_id=' . $attr_type_id));
     } else {
         foreach ($attributes as $attribute) {
             $html_type = $elements[$attribute['element_type']]['type'];
             if (!$html_type || !$attribute['status']) {
                 continue;
             }
             $values = $value = array();
             //values that was setted
             if (in_array($attribute['element_type'], $html_elements_with_options) && $attribute['element_type'] != 'R') {
                 if (is_array($attribute['selected_values'])) {
                     foreach ($attribute['selected_values'] as $val) {
                         $value[$val] = $val;
                     }
                 } else {
                     $value = $attribute['selected_values'];
                 }
             } else {
                 if (isset($attribute['selected_values'])) {
                     $value = $attribute['selected_values'];
                     if ($attribute['element_type'] == 'R' && is_array($value)) {
                         $value = current($value);
                     }
                 } else {
                     $value = $attribute['values'][0]['value'];
                 }
             }
             // possible values
             foreach ($attribute['values'] as $val) {
                 $values[$val['attribute_value_id']] = $val['value'];
             }
             if (!in_array($attribute['element_type'], $html_multivalue_elements)) {
                 $option_name = 'attributes[' . $this->data['download_id'] . '][' . $attribute['attribute_id'] . ']';
             } else {
                 $option_name = 'attributes[' . $this->data['download_id'] . '][' . $attribute['attribute_id'] . '][' . $attribute['attribute_value_id'] . ']';
             }
             $disabled = '';
             $required = $attribute['required'];
             $option_data = array('type' => $html_type, 'name' => $option_name, 'value' => $value, 'options' => $values, 'required' => $required, 'attr' => $disabled, 'style' => 'large-field');
             if ($html_type == 'checkboxgroup') {
                 $option_data['scrollbox'] = true;
             }
             $this->data['entry_attribute_' . $this->data['download_id'] . '_' . $attribute['attribute_id']] = $attribute['name'];
             $this->data['attributes'][$this->data['download_id'] . '_' . $attribute['attribute_id']] = $form->getFieldHtml($option_data);
         }
     }
     // for new download - create form for mapping shared downloads to product
     if (!$file_data['download_id']) {
         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);
         }
         $form0 = new AForm('ST');
         $form0->setForm(array('form_name' => 'SharedFrm' . $file_data['download_id'], 'update' => $this->data['update']));
         $this->data['form0']['form_open'] = $form0->getFieldHtml(array('type' => 'form', 'name' => 'SharedFrm' . $file_data['download_id'], 'attr' => 'confirm-exit="true"', 'action' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $product_id)));
         // exclude this product from multivalue list. why we need relate recursion?
         $this->session->data['multivalue_excludes']['product_id'] = $this->request->get['product_id'];
         $this->data['form0']['fields']['list_hidden'] = $form0->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/download_listing', '&shared_only=1&form_name=SharedFrm' . $file_data['download_id'] . '&multivalue_hidden_id=popup'), '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('button_save'), 'reset' => $this->language->get('button_reset'))));
     }
     $this->view->batchAssign($this->data);
     $this->processTemplate($tpl);
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }