use Koha::DateUtils qw( dt_from_string );
use Koha::Items;
use Koha::ItemTypes;
+use Koha::Items;
use Koha::Libraries;
use Koha::Patrons;
use Koha::SearchEngine::Indexer;
our $dbh = C4::Context->dbh;
+sub add_item_to_item_group {
+ my ( $biblionumber, $itemnumber, $item_group, $item_group_description ) = @_;
+
+ return unless $item_group;
+
+ my $item_group_id;
+ if ( $item_group eq 'create' ) {
+ my $item_group = Koha::Biblio::ItemGroup->new(
+ {
+ biblionumber => $biblionumber,
+ description => $item_group_description,
+ }
+ )->store();
+
+ $item_group_id = $item_group->id;
+ }
+ else {
+ $item_group_id = $item_group;
+ }
+
+ my $item_group_item = Koha::Biblio::ItemGroup::Item->new(
+ {
+ itemnumber => $itemnumber,
+ item_group_id => $item_group_id,
+ }
+ )->store();
+}
+
sub get_item_from_cookie {
my ( $input ) = @_;
my $fa_branch = $input->param('branch');
my $fa_stickyduedate = $input->param('stickyduedate');
my $fa_duedatespec = $input->param('duedatespec');
+my $volume = $input->param('volume');
+my $volume_description = $input->param('volume_description');
our $frameworkcode = &GetFrameworkCode($biblionumber);
}
else {
$item->store->discard_changes;
+ add_item_to_item_group( $item->biblionumber, $item->biblioitemnumber, $volume, $volume_description );
# This is a bit tricky : if there is a cookie for the last created item and
# we just added an item, the cookie value is not correct yet (it will be updated
{ skip_record_index => 1 } );
$current_item->discard_changes; # Cannot chain discard_changes
$current_item = $current_item->unblessed;
+ add_item_to_item_group( $item->biblionumber, $item->biblioitemnumber, $volume, $volume_description );
# We count the item only if it was really added
# That way, all items are added, even if there was some already existing barcodes
$location_field->{marc_value}->{value} ||= $default_location;
}
+my @ig = Koha::Biblio::ItemGroups->search({ biblio_id => $biblionumber })->as_list();
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
$template->param(
biblio => $biblio,
items => \@items,
+ item_groups => \@ig,
item_header_loop => \@header_value_loop,
subfields => $subfields,
itemnumber => $itemnumber,
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'str/cataloging_additem.inc' %]
[% Asset.js("js/cataloging_additem.js") | $raw %]
+ <script>
+ var has_item_groups = "[% item_groups.size | html %]";
+ </script>
</head>
<body id="cat_additem" class="cat">
<input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
[% END %]
+[% IF item_groups.size && op != 'saveitem' && CAN_user_editcatalogue_manage_item_groups %]
+ <fieldset class="rows">
+ <legend><i class="fa fa-plus"></i> Add to item group</legend>
+ [% FOREACH ig IN item_groups %]
+ <input type="hidden" id="item-group-[% ig.id | html %]" value="[% ig.description | html %]" />
+ [% END %]
+ <p>
+ <label for="select_item_group">Options: </label>
+ <select name="item_group" id="item-group-add-or-create-form-select">
+ <optgroup label="Use existing item group">
+ [% FOREACH ig IN item_groups %]
+ <option value="[% ig.id | html %]">Use: [% ig.description | html %]</option>
+ [% END %]
+ </optgroup>
+ <optgroup label="Other options">
+ <option id="item-group-add-or-create-form-no-add" value="">Do not add to item group</option>
+ <option value="create">Create new item group</option>
+ </optgroup>
+ </select>
+ </p>
+
+ <p id="item-group-add-or-create-form-description-block">
+ <label for="item_group_description" class="required">Name: </label>
+ <input name="item_group_description" id="item-group-add-or-create-form-description" type="text" size="30" class="required" />
+ <span class="required">Required</span>
+ </p>
+ </fieldset>
+[% END %]
+
<fieldset class="action"> [% IF op != 'saveitem' %]
<input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
<!-- Note : We use here a false submit button because we have several submit buttons and we don't want the user to believe they validated the adding of multiple items
</div> <!-- /.col-sm-12 -->
</div> <!-- /.row -->
+[% MACRO jsinclude BLOCK %]
+[% END %]
+
[% INCLUDE 'intranet-bottom.inc' %]
multiCopyControl.toggle();
});
+ // Add new item to an item group
+ if ( has_item_groups ) {
+ $('#item-group-add-or-create-form-description-block').hide();
+ $('#item-group-add-or-create-form-no-add').attr('selected', 'selected' );
+
+ $('#item-group-add-or-create-form-select').on('change', function(){
+ if ( $(this).val() == 'create' ) {
+ $('#item-group-add-or-create-form-description')
+ .addClass('required')
+ .attr( 'required', 'required' );
+ $('#item-group-add-or-create-form-description-block').show();
+ } else {
+ $('#item-group-add-or-create-form-description')
+ .removeClass('required')
+ .removeAttr('required');
+ $('#item-group-add-or-create-form-description-block').hide();
+ }
+ });
+ }
+
+ $('#item-group-add-or-create-form-select').on('change', function() {
+ if ( ! $('input.items-enumchron').val() ) {
+ let item_group_selector = '#item-group-' + $(this).val();
+ let enumchron = $(item_group_selector).val();
+ $('input.items-enumchron').val( enumchron );
+ }
+ });
});
function Check(f) {