<?php

error_reporting(0);
ini_set('display_errors', 0);

include 'include/config.php';
// $status = $_GET['msg'];
if(!isset($_SESSION['CMSadmin']))
{
  header("Location: index.php");
}

$Admin = $_SESSION['CMSadmin'];
//`adminid`, `adminname`, `username`, `password`SELECT * FROM `admin` WHERE 1
 		$SESS_Admin = mysqli_query($connect,"SELECT * from admin where adminid ='$Admin'") or die(mysqli_error());
        while($FETCH_session_Admin = mysqli_fetch_array($SESS_Admin)) {
		$Admin_admin_id = $FETCH_session_Admin['adminid'];
		$Admin_adminUsername = $FETCH_session_Admin['username'];
		$Admin_adminPassword = $FETCH_session_Admin['password'];


      }
	  
	//   $reg_id = $_GET['reg_id'];
	//   $reg_name = $_GET['reg_name'];

	//   $USER = mysqli_query($connect,"SELECT * from reg_user where reg_id ='$reg_id'") or die(mysqli_error());
	//   while($fetch_user = mysqli_fetch_array($USER)) {
	//   $user_reg_id = $fetch_user['reg_id'];
	//   $user_reg_name = $fetch_user['reg_name'];
	//   }


	  $site_title = "Nesackkarangal";
/*************************************
      GET PAGENAME
*************************************/
function curPageName() {
 return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

$currentpage = curPageName();

$randno = md5(time());


//current page
if($currentpage == 'home.php')
{
	$home = 'active open';
	$activeid1= '<span class="selected"></span>';
}

//current page
if($currentpage == 'reg_users.php')
{
	$reg_users = 'active open';
	$reg_users1 = '<span class="selected"></span>';
}


// organic_menu
	else if($currentpage == 'organic_menu.php') {
	$organic_menu = ' active open';
	$buyer_menu_arrow_open = ' open';
	$buyer_menu_display = ' style="display: block;"';
}

// sub_menu

	else if($currentpage == 'sub_menu.php') {
	$sub_menu = ' active open';
	$buyer_menu_arrow_open = ' open';
	$buyer_menu_display = ' style="display: block;"';
}

// productlist
	else if($currentpage == 'productlist.php' || $currentpage == 'productAdd.php' || $currentpage == 'productEdit.php' || $currentpage == 'product_image.php') {
	$productlist = ' active open';
	$productlist_arrow_open = ' open';
	$productlist_display = ' style="display: block;"';
}

// setting
	else if($currentpage == 'setting.php') {
	$setting = ' active open';
}


// ordered_customer
	else if($currentpage == 'ordered_customer.php') {
	$ordered_customer = ' active open';
}



// pincode
	else if($currentpage == 'pincode_price.php') {
	$pincode_price = ' active open';
}


//========================================== website settings =====================================================//

// ********************* About Us ****************** //

	else if($currentpage == 'add_aboutus.php') {

	$add_aboutus = ' active open';

	$add_aboutus_arrow_open = ' open';

	$add_aboutus_display = ' style="display: block;"';

}


// ********************* Terms ****************** //

	else if($currentpage == 'add_terms.php') {

	$add_terms = ' active open';

	$add_terms_arrow_open = ' open';

	$add_terms_display = ' style="display: block;"';

}


// ********************* Privacy Policy ****************** //

	else if($currentpage == 'add_privacy.php') {

	$add_privacy = ' active open';

	$add_privacy_arrow_open = ' open';

	$add_privacy_display = ' style="display: block;"';

}


// ********************* Add Contact ****************** //

	else if($currentpage == 'contact_add.php') {

	$add_contact = ' active open';

	$add_contact_arrow_open = ' open';

	$add_contact_display = ' style="display: block;"';

}


// ********************* Social Media ****************** //

	else if($currentpage == 'socialmedia.php') {

	$socialmedia = ' active open';

	$socialmedia_arrow_open = ' open';

	$socialmedia_display = ' style="display: block;"';

}


// ********************* Add Blog ****************** //

	else if($currentpage == 'add_blog.php') {

	$add_blog = ' active open';

	$add_blog_arrow_open = ' open';

	$add_blog_display = ' style="display: block;"';

}

//**************** Slider**********************//

else if($currentpage == 'slider.php') {

	$add_slider = ' active open';

	$add_slider_arrow_open = ' open';

	$add_slider_display = ' style="display: block;"';

}

// // reg user `reg_id`, `reg_name`, `reg_mailid`, `reg_pin`, `reg_newpin`, `reg_phone`SELECT * FROM `reg_user` WHERE 1
function regusersDB($reg_id)
{
	 global $connect;
	$get_buyer = mysqli_query($connect,"SELECT * FROM `reg_user` where reg_id = '$reg_id'") or die(mysqli_error());
	while($get_buyer_menu = mysqli_fetch_array($get_buyer)) 
	{
	                return $get_buyer_menu['reg_phone'];                        
	}
}

function usersDB($user_id)
{
	 global $connect;
	$get_user = mysqli_query($connect,"SELECT * FROM `users` where userid = '$user_id'") or die(mysqli_error());
	while($get_user_menu = mysqli_fetch_array($get_user)) 
	{
	                return $get_user_menu['username'];                        
	}
}


function numberTowords($number)

{ 

	   $no = round($number);

   $point = round($number - $no, 2) * 100;

   $hundred = null;

   $digits_1 = strlen($no);

   $i = 0;

   $str = array();

   $words = array('0' => '', '1' => 'one', '2' => 'two',

    '3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six',

    '7' => 'seven', '8' => 'eight', '9' => 'nine',

    '10' => 'ten', '11' => 'eleven', '12' => 'twelve',

    '13' => 'thirteen', '14' => 'fourteen',

    '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',

    '18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',

    '30' => 'thirty', '40' => 'forty', '50' => 'fifty',

    '60' => 'sixty', '70' => 'seventy',

    '80' => 'eighty', '90' => 'ninety');

   $digits = array('', 'hundred', 'thousand', 'lakh', 'crore');

   while ($i < $digits_1) {

     $divider = ($i == 2) ? 10 : 100;

     $number = floor($no % $divider);

     $no = floor($no / $divider);

     $i += ($divider == 10) ? 1 : 2;

     if ($number) {

        $plural = (($counter = count($str)) && $number > 9) ? 's' : null;

        $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;

        $str [] = ($number < 21) ? $words[$number] .

            " " . $digits[$counter] . $plural . " " . $hundred

            :

            $words[floor($number / 10) * 10]

            . " " . $words[$number % 10] . " "

            . $digits[$counter] . $plural . " " . $hundred;

     } else $str[] = null;

  }

  $str = array_reverse($str);

  $result = implode('', $str);

  $points = ($point) ?

    "." . $words[$point / 10] . " " . 

          $words[$point = $point % 10] : '';





          return $result;

} 






// function userNameDB($username)
// {
//     global $connect;
//     $get_customer = mysqli_query($connect, "SELECT * from users where userid = '$username'") or die(mysqli_error());
//     while ($fetch_customer = mysqli_fetch_array($get_customer))
//     {
//         return $fetch_customer['username'];
//     }
// }






?>