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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt (+2 lines)
Lines 176-181 function filter() { Link Here
176
                                [% CASE 'name' %]<th>Name</th>
176
                                [% CASE 'name' %]<th>Name</th>
177
                                [% CASE 'branch' %]<th>Library</th>
177
                                [% CASE 'branch' %]<th>Library</th>
178
                                [% CASE 'category' %]<th>Category</th>
178
                                [% CASE 'category' %]<th>Category</th>
179
                                [% CASE 'dateexpiry' %]<th>Expires on</td>
180
                                [% CASE 'borrowernotes' %]<th>Notes</th>
179
                                [% CASE 'action' %]<th>&nbsp;</th>
181
                                [% CASE 'action' %]<th>&nbsp;</th>
180
                            [% END %]
182
                            [% END %]
181
                        [% END %]
183
                        [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt (-2 / +13 lines)
Lines 46-54 Link Here
46
                    return; // abort delete
46
                    return; // abort delete
47
                }
47
                }
48
            };
48
            };
49
49
            function Add() {
50
            function Add() {
50
                window.open("/cgi-bin/koha/patroncards/members-search.pl?batch_id=[% batch_id %]",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
51
                window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
51
            };
52
                   'PatronPopup',
53
                   'width=740,height=450,location=yes,toolbar=no,'
54
                   + 'scrollbars=yes,resize=yes'
55
               );
56
            }
57
58
            function add_user(borrowernumber) {
59
                var myurl = "edit-batch.pl?op=add&batch_id=[% batch_id %]&borrower_number="+borrowernumber;
60
                window.location.href = myurl;
61
            }
62
52
            function DeDuplicate() {
63
            function DeDuplicate() {
53
                window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id %]";
64
                window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id %]";
54
            };
65
            };
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/members-search.tt (-126 lines)
Lines 1-126 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
	<style type="text/css">
5
   		#custom-doc { width:47.23em;*width:46.04em;min-width:600px; margin:auto; text-align:left; }
6
   	</style>
7
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
8
<script type="text/javascript">
9
//<![CDATA[
10
$(document).ready(function(){
11
    $("#CheckAll").click(function(){
12
		$(".checkboxed").checkCheckboxes();
13
	        return false;
14
    });
15
    $("#CheckNone").click(function(){
16
        $(".checkboxed").unCheckCheckboxes();
17
        return false;
18
    });
19
});
20
function add_item(borrowernum,batch_id,type_id){
21
 var getstr='';
22
 if (borrowernum == 'checked') {
23
    itms= new Array;
24
    if(document.resultform.borrowernumber.length > 0) {
25
        for (var i=0; i < document.resultform.borrowernumber.length; i++) {
26
            if (document.resultform.borrowernumber[i].checked) {
27
                itms.push("borrower_number=" +  document.resultform.borrowernumber[i].value);
28
            }
29
        }
30
        getstr = itms.join("&");
31
    } else {
32
        getstr = "borrower_number="+document.resultform.borrowernumber.value;
33
    }
34
  } else {
35
		getstr = "borrower_number="+borrowernum;
36
    }
37
 	var myurl = "edit-batch.pl?op=add&batch_id="+batch_id+"&"+getstr;
38
	window.opener.location.href = myurl;
39
}
40
//]]>
41
</script>
42
</head>
43
<body id="pcard_members-search" class="tools pcard">
44
45
<div id="custom-doc" class="yui-t7">
46
  <div id="bd">
47
	<div class="yui-g">
48
<h3>Patron search</h3>
49
50
<div class="browse">
51
    Browse by last name:
52
    [% FOREACH letter IN alphabet.split(' ') %]
53
        <a href="/cgi-bin/koha/patroncards/members-search.pl?not_attributes=1&amp;member=[% letter %]&amp;batch_id=[% batch_id %]">[% letter %]</a>
54
    [% END %]
55
</div>
56
57
<form method="get" action="/cgi-bin/koha/patroncards/members-search.pl"><p>
58
<input type="hidden" name="batch_id" value="[% batch_id %]" />
59
<input type="hidden" name="type" value="[% type %]" />
60
<label for="member">Name: </label>
61
<input id="member" name="member" value="[% member %]" />
62
63
[% UNLESS ( no_categories ) %]
64
    <label for="category">Category: </label>
65
    <select name="category" id="category">
66
        <option value="">Any</option>
67
        [% FOREACH categorie IN categories %]
68
            [% IF ( categorie.categorycode == category ) %]
69
                <option value="[% categorie.categorycode %]" selected="selected">[% categorie.description |html_entity %]</option>
70
            [% ELSE %]
71
                <option value="[% categorie.categorycode %]">[% categorie.description |html_entity %]</option>
72
            [% END %]
73
        [% END %]
74
    </select>
75
[% END %]
76
77
<input type="submit" value="Search" /></p>
78
</form>
79
80
[% IF ( resultsloop ) %]
81
<div id="searchheader"> <h3>Results [% from %] to [% to %] of [% numresults %] found [% IF ( member ) %]for name: '<span class="ex">[% member %]</span>'[% END %] [% IF ( category ) %]with category code: '<span class="ex">[% category %]</span>'[% END %]</h3></div>
82
[% IF ( paginationbar ) %]<div id="pagination_top" class="pages">[% paginationbar %]</div>[% END %]
83
<form name="resultform" action="/cgi-bin/koha/patroncards/members-search.pl" method="get" class="checkboxed"><div style="float: right; margin-top: .5em;"><input type="submit" class="icon addchecked" value="Add checked" onclick="add_item('checked',[% batch_id %]); return false" /> <input type="button" class="close" value="Done" /></div>
84
<div style="line-height: 2em; margin-left: .7em;"><a id="CheckAll" href="/cgi-bin/koha/patroncards/members-search.pl">Select All</a><a id="CheckNone" href="/cgi-bin/koha/patroncards/members-search.pl">Clear All</a></div>
85
<div class="searchresults">
86
87
    <table style="float: left; margin: .5em 0;">
88
    <tr>
89
    <th>Select</th>
90
    <th><a href="members-search.pl?member=[% member %]&amp;category=[% category %]&amp;batch_id=[% batch_id %]&amp;orderby=cardnumber">Card</a></th>
91
    <th><a href="members-search.pl?member=[% member %]&amp;category=[% category %]&amp;batch_id=[% batch_id %]&amp;orderby=surname">Name</a></th>
92
    <th><a href="members-search.pl?member=[% member %]&amp;category=[% category %]&amp;batch_id=[% batch_id %]&amp;orderby=borrowers.categorycode">Category</a></th>
93
    <th><a href="members-search.pl?member=[% member %]&amp;category=[% category %]&amp;batch_id=[% batch_id %]&amp;orderby=branchcode">Library</a></th>
94
    <th>Expires on</th>
95
    <th>Notes</th>
96
    <th></th>
97
    </tr>
98
    [% FOREACH resultsloo IN resultsloop %]
99
    [% UNLESS ( loop.odd ) %]
100
    <tr class="highlight">
101
    [% ELSE %]
102
    <tr>
103
    [% END %]
104
    <td> <input type="checkbox" name="borrowernumber" id="patron[% resultsloo.borrowernumber %]" value="[% resultsloo.borrowernumber %]" />	</td>
105
    <td>[% resultsloo.cardnumber %]</td>
106
    <td style="white-space: nowrap;"><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resultsloo.borrowernumber %]">[% resultsloo.surname %], [% resultsloo.firstname %]</a> <br /> [% resultsloo.address %][% IF ( resultsloo.address2 ) %]<br />[% resultsloo.address2 %][% END %][% IF ( resultsloo.city ) %]<br />[% resultsloo.city %][% END %]</td>
107
    <td>[% resultsloo.category_description %] ([% resultsloo.categorycode %])</td>
108
    <td>[% resultsloo.branchcode %]</td>
109
    <td>[% resultsloo.dateexpiry %]</td>
110
    <td>[% resultsloo.borrowernotes %]</td>
111
    <td><a onclick="add_item('[% resultsloo.borrowernumber %]',[% batch_id %]); return false" href="/cgi-bin/koha/patroncards/edit-batch.pl?borrower_number=[% resultsloo.borrowernumber %]&amp;batch_id=[% batch_id %]&amp;op=add">Add</a></td>
112
    </tr>
113
    [% END %]
114
    </table>
115
	</div>
116
</form>
117
118
[% ELSE %]
119
[% IF ( searching ) %]
120
No results found
121
[% END %]
122
[% END %]
123
124
</div>
125
</div>
126
[% INCLUDE 'popup-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/tables/members_results.tt (+26 lines)
Line 0 Link Here
1
[% USE To %]
2
{
3
    "sEcho": [% sEcho %],
4
    "iTotalRecords": [% iTotalRecords %],
5
    "iTotalDisplayRecords": [% iTotalDisplayRecords %],
6
    "aaData": [
7
        [% FOREACH data IN aaData %]
8
            {
9
                "dt_cardnumber":
10
                    "[% data.cardnumber %]",
11
                "dt_name":
12
                    "<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>",
13
                "dt_category":
14
                    "[% data.category_description |html %] ([% data.category_type |html %])",
15
                "dt_branch":
16
                    "[% data.branchname |html %]",
17
                "dt_dateexpiry":
18
                    "[% data.dateexpiry %]",
19
                "dt_borrowernotes":
20
                    "[% data.borrowernotes.replace('\\\\' , '\\\\') |html |html_line_break |collapse %]",
21
                "dt_action":
22
                    "<a style='cursor:pointer' onclick='add_user(\"[% data.borrowernumber %]\", \"[% data.firstname %] [% data.surname %]\"); return false;'>Add</a>"
23
            }[% UNLESS loop.last %],[% END %]
24
        [% END %]
25
    ]
26
}
(-)a/patroncards/add_user_search.pl (+51 lines)
Line 0 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;
24
use C4::Output;
25
use C4::Members;
26
27
my $input = new CGI;
28
29
my $dbh = C4::Context->dbh;
30
31
my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
32
    {   template_name   => "common/patron_search.tt",
33
        query           => $input,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired => { serials => 'routing' },
37
    }
38
);
39
40
my $q = $input->param('q') || '';
41
my $op = $input->param('op') || '';
42
43
my $referer = $input->referer();
44
45
$template->param(
46
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
47
    columns => ['cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'],
48
    json_template => 'patroncards/tables/members_results.tt',
49
    selection_type => 'add',
50
);
51
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/patroncards/members-search.pl (-148 lines)
Lines 1-147 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
#
5
# This file is part of Koha.
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 2 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 strict;
21
use warnings;
22
23
use CGI qw ( -utf8 );
24
25
use C4::Auth;
26
use C4::Output;
27
use C4::Members;
28
use C4::Debug;
29
30
my $cgi = CGI->new;
31
32
my $batch_id = $cgi->param('batch_id') || 0;
33
my $startfrom = $cgi->param('startfrom')||1;
34
my $resultsperpage = $cgi->param('resultsperpage')||C4::Context->preference("PatronsPerPage")||20;
35
my $category = $cgi->param('category') || undef;
36
my $member = $cgi->param('member') || '';
37
my $orderby = $cgi->param('orderby') || undef;
38
my $not_attributes = $cgi->param('not_attributes') || undef;
39
40
my @categories=C4::Category->all;
41
my %categories_display;
42
my $no_categories;
43
44
foreach my $category (@categories) {
45
    my $hash={
46
        category_description=>$$category{description},
47
        category_type=>$$category{category_type}
48
    };
49
    $categories_display{$$category{categorycode}} = $hash;
50
}
51
52
53
my ($template, $loggedinuser, $cookie) = get_template_and_user({
54
                template_name => "patroncards/members-search.tt",
55
                query => $cgi,
56
                type => "intranet",
57
                authnotrequired => 0,
58
                flagsrequired => {borrowers => 1},
59
                debug => 1,});
60
61
if(scalar(@categories) < 1){ $no_categories = 1; }
62
if($no_categories && C4::Context->preference("AddPatronLists")=~/code/){
63
    $template->param(no_categories => 1);
64
} else {
65
    $template->param(
66
        categories=>\@categories,
67
        category => $category
68
    );
69
}
70
71
$orderby = "surname,firstname" unless $orderby;
72
$member =~ s/,//g;   #remove any commas from search string
73
$member =~ s/\*/%/g;
74
75
if ($member || $category) {
76
    my $results = $category ? Search({''=>$member, categorycode=>$category}, $orderby, undef, undef, undef, undef, $not_attributes )
77
                            : Search($member, $orderby, undef, undef, undef, undef, $not_attributes);
78
    my $count = $results ? @$results : 0;
79
80
    my @resultsdata = ();
81
    my $to = ($count>($startfrom * $resultsperpage)?$startfrom * $resultsperpage:$count);
82
    for (my $i = ($startfrom-1) * $resultsperpage; $i < $to; $i++){
83
        #find out stats
84
        my ($od,$issue,$fines) = GetMemberIssuesAndFines($results->[$i]{'borrowernumber'});
85
        my %row = (
86
            count               => $i + 1,
87
                %{$categories_display{$results->[$i]{categorycode}}},
88
            borrowernumber      => $results->[$i]{'borrowernumber'},
89
            cardnumber          => $results->[$i]{'cardnumber'},
90
            surname             => $results->[$i]{'surname'},
91
            firstname           => $results->[$i]{'firstname'},
92
            categorycode        => $results->[$i]{'categorycode'},
93
            address             => $results->[$i]{'address'},
94
            address2            => $results->[$i]{'address2'},
95
            city                => $results->[$i]{'city'},
96
            zipcode             => $results->[$i]{'zipcode'},
97
            country             => $results->[$i]{'country'},
98
            branchcode          => $results->[$i]{'branchcode'},
99
            overdues            => $od,
100
            issues              => $issue,
101
            odissue             => "$od/$issue",
102
            fines               => ($fines ? sprintf("%.2f",$fines) : ''),
103
            borrowernotes       => $results->[$i]{'borrowernotes'},
104
            sort1               => $results->[$i]{'sort1'},
105
            sort2               => $results->[$i]{'sort2'},
106
            dateexpiry          => C4::Dates->new($results->[$i]{'dateexpiry'},'iso')->output('syspref'),
107
        );
108
        push(@resultsdata, \%row);
109
    }
110
    my $base_url = '?' . join('&amp;', map { $_->{term} . '=' . $_->{val} } (
111
                                            { term => 'member',         val => $member         },
112
                                            { term => 'category',       val => $category       },
113
                                            { term => 'orderby',        val => $orderby        },
114
                                            { term => 'resultsperpage', val => $resultsperpage },
115
                                            { term => 'batch_id',       val => $batch_id       },)
116
                                        );
117
    $template->param(
118
        paginationbar   => pagination_bar(
119
                                            $base_url,  int( $count / $resultsperpage ) + 1,
120
                                            $startfrom, 'startfrom'
121
                                         ),
122
        startfrom       => $startfrom,
123
        from            => ($startfrom-1) * $resultsperpage + 1,
124
        to              => $to,
125
        multipage       => ($count != $to || $startfrom != 1),
126
        searching       => "1",
127
        member          => $member,
128
        category_type   => $category,
129
        numresults      => $count,
130
        resultsloop     => \@resultsdata,
131
        batch_id        => $batch_id,
132
    );
133
}
134
else {
135
    $template->param( batch_id => $batch_id);
136
}
137
138
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
139
140
output_html_with_http_headers $cgi, $cookie, $template->output;
141
142
__END__
143
144
#script to do a borrower enquiry/bring up borrower details etc
145
#written 20/12/99 by chris@katipo.co.nz
146
147
148
- 

Return to bug 13891