Lines 81-87
my $sql = '
Link Here
|
81 |
borrowernumber, |
81 |
borrowernumber, |
82 |
surname, |
82 |
surname, |
83 |
firstname, |
83 |
firstname, |
84 |
cardnumber |
84 |
cardnumber, |
|
|
85 |
|
86 |
DATEDIFF( issuedate, CURRENT_DATE() ) AS not_issued_today |
85 |
FROM issues |
87 |
FROM issues |
86 |
LEFT JOIN items USING ( itemnumber ) |
88 |
LEFT JOIN items USING ( itemnumber ) |
87 |
LEFT JOIN biblio USING ( biblionumber ) |
89 |
LEFT JOIN biblio USING ( biblionumber ) |
Lines 95-101
if ( @borrowernumber == 1 ) {
Link Here
|
95 |
$sql .= '= ?'; |
97 |
$sql .= '= ?'; |
96 |
} |
98 |
} |
97 |
else { |
99 |
else { |
98 |
$sql = ' IN (' . join( ',', ('?') x @borrowernumber ) . ') '; |
100 |
$sql .= ' IN (' . join( ',', ('?') x @borrowernumber ) . ') '; |
99 |
} |
101 |
} |
100 |
push( @parameters, @borrowernumber ); |
102 |
push( @parameters, @borrowernumber ); |
101 |
|
103 |
|
Lines 103-113
$sql .= " ORDER BY $sorting_column $sorting_direction ";
Link Here
|
103 |
|
105 |
|
104 |
my $dbh = C4::Context->dbh(); |
106 |
my $dbh = C4::Context->dbh(); |
105 |
my $sth = $dbh->prepare($sql); |
107 |
my $sth = $dbh->prepare($sql); |
106 |
$sth->execute( @parameters ); |
108 |
$sth->execute(@parameters); |
107 |
|
109 |
|
108 |
my $item_level_itypes = C4::Context->preference('item-level_itypes'); |
110 |
my $item_level_itypes = C4::Context->preference('item-level_itypes'); |
109 |
|
111 |
|
110 |
my @checkouts; |
112 |
my @checkouts_today; |
|
|
113 |
my @checkouts_previous; |
111 |
while ( my $c = $sth->fetchrow_hashref() ) { |
114 |
while ( my $c = $sth->fetchrow_hashref() ) { |
112 |
my ($charge) = GetIssuingCharges( $c->{itemnumber}, $c->{borrowernumber} ); |
115 |
my ($charge) = GetIssuingCharges( $c->{itemnumber}, $c->{borrowernumber} ); |
113 |
|
116 |
|
Lines 116-165
while ( my $c = $sth->fetchrow_hashref() ) {
Link Here
|
116 |
|
119 |
|
117 |
my ( $renewals_count, $renewals_allowed, $renewals_remaining ) = |
120 |
my ( $renewals_count, $renewals_allowed, $renewals_remaining ) = |
118 |
GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} ); |
121 |
GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} ); |
119 |
push( |
122 |
|
120 |
@checkouts, |
123 |
my $checkout = { |
121 |
{ |
124 |
DT_RowId => $c->{itemnumber} . '-' . $c->{borrowernumber}, |
122 |
DT_RowId => $c->{itemnumber} . '-' . $c->{borrowernumber}, |
125 |
title => $c->{title}, |
123 |
title => $c->{title}, |
126 |
author => $c->{author}, |
124 |
author => $c->{author}, |
127 |
barcode => $c->{barcode}, |
125 |
barcode => $c->{barcode}, |
128 |
itemtype => $item_level_itypes ? $c->{itype} : $c->{itemtype}, |
126 |
itemtype => $item_level_itypes ? $c->{itype} : $c->{itemtype}, |
129 |
itemnotes => $c->{itemnotes}, |
127 |
itemnotes => $c->{itemnotes}, |
130 |
branchcode => $c->{branchcode}, |
128 |
branchcode => $c->{branchcode}, |
131 |
branchname => $c->{branchname}, |
129 |
branchname => $c->{branchname}, |
132 |
itemcallnumber => $c->{itemcallnumber} || q{}, |
130 |
itemcallnumber => $c->{itemcallnumber} || q{}, |
133 |
charge => $charge, |
131 |
charge => $charge, |
134 |
price => $c->{replacementprice} || q{}, |
132 |
price => $c->{replacementprice} || q{}, |
135 |
can_renew => $can_renew, |
133 |
can_renew => $can_renew, |
136 |
can_renew_error => $can_renew_error, |
134 |
can_renew_error => $can_renew_error, |
137 |
itemnumber => $c->{itemnumber}, |
135 |
itemnumber => $c->{itemnumber}, |
138 |
borrowernumber => $c->{borrowernumber}, |
136 |
borrowernumber => $c->{borrowernumber}, |
139 |
biblionumber => $c->{biblionumber}, |
137 |
biblionumber => $c->{biblionumber}, |
140 |
issuedate => $c->{issuedate}, |
138 |
issuedate => $c->{issuedate}, |
141 |
date_due => $c->{date_due}, |
139 |
date_due => $c->{date_due}, |
142 |
renewals_count => $renewals_count, |
140 |
renewals_count => $renewals_count, |
143 |
renewals_allowed => $renewals_allowed, |
141 |
renewals_allowed => $renewals_allowed, |
144 |
renewals_remaining => $renewals_remaining, |
142 |
renewals_remaining => $renewals_remaining, |
145 |
issuedate_formatted => output_pref( |
143 |
issuedate_formatted => |
146 |
{ |
144 |
output_pref( dt_from_string( $c->{issuedate} ) ), |
147 |
dt => dt_from_string( $c->{issuedate} ), |
145 |
date_due_formatted => |
148 |
as_due_date => 1 |
146 |
output_pref_due( dt_from_string( $c->{date_due} ) ), |
149 |
} |
147 |
subtitle => GetRecordValue( |
150 |
), |
148 |
'subtitle', |
151 |
date_due_formatted => output_pref( |
149 |
GetMarcBiblio( $c->{biblionumber} ), |
152 |
{ |
150 |
GetFrameworkCode( $c->{biblionumber} ) |
153 |
dt => dt_from_string( $c->{date_due} ), |
151 |
), |
154 |
as_due_date => 1 |
152 |
borrower => { |
|
|
153 |
surname => $c->{surname}, |
154 |
firstname => $c->{firstname}, |
155 |
cardnumber => $c->{cardnumber}, |
156 |
} |
155 |
} |
157 |
} |
156 |
), |
158 |
); |
157 |
subtitle => GetRecordValue( |
|
|
158 |
'subtitle', |
159 |
GetMarcBiblio( $c->{biblionumber} ), |
160 |
GetFrameworkCode( $c->{biblionumber} ) |
161 |
), |
162 |
borrower => { |
163 |
surname => $c->{surname}, |
164 |
firstname => $c->{firstname}, |
165 |
cardnumber => $c->{cardnumber}, |
166 |
}, |
167 |
issued_today => !$c->{not_issued_today}, |
168 |
}; |
169 |
|
170 |
if ( $c->{not_issued_today} ) { |
171 |
push( @checkouts_previous, $checkout ); |
172 |
} |
173 |
else { |
174 |
push( @checkouts_today, $checkout ); |
175 |
} |
159 |
} |
176 |
} |
160 |
|
177 |
|
|
|
178 |
@checkouts_today = reverse(@checkouts_today) |
179 |
if ( C4::Context->preference('todaysIssuesDefaultSortOrder') eq 'desc' ); |
180 |
@checkouts_previous = reverse(@checkouts_previous) |
181 |
if ( C4::Context->preference('previousIssuesDefaultSortOrder') eq 'desc' ); |
182 |
|
183 |
my @checkouts = ( @checkouts_today, @checkouts_previous ); |
184 |
|
161 |
my $data; |
185 |
my $data; |
162 |
$data->{'iTotalRecords'} = scalar @checkouts; #FIXME |
186 |
$data->{'iTotalRecords'} = scalar @checkouts; |
163 |
$data->{'iTotalDisplayRecords'} = scalar @checkouts; |
187 |
$data->{'iTotalDisplayRecords'} = scalar @checkouts; |
164 |
$data->{'sEcho'} = $input->param('sEcho') || undef; |
188 |
$data->{'sEcho'} = $input->param('sEcho') || undef; |
165 |
$data->{'aaData'} = \@checkouts; |
189 |
$data->{'aaData'} = \@checkouts; |