<?php
namespace DcSiteBundle\Controller;
use CoreBundle\Component\CoreFormFactory;
use CoreBundle\Component\FormManager;
use CoreBundle\Entity\Brand;
use CoreBundle\Entity\Dealer;
use CoreBundle\Entity\Model;
use CoreBundle\Entity\Vehicles\Vehicle;
use CoreBundle\Factory\Vehicle as VehicleFactory;
use CoreBundle\Model\Api\OnlineService\ApiServer1C;
use CoreBundle\Model\Vehicles\Repository;
use CoreBundle\Services\MediaExtensionVidi;
use DateTime;
use DcSiteBundle\Entity\ServiceVariation;
use DcSiteBundle\Entity\ServiceWork;
use DcSiteBundle\Entity\ServiceWorkJob;
use DcSiteBundle\Entity\ServiceWorkPart;
use Doctrine\ORM\EntityManagerInterface;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Mpdf\Mpdf;
use Mpdf\MpdfException;
use PortalBundle\Model\SeoMetaTag;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\RouterInterface;
use Twig\Environment;
class RegulationToController extends BaseDcController
{
public function __construct(CoreFormFactory $coreFormFactory, SeoMetaTag $seoMetaTag, RequestStack $requestStack, RouterInterface $router, FormManager $formManager, EntityManagerInterface $em, ApiServer1C $apiServer1C, SessionInterface $session, Filesystem $filesystem, MediaExtensionVidi $mediaExtensionVidi, Repository $vehicleRepository, VehicleFactory $vehicleFactory, Environment $twig)
{
parent::__construct($coreFormFactory, $seoMetaTag, $requestStack, $router, $formManager, $em, $apiServer1C, $session, $filesystem, $mediaExtensionVidi, $vehicleRepository, $vehicleFactory, $twig);
}
public function init(Request $request): JsonResponse
{
try {
$dealerId = $request->get('dealer');
if ($dealerId) {
$Dealer = $this->em->getRepository(Dealer::class)->find($dealerId);
} else {
$Dealer = $this->getDealer();
}
} catch (NotFoundHttpException $e) {
$Dealer = false;
}
if (!$Dealer) {
$CarRepo = $this->vehicleRepository;
$brands = $CarRepo->getAvailBrandsInstance($request->getLocale());
foreach ($brands as &$brand) {
$brand['image'] = $this->mediaExtensionVidi->getPath($brand['image'], 'menu');
}
return new JsonResponse(['success' => true, 'brands' => $brands]);
}
$imageProvider = $this->mediaExtensionVidi;
$brandId = $request->get('brandId');
$variations = $this->em->getRepository(ServiceVariation::class)->getRegulationVariations($Dealer, $brandId);
$models = [];
/** @var ServiceVariation $variation */
foreach ($variations as $variation) {
$Model = $variation->getModel();
if (!isset($models[$Model->getId()])) {
$modelImage = $Model->getImage();
if ($modelImage) {
$img = $imageProvider->getPath($modelImage, 'small');
} else {
$vehicle = $this->em->getRepository(Vehicle::class)->findOneBy(['dealer' => $Dealer, 'model' => $Model, 'state' => 1, 'is_used' => 0]);
$img = ($vehicle) ? $imageProvider->getPath($vehicle->getPreview(), 'small') : $imageProvider->getPath($Model->getBrand()->getLogo(), 'reference');
}
$models[$Model->getId()] = [
'id' => $Model->getId(),
'title' => $Model->getTitle(),
'img' => $img,
];
}
}
usort($models, fn($item1, $item2) => $item1['title'] <=> $item2['title']);
return new JsonResponse(['success' => true, 'models' => $models]);
}
public function getDataRegulationTo(): JsonResponse
{
$repositoryBrands = $this->em->getRepository(Brand::class)->getBrandsHasRegulation();
$brands = [];
$models = [];
$dealers = [];
/** @var Brand $brand */
foreach ($repositoryBrands as $brand) {
$brands[$brand->getId()] = [
'id' => $brand->getId(),
'title' => $brand->getName()
];
/** @var Dealer $dealer */
foreach ($brand->getDealer() as $dealer) {
$isNight = $dealer->getIsNightDealer();
$agreementUrl = ($isNight) ? $this->router->generate('my_profile_night_service_agreement_dealer', ['dealerUrl' => $dealer->getUrl()]) : false;
$dealers[$brand->getId()][$dealer->getId()] = [
'id' => $dealer->getId(),
'title' => $dealer->getNameByLocale('ua'),
'isNight' => $isNight,
'agreementUrl' => $agreementUrl,
'brandId' => $brand->getId()
];
}
$models[$brand->getId()] = $this->getModelsHasRegulationByBrand($brand->getId());
}
return new JsonResponse(['success' => true, 'brands' => $brands, 'models' => $models, 'dealers' => $dealers]);
}
public function getModelsHasRegulationByBrand($brandId): array
{
$repositoryModels = $this->em->getRepository(Model::class)->getModelsHasRegulationByBrand($brandId);
$models = [];
/** @var Model $item */
foreach ($repositoryModels as $item) {
$models[$item->getId()] = [
'id' => $item->getId(),
'title' => $item->getTitle(),
'brandId' => $item->getBrand()->getId()
];
}
return $models;
}
public function getFilteredDealersByModel(Request $request): JsonResponse
{
$modelId = $request->get('modelId');
$repositoryServiceVariations = $this->em->getRepository(ServiceVariation::class)->findDealersByModel($modelId);
$dealerIds = [];
foreach ($repositoryServiceVariations as $repositoryServiceVariation) {
if ($repositoryServiceVariation->getDealer()->getId() == 7) { // unset Toyota Palmira
continue;
}
$dealerIds[] = $repositoryServiceVariation->getDealer()->getId();
}
return new JsonResponse(['success' => true, 'dealerIds' => array_values(array_unique($dealerIds))]);
}
public function getVariationRegulationToByFilter(Request $request): JsonResponse
{
$modelId = $request->get('modelId');
$dealerId = $request->get('dealerId');
$locale = $request->getLocale();
$repositoryServiceVariations = $this->em->getRepository(ServiceVariation::class)->findRegulationWorkByVariation($dealerId, $modelId);
$makeYears = [];
$variations = [];
$works = [];
/** @var ServiceVariation $serviceVariation */
foreach ($repositoryServiceVariations as $serviceVariation) {
$yearTo = ($serviceVariation->getYearTo() == 0) ? date('Y', time()) : $serviceVariation->getYearTo();
$makeYearId = $serviceVariation->getYearFrom() . $yearTo;
if (!isset($makeYears[$serviceVariation->getYearFrom()])) {
$makeYears[$makeYearId] = [
'id' => $makeYearId,
'title' => $serviceVariation->getYearFrom() . ' - ' . $yearTo,
];
}
$variationsTitle = '';
if ($serviceVariation->getFuelType()) {
$variationsTitle .= $serviceVariation->getFuelType()->getValue($locale);
}
$variationsTitle .= ' ' . round($serviceVariation->getEngineVolume() / 1000, 1) . 'л';
if ($serviceVariation->getDriveUnit()) {
$variationsTitle .= ', ' . $serviceVariation->getDriveUnit()->getValue($locale);
}
if ($serviceVariation->getTransmissionType()) {
$variationsTitle .= ', ' . $serviceVariation->getTransmissionType()->getValue($locale);
}
$variationsTitle .= ($serviceVariation->getTransmissionStepCount()) ? ', ' . $serviceVariation->getTransmissionStepCount() . 'ст.' : '';
if ($serviceVariation->getEmission()) {
$variationsTitle .= ', ' . $serviceVariation->getEmission();
}
if ($serviceVariation->getDescription()) {
$variationsTitle .= ', ' . $serviceVariation->getDescription();
}
$variations[] = [
'id' => $serviceVariation->getId(),
'title' => $variationsTitle,
'makeYearId' => $makeYearId,
'yearFrom' => $serviceVariation->getYearFrom(),
'yearTo' => $yearTo,
];
$repositoryServiceWorks = $this->em->getRepository(ServiceWork::class)->findRegulationWorkByVariation($serviceVariation);
/** @var ServiceWork $serviceWork */
foreach ($repositoryServiceWorks as $serviceWork) {
$works[$serviceWork->getId()] = [
'id' => $serviceWork->getId(),
'title' => $serviceWork->getMileage(),
'variationId' => $serviceVariation->getId(),
];
}
usort($works, fn($item1, $item2) => $item1['title'] <=> $item2['title']);
}
return new JsonResponse(['success' => true, 'makeYears' => $makeYears, 'variations' => $variations, 'works' => $works]);
}
public function getRegulationWork(Request $request): JsonResponse
{
$locale = $request->getLocale();
$workId = $request->get('workId');
$work = $this->em->getRepository(ServiceWork::class)->find($workId);
if (!$work) {
return new JsonResponse(['success' => false]);
}
$regulationWork = $this->getRegulationToWork($work, $locale);
return new JsonResponse(['success' => true, 'regulationWork' => $regulationWork]);
}
private function getRegulationToWork(ServiceWork $work, $locale): array
{
$regulationWork = [
'works' => [],
'parts' => [],
'cost' => [
'costWorks' => 0,
'costParts' => 0,
'costRegulationWork' => 0,
],
'mileage' => $work->getMileage(),
];
/** @var ServiceWorkJob $job */
foreach ($work->getJobs() as $job) {
$regulationWork['works'][] = [
'title' => $job->getJob()->getNameByLocale($locale),
'price' => round($job->getPrice()),
];
$regulationWork['cost']['costWorks'] += round($job->getPrice());
}
/** @var ServiceWorkPart $part */
foreach ($work->getParts() as $part) {
if (empty($part->getPrice())) {
$cost = round($part->getCount() * $part->getPart()->getPrice());
} else {
$cost = round($part->getCount() * $part->getPrice());
}
$regulationWork['parts'][] = [
'title' => $part->getPart()->getNameByLocale($locale),
'count' => $part->getCount(),
'price' => round($cost),
];
$regulationWork['cost']['costParts'] += round($cost);
}
$regulationWork['cost']['costRegulationWork'] = $regulationWork['cost']['costWorks'] + $regulationWork['cost']['costParts'];
return $regulationWork;
}
public function variations(Request $request): JsonResponse
{
$modelId = $request->request->get('modelId');
$dealerId = $request->get('dealer');
if ($dealerId) {
$Dealer = $this->em->getRepository(Dealer::class)->find($dealerId);
} else {
$Dealer = $this->getDealer();
}
$variations = $this->em->getRepository(ServiceVariation::class)->findBy(['dealer' => $Dealer, 'model' => $modelId, 'is_delete' => [0, null]], ['year_from' => 'ASC']);
$variationsArray = [];
/** @var ServiceVariation $variation */
foreach ($variations as $variation) {
$hasRegulation = false;
/** @var ServiceWork $work */
foreach ($variation->getServiceWorks() as $work) {
if ($work->getIsRegulations()) {
$hasRegulation = true;
}
}
if (!$hasRegulation) {
continue;
}
$key = $variation->getYearFrom() . ' - ' . ($variation->getYearTo() ?: '...');
if (!isset($variationsArray[$key])) {
$variationsArray[$key] = [
'period' => $key,
'from' => $variation->getYearFrom(),
'to' => $variation->getYearTo() ?: (int)(new DateTime())->format('Y'),
'image' => null,
'image_webp' => null,
'items' => [],
];
}
$vImage = $variation->getImage();
if (!$variationsArray[$key]['image'] && $vImage) {
$variationsArray[$key]['image'] = $this->mediaExtensionVidi->getPath($vImage, 'reference');
$variationsArray[$key]['image_webp'] = $this->mediaExtensionVidi->pathWebp($vImage, 'reference');
} else if (!$variationsArray[$key]['image']) {
$variationsArray[$key]['image'] = $this->mediaExtensionVidi->getPath($Dealer->getBrand()->getLogo(), 'reference');
$variationsArray[$key]['image_webp'] = $this->mediaExtensionVidi->pathWebp($Dealer->getBrand()->getLogo(), 'reference');
}
$fuel = $variation->getFuelType() ? $variation->getFuelType()->getValue($request->getLocale()) : '';
$volume = $variation->getEngineVolume();
if ($volume > 200) {
$volume = number_format(round($volume / 1000, 1), 1, '.', '');
}
$power = $variation->getPower();
// $engine = $fuel.' / '.$volume.' куб.см.';
// if($power) {
// $engine .= ' / '. $power . ($request->getLocale() == 'ru' ? 'л.с.' : 'к.с.');
// }
$transmission = $variation->getTransmissionType() ? $variation->getTransmissionType()->getValue($request->getLocale()) : false;
if ($transmission && $variation->getTransmissionStepCount()) {
$transmission .= ', ' . $variation->getTransmissionStepCount() . ' ст.';
}
$variationsArray[$key]['items'][] = [
'id' => $variation->getId(),
'fuel' => $fuel,
'volume' => $volume,
'engineName' => $variation->getEngineName(),
'emission' => $variation->getEmission(),
'power' => $power,
'trans' => $transmission,
'drive' => $variation->getDriveUnit() ? $variation->getDriveUnit()->getValue($request->getLocale()) : false,
'description' => $variation->getDescription(),
];
}
foreach ($variationsArray as &$variationPeriod) {
usort($variationPeriod['items'], fn($item1, $item2) => $item1['drive'] <=> $item2['drive']);
usort($variationPeriod['items'], fn($item1, $item2) => $item1['trans'] <=> $item2['trans']);
usort($variationPeriod['items'], fn($item1, $item2) => $item1['volume'] <=> $item2['volume']);
}
return new JsonResponse(['success' => true, 'variations' => $variationsArray]);
}
public function reg(Request $request): JsonResponse
{
$dealerId = $request->get('dealer');
if ($dealerId) {
$Dealer = $this->em->getRepository(Dealer::class)->find($dealerId);
} else {
$Dealer = $this->getDealer();
}
$vId = $request->request->get('vId');
$V = $this->em->getRepository(ServiceVariation::class)->find($vId);
$regulations = $V->getServiceWorks();
$regulationsArray = [
'mileages' => [],
'parts' => [],
'works' => [],
'amounts' => [],
'id' => [],
];
/** @var ServiceWork $regulation */
foreach ($regulations as $regulation) {
if (!$regulation->getIsRegulations()) {
continue;
}
$regulationsArray['mileages'][] = $regulation->getMileage();
$regulationsArray['id'][$regulation->getMileage()] = $regulation->getId();
/** @var ServiceWorkPart $part */
foreach ($regulation->getParts() as $part) {
if (!$part->getPart()) {
continue;
}
if (empty($part->getPrice())) {
$pCost = round($part->getPart()->getPrice() * $part->getCount());
} else {
$pCost = round($part->getPrice() * $part->getCount());
}
if (!isset($regulationsArray['parts'][$part->getPart()->getId()])) {
$regulationsArray['parts'][$part->getPart()->getId()] = [
'title' => $part->getPart()->getNameByLocale($request->getLocale()),
'price' => $part->getPart()->getPrice(),
'units' => $part->getUnits()->getShortRu(),
'unit' => $part->getUnits()->getShortRu(),
'mileages' => [],
];
}
$regulationsArray['parts'][$part->getPart()->getId()]['mileages'][$regulation->getMileage()] = [
'count' => $part->getCount(),
'amount' => $pCost,
];
if (!isset($regulationsArray['amounts'][$regulation->getMileage()])) {
$regulationsArray['amounts'][$regulation->getMileage()] = 0;
}
if (!isset($regulationsArray['partsAmount'][$regulation->getMileage()])) {
$regulationsArray['partsAmount'][$regulation->getMileage()] = 0;
}
$regulationsArray['amounts'][$regulation->getMileage()] += $pCost;
$regulationsArray['partsAmount'][$regulation->getMileage()] += $pCost;
}
/** @var ServiceWorkJob $job */
foreach ($regulation->getJobs() as $job) {
if (!isset($regulationsArray['works'][$job->getJob()->getId()])) {
$regulationsArray['works'][$job->getJob()->getId()] = [
'title' => $job->getJob()->getNameByLocale($request->getLocale()),
'mileages' => [],
];
}
$regulationsArray['works'][$job->getJob()->getId()]['mileages'][$regulation->getMileage()] = [
'amount' => $job->getJobHours(),
];
if (!isset($regulationsArray['amounts'][$regulation->getMileage()])) {
$regulationsArray['amounts'][$regulation->getMileage()] = 0;
}
if (!isset($regulationsArray['jobsAmount'][$regulation->getMileage()])) {
$regulationsArray['jobsAmount'][$regulation->getMileage()] = 0;
}
$regulationsArray['amounts'][$regulation->getMileage()] += $job->getPrice();
$regulationsArray['jobsAmount'][$regulation->getMileage()] += $job->getPrice();
}
$regulationsArray['amounts'][$regulation->getMileage()] = round($regulationsArray['amounts'][$regulation->getMileage()], 2);
$regulationsArray['jobsAmount'][$regulation->getMileage()] = round($regulationsArray['jobsAmount'][$regulation->getMileage()], 2);
}
sort($regulationsArray['mileages']);
return new JsonResponse(['regulations' => $regulationsArray]);
}
public function download(Request $request, Filesystem $filesystem): Response
{
$dealerId = $request->get('dealer');
$vidiSite = false;
$excludeDealers = [3, 15];
if ($dealerId) {
$Dealer = $this->em->getRepository(Dealer::class)->find($dealerId);
$vidiSite = true;
} else {
$Dealer = $this->getDealer();
if (in_array($Dealer->getId(), $excludeDealers)) {
$vidiSite = true;
}
}
$vId = $request->get('vId');
$ToVariation = $this->em->getRepository(ServiceVariation::class)->find($vId);
if (!$ToVariation) {
throw new NotFoundHttpException();
}
$regulationTo = [];
$workId = $request->get('workId');
if ($workId) {
$serviceWorkTo = $this->em->getRepository(ServiceWork::class)->find($workId);
$regulationTo = $this->getRegulationToWork($serviceWorkTo, 'ua');
}
$regulationData = $this->getRegulationData($Dealer, $ToVariation, $request);
$model = $ToVariation->getModel();
$fTypeName = $ToVariation->getFuelType() ? $ToVariation->getFuelType()->getValueUa() : '';
$tTypeName = $ToVariation->getTransmissionType() ? $ToVariation->getTransmissionType()->getValueUa() : '';
$dTypeName = $ToVariation->getDriveUnit() ? $ToVariation->getDriveUnit()->getValueUa() : '';
$title = $model->getBrand()->getNameUa() . ' ' .
$model->getTitle() . ' ' .
$fTypeName . ', ' .
$tTypeName . ', ' .
$dTypeName . ' ';
try {
$rootDir = $this->getParameter('kernel.project_dir');
$newTempDir = $this->getParameter('file_directory_mpdf');
if (!$filesystem->exists($newTempDir)) {
$filesystem->mkdir($newTempDir, 0777);
}
$mpdf = new Mpdf(['mode' => 'utf-8', 'format' => [420, 270], 'tempDir' => $newTempDir, 'curlAllowUnsafeSslRequests' => true]);
$mpdf->curlAllowUnsafeSslRequests = true;
// $mpdf->showImageErrors = true;
$logger = new Logger('mpdf');
$logger->pushHandler(new StreamHandler($rootDir . '/var/logs/mpdf.log', Logger::DEBUG));
$mpdf->setLogger($logger);
if ($filesystem->exists($rootDir . '/public' . $this->mediaExtensionVidi->getPath($Dealer->getBrand()->getLogo(), 'reference'))) {
$brandLogoImage = file_get_contents($rootDir . '/public' . $this->mediaExtensionVidi->getPath($Dealer->getBrand()->getLogo(), 'reference'));
$mpdf->imageVars['brand'] = $brandLogoImage;
}
$mpdf->imageVars['header'] = file_get_contents($rootDir . '/src/DcSiteBundle/Resources/public/img/modules/reglament-to-pdf/logo-header.png');
$mpdf->imageVars['footer'] = file_get_contents($rootDir . '/src/DcSiteBundle/Resources/public/img/logo-vidi-big.jpg');
$mpdf->imageVars['qr'] = file_get_contents($rootDir . '/public/bundles/dcsite/img/qr_code/map/qr_code_night_booking.svg');
$mpdf->imageVars['dcMap'] = file_get_contents($rootDir . '/public/bundles/dcsite/img/qr_code/map/dc_map_' . $Dealer->getId() . '.svg');
$mpdf->imageVars['map'] = file_get_contents($rootDir . '/public/bundles/dcsite/img/map-icon.png');
$mpdf->imageVars['phone'] = file_get_contents($rootDir . '/public/bundles/dcsite/img/phone-icon.png');
$mpdf->imageVars['watch'] = file_get_contents($rootDir . '/public/bundles/dcsite/img/watch-icon.png');
$regulationData['regulationData'] = array_slice($regulationData['regulationData'], 0, 12);
$logoMediaUrl = $Dealer->getBrand() ? $this->mediaExtensionVidi->getPath($Dealer->getBrand()->getLogo(), 'reference') : null;
$logoMediaWhiteUrl = $Dealer->getBrand() ? $this->mediaExtensionVidi->getPath($Dealer->getBrand()->getLogoWhite(), 'reference') : null;
$logoImage = '';
$logoWhiteImage = '';
if ($vidiSite) {
$logoImage = parse_url($logoMediaUrl, PHP_URL_PATH);
$logoWhiteImage = parse_url($logoMediaWhiteUrl, PHP_URL_PATH);
}
$html = $this->twig->render('@DcSite/Modules/reglament-to-pdf/reglament-to.html.twig', [
'regulations' => $regulationData['regulationData'],
'regulationTo' => $regulationTo,
'dealer' => $Dealer,
'logoImage' => $logoImage,
'logoWhiteImage' => $logoWhiteImage,
'model' => $model,
'title' => $title,
'amountWork' => $regulationData['amountWorks'],
'amountParts' => $regulationData['amountParts'],
'amountOverall' => $regulationData['overall'],
]);
$mpdf->WriteHTML($html);
$mpdf->Output();
return new Response();
} catch (MpdfException $exception) {
throw new NotFoundHttpException();
}
}
public function getRegulationData(Dealer $dealer, ServiceVariation $serviceVariation, Request $request): array
{
$regulations = $serviceVariation->getServiceWorks();
$regulationsArray = [
'mileages' => [],
'parts' => [],
'works' => [],
'amounts' => [],
];
$amountParts = false;
$amountWorks = false;
$overall = false;
$hCost = $dealer->getHourCost();
/** @var ServiceWork $regulation */
foreach ($regulations as $regulation) {
if (!$regulation->getIsRegulations() || count($regulationsArray['mileages']) >= 12) {
continue;
}
$regulationsArray['mileages'][] = $regulation->getMileage();
$amountParts[$regulation->getMileage()] = 0;
$amountWorks[$regulation->getMileage()] = 0;
/** @var ServiceWorkPart $part */
foreach ($regulation->getParts() as $part) {
if (!$part->getPart()) {
continue;
}
if (empty($part->getPrice())) {
$pCost = round($part->getPart()->getPrice() * $part->getCount());
} else {
$pCost = round($part->getPrice() * $part->getCount());
}
if (!isset($regulationsArray['parts'][$part->getPart()->getId()])) {
$regulationsArray['parts'][$part->getPart()->getId()] = [
'title' => $part->getPart()->getNameByLocale($request->getLocale()),
'price' => $part->getPart()->getPrice(),
'units' => $part->getUnits()->getShortRu(),
'count' => $part->getCount(),
'mileages' => [],
];
}
$regulationsArray['parts'][$part->getPart()->getId()]['mileages'][$regulation->getMileage()] = [
'amount' => $pCost,
];
if (!isset($regulationsArray['amounts'][$regulation->getMileage()])) {
$regulationsArray['amounts'][$regulation->getMileage()] = 0;
}
$regulationsArray['amounts'][$regulation->getMileage()] += $pCost;
$amountParts[$regulation->getMileage()] += $pCost;
}
/** @var ServiceWorkJob $job */
foreach ($regulation->getJobs() as $job) {
$jCost = round($job->getPrice(), 2);
if (!isset($regulationsArray['works'][$job->getJob()->getId()])) {
$regulationsArray['works'][$job->getJob()->getId()] = [
'title' => $job->getJob()->getNameByLocale($request->getLocale()),
'mileages' => [],
];
}
$regulationsArray['works'][$job->getJob()->getId()]['mileages'][$regulation->getMileage()] = [
'amount' => $jCost,
'hours' => $job->getJobHours(),
];
if (!isset($regulationsArray['amounts'][$regulation->getMileage()])) {
$regulationsArray['amounts'][$regulation->getMileage()] = 0;
}
$regulationsArray['amounts'][$regulation->getMileage()] += $jCost;
$amountWorks[$regulation->getMileage()] += $jCost;
if (!isset($overall[$regulation->getMileage()])) {
$overall[$regulation->getMileage()] = 0;
}
$overall[$regulation->getMileage()] = $amountWorks[$regulation->getMileage()] + $amountParts[$regulation->getMileage()];
}
}
sort($regulationsArray['mileages']);
return ['regulationData' => $regulationsArray, 'amountParts' => $amountParts, 'amountWorks' => $amountWorks, 'overall' => $overall];
}
public function widgetTest(): Response
{
return new Response('<iframe width="100%" height="100%" src="http://new.vidi.yz/ua/regulation/toyota"></iframe>', Response::HTTP_OK);
}
}