Beispiel #1
0
 public function indexAction()
 {
     RM_Head::getInstance()->getJS()->add('banner');
     RM_Head::getInstance()->getJS()->add('reservation');
     RM_Head::getInstance()->getJS()->add('calendar');
     $this->_currentMenuAlias = 'index';
     $this->view->assign(array('banners' => (new Application_Model_Banner_Search_Repository())->getShownOnMainBanners(), 'feedbacks' => (new Application_Model_Feedback_Search_Repository())->getShownOnMainFeedbacks(), 'services' => Application_Model_Medical_Service::getList()));
 }
 public function editAction()
 {
     parent::editAction();
     $this->_entity = MedicalService::getById($this->_getParam('id'));
     if ($this->getRequest()->isPost()) {
         $data = (object) $this->getRequest()->getPost();
         try {
             $this->__setData($data);
             $this->_entity->validate();
             $this->_entity->save();
             $this->view->showMessage('Изменения сохранены');
         } catch (Exception $e) {
             $this->view->showMessage($e);
         }
     } else {
         $this->__postContentFields();
     }
 }
Beispiel #3
0
 /**
  * @return Application_Model_Medical_Service|null
  */
 public function getTo()
 {
     return Application_Model_Medical_Service::getById($this->getIdTo());
 }
 protected function __setData(stdClass $data)
 {
     try {
         $finalVisitTime = DateTime::create($data->final_visit_time);
         $visitEndTime = DateTime::create($data->visit_end_time);
     } catch (Exception $e) {
         throw new Exception('Время имеет неверный формат');
     }
     if ($finalVisitTime->getTimestamp() > $visitEndTime->getTimestamp()) {
         throw new Exception('Время приема не может быть позже времени окончания приема');
     }
     $timeChanged = false || $this->_entity->getFinalVisitTime() != $finalVisitTime->getTimestamp();
     $timeChanged = $timeChanged || $this->_entity->getVisitEndTime() != $visitEndTime->getTimestamp();
     if ($timeChanged) {
         $schedule = $this->_entity->getDoctor()->getSchedule($finalVisitTime);
         if (!$schedule->isAvailable($finalVisitTime, $visitEndTime, [(int) $this->_entity->getId()])) {
             throw new Exception('В это время доктор не принимает или занят');
         }
     }
     $this->_entity->setFinalVisitTime($finalVisitTime->getTimestamp());
     $this->_entity->setVisitEndTime($visitEndTime->getTimestamp());
     $serviceCollection = $this->_entity->getServiceCollection();
     $serviceCollection->resetItems();
     foreach ($data->id_services as $idService) {
         $service = Application_Model_Medical_Service::getById($idService);
         if ($service instanceof Application_Model_Medical_Service) {
             $serviceCollection->add($service);
         }
     }
     $this->_entity->setStatus($data->status);
 }
 protected function __setData(stdClass $data)
 {
     $this->__setContentFields();
     $photo = RM_Photo::getById($data->id_photo);
     if (!$photo instanceof RM_Photo) {
         throw new Exception('Не выбрана фотография');
     }
     if (empty($data->id_posts)) {
         throw new Exception('Не выбрана должность');
     }
     $this->_entity->setPhoto($photo);
     $postCollection = $this->_entity->getPostCollection();
     $postCollection->resetItems();
     foreach ($data->id_posts as $idPost) {
         $post = Application_Model_Medical_Post::getById($idPost);
         if ($post instanceof Application_Model_Medical_Post) {
             $postCollection->add($post);
         }
     }
     $serviceCollection = $this->_entity->getServiceCollection();
     $serviceCollection->resetItems();
     foreach ($data->id_services as $idService) {
         $service = Application_Model_Medical_Service::getById($idService);
         if ($service instanceof Application_Model_Medical_Service) {
             $serviceCollection->add($service);
         }
     }
     $this->_initWorkTimeList($data);
     $user = Application_Model_User_Profile::getById($data->id_user);
     if ($user instanceof Application_Model_User_Profile) {
         $this->_entity->setUser($user);
     } else {
         $this->_entity->resetUser();
     }
     $this->_entity->setReceptionDuration(new MedOptima_DateTime_Duration_InsideDay((int) $data->reception_duration));
 }