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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt (+22 lines)
Lines 34-39 Link Here
34
        <div class="col-sm-10 col-sm-push-2">
34
        <div class="col-sm-10 col-sm-push-2">
35
            <main>
35
            <main>
36
36
37
37
                [% IF ( op == 'show_form' ) %]
38
                [% IF ( op == 'show_form' ) %]
38
                <h1>Batch patron modification</h1>
39
                <h1>Batch patron modification</h1>
39
                <form id="patron_batchmod_form" method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
40
                <form id="patron_batchmod_form" method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
Lines 223-228 Link Here
223
                                                <th>Expiry date</th>
224
                                                <th>Expiry date</th>
224
                                                <th>Circulation note</th>
225
                                                <th>Circulation note</th>
225
                                                <th>OPAC note</th>
226
                                                <th>OPAC note</th>
227
                                                <th>Message</th>
226
                                                <th>Restriction expiration</th>
228
                                                <th>Restriction expiration</th>
227
                                                <th>Restriction comment</th>
229
                                                <th>Restriction comment</th>
228
                                                [% FOREACH attrh IN attributes_header %]
230
                                                [% FOREACH attrh IN attributes_header %]
Lines 259-264 Link Here
259
                                                    <td data-order="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</td>
261
                                                    <td data-order="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</td>
260
                                                    <td>[% borrower.borrowernotes | html %]</td>
262
                                                    <td>[% borrower.borrowernotes | html %]</td>
261
                                                    <td>[% borrower.opacnote | html %]</td>
263
                                                    <td>[% borrower.opacnote | html %]</td>
264
                                                    <td>
265
                                                        [% FOREACH patron_message IN borrower.patron_messages %]
266
                                                            [% patron_message.message | html %] <br>
267
                                                            <strong>
268
                                                            [% IF (patron_message.message_type == 'B') %]
269
                                                                ( OPAC )
270
                                                            [% ELSE %]
271
                                                                ( Staff )
272
                                                            [% END %]
273
                                                            </strong><br><br>
274
                                                        [% END %]
275
                                                    </td>
262
                                                    <td data-order="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</td>
276
                                                    <td data-order="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</td>
263
                                                    <td>[% borrower.debarredcomment | html %]</td>
277
                                                    <td>[% borrower.debarredcomment | html %]</td>
264
                                                    [% FOREACH pa IN borrower.patron_attributes %]
278
                                                    [% FOREACH pa IN borrower.patron_attributes %]
Lines 310-315 Link Here
310
                                                [% CASE 'dateexpiry' %]<span>Expiry date:</span>
324
                                                [% CASE 'dateexpiry' %]<span>Expiry date:</span>
311
                                                [% CASE 'borrowernotes' %]<span>Circulation note:</span>
325
                                                [% CASE 'borrowernotes' %]<span>Circulation note:</span>
312
                                                [% CASE 'opacnote' %]<span>OPAC note:</span>
326
                                                [% CASE 'opacnote' %]<span>OPAC note:</span>
327
                                                [% CASE "message" %]<span>Message:</span>
313
                                                [% CASE 'debarred' %]<span>Restriction expiration:</span>
328
                                                [% CASE 'debarred' %]<span>Restriction expiration:</span>
314
                                                [% CASE 'debarredcomment' %]<span>Restriction comment:</span>
329
                                                [% CASE 'debarredcomment' %]<span>Restriction comment:</span>
315
                                            [% END %]
330
                                            [% END %]
Lines 317-322 Link Here
317
                                            [% IF ( field.type == 'text' ) %]
332
                                            [% IF ( field.type == 'text' ) %]
318
                                                <input type="text" name="[% field.name | html %]" value="" />
333
                                                <input type="text" name="[% field.name | html %]" value="" />
319
                                            [% END %]
334
                                            [% END %]
335
                                            [% IF ( field.type == 'message_type' ) %]
336
                                                <input type="text" name="[% field.name | html %]" value="" />
337
                                                <select name="add_message_type" id="message_type">
338
                                                    <option value="L">Staff - Internal note</option>
339
                                                    <option value="B">OPAC</option>
340
                                                </select>
341
                                            [% END %]
320
                                            [% IF ( field.type == 'select' ) %]
342
                                            [% IF ( field.type == 'select' ) %]
321
                                                [% IF field.option.size %]
343
                                                [% IF field.option.size %]
322
                                                    <select name="[% field.name | html %]" >
344
                                                    <select name="[% field.name | html %]" >
(-)a/tools/modborrowers.pl (-2 / +40 lines)
Lines 31-36 use C4::Auth qw( get_template_and_user ); Link Here
31
use C4::Koha qw( GetAuthorisedValues );
31
use C4::Koha qw( GetAuthorisedValues );
32
use C4::Members;
32
use C4::Members;
33
use C4::Output qw( output_html_with_http_headers );
33
use C4::Output qw( output_html_with_http_headers );
34
use C4::Context;
34
use Koha::DateUtils qw( dt_from_string );
35
use Koha::DateUtils qw( dt_from_string );
35
use Koha::List::Patron qw( GetPatronLists );
36
use Koha::List::Patron qw( GetPatronLists );
36
use Koha::Libraries;
37
use Koha::Libraries;
Lines 38-43 use Koha::Patron::Categories; Link Here
38
use Koha::Patron::Debarments qw( AddDebarment DelDebarment GetDebarments );
39
use Koha::Patron::Debarments qw( AddDebarment DelDebarment GetDebarments );
39
use Koha::Patrons;
40
use Koha::Patrons;
40
use List::MoreUtils qw(uniq);
41
use List::MoreUtils qw(uniq);
42
use Koha::Patron::Messages;
41
43
42
my $input = CGI->new;
44
my $input = CGI->new;
43
my $op = $input->param('op') || 'show_form';
45
my $op = $input->param('op') || 'show_form';
Lines 109-114 if ( $op eq 'show' ) { Link Here
109
            if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
111
            if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
110
                my $borrower = $patron->unblessed;
112
                my $borrower = $patron->unblessed;
111
                my $attributes = $patron->extended_attributes;
113
                my $attributes = $patron->extended_attributes;
114
                my $patron_messages = Koha::Patron::Messages->search(
115
                    {
116
                        'me.borrowernumber' => $patron->borrowernumber,
117
                    }
118
                );
119
                $borrower->{patron_messages} = $patron_messages->as_list;
112
                $borrower->{patron_attributes} = $attributes->as_list;
120
                $borrower->{patron_attributes} = $attributes->as_list;
113
                $borrower->{patron_attributes_count} = $attributes->count;
121
                $borrower->{patron_attributes_count} = $attributes->count;
114
                $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr;
122
                $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr;
Lines 317-322 if ( $op eq 'show' ) { Link Here
317
            mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0,
325
            mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0,
318
        }
326
        }
319
        ,
327
        ,
328
        {
329
            name => "message",
330
            type => "message_type",
331
            mandatory => ( grep /message/, @mandatoryFields ) ? 1 : 0,
332
        }
333
        ,
320
        {
334
        {
321
            name => "debarred",
335
            name => "debarred",
322
            type => "date",
336
            type => "date",
Lines 380-386 if ( $op eq 'do' ) { Link Here
380
                   }
394
                   }
381
                };
395
                };
382
            }
396
            }
383
397
            # If 'message' or 'add_message_type' is defined then delete both at the same time
398
            if ( grep { $_ eq 'message' } @disabled) {
399
                my $patron = Koha::Patrons->find( $borrowernumber );
400
                $patron->messages()->delete();
401
            }
384
            $infos->{borrowernumber} = $borrowernumber;
402
            $infos->{borrowernumber} = $borrowernumber;
385
            eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; };
403
            eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; };
386
            if ( $@ ) { # FIXME We could provide better error handling here
404
            if ( $@ ) { # FIXME We could provide better error handling here
Lines 419-425 if ( $op eq 'do' ) { Link Here
419
            }
437
            }
420
            $i++;
438
            $i++;
421
        }
439
        }
440
441
        # Handle patron messages
442
        my $message          = $input->param('message');
443
        my $branchcode       = C4::Context::mybranch;
444
        my $message_type     = $input->param('add_message_type');
445
446
        Koha::Patron::Message->new(
447
            {
448
                borrowernumber => $borrowernumber,
449
                branchcode     => $branchcode,
450
                message_type   => $message_type,
451
                message        => $message,
452
            }
453
        )->store;
422
    }
454
    }
455
423
    $op = "show_results"; # We have process modifications, the user want to view its
456
    $op = "show_results"; # We have process modifications, the user want to view its
424
457
425
    # Construct the results list
458
    # Construct the results list
Lines 430-435 if ( $op eq 'do' ) { Link Here
430
        if ( $patron ) {
463
        if ( $patron ) {
431
            my $category_description = $patron->category->description;
464
            my $category_description = $patron->category->description;
432
            my $borrower = $patron->unblessed;
465
            my $borrower = $patron->unblessed;
466
            my $patron_messages = Koha::Patron::Messages->search(
467
                    {
468
                        'me.borrowernumber' => $patron->borrowernumber,
469
                    }
470
                );
471
            $borrower->{patron_messages} = $patron_messages->as_list;
433
            $borrower->{category_description} = $category_description;
472
            $borrower->{category_description} = $category_description;
434
            my $attributes = $patron->extended_attributes;
473
            my $attributes = $patron->extended_attributes;
435
            $borrower->{patron_attributes} = $attributes->as_list;
474
            $borrower->{patron_attributes} = $attributes->as_list;
436
- 

Return to bug 27123