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

(-)a/C4/Category.pm (+34 lines)
Lines 94-99 sub all { Link Here
94
    };
94
    };
95
}
95
}
96
96
97
=head3 C4::Category->get
98
99
    $cat = get( $category_code );
100
    This returns the category as an object.
101
102
=cut
103
104
sub get {
105
    my ( $class, $code ) = @_;
106
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
107
    my $dbh = C4::Context->dbh;
108
109
    my ( $query , @params );
110
    if( $branch_limit ){
111
        $query = qq| SELECT categories.* FROM categories
112
                     LEFT JOIN categories_branches ON categories_branches.categorycode = categories.categorycode
113
                     WHERE categories.categorycode = ? AND (categories_branches.branchcode = ? OR categories_branches.branchcode IS NULL)
114
                    |;
115
        @params = ( $code, $branch_limit );
116
    }
117
    else{
118
       $query = "SELECT categories.* FROM categories WHERE categorycode = ?";
119
       @params = ( $code );
120
    }
121
122
    my $data = $dbh->selectrow_hashref( $query, undef, @params );
123
124
    return $class->new($data);
125
}
126
97
127
98
128
99
129
Lines 149-154 These are read-only accessors for attributes of a C4::Category object. Link Here
149
179
150
=cut
180
=cut
151
181
182
=head3 $category->canbeguarantee
183
184
=cut
185
152
sub AUTOLOAD {
186
sub AUTOLOAD {
153
    my $self = shift;
187
    my $self = shift;
154
    my $attr = $AUTOLOAD;
188
    my $attr = $AUTOLOAD;
(-)a/C4/Members/Attributes.pm (-1 / +16 lines)
Lines 34-40 BEGIN { Link Here
34
    @EXPORT_OK = qw(GetBorrowerAttributes GetBorrowerAttributeValue CheckUniqueness SetBorrowerAttributes
34
    @EXPORT_OK = qw(GetBorrowerAttributes GetBorrowerAttributeValue CheckUniqueness SetBorrowerAttributes
35
                    DeleteBorrowerAttribute UpdateBorrowerAttribute
35
                    DeleteBorrowerAttribute UpdateBorrowerAttribute
36
                    extended_attributes_code_value_arrayref extended_attributes_merge
36
                    extended_attributes_code_value_arrayref extended_attributes_merge
37
                    SearchIdMatchingAttribute);
37
                    SearchIdMatchingAttribute get_guarantor_shared_attributes);
38
    %EXPORT_TAGS = ( all => \@EXPORT_OK );
38
    %EXPORT_TAGS = ( all => \@EXPORT_OK );
39
}
39
}
40
40
Lines 357-362 sub _sort_by_code { Link Here
357
    return $x->{code} cmp $y->{code} || $x->{value} cmp $y->{value};
357
    return $x->{code} cmp $y->{code} || $x->{value} cmp $y->{value};
358
}
358
}
359
359
360
=head2 get_guarantor_shared_attributes
361
362
    $guarantor_attributes = get_guarantor_attributes();
363
364
    returns an array reference containing attributes to be shared between guarantor and guarantee.
365
=cut
366
sub get_guarantor_shared_attributes{
367
    my @attributes    = qw( streetnumber address address2 city state zipcode country branchcode phone phonepro mobile email emailpro fax );
368
    if( my @additional = split(/\|/, C4::Context->preference("AdditionalGuarantorField")) ){
369
        $_ =~ s/(?:^\s+)|(?:\s+$)//g for (@additional); # Trim whitespaces
370
        @attributes = ( @attributes, @additional);
371
    }
372
    return \@attributes;
373
}
374
360
=head1 AUTHOR
375
=head1 AUTHOR
361
376
362
Koha Development Team <http://koha-community.org/>
377
Koha Development Team <http://koha-community.org/>
(-)a/C4/Utils/DataTables/Members.pm (-7 / +15 lines)
Lines 4-9 use Modern::Perl; Link Here
4
use C4::Branch qw/onlymine/;
4
use C4::Branch qw/onlymine/;
5
use C4::Context;
5
use C4::Context;
6
use C4::Members qw/GetMemberIssuesAndFines/;
6
use C4::Members qw/GetMemberIssuesAndFines/;
7
use C4::Members::Attributes qw/get_guarantor_shared_attributes/;
7
use C4::Utils::DataTables;
8
use C4::Utils::DataTables;
8
use Koha::DateUtils;
9
use Koha::DateUtils;
9
10
Lines 32-44 sub search { Link Here
32
    }
33
    }
33
34
34
    my $dbh = C4::Context->dbh;
35
    my $dbh = C4::Context->dbh;
35
    my $select = "SELECT
36
    my @columns = qw( borrowernumber surname firstname streetnumber streettype address address2 city state zipcode country cardnumber dateexpiry borrowernotes branchcode email userid dateofbirth categorycode );
36
        borrowers.borrowernumber, borrowers.surname, borrowers.firstname,
37
    if( my @guarantor_attributes = @{ get_guarantor_shared_attributes() }){
37
        borrowers.streetnumber, borrowers.streettype, borrowers.address,
38
        foreach my $item (@guarantor_attributes) {
38
        borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode,
39
             if (! grep {$_ eq $item} @columns) {
39
        borrowers.country, cardnumber, borrowers.dateexpiry,
40
                 push @columns, $item;
40
        borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
41
	     }
41
        borrowers.userid, borrowers.dateofbirth, borrowers.categorycode,
42
	}
43
    };
44
    my $borrowers_columns = "";
45
    foreach my $item (@columns) {
46
        $borrowers_columns .= "borrowers." . $item . ", ";
47
    }
48
49
    my $select = "SELECT " . $borrowers_columns . "
42
        categories.description AS category_description, categories.category_type,
50
        categories.description AS category_description, categories.category_type,
43
        branches.branchname";
51
        branches.branchname";
44
    my $from = "FROM borrowers
52
    my $from = "FROM borrowers
(-)a/Koha/Schema/Result/Category.pm (+8 lines)
Lines 109-114 __PACKAGE__->table("categories"); Link Here
109
  default_value: -1
109
  default_value: -1
110
  is_nullable: 0
110
  is_nullable: 0
111
111
112
=head2 canbeguarantee
113
114
  data_type: 'tinyint'
115
  default_value: 0
116
  is_nullable: 0
117
112
=head2 default_privacy
118
=head2 default_privacy
113
119
114
  data_type: 'enum'
120
  data_type: 'enum'
Lines 154-159 __PACKAGE__->add_columns( Link Here
154
    default_value => -1,
160
    default_value => -1,
155
    is_nullable   => 0,
161
    is_nullable   => 0,
156
  },
162
  },
163
  "canbeguarantee",
164
  { data_type => "tinyint", default_value => 0, is_nullable => 0},
157
  "default_privacy",
165
  "default_privacy",
158
  {
166
  {
159
    data_type => "enum",
167
    data_type => "enum",
(-)a/admin/categorie.pl (+423 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#script to administer the categories table
4
#written 20/02/2002 by paul.poulain@free.fr
5
6
# ALGO :
7
# this script use an $op to know what to do.
8
# if $op is empty or none of the above values,
9
#	- the default screen is build (with all records, or filtered datas).
10
#	- the   user can clic on add, modify or delete record.
11
# if $op=add_form
12
#	- if primkey exists, this is a modification,so we read the $primkey record
13
#	- builds the add/modify form
14
# if $op=add_validate
15
#	- the user has just send datas, so we create/modify the record
16
# if $op=delete_form
17
#	- we show the record having primkey=$primkey and ask for deletion validation form
18
# if $op=delete_confirm
19
#	- we delete the record having primkey=$primkey
20
21
# Copyright 2000-2002 Katipo Communications
22
#
23
# This file is part of Koha.
24
#
25
# Koha is free software; you can redistribute it and/or modify it
26
# under the terms of the GNU General Public License as published by
27
# the Free Software Foundation; either version 3 of the License, or
28
# (at your option) any later version.
29
#
30
# Koha is distributed in the hope that it will be useful, but
31
# WITHOUT ANY WARRANTY; without even the implied warranty of
32
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33
# GNU General Public License for more details.
34
#
35
# You should have received a copy of the GNU General Public License
36
# along with Koha; if not, see <http://www.gnu.org/licenses>.
37
38
use Modern::Perl;
39
40
use CGI qw ( -utf8 );
41
use C4::Context;
42
use C4::Auth;
43
use C4::Branch;
44
use C4::Output;
45
use C4::Dates;
46
use C4::Form::MessagingPreferences;
47
use Koha::Database;
48
49
sub StringSearch {
50
    my ( $searchstring, $type ) = @_;
51
    my $dbh = C4::Context->dbh;
52
    $searchstring //= '';
53
    $searchstring =~ s/\'/\\\'/g;
54
    my @data = split( ' ', $searchstring );
55
    push @data, q{} if $#data == -1;
56
    my $count = @data;
57
    my $sth   = $dbh->prepare("Select * from categories where (description like ?) order by category_type,description,categorycode");
58
    $sth->execute("$data[0]%");
59
    my @results;
60
61
    while ( my $data = $sth->fetchrow_hashref ) {
62
        push( @results, $data );
63
    }
64
65
    #  $sth->execute;
66
    $sth->finish;
67
    return ( scalar(@results), \@results );
68
}
69
70
my $input         = new CGI;
71
my $searchfield   = $input->param('description');
72
my $script_name   = "/cgi-bin/koha/admin/categorie.pl";
73
my $categorycode  = $input->param('categorycode');
74
my $op            = $input->param('op') // 'list';
75
my $block_expired = $input->param("block_expired");
76
my @messages;
77
78
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
79
    {
80
        template_name   => "admin/categorie.tt",
81
        query           => $input,
82
        type            => "intranet",
83
        authnotrequired => 0,
84
        flagsrequired   => { parameters => 'parameters_remaining_permissions' },
85
        debug           => 1,
86
    }
87
);
88
89
################## ADD_FORM ##################################
90
# called by default. Used to create form to add or  modify a record
91
if ( $op eq 'add_form' ) {
92
    $template->param( add_form => 1 );
93
94
    #---- if primkey exists, it's a modify action, so read values to modify...
95
    my $data;
96
    my @selected_branches;
97
    if ($categorycode) {
98
        my $dbh = C4::Context->dbh;
99
        my $sth =
100
          $dbh->prepare("SELECT * FROM categories WHERE categorycode=?");
101
        $sth->execute($categorycode);
102
        $data = $sth->fetchrow_hashref;
103
104
        $sth = $dbh->prepare(
105
            "SELECT b.branchcode, b.branchname
106
            FROM categories_branches AS cb, branches AS b
107
            WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?
108
        ");
109
        $sth->execute($categorycode);
110
        while ( my $branch = $sth->fetchrow_hashref ) {
111
            push @selected_branches, $branch;
112
        }
113
        $sth->finish;
114
    }
115
116
    if (   $data->{'enrolmentperioddate'}
117
        && $data->{'enrolmentperioddate'} eq '0000-00-00' )
118
    {
119
        $data->{'enrolmentperioddate'} = undef;
120
    }
121
122
    $data->{'category_type'} //= '';
123
124
    my $branches = GetBranches();
125
    my @branches_loop;
126
    foreach my $branch ( sort keys %$branches ) {
127
        my $selected =
128
          ( grep { $$_{branchcode} eq $branch } @selected_branches ) ? 1 : 0;
129
        push @branches_loop,
130
          {
131
            branchcode => $$branches{$branch}{branchcode},
132
            branchname => $$branches{$branch}{branchname},
133
            selected   => $selected,
134
          };
135
    }
136
137
    $template->param(
138
        branches_loop       => \@branches_loop,
139
        description         => $data->{'description'},
140
        enrolmentperiod     => $data->{'enrolmentperiod'},
141
        enrolmentperioddate => $data->{'enrolmentperioddate'},
142
        upperagelimit       => $data->{'upperagelimit'},
143
        dateofbirthrequired => $data->{'dateofbirthrequired'},
144
        enrolmentfee        => sprintf( "%.2f", $data->{'enrolmentfee'} || 0 ),
145
        overduenoticerequired => $data->{'overduenoticerequired'},
146
        issuelimit            => $data->{'issuelimit'},
147
        reservefee            => sprintf( "%.2f", $data->{'reservefee'} || 0 ),
148
        hidelostitems         => $data->{'hidelostitems'},
149
        category_type         => $data->{'category_type'},
150
        default_privacy       => $data->{'default_privacy'},
151
        SMSSendDriver         => C4::Context->preference("SMSSendDriver"),
152
        "type_" . $data->{'category_type'} => 1,
153
        BlockExpiredPatronOpacActions =>
154
          $data->{'BlockExpiredPatronOpacActions'},
155
        TalkingTechItivaPhone =>
156
          C4::Context->preference("TalkingTechItivaPhoneNotification"),
157
        canbeguarantee       => $data->{'canbeguarantee'},
158
    );
159
160
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
161
        C4::Form::MessagingPreferences::set_form_values(
162
            { categorycode => $categorycode }, $template );
163
    }
164
165
    # END $OP eq ADD_FORM
166
################## ADD_VALIDATE ##################################
167
    # called by add_form, used to insert/modify data in DB
168
}
169
elsif ( $op eq 'add_validate' ) {
170
171
    my $is_a_modif = $input->param("is_a_modif");
172
173
    my $dbh = C4::Context->dbh;
174
175
    if ( $input->param('enrolmentperioddate') ) {
176
        $input->param(
177
            'enrolmentperioddate' => C4::Dates::format_date_in_iso(
178
                $input->param('enrolmentperioddate')
179
            )
180
        );
181
    }
182
    if ($is_a_modif) {
183
        my $sth = $dbh->prepare( "
184
                UPDATE categories
185
                SET description=?,
186
                    enrolmentperiod=?,
187
                    enrolmentperioddate=?,
188
                    upperagelimit=?,
189
                    dateofbirthrequired=?,
190
                    enrolmentfee=?,
191
                    reservefee=?,
192
                    hidelostitems=?,
193
                    overduenoticerequired=?,
194
                    category_type=?,
195
                    BlockExpiredPatronOpacActions=?,
196
                    default_privacy=?,
197
                    canbeguarantee=?
198
                WHERE categorycode=?"
199
        );
200
        $sth->execute(
201
            map { $input->param($_) } (
202
                'description',           'enrolmentperiod',
203
                'enrolmentperioddate',   'upperagelimit',
204
                'dateofbirthrequired',   'enrolmentfee',
205
                'reservefee',            'hidelostitems',
206
                'overduenoticerequired', 'category_type',
207
                'block_expired',         'default_privacy',
208
                'canbeguarantee', 'categorycode'
209
            )
210
        );
211
        $sth->finish;
212
    }
213
    else {
214
        my $sth = $dbh->prepare( "
215
            INSERT INTO categories (
216
                categorycode,
217
                description,
218
                enrolmentperiod,
219
                enrolmentperioddate,
220
                upperagelimit,
221
                dateofbirthrequired,
222
                enrolmentfee,
223
                reservefee,
224
                hidelostitems,
225
                overduenoticerequired,
226
                category_type,
227
                BlockExpiredPatronOpacActions,
228
                default_privacy,
229
                canbeguarantee
230
            )
231
            VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)" );
232
        my $inserted = $sth->execute(
233
            map { $input->param($_) } (
234
                'categorycode',    'description',
235
                'enrolmentperiod', 'enrolmentperioddate',
236
                'upperagelimit',   'dateofbirthrequired',
237
                'enrolmentfee',    'reservefee',
238
                'hidelostitems',   'overduenoticerequired',
239
                'category_type',   'block_expired',
240
                'default_privacy', 'canbeguarantee'
241
            )
242
        );
243
        if ( $inserted ) {
244
            push @messages, { type => 'message', code => 'success_on_insert' };
245
        } else {
246
            push @messages, { type => 'error', code => 'error_on_insert' };
247
        }
248
    }
249
250
    my @branches = $input->param("branches");
251
    if (@branches) {
252
        my $sth = $dbh->prepare(
253
            "DELETE FROM categories_branches WHERE categorycode = ?"
254
        );
255
        $sth->execute( $input->param("categorycode") );
256
        $sth = $dbh->prepare(
257
            "INSERT INTO categories_branches ( categorycode, branchcode ) VALUES ( ?, ? )"
258
        );
259
        for my $branchcode (@branches) {
260
            next if not $branchcode;
261
            $sth->bind_param( 1, $input->param("categorycode") );
262
            $sth->bind_param( 2, $branchcode );
263
            $sth->execute;
264
        }
265
    }
266
267
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
268
        C4::Form::MessagingPreferences::handle_form_action( $input,
269
            { categorycode => $input->param('categorycode') }, $template );
270
    }
271
272
    $searchfield = q||;
273
    $op = 'list';
274
275
    # END $OP eq ADD_VALIDATE
276
################## DELETE_CONFIRM ##################################
277
    # called by default form, used to confirm deletion of data in DB
278
}
279
elsif ( $op eq 'delete_confirm' ) {
280
    my $schema = Koha::Database->new()->schema();
281
    $template->param( delete_confirm => 1 );
282
283
    my $count =
284
      $schema->resultset('Borrower')
285
      ->search( { categorycode => $categorycode } )->count();
286
287
    my $category = $schema->resultset('Category')->find($categorycode);
288
289
    $category->enrolmentperioddate(
290
        C4::Dates::format_date( $category->enrolmentperioddate() ) );
291
292
    $template->param( category => $category, patrons_in_category => $count );
293
294
    # END $OP eq DELETE_CONFIRM
295
################## DELETE_CONFIRMED ##################################
296
  # called by delete_confirm, used to effectively confirm deletion of data in DB
297
}
298
elsif ( $op eq 'delete_confirmed' ) {
299
    $template->param( delete_confirmed => 1 );
300
    my $dbh = C4::Context->dbh;
301
302
    my $categorycode = uc( $input->param('categorycode') );
303
304
    my $sth = $dbh->prepare("delete from categories where categorycode=?");
305
306
    my $deleted = $sth->execute($categorycode);
307
308
    if ( $deleted ) {
309
        push @messages, { type => 'message', code => 'success_on_delete' };
310
    } else {
311
        push @messages, { type => 'error', code => 'error_on_delete' };
312
    }
313
314
    $op = 'list';
315
316
    # END $OP eq DELETE_CONFIRMED
317
}
318
319
if ( $op eq 'list' ) {
320
    $template->param( else => 1 );
321
    my @loop;
322
    my ( $count, $results ) = StringSearch( $searchfield, 'web' );
323
324
    my $dbh = C4::Context->dbh;
325
    my $sth = $dbh->prepare("
326
        SELECT b.branchcode, b.branchname
327
        FROM categories_branches AS cb, branches AS b
328
        WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?
329
    ");
330
331
    for ( my $i = 0 ; $i < $count ; $i++ ) {
332
        $sth->execute( $results->[$i]{'categorycode'} );
333
334
        my @selected_branches;
335
        while ( my $branch = $sth->fetchrow_hashref ) {
336
            push @selected_branches, $branch;
337
        }
338
339
        my $enrolmentperioddate = $results->[$i]{'enrolmentperioddate'};
340
        if ( $enrolmentperioddate && $enrolmentperioddate eq '0000-00-00' ) {
341
            $enrolmentperioddate = undef;
342
        }
343
344
        $results->[$i]{'category_type'} //= '';
345
        my %row = (
346
            branches              => \@selected_branches,
347
            categorycode          => $results->[$i]{'categorycode'},
348
            description           => $results->[$i]{'description'},
349
            enrolmentperiod       => $results->[$i]{'enrolmentperiod'},
350
            enrolmentperioddate   => $enrolmentperioddate,
351
            upperagelimit         => $results->[$i]{'upperagelimit'},
352
            dateofbirthrequired   => $results->[$i]{'dateofbirthrequired'},
353
            overduenoticerequired => $results->[$i]{'overduenoticerequired'},
354
            issuelimit            => $results->[$i]{'issuelimit'},
355
            hidelostitems         => $results->[$i]{'hidelostitems'},
356
            category_type         => $results->[$i]{'category_type'},
357
            default_privacy       => $results->[$i]{'default_privacy'},
358
            canbeguarantee       => $results->[$i]{'canbeguarantee'},
359
            reservefee => sprintf( "%.2f", $results->[$i]{'reservefee'} || 0 ),
360
            enrolmentfee =>
361
              sprintf( "%.2f", $results->[$i]{'enrolmentfee'} || 0 ),
362
            "type_" . $results->[$i]{'category_type'} => 1,
363
        );
364
365
        if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
366
            my $brief_prefs =
367
              _get_brief_messaging_prefs( $results->[$i]{'categorycode'} );
368
            $row{messaging_prefs} = $brief_prefs if @$brief_prefs;
369
        }
370
        push @loop, \%row;
371
    }
372
373
    $template->param( loop => \@loop );
374
375
    # check that I (institution) and C (child) exists. otherwise => warning to the user
376
    $sth = $dbh->prepare("select category_type from categories where category_type='C'");
377
    $sth->execute;
378
    my ($categoryChild) = $sth->fetchrow;
379
    $template->param( categoryChild => $categoryChild );
380
381
    $sth = $dbh->prepare("select category_type from categories where category_type='I'");
382
    $sth->execute;
383
    my ($categoryInstitution) = $sth->fetchrow;
384
    $template->param( categoryInstitution => $categoryInstitution );
385
    $sth->finish;
386
387
}    #---- END $OP eq DEFAULT
388
389
$template->param(
390
    script_name  => $script_name,
391
    categorycode => $categorycode,
392
    searchfield  => $searchfield,
393
    messages     => \@messages,
394
);
395
396
output_html_with_http_headers $input, $cookie, $template->output;
397
398
exit 0;
399
400
sub _get_brief_messaging_prefs {
401
    my $categorycode      = shift;
402
    my $messaging_options = C4::Members::Messaging::GetMessagingOptions();
403
    my $results           = [];
404
    PREF: foreach my $option (@$messaging_options) {
405
        my $pref = C4::Members::Messaging::GetMessagingPreferences(
406
            {
407
                categorycode => $categorycode,
408
                message_name => $option->{'message_name'}
409
            }
410
        );
411
        next unless $pref->{'transports'};
412
        my $brief_pref = {
413
            message_attribute_id      => $option->{'message_attribute_id'},
414
            message_name              => $option->{'message_name'},
415
            $option->{'message_name'} => 1
416
        };
417
        foreach my $transport ( keys %{ $pref->{'transports'} } ) {
418
            push @{ $brief_pref->{'transports'} }, { transport => $transport };
419
        }
420
        push @$results, $brief_pref;
421
    }
422
    return $results;
423
}
(-)a/admin/categories.pl (+3 lines)
Lines 91-96 elsif ( $op eq 'add_validate' ) { Link Here
91
    my $category_type = $input->param('category_type');
91
    my $category_type = $input->param('category_type');
92
    my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions');
92
    my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions');
93
    my $default_privacy = $input->param('default_privacy');
93
    my $default_privacy = $input->param('default_privacy');
94
    my $canbeguarantee = $input->param('canbeguarantee');
94
    my @branches = grep { $_ ne q{} } $input->param('branches');
95
    my @branches = grep { $_ ne q{} } $input->param('branches');
95
96
96
    my $is_a_modif = $input->param("is_a_modif");
97
    my $is_a_modif = $input->param("is_a_modif");
Lines 112-117 elsif ( $op eq 'add_validate' ) { Link Here
112
        $category->hidelostitems($hidelostitems);
113
        $category->hidelostitems($hidelostitems);
113
        $category->overduenoticerequired($overduenoticerequired);
114
        $category->overduenoticerequired($overduenoticerequired);
114
        $category->category_type($category_type);
115
        $category->category_type($category_type);
116
        $category->canbeguarantee($canbeguarantee);
115
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
117
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
116
        $category->default_privacy($default_privacy);
118
        $category->default_privacy($default_privacy);
117
        eval {
119
        eval {
Lines 137-142 elsif ( $op eq 'add_validate' ) { Link Here
137
            hidelostitems => $hidelostitems,
139
            hidelostitems => $hidelostitems,
138
            overduenoticerequired => $overduenoticerequired,
140
            overduenoticerequired => $overduenoticerequired,
139
            category_type => $category_type,
141
            category_type => $category_type,
142
            canbeguarantee => $canbeguarantee,
140
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
143
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
141
            default_privacy => $default_privacy,
144
            default_privacy => $default_privacy,
142
        });
145
        });
(-)a/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql (+10 lines)
Line 0 Link Here
1
-- ******** --
2
-- SYSPREFS --
3
-- ******** --
4
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
5
VALUES ('AdditionalGuarantorField','',NULL,'Additional fields name to be transfer from guarantor to guarantee.','free');
6
7
-- ********* --
8
-- STRUCTURE --
9
-- ********* --
10
ALTER TABLE categories ADD COLUMN `canbeguarantee` tinyint(1) NOT NULL default '0';
(-)a/installer/data/mysql/kohastructure.sql (-1 / +2 lines)
Lines 488-494 CREATE TABLE `categories` ( -- this table shows information related to Koha patr Link Here
488
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
488
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
489
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
489
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
490
  `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions
490
  `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions
491
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
491
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category,
492
  `canbeguarantee` tinyint(1) NOT NULL default '0'
492
  PRIMARY KEY  (`categorycode`),
493
  PRIMARY KEY  (`categorycode`),
493
  UNIQUE KEY `categorycode` (`categorycode`)
494
  UNIQUE KEY `categorycode` (`categorycode`)
494
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
495
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
(-)a/installer/data/mysql/sysprefs.sql (-1 / +3 lines)
Lines 6-11 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
9
('AdditionalGuarantorField','',NULL,'Additional fields name to be transfer from guarantor to guarantee.','free'),
10
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
9
('AddressFormat','us','','Choose format to display postal addresses', 'Choice'),
11
('AddressFormat','us','','Choose format to display postal addresses', 'Choice'),
10
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
12
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
11
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
13
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
Lines 517-521 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
517
('XSLTDetailsDisplay','default','','Enable XSL stylesheet control over details page display on intranet','Free'),
519
('XSLTDetailsDisplay','default','','Enable XSL stylesheet control over details page display on intranet','Free'),
518
('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'),
520
('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'),
519
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
521
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
520
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo')
522
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
521
;
523
;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (-1 / +1 lines)
Lines 146-152 function searchToHold(){ Link Here
146
146
147
    [% IF ( CAN_user_borrowers ) %]
147
    [% IF ( CAN_user_borrowers ) %]
148
        [% IF ( adultborrower AND activeBorrowerRelationship ) %]
148
        [% IF ( adultborrower AND activeBorrowerRelationship ) %]
149
            <a id="addchild" class="btn btn-small" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantorid=[% borrowernumber %]"><i class="fa fa-plus"></i> Add child</a>
149
            <a id="addchild" class="btn btn-small" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantorid=[% borrowernumber %]&amp;category_type=C"><i class="icon-plus"></i> Add guarantee</a>
150
        [% END %]
150
        [% END %]
151
        [% IF ( CAN_user_borrowers ) %]
151
        [% IF ( CAN_user_borrowers ) %]
152
            <a id="changepassword" class="btn btn-small" href="/cgi-bin/koha/members/member-password.pl?member=[% borrowernumber %]"><i class="fa fa-lock"></i> Change password</a>
152
            <a id="changepassword" class="btn btn-small" href="/cgi-bin/koha/members/member-password.pl?member=[% borrowernumber %]"><i class="fa fa-lock"></i> Change password</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt (+475 lines)
Line 0 Link Here
1
[% USE KohaDates -%]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Administration &rsaquo; Patron categories &rsaquo; [% IF ( add_form ) %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
4
[% IF ( delete_confirm ) %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
5
</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'calendar.inc' %]
8
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
9
[% INCLUDE 'datatables.inc' %]
10
<script type="text/javascript" id="js">
11
//<![CDATA[
12
    $(document).ready(function() {
13
        $("#table_categorie").dataTable($.extend(true, {}, dataTablesDefaults, {
14
            "aoColumnDefs": [
15
                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
16
                { "aTargets": [ 3,4,5 ], "sType": "natural" },
17
            ],
18
            "aaSorting": [[ 1, "asc" ]],
19
            "sPaginationType": "four_button"
20
        }));
21
22
    $( "#enrolmentperioddate" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
23
24
    if ( $("#branches option:selected").length < 1 ) {
25
        $("#branches option:first").attr("selected", "selected");
26
    }
27
    $("#category_type").change(function(){
28
	var canbeguarantee_bydefault = ['C','P'];
29
        var selected = $(this).val();
30
        $("#canbeguarantee").val( ( $.inArray(selected, canbeguarantee_bydefault) != -1 ) ? "1" : "0" );
31
    });
32
});
33
	function isNotNull(f,noalert) {
34
		if (f.value.length ==0) {
35
   return false;
36
		}
37
		return true;
38
	}
39
	//
40
	function isNum(v,maybenull) {
41
	var n = new Number(v.value);
42
	if (isNaN(n)) {
43
		return false;
44
		}
45
	if (maybenull==0 && v.value=='') {
46
		return false;
47
	}
48
	return true;
49
	}
50
	// to check if the data are correctly entered.
51
	function Check(ff) {
52
	    var ok=0;
53
		var _alertString=_("Form not submitted because of the following problem(s)");
54
		_alertString +="\n-------------------------------------------------------------------\n\n";
55
                ff.categorycode.value = $.trim(ff.categorycode.value);
56
                if (ff.categorycode.value.length==0) {
57
                   ok=1;
58
                   _alertString += _("- categorycode missing") + "\n";
59
                }
60
                else{
61
                   var patt=/^[a-zA-Z0-9\-_]+$/g;
62
                   if ( !patt.test(ff.categorycode.value) ) {
63
                      ok=1;
64
                      _alertString += _("- category code can only contain the following characters: letters, numbers, - and _") + "\n";
65
                   }
66
                }
67
		if (!(ff.category_type.value)){
68
		    ok=1;
69
		    _alertString += _("- category type missing") + "\n";
70
		}
71
		if (!(isNotNull(ff.description,1))) {
72
		    ok=1;
73
			_alertString += _("- description missing") + "\n";
74
		}
75
		if (!isNum(ff.upperagelimit,0) && ff.category_type.value=='C') {
76
		    ok=1;
77
			_alertString += _("- upperagelimit is not a number") + "\n";
78
79
		}
80
                if(!(ff.enrolmentperioddate.value || ff.enrolmentperiod.value)) {
81
                    ok=1;
82
                    _alertString += _("- either Enrollment period or Until date must be provided") + "\n";
83
                }
84
		if(ff.enrolmentperioddate.value && ff.enrolmentperiod.value){
85
			document.getElementById('enrolmentmessage').className = "error";
86
			return false;
87
		}
88
89
		if (ok) { // if there is a problem
90
		    alert(_alertString);
91
                    return false;
92
                }
93
                // if all is good
94
		ff.submit();
95
	}
96
	//]]>
97
</script>
98
<style type="text/css">#enrolmentmessage.hint { display : none; }</style>
99
</head>
100
<body id="admin_categorie" class="admin">
101
[% INCLUDE 'header.inc' %]
102
[% INCLUDE 'patrons-admin-search.inc' %]
103
104
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( add_form ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
105
[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( patrons_in_category > 0 ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
106
[% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; Category deleted[% END %]
107
[% IF ( else ) %]Patron categories[% END %]</div>
108
109
<div id="doc3" class="yui-t2">
110
111
   <div id="bd">
112
	<div id="yui-main">
113
	<div class="yui-b">
114
115
[% FOR m IN messages %]
116
    <div class="dialog [% m.type %]">
117
        [% SWITCH m.code %]
118
        [% CASE 'error_on_insert' %]
119
            An error occurred when inserting this patron category. The patron category might already exist.
120
        [% CASE 'error_on_delete' %]
121
            An error occurred when deleting this patron category. Check the logs.
122
        [% CASE 'success_on_insert' %]
123
            Patron category added successfully
124
        [% CASE 'success_on_delete' %]
125
            Patron category deleted successfully.
126
        [% CASE %]
127
            [% m.code %]
128
        [% END %]
129
    </div>
130
[% END %]
131
132
[% IF ( add_form ) %]
133
	<form name="Aform" action="[% script_name %]" method="post">
134
	<input type="hidden" name="op" value="add_validate" />
135
	<input type="hidden" name="checked" value="0" />
136
[% IF ( categorycode ) %]
137
		<h1>Modify category [% categorycode |html %]</h1>
138
	[% ELSE %]
139
		<h1>New category</h1>
140
	[% END %]
141
	<fieldset class="rows">
142
	<ol>[% IF ( categorycode ) %]
143
    <li><span class="label">Category code: </span>[% categorycode |html %]
144
				<input type="hidden" name="categorycode" value="[% categorycode |html %]" /><input type="hidden" name="is_a_modif" value="1" /></li>
145
	[% ELSE %]
146
    <li>
147
        <label for="categorycode" class="required">Category code: </label>
148
        <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" onblur="toUC(this)" />
149
        <span class="required">Required</span>
150
    </li>
151
	[% END %]
152
    <li>
153
        <label for="description" class="required">Description: </label>
154
        <input type="text" name="description" id="description" size="40" maxlength="80" value="[% description |html %]" />
155
        <span class="required">Required</span>
156
    </li>
157
    <li><label for="enrolmentperiod" class="required">Enrollment period: </label>
158
	<fieldset>
159
	<legend>Choose one</legend>
160
	<ol>
161
	<li><label for="enrolmentperiod" style="width:6em;">In months: </label>
162
		<input type="text" name="enrolmentperiod" id="enrolmentperiod" size="3" maxlength="3" value="[% IF ( enrolmentperiod ) %][% enrolmentperiod %][% END %]" /> months</li>
163
	<li><label for="enrolmentperioddate" style="width:6em;">Until date: </label>
164
        <input type="text" name="enrolmentperioddate" id="enrolmentperioddate" value="[% enrolmentperioddate | $KohaDates %]" />
165
		<div id="enrolmentmessage" class="hint" style="margin-left:0;">Cannot have "months" and "until date" at the same time</div>
166
	</li>
167
	</ol>
168
	</fieldset>
169
	</li>
170
	<li><label for="dateofbirthrequired">Age required: </label> <input type="text" name="dateofbirthrequired" id="dateofbirthrequired" value="[% dateofbirthrequired %]" size="3" maxlength="3" /> years</li>
171
	<li><label for="upperagelimit">Upperage limit: </label> <input type="text" name="upperagelimit" id="upperagelimit" size="3" maxlength="3" value="[% upperagelimit %]" /> years</li>
172
	<li><label for="enrolmentfee">Enrollment fee: </label><input type="text" name="enrolmentfee" id="enrolmentfee" size="6" value="[% enrolmentfee %]" /></li>
173
	<li><label for="overduenoticerequired">Overdue notice required: </label> <select name="overduenoticerequired" id="overduenoticerequired">
174
			[% IF ( overduenoticerequired ) %]
175
						<option value="0">No</option>
176
						<option value="1" selected="selected">Yes</option>
177
			[% ELSE %]
178
						<option value="0" selected="selected">No</option>
179
						<option value="1">Yes</option>
180
			[% END %]
181
					</select></li>
182
    <li><label for="hidelostitems">Lost items in staff client: </label> <select name="hidelostitems" id="hidelostitems">
183
			[% IF ( hidelostitems ) %]
184
						<option value="0">Shown</option>
185
						<option value="1" selected="selected">Hidden by default</option>
186
			[% ELSE %]
187
						<option value="0" selected="selected">Shown</option>
188
						<option value="1">Hidden by default</option>
189
			[% END %]
190
					</select></li>
191
	<li><label for="reservefee">Hold fee: </label><input type="text" name="reservefee" id="reservefee" size="6" value="[% reservefee %]" /></li>
192
    <li>
193
        <label for="category_type" class="required">Category type: </label>
194
        <select name="category_type" id="category_type">
195
                        [% IF ( type_n ) %]<option value="" selected="selected">Select a category type</option>[% ELSE %]<option value="">Select a category type</option>[% END %]
196
					[% IF ( type_A ) %]<option value="A" selected="selected">Adult</option>[% ELSE %]<option value="A">Adult</option>[% END %]
197
					[% IF ( type_C ) %]<option value="C" selected="selected">Child</option>[% ELSE %]<option value="C">Child</option>[% END %]
198
					[% IF ( type_S ) %]<option value="S" selected="selected">Staff</option>[% ELSE %]<option value="S">Staff</option>[% END %]
199
					[% IF ( type_I ) %]<option value="I" selected="selected">Organization</option>[% ELSE %]<option value="I">Organization</option>[% END %]
200
					[% IF ( type_P ) %]<option value="P" selected="selected">Professional</option>[% ELSE %]<option value="P">Professional</option>[% END %]
201
					[% IF ( type_X ) %]<option value="X" selected="selected">Statistical</option>[% ELSE %]<option value="X">Statistical</option>[% END %]
202
					</select>
203
        <span class="required">Required</span>
204
    </li>
205
    <li>
206
        <label for="canbeguarantee">Can be guarantee</label>
207
        <select name="canbeguarantee" id="canbeguarantee">
208
            [% IF canbeguarantee %]
209
                <option value="1" selected>Yes</option>
210
                <option value="0">No</option>
211
            [% ELSE %]
212
                <option value="1">Yes</option>
213
                <option value="0" selected>No</option>
214
            [% END %]
215
        <select>
216
    </li>
217
    <li><label for="branches">Branches limitation: </label>
218
        <select id="branches" name="branches" multiple size="10">
219
            <option value="">All branches</option>
220
            [% FOREACH branch IN branches_loop %]
221
              [% IF ( branch.selected ) %]
222
                <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
223
              [% ELSE %]
224
                <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
225
              [% END %]
226
            [% END %]
227
        </select>
228
        <span>Select <i>All branches</i> if this category type must to be displayed all the time. Otherwise select libraries you want to associate with this value.
229
        </span>
230
    </li>
231
    <li><label for="block_expired">Block expired patrons</label>
232
        <select name="block_expired" id="block_expired">
233
            [% IF ( BlockExpiredPatronOpacActions == -1  ) %]
234
                <option value="-1" selected="selected"> Follow system preference BlockExpiredPatronOpacActions </option>
235
            [% ELSE %]
236
                <option value="-1"> Follow system preference BlockExpiredPatronOpacActions </option>
237
            [% END %]
238
239
            [% IF ( BlockExpiredPatronOpacActions == 1   ) %]
240
                <option value="1" selected="selected"> Block </option>
241
            [% ELSE %]
242
                <option value="1"> Block </option>
243
            [% END %]
244
245
            [% IF ( BlockExpiredPatronOpacActions == 0   ) %]
246
                <option value="0" selected="selected"> Don't block </option>
247
            [% ELSE %]
248
                <option value="0"> Don't block </option>
249
            [% END %]
250
        </select>
251
        <span>
252
            Choose whether patrons of this category be blocked from public catalog actions such as renewing and placing holds when their cards have expired.
253
        </span>
254
    </li>
255
    <li>
256
        <label for="default_privacy">Default privacy: </label>
257
        <select id="default_privacy" name="default_privacy">
258
            [% SWITCH default_privacy %]
259
            [% CASE 'forever' %]
260
                <option value="default">Default</option>
261
                <option value="never">Never</option>
262
                <option value="forever" selected="selected">Forever</option>
263
            [% CASE 'never' %]
264
                <option value="default">Default</option>
265
                <option value="never" selected="selected">Never</option>
266
                <option value="forever">Forever</option>
267
            [% CASE %]
268
                <option value="default" selected="selected">Default</option>
269
                <option value="never">Never</option>
270
                <option value="forever">Forever</option>
271
            [% END %]
272
        </select>
273
        <span>Controls how long a patrons checkout history is kept for new patrons of this category. "Never" anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob <i>batch_anonymise.pl</i> which should be set up by your system administrator.</span>
274
    </li>
275
    </ol>
276
</fieldset>
277
278
    [% IF ( EnhancedMessagingPreferences ) %]
279
      <fieldset class="rows">
280
        <h4>Default messaging preferences for this patron category</h4>
281
        [% INCLUDE 'messaging-preference-form.inc' %]
282
      </fieldset>
283
    [% END %]
284
	<fieldset class="action"><input type="button" value="Save" onclick="Check(this.form);" /> </fieldset>
285
	</form>
286
287
[% END %]
288
289
[% IF ( delete_confirm ) %]
290
    <form action="[% script_name %]" method="post">
291
        <fieldset>
292
            <legend>
293
                [% IF ( patrons_in_category > 0 ) %]
294
                    Category [% categorycode |html %] is in use.  Deletion not possible!
295
                [% ELSE %]
296
                    Confirm deletion of category [% categorycode |html %]
297
                [% END %]
298
            </legend>
299
300
[% IF ( totalgtzero ) %]<div class="dialog alert"><strong>This category is used [% total %] times</strong>. Deletion not possible</div>[% END %]
301
	<table>
302
	<tr><th scope="row">Category code: </th><td>[% categorycode |html %]</td></tr>
303
	<tr><th scope="row">Description: </th><td>[% description |html %]</td></tr>
304
	<tr><th scope="row">Enrollment period: </th>
305
		<td>
306
			[% IF ( enrolmentperiod ) %]
307
				[% enrolmentperiod %] months
308
			[% ELSE %]
309
				until [% enrolmentperioddate | $KohaDates %]
310
			[% END %]
311
		</td>
312
	</tr>
313
	<tr><th scope="row">Age required: </th><td>[% dateofbirthrequired %] years</td></tr>
314
	<tr><th scope="row">Upperage limit: </th><td>[% upperagelimit %] years</td></tr>
315
	<tr><th scope="row">Enrollment fee: </th><td>[% enrolmentfee %]</td></tr>
316
	<tr><th scope="row">Receives overdue notices: </th><td>[% IF ( overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td></tr>
317
	<tr><th scope="row">Lost items in staff client</th><td>[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
318
	<tr><th scope="row">Hold fee: </th><td>[% reservefee %]</td></tr>
319
    <tr><th scope="row">Can be guarantee</th><td>[% IF ( canbeguarantee ) %]Yes[% ELSE %]No[% END %]</td></tr>
320
    <tr>
321
        <th scope="row">Default privacy: </th>
322
        <td>
323
            [% SWITCH category.default_privacy %]
324
            [% CASE 'default' %]
325
                Default
326
            [% CASE 'never' %]
327
                Never
328
            [% CASE 'forever' %]
329
                Forever
330
            [% END %]
331
        </td>
332
    </tr>
333
</table>
334
		<fieldset class="action">[% IF ( totalgtzero ) %]
335
<input type="submit" value="OK" /></form>
336
		[% ELSE %]
337
			<input type="hidden" name="op" value="delete_confirmed" />
338
            <input type="hidden" name="categorycode" value="[% categorycode |html %]" /> <input type="submit" value="Delete this category" /> <a class="cancel" href="/cgi-bin/koha/admin/categorie.pl">Cancel</a>
339
		[% END %]</fieldset></fieldset></form>
340
[% END %]
341
342
[% IF ( else ) %]
343
344
<div id="toolbar" class="btn-toolbar">
345
    <a class="btn btn-small" id="newcategory" href="/cgi-bin/koha/admin/categorie.pl?op=add_form"><i class="icon-plus"></i> New category</a>
346
</div>
347
348
<h2>Patron category administration</h2>
349
[% IF ( searchfield ) %]
350
		You Searched for [% searchfield %]</span>
351
	[% END %]
352
[% IF ( loop ) %]
353
<div id="pagertable_categorie">
354
</div>
355
        <table id="table_categorie">
356
		<thead>
357
        <tr>
358
			<th scope="col">Code</th>
359
			<th scope="col">Category name</th>
360
			<th scope="col">Type</th>
361
			<th scope="col">Enrollment period</th>
362
			<th scope="col">Age required</th>
363
			<th scope="col">Upper age limit</th>
364
			<th scope="col">Enrollment fee</th>
365
			<th scope="col">Overdue</th>
366
            <th scope="col">Lost items</th>
367
			<th scope="col">Hold fee</th>
368
            [% IF ( EnhancedMessagingPreferences ) %]
369
            <th scope="col">Messaging</th>
370
            [% END %]
371
            <th scope="col">Branches limitations</th>
372
            <th scope="col">Can be guarantee</th>
373
            <th scope="col">Default privacy</th>
374
            <th scope="col">&nbsp; </th>
375
            <th scope="col">&nbsp; </th>
376
        </tr>
377
		</thead>
378
        <tbody>
379
		[% FOREACH loo IN loop %]
380
			<tr>
381
                        <td>[% loo.categorycode |html %]</td>
382
                        <td>
383
                            <a href="[% loo.script_name %]?op=add_form&amp;categorycode=[% loo.categorycode |uri %]">[% loo.description |html %]</a>
384
                        </td>
385
                        <td>
386
                            [% IF ( loo.type_A ) %]Adult[% END %]
387
                            [% IF ( loo.type_C ) %]Child[% END %]
388
                            [% IF ( loo.type_P ) %]Prof.[% END %]
389
                            [% IF ( loo.type_I ) %]Org.[% END %]
390
                            [% IF ( loo.type_S ) %]Staff[% END %]
391
                            [% IF ( loo.type_X ) %]Statistical[% END %]
392
                        </td>
393
                        <td>
394
				[% IF ( loo.enrolmentperiod ) %]
395
					[% loo.enrolmentperiod %] months
396
				[% ELSE %]
397
					until [% loo.enrolmentperioddate | $KohaDates %]
398
				[% END %]
399
400
                        </td>
401
                        <td>[% loo.dateofbirthrequired %] years</td>
402
			<td>[% loo.upperagelimit %] years</td>
403
                        <td>[% loo.enrolmentfee %]</td>
404
                        <td>[% IF ( loo.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td>
405
                        <td>[% IF ( loo.hidelostitems ) %]Hidden[% ELSE %]Shown[% END %]</td>
406
                        <td>[% loo.reservefee %]</td>
407
                        [% IF ( EnhancedMessagingPreferences ) %]
408
                        <td style="white-space: nowrap; font-size:80%;">
409
                            [% IF ( loo.messaging_prefs ) %]
410
                              [% FOREACH prefs IN loo.messaging_prefs %]
411
	                                [% FOREACH transport IN prefs.transports %]
412
                                         [% IF ( transport.transport ) %]
413
                                            [% IF ( prefs.Item_Due ) %]Item due
414
                                            [% ELSIF ( prefs.Advance_Notice ) %]Advance notice
415
                                            [% ELSIF ( prefs.Upcoming_Events ) %]Upcoming events
416
                                            [% ELSIF ( prefs.Hold_Filled ) %]Hold filled
417
                                            [% ELSIF ( prefs.Item_Check_in ) %]Item check-in
418
                                            [% ELSIF ( prefs.Item_Checkout ) %]Item checkout
419
			                                [% ELSE %]Unknown
420
			                                [% END %]:
421
				                            <strong>[% transport.transport %]</strong><br />
422
				                         [% ELSE %]None<br />[% END %]
423
	                                [% END %]
424
                                [% END %]
425
                            [% ELSE %]
426
                                None
427
                            [% END %]
428
                        </td>
429
                        [% END %]
430
                        <td>
431
                            [% IF loo.branches.size > 0 %]
432
                                [% branches_str = "" %]
433
                                [% FOREACH branch IN loo.branches %]
434
                                    [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %]
435
                                [% END %]
436
                                <span title="[% branches_str %]">
437
                                    [% IF loo.branches.size > 1 %]
438
                                        [% loo.branches.size %] branches limitations
439
                                    [% ELSE %]
440
                                        [% loo.branches.size %] branch limitation
441
                                    [% END %]
442
                                </span>
443
                            [% ELSE %]
444
                                No limitation
445
                            [% END %]
446
                        </td>
447
                        <td>[% IF loo.canbeguarantee %]Yes[% ELSE %]No[% END %]</td>
448
                        <td>
449
                            [% SWITCH loo.default_privacy %]
450
                            [% CASE 'default' %]
451
                                Default
452
                            [% CASE 'never' %]
453
                                Never
454
                            [% CASE 'forever' %]
455
                                Forever
456
                            [% END %]
457
                        </td>
458
                        <td><a href="[% loo.script_name %]?op=add_form&amp;categorycode=[% loo.categorycode |uri %]">Edit</a></td>
459
                        <td><a href="[% loo.script_name %]?op=delete_confirm&amp;categorycode=[% loo.categorycode |uri %]">Delete</a></td>
460
		</tr>
461
		[% END %]
462
        </tbody>
463
	</table>
464
[% ELSE %]
465
	<div class="dialog alert">No categories have been defined. <a href="/cgi-bin/koha/admin/categorie.pl?op=add_form">Create a new category</a>.</div>
466
[% END %]
467
[% END %]
468
469
</div>
470
</div>
471
<div class="yui-b">
472
[% INCLUDE 'admin-menu.inc' %]
473
</div>
474
</div>
475
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt (+15 lines)
Lines 238-243 Link Here
238
                    </select>
238
                    </select>
239
                    <span class="required">Required</span>
239
                    <span class="required">Required</span>
240
                </li>
240
                </li>
241
                <li>
242
                    <label for="canbeguarantee">Can be guarantee</label>
243
                    <select name="canbeguarantee" id="canbeguarantee">
244
                        [% IF category.canbeguarantee %]
245
                            <option value="1" selected>Yes</option>
246
                            <option value="0">No</option>
247
                        [% ELSE %]
248
                            <option value="1">Yes</option>
249
                            <option value="0" selected>No</option>
250
                        [% END %]
251
                    <select>
252
                </li>
241
                <li><label for="branches">Branches limitation: </label>
253
                <li><label for="branches">Branches limitation: </label>
242
                    <select id="branches" name="branches" multiple size="10">
254
                    <select id="branches" name="branches" multiple size="10">
243
                        <option value="">All branches</option>
255
                        <option value="">All branches</option>
Lines 345-350 Link Here
345
                <tr><th scope="row">Receives overdue notices: </th><td>[% IF category. overduenoticerequired %]Yes[% ELSE %]No[% END %]</td></tr>
357
                <tr><th scope="row">Receives overdue notices: </th><td>[% IF category. overduenoticerequired %]Yes[% ELSE %]No[% END %]</td></tr>
346
                <tr><th scope="row">Lost items in staff client</th><td>[% IF category.hidelostitems %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
358
                <tr><th scope="row">Lost items in staff client</th><td>[% IF category.hidelostitems %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
347
                <tr><th scope="row">Hold fee: </th><td>[% category.reservefee | $Price %]</td></tr>
359
                <tr><th scope="row">Hold fee: </th><td>[% category.reservefee | $Price %]</td></tr>
360
                <tr><th scope="row">Can be guarantee</th><td>[% IF category.canbeguarantee %]Yes[% ELSE %]No[% END %]</td></tr>
348
                <tr>
361
                <tr>
349
                    <th scope="row">Default privacy: </th>
362
                    <th scope="row">Default privacy: </th>
350
                    <td>
363
                    <td>
Lines 401-406 Link Here
401
                    <th scope="col">Messaging</th>
414
                    <th scope="col">Messaging</th>
402
                    [% END %]
415
                    [% END %]
403
                    <th scope="col">Branches limitations</th>
416
                    <th scope="col">Branches limitations</th>
417
                    <th scope="col">Can be guarantee</th>
404
                    <th scope="col">Default privacy</th>
418
                    <th scope="col">Default privacy</th>
405
                    <th scope="col">&nbsp; </th>
419
                    <th scope="col">&nbsp; </th>
406
                    <th scope="col">&nbsp; </th>
420
                    <th scope="col">&nbsp; </th>
Lines 478-483 Link Here
478
                                No limitation
492
                                No limitation
479
                            [% END %]
493
                            [% END %]
480
                        </td>
494
                        </td>
495
                        <td>[% IF category.canbeguarantee %] Yes [% ELSE %] no [% END %]</td>
481
                        <td>
496
                        <td>
482
                            [% SWITCH category.default_privacy %]
497
                            [% SWITCH category.default_privacy %]
483
                            [% CASE 'default' %]
498
                            [% CASE 'default' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+5 lines)
Lines 159-164 Patrons: Link Here
159
               yes: Do
159
               yes: Do
160
               no: "Don't"
160
               no: "Don't"
161
         - charge a fee when a patron changes to a category with an enrollment fee.
161
         - charge a fee when a patron changes to a category with an enrollment fee.
162
     -
163
         - "These additional following <a href='http://schema.koha-community.org/tables/borrowers.html' target='blank'>database columns</a> will be transferred from guarantor to guarantee:"
164
         - pref: AdditionalGuarantorField
165
           class: multi
166
         - (separate columns with |)
162
    "Norwegian patron database":
167
    "Norwegian patron database":
163
     -
168
     -
164
         - pref: NorwegianPatronDBEnable
169
         - pref: NorwegianPatronDBEnable
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-12 / +6 lines)
Lines 131-144 Link Here
131
            .val(borrower.firstname)
131
            .val(borrower.firstname)
132
            .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden';
132
            .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden';
133
133
134
        form.streetnumber.value = borrower.streetnumber;
134
        [% FOREACH field IN guarantor_attributes %]
135
        form.address.value = borrower.address;
135
            $(form.[% field %]).val(borrower.[% field %]);
136
        form.address2.value = borrower.address2;
136
        [% END %]
137
        form.city.value = borrower.city;
138
        form.state.value = borrower.state;
139
        form.zipcode.value = borrower.zipcode;
140
        form.country.value = borrower.country;
141
        form.branchcode.value = borrower.branchcode;
142
137
143
        form.guarantorsearch.value = _("Change");
138
        form.guarantorsearch.value = _("Change");
144
139
Lines 435-441 Link Here
435
	            [% END %]
430
	            [% END %]
436
	        </li>
431
	        </li>
437
[% ELSE %]
432
[% ELSE %]
438
 [% IF ( C ) %]
439
 [% IF ( guarantorid ) %]
433
 [% IF ( guarantorid ) %]
440
 <li id="contact-details">
434
 <li id="contact-details">
441
 [% ELSE %]
435
 [% ELSE %]
Lines 453-461 Link Here
453
        <input name="contactname" id="contactname" type="text" size="20" value="[% contactname %]" />
447
        <input name="contactname" id="contactname" type="text" size="20" value="[% contactname %]" />
454
     [% END %]
448
     [% END %]
455
 </li>
449
 </li>
456
        [% END %]
450
     [% UNLESS nocontactfirstname %]
457
        [% UNLESS nocontactfirstname %]
451
<li>
458
 <li>
459
     <label for="contactfirstname">First name: </label>
452
     <label for="contactfirstname">First name: </label>
460
     [% IF ( guarantorid ) %]
453
     [% IF ( guarantorid ) %]
461
     <span>[% contactfirstname %]</span>
454
     <span>[% contactfirstname %]</span>
Lines 1025-1030 Link Here
1025
                <li data-category_code="[% patron_attribute.category_code %]">
1018
                <li data-category_code="[% patron_attribute.category_code %]">
1026
                    <label for="[% patron_attribute.form_id %]">[% patron_attribute.description %]: </label>
1019
                    <label for="[% patron_attribute.form_id %]">[% patron_attribute.description %]: </label>
1027
                        <input type="hidden" id="[% patron_attribute.form_id %]_code" name="[% patron_attribute.form_id %]_code" value="[% patron_attribute.code |html %]" />
1020
                        <input type="hidden" id="[% patron_attribute.form_id %]_code" name="[% patron_attribute.form_id %]_code" value="[% patron_attribute.code |html %]" />
1021
                        <input type="hidden" id="[% patron_attribute.form_id %]_desc" name="[% patron_attribute.form_id %]_desc" value="[% patron_attribute.description |html %]" />
1028
                        [% IF ( patron_attribute.use_dropdown ) %]
1022
                        [% IF ( patron_attribute.use_dropdown ) %]
1029
                            <select id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">
1023
                            <select id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">
1030
                                <option value=""></option>
1024
                                <option value=""></option>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-3 / +14 lines)
Lines 232-244 function validate1(date) { Link Here
232
    </li>[% END %][% END %]
232
    </li>[% END %][% END %]
233
    [% IF ( isguarantee ) %]
233
    [% IF ( isguarantee ) %]
234
        [% IF ( guaranteeloop ) %]
234
        [% IF ( guaranteeloop ) %]
235
            <li><span class="label">Guarantees:</span><ul>[% FOREACH guaranteeloo IN guaranteeloop %]<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber %]">[% guaranteeloo.name %]  </a></li>[% END %]</ul></li>
235
            <li><span class="label">Guarantees:</span>
236
                <table>[% FOREACH guaranteeloo IN guaranteeloop %]
237
                <tr>
238
                    <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber %]">[% guaranteeloo.name %]</a></td>
239
                    <td style='text-align:right'>[% guaranteeloo.finesguarantee %] $</td>
240
                </tr>[% END %]
241
                <tr>
242
                    <td>Total</td>
243
                    <td style='text-align:right'>[% amounttot %] $</td>
244
                </tr>
245
                </table>
246
            </li>
236
        [% END %]
247
        [% END %]
237
    [% ELSE %]
248
    [% END %]
238
        [% IF ( guarantorborrowernumber ) %]
249
        [% IF ( guarantorborrowernumber ) %]
239
            <li><span class="label">Guarantor:</span><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantorborrowernumber %]">[% guarantorsurname %][%IF ( guarantorfirstname ) %], [% guarantorfirstname %] [% END %]</a></li>
250
            <li><span class="label">Guarantor:</span><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantorborrowernumber %]">[% guarantorsurname %][%IF ( guarantorfirstname ) %], [% guarantorfirstname %] [% END %]</a></li>
240
        [% END %]
251
        [% END %]
241
    [% END %]
252
242
</ol>
253
</ol>
243
</div>
254
</div>
244
      <div class="action">
255
      <div class="action">
(-)a/members/memberentry.pl (-4 / +13 lines)
Lines 39-44 use C4::Log; Link Here
39
use C4::Letters;
39
use C4::Letters;
40
use C4::Branch; # GetBranches
40
use C4::Branch; # GetBranches
41
use C4::Form::MessagingPreferences;
41
use C4::Form::MessagingPreferences;
42
use C4::Category;
42
use Koha::Borrower::Debarments;
43
use Koha::Borrower::Debarments;
43
use Koha::DateUtils;
44
use Koha::DateUtils;
44
use Email::Valid;
45
use Email::Valid;
Lines 232-239 if ( ( $op eq 'insert' ) and !$nodouble ) { Link Here
232
    }
233
    }
233
}
234
}
234
235
235
  #recover all data from guarantor address phone ,fax... 
236
#recover all data from guarantor address phone ,fax...
236
if ( $guarantorid ) {
237
if ( $guarantorid and ( $category_type eq 'C' || $category_type eq 'P')) {
238
237
    if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
239
    if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
238
        $category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
240
        $category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
239
        $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
241
        $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
Lines 245-252 if ( $guarantorid ) { Link Here
245
                        zipcode country city state phone phonepro mobile fax email emailpro branchcode
247
                        zipcode country city state phone phonepro mobile fax email emailpro branchcode
246
                        B_streetnumber B_streettype B_address B_address2
248
                        B_streetnumber B_streettype B_address B_address2
247
                        B_city B_state B_zipcode B_country B_email B_phone)) {
249
                        B_city B_state B_zipcode B_country B_email B_phone)) {
248
		        $newdata{$_} = $guarantordata->{$_};
250
                        $newdata{$_} = $guarantordata->{$_};
249
	        }
251
	        }
252
            my $additionalGuarantorField=C4::Context->preference("AdditionalGuarantorField");
253
            my @field_add=split(/\|/,$additionalGuarantorField);
254
            my $guarantordata=GetMember(borrowernumber => $guarantorid);
255
            foreach (@field_add) {
256
                $newdata{$_} = $guarantordata->{$_};
257
            }
250
        }
258
        }
251
    }
259
    }
252
}
260
}
Lines 674-680 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
674
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
682
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
675
}
683
}
676
684
677
$template->param( "showguarantor"  => ($category_type=~/A|I|S|X/) ? 0 : 1); # associate with step to know where you are
685
$template->param( "showguarantor"  => $categorycode ? C4::Category->get($categorycode)->{'canbeguarantee'} : 1); # associate with step to know where you are
686
$template->param( "guarantor_attributes" => C4::Members::Attributes::get_guarantor_shared_attributes() );
678
$debug and warn "memberentry step: $step";
687
$debug and warn "memberentry step: $step";
679
$template->param(%data);
688
$template->param(%data);
680
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
689
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
(-)a/members/moremember.pl (-14 / +14 lines)
Lines 171-203 if ( $count ) { Link Here
171
    # the array, which is probably better done as a foreach loop.
171
    # the array, which is probably better done as a foreach loop.
172
    #
172
    #
173
    my @guaranteedata;
173
    my @guaranteedata;
174
    my $amount;
175
    my $totalmount = 0;
176
174
    for ( my $i = 0 ; $i < $count ; $i++ ) {
177
    for ( my $i = 0 ; $i < $count ; $i++ ) {
178
        my ($amount,$accts,undef) = GetMemberAccountRecords($guarantees->[$i]->{'borrowernumber'});
175
        push(@guaranteedata,
179
        push(@guaranteedata,
176
            {
180
            {
177
                borrowernumber => $guarantees->[$i]->{'borrowernumber'},
181
                borrowernumber => $guarantees->[$i]->{'borrowernumber'},
178
                cardnumber     => $guarantees->[$i]->{'cardnumber'},
182
                cardnumber     => $guarantees->[$i]->{'cardnumber'},
183
                finesguarantee => sprintf("%.2f",$amount),
179
                name           => $guarantees->[$i]->{'firstname'} . " "
184
                name           => $guarantees->[$i]->{'firstname'} . " "
180
                                . $guarantees->[$i]->{'surname'}
185
                                . $guarantees->[$i]->{'surname'}
181
            }
186
            }
182
        );
187
        );
188
        $totalmount += $amount;
183
    }
189
    }
184
    $template->param( guaranteeloop => \@guaranteedata );
190
    $template->param( guaranteeloop => \@guaranteedata );
191
    $template->param( amounttot => sprintf("%.2f",$totalmount));
185
}
192
}
186
else {
193
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' || $category_type eq 'I' );
187
    if ($data->{'guarantorid'}){
194
188
	    my ($guarantor) = GetMember( 'borrowernumber' =>$data->{'guarantorid'});
195
if ($data->{'guarantorid'}){
189
		$template->param(guarantor => 1);
196
    my ($guarantor) = GetMember( 'borrowernumber' =>$data->{'guarantorid'});
190
		foreach (qw(borrowernumber cardnumber firstname surname)) {        
197
    $template->param(guarantor => 1);
191
			  $template->param("guarantor$_" => $guarantor->{$_});
198
    foreach (qw(borrowernumber cardnumber firstname surname)) {
192
        }
199
          $template->param("guarantor$_" => $guarantor->{$_});
193
    }
200
    }
194
	if ($category_type eq 'C'){
195
		$template->param('C' => 1);
196
	}
197
}
201
}
198
199
$template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' );
200
201
my %bor;
202
my %bor;
202
$bor{'borrowernumber'} = $borrowernumber;
203
$bor{'borrowernumber'} = $borrowernumber;
203
204
204
- 

Return to bug 12446