From 4ce367b33d8a4bbc6edef0a62b1437fd6b33d186 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 11 Dec 2012 09:41:04 -0500 Subject: [PATCH] Bug 9261 - Allow librarians to make purchase suggestions for patrons This patch adds a new tab to the patron side menu for purchase suggestions. From this new tab, a librarian can view the patron's existing purchase suggestios and also create new suggestions in the name of that patron. Test Plan: 1) Apply patch 2) Ensure the system preference 'suggestions' is enabled 3) View the details for a patron 4) Click the new 'Purchase suggestions' tab 5) Click the 'New purchase suggestion' button 6) Add the new purchase suggestions 7) You should now end up back at the borrowers purchase suggetions 8) Verify the new purchase suggestion was added Signed-off-by: Corey Fuimaono Step though the test plan. All OK. Signed-off-by: Jonathan Druart --- .../intranet-tmpl/prog/en/includes/circ-menu.inc | 1 + .../en/modules/members/purchase-suggestions.tt | 107 ++++++++++++++++++++ .../prog/en/modules/suggestion/suggestion.tt | 1 + members/purchase-suggestions.pl | 58 +++++++++++ suggestion/suggestion.pl | 14 ++- 5 files changed, 178 insertions(+), 3 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt create mode 100755 members/purchase-suggestions.pl 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 62db1c5..2ad7500 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -83,6 +83,7 @@ [% IF EnableBorrowerFiles %] [% IF ( borrower_files ) %]
  • [% ELSE %]
  • [% END %]Files
  • [% END %] + [% IF ( suggestions ) %]
  • [% ELSE %]
  • [% END %]Purchase suggestions
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt new file mode 100644 index 0000000..db0ccb2 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt @@ -0,0 +1,107 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Patrons › +[% IF ( unknowuser ) %] + Patron does not exist +[% ELSE %] + Purchase suggestions for [% INCLUDE 'patron-title.inc' %] +[% END %] + + +[% INCLUDE 'doc-head-close.inc' %] + +[% INCLUDE 'datatables-strings.inc' %] + +[% INCLUDE 'calendar.inc' %] + + + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'patron-search.inc' %] + + + +
    + +
    +
    +
    +
    +

    Purchase suggestions

    + + + + + + + + + + + + + + + [% FOREACH s IN suggestions %] + + + + + + [% END %] + +
    SummaryNoteManaged byStatus
    +

    [% s.title |html %]

    +

    + [% IF ( s.author ) %][% s.author %],[% END %] + [% IF ( s.copyrightdate ) %] - [% s.copyrightdate %],[% END %] + [% IF ( s.publishercode ) %] - [% s.publishercode %][% END %] + [% IF ( s.place ) %]([% s.place %])[% END %] + [% IF ( s.collectiontitle ) %] , [% s.collectiontitle %][% END %] + [% IF ( s.itemtype ) %] - [% s.itemtype %][% END %] +

    +
    [% s.note %] + + [% IF ( s.surnamemanagedby ) %] + [% s.surnamemanagedby %] + [% IF ( s.firstnamemanagedby ) %],[% END %] + [% s.firstnamemanagedby %] + [% ELSE %] +   + [% END %] + + [% IF ( s.ASKED ) %]Requested[% END %] + [% IF ( s.CHECKED ) %]Checked by the library[% END %] + [% IF ( s.ACCEPTED ) %]Accepted by the library[% END %] + [% IF ( s.ORDERED ) %]Ordered by the library[% END %] + [% IF ( s.REJECTED ) %]Suggestion declined [% END %] + [% IF ( s.AVAILABLE ) %]Available in the library[% END %] + [% IF ( s.reason ) %]([% s.reason %])[% END %] +
    +
    +
    +
    +
    +[% INCLUDE 'circ-menu.inc' %] +
    +
    +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index fc2d438..6119ed6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -296,6 +296,7 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
    [% IF ( op_save ) %]
    + [% IF ( suggestionid ) %]

    Edit purchase suggestion #[% suggestionid %]

    diff --git a/members/purchase-suggestions.pl b/members/purchase-suggestions.pl new file mode 100755 index 0000000..8a55075 --- /dev/null +++ b/members/purchase-suggestions.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl + +# Copyright 2012 ByWater Solutions +# +# 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 2 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., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use Modern::Perl; + +use CGI; +use C4::Auth; +use C4::Context; +use C4::Output; +use C4::Branch; +use C4::Members; +use C4::Suggestions; + +my $input = new CGI; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "members/purchase-suggestions.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { borrowers => 1 }, + debug => 1, + } +); + +my $borrowernumber = $input->param('borrowernumber'); + +# Set informations for the patron +my $borrower = GetMemberDetails( $borrowernumber, 0 ); +foreach my $key ( keys %$borrower ) { + $template->param( $key => $borrower->{$key} ); +} +$template->param( + categoryname => $borrower->{'description'}, + branchname => GetBranchName( $borrower->{'branchcode'} ), +); + +my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } ); + +$template->param( suggestions => $suggestions ); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index fd9a9c2..c90ffcc 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -77,6 +77,7 @@ sub GetCriteriumDesc{ } my $input = CGI->new; +my $redirect = $input->param('redirect'); my $suggestedbyme = (defined $input->param('suggestedbyme')? $input->param('suggestedbyme'):1); my $op = $input->param('op')||'else'; my @editsuggestions = $input->param('edit_field'); @@ -132,6 +133,11 @@ if ( $op =~ /save/i ) { } map{delete $$suggestion_ref{$_}} keys %$suggestion_ref; $op = 'else'; + + if( $redirect ) { + print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$redirect"); + } + } elsif ($op=~/add/) { #Adds suggestion @@ -362,10 +368,8 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { $line{selected} = 1 if ($line{'currcode'} eq $selected_currency); push @loop_currency, \%line; } - -$template->param(loop_currency => \@loop_currency); - $template->param( + loop_currency => \@loop_currency, price => sprintf("%.2f", $$suggestion_ref{'price'}||0), total => sprintf("%.2f", $$suggestion_ref{'total'}||0), ); @@ -386,7 +390,11 @@ foreach my $field ( qw(managedby acceptedby suggestedby budgetid) ) { $hashlists{ lc($field) . "_loop" } = \@codes_list; } $template->param(%hashlists); + $template->param( + %hashlists, + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), + borrowernumber => $input->param('borrowernumber'), SuggestionStatuses => GetAuthorisedValues('SUGGEST_STATUS'), ); output_html_with_http_headers $input, $cookie, $template->output; -- 1.7.10.4