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

(-)a/C4/Serials.pm (-7 / +46 lines)
Lines 51-56 BEGIN { Link Here
51
      &ReNewSubscription  &GetLateIssues      &GetLateOrMissingIssues
51
      &ReNewSubscription  &GetLateIssues      &GetLateOrMissingIssues
52
      &GetSerialInformation                   &AddItem2Serial
52
      &GetSerialInformation                   &AddItem2Serial
53
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
53
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
54
      &GetPreviousSerialid
54
55
55
      &UpdateClaimdateIssues
56
      &UpdateClaimdateIssues
56
      &GetSuppliersWithLateIssues             &getsupplierbyserialid
57
      &GetSuppliersWithLateIssues             &getsupplierbyserialid
Lines 895-900 sub GetLatestSerials { Link Here
895
    return \@serials;
896
    return \@serials;
896
}
897
}
897
898
899
=head2 GetPreviousSerialid
900
901
$serialid = GetPreviousSerialid($subscriptionid, $nth)
902
get the $nth's previous serial for the given subscriptionid
903
return :
904
the serialid
905
906
=cut
907
908
sub GetPreviousSerialid {
909
    my ( $subscriptionid, $nth ) = @_;
910
    $nth ||= 1;
911
    my $dbh = C4::Context->dbh;
912
    my $return = undef;
913
914
    # Status 2: Arrived
915
    my $strsth = "SELECT   serialid
916
                        FROM     serial
917
                        WHERE    subscriptionid = ?
918
                        AND      status = 2
919
                        ORDER BY serialid DESC LIMIT $nth,1 
920
                ";
921
    my $sth = $dbh->prepare($strsth);
922
    $sth->execute($subscriptionid);
923
    my @serials;
924
    my $line = $sth->fetchrow_hashref;
925
    $return = $line->{'serialid'} if ($line);
926
927
    return $return;
928
}
929
930
931
898
=head2 GetDistributedTo
932
=head2 GetDistributedTo
899
933
900
$distributedto=GetDistributedTo($subscriptionid)
934
$distributedto=GetDistributedTo($subscriptionid)
Lines 1385-1391 sub ModSubscription { Link Here
1385
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1419
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1386
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1420
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1387
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1421
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1388
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq
1422
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1423
    $itemtype, $previousitemtype
1389
    ) = @_;
1424
    ) = @_;
1390
1425
1391
    my $dbh   = C4::Context->dbh;
1426
    my $dbh   = C4::Context->dbh;
Lines 1398-1404 sub ModSubscription { Link Here
1398
            callnumber=?, notes=?, letter=?, manualhistory=?,
1433
            callnumber=?, notes=?, letter=?, manualhistory=?,
1399
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1434
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1400
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1435
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1401
            skip_serialseq=?
1436
            skip_serialseq=?, itemtype=?, previousitemtype=?
1402
        WHERE subscriptionid = ?";
1437
        WHERE subscriptionid = ?";
1403
1438
1404
    my $sth = $dbh->prepare($query);
1439
    my $sth = $dbh->prepare($query);
Lines 1412-1417 sub ModSubscription { Link Here
1412
        $letter,          ($manualhistory ? $manualhistory : 0),
1447
        $letter,          ($manualhistory ? $manualhistory : 0),
1413
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1448
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1414
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1449
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1450
        $itemtype,        $previousitemtype,
1415
        $subscriptionid
1451
        $subscriptionid
1416
    );
1452
    );
1417
    my $rows = $sth->rows;
1453
    my $rows = $sth->rows;
Lines 1427-1433 $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu Link Here
1427
    $lastvalue1,$innerloop1,$lastvalue2,$innerloop2,$lastvalue3,$innerloop3,
1463
    $lastvalue1,$innerloop1,$lastvalue2,$innerloop2,$lastvalue3,$innerloop3,
1428
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1464
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1429
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1465
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1430
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq);
1466
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, 
1467
    $skip_serialseq, $itemtype, $previousitemtype);
1431
1468
1432
Create a new subscription with value given on input args.
1469
Create a new subscription with value given on input args.
1433
1470
Lines 1444-1450 sub NewSubscription { Link Here
1444
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1481
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1445
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1482
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1446
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1483
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1447
    $location, $enddate, $skip_serialseq
1484
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype
1448
    ) = @_;
1485
    ) = @_;
1449
    my $dbh = C4::Context->dbh;
1486
    my $dbh = C4::Context->dbh;
1450
1487
Lines 1457-1464 sub NewSubscription { Link Here
1457
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1494
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1458
            irregularity, numberpattern, locale, callnumber,
1495
            irregularity, numberpattern, locale, callnumber,
1459
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1496
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1460
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq)
1497
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq,
1461
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1498
            itemtype, previousitemtype)
1499
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1462
        |;
1500
        |;
1463
    my $sth = $dbh->prepare($query);
1501
    my $sth = $dbh->prepare($query);
1464
    $sth->execute(
1502
    $sth->execute(
Lines 1468-1474 sub NewSubscription { Link Here
1468
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1506
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1469
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1507
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1470
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1508
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1471
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq
1509
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
1510
        $itemtype, $previousitemtype
1472
    );
1511
    );
1473
1512
1474
    my $subscriptionid = $dbh->{'mysql_insertid'};
1513
    my $subscriptionid = $dbh->{'mysql_insertid'};
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 2099-2104 CREATE TABLE `subscription` ( Link Here
2099
  `enddate` date default NULL,
2099
  `enddate` date default NULL,
2100
  `closed` INT(1) NOT NULL DEFAULT 0,
2100
  `closed` INT(1) NOT NULL DEFAULT 0,
2101
  `reneweddate` date default NULL,
2101
  `reneweddate` date default NULL,
2102
  `itemtype` VARCHAR( 10 ) NULL,
2103
  `previousitemtype` VARCHAR( 10 ) NULL,
2102
  PRIMARY KEY  (`subscriptionid`),
2104
  PRIMARY KEY  (`subscriptionid`),
2103
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
2105
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
2104
  CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
2106
  CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 180-185 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
180
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
180
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
181
('LinkerRelink','1',NULL,'If ON the authority linker will relink headings that have previously been linked every time it runs.','YesNo'),
181
('LinkerRelink','1',NULL,'If ON the authority linker will relink headings that have previously been linked every time it runs.','YesNo'),
182
('LocalCoverImages','0','1','Display local cover images on intranet details pages.','YesNo'),
182
('LocalCoverImages','0','1','Display local cover images on intranet details pages.','YesNo'),
183
('makePreviousSerialAvailable','0','','make previous serial automatically available when collecting a new serial. Please note that the item-level_itypes syspref must be set to specific item.','YesNo'),
183
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
184
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
184
('MARCAuthorityControlField008','|| aca||aabn           | a|a     d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'),
185
('MARCAuthorityControlField008','|| aca||aabn           | a|a     d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'),
185
('MarcFieldsToOrder','',NULL,'Set the mapping values for a new order line created from a MARC record in a staged file. In a YAML format.','textarea'),
186
('MarcFieldsToOrder','',NULL,'Set the mapping values for a new order line created from a MARC record in a staged file. In a YAML format.','textarea'),
(-)a/installer/data/mysql/updatedatabase.pl (+18 lines)
Lines 8570-8575 if ( CheckVersion($DBversion) ) { Link Here
8570
    SetVersion($DBversion);
8570
    SetVersion($DBversion);
8571
}
8571
}
8572
8572
8573
8574
8575
8576
8577
$DBversion = "3.17.00.XXX";
8578
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8579
    $dbh->do(q{
8580
        ALTER TABLE `subscription` ADD `itemtype` VARCHAR( 10 ) NULL AFTER reneweddate,
8581
        ADD `previousitemtype` VARCHAR( 10 ) NULL AFTER itemtype
8582
    });
8583
    $dbh->do(
8584
        "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('makePreviousSerialAvailable','0','make previous serial automatically available when collecting a new serial. Please note that the item-level_itypes syspref must be set to specific item.','','YesNo');"
8585
    );
8586
    print "Upgrade to $DBversion done (Bug 7677: Adds fields to subscription table and makePreviousSerialAvailable syspref)\n";
8587
    SetVersion($DBversion);
8588
}
8589
8590
8573
=head1 FUNCTIONS
8591
=head1 FUNCTIONS
8574
8592
8575
=head2 TableExists($table)
8593
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref (+6 lines)
Lines 50-52 Serials: Link Here
50
    -
50
    -
51
        - List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)
51
        - List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)
52
        - pref: SubscriptionDuplicateDroppedInput
52
        - pref: SubscriptionDuplicateDroppedInput
53
    -
54
        - pref: makePreviousSerialAvailable
55
          choices: 
56
            yes: Make
57
            no: Do not make
58
        - previous serial automatically available when collecting a new serial. Please note that the item-level_itypes syspref must be set to specific item.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt (-1 lines)
Lines 58-64 function unHideItems(index,labelindex, serialId) { Link Here
58
    subfield_div = $(item_div).find("input[name='kohafield'][value='items.enumchron']").parent();
58
    subfield_div = $(item_div).find("input[name='kohafield'][value='items.enumchron']").parent();
59
    // Setting text field
59
    // Setting text field
60
    $(subfield_div).children("input[type='text'][name='field_value']").val($("#serialseq" + serialId).val());
60
    $(subfield_div).children("input[type='text'][name='field_value']").val($("#serialseq" + serialId).val());
61
62
}
61
}
63
function HideItems(index,labelindex) {
62
function HideItems(index,labelindex) {
64
	subfield = document.getElementById(index);
63
	subfield = document.getElementById(index);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (+28 lines)
Lines 594-599 $(document).ready(function() { Link Here
594
                                    </select>
594
                                    </select>
595
                                </li>
595
                                </li>
596
                                <li>
596
                                <li>
597
                                    <label for="itemtype">Item type:</label>
598
                                    <select name="itemtype" id="itemtype">
599
                                        <option value=""></option>
600
                                        [% FOREACH type IN typeloop %]
601
                                            [% IF ( type.selected ) %]
602
                                                <option value="[% type.code %]" selected="selected">[% type.value %]</option>
603
                                            [% ELSE %]
604
                                                <option value="[% type.code %]">[% type.value %]</option>
605
                                            [% END %]
606
                                        [% END %]
607
                                    </select>
608
                                </li>
609
                                [%IF makePreviousSerialAvailable %]
610
                                <li>
611
                                    <label for="previousitemtype">Previous item type:</label>
612
                                    <select name="previousitemtype" id="previousitemtype">
613
                                            <option value=""></option>
614
                                        [% FOREACH previous IN previoustypeloop %]
615
                                            [% IF ( previous.selected ) %]
616
                                                <option value="[% previous.code %]" selected="selected">[% previous.value %]</option>
617
                                            [% ELSE %]
618
                                                <option value="[% previous.code %]">[% previous.value %]</option>
619
                                            [% END %]
620
                                        [% END %]
621
                                    </select>
622
                                </li>
623
                                [% END %]
624
                                    <li>
597
                                    <label for="graceperiod">Grace period:</label>
625
                                    <label for="graceperiod">Grace period:</label>
598
                                    <input type="text" name="graceperiod" id="graceperiod" value="[% graceperiod %]" size="5"/> day(s)
626
                                    <input type="text" name="graceperiod" id="graceperiod" value="[% graceperiod %]" size="5"/> day(s)
599
                                </li>
627
                                </li>
(-)a/serials/serials-edit.pl (+24 lines)
Lines 90-95 if ( scalar(@subscriptionids) == 1 && index( $subscriptionids[0], q|,| ) > 0 ) { Link Here
90
}
90
}
91
my @errors;
91
my @errors;
92
my @errseq;
92
my @errseq;
93
my $dbh   = C4::Context->dbh;
93
94
94
# If user comes from subscription details
95
# If user comes from subscription details
95
unless (@serialids) {
96
unless (@serialids) {
Lines 242-247 if ( $op and $op eq 'serialchangestatus' ) { Link Here
242
                $notes[$i]
243
                $notes[$i]
243
            );
244
            );
244
        }
245
        }
246
        my $makePreviousSerialAvailable = C4::Context->preference('makePreviousSerialAvailable');
247
        if ($makePreviousSerialAvailable && $serialids[$i] ne "NEW") {
248
            # We already have created the new expected serial at this point, so we get the second previous serial
249
            my $previous = GetPreviousSerialid($subscriptionids[$i]);
250
            if ($previous) {
251
252
                # Getting the itemnumber matching the serialid
253
                my $query = "SELECT itemnumber FROM serialitems WHERE serialid=?";
254
                my $sth = $dbh->prepare($query);
255
                $sth->execute($previous);
256
                my @row = $sth->fetchrow_array;
257
                if ($row[0]) {
258
                    my $itemnumber = $row[0];
259
260
                    # Getting the itemtype to set from the database
261
                    my $subscriptioninfos = GetSubscription($subscriptionids[$i]);
262
263
                    # Changing the status to "available" and the itemtype according to the previousitemtype db field
264
                    ModItem({notforloan => 0, itype => $subscriptioninfos->{'previousitemtype'} }, undef, $itemnumber);
265
                }
266
            }
267
        }
268
245
    }
269
    }
246
    my @moditems = $query->param('moditem');
270
    my @moditems = $query->param('moditem');
247
    if ( scalar(@moditems) ) {
271
    if ( scalar(@moditems) ) {
(-)a/serials/subscription-add.pl (-2 / +21 lines)
Lines 153-159 my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'}); Link Here
153
$template->param(branchloop => $branchloop,
153
$template->param(branchloop => $branchloop,
154
    locations_loop=>$locations_loop,
154
    locations_loop=>$locations_loop,
155
);
155
);
156
157
my $typeloop = GetItemTypes();
158
159
my @typearg =
160
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{itemtype} and $_ eq $subs->{itemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
161
my @previoustypearg =
162
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{previousitemtype} and $_ eq $subs->{previousitemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
163
164
$template->param(
165
    branchloop               => $branchloop,
166
    typeloop                 => \@typearg,
167
    previoustypeloop         => \@previoustypearg,
168
    locations_loop=>$locations_loop,
169
);
156
# prepare template variables common to all $op conditions:
170
# prepare template variables common to all $op conditions:
171
$template->param('makePreviousSerialAvailable' => 1) if (C4::Context->preference('makePreviousSerialAvailable'));
172
157
if ($op!~/^mod/) {
173
if ($op!~/^mod/) {
158
    my $letters = get_letter_loop();
174
    my $letters = get_letter_loop();
159
    $template->param( letterloop => $letters );
175
    $template->param( letterloop => $letters );
Lines 318-323 sub redirect_add_subscription { Link Here
318
    my $staffdisplaycount = $query->param('staffdisplaycount');
334
    my $staffdisplaycount = $query->param('staffdisplaycount');
319
    my $opacdisplaycount  = $query->param('opacdisplaycount');
335
    my $opacdisplaycount  = $query->param('opacdisplaycount');
320
    my $location          = $query->param('location');
336
    my $location          = $query->param('location');
337
    my $itemtype          = $query->param('itemtype');
338
    my $previousitemtype  = $query->param('previousitemtype');
321
    my $skip_serialseq    = $query->param('skip_serialseq');
339
    my $skip_serialseq    = $query->param('skip_serialseq');
322
    my $startdate = format_date_in_iso( $query->param('startdate') );
340
    my $startdate = format_date_in_iso( $query->param('startdate') );
323
    my $enddate = format_date_in_iso( $query->param('enddate') );
341
    my $enddate = format_date_in_iso( $query->param('enddate') );
Lines 386-391 sub redirect_mod_subscription { Link Here
386
	my $opacdisplaycount = $query->param('opacdisplaycount');
404
	my $opacdisplaycount = $query->param('opacdisplaycount');
387
    my $graceperiod     = $query->param('graceperiod') || 0;
405
    my $graceperiod     = $query->param('graceperiod') || 0;
388
    my $location = $query->param('location');
406
    my $location = $query->param('location');
407
    my $itemtype          = $query->param('itemtype');
408
    my $previousitemtype  = $query->param('previousitemtype');
389
    my $skip_serialseq    = $query->param('skip_serialseq');
409
    my $skip_serialseq    = $query->param('skip_serialseq');
390
410
391
    # Guess end date
411
    # Guess end date
Lines 413-419 sub redirect_mod_subscription { Link Here
413
        $status, $biblionumber, $callnumber, $notes, $letter,
433
        $status, $biblionumber, $callnumber, $notes, $letter,
414
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
434
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
415
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
435
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
416
        $skip_serialseq
436
        $skip_serialseq, $itemtype, $previousitemtype
417
    );
437
    );
418
438
419
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
439
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
420
- 

Return to bug 7677