public function executeUpdateEmail() { $employee_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo'); $employee = EmployeePeer::retrieveByPK($employee_id); $this->forward404Unless($employee); $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('student_id')) { $emp = EmployeePeer::retrieveByPK($this->getRequestParameter('employee_2')); $this->forward404Unless($emp); $inbox_emp = new InboxEmp(); $inbox_emp->setEmployee2($this->getRequestParameter('employee_id')); $inbox_emp->setEmployeeId($emp->getId()); $inbox_emp->setSubject($this->getRequestParameter('subject')); $inbox_emp->setDetail($this->getRequestParameter('detail')); $inbox_emp->setType(2); $inbox_emp->setCreatedAt($this->getRequestParameter('created_at')); $inbox_emp->setCode($emp->toString()); $inbox_emp->save(); $employee = EmployeePeer::retrieveByPK($this->getRequestParameter('employee_id')); $this->forward404Unless($employee); $outbox_emp = new OutboxEmp(); $outbox_emp->setEmployee2($this->getRequestParameter('employee_id')); $outbox_emp->setEmployeeId($emp->getId()); $outbox_emp->setSubject($this->getRequestParameter('subject')); $outbox_emp->setDetail($this->getRequestParameter('detail')); $outbox_emp->setType(2); $outbox_emp->setCreatedAt($this->getRequestParameter('created_at')); $outbox_emp->setCode($employee->toString()); $outbox_emp->save(); } else { $emp = EmployeePeer::retrieveByPK($this->getRequestParameter('employee_2')); $this->forward404Unless($emp); $inbox_stu = new InboxStu(); $inbox_stu->setStudent2($this->getRequestParameter('student_id')); $inbox_stu->setEmployeeId($emp->getId()); $inbox_stu->setSubject($this->getRequestParameter('subject')); $inbox_stu->setDetail($this->getRequestParameter('detail')); $inbox_stu->setType(1); $inbox_stu->setCreatedAt($this->getRequestParameter('created_at')); $inbox_stu->setCode($emp->toString()); $inbox_stu->save(); $stu = StudentPeer::retrieveByPK($this->getRequestParameter('student_id')); $this->forward404Unless($stu); $outbox_emp = new OutboxEmp(); $outbox_emp->setStudentId($this->getRequestParameter('student_id')); $outbox_emp->setEmployeeId($emp->getId()); $outbox_emp->setSubject($this->getRequestParameter('subject')); $outbox_emp->setDetail($this->getRequestParameter('detail')); $outbox_emp->setType(1); $outbox_emp->setCreatedAt($this->getRequestParameter('created_at')); $outbox_emp->setCode($stu->toStringCap()); $outbox_emp->save(); } return $this->redirect('employee_counsel/list'); }
public function executeSaveEmail() { $employee_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo'); $employee = EmployeePeer::retrieveByPK($employee_id); $this->forward404Unless($employee); $outclass_counseling = OutclassCounselingPeer::retrieveByPK($this->getRequestParameter('outclass_counseling_id')); $this->forward404Unless($outclass_counseling); $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('student_id')) { $emp = EmployeePeer::retrieveByPK($this->getRequestParameter('employee_2')); $this->forward404Unless($emp); $inbox_emp = new InboxEmp(); $inbox_emp->setEmployee2($this->getRequestParameter('employee_id')); $inbox_emp->setEmployeeId($emp->getId()); $inbox_emp->setSubject($this->getRequestParameter('subject')); $inbox_emp->setDetail($this->getRequestParameter('detail')); $inbox_emp->setType(2); $inbox_emp->setCreatedAt($this->getRequestParameter('created_at')); $inbox_emp->setCode($emp->toString()); $inbox_emp->save(); $employee = EmployeePeer::retrieveByPK($this->getRequestParameter('employee_id')); $this->forward404Unless($employee); $outbox_emp = new OutboxEmp(); $outbox_emp->setEmployee2($this->getRequestParameter('employee_id')); $outbox_emp->setEmployeeId($emp->getId()); $outbox_emp->setSubject($this->getRequestParameter('subject')); $outbox_emp->setDetail($this->getRequestParameter('detail')); $outbox_emp->setType(2); $outbox_emp->setCreatedAt($this->getRequestParameter('created_at')); $outbox_emp->setCode($employee->toString()); $outbox_emp->save(); } else { $emp = EmployeePeer::retrieveByPK($this->getRequestParameter('employee_2')); $this->forward404Unless($emp); $inbox_stu = new InboxStu(); $inbox_stu->setStudent2($this->getRequestParameter('student_id')); $inbox_stu->setEmployeeId($emp->getId()); $inbox_stu->setSubject($this->getRequestParameter('subject')); $inbox_stu->setDetail($this->getRequestParameter('detail')); $inbox_stu->setType(1); $inbox_stu->setCreatedAt($this->getRequestParameter('created_at')); $inbox_stu->setCode($emp->toString()); $inbox_stu->save(); $stu = StudentPeer::retrieveByPK($this->getRequestParameter('student_id')); $this->forward404Unless($stu); $outbox_emp = new OutboxEmp(); $outbox_emp->setStudentId($this->getRequestParameter('student_id')); $outbox_emp->setEmployeeId($emp->getId()); $outbox_emp->setSubject($this->getRequestParameter('subject')); $outbox_emp->setDetail($this->getRequestParameter('detail')); $outbox_emp->setType(1); $outbox_emp->setCreatedAt($this->getRequestParameter('created_at')); $outbox_emp->setCode($stu->toStringCap()); $outbox_emp->save(); /* SMS ADD */ if (SF_ENVIRONMENT == 'dev') { if ($this->getRequestParameter('send_message') == 1) { $lekarSms = new lekarSms(); $sms = array('subject' => $this->getRequestParameter('subject'), 'message' => $this->getRequestParameter('detail')); $userType = $this->getContext()->getUser()->getAttribute('usertype', '', 'bo'); $lekarSms->sendSmsCounseling($userType, $emp->getId(), $this->getRequestParameter('student_id'), $sms); } } /* ------------------------------- */ } if ($outclass_counseling->getAcademicCalendar()->getCourseModel() == 'A') { return $this->redirect('course_counseling/listEmployee'); } else { return $this->redirect('course_counseling/listEmployee2'); } }