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

(-)a/C4/Serials.pm (-3 / +10 lines)
Lines 712-720 sub GetSerials2 { Link Here
712
    my @serials;
712
    my @serials;
713
713
714
    while ( my $line = $sth->fetchrow_hashref ) {
714
    while ( my $line = $sth->fetchrow_hashref ) {
715
        $line->{ "status" . $line->{status} } = 1;                                         # fills a "statusX" value, used for template status select list
715
        $line->{ "status" . $line->{status} } = 1; # fills a "statusX" value, used for template status select list
716
        $line->{"planneddate"}                = format_date( $line->{"planneddate"} );
716
        # Format dates for display
717
        $line->{"publisheddate"}              = format_date( $line->{"publisheddate"} );
717
        for my $datefield ( qw( planneddate publisheddate ) ) {
718
            if ($line->{$datefield} =~m/^00/) {
719
                $line->{$datefield} = q{};
720
            }
721
            else {
722
                $line->{"planneddate"} = format_date( $line->{$datefield} );
723
            }
724
        }
718
        push @serials, $line;
725
        push @serials, $line;
719
    }
726
    }
720
    return @serials;
727
    return @serials;
(-)a/serials/serials-edit.pl (-46 / +55 lines)
Lines 90-122 my @errseq; Link Here
90
90
91
# If user comes from subscription details
91
# If user comes from subscription details
92
unless (@serialids) {
92
unless (@serialids) {
93
    foreach my $subscriptionid (@subscriptionids) {
93
    my $serstatus = $query->param('serstatus');
94
        my $serstatus = $query->param('serstatus');
94
    if ($serstatus) {
95
        if ($serstatus) {
95
        foreach my $subscriptionid (@subscriptionids) {
96
            my @tmpser = GetSerials2( $subscriptionid, $serstatus );
96
            my @tmpser = GetSerials2( $subscriptionid, $serstatus );
97
            foreach (@tmpser) {
97
            @serialids = map { $_->{serialid} } @tmpser;
98
                push @serialids, $_->{'serialid'};
99
            }
100
        }
98
        }
101
    }
99
    }
102
}
100
}
103
101
104
unless ( scalar(@serialids) ) {
102
unless ( @serialids ) {
105
    my $string =
103
    my $string =
106
      "serials-collection.pl?subscriptionid=" . join( ",", @subscriptionids );
104
      'serials-collection.pl?subscriptionid=' . join ',', @subscriptionids;
107
    $string =~ s/,$//;
108
109
    print $query->redirect($string);
105
    print $query->redirect($string);
110
}
106
}
111
107
112
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
108
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
113
    {
109
    {
114
	template_name   => "serials/serials-edit.tmpl",
110
        template_name   => 'serials/serials-edit.tmpl',
115
	query           => $query,
111
        query           => $query,
116
	type            => "intranet",
112
        type            => 'intranet',
117
	authnotrequired => 0,
113
        authnotrequired => 0,
118
	flagsrequired   => {serials => 'receive_serials'},
114
        flagsrequired   => { serials => 1 },
119
	debug           => 1,
115
        debug           => 1,
120
    }
116
    }
121
);
117
);
122
118
Lines 124-153 my @serialdatalist; Link Here
124
my %processedserialid;
120
my %processedserialid;
125
121
126
my $today = C4::Dates->new();
122
my $today = C4::Dates->new();
127
foreach my $tmpserialid (@serialids) {
123
foreach my $serialid (@serialids) {
128
124
129
    #filtering serialid for duplication
125
    #filtering serialid for duplication
130
    #NEW serial should appear only once and are created afterwards
126
    #NEW serial should appear only once and are created afterwards
131
    if (   defined($tmpserialid)
127
    if (   $serialid
132
        && $tmpserialid =~ /^[0-9]+$/
128
        && $serialid =~ /^[0-9]+$/
133
        && !$processedserialid{$tmpserialid} )
129
        && !$processedserialid{$serialid} )
134
    {
130
    {
135
        my $data = GetSerialInformation($tmpserialid);
131
        my $serinfo = GetSerialInformation($serialid); #TODO duplicates work done by GetSerials2 above
136
        $data->{publisheddate} = format_date( $data->{publisheddate} );
132
        for my $d ( qw( publisheddate planneddate )){
137
        $data->{planneddate}   = format_date( $data->{planneddate} );
133
            if ( $serinfo->{$d} =~m/^00/ ) {
138
        $data->{arriveddate}=$today->output('syspref');
134
                $serinfo->{$d} = q{};
139
        $data->{'editdisable'} = (
135
            }
136
            else {
137
                $serinfo->{$d} = format_date( $serinfo->{$d} );
138
            }
139
        }
140
        $serinfo->{arriveddate}=$today->output('syspref');
141
142
        $serinfo->{'editdisable'} = (
140
            (
143
            (
141
                HasSubscriptionExpired( $data->{subscriptionid} )
144
                HasSubscriptionExpired( $serinfo->{subscriptionid} )
142
                  && $data->{'status1'}
145
                && $serinfo->{'status1'}
143
            )
146
            )
144
              || $data->{'cannotedit'}
147
            || $serinfo->{'cannotedit'}
145
        );
148
        );
146
        push @serialdatalist, $data;
149
        push @serialdatalist, $serinfo;
147
        $processedserialid{$tmpserialid} = 1;
150
        $processedserialid{$serialid} = 1;
148
    }
151
    }
149
}
152
}
150
my $bibdata = GetBiblioData( $serialdatalist[0]->{'biblionumber'} );
153
my $biblio = GetBiblioData( $serialdatalist[0]->{'biblionumber'} );
151
154
152
my @newserialloop;
155
my @newserialloop;
153
my @subscriptionloop;
156
my @subscriptionloop;
Lines 157-164 my %processedsubscriptionid; Link Here
157
foreach my $subscriptionid (@subscriptionids) {
160
foreach my $subscriptionid (@subscriptionids) {
158
161
159
    #Do not process subscriptionid twice if it was already processed.
162
    #Do not process subscriptionid twice if it was already processed.
160
    if ( defined($subscriptionid)
163
    if ( $subscriptionid && !$processedsubscriptionid{$subscriptionid} )
161
        && !$processedsubscriptionid{$subscriptionid} )
162
    {
164
    {
163
        my $cell;
165
        my $cell;
164
        if ( $serialdatalist[0]->{'serialsadditems'} ) {
166
        if ( $serialdatalist[0]->{'serialsadditems'} ) {
Lines 170-177 foreach my $subscriptionid (@subscriptionids) { Link Here
170
            $cell->{serialsadditems} = 1;
172
            $cell->{serialsadditems} = 1;
171
        }
173
        }
172
        $cell->{'subscriptionid'} = $subscriptionid;
174
        $cell->{'subscriptionid'} = $subscriptionid;
173
        $cell->{'itemid'}         = "NNEW";
175
        $cell->{'itemid'}         = 'NNEW';
174
        $cell->{'serialid'}       = "NEW";
176
        $cell->{'serialid'}       = 'NEW';
175
        $cell->{'issuesatonce'}   = 1;
177
        $cell->{'issuesatonce'}   = 1;
176
        push @newserialloop, $cell;
178
        push @newserialloop, $cell;
177
        push @subscriptionloop,
179
        push @subscriptionloop,
Lines 190-197 if ( $op and $op eq 'serialchangestatus' ) { Link Here
190
192
191
    my $newserial;
193
    my $newserial;
192
    for ( my $i = 0 ; $i <= $#serialids ; $i++ ) {
194
    for ( my $i = 0 ; $i <= $#serialids ; $i++ ) {
195
        my ($plan_date, $pub_date);
196
197
        if (defined $planneddates[$i] && $planneddates[$i] ne 'XXX') {
198
            $plan_date = format_date_in_iso( $planneddates[$i] );
199
        }
200
        if (defined $publisheddates[$i] && $publisheddates[$i] ne 'XXX') {
201
            $pub_date = format_date_in_iso( $publisheddates[$i] );
202
        }
193
203
194
        if ( $serialids[$i] && $serialids[$i] eq "NEW" ) {
204
        if ( $serialids[$i] && $serialids[$i] eq 'NEW' ) {
195
            if ( $serialseqs[$i] ) {
205
            if ( $serialseqs[$i] ) {
196
206
197
            #IF newserial was provided a name Then we have to create a newSerial
207
            #IF newserial was provided a name Then we have to create a newSerial
Lines 201-208 if ( $op and $op eq 'serialchangestatus' ) { Link Here
201
                    $subscriptionids[$i],
211
                    $subscriptionids[$i],
202
                    $serialdatalist[0]->{'biblionumber'},
212
                    $serialdatalist[0]->{'biblionumber'},
203
                    $status[$i],
213
                    $status[$i],
204
                    format_date_in_iso( $planneddates[$i] ),
214
                    $plan_date,
205
                    format_date_in_iso( $publisheddates[$i] ),
215
                    $pub_date,
206
                    $notes[$i]
216
                    $notes[$i]
207
                );
217
                );
208
            }
218
            }
Lines 211-218 if ( $op and $op eq 'serialchangestatus' ) { Link Here
211
            ModSerialStatus(
221
            ModSerialStatus(
212
                $serialids[$i],
222
                $serialids[$i],
213
                $serialseqs[$i],
223
                $serialseqs[$i],
214
                format_date_in_iso( $planneddates[$i] ),
224
                $plan_date,
215
                format_date_in_iso( $publisheddates[$i] ),
225
                $pub_date,
216
                $status[$i],
226
                $status[$i],
217
                $notes[$i]
227
                $notes[$i]
218
            );
228
            );
Lines 291-304 if ( $op and $op eq 'serialchangestatus' ) { Link Here
291
                            $serialdatalist[0]->{'biblionumber'}
301
                            $serialdatalist[0]->{'biblionumber'}
292
                        )
302
                        )
293
                      );
303
                      );
294
                    if ( C4::Context->preference("autoBarcode") eq
304
                    if ( C4::Context->preference('autoBarcode') eq
295
                        'incremental' )
305
                        'incremental' )
296
                    {
306
                    {
297
                        if ( !$bib_record->field($barcodetagfield)
307
                        if ( !$bib_record->field($barcodetagfield)
298
                            ->subfield($barcodetagsubfield) )
308
                            ->subfield($barcodetagsubfield) )
299
                        {
309
                        {
300
                            my $sth_barcode = $dbh->prepare(
310
                            my $sth_barcode = $dbh->prepare(
301
                                "select max(abs(barcode)) from items");
311
                                'select max(abs(barcode)) from items');
302
                            $sth_barcode->execute;
312
                            $sth_barcode->execute;
303
                            my ($newbarcode) = $sth_barcode->fetchrow;
313
                            my ($newbarcode) = $sth_barcode->fetchrow;
304
314
Lines 356-363 if ( $op and $op eq 'serialchangestatus' ) { Link Here
356
        }
366
        }
357
    }
367
    }
358
    else {
368
    else {
359
        my $redirect = "serials-collection.pl?";
369
        my $redirect = 'serials-collection.pl?';
360
        $redirect .= join( '&', map { "subscriptionid=" . $_ } sort @subscriptionids );# ID The sort necessary
370
        $redirect .= join( '&', map { 'subscriptionid=' . $_ } @subscriptionids );
361
        print $query->redirect($redirect);
371
        print $query->redirect($redirect);
362
    }
372
    }
363
}
373
}
Lines 365-371 my $default_bib_view = get_default_view(); Link Here
365
375
366
$template->param(
376
$template->param(
367
    serialsadditems => $serialdatalist[0]->{'serialsadditems'},
377
    serialsadditems => $serialdatalist[0]->{'serialsadditems'},
368
    bibliotitle     => $bibdata->{'title'},
378
    bibliotitle     => $biblio->{'title'},
369
    biblionumber    => $serialdatalist[0]->{'biblionumber'},
379
    biblionumber    => $serialdatalist[0]->{'biblionumber'},
370
    serialslist     => \@serialdatalist,
380
    serialslist     => \@serialdatalist,
371
    default_bib_view => $default_bib_view,
381
    default_bib_view => $default_bib_view,
372
- 

Return to bug 5026