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

(-)a/Koha/REST/V1/Acquisitions/Funds.pm (+48 lines)
Lines 55-58 sub list { Link Here
55
    };
55
    };
56
}
56
}
57
57
58
=head3 list_owners
59
60
Return the list of possible funds' owners
61
62
=cut
63
64
sub list_owners {
65
    my $c = shift->openapi->valid_input or return;
66
67
    return try {
68
69
        my $patrons_rs = Koha::Patrons->search->filter_by_have_subpermission('acquisition.budget_modify');
70
        my $patrons    = $c->objects->search( $patrons_rs );
71
72
        return $c->render(
73
            status  => 200,
74
            openapi => $patrons
75
        );
76
    }
77
    catch {
78
        $c->unhandled_exception($_);
79
    };
80
}
81
82
=head3 list_users
83
84
Return the list of possible funds' users
85
86
=cut
87
88
sub list_users {
89
    my $c = shift->openapi->valid_input or return;
90
91
    return try {
92
93
        my $patrons_rs = Koha::Patrons->search->filter_by_have_subpermission('acquisition.budget_modify');
94
        my $patrons    = $c->objects->search( $patrons_rs );
95
96
        return $c->render(
97
            status  => 200,
98
            openapi => $patrons
99
        );
100
    }
101
    catch {
102
        $c->unhandled_exception($_);
103
    };
104
}
105
58
1;
106
1;
(-)a/admin/add_user_search.pl (-65 lines)
Lines 1-65 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright 2014 BibLibre
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI qw ( -utf8 );
23
use C4::Auth qw( get_template_and_user );
24
use C4::Output qw( output_html_with_http_headers );
25
use C4::Members;
26
27
use Koha::Patron::Categories;
28
29
my $input = CGI->new;
30
31
my $dbh = C4::Context->dbh;
32
33
my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
34
    {   template_name   => "common/patron_search.tt",
35
        query           => $input,
36
        type            => "intranet",
37
        flagsrequired   => { acquisition => 'budget_modify'  },
38
    }
39
);
40
41
my $q = $input->param('q') || '';
42
my $op = $input->param('op') || '';
43
my $selection_type = $input->param('selection_type') || 'add';
44
45
my $referer = $input->referer();
46
47
# If this script is called by admin/aqbudgets.pl
48
# the patrons to return should be superlibrarian or have the order_manage
49
# acquisition flag.
50
my $search_patrons_with_acq_perm_only =
51
    ( $referer =~ m|admin/aqbudgets.pl| )
52
        ? 1 : 0;
53
54
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
55
$template->param(
56
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
57
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
58
    columns => ['cardnumber', 'name', 'branch', 'category', 'action'],
59
    json_template => 'acqui/tables/members_results.tt',
60
    selection_type => $selection_type,
61
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
62
    categories      => $patron_categories,
63
    aaSorting       => 1,
64
);
65
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/api/v1/swagger/paths.yaml (+4 lines)
Lines 13-18 Link Here
13
  $ref: paths/acquisitions_vendors.yaml#/~1acquisitions~1vendors~1{vendor_id}
13
  $ref: paths/acquisitions_vendors.yaml#/~1acquisitions~1vendors~1{vendor_id}
14
/acquisitions/funds:
14
/acquisitions/funds:
15
  $ref: paths/acquisitions_funds.yaml#/~1acquisitions~1funds
15
  $ref: paths/acquisitions_funds.yaml#/~1acquisitions~1funds
16
/acquisitions/funds/owners:
17
  $ref: paths/acquisitions_funds.yaml#/~1acquisitions~1funds~1owners
18
/acquisitions/funds/users:
19
  $ref: paths/acquisitions_funds.yaml#/~1acquisitions~1funds~1users
16
"/article_requests/{article_request_id}":
20
"/article_requests/{article_request_id}":
17
  $ref: paths/article_requests.yaml#/~1article_requests~1{article_request_id}
21
  $ref: paths/article_requests.yaml#/~1article_requests~1{article_request_id}
18
"/biblios/{biblio_id}":
22
"/biblios/{biblio_id}":
(-)a/api/v1/swagger/paths/acquisitions_funds.yaml (+86 lines)
Lines 59-61 Link Here
59
    x-koha-authorization:
59
    x-koha-authorization:
60
      permissions:
60
      permissions:
61
        acquisition: budget_manage_all
61
        acquisition: budget_manage_all
62
/acquisitions/funds/owners:
63
  get:
64
    x-mojo-to: Acquisitions::Funds#list_owners
65
    operationId: listFundsOwners
66
    description: This resource returns a list of patron allowed to be owner of funds
67
    summary: List possibe owners for funds
68
    tags:
69
      - funds
70
    parameters:
71
      - $ref: ../parameters.yaml#/match
72
      - $ref: ../parameters.yaml#/order_by
73
      - $ref: ../parameters.yaml#/page
74
      - $ref: ../parameters.yaml#/per_page
75
      - $ref: ../parameters.yaml#/q_param
76
      - $ref: ../parameters.yaml#/q_body
77
      - $ref: ../parameters.yaml#/q_header
78
    produces:
79
      - application/json
80
    responses:
81
      "200":
82
        description: A list of funds' owners
83
        schema:
84
          type: array
85
          items:
86
            $ref: ../definitions.yaml#/patron
87
      "403":
88
        description: Access forbidden
89
        schema:
90
          $ref: ../definitions.yaml#/error
91
      "500":
92
        description: |
93
          Internal server error. Possible `error_code` attribute values:
94
95
          * `internal_server_error`
96
        schema:
97
          $ref: ../definitions.yaml#/error
98
      "503":
99
        description: Under maintenance
100
        schema:
101
          $ref: ../definitions.yaml#/error
102
    x-koha-authorization:
103
      permissions:
104
        acquisition: budget_modify
105
/acquisitions/funds/users:
106
  get:
107
    x-mojo-to: Acquisitions::Funds#list_users
108
    operationId: listFundsUsers
109
    description: This resource returns a list of patron allowed to be owner of funds
110
    summary: List possibe users for funds
111
    tags:
112
      - funds
113
    parameters:
114
      - $ref: ../parameters.yaml#/match
115
      - $ref: ../parameters.yaml#/order_by
116
      - $ref: ../parameters.yaml#/page
117
      - $ref: ../parameters.yaml#/per_page
118
      - $ref: ../parameters.yaml#/q_param
119
      - $ref: ../parameters.yaml#/q_body
120
      - $ref: ../parameters.yaml#/q_header
121
    produces:
122
      - application/json
123
    responses:
124
      "200":
125
        description: A list of funds' users
126
        schema:
127
          type: array
128
          items:
129
            $ref: ../definitions.yaml#/patron
130
      "403":
131
        description: Access forbidden
132
        schema:
133
          $ref: ../definitions.yaml#/error
134
      "500":
135
        description: |
136
          Internal server error. Possible `error_code` attribute values:
137
138
          * `internal_server_error`
139
        schema:
140
          $ref: ../definitions.yaml#/error
141
      "503":
142
        description: Under maintenance
143
        schema:
144
          $ref: ../definitions.yaml#/error
145
    x-koha-authorization:
146
      permissions:
147
        acquisition: budget_modify
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/tables/members_results.tt (-26 lines)
Lines 1-26 Link Here
1
[% USE To %]
2
{
3
    "sEcho": [% sEcho | html %],
4
    "iTotalRecords": [% iTotalRecords | html %],
5
    "iTotalDisplayRecords": [% iTotalDisplayRecords | html %],
6
    "aaData": [
7
        [% FOREACH data IN aaData %]
8
            {
9
                "dt_cardnumber":
10
                    "[% data.cardnumber | html %]",
11
                "dt_name":
12
                    "<a href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=[% data.borrowernumber | html %]\" class=\"patron_preview\" data-borrowernumber=\"[% data.borrowernumber | html %]\" style='white-space:nowrap'>[% INCLUDE 'patron-title.inc' borrowernumber = data.borrowernumber category_type = data.category_type firstname = To.json(data.firstname) surname = To.json(data.surname) othernames = To.json(data.othernames) cardnumber = data.cardnumber invert_name = 1%]</a>",
13
                "dt_branch":
14
                    "[% data.branchname | html %]",
15
                "dt_category":
16
                    "[% data.category_description | html %] <span class=\"patron_category_type\">([% data.category_type | html %])</span>",
17
                "dt_action":
18
                    [%- IF selection_type == 'select' -%]
19
                        "<a class=\"btn btn-default btn-xs select_user\" href=\"#\" data-borrowernumber=\"[% data.borrowernumber | html %]\" data-borrowerdata=\"[% To.json(data) | html %]\">Select</a><input type=\"hidden\" id=\"borrower_data[% data.borrowernumber | html %]\" name=\"borrower_data[% data.borrowernumber | html %]\" value=\"[% To.json(data) | html %]\" />"
20
                    [%- ELSE -%]
21
                        "<a href=\"#\" data-borrowernumber=\"[% data.borrowernumber | html %]\" data-firstname=\"[% data.firstname | html %]\" data-surname=\"[% data.surname | html %]\" class=\"btn btn-default btn-xs add_user\"><i class=\"fa fa-plus\"></i> Add</a>"
22
                    [%- END -%]
23
            }[% UNLESS loop.last %],[% END %]
24
        [% END %]
25
    ]
26
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-2 / +2 lines)
Lines 495-501 Link Here
495
        //<![CDATA[
495
        //<![CDATA[
496
496
497
            function userPopup() {
497
            function userPopup() {
498
                window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
498
                window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=add&filter=funds_users",
499
                    'PatronPopup',
499
                    'PatronPopup',
500
                    'width=740,height=450,location=yes,toolbar=no,'
500
                    'width=740,height=450,location=yes,toolbar=no,'
501
                    + 'scrollbars=yes,resize=yes'
501
                    + 'scrollbars=yes,resize=yes'
Lines 503-509 Link Here
503
            }
503
            }
504
504
505
            function ownerPopup() {
505
            function ownerPopup() {
506
                window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
506
                window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=select&filter=funds_owners",
507
                    'PatronPopup',
507
                    'PatronPopup',
508
                    'width=740,height=450,location=yes,toolbar=no,'
508
                    'width=740,height=450,location=yes,toolbar=no,'
509
                    + 'scrollbars=yes,resize=yes'
509
                    + 'scrollbars=yes,resize=yes'
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt (-1 / +4 lines)
Lines 169-174 Link Here
169
                        "url": '/api/v1/suggestions/managers'
169
                        "url": '/api/v1/suggestions/managers'
170
                    [% CASE 'baskets_managers' %]
170
                    [% CASE 'baskets_managers' %]
171
                        "url": '/api/v1/acquisitions/baskets/managers'
171
                        "url": '/api/v1/acquisitions/baskets/managers'
172
                    [% CASE 'funds_owners' %]
173
                        "url": '/api/v1/acquisitions/funds/owners'
174
                    [% CASE 'funds_users' %]
175
                        "url": '/api/v1/acquisitions/funds/users'
172
                    [% CASE %]
176
                    [% CASE %]
173
                        "url": '/api/v1/patrons'
177
                        "url": '/api/v1/patrons'
174
                    [% END %]
178
                    [% END %]
175
- 

Return to bug 30055