Exemplo n.º 1
0
 public static function getVariables($params, $items_per_page = 0, $lang_code = DESCR_SL)
 {
     // Set default values to input params
     $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
     $params = array_merge($default_params, $params);
     $fields = array('lang.value' => true, 'lang.name' => true);
     if (!empty($params['fields'])) {
         $fields = array_merge($fields, $params['fields']);
     }
     $tables = array('?:language_values as lang');
     $left_join = array();
     $condition = array();
     $condition['param1'] = db_quote('lang.lang_code = ?s', $lang_code);
     if (isset($params['q']) && fn_string_not_empty($params['q'])) {
         $condition['param2'] = db_quote('(lang.name LIKE ?l OR lang.value LIKE ?l)', '%' . trim($params['q']) . '%', '%' . trim($params['q']) . '%');
     }
     fn_set_hook('get_language_variable', $fields, $tables, $left_join, $condition, $params);
     $joins = !empty($left_join) ? ' LEFT JOIN ' . implode(', ', $left_join) : '';
     $limit = '';
     if (!empty($params['items_per_page'])) {
         $params['total_items'] = db_get_field('SELECT COUNT(*) FROM ' . implode(', ', $tables) . $joins . ' WHERE ' . implode(' AND ', $condition));
         $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
     }
     $lang_data = db_get_array('SELECT ' . implode(', ', array_keys($fields)) . ' FROM ' . implode(', ', $tables) . $joins . ' WHERE ' . implode(' AND ', $condition) . ' ORDER BY lang.name ' . $limit);
     return array($lang_data, $params);
 }
Exemplo n.º 2
0
function fn_get_seo_redirects($params = array(), $items_per_page = 0, $lang_code = DESCR_SL)
{
    // Init filter
    $params = LastView::instance()->update('seo_redirects', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $condition = '';
    if (isset($params['src']) && fn_string_not_empty($params['src'])) {
        $condition .= db_quote(" AND src LIKE ?l", "%" . trim($params['src']) . "%");
    }
    if (!empty($params['type'])) {
        $condition .= db_quote(" AND type = ?s", $params['type']);
    }
    if (!empty($params['lang_code'])) {
        $condition .= db_quote(" AND lang_code = ?s", $params['lang_code']);
    }
    $condition .= fn_get_seo_company_condition('?:seo_redirects.company_id');
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:seo_redirects WHERE 1 ?p", $condition);
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $seo_redirects = db_get_hash_array("SELECT * FROM ?:seo_redirects WHERE 1 ?p ORDER BY src {$limit}", 'redirect_id', $condition);
    if (!empty($seo_redirects)) {
        foreach ($seo_redirects as $key => $seo_redirect) {
            $seo_redirects[$key]['parsed_url'] = fn_generate_seo_url_from_schema($seo_redirect);
        }
    }
    return array($seo_redirects, $params);
}
Exemplo n.º 3
0
function fn_get_seo_rules($params = array(), $items_per_page = 0, $lang_code = DESCR_SL)
{
    $condition = fn_get_seo_company_condition('?:seo_names.company_id');
    $lang_code = fn_get_corrected_seo_lang_code($lang_code);
    $global_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' ?p GROUP BY dispatch", $condition);
    $local_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p", $lang_code, $condition);
    if ($diff = array_diff($global_total, $local_total)) {
        foreach ($diff as $disp) {
            fn_create_seo_name(0, 's', str_replace('.', '-', $disp), 0, $disp, '', DESCR_SL);
        }
    }
    // Init filter
    $params = LastView::instance()->update('seo_rules', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    if (isset($params['name']) && fn_string_not_empty($params['name'])) {
        $condition .= db_quote(" AND name LIKE ?l", "%" . trim($params['name']) . "%");
    }
    if (isset($params['rule_params']) && fn_string_not_empty($params['rule_params'])) {
        $condition .= db_quote(" AND dispatch LIKE ?l", "%" . trim($params['rule_params']) . "%");
    }
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p", $lang_code, $condition);
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $seo_data = db_get_array("SELECT name, dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p ORDER BY dispatch {$limit}", $lang_code, $condition);
    return array($seo_data, $params);
}
Exemplo n.º 4
0
function fn_get_discussions($params, $items_per_page)
{
    // Init filter
    $params = LastView::instance()->update('discussion', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array('?:discussion_posts.*', '?:discussion_messages.message', '?:discussion_rating.rating_value', '?:discussion.*');
    // Define sort fields
    $sortings = array('object' => "?:discussion.object_type", 'name' => "?:discussion_posts.name", 'ip_address' => "?:discussion_posts.ip_address", 'timestamp' => "?:discussion_posts.timestamp", 'status' => "?:discussion_posts.status", 'date' => "?:orders.timestamp", 'total' => "?:orders.total");
    $sorting = db_sort($params, $sortings, 'timestamp', 'desc');
    $condition = $join = '';
    if (isset($params['name']) && fn_string_not_empty($params['name'])) {
        $condition .= db_quote(" AND ?:discussion_posts.name LIKE ?l", "%" . trim($params['name']) . "%");
    }
    if (isset($params['message']) && fn_string_not_empty($params['message'])) {
        $condition .= db_quote(" AND ?:discussion_messages.message LIKE ?l", "%" . trim($params['message']) . "%");
    }
    if (!empty($params['type'])) {
        $condition .= db_quote(" AND ?:discussion.type = ?s", $params['type']);
    }
    if (!empty($params['status'])) {
        $condition .= db_quote(" AND ?:discussion_posts.status = ?s", $params['status']);
    }
    if (!empty($params['post_id'])) {
        $condition .= db_quote(" AND ?:discussion_posts.post_id = ?i", $params['post_id']);
    }
    if (isset($params['ip_address']) && fn_string_not_empty($params['ip_address'])) {
        $condition .= db_quote(" AND ?:discussion_posts.ip_address = ?s", fn_ip_to_db(trim($params['ip_address'])));
    }
    if (!empty($params['rating_value'])) {
        $condition .= db_quote(" AND ?:discussion_rating.rating_value = ?i", $params['rating_value']);
    }
    if (!empty($params['object_type'])) {
        $condition .= db_quote(" AND ?:discussion.object_type = ?s", $params['object_type']);
    }
    $condition .= fn_get_discussion_company_condition('?:discussion.company_id');
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:discussion_posts.timestamp >= ?i AND ?:discussion_posts.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    $join .= " INNER JOIN ?:discussion ON ?:discussion.thread_id = ?:discussion_posts.thread_id";
    $join .= " INNER JOIN ?:discussion_messages ON ?:discussion_messages.post_id = ?:discussion_posts.post_id";
    $join .= " INNER JOIN ?:discussion_rating ON ?:discussion_rating.post_id = ?:discussion_posts.post_id";
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:discussion_posts {$join} WHERE 1 {$condition}");
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $posts = db_get_array("SELECT " . implode(',', $fields) . " FROM ?:discussion_posts {$join} WHERE 1 {$condition} {$sorting} {$limit}");
    foreach ($posts as $k => $post) {
        if (isset($post['ip_address'])) {
            $posts[$k]['ip_address'] = fn_ip_from_db($post['ip_address']);
        }
    }
    return array($posts, $params);
}
Exemplo n.º 5
0
/**
 * Handlers
 */
function fn_yandex_metrika_oauth_info()
{
    if (!fn_string_not_empty(Registry::get('addons.rus_yandex_metrika.application_id')) || !fn_string_not_empty(Registry::get('addons.rus_yandex_metrika.application_password'))) {
        return __('yandex_metrika_oauth_info_part1', array('[callback_uri]' => fn_url('yandex_metrika_tools.oauth')));
    } else {
        $client_id = Registry::get('addons.rus_yandex_metrika.application_id');
        return __('yandex_metrika_oauth_info_part2', array('[auth_uri]' => "https://oauth.yandex.ru/authorize?response_type=code&client_id=" . $client_id, '[edit_app_uri]' => "https://oauth.yandex.ru/client/edit/" . $client_id));
    }
}
Exemplo n.º 6
0
 /**
  * Get blocks for the twigmo homepage
  * @param  string $dispatch        Dispatch of needed location
  * @param  array  $allowed_objects - array of blocks types
  * @return array  blocks
  */
 public static final function getBlocksForLocation($dispatch, $allowed_objects)
 {
     $allowed_page_types = array('T', 'L', 'F');
     $blocks = array();
     $location = Location::instance(fn_twg_get_default_layout_id())->get($dispatch);
     if (!$location) {
         return $blocks;
     }
     $get_cont_params = array('location_id' => $location['location_id']);
     $container = Container::getList($get_cont_params);
     if (!$container or !$container['CONTENT']) {
         return $blocks;
     }
     $grids_params = array('container_ids' => $container['CONTENT']['container_id']);
     $grids = Grid::getList($grids_params);
     if (!$grids) {
         return $blocks;
     }
     $block_grids = Block::instance()->getList(array('?:bm_snapping.*', '?:bm_blocks.*', '?:bm_blocks_descriptions.*'), Grid::getIds($grids));
     $image_params = TwigmoSettings::get('images.catalog');
     foreach ($block_grids as $block_grid) {
         foreach ($block_grid as $block) {
             if ($block['status'] != 'A' or !in_array($block['type'], $allowed_objects)) {
                 continue;
             }
             $block_data = array('block_id' => $block['block_id'], 'title' => $block['name'], 'hide_header' => isset($block['properties']['hide_header']) ? $block['properties']['hide_header'] : 'N', 'user_class' => $block['user_class']);
             $block_scheme = SchemesManager::getBlockScheme($block['type'], array());
             if ($block['type'] == 'html_block') {
                 // Html block
                 if (isset($block['content']['content']) and fn_string_not_empty($block['content']['content'])) {
                     $block_data['html'] = $block['content']['content'];
                 }
             } elseif (!empty($block_scheme['content']) and !empty($block_scheme['content']['items'])) {
                 // Products and categories: get items
                 $template_variable = 'items';
                 $field = $block_scheme['content']['items'];
                 fn_set_hook('render_block_content_pre', $template_variable, $field, $block_scheme, $block);
                 $items = RenderManager::getValue($template_variable, $field, $block_scheme, $block);
                 // Filter pages - only texts, links and forms posible
                 if ($block['type'] == 'pages') {
                     foreach ($items as $item_id => $item) {
                         if (!in_array($item['page_type'], $allowed_page_types)) {
                             unset($items[$item_id]);
                         }
                     }
                 }
                 if (empty($items)) {
                     continue;
                 }
                 $block_data['total_items'] = count($items);
                 // Images
                 if ($block['type'] == 'products' or $block['type'] == 'categories') {
                     $object_type = $block['type'] == 'products' ? 'product' : 'category';
                     foreach ($items as $items_id => $item) {
                         if (!empty($item['main_pair'])) {
                             $main_pair = $item['main_pair'];
                         } else {
                             $main_pair = fn_get_image_pairs($item[$object_type . '_id'], $object_type, 'M', true, true);
                         }
                         if (!empty($main_pair)) {
                             $items[$items_id]['icon'] = TwigmoImage::getApiImageData($main_pair, $object_type, 'icon', $image_params);
                         }
                     }
                 }
                 // Banners properties
                 if ($block['type'] == 'banners') {
                     $rotation = $block['properties']['template'] == 'addons/banners/blocks/carousel.tpl' ? 'Y' : 'N';
                     $block_data['delay'] = $rotation == 'Y' ? $block['properties']['delay'] : 0;
                     $block_data['hide_navigation'] = isset($block['properties']['navigation']) && $block['properties']['navigation'] == 'N' ? 'Y' : 'N';
                 }
                 $block_data[$block['type']] = Api::getAsList($block['type'], $items);
             }
             $blocks[$block['block_id']] = $block_data;
         }
     }
     return $blocks;
 }
Exemplo n.º 7
0
/**
 * Returns store logs
 *
 * @param array $params Search parameters
 * @param int $items_per_page Logs limit
 * @return array Logs with search parameters
 */
function fn_get_logs($params, $items_per_page = 0)
{
    // Init filter
    $params = LastView::instance()->update('logs', $params);
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $sortings = array('timestamp' => array('?:logs.timestamp', '?:logs.log_id'), 'user' => array('?:users.lastname', '?:users.firstname'));
    $fields = array('?:logs.*', '?:users.firstname', '?:users.lastname');
    $sorting = db_sort($params, $sortings, 'timestamp', 'desc');
    $join = "LEFT JOIN ?:users USING(user_id)";
    $condition = '';
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($time_from, $time_to) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:logs.timestamp >= ?i AND ?:logs.timestamp <= ?i)", $time_from, $time_to);
    }
    if (isset($params['q_user']) && fn_string_not_empty($params['q_user'])) {
        $condition .= db_quote(" AND (?:users.lastname LIKE ?l OR ?:users.firstname LIKE ?l)", "%" . trim($params['q_user']) . "%", "%" . trim($params['q_user']) . "%");
    }
    if (!empty($params['q_type'])) {
        $condition .= db_quote(" AND ?:logs.type = ?s", $params['q_type']);
    }
    if (!empty($params['q_action'])) {
        $condition .= db_quote(" AND ?:logs.action = ?s", $params['q_action']);
    }
    if (Registry::get('runtime.company_id')) {
        $condition .= db_quote(" AND ?:logs.company_id = ?i", Registry::get('runtime.company_id'));
    }
    fn_set_hook('admin_get_logs', $params, $condition, $join, $sorting);
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT(?:logs.log_id)) FROM ?:logs ?p WHERE 1 ?p", $join, $condition);
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $data = db_get_array("SELECT " . join(', ', $fields) . " FROM ?:logs ?p WHERE 1 ?p {$sorting} {$limit}", $join, $condition);
    foreach ($data as $k => $v) {
        $data[$k]['backtrace'] = !empty($v['backtrace']) ? unserialize($v['backtrace']) : array();
        $data[$k]['content'] = !empty($v['content']) ? unserialize($v['content']) : array();
    }
    return array($data, $params);
}
Exemplo n.º 8
0
    return array(CONTROLLER_STATUS_OK, "hw_404_fixer.manage");
}
if ($mode == 'manage') {
    $params = $_REQUEST;
    $default_params = array('page' => 1, 'items_per_page' => Registry::get('settings.Appearance.admin_products_per_page'));
    if (is_array($params)) {
        $params = array_merge($default_params, $params);
    } else {
        $params = $default_params;
    }
    $fields = array('?:hw_404.*');
    $sortings = array('id' => '?:hw_404.id', 'url' => '?:hw_404.url', 'timestamp' => '?:hw_404.created', 'redirect' => '?:hw_404.redirect', 'hits' => '?:hw_404.hits', 'redirect_type' => '?:hw_404.redirect_type');
    $auth =& $_SESSION['auth'];
    $condition = '1';
    $join = $limit = $group_by = '';
    if (isset($params['q']) && fn_string_not_empty($params['q'])) {
        $condition .= db_quote(' AND ( url LIKE ?l  OR redirect LIKE ?l OR referer LIKE ?l)', '%' . $params['q'] . '%', '%' . $params['q'] . '%', '%' . $params['q'] . '%');
    }
    $company_id = Registry::get('runtime.company_id');
    if ($company_id > 0) {
        $condition .= db_quote(' AND company_id=?i', $company_id);
    }
    #NEW
    if (!isset($_REQUEST['show']) || $_REQUEST['show'] != 'all') {
        $condition .= db_quote(' AND ( redirect=?s OR redirect IS NULL) AND object_id=?i', '', 0);
    }
    $sorting = db_sort($params, $sortings, 'timestamp', 'desc');
    if (!empty($group_by)) {
        $group_by = ' GROUP BY ' . $group_by;
    }
    if (!empty($params['items_per_page'])) {
Exemplo n.º 9
0
function fn_get_news($params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $fields = array('?:news.*', 'descr.news', 'descr.description');
    // Define sort fields
    $sortings = array('position' => '?:news.position', 'name' => 'descr.news', 'date' => '?:news.date');
    $limit = $condition = '';
    $join = db_quote(" LEFT JOIN ?:news_descriptions AS descr ON descr.news_id = ?:news.news_id AND descr.lang_code = ?s", $lang_code);
    $condition .= AREA == 'A' ? '1 ' : " ?:news.status = 'A'";
    $condition .= fn_get_localizations_condition('?:news.localization');
    // Get additional information about companies
    if (fn_allowed_for('ULTIMATE')) {
        $fields[] = ' ?:companies.company as company';
        $sortings['company'] = 'company';
        $join .= db_quote(" LEFT JOIN ?:companies ON ?:companies.company_id = ?:news.company_id");
    }
    if (isset($params['q']) && fn_string_not_empty($params['q'])) {
        $params['q'] = trim($params['q']);
        if ($params['match'] == 'any') {
            $pieces = fn_explode(' ', $params['q']);
            $search_type = ' OR ';
        } elseif ($params['match'] == 'all') {
            $pieces = fn_explode(' ', $params['q']);
            $search_type = ' AND ';
        } else {
            $pieces = array($params['q']);
            $search_type = '';
        }
        $_condition = array();
        foreach ($pieces as $piece) {
            if (strlen($piece) == 0) {
                continue;
            }
            $tmp = array();
            $tmp[] = db_quote("descr.news LIKE ?l", "%{$piece}%");
            $tmp[] = db_quote("descr.description LIKE ?l", "%{$piece}%");
            $_condition[] = '(' . join(' OR ', $tmp) . ')';
        }
        $_cond = implode($search_type, $_condition);
        if (!empty($_condition)) {
            $condition .= ' AND (' . $_cond . ') ';
        }
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:news.date >= ?i AND ?:news.date <= ?i)", $params['time_from'], $params['time_to']);
    }
    if (!empty($params['item_ids'])) {
        $condition .= db_quote(' AND ?:news.news_id IN (?n)', explode(',', $params['item_ids']));
    }
    $limit = '';
    if (!empty($params['limit'])) {
        $limit = db_quote(" LIMIT 0, ?i", $params['limit']);
    } elseif (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(?:news.news_id) FROM ?:news ?p WHERE ?p", $join, $condition);
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    fn_set_hook('get_news', $params, $fields, $join, $condition, $sorting, $limit, $lang_code);
    $sorting = db_sort($params, $sortings, 'date', 'desc');
    // Used for Extended search
    if (!empty($params['get_conditions'])) {
        return array($fields, $join, $condition);
    }
    $fields = join(', ', $fields);
    $news = db_get_array("SELECT ?p FROM ?:news ?p WHERE ?p ?p ?p", $fields, $join, $condition, $sorting, $limit);
    /**
     * Get additional data for selected news
     *
     * @param array  $news      news list
     * @param string $lang_code language code
     */
    fn_set_hook('get_news_post', $news, $lang_code);
    return array($news, $params);
}
Exemplo n.º 10
0
function fn_tags_get_pages(&$params, &$join, &$conditions, &$fields, &$group_by, &$sortings)
{
    if (Registry::get('addons.tags.tags_for_pages') == 'Y') {
        if (isset($params['tag']) && fn_string_not_empty($params['tag'])) {
            $fields[] = '?:tag_links.*, ?:tags.tag, ?:tags.tag_id, ?:tags.timestamp';
            $join .= db_quote(" INNER JOIN ?:tag_links ON ?:pages.page_id = ?:tag_links.object_id");
            $join .= db_quote(" INNER JOIN ?:tags ON ?:tag_links.tag_id = ?:tags.tag_id ?p", fn_get_tags_company_condition('?:tags.company_id'));
            $conditions .= db_quote(" AND (?:tags.tag = ?s) AND ?:tag_links.object_type = 'A' ", trim($params['tag']));
        }
    }
    return true;
}
Exemplo n.º 11
0
function fn_tags_get_users(&$params, &$fields, &$sortings, &$condition, &$join)
{
    if (isset($params['tag']) && fn_string_not_empty($params['tag'])) {
        $join .= db_quote(" LEFT JOIN ?:tag_links ON ?:users.user_id = ?:tag_links.user_id INNER JOIN ?:tags ON ?:tag_links.tag_id = ?:tags.tag_id ");
        $condition['tags_tag'] = db_quote(" AND ?:tags.tag = ?s", $params['tag']);
    }
}
Exemplo n.º 12
0
function fn_get_rma_returns($params, $items_per_page = 0)
{
    // Init filter
    $params = LastView::instance()->update('rma', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array('DISTINCT ?:rma_returns.return_id', '?:rma_returns.order_id', '?:rma_returns.timestamp', '?:rma_returns.status', '?:rma_returns.total_amount', '?:rma_property_descriptions.property AS action', '?:users.firstname', '?:users.lastname');
    // Define sort fields
    $sortings = array('return_id' => "?:rma_returns.return_id", 'timestamp' => "?:rma_returns.timestamp", 'order_id' => "?:rma_returns.order_id", 'status' => "?:rma_returns.status", 'amount' => "?:rma_returns.total_amount", 'action' => "?:rma_returns.action", 'customer' => "?:users.lastname");
    $sorting = db_sort($params, $sortings, 'timestamp', 'desc');
    $join = $condition = $group = '';
    if (isset($params['cname']) && fn_string_not_empty($params['cname'])) {
        $arr = fn_explode(' ', $params['cname']);
        foreach ($arr as $k => $v) {
            if (!fn_string_not_empty($v)) {
                unset($arr[$k]);
            }
        }
        if (sizeof($arr) == 2) {
            $condition .= db_quote(" AND ?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l", "%" . array_shift($arr) . "%", "%" . array_shift($arr) . "%");
        } else {
            $condition .= db_quote(" AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)", "%" . trim($params['cname']) . "%", "%" . trim($params['cname']) . "%");
        }
    }
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition .= db_quote(" AND ?:users.email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    if (isset($params['rma_amount_from']) && fn_is_numeric($params['rma_amount_from'])) {
        $condition .= db_quote("AND ?:rma_returns.total_amount >= ?d", $params['rma_amount_from']);
    }
    if (isset($params['rma_amount_to']) && fn_is_numeric($params['rma_amount_to'])) {
        $condition .= db_quote("AND ?:rma_returns.total_amount <= ?d", $params['rma_amount_to']);
    }
    if (!empty($params['action'])) {
        $condition .= db_quote(" AND ?:rma_returns.action = ?s", $params['action']);
    }
    if (!empty($params['return_id'])) {
        $condition .= db_quote(" AND ?:rma_returns.return_id = ?i", $params['return_id']);
    }
    if (!empty($params['request_status'])) {
        $condition .= db_quote(" AND ?:rma_returns.status IN (?a)", $params['request_status']);
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:rma_returns.timestamp >= ?i AND ?:rma_returns.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    if (!empty($params['order_id'])) {
        $condition .= db_quote(" AND ?:rma_returns.order_id = ?i", $params['order_id']);
    }
    if (isset($params['user_id'])) {
        $condition .= db_quote(" AND ?:rma_returns.user_id = ?i", $params['user_id']);
    }
    if (!empty($params['order_status'])) {
        $condition .= db_quote(" AND ?:orders.status IN (?a)", $params['order_status']);
    }
    if (!empty($params['p_ids']) || !empty($params['product_view_id'])) {
        $arr = strpos($params['p_ids'], ',') !== false || !is_array($params['p_ids']) ? explode(',', $params['p_ids']) : $params['p_ids'];
        if (empty($params['product_view_id'])) {
            $condition .= db_quote(" AND ?:order_details.product_id IN (?n)", $arr);
        } else {
            $condition .= db_quote(" AND ?:order_details.product_id IN (?n)", db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true))));
        }
        $join .= " LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id";
        $group .= db_quote(" GROUP BY ?:rma_returns.return_id HAVING COUNT(?:orders.order_id) >= ?i", count($arr));
    }
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT ?:rma_returns.return_id) FROM ?:rma_returns LEFT JOIN ?:rma_return_products ON ?:rma_return_products.return_id = ?:rma_returns.return_id LEFT JOIN ?:rma_property_descriptions ON ?:rma_property_descriptions.property_id = ?:rma_returns.action LEFT JOIN ?:users ON ?:rma_returns.user_id = ?:users.user_id LEFT JOIN ?:orders ON ?:rma_returns.order_id = ?:orders.order_id {$join} WHERE 1 {$condition} {$group}");
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $return_requests = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:rma_returns LEFT JOIN ?:rma_return_products ON ?:rma_return_products.return_id = ?:rma_returns.return_id LEFT JOIN ?:rma_property_descriptions ON (?:rma_property_descriptions.property_id = ?:rma_returns.action AND ?:rma_property_descriptions.lang_code = ?s) LEFT JOIN ?:users ON ?:rma_returns.user_id = ?:users.user_id LEFT JOIN ?:orders ON ?:rma_returns.order_id = ?:orders.order_id {$join} WHERE 1 {$condition} {$group} {$sorting} {$limit}", AREA == 'C' ? CART_LANGUAGE : DESCR_SL);
    LastView::instance()->processResults('rma_returns', $return_requests, $params);
    return array($return_requests, $params);
}
Exemplo n.º 13
0
function fn_get_call_requests($params = array(), $lang_code = CART_LANGUAGE)
{
    // Init filter
    $params = LastView::instance()->update('call_requests', $params);
    $params = array_merge(array('items_per_page' => 0, 'page' => 1), $params);
    $fields = array('r.*', 'o.status as order_status', 'd.product');
    $joins = array(db_quote("LEFT JOIN ?:users u USING(user_id)"), db_quote("LEFT JOIN ?:orders o USING(order_id)"), db_quote("LEFT JOIN ?:product_descriptions d ON d.product_id = r.product_id AND d.lang_code = ?s", $lang_code));
    $sortings = array('id' => 'r.request_id', 'date' => 'r.timestamp', 'status' => 'r.status', 'name' => 'r.name', 'phone' => 'r.phone', 'user_id' => 'r.user_id', 'user' => array('u.lastname', 'u.firstname'), 'order' => 'r.order_id', 'order_status' => 'o.status');
    $condition = array();
    if (isset($params['id']) && fn_string_not_empty($params['id'])) {
        $params['id'] = trim($params['id']);
        $condition[] = db_quote("r.request_id = ?i", $params['id']);
    }
    if (isset($params['name']) && fn_string_not_empty($params['name'])) {
        $params['name'] = trim($params['name']);
        $condition[] = db_quote("r.name LIKE ?l", '%' . $params['name'] . '%');
    }
    if (isset($params['phone']) && fn_string_not_empty($params['phone'])) {
        $params['phone'] = trim($params['phone']);
        $condition[] = db_quote("r.phone LIKE ?l", '%' . $params['phone'] . '%');
    }
    if (!empty($params['status'])) {
        $condition[] = db_quote("r.status = ?s", $params['status']);
    }
    if (!empty($params['order_status'])) {
        $condition[] = db_quote("o.status = ?s", $params['order_status']);
    }
    if (!empty($params['user_id'])) {
        $condition[] = db_quote("r.user_id = ?s", $params['user_id']);
    }
    if (!empty($params['order_exists'])) {
        $sign = $params['order_exists'] == 'Y' ? '<>' : '=';
        $condition[] = db_quote("r.order_id ?p 0", $sign);
    }
    $fields_str = implode(', ', $fields);
    $joins_str = ' ' . implode(' ', $joins);
    $condition_str = $condition ? ' WHERE ' . implode(' AND ', $condition) : '';
    $sorting_str = db_sort($params, $sortings, 'date', 'desc');
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(r.request_id) FROM ?:call_requests r" . $joins_str . $condition_str);
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $items = db_get_array("SELECT " . $fields_str . " FROM ?:call_requests r" . $joins_str . $condition_str . $sorting_str . $limit);
    if (!empty($items)) {
        $cart_product_ids = array();
        foreach ($items as &$item) {
            if (!empty($item['cart_products'])) {
                $item['cart_products'] = unserialize($item['cart_products']);
                foreach ($item['cart_products'] as $cart_product) {
                    $cart_product_ids[] = $cart_product['product_id'];
                }
            }
        }
        $cart_product_names = db_get_hash_single_array("SELECT product_id, product FROM ?:product_descriptions WHERE product_id IN(?n) AND lang_code = ?s", array('product_id', 'product'), array_unique($cart_product_ids), $lang_code);
        foreach ($items as &$item) {
            if (!empty($item['cart_products'])) {
                foreach ($item['cart_products'] as &$cart_product) {
                    if (!empty($cart_product_names[$cart_product['product_id']])) {
                        $cart_product['product'] = $cart_product_names[$cart_product['product_id']];
                    }
                }
            }
        }
    }
    return array($items, $params);
}
Exemplo n.º 14
0
/**
 * Getting users list
 *
 * @param  array  $params          Params list
 * @param  array  $auth            Auth
 * @param  int    $items_per_page  Items per page
 * @param  str    $custom_view     Custom view
 * @return array
 */
function fn_get_users($params, &$auth, $items_per_page = 0, $custom_view = '')
{
    /**
     * Actions before getting users list
     *
     * @param array $params         Params list
     * @param array $auth           Auth data
     * @param int   $items_per_page Items per page
     * @param str   $custom_view    Custom view
     */
    fn_set_hook('get_users_pre', $params, $auth, $items_per_page, $custom_view);
    // Init filter
    $_view = !empty($custom_view) ? $custom_view : 'users';
    $params = LastView::instance()->update($_view, $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array("?:users.user_id", "?:users.user_login", "?:users.is_root", "?:users.timestamp", "?:users.user_type", "?:users.status", "?:users.firstname", "?:users.lastname", "?:users.email", "?:users.company", "?:users.company_id", "?:companies.company as company_name");
    // Define sort fields
    $sortings = array('id' => "?:users.user_id", 'username' => "?:users.user_login", 'email' => "?:users.email", 'name' => array("?:users.lastname", "?:users.firstname"), 'date' => "?:users.timestamp", 'type' => "?:users.user_type", 'status' => "?:users.status", 'company' => "company_name");
    if (isset($params['compact']) && $params['compact'] == 'Y') {
        $union_condition = ' OR ';
    } else {
        $union_condition = ' AND ';
    }
    $condition = array();
    $join = $group = '';
    $group .= " GROUP BY ?:users.user_id";
    if (isset($params['company']) && fn_string_not_empty($params['company'])) {
        $condition['company'] = db_quote(" AND ?:users.company LIKE ?l", "%" . trim($params['company']) . "%");
    }
    if (isset($params['name']) && fn_string_not_empty($params['name'])) {
        $arr = fn_explode(' ', $params['name']);
        foreach ($arr as $k => $v) {
            if (!fn_string_not_empty($v)) {
                unset($arr[$k]);
            }
        }
        if (sizeof($arr) == 2) {
            $condition['name'] = db_quote(" AND (?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l)", "%" . array_shift($arr) . "%", "%" . array_shift($arr) . "%");
        } else {
            $condition['name'] = db_quote(" AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)", "%" . trim($params['name']) . "%", "%" . trim($params['name']) . "%");
        }
    }
    if (isset($params['user_login']) && fn_string_not_empty($params['user_login'])) {
        $condition['user_login'] = db_quote(" {$union_condition} ?:users.user_login LIKE ?l", "%" . trim($params['user_login']) . "%");
    }
    if (!empty($params['tax_exempt'])) {
        $condition['tax_exempt'] = db_quote(" AND ?:users.tax_exempt = ?s", $params['tax_exempt']);
    }
    if (!fn_allowed_for('ULTIMATE:FREE')) {
        if (isset($params['usergroup_id']) && $params['usergroup_id'] != ALL_USERGROUPS) {
            if (!empty($params['usergroup_id'])) {
                $join .= db_quote(" LEFT JOIN ?:usergroup_links ON ?:usergroup_links.user_id = ?:users.user_id AND ?:usergroup_links.usergroup_id = ?i", $params['usergroup_id']);
                $condition['usergroup_links'] = " AND ?:usergroup_links.status = 'A'";
            } else {
                $join .= " LEFT JOIN ?:usergroup_links ON ?:usergroup_links.user_id = ?:users.user_id AND ?:usergroup_links.status = 'A'";
                $condition['usergroup_links'] = " AND ?:usergroup_links.user_id IS NULL";
            }
        }
    }
    if (!empty($params['status'])) {
        $condition['status'] = db_quote(" AND ?:users.status = ?s", $params['status']);
    }
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition['email'] = db_quote(" {$union_condition} ?:users.email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    if (isset($params['address']) && fn_string_not_empty($params['address'])) {
        $condition['address'] = db_quote(" AND (?:user_profiles.b_address LIKE ?l OR ?:user_profiles.s_address LIKE ?l)", "%" . trim($params['address']) . "%", "%" . trim($params['address']) . "%");
    }
    if (isset($params['zipcode']) && fn_string_not_empty($params['zipcode'])) {
        $condition['zipcode'] = db_quote(" AND (?:user_profiles.b_zipcode LIKE ?l OR ?:user_profiles.s_zipcode LIKE ?l)", "%" . trim($params['zipcode']) . "%", "%" . trim($params['zipcode']) . "%");
    }
    if (!empty($params['country'])) {
        $condition['country'] = db_quote(" AND (?:user_profiles.b_country LIKE ?l OR ?:user_profiles.s_country LIKE ?l)", "%{$params['country']}%", "%{$params['country']}%");
    }
    if (isset($params['state']) && fn_string_not_empty($params['state'])) {
        $condition['state'] = db_quote(" AND (?:user_profiles.b_state LIKE ?l OR ?:user_profiles.s_state LIKE ?l)", "%" . trim($params['state']) . "%", "%" . trim($params['state']) . "%");
    }
    if (isset($params['city']) && fn_string_not_empty($params['city'])) {
        $condition['city'] = db_quote(" AND (?:user_profiles.b_city LIKE ?l OR ?:user_profiles.s_city LIKE ?l)", "%" . trim($params['city']) . "%", "%" . trim($params['city']) . "%");
    }
    if (!empty($params['user_id'])) {
        $condition['user_id'] = db_quote(' AND ?:users.user_id IN (?n)', $params['user_id']);
    }
    if (!empty($params['p_ids']) || !empty($params['product_view_id'])) {
        $arr = strpos($params['p_ids'], ',') !== false || !is_array($params['p_ids']) ? explode(',', $params['p_ids']) : $params['p_ids'];
        if (empty($params['product_view_id'])) {
            $condition['order_product_id'] = db_quote(" AND ?:order_details.product_id IN (?n)", $arr);
        } else {
            $condition['order_product_id'] = db_quote(" AND ?:order_details.product_id IN (?n)", db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true))));
        }
        $join .= db_quote(" LEFT JOIN ?:orders ON ?:orders.user_id = ?:users.user_id AND ?:orders.is_parent_order != 'Y' LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id");
    }
    if (defined('RESTRICTED_ADMIN')) {
        // FIXME: NOT GOOD
        $condition['restricted_admin'] = db_quote(" AND ((?:users.user_type != 'A' AND ?:users.user_type != 'V') OR (?:users.user_type = 'A' AND ?:users.user_id = ?i))", $auth['user_id']);
    }
    // sometimes other vendor's admins could buy products from other vendors.
    if (!empty($params['user_type']) && (!($params['user_type'] == 'C' && Registry::get('runtime.company_id')) || fn_allowed_for('ULTIMATE'))) {
        $condition['user_type'] = db_quote(' AND ?:users.user_type = ?s', $params['user_type']);
    } else {
        // Get active user types
        $user_types = array_keys(fn_get_user_types());
        // Select only necessary groups frm all available
        if (!empty($params['user_types'])) {
            $user_types = array_intersect($user_types, $params['user_types']);
        }
        if (!empty($params['exclude_user_types'])) {
            $user_types = array_diff($user_types, $params['exclude_user_types']);
        }
        $condition['user_type'] = db_quote(" AND ?:users.user_type IN(?a)", $user_types);
    }
    $join .= db_quote(" LEFT JOIN ?:user_profiles ON ?:user_profiles.user_id = ?:users.user_id");
    $join .= db_quote(" LEFT JOIN ?:companies ON ?:companies.company_id = ?:users.company_id");
    /**
     * Prepare params for getting users query
     *
     * @param array $params    Params list
     * @param array $fields    Fields list
     * @param array $sortings  Sorting variants
     * @param array $condition Conditions set
     * @param str   $join      Joins list
     * @param array $auth      Auth data
     */
    fn_set_hook('get_users', $params, $fields, $sortings, $condition, $join, $auth);
    $sorting = db_sort($params, $sortings, 'name', 'asc');
    // Used for Extended search
    if (!empty($params['get_conditions'])) {
        return array($fields, $join, $condition);
    }
    // Paginate search results
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT(?:users.user_id)) FROM ?:users {$join} WHERE 1 " . implode(' ', $condition));
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $users = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:users {$join} WHERE 1" . implode('', $condition) . " {$group} {$sorting} {$limit}");
    LastView::instance()->processResults('users', $users, $params);
    /**
     * Actions after getting users list
     *
     * @param array $users  Users list
     * @param array $params Params list
     * @param array $auth   Auth data
     */
    fn_set_hook('get_users_post', $users, $params, $auth);
    return array($users, $params);
}
Exemplo n.º 15
0
function fn_ult_get_language_variable(&$fields, &$tables, &$left_join, &$condition, &$params)
{
    if (Registry::get('runtime.company_id')) {
        $left_join[] = db_quote("?:ult_language_values ON ?:ult_language_values.name = lang.name AND company_id = ?i AND ?:ult_language_values.lang_code = lang.lang_code", Registry::get('runtime.company_id'));
        unset($fields['lang.value']);
        $fields['IF(?:ult_language_values.value IS NULL, lang.value, ?:ult_language_values.value) as value'] = true;
        if (isset($params['q']) && fn_string_not_empty($params['q'])) {
            $condition['param2'] = db_quote('(IF(?:ult_language_values.name IS NULL, lang.name, ?:ult_language_values.name) LIKE ?l OR IF(?:ult_language_values.value IS NULL, lang.value, ?:ult_language_values.value) LIKE ?l)', '%' . trim($params['q']) . '%', '%' . trim($params['q']) . '%');
        }
    }
}
Exemplo n.º 16
0
 public function prepare()
 {
     $condition = array();
     $table_name = $this->model->getTableName();
     $search_fields = $this->model->getSearchFields();
     $primary_field = $this->model->getPrimaryField();
     if (isset($this->params['ids'])) {
         $condition[] = db_quote("{$table_name}.{$primary_field} IN(?a)", (array) $this->params['ids']);
     }
     if (isset($this->params['not_ids'])) {
         $condition[] = db_quote("{$table_name}.{$primary_field} NOT IN(?a)", (array) $this->params['not_ids']);
     }
     if (!empty($search_fields['number'])) {
         foreach ($search_fields['number'] as $_key => $_field) {
             $param = !is_numeric($_key) ? $_key : $_field;
             $fields = (array) $_field;
             if (isset($this->params[$param]) && fn_string_not_empty($this->params[$param])) {
                 $sub_condition = array();
                 foreach ($fields as $field) {
                     $sub_condition[] = db_quote("{$field} = ?i", $this->params[$param]);
                 }
                 $condition[] = $this->mixSubConditions($sub_condition);
             }
         }
     }
     if (!empty($search_fields['range'])) {
         $ranges = array('from' => '>=', 'to' => '<=');
         foreach ($search_fields['range'] as $_key => $_field) {
             $param = !is_numeric($_key) ? $_key : $_field;
             $fields = (array) $_field;
             foreach ($ranges as $_range_name => $_range_symbol) {
                 if (!empty($this->params[$param . '_' . $_range_name])) {
                     $sub_condition = array();
                     foreach ($fields as $field) {
                         $sub_condition[] = db_quote("{$field} ?p ?i", $_range_symbol, $this->params[$param . '_' . $_range_name]);
                     }
                     $condition[] = $this->mixSubConditions($sub_condition);
                 }
             }
         }
     }
     if (!empty($search_fields['in'])) {
         foreach ($search_fields['in'] as $_key => $_field) {
             $param = !is_numeric($_key) ? $_key : $_field;
             $fields = (array) $_field;
             if (!empty($this->params[$param])) {
                 $_in_values = !is_array($this->params[$param]) ? explode(',', $this->params[$param]) : $this->params[$param];
                 $sub_condition = array();
                 foreach ($fields as $field) {
                     $sub_condition[] = db_quote("{$field} IN(?a)", $_in_values);
                 }
                 $condition[] = $this->mixSubConditions($sub_condition);
             }
         }
     }
     if (!empty($search_fields['not_in'])) {
         foreach ($search_fields['not_in'] as $_key => $_field) {
             $param = !is_numeric($_key) ? $_key : $_field;
             $fields = (array) $_field;
             if (!empty($this->params[$param])) {
                 $_in_values = !is_array($this->params[$param]) ? explode(',', $this->params[$param]) : $this->params[$param];
                 $sub_condition = array();
                 foreach ($fields as $field) {
                     $sub_condition[] = db_quote("{$field} NOT IN(?a)", $_in_values);
                 }
                 $condition[] = $this->mixSubConditions($sub_condition);
             }
         }
     }
     if (!empty($search_fields['string'])) {
         foreach ($search_fields['string'] as $_key => $_field) {
             $param = !is_numeric($_key) ? $_key : $_field;
             $fields = (array) $_field;
             if (isset($this->params[$param]) && fn_string_not_empty($this->params[$param])) {
                 $sub_condition = array();
                 foreach ($fields as $field) {
                     $sub_condition[] = db_quote("{$field} LIKE ?s", trim($this->params[$param]));
                 }
                 $condition[] = $this->mixSubConditions($sub_condition);
             }
         }
     }
     if (!empty($search_fields['text'])) {
         foreach ($search_fields['text'] as $_key => $_field) {
             $param = !is_numeric($_key) ? $_key : $_field;
             $fields = (array) $_field;
             if (isset($this->params[$param]) && fn_string_not_empty($this->params[$param])) {
                 $sub_condition = array();
                 $like = '%' . trim($this->params[$param]) . '%';
                 foreach ($fields as $field) {
                     $sub_condition[] = db_quote("{$field} LIKE ?l", $like);
                 }
                 $condition[] = $this->mixSubConditions($sub_condition);
             }
         }
     }
     if (!empty($search_fields['time'])) {
         $process_time = function ($time) {
             return str_replace('.', '/', $time);
         };
         foreach ($search_fields['time'] as $_key => $_field) {
             $param = !is_numeric($_key) ? $_key : $_field;
             $fields = (array) $_field;
             $period = !empty($this->params[$param . 'period']) ? $this->params[$param . 'period'] : null;
             $from = !empty($this->params[$param . 'time_from']) ? $this->params[$param . 'time_from'] : 0;
             $to = !empty($this->params[$param . 'time_to']) ? $this->params[$param . 'time_to'] : 0;
             if (!empty($from) || !empty($to)) {
                 list($from, $to) = fn_create_periods(array('period' => $period, 'time_from' => $process_time($from), 'time_to' => $process_time($to)));
                 $sub_condition = array();
                 foreach ($fields as $field) {
                     $sub_condition[] = db_quote("({$field} >= ?i AND {$field} <= ?i)", $from, $to);
                 }
                 $condition[] = $this->mixSubConditions($sub_condition);
             } else {
                 if (!empty($this->params[$param . '_from'])) {
                     $sub_condition = array();
                     foreach ($fields as $field) {
                         $sub_condition[] = db_quote("{$field} >= ?i", $this->params[$param . '_from']);
                     }
                     $condition[] = $this->mixSubConditions($sub_condition);
                 }
                 if (!empty($this->params[$param . '_to'])) {
                     $sub_condition = array();
                     foreach ($fields as $field) {
                         $sub_condition[] = db_quote("{$field} <= ?i", $this->params[$param . '_to']);
                     }
                     $condition[] = $this->mixSubConditions($sub_condition);
                 }
             }
         }
     }
     $this->result = array_filter(array_merge($condition, (array) $this->model->getExtraCondition($this->params)));
 }
Exemplo n.º 17
0
function fn_get_carts($params, $items_per_page = 0)
{
    // Init filter
    $params = LastView::instance()->update('carts', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array('?:user_session_products.user_id', '?:users.firstname', '?:users.lastname', '?:user_session_products.timestamp AS date');
    // Define sort fields
    $sortings = array('customer' => "CONCAT(?:users.lastname, ?:users.firstname)", 'date' => "?:user_session_products.timestamp");
    if (fn_allowed_for('ULTIMATE')) {
        $sortings['company_id'] = "?:user_session_products.company_id";
    }
    $sorting = db_sort($params, $sortings, 'customer', 'asc');
    $condition = $join = '';
    $group = " GROUP BY ?:user_session_products.user_id";
    $group_post = '';
    if (isset($params['cname']) && fn_string_not_empty($params['cname'])) {
        $arr = fn_explode(' ', $params['cname']);
        foreach ($arr as $k => $v) {
            if (!fn_string_not_empty($v)) {
                unset($arr[$k]);
            }
        }
        if (sizeof($arr) == 2) {
            $condition .= db_quote(" AND ?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l", "%" . array_shift($arr) . "%", "%" . array_shift($arr) . "%");
        } else {
            $condition .= db_quote(" AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)", "%" . trim($params['cname']) . "%", "%" . trim($params['cname']) . "%");
        }
    }
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition .= db_quote(" AND ?:users.email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    if (!empty($params['user_id'])) {
        $condition .= db_quote(" AND ?:user_session_products.user_id = ?i", $params['user_id']);
    }
    if (!empty($params['online_only'])) {
        $sessions = Session::getOnline('C');
        if (!empty($sessions)) {
            $condition .= db_quote(" AND ?:user_session_products.session_id IN (?a)", $sessions);
        } else {
            $condition .= db_quote(" AND 0");
        }
    }
    if (!empty($params['with_info_only'])) {
        $condition .= db_quote(" AND ?:users.email != ''");
    }
    if (!empty($params['users_type'])) {
        if ($params['users_type'] == 'R') {
            $condition .= db_quote(" AND !ISNULL(?:users.user_id)");
        } elseif ($params['users_type'] == 'G') {
            $condition .= db_quote(" AND ISNULL(?:users.user_id)");
        }
    }
    if (!empty($params['total_from']) || !empty($params['total_to'])) {
        $having = '';
        if (fn_is_numeric($params['total_from'])) {
            $having .= db_quote(" AND SUM(price * amount) >= ?d", $params['total_from']);
        }
        if (fn_is_numeric($params['total_to'])) {
            $having .= db_quote(" AND SUM(price * amount) <= ?d", $params['total_to']);
        }
        if (!empty($having)) {
            $users4total = db_get_fields("SELECT user_id FROM ?:user_session_products GROUP BY user_id HAVING 1 {$having}");
            if (!empty($users4total)) {
                $condition .= db_quote(" AND (?:user_session_products.user_id IN (?n))", $users4total);
            } else {
                $condition .= " AND (?:user_session_products.user_id = 'no')";
            }
        }
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:user_session_products.timestamp >= ?i AND ?:user_session_products.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    $_condition = array();
    if (!empty($params['product_type_c'])) {
        $_condition[] = "?:user_session_products.type = 'C'";
    }
    if (!empty($params['product_type_w']) && $params['product_type_w'] == 'Y') {
        $_condition[] = "?:user_session_products.type = 'W'";
    }
    if (!empty($_condition)) {
        $condition .= " AND (" . implode(" OR ", $_condition) . ")";
    }
    if (!empty($params['p_ids']) || !empty($params['product_view_id'])) {
        $arr = strpos($params['p_ids'], ',') !== false || !is_array($params['p_ids']) ? explode(',', $params['p_ids']) : $params['p_ids'];
        if (empty($params['product_view_id'])) {
            $condition .= db_quote(" AND ?:user_session_products.product_id IN (?n)", $arr);
        } else {
            $condition .= db_quote(" AND ?:user_session_products.product_id IN (?n)", db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true))));
        }
        $group_post .= " HAVING COUNT(?:user_session_products.user_id) >= " . count($arr);
    }
    $join .= " LEFT JOIN ?:users ON ?:user_session_products.user_id = ?:users.user_id";
    // checking types for retrieving from the database
    $type_restrictions = array('C');
    fn_set_hook('get_carts', $type_restrictions, $params, $condition, $join, $fields, $group, $array_index_field);
    if (!empty($type_restrictions) && is_array($type_restrictions)) {
        $condition .= " AND ?:user_session_products.type IN ('" . implode("', '", $type_restrictions) . "')";
    }
    $carts_list = array();
    $group .= $group_post;
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    if (fn_allowed_for('ULTIMATE')) {
        $group = " GROUP BY ?:user_session_products.user_id, ?:user_session_products.company_id";
    }
    $carts_list = db_get_array("SELECT SQL_CALC_FOUND_ROWS " . implode(', ', $fields) . " FROM ?:user_session_products {$join} WHERE 1 {$condition} {$group} {$sorting} {$limit}");
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_found_rows();
    }
    unset($_SESSION['abandoned_carts']);
    return array($carts_list, $params);
}
    function content_55e61e6bb11d10_64552035($_smarty_tpl)
    {
        if (!is_callable('smarty_block_hook')) {
            include '/var/www/html/market/app/functions/smarty_plugins/block.hook.php';
        }
        fn_preload_lang_vars(array('contact_information', 'user_profile_info', 'text_multiprofile_notice', 'billing_address', 'shipping_address', 'shipping_address', 'usergroup', 'status', 'no_data', 'allow_api_access', 'api_key', 'new_profile', 'editing_profile', 'editing_profile', 'editing_profile', 'view_all_orders', 'act_on_behalf', 'delete', 'create', 'notify_user'));
        if ($_smarty_tpl->tpl_vars['user_data']->value) {
            ?>
    <?php 
            $_smarty_tpl->tpl_vars["id"] = new Smarty_variable($_smarty_tpl->tpl_vars['user_data']->value['user_id'], null, 0);
        } else {
            ?>
    <?php 
            $_smarty_tpl->tpl_vars["id"] = new Smarty_variable(0, null, 0);
        }
        ?>

<?php 
        echo $_smarty_tpl->getSubTemplate("views/profiles/components/profiles_scripts.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);
        ?>


<form name="profile_form" action="<?php 
        echo htmlspecialchars(fn_url(''), ENT_QUOTES, 'UTF-8');
        ?>
" method="post" class="form-horizontal form-edit form-table <?php 
        if ($_smarty_tpl->tpl_vars['runtime']->value['company_id'] && $_smarty_tpl->tpl_vars['id']->value && $_smarty_tpl->tpl_vars['user_data']->value['company_id'] != $_smarty_tpl->tpl_vars['runtime']->value['company_id'] && $_smarty_tpl->tpl_vars['id']->value != $_smarty_tpl->tpl_vars['auth']->value['user_id'] || $_smarty_tpl->tpl_vars['hide_inputs']->value) {
            ?>
 cm-hide-inputs<?php 
        }
        ?>
">
<?php 
        $_smarty_tpl->_capture_stack[0][] = array("mainbox", null, null);
        ob_start();
        ?>

<?php 
        $_smarty_tpl->_capture_stack[0][] = array("tabsbox", null, null);
        ob_start();
        ?>
    <?php 
        $_smarty_tpl->tpl_vars['hide_inputs'] = new Smarty_variable(false, null, 0);
        ?>

    <?php 
        if ($_smarty_tpl->tpl_vars['user_data']->value['user_type'] == $_smarty_tpl->tpl_vars['auth']->value['user_type'] && $_smarty_tpl->tpl_vars['user_data']->value['is_root'] == 'Y' && $_smarty_tpl->tpl_vars['user_data']->value['user_id'] != $_smarty_tpl->tpl_vars['auth']->value['user_id'] && (!$_smarty_tpl->tpl_vars['user_data']->value['company_id'] || $_smarty_tpl->tpl_vars['user_data']->value['company_id'] == $_smarty_tpl->tpl_vars['auth']->value['company_id'])) {
            ?>
        <?php 
            $_smarty_tpl->tpl_vars['hide_inputs'] = new Smarty_variable(true, null, 0);
            ?>
    <?php 
        }
        ?>

    <?php 
        if (fn_allowed_for("ULTIMATE") && !fn_allow_save_object($_smarty_tpl->tpl_vars['user_data']->value, "users") && $_smarty_tpl->tpl_vars['id']->value && !fn_ult_check_users_usergroup_companies($_smarty_tpl->tpl_vars['id']->value) && $_smarty_tpl->tpl_vars['user_data']->value['user_id'] != $_smarty_tpl->tpl_vars['auth']->value['user_id']) {
            ?>
        <?php 
            $_smarty_tpl->tpl_vars['hide_inputs'] = new Smarty_variable(true, null, 0);
            ?>
    <?php 
        }
        ?>

    <?php 
        if (fn_allowed_for("MULTIVENDOR") && (!fn_allow_save_object($_smarty_tpl->tpl_vars['user_data']->value, "users") || $_smarty_tpl->tpl_vars['runtime']->value['company_id'] && ($_REQUEST['user_type'] == 'C' || fn_string_not_empty($_smarty_tpl->tpl_vars['user_data']->value['company_id']) && $_smarty_tpl->tpl_vars['user_data']->value['company_id'] != $_smarty_tpl->tpl_vars['runtime']->value['company_id'])) && $_smarty_tpl->tpl_vars['user_data']->value['user_id'] != $_smarty_tpl->tpl_vars['auth']->value['user_id']) {
            ?>
        <?php 
            $_smarty_tpl->tpl_vars['hide_inputs'] = new Smarty_variable(true, null, 0);
            ?>
    <?php 
        }
        ?>

    <input type="hidden" name="user_id" value="<?php 
        echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
        ?>
" />
    <input type="hidden" class="cm-no-hide-input" name="selected_section" id="selected_section" value="<?php 
        echo htmlspecialchars($_smarty_tpl->tpl_vars['selected_section']->value, ENT_QUOTES, 'UTF-8');
        ?>
" />
    <input type="hidden" class="cm-no-hide-input" name="user_type" value="<?php 
        echo htmlspecialchars($_REQUEST['user_type'], ENT_QUOTES, 'UTF-8');
        ?>
" />
    
    <div id="content_general">
        <?php 
        $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "profiles:general_content"));
        $_block_repeat = true;
        echo smarty_block_hook(array('name' => "profiles:general_content"), null, $_smarty_tpl, $_block_repeat);
        while ($_block_repeat) {
            ob_start();
            ?>

            <?php 
            echo $_smarty_tpl->getSubTemplate("views/profiles/components/profiles_account.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);
            ?>


            <?php 
            if ((fn_allowed_for("ULTIMATE") || $_smarty_tpl->tpl_vars['user_type']->value == "V") && $_smarty_tpl->tpl_vars['id']->value != $_smarty_tpl->tpl_vars['auth']->value['user_id']) {
                ?>

                <?php 
                $_smarty_tpl->tpl_vars['zero_company_id_name_lang_var'] = new Smarty_variable(false, null, 0);
                ?>
                <?php 
                if (fn_allowed_for("ULTIMATE") && fn_check_user_type_admin_area($_smarty_tpl->tpl_vars['user_type']->value)) {
                    ?>
                    <?php 
                    $_smarty_tpl->tpl_vars['zero_company_id_name_lang_var'] = new Smarty_variable('all_vendors', null, 0);
                    ?>
                <?php 
                }
                ?>

                <?php 
                echo $_smarty_tpl->getSubTemplate("views/companies/components/company_field.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('name' => "user_data[company_id]", 'id' => "user_data_company_id", 'selected' => $_smarty_tpl->tpl_vars['user_data']->value['company_id'], 'zero_company_id_name_lang_var' => $_smarty_tpl->tpl_vars['zero_company_id_name_lang_var']->value, 'disable_company_picker' => $_smarty_tpl->tpl_vars['hide_inputs']->value), 0);
                ?>


            <?php 
            } else {
                ?>
                <input type="hidden" name="user_data[company_id]" value="<?php 
                echo htmlspecialchars(($tmp = @$_smarty_tpl->tpl_vars['user_data']->value['company_id']) === null || $tmp === '' ? 0 : $tmp, ENT_QUOTES, 'UTF-8');
                ?>
">
            <?php 
            }
            ?>
        <?php 
            $_block_content = ob_get_clean();
            $_block_repeat = false;
            echo smarty_block_hook(array('name' => "profiles:general_content"), $_block_content, $_smarty_tpl, $_block_repeat);
        }
        array_pop($_smarty_tpl->smarty->_tag_stack);
        ?>

        
        <?php 
        echo $_smarty_tpl->getSubTemplate("views/profiles/components/profile_fields.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('section' => "C", 'title' => __("contact_information")), 0);
        ?>


        <?php 
        if ($_smarty_tpl->tpl_vars['settings']->value['General']['user_multiple_profiles'] == "Y" && $_smarty_tpl->tpl_vars['id']->value) {
            ?>
            <?php 
            echo $_smarty_tpl->getSubTemplate("common/subheader.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('title' => __("user_profile_info")), 0);
            ?>

            <p class="form-note"><?php 
            echo $_smarty_tpl->__("text_multiprofile_notice");
            ?>
</p>
            <?php 
            echo $_smarty_tpl->getSubTemplate("views/profiles/components/multiple_profiles.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);
            ?>

        <?php 
        }
        ?>

        <?php 
        if ($_smarty_tpl->tpl_vars['profile_fields']->value['B']) {
            ?>
            <?php 
            echo $_smarty_tpl->getSubTemplate("views/profiles/components/profile_fields.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('section' => "B", 'title' => __("billing_address")), 0);
            ?>

            <?php 
            echo $_smarty_tpl->getSubTemplate("views/profiles/components/profile_fields.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('section' => "S", 'title' => __("shipping_address"), 'body_id' => "sa", 'shipping_flag' => fn_compare_shipping_billing($_smarty_tpl->tpl_vars['profile_fields']->value)), 0);
            ?>

        <?php 
        } else {
            ?>
            <?php 
            echo $_smarty_tpl->getSubTemplate("views/profiles/components/profile_fields.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('section' => "S", 'title' => __("shipping_address"), 'shipping_flag' => false), 0);
            ?>

        <?php 
        }
        ?>
        </div>
    <?php 
        if (!fn_allowed_for("ULTIMATE:FREE")) {
            ?>
        <?php 
            if ($_smarty_tpl->tpl_vars['id']->value && ((!fn_check_user_type_admin_area($_smarty_tpl->tpl_vars['user_data']->value) || !$_smarty_tpl->tpl_vars['user_data']->value['user_id']) && !$_smarty_tpl->tpl_vars['runtime']->value['company_id'] || fn_check_user_type_admin_area($_smarty_tpl->tpl_vars['user_data']->value) && $_smarty_tpl->tpl_vars['user_data']->value['user_id'] && $_smarty_tpl->tpl_vars['usergroups']->value && !$_smarty_tpl->tpl_vars['runtime']->value['company_id'] && $_smarty_tpl->tpl_vars['auth']->value['is_root'] == 'Y' && ($_smarty_tpl->tpl_vars['user_data']->value['company_id'] != 0 || $_smarty_tpl->tpl_vars['user_data']->value['company_id'] == 0 && $_smarty_tpl->tpl_vars['user_data']->value['is_root'] != 'Y') || $_smarty_tpl->tpl_vars['user_data']->value['user_type'] == 'V' && $_smarty_tpl->tpl_vars['runtime']->value['company_id'] && $_smarty_tpl->tpl_vars['auth']->value['is_root'] == 'Y' && $_smarty_tpl->tpl_vars['user_data']->value['user_id'] != $_smarty_tpl->tpl_vars['auth']->value['user_id'] && $_smarty_tpl->tpl_vars['user_data']->value['company_id'] == $_smarty_tpl->tpl_vars['runtime']->value['company_id'])) {
                ?>

            <div id="content_usergroups" class="cm-hide-save-button">
                <?php 
                if ($_smarty_tpl->tpl_vars['usergroups']->value) {
                    ?>
                <table width="100%" class="table table-middle">
                <thead>
                <tr>
                    <th width="50%"><?php 
                    echo $_smarty_tpl->__("usergroup");
                    ?>
</th>
                    <th class="right" width="10%"><?php 
                    echo $_smarty_tpl->__("status");
                    ?>
</th>
                </tr>
                </thead>
                <?php 
                    $_smarty_tpl->tpl_vars['usergroup'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['usergroup']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['usergroups']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['usergroup']->key => $_smarty_tpl->tpl_vars['usergroup']->value) {
                        $_smarty_tpl->tpl_vars['usergroup']->_loop = true;
                        ?>
                    <tr>
                        <td><a href="<?php 
                        echo htmlspecialchars(fn_url("usergroups.manage#group" . (string) $_smarty_tpl->tpl_vars['usergroup']->value['usergroup_id']), ENT_QUOTES, 'UTF-8');
                        ?>
"><?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['usergroup']->value['usergroup'], ENT_QUOTES, 'UTF-8');
                        ?>
</a></td>
                        <td class="right">
                            <?php 
                        if ($_smarty_tpl->tpl_vars['user_data']->value['usergroups'][$_smarty_tpl->tpl_vars['usergroup']->value['usergroup_id']]) {
                            ?>
                                <?php 
                            $_smarty_tpl->tpl_vars["ug_status"] = new Smarty_variable($_smarty_tpl->tpl_vars['user_data']->value['usergroups'][$_smarty_tpl->tpl_vars['usergroup']->value['usergroup_id']]['status'], null, 0);
                            ?>
                            <?php 
                        } else {
                            ?>
                                <?php 
                            $_smarty_tpl->tpl_vars["ug_status"] = new Smarty_variable("F", null, 0);
                            ?>
                            <?php 
                        }
                        ?>
                            <?php 
                        echo $_smarty_tpl->getSubTemplate("common/select_popup.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('id' => $_smarty_tpl->tpl_vars['usergroup']->value['usergroup_id'], 'status' => $_smarty_tpl->tpl_vars['ug_status']->value, 'hidden' => '', 'items_status' => fn_get_predefined_statuses("profiles"), 'extra' => "&user_id=" . (string) $_smarty_tpl->tpl_vars['id']->value, 'update_controller' => "usergroups", 'notify' => true, 'hide_for_vendor' => $_smarty_tpl->tpl_vars['runtime']->value['company_id']), 0);
                        ?>

                        </td>
                    </tr>
                <?php 
                    }
                    ?>
                </table>
                <?php 
                } else {
                    ?>
                    <p class="no-items"><?php 
                    echo $_smarty_tpl->__("no_data");
                    ?>
</p>
                <?php 
                }
                ?>
            </div>
        <?php 
            }
            ?>
    <?php 
        }
        ?>

    <div id="content_addons">
        <?php 
        $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "profiles:detailed_content"));
        $_block_repeat = true;
        echo smarty_block_hook(array('name' => "profiles:detailed_content"), null, $_smarty_tpl, $_block_repeat);
        while ($_block_repeat) {
            ob_start();
            ?>

        <?php 
            $_block_content = ob_get_clean();
            $_block_repeat = false;
            echo smarty_block_hook(array('name' => "profiles:detailed_content"), $_block_content, $_smarty_tpl, $_block_repeat);
        }
        array_pop($_smarty_tpl->smarty->_tag_stack);
        ?>

    </div>
    <?php 
        if ($_smarty_tpl->tpl_vars['show_api_tab']->value) {
            ?>
        <div id="content_api">
            <div class="control-group <?php 
            if ($_smarty_tpl->tpl_vars['hide_api_checkbox']->value) {
                ?>
hidden<?php 
            }
            ?>
">
                <div class="controls">
                    <label class="checkbox" for="sw_api_container">
                    <input <?php 
            if ($_smarty_tpl->tpl_vars['user_data']->value['api_key'] != '') {
                ?>
checked="checked"<?php 
            }
            ?>
 class="cm-combination" type="checkbox" name="user_api_status" value="Y" id="sw_api_container" /><?php 
            echo $_smarty_tpl->__("allow_api_access");
            ?>
</label>
                </div>
            </div>

            <div id="api_container" <?php 
            if ($_smarty_tpl->tpl_vars['user_data']->value['api_key'] == '') {
                ?>
class="hidden"<?php 
            }
            ?>
>
                <div class="control-group">
                    <label class="control-label"><?php 
            echo $_smarty_tpl->__("api_key");
            ?>
</label>
                    <div class="controls">
                        <input type="text" class="input-large" name="user_data[api_key]" value="<?php 
            if ($_smarty_tpl->tpl_vars['user_data']->value['api_key']) {
                echo htmlspecialchars($_smarty_tpl->tpl_vars['user_data']->value['api_key'], ENT_QUOTES, 'UTF-8');
            } else {
                echo htmlspecialchars($_smarty_tpl->tpl_vars['new_api_key']->value, ENT_QUOTES, 'UTF-8');
            }
            ?>
" readonly="readonly"/>
                    </div>
                </div>
            </div>
        </div>
    <?php 
        }
        ?>

    <?php 
        $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "profiles:tabs_content"));
        $_block_repeat = true;
        echo smarty_block_hook(array('name' => "profiles:tabs_content"), null, $_smarty_tpl, $_block_repeat);
        while ($_block_repeat) {
            ob_start();
            ?>

    <?php 
            $_block_content = ob_get_clean();
            $_block_repeat = false;
            echo smarty_block_hook(array('name' => "profiles:tabs_content"), $_block_content, $_smarty_tpl, $_block_repeat);
        }
        array_pop($_smarty_tpl->smarty->_tag_stack);
        ?>

    <?php 
        if (!fn_allow_save_object($_smarty_tpl->tpl_vars['user_data']->value, "users") && $_smarty_tpl->tpl_vars['id']->value && $_smarty_tpl->tpl_vars['user_data']->value['user_id'] != $_smarty_tpl->tpl_vars['auth']->value['user_id'] || $_smarty_tpl->tpl_vars['hide_inputs']->value) {
            ?>
        <?php 
            $_smarty_tpl->tpl_vars["hide_first_button"] = new Smarty_variable(true, null, 0);
            ?>
    <?php 
        }
        ?>

    <?php 
        if ($_smarty_tpl->tpl_vars['id']->value) {
            ?>
        <?php 
            $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "profiles:tabs_extra"));
            $_block_repeat = true;
            echo smarty_block_hook(array('name' => "profiles:tabs_extra"), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                ?>

        <?php 
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo smarty_block_hook(array('name' => "profiles:tabs_extra"), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            ?>

    <?php 
        }
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>

<?php 
        echo $_smarty_tpl->getSubTemplate("common/tabsbox.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('content' => Smarty::$_smarty_vars['capture']['tabsbox'], 'group_name' => $_smarty_tpl->tpl_vars['runtime']->value['controller'], 'active_tab' => $_smarty_tpl->tpl_vars['selected_section']->value, 'track' => true), 0);
        ?>


<?php 
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>

<?php 
        if (!$_smarty_tpl->tpl_vars['id']->value) {
            ?>
    <?php 
            $_smarty_tpl->tpl_vars["_user_desc"] = new Smarty_variable(fn_get_user_type_description($_smarty_tpl->tpl_vars['user_type']->value), null, 0);
            ?>
    <?php 
            ob_start();
            echo $_smarty_tpl->__("new_profile");
            $_tmp1 = ob_get_clean();
            $_smarty_tpl->tpl_vars["_title"] = new Smarty_variable($_tmp1 . " (" . (string) $_smarty_tpl->tpl_vars['_user_desc']->value . ")", null, 0);
        } else {
            ?>
    <?php 
            if ($_smarty_tpl->tpl_vars['user_data']->value['firstname']) {
                ?>
        <?php 
                ob_start();
                echo $_smarty_tpl->__("editing_profile");
                $_tmp2 = ob_get_clean();
                $_smarty_tpl->tpl_vars["_title"] = new Smarty_variable($_tmp2 . ": " . (string) $_smarty_tpl->tpl_vars['user_data']->value['firstname'] . " " . (string) $_smarty_tpl->tpl_vars['user_data']->value['lastname'], null, 0);
                ?>
        <?php 
            } elseif ($_smarty_tpl->tpl_vars['user_data']->value['b_firstname']) {
                ?>
        <?php 
                ob_start();
                echo $_smarty_tpl->__("editing_profile");
                $_tmp3 = ob_get_clean();
                $_smarty_tpl->tpl_vars["_title"] = new Smarty_variable($_tmp3 . ": " . (string) $_smarty_tpl->tpl_vars['user_data']->value['b_firstname'] . " " . (string) $_smarty_tpl->tpl_vars['user_data']->value['b_lastname'], null, 0);
                ?>
        <?php 
            } else {
                ?>
        <?php 
                ob_start();
                echo $_smarty_tpl->__("editing_profile");
                $_tmp4 = ob_get_clean();
                $_smarty_tpl->tpl_vars["_title"] = new Smarty_variable($_tmp4 . ": " . (string) $_smarty_tpl->tpl_vars['user_data']->value['email'], null, 0);
                ?>
    <?php 
            }
        }
        ?>

<?php 
        $_smarty_tpl->tpl_vars['_title'] = new Smarty_variable(preg_replace('!<[^>]*?>!', ' ', $_smarty_tpl->tpl_vars['_title']->value), null, 0);
        $_smarty_tpl->tpl_vars["redirect_url"] = new Smarty_variable("profiles.manage%26user_type=" . (string) $_smarty_tpl->tpl_vars['user_data']->value['user_type'], null, 0);
        ?>

<?php 
        $_smarty_tpl->_capture_stack[0][] = array("buttons", null, null);
        ob_start();
        ?>
    <?php 
        $_smarty_tpl->_capture_stack[0][] = array("tools_list", null, null);
        ob_start();
        ?>
        <?php 
        $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "profiles:update_tools_list"));
        $_block_repeat = true;
        echo smarty_block_hook(array('name' => "profiles:update_tools_list"), null, $_smarty_tpl, $_block_repeat);
        while ($_block_repeat) {
            ob_start();
            ?>

        <?php 
            if ($_smarty_tpl->tpl_vars['user_data']->value['user_type'] == "C") {
                ?>
            <li><?php 
                smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'text' => __("view_all_orders"), 'href' => "orders.manage?user_id=" . (string) $_smarty_tpl->tpl_vars['id']->value));
                ?>
</li>
        <?php 
            }
            ?>
        <?php 
            if (fn_user_need_login($_smarty_tpl->tpl_vars['user_data']->value['user_type']) && (!$_smarty_tpl->tpl_vars['runtime']->value['company_id'] || $_smarty_tpl->tpl_vars['runtime']->value['company_id'] == $_smarty_tpl->tpl_vars['auth']->value['company_id']) && $_smarty_tpl->tpl_vars['user_data']->value['user_id'] != $_smarty_tpl->tpl_vars['auth']->value['user_id'] && !($_smarty_tpl->tpl_vars['user_data']->value['user_type'] == 'A' && $_smarty_tpl->tpl_vars['user_data']->value['is_root'] == 'Y' && !$_smarty_tpl->tpl_vars['user_data']->value['company_id'])) {
                ?>
            <li><?php 
                smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'target' => "_blank", 'text' => __("act_on_behalf"), 'href' => "profiles.act_as_user?user_id=" . (string) $_smarty_tpl->tpl_vars['id']->value));
                ?>
</li>
            <li class="divider"></li>
            <li><?php 
                smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'text' => __("delete"), 'class' => "cm-confirm cm-post", 'href' => "profiles.delete?user_id=" . (string) $_smarty_tpl->tpl_vars['id']->value . "&redirect_url=" . (string) $_smarty_tpl->tpl_vars['redirect_url']->value));
                ?>
</li>
        <?php 
            }
            ?>
        <?php 
            $_block_content = ob_get_clean();
            $_block_repeat = false;
            echo smarty_block_hook(array('name' => "profiles:update_tools_list"), $_block_content, $_smarty_tpl, $_block_repeat);
        }
        array_pop($_smarty_tpl->smarty->_tag_stack);
        ?>

    <?php 
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>
    <?php 
        if ($_smarty_tpl->tpl_vars['id']->value && trim(Smarty::$_smarty_vars['capture']['tools_list']) !== '') {
            ?>
        <?php 
            smarty_template_function_dropdown($_smarty_tpl, array('content' => Smarty::$_smarty_vars['capture']['tools_list']));
            ?>

    <?php 
        }
        ?>
<div class="btn-group btn-hover dropleft">
    <?php 
        if ($_smarty_tpl->tpl_vars['id']->value) {
            ?>
        <?php 
            echo $_smarty_tpl->getSubTemplate("buttons/save_changes.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_meta' => "dropdown-toggle", 'but_role' => "submit-link", 'but_name' => "dispatch[profiles." . (string) $_smarty_tpl->tpl_vars['runtime']->value['mode'] . "]", 'but_target_form' => "profile_form", 'save' => $_smarty_tpl->tpl_vars['id']->value), 0);
            ?>

    <?php 
        } else {
            ?>
        <?php 
            echo $_smarty_tpl->getSubTemplate("buttons/button.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_text' => __("create"), 'but_meta' => "dropdown-toggle", 'but_role' => "submit-link", 'but_name' => "dispatch[profiles." . (string) $_smarty_tpl->tpl_vars['runtime']->value['mode'] . "]", 'but_target_form' => "profile_form", 'save' => $_smarty_tpl->tpl_vars['id']->value), 0);
            ?>

    <?php 
        }
        ?>
    <ul class="dropdown-menu">
        <li><a><input type="checkbox" name="notify_customer" value="Y" checked="checked"  id="notify_customer" />
            <?php 
        echo $_smarty_tpl->__("notify_user");
        ?>
</a></li>
    </ul>
</div>

<?php 
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>

<?php 
        echo $_smarty_tpl->getSubTemplate("common/mainbox.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('title' => $_smarty_tpl->tpl_vars['_title']->value, 'content' => Smarty::$_smarty_vars['capture']['mainbox'], 'buttons' => Smarty::$_smarty_vars['capture']['buttons']), 0);
        ?>

</form><?php 
    }
Exemplo n.º 19
0
function fn_twigmo_get_products(&$params, &$fields, &$sortings, &$condition, &$join, &$sorting, &$group_by, &$lang_code)
{
    if (isset($params['q']) && fn_string_not_empty($params['q']) && !empty($params['ppcode']) && $params['ppcode'] == 'Y') {
        $join .= " LEFT JOIN ?:product_options_inventory as twg_pcinventory\n                ON twg_pcinventory.product_id = products.product_id";
    }
}
Exemplo n.º 20
0
function fn_em_get_subscribers($params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    // Init filter
    $params = LastView::instance()->update('em_subscribers', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array('?:em_subscribers.subscriber_id', '?:em_subscribers.email', '?:em_subscribers.timestamp', '?:em_subscribers.name', '?:em_subscribers.unsubscribe_key', '?:em_subscribers.status');
    // Define sort fields
    $sortings = array('email' => '?:em_subscribers.email', 'name' => '?:em_subscribers.name', 'status' => '?:em_subscribers.status', 'timestamp' => '?:em_subscribers.timestamp');
    $condition = '';
    $group_by = '';
    $join = '';
    if (!empty($params['subscriber_id'])) {
        $condition .= db_quote(" AND ?:em_subscribers.subscriber_id = ?i", $params['subscriber_id']);
    }
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition .= db_quote(" AND ?:em_subscribers.email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    if (!empty($params['status'])) {
        $condition .= db_quote(" AND ?:em_subscribers.status = ?s", $params['status']);
    }
    if (!empty($params['name'])) {
        $condition .= db_quote(" AND ?:em_subscribers.name LIKE ?l", "%" . $params['name'] . "%");
    }
    if (!empty($params['lang_code'])) {
        $condition .= db_quote(" AND ?:em_subscribers.lang_code = ?s", $params['lang_code']);
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:em_subscribers.timestamp >= ?i AND ?:em_subscribers.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    $condition .= fn_em_get_company_condition();
    $sorting = db_sort($params, $sortings, 'timestamp', 'desc');
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(?:em_subscribers.subscriber_id) FROM ?:em_subscribers {$join} WHERE 1 {$condition}");
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $subscribers = db_get_array('SELECT ' . implode(', ', $fields) . " FROM ?:em_subscribers {$join} WHERE 1 {$condition} {$group_by} {$sorting} {$limit}");
    return array($subscribers, $params);
}
Exemplo n.º 21
0
function fn_get_subscribers($params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    // Init filter
    $params = LastView::instance()->update('subscribers', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array('?:subscribers.subscriber_id', '?:subscribers.email', '?:subscribers.timestamp', '?:subscribers.subscriber_id', "GROUP_CONCAT(?:user_mailing_lists.list_id) as list_ids");
    // Define sort fields
    $sortings = array('email' => '?:subscribers.email', 'timestamp' => '?:subscribers.timestamp');
    $condition = '';
    $group_by = "?:subscribers.subscriber_id";
    $join = db_quote(" LEFT JOIN ?:user_mailing_lists ON ?:user_mailing_lists.subscriber_id = ?:subscribers.subscriber_id");
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition .= db_quote(" AND ?:subscribers.email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    if (!empty($params['list_id'])) {
        $condition .= db_quote(" AND ?:user_mailing_lists.list_id = ?i", $params['list_id']);
    }
    if (!empty($params['confirmed'])) {
        $condition .= db_quote(" AND ?:user_mailing_lists.confirmed = ?i", $params['confirmed'] == 'Y');
    }
    if (!empty($params['language'])) {
        $condition .= db_quote(" AND ?:user_mailing_lists.lang_code = ?s", $params['language']);
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:subscribers.timestamp >= ?i AND ?:subscribers.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    $sorting = db_sort($params, $sortings, 'timestamp', 'desc');
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT(?:subscribers.subscriber_id)) FROM ?:subscribers {$join} WHERE 1 {$condition}");
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $subscribers = db_get_array('SELECT ' . implode(', ', $fields) . " FROM ?:subscribers {$join} WHERE 1 {$condition} GROUP BY {$group_by} {$sorting} {$limit}");
    return array($subscribers, $params);
}
Exemplo n.º 22
0
    public function destruct($content = '')
    {
        static $called = false;
        if ($called == false && $this->_internal_request) {
            $called = true;
            $text = $this->_request_type != self::REQUEST_COMET ? ob_get_clean() : '';
            if (empty($text) && !empty($content)) {
                $text = $content;
            }
            if (!empty($this->result_ids)) {
                $result_ids = array();
                // get the matching ids
                foreach ($this->result_ids as $r_id) {
                    if (strpos($r_id, '*')) {
                        $clear_id = str_replace('*', '\\w+?', $r_id);
                        preg_match_all('/<[^>]*?id=(?:\'|")(' . $clear_id . '\\w*?)(?:\'|")[^>]*?>/isS', $text, $ids);
                        if (!empty($ids[1])) {
                            foreach ($ids[1] as $r_id2) {
                                $result_ids[] = $r_id2;
                            }
                        }
                    } else {
                        $result_ids[] = $r_id;
                    }
                }
                foreach ($result_ids as $r_id) {
                    if (strpos($text, ' id="' . $r_id . '">') !== false) {
                        $start = strpos($text, ' id="' . $r_id . '">') + strlen(' id="' . $r_id . '">');
                        $end = strpos($text, '<!--' . $r_id . '--></');
                        $this->assignHtml($r_id, substr($text, $start, $end - $start));
                        // Assume that all data should be put to div with this ID
                    } elseif ($this->_skip_result_ids_check == true) {
                        $this->assignHtml($r_id, $text);
                    }
                }
                if ($this->full_render && preg_match('/<title>(.*?)<\\/title>/s', $text, $m)) {
                    $this->assign('title', html_entity_decode($m[1], ENT_QUOTES));
                }
                // Fix for payment processor form, should be removed after payments refactoring
                if (Embedded::isEnabled() && empty($this->_result['html']) && $this->_skip_result_ids_check == false && !empty($text)) {
                    foreach ($this->result_ids as $r_id) {
                        $text .= '<script type="text/javascript">if (document.process) { document.process.target="_parent"; document.process.submit(); }</script>';
                        $this->assignHtml($r_id, $text);
                        break;
                    }
                }
                $text = '';
            }
            if (empty($this->_result['non_ajax_notifications'])) {
                $this->assign('notifications', fn_get_notifications());
            }
            if (Embedded::isEnabled()) {
                $this->assign('session_data', array('name' => Session::getName(), 'id' => Session::getId()));
            }
            if (!empty($this->anchor)) {
                $this->assign('anchor', $this->anchor);
            }
            // we call session saving directly
            session_write_close();
            // Prepare response
            $response = $this->_result;
            if (fn_string_not_empty($text)) {
                $response['text'] = trim($text);
            }
            $response = json_encode($response, JSON_UNESCAPED_UNICODE);
            if (!headers_sent()) {
                header(' ', true, 200);
                // force 200 header, because we still need to return content
                if (Embedded::isEnabled() || $this->_request_type == self::REQUEST_JSONP_POST) {
                    header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
                    // for IE cors
                }
            }
            if ($this->_request_type == self::REQUEST_XML) {
                // Return json object
                header('Content-type: ' . $this->_content_type . '; charset=' . CHARSET);
            } elseif ($this->_request_type == self::REQUEST_JSONP) {
                // Return jsonp object
                header('Content-type: ' . $this->_content_type . '; charset=' . CHARSET);
                $response = $this->callback . '(' . $response . ');';
            } elseif ($this->_request_type == self::REQUEST_JSONP_POST) {
                // Return jsonp object
                header("X-Frame-Options: ", true);
                $response = '<script type="text/javascript" src="' . Registry::get('config.current_location') . '/js/lib/jquery/jquery.min.js' . '"></script>
                             <script type="text/javascript" src="' . Registry::get('config.current_location') . '/js/lib/postmessage/jquery.ba-postmessage.js' . '"></script>
                             <script type="text/javascript">

                                var Tygh = {};
                                Tygh.$ = jQuery.noConflict(true);
                             </script>
                             <script type="text/javascript">Tygh.$.postMessage(
                                "' . fn_js_escape($response) . '",\'' . Embedded::getUrl() . '\');</script>';
            } else {
                // Return html textarea object
                $response = '<textarea>' . fn_html_escape($response) . '</textarea>';
            }
            fn_echo($response);
        }
    }
Exemplo n.º 23
0
/**
 * Returns list of pages
 * <i>$params</i> - Array of various parameters used for element selection:
 * <ul>
 *      <li>page_id - If defined and not zero, get data for the page with this id; otherwise get data for all pages</li>
 *      <li>item_ids - A comma-delimited page identifiers list; if defined, get data for the pages with these ids; otherwise get data for all pages</li>
 *      <li>except_id - Identifier of the page to be excluded from the result</li>
 *   	<li>parent_id - If defined and not zero, get data for the pages with this parent page id</li>
 *   	<li>active_page_id - Identifier of the page being currently shown</li>
 *   	<li>current_page_id - The same as <i>active_page_id</i></li>
 *
 *   	<li>add_root - If defined, additionally returns root element data</li>
 *  	<li>subpages - If defined, additionally returns subpages</li>
 *  	<li>get_tree - If defined, pages will be returned as tree; otherwise as list. Possible value: <i>plain</i></li>
 *  	<li>visible - For pages tree: show visible branch only</li>
 *
 *  	<li>page - Number of the current page for pagination</li>
 *
 *  	<li>pdescr - If defined, additionally returns descriptions.  Possible value: <i>Y</i></li>
 *
 *   	<li>vendor_pages - If defined, try to return pages for the company defined by <i>company_id</i></li>
 *   	<li>company_id - If <i>vendor_pages</i> is defined: if defined, get data for the company with this id</li>
 *
 *   	<li>neighbours - If defined, try to return neighbor pages for the page with the id <i>neighbours_page_id</i></li>
 *   	<li>neighbours_page_id -  If <i>neighbours</i> is defined: if defined, get neighbor pages for the page with this id</li>
 *
 *   	<li>limit - If defined, used to limit your MySQL query results by this value</li>
 *   	<li>sort_by - Table field to sort by, default is position</li>
 *   	<li>sort_order - Sorting direction, ascending or descending; Possible values: <i>asc</i> or <i>desc</i>, default is <i>asc</i></li>
 *
 *   	<li>status - If defined, returns pages only with this status. Can be comma delimited statuses list</li>
 *
 *  	<li>period - If defined, get pages by time period. Time period is generated by ::fn_create_periods</li>
 *   	<li>time_from - Returns pages created earlier than this time</li>
 *   	<li>time_to - Returns pages created later than this time</li>
 *
 *   	<li>parent_page_id - Deprecated, <i>parent_id</i> used instead</li>
 *   	<li>from_page_id - Deprecated, <i>parent_id</i> used instead</li>
 * </ul>
 * @param array $params Array of params
 * @param int $items_per_page  Limit items per page
 * @param string $lang_code 2-letter language code
 * @return array List of pages, params
 */
function fn_get_pages($params = array(), $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    /**
     * Changes params for selecting pages
     *
     * @param array  $params         Pages search params
     * @param int    $items_per_page Items per page
     * @param string $lang_code      Two-letter language code (e.g. 'en', 'ru', etc.)
     */
    fn_set_hook('get_pages_pre', $params, $items_per_page, $lang_code);
    $view_type = 'pages';
    if (!empty($params['page_type']) && fn_is_exclusive_page_type($params['page_type'])) {
        $view_type .= '_' . $params['page_type'];
    }
    // Init filter
    $params = LastView::instance()->update($view_type, $params);
    $default_params = array('page_id' => 0, 'page' => 1, 'visible' => false, 'get_tree' => '', 'pdescr' => '', 'subpages' => '', 'match' => '', 'page_type' => '', 'items_per_page' => $items_per_page);
    if (is_array($params)) {
        $params = array_merge($default_params, $params);
    } else {
        $params = $default_params;
    }
    if (empty($params['pname']) && empty($params['pdescr']) && empty($params['subpages'])) {
        $params['pname'] = 'Y';
    }
    $fields = array('?:pages.*');
    if (!empty($params['simple'])) {
        $fields[] = '?:page_descriptions.page';
    } else {
        $fields[] = '?:page_descriptions.*';
    }
    // Define sort fields
    $sortings = array('position' => array('?:pages.position', '?:page_descriptions.page'), 'name' => '?:page_descriptions.page', 'timestamp' => '?:pages.timestamp', 'type' => '?:pages.page_type', 'multi_level' => array('?:pages.parent_id', '?:pages.position', '?:page_descriptions.page'));
    $auth =& $_SESSION['auth'];
    $condition = '1';
    $join = $limit = $group_by = '';
    if (isset($params['q']) && fn_string_not_empty($params['q'])) {
        $params['q'] = trim($params['q']);
        if ($params['match'] == 'any') {
            $pieces = fn_explode(' ', $params['q']);
            $search_type = ' OR ';
        } elseif ($params['match'] == 'all') {
            $pieces = fn_explode(' ', $params['q']);
            $search_type = ' AND ';
        } else {
            $pieces = array($params['q']);
            $search_type = '';
        }
        $_condition = array();
        foreach ($pieces as $piece) {
            if (strlen($piece) == 0) {
                continue;
            }
            $tmp = array();
            if (!empty($params['pname']) && $params['pname'] == 'Y') {
                $tmp[] = db_quote("?:page_descriptions.page LIKE ?l", "%{$piece}%");
                // check search words
            }
            if ($params['pdescr'] == 'Y') {
                $tmp[] = db_quote("?:page_descriptions.description LIKE ?l", "%{$piece}%");
            }
            if (!empty($tmp)) {
                $_condition[] = '(' . implode(' OR ', $tmp) . ')';
            }
        }
        if (!empty($_condition)) {
            $condition .= ' AND (' . implode($search_type, $_condition) . ')';
        }
    }
    $condition .= fn_get_company_condition('?:pages.company_id');
    if (isset($params['parent_id']) && $params['parent_id'] !== '') {
        $p_ids = array();
        if ($params['subpages'] == 'Y') {
            $p_ids = db_get_fields("SELECT a.page_id FROM ?:pages as a LEFT JOIN ?:pages as b ON b.page_id = ?i WHERE a.id_path LIKE CONCAT(b.id_path, '/%')", $params['parent_id']);
        }
        $p_ids[] = $params['parent_id'];
        $condition .= db_quote(" AND ?:pages.parent_id IN (?n)", $p_ids);
    }
    if (isset($params['parent_page_id'])) {
        // set parent id, that was set in block properties
        $params['from_page_id'] = $params['parent_page_id'];
    }
    if (!empty($params['from_page_id'])) {
        $from_id_path = db_get_field("SELECT id_path FROM ?:pages WHERE page_id = ?i", $params['from_page_id']);
        $condition .= db_quote(" AND ?:pages.id_path LIKE ?l", "{$from_id_path}/%");
    }
    if (!empty($params['status'])) {
        $condition .= db_quote(" AND ?:pages.status IN (?a)", $params['status']);
    }
    if (!empty($params['vendor_pages']) && empty($params['company_id'])) {
        return array(array(), $params);
    } elseif (!empty($params['company_id'])) {
        $condition .= db_quote(" AND ?:pages.company_id = ?i", $params['company_id']);
    }
    if (empty($params['full_search'])) {
        $condition .= db_quote(" AND ?:pages.page_type IN (?a)", array_keys(fn_get_page_type_filter($params['page_type'])));
    }
    if (!empty($params['visible'])) {
        // for pages tree: show visible branch only
        $page_ids = array();
        if (!empty($params['current_page_id'])) {
            $cur_id_path = db_get_field("SELECT id_path FROM ?:pages WHERE page_id = ?i", $params['current_page_id']);
            if (!empty($cur_id_path)) {
                $page_ids = explode('/', $cur_id_path);
            }
        }
        if (!empty($from_id_path)) {
            $_page_ids = explode('/', $from_id_path);
            $page_ids = array_merge($page_ids, $_page_ids);
            $page_ids = array_unique($page_ids);
        }
        $page_ids[] = $params['page_id'];
        $condition .= db_quote(" AND ?:pages.parent_id IN (?n)", $page_ids);
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:pages.timestamp >= ?i AND ?:pages.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    if (!empty($params['item_ids'])) {
        // get only defined pages
        $condition .= db_quote(" AND ?:pages.page_id IN (?n)", explode(',', $params['item_ids']));
    }
    if (!empty($params['except_id']) && (empty($params['item_ids']) || !empty($params['item_ids']) && !in_array($params['except_id'], explode(',', $params['item_ids'])))) {
        $condition .= db_quote(' AND ?:pages.page_id != ?i AND ?:pages.parent_id != ?i', $params['except_id'], $params['except_id']);
    }
    if (AREA != 'A') {
        $condition .= " AND (" . fn_find_array_in_set($auth['usergroup_ids'], '?:pages.usergroup_ids', true) . ")";
        $condition .= fn_get_localizations_condition('?:pages.localization', true);
        $condition .= db_quote(" AND (use_avail_period = ?s OR (use_avail_period = ?s AND avail_from_timestamp <= ?i AND avail_till_timestamp >= ?i))", 'N', 'Y', TIME, TIME);
    }
    $join = db_quote('LEFT JOIN ?:page_descriptions ON ?:pages.page_id = ?:page_descriptions.page_id AND ?:page_descriptions.lang_code = ?s', $lang_code);
    if (!empty($params['limit'])) {
        $limit = db_quote(" LIMIT 0, ?i", $params['limit']);
    }
    if (!empty($params['neighbours'])) {
        $parent_ids = array();
        if (!empty($params['neighbours_page_id'])) {
            $id_path = db_get_field("SELECT id_path FROM ?:pages WHERE page_id = ?i", $params['neighbours_page_id']);
            $parent_ids = explode('/', $id_path);
            if (count($parent_ids) == 1) {
                array_unshift($parent_ids, 0);
            }
            $params['root_id'] = $parent_ids[0];
        } else {
            $parent_ids[] = 0;
        }
        $condition .= db_quote(" AND ?:pages.parent_id IN (?n)", array_unique($parent_ids));
    }
    fn_set_hook('get_pages', $params, $join, $condition, $fields, $group_by, $sortings, $lang_code);
    if (!empty($params['get_tree'])) {
        $params['sort_by'] = 'multi_level';
    }
    $sorting = db_sort($params, $sortings, 'position', 'asc');
    if (!empty($group_by)) {
        $group_by = ' GROUP BY ' . $group_by;
    }
    // Get search conditions
    if (!empty($params['get_conditions'])) {
        return array($fields, $join, $condition);
    }
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT(?:pages.page_id)) FROM ?:pages ?p WHERE ?p ?p ?p", $join, $condition, $group_by, $sorting);
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $pages = db_get_hash_array("SELECT " . implode(', ', $fields) . " FROM ?:pages ?p WHERE ?p ?p ?p ?p", 'page_id', $join, $condition, $group_by, $sorting, $limit);
    if (!empty($params['active_page_id']) && !empty($pages[$params['active_page_id']])) {
        $pages[$params['active_page_id']]['active'] = true;
        Registry::set('runtime.active_page_ids', explode('/', $pages[$params['active_page_id']]['id_path']));
    }
    if (!empty($pages)) {
        foreach ($pages as $k => $v) {
            $pages[$k]['level'] = substr_count($v['id_path'], '/');
        }
        if (!empty($params['get_tree'])) {
            $delete_keys = array();
            foreach ($pages as $k => $v) {
                if (!empty($v['parent_id']) && !empty($pages[$v['parent_id']])) {
                    $pages[$v['parent_id']]['subpages'][$v['page_id']] =& $pages[$k];
                    $delete_keys[] = $k;
                }
                if (!empty($v['parent_id']) && (!isset($params['root_id']) && empty($pages[$v['parent_id']]) || isset($params['root_id']) && $v['parent_id'] != $params['root_id']) && (empty($params['from_page_id']) || $params['from_page_id'] != $v['parent_id'])) {
                    // delete pages that don't have parent. FIXME: should be done on database layer
                    $delete_keys[] = $k;
                }
            }
            foreach ($delete_keys as $k) {
                unset($pages[$k]);
            }
        } elseif (!empty($params['item_ids'])) {
            $pages = fn_sort_by_ids($pages, explode(',', $params['item_ids']), 'page_id');
        }
        if ($params['get_tree'] == 'plain') {
            $pages = fn_multi_level_to_plain($pages, 'subpages');
        }
        if (!empty($params['get_children_count'])) {
            $where_condition = !empty($params['except_id']) ? db_quote(' AND page_id != ?i', $params['except_id']) : '';
            if ($params['get_tree'] == 'plain') {
                $_page_ids = array();
                foreach ($pages as $_p) {
                    $_page_ids[] = $_p['page_id'];
                }
            } else {
                $_page_ids = array_keys($pages);
            }
            $children = db_get_hash_single_array("SELECT parent_id, COUNT(page_id) as children FROM ?:pages WHERE parent_id IN (?n) ?p GROUP BY parent_id", array('parent_id', 'children'), $_page_ids, $where_condition);
            if (!empty($children)) {
                if ($params['get_tree'] == 'plain') {
                    foreach ($pages as $_id => $_p) {
                        if (!empty($children[$_p['page_id']])) {
                            $pages[$_id]['has_children'] = true;
                        }
                    }
                } else {
                    foreach ($children as $k => $v) {
                        $pages[$k]['has_children'] = !empty($v);
                    }
                }
            }
        }
    }
    if (!empty($params['add_root'])) {
        array_unshift($pages, array('page_id' => '', 'page' => $params['add_root']));
    }
    fn_dropdown_appearance_cut_second_third_levels($pages, 'subpages', $params);
    fn_set_hook('post_get_pages', $pages, $params, $lang_code);
    LastView::instance()->processResults($view_type, $pages, $params);
    return array($pages, $params);
}
    function content_55ccecb4b64bd2_27511562($_smarty_tpl)
    {
        if (!is_callable('smarty_block_hook')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/block.hook.php';
        }
        if (!is_callable('smarty_modifier_truncate')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/modifier.truncate.php';
        }
        fn_preload_lang_vars(array('search', 'find_results_with', 'price', 'search_in_category', 'all_categories', 'all_categories', 'search_in', 'product_name', 'short_description', 'full_description', 'keywords', 'search_by_product_filters', 'search_by_product_features', 'search_by_sku', 'popularity', 'ttc_popularity', 'subcategories', 'shipping_freight', 'weight', 'quantity', 'free_shipping', 'yes', 'no', 'status', 'active', 'hidden', 'disabled', 'purchased_in_orders', 'no_items', 'sort_by', 'list_price', 'name', 'price', 'sku', 'quantity', 'status', 'desc', 'asc'));
        if ($_smarty_tpl->tpl_vars['in_popup']->value) {
            ?>
    <div class="adv-search">
    <div class="group">
<?php 
        } else {
            ?>
    <div class="sidebar-row">
    <h6><?php 
            echo $_smarty_tpl->__("search");
            ?>
</h6>
<?php 
        }
        ?>

<?php 
        if ($_smarty_tpl->tpl_vars['page_part']->value) {
            ?>
    <?php 
            $_smarty_tpl->tpl_vars["_page_part"] = new Smarty_variable("#" . (string) $_smarty_tpl->tpl_vars['page_part']->value, null, 0);
        }
        ?>

<form action="<?php 
        echo htmlspecialchars(fn_url(''), ENT_QUOTES, 'UTF-8');
        echo htmlspecialchars($_smarty_tpl->tpl_vars['_page_part']->value, ENT_QUOTES, 'UTF-8');
        ?>
" name="<?php 
        echo htmlspecialchars($_smarty_tpl->tpl_vars['product_search_form_prefix']->value, ENT_QUOTES, 'UTF-8');
        ?>
search_form" method="get" class="cm-disable-empty <?php 
        echo htmlspecialchars($_smarty_tpl->tpl_vars['form_meta']->value, ENT_QUOTES, 'UTF-8');
        ?>
">
<input type="hidden" name="type" value="<?php 
        echo htmlspecialchars(($tmp = @$_smarty_tpl->tpl_vars['search_type']->value) === null || $tmp === '' ? "simple" : $tmp, ENT_QUOTES, 'UTF-8');
        ?>
" />
<?php 
        if ($_REQUEST['redirect_url']) {
            ?>
    <input type="hidden" name="redirect_url" value="<?php 
            echo htmlspecialchars($_REQUEST['redirect_url'], ENT_QUOTES, 'UTF-8');
            ?>
" />
<?php 
        }
        if ($_smarty_tpl->tpl_vars['selected_section']->value != '') {
            ?>
    <input type="hidden" id="selected_section" name="selected_section" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['selected_section']->value, ENT_QUOTES, 'UTF-8');
            ?>
" />
<?php 
        }
        ?>

<?php 
        if ($_smarty_tpl->tpl_vars['put_request_vars']->value) {
            $_smarty_tpl->tpl_vars["v"] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars["v"]->_loop = false;
            $_smarty_tpl->tpl_vars["k"] = new Smarty_Variable();
            $_from = $_REQUEST;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars["v"]->key => $_smarty_tpl->tpl_vars["v"]->value) {
                $_smarty_tpl->tpl_vars["v"]->_loop = true;
                $_smarty_tpl->tpl_vars["k"]->value = $_smarty_tpl->tpl_vars["v"]->key;
                if ($_smarty_tpl->tpl_vars['v']->value && $_smarty_tpl->tpl_vars['k']->value != "callback") {
                    ?>
<input type="hidden" name="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['k']->value, ENT_QUOTES, 'UTF-8');
                    ?>
" value="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['v']->value, ENT_QUOTES, 'UTF-8');
                    ?>
" />
<?php 
                }
            }
        }
        ?>

<?php 
        echo $_smarty_tpl->tpl_vars['extra']->value;
        ?>


<?php 
        $_smarty_tpl->_capture_stack[0][] = array("simple_search", null, null);
        ob_start();
        ?>
    <?php 
        $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "products:simple_search"));
        $_block_repeat = true;
        echo smarty_block_hook(array('name' => "products:simple_search"), null, $_smarty_tpl, $_block_repeat);
        while ($_block_repeat) {
            ob_start();
            ?>

    <div class="sidebar-field">
        <label><?php 
            echo $_smarty_tpl->__("find_results_with");
            ?>
</label>
        <input type="text" name="q" size="20" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['q'], ENT_QUOTES, 'UTF-8');
            ?>
" />
    </div>

    <div class="sidebar-field">
        <label><?php 
            echo $_smarty_tpl->__("price");
            ?>
&nbsp;(<?php 
            echo $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['primary_currency']->value]['symbol'];
            ?>
)</label>
        <input type="text" name="price_from" size="1" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['price_from'], ENT_QUOTES, 'UTF-8');
            ?>
" onfocus="this.select();" class="input-small" /> - <input type="text" size="1" name="price_to" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['price_to'], ENT_QUOTES, 'UTF-8');
            ?>
" onfocus="this.select();" class="input-small" />
    </div>

    <div class="sidebar-field">
        <label><?php 
            echo $_smarty_tpl->__("search_in_category");
            ?>
</label>
        <?php 
            if (fn_show_picker("categories", @constant('CATEGORY_THRESHOLD'))) {
                ?>
            <?php 
                if ($_smarty_tpl->tpl_vars['search']->value['cid']) {
                    ?>
                <?php 
                    $_smarty_tpl->tpl_vars["s_cid"] = new Smarty_variable($_smarty_tpl->tpl_vars['search']->value['cid'], null, 0);
                    ?>
            <?php 
                } else {
                    ?>
                <?php 
                    $_smarty_tpl->tpl_vars["s_cid"] = new Smarty_variable("0", null, 0);
                    ?>
            <?php 
                }
                ?>
            <?php 
                echo $_smarty_tpl->getSubTemplate("pickers/categories/picker.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('company_ids' => $_smarty_tpl->tpl_vars['picker_selected_companies']->value, 'data_id' => "location_category", 'input_name' => "cid", 'item_ids' => $_smarty_tpl->tpl_vars['s_cid']->value, 'hide_link' => true, 'hide_delete_button' => true, 'default_name' => __("all_categories"), 'extra' => ''), 0);
                ?>

        <?php 
            } else {
                ?>
            <?php 
                if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "picker") {
                    ?>
                <?php 
                    $_smarty_tpl->tpl_vars["trunc"] = new Smarty_variable("38", null, 0);
                    ?>
            <?php 
                } else {
                    ?>
                <?php 
                    $_smarty_tpl->tpl_vars["trunc"] = new Smarty_variable("25", null, 0);
                    ?>
            <?php 
                }
                ?>
            <select name="cid">
                <option value="0" <?php 
                if ($_smarty_tpl->tpl_vars['category_data']->value['parent_id'] == "0") {
                    ?>
selected="selected"<?php 
                }
                ?>
>- <?php 
                echo $_smarty_tpl->__("all_categories");
                ?>
 -</option>
                <?php 
                $_smarty_tpl->tpl_vars["search_cat"] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars["search_cat"]->_loop = false;
                $_from = fn_get_plain_categories_tree(0, false, @constant('CART_LANGUAGE'), $_smarty_tpl->tpl_vars['picker_selected_companies']->value);
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                $_smarty_tpl->tpl_vars["search_cat"]->index = -1;
                foreach ($_from as $_smarty_tpl->tpl_vars["search_cat"]->key => $_smarty_tpl->tpl_vars["search_cat"]->value) {
                    $_smarty_tpl->tpl_vars["search_cat"]->_loop = true;
                    $_smarty_tpl->tpl_vars["search_cat"]->index++;
                    $_smarty_tpl->tpl_vars["search_cat"]->first = $_smarty_tpl->tpl_vars["search_cat"]->index === 0;
                    $_smarty_tpl->tpl_vars['smarty']->value['foreach']['search_cat']['first'] = $_smarty_tpl->tpl_vars["search_cat"]->first;
                    ?>
                <?php 
                    if ($_smarty_tpl->tpl_vars['search_cat']->value['store']) {
                        ?>
                <?php 
                        if (!$_smarty_tpl->getVariable('smarty')->value['foreach']['search_cat']['first']) {
                            ?>
                    </optgroup>
                <?php 
                        }
                        ?>

                <optgroup label="<?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['search_cat']->value['category'], ENT_QUOTES, 'UTF-8');
                        ?>
">
                    <?php 
                        $_smarty_tpl->tpl_vars["close_optgroup"] = new Smarty_variable(true, null, 0);
                        ?>
                    <?php 
                    } else {
                        ?>
                    <option value="<?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['search_cat']->value['category_id'], ENT_QUOTES, 'UTF-8');
                        ?>
" <?php 
                        if ($_smarty_tpl->tpl_vars['search_cat']->value['disabled']) {
                            ?>
disabled="disabled"<?php 
                        }
                        ?>
 <?php 
                        if ($_smarty_tpl->tpl_vars['search']->value['cid'] == $_smarty_tpl->tpl_vars['search_cat']->value['category_id']) {
                            ?>
selected="selected"<?php 
                        }
                        ?>
 title="<?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['search_cat']->value['category'], ENT_QUOTES, 'UTF-8');
                        ?>
"><?php 
                        echo preg_replace('!^!m', str_repeat("&#166;&nbsp;&nbsp;&nbsp;&nbsp;", $_smarty_tpl->tpl_vars['search_cat']->value['level']), smarty_modifier_truncate(htmlspecialchars($_smarty_tpl->tpl_vars['search_cat']->value['category'], ENT_QUOTES, 'UTF-8', true), $_smarty_tpl->tpl_vars['trunc']->value, "...", true));
                        ?>
</option>
                    <?php 
                    }
                    ?>
                    <?php 
                }
                ?>
                    <?php 
                if ($_smarty_tpl->tpl_vars['close_optgroup']->value) {
                    ?>
                </optgroup>
                <?php 
                }
                ?>
            </select>
        <?php 
            }
            ?>
    </div>
    <?php 
            $_block_content = ob_get_clean();
            $_block_repeat = false;
            echo smarty_block_hook(array('name' => "products:simple_search"), $_block_content, $_smarty_tpl, $_block_repeat);
        }
        array_pop($_smarty_tpl->smarty->_tag_stack);
        ?>

<?php 
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>

<?php 
        $_smarty_tpl->_capture_stack[0][] = array("advanced_search", null, null);
        ob_start();
        ?>

<?php 
        $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "products:advanced_search"));
        $_block_repeat = true;
        echo smarty_block_hook(array('name' => "products:advanced_search"), null, $_smarty_tpl, $_block_repeat);
        while ($_block_repeat) {
            ob_start();
            ?>

    <div class="group form-horizontal">
    <div class="control-group">
    <label><?php 
            echo $_smarty_tpl->__("search_in");
            ?>
</label>
    <table width="100%">
        <tr class="nowrap">
            <td><label for="pname" class="checkbox inline"><input type="checkbox" value="Y" <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['pname'] == "Y") {
                ?>
checked="checked"<?php 
            }
            ?>
 name="pname" id="pname" /><?php 
            echo $_smarty_tpl->__("product_name");
            ?>
</label></td>
            <td><label for="pshort" class="checkbox inline"><input type="checkbox" value="Y" <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['pshort'] == "Y") {
                ?>
checked="checked"<?php 
            }
            ?>
 name="pshort" id="pshort"  /><?php 
            echo $_smarty_tpl->__("short_description");
            ?>
</label></td>
            <td><label for="pfull" class="checkbox  inline"><input type="checkbox" value="Y" <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['pfull'] == "Y") {
                ?>
checked="checked"<?php 
            }
            ?>
 name="pfull" id="pfull" /><?php 
            echo $_smarty_tpl->__("full_description");
            ?>
</label></td>
            <td><label for="pkeywords" class="checkbox  inline"><input type="checkbox" value="Y" <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['pkeywords'] == "Y") {
                ?>
checked="checked"<?php 
            }
            ?>
 name="pkeywords" id="pkeywords"  /><?php 
            echo $_smarty_tpl->__("keywords");
            ?>
</label></td>
        </tr>
    </table>
    </div>
</div>

<div class="group form-horizontal">
<?php 
            if (!fn_allowed_for("ULTIMATE:FREE") && $_smarty_tpl->tpl_vars['filter_items']->value) {
                ?>
<div class="control-group">

    <a href="#" class="search-link cm-combination open cm-save-state" id="sw_filter">
    <span id="on_filter" class="exicon-expand cm-save-state <?php 
                if ($_COOKIE['filter']) {
                    ?>
hidden<?php 
                }
                ?>
"> </span>
    <span id="off_filter" class="exicon-collapse cm-save-state <?php 
                if (!$_COOKIE['filter']) {
                    ?>
hidden<?php 
                }
                ?>
"></span>
    <?php 
                echo $_smarty_tpl->__("search_by_product_filters");
                ?>
</a>

    <div class="controls">
        <div id="filter"<?php 
                if (!$_COOKIE['filter']) {
                    ?>
 class="hidden"<?php 
                }
                ?>
>
            <?php 
                echo $_smarty_tpl->getSubTemplate("views/products/components/advanced_search_form.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('filter_features' => $_smarty_tpl->tpl_vars['filter_items']->value, 'prefix' => "filter_"), 0);
                ?>

        </div>
    </div>
</div>
<?php 
            }
            ?>
</div>

<?php 
            if ($_smarty_tpl->tpl_vars['feature_items']->value) {
                ?>
<div class="group form-horizontal">
    <div class="control-group">

        <a class="search-link cm-combination nowrap open cm-save-state" id="sw_feature"><span id="on_feature" class="cm-combination cm-save-state <?php 
                if ($_COOKIE['feature']) {
                    ?>
hidden<?php 
                }
                ?>
"><span class="exicon-expand"></span></span><span id="off_feature" class="cm-combination cm-save-state <?php 
                if (!$_COOKIE['feature']) {
                    ?>
hidden<?php 
                }
                ?>
"><span class="exicon-collapse"></span></span><?php 
                echo $_smarty_tpl->__("search_by_product_features");
                ?>
</a>

        <div class="controls">
        <div id="feature"<?php 
                if (!$_COOKIE['feature']) {
                    ?>
 class="hidden"<?php 
                }
                ?>
>
            <input type="hidden" name="advanced_filter" value="Y" />
            <?php 
                echo $_smarty_tpl->getSubTemplate("views/products/components/advanced_search_form.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('filter_features' => $_smarty_tpl->tpl_vars['feature_items']->value, 'prefix' => "feature_"), 0);
                ?>

        </div>
        </div>
    </div>
</div>
<?php 
            }
            ?>

<div class="row-fluid">
<div class="group span6">
    <div class="form-horizontal">
        <div class="control-group">
            <label for="pcode" class="control-label"><?php 
            echo $_smarty_tpl->__("search_by_sku");
            ?>
</label>
            <div class="controls">
                <input type="text" name="pcode" id="pcode" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['pcode'], ENT_QUOTES, 'UTF-8');
            ?>
" onfocus="this.select();"/>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="popularity_from"><?php 
            echo $_smarty_tpl->__("popularity");
            echo $_smarty_tpl->getSubTemplate("common/tooltip.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('tooltip' => __("ttc_popularity")), 0);
            ?>
</label>
            <div class="controls">
                <input type="text" name="popularity_from" id="popularity_from" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['popularity_from'], ENT_QUOTES, 'UTF-8');
            ?>
" onfocus="this.select();" class="input-mini" /> - <input type="text" name="popularity_to" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['popularity_to'], ENT_QUOTES, 'UTF-8');
            ?>
" onfocus="this.select();" class="input-mini" />
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="subcats"><?php 
            echo $_smarty_tpl->__("subcategories");
            ?>
</label>
            <div class="controls">
                <input type="hidden" name="subcats" value="N" />
                <input type="checkbox" value="Y"<?php 
            if ($_smarty_tpl->tpl_vars['search']->value['subcats'] == "Y" || !$_smarty_tpl->tpl_vars['search']->value['subcats']) {
                ?>
 checked="checked"<?php 
            }
            ?>
 name="subcats"  id="subcats" />
            </div>
        </div>
    </div>
</div>

<div class="group span6 form-horizontal">
    <div class="control-group">
        <label class="control-label" for="shipping_freight_from"><?php 
            echo $_smarty_tpl->__("shipping_freight");
            ?>
&nbsp;(<?php 
            echo $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['primary_currency']->value]['symbol'];
            ?>
)</label>
        <div class="controls">
            <input type="text" name="shipping_freight_from" id="shipping_freight_from" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['shipping_freight_from'], ENT_QUOTES, 'UTF-8');
            ?>
" onfocus="this.select();" class="input-mini" /> - <input type="text" name="shipping_freight_to" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['shipping_freight_to'], ENT_QUOTES, 'UTF-8');
            ?>
" onfocus="this.select();" class="input-mini" />
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" for="weight_from"><?php 
            echo $_smarty_tpl->__("weight");
            ?>
&nbsp;(<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['settings']->value['General']['weight_symbol'], ENT_QUOTES, 'UTF-8');
            ?>
)</label>
        <div class="controls">
            <input type="text" name="weight_from" id="weight_from" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['weight_from'], ENT_QUOTES, 'UTF-8');
            ?>
" onfocus="this.select();" class="input-mini" /> - <input type="text" name="weight_to" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['weight_to'], ENT_QUOTES, 'UTF-8');
            ?>
" onfocus="this.select();" class="input-mini" />
        </div>
    </div>

    <?php 
            $_smarty_tpl->tpl_vars["have_amount_filter"] = new Smarty_variable(0, null, 0);
            ?>
    <?php 
            if (!fn_allowed_for("ULTIMATE:FREE")) {
                ?>
        <?php 
                $_smarty_tpl->tpl_vars["ff"] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars["ff"]->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['filter_items']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars["ff"]->key => $_smarty_tpl->tpl_vars["ff"]->value) {
                    $_smarty_tpl->tpl_vars["ff"]->_loop = true;
                    ?>
            <?php 
                    if ($_smarty_tpl->tpl_vars['ff']->value['field_type'] == "A") {
                        ?>
                <?php 
                        $_smarty_tpl->tpl_vars["have_amount_filter"] = new Smarty_variable(1, null, 0);
                        ?>
            <?php 
                    }
                    ?>
        <?php 
                }
                ?>
    <?php 
            }
            ?>
    <?php 
            if (!$_smarty_tpl->tpl_vars['have_amount_filter']->value) {
                ?>
    <div class="control-group">
        <label class="control-label" for="amount_from"><?php 
                echo $_smarty_tpl->__("quantity");
                ?>
:</label>
        <div class="controls">
            <input type="text" name="amount_from" id="amount_from" value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['amount_from'], ENT_QUOTES, 'UTF-8');
                ?>
" onfocus="this.select();" class="input-mini" /> - <input type="text" name="amount_to" value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['amount_to'], ENT_QUOTES, 'UTF-8');
                ?>
" onfocus="this.select();" class="input-mini" />
        </div>
    </div>
    <?php 
            }
            ?>

    <?php 
            $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "companies:products_advanced_search"));
            $_block_repeat = true;
            echo smarty_block_hook(array('name' => "companies:products_advanced_search"), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                ?>

    <?php 
                if (fn_string_not_empty($_smarty_tpl->tpl_vars['picker_selected_company']->value)) {
                    ?>
        <input type="hidden" name="company_id" value="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['picker_selected_company']->value, ENT_QUOTES, 'UTF-8');
                    ?>
" />
    <?php 
                } else {
                    ?>
        <?php 
                    echo $_smarty_tpl->getSubTemplate("common/select_vendor.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);
                    ?>

    <?php 
                }
                ?>
    <?php 
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo smarty_block_hook(array('name' => "companies:products_advanced_search"), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            ?>


</div>
</div>

<div class="row-fluid">
    <div class="group span6 form-horizontal">
        <div class="control-group">
            <label class="control-label" for="free_shipping"><?php 
            echo $_smarty_tpl->__("free_shipping");
            ?>
</label>
            <div class="controls">
            <select name="free_shipping" id="free_shipping">
                <option value="">--</option>
                <option value="Y" <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['free_shipping'] == "Y") {
                ?>
selected="selected"<?php 
            }
            ?>
><?php 
            echo $_smarty_tpl->__("yes");
            ?>
</option>
                <option value="N" <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['free_shipping'] == "N") {
                ?>
selected="selected"<?php 
            }
            ?>
><?php 
            echo $_smarty_tpl->__("no");
            ?>
</option>
            </select>
            </div>
        </div>

        <div class="control-group">
            <label for="status" class="control-label"><?php 
            echo $_smarty_tpl->__("status");
            ?>
</label>
            <div class="controls">
            <select name="status" id="status">
                <option value="">--</option>
                <option value="A" <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['status'] == "A") {
                ?>
selected="selected"<?php 
            }
            ?>
><?php 
            echo $_smarty_tpl->__("active");
            ?>
</option>
                <option value="H" <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['status'] == "H") {
                ?>
selected="selected"<?php 
            }
            ?>
><?php 
            echo $_smarty_tpl->__("hidden");
            ?>
</option>
                <option value="D" <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['status'] == "D") {
                ?>
selected="selected"<?php 
            }
            ?>
><?php 
            echo $_smarty_tpl->__("disabled");
            ?>
</option>
            </select>
            </div>
        </div>
                
        <?php 
            $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "products:search_form"));
            $_block_repeat = true;
            echo smarty_block_hook(array('name' => "products:search_form"), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo smarty_block_hook(array('name' => "products:search_form"), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            ?>

    </div>

    <div class="group span6 form-horizontal">
        
        <?php 
            $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "products:search_in_orders"));
            $_block_repeat = true;
            echo smarty_block_hook(array('name' => "products:search_in_orders"), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                ?>

        <div class="control-group">
            <label class="control-label" for="popularity_from"><?php 
                echo $_smarty_tpl->__("purchased_in_orders");
                ?>
</label>
            <div class="controls">
                <?php 
                echo $_smarty_tpl->getSubTemplate("pickers/orders/picker.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('item_ids' => $_smarty_tpl->tpl_vars['search']->value['order_ids'], 'no_item_text' => __("no_items"), 'data_id' => "order_ids", 'input_name' => "order_ids", 'view_mode' => "simple"), 0);
                ?>

            </div>
        </div>
        <?php 
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo smarty_block_hook(array('name' => "products:search_in_orders"), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            ?>

        <div class="control-group">
            <label class="control-label" for="sort_by"><?php 
            echo $_smarty_tpl->__("sort_by");
            ?>
</label>
            <div class="controls">
            <select class="input-mini" name="sort_by" id="sort_by">
                <option <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "list_price") {
                ?>
selected="selected"<?php 
            }
            ?>
 value="list_price"><?php 
            echo $_smarty_tpl->__("list_price");
            ?>
</option>
                <option <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "product") {
                ?>
selected="selected"<?php 
            }
            ?>
 value="product"><?php 
            echo $_smarty_tpl->__("name");
            ?>
</option>
                <option <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "price") {
                ?>
selected="selected"<?php 
            }
            ?>
 value="price"><?php 
            echo $_smarty_tpl->__("price");
            ?>
</option>
                <option <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "code") {
                ?>
selected="selected"<?php 
            }
            ?>
 value="code"><?php 
            echo $_smarty_tpl->__("sku");
            ?>
</option>
                <option <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "amount") {
                ?>
selected="selected"<?php 
            }
            ?>
 value="amount"><?php 
            echo $_smarty_tpl->__("quantity");
            ?>
</option>
                <option <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "status") {
                ?>
selected="selected"<?php 
            }
            ?>
 value="status"><?php 
            echo $_smarty_tpl->__("status");
            ?>
</option>
            </select> -
            <select class="input-mini" name="sort_order" id="sort_order">
                <option <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['sort_order_rev'] == "asc") {
                ?>
selected="selected"<?php 
            }
            ?>
 value="desc"><?php 
            echo $_smarty_tpl->__("desc");
            ?>
</option>
                <option <?php 
            if ($_smarty_tpl->tpl_vars['search']->value['sort_order_rev'] == "desc") {
                ?>
selected="selected"<?php 
            }
            ?>
 value="asc"><?php 
            echo $_smarty_tpl->__("asc");
            ?>
</option>
            </select>
            </div>
        </div>
    </div>
</div>
<?php 
            $_block_content = ob_get_clean();
            $_block_repeat = false;
            echo smarty_block_hook(array('name' => "products:advanced_search"), $_block_content, $_smarty_tpl, $_block_repeat);
        }
        array_pop($_smarty_tpl->smarty->_tag_stack);
        ?>

<?php 
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>

<?php 
        echo $_smarty_tpl->getSubTemplate("common/advanced_search.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('simple_search' => Smarty::$_smarty_vars['capture']['simple_search'], 'advanced_search' => Smarty::$_smarty_vars['capture']['advanced_search'], 'dispatch' => $_smarty_tpl->tpl_vars['dispatch']->value, 'view_type' => "products", 'in_popup' => $_smarty_tpl->tpl_vars['in_popup']->value), 0);
        ?>


</form>
<?php 
        if ($_smarty_tpl->tpl_vars['in_popup']->value) {
            ?>
    </div></div>
<?php 
        } else {
            ?>
    </div><hr>
<?php 
        }
    }
Exemplo n.º 25
0
/**
 * Gets company data array
 *
 * @param array $params Array of search params:
 * <ul>
 *		  <li>string company - Name of company</li>
 *		  <li>string status - Status of company</li>
 *		  <li>string email - Email of company</li>
 *		  <li>string address - Address of company</li>
 *		  <li>string zipcode - Zipcode of company</li>
 *		  <li>string country - 2-letters country code of company country</li>
 *		  <li>string state - State code of company</li>
 *		  <li>string city - City of company</li>
 *		  <li>string phone - Phone of company</li>
 *		  <li>string url - URL address of company</li>
 *		  <li>string fax - Fax number of company</li>
 *		  <li>mixed company_id - Company ID, array with company IDs or comma-separated list of company IDs.
 * If defined, data will be returned only for companies with such company IDs.</li>
 *		  <li>int exclude_company_id - Company ID, if defined,
 * result array will not include the data for company with such company ID.</li>
 *		  <li>int page - First page to displaying list of companies (if <i>$items_per_page</i> it not empty.</li>
 *		  <li>string sort_order - <i>ASC</i> or <i>DESC</i>: database query sorting order</li>
 *		  <li>string sort_by - One or list of database fields for sorting.</li>
 * </ul>
 * @param array $auth Array of user authentication data (e.g. uid, usergroup_ids, etc.)
 * @param int $items_per_page
 * @param string $lang_code 2-letter language code (e.g. 'en', 'ru', etc.)
 * @return array Array:
 * <ul>
 *		<li>0 - First element is array with companies data.</li>
 *		<li>1 - is possibly modified array with searh params (<i>$params</i>).</li>
 * </ul>
 */
function fn_get_companies($params, &$auth, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    // Init filter
    $_view = 'companies';
    $params = LastView::instance()->update($_view, $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array('?:companies.company_id', '?:companies.lang_code', '?:companies.email', '?:companies.company', '?:companies.timestamp', '?:companies.status');
    if (fn_allowed_for('ULTIMATE')) {
        $fields[] = '?:companies.storefront';
        $fields[] = '?:companies.secure_storefront';
    }
    // Define sort fields
    $sortings = array('id' => '?:companies.company_id', 'company' => '?:companies.company', 'email' => '?:companies.email', 'date' => '?:companies.timestamp', 'status' => '?:companies.status');
    if (fn_allowed_for('ULTIMATE')) {
        $sortings['storefront'] = '?:companies.storefront';
    }
    $condition = $join = $group = '';
    $condition .= fn_get_company_condition('?:companies.company_id');
    $group .= " GROUP BY ?:companies.company_id";
    if (isset($params['company']) && fn_string_not_empty($params['company'])) {
        $condition .= db_quote(" AND ?:companies.company LIKE ?l", "%" . trim($params['company']) . "%");
    }
    if (!empty($params['status'])) {
        if (is_array($params['status'])) {
            $condition .= db_quote(" AND ?:companies.status IN (?a)", $params['status']);
        } else {
            $condition .= db_quote(" AND ?:companies.status = ?s", $params['status']);
        }
    }
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition .= db_quote(" AND ?:companies.email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    if (isset($params['address']) && fn_string_not_empty($params['address'])) {
        $condition .= db_quote(" AND ?:companies.address LIKE ?l", "%" . trim($params['address']) . "%");
    }
    if (isset($params['zipcode']) && fn_string_not_empty($params['zipcode'])) {
        $condition .= db_quote(" AND ?:companies.zipcode LIKE ?l", "%" . trim($params['zipcode']) . "%");
    }
    if (!empty($params['country'])) {
        $condition .= db_quote(" AND ?:companies.country = ?s", $params['country']);
    }
    if (isset($params['state']) && fn_string_not_empty($params['state'])) {
        $condition .= db_quote(" AND ?:companies.state LIKE ?l", "%" . trim($params['state']) . "%");
    }
    if (isset($params['city']) && fn_string_not_empty($params['city'])) {
        $condition .= db_quote(" AND ?:companies.city LIKE ?l", "%" . trim($params['city']) . "%");
    }
    if (isset($params['phone']) && fn_string_not_empty($params['phone'])) {
        $condition .= db_quote(" AND ?:companies.phone LIKE ?l", "%" . trim($params['phone']) . "%");
    }
    if (isset($params['url']) && fn_string_not_empty($params['url'])) {
        $condition .= db_quote(" AND ?:companies.url LIKE ?l", "%" . trim($params['url']) . "%");
    }
    if (isset($params['fax']) && fn_string_not_empty($params['fax'])) {
        $condition .= db_quote(" AND ?:companies.fax LIKE ?l", "%" . trim($params['fax']) . "%");
    }
    if (!empty($params['company_id'])) {
        $condition .= db_quote(' AND ?:companies.company_id IN (?n)', $params['company_id']);
    }
    if (!empty($params['exclude_company_id'])) {
        $condition .= db_quote(' AND ?:companies.company_id != ?i', $params['exclude_company_id']);
    }
    fn_set_hook('get_companies', $params, $fields, $sortings, $condition, $join, $auth, $lang_code, $group);
    $sorting = db_sort($params, $sortings, 'company', 'asc');
    // Paginate search results
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT(?:companies.company_id)) FROM ?:companies {$join} WHERE 1 {$condition}");
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $companies = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:companies {$join} WHERE 1 {$condition} {$group} {$sorting} {$limit}");
    return array($companies, $params);
}
Exemplo n.º 26
0
function fn_searchanise_get_products_before_select(&$params, &$join, &$condition, &$u_condition, &$inventory_condition, &$sortings, &$total, &$items_per_page, &$lang_code, &$having)
{
    // disable by core
    if (AREA == 'A' || fn_se_check_disabled() || !empty($params['having']) || !empty($params['disable_searchanise']) || empty($params['search_performed']) || !empty($params['block_data']) || empty($params['q']) && fn_se_get_simple_setting('use_navigation') !== 'Y' || fn_se_get_import_status(fn_se_get_company_id(), $lang_code) != 'done' || !empty($params['pid']) || !empty($params['b_id']) || !empty($params['item_ids']) || !empty($params['feature']) || !empty($params['downloadable']) || !empty($params['tracking']) || !empty($params['shipping_freight_from']) || !empty($params['shipping_freight_to']) || !empty($params['exclude_pid']) || !empty($params['get_query']) || !empty($params['only_short_fields']) || isset($params['supplier_id']) || isset($params['amount_to']) || isset($params['amount_from']) || isset($params['q']) && Registry::get('settings.General.search_objects') || isset($params['compact']) && $params['compact'] == 'Y' || !empty($_REQUEST['sort_by']) && !in_array($_REQUEST['sort_by'], fn_se_get_valid_sortings()) || !empty($params['force_get_by_ids']) && empty($params['pid']) && empty($params['product_id'])) {
        return;
    }
    // disable by addons
    if (!empty($params['rating']) || !empty($params['bestsellers']) || !empty($params['also_bought_for_product_id']) || !empty($params['for_required_product']) || !empty($params['ppcode']) && $params['ppcode'] == 'Y' || isset($params['tag']) && fn_string_not_empty($params['tag']) || Registry::ifGet('addons.age_verification.status', 'D') == 'A' || Registry::ifGet('addons.vendor_data_premoderation.status', 'D') == 'A' || !empty($params['picker_for']) && $params['picker_for'] == 'gift_certificates') {
        return;
    }
    list($restrict_by, $query_by, $union) = fn_se_prepare_request_params($params);
    //
    // Categories
    //
    if (!empty($params['cid'])) {
        $cids = is_array($params['cid']) ? $params['cid'] : array($params['cid']);
        $c_condition = '';
        if (AREA == 'C') {
            $_c_statuses = array('A', 'H');
            // Show enabled categories
            $cids = db_get_fields("SELECT a.category_id FROM ?:categories as a WHERE a.category_id IN (?n) AND a.status IN (?a)", $cids, $_c_statuses);
            $c_condition = db_quote('AND a.status IN (?a) AND (' . fn_find_array_in_set(Tygh::$app['session']['auth']['usergroup_ids'], 'a.usergroup_ids', true) . ')', $_c_statuses);
        }
        $sub_categories_ids = db_get_fields("SELECT a.category_id FROM ?:categories as a LEFT JOIN ?:categories as b ON b.category_id IN (?n) WHERE a.id_path LIKE CONCAT(b.id_path, '/%') ?p", $cids, $c_condition);
        $sub_categories_ids = fn_array_merge($cids, $sub_categories_ids, false);
        if (empty($sub_categories_ids)) {
            $params['force_get_by_ids'] = true;
            $params['pid'] = $params['product_id'] = 0;
            return;
        }
        if (!empty($params['subcats']) && $params['subcats'] == 'Y') {
            $restrict_by['category_id'] = join('|', $sub_categories_ids);
        } else {
            $restrict_by['category_id'] = join('|', $cids);
        }
    }
    //
    // Sortings
    //
    if (!empty($_REQUEST['search_performed']) && empty($_REQUEST['sort_by']) && SE_USE_RELEVANCE_AS_DEFAULT_SORTING == 'Y') {
        $params['sort_by'] = 'relevance';
        $params['sort_order'] = 'asc';
    }
    if (!empty($params['sort_by']) && !in_array($params['sort_by'], fn_se_get_valid_sortings())) {
        return;
    }
    if ($params['sort_by'] == 'product') {
        $sort_by = 'title';
    } elseif ($params['sort_by'] == 'relevance') {
        $params['sort_order'] = 'asc';
        $sort_by = 'relevance';
    } else {
        $sort_by = $params['sort_by'];
    }
    $sort_order = $params['sort_order'] == 'asc' ? 'asc' : 'desc';
    //
    // Items_per_page
    //
    $items_per_page = empty($params['items_per_page']) ? 10 : (int) $params['items_per_page'];
    if (!empty($params['limit'])) {
        $max_results = $params['limit'];
    } else {
        $max_results = $items_per_page;
    }
    $get_items = true;
    $get_facets = false;
    if (!fn_allowed_for('ULTIMATE:FREE') && AREA == 'C' && !empty($params['dispatch']) && in_array($params['dispatch'], fn_se_get_facet_valid_locations()) && fn_se_check_product_filter_block() == true) {
        $get_facets = true;
    }
    $request_params = array('sortBy' => $sort_by, 'sortOrder' => $sort_order, 'union' => $union, 'queryBy' => $query_by, 'restrictBy' => $restrict_by, 'items' => $get_items == true ? 'true' : 'false', 'facets' => $get_facets == true ? 'true' : 'false', 'maxResults' => $max_results, 'startIndex' => ($params['page'] - 1) * $items_per_page);
    if ($request_params['sortBy'] == 'null') {
        unset($request_params['sortBy']);
    }
    if (!empty($params['q']) && fn_strlen($params['q']) > 0) {
        $request_params['q'] = $params['q'];
        $request_params['suggestions'] = 'true';
        $request_params['query_correction'] = 'false';
        $request_params['suggestionsMaxResults'] = 1;
    } else {
        $request_params['q'] = '';
    }
    $result = fn_searchanise_send_search_request($request_params, $lang_code);
    if ($result == false) {
        //revert to standart sorting
        if ($params['sort_by'] == 'relevance') {
            $params['sort_by'] = '';
        }
        Registry::set('runtime.se_use_relevance_sorting', false);
        return;
    }
    if (!empty($result['suggestions']) && count($result['suggestions']) > 0) {
        $params['suggestion'] = reset($result['suggestions']);
    }
    if (!empty($result['items'])) {
        foreach ($result['items'] as $product) {
            $params['pid'][] = $product['product_id'];
        }
        if ($params['sort_by'] == 'relevance') {
            $sortings['relevance'] = "FIELD(products.product_id, '" . join("','", $params['pid']) . "')";
            $params['sort_order'] = 'asc';
        }
    } else {
        $products = array();
        $params['force_get_by_ids'] = true;
        $params['pid'] = $params['product_id'] = 0;
    }
    if (isset($result['facets'])) {
        Registry::set('searchanise.received_facets', $result['facets']);
    }
    $total = $result['totalItems'];
    $params['limit'] = $items_per_page;
    // need to set it manually for proper pagination
    // reset condition with text search && filtering params  - we are get all control under process of  text search and filtering
    $condition = '';
    $join = '';
    return;
}
Exemplo n.º 27
0
function fn_get_gift_certificates($params, $items_per_page = 0)
{
    // Init filter
    $params = LastView::instance()->update('gift_certs', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array('?:gift_certificates.gift_cert_id', '?:gift_certificates.gift_cert_code', '?:gift_certificates.timestamp', '?:gift_certificates.amount', '?:gift_certificates.status', '?:gift_certificates.recipient', '?:gift_certificates.sender', '?:gift_certificates.send_via', '?:gift_certificates.email');
    if (fn_allowed_for('ULTIMATE')) {
        $fields[] = '?:gift_certificates.company_id';
    }
    // Define sort fields
    $sortings = array('timestamp' => "?:gift_certificates.timestamp", 'amount' => "?:gift_certificates.amount", 'recipient' => "?:gift_certificates.recipient", 'sender' => "?:gift_certificates.sender", 'status' => "?:gift_certificates.status", 'gift_cert_code' => "?:gift_certificates.gift_cert_code", 'send_via' => "?:gift_certificates.send_via");
    $sorting = db_sort($params, $sortings, 'timestamp', 'desc');
    $condition = $join = '';
    if (isset($params['sender']) && fn_string_not_empty($params['sender'])) {
        $condition .= db_quote(" AND ?:gift_certificates.sender LIKE ?l", "%" . trim($params['sender']) . "%");
    }
    if (isset($params['recipient']) && fn_string_not_empty($params['recipient'])) {
        $condition .= db_quote(" AND ?:gift_certificates.recipient LIKE ?l", "%" . trim($params['recipient']) . "%");
    }
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition .= db_quote(" AND ?:gift_certificates.email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    if (!empty($params['amount_from'])) {
        $condition .= db_quote(" AND ?:gift_certificates.amount >= ?d", $params['amount_from']);
    }
    if (!empty($params['amount_to'])) {
        $condition .= db_quote(" AND ?:gift_certificates.amount <= ?d", $params['amount_to']);
    }
    if (!empty($params['gift_cert_ids'])) {
        $condition .= db_quote(" AND ?:gift_certificates.gift_cert_id IN (?n)", $params['gift_cert_ids']);
    }
    if (!empty($params['status'])) {
        $condition .= db_quote(" AND ?:gift_certificates.status IN (?a)", $params['status']);
    }
    if (isset($params['gift_cert_code']) && fn_string_not_empty($params['gift_cert_code'])) {
        $condition .= db_quote(" AND ?:gift_certificates.gift_cert_code LIKE ?l", "%" . trim($params['gift_cert_code']) . "%");
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:gift_certificates.timestamp >= ?i AND ?:gift_certificates.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:gift_certificates WHERE 1 ?p", $condition . fn_get_gift_certificate_company_condition('?:gift_certificates.company_id'));
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $gift_certificates = db_get_array("SELECT ?p  FROM ?:gift_certificates WHERE 1 ?p ?p ?p", implode(',', $fields), $condition . fn_get_gift_certificate_company_condition('?:gift_certificates.company_id'), $sorting, $limit);
    foreach ($gift_certificates as $k => $v) {
        $debit_balance = db_get_row("SELECT debit, debit_products FROM ?:gift_certificates_log WHERE gift_cert_id = ?i ORDER BY log_id DESC", $v['gift_cert_id']);
        $gift_certificates[$k]['debit'] = empty($debit_balance) ? $v['amount'] : $debit_balance['debit'];
    }
    LastView::instance()->processResults('gift_certificates', $gift_certificates, $params);
    return array($gift_certificates, $params);
}
Exemplo n.º 28
0
function fn_get_shipments_info($params, $items_per_page = 0)
{
    // Init view params
    $params = LastView::instance()->update('shipments', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $fields_list = array('?:shipments.shipment_id', '?:shipments.timestamp AS shipment_timestamp', '?:shipments.comments', '?:shipment_items.order_id', '?:orders.timestamp AS order_timestamp', '?:orders.s_firstname', '?:orders.s_lastname', '?:orders.user_id');
    $joins = array('LEFT JOIN ?:shipment_items ON (?:shipments.shipment_id = ?:shipment_items.shipment_id)', 'LEFT JOIN ?:orders ON (?:shipment_items.order_id = ?:orders.order_id)');
    $condition = '';
    if (Registry::get('runtime.company_id')) {
        $joins[] = 'LEFT JOIN ?:companies ON (?:companies.company_id = ?:orders.company_id)';
        $condition = db_quote(' AND ?:companies.company_id = ?i', Registry::get('runtime.company_id'));
    }
    $group = array('?:shipments.shipment_id');
    // Define sort fields
    $sortings = array('id' => "?:shipments.shipment_id", 'order_id' => "?:orders.order_id", 'shipment_date' => "?:shipments.timestamp", 'order_date' => "?:orders.timestamp", 'customer' => array("?:orders.s_lastname", "?:orders.s_firstname"));
    $sorting = db_sort($params, $sortings, 'id', 'desc');
    if (isset($params['advanced_info']) && $params['advanced_info']) {
        $fields_list[] = '?:shipments.shipping_id';
        $fields_list[] = '?:shipping_descriptions.shipping AS shipping';
        $fields_list[] = '?:shipments.tracking_number';
        $fields_list[] = '?:shipments.carrier';
        $joins[] = ' LEFT JOIN ?:shippings ON (?:shipments.shipping_id = ?:shippings.shipping_id)';
        $joins[] = db_quote(' LEFT JOIN ?:shipping_descriptions ON (?:shippings.shipping_id = ?:shipping_descriptions.shipping_id AND ?:shipping_descriptions.lang_code = ?s)', DESCR_SL);
    }
    if (!empty($params['order_id'])) {
        $condition .= db_quote(' AND ?:shipment_items.order_id = ?i', $params['order_id']);
    }
    if (!empty($params['shipment_id'])) {
        $condition .= db_quote(' AND ?:shipments.shipment_id = ?i', $params['shipment_id']);
    }
    if (isset($params['cname']) && fn_string_not_empty($params['cname'])) {
        $arr = fn_explode(' ', $params['cname']);
        foreach ($arr as $k => $v) {
            if (!fn_string_not_empty($v)) {
                unset($arr[$k]);
            }
        }
        if (sizeof($arr) == 2) {
            $condition .= db_quote(" AND ?:orders.firstname LIKE ?l AND ?:orders.lastname LIKE ?l", "%" . array_shift($arr) . "%", "%" . array_shift($arr) . "%");
        } else {
            $condition .= db_quote(" AND (?:orders.firstname LIKE ?l OR ?:orders.lastname LIKE ?l)", "%" . trim($params['cname']) . "%", "%" . trim($params['cname']) . "%");
        }
    }
    if (!empty($params['p_ids']) || !empty($params['product_view_id'])) {
        $arr = strpos($params['p_ids'], ',') !== false || !is_array($params['p_ids']) ? explode(',', $params['p_ids']) : $params['p_ids'];
        if (empty($params['product_view_id'])) {
            $condition .= db_quote(" AND ?:shipment_items.product_id IN (?n)", $arr);
        } else {
            $condition .= db_quote(" AND ?:shipment_items.product_id IN (?n)", db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true)), ','));
        }
        $joins[] = "LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id";
    }
    if (!empty($params['shipment_period']) && $params['shipment_period'] != 'A') {
        $params['time_from'] = $params['shipment_time_from'];
        $params['time_to'] = $params['shipment_time_to'];
        $params['period'] = $params['shipment_period'];
        list($params['shipment_time_from'], $params['shipment_time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:shipments.timestamp >= ?i AND ?:shipments.timestamp <= ?i)", $params['shipment_time_from'], $params['shipment_time_to']);
    }
    if (!empty($params['order_period']) && $params['order_period'] != 'A') {
        $params['time_from'] = $params['order_time_from'];
        $params['time_to'] = $params['order_time_to'];
        $params['period'] = $params['order_period'];
        list($params['order_time_from'], $params['order_time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:orders.timestamp >= ?i AND ?:orders.timestamp <= ?i)", $params['order_time_from'], $params['order_time_to']);
    }
    fn_set_hook('get_shipments', $params, $fields_list, $joins, $condition, $group);
    $fields_list = implode(', ', $fields_list);
    $joins = implode(' ', $joins);
    $group = implode(', ', $group);
    if (!empty($group)) {
        $group = ' GROUP BY ' . $group;
    }
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT(?:shipments.shipment_id)) FROM ?:shipments {$joins} WHERE 1 {$condition}");
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $shipments = db_get_array("SELECT {$fields_list} FROM ?:shipments {$joins} WHERE 1 {$condition} {$group} {$sorting} {$limit}");
    if (isset($params['advanced_info']) && $params['advanced_info'] && !empty($shipments)) {
        $shipment = reset($shipments);
        $order_info = fn_get_order_info($shipment['order_id']);
        foreach ($shipments as $id => $shipment) {
            $items = db_get_array('SELECT item_id, amount FROM ?:shipment_items WHERE shipment_id = ?i', $shipment['shipment_id']);
            if (!empty($items)) {
                foreach ($items as $item) {
                    $shipments[$id]['products'][$item['item_id']] = $item['amount'];
                    if (!empty($order_info['products'][$item['item_id']]['extra']['group_key'])) {
                        $shipments[$id]['group_key'] = $order_info['products'][$item['item_id']]['extra']['group_key'];
                    } else {
                        $shipments[$id]['group_key'] = 0;
                    }
                }
            }
        }
        if (Settings::instance()->getValue('use_shipments', '', $order_info['company_id']) != 'Y') {
            foreach ($shipments as $id => $shipment) {
                $shipments[$id]['one_full'] = true;
                foreach ($order_info['products'] as $product_key => $product) {
                    $group_key = !empty($product['extra']['group_key']) ? $product['extra']['group_key'] : 0;
                    if ($shipment['group_key'] == $group_key) {
                        if (empty($shipment['products'][$product_key]) || $shipment['products'][$product_key] < $product['amount']) {
                            $shipments[$id]['one_full'] = false;
                            break;
                        }
                    }
                }
            }
        }
    }
    /**
     * Changes selected shipments
     *
     * @param array $shipments Array of shipments
     * @param array $params    Shipments search params
     */
    fn_set_hook('get_shipments_info_post', $shipments, $params);
    LastView::instance()->processResults('shipments_info', $shipments, $params);
    return array($shipments, $params);
}
Exemplo n.º 29
0
function fn_get_product_subscribers($params, $items_per_page = 0)
{
    // Set default values to input params
    $default_params = array('page' => 1, 'email' => '', 'product_id' => 0, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    /**
     * Changes params for getting product subscribers
     *
     * @param array $params Search subscribers params
     */
    fn_set_hook('get_product_subscribers_pre', $params);
    // Init filter
    $params = LastView::instance()->update('subscribers', $params);
    $condition = '';
    $limit = '';
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition .= db_quote(" AND email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    $sorting = db_sort($params, array('email' => 'email'), 'email', 'asc');
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:product_subscriptions WHERE product_id = ?i {$condition}", $params['product_id']);
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $subscribers = db_get_hash_array("SELECT subscription_id as subscriber_id, email FROM ?:product_subscriptions WHERE product_id = ?i {$condition} {$sorting} {$limit}", 'subscriber_id', $params['product_id']);
    /**
     * Changes product subscribers
     *
     * @param int   $product_id  Product identifier
     * @param array $params      Search subscribers params
     * @param array $subscribers Array of subscribers
     */
    fn_set_hook('get_product_subscribers_post', $params, $subscribers);
    return array($subscribers, $params);
}
    function content_55ccf2ea705e17_82557313($_smarty_tpl)
    {
        if (!is_callable('smarty_function_math')) {
            include '/home/coriolan/public_html/lead/app/lib/other/smarty/plugins/function.math.php';
        }
        if (!is_callable('smarty_function_set_id')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/function.set_id.php';
        }
        if ($_smarty_tpl->tpl_vars['runtime']->value['customization_mode']['design'] == "Y" && @constant('AREA') == "C") {
            $_smarty_tpl->_capture_stack[0][] = array("template_content", null, null);
            ob_start();
            $_smarty_tpl->tpl_vars["min"] = new Smarty_variable($_smarty_tpl->tpl_vars['filter']->value['range_values']['min'], null, 0);
            $_smarty_tpl->tpl_vars["max"] = new Smarty_variable($_smarty_tpl->tpl_vars['filter']->value['range_values']['max'], null, 0);
            $_smarty_tpl->tpl_vars["left"] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['filter']->value['range_values']['left']) === null || $tmp === '' ? $_smarty_tpl->tpl_vars['min']->value : $tmp, null, 0);
            $_smarty_tpl->tpl_vars["right"] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['filter']->value['range_values']['right']) === null || $tmp === '' ? $_smarty_tpl->tpl_vars['max']->value : $tmp, null, 0);
            ?>

<?php 
            if ($_smarty_tpl->tpl_vars['max']->value - $_smarty_tpl->tpl_vars['min']->value <= $_smarty_tpl->tpl_vars['filter']->value['round_to']) {
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["disable_slider"] = new Smarty_variable(true, null, 0);
            } elseif ($_smarty_tpl->tpl_vars['max']->value - $_smarty_tpl->tpl_vars['min']->value >= 4 * $_smarty_tpl->tpl_vars['filter']->value['round_to']) {
                ?>
    <?php 
                echo smarty_function_math(array('equation' => "min + round((max - min) * 0.25 / rto) * rto", 'max' => $_smarty_tpl->tpl_vars['max']->value, 'min' => $_smarty_tpl->tpl_vars['min']->value, 'rto' => $_smarty_tpl->tpl_vars['filter']->value['round_to'], 'assign' => "num_25"), $_smarty_tpl);
                ?>

    <?php 
                echo smarty_function_math(array('equation' => "min + round((max - min) * 0.50 / rto) * rto", 'max' => $_smarty_tpl->tpl_vars['max']->value, 'min' => $_smarty_tpl->tpl_vars['min']->value, 'rto' => $_smarty_tpl->tpl_vars['filter']->value['round_to'], 'assign' => "num_50"), $_smarty_tpl);
                ?>

    <?php 
                echo smarty_function_math(array('equation' => "min + round((max - min) * 0.75 / rto) * rto", 'max' => $_smarty_tpl->tpl_vars['max']->value, 'min' => $_smarty_tpl->tpl_vars['min']->value, 'rto' => $_smarty_tpl->tpl_vars['filter']->value['round_to'], 'assign' => "num_75"), $_smarty_tpl);
                ?>

<?php 
            }
            ?>

<?php 
            if (fn_string_not_empty($_smarty_tpl->tpl_vars['filter']->value['range_values']['left']) || fn_string_not_empty($_smarty_tpl->tpl_vars['filter']->value['range_values']['right'])) {
                ?>
    <?php 
                $_smarty_tpl->_capture_stack[0][] = array("has_selected", null, null);
                ob_start();
                ?>
Y<?php 
                list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
                if (!empty($_capture_buffer)) {
                    if (isset($_capture_assign)) {
                        $_smarty_tpl->assign($_capture_assign, ob_get_contents());
                    }
                    if (isset($_capture_append)) {
                        $_smarty_tpl->append($_capture_append, ob_get_contents());
                    }
                    Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
                } else {
                    $_smarty_tpl->capture_error();
                }
            }
            ?>

<?php 
            if ($_smarty_tpl->tpl_vars['dynamic']->value) {
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["filter_slider_hash"] = new Smarty_variable(fn_add_range_to_url_hash($_REQUEST['features_hash'], '###-###', $_smarty_tpl->tpl_vars['filter']->value['field_type']), null, 0);
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["filter_slider_url"] = new Smarty_variable(fn_url(fn_link_attach($_smarty_tpl->tpl_vars['filter_qstring']->value, "features_hash=" . (string) $_smarty_tpl->tpl_vars['filter_slider_hash']->value)), null, 0);
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["use_ajax"] = new Smarty_variable(fn_compare_dispatch($_smarty_tpl->tpl_vars['filter_slider_url']->value, $_smarty_tpl->tpl_vars['config']->value['current_url']), null, 0);
            } else {
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["filter_slider_hash"] = new Smarty_variable(fn_add_range_to_url_hash('', '###-###', $_smarty_tpl->tpl_vars['filter']->value['field_type']), null, 0);
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["filter_slider_url"] = new Smarty_variable(fn_url("products.search?features_hash=" . (string) $_smarty_tpl->tpl_vars['filter_slider_hash']->value), null, 0);
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["use_ajax"] = new Smarty_variable(false, null, 0);
            }
            ?>

<div id="content_<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['filter_uid']->value, ENT_QUOTES, 'UTF-8');
            ?>
" class="ty-price-slider hidden <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['extra_class']->value, ENT_QUOTES, 'UTF-8');
            ?>
 cm-popup-box ty-dropdown-box__content">
    <input type="text" class="ty-price-slider__input-text" id="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
_left" name="left_<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['left']->value, ENT_QUOTES, 'UTF-8');
            ?>
"<?php 
            if ($_smarty_tpl->tpl_vars['disable_slider']->value) {
                ?>
 disabled="disabled"<?php 
            }
            ?>
 />
    &nbsp;–&nbsp;
    <input type="text" class="ty-price-slider__input-text" id="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
_right" name="right_<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['right']->value, ENT_QUOTES, 'UTF-8');
            ?>
"<?php 
            if ($_smarty_tpl->tpl_vars['disable_slider']->value) {
                ?>
 disabled="disabled"<?php 
            }
            ?>
 />
    <?php 
            if ($_smarty_tpl->tpl_vars['filter']->value['field_type'] == 'P') {
                ?>
        &nbsp;<?php 
                echo $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['symbol'];
                ?>

    <?php 
            }
            ?>

    <div id="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
" class="ty-range-slider cm-range-slider">
        <ul class="ty-range-slider__wrapper">
            <li class="ty-range-slider__item" style="left: 0%;"><span class="ty-range-slider__num"><?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['min']->value, ENT_QUOTES, 'UTF-8');
            ?>
</span></li>
            <?php 
            if ($_smarty_tpl->tpl_vars['num_25']->value) {
                ?>
                <li class="ty-range-slider__item" style="left: 25%;"><span class="ty-range-slider__num"><?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['num_25']->value, ENT_QUOTES, 'UTF-8');
                ?>
</span></li>
                <li class="ty-range-slider__item" style="left: 50%;"><span class="ty-range-slider__num"><?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['num_50']->value, ENT_QUOTES, 'UTF-8');
                ?>
</span></li>
                <li class="ty-range-slider__item" style="left: 75%;"><span class="ty-range-slider__num"><?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['num_75']->value, ENT_QUOTES, 'UTF-8');
                ?>
</span></li>
            <?php 
            }
            ?>
            <li class="ty-range-slider__item" style="left: 100%;"><span class="ty-range-slider__num"><?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['max']->value, ENT_QUOTES, 'UTF-8');
            ?>
</span></li>
        </ul>
    </div>

    <?php 
            if ($_smarty_tpl->tpl_vars['right']->value == $_smarty_tpl->tpl_vars['left']->value) {
                ?>
        <?php 
                echo smarty_function_math(array('equation' => "left + rto", 'left' => $_smarty_tpl->tpl_vars['left']->value, 'rto' => $_smarty_tpl->tpl_vars['filter']->value['round_to'], 'assign' => "_right"), $_smarty_tpl);
                ?>

    <?php 
            } else {
                ?>
        <?php 
                $_smarty_tpl->tpl_vars["_right"] = new Smarty_variable($_smarty_tpl->tpl_vars['right']->value, null, 0);
                ?>
    <?php 
            }
            ?>
    
    <input type="hidden" id="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
_json" value='{
        "disabled": <?php 
            echo htmlspecialchars(($tmp = @$_smarty_tpl->tpl_vars['disable_slider']->value) === null || $tmp === '' ? "false" : $tmp, ENT_QUOTES, 'UTF-8');
            ?>
,
        "min": <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['min']->value, ENT_QUOTES, 'UTF-8');
            ?>
,
        "max": <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['max']->value, ENT_QUOTES, 'UTF-8');
            ?>
,
        "left": <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['left']->value, ENT_QUOTES, 'UTF-8');
            ?>
,
        "right": <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['_right']->value, ENT_QUOTES, 'UTF-8');
            ?>
,
        "step": <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['filter']->value['round_to'], ENT_QUOTES, 'UTF-8');
            ?>
,
        "url": "<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['filter_slider_url']->value, ENT_QUOTES, 'UTF-8');
            ?>
",
        "type": "<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['filter']->value['field_type'], ENT_QUOTES, 'UTF-8');
            ?>
",
        "currency": "<?php 
            echo htmlspecialchars(@constant('CART_SECONDARY_CURRENCY'), ENT_QUOTES, 'UTF-8');
            ?>
",
        
        "ajax": false,
        "result_ids": "<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['ajax_div_ids']->value, ENT_QUOTES, 'UTF-8');
            ?>
",
        "scroll": ".cm-pagination-container"
    }' />
    
</div>
<?php 
            list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
            if (!empty($_capture_buffer)) {
                if (isset($_capture_assign)) {
                    $_smarty_tpl->assign($_capture_assign, ob_get_contents());
                }
                if (isset($_capture_append)) {
                    $_smarty_tpl->append($_capture_append, ob_get_contents());
                }
                Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
            } else {
                $_smarty_tpl->capture_error();
            }
            if (trim(Smarty::$_smarty_vars['capture']['template_content'])) {
                if ($_smarty_tpl->tpl_vars['auth']->value['area'] == "A") {
                    ?>
<span class="cm-template-box template-box" data-ca-te-template="blocks/product_filters/components/product_filter_slider.tpl" id="<?php 
                    echo smarty_function_set_id(array('name' => "blocks/product_filters/components/product_filter_slider.tpl"), $_smarty_tpl);
                    ?>
"><div class="cm-template-icon icon-edit ty-icon-edit hidden"></div><?php 
                    echo Smarty::$_smarty_vars['capture']['template_content'];
                    ?>
<!--[/tpl_id]--></span><?php 
                } else {
                    echo Smarty::$_smarty_vars['capture']['template_content'];
                }
            }
        } else {
            $_smarty_tpl->tpl_vars["min"] = new Smarty_variable($_smarty_tpl->tpl_vars['filter']->value['range_values']['min'], null, 0);
            $_smarty_tpl->tpl_vars["max"] = new Smarty_variable($_smarty_tpl->tpl_vars['filter']->value['range_values']['max'], null, 0);
            $_smarty_tpl->tpl_vars["left"] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['filter']->value['range_values']['left']) === null || $tmp === '' ? $_smarty_tpl->tpl_vars['min']->value : $tmp, null, 0);
            $_smarty_tpl->tpl_vars["right"] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['filter']->value['range_values']['right']) === null || $tmp === '' ? $_smarty_tpl->tpl_vars['max']->value : $tmp, null, 0);
            ?>

<?php 
            if ($_smarty_tpl->tpl_vars['max']->value - $_smarty_tpl->tpl_vars['min']->value <= $_smarty_tpl->tpl_vars['filter']->value['round_to']) {
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["disable_slider"] = new Smarty_variable(true, null, 0);
            } elseif ($_smarty_tpl->tpl_vars['max']->value - $_smarty_tpl->tpl_vars['min']->value >= 4 * $_smarty_tpl->tpl_vars['filter']->value['round_to']) {
                ?>
    <?php 
                echo smarty_function_math(array('equation' => "min + round((max - min) * 0.25 / rto) * rto", 'max' => $_smarty_tpl->tpl_vars['max']->value, 'min' => $_smarty_tpl->tpl_vars['min']->value, 'rto' => $_smarty_tpl->tpl_vars['filter']->value['round_to'], 'assign' => "num_25"), $_smarty_tpl);
                ?>

    <?php 
                echo smarty_function_math(array('equation' => "min + round((max - min) * 0.50 / rto) * rto", 'max' => $_smarty_tpl->tpl_vars['max']->value, 'min' => $_smarty_tpl->tpl_vars['min']->value, 'rto' => $_smarty_tpl->tpl_vars['filter']->value['round_to'], 'assign' => "num_50"), $_smarty_tpl);
                ?>

    <?php 
                echo smarty_function_math(array('equation' => "min + round((max - min) * 0.75 / rto) * rto", 'max' => $_smarty_tpl->tpl_vars['max']->value, 'min' => $_smarty_tpl->tpl_vars['min']->value, 'rto' => $_smarty_tpl->tpl_vars['filter']->value['round_to'], 'assign' => "num_75"), $_smarty_tpl);
                ?>

<?php 
            }
            ?>

<?php 
            if (fn_string_not_empty($_smarty_tpl->tpl_vars['filter']->value['range_values']['left']) || fn_string_not_empty($_smarty_tpl->tpl_vars['filter']->value['range_values']['right'])) {
                ?>
    <?php 
                $_smarty_tpl->_capture_stack[0][] = array("has_selected", null, null);
                ob_start();
                ?>
Y<?php 
                list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
                if (!empty($_capture_buffer)) {
                    if (isset($_capture_assign)) {
                        $_smarty_tpl->assign($_capture_assign, ob_get_contents());
                    }
                    if (isset($_capture_append)) {
                        $_smarty_tpl->append($_capture_append, ob_get_contents());
                    }
                    Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
                } else {
                    $_smarty_tpl->capture_error();
                }
            }
            ?>

<?php 
            if ($_smarty_tpl->tpl_vars['dynamic']->value) {
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["filter_slider_hash"] = new Smarty_variable(fn_add_range_to_url_hash($_REQUEST['features_hash'], '###-###', $_smarty_tpl->tpl_vars['filter']->value['field_type']), null, 0);
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["filter_slider_url"] = new Smarty_variable(fn_url(fn_link_attach($_smarty_tpl->tpl_vars['filter_qstring']->value, "features_hash=" . (string) $_smarty_tpl->tpl_vars['filter_slider_hash']->value)), null, 0);
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["use_ajax"] = new Smarty_variable(fn_compare_dispatch($_smarty_tpl->tpl_vars['filter_slider_url']->value, $_smarty_tpl->tpl_vars['config']->value['current_url']), null, 0);
            } else {
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["filter_slider_hash"] = new Smarty_variable(fn_add_range_to_url_hash('', '###-###', $_smarty_tpl->tpl_vars['filter']->value['field_type']), null, 0);
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["filter_slider_url"] = new Smarty_variable(fn_url("products.search?features_hash=" . (string) $_smarty_tpl->tpl_vars['filter_slider_hash']->value), null, 0);
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["use_ajax"] = new Smarty_variable(false, null, 0);
            }
            ?>

<div id="content_<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['filter_uid']->value, ENT_QUOTES, 'UTF-8');
            ?>
" class="ty-price-slider hidden <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['extra_class']->value, ENT_QUOTES, 'UTF-8');
            ?>
 cm-popup-box ty-dropdown-box__content">
    <input type="text" class="ty-price-slider__input-text" id="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
_left" name="left_<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['left']->value, ENT_QUOTES, 'UTF-8');
            ?>
"<?php 
            if ($_smarty_tpl->tpl_vars['disable_slider']->value) {
                ?>
 disabled="disabled"<?php 
            }
            ?>
 />
    &nbsp;–&nbsp;
    <input type="text" class="ty-price-slider__input-text" id="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
_right" name="right_<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['right']->value, ENT_QUOTES, 'UTF-8');
            ?>
"<?php 
            if ($_smarty_tpl->tpl_vars['disable_slider']->value) {
                ?>
 disabled="disabled"<?php 
            }
            ?>
 />
    <?php 
            if ($_smarty_tpl->tpl_vars['filter']->value['field_type'] == 'P') {
                ?>
        &nbsp;<?php 
                echo $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['symbol'];
                ?>

    <?php 
            }
            ?>

    <div id="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
" class="ty-range-slider cm-range-slider">
        <ul class="ty-range-slider__wrapper">
            <li class="ty-range-slider__item" style="left: 0%;"><span class="ty-range-slider__num"><?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['min']->value, ENT_QUOTES, 'UTF-8');
            ?>
</span></li>
            <?php 
            if ($_smarty_tpl->tpl_vars['num_25']->value) {
                ?>
                <li class="ty-range-slider__item" style="left: 25%;"><span class="ty-range-slider__num"><?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['num_25']->value, ENT_QUOTES, 'UTF-8');
                ?>
</span></li>
                <li class="ty-range-slider__item" style="left: 50%;"><span class="ty-range-slider__num"><?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['num_50']->value, ENT_QUOTES, 'UTF-8');
                ?>
</span></li>
                <li class="ty-range-slider__item" style="left: 75%;"><span class="ty-range-slider__num"><?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['num_75']->value, ENT_QUOTES, 'UTF-8');
                ?>
</span></li>
            <?php 
            }
            ?>
            <li class="ty-range-slider__item" style="left: 100%;"><span class="ty-range-slider__num"><?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['max']->value, ENT_QUOTES, 'UTF-8');
            ?>
</span></li>
        </ul>
    </div>

    <?php 
            if ($_smarty_tpl->tpl_vars['right']->value == $_smarty_tpl->tpl_vars['left']->value) {
                ?>
        <?php 
                echo smarty_function_math(array('equation' => "left + rto", 'left' => $_smarty_tpl->tpl_vars['left']->value, 'rto' => $_smarty_tpl->tpl_vars['filter']->value['round_to'], 'assign' => "_right"), $_smarty_tpl);
                ?>

    <?php 
            } else {
                ?>
        <?php 
                $_smarty_tpl->tpl_vars["_right"] = new Smarty_variable($_smarty_tpl->tpl_vars['right']->value, null, 0);
                ?>
    <?php 
            }
            ?>
    
    <input type="hidden" id="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8');
            ?>
_json" value='{
        "disabled": <?php 
            echo htmlspecialchars(($tmp = @$_smarty_tpl->tpl_vars['disable_slider']->value) === null || $tmp === '' ? "false" : $tmp, ENT_QUOTES, 'UTF-8');
            ?>
,
        "min": <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['min']->value, ENT_QUOTES, 'UTF-8');
            ?>
,
        "max": <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['max']->value, ENT_QUOTES, 'UTF-8');
            ?>
,
        "left": <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['left']->value, ENT_QUOTES, 'UTF-8');
            ?>
,
        "right": <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['_right']->value, ENT_QUOTES, 'UTF-8');
            ?>
,
        "step": <?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['filter']->value['round_to'], ENT_QUOTES, 'UTF-8');
            ?>
,
        "url": "<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['filter_slider_url']->value, ENT_QUOTES, 'UTF-8');
            ?>
",
        "type": "<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['filter']->value['field_type'], ENT_QUOTES, 'UTF-8');
            ?>
",
        "currency": "<?php 
            echo htmlspecialchars(@constant('CART_SECONDARY_CURRENCY'), ENT_QUOTES, 'UTF-8');
            ?>
",
        
        "ajax": false,
        "result_ids": "<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['ajax_div_ids']->value, ENT_QUOTES, 'UTF-8');
            ?>
",
        "scroll": ".cm-pagination-container"
    }' />
    
</div>
<?php 
        }
    }