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

(-)a/C4/Serials.pm (-52 / +18 lines)
Lines 47-52 use Koha::SharedContent; Link Here
47
use Koha::Subscription::Histories;
47
use Koha::Subscription::Histories;
48
use Koha::Subscriptions;
48
use Koha::Subscriptions;
49
use Koha::Suggestions;
49
use Koha::Suggestions;
50
use Koha::TemplateUtils qw( process_tt );
50
51
51
# Define statuses
52
# Define statuses
52
use constant {
53
use constant {
Lines 1595-1652 sub NewIssue { Link Here
1595
    my $subscription = Koha::Subscriptions->find( $subscriptionid );
1596
    my $subscription = Koha::Subscriptions->find( $subscriptionid );
1596
1597
1597
    if ( my $template = $subscription->published_on_template ) {
1598
    if ( my $template = $subscription->published_on_template ) {
1598
        # If we detect a TT opening tag, run string through Template Toolkit Processor
1599
        $publisheddatetext = process_tt(
1599
        if ( index( $template, '[%' ) != -1 ) { # Much faster than regex
1600
            $template,
1600
            my $use_template_cache = C4::Context->config('template_cache_dir')
1601
            {
1601
              && defined $ENV{GATEWAY_INTERFACE};
1602
                subscription      => $subscription,
1602
1603
                serialseq         => $serialseq,
1603
            my $tt = Template->new(
1604
                serialseq_x       => $subscription->lastvalue1(),
1604
                {
1605
                serialseq_y       => $subscription->lastvalue2(),
1605
                    EVAL_PERL   => 1,
1606
                serialseq_z       => $subscription->lastvalue3(),
1606
                    ABSOLUTE    => 1,
1607
                subscriptionid    => $subscriptionid,
1607
                    PLUGIN_BASE => 'Koha::Template::Plugin',
1608
                biblionumber      => $biblionumber,
1608
                    COMPILE_EXT => $use_template_cache ? '.ttc' : '',
1609
                status            => $status,
1609
                    COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '',
1610
                planneddate       => $planneddate,
1610
                    FILTERS      => {},
1611
                publisheddate     => $publisheddate,
1611
                    ENCODING     => 'UTF-8',
1612
                publisheddatetext => $publisheddatetext,
1612
                }
1613
                notes             => $notes,
1613
            ) or die Template->error();
1614
                routingnotes      => $routingnotes,
1614
1615
            my $schema = Koha::Database->new->schema;
1616
1617
            $schema->txn_begin;
1618
            try {
1619
                my $text;
1620
                $tt->process(
1621
                    \$template,
1622
                    {
1623
                        subscription      => $subscription,
1624
                        serialseq         => $serialseq,
1625
                        serialseq_x       => $subscription->lastvalue1(),
1626
                        serialseq_y       => $subscription->lastvalue2(),
1627
                        serialseq_z       => $subscription->lastvalue3(),
1628
                        subscriptionid    => $subscriptionid,
1629
                        biblionumber      => $biblionumber,
1630
                        status            => $status,
1631
                        planneddate       => $planneddate,
1632
                        publisheddate     => $publisheddate,
1633
                        publisheddatetext => $publisheddatetext,
1634
                        notes             => $notes,
1635
                        routingnotes      => $routingnotes,
1636
                    },
1637
                    \$text
1638
                );
1639
                $publisheddatetext = $text;
1640
            }
1641
            catch {
1642
                croak "ERROR PROCESSING TEMPLATE: $_ :: " . $template->error();
1643
            }
1615
            }
1644
            finally {
1616
        );
1645
                $schema->txn_rollback;
1646
            };
1647
        } else {
1648
            $publisheddatetext = $template;
1649
        }
1650
    }
1617
    }
1651
1618
1652
    my $serial = Koha::Serial->new(
1619
    my $serial = Koha::Serial->new(
1653
- 

Return to bug 33041