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-48
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; |
|
|
43 |
use Koha::Subscription::Histories; |
44 |
use Koha::SharedContent; |
46 |
use Koha::SharedContent; |
45 |
use Scalar::Util qw( looks_like_number ); |
47 |
use Koha::Subscription::Histories; |
|
|
48 |
use Koha::Subscriptions; |
46 |
|
49 |
|
47 |
# Define statuses |
50 |
# Define statuses |
48 |
use constant { |
51 |
use constant { |
Lines 893-898
sub GetNextSeq {
Link Here
|
893 |
my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale ); |
896 |
my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale ); |
894 |
$calculated =~ s/\{Z\}/$newlastvalue3string/g; |
897 |
$calculated =~ s/\{Z\}/$newlastvalue3string/g; |
895 |
} |
898 |
} |
|
|
899 |
|
896 |
} |
900 |
} |
897 |
|
901 |
|
898 |
return ($calculated, |
902 |
return ($calculated, |
Lines 1286-1292
sub ModSubscription {
Link Here
|
1286 |
$biblionumber, $callnumber, $notes, $letter, $manualhistory, |
1290 |
$biblionumber, $callnumber, $notes, $letter, $manualhistory, |
1287 |
$internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, |
1291 |
$internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, |
1288 |
$graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, |
1292 |
$graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, |
1289 |
$itemtype, $previousitemtype, $mana_id, $ccode |
1293 |
$itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template |
1290 |
) = @_; |
1294 |
) = @_; |
1291 |
|
1295 |
|
1292 |
my $subscription = Koha::Subscriptions->find($subscriptionid); |
1296 |
my $subscription = Koha::Subscriptions->find($subscriptionid); |
Lines 1330-1335
sub ModSubscription {
Link Here
|
1330 |
previousitemtype => $previousitemtype, |
1334 |
previousitemtype => $previousitemtype, |
1331 |
mana_id => $mana_id, |
1335 |
mana_id => $mana_id, |
1332 |
ccode => $ccode, |
1336 |
ccode => $ccode, |
|
|
1337 |
published_on_template => $published_on_template, |
1333 |
} |
1338 |
} |
1334 |
)->store; |
1339 |
)->store; |
1335 |
# FIXME Must be $subscription->serials |
1340 |
# FIXME Must be $subscription->serials |
Lines 1367-1373
sub NewSubscription {
Link Here
|
1367 |
$innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, |
1372 |
$innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, |
1368 |
$numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, |
1373 |
$numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, |
1369 |
$serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, |
1374 |
$serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, |
1370 |
$location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode |
1375 |
$location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, |
|
|
1376 |
$published_on_template, |
1371 |
) = @_; |
1377 |
) = @_; |
1372 |
my $dbh = C4::Context->dbh; |
1378 |
my $dbh = C4::Context->dbh; |
1373 |
|
1379 |
|
Lines 1410-1416
sub NewSubscription {
Link Here
|
1410 |
itemtype => $itemtype, |
1416 |
itemtype => $itemtype, |
1411 |
previousitemtype => $previousitemtype, |
1417 |
previousitemtype => $previousitemtype, |
1412 |
mana_id => $mana_id, |
1418 |
mana_id => $mana_id, |
1413 |
ccode => $ccode |
1419 |
ccode => $ccode, |
|
|
1420 |
published_on_template => $published_on_template, |
1414 |
} |
1421 |
} |
1415 |
)->store; |
1422 |
)->store; |
1416 |
$subscription->discard_changes; |
1423 |
$subscription->discard_changes; |
Lines 1586-1591
sub NewIssue {
Link Here
|
1586 |
|
1593 |
|
1587 |
my $subscription = Koha::Subscriptions->find( $subscriptionid ); |
1594 |
my $subscription = Koha::Subscriptions->find( $subscriptionid ); |
1588 |
|
1595 |
|
|
|
1596 |
if ( my $template = $subscription->published_on_template ) { |
1597 |
# If we detect a TT opening tag, run string through Template Toolkit Processor |
1598 |
if ( index( $template, '[%' ) != -1 ) { # Much faster than regex |
1599 |
my $use_template_cache = C4::Context->config('template_cache_dir') |
1600 |
&& defined $ENV{GATEWAY_INTERFACE}; |
1601 |
|
1602 |
my $tt = Template->new( |
1603 |
{ |
1604 |
EVAL_PERL => 1, |
1605 |
ABSOLUTE => 1, |
1606 |
PLUGIN_BASE => 'Koha::Template::Plugin', |
1607 |
COMPILE_EXT => $use_template_cache ? '.ttc' : '', |
1608 |
COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '', |
1609 |
FILTERS => {}, |
1610 |
ENCODING => 'UTF-8', |
1611 |
} |
1612 |
) or die Template->error(); |
1613 |
|
1614 |
my $schema = Koha::Database->new->schema; |
1615 |
|
1616 |
$schema->txn_begin; |
1617 |
try { |
1618 |
my $text; |
1619 |
$tt->process( |
1620 |
\$template, |
1621 |
{ |
1622 |
subscription => $subscription, |
1623 |
serialseq => $serialseq, |
1624 |
serialseq_x => $subscription->lastvalue1(), |
1625 |
serialseq_y => $subscription->lastvalue2(), |
1626 |
serialseq_z => $subscription->lastvalue3(), |
1627 |
subscriptionid => $subscriptionid, |
1628 |
biblionumber => $biblionumber, |
1629 |
status => $status, |
1630 |
planneddate => $planneddate, |
1631 |
publisheddate => $publisheddate, |
1632 |
publisheddatetext => $publisheddatetext, |
1633 |
notes => $notes, |
1634 |
routingnotes => $routingnotes, |
1635 |
}, |
1636 |
\$text |
1637 |
); |
1638 |
$publisheddatetext = $text; |
1639 |
} |
1640 |
catch { |
1641 |
croak "ERROR PROCESSING TEMPLATE: $_ :: " . $template->error(); |
1642 |
} |
1643 |
finally { |
1644 |
$schema->txn_rollback; |
1645 |
}; |
1646 |
} else { |
1647 |
$publisheddatetext = $template; |
1648 |
} |
1649 |
} |
1650 |
|
1589 |
my $serial = Koha::Serial->new( |
1651 |
my $serial = Koha::Serial->new( |
1590 |
{ |
1652 |
{ |
1591 |
serialseq => $serialseq, |
1653 |
serialseq => $serialseq, |
Lines 1599-1605
sub NewIssue {
Link Here
|
1599 |
publisheddate => $publisheddate, |
1661 |
publisheddate => $publisheddate, |
1600 |
publisheddatetext => $publisheddatetext, |
1662 |
publisheddatetext => $publisheddatetext, |
1601 |
notes => $notes, |
1663 |
notes => $notes, |
1602 |
routingnotes => $routingnotes |
1664 |
routingnotes => $routingnotes, |
1603 |
} |
1665 |
} |
1604 |
)->store(); |
1666 |
)->store(); |
1605 |
|
1667 |
|