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 223-228 Link Here
223
                                                <th>Expiry date</th>
223
                                                <th>Expiry date</th>
224
                                                <th>Circulation note</th>
224
                                                <th>Circulation note</th>
225
                                                <th>OPAC note</th>
225
                                                <th>OPAC note</th>
226
                                                <th>Message</th>
226
                                                <th>Restriction expiration</th>
227
                                                <th>Restriction expiration</th>
227
                                                <th>Restriction comment</th>
228
                                                <th>Restriction comment</th>
228
                                                [% FOREACH attrh IN attributes_header %]
229
                                                [% FOREACH attrh IN attributes_header %]
Lines 259-264 Link Here
259
                                                    <td data-order="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</td>
260
                                                    <td data-order="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</td>
260
                                                    <td>[% borrower.borrowernotes | html %]</td>
261
                                                    <td>[% borrower.borrowernotes | html %]</td>
261
                                                    <td>[% borrower.opacnote | html %]</td>
262
                                                    <td>[% borrower.opacnote | html %]</td>
263
                                                    <td>
264
                                                        [% FOREACH patron_message IN borrower.patron_messages %]
265
                                                            [% patron_message.message %] <br>
266
                                                            <strong>
267
                                                            [% IF (patron_message.message_type == 'B') %]
268
                                                                ( OPAC )
269
                                                            [% ELSE %]
270
                                                                ( Staff )
271
                                                            [% END %]
272
                                                            </strong><br><br>
273
                                                        [% END %]                                 
274
                                                    </td>
262
                                                    <td data-order="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</td>
275
                                                    <td data-order="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</td>
263
                                                    <td>[% borrower.debarredcomment | html %]</td>
276
                                                    <td>[% borrower.debarredcomment | html %]</td>
264
                                                    [% FOREACH pa IN borrower.patron_attributes %]
277
                                                    [% FOREACH pa IN borrower.patron_attributes %]
Lines 330-335 Link Here
330
                                                Circulation note:
343
                                                Circulation note:
331
                                                [% CASE 'opacnote' %]
344
                                                [% CASE 'opacnote' %]
332
                                                OPAC note:
345
                                                OPAC note:
346
                                                [% CASE "message" %]
347
                                                Message:
333
                                                [% CASE 'debarred' %]
348
                                                [% CASE 'debarred' %]
334
                                                Restriction expiration:
349
                                                Restriction expiration:
335
                                                [% CASE 'debarredcomment' %]
350
                                                [% CASE 'debarredcomment' %]
Lines 339-344 Link Here
339
                                            [% IF ( field.type == 'text' ) %]
354
                                            [% IF ( field.type == 'text' ) %]
340
                                                <input type="text" name="[% field.name | html %]" value="" />
355
                                                <input type="text" name="[% field.name | html %]" value="" />
341
                                            [% END %]
356
                                            [% END %]
357
                                            [% IF ( field.type == 'message_type' ) %]
358
                                                <input type="text" name="[% field.name | html %]" value="" />
359
                                                <select name="add_message_type" id="message_type">
360
                                                    <option value="L">Staff - Internal note</option>
361
                                                    <option value="B">OPAC</option>
362
                                                </select>
363
                                            [% END %]
342
                                            [% IF ( field.type == 'select' ) %]
364
                                            [% IF ( field.type == 'select' ) %]
343
                                                [% IF field.option.size %]
365
                                                [% IF field.option.size %]
344
                                                    <select name="[% field.name | html %]" >
366
                                                    <select name="[% field.name | html %]" >
(-)a/tools/modborrowers.pl (-2 / +49 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 111-116 if ( $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 319-324 if ( $op eq 'show' ) { Link Here
319
            mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0,
327
            mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0,
320
        }
328
        }
321
        ,
329
        ,
330
        {
331
            name => "message",
332
            type => "message_type",
333
            mandatory => ( grep /message/, @mandatoryFields ) ? 1 : 0,
334
        }
335
        ,
322
        {
336
        {
323
            name => "debarred",
337
            name => "debarred",
324
            type => "date",
338
            type => "date",
Lines 382-388 if ( $op eq 'do' ) { Link Here
382
                   }
396
                   }
383
                };
397
                };
384
            }
398
            }
385
399
            # If 'message' or 'add_message_type' is defined then delete both at the same time
400
            if ( grep { $_ eq 'message' } @disabled) {
401
                my $patron = Koha::Patrons->find( $borrowernumber );                
402
                $patron->messages()->delete();
403
            }
386
            $infos->{borrowernumber} = $borrowernumber;
404
            $infos->{borrowernumber} = $borrowernumber;
387
            eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; };
405
            eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; };
388
            if ( $@ ) { # FIXME We could provide better error handling here
406
            if ( $@ ) { # FIXME We could provide better error handling here
Lines 421-426 if ( $op eq 'do' ) { Link Here
421
            }
439
            }
422
            $i++;
440
            $i++;
423
        }
441
        }
442
        # Créer un bloc pour enregistrer en bdd l'update de la table patron_messages + sécurité : 'si' tel champ est remplit alors.... etc
443
        my $patron_messages = Koha::Patron::Messages->search(
444
            {
445
                'me.borrowernumber' => $patron->borrowernumber,
446
            }
447
        );
448
        if ( defined $patron_messages ) {
449
            if ( defined $infos ) {
450
                my $message          = $input->param('message');
451
                my $borrowernumber   = $patron->borrowernumber;
452
                my $branchcode       = C4::Context::mybranch;
453
                my $message_type     = $input->param('add_message_type');
454
455
                Koha::Patron::Message->new(
456
                    {
457
                        borrowernumber => $borrowernumber,
458
                        branchcode     => $branchcode,
459
                        message_type   => $message_type,
460
                        message        => $message,
461
                    }
462
                )->store;
463
                $template->param( message_type => $message_type );
464
            }
465
        }
424
    }
466
    }
425
    $op = "show_results"; # We have process modifications, the user want to view its
467
    $op = "show_results"; # We have process modifications, the user want to view its
426
468
Lines 432-437 if ( $op eq 'do' ) { Link Here
432
        if ( $patron ) {
474
        if ( $patron ) {
433
            my $category_description = $patron->category->description;
475
            my $category_description = $patron->category->description;
434
            my $borrower = $patron->unblessed;
476
            my $borrower = $patron->unblessed;
477
            my $patron_messages = Koha::Patron::Messages->search(
478
                    {
479
                        'me.borrowernumber' => $patron->borrowernumber,
480
                    }
481
                );
482
            $borrower->{patron_messages} = $patron_messages->as_list;
435
            $borrower->{category_description} = $category_description;
483
            $borrower->{category_description} = $category_description;
436
            my $attributes = $patron->extended_attributes;
484
            my $attributes = $patron->extended_attributes;
437
            $borrower->{patron_attributes} = $attributes->as_list;
485
            $borrower->{patron_attributes} = $attributes->as_list;
438
- 

Return to bug 27123