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 290-297 Link Here
290
                    <div class="hint">Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.</div>
290
                    <div class="hint">Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.</div>
291
                </li>
291
                </li>
292
                <li>
292
                <li>
293
                    <label for="opening_hours">Opening hours: </label>
293
                    <label for="library_hours">Opening hours: </label>
294
                    <table id="opening_hours_table">
294
                    <table id="library_hours_table">
295
                        <thead>
295
                        <thead>
296
                            <tr>
296
                            <tr>
297
                                <th>Day</th>
297
                                <th>Day</th>
Lines 300-308 Link Here
300
                            </tr>
300
                            </tr>
301
                        </thead>
301
                        </thead>
302
                        <tbody>
302
                        <tbody>
303
                            [% IF opening_hours # Existing library %]
303
                            [% IF library.library_hours # Existing library %]
304
                                [% daycount = 0 %]
304
                                [% daycount = 0 %]
305
                                [% FOREACH hr IN opening_hours %]
305
                                [% FOREACH hr IN library.library_hours %]
306
                                <tr id="hours_[% daycount | html %]">
306
                                <tr id="hours_[% daycount | html %]">
307
                                    <td>
307
                                    <td>
308
                                        [% PROCESS dayname day=daycount %]
308
                                        [% PROCESS dayname day=daycount %]
Lines 417-422 Link Here
417
                    <th>Pickup location</th>
417
                    <th>Pickup location</th>
418
                    <th>Public</th>
418
                    <th>Public</th>
419
                    <th>SMTP server</th>
419
                    <th>SMTP server</th>
420
                    <th>Library hours</th>
420
                    <th data-class-name="actions noExport">Actions</th>
421
                    <th data-class-name="actions noExport">Actions</th>
421
                </tr>
422
                </tr>
422
            </thead>
423
            </thead>
Lines 547-552 Link Here
547
                            <span>No</span>
548
                            <span>No</span>
548
                        [% END %]
549
                        [% END %]
549
                    </li>
550
                    </li>
551
                    <li>
552
                        <span class="label">Opening hours: </span>
553
                        [% IF library.library_hours # Existing library %]
554
                            <table id="library_hours_table">
555
                                <thead>
556
                                    <tr>
557
                                        <th>Day</th>
558
                                        <th>Open time</th>
559
                                        <th>Close time</th>
560
                                    </tr>
561
                                </thead>
562
                                <tbody>
563
                                    [% daycount = 0 %]
564
                                    [% FOREACH hr IN library.library_hours %]
565
                                    <tr id="hours_[% daycount | html %]">
566
                                        <td>
567
                                            <span>[% PROCESS dayname day=daycount %]</span>
568
                                        </td>
569
                                        <td>
570
                                            <span>[% hr.open_time | html %]</span>
571
                                        </td>
572
                                        <td>
573
                                            <span>[% hr.close_time | html %]</span>
574
                                        </td>
575
                                    </tr>
576
                                    [% daycount = daycount+1 %]
577
                                    [% END %]
578
                                </tbody>
579
                            </table>
580
                        [% ELSE %]
581
                            <span>No opening hours have been set.</span>
582
                        [% END %]
583
                    </li>
550
                </ol>
584
                </ol>
551
            </div> <!-- /.rows -->
585
            </div> <!-- /.rows -->
552
        </div> <!-- /.col-sm-6 -->
586
        </div> <!-- /.col-sm-6 -->
Lines 616-622 Link Here
616
                '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>',
650
                '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>',
617
                "stateSave": true,
651
                "stateSave": true,
618
                "columnDefs": [ {
652
                "columnDefs": [ {
619
                    "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16],
653
                    "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16,17],
620
                    "render": function (data, type, row, meta) {
654
                    "render": function (data, type, row, meta) {
621
                        if ( type == 'display' ) {
655
                        if ( type == 'display' ) {
622
                            if ( data != null ) {
656
                            if ( data != null ) {
Lines 711-716 Link Here
711
                        "visible": true,
745
                        "visible": true,
712
                        "orderable": false
746
                        "orderable": false
713
                    },
747
                    },
748
                    {
749
                        "data": function( row, type, val, meta ) {
750
                            const daynames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'];
751
                            var daycount = 0;
752
                            var result = '<table id="library_hours_table"><thead><tr><th>Day</th><th>Open time</th><th>Close time</th></tr></thead><tbody>';
753
                            while ( row.library_hours[daycount] ) {
754
                                result += '<tr id="hours_"'+daycount+'>';
755
                                result += '<td>'+daynames[daycount]+'</td>';
756
                                result += '<td><span>'+row.open_time+'</span></td>';
757
                                result += '<td><span>'+row.close_time+'</span></td>';
758
                                result += '</tr>';
759
                                daycount++;
760
                            }
761
                            result += '</tbody></table>';
762
                            return result;
763
                        },
764
                        "searchable": false,
765
                        "orderable": false
766
                    },
714
                    {
767
                    {
715
                        "data": function( row, type, val, meta ) {
768
                        "data": function( row, type, val, meta ) {
716
769
717
- 

Return to bug 6796