From b3d996496ae757a042d254758a9018ec24082c6d Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT <hdlaurent@afi-sa.fr> Date: Tue, 10 Nov 2020 22:20:36 +0100 Subject: [PATCH] hotline#120962 : Drive : Planning dates would sometimes not be displayed for un noticeable reason for user --- VERSIONS_HOTLINE/120962 | 1 + .../drive-checkout/list-all-holds.phtml | 5 +++++ library/Class/DriveCheckout/Holds.php | 2 +- library/Class/WebService/SIGB/Reservation.php | 7 +++++++ .../View/Helper/Abonne/ReservationsTable.php | 7 ++++++- .../Intonation/Library/View/Wrapper/Hold.php | 10 +++++++++ .../controllers/AbonneControllerPretsTest.php | 3 +-- .../Helper/Abonne/ReservationsTableTest.php | 21 ++++++++++++++++++- .../DriveCheckOutBookingTest.php | 17 ++++++++++----- .../DriveCheckoutAdminControllerTest.php | 10 +++++---- .../Templates/TemplatesAbonneTest.php | 15 ++++++++++++- 11 files changed, 83 insertions(+), 15 deletions(-) create mode 100644 VERSIONS_HOTLINE/120962 diff --git a/VERSIONS_HOTLINE/120962 b/VERSIONS_HOTLINE/120962 new file mode 100644 index 00000000000..b06ac7e522b --- /dev/null +++ b/VERSIONS_HOTLINE/120962 @@ -0,0 +1 @@ + - ticket #120962 : Drive et réservations : ajout de la date d\'expiration des reservations dans les listes et prise en compte de la dernière date d'expiration pour les réservations plutôt que la première \ No newline at end of file diff --git a/application/modules/admin/views/scripts/drive-checkout/list-all-holds.phtml b/application/modules/admin/views/scripts/drive-checkout/list-all-holds.phtml index 536a3431707..b17cff28938 100644 --- a/application/modules/admin/views/scripts/drive-checkout/list-all-holds.phtml +++ b/application/modules/admin/views/scripts/drive-checkout/list-all-holds.phtml @@ -3,6 +3,11 @@ echo $this->renderTable((new Class_TableDescription('holds')) ->addColumn($this->_('Bibliothèque'), function($hold) { return $hold->getBibliotheque(); }) ->addColumn($this->_('Code-barres'), function($hold) { return $hold->getCodeBarre(); }) ->addColumn($this->_('Etat'), function($hold) { return $hold->getEtat(); }) + ->addColumn($this->_('Expiration'), + function($hold) + { return $hold->getFormattedAvailabilityEndDate(); + }) + ->addColumn($this->_('Titre'), function($hold) { return $hold->getTitre(); }), $this->user->getReservations()); diff --git a/library/Class/DriveCheckout/Holds.php b/library/Class/DriveCheckout/Holds.php index 3566117b996..065ad5f3ed5 100644 --- a/library/Class/DriveCheckout/Holds.php +++ b/library/Class/DriveCheckout/Holds.php @@ -92,7 +92,7 @@ class Class_DriveCheckout_Holds extends Storm_Collection { if (null == $current) return $datetime; - return $current < $datetime ? $current : $datetime; + return $current > $datetime ? $current : $datetime; }); } } diff --git a/library/Class/WebService/SIGB/Reservation.php b/library/Class/WebService/SIGB/Reservation.php index f3640c20c11..29333dc7e90 100644 --- a/library/Class/WebService/SIGB/Reservation.php +++ b/library/Class/WebService/SIGB/Reservation.php @@ -98,6 +98,13 @@ class Class_WebService_SIGB_Reservation extends Class_WebService_SIGB_Exemplaire } + public function getFormattedAvailabilityEndDate() { + return $this->_availability_end_date + ? strftime('%d %B', strtotime($this->_availability_end_date)) + : ''; + } + + public function setLocationId($id) { $this->_location_id = $id; return $this; diff --git a/library/ZendAfi/View/Helper/Abonne/ReservationsTable.php b/library/ZendAfi/View/Helper/Abonne/ReservationsTable.php index a7ec5b90914..2c673b75468 100644 --- a/library/ZendAfi/View/Helper/Abonne/ReservationsTable.php +++ b/library/ZendAfi/View/Helper/Abonne/ReservationsTable.php @@ -86,7 +86,12 @@ class ZendAfi_View_Helper_Abonne_ReservationsTable extends ZendAfi_View_Helper_A . $this->_tag('td', $reservation->getBibliotheque()) . $this->_tag('td', - $reservation->getEtat()) + $reservation->getEtat() + . ( + ($end_availability = $reservation->getFormattedAvailabilityEndDate()) + ? $this->_(' jusqu\'au %s', $end_availability) + : '' + )) . $this->_tag('td', $reservation->getRang()) . $this->_tag('td', diff --git a/library/templates/Intonation/Library/View/Wrapper/Hold.php b/library/templates/Intonation/Library/View/Wrapper/Hold.php index a0aef046a5f..b27dcb29e32 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Hold.php +++ b/library/templates/Intonation/Library/View/Wrapper/Hold.php @@ -207,6 +207,16 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp ->setTitle($this->_('Rang de la réservation: %s', $this->_model->getRang()))) ]; + if ($end_availability = $this->_model->getFormattedAvailabilityEndDate()) + $badges []= (new Intonation_Library_Badge) + ->setTag('span') + ->setClass('warning') + ->setImage(Class_Template::current()->getIco($this->_view, + 'library', + 'agenda')) + ->setText($end_availability) + ->setTitle($this->_('Expire le: %s', $end_availability)); + return $this->_view->renderBadges($badges, $this); } diff --git a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php index 3e5ebb3432f..a5a3642b7b7 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php @@ -728,8 +728,7 @@ class AbonneControllerPretsListReservationTest extends AbonneControllerPretsList /** @test */ public function authorShouldBeRowlingAndLinkSearch() { $this->assertXPathContentContains('//tbody/tr[1]//td//a[@href="/recherche/simple/code_rebond/A456/retour_abonne/reservations"]', - 'JOANNE KATHLEEN ROWLING', - $this->_response->getBody()); + 'JOANNE KATHLEEN ROWLING'); } diff --git a/tests/library/ZendAfi/View/Helper/Abonne/ReservationsTableTest.php b/tests/library/ZendAfi/View/Helper/Abonne/ReservationsTableTest.php index 7a52b0eb56b..70ed7de14d6 100644 --- a/tests/library/ZendAfi/View/Helper/Abonne/ReservationsTableTest.php +++ b/tests/library/ZendAfi/View/Helper/Abonne/ReservationsTableTest.php @@ -36,6 +36,11 @@ class ReservationsTableTest extends ViewHelperTestCase { ['id' => 120, 'type_doc' => Class_TypeDoc::LIVRE]); + $jdf_record = $this->fixture('Class_Notice', + ['id' => 340, + 'type_doc' => Class_TypeDoc::LIVRE]) + ->setTitrePrincipal('Le jour des fourmis'); + $harry_potter = new Class_WebService_SIGB_Reservation('10', new Class_WebService_SIGB_Exemplaire(100)); $harry_potter->getExemplaire() ->setTitre('Harry Potter') @@ -51,8 +56,16 @@ class ReservationsTableTest extends ViewHelperTestCase { ->setNoticeOPAC($marche_record); $le_marche->setEtat('Disponible'); + $le_jour_des_fourmis = new Class_WebService_SIGB_Reservation('10', new Class_WebService_SIGB_Exemplaire(100)); + $le_jour_des_fourmis->getExemplaire() + ->setTitre('Le jour des fourmis') + ->setCodeBarre(13579) + ->setNoticeOPAC($jdf_record); + $le_jour_des_fourmis->setEtat('Mis de côté') + ->setAvailabilityEndDate('2020-06-06'); + $emprunteur = new Class_WebService_SIGB_Emprunteur('1234', 'Estelle'); - $emprunteur->reservationsAddAll([$harry_potter, $le_marche]); + $emprunteur->reservationsAddAll([$harry_potter, $le_marche, $le_jour_des_fourmis]); $this->fixture('Class_Exemplaire', ['id' => 45, @@ -98,6 +111,12 @@ class ReservationsTableTest extends ViewHelperTestCase { } + /** @test */ + public function lineLeJourDesFourmisShouldContainsExpirationDate05Mai() { + $this->assertXPath($this->_html, '//td[text()="Le jour des fourmis"]/following-sibling::td[contains(text(),"06 juin")]'); + } + + /** @test */ public function HarryPotterTitleShouldBeLinkToNotice() { $this->assertXPathContentContains($this->_html, '//td/a[contains(@href, "recherche/viewnotice/id/100/retour_abonne/reservations")]', 'Harry Potter'); diff --git a/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php b/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php index cd9c28fad48..530387b7442 100644 --- a/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php +++ b/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php @@ -149,7 +149,8 @@ abstract class DriveCheckOutBookingTestCase extends AbstractControllerTestCase { [$this->_holdIn(1)->setAvailabilityEndDate('2020-05-12'), $this->_holdIn(1)->setAvailabilityEndDate('2020-05-13'), $this->_holdIn(2), - $this->_holdIn(4)])]); + $this->_holdIn(4), + $this->_holdIn(1)->setAvailabilityEndDate('2020-05-01')])]); ZendAfi_Auth::getInstance()->logUser($this->_marcus); @@ -280,14 +281,14 @@ class DriveCheckOutBookingPlanTest extends DriveCheckOutBookingTestCase { /** @test */ public function pageShouldContainsBadge2Holds() { $this->assertXPathContentContains('//span[contains(@class, "badge-primary")]', - '2 réservations'); + '3 réservations'); } /** @test */ public function pageShouldContainsBadge2WaitingToBePulled() { $this->assertXPathContentContains('//span[contains(@class, "badge-success")]', - '2 à retirer'); + '3 à retirer'); } @@ -594,8 +595,14 @@ class DriveCheckOutBookingPlanBibHotelDieuTest extends DriveCheckOutBookingTestC /** @test */ - public function pageShouldNotContainsLinkToChoosePossibleButAfterMaxHold() { - $this->assertNotXPath('//a[contains(@href, "/checkout_date/2020-05-13")]'); + public function pageShouldContainsLinkToChooseLastAvailabilityEndDate() { + $this->assertXPath('//a[contains(@href, "/checkout_date/2020-05-13")]'); + } + + + /** @test */ + public function pageShouldNotContainsLinkToChoosePastLastAvailabilityEndDate() { + $this->assertNotXPath('//a[contains(@href, "/checkout_date/2020-05-14")]'); } diff --git a/tests/scenarios/DriveCheckOut/DriveCheckoutAdminControllerTest.php b/tests/scenarios/DriveCheckOut/DriveCheckoutAdminControllerTest.php index 5694ab45f36..bf19c826e81 100644 --- a/tests/scenarios/DriveCheckOut/DriveCheckoutAdminControllerTest.php +++ b/tests/scenarios/DriveCheckOut/DriveCheckoutAdminControllerTest.php @@ -100,13 +100,15 @@ abstract class DriveCheckOutAdminControllerTestCase extends Admin_AbstractContro ->setCodeBarre('tintin123') ->setTitre('Tintin à Dole') ->setEtat('On le cherche') - ->setWaitingToBePulled(), + ->setWaitingToBePulled() + ->setAvailabilityEndDate('2020-05-05'), Class_WebService_SIGB_Reservation::newInstanceWithEmptyExemplaire() ->setBibliotheque($lib_camus->getLibelle()) ->setCodeBarre('milou123') ->setTitre('Milou à Dole') - ->setWaitingToBePulled(), + ->setWaitingToBePulled() + ->setAvailabilityEndDate('2020-05-14'), Class_WebService_SIGB_Reservation::newInstanceWithEmptyExemplaire() ->setBibliotheque($lib_maurissette->getLibelle()) @@ -470,8 +472,8 @@ class DriveCheckoutAdminControllerListAllHoldsForMauriceIdFourTest extends Drive /** @test */ - public function tableShouldContainsHoldOnTintin() { - $this->assertXPath('//table//td[text()="Tintin à Dole"]'); + public function tableShouldContainsHoldOnTintinAnd5Mai() { + $this->assertXPath('//table//td[text()="05 mai"]/following-sibling::td[text()="Tintin à Dole"]'); } } diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index f3aa4dfa406..7681f5b405d 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -120,6 +120,8 @@ abstract class TemplatesIntonationAccountTestCase extends TemplatesIntonationTes 'Bibliotheque' => 'Tombouctou', 'N° de notice' => 564]); + $dobby->setAvailabilityEndDate('2020-06-06'); + $istres = $this->fixture('Class_CodifAnnexe', ['id' => 15, 'libelle' => 'Istres', @@ -524,11 +526,22 @@ class TemplatesDispatchAbonneLoansWithHistoryTest extends TemplatesIntonationAcc class TemplatesDispatchAbonneHoldsTest extends TemplatesIntonationAccountTestCase { + public function setUp(){ + parent::setUp(); + $this->dispatch('/opac/abonne/reservations/id_profil/72'); + } + + /** @test */ public function holdsDobbyPotterShouldBeDisplay() { - $this->dispatch('/opac/abonne/reservations/id_profil/72'); $this->assertXPathContentContains('//div', 'Dobby Potter'); } + + + /** @test */ + public function holdsDobbyPotterBadgeForAvailabilityEndDateShouldContainsSixJuin() { + $this->assertXPathContentContains('//div[contains(@class,"badge_group_Intonation_Library_View_Wrapper_Hold")]//span[@title="Expire le: 06 juin"]', '06 juin'); + } } -- GitLab