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

(-)a/api/v1/swagger/paths/suggestions.yaml (-5 / +14 lines)
Lines 42-48 Link Here
42
          $ref: "../swagger.yaml#/definitions/error"
42
          $ref: "../swagger.yaml#/definitions/error"
43
    x-koha-authorization:
43
    x-koha-authorization:
44
      permissions:
44
      permissions:
45
        suggestions: suggestions_manage
45
        suggestions:
46
          - suggestions_manage
47
          - suggestions_delete
48
          - suggestions_create
46
  post:
49
  post:
47
    x-mojo-to: Suggestions#add
50
    x-mojo-to: Suggestions#add
48
    operationId: addSuggestions
51
    operationId: addSuggestions
Lines 101-107 Link Here
101
          $ref: "../swagger.yaml#/definitions/error"
104
          $ref: "../swagger.yaml#/definitions/error"
102
    x-koha-authorization:
105
    x-koha-authorization:
103
      permissions:
106
      permissions:
104
        suggestions: suggestions_manage
107
        suggestions: suggestions_create
105
"/suggestions/{suggestion_id}":
108
"/suggestions/{suggestion_id}":
106
  get:
109
  get:
107
    x-mojo-to: Suggestions#get
110
    x-mojo-to: Suggestions#get
Lines 140-146 Link Here
140
          $ref: "../swagger.yaml#/definitions/error"
143
          $ref: "../swagger.yaml#/definitions/error"
141
    x-koha-authorization:
144
    x-koha-authorization:
142
      permissions:
145
      permissions:
143
        suggestions: suggestions_manage
146
        suggestions:
147
          - suggestions_manage
148
          - suggestions_delete
149
          - suggestions_create
144
  put:
150
  put:
145
    x-mojo-to: Suggestions#update
151
    x-mojo-to: Suggestions#update
146
    operationId: updateSuggestion
152
    operationId: updateSuggestion
Lines 230-236 Link Here
230
          $ref: "../swagger.yaml#/definitions/error"
236
          $ref: "../swagger.yaml#/definitions/error"
231
    x-koha-authorization:
237
    x-koha-authorization:
232
      permissions:
238
      permissions:
233
        suggestions: suggestions_manage
239
        suggestions: suggestions_delete
234
/suggestions/managers:
240
/suggestions/managers:
235
  get:
241
  get:
236
    x-mojo-to: Suggestions#list_managers
242
    x-mojo-to: Suggestions#list_managers
Lines 283-286 Link Here
283
          $ref: "../swagger.yaml#/definitions/error"
289
          $ref: "../swagger.yaml#/definitions/error"
284
    x-koha-authorization:
290
    x-koha-authorization:
285
      permissions:
291
      permissions:
286
        suggestions: suggestions_manage
292
        suggestions:
293
          - suggestions_manage
294
          - suggestions_delete
295
          - 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 ( suggestion && 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 96-102 Link Here
96
[% BLOCK patron_search_table %]
96
[% BLOCK patron_search_table %]
97
97
98
    [% IF filter == 'suggestions_managers' %]
98
    [% IF filter == 'suggestions_managers' %]
99
        <div class="hint">Only staff with superlibrarian or suggestions_manage permissions are returned in the search results</div>
99
        <div class="hint">Only staff with superlibrarian or full suggestions permissions are returned in the search results</div>
100
    [% ELSIF filter == 'orders_managers' %]
100
    [% ELSIF filter == 'orders_managers' %]
101
        <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>
101
        <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>
102
    [% ELSIF filter == 'funds_owners' OR filter == 'funds_users' %]
102
    [% 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 / +154 lines)
Lines 114-121 Link Here
114
                <div class="col-md-8 col-md-offset-2">
114
                <div class="col-md-8 col-md-offset-2">
115
115
116
                    <div id="toolbar" class="btn-toolbar">
116
                    <div id="toolbar" class="btn-toolbar">
117
                        <a class="btn btn-default" id="editsuggestion" href="suggestion.pl?op=edit&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-pencil"></i> Edit</a>
117
                        [% IF CAN_user_suggestions_suggestions_manage %]
118
                        <a class="btn btn-default deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
118
                            <a class="btn btn-default" id="editsuggestion" href="suggestion.pl?op=edit&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-pencil"></i> Edit</a>
119
                        [% END %]
120
                        [% IF CAN_user_suggestions_suggestions_delete %]
121
                            <a class="btn btn-default deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
122
                        [% END %]
119
                    </div>
123
                    </div>
120
124
121
                    <fieldset class="rows">
125
                    <fieldset class="rows">
Lines 348-353 Link Here
348
                        <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>
352
                        <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>
349
                    [%  CASE 'manager_not_enough_permissions' %]
353
                    [%  CASE 'manager_not_enough_permissions' %]
350
                        <span>The manager you selected does not have sufficient permissions.</span>
354
                        <span>The manager you selected does not have sufficient permissions.</span>
355
                    [% CASE 'no_manage_permission' %]
356
                        <span>You do not have permissions to manage suggestions</span>
357
                    [% CASE 'no_create_permission' %]
358
                        <span>You do not have permissions to create suggestions</span>
359
                    [% CASE 'no_delete_permission' %]
360
                        <span>You do not have permissions to delete suggestions</span>
351
                    [% CASE %]
361
                    [% CASE %]
352
                        <span>[% m.code | html %]</span>
362
                        <span>[% m.code | html %]</span>
353
                    [% END %]
363
                    [% END %]
Lines 567-573 Link Here
567
                            <label for="managedby_name">by:</label>
577
                            <label for="managedby_name">by:</label>
568
                            <div>
578
                            <div>
569
                                <span id="managedby_name" name="managedby_name">
579
                                <span id="managedby_name" name="managedby_name">
570
                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% logged_in_user.borrowernumber | uri %]">You</a>
580
                                    [% IF CAN_user_suggestions_suggestions_manage %]
581
                                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% logged_in_user.borrowernumber | uri %]">You</a>
582
                                    [% ELSE %]
583
                                        Nobody
584
                                    [% END %]
571
                                </span>
585
                                </span>
572
                                [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %]
586
                                [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %]
573
                                    | 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 %])
587
                                    | 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 577-583 Link Here
577
                                [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %]
591
                                [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %]
578
                                    <a id="restore_previous_manager" href="#"><i class="fa fa-trash"></i> Keep existing manager</a>
592
                                    <a id="restore_previous_manager" href="#"><i class="fa fa-trash"></i> Keep existing manager</a>
579
                                [% END %]
593
                                [% END %]
580
                                <input type="hidden" name="managedby" id="managedby" value="[% logged_in_user.borrowernumber | html %]" />
594
                                
595
                                [% IF CAN_user_suggestions_suggestions_manage %]
596
                                    <input type="hidden" name="managedby" id="managedby" value="[% logged_in_user.borrowernumber | html %]" />
597
                                [% END %]
581
598
582
                                <br/>
599
                                <br/>
583
                                <label for="notify">Notify manager:</label>
600
                                <label for="notify">Notify manager:</label>
Lines 671-677 Link Here
671
688
672
        [% IF op == 'else' %]
689
        [% IF op == 'else' %]
673
            <div id="toolbar" class="btn-toolbar">
690
            <div id="toolbar" class="btn-toolbar">
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>
691
                [% IF CAN_user_suggestions_suggestions_create %]
692
                    <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>
693
                [% END %]
675
            </div>
694
            </div>
676
695
677
            <h1>Suggestions management</h1>
696
            <h1>Suggestions management</h1>
Lines 859-871 Link Here
859
                                                    </td>
878
                                                    </td>
860
                                                    <td class="actions">
879
                                                    <td class="actions">
861
                                                        <div class="btn-group dropup">
880
                                                        <div class="btn-group dropup">
862
                                                            <a class="btn btn-default btn-xs" role="button" href="suggestion.pl?suggestionid=[% s.suggestionid | html %]&amp;op=edit"><i class="fa fa-pencil"></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>
881
                                                            [% IF CAN_user_suggestions_suggestions_manage %]
882
                                                                <a class="btn btn-default btn-xs" role="button" href="suggestion.pl?suggestionid=[% s.suggestionid | html %]&amp;op=edit"><i class="fa fa-pencil"></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>
883
                                                            [% ELSIF CAN_user_suggestions_suggestions_delete %]
884
                                                                <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>
885
                                                            [% END %]
863
                                                            <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="more_actions_[% s.suggestionid | html %]">
886
                                                            <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="more_actions_[% s.suggestionid | html %]">
864
                                                                <li><a class="deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a></li>
887
                                                                [% IF CAN_user_suggestions_suggestions_delete %]
865
                                                                [% UNLESS s.archived %]
888
                                                                    <li><a class="deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a></li>
866
                                                                    <li><a class="archivesuggestion" href="suggestion.pl?op=archive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Archive</a></li>
889
                                                                [% END %]
867
                                                                [% ELSE %]
890
                                                                [% IF CAN_user_suggestions_suggestions_manage %]
868
                                                                    <li><a class="unarchivesuggestion" href="suggestion.pl?op=unarchive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Unarchive</a></li>
891
                                                                    [% UNLESS s.archived %]
892
                                                                        <li><a class="archivesuggestion" href="suggestion.pl?op=archive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Archive</a></li>
893
                                                                    [% ELSE %]
894
                                                                        <li><a class="unarchivesuggestion" href="suggestion.pl?op=unarchive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Unarchive</a></li>
895
                                                                    [% END %]
869
                                                                [% END %]
896
                                                                [% END %]
870
                                                            </ul>
897
                                                            </ul>
871
                                                        </div>
898
                                                        </div>
Lines 881-999 Link Here
881
                                        </div>
908
                                        </div>
882
                                    </div>
909
                                    </div>
883
                                    <div id="suggestions_batch_ops" class="row">
910
                                    <div id="suggestions_batch_ops" class="row">
884
                                        <div class="col-sm-4">
911
                                        [% IF CAN_user_suggestions_suggestions_manage %]
885
                                            <fieldset class="brief">
912
                                            <div class="col-sm-4">
886
                                                <div id="select-reason[% loop.index | html %]">
913
                                                <fieldset class="brief">
887
                                                    <label for="STATUSreason[% loop.index | html %]">Mark selected as: </label>
914
                                                    <div id="select-reason[% loop.index | html %]">
888
                                                    <select name="STATUS" id="STATUSreason[% loop.index | html %]">
915
                                                        <label for="STATUSreason[% loop.index | html %]">Mark selected as: </label>
889
                                                        <option value=""> -- Choose a status --</option>
916
                                                        <select name="STATUS" id="STATUSreason[% loop.index | html %]">
890
917
                                                            <option value=""> -- Choose a status --</option>
891
                                                        [% IF (statusselected_ASKED ) %]
918
892
                                                            <option value="ASKED" selected="selected">Pending</option>
919
                                                            [% IF (statusselected_ASKED ) %]
893
                                                        [% ELSE %]
920
                                                                <option value="ASKED" selected="selected">Pending</option>
894
                                                            <option value="ASKED">Pending</option>
921
                                                            [% ELSE %]
895
                                                        [% END %]
922
                                                                <option value="ASKED">Pending</option>
896
923
                                                            [% END %]
897
                                                        [% IF (statusselected_ACCEPTED ) %]
924
898
                                                            <option value="ACCEPTED" selected="selected">Accepted</option>
925
                                                            [% IF (statusselected_ACCEPTED ) %]
899
                                                        [% ELSE %]
926
                                                                <option value="ACCEPTED" selected="selected">Accepted</option>
900
                                                            <option value="ACCEPTED">Accepted</option>
927
                                                            [% ELSE %]
901
                                                        [% END %]
928
                                                                <option value="ACCEPTED">Accepted</option>
902
929
                                                            [% END %]
903
                                                        [% IF (statusselected_CHECKED ) %]
930
904
                                                            <option value="CHECKED" selected="selected">Checked</option>
931
                                                            [% IF (statusselected_CHECKED ) %]
905
                                                        [% ELSE %]
932
                                                                <option value="CHECKED" selected="selected">Checked</option>
906
                                                            <option value="CHECKED">Checked</option>
933
                                                            [% ELSE %]
907
                                                        [% END %]
934
                                                                <option value="CHECKED">Checked</option>
908
935
                                                            [% END %]
909
                                                        [% IF ( statusselected_REJECTED ) %]
936
910
                                                            <option value="REJECTED" selected="selected">Rejected</option>
937
                                                            [% IF ( statusselected_REJECTED ) %]
911
                                                        [% ELSE %]
938
                                                                <option value="REJECTED" selected="selected">Rejected</option>
912
                                                            <option value="REJECTED">Rejected</option>
939
                                                            [% ELSE %]
913
                                                        [% END %]
940
                                                                <option value="REJECTED">Rejected</option>
914
941
                                                            [% END %]
915
                                                        [% IF ( statusselected_ORDERED ) %]
942
916
                                                            <option value="ORDERED" selected="selected">Ordered</option>
943
                                                            [% IF ( statusselected_ORDERED ) %]
917
                                                        [% ELSE %]
944
                                                                <option value="ORDERED" selected="selected">Ordered</option>
918
                                                            <option value="ORDERED">Ordered</option>
945
                                                            [% ELSE %]
919
                                                        [% END %]
946
                                                                <option value="ORDERED">Ordered</option>
920
947
                                                            [% END %]
921
                                                        [% FOREACH s IN SuggestionStatuses %]
948
922
                                                            <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
949
                                                            [% FOREACH s IN SuggestionStatuses %]
923
                                                        [% END %]
950
                                                                <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
924
                                                    </select>
951
                                                            [% END %]
952
                                                        </select>
953
954
                                                        <label for="choosereason[% loop.index | html %]">with this reason:</label>
955
                                                        <select name="reason" id="choosereason[% loop.index | html %]">
956
                                                            <option value=""> -- Choose a reason -- </option>
957
                                                            [% FOREACH reasonsloo IN suggestion.reasonsloop %]
958
                                                                <option value="[% reasonsloo.lib | html %]">[% reasonsloo.lib | html %]</option>
959
                                                            [% END %]
960
                                                            <option value="other">Others...</option>
961
                                                        </select>
962
963
                                                        <span class="other_reason">
964
                                                            <input type="text" size="31" name="other_reason" placeholder="please note your reason here..." />
965
                                                            <a href="#" class="cancel_note">Cancel</a>
966
                                                        </span>
967
                                                    </div>
968
969
                                                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
970
                                                    <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
971
                                                </fieldset>
972
                                                <fieldset class="action">
973
                                                    <button type="submit" class="btn btn-primary" value="update_status">Submit</button>
974
                                                </fieldset>
975
                                            </div> <!-- /.col-sm-4 -->
976
977
                                            <div class="col-sm-2">
978
                                                <fieldset class="brief">
979
                                                    <label id="suggestion_itemtype">
980
                                                        Update item types with:
981
                                                    </label>
982
                                                    [% PROCESS 'av-build-dropbox.inc' name="suggestion_itemtype", category="SUGGEST_FORMAT", size = 20  %]
983
                                                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
984
                                                    <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
985
                                                </fieldset>
986
                                                <fieldset class="action">
987
                                                    <button type="submit" class="btn btn-primary" value="update_itemtype">Submit</button>
988
                                                </fieldset>
989
                                            </div> <!-- /.col-sm-4 -->
990
991
                                            <div class="col-sm-2">
992
                                                <fieldset class="brief">
993
                                                    <span class="label">Update manager</span>
994
                                                    <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>
995
                                                    <span id="managedby_name[% loop.count | html %]"></span>
996
                                                    <input type="hidden" name="suggestion_managedby" id="managedby[% loop.count | html %]" value="[% logged_in_user.borrowernumber | html %]" />
997
                                                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
998
                                                    <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
999
                                                </fieldset>
1000
                                                <fieldset class="action">
1001
                                                    <button type="submit" class="btn btn-primary" value="update_manager">Submit</button>
1002
                                                </fieldset>
1003
                                            </div> <!-- /.col-sm-2 -->
1004
                                        [% END %]
925
1005
926
                                                    <label for="choosereason[% loop.index | html %]">with this reason:</label>
1006
                                        [% IF CAN_user_suggestions_suggestions_delete %]
927
                                                    <select name="reason" id="choosereason[% loop.index | html %]">
1007
                                            <div class="col-sm-2">
928
                                                        <option value=""> -- Choose a reason -- </option>
1008
                                                <fieldset class="brief">
929
                                                        [% FOREACH reasonsloo IN suggestion.reasonsloop %]
1009
                                                    <span class="label">Delete selected</span>
930
                                                            <option value="[% reasonsloo.lib | html %]">[% reasonsloo.lib | html %]</option>
1010
                                                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
931
                                                        [% END %]
1011
                                                    <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
932
                                                        <option value="other">Others...</option>
1012
                                                </fieldset>
933
                                                    </select>
934
935
                                                    <span class="other_reason">
936
                                                        <input type="text" size="31" name="other_reason" placeholder="please note your reason here..." />
937
                                                        <a href="#" class="cancel_note">Cancel</a>
938
                                                    </span>
939
                                                </div>
940
941
                                                <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
942
                                                <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
943
                                            </fieldset>
944
                                            <fieldset class="action">
945
                                                <button type="submit" class="btn btn-primary" value="update_status">Submit</button>
946
                                            </fieldset>
947
                                        </div> <!-- /.col-sm-4 -->
948
949
                                        <div class="col-sm-2">
950
                                            <fieldset class="brief">
951
                                                <label id="suggestion_itemtype">
952
                                                    Update item types with:
953
                                                </label>
954
                                                [% PROCESS 'av-build-dropbox.inc' name="suggestion_itemtype", category="SUGGEST_FORMAT", size = 20  %]
955
                                                <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
956
                                                <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
957
                                            </fieldset>
958
                                            <fieldset class="action">
959
                                                <button type="submit" class="btn btn-primary" value="update_itemtype">Submit</button>
960
                                            </fieldset>
961
                                        </div> <!-- /.col-sm-4 -->
962
963
                                        <div class="col-sm-2">
964
                                            <fieldset class="brief">
965
                                                <span class="label">Update manager</span>
966
                                                <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>
967
                                                <span id="managedby_name[% loop.count | html %]"></span>
968
                                                <input type="hidden" name="suggestion_managedby" id="managedby[% loop.count | html %]" value="[% logged_in_user.borrowernumber | html %]" />
969
                                                <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
970
                                                <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
971
                                            </fieldset>
972
                                            <fieldset class="action">
973
                                                <button type="submit" class="btn btn-primary" value="update_manager">Submit</button>
974
                                            </fieldset>
975
                                        </div> <!-- /.col-sm-2 -->
976
977
                                        <div class="col-sm-2">
978
                                            <fieldset class="brief">
979
                                                <span class="label">Delete selected</span>
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="delete">Delete</button>
985
                                            </fieldset>
986
                                        </div> <!-- /.col-sm-2 -->
987
                                        <div class="col-sm-2">
988
                                            <fieldset class="brief">
989
                                                <span class="label">Archive selected</span>
990
                                                <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
991
                                                <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
992
                                                <fieldset class="action">
1013
                                                <fieldset class="action">
993
                                                    <button type="submit" class="btn btn-primary" value="archive">Archive</button>
1014
                                                    <button type="submit" class="btn btn-primary" value="delete">Delete</button>
1015
                                                </fieldset>
1016
                                            </div> <!-- /.col-sm-2 -->
1017
                                        [% END %]
1018
                                        [% IF CAN_user_suggestions_suggestions_manage %]
1019
                                            <div class="col-sm-2">
1020
                                                <fieldset class="brief">
1021
                                                    <span class="label">Archive selected</span>
1022
                                                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
1023
                                                    <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
1024
                                                    <fieldset class="action">
1025
                                                        <button type="submit" class="btn btn-primary" value="archive">Archive</button>
1026
                                                    </fieldset>
994
                                                </fieldset>
1027
                                                </fieldset>
995
                                            </fieldset>
1028
                                            </div> <!-- /.col-sm-2 -->
996
                                        </div> <!-- /.col-sm-2 -->
1029
                                        [% END %]
997
                                    </div> <!-- /.row -->
1030
                                    </div> <!-- /.row -->
998
1031
999
                                [% ELSE %]
1032
                                [% 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 120-129 my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user( Link Here
120
            template_name   => "suggestion/suggestion.tt",
120
            template_name   => "suggestion/suggestion.tt",
121
            query           => $input,
121
            query           => $input,
122
            type            => "intranet",
122
            type            => "intranet",
123
            flagsrequired   => { suggestions => 'suggestions_manage' },
123
            flagsrequired   => { suggestions => '*' },
124
        }
124
        }
125
    );
125
    );
126
126
127
my $librarian = Koha::Patrons->find($borrowernumber);
128
127
$borrowernumber = $input->param('borrowernumber') if ( $input->param('borrowernumber') );
129
$borrowernumber = $input->param('borrowernumber') if ( $input->param('borrowernumber') );
128
$template->param('borrowernumber' => $borrowernumber);
130
$template->param('borrowernumber' => $borrowernumber);
129
my $branchfilter = $input->param('branchcode') || C4::Context->userenv->{'branch'};
131
my $branchfilter = $input->param('branchcode') || C4::Context->userenv->{'branch'};
Lines 132-139 my $branchfilter = $input->param('branchcode') || C4::Context->userenv->{'branch Link Here
132
##  Operations
134
##  Operations
133
##
135
##
134
136
137
my @messages;
135
if ( $op =~ /save/i ) {
138
if ( $op =~ /save/i ) {
136
    my @messages;
137
    my $biblio = MarcRecordFromNewSuggestion({
139
    my $biblio = MarcRecordFromNewSuggestion({
138
            title => $suggestion_only->{title},
140
            title => $suggestion_only->{title},
139
            author => $suggestion_only->{author},
141
            author => $suggestion_only->{author},
Lines 192-198 if ( $op =~ /save/i ) { Link Here
192
              if exists $suggestion_only->{branchcode}
194
              if exists $suggestion_only->{branchcode}
193
              && $suggestion_only->{branchcode} eq "";
195
              && $suggestion_only->{branchcode} eq "";
194
196
195
            &ModSuggestion($suggestion_only);
197
            if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) {
198
                &ModSuggestion($suggestion_only);
199
            }
200
            else {
201
                push @messages, { type => 'error', code => 'no_manage_permission' };
202
                $template->param( messages => \@messages, );
203
            }
196
204
197
            if ( $notify ) {
205
            if ( $notify ) {
198
                my $patron = Koha::Patrons->find( $suggestion_only->{managedby} );
206
                my $patron = Koha::Patrons->find( $suggestion_only->{managedby} );
Lines 232-238 if ( $op =~ /save/i ) { Link Here
232
            }
240
            }
233
            else {
241
            else {
234
                ## Adding some informations related to suggestion
242
                ## Adding some informations related to suggestion
235
                &NewSuggestion($suggestion_only);
243
                if ( $librarian->has_permission({ 'suggestions' => 'suggestions_create' }) ) {
244
                    &NewSuggestion($suggestion_only);
245
                }
246
                else {
247
                    push @messages, { type => 'error', code => 'no_delete_permission' };
248
                    $template->param( messages => \@messages );
249
                }
236
            }
250
            }
237
            # empty fields, to avoid filter in "SearchSuggestion"
251
            # empty fields, to avoid filter in "SearchSuggestion"
238
        }
252
        }
Lines 295-311 elsif ($op eq "update_status" ) { Link Here
295
        $suggestion->{reason} = $reason;
309
        $suggestion->{reason} = $reason;
296
    }
310
    }
297
311
298
    foreach my $suggestionid (@editsuggestions) {
312
    if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) {
299
        next unless $suggestionid;
313
        foreach my $suggestionid (@editsuggestions) {
300
        $suggestion->{suggestionid} = $suggestionid;
314
            next unless $suggestionid;
301
        &ModSuggestion($suggestion);
315
            $suggestion->{suggestionid} = $suggestionid;
316
            &ModSuggestion($suggestion);
317
        }
318
        redirect_with_params($input);
319
    }
320
    else {
321
        push @messages, { type => 'error', code => 'no_manage_permission' };
322
        $template->param( messages => \@messages, );
302
    }
323
    }
303
    redirect_with_params($input);
304
}elsif ($op eq "delete" ) {
324
}elsif ($op eq "delete" ) {
305
    foreach my $delete_field (@editsuggestions) {
325
    if ( $librarian->has_permission( { 'suggestions' => 'suggestions_delete' } )
306
        &DelSuggestion( $borrowernumber, $delete_field,'intranet' );
326
      )
327
    {
328
        foreach my $delete_field (@editsuggestions) {
329
            &DelSuggestion( $borrowernumber, $delete_field, 'intranet' );
330
        }
331
        redirect_with_params($input);
332
    }
333
    else {
334
        push @messages, { type => 'error', code => 'no_delete_permission' };
335
        $template->param( messages => \@messages, );
307
    }
336
    }
308
    redirect_with_params($input);
309
}
337
}
310
elsif ($op eq "archive" ) {
338
elsif ($op eq "archive" ) {
311
    Koha::Suggestions->find($_)->update({ archived => 1 }) for @editsuggestions;
339
    Koha::Suggestions->find($_)->update({ archived => 1 }) for @editsuggestions;
Lines 318-337 elsif ($op eq "unarchive" ) { Link Here
318
    redirect_with_params($input);
346
    redirect_with_params($input);
319
}
347
}
320
elsif ( $op eq 'update_itemtype' ) {
348
elsif ( $op eq 'update_itemtype' ) {
321
    my $new_itemtype = $input->param('suggestion_itemtype');
349
    if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) {
322
    foreach my $suggestionid (@editsuggestions) {
350
        my $new_itemtype = $input->param('suggestion_itemtype');
323
        next unless $suggestionid;
351
        foreach my $suggestionid (@editsuggestions) {
324
        &ModSuggestion({ suggestionid => $suggestionid, itemtype => $new_itemtype });
352
            next unless $suggestionid;
353
            &ModSuggestion({ suggestionid => $suggestionid, itemtype => $new_itemtype });
354
        }
355
        redirect_with_params($input);
356
    }
357
    else {
358
        push @messages, { type => 'error', code => 'no_manage_permission' };
359
        $template->param( messages => \@messages, );
325
    }
360
    }
326
    redirect_with_params($input);
327
}
361
}
328
elsif ( $op eq 'update_manager' ) {
362
elsif ( $op eq 'update_manager' ) {
329
    my $managedby = $input->param('suggestion_managedby');
363
    if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) {
330
    foreach my $suggestionid (@editsuggestions) {
364
        my $managedby = $input->param('suggestion_managedby');
331
        next unless $suggestionid;
365
        foreach my $suggestionid (@editsuggestions) {
332
        &ModSuggestion({ suggestionid => $suggestionid, managedby => $managedby });
366
            next unless $suggestionid;
367
            &ModSuggestion({ suggestionid => $suggestionid, managedby => $managedby });
368
        }
369
        redirect_with_params($input);
370
    }
371
    else {
372
        push @messages, { type => 'error', code => 'no_manage_permission' };
373
        $template->param( messages => \@messages, );
333
    }
374
    }
334
    redirect_with_params($input);
335
}
375
}
336
elsif ( $op eq 'show' ) {
376
elsif ( $op eq 'show' ) {
337
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
377
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
(-)a/t/Koha/Auth/Permissions.t (-1 / +2 lines)
Lines 234-240 subtest 'superlibrarian tests' => sub { Link Here
234
        'CAN_user_stockrotation_manage_rota_items'                  => 1,
234
        'CAN_user_stockrotation_manage_rota_items'                  => 1,
235
        'CAN_user_stockrotation_manage_rotas'                       => 1,
235
        'CAN_user_stockrotation_manage_rotas'                       => 1,
236
        'CAN_user_stockrotation'                                    => 1,
236
        'CAN_user_stockrotation'                                    => 1,
237
        'CAN_user_suggestions_suggestions_create'                   => 1,
237
        'CAN_user_suggestions_suggestions_manage'                   => 1,
238
        'CAN_user_suggestions_suggestions_manage'                   => 1,
239
        'CAN_user_suggestions_suggestions_delete'                   => 1,
238
        'CAN_user_suggestions'                                      => 1,
240
        'CAN_user_suggestions'                                      => 1,
239
        'CAN_user_superlibrarian'                                   => 1,
241
        'CAN_user_superlibrarian'                                   => 1,
240
        'CAN_user_tools_access_files'                               => 1,
242
        'CAN_user_tools_access_files'                               => 1,
241
- 

Return to bug 33363