break; } } } // Registry::get('view')->assign('ls_shipping_estimation_date', date('d m Y',$ls_individual_estimation)); // echo "shipping estimation for the products is ".date('Y m d',$ls_individual_estimation); Registry::get('view')->assign('ls_shipping_estimation_date', $ls_individual_estimation); Registry::get('view')->assign('ls_inventory_amount', $product['inventory_amount']); Registry::get('view')->assign('ls_amount', $product['amount']); Registry::get('view')->assign('product', $product); // If page title for this product is exist than assign it to template if (!empty($product['page_title'])) { Registry::get('view')->assign('page_title', $product['page_title']); } $params = array('product_id' => $_REQUEST['product_id'], 'preview_check' => true); list($files) = fn_get_product_files($params); if (!empty($files)) { Registry::get('view')->assign('files', $files); } /* [Product tabs] */ $tabs = ProductTabs::instance()->getList('', $product['product_id'], DESCR_SL); foreach ($tabs as $tab_id => $tab) { if ($tab['status'] == 'D') { continue; } if (!empty($tab['template'])) { $tabs[$tab_id]['html_id'] = fn_basename($tab['template'], ".tpl"); } else { $tabs[$tab_id]['html_id'] = 'product_tab_' . $tab_id; } if ($tab['show_in_popup'] != "Y") {
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); }
} exit; // // Display list of files for downloadable product // } elseif ($mode == 'download') { if (!empty($_REQUEST['ekey'])) { $ekey_info = fn_get_product_edp_info($_REQUEST['product_id'], $_REQUEST['ekey']); if (empty($ekey_info)) { return array(CONTROLLER_STATUS_DENIED); } $product = array('ekey' => $_REQUEST['ekey'], 'product_id' => $ekey_info['product_id']); if (!empty($product['product_id'])) { $product['product'] = db_get_field("SELECT product FROM ?:product_descriptions WHERE product_id = ?i AND lang_code = ?s", $product['product_id'], CART_LANGUAGE); $params = array('product_id' => $product['product_id'], 'order_id' => $ekey_info['order_id']); $product['files'] = fn_get_product_files($params); } } if (!empty($auth['user_id'])) { fn_add_breadcrumb(__('downloads'), "profiles.downloads"); } fn_add_breadcrumb($product['product'], "products.view?product_id={$product['product_id']}"); fn_add_breadcrumb(__('download')); if (!empty($product['files'])) { Registry::get('view')->assign('product', $product); } else { return array(CONTROLLER_STATUS_DENIED); } } elseif ($mode == 'get_custom_file') { $filename = !empty($_REQUEST['filename']) ? $_REQUEST['filename'] : ''; if (!empty($_REQUEST['file'])) {
fn_set_notification('N', fn_get_lang_var('notice'), $msg); } return array(CONTROLLER_STATUS_REDIRECT, "products.update?product_id={$pid}"); } } elseif ($mode == 'delete_file') { if (!empty($_REQUEST['file_id'])) { $files_path = db_get_row("SELECT file_path, preview_path, product_id FROM ?:product_files WHERE file_id = ?i", $_REQUEST['file_id']); if (!empty($files_path['file_path'])) { unlink(DIR_DOWNLOADS . $files_path['product_id'] . '/' . $files_path['file_path']); } if (!empty($files_path['preview_path'])) { unlink(DIR_DOWNLOADS . $files_path['product_id'] . '/' . $files_path['preview_path']); } db_query("DELETE FROM ?:product_files WHERE file_id = ?i", $_REQUEST['file_id']); db_query("DELETE FROM ?:product_file_descriptions WHERE file_id = ?i", $_REQUEST['file_id']); $_files = fn_get_product_files($files_path['product_id']); if (empty($_files)) { $view->display('views/products/components/products_update_files.tpl'); } } exit; } elseif ($mode == 'dev_mode') { die('ada'); } function fn_add_to_new_items_block($itemId) { include_once DIR_ROOT . "/controllers/admin/block_manager.php"; $data = fn_get_block_data(49); if ($data['properties']['auto_add'] == 'Y') { $block_items = db_get_field("SELECT item_ids FROM cscart_block_links WHERE block_id = 49"); $items = explode(",", $block_items);
fn_add_breadcrumb($product['product']); if (!empty($_REQUEST['combination'])) { $product['combination'] = $_REQUEST['combination']; } fn_gather_additional_product_data($product, true, true); //var_dump($product); //die(); $view->assign('product', $product); $amount = db_get_field("SELECT count(*) FROM `cscart_discussion_messages` cm LEFT OUTER JOIN `cscart_discussion` cd ON cm.thread_id = cd.thread_id \n\t\t\t\t\t\t\tWHERE cd.object_id = '" . $product['product_id'] . "' AND cd.object_type = 'P'"); $view->assign('postCount', $amount); // If page title for this product is exist than assign it to template if (!empty($product['page_title'])) { $view->assign('page_title', $product['page_title'] . ' - ' . $product['price'] . ' руб.'); //var_dump($product); } $files = fn_get_product_files($_REQUEST['product_id'], true); if (!empty($files)) { $view->assign('files', $files); } /* [Block manager tabs] */ $_blocks = $view->get_var('blocks'); foreach ($_blocks as $block) { if (!empty($block['text_id']) && $block['text_id'] == 'product_details') { $tabs_group_id = $block['block_id']; break; } } if (!empty($tabs_group_id)) { $view->assign('tabs_block_id', $tabs_group_id); foreach ($_blocks as $block) { if (!empty($block['group_id']) && $block['group_id'] == $tabs_group_id) {
if (fn_delete_product_files($_REQUEST['file_id']) == false) { return array(CONTROLLER_STATUS_DENIED); } list($_files) = fn_get_product_files(array('product_id' => $_REQUEST['product_id'])); list($_folder) = fn_get_product_file_folders(array('product_id' => $_REQUEST['product_id'])); if (empty($_files) && empty($_folder)) { Registry::get('view')->assign('product_id', $_REQUEST['product_id']); } } return array(CONTROLLER_STATUS_OK, fn_url('products.update?product_id=' . $_REQUEST['product_id'] . '&selected_section=files')); } elseif ($mode == 'delete_folder') { if (!empty($_REQUEST['folder_id']) && !empty($_REQUEST['product_id'])) { if (fn_delete_product_file_folders($_REQUEST['folder_id'], $_REQUEST['product_id']) == false) { return array(CONTROLLER_STATUS_DENIED); } 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); Registry::get('view')->assign('product_file_folders', $product_file_folders); Registry::get('view')->assign('product_files', $product_files); Registry::get('view')->assign('files_tree', $files_tree); Registry::get('view')->assign('product_id', $_REQUEST['product_id']); } return array(CONTROLLER_STATUS_OK, fn_url('products.update?product_id=' . $_REQUEST['product_id'] . '&selected_section=files')); } //get category for required products list Registry::get('view')->assign('category_name', $category_name); function getProductName($product_id) { //$products_id=Registry::get('view')->getTemplateVars(); $product_name = db_get_field("SELECT product FROM ?:product_descriptions WHERE product_id='{$product_id}' AND lang_code=?s", DESCR_SL);
} } return array(CONTROLLER_STATUS_DENIED); // // Display list of files for downloadable product // } elseif ($mode == 'download') { if (!empty($_REQUEST['ekey'])) { $ekey_info = fn_get_product_edp_info($_REQUEST['product_id'], $_REQUEST['ekey']); if (empty($ekey_info)) { return array(CONTROLLER_STATUS_DENIED); } $product = array('ekey' => $_REQUEST['ekey'], 'product_id' => $ekey_info['product_id']); if (!empty($product['product_id'])) { $product['product'] = db_get_field("SELECT product FROM ?:product_descriptions WHERE product_id = ?i AND lang_code = ?s", $product['product_id'], CART_LANGUAGE); $product['files'] = fn_get_product_files($product['product_id'], false, $ekey_info['order_id']); } } if (!empty($auth['user_id'])) { fn_add_breadcrumb(fn_get_lang_var('downloads'), "profiles.downloads"); } fn_add_breadcrumb($product['product'], "products.view?product_id={$product['product_id']}"); fn_add_breadcrumb(fn_get_lang_var('download')); if (!empty($product['files'])) { $view->assign('product', $product); } else { return array(CONTROLLER_STATUS_DENIED); } } elseif ($mode == 'get_custom_file') { $filename = !empty($_REQUEST['filename']) ? $_REQUEST['filename'] : ''; if (!empty($_REQUEST['file']) && !empty($_REQUEST['order_id'])) {
function fn_get_user_edp($user_id, $order_id = 0, $page = 1) { $fields = array('?:order_details.product_id', '?:order_details.order_id', '?:order_details.extra', '?:orders.status', '?:products.unlimited_download', '?:product_descriptions.product'); $where = $limit = ''; if (!empty($order_id)) { if (is_array($order_id)) { $where = db_quote("AND ?:orders.order_id IN (?n)", $order_id); } else { $where = db_quote("AND ?:orders.order_id = ?i", $order_id); } } else { $_total = db_get_fields("SELECT COUNT(*) FROM ?:order_details INNER JOIN ?:orders ON ?:orders.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' GROUP BY ?:order_details.product_id, ?:order_details.order_id", $user_id); $total = count($_total); $limit = fn_paginate($page, $total, Registry::get('settings.Appearance.elements_per_page')); } $products = db_get_array("SELECT " . implode(', ', $fields) . "\tFROM ?: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 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 WHERE ?:orders.user_id = ?i AND ?:orders.is_parent_order != 'Y' AND ?:product_files.status = 'A' {$where} GROUP BY ?:order_details.order_id, ?:order_details.product_id ORDER BY ?:orders.order_id DESC {$limit}", CART_LANGUAGE, $user_id); if (!empty($products)) { foreach ($products as $k => $v) { $products[$k]['files'] = fn_get_product_files($v['product_id'], false, $v['order_id']); } } return $products; }