Quellcode durchsuchen

[Administration] Correctif activation des distributions à l'avance

master
Guillaume Bourgeois vor 1 Jahr
Ursprung
Commit
cd4b1ed6ea
2 geänderte Dateien mit 17 neuen und 7 gelöschten Zeilen
  1. +10
    -5
      common/logic/Distribution/Distribution/Service/DistributionBuilder.php
  2. +7
    -2
      console/commands/ActiveDistributionsInAdvanceController.php

+ 10
- 5
common/logic/Distribution/Distribution/Service/DistributionBuilder.php Datei anzeigen

@@ -208,15 +208,20 @@ class DistributionBuilder extends AbstractBuilder
$this->activeDistribution($distribution, $active);
}

public function activeDistributionByDayWeek(string $date, string $dayWeek, bool $active = true)
public function activeDistributionByDateIfDelivery(\DateTime $date, bool $active = true): void
{
$activeDay = $this->pointSaleRepository->isDayOfWeekWithDelivery($date->format('l'));
if($activeDay || !$active) {
$this->activeDistributionByDate($date, $active);
}
}

public function activeDistributionByDayWeek(string $date, string $dayWeek, bool $active = true): void
{
$week = sprintf('%02d', date('W', strtotime($date)));
$start = strtotime(date('Y', strtotime($date)) . 'W' . $week);
$dateDay = new \DateTime(date('Y-m-d', strtotime($dayWeek, $start)));
$activeDay = $this->pointSaleRepository->isDayOfWeekWithDelivery($dayWeek);
if ($activeDay || !$active) {
$this->activeDistributionByDate($dateDay, $active);
}
$this->activeDistributionByDateIfDelivery($dateDay, $active);
}

public function activeDistributionsOfWeek(string $date, bool $active = true): void

+ 7
- 2
console/commands/ActiveDistributionsInAdvanceController.php Datei anzeigen

@@ -19,8 +19,13 @@ class ActiveDistributionsInAdvanceController extends Controller
$weeksDistributionsActivatedInAdvance = $producerModule->getSolver()->getConfig('option_weeks_distributions_activated_in_advance');
if($weeksDistributionsActivatedInAdvance) {
$date = new \DateTime('+'.$weeksDistributionsActivatedInAdvance.' weeks');
$distributionModule->getBuilder()->activeDistributionByDate($date);
echo $producer->name. ' : distribution du ' . $date->format('d/m/Y') .' activée' ."\n";
$distributionModule->getBuilder()->activeDistributionByDateIfDelivery($date);

$distribution = $distributionModule->getRepository()
->findOneDistribution($date->format('Y-m-d'), true);
if($distribution) {
echo $producer->name. ' : distribution du ' . $date->format('d/m/Y') .' activée' ."\n";
}
}
}
}

Laden…
Abbrechen
Speichern