Example #1
0
 public function executeDownloableDocument(sfWebRequest $request)
 {
     $student_attendance_justification = StudentAttendanceJustificationPeer::retrieveByPK($request->getParameter('id'));
     if ($student_attendance_justification && $student_attendance_justification->getDocument()) {
         $filePath = $student_attendance_justification->getDocumentFullPath();
         $response = $this->getResponse();
         $response->setHttpHeader('Pragma', '');
         $response->setHttpHeader('Cache-Control', '');
         $data = file_get_contents($filePath);
         $file_exploded = explode('.', $student_attendance_justification->getDocument());
         $file_extension = end($file_exploded);
         if ($file_extension == 'pdf') {
             $response->setHttpHeader('Content-Type', 'application/pdf');
         } else {
             if ($file_extension == 'jpg') {
                 $content_type = 'jpeg';
             } else {
                 $content_type = $file_extension;
             }
             $response->setHttpHeader('Content-Type', 'image/' . $content_type);
         }
         $response->setHttpHeader('Content-Disposition', "attachment; filename=\"" . $student_attendance_justification->getDocument() . "\"");
         $response->setContent($data);
     }
     return sfView::NONE;
 }
Example #2
0
 public function executeShow(sfWebRequest $request)
 {
     $this->student_attendance_justification = StudentAttendanceJustificationPeer::retrieveByPK($request->getParameter('id'));
 }
Example #3
0
 public function deleteStudentAttendances()
 {
     $student_attendances = array();
     foreach (StudentAttendancePeer::retrieveBySubject($this) as $student_attendance) {
         StudentAttendanceJustificationPeer::doDelete($student_attendance->getStudentAttendanceJustificationId());
         $student_attendance->delete();
     }
 }