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

(-)a/C4/Letters.pm (+3 lines)
Lines 770-775 sub GetPreparedLetter { Link Here
770
        {
770
        {
771
            content => $letter->{content},
771
            content => $letter->{content},
772
            tables  => $tables,
772
            tables  => $tables,
773
            substitute => $substitute,
773
        }
774
        }
774
    );
775
    );
775
776
Lines 1440-1445 sub _process_tt { Link Here
1440
1441
1441
    my $content = $params->{content};
1442
    my $content = $params->{content};
1442
    my $tables = $params->{tables};
1443
    my $tables = $params->{tables};
1444
    my $substitute = $params->{substitute} || {};
1443
1445
1444
    my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
1446
    my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
1445
    my $template           = Template->new(
1447
    my $template           = Template->new(
Lines 1455-1460 sub _process_tt { Link Here
1455
    ) or die Template->error();
1457
    ) or die Template->error();
1456
1458
1457
    my $tt_params = _get_tt_params( $tables );
1459
    my $tt_params = _get_tt_params( $tables );
1460
    $tt_params = { %$tt_params, %$substitute };
1458
1461
1459
    $content = qq|[% USE KohaDates %]$content|;
1462
    $content = qq|[% USE KohaDates %]$content|;
1460
1463
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +30 lines)
Lines 285-291 $prepared_letter = GetPreparedLetter( Link Here
285
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' );
285
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' );
286
286
287
subtest 'regression tests' => sub {
287
subtest 'regression tests' => sub {
288
    plan tests => 3;
288
    plan tests => 4;
289
289
290
    my $library = $builder->build( { source => 'Branch' } );
290
    my $library = $builder->build( { source => 'Branch' } );
291
    my $patron  = $builder->build( { source => 'Borrower' } );
291
    my $patron  = $builder->build( { source => 'Borrower' } );
Lines 470-475 Thank you for visiting [% branch.branchname %]. Link Here
470
        is( $second_checkin_tt_letter->content, $second_checkin_letter->content, );
470
        is( $second_checkin_tt_letter->content, $second_checkin_letter->content, );
471
471
472
    };
472
    };
473
474
    subtest 'DUEDGST|count' => sub {
475
        plan tests => 1;
476
477
        my $code = 'DUEDGST';
478
479
        my $dbh = C4::Context->dbh;
480
        # Enable notification for DUEDGST - Things are hardcoded here but should work with default data
481
        $dbh->do(q|INSERT INTO borrower_message_preferences( borrowernumber, message_attribute_id ) VALUES ( ?, ? )|, undef, $patron->{borrowernumber}, 1 );
482
        my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef);
483
        $dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' );
484
485
        my $params = {
486
            code => $code,
487
            substitute => { count => 42 },
488
        };
489
490
        my $template = q|
491
You have <<count>> items due
492
        |;
493
        my $letter = process_letter( { template => $template, %$params });
494
495
        my $tt_template = q|
496
You have [% count %] items due
497
        |;
498
        my $tt_letter = process_letter( { template => $tt_template, %$params });
499
        is( $tt_letter->{content}, $letter->{content}, );
500
    };
501
473
};
502
};
474
503
475
sub reset_template {
504
sub reset_template {
476
- 

Return to bug 17965