Bug 23268

Summary: "Suspend all holds" calendar allows to select past date
Product: Koha Reporter: Emmi Takkinen <emmi.takkinen>
Component: TemplatesAssignee: Emmi Takkinen <emmi.takkinen>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: 1joynelson, david.roberts, emmi.takkinen, jonathan.druart, lucas
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.05
Attachments: Bug 23268: "Suspend all holds" calendar allows to select past date
Bug 23268: "Suspend all holds" calendar allows to select past date
Bug 23268: Make "Suspend all holds" calendar select a date from tomorrow

Description Emmi Takkinen 2019-07-05 07:13:07 UTC
When using "Suspend all holds" in "circulation" and "moremember" templates, patron is able to select past dates. This doesn't occur when suspending individual holds.
Comment 1 Emmi Takkinen 2019-07-05 08:50:01 UTC
Created attachment 91327 [details] [review]
Bug 23268:  "Suspend all holds" calendar allows to  select past date

This patch removes "circulation" and moremember" templates functions
for Datepicker plugin. They now use options common for all inputs with
"datepicker" class and get "minDate" option from id assigned function
in "calender.inc"

To test:
- Apply patch
- Add holds for patron
- Use "Suspend all holds" calendar
=>Calendar greys out dates past from today
Comment 2 Owen Leonard 2019-07-05 14:20:53 UTC
I wish I understood why this bug exists! Looking at the code I don't understand what we're doing wrong.

However, seeing the change made in calendar.inc gives me the idea that we might apply a fix which is more generalized:

We could use the jQueryUI datepicker's "option" method to apply a special configuration if the date field has a particular class:

    $(".futuredate").datepicker("option", { minDate: 1 });

Then we modify the suspend_until fields:

<input type="text" size="10" id="suspend_until" name="suspend_until" class="datepicker futuredate"/>

I would prefer this to adding code to calendar.inc which targets a specific ID. What do you think?
Comment 3 Emmi Takkinen 2019-07-08 05:07:31 UTC
I agree, generalizing this works far better.
Comment 4 Emmi Takkinen 2019-07-08 05:31:57 UTC
Created attachment 91400 [details] [review]
Bug 23268:  "Suspend all holds" calendar allows to   select past date

This patch removes "circulation" and moremember" templates functions
for Datepicker plugin. They now use options common for all inputs with
"datepicker" class and get "minDate" option from class "futuredate" assigned
function in "calender.inc".

To test:
- Apply patch
- Add holds for patron
- Use "Suspend all holds" calendar
=>Calendar greys out dates past from today
Comment 5 David Roberts 2020-02-15 00:43:27 UTC
Tested in my dev environment, and works perfectly as per test plan.
Comment 6 Jonathan Druart 2020-03-10 12:03:59 UTC
Created attachment 100452 [details] [review]
Bug 23268: Make "Suspend all holds" calendar select a date from tomorrow

This patch removes "circulation" and moremember" templates functions
for Datepicker plugin. They now use options common for all inputs with
"datepicker" class and get "minDate" option from class "futuredate" assigned
function in "calender.inc".

To test:
- Apply patch
- Add holds for patron
- Use "Suspend all holds" calendar
=>Calendar greys out dates past from today

Signed-off-by: David Roberts <david.roberts@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Amended patch: Align .futuredate in calendar.inc
Comment 7 Jonathan Druart 2020-03-10 12:04:23 UTC
Note: the value still can be forced if the input is edited manually.
Comment 8 Martin Renvoize 2020-03-10 15:17:38 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 9 Joy Nelson 2020-04-02 20:38:34 UTC
Backported to 19.11.x for 19.11.05
Comment 10 Lucas Gass 2020-04-09 21:01:30 UTC
enhancement will not be backported to 19.05.x