From dcb4010e2bdda7aeb523706f0902a372cfb871a6 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 10 Jun 2019 15:17:35 +0100 Subject: [PATCH] Bug 22569: Proof of concept This patch adds a proof of concept 'Transfers to send' report to the circulation page. --- Koha/Item/Transfer.pm | 14 +++ Koha/Library.pm | 14 +++ circ/transferstosend.pl | 67 +++++++++++ .../prog/en/modules/circ/circulation-home.tt | 3 + .../prog/en/modules/circ/transferstosend.tt | 104 ++++++++++++++++++ 5 files changed, 202 insertions(+) create mode 100755 circ/transferstosend.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstosend.tt diff --git a/Koha/Item/Transfer.pm b/Koha/Item/Transfer.pm index 50c381db39..e30fefa4a3 100644 --- a/Koha/Item/Transfer.pm +++ b/Koha/Item/Transfer.pm @@ -33,6 +33,20 @@ Koha::Item::Transfer - Koha Item Transfer Object class =cut +=head3 item + + my $item = Koha::Library->item; + +Returns the associated item for this transfer. + +=cut + +sub item { + my ( $self ) = @_; + my $rs = $self->_result->itemnumber; + return Koha::Item->_new_from_dbic( $rs ); +} + =head3 type =cut diff --git a/Koha/Library.pm b/Koha/Library.pm index f1a5597305..3b864ad019 100644 --- a/Koha/Library.pm +++ b/Koha/Library.pm @@ -50,6 +50,20 @@ sub stockrotationstages { return Koha::StockRotationStages->_new_from_dbic( $rs ); } +=head3 outgoing_transfers + + my $outgoing_transfers = Koha::Library->outgoing_transfers; + +Returns the outgoing item transfers associated with this Library. + +=cut + +sub outgoing_transfers { + my ( $self ) = @_; + my $rs = $self->_result->branchtransfers_frombranches; + return Koha::Item::Transfers->_new_from_dbic( $rs ); +} + =head3 get_effective_marcorgcode my $marcorgcode = Koha::Libraries->find( $library_id )->get_effective_marcorgcode(); diff --git a/circ/transferstosend.pl b/circ/transferstosend.pl new file mode 100755 index 0000000000..2e5afcfe5c --- /dev/null +++ b/circ/transferstosend.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl + +# Copyright 2000-2002 Katipo Communications +# +# 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::Context; +use C4::Auth; +use C4::Output; + +use Koha::DateUtils; + +my $input = new CGI; +my $itemnumber = $input->param('itemnumber'); + +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "circ/transferstosend.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => "circulate_remaining_permissions" }, + debug => 1, + } +); + +# set the userenv branch +my $branchcode = C4::Context->userenv->{'branch'}; + +# transfers prompted by stockrotation +my @transfers = Koha::Libraries->search( + { + 'branchtransfers_frombranches.frombranch' => $branchcode, + 'branchtransfers_frombranches.datesent' => { '!=' => undef }, + 'branchtransfers_frombranches.datearrived' => undef, + 'branchtransfers_frombranches.comments' => "StockrotationAdvance" + }, + { + prefetch => 'branchtransfers_frombranches', + order_by => 'branchtransfers_frombranches.frombranch' + } +); + +$template->param( + branchesloop => \@transfers, + show_date => output_pref( + { dt => dt_from_string, dateformat => 'iso', dateonly => 1 } + ) +); + +output_html_with_http_headers $input, $cookie, $template->output; + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt index b1bac4ae2b..a5f5420f3c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt @@ -93,6 +93,9 @@ Transfer [% END %] +
  • + Transfers to send +
  • Transfers to receive
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstosend.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstosend.tt new file mode 100644 index 0000000000..c9b4fc5c29 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstosend.tt @@ -0,0 +1,104 @@ +[% USE raw %] +[% USE Asset %] +[% USE Koha %] +[% USE KohaDates %] +[% USE Branches %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Transfers to send +[% INCLUDE 'doc-head-close.inc' %] + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'circ-search.inc' %] + + + +
    +
    +
    +
    +
    + + [% IF Koha.Preference('CircSidebar') %] +
    + [% ELSE %] +
    + [% END %] + +

    Transfers required by your library as of [% show_date | $KohaDates %]

    + [% IF ( branchesloop ) %] +

    Your library is the origin for the following transfer(s)

    +
    + [% FOREACH branchesloo IN branchesloop %] + [% IF ( branchesloo.branchcode ) %] + + + + + + + + + + + [% FOREACH transfer IN branchesloo.outgoing_transfers %] + + + + + + + + + [% END %] +
    Sending to [% branchesloo.branchname | html %]
    Date of requestTitleOn hold forHome libraryCall no. 

    [% transfer.datesent | $KohaDates %]

    + [% INCLUDE 'biblio-default-view.inc' biblionumber = transfer.item.biblionumber %][% transfer.item.biblio.title | html %] [% IF ( transfer.item.biblio.subtitles ) %] [% FOREACH subtitle IN transfer.item.biblio.subtitles %][% subtitle.subfield | html %][% END %][% END %] [% IF ( transfer.item.biblio.author ) %]by [% transfer.item.biblio.author | html %][% END %] + [% IF ( transfer.item.effective_itemtype ) %] ([% transfer.item.effective_itemtype | html %])[% END %] +
    Barcode: [% transfer.item.barcode | html %] +

    None

    [% transfer.item.itemcallnumber | html %] + Mark "In demand" + Cancel transfer +
    + [% END %] + [% END %] +
    + [% ELSE %] +

    No transfers to send

    + [% END %] + + [% IF Koha.Preference('CircSidebar') %] +
    +
    + +
    +
    + [% END %] + +
    +
    +
    + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] + +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] -- 2.20.1