+my $branchcode;
+if((!defined($input->param('branchcode'))) & mybranch() ne '')
+{
+ $branchcode = mybranch();
+}
+else
+{
+ $branchcode = $input->param('branchcode');
+}
+
+my $branchname = GetBranchName($branchcode);
+
+# Getting the branches for user selection
+my $branches = GetBranches();
+my @branch_loop;
+for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
+ my %row =(value => $thisbranch,
+ branchname => $branches->{$thisbranch}->{'branchname'},
+ selected => $thisbranch eq $branchcode ? 1 : 0,
+ );
+ push @branch_loop, \%row;
+}
+