From 59e7d3d1f191b7b05120272da3723a66666de5da Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Wed, 14 Dec 2016 10:52:12 +0000 Subject: [PATCH] Bug 11897: Interface for rota items from biblio * catalogue/stockrotation.pl: New file * koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/stockrotation.tt: New file Signed-off-by: Kathleen Milne --- catalogue/stockrotation.pl | 169 +++++++++++++++++++++ .../prog/en/modules/catalogue/stockrotation.tt | 157 +++++++++++++++++++ 2 files changed, 326 insertions(+) create mode 100755 catalogue/stockrotation.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/stockrotation.tt diff --git a/catalogue/stockrotation.pl b/catalogue/stockrotation.pl new file mode 100755 index 0000000000..d12b17c62a --- /dev/null +++ b/catalogue/stockrotation.pl @@ -0,0 +1,169 @@ +#!/usr/bin/perl + +# Copyright 2016 PTFS-Europe Ltd +# +# 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. + +=head1 stockrotation.pl + + Script to manage item assignments to stock rotation rotas. Including their + assiciated stages + +=cut + +use Modern::Perl; +use CGI; + +use C4::Auth; +use C4::Output; +use C4::Search; + +use Koha::Biblio; +use Koha::Item; +use Koha::Stockrotationrotas; +use Koha::Stockrotationstages; +use Koha::Util::Stockrotation qw(:ALL); + +my $input = new CGI; + +my %params = $input->Vars(); + +my $op = $params{op}; + +my $biblionumber = $input->param('biblionumber'); + +my ($template, $loggedinuser, $cookie) = get_template_and_user( + { + template_name => 'catalogue/stockrotation.tt', + query => $input, + type => 'intranet', + authnotrequired => 0, + flagsrequired => { catalogue => 1 } + } +); + +if (!defined $op) { + + # List all items along with their associated rotas + my $biblio = Koha::Biblios->find($biblionumber); + + my $items = $biblio->items; + + # Get only rotas with stages + my $rotas = Koha::Stockrotationrotas->search( + { + 'stockrotationstages.stage_id' => { '!=', undef } + }, + { + join => 'stockrotationstages', + collapse => 1 + } + ); + + # Construct a model to pass to the view + my @item_data = (); + + while (my $item = $items->next) { + + my $item_hashref = { + bib_item => $item + }; + + my $stockrotationitem = $item->stockrotationitem; + + # If this item is on a rota + if ($stockrotationitem != 0) { + + # This item's rota + my $rota = $stockrotationitem->stage->rota; + + # This rota's stages + my $stages = get_stages($rota); + + $item_hashref->{rota} = $rota; + + $item_hashref->{stockrotationitem} = $stockrotationitem; + + $item_hashref->{stages} = $stages; + + } + + push @item_data, $item_hashref; + + } + + $template->param( + no_op_set => 1, + rotas => $rotas, + items => \@item_data, + branches => get_branches(), + biblio => $biblio, + biblionumber => $biblio->biblionumber, + stockrotationview => 1, + C4::Search::enabled_staff_search_views + ); + +} elsif ($op eq "toggle_in_demand") { + + # Toggle in demand + toggle_indemand($params{item_id}, $params{stage_id}); + + # Return to items list + print $input->redirect("?biblionumber=$biblionumber"); + +} elsif ($op eq "remove_item_from_stage") { + + # Remove from the stage + remove_from_stage($params{item_id}, $params{stage_id}); + + # Return to items list + print $input->redirect("?biblionumber=$biblionumber"); + +} elsif ($op eq "move_to_next_stage") { + + move_to_next_stage($params{item_id}, $params{stage_id}); + + # Return to items list + print $input->redirect("?biblionumber=" . $params{biblionumber}); + +} elsif ($op eq "add_item_to_rota") { + + my $item = Koha::Items->find($params{item_id}); + + $item->add_to_rota($params{rota_id}); + + print $input->redirect("?biblionumber=" . $params{biblionumber}); + +} elsif ($op eq "confirm_remove_from_rota") { + + $template->param( + op => $params{op}, + stage_id => $params{stage_id}, + item_id => $params{item_id}, + biblionumber => $params{biblionumber}, + stockrotationview => 1, + C4::Search::enabled_staff_search_views + ); + +} + +output_html_with_http_headers $input, $cookie, $template->output; + +=head1 AUTHOR + +Andrew Isherwood + +=cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/stockrotation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/stockrotation.tt new file mode 100644 index 0000000000..e4ead12837 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/stockrotation.tt @@ -0,0 +1,157 @@ +[% USE Koha %] +[% USE Branches %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Catalog › Stock rotation details for [% biblio.title %] +[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'browser-strings.inc' %] + + + + + +[% USE KohaDates %] +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
+ +
+
+
+ +
+ + [% IF no_op_set %] +

Stock rotation details for [% biblio.title | html %]

+ [% IF rotas.count > 0 && items.size > 0 %] + + + + + + + + + + + + + + + [% FOREACH item IN items %] + + + + + + + + + + [% END %] + + + [% END %] + [% IF !items || items.size == 0 %] +

No physical items for this record

+ [% END %] + [% IF !rotas || rotas.count == 0 %] +

There are no rotas with stages assigned

+ [% END %] + [% ELSIF op == 'confirm_remove_from_rota' %] +
+

Are you sure you want to remove this item from it's rota?

+

+ Yes + No +

+
+ [% END %] + +
+ +
+
+
+[% INCLUDE 'biblio-view-menu.inc' %] +
+
+[% INCLUDE 'intranet-bottom.inc' %] -- 2.13.4