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

(-)a/circ/pendingreserves.pl (-85 / +61 lines)
Lines 17-29 Link Here
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
# Modification by D.Ulm, actually works (as long as indep. branches not turned on)
20
use Modern::Perl;
21
#		Someone let me know what indep. branches is supposed to do and I'll make that part work too
22
#
23
# 		The reserve pull lists *works* as long as not for indepencdant branches, I can fix!
24
25
use strict;
26
#use warnings; FIXME - Bug 2505
27
21
28
use constant PULL_INTERVAL => 2;
22
use constant PULL_INTERVAL => 2;
29
23
Lines 37-45 use Koha::DateUtils; Link Here
37
use DateTime::Duration;
31
use DateTime::Duration;
38
32
39
my $input = new CGI;
33
my $input = new CGI;
40
my $startdate=$input->param('from');
34
my $startdate = $input->param('from');
41
my $enddate=$input->param('to');
35
my $enddate = $input->param('to');
42
my $run_report = ( not defined $input->param('run_report') ) ? 1 : $input->param('run_report');
43
36
44
my $theme = $input->param('theme');    # only used if allowthemeoverride is set
37
my $theme = $input->param('theme');    # only used if allowthemeoverride is set
45
38
Lines 55-66 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
55
);
48
);
56
49
57
my $today = dt_from_string;
50
my $today = dt_from_string;
58
$startdate =~ s/^\s+//;
59
$startdate =~ s/\s+$//;
60
$enddate =~ s/^\s+//;
61
$enddate =~ s/\s+$//;
62
51
63
if ( $startdate ) {
52
if ( $startdate ) {
53
    $startdate =~ s/^\s+//;
54
    $startdate =~ s/\s+$//;
64
    $startdate = eval{dt_from_string( $startdate )};
55
    $startdate = eval{dt_from_string( $startdate )};
65
}
56
}
66
unless ( $startdate ){
57
unless ( $startdate ){
Lines 70-75 unless ( $startdate ){ Link Here
70
}
61
}
71
62
72
if ( $enddate ) {
63
if ( $enddate ) {
64
    $enddate =~ s/^\s+//;
65
    $enddate =~ s/\s+$//;
73
    $enddate = eval{dt_from_string( $enddate )};
66
    $enddate = eval{dt_from_string( $enddate )};
74
}
67
}
75
unless ( $enddate ) {
68
unless ( $enddate ) {
Lines 78-109 unless ( $enddate ) { Link Here
78
}
71
}
79
72
80
my @reservedata;
73
my @reservedata;
81
if ( $run_report ) {
74
my $dbh = C4::Context->dbh;
82
    my $dbh    = C4::Context->dbh;
75
my $sqldatewhere = "";
83
    my $sqldatewhere = "";
76
my $startdate_iso = output_pref({ dt => $startdate, dateformat => 'iso', dateonly => 1 });
84
    my $startdate_iso = output_pref({ dt => $startdate, dateformat => 'iso', dateonly => 1 });
77
my $enddate_iso   = output_pref({ dt => $enddate, dateformat => 'iso', dateonly => 1 });
85
    my $enddate_iso   = output_pref({ dt => $enddate, dateformat => 'iso', dateonly => 1 });
86
    $debug and warn $startdate_iso. "\n" . $enddate_iso;
87
    my @query_params = ();
88
    if ($startdate_iso) {
89
        $sqldatewhere .= " AND reservedate >= ?";
90
        push @query_params, $startdate_iso;
91
    }
92
    if ($enddate_iso) {
93
        $sqldatewhere .= " AND reservedate <= ?";
94
        push @query_params, $enddate_iso;
95
    }
96
78
97
    my $strsth =
79
$debug and warn $startdate_iso. "\n" . $enddate_iso;
80
81
my @query_params = ();
82
83
if ($startdate_iso) {
84
    $sqldatewhere .= " AND reservedate >= ?";
85
    push @query_params, $startdate_iso;
86
}
87
if ($enddate_iso) {
88
    $sqldatewhere .= " AND reservedate <= ?";
89
    push @query_params, $enddate_iso;
90
}
91
92
my $strsth =
98
    "SELECT min(reservedate) as l_reservedate,
93
    "SELECT min(reservedate) as l_reservedate,
99
            reserves.borrowernumber as borrowernumber,
94
            reserves.borrowernumber as borrowernumber,
100
            GROUP_CONCAT(DISTINCT items.holdingbranch 
95
            GROUP_CONCAT(DISTINCT items.holdingbranch 
101
                    ORDER BY items.itemnumber SEPARATOR '|') l_holdingbranch,
96
                    ORDER BY items.itemnumber SEPARATOR '|') l_holdingbranch,
102
            reserves.biblionumber,
97
            reserves.biblionumber,
103
            reserves.branchcode,
98
            reserves.branchcode as l_branch,
104
            GROUP_CONCAT(DISTINCT reserves.branchcode 
105
                    ORDER BY items.itemnumber SEPARATOR ', ') l_branch,
106
            items.holdingbranch as branch,
107
            GROUP_CONCAT(DISTINCT items.itype 
99
            GROUP_CONCAT(DISTINCT items.itype 
108
                    ORDER BY items.itemnumber SEPARATOR '|') l_itype,
100
                    ORDER BY items.itemnumber SEPARATOR '|') l_itype,
109
            GROUP_CONCAT(DISTINCT items.location 
101
            GROUP_CONCAT(DISTINCT items.location 
Lines 114-124 if ( $run_report ) { Link Here
114
                    ORDER BY items.itemnumber SEPARATOR '<br/>') l_enumchron,
106
                    ORDER BY items.itemnumber SEPARATOR '<br/>') l_enumchron,
115
            GROUP_CONCAT(DISTINCT items.copynumber
107
            GROUP_CONCAT(DISTINCT items.copynumber
116
                    ORDER BY items.itemnumber SEPARATOR '<br/>') l_copynumber,
108
                    ORDER BY items.itemnumber SEPARATOR '<br/>') l_copynumber,
117
            items.itemnumber,
118
            notificationdate,
119
            reminderdate,
120
            max(priority) as priority,
121
            reserves.found,
122
            biblio.title,
109
            biblio.title,
123
            biblio.author,
110
            biblio.author,
124
            count(DISTINCT items.itemnumber) as icount,
111
            count(DISTINCT items.itemnumber) as icount,
Lines 136-142 if ( $run_report ) { Link Here
136
    $sqldatewhere
123
    $sqldatewhere
137
    AND (reserves.itemnumber IS NULL OR reserves.itemnumber = items.itemnumber)
124
    AND (reserves.itemnumber IS NULL OR reserves.itemnumber = items.itemnumber)
138
    AND items.itemnumber NOT IN (SELECT itemnumber FROM branchtransfers where datearrived IS NULL)
125
    AND items.itemnumber NOT IN (SELECT itemnumber FROM branchtransfers where datearrived IS NULL)
139
    AND items.itemnumber NOT IN (select itemnumber FROM reserves where found='W')
126
    AND items.itemnumber NOT IN (select itemnumber FROM reserves where found IS NOT NULL)
140
    AND issues.itemnumber IS NULL
127
    AND issues.itemnumber IS NULL
141
    AND reserves.priority <> 0 
128
    AND reserves.priority <> 0 
142
    AND reserves.suspend = 0
129
    AND reserves.suspend = 0
Lines 146-205 if ( $run_report ) { Link Here
146
    #    multiple patrons have a hold on an item
133
    #    multiple patrons have a hold on an item
147
134
148
135
149
    if (C4::Context->preference('IndependentBranches')){
136
if (C4::Context->preference('IndependentBranches')){
150
        $strsth .= " AND items.holdingbranch=? ";
137
    $strsth .= " AND items.holdingbranch=? ";
151
        push @query_params, C4::Context->userenv->{'branch'};
138
    push @query_params, C4::Context->userenv->{'branch'};
152
    }
139
}
153
    $strsth .= " GROUP BY reserves.biblionumber ORDER BY biblio.title ";
140
$strsth .= " GROUP BY reserves.biblionumber ORDER BY biblio.title ";
154
141
155
    my $sth = $dbh->prepare($strsth);
142
my $sth = $dbh->prepare($strsth);
156
    $sth->execute(@query_params);
143
$sth->execute(@query_params);
157
144
158
    while ( my $data = $sth->fetchrow_hashref ) {
145
while ( my $data = $sth->fetchrow_hashref ) {
159
        my $record = Koha::Biblios->find($data->{biblionumber});
146
    my $record = Koha::Biblios->find($data->{biblionumber});
160
        if ($record){
147
    if ($record){
161
            $data->{subtitle} = [ $record->subtitles ];
148
        $data->{subtitle} = [ $record->subtitles ];
162
        }
163
        push(
164
            @reservedata,
165
            {
166
                reservedate     => $data->{l_reservedate},
167
                priority        => $data->{priority},
168
                firstname       => $data->{firstname} || '',
169
                surname         => $data->{surname},
170
                title           => $data->{title},
171
                subtitle        => $data->{subtitle},
172
                author          => $data->{author},
173
                borrowernumber  => $data->{borrowernumber},
174
                itemnum         => $data->{itemnumber},
175
                phone           => $data->{phone},
176
                email           => $data->{email},
177
                biblionumber    => $data->{biblionumber},
178
                statusw         => ( $data->{found} eq "W" ),
179
                statusf         => ( $data->{found} eq "F" ),
180
                holdingbranches => [split('\|', $data->{l_holdingbranch})],,
181
                branch          => $data->{l_branch},
182
                itemcallnumber  => $data->{l_itemcallnumber},
183
                enumchron       => $data->{l_enumchron},
184
                copyno          => $data->{l_copynumber},
185
                notificationdate=> $data->{notificationdate},
186
                reminderdate    => $data->{reminderdate},
187
                count           => $data->{icount},
188
                rcount          => $data->{rcount},
189
                pullcount       => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount},
190
                itypes          => [split('\|', $data->{l_itype})],
191
                locations       => [split('\|', $data->{l_location})],
192
            }
193
        );
194
    }
149
    }
195
    $sth->finish;
150
    push(
151
        @reservedata, {
152
            reservedate     => $data->{l_reservedate},
153
            firstname       => $data->{firstname} || '',
154
            surname         => $data->{surname},
155
            title           => $data->{title},
156
            subtitle        => $data->{subtitle},
157
            author          => $data->{author},
158
            borrowernumber  => $data->{borrowernumber},
159
            biblionumber    => $data->{biblionumber},
160
            holdingbranches => [split('\|', $data->{l_holdingbranch})],
161
            branch          => $data->{l_branch},
162
            itemcallnumber  => $data->{l_itemcallnumber},
163
            enumchron       => $data->{l_enumchron},
164
            copyno          => $data->{l_copynumber},
165
            count           => $data->{icount},
166
            rcount          => $data->{rcount},
167
            pullcount       => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount},
168
            itypes          => [split('\|', $data->{l_itype})],
169
            locations       => [split('\|', $data->{l_location})],
170
        }
171
    );
196
}
172
}
173
$sth->finish;
197
174
198
$template->param(
175
$template->param(
199
    todaysdate          => $today,
176
    todaysdate          => $today,
200
    from                => $startdate,
177
    from                => $startdate,
201
    to                  => $enddate,
178
    to                  => $enddate,
202
    run_report          => $run_report,
203
    reserveloop         => \@reservedata,
179
    reserveloop         => \@reservedata,
204
    "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
180
    "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
205
    HoldsToPullStartDate => C4::Context->preference('HoldsToPullStartDate') || PULL_INTERVAL,
181
    HoldsToPullStartDate => C4::Context->preference('HoldsToPullStartDate') || PULL_INTERVAL,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt (-5 / +1 lines)
Lines 85-92 $(document).ready(function() { Link Here
85
    <div id="yui-main">
85
    <div id="yui-main">
86
    <div class="yui-b">
86
    <div class="yui-b">
87
87
88
<h2>Holds to pull[% IF ( run_report ) %] placed between [% from | $KohaDates %] and [% to | $KohaDates %][% END %]</h2>
88
<h2>Holds to pull placed between [% from | $KohaDates %] and [% to | $KohaDates %]</h2>
89
[% IF ( run_report ) %]
90
<h3>Reported on [% todaysdate | $KohaDates %]</h3>
89
<h3>Reported on [% todaysdate | $KohaDates %]</h3>
91
<p>The following holds have not been filled. Please retrieve them and check them in.</p>
90
<p>The following holds have not been filled. Please retrieve them and check them in.</p>
92
<div class="searchresults">
91
<div class="searchresults">
Lines 149-155 $(document).ready(function() { Link Here
149
        </td>
148
        </td>
150
        <td>
149
        <td>
151
            <span title="[% reserveloo.reservedate %]">[% reserveloo.reservedate | $KohaDates %] in [% Branches.GetName ( reserveloo.branch ) %]</span>
150
            <span title="[% reserveloo.reservedate %]">[% reserveloo.reservedate | $KohaDates %] in [% Branches.GetName ( reserveloo.branch ) %]</span>
152
            [% IF ( reserveloo.statusw ) %]<p>Waiting</p>[% END %][% IF ( reserveloo.statusf ) %]<p>Fulfilled</p>[% END %]
153
        </td>
151
        </td>
154
        </tr>
152
        </tr>
155
        [% END %]
153
        [% END %]
Lines 175-181 $(document).ready(function() { Link Here
175
        <b>No items found.</b>
173
        <b>No items found.</b>
176
    [% END %]
174
    [% END %]
177
</div>
175
</div>
178
[% END %]
179
176
180
</div>
177
</div>
181
</div>
178
</div>
182
- 

Return to bug 18079