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

(-)a/C4/Utils/DataTables/Members.pm (-1 / +5 lines)
Lines 13-21 sub search { Link Here
13
    my $categorycode = $params->{categorycode};
13
    my $categorycode = $params->{categorycode};
14
    my $branchcode = $params->{branchcode};
14
    my $branchcode = $params->{branchcode};
15
    my $searchtype = $params->{searchtype};
15
    my $searchtype = $params->{searchtype};
16
    my $searchfieldstype = $params->{searchfieldstype};
16
    my $searchfieldstype = $params->{searchfieldstype} || 'standard';
17
    my $dt_params = $params->{dt_params};
17
    my $dt_params = $params->{dt_params};
18
18
19
    unless ( $searchmember ) {
20
        $searchmember = $dt_params->{sSearch};
21
    }
22
19
    my ($iTotalRecords, $iTotalDisplayRecords);
23
    my ($iTotalRecords, $iTotalDisplayRecords);
20
24
21
    # If branches are independant and user is not superlibrarian
25
    # If branches are independant and user is not superlibrarian
(-)a/acqui/aqbasketuser_search.pl (-20 / +38 lines)
Lines 1-23 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# script to find a basket user
4
5
# Copyright 2012 BibLibre SARL
6
#
7
# This file is part of Koha.
3
# This file is part of Koha.
8
#
4
#
9
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright 2014 BibLibre
10
# terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
12
# version.
13
#
6
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
7
# Koha is free software; you can redistribute it and/or modify it
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
8
# under the terms of the GNU General Public License as published by
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
17
#
11
#
18
# You should have received a copy of the GNU General Public License along
12
# Koha is distributed in the hope that it will be useful, but
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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>.
21
19
22
use Modern::Perl;
20
use Modern::Perl;
23
21
Lines 31-37 my $input = new CGI; Link Here
31
my $dbh = C4::Context->dbh;
29
my $dbh = C4::Context->dbh;
32
30
33
my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
31
my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
34
    {   template_name   => "acqui/aqbasketuser_search.tt",
32
    {   template_name   => "acqui/add_user_search.tt",
35
        query           => $input,
33
        query           => $input,
36
        type            => "intranet",
34
        type            => "intranet",
37
        authnotrequired => 0,
35
        authnotrequired => 0,
Lines 42-59 my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user( Link Here
42
my $q = $input->param('q') || '';
40
my $q = $input->param('q') || '';
43
my $op = $input->param('op') || '';
41
my $op = $input->param('op') || '';
44
42
43
my $referer = $input->referer();
44
45
# If this script is called by acqui/basket.pl
46
# the patrons to return should be superlibrarian or have the order_manage
47
# acquisition flag.
48
my $search_patrons_with_acq_perm_only =
49
    ( $referer =~ m|acqui/basket.pl| )
50
        ? 1 : 0;
51
45
if( $op eq "do_search" ) {
52
if( $op eq "do_search" ) {
46
    my $results = C4::Members::Search( $q, "surname");
53
    my $results = C4::Members::Search( $q, "surname");
47
54
48
    my @users_loop;
55
    my @users_loop;
49
    my $nresults = 0;
56
    my $nresults = 0;
50
    foreach my $res (@$results) {
57
    foreach my $res (@$results) {
51
        my $perms = haspermission( $res->{userid} );
58
        my $should_be_returned = 1;
52
        my $subperms = get_user_subpermissions( $res->{userid} );
59
60
        if ( $search_patrons_with_acq_perm_only ) {
61
            $should_be_returned = 0;
62
            my $perms = haspermission( $res->{userid} );
63
            my $subperms = get_user_subpermissions( $res->{userid} );
53
64
54
        if( $perms->{superlibrarian} == 1
65
            if( $perms->{superlibrarian} == 1
55
         || $perms->{acquisition} == 1
66
             || $perms->{acquisition} == 1
56
         || $subperms->{acquisition}->{'order_manage'} ) {
67
             || $subperms->{acquisition}->{'order_manage'} ) {
68
                $should_be_returned = 1;
69
            }
70
        }
71
        if ( $should_be_returned ) {
57
            my %row = (
72
            my %row = (
58
                borrowernumber  => $res->{borrowernumber},
73
                borrowernumber  => $res->{borrowernumber},
59
                cardnumber      => $res->{cardnumber},
74
                cardnumber      => $res->{cardnumber},
Lines 74-77 if( $op eq "do_search" ) { Link Here
74
    );
89
    );
75
}
90
}
76
91
92
$template->param(
93
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
94
);
77
output_html_with_http_headers( $input, $cookie, $template->output );
95
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/add_user_search.tt (+95 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Patron search</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
6
[% INCLUDE 'datatables.inc' %]
7
8
<script type="text/javascript">
9
//<![CDATA[
10
11
$(document).ready(function(){
12
    $("#info").hide();
13
    $("#error").hide();
14
    // Apply DataTables on the results table
15
    dtMemberResults = $("#memberresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
16
        'bServerSide': true,
17
        'sAjaxSource': "/cgi-bin/koha/svc/members/search",
18
        'fnServerData': function(sSource, aoData, fnCallback) {
19
            aoData.push({
20
                'name': 'template_path',
21
                'value': 'acqui/tables/members_results.tt',
22
            });
23
            $.ajax({
24
                'dataType': 'json',
25
                'type': 'POST',
26
                'url': sSource,
27
                'data': aoData,
28
                'success': function(json){
29
                    fnCallback(json);
30
                }
31
            });
32
        },
33
        'aoColumns':[
34
            { 'mDataProp': 'dt_cardnumber' },
35
            { 'mDataProp': 'dt_name' },
36
            { 'mDataProp': 'dt_branch' },
37
            { 'mDataProp': 'dt_category' },
38
            { 'mDataProp': 'dt_action', 'bSortable': false }
39
        ],
40
        'bAutoWidth': false,
41
        'sPaginationType': 'full_numbers',
42
        "iDisplayLength": [% Koha.Preference('PatronsPerPage') %],
43
        "bProcessing": true,
44
    }));
45
    dtMemberResults.fnAddFilters("filter", 750);
46
});
47
48
    // modify parent window owner element
49
    function add_user(borrowernumber, borrowername) {
50
        var p = window.opener;
51
        $("#info").hide();
52
        $("#error").hide();
53
        if ( p.add_user(borrowernumber, borrowername) < 0 ) {
54
            $("#error").html(_("Borrower '%s' is already in the list.").format(borrowername));
55
            $("#error").show();
56
        } else {
57
            $("#info").html(_("Borrower '%s' added.").format(borrowername));
58
            $("#info").show();
59
60
        }
61
    }
62
//]]>
63
</script>
64
65
</head>
66
<body>
67
<div id="patron_search" class="yui-t7">
68
  <div id="bd">
69
    <div class="yui-g">
70
71
        <h3>Search for patron</h3>
72
        [% IF patrons_with_acq_perm_only %]
73
            <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>
74
        [% END %]
75
76
        <div id="info" class="dialog message"></div>
77
        <div id="error" class="dialog alert"></div>
78
79
        <table id="memberresultst">
80
          <thead>
81
            <tr>
82
              <th>Card</th>
83
              <th>Name</th>
84
              <th>Library</th>
85
              <th>Category</th>
86
              <th>&nbsp;</th>
87
            </tr>
88
          </thead>
89
          <tbody></tbody>
90
        </table>
91
92
<div id="closewindow"><a href="#" class="close">Close</a></div>
93
</div>
94
</div>
95
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/aqbasketuser_search.tt (-79 lines)
Lines 1-79 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Basket User Search</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
5
<style type="text/css">
6
    #custom-doc {
7
        width:44.46em;
8
        *width:43.39em;
9
        min-width:578px;
10
        margin:auto;
11
        text-align:left;
12
    }
13
</style>
14
15
<script type="text/javascript">
16
//<![CDATA[
17
    // modify parent window owner element
18
    function add_user(borrowernumber, borrowername) {
19
        var p = window.opener;
20
        if(p.add_basket_user(borrowernumber, borrowername) < 0) {
21
            alert(_("Borrower '%s' is already in the list.").format(borrowername));
22
        }
23
    }
24
//]]>
25
</script>
26
27
</head>
28
<body>
29
<div id="custom-doc" class="yui-t7">
30
  <div id="bd">
31
    <div class="yui-g">
32
33
      <h3>Search for Basket User</h3>
34
      <form action="/cgi-bin/koha/acqui/aqbasketuser_search.pl" method="post">
35
        <fieldset>
36
          <input type="hidden" name="op" id="op" value="do_search" />
37
          <input type="text" name="q" id="q" value="[% q %]" class="focus" />
38
          <input type="submit" class="button" value="Search" />
39
        </fieldset>
40
        <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>
41
      </form>
42
43
[% IF (q) %]
44
    <p>Searched for <span class="ex">[% q %]</span>, [% nresults %] patron(s) found.</p>
45
[% END %]
46
[% IF ( users_loop ) %]
47
    <table>
48
      <thead>
49
        <tr>
50
            <th>Cardnumber</th>
51
            <th>Name</th>
52
            <th>Branch</th>
53
            <th>Categorycode</th>
54
            <th>Select?</th>
55
        </tr>
56
      </thead>
57
      <tbody>
58
        [% FOREACH user IN users_loop %]
59
          [% IF ( loop.odd ) %]
60
            <tr>
61
          [% ELSE %]
62
            <tr class="highlight">
63
          [% END %]
64
                <td>[% user.cardnumber %]</td>
65
                <td>[% user.surname %], [% user.firstname %]</td>
66
                <td>[% user.branchcode %]</td>
67
                <td>[% user.categorycode %]</td>
68
                <td>
69
                    <a style="cursor:pointer" onclick="add_user('[% user.borrowernumber %]', '[% user.firstname %] [% user.surname %]');">Add</a>
70
                </td>
71
            </tr>
72
        [% END %]
73
    </table>
74
[% END %]
75
76
<div id="closewindow"><a href="#" class="close">Close</a></div>
77
</div>
78
</div>
79
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-16 / +16 lines)
Lines 105-120 Link Here
105
        });
105
        });
106
    });
106
    });
107
107
108
    function basketUserSearchPopup(f) {
108
    function UserSearchPopup(f) {
109
        window.open(
109
        window.open(
110
            "/cgi-bin/koha/acqui/aqbasketuser_search.pl",
110
            "/cgi-bin/koha/acqui/add_user_search.pl",
111
            'BasketUserSearchPopup',
111
            'UserSearchPopup',
112
            'width=740,height=450,toolbar=no,'
112
            'width=740,height=450,toolbar=no,'
113
         );
113
         );
114
    }
114
    }
115
115
116
    function add_basket_user(borrowernumber, borrowername) {
116
    function add_user(borrowernumber, borrowername) {
117
        var ids = $("#basketusers_ids").val();
117
        var ids = $("#users_ids").val();
118
        if(ids.length > 0) {
118
        if(ids.length > 0) {
119
            ids = ids.split(':');
119
            ids = ids.split(':');
120
        } else {
120
        } else {
Lines 122-142 Link Here
122
        }
122
        }
123
        if (ids.indexOf(borrowernumber) < 0) {
123
        if (ids.indexOf(borrowernumber) < 0) {
124
            ids.push(borrowernumber);
124
            ids.push(borrowernumber);
125
            $("#basketusers_ids").val(ids.join(':'));
125
            $("#users_ids").val(ids.join(':'));
126
            var li = '<li id="user_'+borrowernumber+'">'+borrowername
126
            var li = '<li id="user_'+borrowernumber+'">'+borrowername
127
                + ' [<a style="cursor:pointer" onclick="del_basket_user('+borrowernumber+');">'
127
                + ' [<a style="cursor:pointer" onclick="del_user('+borrowernumber+');">'
128
                + _("Delete user") + '</a>]</li>';
128
                + _("Delete user") + '</a>]</li>';
129
            $("#basketusers_names").append(li);
129
            $("#users_names").append(li);
130
            return 0;
130
            return 0;
131
        }
131
        }
132
        return -1;
132
        return -1;
133
    }
133
    }
134
134
135
    function del_basket_user(borrowernumber) {
135
    function del_user(borrowernumber) {
136
      $("#user_"+borrowernumber).remove();
136
      $("#user_"+borrowernumber).remove();
137
      var ids = $("#basketusers_ids").val().split(':');
137
      var ids = $("#users_ids").val().split(':');
138
      ids.splice(ids.indexOf(borrowernumber.toString()), 1);
138
      ids.splice(ids.indexOf(borrowernumber.toString()), 1);
139
      $("#basketusers_ids").val(ids.join(':'));
139
      $("#users_ids").val(ids.join(':'));
140
    }
140
    }
141
//]]>
141
//]]>
142
</script>
142
</script>
Lines 277-294 Link Here
277
                    <form action="" method="post">
277
                    <form action="" method="post">
278
                        <span class="label">Managed by:</span>
278
                        <span class="label">Managed by:</span>
279
                        <div style="float:left">
279
                        <div style="float:left">
280
                            <ul id="basketusers_names" style="padding-left:0">
280
                            <ul id="users_names" style="padding-left:0">
281
                              [% FOREACH user IN basketusers %]
281
                              [% FOREACH user IN users %]
282
                                <li id="user_[% user.borrowernumber %]">
282
                                <li id="user_[% user.borrowernumber %]">
283
                                    [% user.firstname %] [% user.surname %]
283
                                    [% user.firstname %] [% user.surname %]
284
                                    [<a onclick="del_basket_user([% user.borrowernumber %]);" style="cursor:pointer">Delete user</a>]
284
                                    [<a onclick="del_user([% user.borrowernumber %]);" style="cursor:pointer">Delete user</a>]
285
                                </li>
285
                                </li>
286
                              [% END %]
286
                              [% END %]
287
                            </ul>
287
                            </ul>
288
                            <input type="hidden" id="basketno" name="basketno" value="[% basketno %]" />
288
                            <input type="hidden" id="basketno" name="basketno" value="[% basketno %]" />
289
                            <input type="hidden" id="basketusers_ids" name="basketusers_ids" value="[% basketusers_ids %]" />
289
                            <input type="hidden" id="users_ids" name="users_ids" value="[% users_ids %]" />
290
                            <input type="hidden" id="op" name="op" value="mod_users" />
290
                            <input type="hidden" id="op" name="op" value="mod_users" />
291
                            <input type="button" id="add_user" onclick="basketUserSearchPopup();" value="Add user" />
291
                            <input type="button" id="add_user" onclick="UserSearchPopup();" value="Add user" />
292
                            <input type="submit" value="Save changes" />
292
                            <input type="submit" value="Save changes" />
293
                        </div>
293
                        </div>
294
                    </form>
294
                    </form>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/tables/members_results.tt (+21 lines)
Line 0 Link Here
1
{
2
    "sEcho": [% sEcho %],
3
    "iTotalRecords": [% iTotalRecords %],
4
    "iTotalDisplayRecords": [% iTotalDisplayRecords %],
5
    "aaData": [
6
        [% FOREACH data IN aaData %]
7
            {
8
                "dt_cardnumber":
9
                    "[% data.cardnumber %]",
10
                "dt_name":
11
                    "<span style='white-space:nowrap'><a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=[% data.borrowernumber %]'>[% INCLUDE 'patron-title.inc' borrowernumber = data.borrowernumber category_type = data.category_type firstname = data.firstname surname = data.surname othernames = data.othernames cardnumber = data.cardnumber invert_name = 1%]</a></span>",
12
                "dt_branch":
13
                    "[% data.branchname |html %]",
14
                "dt_category":
15
                    "[% data.category_description |html %] ([% data.category_type |html %])",
16
                "dt_action":
17
                    "<a style=\"cursor:pointer\" onclick=\"add_user('[% data.borrowernumber %]', '[% data.surname %]', '[% data.firstname %]');\">Add</a>"
18
            }[% UNLESS loop.last %],[% END %]
19
        [% END %]
20
    ]
21
}
(-)a/svc/members/search (-2 / +1 lines)
Lines 43-49 my $firstletter = $input->param('firstletter'); Link Here
43
my $categorycode = $input->param('categorycode');
43
my $categorycode = $input->param('categorycode');
44
my $branchcode = $input->param('branchcode');
44
my $branchcode = $input->param('branchcode');
45
my $searchtype = $input->param('searchtype');
45
my $searchtype = $input->param('searchtype');
46
my $searchfieldstype = $input->param('searchfieldstype');
46
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
47
47
48
if ( $searchfieldstype eq "dateofbirth" ) {
48
if ( $searchfieldstype eq "dateofbirth" ) {
49
    $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
49
    $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
50
- 

Return to bug 12648