- Adds location dropdown to subscription edit form
- Pulls authorised value for display on subscription detail page
- Adds function for pulling authorised value description based
  on category and value

This patch does NOT implement automatic preselection of the shelving
location form field on the serial add item screen. This must be
worked out in order for the bug to be closed.
---
 C4/Koha.pm                                         |   22 ++++++++++++++++++++
 .../prog/en/modules/serials/subscription-add.tmpl  |    5 +++-
 serials/subscription-add.pl                        |    4 +++
 serials/subscription-detail.pl                     |    3 +-
 4 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/C4/Koha.pm b/C4/Koha.pm
index cb93034..47c11b1 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -55,6 +55,7 @@ BEGIN {
                &GetAuthorisedValueCategories
                &GetKohaAuthorisedValues
                &GetKohaAuthorisedValuesFromField
+    &GetKohaAuthorisedValueLib
                &GetAuthValCode
                &GetNormalizedUPC
                &GetNormalizedISBN
@@ -1188,6 +1189,27 @@ sub GetKohaAuthorisedValuesFromField {
   }
 }
 
+=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/serials/subscription-add.tmpl 
b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl
index 5a665de..ae4932e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl
@@ -1007,7 +1007,10 @@ $(document).ready(function() {
         </li>
         <li>
             <label for="location">Location:</label>
-            <input type="text" name="location" id="location" value="<!-- 
TMPL_VAR name="location" -->" size="30" />
+            <select name="location" id="location">
+                <option value="">None</option>
+                <!-- TMPL_LOOP NAME="locations_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>
          <li>
             <label for="callnumber">Call Number:</label>
diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl
index d8c0ea3..0cb0a2b 100755
--- a/serials/subscription-add.pl
+++ b/serials/subscription-add.pl
@@ -128,8 +128,12 @@ for my $thisbranch (sort { $branches->{$a}->{branchname} 
cmp $branches->{$b}->{b
         branchname => $branches->{$thisbranch}->{'branchname'},
     };
 }
+
+my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'});
+
 $template->param(branchloop => $branchloop,
     DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
+    locations_loop=>$locations_loop,
 );
 my $count = 0;
 # prepare template variables common to all $op conditions:
diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl
index b6538fe..c896984 100755
--- a/serials/subscription-detail.pl
+++ b/serials/subscription-detail.pl
@@ -93,7 +93,6 @@ if ($op eq 'del') {
     }
 }
 my $hasRouting = check_routing($subscriptionid);
-my ($totalissues,@serialslist) = GetSerials($subscriptionid);
 $totalissues-- if $totalissues; # the -1 is to have 0 if this is a new 
subscription (only 1 issue)
 # the subscription must be deletable if there is NO issues for a reason or 
another (should not happend, but...)
 
@@ -106,8 +105,8 @@ my ($user, $sessionID, $flags);
 for my $date qw(startdate enddate firstacquidate histstartdate histenddate){
     $$subs{$date}      = format_date($$subs{$date}) if $date && $$subs{$date};
 }
+$subs->{location} = GetKohaAuthorisedValueLib("LOC",$subs->{location});
 $subs->{abouttoexpire}  = abouttoexpire($subs->{subscriptionid});
-
 $template->param($subs);
 $template->param(biblionumber_for_new_subscription => $subs->{bibnum});
 my @irregular_issues = split /,/, $subs->{irregularity};
-- 
1.7.0.4

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches

Reply via email to