<?php
session_start();
// ==================			  
include("../php_crud/my_class.php");
$obj = new my_class();	
// ==================	

$group_id =  trim($_POST["group_id"]);
	if($group_id =='11'){
		
		$username = trim($_POST["username"]);
		$password = md5(trim($_POST["password"]));
		
		$table_name='_pf_emp_personal_info';
		 $where_cond = "_uniq_id='$username' AND _pass_word='$password' AND _status='A'";
		$val=$obj->Login_Check($table_name,$where_cond);
	
		 $flag  = $val['_uniq_id'];
		 
		if($flag!=0) {
            $_SESSION["valid"]="true";			
			$_SESSION["LOGIN_USER"] = $val['_full_name'];//$username;
			$_SESSION["_image_location"] = isset($val['_image_location']) ? $val['_image_location'] : '';//$username;
			$_SESSION["_full_name"] = isset($val['_full_name']) ? $val['_full_name'] : ''; 
			$_SESSION["LOGIN_USERID"] = $val['_uniq_id'];
			$_SESSION["LOGIN_EMPLOYEEID"] = $val['_uniq_id'];
			$_SESSION["LOGIN_USERGRP"] = $val['_group_id'];
			$_SESSION["LOGIN_BRANCHES"] = $val['_branch_id'];
			$_SESSION["LOGIN_IP"] = $_SERVER["REMOTE_ADDR"];
			$_SESSION["powred"] = 'leotechbd.com';
			$_SESSION["login_status"] = $val['_login_status'];
			$_SESSION["user_expire_date"] = $val['_user_expire_date'];

		 	$_SESSION["BASE_URL"] ='.';

			
			$_SESSION["LOGIN_TIME"] = date("Y-m-d H:i:s");
			$_SESSION["LOGIN_DATE"] = date("Y-m-d");
			if($_SESSION["LOGIN_DATE"] == $_SESSION["user_expire_date"]){
				echo 'ex';
			}
			else{
			
			echo $_SESSION["login_status"];
			}
		}else{
			echo 0;
		} 
		
	}




else{

		  
		$username = trim($_POST["username"]);
		$password = md5(trim($_POST["password"]));
			  
	
		$table_name='ST_USER_INFO';
		$where_cond = "USER_LOGIN_ID='$username' AND USER_PASSWORD='$password' AND ACTIVE_FLAG='Y'";
		
//	echo 'SELECT * FROM '.$table_name.' WHERE'.$where_cond;
	
		$val=$obj->Login_Check($table_name,$where_cond);
	
		 $flag  = $val['user_id'];
		 
		if($flag!=0) {
            $_SESSION["valid"]="true";			
			$_SESSION["LOGIN_USER"] = $val['USER_FULL_NAME'];//$username;
			$_SESSION["_image_location"] = isset($val['IMAGE_LOCATION']) ? $val['IMAGE_LOCATION'] : '';//$username;
			$_SESSION["_full_name"] = isset($val['USER_FULL_NAME']) ? $val['USER_FULL_NAME'] : ''; // From pf_address_info
			$_SESSION["LOGIN_USERID"] = $val['USER_ID'];
			$_SESSION["LOGIN_EMPLOYEEID"] = $val['PID'];
			$_SESSION["LOGIN_USERGRP"] = $val['USER_GROUP_ID'];
			$_SESSION["LOGIN_INSTITUTE"] = $val['INSTITUTE_ID'];
			$_SESSION["LOGIN_BRANCHES"] = $val['BRANCH'];
			$_SESSION["LOGIN_IP"] = $_SERVER["REMOTE_ADDR"];
			$_SESSION["powred"] = 'leotechbd.com';

		 	//$_SESSION["BASE_URL"] ='http://202.161.188.108/school/schoobee/dev/development/app';
                        $_SESSION["BASE_URL"] ='.';

			//$_SESSION["BASE_URL"] ='http://localhost:8088/schoobee'; 
			//$_SESSION["BASE_URL"] ='http://192.162.0.100:8088/schoobee'; 
			
			$_SESSION["LOGIN_TIME"] = date("Y-m-d H:i:s");
			
			echo 1;
		}else{
			echo 0;
		} 
		
}
?>
