From 06f83afa30f725c6f708c2690fa882e5c6a5129c Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 23 Apr 2020 15:35:33 +0000 Subject: [PATCH] Bug 19532: Recalls on intranet --- catalogue/detail.pl | 6 + circ/circulation.pl | 4 +- circ/transferstoreceive.pl | 7 + .../prog/en/includes/biblio-view-menu.inc | 3 + .../intranet-tmpl/prog/en/includes/circ-menu.inc | 3 + .../intranet-tmpl/prog/en/includes/circ-nav.inc | 8 + .../intranet-tmpl/prog/en/includes/recalls.inc | 123 ++++++++++++++ .../prog/en/modules/catalogue/detail.tt | 13 +- .../prog/en/modules/circ/circulation-home.tt | 12 ++ .../prog/en/modules/circ/circulation.tt | 47 +++++- .../prog/en/modules/circ/transferstoreceive.tt | 2 + .../prog/en/modules/members/moremember.tt | 14 ++ .../prog/en/modules/members/recallshistory.tt | 45 +++++ .../prog/en/modules/recalls/recalls_old_queue.tt | 57 +++++++ .../prog/en/modules/recalls/recalls_overdue.tt | 68 ++++++++ .../prog/en/modules/recalls/recalls_queue.tt | 68 ++++++++ .../prog/en/modules/recalls/recalls_to_pull.tt | 151 +++++++++++++++++ .../prog/en/modules/recalls/recalls_waiting.tt | 183 +++++++++++++++++++++ .../prog/en/modules/recalls/request.tt | 66 ++++++++ .../prog/en/modules/reserve/request.tt | 4 +- koha-tmpl/intranet-tmpl/prog/js/recalls.js | 172 +++++++++++++++++++ members/moremember.pl | 2 + members/recallshistory.pl | 47 ++++++ recalls/recalls_old_queue.pl | 47 ++++++ recalls/recalls_overdue.pl | 61 +++++++ recalls/recalls_queue.pl | 57 +++++++ recalls/recalls_to_pull.pl | 95 +++++++++++ recalls/recalls_waiting.pl | 76 +++++++++ recalls/request.pl | 63 +++++++ reserve/request.pl | 4 + svc/recall | 96 +++++++++++ tools/letter.pl | 2 +- 32 files changed, 1600 insertions(+), 6 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/recallshistory.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_old_queue.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_overdue.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_queue.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_to_pull.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_waiting.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/js/recalls.js create mode 100755 members/recallshistory.pl create mode 100755 recalls/recalls_old_queue.pl create mode 100755 recalls/recalls_overdue.pl create mode 100755 recalls/recalls_queue.pl create mode 100755 recalls/recalls_to_pull.pl create mode 100755 recalls/recalls_waiting.pl create mode 100755 recalls/request.pl create mode 100755 svc/recall diff --git a/catalogue/detail.pl b/catalogue/detail.pl index c968e33dc99..5a564286f3c 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -395,6 +395,12 @@ foreach my $item (@items) { } } + my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber}, old => undef }); + if ( defined $recall ) { + $item->{recalled} = 1; + $item->{recall} = $recall; + } + if ($currentbranch and C4::Context->preference('SeparateHoldings')) { if ($itembranchcode and $itembranchcode eq $currentbranch) { push @itemloop, $item; diff --git a/circ/circulation.pl b/circ/circulation.pl index 81c3bcdf561..3bb04628bd1 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -410,7 +410,7 @@ if (@$barcodes) { } unless($confirm_required) { my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}; - my $issue = AddIssue( $patron->unblessed, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, } ); + my $issue = AddIssue( $patron->unblessed, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $session->param('cancel_recall'), recall_id => $session->param('recall_id'), } ); $template_params->{issue} = $issue; $session->clear('auto_renew'); $inprocess = 1; @@ -456,6 +456,8 @@ if ($patron) { $template->param( holds_count => $holds->count(), WaitingHolds => $waiting_holds, + recalls => $patron->recalls, + specific_patron => 1, ); } diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index b9123f6c017..33055d3812f 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -117,6 +117,13 @@ while ( my $library = $libraries->next ) { if ( my $first_hold = $holds->next ) { $getransf{patron} = Koha::Patrons->find( $first_hold->borrowernumber ); } + + # check for a recall for this transfer + my $recall = $item->recall; + if ( defined $recall ) { + $getransf{recall} = $recall; + } + push( @transferloop, \%getransf ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc index 2080b07707d..599aa5f3601 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc @@ -41,5 +41,8 @@ Checkout history [% IF ( CAN_user_tools_view_system_logs ) %][% IF ( logview ) %]
  • [% ELSE %]
  • [% END %]Modification log
  • [% END %] [% IF ( CAN_user_stockrotation_manage_rota_items && Koha.Preference('StockRotation') ) %][% IF ( stockrotationview ) %]
  • [% ELSE %]
  • [% END %]Rota
  • [% END %] + [% IF ( Koha.Preference('UseRecalls') && CAN_user_recalls ) %] + [% IF ( recallsview ) %]
  • [% ELSE %]
  • [% END %]Recalls ([% Biblio.RecallsCount( biblio_object_id ) %])
  • + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc index d665e811045..8f5d996c936 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -139,6 +139,9 @@ [% IF Koha.Preference('ILLModule') && CAN_user_ill %] [% IF illview %]
  • [% ELSE %]
  • [% END %]ILL requests history
  • [% END %] + [% IF Koha.Preference('UseRecalls') && CAN_user_recalls %] + [% IF recallsview %]
  • [% ELSE %]
  • [% END %]Recalls history
  • + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc index 979871a0b99..535ba7be900 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc @@ -39,6 +39,14 @@ [% IF Koha.Preference('OnSiteCheckouts') %]
  • Pending on-site checkouts
  • [% END %] + + [% IF Koha.Preference('UseRecalls') and CAN_user_recalls %] +
  • Recalls queue
  • +
  • Recalls to pull
  • +
  • Overdue recalls
  • +
  • Recalls awaiting pickup
  • +
  • Old recalls
  • + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc new file mode 100644 index 00000000000..033adb7b64e --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc @@ -0,0 +1,123 @@ +
    +[% IF recalls.count %] + + + + [% IF checkboxes %][% END %] + + [% UNLESS specific_patron %][% END %] + + + + + + [% UNLESS viewing_old %][% END %] + + + + + [% FOREACH recall IN recalls %] + [% IF recall.old %][% ELSE %][% END %] + + [% IF checkboxes %] + + [% END %] + + + + [% UNLESS specific_patron %] + + [% END %] + + + + + + + + + + + + [% UNLESS viewing_old %] + + [% END %] + + + [% END %] + +
     TitleRequested byPlaced onExpires onPickup locationStatusDue date 
    + [% IF recall.old %] +   + [% ELSE %] + + [% END %] + + + [% recall.biblio.title %] + [% FOREACH s IN recall.biblio.subtitle %] + [% s %] + [% END %] + + [% IF recall.item %][% recall.item.barcode %][% END %] + [% recall.biblio.author %] + + [% recall.patron.firstname %] [% recall.patron.surname %] ([% recall.patron.cardnumber %]) + + [% recall.recalldate | $KohaDates %] + + [% IF ( recall.expirationdate ) %] + [% recall.expirationdate | $KohaDates %] + [% ELSIF ( !recall.old ) %] + Never expires + [% ELSE %] + - + [% END %] + + [% recall.library.branchname %] + + [% IF ( recall.in_transit ) %] + In transit to [% recall.library.branchname %] + [% ELSIF ( recall.waiting ) %] + Ready for pickup + [% ELSIF ( recall.expired ) %] + Expired on [% recall.expirationdate | $KohaDates %] + [% ELSIF ( recall.cancelled ) %] + Cancelled on [% recall.cancellationdate | $KohaDates %] + [% ELSIF ( recall.overdue ) %] + Overdue to be returned + [% ELSIF ( recall.finished ) %] + Fulfilled + [% ELSE %] + Requested + [% END %] + + [% IF recall.requested %] + Due to be returned by [% recall.checkout.date_due | $KohaDates %] + [% ELSIF recall.waiting and RECALL.expirationdate %] + Pick up by [% RECALL.expirationdate | $KohaDates %] + [% ELSE %] + - + [% END %] + +
    + Actions + +
    +
    + [% ELSE %] + [% IF patron.borrowernumber %] +
    Patron has no current recalls.
    + [% ELSE %] +
    There are no recalls to show.
    + [% END %] + [% END %] +
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 95af8c679cb..d2e0d1f4d9a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -391,14 +391,22 @@ Note that permanent location is a code, and location may be an authval. There is an item level hold on this item (priority = [% hold.priority | html %]). [% END %] [% END %] - [% UNLESS ( item.itemnotforloan || item.notforloan_per_itemtype || item.onloan || item.itemlost || item.withdrawn || item.damaged || item.transfertwhen || hold ) %] + + [% IF item.recalled %] + [% IF item.recall.waitingdate %] + Waiting at [% Branches.GetName( item.recall.branchcode ) | html %] since [% item.recall.waitingdate | $KohaDates %] + [% ELSE %] + Item recalled by [% item.recall.patron.firstname %] [% item.recall.patron.surname %] ([% item.recall.patron.cardnumber %]) on [% item.recall.recalldate | $KohaDates %] + [% END %] + [% END %] + + [% UNLESS ( item.itemnotforloan || item.notforloan_per_itemtype || item.onloan || item.itemlost || item.withdrawn || item.damaged || item.transfertwhen || hold || item.recalled ) %] Available [% END %] [% IF ( item.restricted ) %] ([% item.restrictedvalue | html %]) [% END %] - [% item.datelastseen | $KohaDates %] [% item.dateaccessioned | $KohaDates %] @@ -895,6 +903,7 @@ Note that permanent location is a code, and location may be an authval. [% MACRO jsinclude BLOCK %] [% INCLUDE 'catalog-strings.inc' %] [% Asset.js("js/catalog.js") | $raw %] + [% Asset.js("js/recalls.js") | $raw %] [% Asset.js("js/coce.js") | $raw %] [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") | $raw %] + [% Asset.js("js/recalls.js") %] [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt index f0c3d4ffdfd..d69a12f4a4a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt @@ -68,6 +68,8 @@ [% reser.patron.first_valid_email_address | html %] [% END %] + [% ELSIF ( reser.recall ) %] + Recall requested by [% reser.recall.patron.surname %][% IF reser.recall.patron.firstname %], [% reser.recall.patron.firstname %][% END %] ([% reser.recall.patron.cardnumber %]) [% ELSE %]

    None

    [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 8321edef92b..6dec0ab41f0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -760,6 +760,14 @@ [% END %] + + [% IF Koha.Preference('UseRecalls') %] +
  • + + [% recalls.count %] Recalls + +
  • + [% END %] [% INCLUDE "checkouts-table.inc" %] @@ -782,6 +790,12 @@ [% END %] + [% IF Koha.Preference('UseRecalls') %] +
    + [% INCLUDE 'recalls.inc' %] +
    + [% END %] + [% INCLUDE borrower_debarments.inc %] [% IF ( CAN_user_circulate_circulate_remaining_permissions ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/recallshistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/recallshistory.tt new file mode 100644 index 00000000000..bfead8994a6 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/recallshistory.tt @@ -0,0 +1,45 @@ +[% USE KohaDates %] +[% USE Koha %] +[% USE Asset %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Recalls history for [% INCLUDE 'patron-title.inc' %] +[% INCLUDE 'doc-head-close.inc' %] +[% Asset.css("css/datatables.css") %] + + + + [% INCLUDE 'header.inc' %] + [% INCLUDE 'patron-search.inc' %] + + +
    +
    +
    +
    + [% INCLUDE 'members-toolbar.inc' %] +

    Recalls history

    + [% IF Koha.Preference('UseRecalls') %] + [% INCLUDE 'recalls.inc' %] + [% ELSE %] +
    Recalls have not been enabled. Enable the UseRecalls system preference to use recalls.
    + [% END %] +
    +
    +
    + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] + [% Asset.js("js/recalls.js") %] +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_old_queue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_old_queue.tt new file mode 100644 index 00000000000..898c6c6ea69 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_old_queue.tt @@ -0,0 +1,57 @@ +[% USE Koha %] +[% USE KohaDates %] +[% USE Asset %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Old recalls +[% INCLUDE 'doc-head-close.inc' %] + +[% Asset.css("css/datatables.css") %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
    +
    + [% IF Koha.Preference('CircSidebar') %] +
    + [% ELSE %] +
    + [% END %] +
    + +

    Old recalls

    + [% IF Koha.Preference('UseRecalls') %] + [% INCLUDE 'recalls.inc' %] + [% ELSE %] +
    Recalls have not been enabled. Enable the UseRecalls system preference to use recalls.
    + [% END %] + +
    +
    + + [% IF Koha.Preference('CircSidebar') %] +
    + +
    + [% END %] + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'columns_settings.inc' %] + [% Asset.js("js/recalls.js") %] +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_overdue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_overdue.tt new file mode 100644 index 00000000000..a391dc5c789 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_overdue.tt @@ -0,0 +1,68 @@ +[% USE Koha %] +[% USE KohaDates %] +[% USE Asset %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Overdue recalls +[% INCLUDE 'doc-head-close.inc' %] + +[% Asset.css("css/datatables.css") %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
    +
    + [% IF Koha.Preference('CircSidebar') %] +
    + [% ELSE %] +
    + [% END %] +
    + +

    Overdue recalls

    + [% IF Koha.Preference('UseRecalls') %] + [% IF recalls.count %] +
    + + Select all + [% INCLUDE 'recalls.inc' %] +
    + +
    +
    + [% ELSE %] +
    There are no recalls to show.
    + [% END %] + [% ELSE %] +
    Recalls have not been enabled. Enable the UseRecalls system preference to use recalls.
    + [% END %] + +
    +
    + + [% IF Koha.Preference('CircSidebar') %] +
    + +
    + [% END %] + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'columns_settings.inc' %] + [% Asset.js("js/recalls.js") %] +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_queue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_queue.tt new file mode 100644 index 00000000000..374a8bb8f4c --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_queue.tt @@ -0,0 +1,68 @@ +[% USE Koha %] +[% USE KohaDates %] +[% USE Asset %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Recalls queue +[% INCLUDE 'doc-head-close.inc' %] + +[% Asset.css("css/datatables.css") %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
    +
    + [% IF Koha.Preference('CircSidebar') %] +
    + [% ELSE %] +
    + [% END %] +
    + +

    Recalls queue

    + [% IF Koha.Preference('UseRecalls') %] + [% IF recalls.count %] +
    + + Select all + [% INCLUDE 'recalls.inc' %] +
    + +
    +
    + [% ELSE %] +
    There are no recalls to show.
    + [% END %] + [% ELSE %] +
    Recalls have not been enabled. Enable the UseRecalls system preference to use recalls.
    + [% END %] + +
    +
    + + [% IF Koha.Preference('CircSidebar') %] +
    + +
    + [% END %] + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'columns_settings.inc' %] + [% Asset.js("js/recalls.js") %] +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_to_pull.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_to_pull.tt new file mode 100644 index 00000000000..05d4c8e5154 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_to_pull.tt @@ -0,0 +1,151 @@ +[% USE Koha %] +[% USE KohaDates %] +[% USE AuthorisedValues %] +[% USE Branches %] +[% USE ItemTypes %] +[% USE Asset %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Recalls to pull +[% INCLUDE 'doc-head-close.inc' %] + +[% Asset.css("css/datatables.css") %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
    +
    + [% IF Koha.Preference('CircSidebar') %] +
    + [% ELSE %] +
    + [% END %] +
    + +

    Recalls to pull

    + [% IF Koha.Preference('UseRecalls') %] +
    + [% IF recalls.count %] + + + + + + + + + + + + + + + + + + + + [% FOREACH recall IN recalls %] + + + + + + + + + + + + + + + + [% END %] + +
    Pull this many itemsItems availablePatrons with recallsFirst patronTitleLibrariesAvailable call numbersAvailable copy numbersAvailable enumerationAvailable item typesAvailable locationsEarlier recall date 
    [% recall.pull_count %][% recall.items_count %][% recall.patrons_count %][% recall.first_patron.firstname %] [% recall.first_patron.surname %] + [% INCLUDE 'biblio-default-view.inc' biblionumber=recall.biblio.biblionumber %] + [% INCLUDE 'biblio-title.inc' biblio=recall.biblio %] + [% IF recall.biblio.author %] by [% recall.biblio.author %][% END %] + +
      + [% FOREACH library IN recall.libraries %] +
    • [% Branches.GetName( library ) %]
    • + [% END %] +
    +
    +
      + [% FOREACH callnumber IN recall.callnumbers %] +
    • [% callnumber %]
    • + [% END %] +
    +
    +
      + [% FOREACH copyno IN recall.copynumbers %] +
    • [% copyno %]
    • + [% END %] +
    +
    +
      + [% FOREACH enumchron IN recall.enumchrons %] +
    • [% enumchron %]
    • + [% END %] +
    +
    +
      + [% FOREACH itemtype IN recall.itemtypes %] +
    • [% ItemTypes.GetDescription( itemtype ) %]
    • + [% END %] +
    +
    +
      + [% FOREACH loc IN recall.locations %] +
    • [% AuthorisedValues.GetByCode('LOC', loc) %]
    • + [% END %] +
    +
    + [% recall.first_date | $KohaDates %] in [% recall.first_library.branchname %] + +
    + + + +
    +
    + [% ELSE %] +
    There are no recalls to pull.
    + [% END %] +
    + [% ELSE %] +
    Recalls have not been enabled. Enable the UseRecalls system preference to use recalls.
    + [% END %] + +
    +
    + + [% IF Koha.Preference('CircSidebar') %] +
    + +
    + [% END %] + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'columns_settings.inc' %] + [% Asset.js("js/recalls.js") %] +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_waiting.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_waiting.tt new file mode 100644 index 00000000000..84e42f37bc6 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_waiting.tt @@ -0,0 +1,183 @@ +[% USE Koha %] +[% USE KohaDates %] +[% USE Asset %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Recalls awaiting pickup +[% INCLUDE 'doc-head-close.inc' %] + +[% Asset.css("css/datatables.css") %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
    +
    + [% IF Koha.Preference('CircSidebar') %] +
    + [% ELSE %] +
    + [% END %] +
    +

    Recalls awaiting pickup

    + + [% IF Koha.Preference('UseRecalls') %] + +
    + + + +
    + [% IF ( recalls.size > 0 ) %] + + + + + + + + + + [% FOREACH recall IN recalls %] + + + + + + [% END %] + +
    Available sinceTitleRequested byPickup location 
    [% recall.waitingdate | $KohaDates %] + + [% recall.biblio.title %] + [% FOREACH s IN recall.biblio.subtitles %] + [% s %] + [% END %] + + [% recall.biblio.author %] +
    Barcode: [% recall.item.barcode %] +
    + [% recall.patron.firstname %] [% recall.patron.surname %] + [% IF ( recall.patron.phone ) %]
    [% recall.patron.phone %][% END %] + [% IF ( recall.patron.email ) %]
    [% recall.patron.email %][% END %] +
    [% recall.library.branchname %] +
    + + +
    + + +
    +
    +
    + [% ELSE %] +
    There are no recalls to show.
    + [% END %] +
    + +
    + [% IF ( over.size ) %] + [% IF ( Koha.Preference('RecallsMaxPickUpDelay') ) %]

    Recalls listed here have been awaiting pickup for more than [% Koha.Preference('RecallsMaxPickUpDelay') %] days.

    [% END %] + + + + + + + + + + [% FOREACH recall IN over %] + + + + + + [% END %] + +
    Available sinceTitleRequested byPickup location 
    [% recall.waitingdate | $KohaDates %] + + [% recall.biblio.title %] + [% FOREACH s IN recall.biblio.subtitles %] + [% s %] + [% END %] + [% recall.item.enumchron %] + + [% recall.biblio.author %] +
    Barcode: [% recall.item.barcode %] +
    + [% recall.patron.firstname %] [% recall.patron.surname %] + [% IF ( recall.patron.phone ) %]
    [% recall.patron.phone %][% END %] + [% IF ( recall.patron.email ) %]
    [% recall.patron.email %][% END %] +
    [% recall.library.branchname %] +
    + + +
    + + +
    +
    +
    + [% ELSE %] +
    There are no recalls to show.
    + [% END %] +
    + +
    + + [% ELSE %] +
    Recalls have not been enabled. Enable the UseRecalls system preference to use recalls.
    + [% END %] + +
    +
    + + [% IF Koha.Preference('CircSidebar') %] +
    + +
    + [% END %] + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] + +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt new file mode 100644 index 00000000000..03f51d286bb --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt @@ -0,0 +1,66 @@ +[% USE Asset %] +[% USE Koha %] +[% USE KohaDates %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Recalls › Confirm recalls +[% INCLUDE 'doc-head-close.inc' %] +[% Asset.css("css/datatables.css") %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'circ-search.inc' %] + + + +
    +
    +
    +
    + +

    Existing recalls

    + + [% IF Koha.Preference('UseRecalls') %] + [% IF recalls.count %] +
    + + Select all + [% INCLUDE 'recalls.inc' %] +
    + +
    +
    + [% ELSE %] +
    No recalls have been made.
    + [% END %] + [% ELSE %] +
    Recalls have not been enabled. Enable the UseRecalls system preference to use recalls.
    + [% END %] + +
    +
    + +
    + +
    + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% Asset.js("js/recalls.js") %] + [% INCLUDE 'datatables.inc' %] + +[% END %] +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index acb9bd91399..2acfbc16bea 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -296,7 +296,7 @@
    [% END %] - [% IF ( exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted ) %] + [% IF ( exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted || recall ) %]
    [% UNLESS ( multi_hold ) %] @@ -316,6 +316,8 @@
  • No items are available to be placed on hold.
  • [% ELSIF ( maxreserves ) %]
  • Too many holds: [% patron.firstname | html %] [% patron.surname | html %] has too many holds.
  • + [% ELSIF ( recall ) %] +
  • [% patron.firstname | html %] [% patron.surname | html %] has already placed a recall on this item.
  • [% END # /IF exceeded_maxreserves %] [% ELSE # UNLESS multi_hold %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/recalls.js b/koha-tmpl/intranet-tmpl/prog/js/recalls.js new file mode 100644 index 00000000000..98608040e04 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/recalls.js @@ -0,0 +1,172 @@ +$(document).ready(function() { + + $(".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, + }; + var $howmanyparents = $(this).data('parent'); + + $.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"); + } + if ( $howmanyparents == "one" ){ + $self.parent().html(message); + } else { + $self.parent().parent().parent().parent().html(message); + } + }); + } + }); + + $(".checkin_recall").click(function(e){ + if (confirmDelete(_("Are you sure you want to check in this item and confirm the recall as 'waiting'?"))){ + 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 checked in. Please refresh the page."); + } else { + message = _("Completed"); + } + $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, + }; + + var $howmanyparents = $(this).data('parent'); + + $.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"); + } + if ( $howmanyparents == "one" ){ + $self.parent().html(message); + } else { + $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, + }; + + var $howmanyparents = $(this).data('parent'); + + $.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 = _("Status updated"); + } + if ( $howmanyparents == "one" ){ + $self.parent().html(message); + } else { + $self.parent().parent().parent().parent().html(message); + } + }); + } + }); + + $("#recalls-table").dataTable($.extend(true, {}, dataTablesDefaults, { + "aoColumnDefs": [ + { 'bSortable': false, 'aTargets': [ 'nosort' ] }, + { "sType": "title-string", "aTargets" : [ "title-string" ] }, + { "sType": "anti-the", "aTargets": [ "anti-the" ] } + ], + "sPaginationType": "full_numbers" + })); + + $("#cancel_selected").click(function(e){ + if ($("input[name='recall_ids']:checked").length > 0){ + return confirmDelete(_("Are you sure you want to remove the selected recall(s)?")); + } else { + alert(_("Please make a selection.")); + } + }); + + $("#expire_selected").click(function(e){ + if ($("input[name='recall_ids']:checked").length > 0){ + return confirmDelete(_("Are you sure you want to expire the selected recall(s)?")); + } else { + alert(_("Please make a selection.")); + } + }); + + $("#select_all").click(function(){ + if ($("#select_all").prop("checked")){ + $("input[name='recall_ids']").prop("checked", true); + } else { + $("input[name='recall_ids']").prop("checked", false); + } + }); + + $("#hide_old").click(function(){ + if ($("#hide_old").prop("checked")){ + $(".old").show(); + } else { + $(".old").hide(); + } + }); +}); diff --git a/members/moremember.pl b/members/moremember.pl index 656ee35a939..9e8ad05d7e0 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -210,6 +210,8 @@ $template->param( relatives_issues_count => $relatives_issues_count, relatives_borrowernumbers => \@relatives, logged_in_user => $logged_in_user, + recalls => $patron->recalls, + specific_patron => 1, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/members/recallshistory.pl b/members/recallshistory.pl new file mode 100755 index 00000000000..b4d83680d73 --- /dev/null +++ b/members/recallshistory.pl @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. + +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth; +use C4::Output; + +my $input = CGI->new; +my ($template, $loggedinuser, $cookie)= get_template_and_user( + { + template_name => "members/recallshistory.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => 1 }, + debug => 1, + } +); + +my $borrowernumber = $input->param('borrowernumber'); +my $recalls = Koha::Recalls->search({ borrowernumber => $borrowernumber }); +my $patron = Koha::Patrons->find( $borrowernumber ); + +$template->param( + patron => $patron, + recalls => $recalls, + recallsview => 1, + specific_patron => 1, +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/recalls/recalls_old_queue.pl b/recalls/recalls_old_queue.pl new file mode 100755 index 00000000000..161dcd41a1b --- /dev/null +++ b/recalls/recalls_old_queue.pl @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth; +use C4::Output; +use Koha::BiblioFrameworks; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "recalls/recalls_old_queue.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => "manage_recalls" }, + debug => 1, + } +); + +my $recalls = Koha::Recalls->search({ old => 1 }); +$template->param( + recalls => $recalls, + viewing_old => 1 +); + +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + +# writing the template +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/recalls/recalls_overdue.pl b/recalls/recalls_overdue.pl new file mode 100755 index 00000000000..91c1e6973db --- /dev/null +++ b/recalls/recalls_overdue.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth; +use C4::Output; +use Koha::BiblioFrameworks; +use Koha::DateUtils; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "recalls/recalls_overdue.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => "manage_recalls" }, + debug => 1, + } +); + +my $op = $query->param('op') || 'list'; +my @recall_ids = $query->multi_param('recall_ids'); + +if ( $op eq 'cancel_multiple_recalls' ) { + foreach my $id ( @recall_ids ) { + Koha::Recalls->find( $id )->set_cancelled; + } + $op = 'list' +} + +if ( $op eq 'list' ) { + my $recalls = Koha::Recalls->search({ status => 'O' }); + # will be set as Overdue by the misc/cronjobs/recall/overdue_recalls.pl cronjob + $template->param( + recalls => $recalls, + checkboxes => 1, + ); +} + +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + +# writing the template +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/recalls/recalls_queue.pl b/recalls/recalls_queue.pl new file mode 100755 index 00000000000..0d820592a0f --- /dev/null +++ b/recalls/recalls_queue.pl @@ -0,0 +1,57 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth; +use C4::Output; +use Koha::BiblioFrameworks; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "recalls/recalls_queue.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => 'manage_recalls' }, + debug => 1, + } +); + +my $op = $query->param('op') || 'list'; +my @recall_ids = $query->multi_param('recall_ids'); +if ( $op eq 'cancel_multiple_recalls' ) { + foreach my $id ( @recall_ids ) { + Koha::Recalls->find( $id )->set_cancelled; + } + $op = 'list' +} +elsif ( $op eq 'list' ) { + my $recalls = Koha::Recalls->search({ old => undef }); + $template->param( + recalls => $recalls, + checkboxes => 1, + ); +} + +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + +# writing the template +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/recalls/recalls_to_pull.pl b/recalls/recalls_to_pull.pl new file mode 100755 index 00000000000..9e31ff9fa35 --- /dev/null +++ b/recalls/recalls_to_pull.pl @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth; +use C4::Output; +use Koha::BiblioFrameworks; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "recalls/recalls_to_pull.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => 'manage_recalls' }, + debug => 1, + } +); + +my $op = $query->param('op') || 'list'; +my $recall_id = $query->param('recall_id'); +if ( $op eq 'cancel' ) { + Koha::Recalls->find( $recall_id )->set_cancelled; + $op = 'list'; +} +elsif ( $op eq 'list' ) { + my @recalls = Koha::Recalls->search({ status => [ 'R','O' ] }); + my @pull_list; + foreach my $recall ( @recalls ) { + my @items = Koha::Items->search({ biblionumber => $recall->biblionumber }); + my $distinct_recalls = Koha::Recalls->search({ biblionumber => $recall->biblionumber, status => [ 'R','O' ] }, { columns => [ 'borrowernumber' ], distinct => 1, order_by => { -asc => 'recalldate' } }); + my $recalls_count = $distinct_recalls->count; + my $first_recall = $distinct_recalls->next; + my $items_count; + my @callnumbers; + my @copynumbers; + my @enumchrons; + my @itemtypes; + my @locations; + my @libraries; + foreach my $item ( @items ) { + if ( $item->can_be_waiting_recall ) { + $items_count++; + push( @callnumbers, $item->itemcallnumber ); + push( @copynumbers, $item->copynumber ); + push( @enumchrons, $item->enumchron ); + push( @itemtypes, $item->effective_itemtype ); + push( @locations, $item->location ); + push( @libraries, $item->holdingbranch ); + } + } + push( @pull_list, { + recall => $recall, + biblio => $recall->biblio, + items_count => $items_count, + recalls_count => $recalls_count, + pull_count => $items_count <= $recalls_count ? $items_count : $recalls_count, + first_patron => $first_recall->patron, + first_date => $first_recall->recalldate, + first_library => $first_recall->library, + callnumbers => @callnumbers, + copynumbers => @copynumbers, + enumchrons => @enumchrons, + itemtypes => @itemtypes, + locations => @locations, + libraries => @libraries, + }); + } + $template->param( + recalls => \@pull_list, + ); +} + +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + +# writing the template +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/recalls/recalls_waiting.pl b/recalls/recalls_waiting.pl new file mode 100755 index 00000000000..97cbf27252a --- /dev/null +++ b/recalls/recalls_waiting.pl @@ -0,0 +1,76 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth; +use C4::Output; +use Koha::Recalls; +use Koha::BiblioFrameworks; +use Koha::DateUtils; +use Koha::Patrons; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "recalls/recalls_waiting.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => "manage_recalls" }, + debug => 1, + } +); + +my $op = $query->param('op') || 'list'; + +if ( $op eq 'modify' ) { + my $expire = $query->param('expire'); + my $revert = $query->param('revert'); + my $recall_id = $query->param('recall_id'); + if ( $expire ) { + Koha::Recalls->find( $recall_id )->set_expired({ interface => 'INTRANET' }); + } elsif ( $revert ) { + Koha::Recalls->find( $recall_id )->revert_waiting; + } + $op = 'list'; +} + +elsif ( $op eq 'list' ) { + my @recalls = Koha::Recalls->search({ status => 'W' }); + my $borrower = Koha::Patrons->find( $loggedinuser ); + my @over; + my $maxdelay = C4::Context->preference('RecallsMaxPickUpDelay') || 7; + my $today = dt_from_string(); + foreach my $r ( @recalls ){ + my $lastwaitingday = dt_from_string( $r->waitingdate )->add( days => $maxdelay ); + if ( $today > $lastwaitingday ){ + push @over, $r; + } + } + $template->param( + recalls => \@recalls, + over => \@over, + ); +} + +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + +# writing the template +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/recalls/request.pl b/recalls/request.pl new file mode 100755 index 00000000000..b907522b4dd --- /dev/null +++ b/recalls/request.pl @@ -0,0 +1,63 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth; +use C4::Output; +use C4::Search; +use Koha::Recalls; +use Koha::Biblios; + +my $input = CGI->new; +my ($template, $loggedinuser, $cookie)= get_template_and_user( + { + template_name => "recalls/request.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => "manage_recalls" }, + debug => 1, + } +); + +my $op = $input->param('op') || 'list'; +my @recall_ids = $input->multi_param('recall_ids'); +my $biblionumber = $input->param('biblionumber'); +my $recalls = Koha::Recalls->search({ biblionumber => $biblionumber, old => undef }); +my $biblio = Koha::Biblios->find( $biblionumber ); + +if ( $op eq 'cancel_multiple_recalls' ) { + foreach my $id ( @recall_ids ) { + Koha::Recalls->find( $id )->set_cancelled; + } + $op = 'list' +} else { + $recalls = Koha::Recalls->search({ biblionumber => $biblionumber, old => undef }); + $biblio = Koha::Biblios->find( $biblionumber ); +} + +$template->param( + recalls => $recalls, + recallsview => 1, + biblio => $biblio, + checkboxes => 1, + C4::Search::enabled_staff_search_views, +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/reserve/request.pl b/reserve/request.pl index 61f853d0857..6377ef0b69a 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -314,6 +314,10 @@ foreach my $biblionumber (@biblionumbers) { $template->param( $canReserve->{status} => 1 ); $biblioloopiter{ $canReserve->{status} } = 1; } + elsif ( $canReserve->{status} eq 'recall' ) { + $template->param( $canReserve->status} } = 1 ); + $biblioloopiter{ $canReserve->{status} } = 1; + } else { $biblioloopiter{ $canReserve->{status} } = 1; } diff --git a/svc/recall b/svc/recall new file mode 100755 index 00000000000..4d85f68691a --- /dev/null +++ b/svc/recall @@ -0,0 +1,96 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use CGI; +use JSON qw(encode_json); + +use C4::Context; +use C4::Auth qw(check_cookie_auth); +use C4::Output qw(output_with_http_headers); +use C4::Circulation qw(AddReturn); +use Koha::Recalls; + +my $input = new CGI; + +my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { recall => 'manage_recalls' } ); + +if ( $auth_status ne "ok" ) { + print $input->header(-type => 'text/plain', -status => '403 Forbidden'); + exit 0; +} + +my $recall_id = $input->param('recall_id'); +my $recall = Koha::Recalls->find( $recall_id ); +unless ( $recall ) { + my $json = encode_json({ success => 0 }); + output_with_http_headers( $input, undef, $json, "json" ); + exit; +} + +my $op = $input->param('action'); + +if ( $op eq 'cancel' ) { + # cancel recall + $recall->set_cancelled; +} elsif ( $op eq 'checkin' ) { + # check in recall and set to waiting + my $branch = $input->param('branchcode'); + my $item; + if ( $recall->item_level_recall ) { + $item = $recall->item; + } elsif ( $recall->checkout ) { + # biblio-level recall with a relevant item that is still checked out to another borrower + $item = $recall->checkout->item; + } else { + # biblio-level recall with no items checked out, so take the first available and recallable item + my @items = Koha::Items->search({ biblionumber => $recall->biblionumber }); + foreach ( @items ) { + if ( $_->can_be_waiting_recall ){ + $item = $_; + last; + } + } + } + + my $barcode = $item->barcode; + + my ( $result, $messages ) = AddReturn( $barcode, $branch ); + + foreach my $code ( %$messages ) { + if ( $code eq 'RecallFound' ) { + my $expirationdate = $recall->calc_expirationdate; + if ( $recall->item_level_recall ) { + $recall->set_waiting({ expirationdate => $expirationdate }); + } else { + $recall->set_waiting({ expirationdate => $expirationdate, item => $item }); + } + } + } +} elsif ( $op eq 'expire' ) { + # expire recall + $recall->set_expired({ interface => 'INTRANET' }); +} elsif ( $op eq 'revert' ) { + # revert recall waiting status + $recall->revert_waiting; +} + +my $json = encode_json({ success => 1 }); +output_with_http_headers( $input, undef, $json, "json" ); diff --git a/tools/letter.pl b/tools/letter.pl index 6044243c090..e95746e1e21 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -248,7 +248,7 @@ sub add_form { {value => 'items.fine', text => 'items.fine'}, add_fields('borrowers'); if ($module eq 'circulation') { - push @{$field_selection}, add_fields('opac_news'); + push @{$field_selection}, add_fields('opac_news', 'recalls'); } -- 2.11.0