Esempio n. 1
0
 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());
 }
Esempio n. 2
0
 public function getClassAgenda($con = null)
 {
     include_once 'lib/model/om/BaseClassAgendaPeer.php';
     if ($this->aClassAgenda === null && $this->class_agenda_id !== null) {
         $this->aClassAgenda = ClassAgendaPeer::retrieveByPK($this->class_agenda_id, $con);
     }
     return $this->aClassAgenda;
 }