|
Lines 1070-1248
Link Here
|
| 1070 |
const is_debarred = [% userdebarred ? 1 : 0 | html %]; |
1070 |
const is_debarred = [% userdebarred ? 1 : 0 | html %]; |
| 1071 |
const current_article_requests_size = [% current_article_requests.size || 0 | html %]; |
1071 |
const current_article_requests_size = [% current_article_requests.size || 0 | html %]; |
| 1072 |
</script> |
1072 |
</script> |
| 1073 |
|
|
|
| 1074 |
<script> |
1073 |
<script> |
| 1075 |
var AR_CAPTION_COUNT = _("(%s total)"); |
1074 |
var AR_CAPTION_COUNT = _("(%s total)"); |
| 1076 |
|
1075 |
|
| 1077 |
|
1076 |
function tableInit(tableId) { |
| 1078 |
function tableInit( tableId ){ |
1077 |
if (tableId == "checkoutst") { |
| 1079 |
if( tableId == "checkoutst" ){ |
1078 |
$(".dt-buttons").append('<button type="button" class="dt-button buttons-ical" id="buttons-ics">iCal</button> '); |
| 1080 |
$(".dt-buttons").append("<button type=\"button\" class=\"dt-button buttons-ical\" id=\"buttons-ics\">iCal</button> "); |
1079 |
if (prefs.OpacRenewalAllowed && can_renew && !is_debarred) { |
| 1081 |
if (prefs.OpacRenewalAllowed && can_renew && !is_debarred){ |
1080 |
$(".dt-buttons").append( |
| 1082 |
$(".dt-buttons").append("<button id=\"renewselected_link\" class=\"dt-button buttons-renew\"><i class=\"fa fa-check\" aria-hidden=\"true\"></i> "+_("Renew selected")+"</button> <button id=\"renewall_link\" class=\"dt-button buttons-renewall\"><span class=\"fa-stack\"><i class=\"fa fa-check fa-stack-1x\" aria-hidden=\"true\"></i><i class=\"fa fa-check fa-stack-1x\" aria-hidden=\"true\"></i></span> "+_("Renew all")+"</button>"); |
1081 |
'<button id="renewselected_link" class="dt-button buttons-renew"><i class="fa fa-check" aria-hidden="true"></i> ' + |
|
|
1082 |
_("Renew selected") + |
| 1083 |
'</button> <button id="renewall_link" class="dt-button buttons-renewall"><span class="fa-stack"><i class="fa fa-check fa-stack-1x" aria-hidden="true"></i><i class="fa fa-check fa-stack-1x" aria-hidden="true"></i></span> ' + |
| 1084 |
_("Renew all") + |
| 1085 |
"</button>" |
| 1086 |
); |
| 1083 |
} |
1087 |
} |
| 1084 |
} |
1088 |
} |
| 1085 |
} |
1089 |
} |
| 1086 |
$(document).ready(function(){ |
1090 |
$(document).ready(function () { |
| 1087 |
if (tab){ |
1091 |
if (tab) { |
| 1088 |
$(`#opac-user-views a[href='#${tab}_panel']`).tab("show"); |
1092 |
$(`#opac-user-views a[href='#${tab}_panel']`).tab("show"); |
| 1089 |
} |
1093 |
} |
| 1090 |
if( $("#opac-user-views .tab-pane.active").length < 1 ){ |
1094 |
if ($("#opac-user-views .tab-pane.active").length < 1) { |
| 1091 |
$("#opac-user-views a:first").tab("show"); |
1095 |
$("#opac-user-views a:first").tab("show"); |
| 1092 |
} |
1096 |
} |
| 1093 |
|
1097 |
|
| 1094 |
$('#article-requests-table caption .count').html(AR_CAPTION_COUNT.format(current_article_requests_size)); |
1098 |
$("#article-requests-table caption .count").html(AR_CAPTION_COUNT.format(current_article_requests_size)); |
| 1095 |
|
1099 |
|
| 1096 |
$(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs"); |
1100 |
$(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs"); |
| 1097 |
|
1101 |
|
| 1098 |
$(".btn-delete-hold").on("click", function(e){ |
1102 |
$(".btn-delete-hold").on("click", function (e) { |
| 1099 |
e.preventDefault(); |
1103 |
e.preventDefault(); |
| 1100 |
var hold_title = $(this).data("title"); |
1104 |
var hold_title = $(this).data("title"); |
| 1101 |
var reserve_id = $(this).data("reserve_id"); |
1105 |
var reserve_id = $(this).data("reserve_id"); |
| 1102 |
confirmModal( hold_title, _("Are you sure you want to cancel this hold?"), _("Yes, cancel hold"), _("No, do not cancel hold"), function( result ){ |
1106 |
confirmModal(hold_title, _("Are you sure you want to cancel this hold?"), _("Yes, cancel hold"), _("No, do not cancel hold"), function (result) { |
| 1103 |
if( result ){ |
1107 |
if (result) { |
| 1104 |
$("#delete_hold_" + reserve_id ).submit(); |
1108 |
$("#delete_hold_" + reserve_id).submit(); |
| 1105 |
} |
|
|
| 1106 |
} |
1109 |
} |
| 1107 |
); |
1110 |
}); |
| 1108 |
}); |
1111 |
}); |
| 1109 |
|
1112 |
|
| 1110 |
$(".btn-req-delete-hold").on("click", function(e){ |
1113 |
$(".btn-req-delete-hold").on("click", function (e) { |
| 1111 |
e.preventDefault(); |
1114 |
e.preventDefault(); |
| 1112 |
var hold_title = $(this).data("title"); |
1115 |
var hold_title = $(this).data("title"); |
| 1113 |
var reserve_id = $(this).data("reserve_id"); |
1116 |
var reserve_id = $(this).data("reserve_id"); |
| 1114 |
confirmModal( hold_title, _("Are you sure you want to request cancelling this hold?"), _("Yes"), _("No"), function( result ){ |
1117 |
confirmModal(hold_title, _("Are you sure you want to request cancelling this hold?"), _("Yes"), _("No"), function (result) { |
| 1115 |
if( result ){ |
1118 |
if (result) { |
| 1116 |
$("#req_cancel_hold_" + reserve_id ).submit(); |
1119 |
$("#req_cancel_hold_" + reserve_id).submit(); |
| 1117 |
} |
|
|
| 1118 |
} |
1120 |
} |
| 1119 |
); |
1121 |
}); |
| 1120 |
}); |
1122 |
}); |
| 1121 |
|
1123 |
|
| 1122 |
$("#article-requests-table").on("click", ".btn-delete-article-request", function(e){ |
1124 |
$("#article-requests-table").on("click", ".btn-delete-article-request", function (e) { |
| 1123 |
e.preventDefault(); |
1125 |
e.preventDefault(); |
| 1124 |
var article_request = $(this).data("title"); |
1126 |
var article_request = $(this).data("title"); |
| 1125 |
var article_request_id = $(this).data("article-request_id"); |
1127 |
var article_request_id = $(this).data("article-request_id"); |
| 1126 |
(function(row){ |
1128 |
(function (row) { |
| 1127 |
var doCancel = function( result ){ |
1129 |
var doCancel = function (result) { |
| 1128 |
if( result ){ |
1130 |
if (result) { |
| 1129 |
$.ajax({ |
1131 |
$.ajax({ |
| 1130 |
type: "DELETE", |
1132 |
type: "DELETE", |
| 1131 |
url: `/api/v1/public/patrons/${logged_in_user_borrowernumber}/article_requests/${article_request_id}?cancellation_reason=OPAC`, |
1133 |
url: `/api/v1/public/patrons/${logged_in_user_borrowernumber}/article_requests/${article_request_id}?cancellation_reason=OPAC`, |
| 1132 |
success: function( data ) { |
1134 |
success: function (data) { |
| 1133 |
$("#article_" + article_request_id ).hide({ |
1135 |
$("#article_" + article_request_id).hide({ |
| 1134 |
duration: 'slow', |
1136 |
duration: "slow", |
| 1135 |
complete: function() { |
1137 |
complete: function () { |
| 1136 |
$(this).siblings(".child").hide(); |
1138 |
$(this).siblings(".child").hide(); |
| 1137 |
var ar_tab = $('a[href="#opac-user-article-requests_panel"'); |
1139 |
var ar_tab = $('a[href="#opac-user-article-requests_panel"'); |
| 1138 |
var ar_table = $('#article-requests-table'); |
1140 |
var ar_table = $("#article-requests-table"); |
| 1139 |
var ar_length = $('tbody tr:visible', ar_table).length; |
1141 |
var ar_length = $("tbody tr:visible", ar_table).length; |
| 1140 |
var ar_count = $('caption .count', ar_table); |
1142 |
var ar_count = $("caption .count", ar_table); |
| 1141 |
|
1143 |
|
| 1142 |
ar_tab.html(ar_tab.html().replace(/\(\d+\)/, '('+ar_length+')')); |
1144 |
ar_tab.html(ar_tab.html().replace(/\(\d+\)/, "(" + ar_length + ")")); |
| 1143 |
ar_count.html(AR_CAPTION_COUNT.format(ar_length)); |
1145 |
ar_count.html(AR_CAPTION_COUNT.format(ar_length)); |
| 1144 |
|
1146 |
}, |
| 1145 |
} |
|
|
| 1146 |
}); |
1147 |
}); |
| 1147 |
} |
1148 |
}, |
| 1148 |
}); |
1149 |
}); |
| 1149 |
} |
1150 |
} |
| 1150 |
}; |
1151 |
}; |
| 1151 |
confirmModal( article_request, _("Are you sure you want to cancel this article request?"), _("Yes, cancel article request"), _("No, do not cancel article request"), doCancel); |
1152 |
confirmModal(article_request, _("Are you sure you want to cancel this article request?"), _("Yes, cancel article request"), _("No, do not cancel article request"), doCancel); |
| 1152 |
})($(this)) |
1153 |
})($(this)); |
| 1153 |
}); |
1154 |
}); |
| 1154 |
|
1155 |
|
| 1155 |
/* We initiate this flatpickr instance here so that we can use the variable later */ |
1156 |
/* We initiate this flatpickr instance here so that we can use the variable later */ |
| 1156 |
var suspend_until_date = $("#suspend_untilDate").flatpickr({ |
1157 |
var suspend_until_date = $("#suspend_untilDate").flatpickr({ |
| 1157 |
minDate: "today" |
1158 |
minDate: "today", |
| 1158 |
}); |
1159 |
}); |
| 1159 |
|
1160 |
|
| 1160 |
$(document).on("click", ".suspend_hold", function(e){ |
1161 |
$(document).on("click", ".suspend_hold", function (e) { |
| 1161 |
e.preventDefault(); |
1162 |
e.preventDefault(); |
| 1162 |
var title = $(this).data("title"); |
1163 |
var title = $(this).data("title"); |
| 1163 |
var reserve_id = $(this).data("reserve_id"); |
1164 |
var reserve_id = $(this).data("reserve_id"); |
| 1164 |
$("#suspendHoldReserveId").val( reserve_id ); |
1165 |
$("#suspendHoldReserveId").val(reserve_id); |
| 1165 |
$("#suspendHoldTitle").html( "<em>" + title + "</em>" ); |
1166 |
$("#suspendHoldTitle").html("<em>" + title + "</em>"); |
| 1166 |
$("#suspendHoldModal").modal("show"); |
1167 |
$("#suspendHoldModal").modal("show"); |
| 1167 |
}); |
1168 |
}); |
| 1168 |
|
1169 |
|
| 1169 |
$("#suspendHoldModal").on("hidden.bs.modal", function(){ |
1170 |
$("#suspendHoldModal").on("hidden.bs.modal", function () { |
| 1170 |
$("#suspendHoldTitle").html(""); |
1171 |
$("#suspendHoldTitle").html(""); |
| 1171 |
$("#suspendHoldReserveId").val(""); |
1172 |
$("#suspendHoldReserveId").val(""); |
| 1172 |
suspend_until_date.clear(); |
1173 |
suspend_until_date.clear(); |
| 1173 |
}); |
1174 |
}); |
| 1174 |
|
1175 |
|
| 1175 |
$("#suspend_all_submit").on("click", function(e){ |
1176 |
$("#suspend_all_submit").on("click", function (e) { |
| 1176 |
e.preventDefault(); |
1177 |
e.preventDefault(); |
| 1177 |
var title = _("Are you sure you want to suspend all holds?"); |
1178 |
var title = _("Are you sure you want to suspend all holds?"); |
| 1178 |
var body = _("All holds will be suspended."); |
1179 |
var body = _("All holds will be suspended."); |
| 1179 |
confirmModal( body, title, _("Yes, suspend all holds"), "", function( result ){ |
1180 |
confirmModal(body, title, _("Yes, suspend all holds"), "", function (result) { |
| 1180 |
if( result ){ |
1181 |
if (result) { |
| 1181 |
$("#suspend_all_holds").submit(); |
1182 |
$("#suspend_all_holds").submit(); |
| 1182 |
} |
|
|
| 1183 |
} |
1183 |
} |
| 1184 |
); |
1184 |
}); |
| 1185 |
}); |
1185 |
}); |
| 1186 |
|
1186 |
|
| 1187 |
$("#resume_all_submit").on("click", function(e){ |
1187 |
$("#resume_all_submit").on("click", function (e) { |
| 1188 |
e.preventDefault(); |
1188 |
e.preventDefault(); |
| 1189 |
var title = _("Are you sure you want to resume all suspended holds?"); |
1189 |
var title = _("Are you sure you want to resume all suspended holds?"); |
| 1190 |
var body = _("All holds will resume."); |
1190 |
var body = _("All holds will resume."); |
| 1191 |
confirmModal( body, title, _("Yes, resume all holds"), _("No, do not resume holds"), function( result ){ |
1191 |
confirmModal(body, title, _("Yes, resume all holds"), _("No, do not resume holds"), function (result) { |
| 1192 |
if( result ){ |
1192 |
if (result) { |
| 1193 |
$("#resume_all_holds").submit(); |
1193 |
$("#resume_all_holds").submit(); |
| 1194 |
} |
|
|
| 1195 |
} |
1194 |
} |
| 1196 |
); |
1195 |
}); |
| 1197 |
}); |
1196 |
}); |
| 1198 |
|
1197 |
|
| 1199 |
var dTables = $("#checkoutst,#holdst,#overduest,#opac-user-relative-issues-table"); |
1198 |
var dTables = $("#checkoutst,#holdst,#overduest,#opac-user-relative-issues-table"); |
| 1200 |
dTables.each(function(){ |
1199 |
dTables.each(function () { |
| 1201 |
var thIndex = $(this).find("th.psort").index(); |
1200 |
var thIndex = $(this).find("th.psort").index(); |
| 1202 |
$(this).on("init.dt", function() { |
1201 |
$(this) |
| 1203 |
tableInit( $(this).attr("id") ); |
1202 |
.on("init.dt", function () { |
|
|
1203 |
tableInit($(this).attr("id")); |
| 1204 |
}) |
1204 |
}) |
| 1205 |
.kohaTable({ |
1205 |
.kohaTable({ |
| 1206 |
order: [[ thIndex, 'asc' ]], |
1206 |
order: [[thIndex, "asc"]], |
| 1207 |
dom: '<"top"<"table_entries"><"table_controls"fB>>t', |
1207 |
dom: '<"top"<"table_entries"><"table_controls"fB>>t', |
| 1208 |
columnDefs: [ |
1208 |
columnDefs: [ |
| 1209 |
{ visible: false, "targets" : [ "hidden" ] }, |
1209 |
{ visible: false, targets: ["hidden"] }, |
| 1210 |
{ className: 'dtr-control', orderable: false, targets: -1 } |
1210 |
{ className: "dtr-control", orderable: false, targets: -1 }, |
| 1211 |
], |
1211 |
], |
| 1212 |
language: { |
1212 |
language: { |
| 1213 |
search: "_INPUT_", |
1213 |
search: "_INPUT_", |
| 1214 |
searchPlaceholder: _("Search") |
1214 |
searchPlaceholder: _("Search"), |
| 1215 |
}, |
|
|
| 1216 |
responsive: { |
| 1217 |
details: { |
| 1218 |
type: 'column', |
| 1219 |
target: -1 |
| 1220 |
} |
| 1221 |
}, |
| 1222 |
buttons: [ |
| 1223 |
/* Override default button set so that we can extend the options of print and csv */ |
| 1224 |
'clearFilter', 'copy', |
| 1225 |
{ |
| 1226 |
extend: "print", |
| 1227 |
exportOptions: { |
| 1228 |
/* Print view should show all columns (even invisible ones) unless they are .no-export */ |
| 1229 |
columns: ":not(.no-export)" |
| 1230 |
} |
| 1231 |
}, |
1215 |
}, |
| 1232 |
{ |
1216 |
responsive: { |
| 1233 |
extend: "csv", |
1217 |
details: { |
| 1234 |
exportOptions: { |
1218 |
type: "column", |
| 1235 |
/* CSV export should include all columns (even invisible ones) unless they are .no-export */ |
1219 |
target: -1, |
| 1236 |
columns: ":not(.no-export)" |
1220 |
}, |
| 1237 |
} |
1221 |
}, |
| 1238 |
} |
1222 |
buttons: [ |
| 1239 |
] |
1223 |
/* Override default button set so that we can extend the options of print and csv */ |
| 1240 |
}); |
1224 |
"clearFilter", |
|
|
1225 |
"copy", |
| 1226 |
{ |
| 1227 |
extend: "print", |
| 1228 |
exportOptions: { |
| 1229 |
/* Print view should show all columns (even invisible ones) unless they are .no-export */ |
| 1230 |
columns: ":not(.no-export)", |
| 1231 |
}, |
| 1232 |
}, |
| 1233 |
{ |
| 1234 |
extend: "csv", |
| 1235 |
exportOptions: { |
| 1236 |
/* CSV export should include all columns (even invisible ones) unless they are .no-export */ |
| 1237 |
columns: ":not(.no-export)", |
| 1238 |
}, |
| 1239 |
}, |
| 1240 |
], |
| 1241 |
}); |
| 1241 |
}); |
1242 |
}); |
| 1242 |
|
1243 |
|
| 1243 |
var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow; |
1244 |
var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow; |
| 1244 |
var dataTables = $("#recalls-table,#article-requests-table"); |
1245 |
var dataTables = $("#recalls-table,#article-requests-table"); |
| 1245 |
dataTables.each(function(){ |
1246 |
dataTables.each(function () { |
| 1246 |
$(this).kohaTable({ |
1247 |
$(this).kohaTable({ |
| 1247 |
searching: false, |
1248 |
searching: false, |
| 1248 |
paging: false, |
1249 |
paging: false, |
|
Lines 1251-1319
Link Here
|
| 1251 |
details: { |
1252 |
details: { |
| 1252 |
display: responsive_display, |
1253 |
display: responsive_display, |
| 1253 |
type: "column", |
1254 |
type: "column", |
| 1254 |
target: -1 |
1255 |
target: -1, |
| 1255 |
}, |
1256 |
}, |
| 1256 |
}, |
1257 |
}, |
| 1257 |
columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }], |
1258 |
columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }], |
| 1258 |
}); |
1259 |
}); |
| 1259 |
}); |
1260 |
}); |
| 1260 |
$('a[data-bs-toggle="tab"]').on('shown.bs.tab', function (event) { |
1261 |
$('a[data-bs-toggle="tab"]').on("shown.bs.tab", function (event) { |
| 1261 |
dTables.DataTable().responsive.recalc(); |
1262 |
dTables.DataTable().responsive.recalc(); |
| 1262 |
dataTables.DataTable().responsive.recalc(); |
1263 |
dataTables.DataTable().responsive.recalc(); |
| 1263 |
} ); |
1264 |
}); |
| 1264 |
|
1265 |
|
| 1265 |
$("body").on("click", "#buttons-ics", function(){ |
1266 |
$("body").on("click", "#buttons-ics", function () { |
| 1266 |
location.href="/cgi-bin/koha/opac-ics.pl"; |
1267 |
location.href = "/cgi-bin/koha/opac-ics.pl"; |
| 1267 |
}); |
1268 |
}); |
| 1268 |
|
1269 |
|
| 1269 |
if (prefs.GoogleJackets){ |
1270 |
if (prefs.GoogleJackets) { |
| 1270 |
KOHA.Google.GetCoverFromIsbn(); |
1271 |
KOHA.Google.GetCoverFromIsbn(); |
| 1271 |
} |
1272 |
} |
| 1272 |
if (prefs.OpacRenewalAllowed && can_renew && !is_debarred){ |
1273 |
if (prefs.OpacRenewalAllowed && can_renew && !is_debarred) { |
| 1273 |
$("#renewselected").submit(function(){ |
1274 |
$("#renewselected").submit(function () { |
| 1274 |
valid = false; |
1275 |
valid = false; |
| 1275 |
$("input[type=checkbox]").each(function(){ |
1276 |
$("input[type=checkbox]").each(function () { |
| 1276 |
if($(this).is(':checked')){ |
1277 |
if ($(this).is(":checked")) { |
| 1277 |
valid = true; |
1278 |
valid = true; |
| 1278 |
} |
1279 |
} |
| 1279 |
}); |
1280 |
}); |
| 1280 |
if(!valid){ |
1281 |
if (!valid) { |
| 1281 |
alert(_("Nothing has been selected. Check the box for each item you want to renew")); |
1282 |
alert(_("Nothing has been selected. Check the box for each item you want to renew")); |
| 1282 |
} |
1283 |
} |
| 1283 |
return valid; |
1284 |
return valid; |
| 1284 |
}); |
1285 |
}); |
| 1285 |
$("body").on("click","#renewselected_link",function(e){ |
1286 |
$("body").on("click", "#renewselected_link", function (e) { |
| 1286 |
e.preventDefault(); |
1287 |
e.preventDefault(); |
| 1287 |
$("#renewselected").submit(); |
1288 |
$("#renewselected").submit(); |
| 1288 |
}); |
1289 |
}); |
| 1289 |
$("body").on("click","#renewall_link, #renewall_js",function(e){ |
1290 |
$("body").on("click", "#renewall_link, #renewall_js", function (e) { |
| 1290 |
e.preventDefault(); |
1291 |
e.preventDefault(); |
| 1291 |
$("#renewall").submit(); |
1292 |
$("#renewall").submit(); |
| 1292 |
}); |
1293 |
}); |
| 1293 |
} |
1294 |
} |
| 1294 |
|
1295 |
|
| 1295 |
if (prefs.AllowCheckoutNotes){ |
1296 |
if (prefs.AllowCheckoutNotes) { |
| 1296 |
|
|
|
| 1297 |
/* If JS enabled, show button, otherwise show link to redirect to a page where note can be submitted */ |
1297 |
/* If JS enabled, show button, otherwise show link to redirect to a page where note can be submitted */ |
| 1298 |
$(".nonjs_submitnote").hide(); |
1298 |
$(".nonjs_submitnote").hide(); |
| 1299 |
|
1299 |
|
| 1300 |
$("input[name='note']").prop('readonly', false); |
1300 |
$("input[name='note']").prop("readonly", false); |
| 1301 |
$("input[name='note']").keypress(function(e){ |
1301 |
$("input[name='note']").keypress(function (e) { |
| 1302 |
/* prevent submitting of renewselected form */ |
1302 |
/* prevent submitting of renewselected form */ |
| 1303 |
if(e.which == 13) |
1303 |
if (e.which == 13) e.preventDefault(); |
| 1304 |
e.preventDefault(); |
|
|
| 1305 |
}); |
1304 |
}); |
| 1306 |
|
1305 |
|
| 1307 |
$("input[name='note']").keyup(function(e){ |
1306 |
$("input[name='note']").keyup(function (e) { |
| 1308 |
var $btn_save = $('#save_'+$(this).data('issue_id')); |
1307 |
var $btn_save = $("#save_" + $(this).data("issue_id")); |
| 1309 |
var origvalue = $(this).data('origvalue'); |
1308 |
var origvalue = $(this).data("origvalue"); |
| 1310 |
var value = $(this).val(); |
1309 |
var value = $(this).val(); |
| 1311 |
|
1310 |
|
| 1312 |
if(origvalue != value) { |
1311 |
if (origvalue != value) { |
| 1313 |
if(origvalue != "") |
1312 |
if (origvalue != "") $btn_save.text(_("Submit changes")); |
| 1314 |
$btn_save.text(_("Submit changes")); |
1313 |
else $btn_save.text(_("Submit note")); |
| 1315 |
else |
|
|
| 1316 |
$btn_save.text(_("Submit note")); |
| 1317 |
$btn_save.show(); |
1314 |
$btn_save.show(); |
| 1318 |
} else { |
1315 |
} else { |
| 1319 |
$btn_save.hide(); |
1316 |
$btn_save.hide(); |
|
Lines 1321-1440
Link Here
|
| 1321 |
}); |
1318 |
}); |
| 1322 |
} |
1319 |
} |
| 1323 |
|
1320 |
|
| 1324 |
$(".change_pickup").on("click", function(){ |
1321 |
$(".change_pickup").on("click", function () { |
| 1325 |
var hold_id = $(this).data("hold-id"); |
1322 |
var hold_id = $(this).data("hold-id"); |
| 1326 |
$(this).hide(); |
1323 |
$(this).hide(); |
| 1327 |
$("#change-pickup-location" + hold_id ).show(); |
1324 |
$("#change-pickup-location" + hold_id).show(); |
| 1328 |
}); |
1325 |
}); |
| 1329 |
|
1326 |
|
| 1330 |
if ( $('#opac-user-clubs_panel').length ) { |
1327 |
if ($("#opac-user-clubs_panel").length) { |
| 1331 |
$('#opac-user-clubs-tab').on('click', function() { |
1328 |
$("#opac-user-clubs-tab").on("click", function () { |
| 1332 |
$('#opac-user-clubs_panel').text(_("Loading...")); |
1329 |
$("#opac-user-clubs_panel").text(_("Loading...")); |
| 1333 |
$('#opac-user-clubs_panel').load(`/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=${logged_in_user_borrowernumber}`); |
1330 |
$("#opac-user-clubs_panel").load(`/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=${logged_in_user_borrowernumber}`); |
| 1334 |
}); |
1331 |
}); |
| 1335 |
} |
1332 |
} |
| 1336 |
|
1333 |
|
| 1337 |
$(".cancel_recall").click(function(e){ |
1334 |
$(".cancel_recall").click(function (e) { |
| 1338 |
return confirmDelete(_("Are you sure you want to remove this recall?")); |
1335 |
return confirmDelete(_("Are you sure you want to remove this recall?")); |
| 1339 |
}); |
1336 |
}); |
| 1340 |
|
1337 |
|
| 1341 |
$("body").on("click", ".btn-add-note", function(e){ |
1338 |
$("body").on("click", ".btn-add-note", function (e) { |
| 1342 |
e.preventDefault(); |
1339 |
e.preventDefault(); |
| 1343 |
var title = $(this).data("title"); |
1340 |
var title = $(this).data("title"); |
| 1344 |
var issue_id = $(this).data("issueid"); |
1341 |
var issue_id = $(this).data("issueid"); |
| 1345 |
var note = $("#note_" + issue_id ).val(); |
1342 |
var note = $("#note_" + issue_id).val(); |
| 1346 |
var origvalue = $("#note_" + issue_id ).data("origvalue"); |
1343 |
var origvalue = $("#note_" + issue_id).data("origvalue"); |
| 1347 |
$("#addNote").val( note ); |
1344 |
$("#addNote").val(note); |
| 1348 |
$("#addNoteIssueId").val( issue_id ); |
1345 |
$("#addNoteIssueId").val(issue_id); |
| 1349 |
$("#addNoteTitle").text( title ); |
1346 |
$("#addNoteTitle").text(title); |
| 1350 |
$("#addNoteModal").modal("show"); |
1347 |
$("#addNoteModal").modal("show"); |
| 1351 |
}); |
1348 |
}); |
| 1352 |
|
1349 |
|
| 1353 |
$("#addNoteForm").on("submit", function(e){ |
1350 |
$("#addNoteForm").on("submit", function (e) { |
| 1354 |
e.preventDefault(); |
1351 |
e.preventDefault(); |
| 1355 |
var title = $("#addNoteTitle").text(); |
1352 |
var title = $("#addNoteTitle").text(); |
| 1356 |
var issue_id = $("#addNoteIssueId").val(); |
1353 |
var issue_id = $("#addNoteIssueId").val(); |
| 1357 |
var note = $("#addNote").val(); |
1354 |
var note = $("#addNote").val(); |
| 1358 |
submitNote( title, issue_id, note ); |
1355 |
submitNote(title, issue_id, note); |
| 1359 |
}); |
1356 |
}); |
| 1360 |
|
1357 |
|
| 1361 |
$("#addNoteModal").on("hidden.bs.modal", function(){ |
1358 |
$("#addNoteModal").on("hidden.bs.modal", function () { |
| 1362 |
$("#addNoteTitle").text(""); |
1359 |
$("#addNoteTitle").text(""); |
| 1363 |
$("#addNote").val(""); |
1360 |
$("#addNote").val(""); |
| 1364 |
}); |
1361 |
}); |
| 1365 |
|
1362 |
|
| 1366 |
$(".dismiss-message-button").click(function(e){ |
1363 |
$(".dismiss-message-button").click(function (e) { |
| 1367 |
return confirmDelete(_("Are you sure you want to dismiss this message?")); |
1364 |
return confirmDelete(_("Are you sure you want to dismiss this message?")); |
| 1368 |
}); |
1365 |
}); |
| 1369 |
|
|
|
| 1370 |
}); |
1366 |
}); |
| 1371 |
|
1367 |
|
| 1372 |
function submitNote( title, issue_id, note ){ |
1368 |
function submitNote(title, issue_id, note) { |
| 1373 |
var self = $("#addNoteModal"); |
1369 |
var self = $("#addNoteModal"); |
| 1374 |
var notebutton = $("#save_" + issue_id ); |
1370 |
var notebutton = $("#save_" + issue_id); |
| 1375 |
var noteinput = $("#note_" + issue_id ); |
1371 |
var noteinput = $("#note_" + issue_id); |
| 1376 |
|
1372 |
|
| 1377 |
var ajaxData = { |
1373 |
var ajaxData = { |
| 1378 |
'action': 'issuenote', |
1374 |
action: "issuenote", |
| 1379 |
'issue_id': issue_id, |
1375 |
issue_id: issue_id, |
| 1380 |
'note': note, |
1376 |
note: note, |
| 1381 |
csrf_token: $('meta[name="csrf-token"]').attr('content'), |
1377 |
csrf_token: $('meta[name="csrf-token"]').attr("content"), |
| 1382 |
op: 'cud-add_note', |
1378 |
op: "cud-add_note", |
| 1383 |
}; |
1379 |
}; |
| 1384 |
|
1380 |
|
| 1385 |
$.ajax({ |
1381 |
$.ajax({ |
| 1386 |
url: '/cgi-bin/koha/svc/checkout_notes/', |
1382 |
url: "/cgi-bin/koha/svc/checkout_notes/", |
| 1387 |
type: 'POST', |
1383 |
type: "POST", |
| 1388 |
dataType: 'json', |
1384 |
dataType: "json", |
| 1389 |
data: ajaxData, |
1385 |
data: ajaxData, |
| 1390 |
}) |
1386 |
}) |
| 1391 |
.done(function(data) { |
1387 |
.done(function (data) { |
| 1392 |
var message = ""; |
1388 |
var message = ""; |
| 1393 |
if(data.status == 'saved') { |
1389 |
if (data.status == "saved") { |
| 1394 |
$("#notesaved").removeClass("alert-error"); |
1390 |
$("#notesaved").removeClass("alert-error"); |
| 1395 |
$("#notesaved").addClass("alert-info"); |
1391 |
$("#notesaved").addClass("alert-info"); |
| 1396 |
noteinput.data('origvalue', data.note) |
1392 |
noteinput.data("origvalue", data.note).val(data.note); |
| 1397 |
.val(data.note); |
1393 |
notebutton.text(_("Edit note")); |
| 1398 |
notebutton.text( _("Edit note" ) ); |
1394 |
$("#viewnote_" + issue_id).text(data.note); |
| 1399 |
$("#viewnote_" + issue_id ).text( data.note ); |
1395 |
message = "<p>" + _("Your note about %s has been saved and sent to the library.").format(em(title)) + "</p>"; |
| 1400 |
message = "<p>" + _("Your note about %s has been saved and sent to the library.").format( em(title) ) + "</p>"; |
1396 |
message += '<p class="checkout_note">' + data.note; |
| 1401 |
message += "<p class=\"checkout_note\">" + data.note; |
1397 |
message += |
| 1402 |
message += "<a href=\"/cgi-bin/koha/opac-issue-note.pl?issue_id=" + issue_id + "\" class=\"btn btn-link btn-sm btn-add-note\" data-title=\"" + title + "\" data-issueid=\"" + issue_id + "\"><i class=\"fa fa-pencil\" aria-hidden=\"true\"></i> " + _("Edit note") + "</a>"; |
1398 |
'<a href="/cgi-bin/koha/opac-issue-note.pl?issue_id=' + |
| 1403 |
message += "</p>"; |
1399 |
issue_id + |
| 1404 |
} else if(data.status == 'removed') { |
1400 |
'" class="btn btn-link btn-sm btn-add-note" data-title="' + |
| 1405 |
$("#notesaved").removeClass("alert-error"); |
1401 |
title + |
| 1406 |
$("#notesaved").addClass("alert-info"); |
1402 |
'" data-issueid="' + |
| 1407 |
noteinput.data('origvalue', "") |
1403 |
issue_id + |
| 1408 |
.val("") |
1404 |
'"><i class="fa fa-pencil" aria-hidden="true"></i> ' + |
| 1409 |
notebutton.text( _("Add note") ); |
1405 |
_("Edit note") + |
| 1410 |
$("#viewnote_" + issue_id ).text( data.note ); |
1406 |
"</a>"; |
| 1411 |
message = "<p>" + _("Your note about %s was removed.").format( em(title) ) + "</p>"; |
1407 |
message += "</p>"; |
| 1412 |
} else { |
1408 |
} else if (data.status == "removed") { |
|
|
1409 |
$("#notesaved").removeClass("alert-error"); |
| 1410 |
$("#notesaved").addClass("alert-info"); |
| 1411 |
noteinput.data("origvalue", "").val(""); |
| 1412 |
notebutton.text(_("Add note")); |
| 1413 |
$("#viewnote_" + issue_id).text(data.note); |
| 1414 |
message = "<p>" + _("Your note about %s was removed.").format(em(title)) + "</p>"; |
| 1415 |
} else { |
| 1416 |
$("#notesaved").removeClass("alert-info"); |
| 1417 |
$("#notesaved").addClass("alert-error"); |
| 1418 |
message = "<p>" + _("Your note about %s could not be saved.").format(em(title)) + "</p>"; |
| 1419 |
notebutton.text(_("Add note")); |
| 1420 |
$("#viewnote_" + issue_id).text(data.note); |
| 1421 |
message += '<p style="font-weight:bold;">' + _("Something went wrong. The note has not been saved") + "</p>"; |
| 1422 |
} |
| 1423 |
$("#notesaved").html(message); |
| 1424 |
}) |
| 1425 |
.fail(function (data) { |
| 1413 |
$("#notesaved").removeClass("alert-info"); |
1426 |
$("#notesaved").removeClass("alert-info"); |
| 1414 |
$("#notesaved").addClass("alert-error"); |
1427 |
$("#notesaved").addClass("alert-error"); |
| 1415 |
message = "<p>" + _("Your note about %s could not be saved.").format( em(title) ) + "</p>"; |
1428 |
var message = '<p style="font-weight:bold;">' + _("Something went wrong. The note has not been saved") + "</p>"; |
| 1416 |
notebutton.text( _("Add note") ); |
1429 |
$("#notesaved").html(message); |
| 1417 |
$("#viewnote_" + issue_id ).text( data.note ); |
1430 |
}) |
| 1418 |
message += "<p style=\"font-weight:bold;\">" + _("Something went wrong. The note has not been saved") + "</p>"; |
1431 |
.always(function () { |
| 1419 |
} |
1432 |
self.modal("hide"); |
| 1420 |
$("#notesaved").html(message); |
1433 |
$("#notesaved").show(); |
| 1421 |
}) |
1434 |
}); |
| 1422 |
.fail(function(data) { |
|
|
| 1423 |
$("#notesaved").removeClass("alert-info"); |
| 1424 |
$("#notesaved").addClass("alert-error"); |
| 1425 |
var message = "<p style=\"font-weight:bold;\">" + _("Something went wrong. The note has not been saved") + "</p>"; |
| 1426 |
$("#notesaved").html(message); |
| 1427 |
}) |
| 1428 |
.always(function() { |
| 1429 |
self.modal("hide"); |
| 1430 |
$("#notesaved").show(); |
| 1431 |
}); |
| 1432 |
} |
1435 |
} |
| 1433 |
|
1436 |
|
| 1434 |
function em( title ){ |
1437 |
function em(title) { |
| 1435 |
return "<em>" + title + "</em>"; |
1438 |
return "<em>" + title + "</em>"; |
| 1436 |
} |
1439 |
} |
| 1437 |
|
|
|
| 1438 |
</script> |
1440 |
</script> |
| 1439 |
[% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %] |
1441 |
[% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %] |
| 1440 |
[% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %] |
1442 |
[% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %] |
| 1441 |
- |
|
|