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

(-)a/C4/Utils/DataTables/Members.pm (-1 / +1 lines)
Lines 37-43 sub search { Link Here
37
        borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode,
37
        borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode,
38
        borrowers.country, cardnumber, borrowers.dateexpiry,
38
        borrowers.country, cardnumber, borrowers.dateexpiry,
39
        borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
39
        borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
40
        borrowers.userid,
40
        borrowers.userid, borrowers.dateofbirth,
41
        categories.description AS category_description, categories.category_type,
41
        categories.description AS category_description, categories.category_type,
42
        branches.branchname";
42
        branches.branchname";
43
    my $from = "FROM borrowers
43
    my $from = "FROM borrowers
(-)a/Koha/Template/Plugin/To.pm (+33 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::To;
2
3
# This file is part of Koha.
4
#
5
# Copyright BibLibre 2014
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use base qw( Template::Plugin );
23
24
use JSON qw( to_json );
25
26
sub json {
27
    my ( $self, $value ) = @_;
28
29
    my $json = JSON->new->allow_nonref(1);
30
    return $json->encode( $value );
31
}
32
33
1;
(-)a/acqui/add_user_search.pl (+3 lines)
Lines 52-56 my $search_patrons_with_acq_perm_only = Link Here
52
$template->param(
52
$template->param(
53
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
53
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
54
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
54
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
55
    columns => ['cardnumber', 'name', 'branch', 'category', 'action'],
56
    json_template => 'acqui/tables/members_results.tt',
57
    selection_type => 'add',
55
);
58
);
56
output_html_with_http_headers( $input, $cookie, $template->output );
59
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/tables/members_results.tt (-1 / +1 lines)
Lines 14-20 Link Here
14
                "dt_category":
14
                "dt_category":
15
                    "[% data.category_description |html %] ([% data.category_type |html %])",
15
                    "[% data.category_description |html %] ([% data.category_type |html %])",
16
                "dt_action":
16
                "dt_action":
17
                    "<a style='cursor:pointer' onclick='add_user(\"[% data.borrowernumber %]\", \"[% data.firstname %] [% data.surname %]\");'>Add</a>"
17
                    "<a style='cursor:pointer' onclick='add_user(\"[% data.borrowernumber %]\", \"[% data.firstname %] [% data.surname %]\");'>Select</a>"
18
            }[% UNLESS loop.last %],[% END %]
18
            }[% UNLESS loop.last %],[% END %]
19
        [% END %]
19
        [% END %]
20
    ]
20
    ]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudget_user_search.tt (-3 / +3 lines)
Lines 22-33 Link Here
22
    //<![CDATA[
22
    //<![CDATA[
23
23
24
    // modify parent window owner element
24
    // modify parent window owner element
25
    function add_user(borrowernumber, surname, firstname) {
25
    function add_user(borrowernumber, borrowername) {
26
        [% IF (type == 'owner') %]
26
        [% IF (type == 'owner') %]
27
            top.opener.edit_owner(borrowernumber, surname, firstname);
27
            top.opener.edit_owner(borrowernumber, borrowername);
28
            window.close();
28
            window.close();
29
        [% ELSE %]
29
        [% ELSE %]
30
            var ret = top.opener.add_user(borrowernumber, surname, firstname);
30
            var ret = top.opener.add_user(borrowernumber, borrowername);
31
            if (ret != 0) {
31
            if (ret != 0) {
32
                alert(_("This user is already in the list."));
32
                alert(_("This user is already in the list."));
33
            }
33
            }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-4 / +4 lines)
Lines 31-43 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
31
        );
31
        );
32
    }
32
    }
33
33
34
    function edit_owner(borrowernumber, surname, firstname) {
34
    function edit_owner(borrowernumber, borrowername) {
35
        $('#budget_owner_name').empty();
35
        $('#budget_owner_name').empty();
36
        $('#budget_owner_id').val('');
36
        $('#budget_owner_id').val('');
37
        if (borrowernumber) {
37
        if (borrowernumber) {
38
            var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
38
            var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
39
                + '?borrowernumber=' + borrowernumber + '">'
39
                + '?borrowernumber=' + borrowernumber + '">'
40
                + firstname + ' ' + surname + '</a>';
40
                + borrowername + '</a>';
41
            $('#budget_owner_name').html(ownerlink);
41
            $('#budget_owner_name').html(ownerlink);
42
            $('#budget_owner_id').val(borrowernumber);
42
            $('#budget_owner_id').val(borrowernumber);
43
        }
43
        }
Lines 47-58 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
47
        edit_owner(0);
47
        edit_owner(0);
48
    }
48
    }
49
49
50
    function add_user(borrowernumber, surname, firstname) {
50
    function add_user(borrowernumber, borrowername) {
51
        var ids = $("#budget_users_id").val().split(':');
51
        var ids = $("#budget_users_id").val().split(':');
52
        if(borrowernumber && ids.indexOf(borrowernumber) == -1) {
52
        if(borrowernumber && ids.indexOf(borrowernumber) == -1) {
53
            var li = '<li id="user_' + borrowernumber + '">'
53
            var li = '<li id="user_' + borrowernumber + '">'
54
                + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
54
                + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
55
                + borrowernumber + '">' + firstname + ' ' + surname
55
                + borrowernumber + '">' + borrowername
56
                + '</a> [<a style="cursor:pointer"'
56
                + '</a> [<a style="cursor:pointer"'
57
                + 'onclick="del_user(' + borrowernumber +')">Remove</a>]</li>';
57
                + 'onclick="del_user(' + borrowernumber +')">Remove</a>]</li>';
58
            $(li).insertBefore("li#add_user_button");
58
            $(li).insertBefore("li#add_user_button");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt (-23 / +40 lines)
Lines 35-41 $(document).ready(function(){ Link Here
35
            },
35
            },
36
            {
36
            {
37
                'name': 'template_path',
37
                'name': 'template_path',
38
                'value': 'acqui/tables/members_results.tt',
38
                'value': '[% json_template %]',
39
            }
39
            }
40
            [% IF patrons_with_acq_perm_only %]
40
            [% IF patrons_with_acq_perm_only %]
41
            ,{
41
            ,{
Lines 55-65 $(document).ready(function(){ Link Here
55
            });
55
            });
56
        },
56
        },
57
        'aoColumns':[
57
        'aoColumns':[
58
            { 'mDataProp': 'dt_cardnumber' },
58
            [% FOR column IN columns %]
59
            { 'mDataProp': 'dt_name' },
59
                [% IF column == 'action' %]
60
            { 'mDataProp': 'dt_branch' },
60
                    { 'mDataProp': 'dt_action', 'bSortable': false }
61
            { 'mDataProp': 'dt_category' },
61
                [% ELSE %]
62
            { 'mDataProp': 'dt_action', 'bSortable': false }
62
                    { 'mDataProp': 'dt_[% column %]' }
63
                [% END %]
64
                [% UNLESS loop.last %],[% END %]
65
            [% END %]
63
        ],
66
        ],
64
        'bAutoWidth': false,
67
        'bAutoWidth': false,
65
        [% IF patrons_with_acq_perm_only %]
68
        [% IF patrons_with_acq_perm_only %]
Lines 97-115 function filter() { Link Here
97
}
100
}
98
101
99
    // modify parent window owner element
102
    // modify parent window owner element
100
    function add_user(borrowernumber, borrowername) {
103
    [% IF selection_type == 'add' %]
101
        var p = window.opener;
104
        [%# Note that add_user could sent data instead of borrowername too %]
102
        $("#info").hide();
105
        function add_user(borrowernumber, borrowername) {
103
        $("#error").hide();
106
            var p = window.opener;
104
        if ( p.add_user(borrowernumber, borrowername) < 0 ) {
107
            $("#info").hide();
105
            $("#error").html(_("Borrower '%s' is already in the list.").format(borrowername));
108
            $("#error").hide();
106
            $("#error").show();
109
            if ( p.add_user(borrowernumber, borrowername) < 0 ) {
107
        } else {
110
                $("#error").html(_("Borrower '%s' is already in the list.").format(borrowername));
108
            $("#info").html(_("Borrower '%s' added.").format(borrowername));
111
                $("#error").show();
109
            $("#info").show();
112
            } else {
110
113
                $("#info").html(_("Borrower '%s' added.").format(borrowername));
114
                $("#info").show();
115
            }
111
        }
116
        }
112
    }
117
    [% ELSIF selection_type == 'select' %]
118
        function select_user(borrowernumber, data) {
119
            var p = window.opener;
120
            p.select_user(borrowernumber, data);
121
            window.close();
122
        }
123
    [% END %]
113
//]]>
124
//]]>
114
</script>
125
</script>
115
126
Lines 135-145 function filter() { Link Here
135
            <table id="memberresultst">
146
            <table id="memberresultst">
136
                <thead>
147
                <thead>
137
                    <tr>
148
                    <tr>
138
                        <th>Card</th>
149
                        [% FOR column IN columns %]
139
                        <th>Name</th>
150
                            [% SWITCH column %]
140
                        <th>Library</th>
151
                                [% CASE 'cardnumber' %]<th>Card</th>
141
                        <th>Category</th>
152
                                [% CASE 'dateofbirth' %]<th>Date of birth</th>
142
                        <th>&nbsp;</th>
153
                                [% CASE 'address' %]<th>Address</th>
154
                                [% CASE 'name' %]<th>Name</th>
155
                                [% CASE 'branch' %]<th>Library</th>
156
                                [% CASE 'category' %]<th>Category</th>
157
                                [% CASE 'action' %]<th>&nbsp;</th>
158
                            [% END %]
159
                        [% END %]
143
                    </tr>
160
                    </tr>
144
                  </thead>
161
                  </thead>
145
                <tbody></tbody>
162
                <tbody></tbody>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (+37 lines)
Lines 100-105 Link Here
100
        $(mytables).find(" li[data-category_code='']").show();
100
        $(mytables).find(" li[data-category_code='']").show();
101
    }
101
    }
102
102
103
    function select_user(borrowernumber, borrower) {
104
        var form = $('#entryform').get(0);
105
        if (form.guarantorid.value) {
106
            $("#contact-details").find('a').remove();
107
            $("#contactname, #contactfirstname").parent().find('span').remove();
108
        }
109
110
        var id = borrower.borrowernumber;
111
        form.guarantorid.value = id;
112
        $('#contact-details')
113
            .show()
114
            .find('span')
115
            .after('<a target="blank" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=' + id + '">' + id + '</a>');
116
117
        $(form.contactname)
118
            .val(borrower.surname)
119
            .before('<span>' + borrower.surname + '</span>').get(0).type = 'hidden';
120
        $(form.contactfirstname)
121
            .val(borrower.firstname)
122
            .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden';
123
124
        form.streetnumber.value = borrower.streetnumber;
125
        form.address.value = borrower.address;
126
        form.address2.value = borrower.address2;
127
        form.city.value = borrower.city;
128
        form.state.value = borrower.state;
129
        form.zipcode.value = borrower.zipcode;
130
        form.country.value = borrower.country;
131
        form.branchcode.value = borrower.branchcode;
132
133
        form.guarantorsearch.value = 'Change';
134
135
        return 0;
136
    }
137
138
139
103
        var MSG_SEPARATOR = _("Separator must be / in field %s");
140
        var MSG_SEPARATOR = _("Separator must be / in field %s");
104
        var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
141
        var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
105
        var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
142
        var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt (+21 lines)
Line 0 Link Here
1
[% USE To %]
2
[% USE KohaDates %]
3
{
4
    "sEcho": [% sEcho %],
5
    "iTotalRecords": [% iTotalRecords %],
6
    "iTotalDisplayRecords": [% iTotalDisplayRecords %],
7
    "aaData": [
8
        [% FOREACH data IN aaData %]
9
            {
10
                "dt_cardnumber":
11
                    "[% data.cardnumber %]",
12
                "dt_dateofbirth":
13
                    "[% data.dateofbirth | $KohaDates %]",
14
                "dt_address":
15
                    "[% data.streetnumber %] [% data.address | html %] [% data.address2 | html %] [% data.city | html %] [% data.state | html %] [% data.zipcode | html %] [% data.country | html %] [% data.branchcode %]",
16
                "dt_action":
17
                    "<a style='cursor:pointer' onclick='select_user(\"[% data.borrowernumber %]\", [% To.json(data) | html %] );'>Select</a>"
18
            }[% UNLESS loop.last %],[% END %]
19
        [% END %]
20
    ]
21
}
(-)a/members/guarantor_search.pl (-74 / +24 lines)
Lines 1-100 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# script to find a guarantor
4
5
# Copyright 2006 OUEST PROVENCE
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
24
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
25
26
use C4::Auth;
23
use C4::Auth;
27
use C4::Output;
24
use C4::Output;
28
use C4::Dates qw/format_date/;
29
use C4::Members;
25
use C4::Members;
30
26
31
my $input = new CGI;
27
my $input = new CGI;
32
my ( $template, $loggedinuser, $cookie );
33
28
34
( $template, $loggedinuser, $cookie ) = get_template_and_user(
29
my $dbh = C4::Context->dbh;
35
    {
30
36
        template_name   => "members/guarantor_search.tt",
31
my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
32
    {   template_name   => "common/patron_search.tt",
37
        query           => $input,
33
        query           => $input,
38
        type            => "intranet",
34
        type            => "intranet",
39
        authnotrequired => 0,
35
        authnotrequired => 0,
40
        flagsrequired   => { borrowers => 1 },
36
        flagsrequired   => { borrowers => 1 },
41
        debug           => 1,
42
    }
37
    }
43
);
38
);
44
39
45
my $member        = $input->param('member') // '';
40
my $q = $input->param('q') || '';
46
my $orderby       = $input->param('orderby');
41
my $op = $input->param('op') || '';
47
my $category_type = $input->param('category_type');
48
49
$orderby = "surname,firstname" unless $orderby;
50
$member =~ s/,//g;     #remove any commas from search string
51
$member =~ s/\*/%/g;
52
53
$template->param( results => $member );
54
42
55
my $search_category = 'A';
43
my $referer = $input->referer();
56
if ( $category_type eq 'P' ) {
57
    $search_category = 'I';
58
}
59
60
my ( $count, $results );
61
my @resultsdata;
62
63
if ( $member ne '' ) {
64
    $results =
65
      Search( { '' => $member, category_type => $search_category }, $orderby );
66
67
    $count = $results ? @$results : 0;
68
69
    for ( my $i = 0 ; $i < $count ; $i++ ) {
70
        my %row = (
71
            count          => $i + 1,
72
            borrowernumber => $results->[$i]{'borrowernumber'},
73
            cardnumber     => $results->[$i]{'cardnumber'},
74
            surname        => $results->[$i]{'surname'},
75
            firstname      => $results->[$i]{'firstname'},
76
            categorycode   => $results->[$i]{'categorycode'},
77
            streetnumber   => $results->[$i]{'streetnumber'},
78
            address        => $results->[$i]{'address'},
79
            address2       => $results->[$i]{'address2'},
80
            city           => $results->[$i]{'city'},
81
            state          => $results->[$i]{'state'},
82
            zipcode        => $results->[$i]{'zipcode'},
83
            country        => $results->[$i]{'country'},
84
            branchcode     => $results->[$i]{'branchcode'},
85
            dateofbirth    => format_date( $results->[$i]{'dateofbirth'} ),
86
            borrowernotes  => $results->[$i]{'borrowernotes'}
87
        );
88
89
        push( @resultsdata, \%row );
90
    }
91
}
92
44
93
$template->param(
45
$template->param(
94
    member        => $member,
46
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
95
    numresults    => $count,
47
    columns => ['cardnumber', 'dateofbirth', 'address', 'action' ],
96
    category_type => $category_type,
48
    json_template => 'members/tables/guarantor_search.tt',
97
    resultsloop   => \@resultsdata
49
    selection_type => 'select',
98
);
50
);
99
51
output_html_with_http_headers( $input, $cookie, $template->output );
100
output_html_with_http_headers $input, $cookie, $template->output;
101
- 

Return to bug 13021