Bug 24279: Disable editing lost status in items editor if item is a return claim

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Kyle Hall 2020-07-24 07:26:14 -04:00 committed by Jonathan Druart
parent 6fa926be88
commit 330c51c272
2 changed files with 18 additions and 13 deletions

View file

@ -107,7 +107,7 @@ sub _increment_barcode {
sub generate_subfield_form {
my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $biblionumber, $temp, $loop_data, $i, $restrictededition) = @_;
my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $biblionumber, $temp, $loop_data, $i, $restrictededition, $item) = @_;
my $frameworkcode = &GetFrameworkCode($biblionumber);
@ -171,13 +171,18 @@ sub generate_subfield_form {
my %authorised_lib;
# builds list, depending on authorised value...
if ( $subfieldlib->{authorised_value} eq "LOST" ) {
$subfield_data{IS_LOST_AV} = 1;
push @authorised_values, qq{};
my $av = GetAuthorisedValues( $subfieldlib->{authorised_value} );
for my $r ( @$av ) {
push @authorised_values, $r->{authorised_value};
$authorised_lib{$r->{authorised_value}} = $r->{lib};
}
my $ClaimReturnedLostValue = C4::Context->preference('ClaimReturnedLostValue');
my $item_is_return_claim = $ClaimReturnedLostValue && $item && $item->itemlost && $ClaimReturnedLostValue eq $item->itemlost;
$subfield_data{IS_RETURN_CLAIM} = $item_is_return_claim;
$subfield_data{IS_LOST_AV} = 1;
push @authorised_values, qq{};
my $av = GetAuthorisedValues( $subfieldlib->{authorised_value} );
for my $r ( @$av ) {
push @authorised_values, $r->{authorised_value};
$authorised_lib{$r->{authorised_value}} = $r->{lib};
}
}
elsif ( $subfieldlib->{authorised_value} eq "branches" ) {
foreach my $thisbranch (@$branches) {
@ -918,6 +923,8 @@ for my $library ( @$libraries ) {
$library->{selected} = 1 if $library->{branchcode} eq $branch
}
my $item = Koha::Items->find($itemnumber);
# We generate form, from actuel record
@fields = ();
if($itemrecord){
@ -931,7 +938,7 @@ if($itemrecord){
next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $libraries, $biblionumber, $temp, \@loop_data, $i, $restrictededition);
my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $libraries, $biblionumber, $temp, \@loop_data, $i, $restrictededition, $item);
push @fields, "$tag$subfieldtag";
push (@loop_data, $subfield_data);
$i++;
@ -955,7 +962,7 @@ foreach my $tag ( keys %{$tagslib}){
my @values = (undef);
@values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)) && defined($itemrecord->field($tag)->subfield($subtag)));
for my $value (@values){
my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $libraries, $biblionumber, $temp, \@loop_data, $i, $restrictededition);
my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $libraries, $biblionumber, $temp, \@loop_data, $i, $restrictededition, $item);
push (@loop_data, $subfield_data);
$i++;
}
@ -963,8 +970,6 @@ foreach my $tag ( keys %{$tagslib}){
}
@loop_data = sort {$a->{subfield} cmp $b->{subfield} } @loop_data;
my $item = Koha::Items->find($itemnumber); # We certainly want to fetch it earlier
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
$template->param(
biblionumber => $biblionumber,

View file

@ -157,7 +157,7 @@
[% IF ( mv.type == 'hidden' ) %]
<input type="hidden" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]">
[% ELSIF ( mv.type == 'select' ) %]
[% IF ( mv.readonly ) %]
[% IF ( mv.readonly || ite.IS_RETURN_CLAIM ) %]
<select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
[% ELSE %]
<select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor">