View | Details | Raw Unified | Return to bug 6796
Collapse All | Expand All

(-)a/Koha/Library.pm (+13 lines)
Lines 26-31 use Koha::Caches; Link Here
26
use Koha::Database;
26
use Koha::Database;
27
use Koha::StockRotationStages;
27
use Koha::StockRotationStages;
28
use Koha::SMTP::Servers;
28
use Koha::SMTP::Servers;
29
use Koha::Library::Hours;
29
30
30
use base qw(Koha::Object);
31
use base qw(Koha::Object);
31
32
Lines 418-423 sub validate_float_sibling { Link Here
418
    return $self->get_float_libraries->search( { branchcode => $branchcode } )->count > 0;
419
    return $self->get_float_libraries->search( { branchcode => $branchcode } )->count > 0;
419
}
420
}
420
421
422
=head3 library_hours
423
424
Returns the open and close times for a library.
425
426
=cut
427
428
sub library_hours {
429
    my $self             = shift;
430
    my $library_hours_rs = $self->_result->library_hours;
431
    return Koha::Library::Hours->_new_from_dbic($library_hours_rs);
432
}
433
421
=head2 Internal methods
434
=head2 Internal methods
422
435
423
=head3 _type
436
=head3 _type
(-)a/admin/branches.pl (-6 / +2 lines)
Lines 50-62 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
50
);
50
);
51
51
52
if ( $op eq 'add_form' ) {
52
if ( $op eq 'add_form' ) {
53
    my @opening_hours =
54
        Koha::Library::Hours->search( { library_id => $branchcode }, { order_by => { -asc => 'day' } } )->as_list;
55
56
    $template->param(
53
    $template->param(
57
        library       => Koha::Libraries->find($branchcode),
54
        library      => Koha::Libraries->find($branchcode),
58
        smtp_servers  => Koha::SMTP::Servers->search,
55
        smtp_servers => Koha::SMTP::Servers->search,
59
        opening_hours => \@opening_hours
60
    );
56
    );
61
} elsif ( $branchcode && $op eq 'view' ) {
57
} elsif ( $branchcode && $op eq 'view' ) {
62
    my $library = Koha::Libraries->find($branchcode);
58
    my $library = Koha::Libraries->find($branchcode);
(-)a/admin/columns_settings.yml (+2 lines)
Lines 359-364 modules: Link Here
359
              columnname: public
359
              columnname: public
360
            -
360
            -
361
              columnname: smtp_server
361
              columnname: smtp_server
362
            -
363
              columnname: library_hours
362
            -
364
            -
363
              columnname: actions
365
              columnname: actions
364
              cannot_be_toggled: 1
366
              cannot_be_toggled: 1
(-)a/api/v1/swagger/definitions/library.yaml (+5 lines)
Lines 115-120 properties: Link Here
115
  needs_override:
115
  needs_override:
116
    type: boolean
116
    type: boolean
117
    description: If the library needs an override to act as pickup location for a hold
117
    description: If the library needs an override to act as pickup location for a hold
118
  library_hours:
119
    type:
120
      - object
121
      - "null"
122
    description: The open and close times for a library on any given day
118
additionalProperties: false
123
additionalProperties: false
119
required:
124
required:
120
  - library_id
125
  - library_id
(-)a/api/v1/swagger/paths/libraries.yaml (+5 lines)
Lines 87-92 Link Here
87
        description: Case insensitive 'starts_with' search on notes
87
        description: Case insensitive 'starts_with' search on notes
88
        required: false
88
        required: false
89
        type: string
89
        type: string
90
      - name: library_hours
91
        in: query
92
        description: Case insensitive 'starts_with' search on notes
93
        required: false
94
        type: string
90
      - $ref: "../swagger.yaml#/parameters/match"
95
      - $ref: "../swagger.yaml#/parameters/match"
91
      - $ref: "../swagger.yaml#/parameters/order_by"
96
      - $ref: "../swagger.yaml#/parameters/order_by"
92
      - $ref: "../swagger.yaml#/parameters/page"
97
      - $ref: "../swagger.yaml#/parameters/page"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (-6 / +58 lines)
Lines 287-294 Link Here
287
                    <div class="hint">Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.</div>
287
                    <div class="hint">Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.</div>
288
                </li>
288
                </li>
289
                <li>
289
                <li>
290
                    <label for="opening_hours">Opening hours: </label>
290
                    <label for="library_hours">Opening hours: </label>
291
                    <table id="opening_hours_table">
291
                    <table id="library_hours_table">
292
                        <thead>
292
                        <thead>
293
                            <tr>
293
                            <tr>
294
                                <th>Day</th>
294
                                <th>Day</th>
Lines 297-305 Link Here
297
                            </tr>
297
                            </tr>
298
                        </thead>
298
                        </thead>
299
                        <tbody>
299
                        <tbody>
300
                            [% IF opening_hours # Existing library %]
300
                            [% IF library.library_hours # Existing library %]
301
                                [% daycount = 0 %]
301
                                [% daycount = 0 %]
302
                                [% FOREACH hr IN opening_hours %]
302
                                [% FOREACH hr IN library.library_hours %]
303
                                <tr id="hours_[% daycount | html %]">
303
                                <tr id="hours_[% daycount | html %]">
304
                                    <td>
304
                                    <td>
305
                                        [% PROCESS dayname day=daycount %]
305
                                        [% PROCESS dayname day=daycount %]
Lines 398-403 Link Here
398
                    <th>Pickup location</th>
398
                    <th>Pickup location</th>
399
                    <th>Public</th>
399
                    <th>Public</th>
400
                    <th>SMTP server</th>
400
                    <th>SMTP server</th>
401
                    <th>Library hours</th>
401
                    <th data-class-name="actions noExport">Actions</th>
402
                    <th data-class-name="actions noExport">Actions</th>
402
                </tr>
403
                </tr>
403
            </thead>
404
            </thead>
Lines 528-533 Link Here
528
                            <span>No</span>
529
                            <span>No</span>
529
                        [% END %]
530
                        [% END %]
530
                    </li>
531
                    </li>
532
                    <li>
533
                        <span class="label">Opening hours: </span>
534
                        [% IF library.library_hours # Existing library %]
535
                            <table id="library_hours_table">
536
                                <thead>
537
                                    <tr>
538
                                        <th>Day</th>
539
                                        <th>Open time</th>
540
                                        <th>Close time</th>
541
                                    </tr>
542
                                </thead>
543
                                <tbody>
544
                                    [% daycount = 0 %]
545
                                    [% FOREACH hr IN library.library_hours %]
546
                                    <tr id="hours_[% daycount | html %]">
547
                                        <td>
548
                                            <span>[% PROCESS dayname day=daycount %]</span>
549
                                        </td>
550
                                        <td>
551
                                            <span>[% hr.open_time | html %]</span>
552
                                        </td>
553
                                        <td>
554
                                            <span>[% hr.close_time | html %]</span>
555
                                        </td>
556
                                    </tr>
557
                                    [% daycount = daycount+1 %]
558
                                    [% END %]
559
                                </tbody>
560
                            </table>
561
                        [% ELSE %]
562
                            <span>No opening hours have been set.</span>
563
                        [% END %]
564
                    </li>
531
                </ol>
565
                </ol>
532
            </div> <!-- /.rows -->
566
            </div> <!-- /.rows -->
533
        </div> <!-- /.col-sm-6 -->
567
        </div> <!-- /.col-sm-6 -->
Lines 576-582 Link Here
576
                '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>',
610
                '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>',
577
                "stateSave": true,
611
                "stateSave": true,
578
                "columnDefs": [ {
612
                "columnDefs": [ {
579
                    "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16],
613
                    "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16,17],
580
                    "render": function (data, type, row, meta) {
614
                    "render": function (data, type, row, meta) {
581
                        if ( type == 'display' ) {
615
                        if ( type == 'display' ) {
582
                            if ( data != null ) {
616
                            if ( data != null ) {
Lines 671-676 Link Here
671
                        "visible": true,
705
                        "visible": true,
672
                        "orderable": false
706
                        "orderable": false
673
                    },
707
                    },
708
                    {
709
                        "data": function( row, type, val, meta ) {
710
                            const daynames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'];
711
                            var daycount = 0;
712
                            var result = '<table id="library_hours_table"><thead><tr><th>Day</th><th>Open time</th><th>Close time</th></tr></thead><tbody>';
713
                            while ( row.library_hours[daycount] ) {
714
                                result += '<tr id="hours_"'+daycount+'>';
715
                                result += '<td>'+daynames[daycount]+'</td>';
716
                                result += '<td><span>'+row.open_time+'</span></td>';
717
                                result += '<td><span>'+row.close_time+'</span></td>';
718
                                result += '</tr>';
719
                                daycount++;
720
                            }
721
                            result += '</tbody></table>';
722
                            return result;
723
                        },
724
                        "searchable": false,
725
                        "orderable": false
726
                    },
674
                    {
727
                    {
675
                        "data": function( row, type, val, meta ) {
728
                        "data": function( row, type, val, meta ) {
676
729
677
- 

Return to bug 6796