View | Details | Raw Unified | Return to bug 33363
Collapse All | Expand All

(-)a/api/v1/swagger/paths/suggestions.yaml (-5 / +14 lines)
Lines 41-47 Link Here
41
          $ref: "../swagger.yaml#/definitions/error"
41
          $ref: "../swagger.yaml#/definitions/error"
42
    x-koha-authorization:
42
    x-koha-authorization:
43
      permissions:
43
      permissions:
44
        suggestions: suggestions_manage
44
        suggestions:
45
          - suggestions_manage
46
          - suggestions_delete
47
          - suggestions_create
45
  post:
48
  post:
46
    x-mojo-to: Suggestions#add
49
    x-mojo-to: Suggestions#add
47
    operationId: addSuggestions
50
    operationId: addSuggestions
Lines 100-106 Link Here
100
          $ref: "../swagger.yaml#/definitions/error"
103
          $ref: "../swagger.yaml#/definitions/error"
101
    x-koha-authorization:
104
    x-koha-authorization:
102
      permissions:
105
      permissions:
103
        suggestions: suggestions_manage
106
        suggestions: suggestions_create
104
"/suggestions/{suggestion_id}":
107
"/suggestions/{suggestion_id}":
105
  get:
108
  get:
106
    x-mojo-to: Suggestions#get
109
    x-mojo-to: Suggestions#get
Lines 139-145 Link Here
139
          $ref: "../swagger.yaml#/definitions/error"
142
          $ref: "../swagger.yaml#/definitions/error"
140
    x-koha-authorization:
143
    x-koha-authorization:
141
      permissions:
144
      permissions:
142
        suggestions: suggestions_manage
145
        suggestions:
146
          - suggestions_manage
147
          - suggestions_delete
148
          - suggestions_create
143
  put:
149
  put:
144
    x-mojo-to: Suggestions#update
150
    x-mojo-to: Suggestions#update
145
    operationId: updateSuggestion
151
    operationId: updateSuggestion
Lines 229-235 Link Here
229
          $ref: "../swagger.yaml#/definitions/error"
235
          $ref: "../swagger.yaml#/definitions/error"
230
    x-koha-authorization:
236
    x-koha-authorization:
231
      permissions:
237
      permissions:
232
        suggestions: suggestions_manage
238
        suggestions: suggestions_delete
233
/suggestions/managers:
239
/suggestions/managers:
234
  get:
240
  get:
235
    x-mojo-to: Suggestions#list_managers
241
    x-mojo-to: Suggestions#list_managers
Lines 281-284 Link Here
281
          $ref: "../swagger.yaml#/definitions/error"
287
          $ref: "../swagger.yaml#/definitions/error"
282
    x-koha-authorization:
288
    x-koha-authorization:
283
      permissions:
289
      permissions:
284
        suggestions: suggestions_manage
290
        suggestions:
291
          - suggestions_manage
292
          - suggestions_delete
293
          - suggestions_create
(-)a/installer/data/mysql/atomicupdate/bug_33363.pl (+16 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "33363",
5
    description => "Split suggestions_manage into three separate permissions for creating, updating, and deleting suggetions",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (12, 'suggestions_create', 'Create purchase suggestions')});
11
        $dbh->do(q{INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (12, 'suggestions_delete', 'Update purchase suggestions')});
12
13
        $dbh->do(q{INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code) SELECT borrowernumber, 12, 'suggestions_create' FROM borrowers WHERE flags & (1 << 2)});
14
        $dbh->do(q{INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code) SELECT borrowernumber, 12, 'suggestions_delete' FROM borrowers WHERE flags & (1 << 2)});
15
    },
16
};
(-)a/installer/data/mysql/mandatory/userpermissions.sql (+2 lines)
Lines 83-89 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
83
   (11, 'delete_invoices', 'Delete invoices'),
83
   (11, 'delete_invoices', 'Delete invoices'),
84
   (11, 'merge_invoices', 'Merge invoices'),
84
   (11, 'merge_invoices', 'Merge invoices'),
85
   (11, 'delete_baskets', 'Delete baskets'),
85
   (11, 'delete_baskets', 'Delete baskets'),
86
   (12, 'suggestions_create', 'Create purchase suggestions'),
86
   (12, 'suggestions_manage', 'Manage purchase suggestions'),
87
   (12, 'suggestions_manage', 'Manage purchase suggestions'),
88
   (12, 'suggestions_delete', 'Delete purchase suggestions'),
87
   (13, 'edit_additional_contents', 'Write additional contents for the OPAC and staff interfaces (news and HTML customizations)'),
89
   (13, 'edit_additional_contents', 'Write additional contents for the OPAC and staff interfaces (news and HTML customizations)'),
88
   (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'),
90
   (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'),
89
   (13, 'edit_calendar', 'Define days when the library is closed'),
91
   (13, 'edit_calendar', 'Define days when the library is closed'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc (-1 / +1 lines)
Lines 5-11 Link Here
5
        <ul>
5
        <ul>
6
            <li><a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions home</a></li>
6
            <li><a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions home</a></li>
7
            [% IF ( CAN_user_acquisition_order_receive ) %]<li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>[% END %]
7
            [% IF ( CAN_user_acquisition_order_receive ) %]<li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>[% END %]
8
            [% IF ( CAN_user_suggestions_suggestions_manage ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% END %]
8
            [% IF ( suggestion && ( CAN_user_suggestions_suggestions_create || CAN_user_suggestions_suggestions_manage || CAN_user_suggestions_suggestions_delete )  )  %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% END %]
9
            <li><a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a></li>
9
            <li><a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a></li>
10
            [% IF Koha.Preference('EDIFACT') && CAN_user_acquisition_edi_manage %]
10
            [% IF Koha.Preference('EDIFACT') && CAN_user_acquisition_edi_manage %]
11
                <li><a href="/cgi-bin/koha/acqui/edifactmsgs.pl">EDIFACT messages</a></li>
11
                <li><a href="/cgi-bin/koha/acqui/edifactmsgs.pl">EDIFACT messages</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc (-1 / +1 lines)
Lines 170-176 Link Here
170
        [% END %]
170
        [% END %]
171
    [% END %]
171
    [% END %]
172
172
173
    [% IF CAN_user_suggestions_suggestions_manage %]
173
    [% IF CAN_user_suggestions_suggestions_create || CAN_user_suggestions_suggestions_manage || CAN_user_suggestions_suggestions_delete %]
174
        [% IF ( suggestionsview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=[% patron.borrowernumber | uri %]">Purchase suggestions</a></li>
174
        [% IF ( suggestionsview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=[% patron.borrowernumber | uri %]">Purchase suggestions</a></li>
175
    [% END %]
175
    [% END %]
176
    [% IF CAN_user_borrowers_edit_borrowers && useDischarge %]
176
    [% IF CAN_user_borrowers_edit_borrowers && useDischarge %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (-1 / +1 lines)
Lines 52-58 Link Here
52
                    [% IF ( CAN_user_reports ) %]
52
                    [% IF ( CAN_user_reports ) %]
53
                        <li><a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a></li>
53
                        <li><a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a></li>
54
                    [% END %]
54
                    [% END %]
55
                    [% IF ( CAN_user_suggestions_suggestions_manage ) %]
55
                    [% IF ( CAN_user_suggestions_suggestions_create || CAN_user_suggestions_suggestions_manage || CAN_user_suggestions_suggestions_delete ) %]
56
                        <li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>
56
                        <li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>
57
                    [% END %]
57
                    [% END %]
58
                    [% IF ( CAN_user_tools || CAN_user_clubs ) %]
58
                    [% IF ( CAN_user_tools || CAN_user_clubs ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-1 / +1 lines)
Lines 109-115 Link Here
109
[% BLOCK patron_search_table %]
109
[% BLOCK patron_search_table %]
110
110
111
    [% IF filter == 'suggestions_managers' %]
111
    [% IF filter == 'suggestions_managers' %]
112
        <div class="hint">Only staff with superlibrarian or suggestions_manage permissions are returned in the search results</div>
112
        <div class="hint">Only staff with superlibrarian or full suggestions permissions are returned in the search results</div>
113
    [% ELSIF filter == 'orders_managers' %]
113
    [% ELSIF filter == 'orders_managers' %]
114
        <div class="hint">Only staff with superlibrarian or acquisitions permissions (or order_manage permission if granular permissions are enabled) are returned in the search results</div>
114
        <div class="hint">Only staff with superlibrarian or acquisitions permissions (or order_manage permission if granular permissions are enabled) are returned in the search results</div>
115
    [% ELSIF filter == 'funds_owners' OR filter == 'funds_users' %]
115
    [% ELSIF filter == 'funds_owners' OR filter == 'funds_users' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc (+10 lines)
Lines 409-419 Link Here
409
            Add manual credits to a patron account
409
            Add manual credits to a patron account
410
        </span>
410
        </span>
411
        <span class="permissioncode">([% name | html %])</span>
411
        <span class="permissioncode">([% name | html %])</span>
412
    [%- CASE 'suggestions_create' -%]
413
        <span class="sub_permission suggestions_create_subpermission">
414
            Create purchase suggestions
415
        </span>
416
        <span class="permissioncode">([% name | html %])</span>
412
    [%- CASE 'suggestions_manage' -%]
417
    [%- CASE 'suggestions_manage' -%]
413
        <span class="sub_permission suggestions_manage_subpermission">
418
        <span class="sub_permission suggestions_manage_subpermission">
414
            Manage purchase suggestions
419
            Manage purchase suggestions
415
        </span>
420
        </span>
416
        <span class="permissioncode">([% name | html %])</span>
421
        <span class="permissioncode">([% name | html %])</span>
422
    [%- CASE 'suggestions_delete' -%]
423
        <span class="sub_permission suggestions_delete_subpermission">
424
            Delete purchase suggestions
425
        </span>
426
        <span class="permissioncode">([% name | html %])</span>
417
    [%- CASE 'budget_add_del' -%]
427
    [%- CASE 'budget_add_del' -%]
418
        <span class="sub_permission budget_add_del_subpermission">
428
        <span class="sub_permission budget_add_del_subpermission">
419
            Add and delete funds (but can't modify funds)
429
            Add and delete funds (but can't modify funds)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt (-1 / +3 lines)
Lines 38-44 Link Here
38
                <h1>Purchase suggestions</h1>
38
                <h1>Purchase suggestions</h1>
39
39
40
                <div id="toolbar" class="btn-toolbar">
40
                <div id="toolbar" class="btn-toolbar">
41
                    <a class="btn btn-default" id="newsuggestion" href="/cgi-bin/koha/suggestion/suggestion.pl?op=add&amp;suggestedby=[% patron.borrowernumber | html %]&amp;redirect=purchase_suggestions&amp;borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> New purchase suggestion</a>
41
                    [% IF CAN_user_suggestions_suggestions_create %]
42
                        <a class="btn btn-default" id="newsuggestion" href="/cgi-bin/koha/suggestion/suggestion.pl?op=add&amp;suggestedby=[% patron.borrowernumber | html %]&amp;redirect=purchase_suggestions&amp;borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> New purchase suggestion</a>
43
                    [% END %]
42
                </div>
44
                </div>
43
45
44
                [% IF suggestions.size %]
46
                [% IF suggestions.size %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-121 / +155 lines)
Lines 96-103 Link Here
96
                <div class="col-md-8 col-md-offset-2">
96
                <div class="col-md-8 col-md-offset-2">
97
97
98
                    <div id="toolbar" class="btn-toolbar">
98
                    <div id="toolbar" class="btn-toolbar">
99
                        <a class="btn btn-default" id="editsuggestion" href="suggestion.pl?op=edit&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-pencil-alt"></i> Edit</a>
99
                        [% IF CAN_user_suggestions_suggestions_manage %]
100
                        <a class="btn btn-default deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-trash-can"></i> Delete</a>
100
                            <a class="btn btn-default" id="editsuggestion" href="suggestion.pl?op=edit&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-pencil-alt"></i> Edit</a>
101
                        [% END %]
102
                        [% IF CAN_user_suggestions_suggestions_delete %]
103
                            <a class="btn btn-default deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-trash-can"></i> Delete</a>
104
                        [% END %]
101
                    </div>
105
                    </div>
102
106
103
                    <fieldset class="rows">
107
                    <fieldset class="rows">
Lines 330-335 Link Here
330
                        <span>A similar document already exists: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.id | uri %]">[% m.title | html %]</a>. Click on "Confirm your suggestion" to ignore this message.</span>
334
                        <span>A similar document already exists: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.id | uri %]">[% m.title | html %]</a>. Click on "Confirm your suggestion" to ignore this message.</span>
331
                    [%  CASE 'manager_not_enough_permissions' %]
335
                    [%  CASE 'manager_not_enough_permissions' %]
332
                        <span>The manager you selected does not have sufficient permissions.</span>
336
                        <span>The manager you selected does not have sufficient permissions.</span>
337
                    [% CASE 'no_manage_permission' %]
338
                        <span>You do not have permissions to manage suggestions</span>
339
                    [% CASE 'no_create_permission' %]
340
                        <span>You do not have permissions to create suggestions</span>
341
                    [% CASE 'no_delete_permission' %]
342
                        <span>You do not have permissions to delete suggestions</span>
333
                    [% CASE %]
343
                    [% CASE %]
334
                        <span>[% m.code | html %]</span>
344
                        <span>[% m.code | html %]</span>
335
                    [% END %]
345
                    [% END %]
Lines 549-555 Link Here
549
                            <label for="managedby_name">by:</label>
559
                            <label for="managedby_name">by:</label>
550
                            <div>
560
                            <div>
551
                                <span id="managedby_name" name="managedby_name">
561
                                <span id="managedby_name" name="managedby_name">
552
                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% logged_in_user.borrowernumber | uri %]">You</a>
562
                                    [% IF CAN_user_suggestions_suggestions_manage %]
563
                                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% logged_in_user.borrowernumber | uri %]">You</a>
564
                                    [% ELSE %]
565
                                        Nobody
566
                                    [% END %]
553
                                </span>
567
                                </span>
554
                                [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %]
568
                                [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %]
555
                                    | Previously was [% INCLUDE 'patron-title.inc' patron=managedby_patron hide_patron_infos_if_needed=1 %] [% Branches.GetName( managedby_patron.branchcode ) | html %] ([% managedby_patron.category.description | html %])
569
                                    | Previously was [% INCLUDE 'patron-title.inc' patron=managedby_patron hide_patron_infos_if_needed=1 %] [% Branches.GetName( managedby_patron.branchcode ) | html %] ([% managedby_patron.category.description | html %])
Lines 559-565 Link Here
559
                                [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %]
573
                                [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %]
560
                                    <a id="restore_previous_manager" href="#"><i class="fa fa-trash-can"></i> Keep existing manager</a>
574
                                    <a id="restore_previous_manager" href="#"><i class="fa fa-trash-can"></i> Keep existing manager</a>
561
                                [% END %]
575
                                [% END %]
562
                                <input type="hidden" name="managedby" id="managedby" value="[% logged_in_user.borrowernumber | html %]" />
576
577
                                [% IF CAN_user_suggestions_suggestions_manage %]
578
                                    <input type="hidden" name="managedby" id="managedby" value="[% logged_in_user.borrowernumber | html %]" />
579
                                [% END %]
563
580
564
                                <br/>
581
                                <br/>
565
                                <label for="notify">Notify manager:</label>
582
                                <label for="notify">Notify manager:</label>
Lines 653-659 Link Here
653
670
654
        [% IF op == 'else' %]
671
        [% IF op == 'else' %]
655
            <div id="toolbar" class="btn-toolbar">
672
            <div id="toolbar" class="btn-toolbar">
656
                <a class="btn btn-default" id="newsuggestion" href="suggestion.pl?op=add&branchcode=[% branchcode | uri %]"><i class="fa fa-plus"></i> New purchase suggestion</a>
673
                [% IF CAN_user_suggestions_suggestions_create %]
674
                    <a class="btn btn-default" id="newsuggestion" href="suggestion.pl?op=add&branchcode=[% branchcode | uri %]"><i class="fa fa-plus"></i> New purchase suggestion</a>
675
                [% END %]
657
            </div>
676
            </div>
658
677
659
            <h1>Suggestions management</h1>
678
            <h1>Suggestions management</h1>
Lines 841-853 Link Here
841
                                                    </td>
860
                                                    </td>
842
                                                    <td class="actions">
861
                                                    <td class="actions">
843
                                                        <div class="btn-group dropup">
862
                                                        <div class="btn-group dropup">
844
                                                            <a class="btn btn-default btn-xs" role="button" href="suggestion.pl?suggestionid=[% s.suggestionid | html %]&amp;op=edit"><i class="fa fa-pencil-alt"></i> Edit</a><a class="btn btn-default btn-xs dropdown-toggle" id="more_actions_[% s.suggestionid | html %]" role="button" data-toggle="dropdown" href="#"><b class="caret"></b></a>
863
                                                            [% IF CAN_user_suggestions_suggestions_manage %]
864
                                                                <a class="btn btn-default btn-xs" role="button" href="suggestion.pl?suggestionid=[% s.suggestionid | html %]&amp;op=edit"><i class="fa fa-pencil-alt"></i> Edit</a><a class="btn btn-default btn-xs dropdown-toggle" id="more_actions_[% s.suggestionid | html %]" role="button" data-toggle="dropdown" href="#"><b class="caret"></b></a>
865
                                                            [% ELSIF CAN_user_suggestions_suggestions_delete %]
866
                                                                <a class="btn btn-default btn-xs" role="button" href="suggestion.pl?op=delete&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-trash"></i>Delete</a>
867
                                                            [% END %]
845
                                                            <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="more_actions_[% s.suggestionid | html %]">
868
                                                            <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="more_actions_[% s.suggestionid | html %]">
846
                                                                <li><a class="deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-trash-can"></i> Delete</a></li>
869
                                                                [% IF CAN_user_suggestions_suggestions_delete %]
847
                                                                [% UNLESS s.archived %]
870
                                                                    <li><a class="deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-trash-can"></i> Delete</a></li>
848
                                                                    <li><a class="archivesuggestion" href="suggestion.pl?op=archive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Archive</a></li>
871
                                                                [% END %]
849
                                                                [% ELSE %]
872
                                                                [% IF CAN_user_suggestions_suggestions_manage %]
850
                                                                    <li><a class="unarchivesuggestion" href="suggestion.pl?op=unarchive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Unarchive</a></li>
873
                                                                    [% UNLESS s.archived %]
874
                                                                        <li><a class="archivesuggestion" href="suggestion.pl?op=archive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Archive</a></li>
875
                                                                    [% ELSE %]
876
                                                                        <li><a class="unarchivesuggestion" href="suggestion.pl?op=unarchive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Unarchive</a></li>
877
                                                                    [% END %]
851
                                                                [% END %]
878
                                                                [% END %]
852
                                                            </ul>
879
                                                            </ul>
853
                                                        </div>
880
                                                        </div>
Lines 862-981 Link Here
862
                                            <h2>Change selected suggestions</h2>
889
                                            <h2>Change selected suggestions</h2>
863
                                        </div>
890
                                        </div>
864
                                    </div>
891
                                    </div>
865
                                    <div class="suggestions_batch_ops row">
866
                                        <div class="col-sm-4">
867
                                            <fieldset class="brief">
868
                                                <div id="select-reason[% loop.index | html %]">
869
                                                    <label for="STATUSreason[% loop.index | html %]">Mark selected as: </label>
870
                                                    <select name="STATUS" id="STATUSreason[% loop.index | html %]">
871
                                                        <option value=""> -- Choose a status --</option>
872
873
                                                        [% IF (statusselected_ASKED ) %]
874
                                                            <option value="ASKED" selected="selected">Pending</option>
875
                                                        [% ELSE %]
876
                                                            <option value="ASKED">Pending</option>
877
                                                        [% END %]
878
892
879
                                                        [% IF (statusselected_ACCEPTED ) %]
893
                                    <div class="suggestions_batch_ops row">
880
                                                            <option value="ACCEPTED" selected="selected">Accepted</option>
894
                                        [% IF CAN_user_suggestions_suggestions_manage %]
881
                                                        [% ELSE %]
895
                                            <div class="col-sm-4">
882
                                                            <option value="ACCEPTED">Accepted</option>
896
                                                <fieldset class="brief">
883
                                                        [% END %]
897
                                                    <div id="select-reason[% loop.index | html %]">
884
898
                                                        <label for="STATUSreason[% loop.index | html %]">Mark selected as: </label>
885
                                                        [% IF (statusselected_CHECKED ) %]
899
                                                        <select name="STATUS" id="STATUSreason[% loop.index | html %]">
886
                                                            <option value="CHECKED" selected="selected">Checked</option>
900
                                                            <option value=""> -- Choose a status --</option>
887
                                                        [% ELSE %]
901
888
                                                            <option value="CHECKED">Checked</option>
902
                                                            [% IF (statusselected_ASKED ) %]
889
                                                        [% END %]
903
                                                                <option value="ASKED" selected="selected">Pending</option>
890
904
                                                            [% ELSE %]
891
                                                        [% IF ( statusselected_REJECTED ) %]
905
                                                                <option value="ASKED">Pending</option>
892
                                                            <option value="REJECTED" selected="selected">Rejected</option>
906
                                                            [% END %]
893
                                                        [% ELSE %]
907
894
                                                            <option value="REJECTED">Rejected</option>
908
                                                            [% IF (statusselected_ACCEPTED ) %]
895
                                                        [% END %]
909
                                                                <option value="ACCEPTED" selected="selected">Accepted</option>
896
910
                                                            [% ELSE %]
897
                                                        [% IF ( statusselected_ORDERED ) %]
911
                                                                <option value="ACCEPTED">Accepted</option>
898
                                                            <option value="ORDERED" selected="selected">Ordered</option>
912
                                                            [% END %]
899
                                                        [% ELSE %]
913
900
                                                            <option value="ORDERED">Ordered</option>
914
                                                            [% IF (statusselected_CHECKED ) %]
901
                                                        [% END %]
915
                                                                <option value="CHECKED" selected="selected">Checked</option>
902
916
                                                            [% ELSE %]
903
                                                        [% FOREACH s IN SuggestionStatuses %]
917
                                                                <option value="CHECKED">Checked</option>
904
                                                            <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
918
                                                            [% END %]
905
                                                        [% END %]
919
906
                                                    </select>
920
                                                            [% IF ( statusselected_REJECTED ) %]
921
                                                                <option value="REJECTED" selected="selected">Rejected</option>
922
                                                            [% ELSE %]
923
                                                                <option value="REJECTED">Rejected</option>
924
                                                            [% END %]
925
926
                                                            [% IF ( statusselected_ORDERED ) %]
927
                                                                <option value="ORDERED" selected="selected">Ordered</option>
928
                                                            [% ELSE %]
929
                                                                <option value="ORDERED">Ordered</option>
930
                                                            [% END %]
931
932
                                                            [% FOREACH s IN SuggestionStatuses %]
933
                                                                <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
934
                                                            [% END %]
935
                                                        </select>
936
937
                                                        <label for="choosereason[% loop.index | html %]">with this reason:</label>
938
                                                        <select name="reason" id="choosereason[% loop.index | html %]">
939
                                                            <option value=""> -- Choose a reason -- </option>
940
                                                            [% FOREACH reasonsloo IN suggestion.reasonsloop %]
941
                                                                <option value="[% reasonsloo.lib | html %]">[% reasonsloo.lib | html %]</option>
942
                                                            [% END %]
943
                                                            <option value="other">Others...</option>
944
                                                        </select>
945
946
                                                        <span class="other_reason">
947
                                                            <input type="text" size="31" name="other_reason" placeholder="please note your reason here..." />
948
                                                            <a href="#" class="cancel_note">Cancel</a>
949
                                                        </span>
950
                                                    </div>
951
952
                                                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
953
                                                    <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
954
                                                </fieldset>
955
                                                <fieldset class="action">
956
                                                    <button type="submit" class="btn btn-primary" value="update_status">Submit</button>
957
                                                </fieldset>
958
                                            </div> <!-- /.col-sm-4 -->
959
960
                                            <div class="col-sm-2">
961
                                                <fieldset class="brief">
962
                                                    <label id="suggestion_itemtype">
963
                                                        Update item types with:
964
                                                    </label>
965
                                                    [% PROCESS 'av-build-dropbox.inc' name="suggestion_itemtype", category="SUGGEST_FORMAT", size = 20  %]
966
                                                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
967
                                                    <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
968
                                                </fieldset>
969
                                                <fieldset class="action">
970
                                                    <button type="submit" class="btn btn-primary" value="update_itemtype">Submit</button>
971
                                                </fieldset>
972
                                            </div> <!-- /.col-sm-4 -->
973
974
                                            <div class="col-sm-2">
975
                                                <fieldset class="brief">
976
                                                    <span class="label">Update manager</span>
977
                                                    <a id="set_manager_[% loop.count | html %]" data-tab="[% loop.count | html %]" class="set_manager" href="#"><i class="fa fa-search"></i> Select manager</a>
978
                                                    <span id="managedby_name[% loop.count | html %]"></span>
979
                                                    <input type="hidden" name="suggestion_managedby" id="managedby[% loop.count | html %]" value="[% logged_in_user.borrowernumber | html %]" />
980
                                                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
981
                                                    <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
982
                                                </fieldset>
983
                                                <fieldset class="action">
984
                                                    <button type="submit" class="btn btn-primary" value="update_manager">Submit</button>
985
                                                </fieldset>
986
                                            </div> <!-- /.col-sm-2 -->
987
                                        [% END %]
907
988
908
                                                    <label for="choosereason[% loop.index | html %]">with this reason:</label>
989
                                        [% IF CAN_user_suggestions_suggestions_delete %]
909
                                                    <select name="reason" id="choosereason[% loop.index | html %]">
990
                                            <div class="col-sm-2">
910
                                                        <option value=""> -- Choose a reason -- </option>
991
                                                <fieldset class="brief">
911
                                                        [% FOREACH reasonsloo IN suggestion.reasonsloop %]
992
                                                    <span class="label">Delete selected</span>
912
                                                            <option value="[% reasonsloo.lib | html %]">[% reasonsloo.lib | html %]</option>
993
                                                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
913
                                                        [% END %]
994
                                                    <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
914
                                                        <option value="other">Others...</option>
995
                                                </fieldset>
915
                                                    </select>
916
917
                                                    <span class="other_reason">
918
                                                        <input type="text" size="31" name="other_reason" placeholder="please note your reason here..." />
919
                                                        <a href="#" class="cancel_note">Cancel</a>
920
                                                    </span>
921
                                                </div>
922
923
                                                <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
924
                                                <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
925
                                            </fieldset>
926
                                            <fieldset class="action">
927
                                                <button type="submit" class="btn btn-primary" value="update_status">Submit</button>
928
                                            </fieldset>
929
                                        </div> <!-- /.col-sm-4 -->
930
931
                                        <div class="col-sm-2">
932
                                            <fieldset class="brief">
933
                                                <label id="suggestion_itemtype">
934
                                                    Update item types with:
935
                                                </label>
936
                                                [% PROCESS 'av-build-dropbox.inc' name="suggestion_itemtype", category="SUGGEST_FORMAT", size = 20  %]
937
                                                <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
938
                                                <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
939
                                            </fieldset>
940
                                            <fieldset class="action">
941
                                                <button type="submit" class="btn btn-primary" value="update_itemtype">Submit</button>
942
                                            </fieldset>
943
                                        </div> <!-- /.col-sm-4 -->
944
945
                                        <div class="col-sm-2">
946
                                            <fieldset class="brief">
947
                                                <span class="label">Update manager</span>
948
                                                <a id="set_manager_[% loop.count | html %]" data-tab="[% loop.count | html %]" class="set_manager" href="#"><i class="fa fa-search"></i> Select manager</a>
949
                                                <span id="managedby_name[% loop.count | html %]"></span>
950
                                                <input type="hidden" name="suggestion_managedby" id="managedby[% loop.count | html %]" value="[% logged_in_user.borrowernumber | html %]" />
951
                                                <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
952
                                                <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
953
                                            </fieldset>
954
                                            <fieldset class="action">
955
                                                <button type="submit" class="btn btn-primary" value="update_manager">Submit</button>
956
                                            </fieldset>
957
                                        </div> <!-- /.col-sm-2 -->
958
959
                                        <div class="col-sm-2">
960
                                            <fieldset class="brief">
961
                                                <span class="label">Delete selected</span>
962
                                                <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
963
                                                <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
964
                                            </fieldset>
965
                                            <fieldset class="action">
966
                                                <button type="submit" class="btn btn-primary" value="delete">Delete</button>
967
                                            </fieldset>
968
                                        </div> <!-- /.col-sm-2 -->
969
                                        <div class="col-sm-2">
970
                                            <fieldset class="brief">
971
                                                <span class="label">Archive selected</span>
972
                                                <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
973
                                                <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
974
                                                <fieldset class="action">
996
                                                <fieldset class="action">
975
                                                    <button type="submit" class="btn btn-primary" value="archive">Archive</button>
997
                                                    <button type="submit" class="btn btn-primary" value="delete">Delete</button>
976
                                                </fieldset>
998
                                                </fieldset>
977
                                            </fieldset>
999
                                            </div> <!-- /.col-sm-2 -->
978
                                        </div> <!-- /.col-sm-2 -->
1000
                                        [% END %]
1001
                                        [% IF CAN_user_suggestions_suggestions_manage %]
1002
                                            <div class="col-sm-2">
1003
                                                <fieldset class="brief">
1004
                                                    <span class="label">Archive selected</span>
1005
                                                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
1006
                                                    <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
1007
                                                    <fieldset class="action">
1008
                                                        <button type="submit" class="btn btn-primary" value="archive">Archive</button>
1009
                                                    </fieldset>
1010
                                                </fieldset>
1011
                                            </div> <!-- /.col-sm-2 -->
1012
                                        [% END %]
979
                                    </div> <!-- /.row -->
1013
                                    </div> <!-- /.row -->
980
1014
981
                                [% ELSE %]
1015
                                [% ELSE %]
(-)a/members/purchase-suggestions.pl (-1 / +1 lines)
Lines 32-38 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
32
    {   template_name   => "members/purchase-suggestions.tt",
32
    {   template_name   => "members/purchase-suggestions.tt",
33
        query           => $input,
33
        query           => $input,
34
        type            => "intranet",
34
        type            => "intranet",
35
        flagsrequired   => { suggestions => 'suggestions_manage' },
35
        flagsrequired   => { suggestions => '*' },
36
    }
36
    }
37
);
37
);
38
38
(-)a/suggestion/suggestion.pl (-22 / +62 lines)
Lines 121-130 my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user( Link Here
121
            template_name   => "suggestion/suggestion.tt",
121
            template_name   => "suggestion/suggestion.tt",
122
            query           => $input,
122
            query           => $input,
123
            type            => "intranet",
123
            type            => "intranet",
124
            flagsrequired   => { suggestions => 'suggestions_manage' },
124
            flagsrequired   => { suggestions => '*' },
125
        }
125
        }
126
    );
126
    );
127
127
128
my $librarian = Koha::Patrons->find($borrowernumber);
129
128
$borrowernumber = $input->param('borrowernumber') if ( $input->param('borrowernumber') );
130
$borrowernumber = $input->param('borrowernumber') if ( $input->param('borrowernumber') );
129
$template->param('borrowernumber' => $borrowernumber);
131
$template->param('borrowernumber' => $borrowernumber);
130
my $branchfilter = $input->param('branchcode') || C4::Context->userenv->{'branch'};
132
my $branchfilter = $input->param('branchcode') || C4::Context->userenv->{'branch'};
Lines 133-140 my $branchfilter = $input->param('branchcode') || C4::Context->userenv->{'branch Link Here
133
##  Operations
135
##  Operations
134
##
136
##
135
137
138
my @messages;
136
if ( $op =~ /save/i ) {
139
if ( $op =~ /save/i ) {
137
    my @messages;
138
    my $biblio = MarcRecordFromNewSuggestion({
140
    my $biblio = MarcRecordFromNewSuggestion({
139
            title => $suggestion_only->{title},
141
            title => $suggestion_only->{title},
140
            author => $suggestion_only->{author},
142
            author => $suggestion_only->{author},
Lines 193-199 if ( $op =~ /save/i ) { Link Here
193
              if exists $suggestion_only->{branchcode}
195
              if exists $suggestion_only->{branchcode}
194
              && $suggestion_only->{branchcode} eq "";
196
              && $suggestion_only->{branchcode} eq "";
195
197
196
            &ModSuggestion($suggestion_only);
198
            if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) {
199
                &ModSuggestion($suggestion_only);
200
            }
201
            else {
202
                push @messages, { type => 'error', code => 'no_manage_permission' };
203
                $template->param( messages => \@messages, );
204
            }
197
205
198
            if ( $notify ) {
206
            if ( $notify ) {
199
                my $patron = Koha::Patrons->find( $suggestion_only->{managedby} );
207
                my $patron = Koha::Patrons->find( $suggestion_only->{managedby} );
Lines 233-239 if ( $op =~ /save/i ) { Link Here
233
            }
241
            }
234
            else {
242
            else {
235
                ## Adding some informations related to suggestion
243
                ## Adding some informations related to suggestion
236
                Koha::Suggestion->new($suggestion_only)->store();
244
                if ( $librarian->has_permission({ 'suggestions' => 'suggestions_create' }) ) {
245
                    Koha::Suggestion->new($suggestion_only)->store();
246
                }
247
                else {
248
                    push @messages, { type => 'error', code => 'no_delete_permission' };
249
                    $template->param( messages => \@messages );
250
                }
237
            }
251
            }
238
            # empty fields, to avoid filter in "SearchSuggestion"
252
            # empty fields, to avoid filter in "SearchSuggestion"
239
        }
253
        }
Lines 296-312 elsif ($op eq "update_status" ) { Link Here
296
        $suggestion->{reason} = $reason;
310
        $suggestion->{reason} = $reason;
297
    }
311
    }
298
312
299
    foreach my $suggestionid (@editsuggestions) {
313
    if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) {
300
        next unless $suggestionid;
314
        foreach my $suggestionid (@editsuggestions) {
301
        $suggestion->{suggestionid} = $suggestionid;
315
            next unless $suggestionid;
302
        &ModSuggestion($suggestion);
316
            $suggestion->{suggestionid} = $suggestionid;
317
            &ModSuggestion($suggestion);
318
        }
319
        redirect_with_params($input);
320
    }
321
    else {
322
        push @messages, { type => 'error', code => 'no_manage_permission' };
323
        $template->param( messages => \@messages, );
303
    }
324
    }
304
    redirect_with_params($input);
305
}elsif ($op eq "delete" ) {
325
}elsif ($op eq "delete" ) {
306
    foreach my $delete_field (@editsuggestions) {
326
    if ( $librarian->has_permission( { 'suggestions' => 'suggestions_delete' } )
307
        &DelSuggestion( $borrowernumber, $delete_field,'intranet' );
327
      )
328
    {
329
        foreach my $delete_field (@editsuggestions) {
330
            &DelSuggestion( $borrowernumber, $delete_field, 'intranet' );
331
        }
332
        redirect_with_params($input);
333
    }
334
    else {
335
        push @messages, { type => 'error', code => 'no_delete_permission' };
336
        $template->param( messages => \@messages, );
308
    }
337
    }
309
    redirect_with_params($input);
310
}
338
}
311
elsif ($op eq "archive" ) {
339
elsif ($op eq "archive" ) {
312
    Koha::Suggestions->find($_)->update({ archived => 1 }) for @editsuggestions;
340
    Koha::Suggestions->find($_)->update({ archived => 1 }) for @editsuggestions;
Lines 319-338 elsif ($op eq "unarchive" ) { Link Here
319
    redirect_with_params($input);
347
    redirect_with_params($input);
320
}
348
}
321
elsif ( $op eq 'update_itemtype' ) {
349
elsif ( $op eq 'update_itemtype' ) {
322
    my $new_itemtype = $input->param('suggestion_itemtype');
350
    if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) {
323
    foreach my $suggestionid (@editsuggestions) {
351
        my $new_itemtype = $input->param('suggestion_itemtype');
324
        next unless $suggestionid;
352
        foreach my $suggestionid (@editsuggestions) {
325
        &ModSuggestion({ suggestionid => $suggestionid, itemtype => $new_itemtype });
353
            next unless $suggestionid;
354
            &ModSuggestion({ suggestionid => $suggestionid, itemtype => $new_itemtype });
355
        }
356
        redirect_with_params($input);
357
    }
358
    else {
359
        push @messages, { type => 'error', code => 'no_manage_permission' };
360
        $template->param( messages => \@messages, );
326
    }
361
    }
327
    redirect_with_params($input);
328
}
362
}
329
elsif ( $op eq 'update_manager' ) {
363
elsif ( $op eq 'update_manager' ) {
330
    my $managedby = $input->param('suggestion_managedby');
364
    if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) {
331
    foreach my $suggestionid (@editsuggestions) {
365
        my $managedby = $input->param('suggestion_managedby');
332
        next unless $suggestionid;
366
        foreach my $suggestionid (@editsuggestions) {
333
        &ModSuggestion({ suggestionid => $suggestionid, managedby => $managedby });
367
            next unless $suggestionid;
368
            &ModSuggestion({ suggestionid => $suggestionid, managedby => $managedby });
369
        }
370
        redirect_with_params($input);
371
    }
372
    else {
373
        push @messages, { type => 'error', code => 'no_manage_permission' };
374
        $template->param( messages => \@messages, );
334
    }
375
    }
335
    redirect_with_params($input);
336
}
376
}
337
elsif ( $op eq 'show' ) {
377
elsif ( $op eq 'show' ) {
338
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
378
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
(-)a/t/Koha/Auth/Permissions.t (-1 / +2 lines)
Lines 235-241 subtest 'superlibrarian tests' => sub { Link Here
235
        'CAN_user_stockrotation_manage_rota_items'                  => 1,
235
        'CAN_user_stockrotation_manage_rota_items'                  => 1,
236
        'CAN_user_stockrotation_manage_rotas'                       => 1,
236
        'CAN_user_stockrotation_manage_rotas'                       => 1,
237
        'CAN_user_stockrotation'                                    => 1,
237
        'CAN_user_stockrotation'                                    => 1,
238
        'CAN_user_suggestions_suggestions_create'                   => 1,
238
        'CAN_user_suggestions_suggestions_manage'                   => 1,
239
        'CAN_user_suggestions_suggestions_manage'                   => 1,
240
        'CAN_user_suggestions_suggestions_delete'                   => 1,
239
        'CAN_user_suggestions'                                      => 1,
241
        'CAN_user_suggestions'                                      => 1,
240
        'CAN_user_superlibrarian'                                   => 1,
242
        'CAN_user_superlibrarian'                                   => 1,
241
        'CAN_user_tools_access_files'                               => 1,
243
        'CAN_user_tools_access_files'                               => 1,
242
- 

Return to bug 33363