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

(-)a/Koha/List/Patron.pm (+222 lines)
Line 0 Link Here
1
package Koha::List::Patron;
2
3
# Copyright 2013 ByWater Solutions
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
=head1 NAME
21
22
Koha::List::Patron - Managment of lists of patrons
23
24
=head1 FUNCTIONS
25
26
=cut
27
28
use Modern::Perl;
29
30
use Carp;
31
32
use Koha::Database;
33
34
use base 'Exporter';
35
our @EXPORT = (
36
    qw(
37
      GetPatronLists
38
39
      DelPatronList
40
      AddPatronList
41
      ModPatronList
42
43
      AddPatronsToList
44
      DelPatronsFromList
45
      )
46
);
47
48
=head2 GetPatronLists
49
50
    my @lists = GetPatronLists( $params );
51
52
    Returns an array of lists created by the the given user
53
    or the logged in user if none is passed in.
54
=cut
55
56
sub GetPatronLists {
57
    my ($params) = @_;
58
59
    $params->{owner} ||= C4::Context->userenv->{'number'};
60
61
    unless ( $params->{owner} ) {
62
        carp("No owner passed in or defined!");
63
        return;
64
    }
65
66
    delete( $params->{owner} ) if ( C4::Context->IsSuperLibrarian() );
67
68
    my $schema = Koha::Database->new()->schema();
69
70
    my @patron_lists = $schema->resultset('PatronList')->search($params);
71
72
    return wantarray() ? @patron_lists : \@patron_lists;
73
}
74
75
=head2 DelPatronList
76
77
    DelPatronList( { patron_list_id => $list_id [, owner => $owner ] } );
78
79
=cut
80
81
sub DelPatronList {
82
    my ($params) = @_;
83
84
    $params->{owner} ||= C4::Context->userenv->{'number'};
85
86
    unless ( $params->{patron_list_id} ) {
87
        croak("No patron list id passed in!");
88
    }
89
    unless ( $params->{owner} ) {
90
        carp("No owner passed in or defined!");
91
        return;
92
    }
93
94
    delete( $params->{owner} ) if ( C4::Context->IsSuperLibrarian() );
95
96
    return Koha::Database->new()->schema()->resultset('PatronList')
97
      ->search($params)->single()->delete();
98
}
99
100
=head2 AddPatronList
101
102
    AddPatronList( { name => $name [, owner => $owner ] } );
103
104
=cut
105
106
sub AddPatronList {
107
    my ($params) = @_;
108
109
    $params->{owner} ||= C4::Context->userenv->{'number'};
110
111
    unless ( $params->{owner} ) {
112
        carp("No owner passed in or defined!");
113
        return;
114
    }
115
116
    unless ( $params->{name} ) {
117
        carp("No list name passed in!");
118
        return;
119
    }
120
121
    return Koha::Database->new()->schema()->resultset('PatronList')
122
      ->create($params);
123
}
124
125
=head2 ModPatronList
126
127
    ModPatronList( { patron_list_id => $id, name => $name [, owner => $owner ] } );
128
129
=cut
130
131
sub ModPatronList {
132
    my ($params) = @_;
133
134
    unless ( $params->{patron_list_id} ) {
135
        carp("No patron list id passed in!");
136
        return;
137
    }
138
139
    my ($list) = GetPatronLists(
140
        {
141
            patron_list_id => $params->{patron_list_id},
142
            owner          => $params->{owner}
143
        }
144
    );
145
146
    return $list->update($params);
147
}
148
149
=head2 AddPatronsToList
150
151
    AddPatronsToList({ list => $list, cardnumbers => \@cardnumbers });
152
153
=cut
154
155
sub AddPatronsToList {
156
    my ($params) = @_;
157
158
    my $list            = $params->{list};
159
    my $cardnumbers     = $params->{'cardnumbers'};
160
    my $borrowernumbers = $params->{'borrowernumbers'};
161
162
    return unless ( $list && ( $cardnumbers || $borrowernumbers ) );
163
164
    my @borrowernumbers;
165
166
    if ($cardnumbers) {
167
        @borrowernumbers =
168
          Koha::Database->new()->schema()->resultset('Borrower')->search(
169
            { cardnumber => { 'IN' => $cardnumbers } },
170
            { columns    => [qw/ borrowernumber /] }
171
          )->get_column('borrowernumber')->all();
172
    }
173
    else {
174
        @borrowernumbers = @$borrowernumbers;
175
    }
176
177
    my $patron_list_id = $list->patron_list_id();
178
179
    my $plp_rs = Koha::Database->new()->schema()->resultset('PatronListPatron');
180
181
    my @results;
182
    foreach my $borrowernumber (@borrowernumbers) {
183
        my $result = $plp_rs->update_or_create(
184
            {
185
                patron_list_id => $patron_list_id,
186
                borrowernumber => $borrowernumber
187
            }
188
        );
189
        push( @results, $result );
190
    }
191
192
    return wantarray() ? @results : \@results;
193
}
194
195
=head2 DelPatronsFromList
196
197
    DelPatronsFromList({ list => $list, patron_list_patrons => \@patron_list_patron_ids });
198
199
=cut
200
201
sub DelPatronsFromList {
202
    my ($params) = @_;
203
204
    my $list                = $params->{list};
205
    my $patron_list_patrons = $params->{patron_list_patrons};
206
207
    return unless ( $list && $patron_list_patrons );
208
209
    return Koha::Database->new()->schema()->resultset('PatronListPatron')
210
      ->search( { patron_list_patron_id => { 'IN' => $patron_list_patrons } } )
211
      ->delete();
212
}
213
214
=head1 AUTHOR
215
216
Kyle M Hall, E<lt>kyle@bywatersolutions.comE<gt>
217
218
=cut
219
220
1;
221
222
__END__
(-)a/Koha/Schema/Result/PatronList.pm (+90 lines)
Line 0 Link Here
1
package Koha::Schema::Result::PatronList;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::PatronList
15
16
=cut
17
18
__PACKAGE__->table("patron_lists");
19
20
=head1 ACCESSORS
21
22
=head2 patron_list_id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 name
29
30
  data_type: 'varchar'
31
  is_nullable: 0
32
  size: 255
33
34
=head2 owner
35
36
  data_type: 'integer'
37
  is_foreign_key: 1
38
  is_nullable: 0
39
40
=cut
41
42
__PACKAGE__->add_columns(
43
  "patron_list_id",
44
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
45
  "name",
46
  { data_type => "varchar", is_nullable => 0, size => 255 },
47
  "owner",
48
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
49
);
50
__PACKAGE__->set_primary_key("patron_list_id");
51
52
=head1 RELATIONS
53
54
=head2 patron_list_patrons
55
56
Type: has_many
57
58
Related object: L<Koha::Schema::Result::PatronListPatron>
59
60
=cut
61
62
__PACKAGE__->has_many(
63
  "patron_list_patrons",
64
  "Koha::Schema::Result::PatronListPatron",
65
  { "foreign.patron_list_id" => "self.patron_list_id" },
66
  { cascade_copy => 0, cascade_delete => 0 },
67
);
68
69
=head2 owner
70
71
Type: belongs_to
72
73
Related object: L<Koha::Schema::Result::Borrower>
74
75
=cut
76
77
__PACKAGE__->belongs_to(
78
  "owner",
79
  "Koha::Schema::Result::Borrower",
80
  { borrowernumber => "owner" },
81
  { on_delete => "CASCADE", on_update => "CASCADE" },
82
);
83
84
85
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2013-07-10 10:39:50
86
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XegvNUkfR/cYwxlLLX3h3A
87
88
89
# You can replace this text with custom content, and it will be preserved on regeneration
90
1;
(-)a/Koha/Schema/Result/PatronListPatron.pm (+90 lines)
Line 0 Link Here
1
package Koha::Schema::Result::PatronListPatron;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::PatronListPatron
15
16
=cut
17
18
__PACKAGE__->table("patron_list_patrons");
19
20
=head1 ACCESSORS
21
22
=head2 patron_list_patron_id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 patron_list_id
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 borrowernumber
35
36
  data_type: 'integer'
37
  is_foreign_key: 1
38
  is_nullable: 0
39
40
=cut
41
42
__PACKAGE__->add_columns(
43
  "patron_list_patron_id",
44
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
45
  "patron_list_id",
46
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
47
  "borrowernumber",
48
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
49
);
50
__PACKAGE__->set_primary_key("patron_list_patron_id");
51
52
=head1 RELATIONS
53
54
=head2 borrowernumber
55
56
Type: belongs_to
57
58
Related object: L<Koha::Schema::Result::Borrower>
59
60
=cut
61
62
__PACKAGE__->belongs_to(
63
  "borrowernumber",
64
  "Koha::Schema::Result::Borrower",
65
  { borrowernumber => "borrowernumber" },
66
  { on_delete => "CASCADE", on_update => "CASCADE" },
67
);
68
69
=head2 patron_list
70
71
Type: belongs_to
72
73
Related object: L<Koha::Schema::Result::PatronList>
74
75
=cut
76
77
__PACKAGE__->belongs_to(
78
  "patron_list",
79
  "Koha::Schema::Result::PatronList",
80
  { patron_list_id => "patron_list_id" },
81
  { on_delete => "CASCADE", on_update => "CASCADE" },
82
);
83
84
85
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2013-07-10 10:39:50
86
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:c+znpWBlv6I+yi1EuGUKrQ
87
88
89
# You can replace this text with custom content, and it will be preserved on regeneration
90
1;
(-)a/installer/data/mysql/kohastructure.sql (+41 lines)
Lines 3214-3219 CREATE TABLE IF NOT EXISTS plugin_data ( Link Here
3214
  PRIMARY KEY (plugin_class,plugin_key)
3214
  PRIMARY KEY (plugin_class,plugin_key)
3215
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3215
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3216
3216
3217
--
3218
-- Table structure for table `patron_lists`
3219
--
3220
3221
DROP TABLE IF EXISTS patron_lists;
3222
CREATE TABLE patron_lists (
3223
  patron_list_id int(11) NOT NULL AUTO_INCREMENT, -- unique identifier
3224
  name varchar(255) CHARACTER SET utf8 NOT NULL,  -- the list's name
3225
  owner int(11) NOT NULL,                         -- borrowernumber of the list creator
3226
  PRIMARY KEY (patron_list_id),
3227
  KEY owner (owner)
3228
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3229
3230
--
3231
-- Constraints for table `patron_lists`
3232
--
3233
ALTER TABLE `patron_lists`
3234
  ADD CONSTRAINT patron_lists_ibfk_1 FOREIGN KEY (`owner`) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
3235
3236
--
3237
-- Table structure for table 'patron_list_patrons'
3238
--
3239
3240
DROP TABLE IF EXISTS patron_list_patrons;
3241
CREATE TABLE patron_list_patrons (
3242
  patron_list_patron_id int(11) NOT NULL AUTO_INCREMENT, -- unique identifier
3243
  patron_list_id int(11) NOT NULL,                       -- the list this entry is part of
3244
  borrowernumber int(11) NOT NULL,                       -- the borrower that is part of this list
3245
  PRIMARY KEY (patron_list_patron_id),
3246
  KEY patron_list_id (patron_list_id),
3247
  KEY borrowernumber (borrowernumber)
3248
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3249
3250
--
3251
-- Constraints for table `patron_list_patrons`
3252
--
3253
ALTER TABLE `patron_list_patrons`
3254
  ADD CONSTRAINT patron_list_patrons_ibfk_1 FOREIGN KEY (patron_list_id) REFERENCES patron_lists (patron_list_id) ON DELETE CASCADE ON UPDATE CASCADE,
3255
  ADD CONSTRAINT patron_list_patrons_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
3256
3257
3217
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3258
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3218
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3259
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3219
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
3260
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/updatedatabase.pl (+39 lines)
Lines 7044-7049 if ( CheckVersion($DBversion) ) { Link Here
7044
    SetVersion($DBversion);
7044
    SetVersion($DBversion);
7045
}
7045
}
7046
7046
7047
$DBversion = "3.13.00.XXX";
7048
if ( CheckVersion($DBversion) ) {
7049
7050
    $dbh->do(q{
7051
        CREATE TABLE IF NOT EXISTS `patron_lists` (
7052
          patron_list_id int(11) NOT NULL AUTO_INCREMENT,
7053
          name varchar(255) CHARACTER SET utf8 NOT NULL,
7054
          owner int(11) NOT NULL,
7055
          PRIMARY KEY (patron_list_id),
7056
          KEY owner (owner)
7057
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7058
    });
7059
7060
    $dbh->do(q{
7061
        ALTER TABLE `patron_lists`
7062
          ADD CONSTRAINT patron_lists_ibfk_1 FOREIGN KEY (`owner`) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
7063
    });
7064
7065
    $dbh->do(q{
7066
        CREATE TABLE patron_list_patrons (
7067
          patron_list_patron_id int(11) NOT NULL AUTO_INCREMENT,
7068
          patron_list_id int(11) NOT NULL,
7069
          borrowernumber int(11) NOT NULL,
7070
          PRIMARY KEY (patron_list_patron_id),
7071
          KEY patron_list_id (patron_list_id),
7072
          KEY borrowernumber (borrowernumber)
7073
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7074
    });
7075
7076
    $dbh->do(q{
7077
        ALTER TABLE `patron_list_patrons`
7078
          ADD CONSTRAINT patron_list_patrons_ibfk_1 FOREIGN KEY (patron_list_id) REFERENCES patron_lists (patron_list_id) ON DELETE CASCADE ON UPDATE CASCADE,
7079
          ADD CONSTRAINT patron_list_patrons_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
7080
    });
7081
7082
    print "Upgrade to $DBversion done (Bug 10565 - Add a 'Patron List' feature for storing and manipulating collections of patrons)\n";
7083
    SetVersion($DBversion);
7084
}
7085
7047
=head1 FUNCTIONS
7086
=head1 FUNCTIONS
7048
7087
7049
=head2 TableExists($table)
7088
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-7 / +122 lines)
Lines 1-6 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
2
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
5
<script type="text/javascript">
6
//<![CDATA[
7
$(document).ready(function() {
8
    $('#add_to_patron_list_submit').attr('disabled', 'disabled');
9
    $('#new_patron_list').hide();
10
11
    $('#add_to_patron_list').change(function() {
12
        var value = $('#add_to_patron_list').val();
13
        if ( value == 'new' ) {
14
            $('#new_patron_list').val('')
15
            $('#new_patron_list').show();
16
            $('#new_patron_list').focus();
17
        } else if ( value ) {
18
            $('#new_patron_list').hide();
19
            $('#add_to_patron_list_submit').removeAttr('disabled');
20
        } else {
21
            $('#new_patron_list').hide();
22
            $('#add_to_patron_list_submit').attr('disabled', 'disabled');
23
        }
24
25
    });
26
27
    $('#new_patron_list').on('input', function() {
28
        if ( $('#new_patron_list').val() ) {
29
            $('#add_to_patron_list_submit').removeAttr('disabled');
30
        } else {
31
            $('#add_to_patron_list_submit').attr('disabled', 'disabled');
32
        }
33
    });
34
});
35
36
function CheckForm() {
37
    if ( $('#add_to_patron_list').val() == 'new' ) {
38
        if ( $('#new_patron_list').val() ) {
39
            var exists = false;
40
            $("#add_to_patron_list option").each(function() {
41
                if ( $(this).text() == $('#new_patron_list').val() ) {
42
                    exists = true;
43
                    return false;
44
                }
45
            });
46
47
            if ( exists ) {
48
                alert( _('You already have a list with that name!') );
49
                return false;
50
            }
51
        } else {
52
            alert( _('You must give your new patron list a name!') );
53
            return false;
54
        }
55
    }
56
57
    if ( $('#add_to_patron_list_which').val() == 'all' ) {
58
        return confirm( _('Are you sure you want to add the entire set of patron results to this list ( including results on other pages )?') );
59
    } else {
60
         if ( $("#add-patrons-to-list-form input:checkbox:checked").length == 0 ) {
61
             alert( _('You have not selected any patrons to add to a list!') );
62
             return false;
63
         }
64
    }
65
66
    return true;
67
}
68
//]]>
69
</script>
70
4
</head>
71
</head>
5
<body id="pat_member" class="pat">
72
<body id="pat_member" class="pat">
6
[% INCLUDE 'header.inc' %]
73
[% INCLUDE 'header.inc' %]
Lines 15-20 Link Here
15
		    <div class="yui-b">
82
		    <div class="yui-b">
16
				<div class="yui-g">
83
				<div class="yui-g">
17
84
85
                [% IF patron_list %]
86
                    <div class="dialog alert">
87
                        Added [% patrons_added_to_list.size %] patrons to <a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% patron_list.patron_list_id %]">[% patron_list.name %]</a>.
88
                    </div>
89
                [% END %]
90
18
				[% INCLUDE 'patron-toolbar.inc' %]
91
				[% INCLUDE 'patron-toolbar.inc' %]
19
92
20
	[% IF ( no_add ) %]<div class="dialog alert"><h3>Cannot add patron</h3>
93
	[% IF ( no_add ) %]<div class="dialog alert"><h3>Cannot add patron</h3>
Lines 36-48 Link Here
36
                        </div>
109
                        </div>
37
                    [% END %]
110
                    [% END %]
38
111
39
						[% IF ( resultsloop ) %]
112
                    [% IF ( resultsloop ) %]
40
						<div id="searchheader"> <h3>Results [% from %] to [% to %] of [% numresults %] found for [% IF ( member ) %]'<span class="ex">[% member %]</span>'[% END %][% IF ( surname ) %]'<span class="ex">[% surname %]</span>'[% END %]</h3></div>
113
                    <form id="add-patrons-to-list-form" method="post" action="member.pl" onsubmit="return CheckForm()">
114
                        <div id="searchheader">
115
                            <h3>Results [% from %] to [% to %] of [% numresults %] found for [% IF ( member ) %]'<span class="ex">[% member %]</span>'[% END %][% IF ( surname ) %]'<span class="ex">[% surname %]</span>'[% END %]</h3>
116
117
                            <div>
118
                                <a href="javascript:void(0)" onclick="$('.selection').prop('checked', true)">Select all</a>
119
                                |
120
                                <a href="javascript:void(0)" onclick="$('.selection').prop('checked', false)">Clear all</a>
121
                                |
122
                                <span>
123
                                    <label for="add_to_patron_list_which">Add:</label>
124
                                    <select id="add_to_patron_list_which" name="add_to_patron_list_which">
125
                                        <option value="selected">Selected patrons</option>
126
                                        <option value="all">All resultant patrons</option>
127
                                    </select>
128
129
                                    <label for="add_to_patron_list">to:</label>
130
                                    <select id="add_to_patron_list" name="add_to_patron_list">
131
                                        <option value=""></option>
132
                                        [% IF patron_lists %]
133
                                            <optgroup label="Patron lists:">
134
                                                [% FOREACH pl IN patron_lists %]
135
                                                    <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
136
                                                [% END %]
137
                                            </optgroup>
138
                                        [% END %]
139
140
                                        <option value="new">[ New list ]</option>
141
                                    </select>
142
143
                                    <input type="text" id="new_patron_list" name="new_patron_list" id="new_patron_list" />
144
145
                                    [% FOREACH key IN search_parameters.keys %]
146
                                        <input type="hidden" name="[% key %]" value="[% search_parameters.$key %]" />
147
                                    [% END %]
148
149
                                    <input id="add_to_patron_list_submit" type="submit" class="submit" value="Save">
150
                                </span>
151
                            </div>
152
                        </div>
41
						<div class="searchresults">
153
						<div class="searchresults">
42
154
43
							<table id="memberresultst">
155
							<table id="memberresultst">
44
							<thead>
156
							<thead>
45
							<tr>
157
							<tr>
158
                            <th>&nbsp</th>
46
							<th>Card</th>
159
							<th>Card</th>
47
							<th>Name</th>
160
							<th>Name</th>
48
							<th>Cat</th>
161
							<th>Cat</th>
Lines 65-70 Link Here
65
							<tr>
178
							<tr>
66
							[% END %]
179
							[% END %]
67
							[% END %]
180
							[% END %]
181
                            <td><input type="checkbox" class="selection" name="borrowernumber" value="[% resultsloo.borrowernumber %]" /></td>
68
							<td>[% resultsloo.cardnumber %]</td>
182
							<td>[% resultsloo.cardnumber %]</td>
69
                            <td style="white-space: nowrap;">
183
                            <td style="white-space: nowrap;">
70
                            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resultsloo.borrowernumber %]">
184
                            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resultsloo.borrowernumber %]">
Lines 92-102 Link Here
92
							</table>
206
							</table>
93
							<div class="pages">[% IF ( multipage ) %][% paginationbar %][% END %]</div>
207
							<div class="pages">[% IF ( multipage ) %][% paginationbar %][% END %]</div>
94
						</div>
208
						</div>
95
						[% ELSE %]
209
                    </form>
96
						[% IF ( searching ) %]
210
                    [% ELSE %]
97
						<div class="dialog alert">No results found</div>
211
                        [% IF ( searching ) %]
98
						[% END %]
212
                            <div class="dialog alert">No results found</div>
99
						[% END %]
213
                        [% END %]
214
                    [% END %]
100
215
101
					</div>
216
					</div>
102
				</div>
217
				</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/add-modify.tt (+56 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Patron lists &rsaquo; New list</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
5
<script type="text/javascript">
6
//<![CDATA[
7
8
function CheckForm() {
9
  if ( !$("#list-name").val() ) {
10
    alert( _("Name is a required field!")  );
11
    return false;
12
  }
13
14
  return true;
15
}
16
17
//]]>
18
</script>
19
20
</head>
21
22
<body>
23
[% INCLUDE 'header.inc' %]
24
[% INCLUDE 'cat-search.inc' %]
25
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="lists.pl">Patron lists</a> &rsaquo; Add / modify list</div>
26
27
28
<div class="yui-t7">
29
    <div class="yui-main">
30
        <h1>New patron list</h1>
31
32
        <form method="post" onsubmit="return CheckForm()">
33
            <fieldset class="rows">
34
35
                <legend>Create a new patron list</legend>
36
37
                <ol>
38
                    <li>
39
                        <label class="required" for="name">Name:</label>
40
                        <input id="list-name" name="name" type="text" value="[% list.name %]" />
41
                    </li>
42
43
                    <li>
44
                        <span class="label">Owner: </span>[% loggedinusername %]
45
                    </li>
46
                </ol>
47
48
            </fieldset>
49
50
            <input type="hidden" name="patron_list_id" value="[% list.patron_list_id %]" />
51
            <input type="submit" class="btn btn-primary" value="Save" />
52
            <a href="lists.pl" class="cancel">Cancel</a>
53
        </form>
54
    </div>
55
</div>
56
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt (+74 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Patron lists</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
5
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
6
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
7
[% INCLUDE 'datatables-strings.inc' %]
8
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
9
10
<script type="text/javascript">
11
//<![CDATA[
12
    $(document).ready(function() {
13
        $('#patron-lists-table').dataTable($.extend(true, {}, dataTablesDefaults));
14
    });
15
16
    function ConfirmDelete( list ) {
17
        return confirm( _('Are you sure you want to delete the list ') + list + '?' );
18
    }
19
//]]>
20
</script>
21
22
</head>
23
24
<body>
25
[% INCLUDE 'header.inc' %]
26
[% INCLUDE 'cat-search.inc' %]
27
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; Patron lists</div>
28
29
<div class="yui-t7">
30
    <div class="yui-main">
31
        <h1>Your patron lists</h1>
32
33
        <div class="btn-group">
34
            <a class="btn btn-small" href="add-modify.pl"><i class="icon-plus"></i> New patron list</a>
35
        </div>
36
37
        <table id="patron-lists-table">
38
            <thead>
39
                <tr>
40
                    <th>Name</th>
41
                    <th>Patrons in list</th>
42
                    <th>&nbsp;</th>
43
                    <th>&nbsp;</th>
44
                    <th>&nbsp;</th>
45
                </tr>
46
            </thead>
47
48
            <tbody>
49
                [% FOREACH l IN lists %]
50
                    <tr>
51
                        <td>[% l.name %]</td>
52
                        <td>[% l.patron_list_patrons.size || 0 %]</td>
53
                        <td>
54
                            <a class="btn" href="list.pl?patron_list_id=[% l.patron_list_id %]">
55
                                <i class="icon-plus-sign"></i> Add patrons <i class="icon-user"></i>
56
                            </a>
57
                        </td>
58
                        <td>
59
                            <a class="btn" href="add-modify.pl?patron_list_id=[% l.patron_list_id %]">
60
                                <i class="icon-edit"></i> Edit
61
                            </a>
62
                        </td>
63
                        <td>
64
                            <a class="btn" href="delete.pl?patron_list_id=[% l.patron_list_id %]" onclick='return ConfirmDelete("[% l.name | html %]")'>
65
                                <i class="icon-trash"></i> Delete
66
                            </a>
67
                        </td>
68
                    </tr>
69
                [% END %]
70
            </tbody>
71
        </table>
72
    </div>
73
</div>
74
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt (-4 / +22 lines)
Lines 128-138 Link Here
128
                <h1>Batch patron modification</h1>
128
                <h1>Batch patron modification</h1>
129
                <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
129
                <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
130
                    <fieldset class="rows">
130
                    <fieldset class="rows">
131
                    <legend>Use a file</legend>
131
                        <legend>Use a file</legend>
132
                    <ol>
132
                        <ol>
133
                    <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
133
                            <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
134
                    </ol>
134
                        </ol>
135
                    </fieldset>
135
                    </fieldset>
136
137
                    [% IF patron_lists %]
138
                    <fieldset class="rows">
139
                        <legend>Or use a patron list</legend>
140
                        <ol>
141
                            <li>
142
                                <label for="patron_list_id">Patron list: </label>
143
                                <select id="patron_list_id" name="patron_list_id">
144
                                    <option value=""></option>
145
                                    [% FOREACH pl IN patron_lists %]
146
                                        <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
147
                                    [% END %]
148
                                </select>
149
                            </li>
150
                        </ol>
151
                    </fieldset>
152
                    [% END %]
153
136
                    <fieldset class="rows">
154
                    <fieldset class="rows">
137
                        <legend>Or list cardnumbers one by one</legend>
155
                        <legend>Or list cardnumbers one by one</legend>
138
                        <ol>
156
                        <ol>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (-1 / +4 lines)
Lines 15-21 Link Here
15
<div class="yui-u first">
15
<div class="yui-u first">
16
<h3>Patrons and circulation</h3>
16
<h3>Patrons and circulation</h3>
17
<dl>
17
<dl>
18
    [% IF ( CAN_user_tools_moderate_comments ) %]
18
    <dt><a href="/cgi-bin/koha/patron_lists/lists.pl">Patron lists</a>
19
    <dd>Manage lists of patrons.</dd>
20
21
[% IF ( CAN_user_tools_moderate_comments ) %]
19
    <dt><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">Comments</a> [% IF ( pendingcomments ) %]<span class="holdcount"><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">[% pendingcomments %]</a></span>[% END %]</dt>
22
    <dt><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">Comments</a> [% IF ( pendingcomments ) %]<span class="holdcount"><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">[% pendingcomments %]</a></span>[% END %]</dt>
20
	<dd>Moderate patron comments. </dd>
23
	<dd>Moderate patron comments. </dd>
21
    [% END %]
24
    [% END %]
(-)a/members/member.pl (-16 / +54 lines)
Lines 33-38 use C4::Branch; Link Here
33
use C4::Category;
33
use C4::Category;
34
use Koha::DateUtils;
34
use Koha::DateUtils;
35
use File::Basename;
35
use File::Basename;
36
use Koha::List::Patron;
36
37
37
my $input = new CGI;
38
my $input = new CGI;
38
my $quicksearch = $input->param('quicksearch');
39
my $quicksearch = $input->param('quicksearch');
Lines 49-54 my ($template, $loggedinuser, $cookie) Link Here
49
50
50
my $theme = $input->param('theme') || "default";
51
my $theme = $input->param('theme') || "default";
51
52
53
my $add_to_patron_list       = $input->param('add_to_patron_list');
54
my $add_to_patron_list_which = $input->param('add_to_patron_list_which');
55
my $new_patron_list          = $input->param('new_patron_list');
56
my @borrowernumbers          = $input->param('borrowernumber');
57
$input->delete(
58
    'add_to_patron_list', 'add_to_patron_list_which',
59
    'new_patron_list',    'borrowernumber',
60
);
61
52
my $patron = $input->Vars;
62
my $patron = $input->Vars;
53
foreach (keys %$patron){
63
foreach (keys %$patron){
54
	delete $$patron{$_} unless($$patron{$_});
64
	delete $$patron{$_} unless($$patron{$_});
Lines 115-120 if ($member || keys %$patron) { Link Here
115
    ($results) = Search( $member || $patron, \@orderby, undef, undef, \@searchfields, $search_scope );
125
    ($results) = Search( $member || $patron, \@orderby, undef, undef, \@searchfields, $search_scope );
116
}
126
}
117
127
128
if ($add_to_patron_list) {
129
    my $patron_list;
130
131
    if ( $add_to_patron_list eq 'new' ) {
132
        $patron_list = AddPatronList( { name => $new_patron_list } );
133
    }
134
    else {
135
        $patron_list =
136
          [ GetPatronLists( { patron_list_id => $add_to_patron_list } ) ]->[0];
137
    }
138
139
    if ( $add_to_patron_list_which eq 'all' ) {
140
        @borrowernumbers = map { $_->{borrowernumber} } @$results;
141
    }
142
143
    my @patrons_added_to_list = AddPatronsToList( { list => $patron_list, borrowernumbers => \@borrowernumbers } );
144
145
    $template->param(
146
        patron_list           => $patron_list,
147
        patrons_added_to_list => \@patrons_added_to_list,
148
      )
149
}
150
118
if ($results) {
151
if ($results) {
119
	for my $field ('categorycode','branchcode'){
152
	for my $field ('categorycode','branchcode'){
120
		next unless ($patron->{$field});
153
		next unless ($patron->{$field});
Lines 170-193 my $base_url = Link Here
170
my @letters = map { {letter => $_} } ( 'A' .. 'Z');
203
my @letters = map { {letter => $_} } ( 'A' .. 'Z');
171
204
172
$template->param(
205
$template->param(
173
    letters => \@letters,
206
    %$patron,
207
    letters       => \@letters,
174
    paginationbar => pagination_bar(
208
    paginationbar => pagination_bar(
175
        $base_url,
209
        $base_url,
176
        int( $count / $resultsperpage ) + ($count % $resultsperpage ? 1 : 0),
210
        int( $count / $resultsperpage ) + ( $count % $resultsperpage ? 1 : 0 ),
177
        $startfrom, 'startfrom'
211
        $startfrom,
212
        'startfrom'
178
    ),
213
    ),
179
    startfrom => $startfrom,
214
    startfrom    => $startfrom,
180
    from      => ($startfrom-1)*$resultsperpage+1,  
215
    from         => ( $startfrom - 1 ) * $resultsperpage + 1,
181
    to        => $to,
216
    to           => $to,
182
    multipage => ($count != $to || $startfrom!=1),
217
    multipage    => ( $count != $to || $startfrom != 1 ),
183
    advsearch => ($$patron{categorycode} || $$patron{branchcode}),
218
    advsearch    => ( $$patron{categorycode} || $$patron{branchcode} ),
184
    branchloop=>\@branchloop,
219
    branchloop   => \@branchloop,
185
    categories=>\@categories,
220
    categories   => \@categories,
186
    searching       => "1",
221
    searching    => "1",
187
		actionname		=>basename($0),
222
    actionname   => basename($0),
188
		%$patron,
223
    numresults   => $count,
189
        numresults      => $count,
224
    resultsloop  => \@resultsdata,
190
        resultsloop     => \@resultsdata,
225
    results_per_page => $resultsperpage,
191
            );
226
    member => $member,
227
    search_parameters => \%parameters,
228
    patron_lists => [ GetPatronLists() ],
229
);
192
230
193
output_html_with_http_headers $input, $cookie, $template->output;
231
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/patron_lists/add-modify.pl (+59 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
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 Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::List::Patron;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "patron_lists/add-modify.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 1,
36
    }
37
);
38
39
my $id   = $cgi->param('patron_list_id');
40
my $name = $cgi->param('name');
41
42
if ($id) {
43
    my ($list) = GetPatronLists( { patron_list_id => $id } );
44
    $template->param( list => $list );
45
}
46
47
if ($name) {
48
    if ($id) {
49
        ModPatronList( { patron_list_id => $id, name => $name } );
50
    }
51
    else {
52
        AddPatronList( { name => $name } );
53
    }
54
55
    print $cgi->redirect('lists.pl');
56
    exit;
57
}
58
59
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/patron_lists/delete.pl (+43 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
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 Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::List::Patron;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "patron_lists/lists.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 1,
36
    }
37
);
38
39
my $id = $cgi->param('patron_list_id');
40
41
DelPatronList( { patron_list_id => $id } );
42
43
print $cgi->redirect('lists.pl');
(-)a/patron_lists/list.pl (+54 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
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 Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::List::Patron;
27
28
my $cgi = new CGI;
29
30
my ( $template, $logged_in_user, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "patron_lists/list.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 1,
36
    }
37
);
38
39
my ($list) =
40
  GetPatronLists( { patron_list_id => $cgi->param('patron_list_id') } );
41
42
my @patrons_to_add = $cgi->param('patrons_to_add');
43
if (@patrons_to_add) {
44
    AddPatronsToList( { list => $list, cardnumbers => \@patrons_to_add } );
45
}
46
47
my @patrons_to_remove = $cgi->param('patrons_to_remove');
48
if (@patrons_to_remove) {
49
    DelPatronsFromList( { list => $list, patron_list_patrons => \@patrons_to_remove } );
50
}
51
52
$template->param( list => $list );
53
54
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/patron_lists/lists.pl (+43 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
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 Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::List::Patron;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "patron_lists/lists.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 1,
36
    }
37
);
38
39
my @lists = GetPatronLists();
40
41
$template->param( lists => \@lists );
42
43
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/patron_lists/patrons.pl (+59 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
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 Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::List::Patron;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "patron_lists/add-modify.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 1,
36
    }
37
);
38
39
my $id   = $cgi->param('patron_list_id');
40
my $name = $cgi->param('name');
41
42
if ($id) {
43
    my ($list) = GetPatronLists( { patron_list_id => $id } );
44
    $template->param( list => $list );
45
}
46
47
if ($name) {
48
    if ($id) {
49
        ModPatronList( { patron_list_id => $id, name => $name } );
50
    }
51
    else {
52
        AddPatronList( { name => $name } );
53
    }
54
55
    print $cgi->redirect('lists.pl');
56
    exit;
57
}
58
59
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/t/db_dependent/PatronLists.t (+75 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
#
3
use Modern::Perl;
4
5
use Test::More tests => 9;
6
7
BEGIN {
8
    use_ok('C4::Context');
9
    use_ok('Koha::List::Patron');
10
}
11
12
my $dbh = C4::Context->dbh;
13
my $sth = $dbh->prepare("SELECT * FROM borrowers ORDER BY RAND() LIMIT 10");
14
$sth->execute();
15
my @borrowers = @{ $sth->fetchall_arrayref( {} ) };
16
17
my @lists = GetPatronLists( { owner => 1 } );
18
my $list_count_original = @lists;
19
20
my $list1 = AddPatronList( { name => 'Test List 1', owner => 1 } );
21
ok( $list1->name() eq 'Test List 1', 'AddPatronList works' );
22
23
my $list2 = AddPatronList( { name => 'Test List 2', owner => 1 } );
24
25
ModPatronList(
26
    {
27
        patron_list_id => $list2->patron_list_id(),
28
        name           => 'Test List 3',
29
        owner          => 1
30
    }
31
);
32
$list2->discard_changes();
33
ok( $list2->name() eq 'Test List 3', 'ModPatronList works' );
34
35
AddPatronsToList(
36
    { list => $list1, cardnumbers => [ map { $_->{cardnumber} } @borrowers ] }
37
);
38
ok(
39
    scalar @borrowers ==
40
      $list1->patron_list_patrons()->search_related('borrowernumber')->all(),
41
    'AddPatronsToList works for cardnumbers'
42
);
43
44
AddPatronsToList(
45
    {
46
        list            => $list2,
47
        borrowernumbers => [ map { $_->{borrowernumber} } @borrowers ]
48
    }
49
);
50
ok(
51
    scalar @borrowers ==
52
      $list2->patron_list_patrons()->search_related('borrowernumber')->all(),
53
    'AddPatronsToList works for borrowernumbers'
54
);
55
56
my @ids =
57
  $list1->patron_list_patrons()->get_column('patron_list_patron_id')->all();
58
DelPatronsFromList(
59
    {
60
        list                => $list1,
61
        patron_list_patrons => \@ids,
62
    }
63
);
64
$list1->discard_changes();
65
ok( !$list1->patron_list_patrons()->count(), 'DelPatronsFromList works.' );
66
67
@lists = GetPatronLists( { owner => 1 } );
68
ok( @lists == $list_count_original + 2, 'GetPatronLists works' );
69
70
DelPatronList( { patron_list_id => $list1->patron_list_id(), owner => 1 } );
71
DelPatronList( { patron_list_id => $list2->patron_list_id(), owner => 1 } );
72
73
@lists =
74
  GetPatronLists( { patron_list_id => $list1->patron_list_id(), owner => 1 } );
75
ok( !@lists, 'DelPatronList works' );
(-)a/tools/modborrowers.pl (-5 / +14 lines)
Lines 34-39 use C4::Members::Attributes; Link Here
34
use C4::Members::AttributeTypes qw/GetAttributeTypes_hashref/;
34
use C4::Members::AttributeTypes qw/GetAttributeTypes_hashref/;
35
use C4::Output;
35
use C4::Output;
36
use List::MoreUtils qw /any uniq/;
36
use List::MoreUtils qw /any uniq/;
37
use Koha::List::Patron;
37
38
38
my $input = new CGI;
39
my $input = new CGI;
39
my $op = $input->param('op') || 'show_form';
40
my $op = $input->param('op') || 'show_form';
Lines 50-61 my %cookies = parse CGI::Cookie($cookie); Link Here
50
my $sessionID = $cookies{'CGISESSID'}->value;
51
my $sessionID = $cookies{'CGISESSID'}->value;
51
my $dbh       = C4::Context->dbh;
52
my $dbh       = C4::Context->dbh;
52
53
53
54
55
# Show borrower informations
54
# Show borrower informations
56
if ( $op eq 'show' ) {
55
if ( $op eq 'show' ) {
57
    my $filefh      = $input->upload('uploadfile');
56
    my $filefh         = $input->upload('uploadfile');
58
    my $filecontent = $input->param('filecontent');
57
    my $filecontent    = $input->param('filecontent');
58
    my $patron_list_id = $input->param('patron_list_id');
59
    my @borrowers;
59
    my @borrowers;
60
    my @cardnumbers;
60
    my @cardnumbers;
61
    my @notfoundcardnumbers;
61
    my @notfoundcardnumbers;
Lines 67-72 if ( $op eq 'show' ) { Link Here
67
            $content =~ s/[\r\n]*$//g;
67
            $content =~ s/[\r\n]*$//g;
68
            push @cardnumbers, $content if $content;
68
            push @cardnumbers, $content if $content;
69
        }
69
        }
70
    } elsif ( $patron_list_id ) {
71
        my ($list) = GetPatronLists( { patron_list_id => $patron_list_id } );
72
73
        @cardnumbers =
74
          $list->patron_list_patrons()->search_related('borrowernumber')
75
          ->get_column('cardnumber')->all();
76
70
    } else {
77
    } else {
71
        if ( my $list = $input->param('cardnumberlist') ) {
78
        if ( my $list = $input->param('cardnumberlist') ) {
72
            push @cardnumbers, split( /\s\n/, $list );
79
            push @cardnumbers, split( /\s\n/, $list );
Lines 314-319 if ( $op eq 'do' ) { Link Here
314
321
315
    $template->param( borrowers => \@borrowers );
322
    $template->param( borrowers => \@borrowers );
316
    $template->param( errors => \@errors );
323
    $template->param( errors => \@errors );
324
} else {
325
326
    $template->param( patron_lists => [ GetPatronLists() ] );
317
}
327
}
318
328
319
$template->param(
329
$template->param(
320
- 

Return to bug 10565