<?php

$cartCore = new cartCore;

class cartCore{

	public $config = array();

	public $userDateFormat = "";
	
	public function domain(){
		$domainname = "http://product.sayurabeachhotel.com";
		return $domainname;	
	}
	
	public function ClearInput($dirty){

		$dirty = mysql_real_escape_string($dirty);

		return $dirty;

	}
	
	function AutoGenValue(){
		$auto_number = substr(uniqid(), -6, 6);
		return $auto_number;
	}
	
	function view_current_date($COMPANY_ID){
		global $cartCore;
		
		$tz=mysql_fetch_assoc($cartCore->get_global_config_by_company_id($COMPANY_ID));
		 date_default_timezone_set($tz['COMPANY_TIME_ZONE']);

    // Then call the date functions
    $date = date('Y-m-d H:i:s');
    // Or
    return date('Y/m/d');
	}
	
	function view_current_date_time($COMPANY_ID){
		global $cartCore;
		
		$tz=mysql_fetch_assoc($cartCore->get_global_config_by_company_id($COMPANY_ID));
		 date_default_timezone_set($tz['COMPANY_TIME_ZONE']);

    // Then call the date functions
    $date = date('Y-m-d H:i:s');
    // Or
    return $date;
	}
	
	function configuration_email($message,$email_subject,$notifyemailscontent,$COMPANY_ID,$message_admin,$email_subject_admin){
			global $cartCore;
			require("mail/PHPMailer/class.phpmailer.php");
			$row=$cartCore->get_smtp_info_by_company_id($COMPANY_ID);
			$result=mysql_fetch_assoc($row);
			$fetch_company_details=$cartCore->fetch_global_config_by_company_id($COMPANY_ID);
			$subject=$email_subject;
			
			//email primary
			
    		$mail = new PHPMailer(); // create a new object
    		$mail->IsSMTP(); // enable SMTP
    		$mail->SMTPDebug = $result['SMTP_DEBUG']; // debugging: 1 = errors and messages, 2 = messages only
   	 		$mail->SMTPAuth = $result['SMTPAUTH']; // true authentication enabled
    		$mail->SMTPSecure = $result['SMTPSECURE']; // secure transfer enabled REQUIRED for GMail ssl or tls
    		$mail->Host = $result['HOST']; //smtp.gmail.com"
    		$mail->Port = $result['PORT']; // 465 or 587
    		$mail->IsHTML(true);
    		$mail->Username = $result['USERNAME'];
    		$mail->Password = $result['PASSWORD'];
    		$mail->SetFrom($result['SET_FROM_EMAIL']);
    		$mail->FromName=$result['FROM_NAME'];
			$mail2 = clone $mail;
			
			//secondary email
			$admin_mail=$fetch_company_details['COMPANY_EMAIL_01'];
			$mail2->AddAddress($admin_mail,"I concept");
			$mail2->Subject =$email_subject_admin;
			$mail2->Body = $message_admin;
			$mail2->Send();
    	

		foreach($notifyemailscontent as $SENT_MAIL)
			{
   				$mail->AddAddress($SENT_MAIL);
			}
    	
    	$logfile = dirname(dirname(__FILE__)) . '/mail.log';
    	try {
    	    
        	$mail->Subject = $subject;
			

			$mail->Body = $message;
        	file_put_contents($logfile, "Content: \n", FILE_APPEND);
        	file_put_contents($logfile, $message . "\n\n", FILE_APPEND);

        		if(!$mail->Send()) {
            	echo "Mailer Error: " . $mail->ErrorInfo;
				$status = 'err';
				return $status;
        		} else {
            	$status = 'ok';
				return $status;
       			}
    		} catch (Exception $e) {
        		#print_r($e->getMessage());
        		file_put_contents($logfile, "Error: \n", FILE_APPEND);
        		file_put_contents($logfile, $e->getMessage() . "\n", FILE_APPEND);
        		file_put_contents($logfile, $e->getTraceAsString() . "\n\n", FILE_APPEND);
				echo '<H1>'.$result['USERNAME'].'<H1>';
				echo $result['PASSWORD'];
    	}
		
	}
	
	function update_user_password($USERNAME,$ENT_PASSWORD){
		mysql_query("update cart_user set `PASSWORD`='".$ENT_PASSWORD."' where USERNAME='".$USERNAME."'");
	}
	
	function update_customer_profile($USERID,$FULLNAME,$ADDRESS,$COUNTRY,$TELEPHONE,$EMAIL){
		mysql_query("update cart_customer set `FULL_NAME`='".$FULLNAME."',`ADDRESS`='".$ADDRESS."',`COUNTRY`='".$COUNTRY."',`TELEPHONE`='".$TELEPHONE."',`EMAIL`='".$EMAIL."' where USER_ID='".$USERID."'");
	}
	
	function update_user_profile($USERID,$FULLNAME,$EMAIL){
		mysql_query("update cart_user set `FULL_NAME`='".$FULLNAME."',`E_MAIL`='".$EMAIL."' where USER_ID='".$USERID."'");
	}
	
	function get_user_info($functionusername){
		$row=mysql_fetch_assoc(mysql_query("SELECT * FROM cart_user where username='".$functionusername."'"));
		return $row;
	}
	
	function get_user_info_by_user_id($functionusername){
		$row=mysql_fetch_assoc(mysql_query("SELECT * FROM cart_user where user_id='".$functionusername."'"));
		return $row;
	}
	
	function purchase_count($COMPANY_ID){
		$row=mysql_num_rows(mysql_query("select * from cart_order where COMPANY_ID='".$COMPANY_ID."' AND STATUS='PAID'"));
		return $row;
	}
	
	function system_user_count(){
		$row=mysql_num_rows(mysql_query("select * from cart_user where status=1"));
		return $row;
	}
	
	function system_customer_count(){
		$row=mysql_num_rows(mysql_query("select * from cart_customer"));
		return $row;
	}
	
	function get_system_user_details_by_username($username){
		$row=mysql_query("select * from cart_user where username='".$username."'");
		return $row;
	}
	function fetch_cart_user_details_by_username($username){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_user where username='".$username."'"));
		return $row;
	}
	
	function get_system_user_details_by_username_filter_system_user($username,$system_user){
		$row=mysql_query("select * from cart_user where username='".$username."' AND system_user='".$system_user."'");
		return $row;
	}
	
	function get_user_for_table(){
		$row=mysql_query("select * from cart_user");
		return $row;
	}
	
	function get_user_for_selected_option($status){
		$row=mysql_query("select * from cart_user where status='".$status."' AND system_user=1");
		return $row;
	}
	
	function fetch_system_user_company_details_by_userid($user_id){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_company_user_enrollment where user_id='".$user_id."'"));
		return $row;
	}
	
	function get_menu_for_table($menu_type){
		$row=mysql_query("select * from cart_menu where menu_type='".$menu_type."'");
		return $row;
	}
	
	function get_menu_info($menu_id){
		$row=mysql_fetch_assoc(mysql_query("SELECT * FROM cart_menu where menu_id='".$menu_id."'"));
		return $row;
	}
	
	function get_menu_info_query_only($menu_type){
		$row=mysql_query("SELECT * FROM cart_menu where menu_type='".$menu_type."'");
		return $row;
	}
	
	function get_permission_info($rid){
		$row=mysql_fetch_assoc(mysql_query("SELECT * FROM cart_menu_permission where per_id='".$rid."'"));
		return $row;
	}
	
	function get_menu_info_by_menu_name($menu_name){
		$row=mysql_query("SELECT * FROM cart_menu where menu_name='".$menu_name."'");
		return $row;
	}
	
	function get_menu_permission_info_by_user_id($userid){
		$row=mysql_query("SELECT * FROM cart_menu_permission where user_id='".$userid."' AND menu_id!='0'");
		return $row;
	}
	
	function getPageHeading($pagename){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_menu where page_name='".$pagename."'"));
		$menu_name=$row['MENU_NAME'];
		return $menu_name;
	}
	
	function getMainPageHeading($subpagename){
		global $cartCore;
		$row=mysql_fetch_assoc(mysql_query("select * from cart_menu where page_name='".$subpagename."'"));
		$main_menu=mysql_fetch_assoc(mysql_query("select * from cart_menu where menu_id='".$row['MENU_PARENT']."'"));
		$parentmenu_name=$main_menu['MENU_NAME'];
		return $parentmenu_name;
	}
	
	function get_country_by_iso($iso){
		$row=mysql_query("select * from cart_country where iso='".$iso."'");
		return $row;
	}
	
	function fetch_country_by_iso($iso){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_country where iso='".$iso."'"));
		return $row;
	}
	
	function get_country(){

		$row=mysql_query("select * from cart_country");
		return $row;
	}
	
	function get_basic_configure_for_table(){
		$row=mysql_query("select * from cart_global");
		return $row;
	}
	
	function get_smtp_info(){
		$row=mysql_query("select * from cart_smtp_config");
		return $row;
	}
	
	function get_smtp_info_by_company_id($company_id){
		$row=mysql_query("select * from cart_smtp_config where GLOBAL_ID='".$company_id."'");
		return $row;
	}
	
	function get_global_config_by_company_id($company_id){
		$row=mysql_query("select * from cart_global where GLOBAL_ID='".$company_id."'");
		return $row;
	}
	
	function fetch_global_config_by_company_id($company_id){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_global where GLOBAL_ID='".$company_id."'"));
		return $row;
	}
	
	function fetch_payment_gateway_by_company_id($company_id){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_paymentgateway where COMPANY_ID='".$company_id."'"));
		return $row;
	}
	
	function system_new_user_precentage(){
		$row=mysql_num_rows(mysql_query("SELECT * FROM cart_user WHERE ENROLL_DATE > DATE_SUB(DATE(NOW()), INTERVAL DAYOFWEEK(NOW())+6 DAY) AND ENROLL_DATE <= DATE_SUB(DATE(NOW()), INTERVAL DAYOFWEEK(NOW())-1 DAY)"));
		return $row;
	}
	
	function system_new_customer_precentage(){
		$row=mysql_num_rows(mysql_query("SELECT * FROM cart_customer WHERE LAST_UPDATE > DATE_SUB(DATE(NOW()), INTERVAL DAYOFWEEK(NOW())+6 DAY) AND LAST_UPDATE <= DATE_SUB(DATE(NOW()), INTERVAL DAYOFWEEK(NOW())-1 DAY)"));
		return $row;
	}
	
	function system_pruchase_precentage($COMPANY_ID){
		$row=mysql_num_rows(mysql_query("SELECT * FROM cart_order WHERE (COMPANY_ID='".$COMPANY_ID."' AND STATUS='PAID') AND DATE_TIME > DATE_SUB(DATE(NOW()), INTERVAL DAYOFWEEK(NOW())+6 DAY) AND DATE_TIME <= DATE_SUB(DATE(NOW()), INTERVAL DAYOFWEEK(NOW())-1 DAY)"));
		return $row;
	}
	
	function get_enroll_info_by_globalid($GLOBAL_ID){
		$row=mysql_query("select * from cart_company_user_enrollment where company_id='".$GLOBAL_ID."'");
		return $row;
	}
	
	function get_product_table_by_company_id($COMPNAY_ID){
		$row=mysql_query("select * from cart_product where company_id='".$COMPNAY_ID."'");
		return $row;
	}
	
	function get_catagory_table_by_company_id($COMPNAY_ID){
		$query="select * from cart_catagory where company_id='".$COMPNAY_ID."'";
		$result = mysql_query($query) or die(mysql_error());
		return $result;
	}
	
	function get_catagory_product_table_by_company_id($COMPNAY_ID){
		$row=mysql_query("select * from cart_catagory_product where company_id='".$COMPNAY_ID."'");
		return $row;
	}
	
	function get_image_table_by_selling_product_id($SELLING_PRODUCT_ID){
		$row=mysql_query("select * from cart_product_image where selling_product_id='".$SELLING_PRODUCT_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_product_catagory_details_by_product_catagory_id($PRODUCT_CATAGORY_ID){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_catagory_product where ID='".$PRODUCT_CATAGORY_ID."'"));
		return $row;
	}
	
	function get_enroll_info_by_globalid_userid($COMPANY_ID,$USER_ID){
		$row=mysql_query("select * from cart_company_user_enrollment where company_id='".$COMPANY_ID."' AND user_id='".$USER_ID."'");
		return $row;
	}
	
	function fetch_oneproduct_by_invoice_number($INVOICE_ID){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_order_product where ORDER_ID='".$INVOICE_ID."'"));
		return $row;
	}
	
	function get_currency(){
		$row=mysql_query("select * from cart_currency");
		return $row;
	}
	
	function get_currency_by_id($CURRENCY_ID){
		$row=mysql_query("select * from cart_currency where currency_id='".$CURRENCY_ID."'");
		return $row;
	}
	
	function fetch_currency_by_symbol($CURRENCY_SYMBOL){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_currency where CURRENCY_SYMBOL='".$CURRENCY_SYMBOL."'"));
		return $row;
	}
	
	function fetch_customer_details_by_user_id($USER_ID){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_customer where user_id='".$USER_ID."'"));
		return $row;
	}
	
	function md5_base64_encode($data){
		$encode_data=base64_encode($data);
		return $encode_data;
	}
	function md5_base64_decode($data){
		$decode_data=base64_decode($data);
		return $decode_data;
	}
	function md5_pure_encode($data){
		return md5($data);
	}
 function tz_list() 
	{
  		$zones_array = array();
  		$timestamp = time();
  		foreach(timezone_identifiers_list() as $key => $zone) 
		{
    	date_default_timezone_set($zone);
    	$zones_array[$key]['zone'] = $zone;
    	$zones_array[$key]['diff_from_GMT'] = 'UTC/GMT ' . date('P', $timestamp);
  		}
 	 return $zones_array;
	}
	
	function total_calculation_by_invoice_id($INVOICE_ID){
		$price=0;
		$row=mysql_query("SELECT * FROM cart_order_product WHERE ORDER_ID = '".$INVOICE_ID."'");
		while($result=mysql_fetch_array($row))
		{
			$buy_item_price=$result['PRICE']*$result['QUANTITY'];
			$price=$price+$buy_item_price;
		}
		return $price;
	}
	
	function fetch_tax_info_by_tax_id($TAX_ID){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_tax where tax_id='".$TAX_ID."'"));
		return $row;
	}
	
	function fetch_shipping_info_by_shipping_id($SHIPPING_ID){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_shipping where shipping_id='".$SHIPPING_ID."'"));
		return $row;
	}
	
	
	function fetch_cart_tax_by_country_code_global_id($COUNTRY_CODE,$GLOBAL_ID){
		$row=mysql_fetch_assoc(mysql_query("SELECT * FROM cart_tax WHERE TAX_COUNTRY = '".$COUNTRY_CODE."' AND GLOBAL_ID='".$GLOBAL_ID."'"));
		return $row;
	}
	
	function fetch_tax_details_by_tax_country_company_id($COUNTRY_CODE,$GLOBAL_ID){
		$row=mysql_fetch_assoc(mysql_query("SELECT * FROM cart_tax WHERE TAX_COUNTRY = '".$COUNTRY_CODE."' AND GLOBAL_ID='".$GLOBAL_ID."'"));
		return $row;
	}
	
	function get_cart_tax_by_country_code_global_id($COUNTRY_CODE,$GLOBAL_ID){
		$row=mysql_query("SELECT * FROM cart_tax WHERE TAX_COUNTRY = '".$COUNTRY_CODE."' AND GLOBAL_ID='".$GLOBAL_ID."'");
		return $row;
	}
	
	function get_tax_table_by_company_id($GLOBAL_ID){
		$row=mysql_query("select * from cart_tax WHERE GLOBAL_ID='".$GLOBAL_ID."'");
		return $row;
	}
	
	function get_shipping_table_by_company_id($GLOBAL_ID){
		$row=mysql_query("select * from cart_shipping WHERE GLOBAL_ID='".$GLOBAL_ID."'");
		return $row;
	}
	
	function fetch_cart_shipping_by_country_code_global_id($COUNTRY_CODE,$GLOBAL_ID){
		$row=mysql_fetch_assoc(mysql_query("SELECT * FROM cart_shipping WHERE SHIPPING_COUNTRY = '".$COUNTRY_CODE."' AND GLOBAL_ID='".$GLOBAL_ID."'"));
		return $row;
	}
	
	function get_cart_shipping_by_country_code_global_id($COUNTRY_CODE,$GLOBAL_ID){
		$row=mysql_query("SELECT * FROM cart_shipping WHERE SHIPPING_COUNTRY = '".$COUNTRY_CODE."' AND GLOBAL_ID='".$GLOBAL_ID."'");
		return $row;
	}
	
	function get_cart_promo_by_promo_code_global_id($PROMO_CODE,$GLOBAL_ID){
		$row=mysql_query("SELECT * FROM cart_promotion WHERE PROMO_CODE = '".$PROMO_CODE."' AND GLOBAL_ID='".$GLOBAL_ID."'");
		return $row;
	}
	
	function fetch_cart_promo_by_promo_code_global_id($PROMO_CODE,$GLOBAL_ID){
		global $cartCore;
		$row=mysql_fetch_assoc($cartCore->get_cart_promo_by_promo_code_global_id($PROMO_CODE,$GLOBAL_ID));
		return $row;
	}
	
	function get_coupon_table_by_company_id($GLOBAL_ID){
		$row=mysql_query("select * from cart_promotion WHERE GLOBAL_ID='".$GLOBAL_ID."'");
		return $row;
	}
	
	function get_invoice_details_by_company_id($COMPANY_ID){
		$row=mysql_query("select * from cart_order where COMPANY_ID='".$COMPANY_ID."'");
		return $row;
	}
	
	function get_invoice_details_by_customer_username($USERNAME){
		$row=mysql_query("select * from cart_order where CUSTOMER_USERNAME='".$USERNAME."'");
		return $row;
	}
	
	function fetch_invoice_details_by_invoice_id($INVOICE_ID){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_order where ORDER_ID='".$INVOICE_ID."'"));
		return $row;
	}
	
	function get_paymentgateway_by_company_id($COMPANY_ID){
		$row=mysql_query("select * from cart_paymentgateway where COMPANY_ID='".$COMPANY_ID."'");
		return $row;
	}
	
	function fetch_customer_details_by_userid($USERID){
		$row=mysql_fetch_assoc(mysql_query("select * from cart_customer where USER_ID='".$USERID."'"));
		return $row;
	}
	
	
	
	function get_customer_details(){
		$row=mysql_query("select * from cart_customer");
		return $row;
	}
	
	function get_cart_order_by_customer_username_company_id($CUSTOMER_USERNAME,$COMPANY_ID)
	{
		$row=mysql_query("select * from cart_order where CUSTOMER_USERNAME='".$CUSTOMER_USERNAME."' AND COMPANY_ID='".$COMPANY_ID."'");
		return $row;
	}
	
	function get_cart_order_product_by_order_id($ORDER_ID){
		$row=mysql_query("select * from cart_order_product where ORDER_ID='".$ORDER_ID."'");
		return $row;
	}
	
	// checking functions
	
	function check_same_product_id_catagory_id($product_id,$catagory_id){
		$row=mysql_query("select * from cart_catagory_product where product_id='".$product_id."' AND catagory_id='".$catagory_id."'");
		return $row;
	}
	
	function get_invoice_details_by_invoice_id($INVOICE_ID){
		$row=mysql_query("select * from cart_order where ORDER_ID='".$INVOICE_ID."'");
		return $row;
	}
	
	
	
	
	
	
	public function get_headder(){
		global $cartAdminMain;
		$global_config=$cartAdminMain->get_global_config();
		echo '<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>'.$global_config['TITLE_NAME'].'</title>

    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
    <!-- iCheck -->
    <link href="../vendors/iCheck/skins/flat/green.css" rel="stylesheet">
    <!-- bootstrap-wysiwyg -->
    <link href="../vendors/google-code-prettify/bin/prettify.min.css" rel="stylesheet">
    <!-- Select2 -->
    <link href="../vendors/select2/dist/css/select2.min.css" rel="stylesheet">
    <!-- Switchery -->
    <link href="../vendors/switchery/dist/switchery.min.css" rel="stylesheet">
    <!-- starrr -->
    <link href="../vendors/starrr/dist/starrr.css" rel="stylesheet">
    <!-- bootstrap-daterangepicker -->
    <link href="../vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
  </head>';
	}
	
	public function get_footer(){
		$ehtml=' <footer>
          <div class="pull-right">
            &copy;2018 <a href="#">Digital Dreams</a>
          </div>
          <div class="clearfix"></div>
        </footer>';
		return $ehtml;
	}
	
	public function get_headder_customer(){
		echo '<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Customer</title>

    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
    <!-- iCheck -->
    <link href="../vendors/iCheck/skins/flat/green.css" rel="stylesheet">
    <!-- bootstrap-wysiwyg -->
    <link href="../vendors/google-code-prettify/bin/prettify.min.css" rel="stylesheet">
    <!-- Select2 -->
    <link href="../vendors/select2/dist/css/select2.min.css" rel="stylesheet">
    <!-- Switchery -->
    <link href="../vendors/switchery/dist/switchery.min.css" rel="stylesheet">
    <!-- starrr -->
    <link href="../vendors/starrr/dist/starrr.css" rel="stylesheet">
    <!-- bootstrap-daterangepicker -->
    <link href="../vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
  </head>';
	}
	
	public function view_welcome($username,$userimage){
		global $cartAdminMain;
		$global_config=$cartAdminMain->get_global_config();
		echo '
		 <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
            <div class="navbar nav_title" style="border: 0;">
              <a href="index.html" class="site_title"><i class="fa fa-paw"></i> <span>'.$global_config['TITLE_NAME'].'</span></a>
            </div>

            <div class="clearfix"></div>
            <div class="profile clearfix">
              <div class="profile_pic">
                <img src="data:image/png;base64,'.$userimage.'" alt="..." class="img-circle profile_img">
              </div>
              <div class="profile_info">
                <span>Welcome,</span>
                <h2>'.$username.'</h2>
              </div>
            </div>
            
            <br />';
	}
	
	public function view_welcome_customer($FULL_NAME,$userimage){
		
		echo '
		 <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
            <div class="navbar nav_title" style="border: 0;">
              <a href="#" class="site_title"><i class="fa fa-paw"></i> <span>Universal Access</span></a>
            </div>

            <div class="clearfix"></div>
            <div class="profile clearfix">
              <div class="profile_pic">
                <img src="data:image/png;base64,'.$userimage.'" alt="..." class="img-circle profile_img">
              </div>
              <div class="profile_info">
                <span>Welcome,</span>
                <h2>'.$FULL_NAME.'</h2>
              </div>
            </div>
            
            <br />';
	}
	
	public function view_sidebar($user_id,$token_id){
		echo ' <!-- sidebar menu -->
            <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
			<div class="menu_section">
						  <ul class="nav side-menu">';
 $sql_parent=mysql_query("select * from cart_menu where menu_type=0");
	while($row_parent=mysql_fetch_array($sql_parent))
	{
		
			echo ' 
                  			<li><a><i class="fa fa-asterisk"></i>'.$row_parent['MENU_NAME'].' <span class="fa fa-chevron-down"></span></a>
								<ul class="nav child_menu">';
			
			$sql_child=mysql_query("select * from cart_menu where menu_type=1 AND menu_parent='".$row_parent['MENU_ID']."'");
				while($row_child=mysql_fetch_array($sql_child))
					{
						$menu_access=mysql_query("select * from cart_menu_permission where user_id='".$user_id."' AND menu_id='".$row_child['MENU_ID']."'");
							while($row_access=mysql_fetch_assoc($menu_access))
							{
								if($row_child['MENU_ID']==$row_access['MENU_ID'])
									{
									echo '<li><a href="'.$row_child['PAGE_NAME'].'?token_id='.$token_id.'&menu_name='.base64_encode($row_child['MENU_NAME']).'">'.$row_child['MENU_NAME'].'</a></li>';
									}
							}
			
					}
							echo '</ul>
							</li>
							';
		
	}

echo '</ul>
							</div> </div>
            <!-- /sidebar menu -->';
	}
	
	
	public function view_customer_sidebar($user_id){
		echo ' <!-- sidebar menu -->
            <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
			<div class="menu_section">
						  <ul class="nav side-menu">
 								<li><a><i class="fa fa-asterisk"></i>Customer<span class="fa fa-chevron-down"></span></a>
									<ul class="nav child_menu">
										<li><a href="">Orders</a></li>
									</ul>
								</li>
						  </ul>
			</div> 
			</div>
            <!-- /sidebar menu -->';
	}

	public function view_credit($COMPANY_ID,$backlink){
		echo ' <!-- /menu footer buttons -->
            <div class="sidebar-footer hidden-small">
              <a data-toggle="tooltip" data-placement="top" title="Digital Dreams Global Edition">
                <span class="glyphicon glyphicon glyphicon-globe" aria-hidden="true"></span>
              </a>
              <a data-toggle="tooltip" data-placement="top" title="+94716 334114">
                <span class="glyphicon glyphicon-phone-alt" aria-hidden="true"></span>
              </a>
              <a data-toggle="tooltip" data-placement="top" title="madhusanka.pm@gmail.com">
                <span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
              </a>
              
                 <a data-toggle="tooltip" data-placement="top" title="madhusanka.pm@gmail.com">
                <span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
              </a>
            </div>
            <!-- /menu footer buttons -->
			</div>
        </div>';
	}
	
	public function view_userprofile($userid,$username,$image,$token,$COMPANY_ID,$backlink){
		global $cartCore;
		$encode_user_id=$cartCore->md5_base64_encode($userid);
		$COMPANY_ID=$cartCore->md5_base64_encode($COMPANY_ID);
		
		echo ' <li class="">
                  <a href="javascript:;" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                    <img src="data:image/png;base64,'.$image.'" alt="">'.$username.'
                    <span class=" fa fa-angle-down"></span>
                  </a>
                  <ul class="dropdown-menu dropdown-usermenu pull-right"> 
                    <li>
                      <a href="profile.php?token_id='.$token.'&pid='.$encode_user_id.'&bk='.$backlink.'">
                        <span class="badge bg-red pull-right">50%</span>
                        <span>Settings</span>
                      </a>
                    </li>
                    <li><a href="javascript:;">Help</a></li>
                    <li><a href="logout.php?condition='.$COMPANY_ID.'&bk='.$backlink.'"><i class="fa fa-sign-out pull-right"></i> Log Out</a></li>
                  </ul>
                </li>';
	}
	
	public function view_userprofile_customer($userid,$FULL_NAME,$image,$COMPANY_ID,$backlink){
		global $cartCore;
		$encode_user_id=$cartCore->md5_base64_encode($userid);
		$COMPANY_ID=$cartCore->md5_base64_encode($COMPANY_ID);
		
		echo ' <li class="">
                  <a href="javascript:;" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                    <img src="data:image/png;base64,'.$image.'" alt="">'.$FULL_NAME.'
                    <span class=" fa fa-angle-down"></span>
                  </a>
                  <ul class="dropdown-menu dropdown-usermenu pull-right"> 
                    <li><a href="javascript:;">Help</a></li>
                    
                  </ul>
                </li>';
	}
	
	public function display_sucess_msg($msg){
		echo '<div class="alert alert-success alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Perfect! </strong>'.$msg.'
                  </div>';
	}
	public function display_warning_msg($msg){
		echo '<div class="alert alert-warning alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                   <strong>Warning! </strong>'.$msg.'
                  </div>';
	}
	
	function processPayPal($TOTAL,$ORDER_ID){


	global $bsiCore;

	echo "<script language=\"JavaScript\">";

	echo "document.write('<form action=\"paypal.php\" method=\"post\" name=\"formpaypal\">');";

	echo "document.write('<input type=\"hidden\" name=\"amount\"  value=\"".$TOTAL."\">');";

	echo "document.write('<input type=\"hidden\" name=\"invoice\"  value=\"".$ORDER_ID."\">');";
	
	echo "document.write('<input type=\"hidden\" name=\"item_number\"  value=\"".$ORDER_ID."\">');";

	echo "document.write('</form>');";

	echo "setTimeout(\"document.formpaypal.submit()\",500);";

	echo "</script>";	

}


}