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

(-)a/C4/Koha.pm (-44 / +39 lines)
Lines 27-32 use C4::Context; Link Here
27
use C4::Branch qw(GetBranchesCount);
27
use C4::Branch qw(GetBranchesCount);
28
use Koha::Cache;
28
use Koha::Cache;
29
use Koha::DateUtils qw(dt_from_string);
29
use Koha::DateUtils qw(dt_from_string);
30
use C4::ItemType;
30
use DateTime::Format::MySQL;
31
use DateTime::Format::MySQL;
31
use Business::ISBN;
32
use Business::ISBN;
32
use autouse 'Data::cselectall_arrayref' => qw(Dumper);
33
use autouse 'Data::cselectall_arrayref' => qw(Dumper);
Lines 130-206 sub subfield_is_koha_internal_p { Link Here
130
131
131
=head2 GetSupportName
132
=head2 GetSupportName
132
133
133
  $itemtypename = &GetSupportName($codestring);
134
  $lib = &GetSupportName($authorised_value);
134
135
135
Returns a string with the name of the itemtype.
136
Returns the name of the support corresponding to specified authorised value.
136
137
137
=cut
138
=cut
138
139
139
sub GetSupportName{
140
sub GetSupportName {
140
	my ($codestring)=@_;
141
    my $authorised_value = shift;
141
	return if (! $codestring); 
142
    return '' unless $authorised_value;
142
	my $resultstring;
143
    my $supports_av = C4::Context->preference("SupportsAuthorizedValues") || 'itemtypes';
143
	my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
144
    if ( $supports_av eq 'itemtypes' ) {
144
	if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {  
145
        my $itemtype = getitemtypeinfo($authorised_value);
145
		my $query = qq|
146
        return $itemtype->{'description'} if $itemtype;
146
			SELECT description
147
    }
147
			FROM   itemtypes
148
    else {
148
			WHERE itemtype=?
149
        my $lib = GetKohaAuthorisedValueLib( $supports_av, $authorised_value );
149
			order by description
150
        return $lib if $lib;
150
		|;
151
    }
151
		my $sth = C4::Context->dbh->prepare($query);
152
    return '';
152
		$sth->execute($codestring);
153
		($resultstring)=$sth->fetchrow;
154
		return $resultstring;
155
	} else {
156
        my $sth =
157
            C4::Context->dbh->prepare(
158
                    "SELECT lib FROM authorised_values WHERE category = ? AND authorised_value = ?"
159
                    );
160
        $sth->execute( $advanced_search_types, $codestring );
161
        my $data = $sth->fetchrow_hashref;
162
        return $$data{'lib'};
163
	}
164
165
}
153
}
154
166
=head2 GetSupportList
155
=head2 GetSupportList
167
156
168
  $itemtypes = &GetSupportList();
157
  $supports = &GetSupportList();
169
158
170
Returns an array ref containing informations about Support (since itemtype is rather a circulation code when item-level-itypes is used).
159
Returns an array ref containing informations about support : authorised_value, lib, imageurl
171
160
172
build a HTML select with the following code :
161
build a HTML select with the following code :
173
162
174
=head3 in PERL SCRIPT
163
=head3 in PERL SCRIPT
175
164
176
    my $itemtypes = GetSupportList();
165
    my $supports = GetSupportList();
177
    $template->param(itemtypeloop => $itemtypes);
166
    $template->param(supportsloop => $supports);
178
167
179
=head3 in TEMPLATE
168
=head3 in TEMPLATE
180
169
181
    <select name="itemtype" id="itemtype">
170
    <select name="itemtype" id="itemtype">
182
        <option value=""></option>
183
        [% FOREACH itemtypeloo IN itemtypeloop %]
171
        [% FOREACH itemtypeloo IN itemtypeloop %]
184
             [% IF ( itemtypeloo.selected ) %]
172
             [% IF ( itemtypeloo.selected ) %]
185
                <option value="[% itemtypeloo.itemtype %]" selected="selected">[% itemtypeloo.description %]</option>
173
                <option value="[% itemtypeloo.code %]" selected="selected">[% itemtypeloo.description %]</option>
186
            [% ELSE %]
174
            [% ELSE %]
187
                <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.description %]</option>
175
                <option value="[% itemtypeloo.code %]">[% itemtypeloo.description %]</option>
188
            [% END %]
176
            [% END %]
189
       [% END %]
177
       [% END %]
190
    </select>
178
    </select>
191
179
192
=cut
180
=cut
193
181
194
sub GetSupportList{
182
sub GetSupportList {
195
	my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
183
    my $supports_av = C4::Context->preference("SupportsAuthorizedValues") || 'itemtypes';
196
    if (!$advanced_search_types or $advanced_search_types =~ /itemtypes/) {
184
    if ( $supports_av eq 'itemtypes' ) {
197
        return GetItemTypes( style => 'array' );
185
        my @supports = map {
198
	} else {
186
            {
199
		my $advsearchtypes = GetAuthorisedValues($advanced_search_types);
187
                authorised_value => $_->{'itemtype'},
200
		my @results= map {{itemtype=>$$_{authorised_value},description=>$$_{lib},imageurl=>$$_{imageurl}}} @$advsearchtypes;
188
                lib              => $_->{'description'},
201
		return \@results;
189
                imageurl         => $_->{'imageurl'}
202
	}
190
            }
191
        } C4::ItemType->all;
192
        return \@supports;
193
    }
194
    else {
195
        return GetAuthorisedValues($supports_av);
196
    }
203
}
197
}
198
204
=head2 GetItemTypes
199
=head2 GetItemTypes
205
200
206
  $itemtypes = &GetItemTypes( style => $style );
201
  $itemtypes = &GetItemTypes( style => $style );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-5 / +5 lines)
Lines 213-220 h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o Link Here
213
        <li><span class="label">Publication place:</span>[% place |html %]</li>
213
        <li><span class="label">Publication place:</span>[% place |html %]</li>
214
        <li><span class="label">Collection title:</span>[% collectiontitle |html %]</li>
214
        <li><span class="label">Collection title:</span>[% collectiontitle |html %]</li>
215
        <li><span class="label">Document type:</span>
215
        <li><span class="label">Document type:</span>
216
            [% FOREACH itemtypeloo IN itemtypeloop %]
216
            [% FOREACH supports_loo IN supports_loop %]
217
                [% IF ( itemtypeloo.selected ) %][% itemtypeloo.translated_description %][% END %]
217
                [% IF ( supports_loo.selected ) %][% supports_loo.lib %][% END %]
218
            [% END %]
218
            [% END %]
219
        </li>
219
        </li>
220
        [% IF ( patron_reason_loop ) %]
220
        [% IF ( patron_reason_loop ) %]
Lines 337-345 h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o Link Here
337
        <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" value="[% collectiontitle | html %]"/></li>
337
        <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" value="[% collectiontitle | html %]"/></li>
338
        <li><label for="itemtype">Document type:</label>
338
        <li><label for="itemtype">Document type:</label>
339
            <select id="itemtype" name="itemtype" >
339
            <select id="itemtype" name="itemtype" >
340
            [% FOREACH itemtypeloo IN itemtypeloop %]
340
            [% FOREACH supports_loo IN supports_loop %]
341
                [% IF ( itemtypeloo.selected ) %]<option selected="selected" value="[% itemtypeloo.itemtype %]">[% ELSE %]<option value="[% itemtypeloo.itemtype %]">[% END %]
341
                [% IF ( supports_loo.selected ) %]<option selected="selected" value="[% supports_loo.authorised_value %]">[% ELSE %]<option value="[% supports_loo.authorised_value %]">[% END %]
342
                [% itemtypeloo.translated_description %]</option>
342
                [% supports_loo.lib %]</option>
343
            [% END %]
343
            [% END %]
344
            </select>
344
            </select>
345
        </li>
345
        </li>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-6 / +6 lines)
Lines 42-57 Link Here
42
                                        <li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" class="span6" maxlength="80" /></li>
42
                                        <li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" class="span6" maxlength="80" /></li>
43
                                        <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" class="span6" maxlength="80" /></li>
43
                                        <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" class="span6" maxlength="80" /></li>
44
                                        <li><label for="place">Publication place:</label><input type="text" id="place" name="place"  maxlength="80" /></li>
44
                                        <li><label for="place">Publication place:</label><input type="text" id="place" name="place"  maxlength="80" /></li>
45
                                        <li><label for="itemtype">Item type:</label>
45
                                        <li><label for="itemtype">Document type:</label>
46
                                            <select name="itemtype" id="itemtype">
46
                                            <select name="itemtype" id="itemtype">
47
                                                <option value="">Default</option>
47
                                                <option value="">Default</option>
48
                                                [% FOREACH itemtypeloo IN itemtypeloop %]
48
                                                [% FOREACH supports_loo IN supports_loop %]
49
                                                    [% IF ( itemtypeloo.selected ) %]
49
                                                    [% IF ( supports_loo.selected ) %]
50
                                                        <option value="[% itemtypeloo.itemtype %]" selected="selected">
50
                                                        <option value="[% supports_loo.itemtype %]" selected="selected">
51
                                                    [% ELSE %]
51
                                                    [% ELSE %]
52
                                                        <option value="[% itemtypeloo.itemtype %]">
52
                                                        <option value="[% supports_loo.itemtype %]">
53
                                                    [% END %]
53
                                                    [% END %]
54
                                                            [% itemtypeloo.translated_description %]
54
                                                            [% supports_loo.description %]
55
                                                        </option>
55
                                                        </option>
56
                                                [% END %]
56
                                                [% END %]
57
                                            </select>
57
                                            </select>
(-)a/opac/opac-suggestions.pl (-1 / +1 lines)
Lines 189-195 if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) { Link Here
189
189
190
$template->param(
190
$template->param(
191
	%$suggestion,
191
	%$suggestion,
192
	itemtypeloop=> $supportlist,
192
	supports_loop => $supportlist,
193
    suggestions_loop => $suggestions_loop,
193
    suggestions_loop => $suggestions_loop,
194
    patron_reason_loop => $patron_reason_loop,
194
    patron_reason_loop => $patron_reason_loop,
195
    "op_$op"         => 1,
195
    "op_$op"         => 1,
(-)a/suggestion/suggestion.pl (-5 / +4 lines)
Lines 328-343 $template->param( branchloop => \@branchloop, Link Here
328
my $supportlist = GetSupportList();
328
my $supportlist = GetSupportList();
329
329
330
foreach my $support (@$supportlist) {
330
foreach my $support (@$supportlist) {
331
    $$support{'selected'} = (defined $$suggestion_ref{'itemtype'})
331
    if ( defined $$suggestion_ref{'itemtype'} && $support->{'authorised_value'} eq $$suggestion_ref{'itemtype'}) {
332
        ? $$support{'itemtype'} eq $$suggestion_ref{'itemtype'}
332
        $$support{'selected'} = 1;
333
        : 0;
333
    }
334
    if ( $$support{'imageurl'} ) {
334
    if ( $$support{'imageurl'} ) {
335
        $$support{'imageurl'} = getitemtypeimagelocation( 'intranet', $$support{'imageurl'} );
335
        $$support{'imageurl'} = getitemtypeimagelocation( 'intranet', $$support{'imageurl'} );
336
    } else {
336
    } else {
337
        delete $$support{'imageurl'};
337
        delete $$support{'imageurl'};
338
    }
338
    }
339
}
339
}
340
$template->param(itemtypeloop=>$supportlist);
340
$template->param( supports_loop => $supportlist);
341
$template->param( returnsuggestedby => $returnsuggestedby );
341
$template->param( returnsuggestedby => $returnsuggestedby );
342
342
343
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG",$$suggestion_ref{'patronreason'});
343
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG",$$suggestion_ref{'patronreason'});
344
- 

Return to bug 9223