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

(-)a/C4/Serials.pm (-7 / +46 lines)
Lines 74-79 BEGIN { Link Here
74
      &ReNewSubscription  &GetLateOrMissingIssues
74
      &ReNewSubscription  &GetLateOrMissingIssues
75
      &GetSerialInformation                   &AddItem2Serial
75
      &GetSerialInformation                   &AddItem2Serial
76
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
76
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
77
      &GetPreviousSerialid
77
78
78
      &UpdateClaimdateIssues
79
      &UpdateClaimdateIssues
79
      &GetSuppliersWithLateIssues             &getsupplierbyserialid
80
      &GetSuppliersWithLateIssues             &getsupplierbyserialid
Lines 832-837 sub GetLatestSerials { Link Here
832
    return \@serials;
833
    return \@serials;
833
}
834
}
834
835
836
=head2 GetPreviousSerialid
837
838
$serialid = GetPreviousSerialid($subscriptionid, $nth)
839
get the $nth's previous serial for the given subscriptionid
840
return :
841
the serialid
842
843
=cut
844
845
sub GetPreviousSerialid {
846
    my ( $subscriptionid, $nth ) = @_;
847
    $nth ||= 1;
848
    my $dbh = C4::Context->dbh;
849
    my $return = undef;
850
851
    # Status 2: Arrived
852
    my $strsth = "SELECT   serialid
853
                        FROM     serial
854
                        WHERE    subscriptionid = ?
855
                        AND      status = 2
856
                        ORDER BY serialid DESC LIMIT $nth,1
857
                ";
858
    my $sth = $dbh->prepare($strsth);
859
    $sth->execute($subscriptionid);
860
    my @serials;
861
    my $line = $sth->fetchrow_hashref;
862
    $return = $line->{'serialid'} if ($line);
863
864
    return $return;
865
}
866
867
868
835
=head2 GetDistributedTo
869
=head2 GetDistributedTo
836
870
837
$distributedto=GetDistributedTo($subscriptionid)
871
$distributedto=GetDistributedTo($subscriptionid)
Lines 1331-1337 sub ModSubscription { Link Here
1331
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1365
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1332
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1366
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1333
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1367
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1334
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq
1368
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1369
    $itemtype, $previousitemtype
1335
    ) = @_;
1370
    ) = @_;
1336
1371
1337
    my $dbh   = C4::Context->dbh;
1372
    my $dbh   = C4::Context->dbh;
Lines 1344-1350 sub ModSubscription { Link Here
1344
            callnumber=?, notes=?, letter=?, manualhistory=?,
1379
            callnumber=?, notes=?, letter=?, manualhistory=?,
1345
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1380
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1346
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1381
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1347
            skip_serialseq=?
1382
            skip_serialseq=?, itemtype=?, previousitemtype=?
1348
        WHERE subscriptionid = ?";
1383
        WHERE subscriptionid = ?";
1349
1384
1350
    my $sth = $dbh->prepare($query);
1385
    my $sth = $dbh->prepare($query);
Lines 1358-1363 sub ModSubscription { Link Here
1358
        $letter,          ($manualhistory ? $manualhistory : 0),
1393
        $letter,          ($manualhistory ? $manualhistory : 0),
1359
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1394
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1360
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1395
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1396
        $itemtype,        $previousitemtype,
1361
        $subscriptionid
1397
        $subscriptionid
1362
    );
1398
    );
1363
    my $rows = $sth->rows;
1399
    my $rows = $sth->rows;
Lines 1373-1379 $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu Link Here
1373
    $lastvalue1,$innerloop1,$lastvalue2,$innerloop2,$lastvalue3,$innerloop3,
1409
    $lastvalue1,$innerloop1,$lastvalue2,$innerloop2,$lastvalue3,$innerloop3,
1374
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1410
    $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern,
1375
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1411
    $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems,
1376
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq);
1412
    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
1413
    $skip_serialseq, $itemtype, $previousitemtype);
1377
1414
1378
Create a new subscription with value given on input args.
1415
Create a new subscription with value given on input args.
1379
1416
Lines 1390-1396 sub NewSubscription { Link Here
1390
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1427
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1391
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1428
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1392
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1429
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1393
    $location, $enddate, $skip_serialseq
1430
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype
1394
    ) = @_;
1431
    ) = @_;
1395
    my $dbh = C4::Context->dbh;
1432
    my $dbh = C4::Context->dbh;
1396
1433
Lines 1403-1410 sub NewSubscription { Link Here
1403
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1440
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1404
            irregularity, numberpattern, locale, callnumber,
1441
            irregularity, numberpattern, locale, callnumber,
1405
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1442
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1406
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq)
1443
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq,
1407
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1444
            itemtype, previousitemtype)
1445
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1408
        |;
1446
        |;
1409
    my $sth = $dbh->prepare($query);
1447
    my $sth = $dbh->prepare($query);
1410
    $sth->execute(
1448
    $sth->execute(
Lines 1414-1420 sub NewSubscription { Link Here
1414
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1452
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1415
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1453
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1416
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1454
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1417
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq
1455
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
1456
        $itemtype, $previousitemtype
1418
    );
1457
    );
1419
1458
1420
    my $subscriptionid = $dbh->{'mysql_insertid'};
1459
    my $subscriptionid = $dbh->{'mysql_insertid'};
(-)a/installer/data/mysql/atomicupdate/bug_7677_Adds_fields_to_subscription_table_and_makePreviousSerialAvailable_syspref.sql (+2 lines)
Line 0 Link Here
1
ALTER TABLE `subscription` ADD `itemtype` VARCHAR( 10 ) NULL AFTER reneweddate, ADD `previousitemtype` VARCHAR( 10 ) NULL AFTER itemtype;
2
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');
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 2108-2113 CREATE TABLE `subscription` ( -- information related to the subscription Link Here
2108
  `enddate` date default NULL, -- subscription end date
2108
  `enddate` date default NULL, -- subscription end date
2109
  `closed` INT(1) NOT NULL DEFAULT 0, -- yes / no if the subscription is closed
2109
  `closed` INT(1) NOT NULL DEFAULT 0, -- yes / no if the subscription is closed
2110
  `reneweddate` date default NULL, -- date of last renewal for the subscription
2110
  `reneweddate` date default NULL, -- date of last renewal for the subscription
2111
  `itemtype` VARCHAR( 10 ) NULL,
2112
  `previousitemtype` VARCHAR( 10 ) NULL,
2111
  PRIMARY KEY  (`subscriptionid`),
2113
  PRIMARY KEY  (`subscriptionid`),
2112
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
2114
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
2113
  CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
2115
  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 207-212 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
207
('LocalHoldsPriority',  '0', NULL,  'Enables the LocalHoldsPriority feature',  'YesNo'),
207
('LocalHoldsPriority',  '0', NULL,  'Enables the LocalHoldsPriority feature',  'YesNo'),
208
('LocalHoldsPriorityItemControl',  'holdingbranch',  'holdingbranch|homebranch',  'decides if the feature operates using the item''s home or holding library.',  'Choice'),
208
('LocalHoldsPriorityItemControl',  'holdingbranch',  'holdingbranch|homebranch',  'decides if the feature operates using the item''s home or holding library.',  'Choice'),
209
('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'),
209
('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'),
210
('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'),
210
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
211
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
211
('MARCAuthorityControlField008','|| aca||aabn           | a|a     d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'),
212
('MARCAuthorityControlField008','|| aca||aabn           | a|a     d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'),
212
('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'),
213
('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/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 29-35 function unHideItems(index,labelindex, serialId) { Link Here
29
    subfield_div = $(item_div).find("input[name='kohafield'][value='items.enumchron']").parent();
29
    subfield_div = $(item_div).find("input[name='kohafield'][value='items.enumchron']").parent();
30
    // Setting text field
30
    // Setting text field
31
    $(subfield_div).children("input[type='text'][name='field_value']").val($("#serialseq" + serialId).val());
31
    $(subfield_div).children("input[type='text'][name='field_value']").val($("#serialseq" + serialId).val());
32
33
}
32
}
34
function HideItems(index,labelindex) {
33
function HideItems(index,labelindex) {
35
	subfield = document.getElementById(index);
34
	subfield = document.getElementById(index);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (+28 lines)
Lines 606-611 $(document).ready(function() { Link Here
606
                                    </select>
606
                                    </select>
607
                                </li>
607
                                </li>
608
                                <li>
608
                                <li>
609
                                    <label for="itemtype">Item type:</label>
610
                                    <select name="itemtype" id="itemtype">
611
                                        <option value=""></option>
612
                                        [% FOREACH type IN typeloop %]
613
                                            [% IF ( type.selected ) %]
614
                                                <option value="[% type.code %]" selected="selected">[% type.value %]</option>
615
                                            [% ELSE %]
616
                                                <option value="[% type.code %]">[% type.value %]</option>
617
                                            [% END %]
618
                                        [% END %]
619
                                    </select>
620
                                </li>
621
                                [%IF makePreviousSerialAvailable %]
622
                                <li>
623
                                    <label for="previousitemtype">Previous item type:</label>
624
                                    <select name="previousitemtype" id="previousitemtype">
625
                                            <option value=""></option>
626
                                        [% FOREACH previous IN previoustypeloop %]
627
                                            [% IF ( previous.selected ) %]
628
                                                <option value="[% previous.code %]" selected="selected">[% previous.value %]</option>
629
                                            [% ELSE %]
630
                                                <option value="[% previous.code %]">[% previous.value %]</option>
631
                                            [% END %]
632
                                        [% END %]
633
                                    </select>
634
                                </li>
635
                                [% END %]
636
                                    <li>
609
                                    <label for="graceperiod">Grace period:</label>
637
                                    <label for="graceperiod">Grace period:</label>
610
                                    <input type="text" name="graceperiod" id="graceperiod" value="[% graceperiod %]" size="5"/> day(s)
638
                                    <input type="text" name="graceperiod" id="graceperiod" value="[% graceperiod %]" size="5"/> day(s)
611
                                </li>
639
                                </li>
(-)a/serials/serials-edit.pl (+24 lines)
Lines 93-98 if ( scalar(@subscriptionids) == 1 && index( $subscriptionids[0], q|,| ) > 0 ) { Link Here
93
}
93
}
94
my @errors;
94
my @errors;
95
my @errseq;
95
my @errseq;
96
my $dbh   = C4::Context->dbh;
96
97
97
# If user comes from subscription details
98
# If user comes from subscription details
98
unless (@serialids) {
99
unless (@serialids) {
Lines 250-255 if ( $op and $op eq 'serialchangestatus' ) { Link Here
250
                $notes[$i]
251
                $notes[$i]
251
            );
252
            );
252
        }
253
        }
254
        my $makePreviousSerialAvailable = C4::Context->preference('makePreviousSerialAvailable');
255
        if ($makePreviousSerialAvailable && $serialids[$i] ne "NEW") {
256
            # We already have created the new expected serial at this point, so we get the second previous serial
257
            my $previous = GetPreviousSerialid($subscriptionids[$i]);
258
            if ($previous) {
259
260
                # Getting the itemnumber matching the serialid
261
                my $query = "SELECT itemnumber FROM serialitems WHERE serialid=?";
262
                my $sth = $dbh->prepare($query);
263
                $sth->execute($previous);
264
                my @row = $sth->fetchrow_array;
265
                if ($row[0]) {
266
                    my $itemnumber = $row[0];
267
268
                    # Getting the itemtype to set from the database
269
                    my $subscriptioninfos = GetSubscription($subscriptionids[$i]);
270
271
                    # Changing the status to "available" and the itemtype according to the previousitemtype db field
272
                    ModItem({notforloan => 0, itype => $subscriptioninfos->{'previousitemtype'} }, undef, $itemnumber);
273
                }
274
            }
275
        }
276
253
    }
277
    }
254
    my @moditems = $query->param('moditem');
278
    my @moditems = $query->param('moditem');
255
    if ( scalar(@moditems) ) {
279
    if ( scalar(@moditems) ) {
(-)a/serials/subscription-add.pl (-2 / +21 lines)
Lines 162-168 for my $field ( @$additional_fields ) { Link Here
162
}
162
}
163
$template->param( additional_fields_for_subscription => $additional_fields );
163
$template->param( additional_fields_for_subscription => $additional_fields );
164
164
165
my $typeloop = GetItemTypes();
166
167
my @typearg =
168
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{itemtype} and $_ eq $subs->{itemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
169
my @previoustypearg =
170
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{previousitemtype} and $_ eq $subs->{previousitemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
171
172
$template->param(
173
    branchloop               => $branchloop,
174
    typeloop                 => \@typearg,
175
    previoustypeloop         => \@previoustypearg,
176
    locations_loop=>$locations_loop,
177
);
178
165
# prepare template variables common to all $op conditions:
179
# prepare template variables common to all $op conditions:
180
$template->param('makePreviousSerialAvailable' => 1) if (C4::Context->preference('makePreviousSerialAvailable'));
181
166
if ($op!~/^mod/) {
182
if ($op!~/^mod/) {
167
    my $letters = get_letter_loop();
183
    my $letters = get_letter_loop();
168
    $template->param( letterloop => $letters );
184
    $template->param( letterloop => $letters );
Lines 321-326 sub redirect_add_subscription { Link Here
321
    my $staffdisplaycount = $query->param('staffdisplaycount');
337
    my $staffdisplaycount = $query->param('staffdisplaycount');
322
    my $opacdisplaycount  = $query->param('opacdisplaycount');
338
    my $opacdisplaycount  = $query->param('opacdisplaycount');
323
    my $location          = $query->param('location');
339
    my $location          = $query->param('location');
340
    my $itemtype          = $query->param('itemtype');
341
    my $previousitemtype  = $query->param('previousitemtype');
324
    my $skip_serialseq    = $query->param('skip_serialseq');
342
    my $skip_serialseq    = $query->param('skip_serialseq');
325
343
326
    my $startdate      = output_pref( { str => $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
344
    my $startdate      = output_pref( { str => $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
Lines 398-403 sub redirect_mod_subscription { Link Here
398
	my $opacdisplaycount = $query->param('opacdisplaycount');
416
	my $opacdisplaycount = $query->param('opacdisplaycount');
399
    my $graceperiod     = $query->param('graceperiod') || 0;
417
    my $graceperiod     = $query->param('graceperiod') || 0;
400
    my $location = $query->param('location');
418
    my $location = $query->param('location');
419
    my $itemtype          = $query->param('itemtype');
420
    my $previousitemtype  = $query->param('previousitemtype');
401
    my $skip_serialseq    = $query->param('skip_serialseq');
421
    my $skip_serialseq    = $query->param('skip_serialseq');
402
422
403
    # Guess end date
423
    # Guess end date
Lines 425-431 sub redirect_mod_subscription { Link Here
425
        $status, $biblionumber, $callnumber, $notes, $letter,
445
        $status, $biblionumber, $callnumber, $notes, $letter,
426
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
446
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
427
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
447
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
428
        $skip_serialseq
448
        $skip_serialseq, $itemtype, $previousitemtype
429
    );
449
    );
430
450
431
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
451
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
432
- 

Return to bug 7677