Exemplo n.º 1
0
 function __construct()
 {
     global $osC_Language, $osC_MessageStack, $osC_Currencies, $osC_Tax, $osC_CategoryTree, $osC_Image, $current_category_id;
     $this->_page_title = $osC_Language->get('heading_title');
     $current_category_id = 0;
     if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
         $current_category_id = $_GET['cID'];
     } else {
         $_GET['cID'] = $current_category_id;
     }
     require '../includes/classes/currencies.php';
     $osC_Currencies = new osC_Currencies();
     require 'includes/classes/tax.php';
     $osC_Tax = new osC_Tax_Admin();
     require 'includes/classes/category_tree.php';
     $osC_CategoryTree = new osC_CategoryTree_Admin();
     $osC_CategoryTree->setSpacerString(' ', 2);
     require 'includes/classes/image.php';
     $osC_Image = new osC_Image_Admin();
     // check if the catalog image directory exists
     if (is_dir(realpath('../images/products'))) {
         if (!is_writeable(realpath('../images/products'))) {
             $osC_MessageStack->add('header', sprintf($osC_Language->get('ms_error_image_directory_not_writable'), realpath('../images/products')), 'error');
         }
     } else {
         $osC_MessageStack->add('header', sprintf($osC_Language->get('ms_error_image_directory_non_existant'), realpath('../images/products')), 'error');
     }
 }
Exemplo n.º 2
0
 public static function find($search, $id = null)
 {
     global $osC_Database, $osC_Language, $current_category_id;
     if (!is_numeric($id)) {
         if (isset($current_category_id) && is_numeric($current_category_id)) {
             $id = $current_category_id;
         } else {
             $id = 0;
         }
     }
     $osC_CategoryTree = new osC_CategoryTree_Admin();
     $osC_CategoryTree->setRootCategoryID($id);
     $categories = array();
     $Qcategories = $osC_Database->query('select c.categories_id from :table_categories c, :table_categories_description cd where c.categories_id = cd.categories_id and cd.language_id = :language_id and (cd.categories_name like :categories_name)');
     $Qcategories->bindTable(':table_categories', TABLE_CATEGORIES);
     $Qcategories->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
     $Qcategories->bindInt(':language_id', $osC_Language->getID());
     $Qcategories->bindValue(':categories_name', '%' . $search . '%');
     $Qcategories->execute();
     while ($Qcategories->next()) {
         if ($Qcategories->valueInt('categories_id') != $id) {
             $category_path = $osC_CategoryTree->getPathArray($Qcategories->valueInt('categories_id'));
             $top_category_id = $category_path[0]['id'];
             if (!in_array($top_category_id, $categories)) {
                 $categories[] = $top_category_id;
             }
         }
     }
     $result = array('entries' => array());
     $Qcategories = $osC_Database->query('select c.*, cd.categories_name from :table_categories c, :table_categories_description cd where c.categories_id = cd.categories_id and cd.language_id = :language_id and c.categories_id in :categories_id order by c.sort_order, cd.categories_name');
     $Qcategories->bindTable(':table_categories', TABLE_CATEGORIES);
     $Qcategories->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
     $Qcategories->bindInt(':language_id', $osC_Language->getID());
     $Qcategories->bindRaw(':categories_id', '("' . implode('", "', $categories) . '")');
     $Qcategories->execute();
     while ($Qcategories->next()) {
         $result['entries'][] = $Qcategories->toArray();
     }
     $result['total'] = $Qcategories->numberOfRows();
     $Qcategories->freeResult();
     return $result;
 }
Exemplo n.º 3
0
 function listParentCategory()
 {
     global $toC_Json, $osC_Language;
     $osC_CategoryTree = new osC_CategoryTree_Admin();
     $records = array(array('id' => '0', 'text' => $osC_Language->get('top_category')));
     foreach ($osC_CategoryTree->getTree() as $value) {
         $records[] = array('id' => $value['id'], 'text' => $value['title']);
     }
     $response = array(EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 4
0
 public static function find($search, $category_id = null, $pageset = 1)
 {
     global $osC_Database, $osC_Language, $osC_Currencies;
     if (!is_numeric($category_id)) {
         $category_id = 0;
     }
     if (!is_numeric($pageset) || floor($pageset) != $pageset) {
         $pageset = 1;
     }
     $result = array('entries' => array());
     if ($category_id > 0) {
         $osC_CategoryTree = new osC_CategoryTree_Admin();
         $osC_CategoryTree->setBreadcrumbUsage(false);
         $in_categories = array($category_id);
         foreach ($osC_CategoryTree->getArray($category_id) as $category) {
             $in_categories[] = $category['id'];
         }
         $Qproducts = $osC_Database->query('select SQL_CALC_FOUND_ROWS distinct p.*, pd.products_name from :table_products p, :table_products_description pd, :table_products_to_categories p2c where p.parent_id = 0 and p.products_id = pd.products_id and pd.language_id = :language_id and p.products_id = p2c.products_id and p2c.categories_id in (:categories_id)');
         $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
         $Qproducts->bindRaw(':categories_id', implode(',', $in_categories));
     } else {
         $Qproducts = $osC_Database->query('select SQL_CALC_FOUND_ROWS p.*, pd.products_name from :table_products p, :table_products_description pd where p.parent_id = 0 and p.products_id = pd.products_id and pd.language_id = :language_id');
     }
     $Qproducts->appendQuery('and (pd.products_name like :products_name or pd.products_keyword like :products_keyword) order by pd.products_name');
     $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qproducts->bindInt(':language_id', $osC_Language->getID());
     $Qproducts->bindValue(':products_name', '%' . $search . '%');
     $Qproducts->bindValue(':products_keyword', '%' . $search . '%');
     if ($pageset !== -1) {
         $Qproducts->setBatchLimit($pageset, MAX_DISPLAY_SEARCH_RESULTS);
     }
     $Qproducts->execute();
     while ($Qproducts->next()) {
         $price = $osC_Currencies->format($Qproducts->value('products_price'));
         $products_status = $Qproducts->valueInt('products_status') === 1;
         $products_quantity = $Qproducts->valueInt('products_quantity');
         if ($Qproducts->valueInt('has_children') === 1) {
             $Qvariants = $osC_Database->query('select min(products_price) as min_price, max(products_price) as max_price, sum(products_quantity) as total_quantity, min(products_status) as products_status from :table_products where parent_id = :parent_id');
             $Qvariants->bindTable(':table_products', TABLE_PRODUCTS);
             $Qvariants->bindInt(':parent_id', $Qproducts->valueInt('products_id'));
             $Qvariants->execute();
             $products_status = $Qvariants->valueInt('products_status') === 1;
             $products_quantity = '(' . $Qvariants->valueInt('total_quantity') . ')';
             $price = $osC_Currencies->format($Qvariants->value('min_price'));
             if ($Qvariants->value('min_price') != $Qvariants->value('max_price')) {
                 $price .= ' - ' . $osC_Currencies->format($Qvariants->value('max_price'));
             }
         }
         $extra_data = array('products_price_formatted' => $price, 'products_status' => $products_status, 'products_quantity' => $products_quantity);
         $result['entries'][] = array_merge($Qproducts->toArray(), $extra_data);
     }
     $result['total'] = $Qproducts->getBatchSize();
     $Qproducts->freeResult();
     return $result;
 }
Exemplo n.º 5
0
 function getCategories()
 {
     global $toC_Json, $osC_Language;
     $osC_CategoryTree = new osC_CategoryTree_Admin();
     $categories_array = array();
     if (isset($_REQUEST['top']) && $_REQUEST['top'] == '1') {
         $categories_array = array(array('id' => '', 'text' => $osC_Language->get('top_category')));
     }
     foreach ($osC_CategoryTree->getTree() as $value) {
         $categories_array[] = array('id' => $value['id'], 'text' => $value['title']);
     }
     $response = array(EXT_JSON_READER_ROOT => $categories_array);
     echo $toC_Json->encode($response);
 }
 function loadProducts()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $osC_CategoryTree = new osC_CategoryTree_Admin();
     //Get the current category - Fix the bug#78
     $cPath = isset($_POST['categories_id']) && !empty($_POST['categories_id']) ? $_POST['categories_id'] : 0;
     $cPath_array = array_unique(array_filter(explode('_', $cPath), 'is_numeric'));
     $current_category_id = end($cPath_array);
     if ($current_category_id > 0) {
         $osC_CategoryTree->setBreadcrumbUsage(false);
         $in_categories = array($current_category_id);
         foreach ($osC_CategoryTree->getTree($current_category_id) as $category) {
             $in_categories[] = $category['id'];
         }
         $Qproducts = $osC_Database->query('select p.products_id, pd.products_name, p.products_price from :table_products p, :table_products_description pd, :table_products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = :language_id and p.products_id = p2c.products_id and p2c.categories_id in (:categories_id)');
         $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
         $Qproducts->bindRaw(':categories_id', implode(',', $in_categories));
     } else {
         $Qproducts = $osC_Database->query('select p.products_id, pd.products_name, p.products_price from :table_products p, :table_products_description pd where p.products_id = pd.products_id and pd.language_id = :language_id');
     }
     if (!empty($_REQUEST['cManufacturer'])) {
         $Qproducts->appendQuery('and p.manufacturers_id = :manufacturers_id');
         $Qproducts->bindValue(':manufacturers_id', $_REQUEST['cManufacturer']);
     }
     if (!empty($_REQUEST['products_sku'])) {
         $Qproducts->appendQuery('and p.products_sku like :products_sku');
         $Qproducts->bindValue(':products_sku', '%' . $_REQUEST['products_sku'] . '%');
     }
     if (!empty($_REQUEST['products_name'])) {
         $Qproducts->appendQuery('and pd.products_name like :products_name');
         $Qproducts->bindValue(':products_name', '%' . $_REQUEST['products_name'] . '%');
     }
     $Qproducts->appendQuery(' and p.products_type <> :products_type');
     $Qproducts->appendQuery('order by pd.products_name');
     $Qproducts->bindTable(':table_specials', TABLE_SPECIALS);
     $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qproducts->bindInt(':language_id', $osC_Language->getID());
     $Qproducts->bindInt(':products_type', PRODUCT_TYPE_GIFT_CERTIFICATE);
     $Qproducts->execute();
     $products = array();
     while ($Qproducts->next()) {
         $products[] = array('products_id' => $Qproducts->value('products_id'), 'products_name' => $Qproducts->value('products_name'), 'products_price' => $Qproducts->value('products_price'), 'special_price' => 0);
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qproducts->getBatchSize(), EXT_JSON_READER_ROOT => $products);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 7
0
 function loadVariantsProducts()
 {
     global $toC_Json;
     //get the filters
     $manufacturer = !empty($_POST['cManufacturer']) ? $_POST['cManufacturer'] : null;
     $products_sku = !empty($_POST['products_sku']) ? $_POST['products_sku'] : null;
     $products_name = !empty($_POST['products_name']) ? $_POST['products_name'] : null;
     //Get the current category - Fix the bug#78
     $osC_CategoryTree = new osC_CategoryTree_Admin();
     $cPath = isset($_POST['categories_id']) && !empty($_POST['categories_id']) ? $_POST['categories_id'] : 0;
     $cPath_array = array_unique(array_filter(explode('_', $cPath), 'is_numeric'));
     $current_category_id = end($cPath_array);
     //get the categories
     $in_categories = array();
     if ($current_category_id > 0) {
         $osC_CategoryTree->setBreadcrumbUsage(false);
         $in_categories = array($current_category_id);
         foreach ($osC_CategoryTree->getTree($current_category_id) as $category) {
             $in_categories[] = $category['id'];
         }
     }
     //load the variants products
     $result = osC_Specials_Admin::loadVariantsProducts($in_categories, $manufacturer, $products_sku, $products_name);
     $response = array(EXT_JSON_READER_TOTAL => count($result), EXT_JSON_READER_ROOT => $result);
     echo $toC_Json->encode($response);
 }
 function listProducts()
 {
     global $toC_Json, $osC_Database, $osC_Language, $osC_Currencies;
     require_once '../includes/classes/currencies.php';
     $osC_Currencies = new osC_Currencies();
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $current_category_id = empty($_REQUEST['categories_id']) ? 0 : $_REQUEST['categories_id'];
     if ($current_category_id > 0) {
         $osC_CategoryTree = new osC_CategoryTree_Admin();
         $osC_CategoryTree->setBreadcrumbUsage(false);
         $in_categories = array($current_category_id);
         foreach ($osC_CategoryTree->getTree($current_category_id) as $category) {
             $in_categories[] = $category['id'];
         }
         $Qproducts = $osC_Database->query('select distinct p.products_id, p.products_type, pd.products_name, p.products_quantity, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from :table_products p, :table_products_description pd, :table_products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = :language_id and p.products_id = p2c.products_id and p2c.categories_id in (:categories_id)');
         $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
         $Qproducts->bindRaw(':categories_id', implode(',', $in_categories));
     } else {
         $Qproducts = $osC_Database->query('select p.products_id, p.products_type, pd.products_name, p.products_quantity, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from :table_products p, :table_products_description pd where p.products_id = pd.products_id and pd.language_id = :language_id');
     }
     if (!empty($_REQUEST['search'])) {
         $Qproducts->appendQuery('and pd.products_name like :products_name');
         $Qproducts->bindValue(':products_name', '%' . $_REQUEST['search'] . '%');
     }
     $Qproducts->appendQuery(' order by pd.products_name');
     $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qproducts->bindInt(':language_id', $osC_Language->getID());
     $Qproducts->setExtBatchLimit($start, $limit);
     $Qproducts->execute();
     $records = array();
     while ($Qproducts->next()) {
         $products_price = $osC_Currencies->format($Qproducts->value('products_price'));
         if ($Qproducts->valueInt('products_type') == PRODUCT_TYPE_GIFT_CERTIFICATE) {
             $Qcertificate = $osC_Database->query('select open_amount_min_value, open_amount_max_value from :table_products_gift_certificates where gift_certificates_amount_type = :gift_certificates_amount_type and products_id = :products_id');
             $Qcertificate->bindTable(':table_products_gift_certificates', TABLE_PRODUCTS_GIFT_CERTIFICATES);
             $Qcertificate->bindInt(':gift_certificates_amount_type', GIFT_CERTIFICATE_TYPE_OPEN_AMOUNT);
             $Qcertificate->bindInt(':products_id', $Qproducts->value('products_id'));
             $Qcertificate->execute();
             if ($Qcertificate->numberOfRows() > 0) {
                 $products_price = $osC_Currencies->format($Qcertificate->value('open_amount_min_value')) . ' ~ ' . $osC_Currencies->format($Qcertificate->value('open_amount_max_value'));
             }
         }
         $records[] = array('products_id' => $Qproducts->value('products_id'), 'products_name' => $Qproducts->value('products_name'), 'products_price' => $products_price, 'products_quantity' => $Qproducts->value('products_quantity'));
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qproducts->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }