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 60-65 Link Here
60
            <main>
60
            <main>
61
                [% INCLUDE 'messages.inc' %]
61
                [% INCLUDE 'messages.inc' %]
62
62
63
63
                [% IF ( op == 'show_form' ) %]
64
                [% IF ( op == 'show_form' ) %]
64
                    <h1>Batch patron modification</h1>
65
                    <h1>Batch patron modification</h1>
65
                    <form id="patron_batchmod_form" method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
66
                    <form id="patron_batchmod_form" method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
Lines 262-267 Link Here
262
                                                [% END %]
263
                                                [% END %]
263
                                                <th>Circulation note</th>
264
                                                <th>Circulation note</th>
264
                                                <th>OPAC note</th>
265
                                                <th>OPAC note</th>
266
                                                <th>Message</th>
265
                                                <th>Restriction expiration</th>
267
                                                <th>Restriction expiration</th>
266
                                                <th>Restriction comment</th>
268
                                                <th>Restriction comment</th>
267
                                                [% FOREACH attrh IN attributes_header %]
269
                                                [% FOREACH attrh IN attributes_header %]
Lines 308-313 Link Here
308
                                                    [% END %]
310
                                                    [% END %]
309
                                                    <td>[% borrower.borrowernotes | $raw | html_line_break %]</td>
311
                                                    <td>[% borrower.borrowernotes | $raw | html_line_break %]</td>
310
                                                    <td>[% borrower.opacnote | html %]</td>
312
                                                    <td>[% borrower.opacnote | html %]</td>
313
                                                    <td>
314
                                                        [% FOREACH patron_message IN borrower.patron_messages %]
315
                                                            [% patron_message.message | html %] <br>
316
                                                            <strong>
317
                                                            [% IF (patron_message.message_type == 'B') %]
318
                                                                ( OPAC )
319
                                                            [% ELSE %]
320
                                                                ( Staff )
321
                                                            [% END %]
322
                                                            </strong><br><br>
323
                                                        [% END %]
324
                                                    </td>
311
                                                    <td data-order="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</td>
325
                                                    <td data-order="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</td>
312
                                                    <td>[% borrower.debarredcomment | html %]</td>
326
                                                    <td>[% borrower.debarredcomment | html %]</td>
313
                                                    [% FOREACH pa IN borrower.patron_attributes %]
327
                                                    [% FOREACH pa IN borrower.patron_attributes %]
Lines 360-365 Link Here
360
                                                [% CASE 'dateexpiry' %]<span>Expiry date:</span>
374
                                                [% CASE 'dateexpiry' %]<span>Expiry date:</span>
361
                                                [% CASE 'borrowernotes' %]<span>Circulation note:</span>
375
                                                [% CASE 'borrowernotes' %]<span>Circulation note:</span>
362
                                                [% CASE 'opacnote' %]<span>OPAC note:</span>
376
                                                [% CASE 'opacnote' %]<span>OPAC note:</span>
377
                                                [% CASE "message" %]<span>Message:</span>
363
                                                [% CASE 'debarred' %]<span>Restriction expiration:</span>
378
                                                [% CASE 'debarred' %]<span>Restriction expiration:</span>
364
                                                [% CASE 'debarredcomment' %]<span>Restriction comment:</span>
379
                                                [% CASE 'debarredcomment' %]<span>Restriction comment:</span>
365
                                                [% CASE 'password_expiration_date' %]<span>Password expiration date:</span>
380
                                                [% CASE 'password_expiration_date' %]<span>Password expiration date:</span>
Lines 368-373 Link Here
368
                                            [% IF ( field.type == 'text' ) %]
383
                                            [% IF ( field.type == 'text' ) %]
369
                                                <input type="text" id="[%field.name | html %]" name="[% field.name | html %]" value="" />
384
                                                <input type="text" id="[%field.name | html %]" name="[% field.name | html %]" value="" />
370
                                            [% END %]
385
                                            [% END %]
386
                                            [% IF ( field.type == 'message_type' ) %]
387
                                                <input type="text" name="[% field.name | html %]" value="" />
388
                                                <select name="add_message_type" id="message_type">
389
                                                    <option value="L">Staff - Internal note</option>
390
                                                    <option value="B">OPAC</option>
391
                                                </select>
392
                                            [% END %]
371
                                            [% IF ( field.type == 'select' ) %]
393
                                            [% IF ( field.type == 'select' ) %]
372
                                                [% IF field.option.size %]
394
                                                [% IF field.option.size %]
373
                                                    <select id="[%field.name | html %]" name="[% field.name | html %]" >
395
                                                    <select id="[%field.name | html %]" 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 );
39
use Koha::Patron::Debarments qw( AddDebarment DelDebarment );
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 111-116 if ( $op eq 'cud-show' || $op eq 'show' ) { Link Here
111
            if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
113
            if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
112
                my $borrower = $patron->unblessed;
114
                my $borrower = $patron->unblessed;
113
                my $attributes = $patron->extended_attributes;
115
                my $attributes = $patron->extended_attributes;
116
                my $patron_messages = Koha::Patron::Messages->search(
117
                    {
118
                        'me.borrowernumber' => $patron->borrowernumber,
119
                    }
120
                );
121
                $borrower->{patron_messages} = $patron_messages->as_list;
114
                $borrower->{patron_attributes} = $attributes->as_list;
122
                $borrower->{patron_attributes} = $attributes->as_list;
115
                $borrower->{patron_attributes_count} = $attributes->count;
123
                $borrower->{patron_attributes_count} = $attributes->count;
116
                $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr;
124
                $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr;
Lines 322-327 if ( $op eq 'cud-show' || $op eq 'show' ) { Link Here
322
            mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0,
330
            mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0,
323
        }
331
        }
324
        ,
332
        ,
333
        {
334
            name => "message",
335
            type => "message_type",
336
            mandatory => ( grep /message/, @mandatoryFields ) ? 1 : 0,
337
        }
338
        ,
325
        {
339
        {
326
            name => "debarred",
340
            name => "debarred",
327
            type => "date",
341
            type => "date",
Lines 392-398 if ( $op eq 'cud-do' ) { Link Here
392
                   }
406
                   }
393
                };
407
                };
394
            }
408
            }
395
409
            # If 'message' or 'add_message_type' is defined then delete both at the same time
410
            if ( grep { $_ eq 'message' } @disabled) {
411
                my $patron = Koha::Patrons->find( $borrowernumber );
412
                $patron->messages()->delete();
413
            }
396
            $infos->{borrowernumber} = $borrowernumber;
414
            $infos->{borrowernumber} = $borrowernumber;
397
            eval { $patron->set($infos)->store; };
415
            eval { $patron->set($infos)->store; };
398
            if ( $@ ) { # FIXME We could provide better error handling here
416
            if ( $@ ) { # FIXME We could provide better error handling here
Lines 433-439 if ( $op eq 'cud-do' ) { Link Here
433
                push @errors, { error => $@ } if $@;
451
                push @errors, { error => $@ } if $@;
434
            }
452
            }
435
        }
453
        }
454
455
        # Handle patron messages
456
        my $message          = $input->param('message');
457
        my $branchcode       = C4::Context::mybranch;
458
        my $message_type     = $input->param('add_message_type');
459
460
        Koha::Patron::Message->new(
461
            {
462
                borrowernumber => $borrowernumber,
463
                branchcode     => $branchcode,
464
                message_type   => $message_type,
465
                message        => $message,
466
            }
467
        )->store;
436
    }
468
    }
469
437
    $op = "show_results"; # We have process modifications, the user want to view its
470
    $op = "show_results"; # We have process modifications, the user want to view its
438
471
439
    # Construct the results list
472
    # Construct the results list
Lines 444-449 if ( $op eq 'cud-do' ) { Link Here
444
        if ( $patron ) {
477
        if ( $patron ) {
445
            my $category_description = $patron->category->description;
478
            my $category_description = $patron->category->description;
446
            my $borrower = $patron->unblessed;
479
            my $borrower = $patron->unblessed;
480
            my $patron_messages = Koha::Patron::Messages->search(
481
                    {
482
                        'me.borrowernumber' => $patron->borrowernumber,
483
                    }
484
                );
485
            $borrower->{patron_messages} = $patron_messages->as_list;
447
            $borrower->{category_description} = $category_description;
486
            $borrower->{category_description} = $category_description;
448
            my $attributes = $patron->extended_attributes;
487
            my $attributes = $patron->extended_attributes;
449
            $borrower->{patron_attributes} = $attributes->as_list;
488
            $borrower->{patron_attributes} = $attributes->as_list;
450
- 

Return to bug 27123