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  &GetLateOrMissingIssues
51
      &ReNewSubscription  &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 841-846 sub GetLatestSerials { Link Here
841
    return \@serials;
842
    return \@serials;
842
}
843
}
843
844
845
=head2 GetPreviousSerialid
846
847
$serialid = GetPreviousSerialid($subscriptionid, $nth)
848
get the $nth's previous serial for the given subscriptionid
849
return :
850
the serialid
851
852
=cut
853
854
sub GetPreviousSerialid {
855
    my ( $subscriptionid, $nth ) = @_;
856
    $nth ||= 1;
857
    my $dbh = C4::Context->dbh;
858
    my $return = undef;
859
860
    # Status 2: Arrived
861
    my $strsth = "SELECT   serialid
862
                        FROM     serial
863
                        WHERE    subscriptionid = ?
864
                        AND      status = 2
865
                        ORDER BY serialid DESC LIMIT $nth,1
866
                ";
867
    my $sth = $dbh->prepare($strsth);
868
    $sth->execute($subscriptionid);
869
    my @serials;
870
    my $line = $sth->fetchrow_hashref;
871
    $return = $line->{'serialid'} if ($line);
872
873
    return $return;
874
}
875
876
877
844
=head2 GetDistributedTo
878
=head2 GetDistributedTo
845
879
846
$distributedto=GetDistributedTo($subscriptionid)
880
$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/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 (+16 lines)
Lines 9793-9798 if(CheckVersion($DBversion)) { Link Here
9793
    SetVersion($DBversion);
9793
    SetVersion($DBversion);
9794
}
9794
}
9795
9795
9796
9797
9798
$DBversion = "3.19.00.XXX";
9799
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
9800
    $dbh->do(q{
9801
        ALTER TABLE `subscription` ADD `itemtype` VARCHAR( 10 ) NULL AFTER reneweddate,
9802
        ADD `previousitemtype` VARCHAR( 10 ) NULL AFTER itemtype
9803
    });
9804
    $dbh->do(
9805
        "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');"
9806
    );
9807
    print "Upgrade to $DBversion done (Bug 7677: Adds fields to subscription table and makePreviousSerialAvailable syspref)\n";
9808
    SetVersion($DBversion);
9809
}
9810
9811
9796
=head1 FUNCTIONS
9812
=head1 FUNCTIONS
9797
9813
9798
=head2 TableExists($table)
9814
=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 91-96 if ( scalar(@subscriptionids) == 1 && index( $subscriptionids[0], q|,| ) > 0 ) { Link Here
91
}
91
}
92
my @errors;
92
my @errors;
93
my @errseq;
93
my @errseq;
94
my $dbh   = C4::Context->dbh;
94
95
95
# If user comes from subscription details
96
# If user comes from subscription details
96
unless (@serialids) {
97
unless (@serialids) {
Lines 243-248 if ( $op and $op eq 'serialchangestatus' ) { Link Here
243
                $notes[$i]
244
                $notes[$i]
244
            );
245
            );
245
        }
246
        }
247
        my $makePreviousSerialAvailable = C4::Context->preference('makePreviousSerialAvailable');
248
        if ($makePreviousSerialAvailable && $serialids[$i] ne "NEW") {
249
            # We already have created the new expected serial at this point, so we get the second previous serial
250
            my $previous = GetPreviousSerialid($subscriptionids[$i]);
251
            if ($previous) {
252
253
                # Getting the itemnumber matching the serialid
254
                my $query = "SELECT itemnumber FROM serialitems WHERE serialid=?";
255
                my $sth = $dbh->prepare($query);
256
                $sth->execute($previous);
257
                my @row = $sth->fetchrow_array;
258
                if ($row[0]) {
259
                    my $itemnumber = $row[0];
260
261
                    # Getting the itemtype to set from the database
262
                    my $subscriptioninfos = GetSubscription($subscriptionids[$i]);
263
264
                    # Changing the status to "available" and the itemtype according to the previousitemtype db field
265
                    ModItem({notforloan => 0, itype => $subscriptioninfos->{'previousitemtype'} }, undef, $itemnumber);
266
                }
267
            }
268
        }
269
246
    }
270
    }
247
    my @moditems = $query->param('moditem');
271
    my @moditems = $query->param('moditem');
248
    if ( scalar(@moditems) ) {
272
    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