예제 #1
0
파일: catalog.php 프로젝트: JexyRu/Ksenmart
 function get_set_childs()
 {
     $db = JFactory::getDBO();
     $id = JRequest::getInt('id');
     $html = '';
     $model = $this->getModel('catalog');
     $view = $this->getView('catalog', 'html');
     $view->setModel($model, true);
     $query = $db->getQuery(true);
     $query->select('p.*,pp.product_id as set_id')->from('#__ksenmart_products as p')->innerjoin('#__ksenmart_products_relations as pp on pp.relative_id=p.id')->where('pp.product_id=' . $id)->where('pp.relation_type=' . $db->quote('set'))->order('p.ordering');
     $query = KSMedia::setItemMainImageToQuery($query);
     $db->setQuery($query);
     $items = $db->loadObjectList();
     foreach ($items as $item) {
         $item->small_img = KSMedia::resizeImage($item->filename, $item->folder, $model->params->get('admin_product_thumb_image_width'), $model->params->get('admin_product_thumb_image_heigth'), json_decode($item->params, true));
         $item->medium_img = KSMedia::resizeImage($item->filename, $item->folder, $model->params->get('admin_product_medium_image_width'), $model->params->get('admin_product_medium_image_heigth'), json_decode($item->params, true));
         $view->setLayout('default_item_form');
         $view->item =& $item;
         ob_start();
         $view->display();
         $html .= ob_get_contents();
         ob_end_clean();
     }
     $response = array('html' => $html, 'message' => array(), 'errors' => 0);
     $response = json_encode($response);
     JFactory::getDocument()->setMimeEncoding('application/json');
     echo $response;
     JFactory::getApplication()->close();
 }
예제 #2
0
파일: helper.php 프로젝트: JexyRu/Ksenmart
 public static function getDiscounts($discounts, $params)
 {
     if (empty($discounts)) {
         return array();
     }
     $arr_params = $params->toArray();
     $types = isset($arr_params['types']) && is_array($arr_params['types']) && count($arr_params['types']) ? $arr_params['types'] : array('all');
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('d.id, d.title, d.content, d.from_date, d.to_date, d.info_methods');
     $query->from('#__ksenmart_discounts as d');
     $query->where("d.id IN (" . implode(',', $discounts) . ")");
     if (!in_array('all', $types)) {
         foreach ($types as &$type) {
             $type = $db->quote($type);
         }
         $query->where('d.type in (' . implode(',', $types) . ')');
     }
     $query = KSMedia::setItemMainImageToQuery($query, 'discount', 'd.');
     $results = $db->setQuery($query)->loadObjectList('id');
     foreach ($results as $key => $res) {
         $content = JDispatcher::getInstance()->trigger('onGetDiscountContent', array($res->id));
         if (isset($content[0]) && !empty($content[0])) {
             $results[$key]->content = $content[0];
         }
         $info_methods = json_decode($res->info_methods, true);
         $results[$key]->image = !empty($results[$key]->filename) ? KSMedia::resizeImage($results[$key]->filename, $results[$key]->folder, $params->get('img_width', 200), $params->get('img_height', 100), json_decode($results[$key]->params, true)) : '';
         if (!in_array('module', $info_methods)) {
             unset($results[$key]);
         }
     }
     unset($res);
     return $results;
 }
예제 #3
0
 function getListItems()
 {
     $this->onExecuteBefore('getListItems');
     $types = $this->getState('types');
     $order_dir = $this->getState('order_dir');
     $order_type = $this->getState('order_type');
     $query = $this->_db->getQuery(true);
     $query->select('SQL_CALC_FOUND_ROWS kp.*,e.name as plugin_name')->from('#__ksenmart_payments as kp')->leftjoin('#__extensions as e on e.element=kp.type and e.folder="kmpayment"')->order($order_type . ' ' . $order_dir);
     if (count($types) > 0) {
         $query->where('e.element in (\'' . implode('\',\'', $types) . '\')');
     }
     $query = KSMedia::setItemMainImageToQuery($query, 'payment', 'kp.');
     $this->_db->setQuery($query, $this->getState('list.start'), $this->getState('list.limit'));
     $items = $this->_db->loadObjectList();
     $query = $this->_db->getQuery(true);
     $query->select('FOUND_ROWS()');
     $this->_db->setQuery($query);
     $this->total = $this->_db->loadResult();
     foreach ($items as &$item) {
         $item->folder = 'payments';
         $item->small_img = KSMedia::resizeImage($item->filename, $item->folder, $this->params->get('admin_product_thumb_image_width', 36), $this->params->get('admin_product_thumb_image_heigth', 36), json_decode($item->params, true));
         $item->medium_img = KSMedia::resizeImage($item->filename, $item->folder, $this->params->get('admin_product_medium_image_width', 120), $this->params->get('admin_product_medium_image_heigth', 120), json_decode($item->params, true));
     }
     $this->onExecuteAfter('getListItems', array(&$items));
     return $items;
 }
예제 #4
0
파일: helper.php 프로젝트: JexyRu/Ksenmart
 private function build_tree($params)
 {
     $db = JFactory::getDBO();
     $categories = $params->get('categories', array());
     $sql = $db->getQuery(true);
     $sql->select('kc.*')->from('#__ksenmart_categories as kc')->where('kc.published=1')->order('kc.ordering');
     if ($categories) {
         $sql->where('kc.id IN(' . implode(', ', $categories) . ') OR kc.parent_id IN(' . implode(', ', $categories) . ')');
     }
     KSMedia::setItemMainImageToQuery($sql, 'category', 'kc.');
     $db->setQuery($sql);
     $rows = $db->loadObjectList('id');
     $top_parent = (object) array('id' => 0, 'children' => array());
     $menu = array(0 => $top_parent);
     foreach ($rows as $k => $v) {
         if (!empty($v->folder)) {
             $v->img = KSMedia::resizeImage($v->filename, $v->folder, $params->get('img_width', 200), $params->get('img_height', 200), json_decode($v->params, true));
         }
         if (isset($menu[$k])) {
             $v->children = $menu[$k]->children;
         } else {
             $v->children = array();
         }
         $menu[$k] = $v;
         if (!isset($menu[$v->parent_id])) {
             $menu[$v->parent_id] = new stdClass();
             $menu[$v->parent_id]->children = array();
         }
         $menu[$v->parent_id]->children[$v->id] = $v;
     }
     $this->menu = $menu;
 }
예제 #5
0
파일: catalog.php 프로젝트: JexyRu/Ksenmart
 function getChild($categories = array())
 {
     $this->onExecuteBefore('getChild', array(&$categories));
     $id = JRequest::getInt('id');
     $product = KSSystem::loadDbItem($id, 'products');
     $product = KSMedia::setItemMedia($product, 'product');
     if ($id == 0) {
         $product->parent_id = JRequest::getInt('parent_id');
     }
     $product->categories = array();
     $product->properties = array();
     $product->childs = array();
     if (count($categories)) {
         $query = $this->_db->getQuery(true);
         $query->select('category_id')->from('#__ksenmart_products_categories')->where('product_id=' . $id)->where('is_default=1');
         $this->_db->setQuery($query);
         $is_default = $this->_db->loadResult();
         foreach ($categories as $category_id) {
             $category = new stdClass();
             $category->category_id = $category_id;
             $category->is_default = $category->category_id == $is_default ? 1 : 0;
             $product->categories[$category_id] = $category;
         }
     } else {
         $query = $this->_db->getQuery(true);
         $query->select('category_id, is_default')->from('#__ksenmart_products_categories');
         if ($id > 0) {
             $query->where('product_id=' . $id);
         } else {
             $query->where('product_id=' . $product->parent_id);
         }
         $this->_db->setQuery($query);
         $product->categories = $this->_db->loadObjectList('category_id');
     }
     if ($id == 0) {
         $query = $this->_db->getQuery(true);
         $query->select('manufacturer')->from('#__ksenmart_products')->where('id=' . $product->parent_id);
         $this->_db->setQuery($query);
         $product->manufacturer = $this->_db->loadResult();
     }
     if (count($product->categories)) {
         $query = $this->_db->getQuery(true);
         $query->select('p.*')->from('#__ksenmart_properties as p')->innerjoin('#__ksenmart_product_categories_properties as cp on cp.property_id=p.id')->where('cp.category_id in (' . implode(',', array_keys($product->categories)) . ')');
         $this->_db->setQuery($query);
         $product->properties = $this->_db->loadObjectList('id');
         foreach ($product->properties as &$p) {
             $p->values = array();
         }
         if (!empty($product->properties)) {
             $in = array_keys($product->properties);
             $query = $this->_db->getQuery(true);
             $query->select('*')->from('#__ksenmart_product_properties_values')->where('product_id=' . $id)->where('property_id in (' . implode(',', $in) . ')');
             $this->_db->setQuery($query);
             $values = $this->_db->loadObjectList();
             foreach ($values as $v) {
                 if (isset($product->properties[$v->property_id])) {
                     $product->properties[$v->property_id]->values[$v->id] = $v;
                 }
             }
         }
     }
     $query = $this->_db->getQuery(true);
     $query->select('p.*')->from('#__ksenmart_products as p')->innerjoin('#__ksenmart_products_relations as pr on pr.relative_id=p.id')->where('pr.relation_type=' . $this->_db->quote('relation'))->where('pr.product_id=' . $id);
     $query = KSMedia::setItemMainImageToQuery($query);
     $this->_db->setQuery($query);
     $product->relative = $this->_db->loadObjectList('id');
     foreach ($product->relative as &$prd) {
         $prd->small_img = KSMedia::resizeImage($prd->filename, $prd->folder, $this->params->get('admin_product_thumb_image_width', 36), $this->params->get('admin_product_thumb_image_heigth', 36), json_decode($prd->params, true));
     }
     $this->onExecuteAfter('getChild', array(&$product));
     return $product;
 }
예제 #6
0
파일: cart.php 프로젝트: JexyRu/Ksenmart
    public function getShippings()
    {
        $this->onExecuteBefore('getShippings');
        $shipping_selected = 0;
        $shippings = array();
        if (!empty($this->_region_id)) {
            $query = $this->_db->getQuery(true);
            $query->select('
					s.id,
					s.title,
					s.introcontent,
					s.type,
					s.regions,
					s.days,
					s.ordering
				')->from('#__ksenmart_shippings AS s')->where('s.published=1')->order('s.ordering');
            $query = KSMedia::setItemMainImageToQuery($query, 'shipping', 's.');
            $this->_db->setQuery($query);
            $rows = $this->_db->loadObjectList();
            foreach ($rows as $row) {
                $row->icon = !empty($row->filename) ? KSMedia::resizeImage($row->filename, $row->folder, 20, 20, json_decode($row->params, true)) : '';
                $row->regions = json_decode($row->regions, true);
                foreach ($row->regions as $country) {
                    if (in_array($this->_region_id, $country)) {
                        $row->selected = false;
                        $shipping_selected = $shipping_selected;
                        if ($row->id == $this->_shipping_id) {
                            $row->selected = true;
                            $shipping_selected = $row->id;
                        }
                        $shippings[] = $row;
                    }
                }
            }
        }
        $this->setState('shipping_id', $shipping_selected);
        $this->_session->set($this->context . '.shipping_id', $shipping_selected);
        $this->onExecuteAfter('getShippings', array(&$shippings));
        return $shippings;
    }
예제 #7
0
파일: profile.php 프로젝트: JexyRu/Ksenmart
 public function getShippingsByRegionId($region_id)
 {
     $this->onExecuteBefore('getShippingsByRegionId', array(&$region_id));
     $shippings = array();
     if (!empty($region_id) && $region_id > 0) {
         $query = $this->_db->getQuery(true);
         $query->select('
                 s.id,
                 s.title,
                 s.type,
                 s.regions,
                 s.days,
                 s.ordering
             ')->from('#__ksenmart_shippings AS s')->where('s.published=1')->order('s.ordering');
         $query = KSMedia::setItemMainImageToQuery($query, 'shipping', 's.');
         $this->_db->setQuery($query);
         $db_shippings = $this->_db->loadObjectList();
         foreach ($db_shippings as $db_shipping) {
             if (!$this->checkRegion($db_shipping->regions, $region_id)) {
                 continue;
             }
             $db_shipping->icon = !empty($db_shipping->filename) ? KSMedia::resizeImage($db_shipping->filename, $db_shipping->folder, 80, 80, json_decode($db_shipping->params, true)) : '';
             $cart = new stdClass();
             $cart->shipping_id = $db_shipping->id;
             $cart->region_id = $region_id;
             $cart->items = array();
             JDispatcher::getInstance()->trigger('onAfterExecuteKSMCartGetcart', array(null, &$cart));
             $db_shipping->sum = $cart->shipping_sum;
             $db_shipping->sum_val = $cart->shipping_sum_val;
             $shippings[] = $db_shipping;
         }
     }
     $this->onExecuteAfter('getShippingsByRegionId', array(&$shippings));
     return $shippings;
 }
예제 #8
0
파일: users.php 프로젝트: JexyRu/Ksenmart
    public static function getUser($id = '')
    {
        if (array_key_exists($id, self::$_user)) {
            return self::$_user[$id];
        }
        $db = JFactory::getDBO();
        $original_id = $id;
        if ($id == '') {
            $id = JFactory::getUser()->id;
        }
        if ($id != 0) {
            $query = $db->getQuery(true);
            $query->select('
                km_u.id,  
				km_u.first_name,  
				km_u.last_name,  
				km_u.middle_name,  
                km_u.region_id, 
                km_u.phone, 
                km_u.watched, 
                km_u.favorites,
                km_u.settings,  
                u.id, 
                u.name, 
                u.username,
                u.email,  
                u.block, 
                u.sendEmail, 
                u.registerDate, 
                u.lastvisitDate, 
                u.activation, 
                u.params, 
                u.lastResetTime, 
                u.resetCount,
                ua.city,
                ua.zip,
                ua.street,
                ua.house,
                ua.floor,
                ua.flat,
                ua.coords,
                uf.filename AS logo
            ');
            $query->from('#__users AS u');
            $query->leftjoin('#__ksen_users AS km_u ON km_u.id=u.id');
            $query->leftjoin('#__ksen_files AS uf ON uf.owner_id=u.id');
            $query->leftjoin('#__ksen_user_addresses AS ua ON ua.user_id=u.id AND ua.default=1');
            $query->where('u.id=' . $id);
            $query = KSMedia::setItemMainImageToQuery($query, 'user', 'km_u.', 'ksen');
            $db->setQuery($query);
            $user = $db->loadObject();
            if (!$user) {
                $user = self::getEmptyUserObject();
            }
            $user->folder = 'users';
            $params = JComponentHelper::getParams('com_ksen');
            $user->small_img = KSMedia::resizeImage($user->filename, $user->folder, $params->get('admin_product_thumb_image_width', 36), $params->get('admin_product_thumb_image_heigth', 36), json_decode($user->params, true), 'com_ksen');
            $user->medium_img = KSMedia::resizeImage($user->filename, $user->folder, $params->get('admin_product_medium_image_width', 120), $params->get('admin_product_medium_image_heigth', 120), json_decode($user->params, true), 'com_ksen');
            if (!empty($item->social) && $user->email == $user->username . '@email.ru') {
                $user->email = '';
            }
            if (empty($user->groups)) {
                $user->groups = JFactory::getUser()->groups;
            } else {
                $user->groups = array();
            }
            if (!empty($user->watched)) {
                $user->watched = json_decode($user->watched);
            } else {
                $user->watched = array();
            }
            if (!empty($user->favorites)) {
                $user->favorites = json_decode($user->favorites);
            } else {
                $user->favorites = array();
            }
            if ($user->region_id == 0) {
                $session = JFactory::getSession();
                $user_region = $session->get('user_region', 0);
                $user->region_id = $user_region;
            }
            if ($user->phone == '') {
                $session = JFactory::getSession();
                $phone_code = $session->get('phone_code', '');
                $user->phone = $phone_code;
            }
            if (!is_object($user->settings)) {
                $user->settings = '{"catalog_layout":"' . $params->get('catalog_default_view', 'grid') . '"}';
                $user->settings = json_decode($user->settings);
            }
            $user->address = KSUsers::getDefaultAddress($id);
            KSUsers::setAvatarLogoInObject($user);
            KSUsers::setUserFields($user);
        } else {
            $user = self::getEmptyUserObject();
        }
        self::$_user[$original_id] = $user;
        return $user;
    }
예제 #9
0
파일: reports.php 프로젝트: JexyRu/Ksenmart
 function getFavoritesProducts()
 {
     $this->onExecuteBefore('getFavoritesProducts');
     $order_dir = $this->getState('order_dir');
     $order_type = $this->getState('order_type');
     if ($order_type != 'favorites') {
         $order_type = 'p.' . $order_type;
     }
     $query = $this->_db->getQuery(true);
     $query->select('*')->from('#__ksen_users');
     $this->_db->setQuery($query);
     $users = $this->_db->loadObjectList();
     $favorites = array(0);
     foreach ($users as $user) {
         $user->favorites = json_decode($user->favorites, true);
         if (is_array($user->favorites)) {
             foreach ($user->favorites as $f) {
                 if (!in_array($f, $favorites) && $f != '') {
                     $favorites[] = $f;
                 }
             }
         }
     }
     $query = $this->_db->getQuery(true);
     $query->select('SQL_CALC_FOUND_ROWS p.*,(select count(id) from #__ksen_users where INSTR(favorites,p.id)!=0) as favorites')->from('#__ksenmart_products as p')->order($order_type . ' ' . $order_dir);
     $query->where('p.id in (' . implode(',', $favorites) . ')');
     $query = KSMedia::setItemMainImageToQuery($query);
     $this->_db->setQuery($query, $this->getState('list.start'), $this->getState('list.limit'));
     $items = $this->_db->loadObjectList();
     $query = $this->_db->getQuery(true);
     $query->select('FOUND_ROWS()');
     $this->_db->setQuery($query);
     $this->total = $this->_db->loadResult();
     foreach ($items as &$item) {
         $item->img = KSMedia::resizeImage($item->filename, $item->folder, 30, 30, json_decode($item->params, true));
     }
     $this->onExecuteAfter('getFavoritesProducts', array(&$items));
     return $items;
 }
예제 #10
0
파일: orders.php 프로젝트: JexyRu/Ksenmart
 function getOrder($vars = array())
 {
     $this->onExecuteBefore('getOrder', array(&$value));
     $id = JRequest::getInt('id');
     $order = KSSystem::loadDbItem($id, 'orders');
     if (isset($vars['user_id'])) {
         $order->user_id = $vars['user_id'];
     }
     if (isset($vars['region_id'])) {
         $order->region_id = $vars['region_id'];
     }
     if (isset($vars['shipping_id'])) {
         $order->shipping_id = $vars['shipping_id'];
     }
     if (isset($vars['payment_id'])) {
         $order->payment_id = $vars['payment_id'];
     }
     $order->cost = 0;
     $order->discounts = property_exists($order, 'discounts') ? $order->discounts : '[]';
     $order->customer_fields = json_decode($order->customer_fields, true);
     $order->address_fields = json_decode($order->address_fields, true);
     if (!isset($vars['items'])) {
         $query = $this->_db->getQuery(true);
         $query->select('*')->from('#__ksenmart_order_items')->where('order_id=' . $id);
         $this->_db->setQuery($query);
         $order->items = $this->_db->loadObjectList();
     } else {
         $items = array();
         if (count($vars['items']) == 1 && !is_array($vars['items'][0])) {
             $vars['items'] = array();
         }
         foreach ($vars['items'] as $item) {
             $item['properties'] = isset($item['properties']) ? $item['properties'] : array();
             $item = (object) $item;
             $item->price = KSMProducts::getPriceWithProperties($item->product_id, $item->properties, $item->basic_price);
             $item->properties = json_encode($item->properties);
             $items[] = $item;
         }
         $order->items = $items;
     }
     foreach ($order->items as &$item) {
         $query = $this->_db->getQuery(true);
         $query->select('p.*')->from('#__ksenmart_products as p')->where('p.id=' . $item->product_id);
         $query = KSMedia::setItemMainImageToQuery($query);
         $this->_db->setQuery($query);
         $product = $this->_db->loadObject();
         if (count($product)) {
             $item->title = $product->title;
             $item->alias = $product->alias;
             $item->product_code = $product->product_code;
             $item->product_packaging = $product->product_packaging;
             $item->properties = json_decode($item->properties, true);
             $query = $this->_db->getQuery(true);
             $query->select('kp.*')->from('#__ksenmart_properties as kp')->innerjoin('#__ksenmart_product_properties_values as kppv on kp.id=kppv.property_id')->where('kppv.product_id=' . $item->product_id)->where('kp.type=' . $this->_db->quote('select'))->order('kp.ordering')->group('kp.id');
             $this->_db->setQuery($query);
             $properties = $this->_db->loadObjectList('id');
             foreach ($properties as &$property) {
                 $query = $this->_db->getQuery(true);
                 $query->select('kpv.*')->from('#__ksenmart_property_values as kpv')->innerjoin('#__ksenmart_product_properties_values as kppv on kpv.id=kppv.value_id')->where('kppv.product_id=' . $item->product_id)->where('kpv.property_id=' . $property->id)->order('kpv.ordering')->group('kpv.id');
                 $this->_db->setQuery($query);
                 $property->values = $this->_db->loadObjectList('id');
                 foreach ($property->values as $value) {
                     if (isset($item->properties[$property->id]) && is_array($item->properties[$property->id]) && in_array($value->id, $item->properties[$property->id])) {
                         $value->selected = true;
                     } else {
                         $value->selected = false;
                     }
                 }
             }
             $item->properties = $properties;
             $item->small_img = KSMedia::resizeImage($product->filename, 'products', $this->params->get('admin_product_medium_image_width', 36), $this->params->get('admin_product_medium_image_heigth', 36), json_decode($product->params, true));
         } else {
             $item->title = JText::_('ksm_orders_order_deleteditem_title');
             $item->alias = '';
             $item->product_code = '';
             $item->product_packaging = 1;
             $item->properties = array();
             $item->small_img = KSMedia::resizeImage('', 'products', $this->params->get('admin_product_medium_image_width', 36), $this->params->get('admin_product_medium_image_heigth', 36));
         }
         $item->val_price = KSMPrice::showPriceWithTransform($item->price);
         $item->val_total_price = KSMPrice::showPriceWithTransform($item->price * $item->count);
         $order->cost += $item->price * $item->count;
     }
     $order->costs = array('cost' => $order->cost, 'cost_val' => KSMPrice::showPriceWithTransform($order->cost), 'discount_cost' => 0, 'discount_cost_val' => KSMPrice::showPriceWithTransform(0), 'shipping_cost' => 0, 'shipping_cost_val' => KSMPrice::showPriceWithTransform(0), 'total_cost' => $order->cost, 'total_cost_val' => KSMPrice::showPriceWithTransform($order->cost));
     $this->onExecuteAfter('getOrder', array(&$order));
     return $order;
 }
예제 #11
0
파일: users.php 프로젝트: JexyRu/Ksenmart
 function getUsers($ids)
 {
     $this->onExecuteBefore('getUsers', array(&$ids));
     $query = $this->_db->getQuery(true);
     $query->select('u.*')->from('#__users as u')->where('u.id in (' . implode(',', $ids) . ')');
     $query = KSMedia::setItemMainImageToQuery($query, 'user', 'u.');
     $this->_db->setQuery($query);
     $items = $this->_db->loadObjectList();
     foreach ($items as &$item) {
         $item->small_img = KSMedia::resizeImage($item->filename, $item->folder, $this->params->get('admin_product_thumb_image_width'), $this->params->get('admin_product_thumb_image_heigth'), json_decode($item->params, true));
     }
     $this->onExecuteAfter('getUsers', array(&$items));
     return $items;
 }
예제 #12
0
    public function getInput()
    {
        $db = JFactory::getDBO();
        $params = JComponentHelper::getParams('com_ksenmart');
        $html = '';
        $html .= '<div class="positions">';
        $html .= '	<div id="ksm-slidemodule-commentproduct-container">';
        if ($this->value > 0) {
            $query = $db->getQuery(true);
            $query->select('p.*')->from('#__ksenmart_products as p')->where('p.id=' . $this->value);
            $query = KSMedia::setItemMainImageToQuery($query);
            $db->setQuery($query);
            $product = $db->loadObject();
            if (!count($product)) {
                $product = new stdClass();
                $product->title = JText::_('ksm_comments_comment_deletedproduct_title');
                $product->small_img = KSMedia::resizeImage('', 'products', $params->get('admin_product_medium_image_width'), $params->get('admin_product_medium_image_heigth'));
            } else {
                $product->small_img = KSMedia::resizeImage($product->filename, $product->folder, $params->get('admin_product_thumb_image_width'), $params->get('admin_product_thumb_image_heigth'), json_decode($product->params, true));
            }
            $html .= '	<div class="position">';
            $html .= '		<div class="col1">';
            $html .= '			<div class="img"><img alt="" src="' . $product->small_img . '"></div>';
            $html .= '			<div class="name">' . $product->title . '</div>';
            $html .= '		</div>';
            $html .= '		<a href="#" class="del"></a>';
            $html .= '		<input type="hidden" name="' . $this->name . '" value="' . $this->value . '">';
            $html .= '	</div>';
        } else {
            $html .= '	<div class="position no-items">';
            $html .= '		<div class="col1">' . JText::_('ksm_comments_comment_no_product') . '</div>';
            $html .= '		<input type="hidden" name="' . $this->name . '" value="' . $this->value . '">';
            $html .= '	</div >';
        }
        $html .= '	</div>';
        if ($this->value == 0) {
            $html .= '<div class="row">';
            $html .= '	<a href="' . JRoute::_('index.php?option=com_ksenmart&view=catalog&layout=search&items_tpl=commentproduct&items_to=ksm-slidemodule-commentproduct-container&tmpl=component') . '" class="add">' . JText::_('ksm_add') . '</a>';
            $html .= '</div>';
        }
        $html .= '</div>';
        $script = '
		jQuery(document).ready(function(){
				
			jQuery("body").on("click", ".ksm-slidemodule-commentproduct .add", function(){
				var url=jQuery(this).attr("href");
				jQuery(".ksm-slidemodule-commentproduct input[type=\'hidden\']").each(function(){
					url+="&excluded[]="+jQuery(this).val();
				});
				url+="&excluded[]=";
				var width=jQuery(window).width();
				var height=jQuery(window).height();
				openPopupWindow(url,width,height);
				return false;
			});
			
			jQuery("body").on("click", ".ksm-slidemodule-commentproduct .del", function(){
				jQuery(this).parents(".position:first").remove();
				jQuery("#ksm-slidemodule-commentproduct-container").html("<input type=hidden id=jformproduct_id name=' . $this->name . ' value=0>");
				onChangeProduct();
				return false;
			});
			
		});
		
		function onChangeProduct()
		{
			var data={};
			var vars={};
			var form=jQuery(".form");
			data["model"]="comments";
			data["form"]="comment";
			data["fields"]=["product_id"];
			vars["product_id"]=form.find("#jformproduct_id").val();			
			data["vars"]=vars;
			data["id"]=form.find(".id").val();
			KMRenewFormFields(data);
		}	

		function afterAddingItems()
		{
			jQuery(".ksm-slidemodule-commentproduct .position:first").remove();
			onChangeProduct();
		}		
		';
        $document = JFactory::getDocument();
        $document->addScriptDeclaration($script);
        return $html;
    }