Bug 22927: Do not check an already lost item when marked as withdrawn or damaged
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Sat, 8 Jun 2019 20:34:24 +0000 (15:34 -0500)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 9 Oct 2019 13:29:53 +0000 (14:29 +0100)
Due to how moredetail.pl was written it was hard to know which action
was triggered.

Test plan:
- Set MarkLostItemsAsReturned to "from the items tab of the catalog
module."
- Check an item out to a patron
- Use additem.pl to set that item to a lost status without returning it
- go to moredetail.pl for that item
- mark item as either damaged or withdrawn without interacting with the
lost dropdown
- note that item has not been returned

Note for QA: Maybe we could have just tested if exists $item_changes->{'itemlost'}
to call LostItem

Signed-off-by: Claudie Trégouët <claudie.tregouet@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

catalogue/updateitem.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt

index 7924b2b..6c6bd29 100755 (executable)
@@ -31,6 +31,7 @@ my $cgi= new CGI;
 
 checkauth($cgi, 0, {circulate => 'circulate_remaining_permissions'}, 'intranet');
 
+my $op = $cgi->param('op') || "";
 my $biblionumber=$cgi->param('biblionumber');
 my $itemnumber=$cgi->param('itemnumber');
 my $biblioitemnumber=$cgi->param('biblioitemnumber');
@@ -55,22 +56,22 @@ for ($damaged,$itemlost,$withdrawn) {
 
 # modify MARC item if input differs from items table.
 my $item_changes = {};
-if (defined $itemnotes_nonpublic) { # i.e., itemnotes_nonpublic parameter passed from form
+if ( $op eq "set_non_public_note" ) {
     checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
     if ((not defined  $item_data_hashref->{'itemnotes_nonpublic'}) or $itemnotes_nonpublic ne $item_data_hashref->{'itemnotes_nonpublic'}) {
         $item_changes->{'itemnotes_nonpublic'} = $itemnotes_nonpublic;
     }
 }
-elsif (defined $itemnotes) { # i.e., itemnotes parameter passed from form
+elsif ( $op eq "set_public_note" ) { # i.e., itemnotes parameter passed from form
     checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
     if ((not defined  $item_data_hashref->{'itemnotes'}) or $itemnotes ne $item_data_hashref->{'itemnotes'}) {
         $item_changes->{'itemnotes'} = $itemnotes;
     }
-} elsif ($itemlost ne $item_data_hashref->{'itemlost'}) {
+} elsif ( $op eq "set_lost" && $itemlost ne $item_data_hashref->{'itemlost'}) {
     $item_changes->{'itemlost'} = $itemlost;
-} elsif ($withdrawn ne $item_data_hashref->{'withdrawn'}) {
+} elsif ( $op eq "set_withdrawn" && $withdrawn ne $item_data_hashref->{'withdrawn'}) {
     $item_changes->{'withdrawn'} = $withdrawn;
-} elsif ($damaged ne $item_data_hashref->{'damaged'}) {
+} elsif ( $op eq "set_damaged" && $damaged ne $item_data_hashref->{'damaged'}) {
     $item_changes->{'damaged'} = $damaged;
 } else {
     #nothings changed, so do nothing.
@@ -80,6 +81,6 @@ elsif (defined $itemnotes) { # i.e., itemnotes parameter passed from form
 
 ModItem($item_changes, $biblionumber, $itemnumber);
 
-LostItem($itemnumber, 'moredetail') if $itemlost;
+LostItem($itemnumber, 'moredetail') if $op eq "set_lost";
 
 print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
index 777f866..0a6d060 100644 (file)
                             [% END %]
                         [% END %]
                         </select>
-                        <input type="hidden" name="withdrawn" value="[% ITEM_DAT.withdrawn | html %]" />
-                        <input type="hidden" name="damaged" value="[% ITEM_DAT.damaged | html %]" />
+                        <input type="hidden" name="op" value="set_lost" />
                         <input type="submit" name="submit" class="submit" value="Set status" /></form>
                     [% ELSE %]
                         [% FOREACH itemlostloo IN itemlostloop %]
                 [% END %]
             [% END %]
                     </select>
-                    <input type="hidden" name="withdrawn" value="[% ITEM_DAT.withdrawn | html %]" />
-                    <input type="hidden" name="itemlost" value="[% ITEM_DAT.itemlost | html %]" />
+                    <input type="hidden" name="op" value="set_damaged" />
                     <input type="submit" name="submit" class="submit" value="Set status" /></form>
                 [% ELSE %]
                     [% FOREACH itemdamagedloo IN itemdamagedloop %]
                                     [% END %]
                                 [% END %]
                             </select>
-                            <input type="hidden" name="itemlost" value="[% ITEM_DAT.itemlost | html %]" />
-                            <input type="hidden" name="damaged" value="[% ITEM_DAT.damaged | html %]" />
+                            <input type="hidden" name="op" value="set_withdrawn" />
                             <input type="submit" name="submit" class="submit" value="Set status" /></form>
                     [% ELSE %]
                         [% FOREACH itemwithdrawn IN itemwithdrawnloop %]
                     [% IF ( CAN_user_editcatalogue_edit_items ) %]
                     <form class="inline" action="updateitem.pl" method="post"><input type="hidden" name="biblionumber" value="[% ITEM_DAT.biblionumber | html %]" />
                         <input type="hidden" name="biblioitemnumber" value="[% ITEM_DAT.biblioitemnumber | html %]" /><input type="hidden" name="itemnumber" value="[% ITEM_DAT.itemnumber | html %]" />
+                        <input type="hidden" name="op" value="set_public_note" />
                         <textarea name="itemnotes" rows="2" cols="30">[% ITEM_DAT.itemnotes | html %]</textarea><input type="submit" name="submit" class="submit" value="Update" />
                     </form>
                     [% ELSE %]
                     [% IF ( CAN_user_editcatalogue_edit_items ) %]
                     <form class="inline" action="updateitem.pl" method="post"><input type="hidden" name="biblionumber" value="[% ITEM_DAT.biblionumber | html %]" />
                         <input type="hidden" name="biblioitemnumber" value="[% ITEM_DAT.biblioitemnumber | html %]" /><input type="hidden" name="itemnumber" value="[% ITEM_DAT.itemnumber | html %]" />
+                        <input type="hidden" name="op" value="set_non_public_note" />
                         <textarea name="itemnotes_nonpublic" rows="2" cols="30">[% ITEM_DAT.itemnotes_nonpublic | html %]</textarea><input type="submit" name="submit" class="submit" value="Update" />
                     </form>
                     [% ELSE %]