assign('aaacategory_name_lang', $aaacategory_name_lang); /////////////////////////////// display subcategories ///////////////////////////* $query = "SELECT category_id, picture, category_name_lang1, category_name_lang2, category_name_lang3, category_name_lang4, category_name_lang5, category_name_lang6 FROM diffshop_categories WHERE parent_id='$cat' AND membership <= '$user_membership' AND available='1' ORDER BY position ASC"; $result = mysql_query($query) or die("error in query - $query - ".mysql_error()); $results = mysql_num_rows($result); if ($results) { while($row = mysql_fetch_array($result)){ $subcategory_rows[] = $row; } $i = 0; foreach($subcategory_rows as $subcategory_row) { $subcat_ids[] = $i++; $subcategory_id[] = $subcategory_row[0]; $subpicture[] = $subcategory_row[1]; $subcategory_name_lang1 = $subcategory_row[2]; $subcategory_name_lang2 = $subcategory_row[3]; $subcategory_name_lang3 = $subcategory_row[4]; $subcategory_name_lang4 = $subcategory_row[5]; $subcategory_name_lang5 = $subcategory_row[6]; $subcategory_name_lang6 = $subcategory_row[7]; $subcategory_name_lang = select_language($subcategory_name_lang1, $subcategory_name_lang2, $subcategory_name_lang3, $subcategory_name_lang4, $subcategory_name_lang5, $subcategory_name_lang6); $subcategory_name[] = select_language($subcategory_name_lang1, $subcategory_name_lang2, $subcategory_name_lang3, $subcategory_name_lang4, $subcategory_name_lang5, $subcategory_name_lang6); $subcategory_name_rewrite[] = strtolower(str_replace(" ", "-", $subcategory_name_lang)); } $smarty->assign('cols', 2); $smarty->assign('subcat_ids', $subcat_ids); $smarty->assign('results', $results); $smarty->assign('subcategory_id', $subcategory_id); $smarty->assign('subcategory_name', $subcategory_name); $smarty->assign('subcategory_name_rewrite', $subcategory_name_rewrite); $smarty->assign('subpicture', $subpicture); $smarty->assign('category_dir', $category_dir); $smarty->assign('category_picture_weight', $category_picture_weight); $smarty->assign('category_picture_height', $category_picture_height); } /////////////////////////////////////////////////////////////////////////////////*\ /////////////////////////////// define path ///////////////////////////* $query1 = "SELECT lft, rgt FROM diffshop_categories WHERE category_id ='$cat'"; $result1 = mysql_query($query1) or die("error in query - $query1 - ".mysql_error()); list($lft, $rgt) = mysql_fetch_row($result1); $query12 = "SELECT category_id, category_name_lang1, category_name_lang2, category_name_lang3, category_name_lang4, category_name_lang5, category_name_lang6 FROM diffshop_categories WHERE lft <= '$lft' AND rgt >= '$rgt' ORDER BY lft ASC"; $result12 = mysql_query($query12) or die("error in query - $query12 - ".mysql_error()); $results_path = mysql_num_rows($result12); if ($results_path) { while($row = mysql_fetch_array($result12)) { $path_rows[] = $row; } $i = 0; foreach($path_rows as $path_row) { $path_ids[] = $i++; $path_id[] = $path_row[0]; $path_name_lang1 = $path_row[1]; $path_name_lang2 = $path_row[2]; $path_name_lang3 = $path_row[3]; $path_name_lang4 = $path_row[4]; $path_name_lang5 = $path_row[5]; $path_name_lang6 = $path_row[6]; $path_name_lang = select_language($path_name_lang1, $path_name_lang2, $path_name_lang3, $path_name_lang4, $path_name_lang5, $path_name_lang6); $path_name[] = select_language($path_name_lang1, $path_name_lang2, $path_name_lang3, $path_name_lang4, $path_name_lang5, $path_name_lang6); $path_name_rewrite[] = strtolower(str_replace(" ", "-", $path_name_lang)); } $smarty->assign('path_ids', $path_ids); $smarty->assign('path_id', $path_id); $smarty->assign('path_name', $path_name); $smarty->assign('path_name_rewrite', $path_name_rewrite); } ///////////////////////////////////////////////////////////////////////*\ /////////////////////////////// display featured products for category ///////////////////////////* $query = "SELECT product_id FROM diffshop_categories_featured_products WHERE category_id='$cat' ORDER BY position ASC"; $result = mysql_query($query) or die("error in query - $query - ".mysql_error()); $results_feat_cat_products = mysql_num_rows($result); if ($results_feat_cat_products) { while($row = mysql_fetch_array($result)) { $product_id = $row["product_id"]; $query12 = "SELECT product_id, name_lang1, name_lang2, name_lang3, name_lang4, name_lang5, name_lang6, small_description_lang1, small_description_lang2, small_description_lang3, small_description_lang4, small_description_lang5, small_description_lang6, small_picture, your_price, avail_in_stock, avail_day, avail_month, avail_year, inventory_number FROM diffshop_products WHERE product_id='$product_id' AND available='1'"; $result12 = mysql_query($query12) or die("error in query - $query12 - ".mysql_error()); $results_feat_cat_products1 = mysql_num_rows($result12); if ($results_feat_cat_products1) { while($row_prod = mysql_fetch_array($result12)) { $feat_cat_rows[] = $row_prod; } } } $i = 0; if (count($feat_cat_rows) > 0) { foreach($feat_cat_rows as $feat_cat_row) { $feat_cat_ids[] = $i++; $feat_product_id[] = $feat_cat_row[0]; $feat_name_lang1 = $feat_cat_row[1]; $feat_name_lang2 = $feat_cat_row[2]; $feat_name_lang3 = $feat_cat_row[3]; $feat_name_lang4 = $feat_cat_row[4]; $feat_name_lang5 = $feat_cat_row[5]; $feat_name_lang6 = $feat_cat_row[6]; $feat_small_description_lang1 = $feat_cat_row[7]; $feat_small_description_lang2 = $feat_cat_row[8]; $feat_small_description_lang3 = $feat_cat_row[9]; $feat_small_description_lang4 = $feat_cat_row[10]; $feat_small_description_lang5 = $feat_cat_row[11]; $feat_small_description_lang6 = $feat_cat_row[12]; $feat_small_picture[] = $feat_cat_row[13]; $feat_your_price[] = $feat_cat_row[14]; $feat_avail_in_stock[] = $feat_cat_row[15]; $feat_avail_day[] = $feat_cat_row[16]; $feat_avail_month[] = $feat_cat_row[17]; $feat_avail_year[] = $feat_cat_row[18]; $feat_inventory_number[] = $feat_cat_row[19]; $feat_product_name_lang = select_language($feat_name_lang1, $feat_name_lang2, $feat_name_lang3, $feat_name_lang4, $feat_name_lang5, $feat_name_lang6); $feat_product_name[] = select_language($feat_name_lang1, $feat_name_lang2, $feat_name_lang3, $feat_name_lang4, $feat_name_lang5, $feat_name_lang6); $feat_small_description[] = select_language($feat_small_description_lang1, $feat_small_description_lang2, $feat_small_description_lang3, $feat_small_description_lang4, $feat_small_description_lang5, $feat_small_description_lang6); $feat_product_name_rewrite[] = strtolower(str_replace(" ", "-", $feat_product_name_lang)); } $stock_strings = array(); foreach($feat_avail_in_stock as $stock) { $stock_strings[] = stock_to_string($stock, $lang['2'], $lang['3'], $lang['4'], $lang['5'], $lang['6']); } $month_strings = array(); foreach($feat_avail_month as $month) { $month_strings[] = month_to_string($month, $lang['7'], $lang['8'], $lang['9'], $lang['10'], $lang['11'], $lang['12'], $lang['13'], $lang['14'], $lang['15'], $lang['16'], $lang['17'], $lang['18']); } ///////////////////////////// currency 1 /////////// if (isset($_SESSION['default_rate'])) { $with_vat_prices = array(); foreach($feat_your_price as $price) { $with_vat_prices[] = number_format(($price*$default_rate), 2, '.', ','); } $feat_your_prices = array(); foreach($feat_your_price as $price) { $feat_your_prices[] = number_format(($price * $default_rate), 2, '.', ','); } } else { $with_vat_prices = array(); foreach($feat_your_price as $price) { $with_vat_prices[] = number_format($price, 2, '.', ','); } $feat_your_prices = array(); foreach($feat_your_price as $price) { $feat_your_prices[] = number_format($price, 2, '.', ','); } } } //////////////////////////////////////////////////// $smarty->assign('results_feat_cat_products', $results_feat_cat_products); $smarty->assign('results_feat_cat_products1', $results_feat_cat_products1); $smarty->assign('default_currency', $default_currency); $smarty->assign('products_dir', $products_dir); $smarty->assign('product_small_picture_weight', $product_small_picture_weight); $smarty->assign('product_small_picture_height', $product_small_picture_height); $smarty->assign('feat_cat_ids', $feat_cat_ids); $smarty->assign('feat_product_id', $feat_product_id); $smarty->assign('feat_product_name', $feat_product_name); $smarty->assign('feat_product_name_rewrite', $feat_product_name_rewrite); $smarty->assign('feat_small_description', $feat_small_description); $smarty->assign('feat_small_picture', $feat_small_picture); $smarty->assign('feat_your_price', $feat_your_prices); $smarty->assign('with_vat_prices', $with_vat_prices); $smarty->assign('stock_strings', $stock_strings); $smarty->assign('feat_avail_day', $feat_avail_day); $smarty->assign('month_strings', $month_strings); $smarty->assign('feat_avail_year', $feat_avail_year); $smarty->assign('feat_inventory_number', $feat_inventory_number); } //////////////////////////////////////////////////////////////////////////////////////////////////*\ ///////////////////////////////// display products for category //////////////////////////////////* $rows_per_page = 20; $scroll = 5; $query = "SELECT product_id FROM diffshop_products_aditional_categories WHERE category_id='$cat' ORDER BY product_id ASC"; $result_adit = mysql_query($query) or die("error in query - $query - ".mysql_error()); $aditional_cat_rows = mysql_num_rows($result_adit); while($row_aditional = mysql_fetch_array($result_adit)) { $aditional_prod_id[] = $row_aditional["product_id"]; } $query = "SELECT product_id, name_lang1, name_lang2, name_lang3, name_lang4, name_lang5, name_lang6, small_description_lang1, small_description_lang2, small_description_lang3, small_description_lang4, small_description_lang5, small_description_lang6, small_picture, your_price, avail_in_stock, avail_day, avail_month, avail_year, inventory_number FROM diffshop_products WHERE (category_id='$cat'"; if ($aditional_cat_rows > 0) { $query .= " OR product_id IN (". implode( ', ', $aditional_prod_id)." )"; } $query .= ") AND available='1' ORDER BY position ASC"; $result = mysql_query($query) or die("error in query - $query - ".mysql_error()); $total_records = mysql_num_rows($result); $pages = ceil($total_records / $rows_per_page); mysql_free_result($result); $k = $pages; $l = $rows_per_page; if (!isset($page)) $page = 1; if ($page) { $r = ($page - 1); } $j = ($r * $rows_per_page) +1 ; $j_start = $r * $rows_per_page; $j_end = $j_start + $rows_per_page; if ($j_end <= $total_records) { $j_sub = $j_end; } else { $j_sub = ($total_records - (($page - 1) * $rows_per_page)) + ($j - 1); } $start = (($page * $rows_per_page) - $rows_per_page); $query = "SELECT product_id, name_lang1, name_lang2, name_lang3, name_lang4, name_lang5, name_lang6, small_description_lang1, small_description_lang2, small_description_lang3, small_description_lang4, small_description_lang5, small_description_lang6, small_picture, your_price, avail_in_stock, avail_day, avail_month, avail_year, inventory_number FROM diffshop_products WHERE (category_id='$cat'"; if ($aditional_cat_rows > 0) { $query .= " OR product_id IN (". implode( ', ', $aditional_prod_id)." )"; } $query .= ") AND available='1' ORDER BY position ASC LIMIT $start, $rows_per_page"; $result = mysql_query($query) or die("error in query - $query - ".mysql_error()); $rows2 = mysql_num_rows($result); if ($total_records > 0) { while($row_products = mysql_fetch_array($result)) { $prod_rows[] = $row_products; } $i = 0; foreach($prod_rows as $prod_row) { $prod_ids[] = $i++; $categ_product_id[] = $prod_row[0]; $name_lang1 = $prod_row[1]; $name_lang2 = $prod_row[2]; $name_lang3 = $prod_row[3]; $name_lang4 = $prod_row[4]; $name_lang5 = $prod_row[5]; $name_lang6 = $prod_row[6]; $small_description_lang1 = $prod_row[7]; $small_description_lang2 = $prod_row[8]; $small_description_lang3 = $prod_row[9]; $small_description_lang4 = $prod_row[10]; $small_description_lang5 = $prod_row[11]; $small_description_lang6 = $prod_row[12]; $small_picture[] = $prod_row[13]; $your_price[] = $prod_row[14]; $avail_in_stock[] = $prod_row[15]; $avail_day[] = $prod_row[16]; $avail_month[] = $prod_row[17]; $avail_year[] = $prod_row[18]; $inventory_number[] = $prod_row[19]; $product_name_lang = select_language($name_lang1, $name_lang2, $name_lang3, $name_lang4, $name_lang5, $name_lang6); $product_name[] = select_language($name_lang1, $name_lang2, $name_lang3, $name_lang4, $name_lang5, $name_lang6); $small_description[] = select_language($small_description_lang1, $small_description_lang2, $small_description_lang3, $small_description_lang4, $small_description_lang5, $small_description_lang6); $product_name_rewrite[] = strtolower(str_replace(" ", "-", $product_name_lang)); } ///////////////////////////// currency 1 /////////// if (isset($_SESSION['default_rate'])) { $with_vat_price = array(); foreach($your_price as $price) { $with_vat_price[] = number_format(($price*$default_rate), 2, '.', ','); } $your_prices = array(); foreach($your_price as $price) { $your_prices[] = number_format(($price*$default_rate), 2, '.', ','); } } else { $with_vat_price = array(); foreach($your_price as $price) { $with_vat_price[] = number_format($price, 2, '.', ','); } $your_prices = array(); foreach($your_price as $price) { $your_prices[] = number_format($price, 2, '.', ','); } } //////////////////////////////////////////////////// $prod_stock_strings = array(); foreach($avail_in_stock as $stock) { $prod_stock_strings[] = stock_to_string($stock, $lang['2'], $lang['3'], $lang['4'], $lang['5'], $lang['6']); } $prod_month_strings = array(); foreach($avail_month as $month) { $prod_month_strings[] = month_to_string($month, $lang['7'], $lang['8'], $lang['9'], $lang['10'], $lang['11'], $lang['12'], $lang['13'], $lang['14'], $lang['15'], $lang['16'], $lang['17'], $lang['18']); } $smarty->assign('default_currency', $default_currency); $smarty->assign('products_dir', $products_dir); $smarty->assign('product_small_picture_weight', $product_small_picture_weight); $smarty->assign('product_small_picture_height', $product_small_picture_height); $smarty->assign('total_records', $total_records); $smarty->assign('prod_ids', $prod_ids); $smarty->assign('categ_product_id', $categ_product_id); $smarty->assign('small_picture', $small_picture); $smarty->assign('product_name', $product_name); $smarty->assign('product_name_rewrite', $product_name_rewrite); $smarty->assign('small_description', $small_description); $smarty->assign('your_price', $your_prices); $smarty->assign('with_vat_price', $with_vat_price); $smarty->assign('prod_stock_strings', $prod_stock_strings); $smarty->assign('avail_day', $avail_day); $smarty->assign('prod_month_strings', $prod_month_strings); $smarty->assign('avail_year', $avail_year); $smarty->assign('inventory_number', $inventory_number); if ($pages > 1) { $page_link = "".$lang['178']." $page ".$lang['179']." $pages"; $smarty->assign('page_link', $page_link); } if ($page > 1) { $previous = $page - 1; $previous_link = "".$lang['19'].""; $smarty->assign('previous_link', $previous_link); } if ($total_records != $rows_per_page) { if ($pages > $scroll) { // REMOVE THIS TO GET RID OF THE SCROLL FEATURE $first = $page; // REMOVE THIS TO GET RID OF THE SCROLL FEATURE $last = ($scroll - 1) + $page; // REMOVE THIS TO GET RID OF THE SCROLL FEATURE } else { // REMOVE THIS TO GET RID OF THE SCROLL FEATURE $first = 1; $last = $pages; } // REMOVE THIS TO GET RID OF THE SCROLL FEATURE if ($last > $pages ) { $first = $pages - ($scroll - 1); $last = $pages; } if ($pages > 1) { for ($i = $first;$i <= $last;$i++){ if ($page == $i) { $curent_page .="[ $i ]"; } else { $curent_page .= "[ $i ]"; } } $smarty->assign('curent_page', $curent_page); } } if ($page < $pages) { $next = $page + 1; $next_link = "| $lang[20]"; $smarty->assign('next_link', $next_link); } } //////////////////////////////////////////////////////////////////////////////////////////////////*\ $smarty->display('categories.tpl'); include ("close_mysql.php"); ?>