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

(-)a/C4/Letters.pm (-5 / +131 lines)
Lines 22-27 use warnings; Link Here
22
22
23
use MIME::Lite;
23
use MIME::Lite;
24
use Mail::Sendmail;
24
use Mail::Sendmail;
25
use Date::Calc qw( Add_Delta_Days );
26
use Encode;
27
use Carp;
28
use Template;
29
use Module::Load::Conditional qw(can_load);
25
30
26
use C4::Koha qw(GetAuthorisedValueByCode);
31
use C4::Koha qw(GetAuthorisedValueByCode);
27
use C4::Members;
32
use C4::Members;
Lines 31-41 use C4::Log; Link Here
31
use C4::SMS;
36
use C4::SMS;
32
use C4::Debug;
37
use C4::Debug;
33
use Koha::DateUtils;
38
use Koha::DateUtils;
34
use Date::Calc qw( Add_Delta_Days );
35
use Encode;
36
use Carp;
37
use Koha::Email;
39
use Koha::Email;
38
use Koha::DateUtils qw( format_sqldatetime );
40
use Koha::DateUtils qw( format_sqldatetime dt_from_string );
39
41
40
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
42
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
41
43
Lines 713-720 sub GetPreparedLetter { Link Here
713
        }
715
        }
714
    }
716
    }
715
717
718
    $letter->{content} = _process_tt(
719
        {
720
            content => $letter->{content},
721
            tables  => $tables,
722
        }
723
    );
724
716
    $letter->{content} =~ s/<<\S*>>//go; #remove any stragglers
725
    $letter->{content} =~ s/<<\S*>>//go; #remove any stragglers
717
#   $letter->{content} =~ s/<<[^>]*>>//go;
718
726
719
    return $letter;
727
    return $letter;
720
}
728
}
Lines 1310-1315 sub _set_message_status { Link Here
1310
    return $result;
1318
    return $result;
1311
}
1319
}
1312
1320
1321
sub _process_tt {
1322
    my ( $params ) = @_;
1323
1324
    my $content = $params->{content};
1325
    my $tables = $params->{tables};
1326
1327
    my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
1328
    my $template           = Template->new(
1329
        {
1330
            EVAL_PERL    => 1,
1331
            ABSOLUTE     => 1,
1332
            PLUGIN_BASE  => 'Koha::Template::Plugin',
1333
            COMPILE_EXT  => $use_template_cache ? '.ttc' : '',
1334
            COMPILE_DIR  => $use_template_cache ? C4::Context->config('template_cache_dir') : '',
1335
            FILTERS      => {},
1336
            ENCODING     => 'UTF-8',
1337
        }
1338
    ) or die Template->error();
1339
1340
    my $tt_params = _get_tt_params( $tables );
1341
1342
    my $output;
1343
    $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
1344
1345
    return $output;
1346
}
1347
1348
sub _get_tt_params {
1349
    my ($tables) = @_;
1350
1351
    my $params;
1352
1353
    my $config = {
1354
        biblio => {
1355
            module   => 'Koha::Biblios',
1356
            singular => 'biblio',
1357
            plural   => 'biblios',
1358
            pk       => 'biblionumber',
1359
        },
1360
        borrowers => {
1361
            module   => 'Koha::Borrowers',
1362
            singular => 'borrower',
1363
            plural   => 'borrowers',
1364
            pk       => 'borrowernumber',
1365
        },
1366
        branches => {
1367
            module   => 'Koha::Branches',
1368
            singular => 'branch',
1369
            plural   => 'branches',
1370
            pk       => 'branchcode',
1371
        },
1372
        items => {
1373
            module   => 'Koha::Items',
1374
            singular => 'item',
1375
            plural   => 'items',
1376
            pk       => 'itemnumber',
1377
        },
1378
        opac_news => {
1379
            module   => 'Koha::News',
1380
            singular => 'news',
1381
            plural   => 'news',
1382
            pk       => 'idnew',
1383
        },
1384
        reserves => {
1385
            module   => 'Koha::Holds',
1386
            singular => 'hold',
1387
            plural   => 'holds',
1388
            pk       => 'reserve_id',
1389
        },
1390
        serial => {
1391
            module   => 'Koha::Serials',
1392
            singular => 'serial',
1393
            plural   => 'serials',
1394
            pk       => 'serialid',
1395
        },
1396
        subscription => {
1397
            module   => 'Koha::Subscriptions',
1398
            singular => 'subscription',
1399
            plural   => 'subscriptions',
1400
            pk       => 'subscriptionid',
1401
        },
1402
        suggestions => {
1403
            module   => 'Koha::Suggestions',
1404
            singular => 'suggestion',
1405
            plural   => 'suggestions',
1406
            pk       => 'suggestionid',
1407
        },
1408
    };
1409
1410
    foreach my $table ( keys %$tables ) {
1411
        next unless $config->{$table};
1412
1413
        my $ref = ref( $tables->{$table} ) || q{};
1414
        my $module = $config->{$table}->{module};
1415
1416
        if ( can_load( modules => { $module => undef } ) ) {
1417
            my $pk = $config->{$table}->{pk};
1418
1419
            if ( $ref eq q{} || $ref eq 'HASH' ) {
1420
                my $id = ref eq 'HASH' ? $tables->{$table}->{$pk} : $tables->{$table};
1421
                my $object = $module->find($id);
1422
                $params->{ $config->{$table}->{singular} } = $object;
1423
            }
1424
            else {    # $ref eq 'ARRAY'
1425
                my $objects = $module->search( { $pk => $tables->{$table} } );
1426
                $params->{ $config->{$table}->{plural} } = $objects;
1427
            }
1428
        }
1429
        else {
1430
            croak "ERROR LOADING MODULE $module: $Module::Load::Conditional::ERROR";
1431
        }
1432
    }
1433
1434
    $params->{today} = dt_from_string();
1435
1436
    return $params;
1437
}
1438
1313
1439
1314
1;
1440
1;
1315
__END__
1441
__END__
(-)a/Koha/News.pm (+62 lines)
Line 0 Link Here
1
package Koha::News;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::NewsItem;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::News - Koha News object set class
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub type {
45
    return 'OpacNews';
46
}
47
48
=head3 object_class
49
50
=cut
51
52
sub object_class {
53
    return 'Koha::NewsItem';
54
}
55
56
=head1 AUTHOR
57
58
Kyle M Hall <kyle@bywatersolutions.com>
59
60
=cut
61
62
1;
(-)a/Koha/NewsItem.pm (+56 lines)
Line 0 Link Here
1
package Koha::NewsItem;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Branches;
27
28
use base qw(Koha::Object);
29
30
=head1 NAME
31
32
Koha::NewsItem - Koha News Item object class
33
34
Koha::NewsItem represents a single piece of news from the opac_news table
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 type
43
44
=cut
45
46
sub type {
47
    return 'OpacNews';
48
}
49
50
=head1 AUTHOR
51
52
Kyle M Hall <kyle@bywatersolutions.com>
53
54
=cut
55
56
1;
(-)a/Koha/Serial.pm (+54 lines)
Line 0 Link Here
1
package Koha::Serial;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Branches;
27
28
use base qw(Koha::Object);
29
30
=head1 NAME
31
32
Koha::Serial - Koha Serial object class
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub type {
45
    return 'Serial';
46
}
47
48
=head1 AUTHOR
49
50
Kyle M Hall <kyle@bywatersolutions.com>
51
52
=cut
53
54
1;
(-)a/Koha/Serials.pm (+62 lines)
Line 0 Link Here
1
package Koha::Serials;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Serial;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Serials - Koha Serial object set class
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub type {
45
    return 'Serial';
46
}
47
48
=head3 object_class
49
50
=cut
51
52
sub object_class {
53
    return 'Koha::Serial';
54
}
55
56
=head1 AUTHOR
57
58
Kyle M Hall <kyle@bywatersolutions.com>
59
60
=cut
61
62
1;
(-)a/Koha/Subscription.pm (+54 lines)
Line 0 Link Here
1
package Koha::Subscription;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Branches;
27
28
use base qw(Koha::Object);
29
30
=head1 NAME
31
32
Koha::Subscription - Koha Subscription object class
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub type {
45
    return 'Subscription';
46
}
47
48
=head1 AUTHOR
49
50
Kyle M Hall <kyle@bywatersolutions.com>
51
52
=cut
53
54
1;
(-)a/Koha/Subscriptions.pm (+62 lines)
Line 0 Link Here
1
package Koha::Subscriptions;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Subscription;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Subscriptions - Koha Subscription object set class
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub type {
45
    return 'Subscription';
46
}
47
48
=head3 object_class
49
50
=cut
51
52
sub object_class {
53
    return 'Koha::Subscription';
54
}
55
56
=head1 AUTHOR
57
58
Kyle M Hall <kyle@bywatersolutions.com>
59
60
=cut
61
62
1;
(-)a/Koha/Suggestion.pm (+54 lines)
Line 0 Link Here
1
package Koha::Suggestion;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Branches;
27
28
use base qw(Koha::Object);
29
30
=head1 NAME
31
32
Koha::Suggestion - Koha Suggestion object class
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub type {
45
    return 'Suggestion';
46
}
47
48
=head1 AUTHOR
49
50
Kyle M Hall <kyle@bywatersolutions.com>
51
52
=cut
53
54
1;
(-)a/Koha/Suggestions.pm (-1 / +62 lines)
Line 0 Link Here
0
- 
1
package Koha::Suggestions;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Suggestion;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Suggestions - Koha Suggestion object set class
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub type {
45
    return 'Suggestion';
46
}
47
48
=head3 object_class
49
50
=cut
51
52
sub object_class {
53
    return 'Koha::Suggestion';
54
}
55
56
=head1 AUTHOR
57
58
Kyle M Hall <kyle@bywatersolutions.com>
59
60
=cut
61
62
1;

Return to bug 14757