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

(-)a/C4/Koha.pm (-58 / +47 lines)
Lines 26-31 use strict; Link Here
26
use C4::Context;
26
use C4::Context;
27
use C4::Branch qw(GetBranchesCount);
27
use C4::Branch qw(GetBranchesCount);
28
use Koha::DateUtils qw(dt_from_string);
28
use Koha::DateUtils qw(dt_from_string);
29
use C4::ItemType;
29
use Memoize;
30
use Memoize;
30
use DateTime::Format::MySQL;
31
use DateTime::Format::MySQL;
31
use autouse 'Data::Dumper' => qw(Dumper);
32
use autouse 'Data::Dumper' => qw(Dumper);
Lines 126-209 sub subfield_is_koha_internal_p { Link Here
126
127
127
=head2 GetSupportName
128
=head2 GetSupportName
128
129
129
  $itemtypename = &GetSupportName($codestring);
130
  $lib = &GetSupportName($authorised_value);
130
131
131
Returns a string with the name of the itemtype.
132
Returns the name of the support corresponding to specified authorised value.
132
133
133
=cut
134
=cut
134
135
135
sub GetSupportName{
136
sub GetSupportName {
136
	my ($codestring)=@_;
137
    my $authorised_value = shift;
137
	return if (! $codestring); 
138
    return '' unless $authorised_value;
138
	my $resultstring;
139
    my $supports_av = C4::Context->preference("SupportsAuthorizedValues") || 'itemtypes';
139
	my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
140
    if ( $supports_av eq 'itemtypes' ) {
140
	if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {  
141
        my $itemtype = getitemtypeinfo($authorised_value);
141
		my $query = qq|
142
        return $itemtype->{'description'} if $itemtype;
142
			SELECT description
143
    }
143
			FROM   itemtypes
144
    else {
144
			WHERE itemtype=?
145
        my $lib = GetKohaAuthorisedValueLib( $supports_av, $authorised_value );
145
			order by description
146
        return $lib if $lib;
146
		|;
147
    }
147
		my $sth = C4::Context->dbh->prepare($query);
148
    return '';
148
		$sth->execute($codestring);
149
		($resultstring)=$sth->fetchrow;
150
		return $resultstring;
151
	} else {
152
        my $sth =
153
            C4::Context->dbh->prepare(
154
                    "SELECT lib FROM authorised_values WHERE category = ? AND authorised_value = ?"
155
                    );
156
        $sth->execute( $advanced_search_types, $codestring );
157
        my $data = $sth->fetchrow_hashref;
158
        return $$data{'lib'};
159
	}
160
161
}
149
}
150
162
=head2 GetSupportList
151
=head2 GetSupportList
163
152
164
  $itemtypes = &GetSupportList();
153
  $supports = &GetSupportList();
165
154
166
Returns an array ref containing informations about Support (since itemtype is rather a circulation code when item-level-itypes is used).
155
Returns an array ref containing informations about support : authorised_value, lib, imageurl
167
156
168
build a HTML select with the following code :
157
build a HTML select with the following code :
169
158
170
=head3 in PERL SCRIPT
159
=head3 in PERL SCRIPT
171
160
172
    my $itemtypes = GetSupportList();
161
    my $supports = GetSupportList();
173
    $template->param(itemtypeloop => $itemtypes);
162
    $template->param(supportsloop => $supports);
174
163
175
=head3 in TEMPLATE
164
=head3 in TEMPLATE
176
165
177
    <form action='<!-- TMPL_VAR name="script_name" -->' method=post>
166
    <select id="itemtype" name="itemtype" >
178
        <select name="itemtype">
167
    [% FOREACH itemtypeloo IN itemtypeloop %]
179
            <option value="">Default</option>
168
        [% IF ( itemtypeloo.selected ) %]
180
        <!-- TMPL_LOOP name="itemtypeloop" -->
169
          <option value="[% itemtypeloo.code %]" selected="selected">
181
            <option value="<!-- TMPL_VAR name="itemtype" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->> <!--TMPL_IF Name="imageurl"--><img alt="<!-- TMPL_VAR name="description" -->" src="<!--TMPL_VAR Name="imageurl"-->><!--TMPL_ELSE-->"<!-- TMPL_VAR name="description" --><!--/TMPL_IF--></option>
170
        [% ELSE %]
182
        <!-- /TMPL_LOOP -->
171
          <option value="[% itemtypeloo.code %]">
183
        </select>
172
        [% END %]
184
        <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->">
173
        [% itemtypeloo.description %]</option>
185
        <input type="submit" value="OK" class="button">
174
    [% END %]
186
    </form>
175
    </select>
187
176
188
=cut
177
=cut
189
178
190
sub GetSupportList{
179
sub GetSupportList {
191
	my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
180
    my $supports_av = C4::Context->preference("SupportsAuthorizedValues") || 'itemtypes';
192
	if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {  
181
    if ( $supports_av eq 'itemtypes' ) {
193
		my $query = qq|
182
        my @supports = map {
194
			SELECT *
183
            {
195
			FROM   itemtypes
184
                authorised_value => $_->{'itemtype'},
196
			order by description
185
                lib              => $_->{'description'},
197
		|;
186
                imageurl         => $_->{'imageurl'}
198
		my $sth = C4::Context->dbh->prepare($query);
187
            }
199
		$sth->execute;
188
        } C4::ItemType->all;
200
		return $sth->fetchall_arrayref({});
189
        return \@supports;
201
	} else {
190
    }
202
		my $advsearchtypes = GetAuthorisedValues($advanced_search_types);
191
    else {
203
		my @results= map {{itemtype=>$$_{authorised_value},description=>$$_{lib},imageurl=>$$_{imageurl}}} @$advsearchtypes;
192
        return GetAuthorisedValues($supports_av);
204
		return \@results;
193
    }
205
	}
206
}
194
}
195
207
=head2 GetItemTypes
196
=head2 GetItemTypes
208
197
209
  $itemtypes = &GetItemTypes( style => $style );
198
  $itemtypes = &GetItemTypes( style => $style );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-5 / +5 lines)
Lines 178-185 $(document).ready(function() { calcNewsuggTotal(); }); Link Here
178
        <li><span class="label">Publication place:</span>[% place %]</li>
178
        <li><span class="label">Publication place:</span>[% place %]</li>
179
        <li><span class="label">Collection title:</span>[% collectiontitle %]</li>
179
        <li><span class="label">Collection title:</span>[% collectiontitle %]</li>
180
        <li><span class="label">Document type:</span>
180
        <li><span class="label">Document type:</span>
181
            [% FOREACH itemtypeloo IN itemtypeloop %]
181
            [% FOREACH supports_loo IN supports_loop %]
182
                [% IF ( itemtypeloo.selected ) %][% itemtypeloo.description %][% END %]
182
                [% IF ( supports_loo.selected ) %][% supports_loo.lib %][% END %]
183
            [% END %]
183
            [% END %]
184
        </li>
184
        </li>
185
        [% IF ( patron_reason_loop ) %]
185
        [% IF ( patron_reason_loop ) %]
Lines 294-302 $(document).ready(function() { calcNewsuggTotal(); }); Link Here
294
        <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" value="[% collectiontitle %]"/></li>
294
        <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" value="[% collectiontitle %]"/></li>
295
        <li><label for="itemtype">Document type:</label>
295
        <li><label for="itemtype">Document type:</label>
296
            <select id="itemtype" name="itemtype" >
296
            <select id="itemtype" name="itemtype" >
297
            [% FOREACH itemtypeloo IN itemtypeloop %]
297
            [% FOREACH supports_loo IN supports_loop %]
298
                [% IF ( itemtypeloo.selected ) %]<option selected="selected" value="[% itemtypeloo.itemtype %]">[% ELSE %]<option value="[% itemtypeloo.itemtype %]">[% END %]
298
                [% IF ( supports_loo.selected ) %]<option selected="selected" value="[% supports_loo.authorised_value %]">[% ELSE %]<option value="[% supports_loo.authorised_value %]">[% END %]
299
                [% itemtypeloo.description %]</option>
299
                [% supports_loo.lib %]</option>
300
            [% END %]
300
            [% END %]
301
            </select>
301
            </select>
302
        </li>
302
        </li>
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt (-3 / +3 lines)
Lines 112-121 $.tablesorter.addParser({ Link Here
112
    <li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" size="50" maxlength="80" /></li>
112
    <li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" size="50" maxlength="80" /></li>
113
    <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" /></li>
113
    <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" /></li>
114
    <li><label for="place">Publication place:</label><input type="text" id="place" name="place" size="50" maxlength="80" /></li>
114
    <li><label for="place">Publication place:</label><input type="text" id="place" name="place" size="50" maxlength="80" /></li>
115
    <li><label for="itemtype">Item type:</label><select name="itemtype" id="itemtype">
115
    <li><label for="itemtype">Document type:</label><select name="itemtype" id="itemtype">
116
            <option value="">Default</option>
116
            <option value="">Default</option>
117
        [% FOREACH itemtypeloo IN itemtypeloop %]
117
        [% FOREACH supports_loo IN supports_loop %]
118
			[% IF ( itemtypeloo.selected ) %]<option value="[% itemtypeloo.itemtype %]" selected="selected"> [% ELSE %]<option value="[% itemtypeloo.itemtype %]"> [% END %] [% itemtypeloo.description %]</option>
118
            [% IF ( supports_loo.selected ) %]<option value="[% supports_loo.authorised_value %]" selected="selected">[% ELSE %]<option value="[% supports_loo.authorised_value %]">[% END %][% supports_loo.lib %]</option>
119
        [% END %]
119
        [% END %]
120
        </select> </li>
120
        </select> </li>
121
    [% IF ( branchloop ) %]
121
    [% IF ( branchloop ) %]
(-)a/opac/opac-suggestions.pl (-1 / +1 lines)
Lines 141-147 if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) { Link Here
141
141
142
$template->param(
142
$template->param(
143
	%$suggestion,
143
	%$suggestion,
144
	itemtypeloop=> $supportlist,
144
	supports_loop => $supportlist,
145
    suggestions_loop => $suggestions_loop,
145
    suggestions_loop => $suggestions_loop,
146
    patron_reason_loop => $patron_reason_loop,
146
    patron_reason_loop => $patron_reason_loop,
147
    showall    => $allsuggestions,
147
    showall    => $allsuggestions,
(-)a/suggestion/suggestion.pl (-5 / +4 lines)
Lines 303-318 $template->param( branchloop => \@branchloop, Link Here
303
my $supportlist = GetSupportList();
303
my $supportlist = GetSupportList();
304
304
305
foreach my $support (@$supportlist) {
305
foreach my $support (@$supportlist) {
306
    $$support{'selected'} = (defined $$suggestion_ref{'itemtype'})
306
    if ( defined $$suggestion_ref{'itemtype'} && $support->{'authorised_value'} eq $$suggestion_ref{'itemtype'}) {
307
        ? $$support{'itemtype'} eq $$suggestion_ref{'itemtype'}
307
        $$support{'selected'} = 1;
308
        : 0;
308
    }
309
    if ( $$support{'imageurl'} ) {
309
    if ( $$support{'imageurl'} ) {
310
        $$support{'imageurl'} = getitemtypeimagelocation( 'intranet', $$support{'imageurl'} );
310
        $$support{'imageurl'} = getitemtypeimagelocation( 'intranet', $$support{'imageurl'} );
311
    } else {
311
    } else {
312
        delete $$support{'imageurl'};
312
        delete $$support{'imageurl'};
313
    }
313
    }
314
}
314
}
315
$template->param(itemtypeloop=>$supportlist);
315
$template->param( supports_loop => $supportlist);
316
$template->param( returnsuggestedby => $returnsuggestedby );
316
$template->param( returnsuggestedby => $returnsuggestedby );
317
317
318
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG",$$suggestion_ref{'patronreason'});
318
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG",$$suggestion_ref{'patronreason'});
319
- 

Return to bug 9223