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 420-425 sub validate_float_sibling { Link Here
420
    return $self->get_float_libraries->search( { branchcode => $branchcode } )->count > 0;
421
    return $self->get_float_libraries->search( { branchcode => $branchcode } )->count > 0;
421
}
422
}
422
423
424
=head3 library_hours
425
426
Returns the open and close times for a library.
427
428
=cut
429
430
sub library_hours {
431
    my $self             = shift;
432
    my $library_hours_rs = $self->_result->library_hours;
433
    return Koha::Library::Hours->_new_from_dbic($library_hours_rs);
434
}
435
423
=head2 Internal methods
436
=head2 Internal methods
424
437
425
=head3 _type
438
=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 361-366 modules: Link Here
361
              columnname: public
361
              columnname: public
362
            -
362
            -
363
              columnname: smtp_server
363
              columnname: smtp_server
364
            -
365
              columnname: library_hours
364
            -
366
            -
365
              columnname: actions
367
              columnname: actions
366
              cannot_be_toggled: 1
368
              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 291-298 Link Here
291
                    <div class="hint">Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.</div>
291
                    <div class="hint">Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.</div>
292
                </li>
292
                </li>
293
                <li>
293
                <li>
294
                    <label for="opening_hours">Opening hours: </label>
294
                    <label for="library_hours">Opening hours: </label>
295
                    <table id="opening_hours_table">
295
                    <table id="library_hours_table">
296
                        <thead>
296
                        <thead>
297
                            <tr>
297
                            <tr>
298
                                <th>Day</th>
298
                                <th>Day</th>
Lines 301-309 Link Here
301
                            </tr>
301
                            </tr>
302
                        </thead>
302
                        </thead>
303
                        <tbody>
303
                        <tbody>
304
                            [% IF opening_hours # Existing library %]
304
                            [% IF library.library_hours # Existing library %]
305
                                [% daycount = 0 %]
305
                                [% daycount = 0 %]
306
                                [% FOREACH hr IN opening_hours %]
306
                                [% FOREACH hr IN library.library_hours %]
307
                                <tr id="hours_[% daycount | html %]">
307
                                <tr id="hours_[% daycount | html %]">
308
                                    <td>
308
                                    <td>
309
                                        [% PROCESS dayname day=daycount %]
309
                                        [% PROCESS dayname day=daycount %]
Lines 419-424 Link Here
419
                    <th>Pickup location</th>
419
                    <th>Pickup location</th>
420
                    <th>Public</th>
420
                    <th>Public</th>
421
                    <th>SMTP server</th>
421
                    <th>SMTP server</th>
422
                    <th>Library hours</th>
422
                    <th data-class-name="actions noExport">Actions</th>
423
                    <th data-class-name="actions noExport">Actions</th>
423
                </tr>
424
                </tr>
424
            </thead>
425
            </thead>
Lines 549-554 Link Here
549
                            <span>No</span>
550
                            <span>No</span>
550
                        [% END %]
551
                        [% END %]
551
                    </li>
552
                    </li>
553
                    <li>
554
                        <span class="label">Opening hours: </span>
555
                        [% IF library.library_hours # Existing library %]
556
                            <table id="library_hours_table">
557
                                <thead>
558
                                    <tr>
559
                                        <th>Day</th>
560
                                        <th>Open time</th>
561
                                        <th>Close time</th>
562
                                    </tr>
563
                                </thead>
564
                                <tbody>
565
                                    [% daycount = 0 %]
566
                                    [% FOREACH hr IN library.library_hours %]
567
                                    <tr id="hours_[% daycount | html %]">
568
                                        <td>
569
                                            <span>[% PROCESS dayname day=daycount %]</span>
570
                                        </td>
571
                                        <td>
572
                                            <span>[% hr.open_time | html %]</span>
573
                                        </td>
574
                                        <td>
575
                                            <span>[% hr.close_time | html %]</span>
576
                                        </td>
577
                                    </tr>
578
                                    [% daycount = daycount+1 %]
579
                                    [% END %]
580
                                </tbody>
581
                            </table>
582
                        [% ELSE %]
583
                            <span>No opening hours have been set.</span>
584
                        [% END %]
585
                    </li>
552
                </ol>
586
                </ol>
553
            </div> <!-- /.rows -->
587
            </div> <!-- /.rows -->
554
        </div> <!-- /.col-sm-6 -->
588
        </div> <!-- /.col-sm-6 -->
Lines 618-624 Link Here
618
                '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>',
652
                '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>',
619
                "stateSave": true,
653
                "stateSave": true,
620
                "columnDefs": [ {
654
                "columnDefs": [ {
621
                    "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16],
655
                    "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16,17],
622
                    "render": function (data, type, row, meta) {
656
                    "render": function (data, type, row, meta) {
623
                        if ( type == 'display' ) {
657
                        if ( type == 'display' ) {
624
                            if ( data != null ) {
658
                            if ( data != null ) {
Lines 713-718 Link Here
713
                        "visible": true,
747
                        "visible": true,
714
                        "orderable": false
748
                        "orderable": false
715
                    },
749
                    },
750
                    {
751
                        "data": function( row, type, val, meta ) {
752
                            const daynames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'];
753
                            var daycount = 0;
754
                            var result = '<table id="library_hours_table"><thead><tr><th>Day</th><th>Open time</th><th>Close time</th></tr></thead><tbody>';
755
                            while ( row.library_hours[daycount] ) {
756
                                result += '<tr id="hours_"'+daycount+'>';
757
                                result += '<td>'+daynames[daycount]+'</td>';
758
                                result += '<td><span>'+row.open_time+'</span></td>';
759
                                result += '<td><span>'+row.close_time+'</span></td>';
760
                                result += '</tr>';
761
                                daycount++;
762
                            }
763
                            result += '</tbody></table>';
764
                            return result;
765
                        },
766
                        "searchable": false,
767
                        "orderable": false
768
                    },
716
                    {
769
                    {
717
                        "data": function( row, type, val, meta ) {
770
                        "data": function( row, type, val, meta ) {
718
771
719
- 

Return to bug 6796