From 463a20d07d0615acab7821a0373147373d92d81b 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 +- 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 | 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 5a7ce08f38f..f784b3e4d09 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 60536820ea8..f03c3a37dee 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 b5c94fb1b8a..abb9e68d4f1 100644 --- a/installer/data/mysql/userpermissions.sql +++ b/installer/data/mysql/userpermissions.sql @@ -64,6 +64,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 f0574412a3c..881d4fa9f29 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -672,6 +672,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 40a33b16e30..4dbf2a1c2dc 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 c314452f023..6704fb1f25a 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