use C4::Items;
use C4::Circulation;
use C4::Context;
-use C4::Koha; # XXX subfield_is_koha_internal_p
-use C4::Branch; # XXX subfield_is_koha_internal_p
+use C4::Koha;
use C4::BackgroundJob;
use C4::ClassSource;
use C4::Debug;
my $input = new CGI;
my $dbh = C4::Context->dbh;
my $error = $input->param('error');
-my @itemnumbers = $input->param('itemnumber');
+my @itemnumbers = $input->multi_param('itemnumber');
my $biblionumber = $input->param('biblionumber');
my $op = $input->param('op');
my $del = $input->param('del');
#--- ----------------------------------------------------------------------------
if ($op eq "action") {
#-------------------------------------------------------------------------------
- my @tags = $input->param('tag');
- my @subfields = $input->param('subfield');
- my @values = $input->param('field_value');
- my @disabled = $input->param('disable_input');
+ my @tags = $input->multi_param('tag');
+ my @subfields = $input->multi_param('subfield');
+ my @values = $input->multi_param('field_value');
+ my @disabled = $input->multi_param('disable_input');
# build indicator hash.
- my @ind_tag = $input->param('ind_tag');
- my @indicator = $input->param('indicator');
+ my @ind_tag = $input->multi_param('ind_tag');
+ my @indicator = $input->multi_param('indicator');
# Is there something to modify ?
# TODO : We shall use this var to warn the user in case no modification was done to the items
# Once the job is done
if ($completedJobID) {
# If we have a reasonable amount of items, we display them
- if (scalar(@itemnumbers) <= ( C4::Context->preference("MaxItemsForBatch") // 1000 ) ) {
+ if (scalar(@itemnumbers) <= ( C4::Context->preference("MaxItemsToDisplayForBatchDel") // 1000 ) ) {
$items_display_hashref=BuildItemsData(@itemnumbers);
} else {
# Else, we only display the barcode
$job->progress($i) if $runinbackground;
my $itemdata = GetItem($itemnumber);
if ( $del ){
- my $return = DelItemCheck(C4::Context->dbh, $itemdata->{'biblionumber'}, $itemdata->{'itemnumber'});
+ my $return = DelItemCheck( $itemdata->{'biblionumber'}, $itemdata->{'itemnumber'});
if ($return == 1) {
$deleted_items++;
} else {
# Flag to tell the template there are valid results, hidden or not
if(scalar(@itemnumbers) > 0){ $template->param("itemresults" => 1); }
- # Only display the items if there are no more than pref MaxItemsForBatch
- if (scalar(@itemnumbers) <= ( C4::Context->preference("MaxItemsForBatch") // 1000 ) ) {
+ # Only display the items if there are no more than pref MaxItemsToProcessForBatchMod or MaxItemsToDisplayForBatchDel
+ my $max_items = $del
+ ? C4::Context->preference("MaxItemsToDisplayForBatchDel")
+ : C4::Context->preference("MaxItemsToProcessForBatchMod");
+ if (scalar(@itemnumbers) <= ( $max_items // 1000 ) ) {
$items_display_hashref=BuildItemsData(@itemnumbers);
} else {
$template->param("too_many_items" => scalar(@itemnumbers));
$query .= qq{ GROUP BY lib ORDER BY lib, lib_opac};
my $authorised_values_sth = $dbh->prepare( $query );
-my $branches = GetBranchesLoop(); # build once ahead of time, instead of multiple times later.
+my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;# build once ahead of time, instead of multiple times later.
# Adding a default choice, in case the user does not want to modify the branch
my $nochange_branch = { branchname => '', value => '', selected => 1 };
-unshift (@$branches, $nochange_branch);
+unshift (@$libraries, $nochange_branch);
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
foreach my $tag (sort keys %{$tagslib}) {
# loop through each subfield
foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
- next if subfield_is_koha_internal_p($subfield);
+ next if IsMarcStructureInternal( $tagslib->{$tag}{$subfield} );
next if (not $allowAllSubfields and $restrictededition && !grep { $tag . '$' . $subfield eq $_ } @subfieldsToAllow );
next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
# barcode and stocknumber are not meant to be batch-modified
my @authorised_values;
my %authorised_lib;
# builds list, depending on authorised value...
-
- if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) {
- foreach my $thisbranch (@$branches) {
- push @authorised_values, $thisbranch->{value};
- $authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname};
- }
+
+ if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) {
+ foreach my $library (@$libraries) {
+ push @authorised_values, $library->{branchcode};
+ $authorised_lib{$library->{branchcode}} = $library->{branchname};
+ }
$value = "";
- }
- elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
- push @authorised_values, "";
- my $sth = $dbh->prepare("select itemtype,description from itemtypes order by description");
- $sth->execute;
- while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
- push @authorised_values, $itemtype;
- $authorised_lib{$itemtype} = $description;
- }
+ }
+ elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
+ push @authorised_values, "";
+ my $itemtypes = GetItemTypes( style => 'array' );
+ for my $itemtype ( @$itemtypes ) {
+ push @authorised_values, $itemtype->{itemtype};
+ $authorised_lib{$itemtype->{itemtype}} = $itemtype->{translated_description};
+ }
$value = "";
#---- class_sources