Lines 25-31
use CGI;
Link Here
|
25 |
use C4::Auth qw( get_template_and_user ); |
25 |
use C4::Auth qw( get_template_and_user ); |
26 |
use C4::Output qw( output_html_with_http_headers ); |
26 |
use C4::Output qw( output_html_with_http_headers ); |
27 |
use Koha::Checkouts; |
27 |
use Koha::Checkouts; |
28 |
use Koha::DateUtils qw( dt_from_string ); |
28 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
29 |
|
29 |
|
30 |
my $input = new CGI; |
30 |
my $input = new CGI; |
31 |
my $op = $input->param('op') // q|form|; |
31 |
my $op = $input->param('op') // q|form|; |
Lines 52-57
elsif ( $op eq 'list' ) {
Link Here
|
52 |
my $new_hard_due_date = $input->param('new_hard_due_date'); |
52 |
my $new_hard_due_date = $input->param('new_hard_due_date'); |
53 |
my $due_date_days = $input->param('due_date_days'); |
53 |
my $due_date_days = $input->param('due_date_days'); |
54 |
|
54 |
|
|
|
55 |
$new_hard_due_date &&= dt_from_string($new_hard_due_date); |
56 |
|
55 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
57 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
56 |
my $search_params; |
58 |
my $search_params; |
57 |
if (@categorycodes) { |
59 |
if (@categorycodes) { |
Lines 99-110
elsif ( $op eq 'list' ) {
Link Here
|
99 |
); |
101 |
); |
100 |
|
102 |
|
101 |
my @new_due_dates; |
103 |
my @new_due_dates; |
102 |
if ( not $new_hard_due_date && $due_date_days ) { |
104 |
while ( my $checkout = $checkouts->next ) { |
103 |
while ( my $checkout = $checkouts->next ) { |
105 |
push @new_due_dates, |
104 |
my $due_date = dt_from_string( $checkout->date_due ); |
106 |
output_pref({ dt => calc_new_due_date( |
105 |
push @new_due_dates, $due_date->add( days => $due_date_days ); |
107 |
{ |
106 |
} |
108 |
due_date => dt_from_string($checkout->date_due), |
|
|
109 |
new_hard_due_date => $new_hard_due_date, |
110 |
add_days => $due_date_days |
111 |
} |
112 |
), dateformat => 'iso' }); |
107 |
} |
113 |
} |
|
|
114 |
|
108 |
$template->param( |
115 |
$template->param( |
109 |
checkouts => $checkouts, |
116 |
checkouts => $checkouts, |
110 |
new_hard_due_date => $new_hard_due_date |
117 |
new_hard_due_date => $new_hard_due_date |
Lines 126-133
elsif ( $op eq 'modify' ) {
Link Here
|
126 |
my $checkouts = |
133 |
my $checkouts = |
127 |
Koha::Checkouts->search( { issue_id => { -in => \@issue_ids } } ); |
134 |
Koha::Checkouts->search( { issue_id => { -in => \@issue_ids } } ); |
128 |
while ( my $checkout = $checkouts->next ) { |
135 |
while ( my $checkout = $checkouts->next ) { |
129 |
my $new_due_date = $new_hard_due_date |
136 |
my $new_due_date = calc_new_due_date( |
130 |
|| dt_from_string( $checkout->date_due )->add( days => $due_date_days ); |
137 |
{ |
|
|
138 |
due_date => dt_from_string($checkout->date_due), |
139 |
new_hard_due_date => $new_hard_due_date, |
140 |
add_days => $due_date_days |
141 |
} |
142 |
); |
131 |
|
143 |
|
132 |
# Update checkout's due date |
144 |
# Update checkout's due date |
133 |
$checkout->date_due($new_due_date)->store; |
145 |
$checkout->date_due($new_due_date)->store; |
Lines 142-145
elsif ( $op eq 'modify' ) {
Link Here
|
142 |
); |
154 |
); |
143 |
} |
155 |
} |
144 |
|
156 |
|
|
|
157 |
sub calc_new_due_date { |
158 |
my ($params) = @_; |
159 |
my $due_date = $params->{due_date}; |
160 |
my $new_hard_due_date = $params->{new_hard_due_date}; |
161 |
my $add_days = $params->{add_days}; |
162 |
|
163 |
my $new; |
164 |
if ( $new_hard_due_date ) { |
165 |
$new = $new_hard_due_date->clone->set( |
166 |
hour => $due_date->hour, |
167 |
minute => $due_date->minute, |
168 |
second => $due_date->second, |
169 |
) |
170 |
} else { |
171 |
$new = $due_date->clone->add( days => $add_days ); |
172 |
} |
173 |
return $new; |
174 |
} |
175 |
|
145 |
output_html_with_http_headers $input, $cookie, $template->output; |
176 |
output_html_with_http_headers $input, $cookie, $template->output; |
146 |
- |
|
|