示例#1
0
 public function getDoctorWorkTimeList(Doctor $doctor, MedOptima_DateTime $date = null)
 {
     $condition = $this->__getConditionClass();
     $condition->setDoctor($doctor);
     if ($date) {
         $condition->setWeekday($date->getWeekday());
     }
     return $this->__getEntitySearch($condition)->getResults();
 }
示例#2
0
 public function editAction()
 {
     parent::editAction();
     $this->_entity = Feedback::getById($this->_getParam('id'));
     if (!$this->_entity->isProcessed()) {
         $this->_entity->setProcessed(true);
         $this->_entity->save();
     }
     if ($this->getRequest()->isPost()) {
         $data = (object) $this->getRequest()->getPost();
         try {
             $this->__setData($data);
             $this->_entity->save();
             $this->view->showMessage('Изменения сохранены');
         } catch (Exception $e) {
             $this->view->showMessage($e);
         }
     } else {
         $this->__postContentFields();
         $_POST['visitor_name'] = $this->_entity->getVisitorName();
         $_POST['visitor_phone'] = $this->_entity->getVisitorPhone();
         $_POST['feedback_content'] = $this->_entity->getContent();
         $_POST['date_posted'] = MedOptima_DateTime::toGostDate($this->_entity->getDatePosted());
         $_POST['show_on_main'] = $this->_entity->isShownOnMain();
     }
 }
 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);
 }
示例#4
0
 public function showList()
 {
     $date = isset($this->_data->date) ? $this->_data->date : null;
     $services = isset($this->_data->services) ? $this->_data->services : '';
     if (is_string($date)) {
         $date = MedOptima_DateTime::create($date);
         $services = empty($services) ? [] : explode(',', $services);
         $doctors = (new Repo())->getWorkingDoctorsWithServices($date, $services);
         return DTO::jsonSerializeList($doctors, $date);
     } else {
         return [];
     }
 }
示例#5
0
 private function _process(Google_Event $event)
 {
     $event->setSummary($this->_getReservationSummary());
     $event->setDescription($this->_getReservationDescription());
     $timeBegin = DateTime::createFromTimestamp($this->_reservation->getFinalVisitTime());
     $timeEnd = DateTime::createFromTimestamp($this->_reservation->getVisitEndTime());
     $timeEventBegin = new Google_EventDateTime();
     $timeEventEnd = new Google_EventDateTime();
     $timeEventBegin->setDateTime($timeBegin->getGoogleApiDatetime());
     $timeEventEnd->setDateTime($timeEnd->getGoogleApiDatetime());
     $event->setStart($timeEventBegin);
     $event->setEnd($timeEventEnd);
     return $event;
 }
示例#6
0
 private function _buildReservation(Reservation $reservation)
 {
     $reservation->setDoctor($this->_doctor);
     $reservation->setDesiredVisitTime($this->_fromTime->getTimestamp());
     $reservation->setFinalVisitTime($this->_fromTime->getTimestamp());
     $reservation->setVisitEndTime($this->_toTime->getTimestamp());
     $reservation->setVisitorName($this->_data->visitorName);
     $reservation->setVisitorPhone($this->_data->visitorPhone);
     $serviceCollection = $reservation->getServiceCollection();
     foreach ($this->_services as $service) {
         $serviceCollection->add($service);
     }
     $reservation->setStatus($reservation::STATUS_NEW);
     $reservation->save();
     return $reservation;
 }
示例#7
0
 public function splitRange($from, $to, $step)
 {
     if (is_string($from)) {
         $from = DateTime::timeToSeconds($from);
     }
     if (is_string($to)) {
         $to = DateTime::timeToSeconds($to);
     }
     if (is_string($step)) {
         $step = DateTime::timeToSeconds($step);
     }
     $list = array();
     while ($from <= $to) {
         $list[$from] = (new MedOptima_DateTime_Duration_InsideDay($from))->toString();
         $from += $step;
     }
     return $list;
 }
示例#8
0
 protected function __createWorkTimeDependencies(Doc $doc, WorkTime $initiator)
 {
     $list = [];
     $period = $initiator->getPeriod();
     if ($period->evenWeekdays()) {
         $expected = 0;
     } elseif ($period->oddWeekdays()) {
         $expected = 1;
     } else {
         return $list;
     }
     foreach (DateTime::getWeekdayNames() as $num => $day) {
         if ($num % 2 === $expected) {
             $workTime = $this->__createWorkTime($doc, $num, $period->getTimeBegin(), $period->getTimeEnd());
             $workTime->setIsDependency(true);
             $list[] = $workTime;
         }
     }
     return $list;
 }
示例#9
0
 public function jsonSerialize()
 {
     $result = array();
     $duration = $this->_schedule->getDoctor()->getReceptionDuration()->getTimestamp();
     $from = clone $this->_schedule->getDate();
     $to = clone $from;
     $currentTimestamp = MedOptima_DateTime::create()->getTimestamp();
     foreach ($this->_schedule->getWorkTimeList() as $workTime) {
         $from->setTime(0, 0);
         $to->setTime(0, 0);
         $to->addSeconds($duration);
         $period = $workTime->getPeriod();
         $time = $period->getTimestampBegin();
         $from->addSeconds($time);
         $to->addSeconds($time);
         for (; $time <= $period->getTimestampEnd() - $duration; $time += $duration) {
             $result[$from->getTimestamp()] = array('time' => $from->getGostTime(), 'available' => $from->getTimestamp() > $currentTimestamp && !$this->_getReservationService()->hasReservationsBetween($from, $to));
             $from->addSeconds($duration);
             $to->addSeconds($duration);
         }
     }
     ksort($result);
     return array_values($result);
 }
示例#10
0
 public function __toString()
 {
     return MedOptima_DateTime::secondsToTime($this->getTimestamp());
 }
 public function GetWorkTimeWeekdaysVariants()
 {
     return MedOptima_DateTime::getWeekdayNames() + [MedOptima_DateTime_WeekdayPeriod::EVEN_WEEKDAYS => 'Четные дни', MedOptima_DateTime_WeekdayPeriod::ODD_WEEKDAYS => 'Нечетные дни'];
 }
示例#12
0
 private function _setTimeEnd($time)
 {
     $this->_dataWorker->setValue('timeEnd', DateTime::toMySqlTime($time));
 }
示例#13
0
 public function isExpired()
 {
     return MedOptima_DateTime::create()->getTimestamp() > $this->getTimeExpires();
 }
示例#14
0
 public function onlyActive()
 {
     $this->_getWhere()->add('finalVisitTime', '>', MedOptima_DateTime::create()->getTimestamp());
 }
示例#15
0
 public function setDesiredVisitTime($time)
 {
     $time = (int) $time;
     if ($time < MedOptima_DateTime::currentTimestamp()) {
         throw new Exception('Invalid visit time');
     }
     $this->_dataWorker->setValue('desiredVisitTime', $time);
 }
示例#16
0
 private function _save()
 {
     $this->_reservation->setLastSyncTime(DateTime::currentTimestamp());
     $this->_reservation->save();
 }
示例#17
0
 protected function __updateTimestamp()
 {
     $this->_timestampBegin = DateTime::timeToSeconds($this->_timeBegin);
     $this->_timestampEnd = DateTime::timeToSeconds($this->_timeEnd);
 }
示例#18
0
 public function isWorkingAt(MedOptima_DateTime $date)
 {
     $this->_getJoin()->add('join', 'medicalDoctorWorkTime', 'medicalDoctors', 'idDoctor');
     $this->_getWhere()->add('weekday', '=', $date->getWeekday());
 }