public function save($con = null) { $con = is_null($con) ? Propel::getConnection() : $con; parent::save($con); $values = $this->getValues(); $justification_type_id = $values['justification_type_id']; $observation = $values['observation']; $document = $values['document']; unset($values['justification_type_id'], $values['observation'], $values['document'], $values['id']); $con->beginTransaction(); try { foreach ($values as $value) { $student_attendance = StudentAttendancePeer::retrieveByPK($value); $student_attendance->setStudentAttendanceJustification($this->getObject()); #$student_attendance->updateAbsence($con); no va mas $student_attendance->save($con); } $con->commit(); } catch (PropelException $e) { throw $e; $con->rollBack(); } }
public function executeJustificate(sfWebRequest $request) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('I18N')); $id = $request->getParameter('id'); if ($id != '') { $this->student_attendance = StudentAttendancePeer::retrieveByPK($request->getParameter('id')); $this->student_attendances = array($this->student_attendance->getId()); $this->student_attendance_justification = $this->student_attendance->getStudentAttendanceJustificationOrCreate(); } else { $this->student_attendance_justification = new StudentAttendanceJustification(); $this->student_attendances = $request->getParameter('ids'); } if (StudentAttendancePeer::areAllFromSameStudent($this->student_attendances)) { $this->form = new StudentAttendanceJustificationForm($this->student_attendance_justification); $this->form->setStudentAttendances($this->student_attendances); } else { $this->getUser()->setFlash('error', __('Cant do multiple justification with diferent students')); $this->forward('attendance_justification', 'index'); } }