View | Details | Raw Unified | Return to bug 9836
Collapse All | Expand All

(-)a/admin/authorised_values.pl (-8 / +46 lines)
Lines 27-40 use C4::Context; Link Here
27
use C4::Koha;
27
use C4::Koha;
28
use C4::Output;
28
use C4::Output;
29
29
30
31
sub AuthorizedValuesForCategory {
30
sub AuthorizedValuesForCategory {
32
    my ($searchstring) = shift or return;
31
    my ($searchstring) = shift or return;
33
    my $dbh = C4::Context->dbh;
32
    my $dbh = C4::Context->dbh;
34
    $searchstring=~ s/\'/\\\'/g;
33
    $searchstring=~ s/\'/\\\'/g;
35
    my @data=split(' ',$searchstring);
34
    my @data=split(' ',$searchstring);
36
    my $sth=$dbh->prepare('
35
    my $sth=$dbh->prepare('
37
          SELECT  id, category, authorised_value, lib, lib_opac, imageurl
36
          SELECT *
38
            FROM  authorised_values
37
            FROM  authorised_values
39
           WHERE  (category = ?)
38
           WHERE  (category = ?)
40
        ORDER BY  category, authorised_value
39
        ORDER BY  category, authorised_value
Lines 70-76 if ($op eq 'add_form') { Link Here
70
	my $data;
69
	my $data;
71
    my @selected_branches;
70
    my @selected_branches;
72
	if ($id) {
71
	if ($id) {
73
		my $sth=$dbh->prepare("select id, category, authorised_value, lib, lib_opac, imageurl from authorised_values where id=?");
72
              my $sth=$dbh->prepare("select id, category, authorised_value, lib, lib_opac, linked_with, imageurl from authorised_values where id=?");
74
		$sth->execute($id);
73
		$sth->execute($id);
75
		$data=$sth->fetchrow_hashref;
74
		$data=$sth->fetchrow_hashref;
76
        $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM authorised_values_branches AS avb, branches AS b WHERE avb.branchcode = b.branchcode AND avb.av_id = ?;");
75
        $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM authorised_values_branches AS avb, branches AS b WHERE avb.branchcode = b.branchcode AND avb.av_id = ?;");
Lines 114-120 if ($op eq 'add_form') { Link Here
114
                         offset           => $offset,
113
                         offset           => $offset,
115
                         branches_loop    => \@branches_loop,
114
                         branches_loop    => \@branches_loop,
116
                     );
115
                     );
117
                          
116
    # Add borrower's categories select list, in case we'd like to bind a sort1 criteria to categories
117
    my @linked_with = split ('\|', $data->{'linked_with'} );
118
    my @typeloop;
119
    $template->param('allcatcodes'=>1) unless $data->{'linked_with'};
120
    if ($id){
121
        foreach (qw(C A S P I X)) {
122
           my $action="WHERE category_type=?";
123
           my ($categories,$labels) = C4::Members::GetborCatFromCatType($_,$action);
124
           my @categoryloop;
125
           foreach my $cat (@$categories){
126
               my $selected =  grep (/$cat/, @linked_with ) ? 1 : 0;
127
               push @categoryloop,{
128
                                   'categorycode' => $cat,
129
                                   'categoryname' => $labels->{$cat},
130
                                   'selected'     => $selected,
131
               };
132
           }
133
           my %typehash;
134
           $typehash{'typename'}=$_;
135
           my $typedescription = "typename_".$typehash{'typename'};
136
           $typehash{'categoryloop'}=\@categoryloop;
137
           push @typeloop,{
138
                           'typename' => $_,
139
                           $typedescription => 1,
140
                           'categoryloop' => \@categoryloop
141
                           };
142
        }
143
    }
144
    $template->param('typeloop' => \@typeloop);
145
118
################## ADD_VALIDATE ##################################
146
################## ADD_VALIDATE ##################################
119
# called by add_form, used to insert/modify data in DB
147
# called by add_form, used to insert/modify data in DB
120
} elsif ($op eq 'add_validate') {
148
} elsif ($op eq 'add_validate') {
Lines 141-153 if ($op eq 'add_form') { Link Here
141
                                          authorised_value = ?,
169
                                          authorised_value = ?,
142
                                          lib              = ?,
170
                                          lib              = ?,
143
                                          lib_opac         = ?,
171
                                          lib_opac         = ?,
172
                                          linked_with      = ?,
144
                                          imageurl         = ?
173
                                          imageurl         = ?
145
                                      WHERE id=?' );
174
                                      WHERE id=?' );
146
            my $lib = $input->param('lib');
175
            my $lib = $input->param('lib');
147
            my $lib_opac = $input->param('lib_opac');
176
            my $lib_opac = $input->param('lib_opac');
148
            undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
177
            undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
149
            undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
178
            undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
150
            $sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $imageurl, $id);
179
            my @linked_with = $input->param('categorycode');
180
            # pipe after each code is necessary for correct filtering in memberentrygen.tt
181
            my $linked_with = $linked_with[0] ne '' ? join ('|',@linked_with).'|' : '';
182
            $sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $linked_with, $imageurl, $id);
151
            if ( @branches ) {
183
            if ( @branches ) {
152
                $sth = $dbh->prepare("DELETE FROM authorised_values_branches WHERE av_id = ?");
184
                $sth = $dbh->prepare("DELETE FROM authorised_values_branches WHERE av_id = ?");
153
                $sth->execute( $id );
185
                $sth->execute( $id );
Lines 173-185 if ($op eq 'add_form') { Link Here
173
        ($duplicate_entry) = $sth->fetchrow_array();
205
        ($duplicate_entry) = $sth->fetchrow_array();
174
        unless ( $duplicate_entry ) {
206
        unless ( $duplicate_entry ) {
175
            my $sth=$dbh->prepare( 'INSERT INTO authorised_values
207
            my $sth=$dbh->prepare( 'INSERT INTO authorised_values
176
                                    ( category, authorised_value, lib, lib_opac, imageurl )
208
                                    ( category, authorised_value, lib, lib_opac, linked_with, imageurl )
177
                                    values (?, ?, ?, ?, ?)' );
209
                                    values (?, ?, ?, ?, ?, ?)' );
178
    	    my $lib = $input->param('lib');
210
    	    my $lib = $input->param('lib');
179
    	    my $lib_opac = $input->param('lib_opac');
211
    	    my $lib_opac = $input->param('lib_opac');
180
    	    undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
212
    	    undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
181
    	    undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
213
    	    undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
182
            $sth->execute( $new_category, $new_authorised_value, $lib, $lib_opac, $imageurl );
214
            my @linked_with = $input->param('categorycode');
215
            my $linked_with = $linked_with[0] ne '' ? join ('|',@linked_with).'|' : '';
216
            $sth->execute( $new_category, $new_authorised_value, $lib, $lib_opac, $linked_with, $imageurl );
183
            $id = $dbh->{'mysql_insertid'};
217
            $id = $dbh->{'mysql_insertid'};
184
            if ( @branches ) {
218
            if ( @branches ) {
185
                $sth = $dbh->prepare(
219
                $sth = $dbh->prepare(
Lines 275-285 sub default_form { Link Here
275
        while ( my $branch = $sth->fetchrow_hashref ) {
309
        while ( my $branch = $sth->fetchrow_hashref ) {
276
            push @selected_branches, $branch;
310
            push @selected_branches, $branch;
277
        }
311
        }
312
313
314
278
		my %row_data;  # get a fresh hash for the row data
315
		my %row_data;  # get a fresh hash for the row data
279
		$row_data{category}              = $results->[$i]{'category'};
316
		$row_data{category}              = $results->[$i]{'category'};
280
		$row_data{authorised_value}      = $results->[$i]{'authorised_value'};
317
		$row_data{authorised_value}      = $results->[$i]{'authorised_value'};
281
		$row_data{lib}                   = $results->[$i]{'lib'};
318
		$row_data{lib}                   = $results->[$i]{'lib'};
282
		$row_data{lib_opac}              = $results->[$i]{'lib_opac'};
319
		$row_data{lib_opac}              = $results->[$i]{'lib_opac'};
320
        $row_data{linked_with}           = substr($results->[$i]{'linked_with'},0,-1) if $results->[$i]{'linked_with'} ;# remove last pipe just for display
283
		$row_data{imageurl}              = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} );
321
		$row_data{imageurl}              = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} );
284
		$row_data{edit}                  = "$script_name?op=add_form&id=".$results->[$i]{'id'}."&offset=$offset";
322
		$row_data{edit}                  = "$script_name?op=add_form&id=".$results->[$i]{'id'}."&offset=$offset";
285
		$row_data{delete}                = "$script_name?op=delete_confirm&searchfield=$searchfield&id=".$results->[$i]{'id'}."&offset=$offset";
323
		$row_data{delete}                = "$script_name?op=delete_confirm&searchfield=$searchfield&id=".$results->[$i]{'id'}."&offset=$offset";
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 6784-6789 if ( CheckVersion($DBversion) ) { Link Here
6784
    SetVersion ($DBversion);
6784
    SetVersion ($DBversion);
6785
}
6785
}
6786
6786
6787
$DBversion = "3.11.00.XXX";
6788
if ( CheckVersion($DBversion) ) {
6789
    $dbh->do("ALTER TABLE authorised_values ADD linked_with VARCHAR(200) default NULL AFTER lib_opac;");
6790
    print "Upgrade to $DBversion done (Added linked_with to the authorised_values table)\n";
6791
    SetVersion($DBversion);
6792
}
6793
6787
6794
6788
=head1 FUNCTIONS
6795
=head1 FUNCTIONS
6789
6796
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-1 / +38 lines)
Lines 103-108 $(document).ready(function() { Link Here
103
            <label for="lib_opac">Description (OPAC): </label>
103
            <label for="lib_opac">Description (OPAC): </label>
104
            <input type="text" name="lib_opac" id="lib_opac" value="[% lib_opac %]" maxlength="200" />
104
            <input type="text" name="lib_opac" id="lib_opac" value="[% lib_opac %]" maxlength="200" />
105
        </li>
105
        </li>
106
        [% IF ( category == 'Bsort1' ) %]
107
        <li>
108
        <label for="categorycode">Linked to (patron category)</label>
109
        <select id="categorycode" name="categorycode" multiple size="10">
110
                    
111
        [% FOREACH typeloo IN typeloop %]
112
            [% FOREACH categoryloo IN typeloo.categoryloop %]
113
                [% IF ( loop.first ) %]
114
                    [% IF ( typeloo.typename_C ) %]<optgroup label="Child"        value="C">[% END %]
115
                    [% IF ( typeloo.typename_A ) %]<optgroup label="Adult"        value="A">[% END %]
116
                    [% IF ( typeloo.typename_S ) %]<optgroup label="Staff"        value="S">[% END %]
117
                    [% IF ( typeloo.typename_I ) %]<optgroup label="Organization" value="I">[% END %]
118
                    [% IF ( typeloo.typename_P ) %]<optgroup label="Professional" value="P">[% END %]
119
                    [% IF ( typeloo.typename_X ) %]<optgroup label="Statistical"  value="X">[% END %]
120
                    [% IF ( allcatcodes ) %]
121
                    <option value="" selected="selected' data-typename="[% typeloo.typename %]">All Categories</option>
122
                    [% ELSE %]
123
                    <option value="" data-typename="[% typeloo.typename %]">All Categories</option>
124
                    [% END %]
125
                [% END %]
126
                [% IF ( categoryloo.selected ) %]
127
                    <option value="[% categoryloo.categorycode %]" selected="selected" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
128
                [% ELSE %]
129
                    <option value="[% categoryloo.categorycode %]" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
130
                [% END %]
131
                [% IF ( loop.last ) %]
132
                    </optgroup>
133
                [% END %]
134
            [% END %]
135
        [% END %]
136
        </select><div style="margin-left:400px;position:relative;bottom:100px"><p>Select one or more categories (Ctrl key pressed) if you want this authorised value to be a subcategory of them only.</p></div>
137
        </li>
138
        [% END %]
106
        <li><label for="branches">Libraries limitation: </label>
139
        <li><label for="branches">Libraries limitation: </label>
107
            <select id="branches" name="branches" multiple size="10">
140
            <select id="branches" name="branches" multiple size="10">
108
                <option value="">All libraries</option>
141
                <option value="">All libraries</option>
Lines 238-244 $(document).ready(function() { Link Here
238
 [% END %]
271
 [% END %]
239
<h3>Authorized values for category [% category %]:</h3>
272
<h3>Authorized values for category [% category %]:</h3>
240
273
241
[% IF ( loop ) %]<div id="pagertable_authorized_values">
274
[% IF ( looploop ) %]<div id="pagertable_authorized_values">
242
</div>[% END %]
275
</div>[% END %]
243
276
244
[% IF ( loop ) %]<table id="table_authorized_values" class="tablesorter">
277
[% IF ( loop ) %]<table id="table_authorized_values" class="tablesorter">
Lines 246-251 $(document).ready(function() { Link Here
246
	<th>Authorized value</th>
279
	<th>Authorized value</th>
247
	<th>Description</th>
280
	<th>Description</th>
248
	<th>Description (OPAC)</th>
281
	<th>Description (OPAC)</th>
282
        [% IF ( category == 'Bsort1' ) %]
283
             <th>Linked category codes</th>
284
        [% END %]
249
	<th>Icon</th>
285
	<th>Icon</th>
250
    <th>Branches limitations</th>
286
    <th>Branches limitations</th>
251
	<th>Edit</th>
287
	<th>Edit</th>
Lines 261-266 $(document).ready(function() { Link Here
261
	<td>[% loo.authorised_value %]</td>
297
	<td>[% loo.authorised_value %]</td>
262
	<td>[% loo.lib %]</td>
298
	<td>[% loo.lib %]</td>
263
	<td>[% loo.lib_opac %]</td>
299
	<td>[% loo.lib_opac %]</td>
300
        <td>[% IF ( loo.linked_with ) %][% loo.linked_with %][% ELSE %]All categories[% END %]</td>
264
	<td>[% IF ( loo.imageurl ) %]<img src="[% loo.imageurl %]" alt=""/>[% ELSE %]&nbsp;[% END %]</td>
301
	<td>[% IF ( loo.imageurl ) %]<img src="[% loo.imageurl %]" alt=""/>[% ELSE %]&nbsp;[% END %]</td>
265
    <td>
302
    <td>
266
        [% IF loo.branches.size > 0 %]
303
        [% IF loo.branches.size > 0 %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-2 / +30 lines)
Lines 6-11 Link Here
6
<script type="text/javascript">
6
<script type="text/javascript">
7
//<![CDATA[
7
//<![CDATA[
8
    $(document).ready(function() {
8
    $(document).ready(function() {
9
        $("#categorycode").change(filterSort1).change();
10
        function filterSort1 (){
11
            var catlec= $("#categorycode").find("option:selected").val()+'\\|';
12
            var links=$("#sort1").find("option[title*="+catlec+"]");
13
            if (links.length){
14
                $("#sort1 option").attr('selected', false);
15
                $("#sort1 option").each(function(){
16
                    $(this).hide() ;
17
                });
18
                $(links).each(function(){
19
                    $(this).show() ;
20
                });
21
            } else {
22
                $("#sort1 option").each(function(){
23
                    $(this).show() ;
24
                });
25
            }
26
        }
27
9
		$("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
28
		$("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
10
        $("#guarantordelete").click(function() {
29
        $("#guarantordelete").click(function() {
11
            $("#contact-details").hide().find('a').remove();
30
            $("#contact-details").hide().find('a').remove();
Lines 1042-1049 Link Here
1042
        <label for="sort1">
1061
        <label for="sort1">
1043
      [% END %]
1062
      [% END %]
1044
      Sort 1: </label>
1063
      Sort 1: </label>
1045
      [% IF ( CGIsort1 ) %] 
1064
      [% IF ( sort1loop ) %]
1046
        [% CGIsort1 %]
1065
        <select id="sort1" name="sort1" >
1066
        <option value="" ></option>
1067
        [% FOREACH sort1loo IN sort1loop %]
1068
                [% IF ( sort1loo.selected ) %]
1069
                    <option value="[% sort1loo.authorised_value %]" selected="selected" title="[% sort1loo.linked_with %]">[% sort1loo.lib %]</option>
1070
                [% ELSE %]
1071
                    <option value="[% sort1loo.authorised_value %]" title="[% sort1loo.linked_with %]">[% sort1loo.lib %]</option>
1072
                [% END %]
1073
        [% END %]
1074
        </select>
1047
      [% ELSE %]
1075
      [% ELSE %]
1048
          [% IF ( opduplicate ) %]
1076
          [% IF ( opduplicate ) %]
1049
            <input  type="text" id="sort1" name="sort1" size="20"  value="[% sort1 %]" onclick="this.value=''" />
1077
            <input  type="text" id="sort1" name="sort1" size="20"  value="[% sort1 %]" onclick="this.value=''" />
(-)a/members/memberentry.pl (-5 / +4 lines)
Lines 627-639 if (C4::Context->preference("memberofinstitution")){ Link Here
627
627
628
# --------------------------------------------------------------------------------------------------------
628
# --------------------------------------------------------------------------------------------------------
629
629
630
my $CGIsort = buildCGIsort("Bsort1","sort1",$data{'sort1'});
630
my $sort1auth = GetAuthorisedValues('Bsort1',$data{'sort1'});
631
if ($CGIsort) {
631
if ($sort1auth) {
632
    $template->param(CGIsort1 => $CGIsort);
632
    $template->param(sort1loop => $sort1auth);
633
}
633
}
634
$template->param( sort1 => $data{'sort1'});		# shouldn't this be in an "else" statement like the 2nd one?
634
$template->param( sort1 => $data{'sort1'});		# shouldn't this be in an "else" statement like the 2nd one?
635
635
636
$CGIsort = buildCGIsort("Bsort2","sort2",$data{'sort2'});
636
my $CGIsort = buildCGIsort("Bsort2","sort2",$data{'sort2'});
637
if ($CGIsort) {
637
if ($CGIsort) {
638
    $template->param(CGIsort2 => $CGIsort);
638
    $template->param(CGIsort2 => $CGIsort);
639
} else {
639
} else {
640
- 

Return to bug 9836