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

(-)a/C4/Biblio.pm (-1 lines)
Lines 2723-2729 sub TransformMarcToKohaOneField { Link Here
2723
    return $result;
2723
    return $result;
2724
}
2724
}
2725
2725
2726
2727
#"
2726
#"
2728
2727
2729
#
2728
#
(-)a/C4/Items.pm (+9 lines)
Lines 2718-2723 sub PrepareItemrecordDisplay { Link Here
2718
                        while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
2718
                        while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
2719
                            push @authorised_values, $itemtype;
2719
                            push @authorised_values, $itemtype;
2720
                            $authorised_lib{$itemtype} = $description;
2720
                            $authorised_lib{$itemtype} = $description;
2721
2722
                            # If we have default value named itemtype or itemtypes, we use it
2723
                            $defaultvalue = $itemtype if ($defaultvalues and ($defaultvalues->{'itemtypes'} eq $itemtype or $defaultvalues->{'itemtype'} eq $itemtype));
2721
                        }
2724
                        }
2722
                        #---- class_sources
2725
                        #---- class_sources
2723
                    } elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "cn_source" ) {
2726
                    } elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "cn_source" ) {
Lines 2744-2749 sub PrepareItemrecordDisplay { Link Here
2744
                        while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
2747
                        while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
2745
                            push @authorised_values, $value;
2748
                            push @authorised_values, $value;
2746
                            $authorised_lib{$value} = $lib;
2749
                            $authorised_lib{$value} = $lib;
2750
2751
                            # If we have a default value that has the same name as the authorised value category of the field,
2752
                            # we use it
2753
                            $defaultvalue = $value if ($defaultvalues and $defaultvalues->{$tagslib->{$tag}->{$subfield}->{authorised_value}} and $defaultvalues->{$tagslib->{$tag}->{$subfield}->{authorised_value}} eq $value);
2754
2755
2747
                        }
2756
                        }
2748
                    }
2757
                    }
2749
                    $subfield_data{marc_value} = CGI::scrolling_list(
2758
                    $subfield_data{marc_value} = CGI::scrolling_list(
(-)a/C4/Serials.pm (-8 / +46 lines)
Lines 45-50 BEGIN { Link Here
45
      &ReNewSubscription  &GetLateIssues      &GetLateOrMissingIssues
45
      &ReNewSubscription  &GetLateIssues      &GetLateOrMissingIssues
46
      &GetSerialInformation                   &AddItem2Serial
46
      &GetSerialInformation                   &AddItem2Serial
47
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
47
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
48
      &GetPreviousSerialid
48
49
49
      &UpdateClaimdateIssues
50
      &UpdateClaimdateIssues
50
      &GetSuppliersWithLateIssues             &getsupplierbyserialid
51
      &GetSuppliersWithLateIssues             &getsupplierbyserialid
Lines 858-863 sub GetLatestSerials { Link Here
858
    return \@serials;
859
    return \@serials;
859
}
860
}
860
861
862
=head2 GetPreviousSerialid
863
864
$serialid = GetPreviousSerialid($subscriptionid, $nth)
865
get the $nth's previous serial for the given subscriptionid
866
return :
867
the serialid
868
869
=cut
870
871
sub GetPreviousSerialid {
872
    my ( $subscriptionid, $nth ) = @_;
873
    $nth ||= 1;
874
    my $dbh = C4::Context->dbh;
875
    my $return = undef;
876
877
    # Status 2: Arrived
878
    my $strsth = "SELECT   serialid
879
                        FROM     serial
880
                        WHERE    subscriptionid = ?
881
                        AND      status = 2
882
                        ORDER BY serialid DESC LIMIT $nth,1 
883
                ";
884
    my $sth = $dbh->prepare($strsth);
885
    $sth->execute($subscriptionid);
886
    my @serials;
887
    my $line = $sth->fetchrow_hashref;
888
    $return = $line->{'serialid'} if ($line);
889
890
    return $return;
891
}
892
893
894
861
=head2 GetDistributedTo
895
=head2 GetDistributedTo
862
896
863
$distributedto=GetDistributedTo($subscriptionid)
897
$distributedto=GetDistributedTo($subscriptionid)
Lines 1259-1265 sub ModSubscription { Link Here
1259
        $whenmorethan1,   $setto1,          $lastvalue1,        $innerloop1,       $add2,          $every2,      $whenmorethan2, $setto2,
1293
        $whenmorethan1,   $setto1,          $lastvalue1,        $innerloop1,       $add2,          $every2,      $whenmorethan2, $setto2,
1260
        $lastvalue2,      $innerloop2,      $add3,              $every3,           $whenmorethan3, $setto3,      $lastvalue3,    $innerloop3,
1294
        $lastvalue2,      $innerloop2,      $add3,              $every3,           $whenmorethan3, $setto3,      $lastvalue3,    $innerloop3,
1261
        $numberingmethod, $status,          $biblionumber,      $callnumber,       $notes,         $letter,      $hemisphere,    $manualhistory,
1295
        $numberingmethod, $status,          $biblionumber,      $callnumber,       $notes,         $letter,      $hemisphere,    $manualhistory,
1262
        $internalnotes,   $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,   $location,    $enddate,       $subscriptionid
1296
        $internalnotes,   $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,   $location,    $enddate,       $itemtype,
1297
	$ccode,           $origin,          $domain,            $previousitemtype, $subscriptionid
1263
    ) = @_;
1298
    ) = @_;
1264
1299
1265
    #     warn $irregularity;
1300
    #     warn $irregularity;
Lines 1273-1279 sub ModSubscription { Link Here
1273
                        numberingmethod=?, status=?, biblionumber=?, callnumber=?, notes=?, 
1308
                        numberingmethod=?, status=?, biblionumber=?, callnumber=?, notes=?, 
1274
						letter=?, hemisphere=?,manualhistory=?,internalnotes=?,serialsadditems=?,
1309
						letter=?, hemisphere=?,manualhistory=?,internalnotes=?,serialsadditems=?,
1275
						staffdisplaycount = ?,opacdisplaycount = ?, graceperiod = ?, location = ?
1310
						staffdisplaycount = ?,opacdisplaycount = ?, graceperiod = ?, location = ?
1276
						,enddate=?
1311
						,enddate=?, itemtype=?, ccode=?, origin=?, domain=?, previousitemtype = ?
1277
                    WHERE subscriptionid = ?";
1312
                    WHERE subscriptionid = ?";
1278
1313
1279
    #warn "query :".$query;
1314
    #warn "query :".$query;
Lines 1290-1299 sub ModSubscription { Link Here
1290
        $numberingmethod, $status,         $biblionumber,   $callnumber,
1325
        $numberingmethod, $status,         $biblionumber,   $callnumber,
1291
        $notes, $letter, $hemisphere, ( $manualhistory ? $manualhistory : 0 ),
1326
        $notes, $letter, $hemisphere, ( $manualhistory ? $manualhistory : 0 ),
1292
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1327
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1293
        $graceperiod,   $location,        $enddate,           $subscriptionid
1328
        $graceperiod,   $location,        $enddate,         $itemtype,
1329
	$ccode,         $origin,          $domain,          $previousitemtype,
1330
	$subscriptionid
1294
    );
1331
    );
1295
    my $rows = $sth->rows;
1332
    my $rows = $sth->rows;
1296
1297
    logaction( "SERIAL", "MODIFY", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog");
1333
    logaction( "SERIAL", "MODIFY", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog");
1298
    return $rows;
1334
    return $rows;
1299
}
1335
}
Lines 1321-1327 sub NewSubscription { Link Here
1321
        $lastvalue1,    $innerloop1,      $add2,              $every2,           $whenmorethan2, $setto2,       $lastvalue2,      $innerloop2,
1357
        $lastvalue1,    $innerloop1,      $add2,              $every2,           $whenmorethan2, $setto2,       $lastvalue2,      $innerloop2,
1322
        $add3,          $every3,          $whenmorethan3,     $setto3,           $lastvalue3,    $innerloop3,   $numberingmethod, $status,
1358
        $add3,          $every3,          $whenmorethan3,     $setto3,           $lastvalue3,    $innerloop3,   $numberingmethod, $status,
1323
        $notes,         $letter,          $firstacquidate,    $irregularity,     $numberpattern, $callnumber,   $hemisphere,      $manualhistory,
1359
        $notes,         $letter,          $firstacquidate,    $irregularity,     $numberpattern, $callnumber,   $hemisphere,      $manualhistory,
1324
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,   $location,     $enddate
1360
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,   $location,     $enddate,         $itemtype,
1361
        $ccode,         $origin,          $domain,            $previousitemtype
1325
    ) = @_;
1362
    ) = @_;
1326
    my $dbh = C4::Context->dbh;
1363
    my $dbh = C4::Context->dbh;
1327
1364
Lines 1335-1342 sub NewSubscription { Link Here
1335
            add3,every3,whenmorethan3,setto3,lastvalue3,innerloop3,
1372
            add3,every3,whenmorethan3,setto3,lastvalue3,innerloop3,
1336
            numberingmethod, status, notes, letter,firstacquidate,irregularity,
1373
            numberingmethod, status, notes, letter,firstacquidate,irregularity,
1337
            numberpattern, callnumber, hemisphere,manualhistory,internalnotes,serialsadditems,
1374
            numberpattern, callnumber, hemisphere,manualhistory,internalnotes,serialsadditems,
1338
            staffdisplaycount,opacdisplaycount,graceperiod,location,enddate)
1375
            staffdisplaycount,opacdisplaycount,graceperiod,location,enddate, itemtype, ccode, origin, domain, previousitemtype)
1339
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1376
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1340
        |;
1377
        |;
1341
    my $sth = $dbh->prepare($query);
1378
    my $sth = $dbh->prepare($query);
1342
    $sth->execute(
1379
    $sth->execute(
Lines 1345-1351 sub NewSubscription { Link Here
1345
        $lastvalue1,    $innerloop1,      $add2,              $every2,           $whenmorethan2, $setto2,       $lastvalue2,      $innerloop2,
1382
        $lastvalue1,    $innerloop1,      $add2,              $every2,           $whenmorethan2, $setto2,       $lastvalue2,      $innerloop2,
1346
        $add3,          $every3,          $whenmorethan3,     $setto3,           $lastvalue3,    $innerloop3,   $numberingmethod, "$status",
1383
        $add3,          $every3,          $whenmorethan3,     $setto3,           $lastvalue3,    $innerloop3,   $numberingmethod, "$status",
1347
        $notes,         $letter,          $firstacquidate,    $irregularity,     $numberpattern, $callnumber,   $hemisphere,      $manualhistory,
1384
        $notes,         $letter,          $firstacquidate,    $irregularity,     $numberpattern, $callnumber,   $hemisphere,      $manualhistory,
1348
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,   $location,     $enddate
1385
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,   $location,     $enddate, 	  $itemtype,
1386
	$ccode,         $origin,          $domain, $previousitemtype
1349
    );
1387
    );
1350
1388
1351
    my $subscriptionid = $dbh->{'mysql_insertid'};
1389
    my $subscriptionid = $dbh->{'mysql_insertid'};
(-)a/installer/data/mysql/kohastructure.sql (+5 lines)
Lines 1922-1927 CREATE TABLE `subscription` ( Link Here
1922
  `graceperiod` int(11) NOT NULL default '0',
1922
  `graceperiod` int(11) NOT NULL default '0',
1923
  `enddate` date default NULL,
1923
  `enddate` date default NULL,
1924
  `closed` INT(1) NOT NULL DEFAULT 0,
1924
  `closed` INT(1) NOT NULL DEFAULT 0,
1925
  `itemtype` VARCHAR( 10 ) NULL,
1926
  `ccode` VARCHAR( 10 ) NULL,
1927
  `origin` VARCHAR( 80 ) NULL,
1928
  `domain` VARCHAR( 80 ) NULL,
1929
  `previousitemtype` VARCHAR( 10 ) NULL,
1925
  PRIMARY KEY  (`subscriptionid`)
1930
  PRIMARY KEY  (`subscriptionid`)
1926
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1931
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1927
1932
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 421-423 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES( Link Here
421
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('PatronSelfRegistrationAdditionalInstructions','','A free text field to display additional instructions to newly self registered patrons.','','free');
421
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('PatronSelfRegistrationAdditionalInstructions','','A free text field to display additional instructions to newly self registered patrons.','','free');
422
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseQueryParser', '0', 'If enabled, try to use QueryParser for queries.', NULL, 'YesNo');
422
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseQueryParser', '0', 'If enabled, try to use QueryParser for queries.', NULL, 'YesNo');
423
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('FinesIncludeGracePeriod','1','If enabled, fines calculations will include the grace period.',NULL,'YesNo');
423
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('FinesIncludeGracePeriod','1','If enabled, fines calculations will include the grace period.',NULL,'YesNo');
424
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('makePreviousSerialAvailable','0','make previous serial automatically available when collecting a new serial','','YesNo');
425
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('serialsFieldsToAV','','There are several fields from serials which can use authorised values. Those are support, origin, and domain. You can configure them like this: support:995$r|origin:995$s|domain:995$t','','');
(-)a/installer/data/mysql/updatedatabase.pl (+40 lines)
Lines 6532-6537 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
6532
    SetVersion ($DBversion);
6532
    SetVersion ($DBversion);
6533
}
6533
}
6534
6534
6535
$DBversion = "3.11.00.XXX";
6536
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6537
    $dbh->do(qq{
6538
    ALTER TABLE `subscription` ADD `itemtype` VARCHAR( 10 ) NULL ,
6539
    ADD `ccode` VARCHAR( 10 ) NULL ,
6540
    ADD `origin` VARCHAR( 80 ) NULL ,
6541
    ADD `domain` VARCHAR( 80 ) NULL
6542
    });
6543
    print "Upgrade to $DBversion done (Adds fields to subscription table)\n";
6544
    SetVersion($DBversion);
6545
}
6546
6547
$DBversion = "3.11.00.XXX";
6548
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6549
    $dbh->do(
6550
        "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('makePreviousSerialAvailable','0','make previous serial automatically available when collecting a new serial','','YesNo');"
6551
    );
6552
    print "Upgrade to $DBversion done (added new syspref: makePreviousSerialAvailable)\n";
6553
    SetVersion($DBversion);
6554
}
6555
6556
$DBversion = "3.11.00.XXX";
6557
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6558
    $dbh->do(
6559
        "ALTER TABLE `subscription` ADD `previousitemtype` VARCHAR( 10 ) NULL"
6560
    );
6561
    print "Upgrade to $DBversion done (adds field previousitemtype to subscription)\n";
6562
    SetVersion($DBversion);
6563
}
6564
6565
$DBversion = "3.11.00.XXX";
6566
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6567
    $dbh->do(
6568
        'INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ("serialsFieldsToAV","","There are several fields from serials which can use authorised values. Those are support, origin, and domain. You can configure them like this: support:995$r|origin:995$s|domain:995$t","","");'
6569
    );
6570
    print "Upgrade to $DBversion done (added new syspref: serialsFieldsToAV)\n";
6571
    SetVersion($DBversion);
6572
}
6573
6574
6535
=head1 FUNCTIONS
6575
=head1 FUNCTIONS
6536
6576
6537
=head2 TableExists($table)
6577
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref (+9 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
59
    - 
60
        - pref: serialsFieldsToAV
61
        - "There are several fields from serials which can use authorised values. Those are support, origin, and domain. You can configure them like this: support:995$r|origin:995$s|domain:995$t"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt (+6 lines)
Lines 75-80 function unHideItems(index,labelindex, serialId) { Link Here
75
	subfieldid = "subfield" + itemid.substr(4) + "h";
75
	subfieldid = "subfield" + itemid.substr(4) + "h";
76
	// Setting text field 
76
	// Setting text field 
77
	$("#" + subfieldid + " input[type='text']").val($("#serialseq" + serialId).val());
77
	$("#" + subfieldid + " input[type='text']").val($("#serialseq" + serialId).val());
78
        // Also prefilling 995$l
79
        subfieldid = "subfield" + itemid.substr(4) + "l";
80
        $("#" + subfieldid + " input[type='text']").val($("#serialseq" + serialId).val());
81
        // And prefilling for supplemental issue
82
        $("#subfieldNEWl input[type='text']").val($("#serialseqNEW").val());
83
78
84
79
}
85
}
80
function HideItems(index,labelindex) {
86
function HideItems(index,labelindex) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (+73 lines)
Lines 1049-1054 $(document).ready(function() { Link Here
1049
                [% FOREACH locations_loo IN locations_loop %][% IF ( locations_loo.selected ) %]<option value="[% locations_loo.authorised_value %]" selected="selected">[% locations_loo.lib %]</option>[% ELSE %]<option value="[% locations_loo.authorised_value %]">[% locations_loo.lib %]</option>[% END %][% END %]
1049
                [% FOREACH locations_loo IN locations_loop %][% IF ( locations_loo.selected ) %]<option value="[% locations_loo.authorised_value %]" selected="selected">[% locations_loo.lib %]</option>[% ELSE %]<option value="[% locations_loo.authorised_value %]">[% locations_loo.lib %]</option>[% END %][% END %]
1050
            </select>
1050
            </select>
1051
        </li>
1051
        </li>
1052
	<li>
1053
	    <label for="itemtype">Item type:</label>
1054
	    <select name="itemtype" id="itemtype">
1055
                <option value=""></option>
1056
                [% FOREACH type IN typeloop %]
1057
                    [% IF ( type.selected ) %]
1058
                        <option value="[% type.code %]" selected="selected">[% type.value %]</option>
1059
                    [% ELSE %]
1060
                        <option value="[% type.code %]">[% type.value %]</option>
1061
                    [% END %]
1062
                [% END %]
1063
	    </select>
1064
	</li>
1065
        [%IF makePreviousSerialAvailable %]
1066
        <li>
1067
	    <label for="previousitemtype">Previous serial Item type:</label>
1068
	    <select name="previousitemtype" id="previousitemtype">
1069
		    <option value=""></option>
1070
                [% FOREACH previous IN previoustypeloop %]
1071
                    [% IF ( previous.selected ) %]
1072
                        <option value="[% previous.code %]" selected="selected">[% previous.value %]</option>
1073
                    [% ELSE %]
1074
                        <option value="[% previous.code %]">[% previous.value %]</option>
1075
                    [% END %]
1076
                [% END %]
1077
	    </select>
1078
	</li>
1079
        [% END %]
1080
        [% IF supportloop %]
1081
	<li>
1082
	    <label for="support">Support:</label>
1083
	    <select name="support" id="support">
1084
                <option value=""></option>
1085
                [% FOREACH support IN supportloop %]
1086
                    [% IF ( support.selected ) %]
1087
                        <option value="[% support.code %]" selected="selected">[% support.value %]</option>
1088
                    [% ELSE %]
1089
                        <option value="[% support.code %]">[% support.value %]</option>
1090
                    [% END %]
1091
                [% END %]
1092
	    </select>
1093
	</li>
1094
        [% END %]
1095
        [% IF originloop %]
1096
	<li>
1097
	    <label for="origin">Origin:</label>
1098
	    <select name="origin" id="origin">
1099
                <option value=""></option>
1100
                [% FOREACH origin IN originloop %]
1101
                    [% IF ( origin.selected ) %]
1102
                        <option value="[% origin.code %]" selected="selected">[% origin.value %]</option>
1103
                    [% ELSE %]
1104
                        <option value="[% origin.code %]">[% origin.value %]</option>
1105
                    [% END %]
1106
                [% END %]
1107
	    </select>
1108
	</li>
1109
        [% END %]
1110
        [% IF domainloop %]
1111
	<li>
1112
	    <label for="domain">Domain:</label>
1113
	    <select name="domain" id="domain">
1114
                <option value=""></option>
1115
                [% FOREACH domain IN domainloop %]
1116
                    [% IF ( domain.selected ) %]
1117
                        <option value="[% domain.code %]" selected="selected">[% domain.value %]</option>
1118
                    [% ELSE %]
1119
                        <option value="[% domain.code %]">[% domain.value %]</option>
1120
                    [% END %]
1121
                [% END %]
1122
	    </select>
1123
	</li>
1124
        [% END %]
1052
         <li>
1125
         <li>
1053
            <label for="callnumber">Call number:</label>
1126
            <label for="callnumber">Call number:</label>
1054
            <input type="text" name="callnumber" id="callnumber" value="[% callnumber %]" size="20" />
1127
            <input type="text" name="callnumber" id="callnumber" value="[% callnumber %]" size="20" />
(-)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 241-246 if ( $op and $op eq 'serialchangestatus' ) { Link Here
241
                $notes[$i]
242
                $notes[$i]
242
            );
243
            );
243
        }
244
        }
245
        my $makePreviousSerialAvailable = C4::Context->preference('makePreviousSerialAvailable');
246
        if ($makePreviousSerialAvailable && $serialids[$i] ne "NEW") {
247
            # We already have created the new expected serial at this point, so we get the second previous serial
248
            my $previous = GetPreviousSerialid($subscriptionids[$i]);
249
            if ($previous) {
250
251
                # Getting the itemnumber matching the serialid
252
                my $query = "SELECT itemnumber FROM serialitems WHERE serialid=?";
253
                my $sth = $dbh->prepare($query);
254
                $sth->execute($previous);
255
                my @row = $sth->fetchrow_array;
256
                if ($row[0]) {
257
                    my $itemnumber = $row[0];
258
259
                    # Getting the itemtype to set from the database
260
                    my $subscriptioninfos = GetSubscription($subscriptionids[$i]);
261
262
                    # Changing the status to "available" and the itemtype according to the previousitemtype db field
263
                    ModItem({notforloan => 0, itype => $subscriptioninfos->{'previousitemtype'} }, undef, $itemnumber);
264
                }
265
            }
266
        }
267
244
    }
268
    }
245
    my @moditems = $query->param('moditem');
269
    my @moditems = $query->param('moditem');
246
    if ( scalar(@moditems) ) {
270
    if ( scalar(@moditems) ) {
(-)a/serials/subscription-add.pl (-2 / +74 lines)
Lines 142-147 $template->param(branchloop => $branchloop, Link Here
142
    locations_loop=>$locations_loop,
142
    locations_loop=>$locations_loop,
143
);
143
);
144
# prepare template variables common to all $op conditions:
144
# prepare template variables common to all $op conditions:
145
my $shelflocations = GetKohaAuthorisedValues( 'items.location', '' );
146
147
my @locationarg =
148
  map { { code => $_, value => $shelflocations->{$_}, selected => ( ( $subs->{location} and $_ eq $subs->{location} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$shelflocations};
149
150
my $typeloop = GetItemTypes();
151
152
# Getting which field is mapped to which authorised value
153
my $mapstring = C4::Context->preference('serialsFieldsToAV');
154
my %hashmap = split(/[:|]/, $mapstring);
155
my $supportloop;
156
my $originloop;
157
my $domainloop;
158
159
if ($hashmap{'support'}) {
160
    my ($field, $subfield) = split('\$', $hashmap{'support'});
161
    $supportloop = GetKohaAuthorisedValuesFromField($field, $subfield, '');
162
}
163
164
if ($hashmap{'origin'}) {
165
    my ($field, $subfield) = split('\$', $hashmap{'origin'});
166
    $originloop = GetKohaAuthorisedValuesFromField($field, $subfield, '');
167
}
168
169
if ($hashmap{'domain'}) {
170
    my ($field, $subfield) = split('\$', $hashmap{'domain'});
171
    $domainloop = GetKohaAuthorisedValuesFromField($field, $subfield, '');
172
}
173
174
175
my @typearg = 
176
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{itemtype} and $_ eq $subs->{itemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
177
my @previoustypearg = 
178
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{previousitemtype} and $_ eq $subs->{previousitemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
179
my @supportarg = 
180
    map { { code => $_, value => $supportloop->{$_}, selected => ( ( $subs->{ccode} and $_ eq $subs->{ccode} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$supportloop};
181
my @originarg =
182
    map { { code => $_, value => $originloop->{$_}, selected => ( ( $subs->{origin} and $_ eq $subs->{origin} ) ? "selected=\"selected\"" : "" ), } } sort { lc $originloop->{$a} cmp lc $originloop->{$b} } keys %{$originloop};
183
my @domainarg = 
184
    map { { code => $_, value => $domainloop->{$_}, selected => ( ( $subs->{domain} and $_ eq $subs->{domain} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$domainloop};
185
186
187
188
$template->param( shelflocations => \@locationarg );
189
190
$template->param(
191
    branchloop               => $branchloop,
192
    typeloop                 => \@typearg,
193
    previoustypeloop         => \@previoustypearg,
194
    supportloop              => \@supportarg,
195
    originloop               => \@originarg,
196
    domainloop               => \@domainarg,
197
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
198
    locations_loop=>$locations_loop,
199
);
200
# prepare template variables common to all $op conditions:
201
$template->param(  'dateformat_' . C4::Context->preference('dateformat') => 1 );
202
$template->param('makePreviousSerialAvailable' => 1) if (C4::Context->preference('makePreviousSerialAvailable'));
203
145
if ($op!~/^mod/) {
204
if ($op!~/^mod/) {
146
    letter_loop(q{}, $template);
205
    letter_loop(q{}, $template);
147
}
206
}
Lines 247-252 sub redirect_add_subscription { Link Here
247
    my $staffdisplaycount = $query->param('staffdisplaycount');
306
    my $staffdisplaycount = $query->param('staffdisplaycount');
248
    my $opacdisplaycount  = $query->param('opacdisplaycount');
307
    my $opacdisplaycount  = $query->param('opacdisplaycount');
249
    my $location          = $query->param('location');
308
    my $location          = $query->param('location');
309
    my $itemtype          = $query->param('itemtype');
310
    my $support           = $query->param('support');
311
    my $origin            = $query->param('origin');
312
    my $domain            = $query->param('domain');
313
    my $previousitemtype  = $query->param('previousitemtype');
250
    my $startdate = format_date_in_iso( $query->param('startdate') );
314
    my $startdate = format_date_in_iso( $query->param('startdate') );
251
    my $enddate = format_date_in_iso( $query->param('enddate') );
315
    my $enddate = format_date_in_iso( $query->param('enddate') );
252
    my $firstacquidate  = format_date_in_iso($query->param('firstacquidate'));
316
    my $firstacquidate  = format_date_in_iso($query->param('firstacquidate'));
Lines 263-269 sub redirect_add_subscription { Link Here
263
					$add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
327
					$add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
264
					$numberingmethod, $status, $notes,$letter,$firstacquidate,join(",",@irregularity),
328
					$numberingmethod, $status, $notes,$letter,$firstacquidate,join(",",@irregularity),
265
                    $numberpattern, $callnumber, $hemisphere,($manualhistory?$manualhistory:0),$internalnotes,
329
                    $numberpattern, $callnumber, $hemisphere,($manualhistory?$manualhistory:0),$internalnotes,
266
                    $serialsadditems,$staffdisplaycount,$opacdisplaycount,$graceperiod,$location,$enddate
330
                    $serialsadditems,$staffdisplaycount,$opacdisplaycount,$graceperiod,$location,$enddate, $itemtype, $support, $origin, $domain, $previousitemtype
267
				);
331
				);
268
    ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
332
    ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
269
333
Lines 319-324 sub redirect_mod_subscription { Link Here
319
    my $letter = $query->param('letter');
383
    my $letter = $query->param('letter');
320
    my $manualhistory = $query->param('manualhist');
384
    my $manualhistory = $query->param('manualhist');
321
    my $serialsadditems = $query->param('serialsadditems');
385
    my $serialsadditems = $query->param('serialsadditems');
386
    my $itemtype = $query->param('itemtype');
387
    my $support = $query->param('support');
388
    my $origin = $query->param('origin');
389
    my $domain = $query->param('domain');
390
    my $previousitemtype = $query->param('previousitemtype');
391
322
    # subscription history
392
    # subscription history
323
    my $histenddate = format_date_in_iso($query->param('histenddate'));
393
    my $histenddate = format_date_in_iso($query->param('histenddate'));
324
    my $histstartdate = format_date_in_iso($query->param('histstartdate'));
394
    my $histstartdate = format_date_in_iso($query->param('histstartdate'));
Lines 349-357 sub redirect_mod_subscription { Link Here
349
            $whenmorethan3,   $setto3,       $lastvalue3,     $innerloop3,
419
            $whenmorethan3,   $setto3,       $lastvalue3,     $innerloop3,
350
            $numberingmethod, $status,       $biblionumber,   $callnumber,
420
            $numberingmethod, $status,       $biblionumber,   $callnumber,
351
            $notes,           $letter,       $hemisphere,     $manualhistory,$internalnotes,
421
            $notes,           $letter,       $hemisphere,     $manualhistory,$internalnotes,
352
            $serialsadditems, $staffdisplaycount,$opacdisplaycount,$graceperiod,$location,$enddate,$subscriptionid
422
            $serialsadditems, $staffdisplaycount,$opacdisplaycount,$graceperiod,$location,$enddate, $itemtype, $support, $origin, $domain, $previousitemtype, $subscriptionid
353
        );
423
        );
354
        ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
424
        ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
425
426
355
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
427
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
356
    return;
428
    return;
357
}
429
}
(-)a/t/db_dependent/Serials.t (-2 / +3 lines)
Lines 37-43 if ($subscriptioninformation->{periodicity} % 16==0){ Link Here
37
        whenmorethan1,   setto1,          lastvalue1,        innerloop1,       add2,          every2,      whenmorethan2, setto2,
37
        whenmorethan1,   setto1,          lastvalue1,        innerloop1,       add2,          every2,      whenmorethan2, setto2,
38
        lastvalue2,      innerloop2,      add3,              every3,           whenmorethan3, setto3,      lastvalue3,    innerloop3,
38
        lastvalue2,      innerloop2,      add3,              every3,           whenmorethan3, setto3,      lastvalue3,    innerloop3,
39
        numberingmethod, status,          biblionumber,      callnumber,       notes,         letter,      hemisphere,    manualhistory,
39
        numberingmethod, status,          biblionumber,      callnumber,       notes,         letter,      hemisphere,    manualhistory,
40
        internalnotes,   serialsadditems, staffdisplaycount, opacdisplaycount, graceperiod,   location,    enddate,       subscriptionid
40
        internalnotes,   serialsadditems, staffdisplaycount, opacdisplaycount, graceperiod,   location,    enddate,       
41
	itemtype,        support,         origin,            domain,           previousitemtype,
42
	subscriptionid
41
)});
43
)});
42
}
44
}
43
my $expirationdate = GetExpirationDate(1) ;
45
my $expirationdate = GetExpirationDate(1) ;
44
- 

Return to bug 7677