From 007a04ecd8b032cae15b2a52653a79f8ea7358d0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 10 Dec 2019 21:05:40 +0100 Subject: [PATCH] Bug 24157: New permission - edit_invoices Add a new permission to edit invoices Test plan: - Remove the new permission "edit_invoices" for a given patron, use it to log in into Koha - Create an invoice, edit it (click "detail") => You can see the detail of the invoice, but cannot edit it. It's a read-only view. - Add the permission => The form is back and you can modify the invoices and save the changes. Also, you are able to create adjustments. Sponsored-by: Galway-Mayo Institute of Technology Signed-off-by: Owen Leonard --- acqui/invoice.pl | 6 +- .../data/mysql/atomicupdate/bug_24157.perl | 8 +- installer/data/mysql/userpermissions.sql | 1 + .../prog/en/includes/permissions.inc | 5 + .../prog/en/modules/acqui/invoice.tt | 285 +++++++++++------- .../prog/en/modules/acqui/invoices.tt | 8 +- 6 files changed, 194 insertions(+), 119 deletions(-) diff --git a/acqui/invoice.pl b/acqui/invoice.pl index 5a7ce08f38..f784b3e4d0 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -53,10 +53,13 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( ); my $logged_in_patron = Koha::Patrons->find( $loggedinuser ); - my $invoiceid = $input->param('invoiceid'); my $op = $input->param('op'); +output_and_exit( $input, $cookie, $template, 'insufficient_permission' ) + if $op + && not $logged_in_patron->has_permission( { acquisition => 'edit_invoices' } ); + my $invoice_files; if ( C4::Context->preference('AcqEnableFiles') ) { $invoice_files = Koha::Misc::Files->new( @@ -242,6 +245,7 @@ $template->param( invoiceincgst => $bookseller->invoiceincgst, currency => Koha::Acquisition::Currencies->get_active, budgets => $budget_loop, + budget => GetBudget( $shipmentcost_budgetid ), ); defined( $invoice_files ) && $template->param( files => $invoice_files->GetFilesInfo() ); diff --git a/installer/data/mysql/atomicupdate/bug_24157.perl b/installer/data/mysql/atomicupdate/bug_24157.perl index 60536820ea..f03c3a37de 100644 --- a/installer/data/mysql/atomicupdate/bug_24157.perl +++ b/installer/data/mysql/atomicupdate/bug_24157.perl @@ -5,6 +5,12 @@ if( CheckVersion( $DBversion ) ) { (11, 'reopen_closed_invoices', 'Reopen closed invoices') |); + $dbh->do(q| + INSERT IGNORE INTO permissions (module_bit, code, description) VALUES + (11, 'edit_invoices', 'Edit invoices') + |); + + SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 24157: Add new permission reopen_closed_invoices)\n"; + print "Upgrade to $DBversion done (Bug 24157: Add new permissions reopen_closed_invoices, edit_invoices)\n"; } diff --git a/installer/data/mysql/userpermissions.sql b/installer/data/mysql/userpermissions.sql index 67e2c67ba0..201fb6c509 100644 --- a/installer/data/mysql/userpermissions.sql +++ b/installer/data/mysql/userpermissions.sql @@ -66,6 +66,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'budget_manage_all', 'Manage all funds'), (11, 'edi_manage', 'Manage EDIFACT transmissions'), (11, 'reopen_closed_invoices', 'Reopen closed invoices'), + (11, 'edit_invoices', 'Edit invoices'), (12, 'suggestions_manage', 'Manage purchase suggestions'), (13, 'edit_news', 'Write news for the OPAC and staff interfaces'), (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index e64d5f08f3..20d9d497f1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -695,6 +695,11 @@ Reopen closed invoices ([% name | html %]) + [%- CASE 'edit_invoices' -%] + + Edit invoices + + ([% name | html %]) [%# self_check %] [%- CASE 'self_checkin_module' -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt index fd7ed12a6a..f710d384a0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt @@ -36,42 +36,63 @@
  1. - [% IF readonly %] + [% invoicenumber | html %] [% ELSE %] + Required [% END %]
  2. -
  3. -
  4. - -
  5. -
  6. - -
  7. -
  8. +
  9. + + [% IF readonly %] + [% shipmentdate | $KohaDates %] + [% ELSE %] + + [% END %] +
  10. -
  11. - - [% END %] - - - +
  12. - +
  13. + + [% IF readonly %] + [% shipmentcost | $Price %] + [% ELSE %] + + [% END %] +
  14. +
  15. + + [% IF readonly %] + [% budget.budget_name | html %] + [% ELSE %] + + + + [% END %] +
  16. [% IF ( invoiceclosedate ) %]
  17. Status: @@ -79,20 +100,21 @@
  18. - [% IF CAN_user_acquisition_reopen_closed_invoices %] + [% IF CAN_user_acquisition_reopen_closed_invoices AND NOT readonly %] [% ELSE %] - + [% END %]
  19. [% ELSE %]
  20. Status: Open
  21. -
  22. -
  23. +
  24. +
  25. [% END %]
+ [% UNLESS readonly %]
@@ -101,6 +123,7 @@ Delete [% END %]
+ [% END %]
@@ -120,128 +143,160 @@ Note Fund Encumber while invoice open -   + [% UNLESS readonly %] [% END %] [% total_adj = 0 %] [% FOREACH adjustment IN adjustments %] [% total_adj = total_adj + adjustment.adjustment %] [% adjustment.adjustment_id | html %] - - [% reasons = AuthorisedValues.Get("ADJ_REASON") %] - [% IF reasons.0 %] - + [% END %] + + + [% IF readonly %] + [% AuthorisedValues.GetByCode('ADJ_REASON', adjustment.reason) | html %] + [% ELSE %] + [% reasons = AuthorisedValues.Get("ADJ_REASON") %] + [% IF reasons.0 %] + + + [% ELSE %] +

None

+ + [% END %] + [% END %] + + + [% IF readonly %] + [% adjustment.note | html %] [% ELSE %] -

None

- - [% END %] + + [% END %] - - - [% FOREACH budget IN budgets %] - [% IF ( budget.b_id == adjustment.budget_id ) %] - [% END %] - [% budget.b_txt | html %] - - [% END %] - + + [% END %] [% IF adjustment.encumber_open %] + [% IF readonly %] + + [% ELSE %] + [% END %] [% ELSE %] + [% IF readonly %] + + [% ELSE %] + [% END %] + + [% END %] + [% UNLESS readonly %] + + Delete [% END %] - - Delete - [% END %] [% END %] -

- Add an adjustment -

+ [% UNLESS readonly %] +

+ Add an adjustment +

- +
+ + +
+ [% END %]

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 a77339c4d4..5c574dcc95 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt @@ -85,10 +85,14 @@

  • Reopen
  • [% END %] [% ELSE %] -
  • Close
  • + [% IF CAN_user_acquisition_edit_invoices %] +
  • Close
  • + [% END %] [% END %] [% UNLESS invoice.receivedbiblios || invoice.receiveditems %] -
  • Delete
  • + [% IF CAN_user_acquisition_edit_invoices %] +
  • Delete
  • + [% END %] [% END %] -- 2.20.1