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

(-)a/Koha/Libraries.pm (-2 / +27 lines)
Lines 45-54 Koha::Libraries - Koha Library Object set class Link Here
45
sub search_filtered {
45
sub search_filtered {
46
    my ( $self, $params, $attributes ) = @_;
46
    my ( $self, $params, $attributes ) = @_;
47
47
48
    if ( C4::Context::only_my_library ) {
48
    my @branchcodes;
49
        $params->{branchcode} = C4::Context->userenv->{branch};
49
    if ( my $userenv = C4::Context->userenv ) {
50
        if ( C4::Context::only_my_library ) {
51
            push @branchcodes, $userenv->{branch};
52
        }
53
        else {
54
            my $logged_in_user = Koha::Patrons->find( $userenv->{number} );
55
            unless (
56
                $logged_in_user->can(
57
                    { borrowers => 'view_borrower_infos_from_any_libraries' }
58
                )
59
              )
60
            {
61
                if ( my $library_groups = $logged_in_user->library->library_groups )
62
                {
63
                    while ( my $library_group = $library_groups->next ) {
64
                        push @branchcodes,
65
                          $library_group->parent->children->get_column('branchcode');
66
                    }
67
                }
68
                else {
69
                    push @branchcodes, $userenv->{branch};
70
                }
71
            }
72
        }
50
    }
73
    }
51
74
75
    $params->{branchcode} = { -in => \@branchcodes } if @branchcodes;
76
    delete $params->{only_from_group};
52
    return $self->SUPER::search( $params, $attributes );
77
    return $self->SUPER::search( $params, $attributes );
53
}
78
}
54
79
(-)a/Koha/Template/Plugin/Branches.pm (-1 / +2 lines)
Lines 59-68 sub all { Link Here
59
    my ( $self, $params ) = @_;
59
    my ( $self, $params ) = @_;
60
    my $selected = $params->{selected};
60
    my $selected = $params->{selected};
61
    my $unfiltered = $params->{unfiltered} || 0;
61
    my $unfiltered = $params->{unfiltered} || 0;
62
    my $only_from_group = $params->{only_from_group} || 0;
62
63
63
    my $libraries = $unfiltered
64
    my $libraries = $unfiltered
64
      ? Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed
65
      ? Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed
65
      : Koha::Libraries->search_filtered( {}, { order_by => ['branchname'] } )->unblessed;
66
      : Koha::Libraries->search_filtered( { only_from_group => $only_from_group }, { order_by => ['branchname'] } )->unblessed;
66
67
67
    for my $l ( @$libraries ) {
68
    for my $l ( @$libraries ) {
68
        if (       defined $selected and $l->{branchcode} eq $selected
69
        if (       defined $selected and $l->{branchcode} eq $selected
(-)a/circ/overdue.pl (-2 / +10 lines)
Lines 63-68 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
63
    }
63
    }
64
);
64
);
65
65
66
our $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
67
66
my $dbh = C4::Context->dbh;
68
my $dbh = C4::Context->dbh;
67
69
68
my $req;
70
my $req;
Lines 296-301 if ($noreport) { Link Here
296
        }
298
        }
297
299
298
        push @overduedata, {
300
        push @overduedata, {
301
            patron                 => scalar Koha::Patrons->find( $data->{borrowernumber} ),
299
            duedate                => $data->{date_due},
302
            duedate                => $data->{date_due},
300
            borrowernumber         => $data->{borrowernumber},
303
            borrowernumber         => $data->{borrowernumber},
301
            barcode                => $data->{barcode},
304
            barcode                => $data->{barcode},
Lines 369-382 sub build_csv { Link Here
369
    my @lines = ();
372
    my @lines = ();
370
373
371
    # build header ...
374
    # build header ...
372
    my @keys = qw /duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country
375
    my @keys =
373
                branchcode itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice streetnumber streettype/;
376
      qw ( duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country
377
      branchcode itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice streetnumber streettype);
374
    my $csv = Text::CSV_XS->new();
378
    my $csv = Text::CSV_XS->new();
375
    $csv->combine(@keys);
379
    $csv->combine(@keys);
376
    push @lines, $csv->string();
380
    push @lines, $csv->string();
377
381
382
    my @private_keys = qw( dueborrowertitle firstname surname phone email address address2 zipcode city country streetnumber streettype );
378
    # ... and rest of report
383
    # ... and rest of report
379
    foreach my $overdue ( @{ $overdues } ) {
384
    foreach my $overdue ( @{ $overdues } ) {
385
        unless ( $logged_in_user->can_see_patron_infos( $overdue->{patron} ) ) {
386
            $overdue->{$_} = undef for @private_keys;
387
        }
380
        push @lines, $csv->string() if $csv->combine(map { $overdue->{$_} } @keys);
388
        push @lines, $csv->string() if $csv->combine(map { $overdue->{$_} } @keys);
381
    }
389
    }
382
390
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-1 / +1 lines)
Lines 85-91 Link Here
85
85
86
        <p>
86
        <p>
87
            <label for="branchcode">Library: </label>
87
            <label for="branchcode">Library: </label>
88
            [% SET branches = Branches.all( selected => branchcode_filter ) %]
88
            [% SET branches = Branches.all( selected => branchcode_filter, only_my_group => 1 ) %]
89
            <select name="branchcode_filter" id="branchcode">
89
            <select name="branchcode_filter" id="branchcode">
90
                [% IF branches.size != 1 %]
90
                [% IF branches.size != 1 %]
91
                  <option value="">Any</option>
91
                  <option value="">Any</option>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt (-1 / +1 lines)
Lines 31-37 Link Here
31
                <form id="ar-branchcode-form" method="post">
31
                <form id="ar-branchcode-form" method="post">
32
                    <select name="branchcode" id="branchcode">
32
                    <select name="branchcode" id="branchcode">
33
                        <option value="">All libraries</option>
33
                        <option value="">All libraries</option>
34
                        [% FOREACH b IN Branches.all %]
34
                        [% FOREACH b IN Branches.all( only_from_group => 1 ) %]
35
                            [% IF b.branchcode == branchcode %]
35
                            [% IF b.branchcode == branchcode %]
36
                                <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
36
                                <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
37
                            [% ELSE %]
37
                            [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt (-4 / +7 lines)
Lines 58-66 Link Here
58
      [% FOREACH overdueloo IN overdueloop %]
58
      [% FOREACH overdueloo IN overdueloop %]
59
        <tr>
59
        <tr>
60
          <td><span title="[% overdueloo.duedate %]">[% overdueloo.duedate | $KohaDates %]</span></td>
60
          <td><span title="[% overdueloo.duedate %]">[% overdueloo.duedate | $KohaDates %]</span></td>
61
          <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% overdueloo.borrowernumber %]">[% overdueloo.surname %][% IF (overdueloo.firstname) %], [% overdueloo.firstname %][% END %] ([% overdueloo.cardnumber %])</a>
61
          <td>
62
          [% IF ( overdueloo.email ) %][<a href="mailto:[% overdueloo.email %]?subject=[% INCLUDE subject %] [% overdueloo.title |html %]">email</a>][% END %]
62
            [% INCLUDE 'patron-title.inc' patron=overdueloo.patron hide_patron_infos_if_needed=1 link_to="circulation_reserves" %]
63
          [% IF ( overdueloo.phone ) %]([% overdueloo.phone %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro %])[% END %]</td>
63
            [% IF logged_in_user.can_see_patron_infos( overdueloo.patron ) %]
64
                [% IF ( overdueloo.email ) %][<a href="mailto:[% overdueloo.email %]?subject=[% INCLUDE subject %] [% overdueloo.title |html %]">email</a>][% END %]
65
                [% IF ( overdueloo.phone ) %]([% overdueloo.phone %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro %])[% END %]</td>
66
            [% END %]
64
          <td>[% IF overdueloo.branchcode %][% Branches.GetName( overdueloo.branchcode ) %][% END %]</td>
67
          <td>[% IF overdueloo.branchcode %][% Branches.GetName( overdueloo.branchcode ) %][% END %]</td>
65
          <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = overdueloo.biblionumber %][% overdueloo.title |html %]  [% overdueloo.subtitle %]</a> [% IF ( overdueloo.author ) %], by [% overdueloo.author %][% END %][% IF ( overdueloo.enumchron ) %], [% overdueloo.enumchron %][% END %]</td>
68
          <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = overdueloo.biblionumber %][% overdueloo.title |html %]  [% overdueloo.subtitle %]</a> [% IF ( overdueloo.author ) %], by [% overdueloo.author %][% END %][% IF ( overdueloo.enumchron ) %], [% overdueloo.enumchron %][% END %]</td>
66
          <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% overdueloo.biblionumber %]&amp;itemnumber=[% overdueloo.itemnum %]#item[% overdueloo.itemnum %]">[% overdueloo.barcode %]</a></td>
69
          <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% overdueloo.biblionumber %]&amp;itemnumber=[% overdueloo.itemnum %]#item[% overdueloo.itemnum %]">[% overdueloo.barcode %]</a></td>
Lines 174-180 Link Here
174
        <label>Library of the patron:</label>
177
        <label>Library of the patron:</label>
175
        <select name="branch" id="branch">
178
        <select name="branch" id="branch">
176
            <option value="">Any</option>
179
            <option value="">Any</option>
177
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
180
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter, only_from_group => 1 ) %]
178
        </select>
181
        </select>
179
    </li>
182
    </li>
180
183
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt (-1 / +1 lines)
Lines 175-181 Link Here
175
            <label for="branchlimit">Library: </label>
175
            <label for="branchlimit">Library: </label>
176
            <select name="branchlimit" id="branchlimit">
176
            <select name="branchlimit" id="branchlimit">
177
                <option value="">All</option>
177
                <option value="">All</option>
178
                [% PROCESS options_for_libraries libraries => Branches.all() %]
178
                [% PROCESS options_for_libraries libraries => Branches.all( only_from_group => 1 ) %]
179
            </select>
179
            </select>
180
        </li>
180
        </li>
181
    </ol></fieldset>
181
    </ol></fieldset>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt (-1 / +1 lines)
Lines 195-201 function filterByFirstLetterSurname(letter) { Link Here
195
                    <li>
195
                    <li>
196
                        <label for="branchcode_filter">Library:</label>
196
                        <label for="branchcode_filter">Library:</label>
197
                        <select id="branchcode_filter">
197
                        <select id="branchcode_filter">
198
                            [% SET libraries = Branches.all() %]
198
                            [% SET libraries = Branches.all( only_from_group => 1 ) %]
199
                            [% IF libraries.size != 1 %]
199
                            [% IF libraries.size != 1 %]
200
                                <option value="">Any</option>
200
                                <option value="">Any</option>
201
                            [% END %]
201
                            [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-1 / +1 lines)
Lines 506-512 function filterByFirstLetterSurname(letter) { Link Here
506
            </li>
506
            </li>
507
            <li>
507
            <li>
508
              <label for="branchcode_filter">Library:</label>
508
              <label for="branchcode_filter">Library:</label>
509
              [% SET branches = Branches.all( selected => branchcode_filter ) %]
509
              [% SET branches = Branches.all( selected => branchcode_filter, only_from_group => 1 ) %]
510
              <select id="branchcode_filter">
510
              <select id="branchcode_filter">
511
                [% IF branches.size != 1 %]
511
                [% IF branches.size != 1 %]
512
                  <option value="">Any</option>
512
                  <option value="">Any</option>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-2 / +1 lines)
Lines 679-685 $(document).ready(function() { Link Here
679
    <li>
679
    <li>
680
        <label for="libraries" class="required">Library:</label>
680
        <label for="libraries" class="required">Library:</label>
681
        <select name="branchcode" size="1" id="libraries">
681
        <select name="branchcode" size="1" id="libraries">
682
            [% PROCESS options_for_libraries libraries => Branches.all( selected => userbranch ) %]
682
            [% PROCESS options_for_libraries libraries => Branches.all( selected => userbranch, only_from_group => 1 ) %]
683
        </select>
683
        </select>
684
        <span class="required">Required</span>
684
        <span class="required">Required</span>
685
    </li>
685
    </li>
686
- 

Return to bug 18403