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

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

Return to bug 9223