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