<?php
#####Class For Adding Content Management ######
class Login extends MysqlFns
{
 /* class constructor */
	function astrology()
	{
 		$this->LDDisplayPath= $config['SiteGlobalPath']."class.Login.php";
  		global $config;
  		global $objSmarty;
  		$this->MysqlFns();
  		$this->Limit = 20;

	}


	
//*************************************************************************************************************************************************
	function CheckMember()
	{
  		global $objSmarty;
		 echo $SelQuery = "SELECT * FROM members WHERE `contact_number` = '" . ($_POST["mobileNo"]) . "' AND `password` = '" . ($_POST["password"]) . "'"; exit;
		$LoginMemberList		= $this->ExecuteQuery($SelQuery, 'select');
		
 // $objSmarty->assign('LoginMemberList', $LoginMemberList);//print_r($BranchList);
  if(!empty($LoginMemberList)) {
  
  header('Location:profile.php');
  //$objSmarty->assign('SelResult', $SelResult);
  //return true;
  }else{
  
  $objSmarty->assign('ErrorMessage', "Invalid Mobile Number or Password !");
   return false;
  
  }
  
  	$SelQuery4		= 'SELECT * FROM `branches` WHERE `w_status` = "0" AND b_status="1" AND status="0" AND is_deleted="0" ORDER BY name ASC';
		$PageList3		= $this->ExecuteQuery($SelQuery4, 'select');
		
  $objSmarty->assign('PageList3', $PageList3);//print_r($PageList3);
  return $PageList3;
 
 }
 function AjaxCheckLogin()
	{
  		global $objSmarty;
		  $SelQuery = "SELECT COUNT(*) AS CNT FROM members WHERE `contact_number` = '" . ($_POST["mobileNo"]) . "' AND `password` = '" . ($_POST["password"]) . "'"; 
		$LoginMember		= $this->ExecuteQuery($SelQuery, 'select');
		
 // $objSmarty->assign('LoginMemberList', $LoginMemberList);//print_r($BranchList);
  echo $LoginMember[0]['CNT'];
 
 
 }
/**********************************************************************************************/
	function GetSubscriptionPlan()
	{
  		global $objSmarty;
  		$SelQuery		= 'SELECT DISTINCT subscription_plan_name,sl_no FROM `subscription_plan_master` WHERE `status` = "1" AND subscription_plan_name!="Registration" AND subscription_plan_name!="Platinum Membership" GROUP BY subscription_plan_name ORDER BY subscription_plan_name ASC';
		$SubPlanList		= $this->ExecuteQuery($SelQuery, 'select');
		
  $objSmarty->assign('SubPlanList', $SubPlanList);//print_r($SubPlanList);
 
 }
/**********************************************************************************************/
function GetMembershipPlan()
	{
  		global $objSmarty;
  		$SelQuery		= 'SELECT DISTINCT subscription_plan_name,sl_no FROM `subscription_plan_master` WHERE `status` = "1" AND subscription_plan_name="Registration" OR subscription_plan_name="Platinum Membership" GROUP BY subscription_plan_name ORDER BY subscription_plan_name ASC';
		$MemPlanList		= $this->ExecuteQuery($SelQuery, 'select');
		
  $objSmarty->assign('MemPlanList', $MemPlanList);//print_r($SubPlanList);
 
 }
 
 /*************************************************Insert Employee/***************************************************************/
function InsertMember($objArray)
{
global $objSmarty;

if((!$objArray['regName'])){
$objSmarty->assign('ErrorMessage', 'Member Name should not be blank');
return false;
}elseif(!$objArray['dob']){
$objSmarty->assign('ErrorMessage', 'Date of birth should not be blank');
return false;
}elseif(!$objArray['branchName']){
$objSmarty->assign('ErrorMessage', 'Branch Name should not be blank');
return false;
}elseif(!$objArray['pType']){
$objSmarty->assign('ErrorMessage', 'Plan Type should not be blank');
return false;
}elseif(!$objArray['pPeriod']){
$objSmarty->assign('ErrorMessage', 'Plan Period should not be blank');
return false;
}elseif(!$objArray['emailId']){
$objSmarty->assign('ErrorMessage', 'Email Id should not be blank');
return false;
}elseif(!$objArray['mobileNo']){
$objSmarty->assign('ErrorMessage', 'Mobile Number should not be blank');
return false;
}elseif(!$objArray['password']){
$objSmarty->assign('ErrorMessage', 'Password should not be blank');
return false;
}elseif(!$objArray['address']){
$objSmarty->assign('ErrorMessage', 'Address should not be blank');
return false;
}elseif(!$objArray['pincode']){
$objSmarty->assign('ErrorMessage', 'Pincode should not be blank');
return false;
}

if($objArray['pType'] == '1'){
	$memSubPlan = trim(addslashes($objArray['memPlanName']));
	$memId = $objArray['memPlanName'];
	$memIdSplit = explode("|",$memId);
	$memSubPlanId = $memIdSplit[0];
}else
{
	$memSubPlan = trim(addslashes($objArray['subPlanName']));
	$subId = $objArray['subPlanName'];
	$subIdSplit = explode("|",$subId);
	$memSubPlanId = $subIdSplit[0];
}

    $bId = $objArray['branchName'];
	$bIdSplit = explode("|",$bId);
	$branchId = $bIdSplit[0];
	
$objSmarty->assign('regName', $objArray['regName']);
if($objArray['emailId'] && $objArray['mobileNo']){
  $InsQuery = 'INSERT INTO online_registered_users
(
`name`,
`email_id`,
`dob`,
`mobile_no`,
`password`,
`branch_id`,
`plan_type`,
`mem_sub_id`,
`address`,
`pincode`,
`is_active`
) 
VALUES(
"'.trim(addslashes($objArray['regName'])).'",
"'.trim(addslashes($objArray['emailId'])).'",
"'.trim(addslashes($objArray['dob'])).'",
"'.trim(addslashes($objArray['mobileNo'])).'",
"'.trim(addslashes($objArray['password'])).'",
"'.$branchId.'",
"'.trim(addslashes($objArray['pType'])).'",
"'.$memSubPlanId.'",
"'.trim(addslashes($objArray['address'])).'",
"'.trim(addslashes($objArray['pincode'])).'",
"1")';  
$this->ExecuteQuery($InsQuery, 'insert');
}
header('Location:register.php?success_msg_for_insert');
}
/**********************************************************************************************/

 }
?>


