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-42 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;
37
use Koha::Patron::Categories;
38
use Koha::Patron::Categories;
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;
41
use Koha::Patron::Messages;
40
42
41
my $input = CGI->new;
43
my $input = CGI->new;
42
my $op = $input->param('op') || 'show_form';
44
my $op = $input->param('op') || 'show_form';
Lines 107-112 if ( $op eq 'show' ) { Link Here
107
            if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
109
            if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
108
                my $borrower = $patron->unblessed;
110
                my $borrower = $patron->unblessed;
109
                my $attributes = $patron->extended_attributes;
111
                my $attributes = $patron->extended_attributes;
112
                my $patron_messages = Koha::Patron::Messages->search(
113
                    {
114
                        'me.borrowernumber' => $patron->borrowernumber,
115
                    }
116
                );
117
                $borrower->{patron_messages} = $patron_messages->as_list;
110
                $borrower->{patron_attributes} = $attributes->as_list;
118
                $borrower->{patron_attributes} = $attributes->as_list;
111
                $borrower->{patron_attributes_count} = $attributes->count;
119
                $borrower->{patron_attributes_count} = $attributes->count;
112
                $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr;
120
                $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr;
Lines 315-320 if ( $op eq 'show' ) { Link Here
315
            mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0,
323
            mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0,
316
        }
324
        }
317
        ,
325
        ,
326
        {
327
            name => "message",
328
            type => "message_type",
329
            mandatory => ( grep /message/, @mandatoryFields ) ? 1 : 0,
330
        }
331
        ,
318
        {
332
        {
319
            name => "debarred",
333
            name => "debarred",
320
            type => "date",
334
            type => "date",
Lines 378-384 if ( $op eq 'do' ) { Link Here
378
                   }
392
                   }
379
                };
393
                };
380
            }
394
            }
381
395
            # If 'message' or 'add_message_type' is defined then delete both at the same time
396
            if ( grep { $_ eq 'message' } @disabled) {
397
                my $patron = Koha::Patrons->find( $borrowernumber );
398
                $patron->messages()->delete();
399
            }
382
            $infos->{borrowernumber} = $borrowernumber;
400
            $infos->{borrowernumber} = $borrowernumber;
383
            eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; };
401
            eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; };
384
            if ( $@ ) { # FIXME We could provide better error handling here
402
            if ( $@ ) { # FIXME We could provide better error handling here
Lines 417-422 if ( $op eq 'do' ) { Link Here
417
            }
435
            }
418
            $i++;
436
            $i++;
419
        }
437
        }
438
        # Créer un bloc pour enregistrer en bdd l'update de la table patron_messages + sécurité : 'si' tel champ est remplit alors.... etc
439
        my $patron_messages = Koha::Patron::Messages->search(
440
            {
441
                'me.borrowernumber' => $patron->borrowernumber,
442
            }
443
        );
444
        if ( defined $patron_messages ) {
445
            if ( defined $infos ) {
446
                my $message          = $input->param('message');
447
                my $borrowernumber   = $patron->borrowernumber;
448
                my $branchcode       = C4::Context::mybranch;
449
                my $message_type     = $input->param('add_message_type');
450
451
                Koha::Patron::Message->new(
452
                    {
453
                        borrowernumber => $borrowernumber,
454
                        branchcode     => $branchcode,
455
                        message_type   => $message_type,
456
                        message        => $message,
457
                    }
458
                )->store;
459
                $template->param( message_type => $message_type );
460
            }
461
        }
420
    }
462
    }
421
    $op = "show_results"; # We have process modifications, the user want to view its
463
    $op = "show_results"; # We have process modifications, the user want to view its
422
464
Lines 428-433 if ( $op eq 'do' ) { Link Here
428
        if ( $patron ) {
470
        if ( $patron ) {
429
            my $category_description = $patron->category->description;
471
            my $category_description = $patron->category->description;
430
            my $borrower = $patron->unblessed;
472
            my $borrower = $patron->unblessed;
473
            my $patron_messages = Koha::Patron::Messages->search(
474
                    {
475
                        'me.borrowernumber' => $patron->borrowernumber,
476
                    }
477
                );
478
            $borrower->{patron_messages} = $patron_messages->as_list;
431
            $borrower->{category_description} = $category_description;
479
            $borrower->{category_description} = $category_description;
432
            my $attributes = $patron->extended_attributes;
480
            my $attributes = $patron->extended_attributes;
433
            $borrower->{patron_attributes} = $attributes->as_list;
481
            $borrower->{patron_attributes} = $attributes->as_list;
434
- 

Return to bug 27123