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

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

$data  = $header;
$sql = "SELECT * FROM notes $where ORDER BY note_date DESC";

$rs = mysql_query($sql);
while($row = mysql_fetch_assoc($rs)){
	
	if(isset($row['job_user_id']) && $row['job_user_id'] != 0){
		$created_by = $afcl->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;
?>