<?php
include('db_connection.php');
$Mainclass=new DB_Controller();
$condition=" Order_Code='".$_COOKIE['O_Code']."'";
$Get_Dealer_State=$Mainclass->Fetch_individual_data('dealer_master','State',$condition);
if($_REQUEST['Order']!='')
{
$Get_Member_Other_Details=$Mainclass->Fetch_individual_data('order_address_master_gold',"*","Order_No='".$_REQUEST['Order']."'");
	
	
	$Check_Member=$Mainclass->num_check("member_master","SLN","Phone='".$Get_Member_Other_Details['Contact']."' and Active='Yes'");
	if($Check_Member>0)
	{
		$Member_Status='1';
	}
	else
	{
		$Member_Status='0';
	}
	
	
	
$Salutation=$Get_Member_Other_Details['Salutation'];
$Name=$Get_Member_Other_Details['Customer_Name'];
$Exp=explode(" ",$Name);
if(sizeof($Exp)>2)
{
	$FName=$Exp[0];
	$LName=$Exp[1]." ".$Exp[2];
}
else
{
$FName=$Exp[0];
$LName=$Exp[1];
}
$Phone=$Get_Member_Other_Details['Contact'];
$Email=$Get_Member_Other_Details['Email'];
$Mem_SLN=$Get_Member_Other_Details['SLN'];
$city=$Get_Member_Other_Details['City'];
$pin=$Get_Member_Other_Details['Pin'];
$state=$Get_Member_Other_Details['State'];
//$country=$Get_Member_Other_Details['Country'];
$country="India";
$add1=$Get_Member_Other_Details['Address_Line1'];
$add2=$Get_Member_Other_Details['Address_Line2'];
	
if($Get_Member_Other_Details['DOB']!='1970-01-01' && $Get_Member_Other_Details['DOB']!='0000-00-00')
  {
  $dob=date('d-m-Y',strtotime($Get_Member_Other_Details['DOB']));
  }
$DOB_Type=$Get_Member_Other_Details['DOB_Type'];
$DOB_Age=$Get_Member_Other_Details['Age'];
	
	

if($Get_Member_Other_Details['Anniversary_Date']!='1970-01-01' && $Get_Member_Other_Details['Anniversary_Date']!='0000-00-00')
{
$aniversary=date('d-m-Y',strtotime($Get_Member_Other_Details['Anniversary_Date']));
}
//============================================//
$pur_reason=$Get_Member_Other_Details['Purchase_Reason'];
$Hear=$Get_Member_Other_Details['Hear_About'];
$promotion=$Get_Member_Other_Details['Promotion'];
//$Order_Id=$Get_Order_Id['Order_No'];
//if($Get_Member_Other_Details['Member']==1)
	if($Member_Status==1)
{
$Member="Member";
}
else
{
$Member="Non Member";
}
$Member_type=$Member_Status;
$Ethini=$Get_Member_Other_Details['Ethinicity'];
if($Get_Member_Other_Details['Gender']=='')
{
	if(strtoupper($Get_Member_Other_Details['Salutation'])=='MRS.' || strtoupper($Get_Member_Other_Details['Salutation'])=='MS' || strtoupper($Get_Member_Other_Details['Salutation'])=='MS.' || strtoupper($Get_Member_Other_Details['Salutation'])=='MRS' || strtoupper($Get_Member_Other_Details['Salutation'])=='M/S.' || strtoupper($Get_Member_Other_Details['Salutation'])=='MISS.')
	{
		$gender="Female";
	}
	else if(strtoupper($Get_Member_Other_Details['Salutation'])=='MR.' || strtoupper($Get_Member_Other_Details['Salutation'])=='MR')
	{
		$gender="Male";
	}
}
else
{
	$gender=$Get_Member_Other_Details['Gender'];
}
if($Get_Member_Other_Details['Marital_Status']=='')
{
	if($Get_Member_Other_Details['Anniversary_Date']!='1970-01-01' && $Get_Member_Other_Details['Anniversary_Date']!='0000-00-00')
	{
	$marital="Married";
	}
	else
	{
		$marital="Single";
	}
}
else
{
	$marital=$Get_Member_Other_Details['Marital_Status'];
}
$Building=$Get_Member_Other_Details['Building_No'];
$Street=$Get_Member_Other_Details['Street_Name'];
$Customer_Gst=$Get_Member_Other_Details['Customer_Gst'];
$Error="0";
$Membership_Number=$Get_Member_Other_Details['Member_Id'];
$Bill_Date=date('d-m-Y',strtotime($Get_Member_Other_Details['Order_Date']));
	if($Get_Member_Other_Details['Member']=='1' && $Get_Member_Other_Details['Member_Id']!='')
	{
	$Membership_Status='Membership Active';
	}
	else
	{
		$Membership_Status='Membership Expired';
	}
}
else if($_REQUEST['memid']!='')
{
   $Check=$Mainclass->num_check("member_master","SLN","Member_Id='".$_REQUEST['memid']."' or Phone='".$_REQUEST['memid']."'");
   if($Check>0)
   {
     $Get_Details=$Mainclass->Fetch_individual_data('member_master',"*","Member_Id='".$_REQUEST['memid']."' or Phone='".$_REQUEST['memid']."'");
   }
   else{
     $Get_Details=$Mainclass->Fetch_individual_data('inactive_member_master',"*","Member_Id='".$_REQUEST['memid']."' or Phone='".$_REQUEST['memid']."'");
   }
   //$Get_Details=$Mainclass->member_det('member_master',$_REQUEST['memid']);
   $Salutation=$Get_Details['Salutation'];
$Name=$Get_Details['Name'];
$Exp=explode(" ",$Name);
if(sizeof($Exp)>2)
{
	$FName=$Exp[0];
	$LName=$Exp[1]." ".$Exp[2];
}
else
{
$FName=$Exp[0];
$LName=$Exp[1];
}
if($Get_Details['Phone']!='')
{
$Phone=$Get_Details['Phone'];
}
else
{
$Phone=$_REQUEST['memid'];
}
$Email=$Get_Details['Email'];
$Mem_SLN=$Get_Details['SLN'];
$city=$Get_Details['City'];
$pin=$Get_Details['Pin'];
if($Get_Details['State']!='')
{
$state=$Get_Details['State'];
}
else
{
$state=$Get_Dealer_State['State'];	
}
//$country=$Get_Details['Country'];
$country="India";
$add1=$Get_Details['Address_Line1'];
$add2=$Get_Details['Address_Line2'];
if($Get_Details['DOB']!='1970-01-01' && $Get_Details['DOB']!='0000-00-00')
{
$dob=date('d-m-Y',strtotime($Get_Details['DOB']));
}
	$DOB_Type="";
$DOB_Age=$Get_Details['Age'];
if($Get_Details['Anniversary_Date']!='1970-01-01' && $Get_Details['Anniversary_Date']!='0000-00-00')
{
$aniversary=date('d-m-Y',strtotime($Get_Details['Anniversary_Date']));
}
//============================================//
$pur_reason=$Get_Details['Purchase_Reason'];
$Hear=$Get_Details['Hear_About'];
$promotion=$Get_Details['Promotion'];
//$Order_Id=$Get_Order_Id['Order_No'];
if($Get_Details['Member']==1)
{
$Member="Member";
}
else
{
$Member="Non Member";
}
$Member_type=$Get_Details['Member'];
$Ethini=$Get_Details['Ethinicity'];
//$gender=$Get_Details['Gender'];
if($Get_Details['Gender']=='')
{
	if(strtoupper($Get_Details['Salutation'])=='MRS.' || strtoupper($Get_Details['Salutation'])=='MS' || strtoupper($Get_Details['Salutation'])=='MS.' || strtoupper($Get_Details['Salutation'])=='MRS' || strtoupper($Get_Details['Salutation'])=='M/S.' || strtoupper($Get_Details['Salutation'])=='MISS.')
	{
		$gender="Female";
	}
	else if(strtoupper($Get_Details['Salutation'])=='MR.' || strtoupper($Get_Details['Salutation'])=='MR')
	{
		$gender="Male";
	}
}
else
{
	$gender=$Get_Details['Gender'];
}
//$marital=$Get_Details['Marital_Status'];
if($Get_Details['Marital_Status']=='')
{
	if($Get_Details['Anniversary_Date']!='1970-01-01' && $Get_Details['Anniversary_Date']!='0000-00-00')
	{
	$marital="Married";
	}
	else
	{
		$marital="Single";
	}
}
else
{
	$marital=$Get_Details['Marital_Status'];
}
$Building=$Get_Details['Building_No'];
$Street=$Get_Details['Street_Name'];
$Customer_Gst=$Get_Details['Customer_Gst'];
$Error="0";
$Membership_Number=$Get_Details['Member_Id'];
	if($Get_Details['Active']=='Yes')
	{
		$Membership_Status='Membership Active';
	}
	else
	{
		$Membership_Status='Membership Expired';
	}
}

//$Membership_Number=$Mainclass->get_membership_no($Phone);

echo $FName."*".$Phone."*".$Email."*".$Error."*".$Mem_SLN."*".$city."*".$pin."*".$state."*".$country."*".$add1."*".$add2."*".$dob."*".$aniversary."*".$pur_reason."*".$Hear."*".$promotion."*".$Member."*".$Member_type."*".$Ethini."*".$gender."*".$marital."*".$Membership_Number."*".$Salutation."*".$Building."*".$Street."*".$Customer_Gst."*".$LName."*".$Bill_Date."*".$Membership_Status."*".$DOB_Type."*".$DOB_Age;
?>