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

(-)a/Koha/Bookings.pm (+23 lines)
Lines 20-25 package Koha::Bookings; Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::DateUtils qw(dt_from_string);
24
23
use Koha::Booking;
25
use Koha::Booking;
24
26
25
use base qw(Koha::Objects);
27
use base qw(Koha::Objects);
Lines 32-39 Koha::Bookings - Koha Booking object set class Link Here
32
34
33
=head2 Class Methods
35
=head2 Class Methods
34
36
37
=head3 filter_by_active
38
39
    Koha::Bookings->filter_by_active;
40
41
Returns set of Koha bookings objects that are currently active.
42
43
Active is defined as having a end date in the future.
44
35
=cut
45
=cut
36
46
47
sub filter_by_active {
48
    my ($self) = @_;
49
50
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
51
    my $now = $dtf->format_datetime(dt_from_string());
52
53
    return $self->search(
54
        {
55
            end_date => { '>=' => $now }
56
        }
57
    );
58
}
59
37
=head3 type
60
=head3 type
38
61
39
=cut
62
=cut
(-)a/Koha/Patron.pm (+14 lines)
Lines 1591-1596 sub curbside_pickups { Link Here
1591
    return Koha::CurbsidePickups->_new_from_dbic($curbside_pickups_rs);
1591
    return Koha::CurbsidePickups->_new_from_dbic($curbside_pickups_rs);
1592
}
1592
}
1593
1593
1594
=head3 bookings
1595
1596
  my $bookings = $item->bookings();
1597
1598
Returns the bookings for this patron.
1599
1600
=cut
1601
1602
sub bookings {
1603
    my ( $self, $params ) = @_;
1604
    my $bookings_rs = $self->_result->bookings->search($params);
1605
    return Koha::Bookings->_new_from_dbic( $bookings_rs );
1606
}
1607
1594
=head3 return_claims
1608
=head3 return_claims
1595
1609
1596
my $return_claims = $patron->return_claims
1610
my $return_claims = $patron->return_claims
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc (+11 lines)
Lines 29-34 Link Here
29
            [% WRAPPER tab_item tabname= "holds" %]
29
            [% WRAPPER tab_item tabname= "holds" %]
30
                <span>Holds ([% holds_count || 0 | html %])</span>
30
                <span>Holds ([% holds_count || 0 | html %])</span>
31
            [% END %]
31
            [% END %]
32
            [% WRAPPER tab_item tabname="bookings" %]
33
                <span>Bookings ([% bookings_count || 0 | html %])</span>
34
            [% END %]
32
        [% END %]
35
        [% END %]
33
36
34
        [% IF Koha.Preference('UseRecalls') %]
37
        [% IF Koha.Preference('UseRecalls') %]
Lines 215-220 Link Here
215
                    <p>Patron has nothing on hold.</p>
218
                    <p>Patron has nothing on hold.</p>
216
                [% END %]
219
                [% END %]
217
            [% END # /tab_panel#holds %]
220
            [% END # /tab_panel#holds %]
221
222
            [% WRAPPER tab_panel tabname="bookings" %]
223
                [% IF ( bookings_count ) %]
224
                    <table id="bookings-table" style="width: 100% !Important;"></table>
225
                [% ELSE %]
226
                    <p>Patron has nothing booked.</p>
227
                [% END %]
228
            [% END %]
218
        [% END %]
229
        [% END %]
219
230
220
        [% IF Koha.Preference('UseRecalls') %]
231
        [% IF Koha.Preference('UseRecalls') %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-1 / +84 lines)
Lines 670-676 Link Here
670
                    </div> <!-- /div.row -->
670
                    </div> <!-- /div.row -->
671
671
672
                    [% INCLUDE 'patron-detail-tabs.inc' patronpage = "borrower" %]
672
                    [% INCLUDE 'patron-detail-tabs.inc' patronpage = "borrower" %]
673
674
                </main>
673
                </main>
675
            </div> <!-- /.col-sm-10.col-sm-push-2 -->
674
            </div> <!-- /.col-sm-10.col-sm-push-2 -->
676
675
Lines 685-690 Link Here
685
            [% INCLUDE 'modals/resolve_return_claim.inc' %]
684
            [% INCLUDE 'modals/resolve_return_claim.inc' %]
686
        [% END %]
685
        [% END %]
687
686
687
        [% INCLUDE modals/cancel_booking.inc %]
688
688
[% MACRO jsinclude BLOCK %]
689
[% MACRO jsinclude BLOCK %]
689
    [% INCLUDE 'datatables.inc' %]
690
    [% INCLUDE 'datatables.inc' %]
690
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
691
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
Lines 720-725 Link Here
720
    [% END %]
721
    [% END %]
721
    [% Asset.js("js/holds.js") | $raw %]
722
    [% Asset.js("js/holds.js") | $raw %]
722
    [% INCLUDE 'calendar.inc' %]
723
    [% INCLUDE 'calendar.inc' %]
724
    [% Asset.js("js/bookings.js") | $raw %]
725
    [% Asset.js("js/cancel_booking_modal.js") | $raw %]
723
    [% INCLUDE 'str/members-menu.inc' %]
726
    [% INCLUDE 'str/members-menu.inc' %]
724
    [% Asset.js("js/members-menu.js") | $raw %]
727
    [% Asset.js("js/members-menu.js") | $raw %]
725
    [% Asset.js("js/recalls.js") | $raw %]
728
    [% Asset.js("js/recalls.js") | $raw %]
Lines 748-754 Link Here
748
                $('#guarantees_finesandcharges-tab').click();
751
                $('#guarantees_finesandcharges-tab').click();
749
            });
752
            });
750
753
754
            // Bookings
755
            var bookings_table;
756
            // Load bookings table on tab selection
757
            $("#bookings-tab").on( "click", function(){
758
                if ( !bookings_table ) {
759
                    var today = new Date();
760
                    var bookings_table_url = "/api/v1/bookings";
761
                    bookings_table = $('#bookings-table').kohaTable({
762
                        "ajax": {
763
                            "url": bookings_table_url
764
                        },
765
                        "embed": [
766
                            "biblio",
767
                            "item",
768
                            "patron"
769
                        ],
770
                        "columns": [{
771
                            "data": "booking_id",
772
                            "title": "Booking ID",
773
                            "visible": false,
774
                            "searchable": false,
775
                            "orderable": false
776
                        },
777
                        {
778
                            "data": "biblio.title",
779
                            "title": "Title",
780
                            "searchable": true,
781
                            "orderable": true,
782
                            "render": function(data,type,row,meta) {
783
                                return row.biblio.title;
784
                            }
785
                        },
786
                        {
787
                            "data": "item.external_id",
788
                            "title": "Item",
789
                            "searchable": true,
790
                            "orderable": true,
791
                            "defaultContent": "Any item",
792
                            "render": function(data,type,row,meta) {
793
                                if ( row.item ) {
794
                                    return row.item.external_id;
795
                                } else {
796
                                    return null;
797
                                }
798
                            }
799
                        },
800
                        {
801
                            "data": "start_date",
802
                            "title": "Start date",
803
                            "searchable": true,
804
                            "orderable": true,
805
                            "render": function(data, type, row, meta) {
806
                                return $datetime(row.start_date);
807
                            }
808
                        },
809
                        {
810
                            "data": "end_date",
811
                            "title": "End date",
812
                            "searchable": true,
813
                            "orderable": true,
814
                            "render": function(data, type, row, meta) {
815
                                return $datetime(row.end_date);
816
                            }
817
                        },
818
                        {
819
                            "data": "",
820
                            "title": "Actions",
821
                            "searchable": false,
822
                            "orderable": false,
823
                            "render": function(data, type, row, meta) {
824
                                var result = '<button type="button" class="btn btn-default btn-xs cancel-action" data-toggle="modal" data-target="#cancelBookingModal" data-booking="'+row.booking_id+'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Cancel")+'</button>';
825
                                return result;
826
                            }
827
                        }]
828
                    }, [], 1, { patron_id: "[% patron.borrowernumber | html %]", end_date: { ">=": today.toISOString() } });
829
                };
830
            });
831
            // Bookings
832
751
         });
833
         });
834
752
        function uncheck_sibling(me){
835
        function uncheck_sibling(me){
753
            nodename=me.getAttribute("name");
836
            nodename=me.getAttribute("name");
754
            if (nodename =="barcodes[]"){
837
            if (nodename =="barcodes[]"){
(-)a/members/moremember.pl (-1 / +5 lines)
Lines 217-222 if ( C4::Context->preference('UseRecalls') ) { Link Here
217
    $template->param( waiting_recalls => $waiting_recalls );
217
    $template->param( waiting_recalls => $waiting_recalls );
218
}
218
}
219
219
220
my $bookings = $patron->bookings->filter_by_active;
221
$template->param(
222
    bookings_count => $bookings->count()
223
);
224
220
my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees");
225
my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees");
221
$no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees );
226
$no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees );
222
if ( defined $no_issues_charge_guarantees ) {
227
if ( defined $no_issues_charge_guarantees ) {
223
- 

Return to bug 33737