Browse code

Fix assistant issue with timeframe ending exactly on end date of possible slot and also fix endless loop issue with a buffer time of 0

Benjamin Roth authored on03/09/2025 12:29:46
Showing1 changed files
... ...
@@ -468,7 +468,7 @@ class WeinanlieferungSlotAssistantController extends AbstractController
468 468
             $arrEndTimes = [];
469 469
 
470 470
             // Get existing slots in the timeframe
471
-            $ExistingSlots = $this->db->prepare("SELECT id, date, time as 'start', (time+duration*60) as 'end', duration FROM tl_vr_wa_slot WHERE pid = ? AND (time >= ? OR time+$intDuration+$intBuffer >= ?) AND (time <= ? OR time+$intDuration+$intBuffer <= ?) ORDER BY time")
471
+            $ExistingSlots = $this->db->prepare("SELECT id, date, time as 'start', (time+duration*60-1) as 'end', duration FROM tl_vr_wa_slot WHERE pid = ? AND (time >= ? OR time+$intDuration+$intBuffer >= ?) AND (time <= ? OR time+$intDuration+$intBuffer <= ?) ORDER BY time")
472 472
                                       ->executeQuery([$Standort->id, $intStart, $intStart, $intEnd, $intEnd]);
473 473
 
474 474
             if ($ExistingSlots->rowCount())
... ...
@@ -486,7 +486,7 @@ class WeinanlieferungSlotAssistantController extends AbstractController
486 486
 
487 487
             // Create all possible timeslots for given timeframe
488 488
             $intTime = $intStart;
489
-            while ($intTime < $intEnd-$intDuration)
489
+            while ($intTime <= $intEnd-$intDuration)
490 490
             {
491 491
                 $arrConflicts = [];
492 492
 
... ...
@@ -509,7 +509,7 @@ class WeinanlieferungSlotAssistantController extends AbstractController
509 509
 
510 510
                 if (\count($arrConflicts) > 0)
511 511
                 {
512
-                    $intTime = max($arrConflicts) + $intBuffer;
512
+                    $intTime = max($arrConflicts) + (max($intBuffer,1));
513 513
                     continue;
514 514
                 }
515 515