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

(-)a/Koha/Items.pm (-15 / +18 lines)
Lines 205-211 during the specified period (not booked and not checked out). Link Here
205
=cut
205
=cut
206
206
207
sub filter_by_bookable {
207
sub filter_by_bookable {
208
    my ($self, $params) = @_;
208
    my ( $self, $params ) = @_;
209
209
210
    my $bookable_items;
210
    my $bookable_items;
211
    if ( !C4::Context->preference('item-level_itypes') ) {
211
    if ( !C4::Context->preference('item-level_itypes') ) {
Lines 232-238 sub filter_by_bookable { Link Here
232
        );
232
        );
233
    }
233
    }
234
234
235
    return $self->_filter_by_availability($bookable_items, $params);
235
    return $self->_filter_by_availability( $bookable_items, $params );
236
}
236
}
237
237
238
=head3 _filter_by_availability
238
=head3 _filter_by_availability
Lines 242-248 Internal helper method to filter items by availability during a date range. Link Here
242
=cut
242
=cut
243
243
244
sub _filter_by_availability {
244
sub _filter_by_availability {
245
    my ($self, $bookable_items, $params) = @_;
245
    my ( $self, $bookable_items, $params ) = @_;
246
246
247
    return $bookable_items unless $params && $params->{start_date} && $params->{end_date};
247
    return $bookable_items unless $params && $params->{start_date} && $params->{end_date};
248
248
Lines 267-283 sub _filter_by_availability { Link Here
267
        );
267
        );
268
268
269
        my $item_start_date = $start_date->clone;
269
        my $item_start_date = $start_date->clone;
270
        my $item_end_date = $end_date->clone;
270
        my $item_end_date   = $end_date->clone;
271
271
272
        if (defined $processing_rules->{'bookings_lead_period'} && $processing_rules->{'bookings_lead_period'} ne '') {
272
        if ( defined $processing_rules->{'bookings_lead_period'} && $processing_rules->{'bookings_lead_period'} ne '' )
273
        {
273
            my $lead_days = $processing_rules->{'bookings_lead_period'};
274
            my $lead_days = $processing_rules->{'bookings_lead_period'};
274
            $item_start_date->subtract(days => $lead_days);
275
            $item_start_date->subtract( days => $lead_days );
275
            $item_start_date->set_hour(0)->set_minute(0)->set_second(0);
276
            $item_start_date->set_hour(0)->set_minute(0)->set_second(0);
276
        }
277
        }
277
278
278
        if (defined $processing_rules->{'bookings_trail_period'} && $processing_rules->{'bookings_trail_period'} ne '') {
279
        if ( defined $processing_rules->{'bookings_trail_period'}
280
            && $processing_rules->{'bookings_trail_period'} ne '' )
281
        {
279
            my $trail_days = $processing_rules->{'bookings_trail_period'};
282
            my $trail_days = $processing_rules->{'bookings_trail_period'};
280
            $item_end_date->add(days => $trail_days);
283
            $item_end_date->add( days => $trail_days );
281
            $item_end_date->set_hour(23)->set_minute(59)->set_second(59);
284
            $item_end_date->set_hour(23)->set_minute(59)->set_second(59);
282
        }
285
        }
283
286
Lines 313-330 sub _filter_by_availability { Link Here
313
            }
316
            }
314
        );
317
        );
315
318
316
        my $checkout = $item->checkout;
319
        my $checkout           = $item->checkout;
317
        my $checkout_conflicts = 0;
320
        my $checkout_conflicts = 0;
318
        if ($checkout) {
321
        if ($checkout) {
319
            my $due_date = dt_from_string($checkout->date_due);
322
            my $due_date = dt_from_string( $checkout->date_due );
320
            $checkout_conflicts = 1 if $due_date >= $item_start_date;
323
            $checkout_conflicts = 1 if $due_date >= $item_start_date;
321
        }
324
        }
322
325
323
        if ($existing_bookings->count > 0 || $checkout_conflicts) {
326
        if ( $existing_bookings->count > 0 || $checkout_conflicts ) {
324
            push @excluded_items, $item->itemnumber;
327
            push @excluded_items, $item->itemnumber;
328
325
            # Debug - uncomment to see why items are excluded:
329
            # Debug - uncomment to see why items are excluded:
326
            # warn "EXCLUDED Item #" . $item->itemnumber . " - Bookings: " . $existing_bookings->count . ", Checkout conflicts: $checkout_conflicts, Lead: " . ($processing_rules->{'bookings_lead_period'} // 'none') . ", Trail: " . ($processing_rules->{'bookings_trail_period'} // 'none');
330
            # warn "EXCLUDED Item #" . $item->itemnumber . " - Bookings: " . $existing_bookings->count . ", Checkout conflicts: $checkout_conflicts, Lead: " . ($processing_rules->{'bookings_lead_period'} // 'none') . ", Trail: " . ($processing_rules->{'bookings_trail_period'} // 'none');
327
        } else {
331
        } else {
332
328
            # Debug - uncomment to see items that pass:
333
            # Debug - uncomment to see items that pass:
329
            # warn "PASSED Item #" . $item->itemnumber . " - Lead: " . ($processing_rules->{'bookings_lead_period'} // 'none') . ", Trail: " . ($processing_rules->{'bookings_trail_period'} // 'none');
334
            # warn "PASSED Item #" . $item->itemnumber . " - Lead: " . ($processing_rules->{'bookings_lead_period'} // 'none') . ", Trail: " . ($processing_rules->{'bookings_trail_period'} // 'none');
330
        }
335
        }
Lines 333-341 sub _filter_by_availability { Link Here
333
    $bookable_items->reset;
338
    $bookable_items->reset;
334
339
335
    if (@excluded_items) {
340
    if (@excluded_items) {
336
        return $bookable_items->search({
341
        return $bookable_items->search( { 'me.itemnumber' => { '-not_in' => \@excluded_items } } );
337
            'me.itemnumber' => { '-not_in' => \@excluded_items }
338
        });
339
    }
342
    }
340
343
341
    return $bookable_items;
344
    return $bookable_items;
Lines 889-892 Martin Renvoize <martin.renvoize@ptfs-europe.com> Link Here
889
892
890
=cut
893
=cut
891
894
892
1;
895
1;
(-)a/Koha/REST/V1/Items.pm (-5 / +7 lines)
Lines 437-454 sub available_for_booking { Link Here
437
437
438
    return try {
438
    return try {
439
        my $start_date = $c->param('start_date');
439
        my $start_date = $c->param('start_date');
440
        my $end_date = $c->param('end_date');
440
        my $end_date   = $c->param('end_date');
441
441
442
        $c->req->params->remove('start_date');
442
        $c->req->params->remove('start_date');
443
        $c->req->params->remove('end_date');
443
        $c->req->params->remove('end_date');
444
        my $items_set = Koha::Items->new->filter_by_bookable(
444
        my $items_set = Koha::Items->new->filter_by_bookable(
445
            ($start_date && $end_date) ? {
445
            ( $start_date && $end_date )
446
            ? {
446
                start_date => $start_date,
447
                start_date => $start_date,
447
                end_date => $end_date,
448
                end_date   => $end_date,
448
            } : undef
449
                }
450
            : undef
449
        );
451
        );
450
452
451
        my $items = $c->objects->search( $items_set );
453
        my $items = $c->objects->search($items_set);
452
        return $c->render( status => 200, openapi => $items );
454
        return $c->render( status => 200, openapi => $items );
453
455
454
    } catch {
456
    } catch {
(-)a/api/v1/swagger/paths/items_available_for_booking.yaml (-1 / +1 lines)
Lines 78-81 Link Here
78
          $ref: "../swagger.yaml#/definitions/error"
78
          $ref: "../swagger.yaml#/definitions/error"
79
    x-koha-authorization:
79
    x-koha-authorization:
80
      permissions:
80
      permissions:
81
        circulate: manage_bookings
81
        circulate: manage_bookings
(-)a/circ/available-bookings.pl (-6 / +6 lines)
Lines 15-21 Link Here
15
# GNU General Public License for more details.
15
# GNU General Public License for more details.
16
#
16
#
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <https://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
Lines 39-52 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( Link Here
39
39
40
my $branchcode = defined( $input->param('library') ) ? $input->param('library') : C4::Context->userenv->{'branch'};
40
my $branchcode = defined( $input->param('library') ) ? $input->param('library') : C4::Context->userenv->{'branch'};
41
41
42
my $today = dt_from_string();
42
my $today     = dt_from_string();
43
my $startdate = $today->clone->truncate( to => 'day' );
43
my $startdate = $today->clone->truncate( to => 'day' );
44
my $enddate = $startdate->clone->add( days => 7 );
44
my $enddate   = $startdate->clone->add( days => 7 );
45
45
46
$template->param(
46
$template->param(
47
    branchcode => $branchcode,
47
    branchcode         => $branchcode,
48
    start_date_default => $startdate,
48
    start_date_default => $startdate,
49
    end_date_default => $enddate,
49
    end_date_default   => $enddate,
50
);
50
);
51
51
52
output_html_with_http_headers $input, $cookie, $template->output;
52
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc (-63 / +63 lines)
Lines 64-140 Link Here
64
        </li>
64
        </li>
65
    </ul>
65
    </ul>
66
66
67
67
    <div class="col-sm-6 col-md-12">
68
        <div class="col-sm-6 col-md-12">
69
        [% IF ( CAN_user_circulate_manage_bookings ) %]
68
        [% IF ( CAN_user_circulate_manage_bookings ) %]
70
        <h5>Bookings</h5>
69
            <h5>Bookings</h5>
71
        <ul>
70
            <ul>
72
            <li>
71
                <li>
73
                <a href="/cgi-bin/koha/circ/pendingbookings.pl">Bookings to collect</a>
72
                    <a href="/cgi-bin/koha/circ/pendingbookings.pl">Bookings to collect</a>
74
            </li>
73
                </li>
75
            <li>
74
                <li>
76
                <a href="/cgi-bin/koha/circ/available-bookings.pl">Items available for booking</a>
75
                    <a href="/cgi-bin/koha/circ/available-bookings.pl">Items available for booking</a>
77
            </li>
76
                </li>
78
        </ul>
77
            </ul>
79
        [% END %]
78
        [% END %]
80
79
81
        [% IF Koha.Preference('UseRecalls') and CAN_user_recalls %]
80
        [% IF Koha.Preference('UseRecalls') and CAN_user_recalls %]
82
        <h5>Recalls</h5>
81
            <h5>Recalls</h5>
83
        <ul>
82
            <ul>
84
            <li>
83
                <li>
85
                <a href="/cgi-bin/koha/recalls/recalls_queue.pl" title="All active recalls">Recalls queue</a>
84
                    <a href="/cgi-bin/koha/recalls/recalls_queue.pl" title="All active recalls">Recalls queue</a>
86
            </li>
85
                </li>
87
            <li>
86
                <li>
88
                <a href="/cgi-bin/koha/recalls/recalls_to_pull.pl" title="Recalls that could be filled but have not been set waiting">Recalls to pull</a>
87
                    <a href="/cgi-bin/koha/recalls/recalls_to_pull.pl" title="Recalls that could be filled but have not been set waiting">Recalls to pull</a>
89
            </li>
88
                </li>
90
            <li>
89
                <li>
91
                <a href="/cgi-bin/koha/recalls/recalls_overdue.pl" title="Recalled items that are overdue to be returned">Overdue recalls</a>
90
                    <a href="/cgi-bin/koha/recalls/recalls_overdue.pl" title="Recalled items that are overdue to be returned">Overdue recalls</a>
92
            </li>
91
                </li>
93
            <li>
92
                <li>
94
                <a href="/cgi-bin/koha/recalls/recalls_waiting.pl" title="Recalled items awaiting pickup">Recalls awaiting pickup</a>
93
                    <a href="/cgi-bin/koha/recalls/recalls_waiting.pl" title="Recalled items awaiting pickup">Recalls awaiting pickup</a>
95
            </li>
94
                </li>
96
            <li>
95
                <li>
97
                <a href="/cgi-bin/koha/recalls/recalls_old_queue.pl" title="Inactive recalls">Old recalls</a>
96
                    <a href="/cgi-bin/koha/recalls/recalls_old_queue.pl" title="Inactive recalls">Old recalls</a>
98
            </li>
97
                </li>
99
        </ul>
98
            </ul>
100
    [% END %]
101
102
    [% IF Koha.Preference('ArticleRequests') %]
103
        <h5>Patron request</h5>
104
        <ul>
105
            <li>
106
                <a href="/cgi-bin/koha/circ/article-requests.pl">Article requests</a>
107
            </li>
108
        </ul>
109
    [% END %]
110
111
    <h5>Transfers</h5>
112
    <ul>
113
        [% IF !Koha.Preference('IndependentBranchesTransfers') || CAN_user_superlibrarian %]
114
            <li>
115
                <a href="/cgi-bin/koha/circ/branchtransfers.pl">Transfer</a>
116
            </li>
117
        [% END %]
99
        [% END %]
118
        [% IF Koha.Preference('StockRotation') %]
100
119
            <li>
101
        [% IF Koha.Preference('ArticleRequests') %]
120
                <a href="/cgi-bin/koha/circ/transfers_to_send.pl">Transfers to send</a>
102
            <h5>Patron request</h5>
121
            </li>
103
            <ul>
104
                <li>
105
                    <a href="/cgi-bin/koha/circ/article-requests.pl">Article requests</a>
106
                </li>
107
            </ul>
122
        [% END %]
108
        [% END %]
123
        <li>
124
            <a href="/cgi-bin/koha/circ/transferstoreceive.pl">Transfers to receive</a>
125
        </li>
126
    </ul>
127
109
128
    [% IF ( CAN_user_circulate_overdues_report ) %]
110
        <h5>Transfers</h5>
129
        <h5>Overdues</h5>
130
        <ul>
111
        <ul>
131
            <li>
112
            [% IF !Koha.Preference('IndependentBranchesTransfers') || CAN_user_superlibrarian %]
132
                <a href="/cgi-bin/koha/circ/overdue.pl" title="Warning: This report is very resource intensive on systems with large numbers of overdue items.">Overdues</a>
113
                <li>
133
            </li>
114
                    <a href="/cgi-bin/koha/circ/branchtransfers.pl">Transfer</a>
134
            <li>
115
                </li>
135
                <a href="/cgi-bin/koha/circ/branchoverdues.pl" title="Limited to your library. See report help for other details.">Overdues with fines</a>
116
            [% END %]
117
            [% IF Koha.Preference('StockRotation') %]
118
                <li>
119
                    <a href="/cgi-bin/koha/circ/transfers_to_send.pl">Transfers to send</a>
120
                </li>
121
            [% END %]
122
            <li>
123
                <a href="/cgi-bin/koha/circ/transferstoreceive.pl">Transfers to receive</a>
136
            </li>
124
            </li>
137
        </ul>
125
        </ul>
138
    [% END %]
126
127
        [% IF ( CAN_user_circulate_overdues_report ) %]
128
            <h5>Overdues</h5>
129
            <ul>
130
                <li>
131
                    <a href="/cgi-bin/koha/circ/overdue.pl" title="Warning: This report is very resource intensive on systems with large numbers of overdue items.">Overdues</a>
132
                </li>
133
                <li>
134
                    <a href="/cgi-bin/koha/circ/branchoverdues.pl" title="Limited to your library. See report help for other details.">Overdues with fines</a>
135
                </li>
136
            </ul>
137
        [% END %]
138
    </div>
139
    <!-- /.sidebar_menu -->
139
</div>
140
</div>
140
<!-- /.sidebar_menu -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/available-bookings.tt (-170 / +168 lines)
Lines 9-19 Link Here
9
[% PROCESS 'i18n.inc' %]
9
[% PROCESS 'i18n.inc' %]
10
[% SET footerjs = 1 %]
10
[% SET footerjs = 1 %]
11
[% INCLUDE 'doc-head-open.inc' %]
11
[% INCLUDE 'doc-head-open.inc' %]
12
<title>[% FILTER collapse %]
12
<title
13
    [% t("Items available for booking") | html %] &rsaquo;
13
    >[% FILTER collapse %]
14
    [% t("Circulation") | html %] &rsaquo;
14
        [% t("Items available for booking") | html %]
15
    [% t("Koha") | html %]
15
        &rsaquo; [% t("Circulation") | html %] &rsaquo; [% t("Koha") | html %]
16
[% END %]</title>
16
    [% END %]</title
17
>
17
[% INCLUDE 'doc-head-close.inc' %]
18
[% INCLUDE 'doc-head-close.inc' %]
18
</head>
19
</head>
19
20
Lines 35-41 Link Here
35
36
36
<div class="main container-fluid">
37
<div class="main container-fluid">
37
    <div class="row">
38
    <div class="row">
38
39
        <!-- Results -->
39
        <!-- Results -->
40
        <div class="col-md-10 order-md-2 order-sm1">
40
        <div class="col-md-10 order-md-2 order-sm1">
41
            <main>
41
            <main>
Lines 57-67 Link Here
57
                        <ol>
57
                        <ol>
58
                            <li>
58
                            <li>
59
                                <label for="start_date">Start date: </label>
59
                                <label for="start_date">Start date: </label>
60
                                <input type="text" size="10" id="start_date" name="start_date" value="[% start_date_default | html %]" class="flatpickr" data-date_to="end_date" required/>
60
                                <input type="text" size="10" id="start_date" name="start_date" value="[% start_date_default | html %]" class="flatpickr" data-date_to="end_date" required />
61
                            </li>
61
                            </li>
62
                            <li>
62
                            <li>
63
                                <label for="end_date">End date: </label>
63
                                <label for="end_date">End date: </label>
64
                                <input type="text" size="10" id="end_date" name="end_date" value="[% end_date_default | html %]" class="flatpickr" required/>
64
                                <input type="text" size="10" id="end_date" name="end_date" value="[% end_date_default | html %]" class="flatpickr" required />
65
                            </li>
65
                            </li>
66
                            <li>
66
                            <li>
67
                                <label for="pickup_libraries">Pickup libraries:</label>
67
                                <label for="pickup_libraries">Pickup libraries:</label>
Lines 98-276 Link Here
98
</div>
98
</div>
99
99
100
[% MACRO jsinclude BLOCK %]
100
[% MACRO jsinclude BLOCK %]
101
[% INCLUDE 'calendar.inc' %]
101
    [% INCLUDE 'calendar.inc' %]
102
[% INCLUDE 'datatables.inc' %]
102
    [% INCLUDE 'datatables.inc' %]
103
[% INCLUDE 'js-biblio-format.inc' %]
103
    [% INCLUDE 'js-biblio-format.inc' %]
104
[% INCLUDE 'js-date-format.inc' %]
104
    [% INCLUDE 'js-date-format.inc' %]
105
105
    <script>
106
<script>
106
        let table_settings = [% TablesSettings.GetTableSettings( 'circ', 'available-bookings', 'available-items', 'json' ) | $raw %];
107
let table_settings = [% TablesSettings.GetTableSettings( 'circ', 'available-bookings', 'available-items', 'json' ) | $raw %];
108
107
109
$(document).ready(function() {
108
        $(document).ready(function() {
110
109
111
    let additional_filters = {
110
            let additional_filters = {
112
        'me.holding_library_id': function() {
111
                'me.holding_library_id': function() {
113
            let selectedLibraries = $("#pickup_libraries").val();
112
                    let selectedLibraries = $("#pickup_libraries").val();
114
            if (selectedLibraries && selectedLibraries.length > 0) {
113
                    if (selectedLibraries && selectedLibraries.length > 0) {
115
                selectedLibraries = selectedLibraries.filter(lib => lib !== '');
114
                        selectedLibraries = selectedLibraries.filter(lib => lib !== '');
116
                if (selectedLibraries.length > 0) {
115
                        if (selectedLibraries.length > 0) {
117
                    return selectedLibraries;
116
                            return selectedLibraries;
117
                        }
118
                    }
119
                    return;
120
                },
121
                'me.item_type_id': function() {
122
                    let itemType = $("#item_type").val();
123
                    if (itemType && itemType !== '') {
124
                        return itemType;
125
                    }
126
                    return;
118
                }
127
                }
119
            }
128
            };
120
            return;
121
        },
122
        'me.item_type_id': function() {
123
            let itemType = $("#item_type").val();
124
            if (itemType && itemType !== '') {
125
                return itemType;
126
            }
127
            return;
128
        }
129
    };
130
129
131
    [% SET libraries = Branches.all %]
130
            [% SET libraries = Branches.all %]
132
    let all_libraries  = [% To.json(libraries) | $raw %].map(e => {
131
            let all_libraries  = [% To.json(libraries) | $raw %].map(e => {
133
        e['_id'] = e.branchcode;
132
                e['_id'] = e.branchcode;
134
        e['_str'] = e.branchname;
133
                e['_str'] = e.branchname;
135
        return e;
134
                return e;
136
    });
135
            });
137
    let filters_options = {};
136
            let filters_options = {};
138
137
139
    var available_items_table_url = '/api/v1/items/available_for_booking';
138
            var available_items_table_url = '/api/v1/items/available_for_booking';
140
139
141
    var available_items_table = $("#available_items_table").kohaTable({
140
            var available_items_table = $("#available_items_table").kohaTable({
142
        "ajax": {
141
                "ajax": {
143
            "url": available_items_table_url
142
                    "url": available_items_table_url
144
        },
143
                },
145
        "embed": [
144
                "embed": [
146
            "biblio",
145
                    "biblio",
147
            "+strings",
146
                    "+strings",
148
            "home_library",
147
                    "home_library",
149
            "holding_library",
148
                    "holding_library",
150
            "item_type"
149
                    "item_type"
151
        ],
150
                ],
152
        "order": [[ 2, "asc" ]],
151
                "order": [[ 2, "asc" ]],
153
        "columns": [{
152
                "columns": [{
154
            "data": "home_library.name",
153
                    "data": "home_library.name",
155
            "title": _("Homebranch"),
154
                    "title": _("Homebranch"),
156
            "searchable": true,
155
                    "searchable": true,
157
            "orderable": true,
156
                    "orderable": true,
158
            "render": function( data, type, row, meta ) {
157
                    "render": function( data, type, row, meta ) {
159
                return escape_str(row.home_library_id ? row.home_library.name : row.home_library_id);
158
                        return escape_str(row.home_library_id ? row.home_library.name : row.home_library_id);
160
            }
159
                    }
161
        },
160
                },
162
        {
161
                {
163
            "data": "holding_library.name",
162
                    "data": "holding_library.name",
164
            "title": _("Pickup library"),
163
                    "title": _("Pickup library"),
165
            "searchable": true,
164
                    "searchable": true,
166
            "orderable": true,
165
                    "orderable": true,
167
            "render": function( data, type, row, meta ) {
166
                    "render": function( data, type, row, meta ) {
168
                return escape_str(row.holding_library_id ? row.holding_library.name : row.holding_library_id);
167
                        return escape_str(row.holding_library_id ? row.holding_library.name : row.holding_library_id);
169
            }
168
                    }
170
        },
169
                },
171
        {
170
                {
172
            "data": "biblio.title",
171
                    "data": "biblio.title",
173
            "title": _("Title"),
172
                    "title": _("Title"),
174
            "searchable": true,
173
                    "searchable": true,
175
            "orderable": true,
174
                    "orderable": true,
176
            "render": function(data,type,row,meta) {
175
                    "render": function(data,type,row,meta) {
177
                if ( row.biblio ) {
176
                        if ( row.biblio ) {
178
                    return $biblio_to_html(row.biblio, {
177
                            return $biblio_to_html(row.biblio, {
179
                        link: 'detail'
178
                                link: 'detail'
180
                    });
179
                            });
181
                } else {
180
                        } else {
182
                    return 'No title';
181
                            return 'No title';
183
                }
182
                        }
184
            }
183
                    }
185
        },
184
                },
186
        {
185
                {
187
            "data": "item_type_id",
186
                    "data": "item_type_id",
188
            "title": _("Item type"),
187
                    "title": _("Item type"),
189
            "searchable": true,
188
                    "searchable": true,
190
            "orderable": true,
189
                    "orderable": true,
191
            "render": function(data,type,row,meta) {
190
                    "render": function(data,type,row,meta) {
192
                if ( row.item_type && row.item_type.description ) {
191
                        if ( row.item_type && row.item_type.description ) {
193
                    return escape_str(row.item_type.description);
192
                            return escape_str(row.item_type.description);
194
                } else if ( row._strings && row._strings.item_type_id ) {
193
                        } else if ( row._strings && row._strings.item_type_id ) {
195
                    return escape_str(row._strings.item_type_id.str);
194
                            return escape_str(row._strings.item_type_id.str);
196
                } else {
195
                        } else {
197
                    return escape_str(row.item_type_id || '');
196
                            return escape_str(row.item_type_id || '');
198
                }
197
                        }
199
            }
198
                    }
200
        },
199
                },
201
        {
200
                {
202
            "data": "external_id",
201
                    "data": "external_id",
203
            "title": _("Barcode"),
202
                    "title": _("Barcode"),
204
            "searchable": true,
203
                    "searchable": true,
205
            "orderable": true
204
                    "orderable": true
206
        },
205
                },
207
        {
206
                {
208
            "data": "callnumber",
207
                    "data": "callnumber",
209
            "title": _("Callnumber"),
208
                    "title": _("Callnumber"),
210
            "searchable": true,
209
                    "searchable": true,
211
            "orderable": true
210
                    "orderable": true
212
        },
211
                },
213
        {
212
                {
214
            "data": "location",
213
                    "data": "location",
215
            "title": _("Location"),
214
                    "title": _("Location"),
216
            "searchable": true,
215
                    "searchable": true,
217
            "orderable": true,
216
                    "orderable": true,
218
            "render": function(data,type,row,meta) {
217
                    "render": function(data,type,row,meta) {
219
                if ( row._strings && row._strings.location ) {
218
                        if ( row._strings && row._strings.location ) {
220
                    return row._strings.location.str;
219
                            return row._strings.location.str;
221
                } else {
220
                        } else {
222
                    return row.location || '';
221
                            return row.location || '';
223
                }
222
                        }
224
            }
223
                    }
225
        },
224
                },
226
        {
225
                {
227
            "data": "localuse",
226
                    "data": "localuse",
228
            "title": _("Local use"),
227
                    "title": _("Local use"),
229
            "searchable": true,
228
                    "searchable": true,
230
            "orderable": true
229
                    "orderable": true
231
        }]
230
                }]
232
    }, table_settings, 1, additional_filters, filters_options);
231
            }, table_settings, 1, additional_filters, filters_options);
233
232
234
    $("#available_items_filter").on("submit", function(e){
233
            $("#available_items_filter").on("submit", function(e){
235
        e.preventDefault();
234
                e.preventDefault();
236
235
237
        if (!$("#start_date").val() || !$("#end_date").val()) {
236
                if (!$("#start_date").val() || !$("#end_date").val()) {
238
            alert("Please select both start and end dates");
237
                    alert("Please select both start and end dates");
239
            return false;
238
                    return false;
240
        }
239
                }
241
        let newUrl = '/api/v1/items/available_for_booking';
240
                let newUrl = '/api/v1/items/available_for_booking';
242
        let params = [];
241
                let params = [];
243
242
244
        let fromdate = $("#start_date");
243
                let fromdate = $("#start_date");
245
        let todate = $("#end_date");
244
                let todate = $("#end_date");
246
        if ( fromdate.val() !== '' && todate.val() !== '' ) {
245
                if ( fromdate.val() !== '' && todate.val() !== '' ) {
247
          let fromDateStr = fromdate.val();
246
                  let fromDateStr = fromdate.val();
248
          let toDateStr = todate.val();
247
                  let toDateStr = todate.val();
249
          params.push('start_date=' + encodeURIComponent(fromDateStr));
248
                  params.push('start_date=' + encodeURIComponent(fromDateStr));
250
          params.push('end_date=' + encodeURIComponent(toDateStr));
249
                  params.push('end_date=' + encodeURIComponent(toDateStr));
251
250
252
        }
251
                }
253
        if (params.length > 0) {
252
                if (params.length > 0) {
254
            newUrl += '?' + params.join('&');
253
                    newUrl += '?' + params.join('&');
255
        }
254
                }
256
        available_items_table.DataTable().ajax.url(newUrl).load();
255
                available_items_table.DataTable().ajax.url(newUrl).load();
257
    });
256
            });
258
257
259
    $("#available_items_filter input[type=reset]").on("click", function(e){
258
            $("#available_items_filter input[type=reset]").on("click", function(e){
260
        $("#pickup_libraries").val([]);
259
                $("#pickup_libraries").val([]);
261
        $("#item_type").val('');
260
                $("#item_type").val('');
262
        $("#start_date").val('[% start_date_default | html %]');
261
                $("#start_date").val('[% start_date_default | html %]');
263
        $("#end_date").val('[% end_date_default | html %]');
262
                $("#end_date").val('[% end_date_default | html %]');
264
263
265
        let resetUrl = '/api/v1/items/available_for_booking';
264
                let resetUrl = '/api/v1/items/available_for_booking';
266
        if ('[% start_date_default %]' && '[% end_date_default %]') {
265
                if ('[% start_date_default | html %]' && '[% end_date_default | html %]') {
267
            resetUrl += '?start_date=[% start_date_default | uri %]&end_date=[% end_date_default | uri %]';
266
                    resetUrl += '?start_date=[% start_date_default | uri %]&end_date=[% end_date_default | uri %]';
268
        }
267
                }
269
        available_items_table.DataTable().ajax.url(resetUrl).load();
268
                available_items_table.DataTable().ajax.url(resetUrl).load();
270
    });
269
            });
271
270
272
});
271
        });
273
</script>
272
    </script>
274
[% END %]
273
[% END %]
275
274
276
[% INCLUDE 'intranet-bottom.inc' %]
275
[% INCLUDE 'intranet-bottom.inc' %]
277
- 

Return to bug 41993