Lines 20-28
package C4::Serials;
Link Here
|
20 |
|
20 |
|
21 |
use Modern::Perl; |
21 |
use Modern::Perl; |
22 |
|
22 |
|
23 |
use C4::Auth qw( haspermission ); |
23 |
use Carp qw( croak ); |
24 |
use C4::Context; |
|
|
25 |
use DateTime; |
26 |
use Date::Calc qw( |
24 |
use Date::Calc qw( |
27 |
Add_Delta_Days |
25 |
Add_Delta_Days |
28 |
Add_Delta_YM |
26 |
Add_Delta_YM |
Lines 31-49
use Date::Calc qw(
Link Here
|
31 |
N_Delta_YMD |
29 |
N_Delta_YMD |
32 |
Today |
30 |
Today |
33 |
); |
31 |
); |
|
|
32 |
use DateTime; |
34 |
use POSIX qw( strftime ); |
33 |
use POSIX qw( strftime ); |
|
|
34 |
use Scalar::Util qw( looks_like_number ); |
35 |
use Try::Tiny; |
36 |
|
37 |
use C4::Auth qw( haspermission ); |
35 |
use C4::Biblio qw( GetMarcFromKohaField ModBiblio ); |
38 |
use C4::Biblio qw( GetMarcFromKohaField ModBiblio ); |
|
|
39 |
use C4::Context; |
36 |
use C4::Log qw( logaction ); # logaction |
40 |
use C4::Log qw( logaction ); # logaction |
37 |
use C4::Serials::Frequency qw( GetSubscriptionFrequency ); |
41 |
use C4::Serials::Frequency qw( GetSubscriptionFrequency ); |
38 |
use C4::Serials::Numberpattern; |
42 |
use C4::Serials::Numberpattern; |
39 |
use Koha::AdditionalFieldValues; |
43 |
use Koha::AdditionalFieldValues; |
40 |
use Koha::Biblios; |
44 |
use Koha::Biblios; |
41 |
use Koha::Serial; |
45 |
use Koha::Serial; |
42 |
use Koha::Subscriptions; |
46 |
use Koha::SharedContent; |
43 |
use Koha::Subscription::Histories; |
47 |
use Koha::Subscription::Histories; |
|
|
48 |
use Koha::Subscriptions; |
44 |
use Koha::Suggestions; |
49 |
use Koha::Suggestions; |
45 |
use Koha::SharedContent; |
|
|
46 |
use Scalar::Util qw( looks_like_number ); |
47 |
|
50 |
|
48 |
# Define statuses |
51 |
# Define statuses |
49 |
use constant { |
52 |
use constant { |
Lines 894-899
sub GetNextSeq {
Link Here
|
894 |
my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale ); |
897 |
my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale ); |
895 |
$calculated =~ s/\{Z\}/$newlastvalue3string/g; |
898 |
$calculated =~ s/\{Z\}/$newlastvalue3string/g; |
896 |
} |
899 |
} |
|
|
900 |
|
897 |
} |
901 |
} |
898 |
|
902 |
|
899 |
return ($calculated, |
903 |
return ($calculated, |
Lines 1287-1293
sub ModSubscription {
Link Here
|
1287 |
$biblionumber, $callnumber, $notes, $letter, $manualhistory, |
1291 |
$biblionumber, $callnumber, $notes, $letter, $manualhistory, |
1288 |
$internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, |
1292 |
$internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, |
1289 |
$graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, |
1293 |
$graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, |
1290 |
$itemtype, $previousitemtype, $mana_id, $ccode |
1294 |
$itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template |
1291 |
) = @_; |
1295 |
) = @_; |
1292 |
|
1296 |
|
1293 |
my $subscription = Koha::Subscriptions->find($subscriptionid); |
1297 |
my $subscription = Koha::Subscriptions->find($subscriptionid); |
Lines 1331-1336
sub ModSubscription {
Link Here
|
1331 |
previousitemtype => $previousitemtype, |
1335 |
previousitemtype => $previousitemtype, |
1332 |
mana_id => $mana_id, |
1336 |
mana_id => $mana_id, |
1333 |
ccode => $ccode, |
1337 |
ccode => $ccode, |
|
|
1338 |
published_on_template => $published_on_template, |
1334 |
} |
1339 |
} |
1335 |
)->store; |
1340 |
)->store; |
1336 |
# FIXME Must be $subscription->serials |
1341 |
# FIXME Must be $subscription->serials |
Lines 1368-1374
sub NewSubscription {
Link Here
|
1368 |
$innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, |
1373 |
$innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, |
1369 |
$numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, |
1374 |
$numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, |
1370 |
$serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, |
1375 |
$serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, |
1371 |
$location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode |
1376 |
$location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, |
|
|
1377 |
$published_on_template, |
1372 |
) = @_; |
1378 |
) = @_; |
1373 |
my $dbh = C4::Context->dbh; |
1379 |
my $dbh = C4::Context->dbh; |
1374 |
|
1380 |
|
Lines 1411-1417
sub NewSubscription {
Link Here
|
1411 |
itemtype => $itemtype, |
1417 |
itemtype => $itemtype, |
1412 |
previousitemtype => $previousitemtype, |
1418 |
previousitemtype => $previousitemtype, |
1413 |
mana_id => $mana_id, |
1419 |
mana_id => $mana_id, |
1414 |
ccode => $ccode |
1420 |
ccode => $ccode, |
|
|
1421 |
published_on_template => $published_on_template, |
1415 |
} |
1422 |
} |
1416 |
)->store; |
1423 |
)->store; |
1417 |
$subscription->discard_changes; |
1424 |
$subscription->discard_changes; |
Lines 1587-1592
sub NewIssue {
Link Here
|
1587 |
|
1594 |
|
1588 |
my $subscription = Koha::Subscriptions->find( $subscriptionid ); |
1595 |
my $subscription = Koha::Subscriptions->find( $subscriptionid ); |
1589 |
|
1596 |
|
|
|
1597 |
if ( my $template = $subscription->published_on_template ) { |
1598 |
# If we detect a TT opening tag, run string through Template Toolkit Processor |
1599 |
if ( index( $template, '[%' ) != -1 ) { # Much faster than regex |
1600 |
my $use_template_cache = C4::Context->config('template_cache_dir') |
1601 |
&& defined $ENV{GATEWAY_INTERFACE}; |
1602 |
|
1603 |
my $tt = Template->new( |
1604 |
{ |
1605 |
EVAL_PERL => 1, |
1606 |
ABSOLUTE => 1, |
1607 |
PLUGIN_BASE => 'Koha::Template::Plugin', |
1608 |
COMPILE_EXT => $use_template_cache ? '.ttc' : '', |
1609 |
COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '', |
1610 |
FILTERS => {}, |
1611 |
ENCODING => 'UTF-8', |
1612 |
} |
1613 |
) or die Template->error(); |
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 |
} |
1644 |
finally { |
1645 |
$schema->txn_rollback; |
1646 |
}; |
1647 |
} else { |
1648 |
$publisheddatetext = $template; |
1649 |
} |
1650 |
} |
1651 |
|
1590 |
my $serial = Koha::Serial->new( |
1652 |
my $serial = Koha::Serial->new( |
1591 |
{ |
1653 |
{ |
1592 |
serialseq => $serialseq, |
1654 |
serialseq => $serialseq, |
Lines 1600-1606
sub NewIssue {
Link Here
|
1600 |
publisheddate => $publisheddate, |
1662 |
publisheddate => $publisheddate, |
1601 |
publisheddatetext => $publisheddatetext, |
1663 |
publisheddatetext => $publisheddatetext, |
1602 |
notes => $notes, |
1664 |
notes => $notes, |
1603 |
routingnotes => $routingnotes |
1665 |
routingnotes => $routingnotes, |
1604 |
} |
1666 |
} |
1605 |
)->store(); |
1667 |
)->store(); |
1606 |
|
1668 |
|