Commit 143c86e5 authored by Sara Kuqi's avatar Sara Kuqi
Browse files

pdf user_name, login_button size, tables width

parent 05cfc6ca
......@@ -66,14 +66,16 @@ class SamplesController < ApplicationController
def show
if operator?
@sample = Sample.find(params[:id])
@user = @sample && @sample.user
else
@sample = current_user.samples.find(params[:id])
@user = @sample && @sample.user
end
respond_to do |format|
format.html
format.js
format.pdf do
pdf = SamplePdf.new(@sample,operator?)
pdf = SamplePdf.new(@sample,operator?,@user)
send_data pdf.render, filename: "sample_#{@sample.id}.pdf",
type:"application/pdf",
disposition: "inline"
......@@ -102,6 +104,7 @@ class SamplesController < ApplicationController
if sample.status == "submitted"
sample.status = "measured"
sample.save
@operator = current_user.id
end
UserMailer.delay.measured_email(@user,sample)
redirect_to request.referer + "?display_sample=#{sample.id}"
......
require "prawn/table"
class SamplePdf < Prawn::Document
def initialize(sample,with_results=false)
def initialize(sample,with_results=false,user)
super(top_margin: 50)
@user = user
@sample = sample
@with_results = with_results
text "id: \ #{@sample.id}
text "name: \ #{@user.name}
id: \ #{@sample.id}
name: \ #{@sample.name}
formula:\ #{@sample.formula}
status: \ #{@sample.status}", size: 15, style: :bold
move_down 20
table(table_data,width: bounds.width)
......@@ -52,7 +55,7 @@ class SamplePdf < Prawn::Document
other = 100 - total
other.abs.round(2)
total += other
output += ["%.2f" %other, total]
output += ["%.2f" %other, "%.2f" %total]
end
def res(result)
......
......@@ -28,7 +28,7 @@
</ul>
</li>
<% else %>
<li><%= link_to "Login", login_path ,{:class => "glyphicon glyphicon-log-in glyphicon-bold"}%></li>
<li style="font-size:20px"><%= link_to "Login", login_path ,{:class => "glyphicon glyphicon-log-in glyphicon-bold"}%></li>
<% end %>
</ul>
</div>
......
<% provide(:title, "Forgot password") %>
<div style="margin: 0px 0px 0px 150px">
<h1>Forgot password</h1>
<p>Enter your email address below and we'll send you password reset instructions.</p><hr>
<div class="row">
<div class="col-md-6 col-md-offset-3">
......
......@@ -13,24 +13,24 @@
<div class="col-sm-11">
<table class="table table-bordered" id = "myTable" style="margin-left:20px">
<table class="table table-bordered" id = "myTable" style="margin-left:20px;">
<thead>
<tr>
<th>ELEMENTS:</th>
<th style=" border-bottom:1pt solid black;">ELEMENTS:</th>
<% Sample::PREDEF_ELEMENTS.each do |k| %>
<th><%= k %></th>
<th style=" border-bottom:1pt solid black;"><%= k %></th>
<%end if @sample.calculation%>
<th>Other</th>
<th style=" border-bottom:1pt solid black;">Other</th>
<% (@sample.calculation.keys-Sample::PREDEF_ELEMENTS).each do|k| %>
<th><%= k %></th>
<%end if @sample.calculation%>
</tr>
</thead>
<tbody id= "resultTable">
<tr>
<td>Expected:</td>
<tr style=" border:1pt solid black;">
<td style=" border:1pt solid black;">Expected:</td>
<% Sample::PREDEF_ELEMENTS.each do |k| %>
<td> <%= "%.2f" % (@sample.calculation[k] || 0) %></td>
<td style=" border:1pt solid black;"> <%= "%.2f" % (@sample.calculation[k] || 0) %></td>
<%end if @sample.calculation %>
<%sum,i=0,0 %>
......@@ -43,7 +43,7 @@
<%end%>
<%end%>
<% s = 100 - sum %>
<td><%=s.abs.round(2)%></td>
<td style=" border:1pt solid black;"><%=s.abs.round(2)%></td>
<% (@sample.calculation.keys-Sample::PREDEF_ELEMENTS).each do|k| %>
<td> <%= "%.2f" % @sample.calculation[k] %></td>
......
......@@ -14,7 +14,7 @@ $(document).ready(function() {
});
});
</script>
<table id="tab_logic" class="table table-bordered table-hover table-width" style="margin-top:30px" >
<table id="tab_logic" class="table table-bordered table-hover table-width" style="margin-top:30px;margin-left:25px;width:95%" >
<thead>
<tr>
<th class="text-center">ID</th>
......@@ -67,7 +67,7 @@ $(document).ready(function() {
});
});
</script>
<table class="table table-bordered table-hover table-width" id = "myTable" style="margin-top:50px">
<table class="table table-bordered table-hover", id = "myTable", style="margin-top:50px;margin-left:25px;width:95%">
<thead>
<tr>
<th>ELEMENTS:</th>
......@@ -79,22 +79,22 @@ $(document).ready(function() {
</tr>
</thead>
<tbody >
<tr>
<td>Expected:</td>
<tr style="border:1pt solid black;">
<td style=" border:1pt solid black;">Expected:</td>
<%sum,i=0,0 %>
<%@sample.formatted_calculation.each_pair do |k,v| %>
<%if i<4 %>
<td><%= "%.2f" %v %>
<td style=" border:1pt solid black;"><%= "%.2f" %v %>
<% sum=sum.to_f+v.to_f %>
</td>
<%i=i+1%>
<%end%>
<%end if @sample.calculation %>
<% s = 100 - sum %>
<td><%=s.abs.round(2)%></td>
<td style=" border:1pt solid black;"><%= "%.2f" % s.abs.round(2)%></td>
<% sum = sum + s%>
<td><%= "%.2f" %sum %></td>
</tr>
<td style=" border:1pt solid black;"><%= "%.2f" %sum %></td>
</tr>
<%if (operator? && (@sample.status=='submitted'|| @sample.status=='measured')) || (!operator? && @sample.status=='measured')%>
<%sum2=0;i=1 %>
<% @sample.results.each do |result| %>
......@@ -114,7 +114,7 @@ $(document).ready(function() {
<%end if result.measurement %>
<% i = i+1 %>
<td></td>
<td><%= sum2%></td>
<td><%= "%.2f" % sum2.round(2)%></td>
<%sum2=0%>
</tr>
<tr>
......
......@@ -7,6 +7,6 @@
<%= f.label :Formula %>
<%= f.text_field :formula, class: 'form-control' %>
</fieldset>
<%= f.submit "Create Sample", class: "btn btn-success", style: "width:120px" %>
<%= f.submit "Create Sample", class: "btn btn-success", style: "width:120px;margin-bottom: 8px;" %>
<% end %>
</div>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment