|
Line 0
Link Here
|
|
|
1 |
[% USE raw %] |
| 2 |
[% USE Asset %] |
| 3 |
[% USE Branches %] |
| 4 |
[% USE Koha %] |
| 5 |
[% USE KohaDates %] |
| 6 |
[% USE TablesSettings %] |
| 7 |
[% USE To %] |
| 8 |
[% USE ItemTypes %] |
| 9 |
[% PROCESS 'i18n.inc' %] |
| 10 |
[% SET footerjs = 1 %] |
| 11 |
[% INCLUDE 'doc-head-open.inc' %] |
| 12 |
<title>[% FILTER collapse %] |
| 13 |
[% t("Items available for booking") | html %] › |
| 14 |
[% t("Circulation") | html %] › |
| 15 |
[% t("Koha") | html %] |
| 16 |
[% END %]</title> |
| 17 |
[% INCLUDE 'doc-head-close.inc' %] |
| 18 |
</head> |
| 19 |
|
| 20 |
<body id="circ_available_for_booking" class="circ"> |
| 21 |
[% WRAPPER 'header.inc' %] |
| 22 |
[% INCLUDE 'circ-search.inc' %] |
| 23 |
[% END %] |
| 24 |
|
| 25 |
[% WRAPPER 'sub-header.inc' %] |
| 26 |
[% WRAPPER breadcrumbs %] |
| 27 |
[% WRAPPER breadcrumb_item %] |
| 28 |
<a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> |
| 29 |
[% END %] |
| 30 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
| 31 |
<span>Items available for booking</span> |
| 32 |
[% END %] |
| 33 |
[% END #/ WRAPPER breadcrumbs %] |
| 34 |
[% END #/ WRAPPER sub-header.inc %] |
| 35 |
|
| 36 |
<div class="main container-fluid"> |
| 37 |
<div class="row"> |
| 38 |
|
| 39 |
<!-- Results --> |
| 40 |
<div class="col-md-10 order-md-2 order-sm1"> |
| 41 |
<main> |
| 42 |
[% INCLUDE 'messages.inc' %] |
| 43 |
<h1>Items available for booking</h1> |
| 44 |
<p>Items with bookable status that are not booked and not checked out for the requested period.</p> |
| 45 |
<div id="searchresults"> |
| 46 |
<table id="available_items_table"></table> |
| 47 |
</div> |
| 48 |
</main> |
| 49 |
</div> |
| 50 |
|
| 51 |
<!-- Filters & Navigation --> |
| 52 |
<div class="col-md-2 order-sm-2 order-md-1"> |
| 53 |
<aside> |
| 54 |
<form id="available_items_filter"> |
| 55 |
<fieldset class="rows"> |
| 56 |
<h4>Filter by</h4> |
| 57 |
<ol> |
| 58 |
<li> |
| 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/> |
| 61 |
</li> |
| 62 |
<li> |
| 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/> |
| 65 |
</li> |
| 66 |
<li> |
| 67 |
<label for="pickup_libraries">Pickup libraries:</label> |
| 68 |
<select name="pickup_libraries" id="pickup_libraries" multiple size="10"> |
| 69 |
[% SET libraries = Branches.all( only_from_group => 1 ) %] |
| 70 |
<option value="">All libraries</option> |
| 71 |
[% FOREACH l IN libraries %] |
| 72 |
<option value="[% l.branchcode | html %]">[% l.branchname | html %]</option> |
| 73 |
[% END %] |
| 74 |
</select> |
| 75 |
</li> |
| 76 |
<li> |
| 77 |
<label for="item_type">Item type:</label> |
| 78 |
<select name="item_type" id="item_type" style="width: auto; min-width: 200px;"> |
| 79 |
<option value="">Any</option> |
| 80 |
[% FOREACH itemtype IN ItemTypes.Get() %] |
| 81 |
<option value="[% itemtype.itemtype | html %]">[% itemtype.description | html %]</option> |
| 82 |
[% END %] |
| 83 |
</select> |
| 84 |
</li> |
| 85 |
</ol> |
| 86 |
</fieldset> |
| 87 |
<fieldset class="action"> |
| 88 |
<input type="submit" name="run_report" value="Search" class="btn btn-primary" /> |
| 89 |
<input type="reset" name="clear_form" value="Clear" class="btn btn-default" /> |
| 90 |
</fieldset> |
| 91 |
</form> |
| 92 |
|
| 93 |
[% INCLUDE 'circ-nav.inc' %] |
| 94 |
</aside> |
| 95 |
</div> |
| 96 |
</div> |
| 97 |
<!-- /.row --> |
| 98 |
</div> |
| 99 |
|
| 100 |
[% MACRO jsinclude BLOCK %] |
| 101 |
[% INCLUDE 'calendar.inc' %] |
| 102 |
[% INCLUDE 'datatables.inc' %] |
| 103 |
[% INCLUDE 'js-biblio-format.inc' %] |
| 104 |
[% INCLUDE 'js-date-format.inc' %] |
| 105 |
|
| 106 |
<script> |
| 107 |
let table_settings = [% TablesSettings.GetTableSettings( 'circ', 'available-bookings', 'available-items', 'json' ) | $raw %]; |
| 108 |
|
| 109 |
$(document).ready(function() { |
| 110 |
|
| 111 |
let additional_filters = { |
| 112 |
'me.holding_library_id': function() { |
| 113 |
let selectedLibraries = $("#pickup_libraries").val(); |
| 114 |
if (selectedLibraries && selectedLibraries.length > 0) { |
| 115 |
selectedLibraries = selectedLibraries.filter(lib => lib !== ''); |
| 116 |
if (selectedLibraries.length > 0) { |
| 117 |
return selectedLibraries; |
| 118 |
} |
| 119 |
} |
| 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 |
|
| 131 |
[% SET libraries = Branches.all %] |
| 132 |
let all_libraries = [% To.json(libraries) | $raw %].map(e => { |
| 133 |
e['_id'] = e.branchcode; |
| 134 |
e['_str'] = e.branchname; |
| 135 |
return e; |
| 136 |
}); |
| 137 |
let filters_options = {}; |
| 138 |
|
| 139 |
var available_items_table_url = '/api/v1/items/available_for_booking'; |
| 140 |
|
| 141 |
var available_items_table = $("#available_items_table").kohaTable({ |
| 142 |
"ajax": { |
| 143 |
"url": available_items_table_url |
| 144 |
}, |
| 145 |
"embed": [ |
| 146 |
"biblio", |
| 147 |
"+strings", |
| 148 |
"home_library", |
| 149 |
"holding_library", |
| 150 |
"item_type" |
| 151 |
], |
| 152 |
"order": [[ 2, "asc" ]], |
| 153 |
"columns": [{ |
| 154 |
"data": "home_library.name", |
| 155 |
"title": _("Homebranch"), |
| 156 |
"searchable": true, |
| 157 |
"orderable": true, |
| 158 |
"render": function( data, type, row, meta ) { |
| 159 |
return escape_str(row.home_library_id ? row.home_library.name : row.home_library_id); |
| 160 |
} |
| 161 |
}, |
| 162 |
{ |
| 163 |
"data": "holding_library.name", |
| 164 |
"title": _("Pickup library"), |
| 165 |
"searchable": true, |
| 166 |
"orderable": true, |
| 167 |
"render": function( data, type, row, meta ) { |
| 168 |
return escape_str(row.holding_library_id ? row.holding_library.name : row.holding_library_id); |
| 169 |
} |
| 170 |
}, |
| 171 |
{ |
| 172 |
"data": "biblio.title", |
| 173 |
"title": _("Title"), |
| 174 |
"searchable": true, |
| 175 |
"orderable": true, |
| 176 |
"render": function(data,type,row,meta) { |
| 177 |
if ( row.biblio ) { |
| 178 |
return $biblio_to_html(row.biblio, { |
| 179 |
link: 'detail' |
| 180 |
}); |
| 181 |
} else { |
| 182 |
return 'No title'; |
| 183 |
} |
| 184 |
} |
| 185 |
}, |
| 186 |
{ |
| 187 |
"data": "item_type_id", |
| 188 |
"title": _("Item type"), |
| 189 |
"searchable": true, |
| 190 |
"orderable": true, |
| 191 |
"render": function(data,type,row,meta) { |
| 192 |
if ( row.item_type && row.item_type.description ) { |
| 193 |
return escape_str(row.item_type.description); |
| 194 |
} else if ( row._strings && row._strings.item_type_id ) { |
| 195 |
return escape_str(row._strings.item_type_id.str); |
| 196 |
} else { |
| 197 |
return escape_str(row.item_type_id || ''); |
| 198 |
} |
| 199 |
} |
| 200 |
}, |
| 201 |
{ |
| 202 |
"data": "external_id", |
| 203 |
"title": _("Barcode"), |
| 204 |
"searchable": true, |
| 205 |
"orderable": true |
| 206 |
}, |
| 207 |
{ |
| 208 |
"data": "callnumber", |
| 209 |
"title": _("Callnumber"), |
| 210 |
"searchable": true, |
| 211 |
"orderable": true |
| 212 |
}, |
| 213 |
{ |
| 214 |
"data": "location", |
| 215 |
"title": _("Location"), |
| 216 |
"searchable": true, |
| 217 |
"orderable": true, |
| 218 |
"render": function(data,type,row,meta) { |
| 219 |
if ( row._strings && row._strings.location ) { |
| 220 |
return row._strings.location.str; |
| 221 |
} else { |
| 222 |
return row.location || ''; |
| 223 |
} |
| 224 |
} |
| 225 |
}, |
| 226 |
{ |
| 227 |
"data": "localuse", |
| 228 |
"title": _("Local use"), |
| 229 |
"searchable": true, |
| 230 |
"orderable": true |
| 231 |
}] |
| 232 |
}, table_settings, 1, additional_filters, filters_options); |
| 233 |
|
| 234 |
$("#available_items_filter").on("submit", function(e){ |
| 235 |
e.preventDefault(); |
| 236 |
|
| 237 |
if (!$("#start_date").val() || !$("#end_date").val()) { |
| 238 |
alert("Please select both start and end dates"); |
| 239 |
return false; |
| 240 |
} |
| 241 |
let newUrl = '/api/v1/items/available_for_booking'; |
| 242 |
let params = []; |
| 243 |
|
| 244 |
let fromdate = $("#start_date"); |
| 245 |
let todate = $("#end_date"); |
| 246 |
if ( fromdate.val() !== '' && todate.val() !== '' ) { |
| 247 |
let fromDateStr = fromdate.val(); |
| 248 |
let toDateStr = todate.val(); |
| 249 |
params.push('start_date=' + encodeURIComponent(fromDateStr)); |
| 250 |
params.push('end_date=' + encodeURIComponent(toDateStr)); |
| 251 |
|
| 252 |
} |
| 253 |
if (params.length > 0) { |
| 254 |
newUrl += '?' + params.join('&'); |
| 255 |
} |
| 256 |
available_items_table.DataTable().ajax.url(newUrl).load(); |
| 257 |
}); |
| 258 |
|
| 259 |
$("#available_items_filter input[type=reset]").on("click", function(e){ |
| 260 |
$("#pickup_libraries").val([]); |
| 261 |
$("#item_type").val(''); |
| 262 |
$("#start_date").val('[% start_date_default | html %]'); |
| 263 |
$("#end_date").val('[% end_date_default | html %]'); |
| 264 |
|
| 265 |
let resetUrl = '/api/v1/items/available_for_booking'; |
| 266 |
if ('[% start_date_default %]' && '[% end_date_default %]') { |
| 267 |
resetUrl += '?start_date=[% start_date_default | uri %]&end_date=[% end_date_default | uri %]'; |
| 268 |
} |
| 269 |
available_items_table.DataTable().ajax.url(resetUrl).load(); |
| 270 |
}); |
| 271 |
|
| 272 |
}); |
| 273 |
</script> |
| 274 |
[% END %] |
| 275 |
|
| 276 |
[% INCLUDE 'intranet-bottom.inc' %] |