Bugzilla – Attachment 143148 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]
Add delete action to stock rotation rotas
0001-Bug-30869-Stock-rotation-rotas-cannot-be-deleted.patch (text/plain), 5.09 KB, created by
Pedro Amorim
on 2022-11-03 18:04:37 UTC
(
hide
)
Description:
Add delete action to stock rotation rotas
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2022-11-03 18:04:37 UTC
Size:
5.09 KB
patch
obsolete
>From 4f1271226d7a8fb3a3d1e35d7aa1c80d380d793e Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pjamorim91@gmail.com> >Date: Thu, 3 Nov 2022 17:00:54 -0100 >Subject: [PATCH] Bug 30869: Stock rotation rotas cannot be deleted > >"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. > >To test: >1) Enable StockRotation system preference >2) Tools > 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) Click "return to rotas" and press "Delete" >11) Verify the warning now shows, because items are attached, with the attached items count >12) Click "Delete" -> Deletion is successful > >Sponsored-by: PTFS-Europe >--- > .../prog/en/modules/tools/stockrotation.tt | 19 ++++++++++ > tools/stockrotation.pl | 36 +++++++++++++++++++ > 2 files changed, 55 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 695d9a8bed..629694701e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt >@@ -145,6 +145,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 %] >@@ -366,6 +370,21 @@ > <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 deaad70dcd..ec60a17864 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