Commit cf7cb3ed authored by SuliacLavenant's avatar SuliacLavenant Committed by Regis
Browse files

#88 fix multiple track with same name in event manualy sselection

parent 8d628c93
...@@ -91,6 +91,34 @@ class Track ...@@ -91,6 +91,34 @@ class Track
return $this->totalTime; return $this->totalTime;
} }
public function getTotalTimeInHMS(): string
{
$sec = (int)($this->totalTime / 1000);
$hou = 0;
$min = 0;
if ($sec >= 3600) {
$hou = floor($sec / 3600);
$sec = $sec % 3600;
}
if ($sec >= 60) {
$min = floor($sec / 60);
$sec = $sec % 60;
}
if (strlen((string)$hou) === 1) {
$hou = "0".$hou;
}
if (strlen((string)$min) === 1) {
$min = "0".$min;
}
if (strlen((string)$sec) === 1) {
$sec = "0".$sec;
}
return $hou.":".$min.":".$sec;
}
public function setTotalTime(int $totalTime): self public function setTotalTime(int $totalTime): self
{ {
$this->totalTime = $totalTime; $this->totalTime = $totalTime;
......
...@@ -19,9 +19,24 @@ class ModifyParticipantMakeEventCourseType extends AbstractType ...@@ -19,9 +19,24 @@ class ModifyParticipantMakeEventCourseType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$tracks = []; $tracks = [];
$tracksSimple = [];
$duplicates = [];
$tracks["-"] = null; $tracks["-"] = null;
foreach ($options['course']->getOrienteer() as $track){ foreach ($options['course']->getOrienteer() as $track) {
$tracks[$track->getName()] = $track; if (array_key_exists($track->getName(), $duplicates)) {
if ($duplicates[$track->getName()] === 1) {
$timeOfTheTrack = $tracksSimple[$track->getName()]->getTotalTimeInHMS();
$tracks[$track->getName() . " [1] (" . $timeOfTheTrack . ")"] = $tracks[$track->getName() . " (" . $timeOfTheTrack . ")"];
unset($tracks[$track->getName() . " (" . $timeOfTheTrack . ")"]);
}
$duplicates[$track->getName()] += 1;
$tracks[$track->getName() . " [" . $duplicates[$track->getName()] . "] (" . $track->getTotalTimeInHMS() . ")"] = $track;
} else {
$tracks[$track->getName() . " (" . $track->getTotalTimeInHMS() . ")"] = $track;
$tracksSimple[$track->getName()] = $track;
$duplicates[$track->getName()] = 1;
}
} }
$builder $builder
->add( ->add(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment