File: /home/barbeatleanalyti/public_html/barisnew.beatleanalytics.com/site/backup/include/home.php
<?php
/* <summary>
Class file for home page contains functions related to all sections displayed on home page
<author>
Beatle Buddy 2017.
</author>
Version 1.0
</summary>
*/
class include_home
{
/* <summary>
Default constructor
</summary>
*/
function __CONSTRUCT()
{
}
/* <summary>
Fetch all rotating banners
</summary>
<returns>Returns an array contains all information of rotating banners</returns>
*/
function fetch_rotating_banner()
{
global $objDB;
$SQL = "SELECT * FROM rotating_banners WHERE StoreID = " . $_SESSION['StoreID'] . " AND ActiveLayout = 'Y' AND Active = 'Y' AND BannerType = 'rotating' ORDER BY DisplayOrder";
$res = $objDB->select($SQL);
return $res;
}
/* <summary>
Fetch static banner
</summary>
<returns>Returns an array contains all information of static banner</returns>
*/
function fetch_static_banner()
{
global $objDB;
$SQL = "SELECT * FROM rotating_banners WHERE StoreID = " . $_SESSION['StoreID'] . " AND Active = 'Y' AND BannerType = 'static'";
$res = $objDB->select($SQL);
return $res;
}
/* <summary>
Fetch all products from database marked as Product of the week
</summary>
<returns>Returns an array contains all products marked as product of the week</returns>
*/
function fetch_products_week()
{
global $objDB;
$SQL = "SELECT * FROM `store_".$_SESSION['StoreID']."_master` WHERE `ProductoftheWeek` = 'Yes' ";
if(strtoupper(PRODUCT_OUT_OF_STOCK_DISPLAY) == 'NO'){
$SQL .= " AND Inventory > 0 ";
}
$SQL .= " AND Active = 'Yes' AND Deleted = 0 LIMIT 0,".PRODUCTS_OF_THE_WEEK_RECORDS;
$res = $objDB->select($SQL);
return $res;
}
/* <summary>
Fetch all products from database marked as best seller
</summary>
<param name="type">value to determine from where function is called. either from home page or from best-seller page</param>
<param name="sort">contains field name and sorting type. both value are concated nated with "_"</param>
<param name="start">starting position of record number</param>
<param name="end">ending position of record number</param>
<returns>Returns an array contains all products marked as best seller</returns>
*/
function fetch_best_seller($type="home", $sort='DisplayOrder_ASC', $start=0, $end=0)
{
global $objDB;
$SQL = "SELECT * FROM `store_".$_SESSION['StoreID']."_master` WHERE `BestSeller` = 'Yes' AND Active = 'Yes' AND Deleted = 0";
if(strtoupper(PRODUCT_OUT_OF_STOCK_DISPLAY) == 'NO'){
$SQL .= " AND Inventory > 0 ";
}
if($type == "home")
{
$SQL .= " LIMIT 0,".BEST_SELLERS_RECORDS;
}
else
{
$Fields = explode('_',$sort);
$FieldName = str_replace(' ', '', $Fields[0]);
$sort_method = $Fields[1];
if(stripos($FieldName, 'price') === FALSE){
$SQL .=" ORDER BY $FieldName $sort_method ";
}
else{
$SQL .=" ORDER BY IF($FieldName>0, $FieldName, Price) $sort_method ";
}
if($end>0)
$SQL .= " limit ".$start.", ".$end;
}
$res = $objDB->select($SQL);
return $res;
}
function fetch_best_seller_new($sort='DisplayOrder_ASC', $start=0, $end=0)
{
global $objDB;
$SQL = "SELECT * FROM `store_".$_SESSION['StoreID']."_master` WHERE `BestSeller` = 'Yes' AND Active = 'Yes' AND Deleted = 0";
$Fields = explode('_',$sort);
$FieldName = str_replace(' ', '', $Fields[0]);
$sort_method = $Fields[1];
if(stripos($FieldName, 'price') === FALSE){
$SQL .=" ORDER BY $FieldName $sort_method ";
}
else{
$SQL .=" ORDER BY IF($FieldName>0, $FieldName, Price) $sort_method ";
}
if($end>0)
$SQL .= " limit ".$start.", ".$end;
$res = $objDB->sql_query($SQL);
// echo $SQL;echo "<br/>";
return $res;
}
/* <summary>
Fetch all products from database marked as new arrival
</summary>
<param name="type">value to determine from where function is called. either from home page or from new-arrival page</param>
<param name="sort">contains field name and sorting type. both value are concated nated with "_"</param>
<param name="start">starting position of record number</param>
<param name="end">ending position of record number</param>
<returns>Returns an array contains all products marked as new arrival</returns>
*/
function fetch_new_arrivals($type="home", $sort='DisplayOrder_ASC', $start=0, $end=0)
{
global $objDB;
$SQL = "SELECT * FROM store_".$_SESSION['StoreID']."_master WHERE NewArrival = 'Yes' AND Active = 'Yes' AND Deleted = 0";
if(strtoupper(PRODUCT_OUT_OF_STOCK_DISPLAY) == 'NO'){
$SQL .= " AND Inventory > 0 ";
}
if($type == "home")
{
$SQL .= " LIMIT 0,".NEW_ARRIVALS_RECORDS;
}
else
{
$Fields = explode('_',$sort);
$FieldName = str_replace(' ', '', $Fields[0]);
$sort_method = $Fields[1];
if(stripos($FieldName, 'price') === FALSE){
$SQL .=" ORDER BY $FieldName $sort_method ";
}
else{
$SQL .=" ORDER BY IF($FieldName>0, $FieldName, Price) $sort_method ";
}
if($end>0)
$SQL .= " limit ".$start.", ".$end;
}
$res = $objDB->select($SQL);
return $res;
}
function fetch_new_arrivals_new($sort='DisplayOrder_ASC', $start=0, $end=0)
{
global $objDB;
$SQL = "SELECT * FROM store_".$_SESSION['StoreID']."_master WHERE NewArrival = 'Yes' AND Active = 'Yes' AND Deleted = 0 ";
$Fields = explode('_',$sort);
$FieldName = str_replace(' ', '', $Fields[0]);
$sort_method = $Fields[1];
if(stripos($FieldName, 'price') === FALSE){
$SQL .=" ORDER BY $FieldName $sort_method ";
}
else{
$SQL .=" ORDER BY IF($FieldName>0, $FieldName, Price) $sort_method ";
}
if($end>0)
$SQL .= " limit ".$start.", ".$end;
$res = $objDB->sql_query($SQL);
// echo $SQL;echo "<br/>";
return $res;
}
/* <summary>
Fetch all products from database which support free engraving
</summary>
<returns>Returns an array contains all products which offer free engraving</returns>
*/
function fetch_free_engraving()
{
global $objDB;
$SQL = "SELECT * FROM store_".$_SESSION['StoreID']."_master WHERE FreeEngraving = 'Yes' AND Active = 'Yes' AND Deleted = 0 LIMIT 0, 8";
$res = $objDB->select($SQL);
return $res;
}
/* <summary>
Fetch all categories from database marked as featured category
</summary>
<returns>Returns an array contains all categories marked as feature category</returns>
*/
function fetch_featured_categories()
{
global $objDB;
$SQL = "SELECT * FROM `store_".$_SESSION['StoreID']."_master` WHERE `FeaturedCategory` = 'Yes' AND Active = 'Yes' AND Deleted = 0 AND MasterId IN (SELECT parent FROM term_hierarchy WHERE StoreID = ".$_SESSION['StoreID'].") limit 0,".FEATURED_CATEGORIES_RECORD;
$res = $objDB->select($SQL);
return $res;
}
/* <summary>
Fetch all products from database marked as season on sale
</summary>
<returns>Returns an array contains all products marked as season on sale</returns>
*/
function fetch_season_sale()
{
global $objDB;
$SQL = "SELECT * FROM `store_".$_SESSION['StoreID']."_master` WHERE `SeasonOnSale` = 'Yes' ";
if(strtoupper(PRODUCT_OUT_OF_STOCK_DISPLAY) == 'NO'){
$SQL .= " AND Inventory > 0 ";
}
$SQL .= " AND Active = 'Yes' AND Deleted = 0 LIMIT 0, 2";
$res = $objDB->select($SQL);
return $res;
}
/* <summary>
Fetch all banners to be dipslay on right side of the home page
</summary>
<param name="StoreID">int StoreID</param>
<param name="BannerNo">int BannerNo</param>
<returns>Returns an array contains all products marked as season on sale</returns>
*/
function get_right_banner($StoreID,$BannerNo)
{
global $objDB;
$SQL = "SELECT * FROM `rotating_banners` WHERE `Active` LIKE 'Y' AND `BannerType` = 'right".$BannerNo."' AND StoreID=$StoreID";
$Result = $objDB->select($SQL);
return $Result;
}
/* <summary>
Fetch quantity details for particular order of the perticular customer
</summary>
<param name="CustomerID">int CustomerID</param>
<param name="OrderNo">int OrderNo</param>
<returns>Return an array contains payment method used for particular order</returns>
*/
function fetch_order_quantity_details($CustomerID,$OrderNo){
global $objDB;
$SQL = "SELECT * FROM orderedshoppingcartitems WHERE OrderNumber = '".$OrderNo."' ";
$res = $objDB->sql_query($SQL);
return $res;
}
/* <summary>
Fetch all banners images to be display for particular event
</summary>
<param name="EventID">EventID</param>
<returns>Return an array contains rotating banner images</returns>
*/
function fetch_event_banner_images($EventID)
{
global $objDB;
$SQL = "SELECT * FROM event_banner WHERE EventID = ".$EventID." AND BannerType = 'rotating' ORDER BY BannerPos ASC";
$res = $objDB->select($SQL);
return $res;
}
/* <summary>
Fetch all banners to be dipslay on right side of the home page
</summary>
<param name="StoreID">int StoreID</param>
<returns>Return an array contains rotating banner images</returns>
*/
function FetchRightBannerList($StoreID)
{
global $objDB;
$SQL = "SELECT * FROM `rotating_banners` WHERE `ActiveLayout` = 'Y' AND BannerType LIKE 'right%' AND `StoreID` = '".$StoreID."' ";
$Res = $objDB->select($SQL);
return $Res;
} //end FetchRightBannerList
/* <summary>
Fetch all event banners to be dipslay right or bottom of main banner on the home page
</summary>
<param name="StoreID">int EventID</param>
<returns>Returns an array contains all small banner</returns>
*/
function FetchEventRightBannerList($EventID)
{
global $objDB;
$SQL = "SELECT * FROM `event_banner` WHERE `EventID` = ".$EventID." AND BannerType LIKE 'right%' ";
$Res = $objDB->select($SQL);
return $Res;
} //end FetchEventRightBannerList
/* <summary>
Fetch all banners to be dipslay on right side of the home page
</summary>
<param name="StoreID">int EventID</param>
<param name="BannerNo">int BannerNo</param>
<returns>Returns an array contains all products marked as season on sale</returns>
*/
function FetchEventBannerByNumber($EventID,$BannerNo)
{
global $objDB;
$SQL = "SELECT * FROM `event_banner` WHERE `BannerType` = 'right".$BannerNo."' AND `EventID` = ".$EventID;
$Result = $objDB->select($SQL);
return $Result;
}
}
?>