Bug 29859: Use iterator instead of as_list

On bug 29844 we decided to remove wantarray from Koha::Objects->search.
Reviewing the difference occurrences I found some unnecessary uses of ->as_list,
where iterators should be used instead.

This patch only removes the obvious places, not the tricky ones.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2022-01-12 15:40:36 +01:00 committed by Fridolin Somers
parent 9bf19f628a
commit d02e91f269
60 changed files with 153 additions and 193 deletions

View file

@ -652,7 +652,7 @@ sub GetBranchcodesWithOverdueRules {
|);
if ( $branchcodes->[0] eq '' ) {
# If a default rule exists, all branches should be returned
return map { $_->branchcode } Koha::Libraries->search({}, { order_by => 'branchname' })->as_list;
return Koha::Libraries->search({}, { order_by => 'branchname' })->get_column('branchcode');
}
return @$branchcodes;
}

View file

@ -42,16 +42,12 @@ sub store {
$self->_result->result_source->schema->txn_do( sub {
if ( $self->active ) {
# Remove the active flag from all other active currencies
my @currencies = Koha::Acquisition::Currencies->search(
Koha::Acquisition::Currencies->search(
{
currency => { '!=' => $self->currency },
active => 1,
}
)->as_list;
for my $currency ( @currencies ) {
$currency->active(0);
$currency->store;
}
)->update({ active => 0 });
}
$result = $self->SUPER::store;
});

View file

@ -91,14 +91,14 @@ sub move {
if ( $where eq 'up' ) {
unless ( $alert->precedence() == 1 ) {
my ($other) = $self->search( { precedence => $alert->precedence() - 1 } )->as_list;
my $other = $self->search( { precedence => $alert->precedence() - 1 } )->next;
$other->precedence( $alert->precedence() )->store();
$alert->precedence( $alert->precedence() - 1 )->store();
}
}
elsif ( $where eq 'down' ) {
unless ( $alert->precedence() == $self->get_last_precedence() ) {
my ($other) = $self->search( { precedence => $alert->precedence() + 1 } )->as_list;
my $other = $self->search( { precedence => $alert->precedence() + 1 } )->next;
$other->precedence( $alert->precedence() )->store();
$alert->precedence( $alert->precedence() + 1 )->store();
}

View file

@ -117,22 +117,20 @@ sub get_items_that_can_fill {
push @bibs_or_items, 'me.itemnumber' => { in => \@itemnumbers } if @itemnumbers;
push @bibs_or_items, 'biblionumber' => { in => \@biblionumbers } if @biblionumbers;
my @branchtransfers = map { $_->itemnumber }
Koha::Item::Transfers->search(
{ datearrived => undef },
{
columns => ['itemnumber'],
collapse => 1,
}
)->as_list;
my @waiting_holds = map { $_->itemnumber }
Koha::Holds->search(
{ 'found' => 'W' },
{
columns => ['itemnumber'],
collapse => 1,
}
)->as_list;
my @branchtransfers = Koha::Item::Transfers->search(
{ datearrived => undef },
{
columns => ['itemnumber'],
collapse => 1,
}
)->get_columns('itemnumber');
my @waiting_holds = Koha::Holds->search(
{ 'found' => 'W' },
{
columns => ['itemnumber'],
collapse => 1,
}
)->get_column('itemnumber');
return Koha::Items->search(
{

View file

@ -111,15 +111,13 @@ sub libraries {
my $in_or_not = $invert ? '-not_in' : '-in';
my @children = Koha::Library::Groups->search(
my @branchcodes = Koha::Library::Groups->search(
{
parent_id => $self->id,
branchcode => { '!=' => undef },
},
{ order_by => 'branchcode' }
)->as_list;
my @branchcodes = map { $_->branchcode } @children;
)->get_column('branchcode');
return Koha::Libraries->search(
{

View file

@ -96,12 +96,11 @@ if ($op eq ""){
#
} elsif ($op eq "batch_details"){
#display lines inside the selected batch
# get currencies (for change rates calcs if needed)
my @currencies = Koha::Acquisition::Currencies->search->as_list;
$template->param("batch_details" => 1,
"basketno" => $cgiparams->{'basketno'},
currencies => \@currencies,
# get currencies (for change rates calcs if needed)
currencies => Koha::Acquisition::Currencies->search,
bookseller => $bookseller,
"allmatch" => $allmatch,
);
@ -611,7 +610,6 @@ sub import_biblios_list {
my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
my $nomatch_action = GetImportBatchNoMatchAction($import_batch_id);
my $item_action = GetImportBatchItemAction($import_batch_id);
my @itypes = Koha::ItemTypes->search->as_list;
$template->param(biblio_list => \@list,
num_results => $num_records,
import_batch_id => $import_batch_id,
@ -622,9 +620,9 @@ sub import_biblios_list {
"item_action_${item_action}" => 1,
item_action => $item_action,
item_error => $item_error,
libraries => scalar Koha::Libraries->search(),
libraries => Koha::Libraries->search,
locationloop => \@locations,
itypeloop => \@itypes,
itemtypes => Koha::ItemTypes->search,
ccodeloop => \@ccodes,
notforloanloop => \@notforloans,
);

View file

@ -424,8 +424,8 @@ if ( $op eq 'list' ) {
unclosable => @orders || @cancelledorders ? $basket->{is_standing} : 1,
has_budgets => $has_budgets,
duplinbatch => $duplinbatch,
csv_profiles => [ Koha::CsvProfiles->search({ type => 'sql', used_for => 'export_basket' })->as_list ],
available_additional_fields => [ Koha::AdditionalFields->search( { tablename => 'aqbasket' } )->as_list ],
csv_profiles => Koha::CsvProfiles->search({ type => 'sql', used_for => 'export_basket' }),
available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqbasket' } ),
additional_field_values => { map {
$_->field->name => $_->value
} Koha::Acquisition::Baskets->find($basketno)->additional_field_values->as_list },

View file

@ -74,7 +74,7 @@ my $basket;
my $op = $input->param('op');
my $is_an_edit = $input->param('is_an_edit');
$template->param( available_additional_fields => [ Koha::AdditionalFields->search( { tablename => 'aqbasket' } )->as_list ] );
$template->param( available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqbasket' } ) );
if ( $op eq 'add_form' ) {
my @contractloop;
@ -116,9 +116,9 @@ if ( $op eq 'add_form' ) {
$template->param(contractloop => \@contractloop,
basketcontractnumber => $basket->{'contractnumber'});
}
my @booksellers = Koha::Acquisition::Booksellers->search(
my $booksellers = Koha::Acquisition::Booksellers->search(
undef,
{ order_by => { -asc => 'name' } } )->as_list;
{ order_by => { -asc => 'name' } } );
$template->param( add_form => 1,
basketname => $basket->{'basketname'},
@ -127,7 +127,7 @@ if ( $op eq 'add_form' ) {
booksellername => $bookseller->name,
booksellerid => $booksellerid,
basketno => $basketno,
booksellers => \@booksellers,
booksellers => $booksellers,
is_standing => $basket->{is_standing},
create_items => $basket->{create_items},
);

View file

@ -117,9 +117,8 @@ elsif ( $op eq 'batch_edit' ) {
@{$budget_loop} =
sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @{$budget_loop};
my @currencies = Koha::Acquisition::Currencies->search->as_list;
$template->param(
currencies => \@currencies,
currencies => Koha::Acquisition::Currencies->search,
budget_loop => $budget_loop,
);
}

View file

@ -99,10 +99,10 @@ unless ( $input->param('from') ) {
}
$filters->{from_placed_on} = output_pref( { dt => $from_placed_on, dateformat => 'iso', dateonly => 1 } );
$filters->{to_placed_on} = output_pref( { dt => $to_placed_on, dateformat => 'iso', dateonly => 1 } );
my @additional_fields = Koha::AdditionalFields->search( { tablename => 'aqbasket', searchable => 1 } )->as_list;
$template->param( available_additional_fields => \@additional_fields );
my $additional_fields = Koha::AdditionalFields->search( { tablename => 'aqbasket', searchable => 1 } );
$template->param( available_additional_fields => $additional_fields );
my @additional_field_filters;
foreach my $additional_field (@additional_fields) {
while ( my $additional_field = $additional_fields->next ) {
my $value = $input->param('additional_field_' . $additional_field->id);
if (defined $value and $value ne '') {
push @additional_field_filters, {

View file

@ -157,6 +157,6 @@ $template->param(
estimateddeliverydatefrom => $estimateddeliverydatefrom,
estimateddeliverydateto => $estimateddeliverydateto,
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
csv_profiles => [ Koha::CsvProfiles->search({ type => 'sql', used_for => 'late_orders' })->as_list ],
csv_profiles => Koha::CsvProfiles->search({ type => 'sql', used_for => 'late_orders' }),
);
output_html_with_http_headers $input, $cookie, $template->output;

View file

@ -207,7 +207,6 @@ if ( not $ordernumber ) { # create order
}
if ( not $biblionumber and Koha::BiblioFrameworks->find('ACQ') ) {
#my $acq_mss = Koha::MarcSubfieldStructures->search({ frameworkcode => 'ACQ', tagfield => { '!=' => $itemnumber_tag } });
foreach my $tag ( sort keys %{$tagslib} ) {
next if $tag eq '';
next if $tag eq $itemnumber_tag; # skip items fields
@ -326,7 +325,6 @@ $template->param( catalog_details => \@catalog_details, );
my $suggestion;
$suggestion = GetSuggestionInfo($suggestionid) if $suggestionid;
my @currencies = Koha::Acquisition::Currencies->search->as_list;
my $active_currency = Koha::Acquisition::Currencies->get_active;
# build bookfund list
@ -452,7 +450,7 @@ $template->param(
invoiceincgst => $bookseller->invoiceincgst,
cur_active_sym => $active_currency->symbol,
cur_active => $active_currency->currency,
currencies => \@currencies,
currencies => Koha::Acquisition::Currencies->search,
currency => $data->{currency},
vendor_currency => $bookseller->listprice,
orderexists => ( $new eq 'yes' ) ? 0 : 1,

View file

@ -96,7 +96,6 @@ if ( $op eq 'display' ) {
print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
exit;
} else {
my @currencies = Koha::Acquisition::Currencies->search->as_list;
# get option values from TaxRates syspref
my @gst_values = map {
@ -108,7 +107,7 @@ if ( $op eq 'display' ) {
active => $supplier ? $supplier->active : 1,
tax_rate => $supplier ? $supplier->tax_rate + 0.0 : 0,
gst_values => \@gst_values,
currencies => \@currencies,
currencies => Koha::Acquisition::Currencies->search,
enter => 1,
);
}

View file

@ -117,13 +117,13 @@ if( $basketno && $ordernumber) {
# Search for booksellers to transfer from/to
$op = '' unless $op;
if( $op eq "do_search" ) {
my @booksellers = Koha::Acquisition::Booksellers->search(
my $booksellers = Koha::Acquisition::Booksellers->search(
{ name => { -like => "%$query%" } },
{ order_by => { -asc => 'name' } } )->as_list;
{ order_by => { -asc => 'name' } } );
$template->param(
query => $query,
do_search => 1,
booksellersloop => \@booksellers,
booksellers => $booksellers,
);
}
}

View file

@ -212,13 +212,15 @@ $template->param(
if ( $op eq 'list' ) {
# build categories list
my @categories = Koha::AuthorisedValueCategories->search({ category_name => { -not_in => ['', 'branches', 'itemtypes', 'cn_source']}}, { order_by => ['category_name'] } )->as_list;
my @category_list;
for my $category ( @categories ) {
push( @category_list, $category->category_name );
}
my @category_names = Koha::AuthorisedValueCategories->search(
{
category_name =>
{ -not_in => [ '', 'branches', 'itemtypes', 'cn_source' ] }
},
{ order_by => ['category_name'] }
)->get_column('category_name');
$searchfield ||= $category_list[0];
$searchfield ||= $category_names[0];
my @avs_by_category = Koha::AuthorisedValues->new->search( { category => $searchfield } )->as_list;
my @loop_data = ();
@ -238,7 +240,7 @@ if ( $op eq 'list' ) {
$template->param(
loop => \@loop_data,
category => Koha::AuthorisedValueCategories->find($searchfield), # TODO Move this up and add a Koha::AVC->authorised_values method to replace call for avs_by_category
categories => \@category_list,
category_names => \@category_names,
);
}

View file

@ -49,17 +49,9 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
);
if ( $op eq 'add_form' ) {
my $library;
if ($branchcode) {
$library = Koha::Libraries->find($branchcode);
$template->param( selected_smtp_server => $library->smtp_server );
}
my @smtp_servers = Koha::SMTP::Servers->search->as_list;
$template->param(
library => $library,
smtp_servers => \@smtp_servers
library => Koha::Libraries->find($branchcode),
smtp_servers => Koha::SMTP::Servers->search,
);
} elsif ( $op eq 'add_validate' ) {
my @fields = qw(

View file

@ -47,16 +47,15 @@ sub show {
);
my $branch = $input->param('branch') || '*';
my @categories = Koha::Patron::Categories->search_with_library_limits->as_list;
my @item_types = Koha::ItemTypes->search->as_list;
my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
my $grid_checkin = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' });
$template->param(branch => $branch);
$template->param(categories => \@categories);
$template->param(item_types => \@item_types);
$template->param(grid_checkout => $grid_checkout);
$template->param(grid_checkin => $grid_checkin);
$template->param(
branch => $branch,
item_types => Koha::ItemTypes->search,
grid_checkout => $grid_checkout,
grid_checkin => $grid_checkin,
);
output_html_with_http_headers $input, $cookie, $template->output;
}

View file

@ -198,7 +198,7 @@ if ( $op eq 'add_form' ) {
if ( $op eq 'list' ) {
$template->param(
itemtypes => scalar Koha::ItemTypes->search,
itemtypes => Koha::ItemTypes->search,
messages => \@messages,
);
}

View file

@ -97,8 +97,7 @@ if ( $op eq 'add_form' ) {
$sth2->finish;
$sth2 = $dbh->prepare("select distinct category from authorised_values");
$sth2->execute;
my @av_cat = Koha::AuthorisedValueCategories->search->as_list;
my @authorised_values = map { $_->category_name } @av_cat;
my @authorised_values= Koha::AuthorisedValueCategories->search->get_column('category_name');
# build thesaurus categories list
my @authtypes = uniq( "", map { $_->authtypecode } Koha::Authority::Types->search->as_list );

View file

@ -62,8 +62,8 @@ elsif ( $op eq 'delete' ) {
$provider->delete() if $provider;
}
my @providers = Koha::SMS::Providers->search->as_list;
my $providers = Koha::SMS::Providers->search;
$template->param( providers => \@providers );
$template->param( providers => $providers );
output_html_with_http_headers $cgi, $cookie, $template->output;

View file

@ -36,7 +36,7 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({
my @itemnumbers = $cgi->multi_param('itemnumber');
my $format = $cgi->param('format') // 'csv';
my @items = Koha::Items->search({ itemnumber => { -in => \@itemnumbers } })->as_list;
my $items = Koha::Items->search({ itemnumber => { -in => \@itemnumbers } });
if ($format eq 'barcodes') {
print $cgi->header({
@ -44,14 +44,14 @@ if ($format eq 'barcodes') {
attachment => 'barcodes.txt',
});
foreach my $item (@items) {
while ( my $item = $items->next ) {
print $item->barcode . "\n";
}
exit;
}
$template->param(
results => \@items,
results => $items,
);
print $cgi->header({

View file

@ -260,13 +260,7 @@ if ( defined $format ) {
# Display the search form
my @branches = map { value => $_->branchcode, label => $_->branchname }, Koha::Libraries->search( {}, { order_by => 'branchname' } )->as_list;
my @itemtypes;
foreach my $itemtype ( Koha::ItemTypes->search_with_localization->as_list ) {
push @itemtypes, {
value => $itemtype->itemtype,
label => $itemtype->translated_description,
};
}
my @itemtypes = map { value => $_->itemtype, label => $_->translated_description }, Koha::ItemTypes->search_with_localization->as_list;
my @ccodes = Koha::AuthorisedValues->get_descriptions_by_koha_field({ kohafield => 'items.ccode' });
foreach my $ccode (@ccodes) {

View file

@ -49,11 +49,9 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $schema = Koha::Database->new->schema;
my @keyboard_shortcuts = Koha::KeyboardShortcuts->search->as_list;
# Keyboard shortcuts
$template->param(
shortcuts => \@keyboard_shortcuts,
shortcuts => Koha::KeyboardShortcuts->search,
);
# Available import batches

View file

@ -603,7 +603,7 @@ $template->param(
if ( C4::Context->preference("ExportCircHistory") ) {
$template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' })->as_list ]);
$template->param(csv_profiles => Koha::CsvProfiles->search({ type => 'marc' }));
}
my $has_modifications = Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->count;

View file

@ -41,7 +41,7 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
my $branchcode = C4::Context->userenv->{'branch'};
# transfers requested but not yet sent
my @transfers = Koha::Libraries->search(
my $transfers = Koha::Libraries->search(
{
'branchtransfers_tobranches.frombranch' => $branchcode,
'branchtransfers_tobranches.daterequested' => { '!=' => undef },
@ -53,10 +53,10 @@ my @transfers = Koha::Libraries->search(
prefetch => 'branchtransfers_tobranches',
order_by => 'branchtransfers_tobranches.tobranch'
}
)->as_list;
);
$template->param(
libraries => \@transfers,
libraries => $transfers,
show_date => dt_from_string
);

View file

@ -45,15 +45,12 @@ my $club_id = $cgi->param('club_id');
my $club_template = $club_template_id ? Koha::Club::Templates->find( $club_template_id ) : undef;
my $club = $club_id ? Koha::Clubs->find( $club_id ) : undef;
my @club_templates = Koha::Club::Templates->search->as_list;
my @clubs = Koha::Clubs->search->as_list;
$template->param(
stored => $stored,
club_template => $club_template,
club => $club,
club_templates => \@club_templates,
clubs => \@clubs,
club_templates => Koha::Club::Templates->search,
clubs => Koha::Clubs->search,
);
output_html_with_http_headers( $cgi, $cookie, $template->output );

View file

@ -64,12 +64,12 @@
<select name="issues-table-output-format" id="issues-table-output-format">
<option value="iso2709_995">MARC with items</option>
<option value="iso2709">MARC without items</option>
[% IF csv_profiles.size %]
[% IF csv_profiles.count %]
<option value="csv">CSV</option>
[% END %]
</select>
[% IF csv_profiles.size %]
[% IF csv_profiles.count %]
<select name="csv_profile_id">
[% FOREACH csv_profile IN csv_profiles %]
<option value="[% csv_profile.export_format_id | html %]">[% csv_profile.profile | html %]</option>

View file

@ -215,11 +215,11 @@ Batch list
</select>
</li>
<li><label for="itype_item_[% item.item_id | html %]">itype</label><select id="itype_item_[% item.item_id | html %]" name="itype_[% item.biblio_count | html %]">
[% FOREACH itypeloo IN itypeloop %]
[% IF ( itypeloo.itemtype ) == ( item.itype ) %]
<option value="[% itypeloo.itemtype | html %]" selected="selected">[% itypeloo.description | html %]</option>
[% FOREACH itemtype IN itemtypes %]
[% IF itemtype.itemtype == item.itype %]
<option value="[% itemtype.itemtype | html %]" selected="selected">[% itemtype.description | html %]</option>
[% ELSE %]
<option value="[% itypeloo.itemtype | html %]">[% itypeloo.description | html %]</option>
<option value="[% itemtype.itemtype | html %]">[% itemtype.description | html %]</option>
[% END %]
[% END %]
</select>

View file

@ -7,7 +7,7 @@
<a class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
<ul class="dropdown-menu" id="export-csv-menu">
<li><a href="#">Default</a></li>
[% IF csv_profiles %]
[% IF csv_profiles.count %]
[% FOR csv IN csv_profiles %]
<li><a href="#" data-value="[% csv.export_format_id | html %]">[% csv.profile | html %]</a></li>
[% END %]

View file

@ -148,7 +148,7 @@
</ol>
</fieldset>
[% IF available_additional_fields %]
[% IF available_additional_fields.count %]
[% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
[% END %]

View file

@ -204,7 +204,7 @@
<a class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
<ul class="dropdown-menu" id="export-csv-menu">
<li><a href="#">Default</a></li>
[% IF csv_profiles %]
[% IF csv_profiles.count %]
[% FOR csv IN csv_profiles %]
<li><a href="#" data-value="[% csv.export_format_id | html %]">[% csv.profile | html %]</a></li>
[% END %]

View file

@ -145,7 +145,7 @@
<input type="hidden" name="suggestionid" value="[% suggestionid | html %]" />
<input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" />
[% FOREACH c IN currencies %]
[% FOREACH c IN currencies.count %]
<input type="hidden" id="currency_rate_[% c.currency | html %]" name="[% c.currency | html %]" value="[% c.rate | html %]" />
[% END %]
@ -399,7 +399,7 @@
<li>
<label for="currency">Currency:</label>
<select name="currency" id="currency" onchange="updateCosts();">
[% FOREACH c IN currencies %]
[% FOREACH c IN currencies.count %]
[% IF ordernumber and c.currency == currency or not ordernumber and c.currency == vendor_currency %]
<option value="[% c.currency | html %]" selected="selected">[% c.currency | html %]</option>
[% ELSIF not c.archived %]

View file

@ -98,7 +98,7 @@
[% ELSE %]
<h3>Choose a vendor to transfer from</h3>
[% END %]
[% IF ( booksellersloop ) %]
[% IF booksellers.count %]
<table>
<thead>
<tr>
@ -107,7 +107,7 @@
</tr>
</thead>
<tbody>
[% FOREACH bookseller IN booksellersloop %]
[% FOREACH bookseller IN booksellers %]
<tr>
<td>[% bookseller.name | html %]</td>
<td><a class="btn btn-default btn-xs" href="transferorder.pl?[% IF (bookselleridfrom) %]bookselleridto[% ELSE %]bookselleridfrom[% END %]=[% bookseller.id | html %][% IF (ordernumber) %]&ordernumber=[% ordernumber | html %][% END %]">Choose</a></td>

View file

@ -240,7 +240,7 @@ Authorized values &rsaquo; Administration &rsaquo; Koha
<p>
<label for="category_search">Show category: </label>
<select name="searchfield" id="category_search">
[% FOR c IN categories %]
[% FOR c IN category_names %]
[% IF c == searchfield %]
<option value="[% c | html %]" selected="selected">[% c | html %]</option>
[% ELSE %]
@ -323,7 +323,7 @@ Authorized values &rsaquo; Administration &rsaquo; Koha
</tr>
</thead>
<tbody>
[% FOR c IN categories %]
[% FOR c IN category_names %]
<tr>
<td><a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% c | uri %]">[% c | html %]</a></td>
<td>

View file

@ -220,13 +220,13 @@ Libraries &rsaquo; Administration &rsaquo; Koha
</li>
<li><label for="smtp_server">SMTP server: </label>
<select name="smtp_server" id="smtp_server">
[% IF selected_smtp_server.is_system_default %]
[% IF library AND library.smtp_server.is_system_default %]
<option value="*" selected="selected">Default</option>
[% ELSE %]
<option value="*">Default</option>
[% END %]
[% FOREACH smtp_server IN smtp_servers %]
[% IF smtp_server.id == selected_smtp_server.id %]
[% IF library AND smtp_server.id == library.smtp_server.id %]
<option value="[% smtp_server.id | html %]" selected="selected">[% smtp_server.name | html %]</option>
[% ELSE %]
<option value="[% smtp_server.id | html %]">[% smtp_server.name | html %]</option>

View file

@ -37,7 +37,7 @@
<h2>SMS cellular providers</h2>
[% IF providers.size %]
[% IF providers.count %]
<table id="providerst">
<thead>

View file

@ -43,7 +43,7 @@
<h1>Transfers requested of your library as of [% show_date | $KohaDates %]</h1>
[% IF ( libraries ) %]
[% IF libraries.count %]
<p>Your library is the origin for the following transfer(s)</p>
<div id="resultlist">
[% FOREACH library IN libraries %]

View file

@ -65,7 +65,7 @@
</div>
[% END %]
[% IF club_templates %]
[% IF club_templates.count %]
<table id="club-templates-table">
<thead>
<tr>
@ -120,7 +120,7 @@
[% IF CAN_user_clubs_edit_clubs %]
<div class="btn-toolbar">
<div class="btn-group">
[% IF club_templates %]
[% IF club_templates.count %]
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New club <span class="caret"></span></button>
[% ELSE %]
<button disabled="disabled" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New club <span class="caret"></span></button>
@ -134,10 +134,10 @@
</div>
[% END %]
[% IF clubs %]
[% IF clubs.count %]
[% INCLUDE 'clubs-table.inc' %]
[% ELSE %]
[% IF club_templates %]
[% IF club_templates.count %]
<div class="dialog message">No clubs defined.</div>
[% ELSE %]
<div class="dialog message">No clubs defined. A club template must be defined before a club can be defined.</div>

View file

@ -74,7 +74,7 @@
</form>
<div id="keys">
[% IF api_keys && api_keys.size > 0 %]
[% IF api_keys.count %]
<p>
<button class="btn btn-default toggle_element" type="submit" id="show-api-form" data-element="#add-api-key"><i class="fa fa-plus"></i> Generate a new client id/key pair</button>
</p>

View file

@ -185,7 +185,7 @@
[% END %]</tbody>
</table>
[% IF csv_profiles %]
[% IF csv_profiles.count %]
<fieldset class="action">
<label for="csv_code">Select CSV profile:</label>
<select id="csv_profile_for_export">

View file

@ -157,7 +157,7 @@
</div> <!-- /.col-sm-6 -->
</div> <!-- /.row -->
[% IF available_additional_fields %]
[% IF available_additional_fields.count %]
<hr>
<div class="row">
<div class="col-sm-6">

View file

@ -245,7 +245,7 @@
[% UNLESS hidden.defined('branchcode') %]
<li>
[% IF ( libraries.size > 1 ) %]
[% IF libraries.count %]
<label for="borrower_branchcode" class="[% required.branchcode | html %]">Home library:</label>
<select id="borrower_branchcode" name="borrower_branchcode" class="[% required.branchcode | html %]">

View file

@ -121,10 +121,8 @@ if ($op) {
}
}
my @api_keys = Koha::ApiKeys->search({ patron_id => $patron_id })->as_list;
$template->param(
api_keys => \@api_keys,
api_keys => Koha::ApiKeys->search({ patron_id => $patron_id }),
csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $cgi->cookie('CGISESSID') }),
patron => $patron
);

View file

@ -174,10 +174,10 @@ if ( $action eq 'discount' ) {
#get account details
my $total = $patron->account->balance;
my @accountlines = Koha::Account::Lines->search(
my $accountlines = Koha::Account::Lines->search(
{ borrowernumber => $patron->borrowernumber },
{ order_by => { -desc => 'accountlines_id' } }
)->as_list;
);
my $totalcredit;
if($total <= 0){
@ -209,7 +209,7 @@ $template->param(
finesview => 1,
total => sprintf("%.2f",$total),
totalcredit => $totalcredit,
accounts => \@accountlines,
accounts => $accountlines,
payment_id => $payment_id,
change_given => $change_given,
renew_results => $renew_results_display,

View file

@ -205,12 +205,12 @@ if ($add) {
}
}
my @debit_types = Koha::Account::DebitTypes->search_with_library_limits(
my $debit_types = Koha::Account::DebitTypes->search_with_library_limits(
{ can_be_invoiced => 1, archived => 0 },
{}, $library_id )->as_list;
{}, $library_id );
$template->param(
debit_types => \@debit_types,
debit_types => $debit_types,
csrf_token => Koha::Token->new->generate_csrf(
{ session_id => scalar $input->cookie('CGISESSID') }
),

View file

@ -43,13 +43,14 @@ if( Koha::Libraries->search->count < 1){
$template->param(no_branches => 1);
}
my @categories = Koha::Patron::Categories->search_with_library_limits->as_list;
if(scalar(@categories) < 1){
my $categories = Koha::Patron::Categories->search_with_library_limits;
unless ( $categories->count ) {
$no_add = 1;
$template->param(no_categories => 1);
}
else {
$template->param(categories=>\@categories);
# FIXME This does not seem to be used in the template
$template->param(categories => $categories);
}
my $branch =

View file

@ -162,7 +162,7 @@ if (C4::Context->preference('EnhancedMessagingPreferences')) {
}
if ( C4::Context->preference("ExportCircHistory") ) {
$template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' })->as_list ]);
$template->param(csv_profiles => Koha::CsvProfiles->search({ type => 'marc' }));
}
my $patron_messages = Koha::Patron::Messages->search(

View file

@ -72,7 +72,7 @@ GetOptions(
pod2usage(1) if $help;
cronlogaction();
my @patron_ids = map { $_->borrowernumber } Koha::Account::Lines->search(
my @patron_ids = Koha::Account::Lines->search(
{
amountoutstanding => { '<' => 0 },
borrowernumber => { '!=' => undef }
@ -81,7 +81,7 @@ my @patron_ids = map { $_->borrowernumber } Koha::Account::Lines->search(
columns => [ qw/borrowernumber/ ],
distinct => 1,
}
)->as_list;
)->get_column('borrowernumber');
my $patrons = Koha::Patrons->search({ borrowernumber => { -in => \@patron_ids } });

View file

@ -176,11 +176,8 @@ my $resultsarray = \@results;
# my $itemsarray=\@items;
$template->param(
csv_profiles => [
Koha::CsvProfiles->search(
{ type => 'marc', used_for => 'export_records', staff_only => 0 }
)->as_list
],
csv_profiles => Koha::CsvProfiles->search(
{ type => 'marc', used_for => 'export_records', staff_only => 0 } ),
bib_list => $bib_list,
BIBLIO_RESULTS => $resultsarray,
);

View file

@ -130,16 +130,14 @@ if ($bib_list && $format) {
} else {
$template->param(
csv_profiles => [
Koha::CsvProfiles->search(
{
type => 'marc',
used_for => 'export_records',
staff_only => 0
}
)->as_list
]
csv_profiles => Koha::CsvProfiles->search(
{
type => 'marc',
used_for => 'export_records',
staff_only => 0
}
),
bib_list => $bib_list,
);
$template->param(bib_list => $bib_list);
output_html_with_http_headers $query, $cookie, $template->output;
}

View file

@ -146,17 +146,15 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) {
$template->param(fullpage => 1);
}
$template->param(
csv_profiles => [
Koha::CsvProfiles->search(
{
type => 'marc',
used_for => 'export_records',
staff_only => 0
}
)->as_list
]
csv_profiles => Koha::CsvProfiles->search(
{
type => 'marc',
used_for => 'export_records',
staff_only => 0
}
),
shelf => $shelf,
);
$template->param( shelf => $shelf );
output_html_with_http_headers $query, $cookie, $template->output;
}

View file

@ -86,7 +86,7 @@ if ( $action eq 'create' || $action eq 'new' ) {
$params = { branchcode => { -in => \@PatronSelfRegistrationLibraryList } }
if @PatronSelfRegistrationLibraryList;
}
my @libraries = Koha::Libraries->search($params)->as_list;
my $libraries = Koha::Libraries->search($params);
my ( $min, $max ) = C4::Members::get_cardnumber_length();
if ( defined $min ) {
@ -102,7 +102,7 @@ $template->param(
action => $action,
hidden => GetHiddenFields( $mandatory, $action ),
mandatory => $mandatory,
libraries => \@libraries,
libraries => $libraries,
OPACPatronDetails => C4::Context->preference('OPACPatronDetails'),
defaultCategory => $defaultCategory,
);
@ -162,7 +162,7 @@ if ( $action eq 'create' ) {
borrower => \%borrower
);
$template->param( patron_attribute_classes => GeneratePatronAttributesForm( undef, $attributes ) );
} elsif ( ! grep { $borrower{branchcode} eq $_->branchcode } @libraries ) {
} elsif ( $libraries->find($borrower{branchcode}) ) {
die "Branchcode not allowed"; # They hack the form
}
else {
@ -625,7 +625,7 @@ sub GeneratePatronAttributesForm {
my ( $borrowernumber, $entered_attributes ) = @_;
# Get all attribute types and the values for this patron (if applicable)
my @types = grep { $_->opac_editable() or $_->opac_display }
my @types = grep { $_->opac_editable() or $_->opac_display } # FIXME filter using DBIC
Koha::Patron::Attribute::Types->search()->as_list();
if ( scalar(@types) == 0 ) {
return [];

View file

@ -79,8 +79,8 @@ $template->param(
TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification") );
if ( C4::Context->preference("SMSSendDriver") eq 'Email' ) {
my @providers = Koha::SMS::Providers->search->as_list;
$template->param( sms_providers => \@providers, sms_provider_id => $patron->sms_provider_id );
my $providers = Koha::SMS::Providers->search;
$template->param( sms_providers => $providers, sms_provider_id => $patron->sms_provider_id );
}
my $new_session_id = $cookie->value;

View file

@ -436,8 +436,7 @@ my %is_nolimit = map { $_ => 1 } @nolimits;
if (@searchCategories > 0) {
my @tabcat;
foreach my $typecategory (@searchCategories) {
my @itemtypes = Koha::ItemTypes->search({ searchcategory => $typecategory })->as_list;
push @tabcat, $_->itemtype for @itemtypes;
push @tabcat, Koha::ItemTypes->search({ searchcategory => $typecategory })->get_column('itemtype');
}
foreach my $itemtypeInCategory (@tabcat) {

View file

@ -397,11 +397,13 @@ if ( $op eq 'view' ) {
itemsloop => \@items_info,
sortfield => $sortfield,
direction => $direction,
csv_profiles => [
Koha::CsvProfiles->search(
{ type => 'marc', used_for => 'export_records', staff_only => 0 }
)->as_list
],
csv_profiles => Koha::CsvProfiles->search(
{
type => 'marc',
used_for => 'export_records',
staff_only => 0
}
),
);
if ( $page ) {
my $pager = $contents->pager;

View file

@ -181,7 +181,7 @@ else {
my $CGIsepChoice = GetDelimiterChoices;
my @branches = Koha::Libraries->search({}, { order_by => 'branchname' })->as_list;
my $libraries = Koha::Libraries->search({}, { order_by => 'branchname' });
my $ccode_subfield_structure = GetMarcSubfieldStructureFromKohaField('items.ccode');
my $ccode_label;
@ -201,7 +201,7 @@ else {
Sort1 => $Sort1,
Sort2 => $Sort2,
CGIsepChoice => $CGIsepChoice,
branches => \@branches,
branches => $libraries,
ccode_label => $ccode_label,
ccode_avlist => $ccode_avlist,
);

View file

@ -219,7 +219,7 @@ sub calculate {
}
}
my @branchcodes = map { $_->branchcode } Koha::Libraries->search->as_list;
my @branchcodes = Koha::Libraries->search->get_column('branchcode');
($status ) and push @loopfilter,{crit=>"Status", filter=>$status };
($activity) and push @loopfilter,{crit=>"Activity",filter=>$activity};
# year of activity

View file

@ -96,7 +96,7 @@ $template->param(
supplierid => $supplierid,
claimletter => $claimletter,
additional_fields_for_subscription => $additional_fields,
csv_profiles => [ Koha::CsvProfiles->search({ type => 'sql', used_for => 'late_issues' })->as_list ],
csv_profiles => Koha::CsvProfiles->search({ type => 'sql', used_for => 'late_issues' }),
letters => $letters,
(uc(C4::Context->preference("marcflavour"))) => 1
);

View file

@ -126,7 +126,7 @@ my $default_bib_view = get_default_view();
my $subscription_object = Koha::Subscriptions->find( $subscriptionid );
$template->param(
available_additional_fields => [ Koha::AdditionalFields->search( { tablename => 'subscription' } )->as_list ],
available_additional_fields => Koha::AdditionalFields->search( { tablename => 'subscription' } ),
additional_field_values => {
map { $_->field->name => $_->value }
$subscription_object->additional_field_values->as_list

View file

@ -456,9 +456,9 @@ if( $suggestion_ref->{STATUS} ) {
);
}
my @currencies = Koha::Acquisition::Currencies->search->as_list;
my $currencies = Koha::Acquisition::Currencies->search;
$template->param(
currencies => \@currencies,
currencies => $currencies,
suggestion => $suggestion_ref,
price => sprintf("%.2f", $$suggestion_ref{'price'}||0),
total => sprintf("%.2f", $$suggestion_ref{'total'}||0),