[Koha-patches] [PATCH] Fix for Bug 1883, authorised list of reasons why patron requesting book
Owen Leonard
oleonard at myacpl.org
Mon Dec 6 17:49:02 CET 2010
- Adding form controls to opac submission form and staf client
edit form.
- Adding display of patron reason for suggestion on opac list
- Adding function for pulling an authorized value description
using the category and value
TODO: Add some default authorised values
---
C4/Koha.pm | 22 ++++++++++++++++++++
.../prog/en/modules/suggestion/suggestion.tmpl | 3 ++
.../prog/en/modules/opac-suggestions.tmpl | 3 ++
opac/opac-suggestions.pl | 7 +++++-
suggestion/suggestion.pl | 3 ++
5 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/C4/Koha.pm b/C4/Koha.pm
index a63a3a5..d10c52e 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -57,6 +57,7 @@ BEGIN {
&GetAuthorisedValueCategories
&GetKohaAuthorisedValues
&GetKohaAuthorisedValuesFromField
+ &GetKohaAuthorisedValueLib
&GetAuthValCode
&GetNormalizedUPC
&GetNormalizedISBN
@@ -1214,6 +1215,27 @@ sub xml_escape {
return $str;
}
+=head2 GetKohaAuthorisedValueLib
+
+Takes $category, $authorised_value as parameters.
+
+If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
+
+Returns authorised value description
+
+=cut
+
+sub GetKohaAuthorisedValueLib {
+ my ($category,$authorised_value,$opac) = @_;
+ my $value;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("select lib, lib_opac from authorised_values where category=? and authorised_value=?");
+ $sth->execute($category,$authorised_value);
+ my $data = $sth->fetchrow_hashref;
+ $value = ($opac && $$data{'lib_opac'}) ? $$data{'lib_opac'} : $$data{'lib'};
+ return $value;
+}
+
=head2 display_marc_indicators
my $display_form = C4::Koha::display_marc_indicators($field);
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tmpl
index 7489cb6..4cd86ce 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tmpl
@@ -116,6 +116,9 @@ h4.collapse a { font-size : 80%; text-decoration: none; } fieldset.brief ol { di
<!--/TMPL_LOOP-->
</select>
</li>
+ <!-- TMPL_IF NAME="patron_reason_loop" --><li><label for="patronreason">Reason for suggestion: </label><select name="patronreason" id="patronreason"><option value=""> -- Choose -- </option><!-- TMPL_LOOP NAME="patron_reason_loop" -->
+ <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="authorised_value" -->" selected="selected"><!--TMPL_VAR NAME="lib" --></option><!-- TMPL_ELSE --><option value="<!-- TMPL_VAR NAME="authorised_value" -->"><!--TMPL_VAR NAME="lib" --></option><!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP --></select></li><!-- /TMPL_IF -->
<li><label for="note">Notes:</label><textarea name="note" id="note" rows="5" cols="40"><!--TMPL_VAR Name="note"--></textarea></li>
</ol>
</fieldset>
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl
index ab5b753..483551b 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl
@@ -91,6 +91,9 @@ $.tablesorter.addParser({
<!-- TMPL_IF name="selected" --><option value="<!-- TMPL_VAR name="itemtype"-->" selected="selected"> <!--TMPL_ELSE--><option value="<!-- TMPL_VAR name="itemtype" -->"> <!--/TMPL_IF--> <!-- TMPL_VAR name="description" --></option>
<!-- /TMPL_LOOP -->
</select> </li>
+ <!-- TMPL_IF NAME="patron_reason_loop" --><li><label for="patronreason">Reason for suggestion: </label><select name="patronreason" id="patronreason"><option value="">-- Choose --</option><!-- TMPL_LOOP NAME="patron_reason_loop" -->
+ <option value="<!-- TMPL_VAR NAME="authorised_value" -->"><!--TMPL_VAR NAME="lib" --></option>
+ <!-- /TMPL_LOOP --></select></li><!-- /TMPL_IF -->
<li><label for="note">Notes:</label><textarea name="note" id="note" rows="5" cols="40"></textarea></li>
</ol></fieldset>
<fieldset class="action"><input type="hidden" name="suggestedby" value="<!--TMPL_VAR Name="suggestedbyme"-->" /><input type="hidden" name="op" value="add_confirm" /><input type="submit" onclick="Check(this.form); return false;" value="Submit Your Suggestion" /> <a class="action" href="/cgi-bin/koha/opac-suggestions.pl">Cancel</a></fieldset>
diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl
index fc9ce51..75d0791 100755
--- a/opac/opac-suggestions.pl
+++ b/opac/opac-suggestions.pl
@@ -115,17 +115,22 @@ foreach my $suggestion(@$suggestions_loop) {
} else {
$suggestion->{'showcheckbox'} = 0;
}
+ if($suggestion->{'patronreason'}){
+ $suggestion->{'patronreason'} = GetKohaAuthorisedValueLib("OPAC_SUG",$suggestion->{'patronreason'},1);
+ }
}
+my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG");
+
$template->param(
%$suggestion,
itemtypeloop=> $supportlist,
suggestions_loop => $suggestions_loop,
+ patron_reason_loop => $patron_reason_loop,
showall => $allsuggestions,
"op_$op" => 1,
suggestionsview => 1,
);
-
output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl
index 57a1ba7..73f5ff5 100755
--- a/suggestion/suggestion.pl
+++ b/suggestion/suggestion.pl
@@ -259,6 +259,9 @@ foreach my $support(@$supportlist){
}
$template->param(itemtypeloop=>$supportlist);
+my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG",$$suggestion_ref{'patronreason'});
+$template->param(patron_reason_loop=>$patron_reason_loop);
+
#Budgets management
my $searchbudgets={ budget_branchcode=>$branchfilter} if $branchfilter;
my $budgets = GetBudgets($searchbudgets);
--
1.7.1
More information about the Koha-patches
mailing list