Lines 39-44
use C4::Barcodes::ValueBuilder;
Link Here
|
39 |
use Koha::DateUtils qw( dt_from_string ); |
39 |
use Koha::DateUtils qw( dt_from_string ); |
40 |
use Koha::Items; |
40 |
use Koha::Items; |
41 |
use Koha::ItemTypes; |
41 |
use Koha::ItemTypes; |
|
|
42 |
use Koha::Items; |
42 |
use Koha::Libraries; |
43 |
use Koha::Libraries; |
43 |
use Koha::Patrons; |
44 |
use Koha::Patrons; |
44 |
use Koha::SearchEngine::Indexer; |
45 |
use Koha::SearchEngine::Indexer; |
Lines 57-62
use List::MoreUtils qw( any uniq );
Link Here
|
57 |
|
58 |
|
58 |
our $dbh = C4::Context->dbh; |
59 |
our $dbh = C4::Context->dbh; |
59 |
|
60 |
|
|
|
61 |
sub add_item_to_volume { |
62 |
my ( $biblionumber, $itemnumber, $volume, $volume_description ) = @_; |
63 |
|
64 |
return unless $volume; |
65 |
|
66 |
my $volume_id; |
67 |
if ( $volume eq 'create' ) { |
68 |
my $volume = Koha::Biblio::ItemGroup->new( |
69 |
{ |
70 |
biblionumber => $biblionumber, |
71 |
description => $volume_description, |
72 |
} |
73 |
)->store(); |
74 |
|
75 |
$volume_id = $volume->id; |
76 |
} |
77 |
else { |
78 |
$volume_id = $volume; |
79 |
} |
80 |
|
81 |
my $volume_item = Koha::Biblio::ItemGroup::Item->new( |
82 |
{ |
83 |
itemnumber => $itemnumber, |
84 |
volume_id => $volume_id, |
85 |
} |
86 |
)->store(); |
87 |
} |
88 |
|
60 |
sub get_item_from_cookie { |
89 |
sub get_item_from_cookie { |
61 |
my ( $input ) = @_; |
90 |
my ( $input ) = @_; |
62 |
|
91 |
|
Lines 102-107
my $fa_barcode = $input->param('barcode');
Link Here
|
102 |
my $fa_branch = $input->param('branch'); |
131 |
my $fa_branch = $input->param('branch'); |
103 |
my $fa_stickyduedate = $input->param('stickyduedate'); |
132 |
my $fa_stickyduedate = $input->param('stickyduedate'); |
104 |
my $fa_duedatespec = $input->param('duedatespec'); |
133 |
my $fa_duedatespec = $input->param('duedatespec'); |
|
|
134 |
my $volume = $input->param('volume'); |
135 |
my $volume_description = $input->param('volume_description'); |
105 |
|
136 |
|
106 |
our $frameworkcode = &GetFrameworkCode($biblionumber); |
137 |
our $frameworkcode = &GetFrameworkCode($biblionumber); |
107 |
|
138 |
|
Lines 206-211
if ($op eq "additem") {
Link Here
|
206 |
} |
237 |
} |
207 |
else { |
238 |
else { |
208 |
$item->store->discard_changes; |
239 |
$item->store->discard_changes; |
|
|
240 |
add_item_to_volume( $item->biblionumber, $item->biblioitemnumber, $volume, $volume_description ); |
209 |
|
241 |
|
210 |
# This is a bit tricky : if there is a cookie for the last created item and |
242 |
# This is a bit tricky : if there is a cookie for the last created item and |
211 |
# we just added an item, the cookie value is not correct yet (it will be updated |
243 |
# we just added an item, the cookie value is not correct yet (it will be updated |
Lines 315-320
if ($op eq "additem") {
Link Here
|
315 |
{ skip_record_index => 1 } ); |
347 |
{ skip_record_index => 1 } ); |
316 |
$current_item->discard_changes; # Cannot chain discard_changes |
348 |
$current_item->discard_changes; # Cannot chain discard_changes |
317 |
$current_item = $current_item->unblessed; |
349 |
$current_item = $current_item->unblessed; |
|
|
350 |
add_item_to_volume( $item->biblionumber, $item->biblioitemnumber, $volume, $volume_description ); |
318 |
|
351 |
|
319 |
# We count the item only if it was really added |
352 |
# We count the item only if it was really added |
320 |
# That way, all items are added, even if there was some already existing barcodes |
353 |
# That way, all items are added, even if there was some already existing barcodes |
Lines 603-612
if( my $default_location = C4::Context->preference('NewItemsDefaultLocation') )
Link Here
|
603 |
$location_field->{marc_value}->{value} ||= $default_location; |
636 |
$location_field->{marc_value}->{value} ||= $default_location; |
604 |
} |
637 |
} |
605 |
|
638 |
|
|
|
639 |
my @ig = Koha::Biblio::ItemGroups->search({ biblio_id => $biblionumber })->as_list(); |
606 |
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. |
640 |
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. |
607 |
$template->param( |
641 |
$template->param( |
608 |
biblio => $biblio, |
642 |
biblio => $biblio, |
609 |
items => \@items, |
643 |
items => \@items, |
|
|
644 |
item_groups => \@ig, |
610 |
item_header_loop => \@header_value_loop, |
645 |
item_header_loop => \@header_value_loop, |
611 |
subfields => $subfields, |
646 |
subfields => $subfields, |
612 |
itemnumber => $itemnumber, |
647 |
itemnumber => $itemnumber, |