@@ -, +, @@
- 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(-)
--- a/Koha/Library.pm
+++ a/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);
@@ -420,6 +421,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
--- a/admin/branches.pl
+++ a/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);
--- a/admin/columns_settings.yml
+++ a/admin/columns_settings.yml
@@ -361,6 +361,8 @@ modules:
columnname: public
-
columnname: smtp_server
+ -
+ columnname: library_hours
-
columnname: actions
cannot_be_toggled: 1
--- a/api/v1/swagger/definitions/library.yaml
+++ a/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
--- a/api/v1/swagger/paths/libraries.yaml
+++ a/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"
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt
@@ -290,8 +290,8 @@
Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.
-
-
+
+
Day |
@@ -300,9 +300,9 @@
- [% IF opening_hours # Existing library %]
+ [% IF library.library_hours # Existing library %]
[% daycount = 0 %]
- [% FOREACH hr IN opening_hours %]
+ [% FOREACH hr IN library.library_hours %]
[% PROCESS dayname day=daycount %]
@@ -417,6 +417,7 @@
| Pickup location |
Public |
SMTP server |
+ Library hours |
Actions |
@@ -547,6 +548,39 @@
No
[% END %]
+
+ Opening hours:
+ [% IF library.library_hours # Existing library %]
+
+
+
+ Day |
+ Open time |
+ Close time |
+
+
+
+ [% daycount = 0 %]
+ [% FOREACH hr IN library.library_hours %]
+
+
+ [% PROCESS dayname day=daycount %]
+ |
+
+ [% hr.open_time | html %]
+ |
+
+ [% hr.close_time | html %]
+ |
+
+ [% daycount = daycount+1 %]
+ [% END %]
+
+
+ [% ELSE %]
+ No opening hours have been set.
+ [% END %]
+
@@ -616,7 +650,7 @@
'emptyTable': '',
"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 ) {
@@ -711,6 +745,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 = 'Day | Open time | Close time |
';
+ while ( row.library_hours[daycount] ) {
+ result += '';
+ result += ''+daynames[daycount]+' | ';
+ result += ''+row.open_time+' | ';
+ result += ''+row.close_time+' | ';
+ result += '
';
+ daycount++;
+ }
+ result += '
';
+ return result;
+ },
+ "searchable": false,
+ "orderable": false
+ },
{
"data": function( row, type, val, meta ) {
--