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

(-)a/admin/authorised_values.pl (-7 / +38 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  id, category, authorised_value, lib, lib_opac, imageurl
37
          SELECT *
38
            FROM  authorised_values
38
            FROM  authorised_values
39
           WHERE  (category = ?)
39
           WHERE  (category = ?)
40
        ORDER BY  category, authorised_value
40
        ORDER BY  category, authorised_value
Lines 114-120 if ($op eq 'add_form') { Link Here
114
                         offset           => $offset,
114
                         offset           => $offset,
115
                         branches_loop    => \@branches_loop,
115
                         branches_loop    => \@branches_loop,
116
                     );
116
                     );
117
                          
117
#####################################
118
# Add borrower's categories select list, in case we'd like to bind a sort1 criteria to a category
119
my @typeloop;
120
my $no_categories = 1;
121
foreach (qw(C A S P I X)) {
122
    my $action="WHERE category_type=?";
123
    my ($categories,$labels) = C4::Members::GetborCatFromCatType($_,$action);
124
    if(scalar(@$categories) > 0){ $no_categories = 0; }
125
       my @categoryloop;
126
       foreach my $cat (@$categories){
127
               push @categoryloop,{
128
                                   'categorycode' => $cat,
129
                                   'categoryname' => $labels->{$cat},
130
                                  };
131
       }
132
       my %typehash;
133
       $typehash{'typename'}=$_;
134
       my $typedescription = "typename_".$typehash{'typename'};
135
       $typehash{'categoryloop'}=\@categoryloop;
136
       push @typeloop,{
137
                      'typename' => $_,
138
                      $typedescription => 1,
139
                      'categoryloop' => \@categoryloop
140
                      };
141
}
142
$template->param('typeloop' => \@typeloop,
143
        no_categories => $no_categories);
144
118
################## ADD_VALIDATE ##################################
145
################## ADD_VALIDATE ##################################
119
# called by add_form, used to insert/modify data in DB
146
# called by add_form, used to insert/modify data in DB
120
} elsif ($op eq 'add_validate') {
147
} elsif ($op eq 'add_validate') {
Lines 141-153 if ($op eq 'add_form') { Link Here
141
                                          authorised_value = ?,
168
                                          authorised_value = ?,
142
                                          lib              = ?,
169
                                          lib              = ?,
143
                                          lib_opac         = ?,
170
                                          lib_opac         = ?,
171
                                          linked_with      = ?,
144
                                          imageurl         = ?
172
                                          imageurl         = ?
145
                                      WHERE id=?' );
173
                                      WHERE id=?' );
146
            my $lib = $input->param('lib');
174
            my $lib = $input->param('lib');
147
            my $lib_opac = $input->param('lib_opac');
175
            my $lib_opac = $input->param('lib_opac');
148
            undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
176
            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
177
            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);
178
            my $linked_with = $input->param('categorycode');
179
            $sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $linked_with, $imageurl, $id);
151
            if ( @branches ) {
180
            if ( @branches ) {
152
                $sth = $dbh->prepare("DELETE FROM authorised_values_branches WHERE av_id = ?");
181
                $sth = $dbh->prepare("DELETE FROM authorised_values_branches WHERE av_id = ?");
153
                $sth->execute( $id );
182
                $sth->execute( $id );
Lines 173-185 if ($op eq 'add_form') { Link Here
173
        ($duplicate_entry) = $sth->fetchrow_array();
202
        ($duplicate_entry) = $sth->fetchrow_array();
174
        unless ( $duplicate_entry ) {
203
        unless ( $duplicate_entry ) {
175
            my $sth=$dbh->prepare( 'INSERT INTO authorised_values
204
            my $sth=$dbh->prepare( 'INSERT INTO authorised_values
176
                                    ( category, authorised_value, lib, lib_opac, imageurl )
205
                                    ( category, authorised_value, lib, lib_opac, linked_with, imageurl )
177
                                    values (?, ?, ?, ?, ?)' );
206
                                    values (?, ?, ?, ?, ?, ?)' );
178
    	    my $lib = $input->param('lib');
207
    	    my $lib = $input->param('lib');
179
    	    my $lib_opac = $input->param('lib_opac');
208
    	    my $lib_opac = $input->param('lib_opac');
180
    	    undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
209
    	    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
210
    	    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 );
211
            my $linked_with = $input->param('categorycode');
212
            $sth->execute( $new_category, $new_authorised_value, $lib, $lib_opac, $linked_with, $imageurl );
183
            $id = $dbh->{'mysql_insertid'};
213
            $id = $dbh->{'mysql_insertid'};
184
            if ( @branches ) {
214
            if ( @branches ) {
185
                $sth = $dbh->prepare(
215
                $sth = $dbh->prepare(
Lines 280-285 sub default_form { Link Here
280
		$row_data{authorised_value}      = $results->[$i]{'authorised_value'};
310
		$row_data{authorised_value}      = $results->[$i]{'authorised_value'};
281
		$row_data{lib}                   = $results->[$i]{'lib'};
311
		$row_data{lib}                   = $results->[$i]{'lib'};
282
		$row_data{lib_opac}              = $results->[$i]{'lib_opac'};
312
		$row_data{lib_opac}              = $results->[$i]{'lib_opac'};
313
                $row_data{linked_with}           = C4::Members::GetBorrowercategory($results->[$i]{'linked_with'})->{description} if $results->[$i]{'linked_with'} ;
283
		$row_data{imageurl}              = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} );
314
		$row_data{imageurl}              = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} );
284
		$row_data{edit}                  = "$script_name?op=add_form&id=".$results->[$i]{'id'}."&offset=$offset";
315
		$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";
316
		$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 6505-6510 if ( CheckVersion($DBversion) ) { Link Here
6505
    SetVersion($DBversion);
6505
    SetVersion($DBversion);
6506
}
6506
}
6507
6507
6508
$DBversion = "3.11.00.XXX";
6509
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6510
    $dbh->do("ALTER TABLE authorised_values ADD linked_with VARCHAR(80) default NULL AFTER lib_opac;");
6511
    print "Upgrade to $DBversion done (Added linked_with to the authorised_values table)\n";
6512
    SetVersion($DBversion);
6513
}
6514
6508
=head1 FUNCTIONS
6515
=head1 FUNCTIONS
6509
6516
6510
=head2 TableExists($table)
6517
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (+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" onchange="update_category_code(this);">
110
                    <option value=""></option>
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
                [% END %]
121
                [% IF ( categoryloo.categorycodeselected ) %]
122
                    <option value="[% categoryloo.categorycode %]" selected="selected" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
123
                [% ELSE %]
124
                    <option value="[% categoryloo.categorycode %]" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
125
                [% END %]
126
                [% IF ( loop.last ) %]
127
                    </optgroup>
128
                [% END %]
129
            [% END %]
130
       [% END %]
131
       </select>
132
    </li>
133
        [% END %]
106
        <li><label for="branches">Branches limitation: </label>
134
        <li><label for="branches">Branches limitation: </label>
107
            <select id="branches" name="branches" multiple size="10">
135
            <select id="branches" name="branches" multiple size="10">
108
                <option value="">All branches</option>
136
                <option value="">All branches</option>
Lines 169-180 $(document).ready(function() { Link Here
169
		<th>Value</th>
197
		<th>Value</th>
170
		<th>Description</th>
198
		<th>Description</th>
171
		<th>Description (OPAC)</th>
199
		<th>Description (OPAC)</th>
200
                [% IF ( category == 'Bsort1' ) %]
201
                    <th>Linked with</th>
202
                [% END %]
172
	</tr>
203
	</tr>
173
	<tr>
204
	<tr>
174
	    <td>[% searchfield %]</td>
205
	    <td>[% searchfield %]</td>
175
	    <td>[% Tvalue %]</td>
206
	    <td>[% Tvalue %]</td>
176
	    <td>[% Tlib %]</td>
207
	    <td>[% Tlib %]</td>
177
	    <td>[% Tlib_opac %]</td>
208
	    <td>[% Tlib_opac %]</td>
209
            [% IF ( category == 'Bsort1' ) %]
210
                <th>[% categorycode |html %]</th>
211
            [% END %]
178
	</tr>
212
	</tr>
179
	</table>
213
	</table>
180
	<form action="[% script_name %]" method="post">
214
	<form action="[% script_name %]" method="post">
Lines 246-251 $(document).ready(function() { Link Here
246
	<th>Authorized value</th>
280
	<th>Authorized value</th>
247
	<th>Description</th>
281
	<th>Description</th>
248
	<th>Description (OPAC)</th>
282
	<th>Description (OPAC)</th>
283
        [% IF ( category == 'Bsort1' ) %]
284
             <th>Linked with</th>
285
        [% END %]
249
	<th>Icon</th>
286
	<th>Icon</th>
250
    <th>Branches limitations</th>
287
    <th>Branches limitations</th>
251
	<th>Edit</th>
288
	<th>Edit</th>
Lines 261-266 $(document).ready(function() { Link Here
261
	<td>[% loo.authorised_value %]</td>
298
	<td>[% loo.authorised_value %]</td>
262
	<td>[% loo.lib %]</td>
299
	<td>[% loo.lib %]</td>
263
	<td>[% loo.lib_opac %]</td>
300
	<td>[% loo.lib_opac %]</td>
301
        <td>[% loo.linked_with %]</td>
264
	<td>[% IF ( loo.imageurl ) %]<img src="[% loo.imageurl %]" alt=""/>[% ELSE %]&nbsp;[% END %]</td>
302
	<td>[% IF ( loo.imageurl ) %]<img src="[% loo.imageurl %]" alt=""/>[% ELSE %]&nbsp;[% END %]</td>
265
    <td>
303
    <td>
266
        [% IF loo.branches.size > 0 %]
304
        [% IF loo.branches.size > 0 %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-2 / +32 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
            $("#sort1 option").attr('selected', false);
14
            if ($(links).length){
15
                $("#sort1 option").each(function(){
16
                    $(this).show() ;
17
                    if ($(this).attr("title") != catlec){
18
                        $(this).hide() ;
19
                    }
20
                });
21
            } else {
22
                $("#sort1 option").each(function(){
23
                    $(this).show();
24
                        if ($(this).attr("title") != ""){
25
                            $(this).hide() ;
26
                        }
27
               });
28
            }
29
        }
9
		$("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
30
		$("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
10
        $("#guarantordelete").click(function() {
31
        $("#guarantordelete").click(function() {
11
            $("#contact-details").hide().find('a').remove();
32
            $("#contact-details").hide().find('a').remove();
Lines 1031-1038 Link Here
1031
        <label for="sort1">
1052
        <label for="sort1">
1032
      [% END %]
1053
      [% END %]
1033
      Sort 1: </label>
1054
      Sort 1: </label>
1034
      [% IF ( CGIsort1 ) %] 
1055
      [% IF ( sort1loop ) %]
1035
        [% CGIsort1 %]
1056
        <select id="sort1" name="sort1" >
1057
        <option value="" ></option>
1058
        [% FOREACH sort1loo IN sort1loop %]
1059
                [% IF ( sort1loo.selected ) %]
1060
                    <option value="[% sort1loo.authorised_value %]" selected="selected" title="[% sort1loo.linked_with %]">[% sort1loo.lib %]</option>
1061
                [% ELSE %]
1062
                    <option value="[% sort1loo.authorised_value %]" title="[% sort1loo.linked_with %]">[% sort1loo.lib %]</option>
1063
                [% END %]
1064
        [% END %]
1065
        </select>
1036
      [% ELSE %]
1066
      [% ELSE %]
1037
        <input  type="text" id="sort1" name="sort1" size="20"  value="[% sort1 %]" />
1067
        <input  type="text" id="sort1" name="sort1" size="20"  value="[% sort1 %]" />
1038
	  [% IF ( mandatorysort1 ) %]<span class="required">Required</span>[% END %]
1068
	  [% IF ( mandatorysort1 ) %]<span class="required">Required</span>[% END %]
(-)a/members/memberentry.pl (-5 / +4 lines)
Lines 637-649 if (C4::Context->preference("memberofinstitution")){ Link Here
637
637
638
# --------------------------------------------------------------------------------------------------------
638
# --------------------------------------------------------------------------------------------------------
639
639
640
my $CGIsort = buildCGIsort("Bsort1","sort1",$data{'sort1'});
640
my $sort1auth = GetAuthorisedValues('Bsort1',$data{'sort1'});
641
if ($CGIsort) {
641
if ($sort1auth) {
642
    $template->param(CGIsort1 => $CGIsort);
642
    $template->param(sort1loop => $sort1auth);
643
}
643
}
644
$template->param( sort1 => $data{'sort1'});		# shouldn't this be in an "else" statement like the 2nd one?
644
$template->param( sort1 => $data{'sort1'});		# shouldn't this be in an "else" statement like the 2nd one?
645
645
646
$CGIsort = buildCGIsort("Bsort2","sort2",$data{'sort2'});
646
my $CGIsort = buildCGIsort("Bsort2","sort2",$data{'sort2'});
647
if ($CGIsort) {
647
if ($CGIsort) {
648
    $template->param(CGIsort2 => $CGIsort);
648
    $template->param(CGIsort2 => $CGIsort);
649
} else {
649
} else {
650
- 

Return to bug 9836