<?php
namespace Modules\Orders\MiceProjects; class MiceReports { public function getRecords($id) { $project = \Entity\MiceProject::select($id); $result['startDate'] = $start = DATE_MAX; $result['endDate'] = $stop = DATE_MIN; foreach($project->idOrders as $idOrder){ $order = \Entity\Order::select($idOrder); $services = $order->servicesList; foreach($services as $idService=>$serviceArr){ $service = \Entity\Service::select($idService); $result['services'][$idService]['serviceName'] = $service->serviceName; $result['services'][$idService]['category'] = $service->category; $result['services'][$idService]['startTime'] = $service->startDate; $result['services'][$idService]['endTime'] = $service->endDate; $result['services'][$idService]['productName'] = $service->productName; $result['services'][$idService]['categoryReadable'] = $service->categoryReadable; $result['services'][$idService]['departureCityId'] = $service->departureCityId; $result['services'][$idService]['destinationCityId'] = $service->destinationCityId; $result['services'][$idService]['departureCountryCode'] = $service->departureCountryCode; $result['services'][$idService]['destinationCountryCode'] = $service->destinationCountryCode; $result['services'][$idService]['multiplierReadable'] = $service->multiplierReadable; $result['services'][$idService]['pax'] = $service->pax; $result['services'][$idService]['idSupplier'] = $service->chosenOffer->idSupplier; $result['services'][$idService]['idSupplierProduct'] = $service->idSupplierProduct; $result['services'][$idService]['productTypeCode'] = $service->productTypeCode; $result['services'][$idService]['productTypeReadable'] = $service->productTypeReadable; $result['services'][$idService]['serviceSourceReadable'] = $service->serviceSourceReadable; $result['services'][$idService]['description'] = $service->description; $start = min($start, $service->startDate); $stop = max($stop, $service->endDate); } $result['startDate'] = $start; $result['endDate'] = $stop; } if ($result['startDate']==DATE_MAX) { $result['startDate'] = ''; } if ($result['endDate']==DATE_MIN) { $result['endDate'] = ''; } return $result; } }