Bug 9261 - Allow librarians to make purchase suggestions for patrons
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 11 Dec 2012 14:41:04 +0000 (09:41 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Fri, 15 Nov 2013 00:20:23 +0000 (00:20 +0000)
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 borrower's purchase suggestions
8) Verify the new purchase suggestion was added

Signed-off-by: Corey Fuimaono <agent.075@gmail.com>

Step though the test plan. All OK.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>

koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
members/purchase-suggestions.pl [new file with mode: 0755]
suggestion/suggestion.pl

index 62db1c5..2ad7500 100644 (file)
@@ -83,6 +83,7 @@
     [% IF EnableBorrowerFiles %]
         [% IF ( borrower_files ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/files.pl?borrowernumber=[% borrowernumber %]">Files</a></li>
     [% END %]
+    [% IF (  suggestions ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=[% borrowernumber %]">Purchase suggestions</a></li>
 </ul></div>
 [% 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 (file)
index 0000000..db0ccb2
--- /dev/null
@@ -0,0 +1,107 @@
+[% INCLUDE 'doc-head-open.inc' %]
+<title>Koha &rsaquo; Patrons &rsaquo;
+[% IF ( unknowuser ) %]
+    Patron does not exist
+[% ELSE %]
+    Purchase suggestions for [% INCLUDE 'patron-title.inc' %]
+[% END %]
+</title>
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+[% INCLUDE 'doc-head-close.inc' %]
+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
+[% INCLUDE 'datatables-strings.inc' %]
+<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
+[% INCLUDE 'calendar.inc' %]
+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
+<script type="text/javascript">
+    $(document).ready(function() {
+        $("#suggestions").dataTable($.extend(true, {}, dataTablesDefaults, {
+            'bPaginate': false,
+            'bFilter': false,
+            'bInfo': false,
+        } ));
+
+        new YAHOO.widget.Button("newsuggestion");
+    });
+</script>
+</head>
+
+<body>
+[% INCLUDE 'header.inc' %]
+[% INCLUDE 'patron-search.inc' %]
+
+<div id="breadcrumbs">
+         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
+&rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
+&rsaquo; [% IF ( unknowuser ) %]Patron does not exist[% ELSE %]Purchase suggestions for [% firstname %] [% surname %] ([% cardnumber %])[% END %]
+</div>
+
+<div id="doc3" class="yui-t1">
+
+   <div id="bd">
+    <div id="yui-main">
+        <div class="yui-b">
+            <div class="yui-g">
+                <h2>Purchase suggestions</h2>
+
+                <div id="toolbar">
+                    <ul class="toolbar">
+                        <li><a id="newsuggestion" href="/cgi-bin/koha/suggestion/suggestion.pl?op=add&suggestedby=[% borrowernumber %]&redirect=[% borrowernumber %]">New purchase suggestion</a></li>
+                    </ul>
+                </div>
+
+                <table id="suggestions">
+                    <thead>
+                        <tr>
+                          <th>Summary</th>
+                          <th>Note</th>
+                          <th>Managed by</th>
+                          <th>Status</th>
+                        </tr>
+                    </thead>
+
+                    <tbody>
+                        [% FOREACH s IN suggestions %]
+                            <tr>
+                                <td>
+                                    <p><strong>[% s.title |html %]</strong></p>
+                                    <p>
+                                        [% 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 %]
+                                    </p>
+                                </td>
+                                <td>[% s.note %]
+                                <td>
+                                    [% IF ( s.surnamemanagedby ) %]
+                                        [% s.surnamemanagedby %]
+                                        [% IF ( s.firstnamemanagedby ) %],[% END %]
+                                        [% s.firstnamemanagedby %]
+                                    [% ELSE %]
+                                        &nbsp;
+                                    [% END %]
+                                </td>
+                                <td>
+                                    [% 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 %]
+                                </td>
+                            </tr>
+                        [% END %]
+                    </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+<div class="yui-b">
+[% INCLUDE 'circ-menu.inc' %]
+</div>
+</div>
+[% INCLUDE 'intranet-bottom.inc' %]
index fc2d438..6119ed6 100644 (file)
@@ -296,6 +296,7 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
     <div class="yui-b">
 [% IF ( op_save ) %]
     <form id="add_edit" action="suggestion.pl" method="post">
+    <input type="hidden" name="redirect" id="redirect" value="[% redirect %]" />
     [% IF ( suggestionid ) %]
         <h1>Edit purchase suggestion #[% suggestionid %]</h1>
         <input type="hidden" name="suggestionid" value="[% suggestionid %]"/>
diff --git a/members/purchase-suggestions.pl b/members/purchase-suggestions.pl
new file mode 100755 (executable)
index 0000000..8a55075
--- /dev/null
@@ -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;
index fd9a9c2..c90ffcc 100755 (executable)
@@ -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;