Bug 36084: svc - recall
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
25ea67c2ca
commit
d4ce4d8fa2
|
|
@ -102,15 +102,15 @@
|
|||
</button>
|
||||
<ul class="dropdown-menu pull-right">
|
||||
[% IF ( recall.requested or recall.overdue ) %]
|
||||
<li><a class="cancel_recall" data-id="[% recall.id | html %]" data-action="cancel"><i class="fa fa-times"></i> Cancel</a></li>
|
||||
<li><a class="cancel_recall" data-id="[% recall.id | html %]"><i class="fa fa-times"></i> Cancel</a></li>
|
||||
[% IF ( recall.should_be_overdue ) %]
|
||||
<li><a class="overdue_recall" data-id="[% recall.id | html %]" data-action="overdue"><i class="fa fa-hourglass-end"></i> Mark as overdue</a></li>
|
||||
<li><a class="overdue_recall" data-id="[% recall.id | html %]"><i class="fa fa-hourglass-end"></i> Mark as overdue</a></li>
|
||||
[% END %]
|
||||
[% ELSIF ( recall.waiting ) %]
|
||||
<li><a class="revert_recall" data-id="[% recall.id | html %]" data-action="revert"><i class="fa fa-undo"></i> Revert waiting</a></li>
|
||||
<li><a class="expire_recall" data-id="[% recall.id | html %]" data-action="expire"><i class="fa fa-times"></i> Expire</a></li>
|
||||
<li><a class="revert_recall" data-id="[% recall.id | html %]"><i class="fa fa-undo"></i> Revert waiting</a></li>
|
||||
<li><a class="expire_recall" data-id="[% recall.id | html %]"><i class="fa fa-times"></i> Expire</a></li>
|
||||
[% ELSIF ( recall.in_transit ) %]
|
||||
<li><a class="transit_recall" data-id="[% recall.id | html %]" data-action="transit"><i class="fa fa-times"></i> Cancel recall and return to: [% Branches.GetName(recall.item.homebranch) | html %]</a></li>
|
||||
<li><a class="transit_recall" data-id="[% recall.id | html %]"><i class="fa fa-times"></i> Cancel recall and return to: [% Branches.GetName(recall.item.homebranch) | html %]</a></li>
|
||||
[% END %]
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import ClubAPIClient from "./club-api-client.js";
|
|||
import CoverImageAPIClient from "./cover-image-api-client.js";
|
||||
import LocalizationAPIClient from "./localization-api-client.js";
|
||||
import PatronAPIClient from "./patron-api-client.js";
|
||||
import RecallAPIClient from "./recall-api-client.js";
|
||||
import SysprefAPIClient from "./system-preferences-api-client.js";
|
||||
import TicketAPIClient from "./ticket-api-client.js";
|
||||
|
||||
|
|
@ -16,6 +17,7 @@ export const APIClient = {
|
|||
cover_image: new CoverImageAPIClient(),
|
||||
localization: new LocalizationAPIClient(),
|
||||
patron: new PatronAPIClient(),
|
||||
ticket: new TicketAPIClient(),
|
||||
recall: new RecallAPIClient(),
|
||||
syspref: new SysprefAPIClient(),
|
||||
ticket: new TicketAPIClient(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
import HttpClient from "./http-client.js";
|
||||
|
||||
export class RecallAPIClient extends HttpClient {
|
||||
constructor() {
|
||||
super({
|
||||
baseURL: "/cgi-bin/koha/svc/recall",
|
||||
});
|
||||
}
|
||||
|
||||
get recalls() {
|
||||
return {
|
||||
cancel: recall_id =>
|
||||
this.post({
|
||||
endpoint: "",
|
||||
body: "recall_id=%s&op=%s".format(recall_id, "cud-cancel"),
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"application/x-www-form-urlencoded;charset=utf-8",
|
||||
},
|
||||
}),
|
||||
expire: recall_id =>
|
||||
this.post({
|
||||
endpoint: "",
|
||||
body: "recall_id=%s&op=%s".format(recall_id, "cud-expire"),
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"application/x-www-form-urlencoded;charset=utf-8",
|
||||
},
|
||||
}),
|
||||
|
||||
revert: recall_id =>
|
||||
this.post({
|
||||
endpoint: "",
|
||||
body: "recall_id=%s&op=%s".format(recall_id, "cud-revert"),
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"application/x-www-form-urlencoded;charset=utf-8",
|
||||
},
|
||||
}),
|
||||
|
||||
overdue: recall_id =>
|
||||
this.post({
|
||||
endpoint: "",
|
||||
body: "recall_id=%s&op=%s".format(recall_id, "cud-overdue"),
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"application/x-www-form-urlencoded;charset=utf-8",
|
||||
},
|
||||
}),
|
||||
|
||||
transit: recall_id =>
|
||||
this.post({
|
||||
endpoint: "",
|
||||
body: "recall_id=%s&op=%s".format(recall_id, "cud-transit"),
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"application/x-www-form-urlencoded;charset=utf-8",
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default RecallAPIClient;
|
||||
|
|
@ -1,142 +1,104 @@
|
|||
$(document).ready(function() {
|
||||
|
||||
const client = APIClient.recall;
|
||||
|
||||
$(".cancel_recall").click(function(e){
|
||||
if (confirmDelete(__("Are you sure you want to remove this recall?"))){
|
||||
var $self = $(this);
|
||||
var $recall_id = $(this).data('id');
|
||||
var $action = $(this).data('action');
|
||||
var ajaxData = {
|
||||
'recall_id': $recall_id,
|
||||
'action' : $action,
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: '/cgi-bin/koha/svc/recall',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: ajaxData,
|
||||
})
|
||||
.done(function(data) {
|
||||
var message = "";
|
||||
if(data.success == 0) {
|
||||
message = __("The recall may have already been cancelled. Please refresh the page.");
|
||||
} else {
|
||||
message = __("Cancelled");
|
||||
let td_node = $(this).parents('td');
|
||||
let recall_id = $(this).data('id');
|
||||
client.recalls.cancel(recall_id).then(
|
||||
success => {
|
||||
if(success.success == 0) {
|
||||
message = __("The recall may have already been cancelled. Please refresh the page.");
|
||||
} else {
|
||||
message = __("Cancelled");
|
||||
}
|
||||
td_node.html(message);
|
||||
},
|
||||
error => {
|
||||
console.warn("Something wrong happened: %s".format(error));
|
||||
}
|
||||
$self.parent().parent().parent().parent().html(message);
|
||||
});
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$(".expire_recall").click(function(e){
|
||||
if (confirmDelete(__("Are you sure you want to expire this recall?"))){
|
||||
var $self = $(this);
|
||||
var $recall_id = $(this).data('id');
|
||||
var $action = $(this).data('action');
|
||||
var ajaxData = {
|
||||
'recall_id': $recall_id,
|
||||
'action' : $action,
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: '/cgi-bin/koha/svc/recall',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: ajaxData,
|
||||
})
|
||||
.done(function(data) {
|
||||
var message = "";
|
||||
if(data.success == 0) {
|
||||
message = __("The recall may have already been expired. Please refresh the page.");
|
||||
} else {
|
||||
message = __("Expired");
|
||||
let td_node = $(this).parents('td');
|
||||
let recall_id = $(this).data('id');
|
||||
client.recalls.expire(recall_id).then(
|
||||
success => {
|
||||
if(success.success == 0) {
|
||||
message = __("The recall may have already been expired. Please refresh the page.");
|
||||
} else {
|
||||
message = __("Expired");
|
||||
}
|
||||
td_node.html(message);
|
||||
},
|
||||
error => {
|
||||
console.warn("Something wrong happened: %s".format(error));
|
||||
}
|
||||
$self.parent().parent().parent().parent().html(message);
|
||||
});
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$(".revert_recall").click(function(e){
|
||||
if (confirmDelete(__("Are you sure you want to revert the waiting status of this recall?"))){
|
||||
var $self = $(this);
|
||||
var $recall_id = $(this).data('id');
|
||||
var $action = $(this).data('action');
|
||||
var ajaxData = {
|
||||
'recall_id': $recall_id,
|
||||
'action' : $action,
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: '/cgi-bin/koha/svc/recall',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: ajaxData,
|
||||
})
|
||||
.done(function(data) {
|
||||
var message = "";
|
||||
if(data.success == 0) {
|
||||
message = __("The recall waiting status may have already been reverted. Please refresh the page.");
|
||||
} else {
|
||||
message = __("Waiting status reverted");
|
||||
let td_node = $(this).parents('td');
|
||||
let recall_id = $(this).data('id');
|
||||
client.recalls.revert(recall_id).then(
|
||||
success => {
|
||||
if(success.success == 0) {
|
||||
message = __("The recall may have already been reverted. Please refresh the page.");
|
||||
} else {
|
||||
message = __("Waiting status reverted");
|
||||
}
|
||||
td_node.html(message);
|
||||
},
|
||||
error => {
|
||||
console.warn("Something wrong happened: %s".format(error));
|
||||
}
|
||||
$self.parent().parent().parent().parent().html(message);
|
||||
});
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$(".overdue_recall").click(function(e){
|
||||
if (confirmDelete(__("Are you sure you want to mark this recall as overdue?"))){
|
||||
var $self = $(this);
|
||||
var $recall_id = $(this).data('id');
|
||||
var $action = $(this).data('action');
|
||||
var ajaxData = {
|
||||
'recall_id': $recall_id,
|
||||
'action' : $action,
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: '/cgi-bin/koha/svc/recall',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: ajaxData,
|
||||
})
|
||||
.done(function(data) {
|
||||
var message = "";
|
||||
if(data.success == 0) {
|
||||
message = __("The recall may have already been marked as overdue. Please refresh the page.");
|
||||
} else {
|
||||
message = __("Marked overdue");
|
||||
let td_node = $(this).parents('td');
|
||||
let recall_id = $(this).data('id');
|
||||
client.recalls.overdue(recall_id).then(
|
||||
success => {
|
||||
if(success.success == 0) {
|
||||
message = __("The recall may have already been marked as overdue. Please refresh the page.");
|
||||
} else {
|
||||
message = __("Marked overdue");
|
||||
}
|
||||
td_node.html(message);
|
||||
},
|
||||
error => {
|
||||
console.warn("Something wrong happened: %s".format(error));
|
||||
}
|
||||
$self.parent().parent().parent().parent().html(message);
|
||||
});
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$(".transit_recall").click(function(e){
|
||||
if (confirmDelete(__("Are you sure you want to remove this recall and return the item to it's home library?"))){
|
||||
var $self = $(this);
|
||||
var $recall_id = $(this).data('id');
|
||||
var $action = $(this).data('action');
|
||||
var ajaxData = {
|
||||
'recall_id': $recall_id,
|
||||
'action' : $action,
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: '/cgi-bin/koha/svc/recall',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: ajaxData,
|
||||
})
|
||||
.done(function(data) {
|
||||
var message = "";
|
||||
if(data.success == 0) {
|
||||
message = __("The recall may have already been removed. Please refresh the page.");
|
||||
} else {
|
||||
message = __("Cancelled");
|
||||
let td_node = $(this).parents('td');
|
||||
let recall_id = $(this).data('id');
|
||||
client.recalls.transit(recall_id).then(
|
||||
success => {
|
||||
if(success.success == 0) {
|
||||
message = __("The recall may have already been removed. Please refresh the page.");
|
||||
} else {
|
||||
message = __("Cancelled");
|
||||
}
|
||||
td_node.html(message);
|
||||
},
|
||||
error => {
|
||||
console.warn("Something wrong happened: %s".format(error));
|
||||
}
|
||||
$self.parent().parent().parent().parent().html(message);
|
||||
});
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
12
svc/recall
12
svc/recall
|
|
@ -45,37 +45,37 @@ unless ( $recall ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
my $op = $input->param('action');
|
||||
my $op = $input->param('op');
|
||||
|
||||
if ( $op eq 'cancel' ) {
|
||||
if ( $op eq 'cud-cancel' ) {
|
||||
# cancel recall
|
||||
$recall->set_cancelled;
|
||||
if ( $recall->cancelled ){
|
||||
$json = encode_json({ success => 1 });
|
||||
}
|
||||
|
||||
} elsif ( $op eq 'expire' ) {
|
||||
} elsif ( $op eq 'cud-expire' ) {
|
||||
# expire recall
|
||||
$recall->set_expired({ interface => 'INTRANET' });
|
||||
if ( $recall->expired ){
|
||||
$json = encode_json({ success => 1 });
|
||||
}
|
||||
|
||||
} elsif ( $op eq 'revert' ) {
|
||||
} elsif ( $op eq 'cud-revert' ) {
|
||||
# revert recall waiting status
|
||||
$recall->revert_waiting;
|
||||
if ( $recall->requested ){
|
||||
$json = encode_json({ success => 1 });
|
||||
}
|
||||
|
||||
} elsif ( $op eq 'overdue' ) {
|
||||
} elsif ( $op eq 'cud-overdue' ) {
|
||||
# mark recall as overdue
|
||||
$recall->set_overdue({ interface => 'INTRANET' });
|
||||
if ( $recall->overdue ){
|
||||
$json = encode_json({ success => 1 });
|
||||
}
|
||||
|
||||
} elsif ( $op eq 'transit' ) {
|
||||
} elsif ( $op eq 'cud-transit' ) {
|
||||
# cancel recall and return item to home library
|
||||
if ( $recall->in_transit ) {
|
||||
C4::Items::ModItemTransfer(
|
||||
|
|
|
|||
Loading…
Reference in New Issue