From 766bbed921d33a4a4c28671f0e2f5d47ff5878c6 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 --- acqui/invoice.pl | 6 +- installer/data/mysql/atomicupdate/bug_24157.perl | 8 +- installer/data/mysql/userpermissions.sql | 1 + .../intranet-tmpl/prog/en/includes/permissions.inc | 5 + .../intranet-tmpl/prog/en/modules/acqui/invoice.tt | 293 ++++++++++++--------- .../prog/en/modules/acqui/invoices.tt | 8 +- 6 files changed, 198 insertions(+), 123 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 967c858b6d..df114d2311 100644 --- a/installer/data/mysql/userpermissions.sql +++ b/installer/data/mysql/userpermissions.sql @@ -61,6 +61,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'), (13, 'edit_news', 'Write news for the OPAC and staff interfaces'), (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'), (13, 'edit_calendar', 'Define days when the library is closed'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index ee7b230843..267abc3208 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -654,6 +654,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 17524fa207..04acb4128a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt @@ -36,63 +36,85 @@
  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: - Closed on [% invoiceclosedate | $KohaDates %].
  18. +
  19. Status: + Closed on [% invoiceclosedate | $KohaDates %].
  20. - [% IF CAN_user_acquisition_reopen_closed_invoices %] + [% IF CAN_user_acquisition_reopen_closed_invoices AND NOT readonly %] [% ELSE %] - + [% END %]
  21. [% ELSE %] -
  22. Status: - Open.
  23. +
  24. Status: + Open.
  25. -
  26. -
  27. +
  28. +
  29. [% 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 c314452f02..6704fb1f25 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.11.0