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

(-)a/C4/Letters.pm (-3 / +9 lines)
Lines 479-485 sub SendAlerts { Link Here
479
        $letter->{content} =~ s/<order>(.*?)<\/order>/$1/gxms;
479
        $letter->{content} =~ s/<order>(.*?)<\/order>/$1/gxms;
480
480
481
        # ... then send mail
481
        # ... then send mail
482
        my $from;
482
        my $library = Koha::Libraries->find( $userenv->{branch} );
483
        my $library = Koha::Libraries->find( $userenv->{branch} );
484
        if ($library and $library->branchemail) {
485
            $from = $library->branchemail;
486
        } else {
487
            $from = C4::Context->preference('KohaAdminEmailAddress');
488
        }
483
        my $mail = Koha::Email->create(
489
        my $mail = Koha::Email->create(
484
            {
490
            {
485
                to => join( ',', @email ),
491
                to => join( ',', @email ),
Lines 493-500 sub SendAlerts { Link Here
493
                    ? ( bcc => $userenv->{emailaddress} )
499
                    ? ( bcc => $userenv->{emailaddress} )
494
                    : ()
500
                    : ()
495
                ),
501
                ),
496
                from => $library->branchemail
502
                from => $from,
497
                  || C4::Context->preference('KohaAdminEmailAddress'),
498
                subject => "" . $letter->{title},
503
                subject => "" . $letter->{title},
499
            }
504
            }
500
        );
505
        );
Lines 507-513 sub SendAlerts { Link Here
507
        }
512
        }
508
513
509
        my $success = try {
514
        my $success = try {
510
            $mail->send_or_die({ transport => $library->smtp_server->transport });
515
            my $smtp_server = $library ? $library->smtp_server : Koha::SMTP::Servers->get_default;
516
            $mail->send_or_die({ transport => $smtp_server->transport });
511
        }
517
        }
512
        catch {
518
        catch {
513
            # We expect ref($_) eq 'Email::Sender::Failure'
519
            # We expect ref($_) eq 'Email::Sender::Failure'
(-)a/C4/Serials.pm (-93 / +96 lines)
Lines 1285-1342 returns the number of rows affected Link Here
1285
1285
1286
sub ModSubscription {
1286
sub ModSubscription {
1287
    my (
1287
    my (
1288
    $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
1288
        $auser,         $branchcode,       $aqbooksellerid,    $cost,          $aqbudgetid, $startdate,
1289
    $periodicity, $firstacquidate, $irregularity, $numberpattern, $locale,
1289
        $periodicity,   $firstacquidate,   $irregularity,      $numberpattern, $locale,
1290
    $numberlength, $weeklength, $monthlength, $lastvalue1, $innerloop1,
1290
        $numberlength,  $weeklength,       $monthlength,       $lastvalue1,    $innerloop1,
1291
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1291
        $lastvalue2,    $innerloop2,       $lastvalue3,        $innerloop3,    $status,
1292
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1292
        $biblionumber,  $callnumber,       $notes,             $letter,        $manualhistory,
1293
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1293
        $internalnotes, $serialsadditems,  $staffdisplaycount, $opacdisplaycount,
1294
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1294
        $graceperiod,   $location,         $enddate,           $subscriptionid, $skip_serialseq,
1295
    $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template
1295
        $itemtype,      $previousitemtype, $mana_id,           $ccode,          $published_on_template,
1296
        $auto_claim_enabled
1296
    ) = @_;
1297
    ) = @_;
1297
1298
1298
    my $subscription = Koha::Subscriptions->find($subscriptionid);
1299
    my $subscription = Koha::Subscriptions->find($subscriptionid);
1299
    $subscription->set(
1300
    $subscription->set(
1300
        {
1301
        {
1301
            librarian         => $auser,
1302
            librarian             => $auser,
1302
            branchcode        => $branchcode,
1303
            branchcode            => $branchcode,
1303
            aqbooksellerid    => $aqbooksellerid,
1304
            aqbooksellerid        => $aqbooksellerid,
1304
            cost              => $cost,
1305
            cost                  => $cost,
1305
            aqbudgetid        => $aqbudgetid,
1306
            aqbudgetid            => $aqbudgetid,
1306
            biblionumber      => $biblionumber,
1307
            biblionumber          => $biblionumber,
1307
            startdate         => $startdate,
1308
            startdate             => $startdate,
1308
            periodicity       => $periodicity,
1309
            periodicity           => $periodicity,
1309
            numberlength      => $numberlength,
1310
            numberlength          => $numberlength,
1310
            weeklength        => $weeklength,
1311
            weeklength            => $weeklength,
1311
            monthlength       => $monthlength,
1312
            monthlength           => $monthlength,
1312
            lastvalue1        => $lastvalue1,
1313
            lastvalue1            => $lastvalue1,
1313
            innerloop1        => $innerloop1,
1314
            innerloop1            => $innerloop1,
1314
            lastvalue2        => $lastvalue2,
1315
            lastvalue2            => $lastvalue2,
1315
            innerloop2        => $innerloop2,
1316
            innerloop2            => $innerloop2,
1316
            lastvalue3        => $lastvalue3,
1317
            lastvalue3            => $lastvalue3,
1317
            innerloop3        => $innerloop3,
1318
            innerloop3            => $innerloop3,
1318
            status            => $status,
1319
            status                => $status,
1319
            notes             => $notes,
1320
            notes                 => $notes,
1320
            letter            => $letter,
1321
            letter                => $letter,
1321
            firstacquidate    => $firstacquidate,
1322
            firstacquidate        => $firstacquidate,
1322
            irregularity      => $irregularity,
1323
            irregularity          => $irregularity,
1323
            numberpattern     => $numberpattern,
1324
            numberpattern         => $numberpattern,
1324
            locale            => $locale,
1325
            locale                => $locale,
1325
            callnumber        => $callnumber,
1326
            callnumber            => $callnumber,
1326
            manualhistory     => $manualhistory,
1327
            manualhistory         => $manualhistory,
1327
            internalnotes     => $internalnotes,
1328
            internalnotes         => $internalnotes,
1328
            serialsadditems   => $serialsadditems,
1329
            serialsadditems       => $serialsadditems,
1329
            staffdisplaycount => $staffdisplaycount,
1330
            staffdisplaycount     => $staffdisplaycount,
1330
            opacdisplaycount  => $opacdisplaycount,
1331
            opacdisplaycount      => $opacdisplaycount,
1331
            graceperiod       => $graceperiod,
1332
            graceperiod           => $graceperiod,
1332
            location          => $location,
1333
            location              => $location,
1333
            enddate           => $enddate,
1334
            enddate               => $enddate,
1334
            skip_serialseq    => $skip_serialseq,
1335
            skip_serialseq        => $skip_serialseq,
1335
            itemtype          => $itemtype,
1336
            itemtype              => $itemtype,
1336
            previousitemtype  => $previousitemtype,
1337
            previousitemtype      => $previousitemtype,
1337
            mana_id           => $mana_id,
1338
            mana_id               => $mana_id,
1338
            ccode             => $ccode,
1339
            ccode                 => $ccode,
1339
            published_on_template => $published_on_template,
1340
            published_on_template => $published_on_template,
1341
            auto_claim_enabled    => $auto_claim_enabled // 0,
1340
        }
1342
        }
1341
    )->store;
1343
    )->store;
1342
    # FIXME Must be $subscription->serials
1344
    # FIXME Must be $subscription->serials
Lines 1368-1425 the id of this new subscription Link Here
1368
1370
1369
sub NewSubscription {
1371
sub NewSubscription {
1370
    my (
1372
    my (
1371
    $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
1373
        $auser,                 $branchcode,        $aqbooksellerid,   $cost,          $aqbudgetid, $biblionumber,
1372
    $startdate, $periodicity, $numberlength, $weeklength, $monthlength,
1374
        $startdate,             $periodicity,       $numberlength,     $weeklength,    $monthlength,
1373
    $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3,
1375
        $lastvalue1,            $innerloop1,        $lastvalue2,       $innerloop2,    $lastvalue3,
1374
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1376
        $innerloop3,            $status,            $notes,            $letter,        $firstacquidate, $irregularity,
1375
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1377
        $numberpattern,         $locale,            $callnumber,       $manualhistory, $internalnotes,
1376
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1378
        $serialsadditems,       $staffdisplaycount, $opacdisplaycount, $graceperiod,
1377
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode,
1379
        $location,              $enddate,           $skip_serialseq,   $itemtype, $previousitemtype, $mana_id, $ccode,
1378
    $published_on_template,
1380
        $published_on_template, $auto_claim_enabled
1379
    ) = @_;
1381
    ) = @_;
1380
    my $dbh = C4::Context->dbh;
1382
    my $dbh = C4::Context->dbh;
1381
1383
1382
    my $subscription = Koha::Subscription->new(
1384
    my $subscription = Koha::Subscription->new(
1383
        {
1385
        {
1384
            librarian         => $auser,
1386
            librarian             => $auser,
1385
            branchcode        => $branchcode,
1387
            branchcode            => $branchcode,
1386
            aqbooksellerid    => $aqbooksellerid,
1388
            aqbooksellerid        => $aqbooksellerid,
1387
            cost              => $cost,
1389
            cost                  => $cost,
1388
            aqbudgetid        => $aqbudgetid,
1390
            aqbudgetid            => $aqbudgetid,
1389
            biblionumber      => $biblionumber,
1391
            biblionumber          => $biblionumber,
1390
            startdate         => $startdate,
1392
            startdate             => $startdate,
1391
            periodicity       => $periodicity,
1393
            periodicity           => $periodicity,
1392
            numberlength      => $numberlength,
1394
            numberlength          => $numberlength,
1393
            weeklength        => $weeklength,
1395
            weeklength            => $weeklength,
1394
            monthlength       => $monthlength,
1396
            monthlength           => $monthlength,
1395
            lastvalue1        => $lastvalue1,
1397
            lastvalue1            => $lastvalue1,
1396
            innerloop1        => $innerloop1,
1398
            innerloop1            => $innerloop1,
1397
            lastvalue2        => $lastvalue2,
1399
            lastvalue2            => $lastvalue2,
1398
            innerloop2        => $innerloop2,
1400
            innerloop2            => $innerloop2,
1399
            lastvalue3        => $lastvalue3,
1401
            lastvalue3            => $lastvalue3,
1400
            innerloop3        => $innerloop3,
1402
            innerloop3            => $innerloop3,
1401
            status            => $status,
1403
            status                => $status,
1402
            notes             => $notes,
1404
            notes                 => $notes,
1403
            letter            => $letter,
1405
            letter                => $letter,
1404
            firstacquidate    => $firstacquidate,
1406
            firstacquidate        => $firstacquidate,
1405
            irregularity      => $irregularity,
1407
            irregularity          => $irregularity,
1406
            numberpattern     => $numberpattern,
1408
            numberpattern         => $numberpattern,
1407
            locale            => $locale,
1409
            locale                => $locale,
1408
            callnumber        => $callnumber,
1410
            callnumber            => $callnumber,
1409
            manualhistory     => $manualhistory,
1411
            manualhistory         => $manualhistory,
1410
            internalnotes     => $internalnotes,
1412
            internalnotes         => $internalnotes,
1411
            serialsadditems   => $serialsadditems,
1413
            serialsadditems       => $serialsadditems,
1412
            staffdisplaycount => $staffdisplaycount,
1414
            staffdisplaycount     => $staffdisplaycount,
1413
            opacdisplaycount  => $opacdisplaycount,
1415
            opacdisplaycount      => $opacdisplaycount,
1414
            graceperiod       => $graceperiod,
1416
            graceperiod           => $graceperiod,
1415
            location          => $location,
1417
            location              => $location,
1416
            enddate           => $enddate,
1418
            enddate               => $enddate,
1417
            skip_serialseq    => $skip_serialseq,
1419
            skip_serialseq        => $skip_serialseq,
1418
            itemtype          => $itemtype,
1420
            itemtype              => $itemtype,
1419
            previousitemtype  => $previousitemtype,
1421
            previousitemtype      => $previousitemtype,
1420
            mana_id           => $mana_id,
1422
            mana_id               => $mana_id,
1421
            ccode             => $ccode,
1423
            ccode                 => $ccode,
1422
            published_on_template => $published_on_template,
1424
            published_on_template => $published_on_template,
1425
            auto_claim_enabled    => $auto_claim_enabled // 0,
1423
        }
1426
        }
1424
    )->store;
1427
    )->store;
1425
    $subscription->discard_changes;
1428
    $subscription->discard_changes;
Lines 1859-1865 sub GetLateOrMissingIssues { Link Here
1859
    if ($supplierid) {
1862
    if ($supplierid) {
1860
        $sth = $dbh->prepare(
1863
        $sth = $dbh->prepare(
1861
            "SELECT
1864
            "SELECT
1862
                serialid,      aqbooksellerid,        name,
1865
                serialid,      serial.aqbooksellerid,        name,
1863
                biblio.title,  biblioitems.issn,      planneddate,    serialseq,
1866
                biblio.title,  biblioitems.issn,      planneddate,    serialseq,
1864
                serial.status, serial.subscriptionid, claimdate, claims_count,
1867
                serial.status, serial.subscriptionid, claimdate, claims_count,
1865
                subscription.branchcode, serial.publisheddate
1868
                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 previousitemtype
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 5535-5540 CREATE TABLE `subscription` ( Link Here
5535
  `previousitemtype` varchar(10) DEFAULT NULL,
5535
  `previousitemtype` varchar(10) DEFAULT NULL,
5536
  `mana_id` int(11) DEFAULT NULL,
5536
  `mana_id` int(11) DEFAULT NULL,
5537
  `ccode` varchar(80) DEFAULT NULL COMMENT 'collection code to assign to serial items',
5537
  `ccode` varchar(80) DEFAULT NULL COMMENT 'collection code to assign to serial items',
5538
  `auto_claim_enabled` tinyint NOT NULL DEFAULT 0 COMMENT 'enable automatic claiming',
5538
  `published_on_template` TEXT DEFAULT NULL COMMENT 'Template Toolkit syntax to generate the default "Published on (text)" field when receiving an issue this serial',
5539
  `published_on_template` TEXT DEFAULT NULL COMMENT 'Template Toolkit syntax to generate the default "Published on (text)" field when receiving an issue this serial',
5539
  PRIMARY KEY (`subscriptionid`),
5540
  PRIMARY KEY (`subscriptionid`),
5540
  KEY `subscription_ibfk_1` (`periodicity`),
5541
  KEY `subscription_ibfk_1` (`periodicity`),
(-)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 126-131 Link Here
126
                                                [% END %]
126
                                                [% END %]
127
                                            </li>
127
                                            </li>
128
                                            <li><span class="label">Grace period:</span> [% graceperiod | html %]</li>
128
                                            <li><span class="label">Grace period:</span> [% graceperiod | html %]</li>
129
                                            <li><span class="label">Automatic claims:</span> [% IF auto_claim_enabled %]Enabled[% ELSE %]Disabled[% END %]</li>
129
                                        </ol>
130
                                        </ol>
130
                                    </div> <!-- /.rows -->
131
                                    </div> <!-- /.rows -->
131
                                </div> <!-- /.col-sm-6 -->
132
                                </div> <!-- /.col-sm-6 -->
(-)a/misc/cronjobs/serialsClaim.pl (+124 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 Getopt::Long;
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
sub usage {
47
    return <<EOT;
48
Usage: $0 --letter-code LETTER_CODE [--max-claims MAX_CLAIMS]
49
EOT
50
}
51
52
my $help;
53
my $letter_code;
54
my $max_claims;
55
56
GetOptions(
57
    'help'          => \$help,
58
    'letter-code=s' => \$letter_code,
59
    'max-claims=i'  => \$max_claims,
60
) or die usage();
61
62
if ($help) {
63
    say usage();
64
    exit;
65
}
66
67
die usage() unless $letter_code;
68
69
my $suppliers = C4::Serials::GetSuppliersWithLateIssues();
70
foreach my $supplier (@$suppliers) {
71
    my $bookseller   = Koha::Acquisition::Booksellers->find( $supplier->{id} );
72
    my $supplierinfo = $bookseller->name . ' (' . $bookseller->id . ')';
73
74
    my $deliverytime = $bookseller->deliverytime;
75
    unless ($deliverytime) {
76
        say STDERR
77
            "Warning: There is no delivery time set for supplier $supplierinfo. Automatic claiming is disabled for this supplier.";
78
        next;
79
    }
80
81
    my @serials = C4::Serials::GetLateOrMissingIssues( $bookseller->id );
82
    my @serialids;
83
    foreach my $serial (@serials) {
84
        if ( $max_claims && $serial->{claims_count} >= $max_claims ) {
85
            say "Maximum claims count reached for serial " . $serial->{serialid};
86
            next;
87
        }
88
89
        my $subscription = Koha::Subscriptions->find( $serial->{subscriptionid} );
90
        next unless $subscription->auto_claim_enabled;
91
92
        my $claims_count = $serial->{claims_count};
93
        my $date         = $serial->{claimdate} ? $serial->{claimdate} : $serial->{planneddate};
94
        my $newclaimdate = dt_from_string($date)->add( days => $deliverytime );
95
        my $now          = dt_from_string;
96
97
        if ( $newclaimdate <= $now ) {
98
            push @serialids, $serial->{serialid};
99
        }
100
    }
101
102
    if (@serialids) {
103
        my $err;
104
        eval {
105
            $err = C4::Letters::SendAlerts( 'claimissues', \@serialids, $letter_code );
106
            if ( not ref $err or not exists $err->{error} ) {
107
                C4::Serials::updateClaim( \@serialids );
108
            }
109
        };
110
        if ($@) {
111
            say STDERR "Error: $@ while claiming serials " . join( ',', @serialids );
112
        } elsif ( ref $err and exists $err->{error} ) {
113
            if ( $err->{error} eq "no_email" ) {
114
                say STDERR "Error: Supplier $supplierinfo has no email";
115
            } elsif ( $err->{error} =~ m|Bad or missing From address| ) {
116
                say STDERR "Error: Supplier $supplierinfo has no email";
117
            } else {
118
                say STDERR "Error: " . $err->{error};
119
            }
120
        } else {
121
            say "Claim sent to $supplierinfo for serials " . join( ',', @serialids );
122
        }
123
    }
124
}
(-)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