<?php
$cartCustomerAdminMain = new cartCustomerAdminCore;
class cartCustomerAdminCore{ 

function fetch_catagory_product_details_by_item_id($ITEM_ID){
	$row=mysql_fetch_assoc(mysql_query("select * from cart_catagory_product where ID='".$ITEM_ID."'"));
	return $row;
}

function fetch_product_details_by_product_id($PRODUCT_ID){
	$row=mysql_fetch_assoc(mysql_query("select * from cart_product where product_id='".$PRODUCT_ID."'"));
	return $row;
}

function fetch_catagory_details_by_catagory_id($CATAGORY_ID){
	$row=mysql_fetch_assoc(mysql_query("select * from cart_catagory where catagory_id='".$CATAGORY_ID."'"));
	return $row;
}

function fetch_company_details_by_company_id($COMPANY_ID){
	$row=mysql_fetch_assoc(mysql_query("select * from cart_global where GLOBAL_ID='".$COMPANY_ID."'"));
	return $row;
}

function fetch_one_image_by_selling_product_id($SELLING_PRODUCT_ID){
	$row=mysql_fetch_assoc(mysql_query("select * from cart_product_image where SELLING_PRODUCT_ID='".$SELLING_PRODUCT_ID."'"));
	return $row;
}

function view_product_images($ID){
	$row=mysql_query("select * from cart_product_image where SELLING_PRODUCT_ID='".$ID."'");
	while($result=mysql_fetch_array($row)){
		echo '
		
		<li data-thumb="'.$result['IMAGE'].'">
												<div class="thumb-image"> <img src="'.$result['IMAGE'].'" data-imagezoom="true" class="img-responsive"> </div>
											</li>';
	}
}

function get_selected_currencySymbol($CURRENCY_ID){
	$row=mysql_fetch_assoc(mysql_query("select * from cart_currency where currency_id='".$CURRENCY_ID."'"));
	$html=$row['CURRENCY_SYMBOL'];
	return $html;
}

function get_selected_currencyValue($CURRENCY_ID){
	$row=mysql_fetch_assoc(mysql_query("select * from cart_currency where currency_id='".$CURRENCY_ID."'"));
	$html=$row['CURRENCY_VALUE'];
	return $html;
}

function get_company_hotline($COMPANY_ID){
	global $cartCustomerAdminMain;
	$result=$cartCustomerAdminMain->fetch_company_details_by_company_id($COMPANY_ID);
	if($result['COMPANY_MOBILE']!="")
	{
		$tel=$result['COMPANY_MOBILE'];
	}
	else
	{
		$tel=$result['COMPANY_TELEPHONE_01'];
	}
	return $tel;
}

function get_catagory_by_product_id($PRODUCT_ID,$COMPANY_CURRENCY_ID){
	global $cartCustomerAdminMain;
	global $cartCustomerCore;
	$row=mysql_query("select * from cart_catagory_product where product_id='".$PRODUCT_ID."'");
	$fetch_product_details=$cartCustomerAdminMain->fetch_product_details_by_product_id($PRODUCT_ID);
	while($result=mysql_fetch_assoc($row)){
		$fetch_catagory_details=$cartCustomerAdminMain->fetch_catagory_details_by_catagory_id($result['CATAGORY_ID']);
		$fetch_one_image_details=$cartCustomerAdminMain->fetch_one_image_by_selling_product_id($result['ID']);
		echo '<div class="recent-grids">
								<div class="recent-left">
									<a href="single.html"><img class="img-responsive " src="'.$fetch_one_image_details['IMAGE'].'" alt=""></a>	
								</div>
								<div class="recent-right">
									<h6 class="best2"><a href="index.php?item_id='. $cartCustomerCore->md5_base64_encode($result['ID']).'">'.$fetch_product_details['PRODUCT_NAME'].' <small>('.$fetch_catagory_details['CATAGORY_NAME'].')</small> </a></h6>
									<div class="block">
										<div class="starbox small ghosting"> </div>
									</div>
									<span class=" price-in1">'.$cartCustomerAdminMain->get_selected_currencySymbol($COMPANY_CURRENCY_ID).' '.$result['PRICE'].'</span>
								</div>
								<div class="clearfix"> </div>
							</div>';
	}

}

function get_company_items($COMPANY_ID,$COMPANY_CURRENCY_ID){
	
	global $cartCustomerAdminMain;
	global $cartCustomerCore;
	
	$row=mysql_query("select * from cart_catagory_product");
	$row_count=mysql_num_rows($row);
	$offset=0;
	while($offset<=$row_count)
		{
		
		
		echo '<div class="item">';
		$limit_row=mysql_query("select * from cart_catagory_product WHERE company_id='".$COMPANY_ID."' LIMIT 2 OFFSET $offset ");
		while($result=mysql_fetch_array($limit_row))
		{
			$fetch_one_image_details=$cartCustomerAdminMain->fetch_one_image_by_selling_product_id($result['ID']);
			$fetch_product_details=$cartCustomerAdminMain->fetch_product_details_by_product_id($result['PRODUCT_ID']);
			$fetch_catagory_details=$cartCustomerAdminMain->fetch_catagory_details_by_catagory_id($result['CATAGORY_ID']);
			echo ' <div class="recent-grids">
												<div class="recent-left">
													<a href="index.php?item_id='. $cartCustomerCore->md5_base64_encode($result['ID']).'"><img class="img-responsive " src="'.$fetch_one_image_details['IMAGE'].'" alt=""></a>	
												</div>
												<div class="recent-right">
													<h6 class="best2"><a href="index.php?item_id='. $cartCustomerCore->md5_base64_encode($result['ID']).'">'.$fetch_product_details['PRODUCT_NAME'].'</a></h6>
													<div class="block">
														<small>'.$fetch_catagory_details['CATAGORY_NAME'].'</small>
													</div>
													<span class=" price-in1">'.$cartCustomerAdminMain->get_selected_currencySymbol($COMPANY_CURRENCY_ID).' '.$result['PRICE'].'</span>
												</div>	
												<div class="clearfix"> </div>
											</div>';
		}
		echo '</div>';
		$offset=$offset+2;

	}


}

function view_product_function($PRODUCT_FUNCTION){
			$P_FUNCTION = explode(",", $PRODUCT_FUNCTION);
															
														
		foreach($P_FUNCTION as $cat) 
		{
    			$cat = trim($cat);
    			echo '* <span>'.$cat.'</span><br>';
		}	
}

function count_reviews($SELLING_PRODUCT_ID){
	$row=mysql_num_rows(mysql_query("select * from cart_product_review where selling_product_id='".$SELLING_PRODUCT_ID."'"));
	return $row;
}

}?>