- my $bibid=MARCfind_MARCbibid_from_oldbiblionumber($dbh,$subscription->{biblionumber});
- my $fwk=MARCfind_frameworkcode($dbh,$bibid);
-
- my $branches = GetBranches;
- my @branchloop;
- foreach my $thisbranch (keys %$branches) {
- my %row =(value => $thisbranch,
- branchname => $branches->{$thisbranch}->{'branchname'},
- );
- push @branchloop, \%row;
- }
-
- my $itemstatushash = getitemstatus($fwk);
- my @itemstatusloop;
- foreach my $thisitemstatus (keys %$itemstatushash) {
- my %row =(itemval => $thisitemstatus,
- itemlib => $itemstatushash->{$thisitemstatus},
- );
- push @itemstatusloop, \%row;
- }
-
- my $itemlocationhash = getitemlocation($fwk);
- my @itemlocationloop;
- foreach my $thisitemlocation (keys %$itemlocationhash) {
- my %row =(value => $thisitemlocation,
- itemlocationname => $itemlocationhash->{$thisitemlocation},
- );
- push @itemlocationloop, \%row;
- }
- foreach my $data (@serialslist){
- if (scalar(@itemstatusloop)){$data->{"itemstatusloop"}=\@itemstatusloop;}
- else { $data->{"itemstatusloop"}=[];}
- if (scalar(@itemlocationloop)){$data->{"itemlocationloop"}=\@itemlocationloop;}
- else {$data->{"itemlocationloop"}=[];}
- $data->{"branchloop"}=\@branchloop ;
- }
- $template->param(serialadditems =>C4::Context->preference("serialsadditems"),
- branchloop => \@branchloop,
- ) ;
- $template->param(itemstatus=>1,itemstatusloop=>\@itemstatusloop) if (scalar(@itemstatusloop));
- $template->param(itemlocation=>1,itemlocationloop=>\@itemlocationloop) if (scalar(@itemlocationloop));
+ my $bibid=MARCfind_MARCbibid_from_oldbiblionumber($dbh,$subscription->{biblionumber});
+ my $fwk=MARCfind_frameworkcode($dbh,$bibid);
+
+ my $branches = GetBranches;
+ my @branchloop;
+ foreach my $thisbranch (keys %$branches) {
+ my $selected = 0;
+ if($thisbranch eq $solhistory->{'lastbranch'}){
+ $selected = 1;
+ }
+ my %row =(value => $thisbranch,
+ branchname => $branches->{$thisbranch}->{'branchname'},
+ selected => $selected,
+ );
+ push @branchloop, \%row;
+ }
+
+ my $itemstatushash = getitemstatus($fwk);
+ my @itemstatusloop;
+ my $itemstatusloopcount=0;
+ foreach my $thisitemstatus (keys %$itemstatushash) {
+ my %row =(itemval => $thisitemstatus,
+ itemlib => $itemstatushash->{$thisitemstatus},
+ );
+# warn "".$row{'itemval'}.", ". $row{"itemlib"};
+ $itemstatusloopcount++;
+ push @itemstatusloop, \%row;
+ }
+
+ my $itemlocationhash = getitemlocation($fwk);
+ my @itemlocationloop;
+ foreach my $thisitemlocation (keys %$itemlocationhash) {
+ my %row =(value => $thisitemlocation,
+ itemlocationname => $itemlocationhash->{$thisitemlocation},
+ );
+ push @itemlocationloop, \%row;
+ }
+
+ my $choice = 0;
+ if($itemstatusloopcount == 1){ $choice = 1;}
+ foreach my $data (@serialslist){
+ if (scalar(@itemstatusloop)){$data->{"itemstatusloop"}=\@itemstatusloop;}
+ else { $data->{"itemstatusloop"}=[];}
+ if (scalar(@itemlocationloop)){$data->{"itemlocationloop"}=\@itemlocationloop;}
+ else {$data->{"itemlocationloop"}=[];}
+ $data->{"branchloop"}=\@branchloop ;
+ }
+# warn "Choice: $choice";
+ $template->param(choice => $choice);
+ $template->param(serialadditems =>C4::Context->preference("serialsadditems"),
+ branchloop => \@branchloop,
+ ) ;
+ $template->param(itemstatus=>1,itemstatusloop=>\@itemstatusloop) if (scalar(@itemstatusloop));
+ $template->param(itemlocation=>1,itemlocationloop=>\@itemlocationloop) if (scalar(@itemlocationloop));