Example #1
0
 public function editAction()
 {
     parent::editAction();
     $this->_entity = MedicalPost::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();
     }
 }
Example #2
0
 public function getTo()
 {
     return Application_Model_Medical_Post::getById($this->getIdTo());
 }
Example #3
0
 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));
 }