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 ); |