public function executeDeleteByEmployee() { $class_agenda = ClassAgendaPeer::retrieveByPK($this->getRequestParameter('agenda_id')); $this->forward404Unless($class_agenda); $employee_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo'); $employee = EmployeePeer::retrieveByPK($employee_id); $this->forward404Unless($employee); $this->employee = $employee; $student_absence = StudentAbsencePeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($student_absence); $ref_error = 0; foreach ($student_absence->getRefCountMethods() as $ref) { $method = "count" . $ref['affix']; $count = $student_absence->{$method}(); if ($count > 0) { ++$ref_error; $this->getRequest()->setError('leave/deleteByEmployee/' . sfInflector::camelize($ref['table']), $count); } } if ($ref_error > 0) { $this->getRequest()->setError('leave/deleteByEmployee', '_ERR_DELETE_ (' . $student_absence->toString() . ' - id:' . $student_absence->getId() . ')'); } else { $student_absence->delete(); } return $this->redirect('leave/listByEmployee?agenda_id=' . $class_agenda->getId()); }
public function executeDelete() { $student_absence = StudentAbsencePeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($student_absence); $student_id = $student_absence->getStudentId(); $ref_error = 0; foreach ($student_absence->getRefCountMethods() as $ref) { $method = "count" . $ref['affix']; $count = $student_absence->{$method}(); if ($count > 0) { ++$ref_error; $this->getRequest()->setError('student_absence/delete/' . sfInflector::camelize($ref['table']), $count); } } if ($ref_error > 0) { $this->getRequest()->setError('student_absence/delete', '_ERR_DELETE_ (' . $student_absence->toString() . ' - id:' . $student_absence->getId() . ')'); } else { $student_absence->delete(); } return $this->redirect('student_absence/list?student_id=' . $student_id); }