escape($db -> cipher($decoded,false)); $report_info = $db -> return_result("SELECT r.is_downloadable, ( IF( (SELECT DATEDIFF(r.expire,NOW()) < 0),'3', IF( (SELECT count(id) FROM `report_status` WHERE report_id = r.id AND `status` = 2) = 0 , IF( (SELECT count(id) FROM `report_status` WHERE report_id = r.id AND `status` = 0) = 0 , '1', '0' ), '2' ) ) ) as status FROM `report` r INNER JOIN report_type rt ON r.report_type_id = rt.id WHERE r.control_number = '".$decoded."' "); foreach($report_info as $report_info_data){ $check_report = $report_info_data['status']; $is_downloadable = $report_info_data['is_downloadable']; } if(! $utility_class->isNotEmpty($check_report) || intval($check_report) <> 1){ header('location:requested_reports.php'); return; } $dir ='reportv2/'; chmod($dir, 0777); $file_ =$dir.$file_name.'.pdf'; ?>