<?php require_once('../Connections/oprmConn.php'); include('check-admin-session.php');
mysql_select_db($database_oprmConn, $oprmConn);
$query_MembersList = "select * FROM weby_timesheets ORDER BY project_id ASC";
$MembersList = mysql_query($query_MembersList, $oprmConn) or die(mysql_error());
$row_MembersList = mysql_fetch_assoc($MembersList);
$totalRows_MembersList = mysql_num_rows($MembersList);

Header("Content-Disposition: attachment; filename=timesheet.csv");
?>User #,Name,Project Name,Task Hours,Task Details,Date,Status<?php do { ?>

<?php echo $row_MembersList['user_id']; ?>,<?php mysql_select_db($database_oprmConn, $oprmConn);
$query_getUsree = "select weby_profiles.full_name FROM weby_profiles where weby_profiles.user_id = '$row_MembersList[user_id]' and weby_profiles.status = 'A'";
$getUsree = mysql_query($query_getUsree, $oprmConn) or die(mysql_error());
$row_getUsree = mysql_fetch_assoc($getUsree);
$totalRows_getUsree = mysql_num_rows($getUsree);
echo $row_getUsree['full_name']; ?>,<?php 
mysql_select_db($database_oprmConn, $oprmConn);
$query_getPid = "select weby_projects.project_name FROM weby_projects where weby_projects.projetc_id = '$row_MembersList[project_id]'";
$getPid = mysql_query($query_getPid, $oprmConn) or die(mysql_error());
$row_getPid = mysql_fetch_assoc($getPid);
$totalRows_getPid = mysql_num_rows($getPid);
echo $row_getPid['project_name']; ?>,<?php echo $row_MembersList['total_hrs']; ?>,<?php echo $row_MembersList['taks_details']; ?>,<?php	echo  date("d-m-Y",strtotime($row_MembersList['created_date'])); ?>,<?php	
mysql_select_db($database_oprmConn, $oprmConn);
$query_getSts = "select * FROM weby_timesheetstatus where weby_timesheetstatus.status = 'A' and weby_timesheetstatus.status_key = '$row_MembersList[status]'";
$getSts = mysql_query($query_getSts, $oprmConn) or die(mysql_error());
$row_getSts = mysql_fetch_assoc($getSts);
$totalRows_getSts = mysql_num_rows($getSts);
echo $row_getSts['status_label']; ?>
		<?php } while ($row_MembersList = mysql_fetch_assoc($MembersList)); ?>

<?php
mysql_free_result($MembersList);
?>
