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 899-904 sub GetLatestSerials { Link Here
899
    return \@serials;
900
    return \@serials;
900
}
901
}
901
902
903
=head2 GetPreviousSerialid
904
905
$serialid = GetPreviousSerialid($subscriptionid, $nth)
906
get the $nth's previous serial for the given subscriptionid
907
return :
908
the serialid
909
910
=cut
911
912
sub GetPreviousSerialid {
913
    my ( $subscriptionid, $nth ) = @_;
914
    $nth ||= 1;
915
    my $dbh = C4::Context->dbh;
916
    my $return = undef;
917
918
    # Status 2: Arrived
919
    my $strsth = "SELECT   serialid
920
                        FROM     serial
921
                        WHERE    subscriptionid = ?
922
                        AND      status = 2
923
                        ORDER BY serialid DESC LIMIT $nth,1 
924
                ";
925
    my $sth = $dbh->prepare($strsth);
926
    $sth->execute($subscriptionid);
927
    my @serials;
928
    my $line = $sth->fetchrow_hashref;
929
    $return = $line->{'serialid'} if ($line);
930
931
    return $return;
932
}
933
934
935
902
=head2 GetDistributedTo
936
=head2 GetDistributedTo
903
937
904
$distributedto=GetDistributedTo($subscriptionid)
938
$distributedto=GetDistributedTo($subscriptionid)
Lines 1389-1395 sub ModSubscription { Link Here
1389
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1423
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1390
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1424
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1391
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1425
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1392
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq
1426
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1427
    $itemtype, $previousitemtype
1393
    ) = @_;
1428
    ) = @_;
1394
1429
1395
    my $dbh   = C4::Context->dbh;
1430
    my $dbh   = C4::Context->dbh;
Lines 1402-1408 sub ModSubscription { Link Here
1402
            callnumber=?, notes=?, letter=?, manualhistory=?,
1437
            callnumber=?, notes=?, letter=?, manualhistory=?,
1403
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1438
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1404
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1439
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1405
            skip_serialseq=?
1440
            skip_serialseq=?, itemtype=?, previousitemtype=?
1406
        WHERE subscriptionid = ?";
1441
        WHERE subscriptionid = ?";
1407
1442
1408
    my $sth = $dbh->prepare($query);
1443
    my $sth = $dbh->prepare($query);
Lines 1416-1421 sub ModSubscription { Link Here
1416
        $letter,          ($manualhistory ? $manualhistory : 0),
1451
        $letter,          ($manualhistory ? $manualhistory : 0),
1417
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1452
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1418
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1453
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1454
        $itemtype,        $previousitemtype,
1419
        $subscriptionid
1455
        $subscriptionid
1420
    );
1456
    );
1421
    my $rows = $sth->rows;
1457
    my $rows = $sth->rows;
Lines 1431-1437 $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu Link Here
1431
    $lastvalue1,$innerloop1,$lastvalue2,$innerloop2,$lastvalue3,$innerloop3,
1467
    $lastvalue1,$innerloop1,$lastvalue2,$innerloop2,$lastvalue3,$innerloop3,
1432
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1468
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1433
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1469
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1434
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq);
1470
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, 
1471
    $skip_serialseq, $itemtype, $previousitemtype);
1435
1472
1436
Create a new subscription with value given on input args.
1473
Create a new subscription with value given on input args.
1437
1474
Lines 1448-1454 sub NewSubscription { Link Here
1448
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1485
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1449
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1486
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1450
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1487
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1451
    $location, $enddate, $skip_serialseq
1488
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype
1452
    ) = @_;
1489
    ) = @_;
1453
    my $dbh = C4::Context->dbh;
1490
    my $dbh = C4::Context->dbh;
1454
1491
Lines 1461-1468 sub NewSubscription { Link Here
1461
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1498
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1462
            irregularity, numberpattern, locale, callnumber,
1499
            irregularity, numberpattern, locale, callnumber,
1463
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1500
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1464
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq)
1501
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq,
1465
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1502
            itemtype, previousitemtype)
1503
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1466
        |;
1504
        |;
1467
    my $sth = $dbh->prepare($query);
1505
    my $sth = $dbh->prepare($query);
1468
    $sth->execute(
1506
    $sth->execute(
Lines 1472-1478 sub NewSubscription { Link Here
1472
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1510
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1473
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1511
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1474
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1512
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1475
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq
1513
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
1514
        $itemtype, $previousitemtype
1476
    );
1515
    );
1477
1516
1478
    my $subscriptionid = $dbh->{'mysql_insertid'};
1517
    my $subscriptionid = $dbh->{'mysql_insertid'};
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 2131-2136 CREATE TABLE `subscription` ( Link Here
2131
  `enddate` date default NULL,
2131
  `enddate` date default NULL,
2132
  `closed` INT(1) NOT NULL DEFAULT 0,
2132
  `closed` INT(1) NOT NULL DEFAULT 0,
2133
  `reneweddate` date default NULL,
2133
  `reneweddate` date default NULL,
2134
  `itemtype` VARCHAR( 10 ) NULL,
2135
  `previousitemtype` VARCHAR( 10 ) NULL,
2134
  PRIMARY KEY  (`subscriptionid`),
2136
  PRIMARY KEY  (`subscriptionid`),
2135
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
2137
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
2136
  CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
2138
  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 193-198 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
193
('LocalHoldsPriority',  '0', NULL,  'Enables the LocalHoldsPriority feature',  'YesNo'),
193
('LocalHoldsPriority',  '0', NULL,  'Enables the LocalHoldsPriority feature',  'YesNo'),
194
('LocalHoldsPriorityItemControl',  'holdingbranch',  'holdingbranch|homebranch',  'decides if the feature operates using the item''s home or holding library.',  'Choice'),
194
('LocalHoldsPriorityItemControl',  'holdingbranch',  'holdingbranch|homebranch',  'decides if the feature operates using the item''s home or holding library.',  'Choice'),
195
('LocalHoldsPriorityPatronControl',  'PickupLibrary',  'HomeLibrary|PickupLibrary',  'decides if the feature operates using the library set as the patron''s home library, or the library set as the pickup library for the given hold.',  'Choice'),
195
('LocalHoldsPriorityPatronControl',  'PickupLibrary',  'HomeLibrary|PickupLibrary',  'decides if the feature operates using the library set as the patron''s home library, or the library set as the pickup library for the given hold.',  'Choice'),
196
('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'),
196
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
197
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
197
('MARCAuthorityControlField008','|| aca||aabn           | a|a     d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'),
198
('MARCAuthorityControlField008','|| aca||aabn           | a|a     d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'),
198
('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'),
199
('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 (+17 lines)
Lines 9585-9590 if ( CheckVersion($DBversion) ) { Link Here
9585
    SetVersion ($DBversion);
9585
    SetVersion ($DBversion);
9586
}
9586
}
9587
9587
9588
9589
9590
9591
$DBversion = "3.19.00.XXX";
9592
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
9593
    $dbh->do(q{
9594
        ALTER TABLE `subscription` ADD `itemtype` VARCHAR( 10 ) NULL AFTER reneweddate,
9595
        ADD `previousitemtype` VARCHAR( 10 ) NULL AFTER itemtype
9596
    });
9597
    $dbh->do(
9598
        "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');"
9599
    );
9600
    print "Upgrade to $DBversion done (Bug 7677: Adds fields to subscription table and makePreviousSerialAvailable syspref)\n";
9601
    SetVersion($DBversion);
9602
}
9603
9604
9588
=head1 FUNCTIONS
9605
=head1 FUNCTIONS
9589
9606
9590
=head2 TableExists($table)
9607
=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 59-65 function unHideItems(index,labelindex, serialId) { Link Here
59
    subfield_div = $(item_div).find("input[name='kohafield'][value='items.enumchron']").parent();
59
    subfield_div = $(item_div).find("input[name='kohafield'][value='items.enumchron']").parent();
60
    // Setting text field
60
    // Setting text field
61
    $(subfield_div).children("input[type='text'][name='field_value']").val($("#serialseq" + serialId).val());
61
    $(subfield_div).children("input[type='text'][name='field_value']").val($("#serialseq" + serialId).val());
62
63
}
62
}
64
function HideItems(index,labelindex) {
63
function HideItems(index,labelindex) {
65
	subfield = document.getElementById(index);
64
	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