Bugzilla – Attachment 156780 Details for
Bug 6796
Overnight checkouts taking into account opening and closing hours
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6796: [WIP] (follow-up) Displaying library hours
Bug-6796-WIP-follow-up-Displaying-library-hours.patch (text/plain), 9.72 KB, created by
Aleisha Amohia
on 2023-10-10 04:09:19 UTC
(
hide
)
Description:
Bug 6796: [WIP] (follow-up) Displaying library hours
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2023-10-10 04:09:19 UTC
Size:
9.72 KB
patch
obsolete
>From dc561e818bbf16a212b41f6d8b2392eae84b168c Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 10 Oct 2023 04:06:48 +0000 >Subject: [PATCH] Bug 6796: [WIP] (follow-up) Displaying library hours > >This patch shows the set library hours on a library's view page. >Still to be done: >- show on the Libraries summary page >- write tests >- consider time format settings >- fix translateability of day names in Libraries summary page >--- > Koha/Library.pm | 13 ++++ > admin/branches.pl | 8 +-- > admin/columns_settings.yml | 2 + > api/v1/swagger/definitions/library.yaml | 5 ++ > api/v1/swagger/paths/libraries.yaml | 5 ++ > .../prog/en/modules/admin/branches.tt | 63 +++++++++++++++++-- > 6 files changed, 85 insertions(+), 11 deletions(-) > >diff --git a/Koha/Library.pm b/Koha/Library.pm >index 0cad18364fb..9ce25735ac1 100644 >--- a/Koha/Library.pm >+++ b/Koha/Library.pm >@@ -26,6 +26,7 @@ use Koha::Caches; > use Koha::Database; > use Koha::StockRotationStages; > use Koha::SMTP::Servers; >+use Koha::Library::Hours; > > use base qw(Koha::Object); > >@@ -418,6 +419,18 @@ sub validate_float_sibling { > return $self->get_float_libraries->search( { branchcode => $branchcode } )->count > 0; > } > >+=head3 library_hours >+ >+Returns the open and close times for a library. >+ >+=cut >+ >+sub library_hours { >+ my $self = shift; >+ my $library_hours_rs = $self->_result->library_hours; >+ return Koha::Library::Hours->_new_from_dbic($library_hours_rs); >+} >+ > =head2 Internal methods > > =head3 _type >diff --git a/admin/branches.pl b/admin/branches.pl >index e4bc88278a0..a78f0d6bffc 100755 >--- a/admin/branches.pl >+++ b/admin/branches.pl >@@ -50,13 +50,9 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > ); > > if ( $op eq 'add_form' ) { >- my @opening_hours = >- Koha::Library::Hours->search( { library_id => $branchcode }, { order_by => { -asc => 'day' } } )->as_list; >- > $template->param( >- library => Koha::Libraries->find($branchcode), >- smtp_servers => Koha::SMTP::Servers->search, >- opening_hours => \@opening_hours >+ library => Koha::Libraries->find($branchcode), >+ smtp_servers => Koha::SMTP::Servers->search, > ); > } elsif ( $branchcode && $op eq 'view' ) { > my $library = Koha::Libraries->find($branchcode); >diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml >index 34f3508a327..d2146b4d738 100644 >--- a/admin/columns_settings.yml >+++ b/admin/columns_settings.yml >@@ -359,6 +359,8 @@ modules: > columnname: public > - > columnname: smtp_server >+ - >+ columnname: library_hours > - > columnname: actions > cannot_be_toggled: 1 >diff --git a/api/v1/swagger/definitions/library.yaml b/api/v1/swagger/definitions/library.yaml >index de010c50d30..789d8b6bdfa 100644 >--- a/api/v1/swagger/definitions/library.yaml >+++ b/api/v1/swagger/definitions/library.yaml >@@ -115,6 +115,11 @@ properties: > needs_override: > type: boolean > description: If the library needs an override to act as pickup location for a hold >+ library_hours: >+ type: >+ - object >+ - "null" >+ description: The open and close times for a library on any given day > additionalProperties: false > required: > - library_id >diff --git a/api/v1/swagger/paths/libraries.yaml b/api/v1/swagger/paths/libraries.yaml >index af452c59072..ead9798d60b 100644 >--- a/api/v1/swagger/paths/libraries.yaml >+++ b/api/v1/swagger/paths/libraries.yaml >@@ -87,6 +87,11 @@ > description: Case insensitive 'starts_with' search on notes > required: false > type: string >+ - name: library_hours >+ in: query >+ description: Case insensitive 'starts_with' search on notes >+ required: false >+ type: string > - $ref: "../swagger.yaml#/parameters/match" > - $ref: "../swagger.yaml#/parameters/order_by" > - $ref: "../swagger.yaml#/parameters/page" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >index ad05c0fa104..42f10d01067 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >@@ -287,8 +287,8 @@ > <div class="hint">Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.</div> > </li> > <li> >- <label for="opening_hours">Opening hours: </label> >- <table id="opening_hours_table"> >+ <label for="library_hours">Opening hours: </label> >+ <table id="library_hours_table"> > <thead> > <tr> > <th>Day</th> >@@ -297,9 +297,9 @@ > </tr> > </thead> > <tbody> >- [% IF opening_hours # Existing library %] >+ [% IF library.library_hours # Existing library %] > [% daycount = 0 %] >- [% FOREACH hr IN opening_hours %] >+ [% FOREACH hr IN library.library_hours %] > <tr id="hours_[% daycount | html %]"> > <td> > [% PROCESS dayname day=daycount %] >@@ -398,6 +398,7 @@ > <th>Pickup location</th> > <th>Public</th> > <th>SMTP server</th> >+ <th>Library hours</th> > <th data-class-name="actions noExport">Actions</th> > </tr> > </thead> >@@ -528,6 +529,39 @@ > <span>No</span> > [% END %] > </li> >+ <li> >+ <span class="label">Opening hours: </span> >+ [% IF library.library_hours # Existing library %] >+ <table id="library_hours_table"> >+ <thead> >+ <tr> >+ <th>Day</th> >+ <th>Open time</th> >+ <th>Close time</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% daycount = 0 %] >+ [% FOREACH hr IN library.library_hours %] >+ <tr id="hours_[% daycount | html %]"> >+ <td> >+ <span>[% PROCESS dayname day=daycount %]</span> >+ </td> >+ <td> >+ <span>[% hr.open_time | html %]</span> >+ </td> >+ <td> >+ <span>[% hr.close_time | html %]</span> >+ </td> >+ </tr> >+ [% daycount = daycount+1 %] >+ [% END %] >+ </tbody> >+ </table> >+ [% ELSE %] >+ <span>No opening hours have been set.</span> >+ [% END %] >+ </li> > </ol> > </div> <!-- /.rows --> > </div> <!-- /.col-sm-6 --> >@@ -576,7 +610,7 @@ > 'emptyTable': '<div class="dialog message">'+_("There are no libraries defined.")+' <a href="/cgi-bin/koha/admin/branches.pl?op=add_form">'+_("Start defining libraries")+'</a>.</div>', > "stateSave": true, > "columnDefs": [ { >- "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16], >+ "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16,17], > "render": function (data, type, row, meta) { > if ( type == 'display' ) { > if ( data != null ) { >@@ -671,6 +705,25 @@ > "visible": true, > "orderable": false > }, >+ { >+ "data": function( row, type, val, meta ) { >+ const daynames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']; >+ var daycount = 0; >+ var result = '<table id="library_hours_table"><thead><tr><th>Day</th><th>Open time</th><th>Close time</th></tr></thead><tbody>'; >+ while ( row.library_hours[daycount] ) { >+ result += '<tr id="hours_"'+daycount+'>'; >+ result += '<td>'+daynames[daycount]+'</td>'; >+ result += '<td><span>'+row.open_time+'</span></td>'; >+ result += '<td><span>'+row.close_time+'</span></td>'; >+ result += '</tr>'; >+ daycount++; >+ } >+ result += '</tbody></table>'; >+ return result; >+ }, >+ "searchable": false, >+ "orderable": false >+ }, > { > "data": function( row, type, val, meta ) { > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6796
:
124669
|
124670
|
124671
|
124672
|
134323
|
134324
|
134325
|
134326
|
134327
|
145669
|
145670
|
145671
|
145672
|
145673
|
146988
|
146989
|
146990
|
146991
|
146992
|
150442
|
150443
|
150444
|
150445
|
150446
|
150447
|
150448
|
150477
|
150478
|
153252
|
153253
|
153254
|
153255
|
153256
|
153257
|
153258
|
153259
|
153260
|
153261
|
153271
|
153272
|
153273
|
153274
|
153275
|
153276
|
153277
|
153278
|
153279
|
153280
|
156772
|
156773
|
156774
|
156775
|
156776
|
156777
|
156778
|
156779
|
156780
|
161970
|
161971
|
161972
|
161973
|
161974
|
161975
|
161976
|
161977
|
161978
|
161979
|
161980
|
161986
|
161987
|
161988
|
161989
|
162043
|
162044
|
162045
|
162046
|
162047
|
162048
|
162049
|
162050
|
162051
|
162052
|
162053
|
162054
|
162055
|
162056
|
162090
|
162091
|
162092
|
162093
|
162094
|
162095
|
162096
|
162097
|
162098
|
162099
|
162100
|
162101
|
162102
|
162103
|
162104
|
164511
|
164512
|
164513
|
164514
|
164515
|
164516
|
164517
|
164518
|
164538
|
164539
|
164540
|
164541
|
164542
|
164543
|
164544
|
164545
|
164546
|
164547
|
164548
|
164549
|
164550
|
164551
|
164552