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

(-)a/C4/Koha.pm (-46 / +42 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 130-162 Returns a string with the name of the itemtype. Link Here
130
131
131
=cut
132
=cut
132
133
133
sub GetSupportName{
134
sub GetSupportName {
134
	my ($codestring)=@_;
135
    my $codestring = shift;
135
	return if (! $codestring); 
136
    return '' unless $codestring;
136
	my $resultstring;
137
    my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || 'itemtypes';
137
	my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
138
    for my $support_type ( split /\|/, $advanced_search_types ) {
138
	if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {  
139
        if ( $support_type eq 'itemtypes' ) {
139
		my $query = qq|
140
            my $itemtype = getitemtypeinfo($codestring);
140
			SELECT description
141
            return $itemtype->{'description'} if $itemtype;
141
			FROM   itemtypes
142
        }
142
			WHERE itemtype=?
143
        else {
143
			order by description
144
            my $lib = GetKohaAuthorisedValueLib( $support_type, $codestring );
144
		|;
145
            return $lib if $lib;
145
		my $sth = C4::Context->dbh->prepare($query);
146
        }
146
		$sth->execute($codestring);
147
    }
147
		($resultstring)=$sth->fetchrow;
148
    return '';
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
}
149
}
150
160
=head2 GetSupportList
151
=head2 GetSupportList
161
152
162
  $itemtypes = &GetSupportList();
153
  $itemtypes = &GetSupportList();
Lines 185-207 build a HTML select with the following code : Link Here
185
176
186
=cut
177
=cut
187
178
188
sub GetSupportList{
179
sub GetSupportList {
189
	my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
180
    my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || 'itemtypes';
190
	if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {  
181
    my @all_supports;
191
		my $query = qq|
182
    for my $support_type ( split /\|/, $advanced_search_types ) {
192
			SELECT *
183
        my @supports;
193
			FROM   itemtypes
184
        if ( $support_type eq 'itemtypes' ) {
194
			order by description
185
            @supports = C4::ItemType->all;
195
		|;
186
        }
196
		my $sth = C4::Context->dbh->prepare($query);
187
        else {
197
		$sth->execute;
188
            my $authorised_values = GetAuthorisedValues($support_type);
198
		return $sth->fetchall_arrayref({});
189
            @supports = map {
199
	} else {
190
                {
200
		my $advsearchtypes = GetAuthorisedValues($advanced_search_types);
191
                    itemtype    => $_->{authorised_value},
201
		my @results= map {{itemtype=>$$_{authorised_value},description=>$$_{lib},imageurl=>$$_{imageurl}}} @$advsearchtypes;
192
                    description => $_->{lib},
202
		return \@results;
193
                    imageurl    => $_->{imageurl}
203
	}
194
                }
195
            } @$authorised_values;
196
        }
197
        push @all_supports, @supports;
198
    }
199
    return \@all_supports;
204
}
200
}
201
205
=head2 GetItemTypes
202
=head2 GetItemTypes
206
203
207
  $itemtypes = &GetItemTypes();
204
  $itemtypes = &GetItemTypes();
Lines 437-445 sub getitemtypeinfo { Link Here
437
    my $sth        = $dbh->prepare("select * from itemtypes where itemtype=?");
434
    my $sth        = $dbh->prepare("select * from itemtypes where itemtype=?");
438
    $sth->execute($itemtype);
435
    $sth->execute($itemtype);
439
    my $res = $sth->fetchrow_hashref;
436
    my $res = $sth->fetchrow_hashref;
440
437
    if ( $res ) {
441
    $res->{imageurl} = getitemtypeimagelocation( 'intranet', $res->{imageurl} );
438
        $res->{imageurl} = getitemtypeimagelocation( 'intranet', $res->{imageurl} );
442
439
    }
443
    return $res;
440
    return $res;
444
}
441
}
445
442
446
- 

Return to bug 9223