-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2bd7e5
commit 465aaaf
Showing
3 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ class ReportGenerator < Sinatra::Base | |
|
||
post '/kif/?' do | ||
@kif_info = JSON.parse(params["data"]) | ||
generate_pdf | ||
generate_pdf('reports/kif-report-template.html') | ||
Pony.mail(:to => @kif_info["email"], | ||
:from => '[email protected]', | ||
:subject => 'hi', | ||
|
@@ -19,8 +19,20 @@ class ReportGenerator < Sinatra::Base | |
status 200 | ||
end | ||
|
||
def generate_pdf | ||
kit = PDFKit.new(erb :'reports/kif-report-template.html') | ||
post '/kuf/?' do | ||
@kuf_info = JSON.parse(params["data"]) | ||
generate_pdf('reports/kuf-report-template.html') | ||
Pony.mail(:to => @kuf_info["email"], | ||
:from => '[email protected]', | ||
:subject => 'hi', | ||
:body => "Hello there. It is #{DateTime.now}. Enjoy your KUF report.", | ||
:attachments => {"KUF_report_#{DateTime.now}.pdf" => File.read(@file)}) | ||
|
||
status 200 | ||
end | ||
|
||
def generate_pdf(pdf_path) | ||
kit = PDFKit.new(erb pdf_path.to_sym) | ||
kit.stylesheets << 'views/reports/css/bootstrap-theme.min.css' | ||
kit.stylesheets << 'views/reports/css/bootstrap.min.css' | ||
kit.stylesheets << 'views/reports/css/style.css' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<title>Report</title> | ||
|
||
<meta name="description" content="Source code generated using layoutit.com"> | ||
<meta name="author" content="LayoutIt!"> | ||
|
||
<link href="css/bootstrap.min.css" rel="stylesheet"> | ||
<link href="css/style.css" rel="stylesheet"> | ||
|
||
</head> | ||
<body> | ||
|
||
<div class="container-fluid"> | ||
<div class="row"> | ||
<div class="col-md-offset-1 col-md-4"> | ||
<address> | ||
<strong>Report date:</strong> <%= Date.today %> | ||
<br> | ||
<strong>Report requester:</strong> <%= @kuf_info["email"] %> | ||
<br> | ||
<strong>Requester company:</strong> <%= @kuf_info["company"]["name"] %> | ||
</address> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-2"> | ||
</div> | ||
<div class="col-md-8"> | ||
<table class="table table-bordered table-striped"> | ||
<thead> | ||
<tr> | ||
<th> | ||
Number | ||
</th> | ||
<th> | ||
Payment Amount | ||
</th> | ||
<th> | ||
Remaining Amount | ||
</th> | ||
<th> | ||
Issuance Date | ||
</th> | ||
<th> | ||
Circulation Date | ||
</th> | ||
<th> | ||
Payment Deadline | ||
</th> | ||
<th> | ||
Business Partner | ||
</th> | ||
<th> | ||
Financial Year | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @kuf_info["info"].each do |kif| %> | ||
<tr> | ||
<td> | ||
<%= kif["number"] %> | ||
</td> | ||
<td> | ||
<%= kif["payment_amount"] %> | ||
</td> | ||
<td> | ||
<%= kif["remaining_amount"] %> | ||
</td> | ||
<td> | ||
<%= kif["issuance_date"] %> | ||
</td> | ||
<td> | ||
<%= kif["circulation_date"] %> | ||
</td> | ||
<td> | ||
<%= kif["payment_deadline"] %> | ||
</td> | ||
<td> | ||
<%= kif["business_partner"]["name"] %> | ||
</td> | ||
<td> | ||
<%= kif["financial_year"]["year"] %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
|
||
</tbody> | ||
</table> | ||
</div> | ||
<div class="col-md-2"> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-7"> </div> | ||
<div class="col-md-4"> | ||
<p> | ||
_________________________________ | ||
</p> | ||
<p> | ||
On date: <%= Date.today %> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |