From 11989ad21d8bbbce3521d53eaa07933204309279 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 21 Jul 2020 11:03:07 +0200 Subject: [PATCH] Bug 24157: New permission - merge_invoices Add a new permission to merge invoices Test plan: - Remove the new permission "merge_invoices" for a given patron, use it to log in into Koha - Create 2 invoices, try to merge them => There is no way to merge it - Add the permission => Now you can merge the invoices Sponsored-by: Galway-Mayo Institute of Technology Signed-off-by: Alex Arnaud --- acqui/invoice.pl | 4 ++ installer/data/mysql/atomicupdate/bug_24157.perl | 7 +- installer/data/mysql/userpermissions.sql | 1 + .../intranet-tmpl/prog/en/includes/permissions.inc | 5 ++ .../prog/en/modules/acqui/invoices.tt | 84 ++++++++++++---------- 5 files changed, 61 insertions(+), 40 deletions(-) diff --git a/acqui/invoice.pl b/acqui/invoice.pl index a65b6d8939..00f5ff2bb0 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -103,6 +103,10 @@ elsif ( $op && $op eq 'mod' ) { } elsif ($input->param('close')) { CloseInvoice($invoiceid); } elsif ($input->param('merge')) { + + output_and_exit( $input, $cookie, $template, 'insufficient_permission' ) + unless $logged_in_patron->has_permission( { acquisition => 'merge_invoices' } ); + my @sources = $input->multi_param('merge'); MergeInvoices($invoiceid, \@sources); defined($invoice_files) && $invoice_files->MergeFileRecIds(@sources); diff --git a/installer/data/mysql/atomicupdate/bug_24157.perl b/installer/data/mysql/atomicupdate/bug_24157.perl index e7908dd179..7a7bad0327 100644 --- a/installer/data/mysql/atomicupdate/bug_24157.perl +++ b/installer/data/mysql/atomicupdate/bug_24157.perl @@ -20,6 +20,11 @@ if( CheckVersion( $DBversion ) ) { (11, 'delete_invoices', 'Delete invoices') |); + $dbh->do(q| + INSERT IGNORE INTO permissions (module_bit, code, description) VALUES + (11, 'merge_invoices', 'Merge invoices') + |); + SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 24157: Add new permissions reopen_closed_invoices, edit_invoices, delete_invoices, delete_baskets)\n"; + print "Upgrade to $DBversion done (Bug 24157: Add new permissions reopen_closed_invoices, edit_invoices, delete_invoices, merge_invoices, delete_baskets)\n"; } diff --git a/installer/data/mysql/userpermissions.sql b/installer/data/mysql/userpermissions.sql index 636b24532c..0224a56a79 100644 --- a/installer/data/mysql/userpermissions.sql +++ b/installer/data/mysql/userpermissions.sql @@ -68,6 +68,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'reopen_closed_invoices', 'Reopen closed invoices'), (11, 'edit_invoices', 'Edit invoices'), (11, 'delete_invoices', 'Delete invoices'), + (11, 'merge_invoices', 'Merge invoices'), (11, 'delete_baskets', 'Delete baskets'), (12, 'suggestions_manage', 'Manage purchase suggestions'), (13, 'edit_news', 'Write news for the OPAC and staff interfaces'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index 42dd9ca4f5..79b6560193 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -705,6 +705,11 @@ Delete invoices ([% name | html %]) + [%- CASE 'merge_invoices' -%] + + Merge invoices + + ([% name | html %]) [%- CASE 'delete_baskets' -%] Delete baskets diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt index 06d97452f2..57aeb2749b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt @@ -30,7 +30,9 @@ - + [% IF CAN_user_acquisition_merge_invoices %] + + [% END %] @@ -45,7 +47,9 @@ [% FOREACH invoice IN invoices %] - + [% IF CAN_user_acquisition_merge_invoices %] + + [% END %] @@ -101,46 +105,48 @@ [% END %]
    Invoice no. Vendor
[% invoice.is_linked_to_subscriptions | html %][% invoice.is_linked_to_subscriptions | html %] [% invoice.invoicenumber | html %] [% invoice.suppliername | html %]
- Merge selected invoices -
-
-
-
    -
  1. Merge invoices

  2. -
  3. - - - -
    Invoice no.Shipment dateBilling dateShipment cost
  4. -
  5. - - Required -
  6. -
  7. -
  8. + [% IF CAN_user_acquisition_merge_invoices %] + Merge selected invoices +
    + +
    +
      +
    1. Merge invoices

    2. +
    3. + + + +
      Invoice no.Shipment dateBilling dateShipment cost
    4. +
    5. + + Required +
    6. +
    7. +
    8. -
    9. -
    10. +
    11. +
    12. -
    13. -
    14. -
    15. -
    16. +
    17. +
    18. +
    19. +
    20. -
    21. Status:
    22. -
    23. -
    - - -
    - -
    +
  9. Status:
  10. +
  11. +
+ + +
+ +
+ [% END %] [% ELSE %]

Sorry, but there are no results for your search.

Search was: -- 2.11.0