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

(-)a/C4/Letters.pm (-7 / +7 lines)
Lines 494-506 sub SendAlerts { Link Here
494
                    : ()
494
                    : ()
495
                ),
495
                ),
496
                from => (
496
                from => (
497
                    $type eq 'claimissues'
497
                    $type eq 'claimissues' ? C4::Context->preference('SerialsDefaultEmailAddress')
498
                    ? C4::Context->preference('SerialsDefaultEmailAddress')
499
                    : C4::Context->preference('AcquisitionsDefaultEmailAddress')
498
                    : C4::Context->preference('AcquisitionsDefaultEmailAddress')
500
                    )
499
                    )
501
                    || $library->branchemail
500
                    || ( $library && $library->branchemail ) ? $library->branchemail
502
                    || C4::Context->preference('KohaAdminEmailAddress'),
501
                    : C4::Context->preference('KohaAdminEmailAddress'),
503
                (
502
                    (
504
                    $type eq 'claimissues' && C4::Context->preference('SerialsDefaultReplyTo')
503
                    $type eq 'claimissues' && C4::Context->preference('SerialsDefaultReplyTo')
505
                    ? ( reply_to => C4::Context->preference('SerialsDefaultReplyTo') )
504
                    ? ( reply_to => C4::Context->preference('SerialsDefaultReplyTo') )
506
                    : (
505
                    : (
Lines 509-515 sub SendAlerts { Link Here
509
                        ? ( reply_to => C4::Context->preference('AcquisitionsDefaultReplyTo') )
508
                        ? ( reply_to => C4::Context->preference('AcquisitionsDefaultReplyTo') )
510
                        : ()
509
                        : ()
511
                    )
510
                    )
512
                ),
511
                    ),
513
                subject     => "" . $letter->{title},
512
                subject     => "" . $letter->{title},
514
                template_id => $letter->{id},
513
                template_id => $letter->{id},
515
            }
514
            }
Lines 523-529 sub SendAlerts { Link Here
523
        }
522
        }
524
523
525
        my $success = try {
524
        my $success = try {
526
            $mail->send_or_die({ transport => $library->smtp_server->transport });
525
            my $smtp_server = $library ? $library->smtp_server : Koha::SMTP::Servers->get_default;
526
            $mail->send_or_die({ transport => $smtp_server->transport });
527
        }
527
        }
528
        catch {
528
        catch {
529
            # We expect ref($_) eq 'Email::Sender::Failure'
529
            # We expect ref($_) eq 'Email::Sender::Failure'
(-)a/C4/Serials.pm (-93 / +96 lines)
Lines 1318-1375 returns the number of rows affected Link Here
1318
1318
1319
sub ModSubscription {
1319
sub ModSubscription {
1320
    my (
1320
    my (
1321
    $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
1321
        $auser,         $branchcode,       $aqbooksellerid,    $cost,          $aqbudgetid, $startdate,
1322
    $periodicity, $firstacquidate, $irregularity, $numberpattern, $locale,
1322
        $periodicity,   $firstacquidate,   $irregularity,      $numberpattern, $locale,
1323
    $numberlength, $weeklength, $monthlength, $lastvalue1, $innerloop1,
1323
        $numberlength,  $weeklength,       $monthlength,       $lastvalue1,    $innerloop1,
1324
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1324
        $lastvalue2,    $innerloop2,       $lastvalue3,        $innerloop3,    $status,
1325
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1325
        $biblionumber,  $callnumber,       $notes,             $letter,        $manualhistory,
1326
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1326
        $internalnotes, $serialsadditems,  $staffdisplaycount, $opacdisplaycount,
1327
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1327
        $graceperiod,   $location,         $enddate,           $subscriptionid, $skip_serialseq,
1328
    $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template
1328
        $itemtype,      $previousitemtype, $mana_id,           $ccode,          $published_on_template,
1329
        $auto_claim_enabled
1329
    ) = @_;
1330
    ) = @_;
1330
1331
1331
    my $subscription = Koha::Subscriptions->find($subscriptionid);
1332
    my $subscription = Koha::Subscriptions->find($subscriptionid);
1332
    $subscription->set(
1333
    $subscription->set(
1333
        {
1334
        {
1334
            librarian         => $auser,
1335
            librarian             => $auser,
1335
            branchcode        => $branchcode,
1336
            branchcode            => $branchcode,
1336
            aqbooksellerid    => $aqbooksellerid,
1337
            aqbooksellerid        => $aqbooksellerid,
1337
            cost              => $cost,
1338
            cost                  => $cost,
1338
            aqbudgetid        => $aqbudgetid,
1339
            aqbudgetid            => $aqbudgetid,
1339
            biblionumber      => $biblionumber,
1340
            biblionumber          => $biblionumber,
1340
            startdate         => $startdate,
1341
            startdate             => $startdate,
1341
            periodicity       => $periodicity,
1342
            periodicity           => $periodicity,
1342
            numberlength      => $numberlength,
1343
            numberlength          => $numberlength,
1343
            weeklength        => $weeklength,
1344
            weeklength            => $weeklength,
1344
            monthlength       => $monthlength,
1345
            monthlength           => $monthlength,
1345
            lastvalue1        => $lastvalue1,
1346
            lastvalue1            => $lastvalue1,
1346
            innerloop1        => $innerloop1,
1347
            innerloop1            => $innerloop1,
1347
            lastvalue2        => $lastvalue2,
1348
            lastvalue2            => $lastvalue2,
1348
            innerloop2        => $innerloop2,
1349
            innerloop2            => $innerloop2,
1349
            lastvalue3        => $lastvalue3,
1350
            lastvalue3            => $lastvalue3,
1350
            innerloop3        => $innerloop3,
1351
            innerloop3            => $innerloop3,
1351
            status            => $status,
1352
            status                => $status,
1352
            notes             => $notes,
1353
            notes                 => $notes,
1353
            letter            => $letter,
1354
            letter                => $letter,
1354
            firstacquidate    => $firstacquidate,
1355
            firstacquidate        => $firstacquidate,
1355
            irregularity      => $irregularity,
1356
            irregularity          => $irregularity,
1356
            numberpattern     => $numberpattern,
1357
            numberpattern         => $numberpattern,
1357
            locale            => $locale,
1358
            locale                => $locale,
1358
            callnumber        => $callnumber,
1359
            callnumber            => $callnumber,
1359
            manualhistory     => $manualhistory,
1360
            manualhistory         => $manualhistory,
1360
            internalnotes     => $internalnotes,
1361
            internalnotes         => $internalnotes,
1361
            serialsadditems   => $serialsadditems,
1362
            serialsadditems       => $serialsadditems,
1362
            staffdisplaycount => $staffdisplaycount,
1363
            staffdisplaycount     => $staffdisplaycount,
1363
            opacdisplaycount  => $opacdisplaycount,
1364
            opacdisplaycount      => $opacdisplaycount,
1364
            graceperiod       => $graceperiod,
1365
            graceperiod           => $graceperiod,
1365
            location          => $location,
1366
            location              => $location,
1366
            enddate           => $enddate,
1367
            enddate               => $enddate,
1367
            skip_serialseq    => $skip_serialseq,
1368
            skip_serialseq        => $skip_serialseq,
1368
            itemtype          => $itemtype,
1369
            itemtype              => $itemtype,
1369
            previousitemtype  => $previousitemtype,
1370
            previousitemtype      => $previousitemtype,
1370
            mana_id           => $mana_id,
1371
            mana_id               => $mana_id,
1371
            ccode             => $ccode,
1372
            ccode                 => $ccode,
1372
            published_on_template => $published_on_template,
1373
            published_on_template => $published_on_template,
1374
            auto_claim_enabled    => $auto_claim_enabled // 0,
1373
        }
1375
        }
1374
    )->store;
1376
    )->store;
1375
    # FIXME Must be $subscription->serials
1377
    # FIXME Must be $subscription->serials
Lines 1401-1458 the id of this new subscription Link Here
1401
1403
1402
sub NewSubscription {
1404
sub NewSubscription {
1403
    my (
1405
    my (
1404
    $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
1406
        $auser,                 $branchcode,        $aqbooksellerid,   $cost,          $aqbudgetid, $biblionumber,
1405
    $startdate, $periodicity, $numberlength, $weeklength, $monthlength,
1407
        $startdate,             $periodicity,       $numberlength,     $weeklength,    $monthlength,
1406
    $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3,
1408
        $lastvalue1,            $innerloop1,        $lastvalue2,       $innerloop2,    $lastvalue3,
1407
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1409
        $innerloop3,            $status,            $notes,            $letter,        $firstacquidate, $irregularity,
1408
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1410
        $numberpattern,         $locale,            $callnumber,       $manualhistory, $internalnotes,
1409
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1411
        $serialsadditems,       $staffdisplaycount, $opacdisplaycount, $graceperiod,
1410
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode,
1412
        $location,              $enddate,           $skip_serialseq,   $itemtype, $previousitemtype, $mana_id, $ccode,
1411
    $published_on_template,
1413
        $published_on_template, $auto_claim_enabled
1412
    ) = @_;
1414
    ) = @_;
1413
    my $dbh = C4::Context->dbh;
1415
    my $dbh = C4::Context->dbh;
1414
1416
1415
    my $subscription = Koha::Subscription->new(
1417
    my $subscription = Koha::Subscription->new(
1416
        {
1418
        {
1417
            librarian         => $auser,
1419
            librarian             => $auser,
1418
            branchcode        => $branchcode,
1420
            branchcode            => $branchcode,
1419
            aqbooksellerid    => $aqbooksellerid,
1421
            aqbooksellerid        => $aqbooksellerid,
1420
            cost              => $cost,
1422
            cost                  => $cost,
1421
            aqbudgetid        => $aqbudgetid,
1423
            aqbudgetid            => $aqbudgetid,
1422
            biblionumber      => $biblionumber,
1424
            biblionumber          => $biblionumber,
1423
            startdate         => $startdate,
1425
            startdate             => $startdate,
1424
            periodicity       => $periodicity,
1426
            periodicity           => $periodicity,
1425
            numberlength      => $numberlength,
1427
            numberlength          => $numberlength,
1426
            weeklength        => $weeklength,
1428
            weeklength            => $weeklength,
1427
            monthlength       => $monthlength,
1429
            monthlength           => $monthlength,
1428
            lastvalue1        => $lastvalue1,
1430
            lastvalue1            => $lastvalue1,
1429
            innerloop1        => $innerloop1,
1431
            innerloop1            => $innerloop1,
1430
            lastvalue2        => $lastvalue2,
1432
            lastvalue2            => $lastvalue2,
1431
            innerloop2        => $innerloop2,
1433
            innerloop2            => $innerloop2,
1432
            lastvalue3        => $lastvalue3,
1434
            lastvalue3            => $lastvalue3,
1433
            innerloop3        => $innerloop3,
1435
            innerloop3            => $innerloop3,
1434
            status            => $status,
1436
            status                => $status,
1435
            notes             => $notes,
1437
            notes                 => $notes,
1436
            letter            => $letter,
1438
            letter                => $letter,
1437
            firstacquidate    => $firstacquidate,
1439
            firstacquidate        => $firstacquidate,
1438
            irregularity      => $irregularity,
1440
            irregularity          => $irregularity,
1439
            numberpattern     => $numberpattern,
1441
            numberpattern         => $numberpattern,
1440
            locale            => $locale,
1442
            locale                => $locale,
1441
            callnumber        => $callnumber,
1443
            callnumber            => $callnumber,
1442
            manualhistory     => $manualhistory,
1444
            manualhistory         => $manualhistory,
1443
            internalnotes     => $internalnotes,
1445
            internalnotes         => $internalnotes,
1444
            serialsadditems   => $serialsadditems,
1446
            serialsadditems       => $serialsadditems,
1445
            staffdisplaycount => $staffdisplaycount,
1447
            staffdisplaycount     => $staffdisplaycount,
1446
            opacdisplaycount  => $opacdisplaycount,
1448
            opacdisplaycount      => $opacdisplaycount,
1447
            graceperiod       => $graceperiod,
1449
            graceperiod           => $graceperiod,
1448
            location          => $location,
1450
            location              => $location,
1449
            enddate           => $enddate,
1451
            enddate               => $enddate,
1450
            skip_serialseq    => $skip_serialseq,
1452
            skip_serialseq        => $skip_serialseq,
1451
            itemtype          => $itemtype,
1453
            itemtype              => $itemtype,
1452
            previousitemtype  => $previousitemtype,
1454
            previousitemtype      => $previousitemtype,
1453
            mana_id           => $mana_id,
1455
            mana_id               => $mana_id,
1454
            ccode             => $ccode,
1456
            ccode                 => $ccode,
1455
            published_on_template => $published_on_template,
1457
            published_on_template => $published_on_template,
1458
            auto_claim_enabled    => $auto_claim_enabled // 0,
1456
        }
1459
        }
1457
    )->store;
1460
    )->store;
1458
    $subscription->discard_changes;
1461
    $subscription->discard_changes;
Lines 1892-1898 sub GetLateOrMissingIssues { Link Here
1892
    if ($supplierid) {
1895
    if ($supplierid) {
1893
        $sth = $dbh->prepare(
1896
        $sth = $dbh->prepare(
1894
            "SELECT
1897
            "SELECT
1895
                serialid,      aqbooksellerid,        name,
1898
                serialid,      serial.aqbooksellerid,        name,
1896
                biblio.title,  biblioitems.issn,      planneddate,    serialseq,
1899
                biblio.title,  biblioitems.issn,      planneddate,    serialseq,
1897
                serial.status, serial.subscriptionid, claimdate, claims_count,
1900
                serial.status, serial.subscriptionid, claimdate, claims_count,
1898
                subscription.branchcode, serial.publisheddate
1901
                subscription.branchcode, serial.publisheddate
(-)a/installer/data/mysql/atomicupdate/bug-18783.pl (+23 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "18783",
5
    description => "Automatic claims for serials",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        unless ( column_exists( 'subscription', 'auto_claim_enabled' ) ) {
11
            $dbh->do(
12
                q{
13
                ALTER TABLE subscription
14
                ADD COLUMN auto_claim_enabled tinyint NOT NULL DEFAULT 0 COMMENT 'enable automatic claiming' AFTER published_on_template
15
            }
16
            );
17
18
            say $out "Added column subscription.auto_claim_enabled";
19
        } else {
20
            say $out "Column subscription.auto_claim_enabled already exists";
21
        }
22
    },
23
};
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 6031-6036 CREATE TABLE `subscription` ( Link Here
6031
  `mana_id` int(11) DEFAULT NULL,
6031
  `mana_id` int(11) DEFAULT NULL,
6032
  `ccode` varchar(80) DEFAULT NULL COMMENT 'collection code to assign to serial items',
6032
  `ccode` varchar(80) DEFAULT NULL COMMENT 'collection code to assign to serial items',
6033
  `published_on_template` text DEFAULT NULL COMMENT 'Template Toolkit syntax to generate the default "Published on (text)" field when receiving an issue this serial',
6033
  `published_on_template` text DEFAULT NULL COMMENT 'Template Toolkit syntax to generate the default "Published on (text)" field when receiving an issue this serial',
6034
  `auto_claim_enabled` tinyint NOT NULL DEFAULT 0 COMMENT 'enable automatic claiming',
6034
  PRIMARY KEY (`subscriptionid`),
6035
  PRIMARY KEY (`subscriptionid`),
6035
  KEY `subscription_ibfk_1` (`periodicity`),
6036
  KEY `subscription_ibfk_1` (`periodicity`),
6036
  KEY `subscription_ibfk_2` (`numberpattern`),
6037
  KEY `subscription_ibfk_2` (`numberpattern`),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (+8 lines)
Lines 237-242 fieldset.rows table { clear: none; margin: 0; } Link Here
237
                                    <label for="graceperiod">Grace period:</label>
237
                                    <label for="graceperiod">Grace period:</label>
238
                                    <input type="text" name="graceperiod" id="graceperiod" value="[% graceperiod | html %]" size="5"/> day(s)
238
                                    <input type="text" name="graceperiod" id="graceperiod" value="[% graceperiod | html %]" size="5"/> day(s)
239
                                </li>
239
                                </li>
240
                                <li>
241
                                    <label for="auto_claim_enabled">Enable automatic claims</label>
242
                                    [% IF auto_claim_enabled %]
243
                                        <input type="checkbox" name="auto_claim_enabled" id="auto_claim_enabled" value="1" checked/>
244
                                    [% ELSE %]
245
                                        <input type="checkbox" name="auto_claim_enabled" id="auto_claim_enabled" value="1"/>
246
                                    [% END %]
247
                                </li>
240
                                <li>
248
                                <li>
241
                                     <label class="widelabel" for="staffdisplaycount">Number of issues to display to staff: </label>
249
                                     <label class="widelabel" for="staffdisplaycount">Number of issues to display to staff: </label>
242
                                     <input type="text" name="staffdisplaycount" id="staffdisplaycount" value="[% staffdisplaycount | html %]" inputmode="numeric" pattern="[0-9]*"  size="4"/>
250
                                     <input type="text" name="staffdisplaycount" id="staffdisplaycount" value="[% staffdisplaycount | html %]" inputmode="numeric" pattern="[0-9]*"  size="4"/>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt (+1 lines)
Lines 132-137 Link Here
132
                                                [% END %]
132
                                                [% END %]
133
                                            </li>
133
                                            </li>
134
                                            <li><span class="label">Grace period:</span> [% graceperiod | html %]</li>
134
                                            <li><span class="label">Grace period:</span> [% graceperiod | html %]</li>
135
                                            <li><span class="label">Automatic claims:</span> [% IF auto_claim_enabled %]Enabled[% ELSE %]Disabled[% END %]</li>
135
                                        </ol>
136
                                        </ol>
136
                                    </div> <!-- /.rows -->
137
                                    </div> <!-- /.rows -->
137
                                </div> <!-- /.col-sm-6 -->
138
                                </div> <!-- /.col-sm-6 -->
(-)a/misc/cronjobs/serialsClaim.pl (+127 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2017 Biblibre
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
=head1 NAME
21
22
serialsClaims.pl - Send claim notice to suppliers that have late or missing issues
23
24
=head1 SYNOPSIS
25
26
serialsClaims.pl --letter-code LETTER_CODE [--max-claims MAX_CLAIMS]
27
28
Options:
29
    --letter-code LETTER_CODE   Mandatory. Use letter LETTER_CODE.
30
    --max-claims MAX_CLAIMS     Send up to MAX_CLAIMS notices
31
32
=cut
33
34
use Modern::Perl;
35
36
use Koha::Script -cron;
37
38
use Koha::Acquisition::Booksellers;
39
use Koha::DateUtils qw( dt_from_string );
40
use Koha::Subscriptions;
41
42
use C4::Context;
43
use C4::Letters;
44
use C4::Serials;
45
46
use Getopt::Long qw( GetOptions );
47
48
sub usage {
49
    return <<EOT;
50
Usage: $0 --letter-code LETTER_CODE [--max-claims MAX_CLAIMS]
51
EOT
52
}
53
54
my $command_line_options = join(" ",@ARGV);
55
56
my ( $help, $letter_code, $max_claims );
57
GetOptions(
58
    'help'          => \$help,
59
    'letter-code=s' => \$letter_code,
60
    'max-claims=i'  => \$max_claims,
61
) or die usage();
62
63
if ($help) {
64
    say usage();
65
    exit;
66
}
67
68
die usage() unless $letter_code;
69
70
cronlogaction({ info => $command_line_options });
71
72
my $suppliers = C4::Serials::GetSuppliersWithLateIssues();
73
foreach my $supplier (@$suppliers) {
74
    my $bookseller   = Koha::Acquisition::Booksellers->find( $supplier->{id} );
75
    my $supplierinfo = $bookseller->name . ' (' . $bookseller->id . ')';
76
77
    my $deliverytime = $bookseller->deliverytime;
78
    unless ($deliverytime) {
79
        say STDERR
80
            "Warning: There is no delivery time set for supplier $supplierinfo. Automatic claiming is disabled for this supplier.";
81
        next;
82
    }
83
84
    my @serials = C4::Serials::GetLateOrMissingIssues( $bookseller->id );
85
    my @serialids;
86
    foreach my $serial (@serials) {
87
        if ( $max_claims && $serial->{claims_count} >= $max_claims ) {
88
            say "Maximum claims count reached for serial " . $serial->{serialid};
89
            next;
90
        }
91
92
        my $subscription = Koha::Subscriptions->find( $serial->{subscriptionid} );
93
        next unless $subscription->auto_claim_enabled;
94
95
        my $claims_count = $serial->{claims_count};
96
        my $date         = $serial->{claimdate} ? $serial->{claimdate} : $serial->{planneddate};
97
        my $newclaimdate = dt_from_string($date)->add( days => $deliverytime );
98
        my $now          = dt_from_string;
99
100
        if ( $newclaimdate <= $now ) {
101
            push @serialids, $serial->{serialid};
102
        }
103
    }
104
105
    if (@serialids) {
106
        my $err;
107
        eval {
108
            $err = C4::Letters::SendAlerts( 'claimissues', \@serialids, $letter_code );
109
            if ( not ref $err or not exists $err->{error} ) {
110
                C4::Serials::updateClaim( \@serialids );
111
            }
112
        };
113
        if ($@) {
114
            say STDERR "Error: $@ while claiming serials " . join( ',', @serialids );
115
        } elsif ( ref $err and exists $err->{error} ) {
116
            if ( $err->{error} eq "no_email" ) {
117
                say STDERR "Error: Supplier $supplierinfo has no email";
118
            } elsif ( $err->{error} =~ m|Bad or missing From address| ) {
119
                say STDERR "Error: Supplier $supplierinfo has no email";
120
            } else {
121
                say STDERR "Error: " . $err->{error};
122
            }
123
        } else {
124
            say "Claim sent to $supplierinfo for serials " . join( ',', @serialids );
125
        }
126
    }
127
}
(-)a/serials/subscription-add.pl (-61 / +62 lines)
Lines 308-336 sub redirect_add_subscription { Link Here
308
    my $sublength = $query->param('sublength');
308
    my $sublength = $query->param('sublength');
309
    my ( $numberlength, $weeklength, $monthlength )
309
    my ( $numberlength, $weeklength, $monthlength )
310
        = GetSubscriptionLength( $subtype, $sublength );
310
        = GetSubscriptionLength( $subtype, $sublength );
311
    my $add1              = $query->param('add1');
311
    my $add1                  = $query->param('add1');
312
    my $lastvalue1        = $query->param('lastvalue1');
312
    my $lastvalue1            = $query->param('lastvalue1');
313
    my $innerloop1        = $query->param('innerloop1');
313
    my $innerloop1            = $query->param('innerloop1');
314
    my $innerloop2        = $query->param('innerloop2');
314
    my $innerloop2            = $query->param('innerloop2');
315
    my $lastvalue2        = $query->param('lastvalue2');
315
    my $lastvalue2            = $query->param('lastvalue2');
316
    my $lastvalue3        = $query->param('lastvalue3');
316
    my $lastvalue3            = $query->param('lastvalue3');
317
    my $innerloop3        = $query->param('innerloop3');
317
    my $innerloop3            = $query->param('innerloop3');
318
    my $status            = 1;
318
    my $status                = 1;
319
    my $biblionumber      = $query->param('biblionumber');
319
    my $biblionumber          = $query->param('biblionumber');
320
    my $callnumber        = $query->param('callnumber');
320
    my $callnumber            = $query->param('callnumber');
321
    my $notes             = $query->param('notes');
321
    my $notes                 = $query->param('notes');
322
    my $internalnotes     = $query->param('internalnotes');
322
    my $internalnotes         = $query->param('internalnotes');
323
    my $letter            = $query->param('letter');
323
    my $letter                = $query->param('letter');
324
    my $manualhistory     = $query->param('manualhist') ? 1 : 0;
324
    my $manualhistory         = $query->param('manualhist') ? 1 : 0;
325
    my $serialsadditems   = $query->param('serialsadditems');
325
    my $serialsadditems       = $query->param('serialsadditems');
326
    my $staffdisplaycount = $query->param('staffdisplaycount');
326
    my $staffdisplaycount     = $query->param('staffdisplaycount');
327
    my $opacdisplaycount  = $query->param('opacdisplaycount');
327
    my $opacdisplaycount      = $query->param('opacdisplaycount');
328
    my $location          = $query->param('location');
328
    my $location              = $query->param('location');
329
    my $itemtype          = $query->param('itemtype');
329
    my $itemtype              = $query->param('itemtype');
330
    my $previousitemtype  = $query->param('previousitemtype');
330
    my $previousitemtype      = $query->param('previousitemtype');
331
    my $skip_serialseq    = $query->param('skip_serialseq');
331
    my $skip_serialseq        = $query->param('skip_serialseq');
332
    my $ccode             = $query->param('ccode');
332
    my $ccode                 = $query->param('ccode');
333
    my $published_on_template = $query->param('published_on_template');
333
    my $published_on_template = $query->param('published_on_template');
334
    my $auto_claim_enabled    = $query->param('auto_claim_enabled');
334
335
335
    my $mana_id;
336
    my $mana_id;
336
    if ( $query->param('mana_id') ne "" ) {
337
    if ( $query->param('mana_id') ne "" ) {
Lines 350-363 sub redirect_add_subscription { Link Here
350
        }
351
        }
351
    }
352
    }
352
    my $subscriptionid = NewSubscription(
353
    my $subscriptionid = NewSubscription(
353
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
354
        $auser,                     $branchcode,       $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
354
        $startdate, $periodicity, $numberlength, $weeklength,
355
        $startdate,                 $periodicity,      $numberlength,   $weeklength,
355
        $monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2,
356
        $monthlength,               $lastvalue1,       $innerloop1,     $lastvalue2, $innerloop2,
356
        $lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate,
357
        $lastvalue3,                $innerloop3,       $status,         $notes, $letter, $firstacquidate,
357
        join(";",@irregularity), $numberpattern, $locale, $callnumber,
358
        join( ";", @irregularity ), $numberpattern,    $locale,         $callnumber,
358
        $manualhistory, $internalnotes, $serialsadditems,
359
        $manualhistory,             $internalnotes,    $serialsadditems,
359
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
360
        $staffdisplaycount,         $opacdisplaycount, $graceperiod, $location, $enddate,
360
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template
361
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template, $auto_claim_enabled
361
    );
362
    );
362
    if ( (C4::Context->preference('Mana') == 1) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){
363
    if ( (C4::Context->preference('Mana') == 1) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){
363
        my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription');
364
        my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription');
Lines 417-445 sub redirect_mod_subscription { Link Here
417
    my $subtype = $query->param('subtype');
418
    my $subtype = $query->param('subtype');
418
    my $sublength = $query->param('sublength');
419
    my $sublength = $query->param('sublength');
419
    my ($numberlength, $weeklength, $monthlength) = GetSubscriptionLength( $subtype, $sublength );
420
    my ($numberlength, $weeklength, $monthlength) = GetSubscriptionLength( $subtype, $sublength );
420
    my $locale = $query->param('locale');
421
    my $locale                = $query->param('locale');
421
    my $lastvalue1 = $query->param('lastvalue1');
422
    my $lastvalue1            = $query->param('lastvalue1');
422
    my $innerloop1 = $query->param('innerloop1');
423
    my $innerloop1            = $query->param('innerloop1');
423
    my $lastvalue2 = $query->param('lastvalue2');
424
    my $lastvalue2            = $query->param('lastvalue2');
424
    my $innerloop2 = $query->param('innerloop2');
425
    my $innerloop2            = $query->param('innerloop2');
425
    my $lastvalue3 = $query->param('lastvalue3');
426
    my $lastvalue3            = $query->param('lastvalue3');
426
    my $innerloop3 = $query->param('innerloop3');
427
    my $innerloop3            = $query->param('innerloop3');
427
    my $status = 1;
428
    my $status                = 1;
428
    my $callnumber = $query->param('callnumber');
429
    my $callnumber            = $query->param('callnumber');
429
    my $notes = $query->param('notes');
430
    my $notes                 = $query->param('notes');
430
    my $internalnotes = $query->param('internalnotes');
431
    my $internalnotes         = $query->param('internalnotes');
431
    my $letter = $query->param('letter');
432
    my $letter                = $query->param('letter');
432
    my $manualhistory = $query->param('manualhist') ? 1 : 0;
433
    my $manualhistory         = $query->param('manualhist') ? 1 : 0;
433
    my $serialsadditems = $query->param('serialsadditems');
434
    my $serialsadditems       = $query->param('serialsadditems');
434
	my $staffdisplaycount = $query->param('staffdisplaycount');
435
    my $staffdisplaycount     = $query->param('staffdisplaycount');
435
	my $opacdisplaycount = $query->param('opacdisplaycount');
436
    my $opacdisplaycount      = $query->param('opacdisplaycount');
436
    my $graceperiod     = $query->param('graceperiod') || 0;
437
    my $graceperiod           = $query->param('graceperiod') || 0;
437
    my $location = $query->param('location');
438
    my $location              = $query->param('location');
438
    my $itemtype          = $query->param('itemtype');
439
    my $itemtype              = $query->param('itemtype');
439
    my $previousitemtype  = $query->param('previousitemtype');
440
    my $previousitemtype      = $query->param('previousitemtype');
440
    my $skip_serialseq    = $query->param('skip_serialseq');
441
    my $skip_serialseq        = $query->param('skip_serialseq');
441
    my $ccode             = $query->param('ccode');
442
    my $ccode                 = $query->param('ccode');
442
    my $published_on_template = $query->param('published_on_template');
443
    my $published_on_template = $query->param('published_on_template');
444
    my $auto_claim_enabled    = $query->param('auto_claim_enabled');
443
445
444
    my $mana_id;
446
    my $mana_id;
445
    if ( $query->param('mana_id') ne "" ) {
447
    if ( $query->param('mana_id') ne "" ) {
Lines 468-481 sub redirect_mod_subscription { Link Here
468
    }
470
    }
469
471
470
    ModSubscription(
472
    ModSubscription(
471
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
473
        $auser,            $branchcode,     $aqbooksellerid, $cost, $aqbudgetid, $startdate,
472
        $periodicity, $firstacquidate, join(";",@irregularity),
474
        $periodicity,      $firstacquidate, join( ";", @irregularity ),
473
        $numberpattern, $locale, $numberlength, $weeklength, $monthlength, $lastvalue1,
475
        $numberpattern,    $locale,         $numberlength,    $weeklength, $monthlength, $lastvalue1,
474
        $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3,
476
        $innerloop1,       $lastvalue2,     $innerloop2,      $lastvalue3, $innerloop3,
475
        $status, $biblionumber, $callnumber, $notes, $letter,
477
        $status,           $biblionumber,   $callnumber,      $notes,      $letter,
476
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
478
        $manualhistory,    $internalnotes,  $serialsadditems, $staffdisplaycount,
477
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
479
        $opacdisplaycount, $graceperiod,    $location,        $enddate, $subscriptionid,
478
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template
480
        $skip_serialseq,   $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template, $auto_claim_enabled
479
    );
481
    );
480
482
481
    my @additional_fields;
483
    my @additional_fields;
482
- 

Return to bug 18783