added template export module
authorLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Wed, 17 Jun 2020 20:43:05 +0000 (16:43 -0400)
committerLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Tue, 17 Aug 2021 13:49:09 +0000 (09:49 -0400)
(cherry picked from commit 7cc07bad7b5d258e5dd8462eee39049d1a8484ef)

Open-ILS/src/perlmods/lib/OpenILS/Application/Reporter.pm

index 81964ab..b4182d7 100644 (file)
@@ -246,6 +246,23 @@ sub retrieve_template {
     return $t;
 }
 
+__PACKAGE__->register_method(
+    api_name => 'open-ils.reporter.template.export',
+    method => 'sql_export');
+sub sql_export {
+    my( $self, $conn, $auth, $id ) = @_;
+    my $e = new_rstore_editor(authtoken=>$auth);
+    return $e->die_event unless $e->checkauth;
+    return $e->die_event unless $e->allowed('RUN_REPORTS');
+    my $b = OpenILS::Reporter::SQLBuilder->new;
+    my $t = $e->retrieve_reporter_template($id)
+       or return $e->event;
+    # where are the params going to come from?
+       #   my $report_data = OpenSRF::Utils::JSON->JSON2perl( $t->{report}->{data} );
+       #   $b->register_params( $report_data );
+       $rs = $b->parse_report( OpenSRF::Utils::JSON->JSON2perl( $t->{data} ) );
+    return $rs->toSQL;
+}
 
 __PACKAGE__->register_method(
     api_name => 'open-ils.reporter.report.retrieve',
@@ -616,8 +633,6 @@ sub has_output {
     return 0;
 }
 
-
-
 __PACKAGE__->register_method(
     method => 'org_full_path',
     api_name => 'open-ils.reporter.org_unit.full_path');