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

(-)a/C4/Letters.pm (-1 / +3 lines)
Lines 782-787 sub GetPreparedLetter { Link Here
782
            content => $letter->{content},
782
            content => $letter->{content},
783
            tables  => $tables,
783
            tables  => $tables,
784
            loops  => $loops,
784
            loops  => $loops,
785
            substitute => $substitute,
785
        }
786
        }
786
    );
787
    );
787
788
Lines 1455-1460 sub _process_tt { Link Here
1455
    my $content = $params->{content};
1456
    my $content = $params->{content};
1456
    my $tables = $params->{tables};
1457
    my $tables = $params->{tables};
1457
    my $loops = $params->{loops};
1458
    my $loops = $params->{loops};
1459
    my $substitute = $params->{substitute} || {};
1458
1460
1459
    my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
1461
    my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
1460
    my $template           = Template->new(
1462
    my $template           = Template->new(
Lines 1469-1475 sub _process_tt { Link Here
1469
        }
1471
        }
1470
    ) or die Template->error();
1472
    ) or die Template->error();
1471
1473
1472
    my $tt_params = { %{ _get_tt_params( $tables ) }, %{ _get_tt_params( $loops, 'is_a_loop' ) } };
1474
    my $tt_params = { %{ _get_tt_params( $tables ) }, %{ _get_tt_params( $loops, 'is_a_loop' ) }, %$substitute };
1473
1475
1474
    $content = qq|[% USE KohaDates %]$content|;
1476
    $content = qq|[% USE KohaDates %]$content|;
1475
1477
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +29 lines)
Lines 286-292 $prepared_letter = GetPreparedLetter( Link Here
286
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' );
286
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' );
287
287
288
subtest 'regression tests' => sub {
288
subtest 'regression tests' => sub {
289
    plan tests => 3;
289
    plan tests => 4;
290
290
291
    my $library = $builder->build( { source => 'Branch' } );
291
    my $library = $builder->build( { source => 'Branch' } );
292
    my $patron  = $builder->build( { source => 'Borrower' } );
292
    my $patron  = $builder->build( { source => 'Borrower' } );
Lines 472-477 Thank you for visiting [% branch.branchname %]. Link Here
472
        is( $second_checkin_tt_letter->content, $second_checkin_letter->content, 'Verify second checkin letter' );
472
        is( $second_checkin_tt_letter->content, $second_checkin_letter->content, 'Verify second checkin letter' );
473
473
474
    };
474
    };
475
476
    subtest 'DUEDGST|count' => sub {
477
        plan tests => 1;
478
479
        my $code = 'DUEDGST';
480
481
        my $dbh = C4::Context->dbh;
482
        # Enable notification for DUEDGST - Things are hardcoded here but should work with default data
483
        $dbh->do(q|INSERT INTO borrower_message_preferences( borrowernumber, message_attribute_id ) VALUES ( ?, ? )|, undef, $patron->{borrowernumber}, 1 );
484
        my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef);
485
        $dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' );
486
487
        my $params = {
488
            code => $code,
489
            substitute => { count => 42 },
490
        };
491
492
        my $template = q|
493
You have <<count>> items due
494
        |;
495
        my $letter = process_letter( { template => $template, %$params });
496
497
        my $tt_template = q|
498
You have [% count %] items due
499
        |;
500
        my $tt_letter = process_letter( { template => $tt_template, %$params });
501
        is( $tt_letter->{content}, $letter->{content}, );
502
    };
475
};
503
};
476
504
477
subtest 'loops' => sub {
505
subtest 'loops' => sub {
478
- 

Return to bug 17965