<?php
include("../db.php");
//$id = 6;
$id = $_POST['id'];
$txt = "select * from `cus` left join `member` on `member`.`id_member` = `cus`.`id_member` where `cus`.`id_cus` = '$id'";
$query = mysqli_query($db,$txt);
$row = mysqli_fetch_assoc($query);
$data['name'] = $row['name_cus'];
$data['card'] = $row['id_scanner'];
$data['v_type'] = $row['name_member'];
$data['v_mony'] = $row['mony_cus'];
$data['date'] =  $row['member_date'];
$data['type'] =$row['type_member'];
$data['date_game'] =$row['date_game'];
if($row['type_member'] == 0)
{
	$data['end'] = $row['count_s'];
}
if($row['type_member'] == 1)
{
	if($data['date_game'] == 0)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 1 days'));
	}
	if($data['date_game'] == 1)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 6 days'));
	}
	if($data['date_game'] == 2)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 29 days'));
	}
	if($data['date_game'] == 3)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 364 days'));
	}
	if($data['date_game'] == 4)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 89 days'));
	}
	if($data['date_game'] == 5)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 179 days'));
	}
	if($data['date_game'] == 6)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 269 days'));
	}
		if($data['date_game'] == 7)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 14 days'));
	}
	if($data['date_game'] == 8)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 59 days'));
	}
	if($data['date_game'] == 9)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 21 days'));
	}
	if($data['date_game'] == 10)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 45 days'));
	}
	if($data['date_game'] == 11)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 120 days'));
	}
	if($data['date_game'] == 12)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 150 days'));
	}
	if($data['date_game'] == 13)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 210 days'));
	}
	if($data['date_game'] == 14)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 240 days'));
	}
	if($data['date_game'] == 15)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 300 days'));
	}
	if($data['date_game'] == 16)
	{
		$data['end'] =  date('Y-m-d', strtotime($row['member_date'].'+ 330 days'));
	}
}
if($row['type_member'] == 2)
{
		if($data['date_game'] == 0)
	{
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']. " فى تاريح =" .date('Y-m-d', strtotime($row['member_date'].'+ 1 days'));
	}
	if($data['date_game'] == 1)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 6 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;	}
	if($data['date_game'] == 2)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 29 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;	}
	if($data['date_game'] == 3)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 364 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;	}
	if($data['date_game'] == 4)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 89 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;	}
	if($data['date_game'] == 5)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 179 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;	}
	if($data['date_game'] == 6)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 269 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;
	}
		if($data['date_game'] == 7)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 14 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;
	}
	if($data['date_game'] == 8)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 59 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;
	}

	if($data['date_game'] == 9)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 21 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;
	}
	if($data['date_game'] == 10)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 45 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;
	}
	if($data['date_game'] == 11)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 120 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;
	}
	if($data['date_game'] == 12)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 150 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;
	}
	if($data['date_game'] == 13)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 210 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;
	}
	if($data['date_game'] == 14)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 240 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;
	}
	if($data['date_game'] == 15)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 300 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;
	}
	if($data['date_game'] == 16)
	{
		$end_date = date('Y-m-d', strtotime($row['member_date'].'+ 330 days'));
		$data['end'] =  "عدد الحصص المتبقة =".$row['count_s']." فى تاريح =" .$end_date;
	}
}
echo json_encode($data);
?>