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

(-)a/C4/Utils/DataTables/Members.pm (+9 lines)
Lines 1-5 Link Here
1
package C4::Utils::DataTables::Members;
1
package C4::Utils::DataTables::Members;
2
2
3
use C4::Branch qw/onlymine/;
3
use C4::Context;
4
use C4::Context;
4
use C4::Members qw/GetMemberIssuesAndFines/;
5
use C4::Members qw/GetMemberIssuesAndFines/;
5
use C4::Utils::DataTables;
6
use C4::Utils::DataTables;
Lines 17-22 sub search { Link Here
17
18
18
    my ($iTotalRecords, $iTotalDisplayRecords);
19
    my ($iTotalRecords, $iTotalDisplayRecords);
19
20
21
    # If branches are independant and user is not superlibrarian
22
    # The search has to be only on the user branch
23
    if ( C4::Branch::onlymine ) {
24
        my $userenv = C4::Context->userenv;
25
        $branchcode = $userenv->{'branch'};
26
27
    }
28
20
    my $dbh = C4::Context->dbh;
29
    my $dbh = C4::Context->dbh;
21
    my $select = "SELECT SQL_CALC_FOUND_ROWS
30
    my $select = "SELECT SQL_CALC_FOUND_ROWS
22
        borrowers.borrowernumber, borrowers.surname, borrowers.firstname, borrowers.address,
31
        borrowers.borrowernumber, borrowers.surname, borrowers.firstname, borrowers.address,
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-3 / +7 lines)
Lines 46-54 Link Here
46
      </select>
46
      </select>
47
47
48
    <input value="Search" class="submit" type="submit" />
48
    <input value="Search" class="submit" type="submit" />
49
	[% IF ( branchloop ) %]
49
    [% IF ( branchloop ) %]
50
	<p id="filters"> <label for="branchcode">Library: </label><select name="branchcode" id="branchcode">
50
    <p id="filters"> <label for="branchcode">Library: </label>
51
        <option value="">Any</option>[% FOREACH branchloo IN branchloop %]
51
    <select name="branchcode" id="branchcode">
52
        [% IF branchloop.size != 1 %]
53
          <option value="">Any</option>
54
        [% END %]
55
        [% FOREACH branchloo IN branchloop %]
52
        [% IF ( branchloo.selected ) %]
56
        [% IF ( branchloo.selected ) %]
53
        <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]
57
        <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]
54
        <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
58
        <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-1 / +3 lines)
Lines 294-300 Link Here
294
            <li>
294
            <li>
295
              <label for="branchcode_filter">Branch:</label>
295
              <label for="branchcode_filter">Branch:</label>
296
              <select id="branchcode_filter">
296
              <select id="branchcode_filter">
297
                <option value="">Any</option>
297
                [% IF branchloop.size != 1 %]
298
                  <option value="">Any</option>
299
                [% END %]
298
                [% FOREACH b IN branchloop %]
300
                [% FOREACH b IN branchloop %]
299
                  [% IF b.selected %]
301
                  [% IF b.selected %]
300
                    <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
302
                    <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
(-)a/members/member.pl (-8 / +20 lines)
Lines 55-70 my $searchfieldstype = $input->param('searchfieldstype'); Link Here
55
55
56
my $branches = GetBranches;
56
my $branches = GetBranches;
57
my @branches_loop;
57
my @branches_loop;
58
foreach ( sort { lc($branches->{$a}->{branchname}) cmp lc($branches->{$b}->{branchname}) } keys %$branches ) {
58
if ( C4::Branch::onlymine ) {
59
    my $selected = 0;
59
    my $userenv = C4::Context->userenv;
60
    $selected = 1 if($patron->{branchcode} and $patron->{branchcode} eq $_);
60
    my $branch = C4::Branch::GetBranchDetail( $userenv->{'branch'} );
61
    push @branches_loop, {
61
    push @branches_loop, {
62
        value => $_,
62
        value => $branch->{branchcode},
63
        branchcode => $_,
63
        branchcode => $branch->{branchcode},
64
        branchname => $branches->{$_}->{branchname},
64
        branchname => $branch->{branchname},
65
        selected => $selected
65
        selected => 1
66
    };
66
    }
67
} else {
68
    foreach ( sort { lc($branches->{$a}->{branchname}) cmp lc($branches->{$b}->{branchname}) } keys %$branches ) {
69
        my $selected = 0;
70
        $selected = 1 if($patron->{branchcode} and $patron->{branchcode} eq $_);
71
        push @branches_loop, {
72
            value => $_,
73
            branchcode => $_,
74
            branchname => $branches->{$_}->{branchname},
75
            selected => $selected
76
        };
77
    }
67
}
78
}
79
68
my @categories = C4::Category->all;
80
my @categories = C4::Category->all;
69
if ( $patron->{categorycode} ) {
81
if ( $patron->{categorycode} ) {
70
    foreach my $category ( grep { $_->{categorycode} eq $patron->{categorycode} } @categories ) {
82
    foreach my $category ( grep { $_->{categorycode} eq $patron->{categorycode} } @categories ) {
(-)a/members/members-home.pl (-6 / +16 lines)
Lines 45-56 my ($template, $loggedinuser, $cookie) Link Here
45
45
46
my $branches = GetBranches;
46
my $branches = GetBranches;
47
my @branchloop;
47
my @branchloop;
48
foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
48
if ( C4::Branch::onlymine ) {
49
    my $userenv = C4::Context->userenv;
50
    my $branch = C4::Branch::GetBranchDetail( $userenv->{'branch'} );
49
    push @branchloop, {
51
    push @branchloop, {
50
        value      => $_,
52
        value => $branch->{branchcode},
51
        selected   => ($branches->{$_}->{branchcode} eq $branch),
53
        branchcode => $branch->{branchcode},
52
        branchname => $branches->{$_}->{branchname},
54
        branchname => $branch->{branchname},
53
    };
55
        selected => 1
56
    }
57
} else {
58
    foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
59
        push @branchloop, {
60
            value      => $_,
61
            selected   => ($branches->{$_}->{branchcode} eq $branch),
62
            branchname => $branches->{$_}->{branchname},
63
        };
64
    }
54
}
65
}
55
66
56
my @categories;
67
my @categories;
57
- 

Return to bug 9811