Beispiel #1
0
 public function send()
 {
     if (!$this->buildValidator()->isValid()) {
         return new ActionRedirectResponse('EyeExam', 'index');
     }
     $eyeExamScheduleID = $this->request->get('time');
     // this field is used for passing ID
     $eyeExamSchedule = EyeExamSchedule::getInstanceByID('EyeExamSchedule', $eyeExamScheduleID, ActiveRecord::LOAD_DATA);
     $requestDate = $eyeExamSchedule->date->get();
     $requestTime = $eyeExamSchedule->time->get();
     $eyeExamRequest = EyeExamRequest::getNewInstance();
     $eyeExamRequest->date->set(strtotime($requestDate));
     // does it still needed in DB??
     $eyeExamRequest->time->set($requestTime);
     // does it still needed in DB??
     // custom fields
     $eyeExamRequest->getSpecification()->loadRequestData($this->request);
     $eyeExamRequest->save();
     $eyeExamSchedule->setFieldValue('eyeExamRequestID', $eyeExamRequest);
     $eyeExamSchedule->save();
     $email = new Email($this->application);
     $email->setTemplate('module/eye-exam/eyeExam/eyeExamRequestNotify');
     $email->setTo($this->config->get('NOTIFICATION_EMAIL'), $this->config->get('STORE_NAME'));
     $email->set('date', $requestDate);
     $email->set('time', $requestTime);
     $email->set('doctorName', $eyeExamSchedule->doctorName->get());
     $email->send();
     $response = new ActionResponse();
     $response->set('date', $requestDate);
     $response->set('time', $requestTime);
     $this->addBreadCrumb($this->translate('_title_lang'), $this->router->createUrl(array('controller' => 'EyeExam')));
     $this->addBreadCrumb($this->translate('_form_sent'), '');
     return $response;
 }
 /**
  * @role update
  */
 public function edit()
 {
     $form = $this->buildForm();
     $form->loadData(EyeExamSchedule::getInstanceById($this->request->get('id'), EyeExamSchedule::LOAD_DATA)->toArray());
     return new ActionResponse('form', $form);
 }