Exemple #1
0
     $has_inventory = false;
     foreach ($product_options as $p) {
         if ($p['inventory'] == 'Y') {
             $has_inventory = true;
             break;
         }
     }
     Tygh::$app['view']->assign('has_inventory', $has_inventory);
 }
 Tygh::$app['view']->assign('product_options', $product_options);
 list($global_options) = fn_get_product_global_options();
 Tygh::$app['view']->assign('global_options', $global_options);
 // If the product is electronnicaly distributed, get the assigned files
 list($product_files) = fn_get_product_files(array('product_id' => $_REQUEST['product_id']));
 list($product_file_folders) = fn_get_product_file_folders(array('product_id' => $_REQUEST['product_id']));
 $files_tree = fn_build_files_tree($product_file_folders, $product_files);
 $sharing_company_id = Registry::get('runtime.company_id') ? Registry::get('runtime.company_id') : $product_data['company_id'];
 // Preview URL only exists for companies that have this product shared
 if (fn_allowed_for('ULTIMATE') && !in_array($sharing_company_id, $product_data['shared_between_companies'])) {
     $preview_url = null;
 } else {
     $preview_url = fn_get_preview_url("products.view?product_id={$_REQUEST['product_id']}", $product_data, $auth['user_id']);
 }
 Tygh::$app['view']->assign('view_uri', $preview_url);
 Tygh::$app['view']->assign('product_file_folders', $product_file_folders);
 Tygh::$app['view']->assign('product_files', $product_files);
 Tygh::$app['view']->assign('files_tree', $files_tree);
 Tygh::$app['view']->assign('expand_all', true);
 list($subscribers, $search) = fn_get_product_subscribers($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page'));
 Tygh::$app['view']->assign('product_subscribers', $subscribers);
 Tygh::$app['view']->assign('product_subscribers_search', $search);
Exemple #2
0
function fn_get_user_edp($params, $items_per_page = 0)
{
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $fields = array('?:order_details.product_id', '?:order_details.order_id', '?:order_details.extra', '?:orders.status', '?:products.unlimited_download', '?:product_descriptions.product');
    $where = db_quote(' AND ?:orders.status != ?s', STATUS_INCOMPLETED_ORDER);
    $orders_company_condition = '';
    $limit = '';
    if (fn_allowed_for('ULTIMATE')) {
        $orders_company_condition = fn_get_company_condition('?:orders.company_id');
    }
    if (!empty($params['order_ids'])) {
        if (!is_array($params['order_ids'])) {
            $params['order_ids'] = array($params['order_ids']);
        }
        $where = db_quote(" AND ?:orders.order_id IN (?n)", $params['order_ids']);
    } elseif (!empty($params['items_per_page'])) {
        $params['total_items'] = count(db_get_fields("SELECT COUNT(*)" . " FROM ?:order_details" . " INNER JOIN ?:orders ON ?:orders.order_id = ?:order_details.order_id AND ?:orders.is_parent_order != 'Y' {$orders_company_condition}" . " INNER JOIN ?:product_file_ekeys ON ?:product_file_ekeys.product_id = ?:order_details.product_id AND ?:product_file_ekeys.order_id = ?:order_details.order_id" . " INNER JOIN ?:product_files ON ?:product_files.product_id = ?:order_details.product_id" . " WHERE ?:orders.user_id = ?i AND ?:product_files.status = 'A'" . $where . " GROUP BY ?:order_details.product_id, ?:order_details.order_id", $params['user_id']));
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $products = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:order_details" . " INNER JOIN ?:product_files ON ?:product_files.product_id = ?:order_details.product_id" . " INNER JOIN ?:orders ON ?:orders.order_id = ?:order_details.order_id AND ?:orders.is_parent_order != 'Y' {$orders_company_condition}" . " INNER JOIN ?:product_file_ekeys ON ?:product_file_ekeys.product_id = ?:order_details.product_id AND ?:product_file_ekeys.order_id = ?:order_details.order_id" . " LEFT JOIN ?:products ON ?:products.product_id = ?:order_details.product_id" . " LEFT JOIN ?:product_descriptions ON ?:product_descriptions.product_id = ?:order_details.product_id AND ?:product_descriptions.lang_code = ?s" . " LEFT JOIN ?:product_file_folders ON ?:product_file_folders.product_id = ?:order_details.product_id" . " WHERE ?:orders.user_id = ?i AND ?:orders.is_parent_order != 'Y' AND ?:product_files.status = 'A' AND (?:product_file_folders.status = 'A' OR ?:product_files.folder_id IS NULL)" . $where . " GROUP BY ?:order_details.order_id, ?:order_details.product_id" . " ORDER BY ?:orders.order_id DESC {$limit}", CART_LANGUAGE, $params['user_id']);
    if (!empty($products)) {
        foreach ($products as $k => $v) {
            $_params = array('product_id' => $v['product_id'], 'order_id' => $v['order_id']);
            list($product_file_folders) = fn_get_product_file_folders($_params);
            list($product_files) = fn_get_product_files($_params);
            $products[$k]['files_tree'] = fn_build_files_tree($product_file_folders, $product_files);
        }
    }
    return array($products, $params);
}