Bug 12137 - Extend CalendarFirstDayOfWeek to be any day
Summary: Extend CalendarFirstDayOfWeek to be any day
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Mark Tompsett
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-24 23:08 UTC by Mark Tompsett
Modified: 2016-12-05 21:23 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 12137 - Extend CalendarFirstDayOfWeek to be any day (9.35 KB, patch)
2014-04-24 23:22 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 12137 - Extend CalendarFirstDayOfWeek to be any day (9.91 KB, patch)
2014-06-02 15:42 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 12137 - Extend CalendarFirstDayOfWeek to be any day (9.91 KB, patch)
2014-11-21 00:07 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 12137 - Extend CalendarFirstDayOfWeek to be any day (10.36 KB, patch)
2015-03-19 17:00 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 12137 - Extend CalendarFirstDayOfWeek to be any day (10.51 KB, patch)
2015-06-18 18:24 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 12137 - Extend CalendarFirstDayOfWeek to be any day (10.58 KB, patch)
2015-06-20 07:34 UTC, Indranil Das Gupta
Details | Diff | Splinter Review
(possible followup) sort <select> index by value (1.81 KB, patch)
2015-06-20 12:56 UTC, Indranil Das Gupta
Details | Diff | Splinter Review
Bug 12137: followup sort <select> index by value (1.95 KB, patch)
2015-06-20 17:12 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 12137 - Extend CalendarFirstDayOfWeek to be any day (10.65 KB, patch)
2015-06-22 13:46 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12137: followup sort <select> index by value (2.02 KB, patch)
2015-06-22 13:46 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12137: Use Koha.Preference to access pref value (4.12 KB, patch)
2015-06-22 13:46 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Tompsett 2014-04-24 23:08:58 UTC
On the Koha list,
Mubassir Ahsan<mahsandu@gmail.com> asked:
> Is there any option to set Saturday as First Day of Week. Please help me. I
> am [stuck].

CalendarFirstDayOfWeek is either Sunday|Monday.

By converting it to 0|1|2|3|4|5|6 (Sunday, Monday, ..., Saturday), we can allow any day of the week to be the first day of the week in the date picker.
Comment 1 Mark Tompsett 2014-04-24 23:22:55 UTC Comment hidden (obsolete)
Comment 2 Mark Tompsett 2014-04-25 00:24:43 UTC
YAY! Found it for OPAC

1) Log into OPAC
2) Personal Details Tab.
3) The date picker is there for the date of birth!

And it works. :)
Comment 3 Mark Tompsett 2014-04-25 00:25:53 UTC
NOTE: With the OPAC, you need to test prog and bootstrap themes.
Comment 4 Mark Tompsett 2014-05-15 15:20:15 UTC
Adding mahsandu@gmail.com to the list, since the request was theirs.
Comment 5 Mark Tompsett 2014-06-02 15:42:40 UTC Comment hidden (obsolete)
Comment 6 Mark Tompsett 2014-11-21 00:07:42 UTC Comment hidden (obsolete)
Comment 7 Mark Tompsett 2015-03-19 17:00:01 UTC Comment hidden (obsolete)
Comment 8 Indranil Das Gupta 2015-06-18 10:05:44 UTC
(In reply to M. Tompsett from comment #7)

Applying: Bug 12137 - Extend CalendarFirstDayOfWeek to be any day
Using index info to reconstruct a base tree...
M	C4/Auth.pm
M	installer/data/mysql/sysprefs.sql
M	installer/data/mysql/updatedatabase.pl
M	koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref
Auto-merging installer/data/mysql/updatedatabase.pl
CONFLICT (content): Merge conflict in installer/data/mysql/updatedatabase.pl
Auto-merging installer/data/mysql/sysprefs.sql
Auto-merging C4/Auth.pm
Failed to merge in the changes.
Patch failed at 0001 Bug 12137 - Extend CalendarFirstDayOfWeek to be any day
Comment 9 Indranil Das Gupta 2015-06-18 10:07:51 UTC
Comment on attachment 37017 [details] [review]
Bug 12137 - Extend CalendarFirstDayOfWeek to be any day

Review of attachment 37017 [details] [review]:
-----------------------------------------------------------------

::: installer/data/mysql/updatedatabase.pl
@@ +9804,4 @@
>      SetVersion($DBversion);
>  }
>  
> +$DBversion = "3.19.00.XXX";

prolly needs to be bumped up to 3.21.00.XXX
Comment 10 Mark Tompsett 2015-06-18 18:24:24 UTC Comment hidden (obsolete)
Comment 11 Indranil Das Gupta 2015-06-20 07:34:17 UTC Comment hidden (obsolete)
Comment 12 Indranil Das Gupta 2015-06-20 12:56:38 UTC Comment hidden (obsolete)
Comment 13 Mark Tompsett 2015-06-20 17:12:38 UTC Comment hidden (obsolete)
Comment 14 Jonathan Druart 2015-06-22 11:50:57 UTC
Since the list is complete, it would have been easier to add 'Saturday', don't you think?
Comment 15 Mark Tompsett 2015-06-22 12:09:28 UTC
(In reply to Jonathan Druart from comment #14)
> Since the list is complete, it would have been easier to add 'Saturday',
> don't you think?

And then add 'Wednesday' or some other day when someone else asks? It's easier to change the values to do any day.
Comment 16 Jonathan Druart 2015-06-22 12:18:15 UTC
(In reply to M. Tompsett from comment #15)
> (In reply to Jonathan Druart from comment #14)
> > Since the list is complete, it would have been easier to add 'Saturday',
> > don't you think?
> 
> And then add 'Wednesday' or some other day when someone else asks? It's
> easier to change the values to do any day.

Nobody uses Wednesday as the first day of the week.
The 3 possible values are Saturday, Sunday and Monday.

https://en.wikipedia.org/wiki/Names_of_the_days_of_the_week#Numbered_days_of_the_week
Comment 17 Mark Tompsett 2015-06-22 12:29:42 UTC
(In reply to Jonathan Druart from comment #14)
> Since the list is complete, it would have been easier to add 'Saturday',
> don't you think?

Look at the old code:
CalendarFirstDayOfWeek => ( C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday" ) ? 0 : 1

Is it easier to extend that with more code? Or just use the values 0-6 in the first place?
Comment 18 Jonathan Druart 2015-06-22 12:39:40 UTC
(In reply to M. Tompsett from comment #17)
> (In reply to Jonathan Druart from comment #14)
> > Since the list is complete, it would have been easier to add 'Saturday',
> > don't you think?
> 
> Look at the old code:
> CalendarFirstDayOfWeek => (
> C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday" ) ? 0 : 1
> 
> Is it easier to extend that with more code? Or just use the values 0-6 in
> the first place?

C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday"
 ? 0
 : C4::Context->preference("CalendarFirstDayOfWeek") eq "Saturday"
   ? 6
   : 1

Not very difficult.
We will just need to update the different options available for the pref and if someone already uses this value outside of Koha (ok, there is certainly nobody), he could continue to do it.

But this is not the question, is there another value than can exist for the "first day of week"?
If only Sunday, Monday and Saturday are used all around the world, I don't see any sense to propose the 4 other days :)
Comment 19 Marcel de Rooy 2015-06-22 12:52:30 UTC
(In reply to Jonathan Druart from comment #18)
> If only Sunday, Monday and Saturday are used all around the world, I don't
> see any sense to propose the 4 other days :)

Why should we use more bits for a date. We will never reach 2000.. LOL
Comment 20 Jonathan Druart 2015-06-22 13:46:05 UTC
Created attachment 40472 [details] [review]
Bug 12137 - Extend CalendarFirstDayOfWeek to be any day

Mubassir Ahsan asked on the Koha mailing list:
Is there any option to set Saturday as the first day of
the week? Please help me.

CalendarFirstDayOfWeek is currently either Sunday|Monday.

By converting it to 0|1|2|3|4|5|6
(Sunday, Monday, ..., Saturday), we can allow any day of the
week to be the first day of the week in the date picker.

TEST PLAN
---------
1) Backup DB
2) In mysql:
   > DELETE FROM systempreferences;
   > SOURCE .../installer/data/mysql/sysprefs.sql
   > SELECT variable,value FROM systempreferences;
   -- It should say 'CalendarFirstDayOfWeek' and '0'
      May say '1' if you are using Norwegian.
3) Restore your DB
4) .../installer/data/mysql/updatedatabase.pl
   -- If your previous value for 'CalendarFirstDayOfWeek' was
      'Sunday', it should be '0'. For 'Monday', it should be '1'.
5) Test an installation with 'de-DE' as the language.
   -- The default value should be '1'.
6) Test an installation with 'nb-NO' as the language.
   -- The default value should be '1'.
7) In the staff client, confirm that any day of the week is
   available in the I18N/L10N system preferences for the
   CalendarFirstDayOfWeek dropdown.
   -- I'm aware they aren't in order, but I'm after
      functionality, not finesse.
8) In another tab, go to a staff place that has a datepicker.
   For example, Home -> Tools -> Inventory/stocktaking
9) For each possible value in the CalendarFirstDayOfWeek,
   go to the other tab, refresh the page after updating the
   system preference, and click the datepicker icon.
   -- The date picker should then start on the selected
      day of the week.
10) Log into OPAC
    -- This may require setting: opacuserlogin to 'Allow'.
11) Click the personal details tab on the left.
12) There is a date picker for the date of birth.
    -- The date picker should then start on the selected
       day of the week.
13) Run koha QA test tools.

NOTE: not an atomic update, since this is an old patch.

Signed-off-by: Indranil Das Gupta (L2C2 Technologies) <indradg@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Comment 21 Jonathan Druart 2015-06-22 13:46:09 UTC
Created attachment 40473 [details] [review]
Bug 12137: followup sort <select> index by value

adds alphabetical sorting to <select> lists displayed by
preferences.tt. although added for sorting the days of the
week, this may have larger ramifications. haven't been
tested thoroughly, but no apparent breakage seems to be
happening in preferences.

NOTE: Nice tweak. Makes days of week in sensible order.
      Properly adds sorting based on documentation that
      is really hard to find.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Comment 22 Jonathan Druart 2015-06-22 13:46:13 UTC
Created attachment 40474 [details] [review]
Bug 12137: Use Koha.Preference to access pref value

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Comment 23 Jonathan Druart 2015-06-22 13:51:17 UTC
(In reply to Marcel de Rooy from comment #19)
> (In reply to Jonathan Druart from comment #18)
> > If only Sunday, Monday and Saturday are used all around the world, I don't
> > see any sense to propose the 4 other days :)
> 
> Why should we use more bits for a date. We will never reach 2000.. LOL

The first day of the week comes from tradition.
So let's say we are going to anticipate the change of a tradition.
Comment 24 Tomás Cohen Arazi 2015-07-20 14:06:25 UTC
Enahnement pushed to master.

Good job Mark and friends!