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 297-302 if ($noreport) { Link Here
297
        my $dt = dt_from_string($data->{date_due}, 'sql');
299
        my $dt = dt_from_string($data->{date_due}, 'sql');
298
300
299
        push @overduedata, {
301
        push @overduedata, {
302
            patron                 => Koha::Patrons->find( $data->{borrowernumber} ),
300
            duedate                => output_pref($dt),
303
            duedate                => output_pref($dt),
301
            borrowernumber         => $data->{borrowernumber},
304
            borrowernumber         => $data->{borrowernumber},
302
            barcode                => $data->{barcode},
305
            barcode                => $data->{barcode},
Lines 370-383 sub build_csv { Link Here
370
    my @lines = ();
373
    my @lines = ();
371
374
372
    # build header ...
375
    # build header ...
373
    my @keys = qw /duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country
376
    my @keys =
374
                branchcode itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice streetnumber streettype/;
377
      qw ( duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country
378
      branchcode itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice streetnumber streettype);
375
    my $csv = Text::CSV_XS->new();
379
    my $csv = Text::CSV_XS->new();
376
    $csv->combine(@keys);
380
    $csv->combine(@keys);
377
    push @lines, $csv->string();
381
    push @lines, $csv->string();
378
382
383
    my @private_keys = qw( dueborrowertitle firstname surname phone email address address2 zipcode city country streetnumber streettype );
379
    # ... and rest of report
384
    # ... and rest of report
380
    foreach my $overdue ( @{ $overdues } ) {
385
    foreach my $overdue ( @{ $overdues } ) {
386
        unless ( $logged_in_user->can_see_patron_infos( $overdue->{patron} ) ) {
387
            $overdue->{$_} = undef for @private_keys;
388
        }
381
        push @lines, $csv->string() if $csv->combine(map { $overdue->{$_} } @keys);
389
        push @lines, $csv->string() if $csv->combine(map { $overdue->{$_} } @keys);
382
    }
390
    }
383
391
(-)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 124-130 Link Here
124
                <form id="ar-branchcode-form" method="post">
124
                <form id="ar-branchcode-form" method="post">
125
                    <select name="branchcode" id="branchcode">
125
                    <select name="branchcode" id="branchcode">
126
                        <option value="">All libraries</option>
126
                        <option value="">All libraries</option>
127
                        [% FOREACH b IN Branches.all %]
127
                        [% FOREACH b IN Branches.all( only_from_group => 1 ) %]
128
                            [% IF b.branchcode == branchcode %]
128
                            [% IF b.branchcode == branchcode %]
129
                                <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
129
                                <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
130
                            [% ELSE %]
130
                            [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt (-4 / +7 lines)
Lines 121-129 Link Here
121
      [% FOREACH overdueloo IN overdueloop %]
121
      [% FOREACH overdueloo IN overdueloop %]
122
        <tr>
122
        <tr>
123
          <td>[% overdueloo.duedate %]</td>
123
          <td>[% overdueloo.duedate %]</td>
124
          <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% overdueloo.borrowernumber %]">[% overdueloo.surname %][% IF (overdueloo.firstname) %], [% overdueloo.firstname %][% END %] ([% overdueloo.cardnumber %])</a>
124
          <td>
125
          [% IF ( overdueloo.email ) %][<a href="mailto:[% overdueloo.email %]?subject=[% INCLUDE subject %] [% overdueloo.title |html %]">email</a>][% END %]
125
            [% INCLUDE 'patron-title.inc' patron=overdueloo.patron hide_patron_infos_if_needed=1 link_to="circulation_reserves" %]
126
          [% IF ( overdueloo.phone ) %]([% overdueloo.phone %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro %])[% END %]</td>
126
            [% IF logged_in_user.can_see_patron_infos( overdueloo.patron ) %]
127
                [% IF ( overdueloo.email ) %][<a href="mailto:[% overdueloo.email %]?subject=[% INCLUDE subject %] [% overdueloo.title |html %]">email</a>][% END %]
128
                [% IF ( overdueloo.phone ) %]([% overdueloo.phone %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro %])[% END %]</td>
129
            [% END %]
127
          <td>[% IF overdueloo.branchcode %][% Branches.GetName( overdueloo.branchcode ) %][% END %]</td>
130
          <td>[% IF overdueloo.branchcode %][% Branches.GetName( overdueloo.branchcode ) %][% END %]</td>
128
          <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>
131
          <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>
129
          <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% overdueloo.biblionumber %]&amp;itemnumber=[% overdueloo.itemnum %]#item[% overdueloo.itemnum %]">[% overdueloo.barcode %]</a></td>
132
          <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% overdueloo.biblionumber %]&amp;itemnumber=[% overdueloo.itemnum %]#item[% overdueloo.itemnum %]">[% overdueloo.barcode %]</a></td>
Lines 237-243 Link Here
237
        <label>Library of the patron:</label>
240
        <label>Library of the patron:</label>
238
        <select name="branch" id="branch">
241
        <select name="branch" id="branch">
239
            <option value="">Any</option>
242
            <option value="">Any</option>
240
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
243
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter, only_from_group => 1 ) %]
241
        </select>
244
        </select>
242
    </li>
245
    </li>
243
246
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt (-1 / +1 lines)
Lines 206-212 $(document).ready(function() { Link Here
206
            <label for="branchlimit">Library: </label>
206
            <label for="branchlimit">Library: </label>
207
            <select name="branchlimit" id="branchlimit">
207
            <select name="branchlimit" id="branchlimit">
208
                <option value="">All</option>
208
                <option value="">All</option>
209
                [% PROCESS options_for_libraries libraries => Branches.all() %]
209
                [% PROCESS options_for_libraries libraries => Branches.all( only_from_group => 1 ) %]
210
            </select>
210
            </select>
211
        </li>
211
        </li>
212
			<!-- FIXME Not working yet
212
			<!-- FIXME Not working yet
(-)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 502-508 function filterByFirstLetterSurname(letter) { Link Here
502
            </li>
502
            </li>
503
            <li>
503
            <li>
504
              <label for="branchcode_filter">Library:</label>
504
              <label for="branchcode_filter">Library:</label>
505
              [% SET branches = Branches.all( selected => branchcode_filter ) %]
505
              [% SET branches = Branches.all( selected => branchcode_filter, only_from_group => 1 ) %]
506
              <select id="branchcode_filter">
506
              <select id="branchcode_filter">
507
                [% IF branches.size != 1 %]
507
                [% IF branches.size != 1 %]
508
                  <option value="">Any</option>
508
                  <option value="">Any</option>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-2 / +1 lines)
Lines 634-640 $(document).ready(function() { Link Here
634
    <li>
634
    <li>
635
        <label for="libraries" class="required">Library:</label>
635
        <label for="libraries" class="required">Library:</label>
636
        <select name="branchcode" size="1" id="libraries">
636
        <select name="branchcode" size="1" id="libraries">
637
            [% PROCESS options_for_libraries libraries => Branches.all( selected => userbranch ) %]
637
            [% PROCESS options_for_libraries libraries => Branches.all( selected => userbranch, only_from_group => 1 ) %]
638
        </select>
638
        </select>
639
        <span class="required">Required</span>
639
        <span class="required">Required</span>
640
    </li>
640
    </li>
641
- 

Return to bug 18403