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 @@
@@ -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 %]
- |
+
+ [% 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 %]
+
+ [% END %]
+ |
+
+ [% IF readonly %]
+ [% adjustement.fund.budget_name | html %]
+ [% ELSE %]
+
- [% ELSE %]
- None
-
- [% 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
+
-
- Add an adjustment
-
-
- -
-
-
-
- [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
- [% IF reasons.0 %]
+
+ Add an adjustment
+
+
-
-
-
+ [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
+ [% IF reasons.0 %]
+ -
+
+
+
+ [% ELSE %]
+ -
+ Reason:
+ None
+
Define values in authorised value category ADJ_REASON to enable
+
+ [% END %]
+ -
+
+
+
+ -
+
+
- [% ELSE %]
-
- Reason:
- None
-
Define values in authorised value category ADJ_REASON to enable
+
+
+
- [% END %]
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
- -
-
- Cancel
-
-
-
-
-
-
-
+ -
+
+ Cancel
+
+
+
+
+
+
+
+ [% 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 %]