# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+use Modern::Perl;
+
use Mojo::Base 'Mojolicious::Controller';
use Koha::Illrequests;
use Koha::Libraries;
use Koha::Patrons;
use Koha::Libraries;
+use Koha::DateUtils qw( format_sqldatetime );
=head1 NAME
my $c = shift->openapi->valid_input or return;
my $args = $c->req->params->to_hash // {};
+ my $output = [];
+ my @format_dates = ( 'placed', 'updated', 'completed' );
# Create a hash where all keys are embedded values
# Enables easy checking
foreach my $req(@requests) {
my $to_push = $req->unblessed;
$to_push->{id_prefix} = $req->id_prefix;
+ # Create new "formatted" columns for each date column
+ # that needs formatting
+ foreach my $field(@format_dates) {
+ if (defined $to_push->{$field}) {
+ $to_push->{$field . "_formatted"} = format_sqldatetime(
+ $to_push->{$field},
+ undef,
+ undef,
+ 1
+ );
+ }
+ }
+
foreach my $p(@{$patron_arr}) {
if ($p->{borrowernumber} == $req->borrowernumber) {
$to_push->{patron} = {
- firstname => $p->{firstname},
- surname => $p->{surname},
- cardnumber => $p->{cardnumber}
+ patron_id => $p->{borrowernumber},
+ firstname => $p->{firstname},
+ surname => $p->{surname},
+ cardnumber => $p->{cardnumber}
};
last;
}
if ($embed{comments}) {
$to_push->{comments} = $req->illcomments->count;
}
+ if ($embed{status_alias}) {
+ $to_push->{status_alias} = $req->statusalias;
+ }
push @output, $to_push;
}