From 498192cfe20b3a0798f5881ecdd76cec6c44a44e Mon Sep 17 00:00:00 2001
From: Laurent Laffont <llaffont@afi-sa.fr>
Date: Fri, 29 May 2020 10:59:58 +0200
Subject: [PATCH] hotline#111308 : Drive : Cannot select pickup date

---
 VERSIONS_HOTLINE/111308                                    | 1 +
 library/Class/Bib.php                                      | 2 +-
 tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)
 create mode 100644 VERSIONS_HOTLINE/111308

diff --git a/VERSIONS_HOTLINE/111308 b/VERSIONS_HOTLINE/111308
new file mode 100644
index 00000000000..d8555e1b813
--- /dev/null
+++ b/VERSIONS_HOTLINE/111308
@@ -0,0 +1 @@
+ - ticket #111308 : Drive : Correction de la sélection des dates lorsque la fiche bibliothèque contient des horaires.
\ No newline at end of file
diff --git a/library/Class/Bib.php b/library/Class/Bib.php
index b752ce541b7..d78de69e89b 100644
--- a/library/Class/Bib.php
+++ b/library/Class/Bib.php
@@ -957,7 +957,7 @@ class Class_Bib extends Storm_Model_Abstract {
 
 
   public function getOuvertureOnDate($time, $used_for = Class_Ouverture::USED_FOR_LIBRARY) {
-    if ($this->hasHoraire())
+    if ($used_for !== Class_Ouverture::USED_FOR_DRIVE && $this->hasHoraire())
       return null;
 
     if ($ouverture = Class_Ouverture::findFirstBy(['jour' => date('Y-m-d', $time),
diff --git a/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php b/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php
index ef9f3018744..8a2663d2922 100644
--- a/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php
+++ b/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php
@@ -100,6 +100,7 @@ abstract class DriveCheckOutBookingTestCase extends AbstractControllerTestCase {
                  'libelle' => 'Hotel-Dieu',
                  'closed_on_holidays' => false,
                  'enable_drive' => 1,
+                 'horaire' => 'Ouvert tous les lundis, mardi et mercedi',
                  'ouvertures' => [
                                   Class_Ouverture::chaqueLundi('00:00', '00:00', '12:00', '18:00')
                                   ->beDrive(),
-- 
GitLab