|
Lines 103-139
elsif ( $op eq 'list' ) {
Link Here
|
| 103 |
); |
103 |
); |
| 104 |
|
104 |
|
| 105 |
my @new_due_dates; |
105 |
my @new_due_dates; |
|
|
106 |
my @checkouts; |
| 107 |
|
| 106 |
while ( my $checkout = $checkouts->next ) { |
108 |
while ( my $checkout = $checkouts->next ) { |
|
|
109 |
my $updated_checkout = $checkout->get_from_storage; |
| 107 |
if ($preview_results) { |
110 |
if ($preview_results) { |
| 108 |
push( |
111 |
if ( $new_hard_due_date ) { |
| 109 |
@new_due_dates, |
112 |
$updated_checkout->shift_due_date({ hard_due_date => $new_hard_due_date }); |
| 110 |
output_pref( |
113 |
} |
| 111 |
{ |
114 |
else { |
| 112 |
dt => calc_new_due_date( |
115 |
$updated_checkout->shift_due_date({ days => $due_date_days }); |
| 113 |
{ |
116 |
} |
| 114 |
due_date => |
|
|
| 115 |
dt_from_string( $checkout->date_due ), |
| 116 |
new_hard_due_date => $new_hard_due_date, |
| 117 |
add_days => $due_date_days |
| 118 |
} |
| 119 |
), |
| 120 |
dateformat => 'iso' |
| 121 |
} |
| 122 |
) |
| 123 |
); |
| 124 |
} else { |
117 |
} else { |
| 125 |
push( @issue_ids, $checkout->id ); |
118 |
push( @issue_ids, $checkout->id ); |
| 126 |
} |
119 |
} |
|
|
120 |
|
| 121 |
push @checkouts, { current => $checkout, updated => $updated_checkout }; |
| 127 |
} |
122 |
} |
| 128 |
|
123 |
|
| 129 |
if ( $preview_results ) { |
124 |
if ( $preview_results ) { |
| 130 |
$template->param( |
125 |
$template->param( |
| 131 |
checkouts => $checkouts, |
126 |
checkouts => \@checkouts, |
| 132 |
new_hard_due_date => $new_hard_due_date |
127 |
new_hard_due_date => $new_hard_due_date |
| 133 |
? dt_from_string($new_hard_due_date) |
128 |
? dt_from_string($new_hard_due_date) |
| 134 |
: undef, |
129 |
: undef, |
| 135 |
due_date_days => $due_date_days, |
130 |
due_date_days => $due_date_days, |
| 136 |
new_due_dates => \@new_due_dates, |
|
|
| 137 |
view => 'list', |
131 |
view => 'list', |
| 138 |
); |
132 |
); |
| 139 |
} else { |
133 |
} else { |
|
Lines 151-197
if ( $op eq 'modify' ) {
Link Here
|
| 151 |
@issue_ids = $input->multi_param('issue_id') unless @issue_ids; |
145 |
@issue_ids = $input->multi_param('issue_id') unless @issue_ids; |
| 152 |
|
146 |
|
| 153 |
$new_hard_due_date &&= dt_from_string($new_hard_due_date); |
147 |
$new_hard_due_date &&= dt_from_string($new_hard_due_date); |
| 154 |
my $checkouts = |
148 |
my @checkouts; |
| 155 |
Koha::Checkouts->search( { issue_id => { -in => \@issue_ids } } ); |
149 |
my $checkouts = Koha::Checkouts->search( { issue_id => { -in => \@issue_ids } } ); |
| 156 |
while ( my $checkout = $checkouts->next ) { |
150 |
while ( my $checkout = $checkouts->next ) { |
| 157 |
my $new_due_date = calc_new_due_date( |
|
|
| 158 |
{ |
| 159 |
due_date => dt_from_string($checkout->date_due), |
| 160 |
new_hard_due_date => $new_hard_due_date, |
| 161 |
add_days => $due_date_days |
| 162 |
} |
| 163 |
); |
| 164 |
|
151 |
|
| 165 |
# Update checkout's due date |
152 |
# Update checkout's due date |
| 166 |
$checkout->date_due($new_due_date)->store; |
153 |
if ( $new_hard_due_date ) { |
|
|
154 |
$checkout->shift_due_date({ hard_due_date => $new_hard_due_date }); |
| 155 |
} |
| 156 |
else { |
| 157 |
$checkout->shift_due_date({ days => $due_date_days }); |
| 158 |
} |
| 167 |
|
159 |
|
| 168 |
# Update items.onloan |
160 |
# Update items.onloan |
| 169 |
$checkout->item->onloan($new_due_date)->store; |
161 |
$checkout->item->onloan($checkout->date_due)->store; |
|
|
162 |
|
| 163 |
push @checkouts, $checkout; |
| 170 |
} |
164 |
} |
| 171 |
|
165 |
|
| 172 |
$template->param( |
166 |
$template->param( |
| 173 |
view => 'report', |
167 |
view => 'report', |
| 174 |
checkouts => $checkouts, |
168 |
checkouts => \@checkouts, |
| 175 |
); |
169 |
); |
| 176 |
} |
170 |
} |
| 177 |
|
171 |
|
| 178 |
sub calc_new_due_date { |
|
|
| 179 |
my ($params) = @_; |
| 180 |
my $due_date = $params->{due_date}; |
| 181 |
my $new_hard_due_date = $params->{new_hard_due_date}; |
| 182 |
my $add_days = $params->{add_days}; |
| 183 |
|
| 184 |
my $new; |
| 185 |
if ( $new_hard_due_date ) { |
| 186 |
$new = $new_hard_due_date->clone->set( |
| 187 |
hour => $due_date->hour, |
| 188 |
minute => $due_date->minute, |
| 189 |
second => $due_date->second, |
| 190 |
) |
| 191 |
} else { |
| 192 |
$new = $due_date->clone->add( days => $add_days ); |
| 193 |
} |
| 194 |
return $new; |
| 195 |
} |
| 196 |
|
| 197 |
output_html_with_http_headers $input, $cookie, $template->output; |
172 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 198 |
- |
173 |
|
|
|
174 |
1; |