/**
  * Get pick up date time from a driving mission, which may or may not be
  * assigned to a working day or shift.
  *
  * @param DrivingMission $drivingMission
  * @return \DateTime local time
  */
 private function getPickUpDateTime(DrivingMission $drivingMission)
 {
     /** @var DateTimeService $timeService */
     $timeService = $this->container->get('tixi_api.datetimeservice');
     /** @var DrivingOrder $drivingOrder */
     $drivingOrder = $drivingMission->getDrivingOrders()[0];
     $pickUpDate = $timeService->convertToLocalDateTime($drivingOrder->getPickUpDate());
     $localMinutes = $drivingMission->getServiceMinuteOfDay();
     $localHours = intval($localMinutes / 60);
     $localMinutes = $localMinutes - $localHours * 60;
     $pickUpDate->setTime($localHours, $localMinutes);
     return $pickUpDate;
 }
Example #2
0
 /**
  * passenger ride, represents necessary details of a ordered ride
  * @param DrivingMission $drivingMission
  * @param Address $startAddress
  * @param Address $endAddress
  * @return RideNode
  */
 public static function registerPassengerRide(DrivingMission $drivingMission, Address $startAddress, Address $endAddress)
 {
     $ride = new RideNode(self::RIDE_PASSENGER);
     $ride->drivingMission = $drivingMission;
     $ride->duration = $drivingMission->getServiceDuration();
     // todo check if passenger.extraMinutes are included here
     $ride->distance = $drivingMission->getServiceDistance();
     $ride->startMinute = $drivingMission->getServiceMinuteOfDay();
     $ride->endMinute = $drivingMission->getServiceMinuteOfDay() + $drivingMission->getServiceDuration();
     //fill amount of passenger with or without wheelchair
     foreach ($drivingMission->getDrivingOrders() as $order) {
         /**@var $order DrivingOrder */
         $passenger = $order->getPassenger();
         if ($passenger->getIsInWheelChair()) {
             $ride->wheelChairs++;
         } else {
             $ride->passengers++;
         }
         //add additional companion passenger
         $ride->passengers += $order->getCompanion();
         foreach ($passenger->getContradictVehicleCategories() as $contradict) {
             $ride->contradictingVehicleCategories[$contradict->getId()] = $contradict;
         }
     }
     $ride->startAddress = $startAddress;
     $ride->targetAddress = $endAddress;
     return $ride;
 }