/** * This function is used to find the price range * @param integer $sort * @param string $mode * @return string */ function priceRangeSearch($sort, $mode) { $sql = "select a.*,sum(r.rating)/count(r.user_id) as rating,count(r.user_id) as rcount from products_table a left join product_reviews_table r on a.product_id=r.product_id and a.intro_date <= '" . date('Y-m-d') . "' and a.status=1 "; $conditions = array(); $pagesize = 10; if (isset($_POST['pricerange'])) { $_SESSION['minval'] = $_POST['txtminmsrp']; $_SESSION['maxval'] = $_POST['txtmaxmsrp']; $minval = $_POST['txtminmsrp']; $maxval = $_POST['txtmaxmsrp']; } else { $minval = $_SESSION['minval']; $maxval = $_SESSION['maxval']; } if ((int) $_SESSION['subcategory']) { $category = $_SESSION['subcategory']; } if ((int) $category != 0) { $condition[] = ' a.category_id=' . $category; } if ((int) $minval != 0 && (int) $maxval != 0) { $condition[] = ' a.msrp between ' . $minval . ' and ' . $maxval; } if (isset($_GET['page'])) { $start = trim($_GET['page'] - 1) * $pagesize; $end = $pagesize; } else { $start = 0; $end = $pagesize; } $total = 0; $catagory = $_POST['subcatsel']; $sortby = $_POST['selsort']; if (empty($sortby)) { $sortby = 0; } if ($sortby == 0) { $orderby = " order by a.msrp "; } elseif ($sortby == 1) { $orderby = " order by a.msrp desc "; } elseif ($sortby == 2) { $orderby = " order by a.title "; } elseif ($sortby == 3) { $orderby = " order by a.title desc "; } if (count($condition) > 1) { $sql .= ' where ' . implode(' and ', $condition); } elseif (count($condition) > 0) { $sql .= ' where ' . implode('', $condition); } $sql .= ' group by a.product_id ' . $orderby; $obj = new Bin_Query(); if ($obj->executeQuery($sql)) { $_SESSION['countsearch'] = $obj->totrows; $sql1 = $sql . ' LIMIT ' . $start . ',' . $end; $total = ceil($obj->totrows / $pagesize); include 'classes/Lib/paging.php'; $tmp = new Lib_Paging('classic', array('totalpages' => $total, 'length' => 10), 'pagination'); $this->data['paging'] = $tmp->output; $this->data['prev'] = $tmp->prev; $this->data['next'] = $tmp->next; $query = new Bin_Query(); if ($query->executeQuery($sql1)) { $i = 0; if ((int) $query->totrows > 0) { foreach ($query->records as $row) { $r[$i] = $row; $prid = $row['product_id']; $obj1 = new Core_CKeywordSearch(); $minval = $obj1->disRates($prid); if ($minval > 0 or $minval != '') { $r[$i]['msrp'] = '<!--$-->' . $_SESSION['currencysetting']['selected_currency_settings']['currency_tocken'] . number_format($row['msrp'] * $_SESSION['currencysetting']['selected_currency_settings']['conversion_rate'], 2) . ' - <!--$-->' . $_SESSION['currencysetting']['selected_currency_settings']['currency_tocken'] . number_format($minval * $_SESSION['currencysetting']['selected_currency_settings']['conversion_rate'], 2); } else { $r[$i]['msrp'] = '<!--$-->' . $_SESSION['currencysetting']['selected_currency_settings']['currency_tocken'] . number_format($row['msrp'] * $_SESSION['currencysetting']['selected_currency_settings']['conversion_rate'], 2); } $i++; } } } return Display_DKeywordSearch::priceRangeSearch($r, $mode, $this->data['paging'], $this->data['prev'], $this->data['next']); } else { return Display_DKeywordSearch::priceRangeSearch($r, '', '', '', ''); } $_SESSION['countsearch'] = $obj->totrows; $i = 0; //return Display_DKeywordSearch::displaySearch($r,$mode); }