<?php
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=Roster_Plan_Export.csv');
include ('common/connection.php');
//date('d-m-Y',strtotime(' +1 days'));
$msg="TNA name,".date('d-m-Y',strtotime(' +1 days')).",".date('d-m-Y',strtotime(' +2 days')).",".date('d-m-Y',strtotime(' +3 days')).",".date('d-m-Y',strtotime(' +4 days')).",".date('d-m-Y',strtotime(' +5 days')).",".date('d-m-Y',strtotime(' +6 days')).",".date('d-m-Y',strtotime(' +7 days'))."\r\n";
?>
                  
              
                    <?php
						$fetch_data="select * from employee_master where Designation='TNA'";
						$fetch_query=mysqli_query($con,$fetch_data);
					while($fetch_value=mysqli_fetch_array($fetch_query))
							{
							$tna_name=$fetch_value['First_Name']." ".$fetch_value['Last_Name'];
							//echo "select * from roster_master where TNA_Name='".$fetch_value['SLN']."' and Treatment_Service_Date between '".date('Y-m-d',strtotime('now')) . "' and '" . date('Y-m-d',strtotime('+7 days'))."'";
		$fetch_roster=mysqli_fetch_array(mysqli_query($con,"select * from roster_master where TNA_Name='".$fetch_value['SLN']."' and Treatment_Service_Date='".date('Y-m-d',strtotime(' +1 day'))."'"));
					//echo date('h:i a',strtotime($fetch_roster['Duty_Hour_Start_Time']))." - ".date('h:i a',strtotime($fetch_roster['To_Time']));
					if($fetch_roster['Treatment_Service_Date']!="")
					{
					$first=date('h:i a',strtotime($fetch_roster['Duty_Hour_Start_Time']))."  ".$fetch_roster['Number_Of_Working_Hour'].hr;
					}
					else 
					{
					$first ="";
					}
					
					if($fetch_roster['Treatment_Service_Date']!="")
					{ 
					$second= date('h:i a',strtotime($fetch_roster['Duty_Hour_Start_Time']))."  ".$fetch_roster['Number_Of_Working_Hour'].hr;
					}
					else
					 {
					 $second="";
					 }
					 
					 if($fetch_roster['Treatment_Service_Date']!="")
					{ 
					$third= date('h:i a',strtotime($fetch_roster['Duty_Hour_Start_Time']))."  ".$fetch_roster['Number_Of_Working_Hour'].hr;
					}
					else
					 {
					 $third="";
					 }
					 
					  if($fetch_roster['Treatment_Service_Date']!="")
					{ 
					$fourth= date('h:i a',strtotime($fetch_roster['Duty_Hour_Start_Time']))."  ".$fetch_roster['Number_Of_Working_Hour'].hr;
					}
					else
					 {
					 $fourth="";
					 }
					 
					  if($fetch_roster['Treatment_Service_Date']!="")
					{ 
					$fifth= date('h:i a',strtotime($fetch_roster['Duty_Hour_Start_Time']))."  ".$fetch_roster['Number_Of_Working_Hour'].hr;
					}
					else
					 {
					 $fifth="";
					 }
					 
					  if($fetch_roster['Treatment_Service_Date']!="")
					{ 
					$sixth= date('h:i a',strtotime($fetch_roster['Duty_Hour_Start_Time']))."  ".$fetch_roster['Number_Of_Working_Hour'].hr;
					}
					else
					 {
					 $sixth="";
					 }
					 
					 if($fetch_roster['Treatment_Service_Date']!="")
					{ 
					$seventh= date('h:i a',strtotime($fetch_roster['Duty_Hour_Start_Time']))."  ".$fetch_roster['Number_Of_Working_Hour'].hr;
					}
					else
					 {
					 $seventh="";
					 }
		$msg=$msg.$tna_name.",".$first.",".$second.",".$third.",".$fourth.",".$fifth.",".$sixth.",".$seventh."\r\n";		
		}
		echo $msg;
					?>
					
                      