public function addOutboxStu(OutboxStu $l) { $this->collOutboxStus[] = $l; $l->setEmployee($this); }
public function executeUpdate() { $student_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo'); $student = StudentPeer::retrieveByPK($student_id); $this->forward404Unless($student); $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 (!$this->getRequestParameter('employee_id')) { $stu = StudentPeer::retrieveByPK($this->getRequestParameter('student_2')); $this->forward404Unless($stu); $inbox_stu = new InboxStu(); $inbox_stu->setStudent2($this->getRequestParameter('student_id')); $inbox_stu->setStudentId($stu->getId()); $inbox_stu->setSubject($this->getRequestParameter('subject')); $inbox_stu->setDetail($this->getRequestParameter('detail')); $inbox_stu->setType(2); $inbox_stu->setCreatedAt($this->getRequestParameter('created_at')); $inbox_stu->setCode($stu->toStringCap()); $inbox_stu->save(); $student = StudentPeer::retrieveByPK($this->getRequestParameter('student_id')); $this->forward404Unless($student); $outbox_stu = new OutboxStu(); $outbox_stu->setStudent2($this->getRequestParameter('student_id')); $outbox_stu->setStudentId($stu->getId()); $outbox_stu->setSubject($this->getRequestParameter('subject')); $outbox_stu->setDetail($this->getRequestParameter('detail')); $outbox_stu->setType(2); $outbox_stu->setCreatedAt($this->getRequestParameter('created_at')); $outbox_stu->setCode($student->toStringCap()); $outbox_stu->save(); } else { $stu = StudentPeer::retrieveByPK($this->getRequestParameter('student_2')); $this->forward404Unless($stu); $inbox_emp = new InboxEmp(); $inbox_emp->setEmployee2($this->getRequestParameter('employee_id')); $inbox_emp->setStudentId($stu->getId()); $inbox_emp->setSubject($this->getRequestParameter('subject')); $inbox_emp->setDetail($this->getRequestParameter('detail')); $inbox_emp->setType(1); $inbox_emp->setCreatedAt($this->getRequestParameter('created_at')); $inbox_emp->setCode($stu->toStringCap()); $inbox_emp->save(); $emp = EmployeePeer::retrieveByPK($this->getRequestParameter('employee_id')); $this->forward404Unless($emp); $outbox_stu = new OutboxStu(); $outbox_stu->setEmployeeId($this->getRequestParameter('employee_id')); $outbox_stu->setStudentId($stu->getId()); $outbox_stu->setSubject($this->getRequestParameter('subject')); $outbox_stu->setDetail($this->getRequestParameter('detail')); $outbox_stu->setType(1); $outbox_stu->setCreatedAt($this->getRequestParameter('created_at')); $outbox_stu->setCode($emp->toString()); $outbox_stu->save(); } return $this->redirect('student_email/list'); }