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

(-)a/C4/Serials.pm (-7 / +46 lines)
Lines 50-55 BEGIN { Link Here
50
      &ReNewSubscription  &GetLateIssues      &GetLateOrMissingIssues
50
      &ReNewSubscription  &GetLateIssues      &GetLateOrMissingIssues
51
      &GetSerialInformation                   &AddItem2Serial
51
      &GetSerialInformation                   &AddItem2Serial
52
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
52
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
53
      &GetPreviousSerialid
53
54
54
      &UpdateClaimdateIssues
55
      &UpdateClaimdateIssues
55
      &GetSuppliersWithLateIssues             &getsupplierbyserialid
56
      &GetSuppliersWithLateIssues             &getsupplierbyserialid
Lines 897-902 sub GetLatestSerials { Link Here
897
    return \@serials;
898
    return \@serials;
898
}
899
}
899
900
901
=head2 GetPreviousSerialid
902
903
$serialid = GetPreviousSerialid($subscriptionid, $nth)
904
get the $nth's previous serial for the given subscriptionid
905
return :
906
the serialid
907
908
=cut
909
910
sub GetPreviousSerialid {
911
    my ( $subscriptionid, $nth ) = @_;
912
    $nth ||= 1;
913
    my $dbh = C4::Context->dbh;
914
    my $return = undef;
915
916
    # Status 2: Arrived
917
    my $strsth = "SELECT   serialid
918
                        FROM     serial
919
                        WHERE    subscriptionid = ?
920
                        AND      status = 2
921
                        ORDER BY serialid DESC LIMIT $nth,1 
922
                ";
923
    my $sth = $dbh->prepare($strsth);
924
    $sth->execute($subscriptionid);
925
    my @serials;
926
    my $line = $sth->fetchrow_hashref;
927
    $return = $line->{'serialid'} if ($line);
928
929
    return $return;
930
}
931
932
933
900
=head2 GetDistributedTo
934
=head2 GetDistributedTo
901
935
902
$distributedto=GetDistributedTo($subscriptionid)
936
$distributedto=GetDistributedTo($subscriptionid)
Lines 1420-1426 sub ModSubscription { Link Here
1420
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1454
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1421
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1455
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1422
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1456
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1423
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq
1457
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1458
    $itemtype, $previousitemtype
1424
    ) = @_;
1459
    ) = @_;
1425
1460
1426
    my $dbh   = C4::Context->dbh;
1461
    my $dbh   = C4::Context->dbh;
Lines 1433-1439 sub ModSubscription { Link Here
1433
            callnumber=?, notes=?, letter=?, manualhistory=?,
1468
            callnumber=?, notes=?, letter=?, manualhistory=?,
1434
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1469
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1435
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1470
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1436
            skip_serialseq=?
1471
            skip_serialseq=?, itemtype=?, previousitemtype=?
1437
        WHERE subscriptionid = ?";
1472
        WHERE subscriptionid = ?";
1438
1473
1439
    my $sth = $dbh->prepare($query);
1474
    my $sth = $dbh->prepare($query);
Lines 1447-1452 sub ModSubscription { Link Here
1447
        $letter,          ($manualhistory ? $manualhistory : 0),
1482
        $letter,          ($manualhistory ? $manualhistory : 0),
1448
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1483
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1449
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1484
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1485
        $itemtype,        $previousitemtype,
1450
        $subscriptionid
1486
        $subscriptionid
1451
    );
1487
    );
1452
    my $rows = $sth->rows;
1488
    my $rows = $sth->rows;
Lines 1462-1468 $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu Link Here
1462
    $lastvalue1,$innerloop1,$lastvalue2,$innerloop2,$lastvalue3,$innerloop3,
1498
    $lastvalue1,$innerloop1,$lastvalue2,$innerloop2,$lastvalue3,$innerloop3,
1463
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1499
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1464
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1500
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1465
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq);
1501
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, 
1502
    $skip_serialseq, $itemtype, $previousitemtype);
1466
1503
1467
Create a new subscription with value given on input args.
1504
Create a new subscription with value given on input args.
1468
1505
Lines 1479-1485 sub NewSubscription { Link Here
1479
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1516
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1480
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1517
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1481
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1518
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1482
    $location, $enddate, $skip_serialseq
1519
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype
1483
    ) = @_;
1520
    ) = @_;
1484
    my $dbh = C4::Context->dbh;
1521
    my $dbh = C4::Context->dbh;
1485
1522
Lines 1492-1499 sub NewSubscription { Link Here
1492
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1529
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1493
            irregularity, numberpattern, locale, callnumber,
1530
            irregularity, numberpattern, locale, callnumber,
1494
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1531
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1495
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq)
1532
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq,
1496
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1533
            itemtype, previousitemtype)
1534
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1497
        |;
1535
        |;
1498
    my $sth = $dbh->prepare($query);
1536
    my $sth = $dbh->prepare($query);
1499
    $sth->execute(
1537
    $sth->execute(
Lines 1503-1509 sub NewSubscription { Link Here
1503
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1541
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1504
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1542
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1505
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1543
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1506
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq
1544
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
1545
        $itemtype, $previousitemtype
1507
    );
1546
    );
1508
1547
1509
    my $subscriptionid = $dbh->{'mysql_insertid'};
1548
    my $subscriptionid = $dbh->{'mysql_insertid'};
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 2086-2091 CREATE TABLE `subscription` ( Link Here
2086
  `enddate` date default NULL,
2086
  `enddate` date default NULL,
2087
  `closed` INT(1) NOT NULL DEFAULT 0,
2087
  `closed` INT(1) NOT NULL DEFAULT 0,
2088
  `reneweddate` date default NULL,
2088
  `reneweddate` date default NULL,
2089
  `itemtype` VARCHAR( 10 ) NULL,
2090
  `previousitemtype` VARCHAR( 10 ) NULL,
2089
  PRIMARY KEY  (`subscriptionid`),
2091
  PRIMARY KEY  (`subscriptionid`),
2090
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
2092
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
2091
  CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
2093
  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 173-178 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
173
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
173
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
174
('LinkerRelink','1',NULL,'If ON the authority linker will relink headings that have previously been linked every time it runs.','YesNo'),
174
('LinkerRelink','1',NULL,'If ON the authority linker will relink headings that have previously been linked every time it runs.','YesNo'),
175
('LocalCoverImages','0','1','Display local cover images on intranet details pages.','YesNo'),
175
('LocalCoverImages','0','1','Display local cover images on intranet details pages.','YesNo'),
176
('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'),
176
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
177
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
177
('MARCAuthorityControlField008','|| aca||aabn           | a|a     d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'),
178
('MARCAuthorityControlField008','|| aca||aabn           | a|a     d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'),
178
('MARCOrgCode','OSt','','Define MARC Organization Code for MARC21 records - http://www.loc.gov/marc/organizations/orgshome.html','free'),
179
('MARCOrgCode','OSt','','Define MARC Organization Code for MARC21 records - http://www.loc.gov/marc/organizations/orgshome.html','free'),
(-)a/installer/data/mysql/updatedatabase.pl (+19 lines)
Lines 8012-8017 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
8012
    SetVersion($DBversion);
8012
    SetVersion($DBversion);
8013
}
8013
}
8014
8014
8015
8016
8017
8018
8019
8020
$DBversion = "3.15.00.XXX";
8021
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8022
    $dbh->do(q{
8023
        ALTER TABLE `subscription` ADD `itemtype` VARCHAR( 10 ) NULL AFTER reneweddate,
8024
        ADD `previousitemtype` VARCHAR( 10 ) NULL AFTER itemtype
8025
    });
8026
    $dbh->do(
8027
        "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');"
8028
    );
8029
    print "Upgrade to $DBversion done (Bug 7677: Adds fields to subscription table and makePreviousSerialAvailable syspref)\n";
8030
    SetVersion($DBversion);
8031
}
8032
8033
8015
=head1 FUNCTIONS
8034
=head1 FUNCTIONS
8016
8035
8017
=head2 TableExists($table)
8036
=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 608-613 $(document).ready(function() { Link Here
608
                                    </select>
608
                                    </select>
609
                                </li>
609
                                </li>
610
                                <li>
610
                                <li>
611
                                    <label for="itemtype">Item type:</label>
612
                                    <select name="itemtype" id="itemtype">
613
                                        <option value=""></option>
614
                                        [% FOREACH type IN typeloop %]
615
                                            [% IF ( type.selected ) %]
616
                                                <option value="[% type.code %]" selected="selected">[% type.value %]</option>
617
                                            [% ELSE %]
618
                                                <option value="[% type.code %]">[% type.value %]</option>
619
                                            [% END %]
620
                                        [% END %]
621
                                    </select>
622
                                </li>
623
                                [%IF makePreviousSerialAvailable %]
624
                                <li>
625
                                    <label for="previousitemtype">Previous item type:</label>
626
                                    <select name="previousitemtype" id="previousitemtype">
627
                                            <option value=""></option>
628
                                        [% FOREACH previous IN previoustypeloop %]
629
                                            [% IF ( previous.selected ) %]
630
                                                <option value="[% previous.code %]" selected="selected">[% previous.value %]</option>
631
                                            [% ELSE %]
632
                                                <option value="[% previous.code %]">[% previous.value %]</option>
633
                                            [% END %]
634
                                        [% END %]
635
                                    </select>
636
                                </li>
637
                                [% END %]
638
                                    <li>
611
                                    <label for="graceperiod">Grace period:</label>
639
                                    <label for="graceperiod">Grace period:</label>
612
                                    <input type="text" name="graceperiod" id="graceperiod" value="[% graceperiod %]" size="5"/> day(s)
640
                                    <input type="text" name="graceperiod" id="graceperiod" value="[% graceperiod %]" size="5"/> day(s)
613
                                </li>
641
                                </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 150-156 my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'}); Link Here
150
$template->param(branchloop => $branchloop,
150
$template->param(branchloop => $branchloop,
151
    locations_loop=>$locations_loop,
151
    locations_loop=>$locations_loop,
152
);
152
);
153
154
my $typeloop = GetItemTypes();
155
156
my @typearg =
157
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{itemtype} and $_ eq $subs->{itemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
158
my @previoustypearg =
159
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{previousitemtype} and $_ eq $subs->{previousitemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
160
161
$template->param(
162
    branchloop               => $branchloop,
163
    typeloop                 => \@typearg,
164
    previoustypeloop         => \@previoustypearg,
165
    locations_loop=>$locations_loop,
166
);
153
# prepare template variables common to all $op conditions:
167
# prepare template variables common to all $op conditions:
168
$template->param('makePreviousSerialAvailable' => 1) if (C4::Context->preference('makePreviousSerialAvailable'));
169
154
if ($op!~/^mod/) {
170
if ($op!~/^mod/) {
155
    letter_loop(q{}, $template);
171
    letter_loop(q{}, $template);
156
}
172
}
Lines 313-318 sub redirect_add_subscription { Link Here
313
    my $staffdisplaycount = $query->param('staffdisplaycount');
329
    my $staffdisplaycount = $query->param('staffdisplaycount');
314
    my $opacdisplaycount  = $query->param('opacdisplaycount');
330
    my $opacdisplaycount  = $query->param('opacdisplaycount');
315
    my $location          = $query->param('location');
331
    my $location          = $query->param('location');
332
    my $itemtype          = $query->param('itemtype');
333
    my $previousitemtype  = $query->param('previousitemtype');
316
    my $skip_serialseq    = $query->param('skip_serialseq');
334
    my $skip_serialseq    = $query->param('skip_serialseq');
317
    my $startdate = format_date_in_iso( $query->param('startdate') );
335
    my $startdate = format_date_in_iso( $query->param('startdate') );
318
    my $enddate = format_date_in_iso( $query->param('enddate') );
336
    my $enddate = format_date_in_iso( $query->param('enddate') );
Lines 381-386 sub redirect_mod_subscription { Link Here
381
	my $opacdisplaycount = $query->param('opacdisplaycount');
399
	my $opacdisplaycount = $query->param('opacdisplaycount');
382
    my $graceperiod     = $query->param('graceperiod') || 0;
400
    my $graceperiod     = $query->param('graceperiod') || 0;
383
    my $location = $query->param('location');
401
    my $location = $query->param('location');
402
    my $itemtype          = $query->param('itemtype');
403
    my $previousitemtype  = $query->param('previousitemtype');
384
    my $skip_serialseq    = $query->param('skip_serialseq');
404
    my $skip_serialseq    = $query->param('skip_serialseq');
385
405
386
    # Guess end date
406
    # Guess end date
Lines 408-414 sub redirect_mod_subscription { Link Here
408
        $status, $biblionumber, $callnumber, $notes, $letter,
428
        $status, $biblionumber, $callnumber, $notes, $letter,
409
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
429
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
410
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
430
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
411
        $skip_serialseq
431
        $skip_serialseq, $itemtype, $previousitemtype
412
    );
432
    );
413
433
414
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
434
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
415
- 

Return to bug 7677