Bugzilla – Attachment 147251 Details for
Bug 30869
Stock rotation rotas cannot be deleted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30869: Add the ability to delete stock rotation rotas
Bug-30869-Add-the-ability-to-delete-stock-rotation.patch (text/plain), 5.69 KB, created by
Jonathan Druart
on 2023-02-23 15:03:44 UTC
(
hide
)
Description:
Bug 30869: Add the ability to delete stock rotation rotas
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-02-23 15:03:44 UTC
Size:
5.69 KB
patch
obsolete
>From b6212a371538f59e47ba4859378eec820a4105b1 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Fri, 13 Jan 2023 13:23:17 +0000 >Subject: [PATCH] Bug 30869: Add the ability to delete stock rotation rotas > >'At the moment, it isn't possible to delete any rotas that have 0 items linked to it. The only way to do it is in MySQL - it would be good if this was possible from the staff client.' >This patch implements this, and also implements the possibility of deleting a rota with items linked to it, providing a warning that the item(s) currently in rotation will remain at its/their current stage library. > >Test plan: >1) Enable StockRotation system preference >2) Cataloging > Stock rotation > New rota >3) Enter Name, save >4) Verify 'Delete' button shows on the right >5) Click 'Delete' -> Confirm 'Yes' >6) Repeat steps 1-3 and click 'Manage'->'Stages' >7) Add a new stage, enter Library and Duration, click 'Save' >8) Return to rotas, click 'Manage'->'Items' >9) Add item, enter barcode, click 'Save' (optional: add more than 1 item) >10) Optional: Click 'Move to next stage' and verify that item is now in different branch >11) Click 'return to rotas' and press 'Delete' >12) Verify the warning now shows, because items are attached, with the attached items count >13) Click 'Delete' -> Deletion is successful >14) If you did step 10, verify the item is still in the branch that it was at the time the rota was deleted > >Sponsored-by: PTFS-Europe > >Signed-off-by: David Nind <david@davidnind.com> > >JD Amended patch: >* Fix QA failures > FAIL forbidden patterns > forbidden pattern: tab char (line 150) > forbidden pattern: tab char (line 151) >* Adjust commit message to describe what the patch does >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../prog/en/modules/tools/stockrotation.tt | 20 +++++++++++ > tools/stockrotation.pl | 36 +++++++++++++++++++ > 2 files changed, 56 insertions(+) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt >index 1db4229438e..a7f58583abb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt >@@ -146,6 +146,10 @@ > Deactivate > [% END %] > </a> >+ <a class="btn btn-default btn-xs" href="?op=confirm_delete_rota&rota_id=[% rota.rota_id | uri %]"> >+ <i class="fa fa-trash"></i> >+ Delete >+ </a> > </td> > </tr> > [% END %] >@@ -368,6 +372,22 @@ > <a class="btn btn-default btn-xs deny" href="?op=manage_items&rota_id=[% rota_id | uri %]"><i class="fa fa-fw fa-remove"></i>No</a> > </p> > </div> >+ [% ELSIF (op == 'confirm_delete_rota') %] >+ >+ <div class="dialog alert"> >+ <h1>Are you sure you want to delete this rota?</h1> >+ [% IF sritemstotal > 0 %] >+ [% IF sritemstotal == 1 %] >+ <p> [% sritemstotal | html %] item is still attached to this rota, that item will remain at its current stage libraries.</p> >+ [% ELSE %] >+ <p> [% sritemstotal | html %] items are still attached to this rota, those items will remain at their current stage libraries.</p> >+ [% END %] >+ [% END %] >+ <p> >+ <a class="btn btn-default btn-xs approve" href="?op=delete_rota&rota_id=[% rota_id | uri %]"><i class="fa fa-fw fa-check"></i>Yes</a> >+ <a class="btn btn-default btn-xs deny" href="/cgi-bin/koha/tools/stockrotation.pl"><i class="fa fa-fw fa-remove"></i>No</a> >+ </p> >+ </div> > [% ELSIF (op == 'confirm_delete_stage') %] > > <div class="dialog alert"> >diff --git a/tools/stockrotation.pl b/tools/stockrotation.pl >index deaad70dcdb..ec60a17864a 100755 >--- a/tools/stockrotation.pl >+++ b/tools/stockrotation.pl >@@ -193,6 +193,42 @@ if (!defined $op) { > item_id => $params{item_id} > ); > >+} elsif ($op eq 'confirm_delete_rota') { >+ >+ # Get the rota we're deleting >+ my $rota = Koha::StockRotationRotas->find($params{rota_id}); >+ >+ # Get all items on this rota, for each prefetch their >+ # stage and biblio objects >+ my $sritems = Koha::StockRotationItems->search( >+ { 'stage.rota_id' => $params{rota_id} }, >+ { >+ prefetch => { >+ stage => { >+ 'stockrotationitems' => { >+ 'itemnumber' => 'biblionumber' >+ } >+ } >+ } >+ } >+ ); >+ >+ $template->param( >+ rota_id => $params{rota_id}, >+ sritemstotal => $sritems->count, >+ op => $op >+ ); >+ >+} elsif ($op eq 'delete_rota') { >+ >+ # Get the rota we're deleting >+ my $rota = Koha::StockRotationRotas->find($params{rota_id}); >+ >+ $rota->delete; >+ >+ # Return to the rotas list >+ print $input->redirect("/cgi-bin/koha/tools/stockrotation.pl"); >+ > } elsif ($op eq 'confirm_delete_stage') { > > # Get the stage we're deleting >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30869
:
143144
|
143148
|
145275
|
145323
|
145353
| 147251