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 667-673 Link Here
667
                    </div> <!-- /div.row -->
667
                    </div> <!-- /div.row -->
668
668
669
                    [% INCLUDE 'patron-detail-tabs.inc' patronpage = "borrower" %]
669
                    [% INCLUDE 'patron-detail-tabs.inc' patronpage = "borrower" %]
670
671
                </main>
670
                </main>
672
            </div> <!-- /.col-sm-10.col-sm-push-2 -->
671
            </div> <!-- /.col-sm-10.col-sm-push-2 -->
673
672
Lines 682-687 Link Here
682
            [% INCLUDE 'modals/resolve_return_claim.inc' %]
681
            [% INCLUDE 'modals/resolve_return_claim.inc' %]
683
        [% END %]
682
        [% END %]
684
683
684
        [% INCLUDE modals/cancel_booking.inc %]
685
685
[% MACRO jsinclude BLOCK %]
686
[% MACRO jsinclude BLOCK %]
686
    [% INCLUDE 'datatables.inc' %]
687
    [% INCLUDE 'datatables.inc' %]
687
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
688
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
Lines 717-722 Link Here
717
    [% END %]
718
    [% END %]
718
    [% Asset.js("js/holds.js") | $raw %]
719
    [% Asset.js("js/holds.js") | $raw %]
719
    [% INCLUDE 'calendar.inc' %]
720
    [% INCLUDE 'calendar.inc' %]
721
    [% Asset.js("js/bookings.js") | $raw %]
722
    [% Asset.js("js/cancel_booking_modal.js") | $raw %]
720
    [% INCLUDE 'str/members-menu.inc' %]
723
    [% INCLUDE 'str/members-menu.inc' %]
721
    [% Asset.js("js/members-menu.js") | $raw %]
724
    [% Asset.js("js/members-menu.js") | $raw %]
722
    [% Asset.js("js/recalls.js") | $raw %]
725
    [% Asset.js("js/recalls.js") | $raw %]
Lines 745-751 Link Here
745
                $('#guarantees_finesandcharges-tab').click();
748
                $('#guarantees_finesandcharges-tab').click();
746
            });
749
            });
747
750
751
            // Bookings
752
            var bookings_table;
753
            // Load bookings table on tab selection
754
            $("#bookings-tab").on( "click", function(){
755
                if ( !bookings_table ) {
756
                    var today = new Date();
757
                    var bookings_table_url = "/api/v1/bookings";
758
                    bookings_table = $('#bookings-table').kohaTable({
759
                        "ajax": {
760
                            "url": bookings_table_url
761
                        },
762
                        "embed": [
763
                            "biblio",
764
                            "item",
765
                            "patron"
766
                        ],
767
                        "columns": [{
768
                            "data": "booking_id",
769
                            "title": "Booking ID",
770
                            "visible": false,
771
                            "searchable": false,
772
                            "orderable": false
773
                        },
774
                        {
775
                            "data": "biblio.title",
776
                            "title": "Title",
777
                            "searchable": true,
778
                            "orderable": true,
779
                            "render": function(data,type,row,meta) {
780
                                return row.biblio.title;
781
                            }
782
                        },
783
                        {
784
                            "data": "item.external_id",
785
                            "title": "Item",
786
                            "searchable": true,
787
                            "orderable": true,
788
                            "defaultContent": "Any item",
789
                            "render": function(data,type,row,meta) {
790
                                if ( row.item ) {
791
                                    return row.item.external_id;
792
                                } else {
793
                                    return null;
794
                                }
795
                            }
796
                        },
797
                        {
798
                            "data": "start_date",
799
                            "title": "Start date",
800
                            "searchable": true,
801
                            "orderable": true,
802
                            "render": function(data, type, row, meta) {
803
                                return $datetime(row.start_date);
804
                            }
805
                        },
806
                        {
807
                            "data": "end_date",
808
                            "title": "End date",
809
                            "searchable": true,
810
                            "orderable": true,
811
                            "render": function(data, type, row, meta) {
812
                                return $datetime(row.end_date);
813
                            }
814
                        },
815
                        {
816
                            "data": "",
817
                            "title": "Actions",
818
                            "searchable": false,
819
                            "orderable": false,
820
                            "render": function(data, type, row, meta) {
821
                                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>';
822
                                return result;
823
                            }
824
                        }]
825
                    }, [], 1, { patron_id: "[% patron.borrowernumber | html %]", end_date: { ">=": today.toISOString() } });
826
                };
827
            });
828
            // Bookings
829
748
         });
830
         });
831
749
        function uncheck_sibling(me){
832
        function uncheck_sibling(me){
750
            nodename=me.getAttribute("name");
833
            nodename=me.getAttribute("name");
751
            if (nodename =="barcodes[]"){
834
            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