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 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 1415-1421 sub ModSubscription { Link Here
1415
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1449
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1416
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1450
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1417
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1451
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1418
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq
1452
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1453
    $itemtype, $previousitemtype
1419
    ) = @_;
1454
    ) = @_;
1420
1455
1421
    my $dbh   = C4::Context->dbh;
1456
    my $dbh   = C4::Context->dbh;
Lines 1428-1434 sub ModSubscription { Link Here
1428
            callnumber=?, notes=?, letter=?, manualhistory=?,
1463
            callnumber=?, notes=?, letter=?, manualhistory=?,
1429
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1464
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1430
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1465
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1431
            skip_serialseq=?
1466
            skip_serialseq=?, itemtype=?, previousitemtype=?
1432
        WHERE subscriptionid = ?";
1467
        WHERE subscriptionid = ?";
1433
1468
1434
    my $sth = $dbh->prepare($query);
1469
    my $sth = $dbh->prepare($query);
Lines 1442-1447 sub ModSubscription { Link Here
1442
        $letter,          ($manualhistory ? $manualhistory : 0),
1477
        $letter,          ($manualhistory ? $manualhistory : 0),
1443
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1478
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1444
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1479
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1480
        $itemtype,        $previousitemtype,
1445
        $subscriptionid
1481
        $subscriptionid
1446
    );
1482
    );
1447
    my $rows = $sth->rows;
1483
    my $rows = $sth->rows;
Lines 1457-1463 $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu Link Here
1457
    $lastvalue1,$innerloop1,$lastvalue2,$innerloop2,$lastvalue3,$innerloop3,
1493
    $lastvalue1,$innerloop1,$lastvalue2,$innerloop2,$lastvalue3,$innerloop3,
1458
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1494
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1459
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1495
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1460
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq);
1496
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, 
1497
    $skip_serialseq, $itemtype, $previousitemtype);
1461
1498
1462
Create a new subscription with value given on input args.
1499
Create a new subscription with value given on input args.
1463
1500
Lines 1474-1480 sub NewSubscription { Link Here
1474
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1511
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1475
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1512
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1476
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1513
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1477
    $location, $enddate, $skip_serialseq
1514
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype
1478
    ) = @_;
1515
    ) = @_;
1479
    my $dbh = C4::Context->dbh;
1516
    my $dbh = C4::Context->dbh;
1480
1517
Lines 1487-1494 sub NewSubscription { Link Here
1487
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1524
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1488
            irregularity, numberpattern, locale, callnumber,
1525
            irregularity, numberpattern, locale, callnumber,
1489
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1526
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1490
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq)
1527
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq,
1491
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1528
            itemtype, previousitemtype)
1529
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1492
        |;
1530
        |;
1493
    my $sth = $dbh->prepare($query);
1531
    my $sth = $dbh->prepare($query);
1494
    $sth->execute(
1532
    $sth->execute(
Lines 1498-1504 sub NewSubscription { Link Here
1498
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1536
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1499
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1537
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1500
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1538
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1501
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq
1539
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
1540
        $itemtype, $previousitemtype
1502
    );
1541
    );
1503
1542
1504
    my $subscriptionid = $dbh->{'mysql_insertid'};
1543
    my $subscriptionid = $dbh->{'mysql_insertid'};
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 2097-2102 CREATE TABLE `subscription` ( Link Here
2097
  `enddate` date default NULL,
2097
  `enddate` date default NULL,
2098
  `closed` INT(1) NOT NULL DEFAULT 0,
2098
  `closed` INT(1) NOT NULL DEFAULT 0,
2099
  `reneweddate` date default NULL,
2099
  `reneweddate` date default NULL,
2100
  `itemtype` VARCHAR( 10 ) NULL,
2101
  `previousitemtype` VARCHAR( 10 ) NULL,
2100
  PRIMARY KEY  (`subscriptionid`),
2102
  PRIMARY KEY  (`subscriptionid`),
2101
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
2103
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
2102
  CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (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
(-)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,NULL,'Textarea'),
178
('MARCAuthorityControlField008','|| aca||aabn           | a|a     d',NULL,NULL,'Textarea'),
178
('MARCOrgCode','OSt','','Define MARC Organization Code - http://www.loc.gov/marc/organizations/orgshome.html','free'),
179
('MARCOrgCode','OSt','','Define MARC Organization Code - http://www.loc.gov/marc/organizations/orgshome.html','free'),
(-)a/installer/data/mysql/updatedatabase.pl (+20 lines)
Lines 7912-7917 if ( CheckVersion($DBversion) ) { Link Here
7912
    SetVersion($DBversion);
7912
    SetVersion($DBversion);
7913
}
7913
}
7914
7914
7915
7916
7917
7918
7919
7920
7921
$DBversion = "3.13.00.XXX";
7922
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7923
    $dbh->do(q{
7924
        ALTER TABLE `subscription` ADD `itemtype` VARCHAR( 10 ) NULL AFTER reneweddate,
7925
        ADD `previousitemtype` VARCHAR( 10 ) NULL AFTER itemtype
7926
    });
7927
    $dbh->do(
7928
        "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');"
7929
    );
7930
    print "Upgrade to $DBversion done (Bug 7677: Adds fields to subscription table and makePreviousSerialAvailable syspref)\n";
7931
    SetVersion($DBversion);
7932
}
7933
7934
7915
=head1 FUNCTIONS
7935
=head1 FUNCTIONS
7916
7936
7917
=head2 TableExists($table)
7937
=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