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

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

Return to bug 9223