Bugzilla – Attachment 16255 Details for
Bug 9836
Filtering sort1 list according to patron category in patron data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9836 Filtering sort1 list according to patron category in patron data
0001-Bug-9836-Filtering-sort1-list-according-to-patron-ca.patch (text/plain), 13.91 KB, created by
Koha Team University Lyon 3
on 2013-03-18 14:55:33 UTC
(
hide
)
Description:
Bug 9836 Filtering sort1 list according to patron category in patron data
Filename:
MIME Type:
Creator:
Koha Team University Lyon 3
Created:
2013-03-18 14:55:33 UTC
Size:
13.91 KB
patch
obsolete
>From ec3d03a6deef776e648ab6ad5d7ed27bc63d27e3 Mon Sep 17 00:00:00 2001 >From: Lyon3 Team <koha@univ-lyon3.fr> >Date: Mon, 18 Mar 2013 13:25:03 +0100 >Subject: [PATCH] Bug 9836 Filtering sort1 list according to patron category in patron data > >Sort1 criterias are often used as subcategories of patron ones >This patch adds the possibility to link a sort1 criteria to a patron category in the Bsort1 authorised_values settings. >Then in the patron edition Library management block, the sort1 list is filtered according to the selected patron category >and displays only the criterias linked with it. >--- > admin/authorised_values.pl | 45 ++++++++++++++++--- > installer/data/mysql/updatedatabase.pl | 7 +++ > .../prog/en/modules/admin/authorised_values.tt | 38 ++++++++++++++++ > .../prog/en/modules/members/memberentrygen.tt | 34 ++++++++++++++- > members/memberentry.pl | 8 ++-- > 5 files changed, 119 insertions(+), 13 deletions(-) > >diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl >index c00bb64..387f1ff 100755 >--- a/admin/authorised_values.pl >+++ b/admin/authorised_values.pl >@@ -27,14 +27,14 @@ use C4::Context; > use C4::Koha; > use C4::Output; > >- > sub AuthorizedValuesForCategory { > my ($searchstring) = shift or return; > my $dbh = C4::Context->dbh; > $searchstring=~ s/\'/\\\'/g; > my @data=split(' ',$searchstring); > my $sth=$dbh->prepare(' >- SELECT id, category, authorised_value, lib, lib_opac, imageurl >+ #SELECT id, category, authorised_value, lib, lib_opac, imageurl >+ SELECT * > FROM authorised_values > WHERE (category = ?) > ORDER BY category, authorised_value >@@ -114,7 +114,34 @@ if ($op eq 'add_form') { > offset => $offset, > branches_loop => \@branches_loop, > ); >- >+##################################### >+# Add borrower's categories select list, in case we'd like to bind a sort1 criteria to a category >+my @typeloop; >+my $no_categories = 1; >+foreach (qw(C A S P I X)) { >+ my $action="WHERE category_type=?"; >+ my ($categories,$labels) = C4::Members::GetborCatFromCatType($_,$action); >+ if(scalar(@$categories) > 0){ $no_categories = 0; } >+ my @categoryloop; >+ foreach my $cat (@$categories){ >+ push @categoryloop,{ >+ 'categorycode' => $cat, >+ 'categoryname' => $labels->{$cat}, >+ }; >+ } >+ my %typehash; >+ $typehash{'typename'}=$_; >+ my $typedescription = "typename_".$typehash{'typename'}; >+ $typehash{'categoryloop'}=\@categoryloop; >+ push @typeloop,{ >+ 'typename' => $_, >+ $typedescription => 1, >+ 'categoryloop' => \@categoryloop >+ }; >+} >+$template->param('typeloop' => \@typeloop, >+ no_categories => $no_categories); >+ > ################## ADD_VALIDATE ################################## > # called by add_form, used to insert/modify data in DB > } elsif ($op eq 'add_validate') { >@@ -141,13 +168,15 @@ if ($op eq 'add_form') { > authorised_value = ?, > lib = ?, > lib_opac = ?, >+ linked_with = ?, > imageurl = ? > WHERE id=?' ); > my $lib = $input->param('lib'); > my $lib_opac = $input->param('lib_opac'); > undef $lib if ($lib eq ""); # to insert NULL instead of a blank string > undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string >- $sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $imageurl, $id); >+ my $linked_with = $input->param('categorycode'); >+ $sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $linked_with, $imageurl, $id); > if ( @branches ) { > $sth = $dbh->prepare("DELETE FROM authorised_values_branches WHERE av_id = ?"); > $sth->execute( $id ); >@@ -173,13 +202,14 @@ if ($op eq 'add_form') { > ($duplicate_entry) = $sth->fetchrow_array(); > unless ( $duplicate_entry ) { > my $sth=$dbh->prepare( 'INSERT INTO authorised_values >- ( category, authorised_value, lib, lib_opac, imageurl ) >- values (?, ?, ?, ?, ?)' ); >+ ( category, authorised_value, lib, lib_opac, linked_with, imageurl ) >+ values (?, ?, ?, ?, ?, ?)' ); > my $lib = $input->param('lib'); > my $lib_opac = $input->param('lib_opac'); > undef $lib if ($lib eq ""); # to insert NULL instead of a blank string > undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string >- $sth->execute( $new_category, $new_authorised_value, $lib, $lib_opac, $imageurl ); >+ my $linked_with = $input->param('categorycode'); >+ $sth->execute( $new_category, $new_authorised_value, $lib, $lib_opac, $linked_with, $imageurl ); > $id = $dbh->{'mysql_insertid'}; > if ( @branches ) { > $sth = $dbh->prepare( >@@ -280,6 +310,7 @@ sub default_form { > $row_data{authorised_value} = $results->[$i]{'authorised_value'}; > $row_data{lib} = $results->[$i]{'lib'}; > $row_data{lib_opac} = $results->[$i]{'lib_opac'}; >+ $row_data{linked_with} = C4::Members::GetBorrowercategory($results->[$i]{'linked_with'})->{description} if $results->[$i]{'linked_with'} ; > $row_data{imageurl} = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} ); > $row_data{edit} = "$script_name?op=add_form&id=".$results->[$i]{'id'}."&offset=$offset"; > $row_data{delete} = "$script_name?op=delete_confirm&searchfield=$searchfield&id=".$results->[$i]{'id'}."&offset=$offset"; >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 317680a..55e324c 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -6505,6 +6505,13 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.11.00.XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do("ALTER TABLE authorised_values ADD linked_with VARCHAR(80) default NULL AFTER lib_opac;"); >+ print "Upgrade to $DBversion done (Added linked_with to the authorised_values table)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >index 790f0b5..e7ac269 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >@@ -103,6 +103,34 @@ $(document).ready(function() { > <label for="lib_opac">Description (OPAC)</label> > <input type="text" name="lib_opac" id="lib_opac" value="[% lib_opac %]" maxlength="200" /> > </li> >+ [% IF ( category == 'Bsort1' ) %] >+ <li> >+ <label for="categorycode">Linked to (patron category)</label> >+ <select id="categorycode" name="categorycode" onchange="update_category_code(this);"> >+ <option value=""></option> >+ [% FOREACH typeloo IN typeloop %] >+ [% FOREACH categoryloo IN typeloo.categoryloop %] >+ [% IF ( loop.first ) %] >+ [% IF ( typeloo.typename_C ) %]<optgroup label="Child" value="C">[% END %] >+ [% IF ( typeloo.typename_A ) %]<optgroup label="Adult" value="A">[% END %] >+ [% IF ( typeloo.typename_S ) %]<optgroup label="Staff" value="S">[% END %] >+ [% IF ( typeloo.typename_I ) %]<optgroup label="Organization" value="I">[% END %] >+ [% IF ( typeloo.typename_P ) %]<optgroup label="Professional" value="P">[% END %] >+ [% IF ( typeloo.typename_X ) %]<optgroup label="Statistical" value="X">[% END %] >+ [% END %] >+ [% IF ( categoryloo.categorycodeselected ) %] >+ <option value="[% categoryloo.categorycode %]" selected="selected" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option> >+ [% ELSE %] >+ <option value="[% categoryloo.categorycode %]" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option> >+ [% END %] >+ [% IF ( loop.last ) %] >+ </optgroup> >+ [% END %] >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ [% END %] > <li><label for="branches">Branches limitation: </label> > <select id="branches" name="branches" multiple size="10"> > <option value="">All branches</option> >@@ -169,12 +197,18 @@ $(document).ready(function() { > <th>Value</th> > <th>Description</th> > <th>Description (OPAC)</th> >+ [% IF ( category == 'Bsort1' ) %] >+ <th>Linked with</th> >+ [% END %] > </tr> > <tr> > <td>[% searchfield %]</td> > <td>[% Tvalue %]</td> > <td>[% Tlib %]</td> > <td>[% Tlib_opac %]</td> >+ [% IF ( category == 'Bsort1' ) %] >+ <th>[% categorycode |html %]</th> >+ [% END %] > </tr> > </table> > <form action="[% script_name %]" method="post"> >@@ -246,6 +280,9 @@ $(document).ready(function() { > <th>Authorized value</th> > <th>Description</th> > <th>Description (OPAC)</th> >+ [% IF ( category == 'Bsort1' ) %] >+ <th>Linked with</th> >+ [% END %] > <th>Icon</th> > <th>Branches limitations</th> > <th>Edit</th> >@@ -261,6 +298,7 @@ $(document).ready(function() { > <td>[% loo.authorised_value %]</td> > <td>[% loo.lib %]</td> > <td>[% loo.lib_opac %]</td> >+ <td>[% loo.linked_with %]</td> > <td>[% IF ( loo.imageurl ) %]<img src="[% loo.imageurl %]" alt=""/>[% ELSE %] [% END %]</td> > <td> > [% IF loo.branches.size > 0 %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 68d6a30..2146886 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -6,6 +6,27 @@ > <script type="text/javascript"> > //<![CDATA[ > $(document).ready(function() { >+ $("#categorycode").change(filterSort1).change(); >+ function filterSort1 (){ >+ var catlec= $("#categorycode").find("option:selected").val(); >+ var links=$("#sort1").find("option[title="+catlec+"]"); >+ $("#sort1 option").attr('selected', false); >+ if ($(links).length){ >+ $("#sort1 option").each(function(){ >+ $(this).show() ; >+ if ($(this).attr("title") != catlec){ >+ $(this).hide() ; >+ } >+ }); >+ } else { >+ $("#sort1 option").each(function(){ >+ $(this).show(); >+ if ($(this).attr("title") != ""){ >+ $(this).hide() ; >+ } >+ }); >+ } >+ } > $("fieldset.rows input").keydown(function(e){ return checkEnter(e); }); > $("#guarantordelete").click(function() { > $("#contact-details").hide().find('a').remove(); >@@ -1031,8 +1052,17 @@ > <label for="sort1"> > [% END %] > Sort 1: </label> >- [% IF ( CGIsort1 ) %] >- [% CGIsort1 %] >+ [% IF ( sort1loop ) %] >+ <select id="sort1" name="sort1" > >+ <option value="" ></option> >+ [% FOREACH sort1loo IN sort1loop %] >+ [% IF ( sort1loo.selected ) %] >+ <option value="[% sort1loo.authorised_value %]" selected="selected" title="[% sort1loo.linked_with %]">[% sort1loo.lib %]</option> >+ [% ELSE %] >+ <option value="[% sort1loo.authorised_value %]" title="[% sort1loo.linked_with %]">[% sort1loo.lib %]</option> >+ [% END %] >+ [% END %] >+ </select> > [% ELSE %] > <input type="text" id="sort1" name="sort1" size="20" value="[% sort1 %]" /> > [% IF ( mandatorysort1 ) %]<span class="required">Required</span>[% END %] >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 7fc27c0..3b7128a 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -637,13 +637,13 @@ if (C4::Context->preference("memberofinstitution")){ > > # -------------------------------------------------------------------------------------------------------- > >-my $CGIsort = buildCGIsort("Bsort1","sort1",$data{'sort1'}); >-if ($CGIsort) { >- $template->param(CGIsort1 => $CGIsort); >+my $sort1auth = GetAuthorisedValues('Bsort1',$data{'sort1'}); >+if ($sort1auth) { >+ $template->param(sort1loop => $sort1auth); > } > $template->param( sort1 => $data{'sort1'}); # shouldn't this be in an "else" statement like the 2nd one? > >-$CGIsort = buildCGIsort("Bsort2","sort2",$data{'sort2'}); >+my $CGIsort = buildCGIsort("Bsort2","sort2",$data{'sort2'}); > if ($CGIsort) { > $template->param(CGIsort2 => $CGIsort); > } else { >-- >1.7.2.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9836
:
16255
|
16258
|
16301
|
17929
|
18074
|
18426
|
18461
|
18541