Преглед изворни кода

Opening : ajustements

packProduct
Guillaume пре 3 година
родитељ
комит
691353f558
3 измењених фајлова са 12 додато и 27 уклоњено
  1. +2
    -7
      Controller/Section/OpeningAdminController.php
  2. +2
    -1
      Resolver/OpeningResolver.php
  3. +8
    -19
      Solver/Section/OpeningSolver.php

+ 2
- 7
Controller/Section/OpeningAdminController.php Прегледај датотеку

@@ -24,10 +24,7 @@ abstract class OpeningAdminController extends AbstractAdminController

public function configureFields(string $pageName): iterable
{
$fields = parent::configureFields($pageName);

return array_merge(
[
return [
ChoiceField::new('day')
->setRequired(true)
->setChoices(
@@ -48,9 +45,7 @@ abstract class OpeningAdminController extends AbstractAdminController
->setRequired(false)
->setFormat('H:mm'),
AssociationField::new('groupUser'),
],
$fields
);
];
}

public function configureCrud(Crud $crud): Crud

+ 2
- 1
Resolver/OpeningResolver.php Прегледај датотеку

@@ -254,10 +254,11 @@ class OpeningResolver

if (!$this->isOpenSale($section)) {
$opening = $this->openingSolver->getNextOpeningOfOpening($date, $openingArray);

if ($opening) {
return $this->openingSolver->getFormatedDateByFormatAndDelimiterDayTime(
$date,
$opening->getTimeStart(),
$opening->getTimeStart() ?: (new \DateTime())->setTime(0, 0),
$formatDate,
$delimiterDayTime
);

+ 8
- 19
Solver/Section/OpeningSolver.php Прегледај датотеку

@@ -25,44 +25,33 @@ class OpeningSolver
}

$count = 0;
$isClosingDay = false;

do {
if ($count) {
$date->modify('+1 day');
}
$weekDay = $date->format('N');
$isClosingDay = $this->$methodTestDay($weekDay, $openings);
$testDay = $this->$methodTestDay($weekDay, $openings);
$count++;
} while (!$isClosingDay && $count <= 7);
} while (!$testDay && $count <= 8);

if ($isClosingDay) {
if ($testDay) {
return $this->getOpeningByWeekday($weekDay, $openings);
}

return null;
}

public function isOpeningDay(int $weekDay, array $openings): bool
protected function isOpeningDay(int $weekDay, array $openings): bool
{
return $this->isOpeningOrClosingDay($weekDay, $openings, 'opening');
return (bool) $this->getOpeningByWeekday($weekDay, $openings);
}

public function isClosingDay(int $weekDay, array $openings): bool
protected function isClosingDay(int $weekDay, array $openings): bool
{
return $this->isOpeningOrClosingDay($weekDay, $openings, 'closing');
}

protected function isOpeningOrClosingDay(int $weekDay, array $openings, string $testOpeningOrClosing = 'opening')
{
if ($testOpeningOrClosing == 'opening') {
$methodGetTime = 'getTimeStart';
} else {
$methodGetTime = 'getTimeEnd';
}

$openingDay = $this->getOpeningByWeekday($weekDay, $openings);
if ($openingDay && $openingDay->$methodGetTime()) {

if ($openingDay && $openingDay->getTimeEnd()) {
return true;
}


Loading…
Откажи
Сачувај