public function executeSave() { $i18n = new sfI18N(); $i18n->initialize($this->getContext()); $i18n->setCulture($this->getUser()->getCulture()); $action_i18n = $i18n->globalMessageFormat->format('save as new'); $action_type = $this->getRequestParameter('action_type'); if ($action_type == $action_i18n || !$this->getRequestParameter('id')) { $class_agenda = new ClassAgenda(); } else { $class_agenda = ClassAgendaPeer::retrieveByPk($this->getRequestParameter('id')); #$this->forward404Unless($class_agenda); } $class_agenda->setId($this->getRequestParameter('id')); $class_agenda->setCourseScheduleId($this->getRequestParameter('course_schedule_id')); $class_agenda->setDetail($this->getRequestParameter('detail')); if ($this->getRequestParameter('date')) { $class_agenda->setDate($this->getRequestParameter('date')); } $class_agenda->setStatus($this->getRequestParameter('status')); $class_agenda->setSubjectGradingId($this->getRequestParameter('subject_grading_id')); $class_agenda->setMeetingPoint($this->getRequestParameter('meeting_point')); $class_agenda->setActionType($this->getRequestParameter('action_type')); $class_agenda->setDay($this->getRequestParameter('day')); $class_agenda->save(); if ($this->hasRequestParameter('file') && $this->getRequestParameter('file') != '' && $this->getRequestParameter('file') != null) { $fileName = $this->getRequestParameter('file'); $ca_file = new ClassAgendaFile(); $ca_file->setClassAgenda($class_agenda); $ca_file->setFile($fileName); $ca_file->save(); } if ($this->hasRequestParameter('file_1') && $this->getRequestParameter('file_1') != '' && $this->getRequestParameter('file_1') != null) { $fileName = $this->getRequestParameter('file_1'); $ca_file = new ClassAgendaFile(); $ca_file->setClassAgenda($class_agenda); $ca_file->setFile($fileName); $ca_file->save(); } if ($this->hasRequestParameter('file_2') && $this->getRequestParameter('file_2') != '' && $this->getRequestParameter('file_2') != null) { $fileName = $this->getRequestParameter('file_2'); $ca_file = new ClassAgendaFile(); $ca_file->setClassAgenda($class_agenda); $ca_file->setFile($fileName); $ca_file->save(); } if ($this->hasRequestParameter('file_3') && $this->getRequestParameter('file_3') != '' && $this->getRequestParameter('file_3') != null) { $fileName = $this->getRequestParameter('file_3'); $ca_file = new ClassAgendaFile(); $ca_file->setClassAgenda($class_agenda); $ca_file->setFile($fileName); $ca_file->save(); } if ($this->hasRequestParameter('file_4') && $this->getRequestParameter('file_4') != '' && $this->getRequestParameter('file_4') != null) { $fileName = $this->getRequestParameter('file_4'); $ca_file = new ClassAgendaFile(); $ca_file->setClassAgenda($class_agenda); $ca_file->setFile($fileName); $ca_file->save(); } if ($this->hasRequestParameter('file_5') && $this->getRequestParameter('file_5') != '' && $this->getRequestParameter('file_5') != null) { $fileName = $this->getRequestParameter('file_5'); $ca_file = new ClassAgendaFile(); $ca_file->setClassAgenda($class_agenda); $ca_file->setFile($fileName); $ca_file->save(); } return $this->redirect('class_agenda/list?id=' . $this->getRequestParameter('course_schedule_id')); }
public function addClassAgendaFile(ClassAgendaFile $l) { $this->collClassAgendaFiles[] = $l; $l->setClassAgenda($this); }