<?
ob_clean();
include("../../startup.php"); 
###########################################  	END  FILTER CONITIONS 	#####################################

$header = "client_id,description,created_by,date\n";

$data  = $header;
//$sql = "SELECT * FROM notes $where ORDER BY note_date DESC";
$sql = "SELECT id,job_id,job_user_id,admin_id,note_date,note_text FROM notes $where ORDER BY note_date DESC";

$rs = mysqli_query($conn,$sql);
while($row = mysqli_fetch_assoc($rs)){
	
	if(isset($row['job_user_id']) && $row['job_user_id'] != 0){
		$created_by = $gsi->getJobUserById($row['admin_id']); 
	}else{
		$created_by = Admin::getAdminsById($row['admin_id']); 
	}
	$note_date = ($row['note_date'] != "0000-00-00 00:00:00") ? date("d-m-Y",strtotime($row['note_date'])) : "";
	
	$data .= '"'.$row['job_id'].'"'.",".'"'.$row['note_text'].'"'.",".'"'.$created_by.'"'.",".'"'.$note_date.'"'."\n";
}

$file_name = "note_details_export.csv";
ob_clean();
echo $data;
header("Content-type: application/csv"); 
header("Content-Disposition: attachment; filename=$file_name");
header("Pragma: no-cache");
header("Expires: 0");
die;
?>