当前位置: 首页>>代码示例>>PHP>>正文


PHP fn_create_periods函数代码示例

本文整理汇总了PHP中fn_create_periods函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_create_periods函数的具体用法?PHP fn_create_periods怎么用?PHP fn_create_periods使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fn_create_periods函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fn_get_order_reports

function fn_get_order_reports($view = false, $report_id = 0)
{
    $status = empty($view) ? "" : "AND status = 'A'";
    $data = db_get_hash_array("SELECT a.*, b.description FROM ?:sales_reports as a LEFT JOIN ?:sales_reports_descriptions as b ON a.report_id = b.report_id AND lang_code = ?s WHERE type = 'O' {$status} ORDER BY position", 'report_id', CART_LANGUAGE);
    if (empty($data)) {
        return array();
    }
    // If we manage reports we need only it's name
    if (empty($view)) {
        return $data;
    }
    $k = $report_id;
    list($data[$k]['time_from'], $data[$k]['time_to']) = fn_create_periods($data[$k]);
    $data[$k]['tables'] = db_get_hash_array("SELECT a.*, b.description FROM ?:sales_reports_tables as a LEFT JOIN ?:sales_reports_table_descriptions as b ON a.table_id = b.table_id AND lang_code = ?s WHERE a.report_id = ?i ORDER BY position", 'table_id', CART_LANGUAGE, $report_id);
    foreach ($data[$k]['tables'] as $key => $value) {
        $data[$k]['tables'][$key]['time_from'] = $data[$k]['time_from'];
        $data[$k]['tables'][$key]['time_to'] = $data[$k]['time_to'];
        $elements = db_get_array("SELECT a.*, c.code FROM ?:sales_reports_table_elements as a LEFT JOIN ?:sales_reports_elements as c ON a.element_id = c.element_id WHERE a.table_id = ?i ORDER BY a.position", $value['table_id']);
        //var_dump($key, $value); echo '+++++<br/>'; var_dump($elements); echo '-----<br/>';
        $data[$k]['tables'][$key]['interval_id'] = $value['interval_id'];
        $data[$k]['tables'][$key]['elements'] = fn_check_elements($elements, $data[$k]['tables'][$key]['time_from'], $data[$k]['tables'][$key]['time_to'], $value);
        $data[$k]['tables'][$key]['intervals'] = fn_check_intervals($data[$k]['tables'][$key]['interval_id'], $data[$k]['tables'][$key]['time_from'], $data[$k]['tables'][$key]['time_to']);
    }
    return $data;
}
开发者ID:ambient-lounge,项目名称:site,代码行数:25,代码来源:fn.sales_reports.php

示例2: fn_get_banners

function fn_get_banners($params = array(), $lang_code = CART_LANGUAGE)
{
    $default_params = array('items_per_page' => 0);
    $params = array_merge($default_params, $params);
    $sortings = array('position' => '?:banners.position', 'timestamp' => '?:banners.timestamp', 'name' => '?:banner_descriptions.banner');
    $condition = $limit = '';
    if (!empty($params['limit'])) {
        $limit = db_quote(' LIMIT 0, ?i', $params['limit']);
    }
    $sorting = db_sort($params, $sortings, 'name', 'asc');
    $condition = AREA == 'A' ? '' : " AND ?:banners.status = 'A' ";
    $condition .= fn_get_localizations_condition('?:banners.localization');
    $condition .= AREA == 'A' ? '' : " AND (?:banners.type != 'G' OR ?:banner_images.banner_image_id IS NOT NULL) ";
    if (!empty($params['item_ids'])) {
        $condition .= db_quote(' AND ?:banners.banner_id IN (?n)', explode(',', $params['item_ids']));
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:banners.timestamp >= ?i AND ?:banners.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    fn_set_hook('get_banners', $params, $condition, $sorting, $limit, $lang_code);
    $fields = array('?:banners.banner_id', '?:banners.type', '?:banners.target', '?:banners.status', '?:banners.position', '?:banner_descriptions.banner', '?:banner_descriptions.description', '?:banner_descriptions.url', '?:banner_images.banner_image_id');
    if (fn_allowed_for('ULTIMATE')) {
        $fields[] = '?:banners.company_id';
    }
    $banners = db_get_array("SELECT ?p FROM ?:banners " . "LEFT JOIN ?:banner_descriptions ON ?:banner_descriptions.banner_id = ?:banners.banner_id AND ?:banner_descriptions.lang_code = ?s" . "LEFT JOIN ?:banner_images ON ?:banner_images.banner_id = ?:banners.banner_id AND ?:banner_images.lang_code = ?s" . "WHERE 1 ?p ?p ?p", implode(", ", $fields), $lang_code, $lang_code, $condition, $sorting, $limit);
    foreach ($banners as $k => $v) {
        $banners[$k]['main_pair'] = fn_get_image_pairs($v['banner_image_id'], 'promo', 'M', true, false, $lang_code);
    }
    fn_set_hook('get_banners_post', $banners, $params);
    return array($banners, $params);
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:32,代码来源:func.php

示例3: fn_tags_build_conditions

function fn_tags_build_conditions($params)
{
    $conditions = fn_get_tags_company_condition('?:tags.company_id');
    if (!empty($params['object_type'])) {
        $conditions .= db_quote(" AND ?:tag_links.object_type = ?s", $params['object_type']);
    }
    if (!empty($params['status'])) {
        $conditions .= db_quote(" AND ?:tags.status IN (?a)", $params['status']);
    }
    if (!empty($params['object_id'])) {
        $conditions .= db_quote(" AND ?:tag_links.object_id = ?i", $params['object_id']);
    }
    if (!empty($params['user_id'])) {
        $conditions .= db_quote(" AND ?:tag_links.user_id = ?i", $params['user_id']);
    }
    if (isset($params['tag']) && fn_string_not_empty($params['tag'])) {
        $conditions .= db_quote(" AND ?:tags.tag LIKE ?l", "%" . trim($params['tag']) . "%");
    }
    if (!empty($params['user_and_popular'])) {
        $conditions .= db_quote(" AND IF(?:tag_links.user_id = ?i, 1, ?:tags.status IN ('A'))", $params['user_and_popular']);
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $conditions .= db_quote(" AND (?:tags.timestamp >= ?i AND ?:tags.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    return $conditions;
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:27,代码来源:func.php

示例4: fn_get_discussions

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);
}
开发者ID:askzap,项目名称:ultimate,代码行数:58,代码来源:discussion_manager.php

示例5: fn_get_logs

function fn_get_logs($params, $items_per_page = null)
{
    // Init filter
    $params = fn_init_view('logs', $params);
    if ($items_per_page === null) {
        $items_per_page = Registry::get('settings.Appearance.admin_elements_per_page');
    }
    $sortings = array('timestamp' => '?:logs.timestamp', 'user' => array('?:users.lastname', '?:users.firstname'));
    $directions = array('asc' => 'asc', 'desc' => 'desc');
    $fields = array('?:logs.*', '?:users.firstname', '?:users.lastname');
    if (empty($params['sort_order']) || empty($directions[$params['sort_order']])) {
        $params['sort_order'] = 'asc';
    }
    if (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) {
        $params['sort_by'] = 'timestamp';
        $params['sort_order'] = 'desc';
    }
    $params['page'] = empty($params['page']) ? 1 : $params['page'];
    if (is_array($sortings[$params['sort_by']])) {
        $sorting = join(' ' . $directions[$params['sort_order']] . ', ', $sortings[$params['sort_by']]) . ' ' . $directions[$params['sort_order']];
    } else {
        $sorting = $sortings[$params['sort_by']] . ' ' . $directions[$params['sort_order']];
    }
    $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_no_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 LIKE ?l OR ?:logs.type LIKE ?l)", "%{$params['q_type']}%", "%{$params['q_type']}%");
    }
    if (!empty($params['q_action'])) {
        $condition .= db_quote(" AND (?:logs.action LIKE ?l OR ?:logs.action LIKE ?l)", "%{$params['q_action']}%", "%{$params['q_action']}%");
    }
    $limit = '';
    $total = 0;
    if (!empty($items_per_page)) {
        $total = db_get_field("SELECT COUNT(DISTINCT(?:logs.log_id)) FROM ?:logs ?p WHERE 1 ?p", $join, $condition);
        $limit = fn_paginate($params['page'], $total, $items_per_page);
    }
    $data = db_get_array("SELECT " . join(', ', $fields) . " FROM ?:logs ?p WHERE 1 ?p ORDER BY {$sorting} {$limit}", $join, $condition);
    if (!$total) {
        $total = count($data);
    }
    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, $total);
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:54,代码来源:logs.php

示例6: fn_get_banners

function fn_get_banners($params, $lang_code = CART_LANGUAGE)
{
    $default_params = array('items_per_page' => 0, 'sort_by' => 'name');
    $params = array_merge($default_params, $params);
    $sortings = array('timestamp' => '?:banners.timestamp', 'name' => '?:banner_descriptions.banner');
    $directions = array('asc' => 'asc', 'desc' => 'desc');
    $condition = $limit = '';
    if (!empty($params['limit'])) {
        $limit = db_quote(' LIMIT 0, ?i', $params['limit']);
    }
    if (empty($params['sort_order']) || empty($directions[$params['sort_order']])) {
        $params['sort_order'] = 'asc';
    }
    if (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) {
        $params['sort_by'] = 'name';
    }
    $sorting = $sortings[$params['sort_by']] . ' ' . $directions[$params['sort_order']];
    $condition = AREA == 'A' ? '' : " AND ?:banners.status = 'A' ";
    $condition .= fn_get_localizations_condition('?:banners.localization');
    if (!empty($params['item_ids'])) {
        $condition .= db_quote(' AND ?:banners.banner_id IN (?n)', explode(',', $params['item_ids']));
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:banners.timestamp >= ?i AND ?:banners.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    $banners = db_get_array("SELECT ?:banners.banner_id, ?:banners.type, ?:banners.target, ?:banners.status, ?:banners.url, ?:banner_descriptions.banner, ?:banner_descriptions.description FROM ?:banners LEFT JOIN ?:banner_descriptions ON ?:banner_descriptions.banner_id = ?:banners.banner_id AND ?:banner_descriptions.lang_code = ?s WHERE 1 ?p ORDER BY ?p ?p", $lang_code, $condition, $sorting, $limit);
    foreach ($banners as $k => $v) {
        $banners[$k]['main_pair'] = fn_get_image_pairs($v['banner_id'], 'banner', 'M', true, false, $lang_code);
    }
    if (!empty($params['item_ids'])) {
        $banners = fn_sort_by_ids($banners, explode(',', $params['item_ids']), 'banner_id');
    }
    fn_set_hook('get_banners', $banners);
    return array($banners, $params);
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:36,代码来源:func.php

示例7: fn_get_subscribers

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);
}
开发者ID:askzap,项目名称:ultimate,代码行数:39,代码来源:subscribers.php

示例8: fn_update_sales_report

function fn_update_sales_report($report_data, $report_id = 0, $lang_code = DESCR_SL)
{
    if (empty($report_id)) {
        $report_data['type'] = !empty($report_data['type']) ? $report_data['type'] : 'O';
        $report_data['period'] = !empty($report_data['period']) ? $report_data['period'] : 'Y';
        list($report_data['time_from'], $report_data['time_to']) = fn_create_periods($report_data);
        $report_id = db_query("INSERT INTO ?:sales_reports ?e", $report_data);
        fn_create_description('sales_reports_descriptions', 'report_id', $report_id, $report_data);
    } else {
        db_query('UPDATE ?:sales_reports SET ?u WHERE report_id = ?i', $report_data, $report_id);
        db_query('UPDATE ?:sales_reports_descriptions SET ?u WHERE report_id = ?i AND lang_code = ?s', $report_data, $report_id, $lang_code);
    }
    if (!empty($report_data['tables'])) {
        foreach ($report_data['tables'] as $k => $value) {
            if (!extension_loaded('gd') && $value['type'] != 'T') {
                if (empty($_flag)) {
                    fn_set_notification('W', __('warning'), __('text_gd_not_avail'));
                }
                $_flag = true;
                $value['type'] = 'T';
            }
            db_query("UPDATE ?:sales_reports_tables SET ?u WHERE table_id = ?i", $value, $k);
            db_query('UPDATE ?:sales_reports_table_descriptions SET ?u WHERE table_id = ?i AND lang_code = ?s', $value, $k, $lang_code);
            if ($value['type'] == 'P') {
                db_query("UPDATE ?:sales_reports_tables SET interval_id = 1 WHERE table_id = ?i", $k);
            }
        }
    }
    return $report_id;
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:30,代码来源:sales_reports.php

示例9: fn_get_logs

/**
 * 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);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:47,代码来源:fn.log.php

示例10: fn_get_rma_returns

function fn_get_rma_returns($params)
{
    // Init filter
    $params = fn_init_view('rma', $params);
    // Set default values to input params
    $params['page'] = empty($params['page']) ? 1 : $params['page'];
    // 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");
    $directions = array('asc' => 'asc', 'desc' => 'desc');
    if (empty($params['sort_order']) || empty($directions[$params['sort_order']])) {
        $params['sort_order'] = 'desc';
    }
    if (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) {
        $params['sort_by'] = 'timestamp';
    }
    $sort = $sortings[$params['sort_by']] . " " . $directions[$params['sort_order']];
    // Reverse sorting (for usage in view)
    $params['sort_order'] = $params['sort_order'] == 'asc' ? 'desc' : 'asc';
    $join = $condition = $group = '';
    if (isset($params['cname']) && fn_string_no_empty($params['cname'])) {
        $arr = fn_explode(' ', $params['cname']);
        foreach ($arr as $k => $v) {
            if (!fn_string_no_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_no_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 (!empty($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));
    }
    $items_per_page = Registry::get('settings.Appearance.' . (AREA == 'A') ? 'admin_elements_per_page' : 'elements_per_page');
    $total = 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 = fn_paginate($params['page'], $total, $items_per_page);
    // FIXME
    $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} ORDER BY {$sort} {$limit}", AREA == 'C' ? CART_LANGUAGE : DESCR_SL);
    return array($return_requests, $params);
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:82,代码来源:rma.post.php

示例11: fn_get_news

function fn_get_news($params, $lang_code = CART_LANGUAGE)
{
    $fields = array('?:news.*', 'descr.news', 'descr.description');
    // Define sort fields
    $sortings = array('position' => '?:news.position', 'name' => '?:news_descriptions.news', 'date' => '?:news.date');
    $directions = array('asc' => 'asc', 'desc' => 'desc');
    $limit = $condition = $sorting = '';
    $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');
    if (!empty($params['b_id'])) {
        $join .= " LEFT JOIN ?:block_links ON ?:block_links.object_id = ?:news.news_id AND ?:block_links.location = 'news'";
        $condition .= db_quote(' AND ?:block_links.block_id = ?i', $params['b_id']);
    }
    if (isset($params['q']) && fn_string_no_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['limit'])) {
        $limit = db_quote(" LIMIT 0, ?i", $params['limit']);
    }
    if (empty($params['sort_order']) || empty($directions[$params['sort_order']])) {
        $params['sort_order'] = 'desc';
    }
    if (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) {
        $params['sort_by'] = 'date';
    }
    $sorting = $sortings[$params['sort_by']] . ' ' . $directions[$params['sort_order']];
    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']));
    }
    // Used for Extended search
    if (!empty($params['get_conditions'])) {
        return array($fields, $join, $condition);
    }
    if (!empty($params['paginate'])) {
        $params['page'] = empty($params['page']) ? 1 : $params['page'];
        $total = db_get_field("SELECT COUNT(?:news.news_id) FROM ?:news ?p WHERE ?p", $join, $condition);
        $limit = fn_paginate($params['page'], $total, AREA == 'A' ? Registry::get('settings.Appearance.admin_elements_per_page') : Registry::get('settings.Appearance.elements_per_page'));
    }
    fn_set_hook('get_news', $params, $fields, $join, $condition, $sorting, $limit, $lang_code);
    $fields = join(', ', $fields);
    $news = db_get_array("SELECT ?p FROM ?:news ?p WHERE ?p ORDER BY ?p ?p", $fields, $join, $condition, $sorting, $limit);
    fn_set_hook('get_news_post', $news);
    return array($news, $params);
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:73,代码来源:func.php

示例12: fn_get_gift_certificates

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);
}
开发者ID:arpad9,项目名称:bygmarket,代码行数:57,代码来源:func.php

示例13: getOrderConditions

 public final function getOrderConditions($params)
 {
     $condition = $join = $group = '';
     if (!empty($params['cname'])) {
         $arr = explode(' ', $params['cname']);
         if (sizeof($arr) == 2) {
             $condition .= db_quote(" AND ?:orders.firstname LIKE ?l AND ?:orders.lastname LIKE ?l", "%{$arr['0']}%", "%{$arr['1']}%");
         } else {
             $condition .= db_quote(" AND (?:orders.firstname LIKE ?l OR ?:orders.lastname LIKE ?l)", "%{$params['cname']}%", "%{$params['cname']}%");
         }
     }
     if (!empty($params['tax_exempt'])) {
         $condition .= db_quote(" AND ?:orders.tax_exempt = ?s", $params['tax_exempt']);
     }
     if (!empty($params['email'])) {
         $condition .= db_quote(" AND ?:orders.email LIKE ?l", "%{$params['email']}%");
     }
     if (!empty($params['user_id'])) {
         $condition .= db_quote(' AND ?:orders.user_id IN (?n)', $params['user_id']);
     }
     if (!empty($params['total_from'])) {
         $condition .= db_quote(" AND ?:orders.total >= ?d", fn_convert_price($params['total_from']));
     }
     if (!empty($params['total_to'])) {
         $condition .= db_quote(" AND ?:orders.total <= ?d", fn_convert_price($params['total_to']));
     }
     if (!empty($params['status'])) {
         $condition .= db_quote(' AND ?:orders.status IN (?a)', $params['status']);
     }
     if (!empty($params['order_id'])) {
         $multiple_ids = strpos($params['order_id'], ',') !== false;
         $condition .= db_quote(' AND ?:orders.order_id IN (?n)', !is_array($params['order_id']) && $multiple_ids ? explode(',', $params['order_id']) : $params['order_id']);
     }
     if (!empty($params['p_ids']) || !empty($params['product_view_id'])) {
         $multiple_ids = strpos($params['p_ids'], ',') !== false;
         $arr = $multiple_ids || !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";
     }
     if (!empty($params['admin_user_id'])) {
         $condition .= db_quote(" AND ?:new_orders.user_id = ?i", $params['admin_user_id']);
         $join .= " LEFT JOIN ?:new_orders ON ?:new_orders.order_id = ?:orders.order_id";
     }
     if (!empty($params['shippings'])) {
         $set_conditions = array();
         foreach ($params['shippings'] as $v) {
             $set_conditions[] = db_quote("FIND_IN_SET(?s, ?:orders.shipping_ids)", $v);
         }
         $condition .= " AND (" . implode(' OR ', $set_conditions) . ")";
     }
     if (!empty($params['period']) && $params['period'] != 'A') {
         list($params['time_from'], $params['time_to']) = fn_create_periods($params);
         $condition .= db_quote(" AND (?:orders.timestamp >= ?i AND ?:orders.timestamp <= ?i)", $params['time_from'], $params['time_to']);
     }
     if (!empty($params['custom_files']) && $params['custom_files'] == 'Y') {
         $condition .= db_quote(" AND ?:order_details.extra LIKE ?l", "%custom_files%");
         if (empty($params['p_ids']) && empty($params['product_view_id'])) {
             $join .= " LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id";
         }
     }
     return array($condition, $join);
 }
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:66,代码来源:OrderMethods.php

示例14: fn_get_pages


//.........这里部分代码省略.........
    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));
    }
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:67,代码来源:fn.cms.php

示例15: fn_get_rma_returns

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);
}
开发者ID:askzap,项目名称:ultimate,代码行数:76,代码来源:rma.post.php


注:本文中的fn_create_periods函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。