Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add some nicer data representations

Signed-off-by: trebor8x <trobbe@online.de>
  • Loading branch information...
commit 2ac0effef7cf2b4d09d40d4f877f3227f3f41a90 1 parent cc6b390
@grobie grobie authored committed
View
10 app/models/doc.rb
@@ -1,8 +1,8 @@
class Doc < StoredFile
- set_table_name "stored_files"
- has_attachment :content_type => 'application/msword',
- :max_size => 3.megabytes,
- :storage => :file_system
+ set_table_name "stored_files"
+ has_attachment :content_type => 'application/msword',
+ :max_size => 3.megabytes,
+ :storage => :file_system
- validates_as_attachment
+ validates_as_attachment
end
View
43 app/views/customers/index.html.erb
@@ -1,26 +1,27 @@
<h2 class="head">Kundenliste</h2>
<div id="list">
- <table>
- <tr>
- <th>Kundennummer</th>
- <th>Firmenname</th>
- <th>Telefonnummer</th>
- <th>Email</th>
- <th>Kontaktname</th>
- </tr>
+ <table>
+ <tr>
+ <th>#</th>
+ <th>Firmenname</th>
+ <th>Kontaktname</th>
+ <th>Email</th>
+ <th>Telefonnummer</th>
+ <th colspan="3"></th>
+ </tr>
- <% for customer in @customers %>
- <tr class="<%= cycle('list-line-odd', 'list-line-even') %>">
- <td><%=h customer.customer_num %></td>
- <td><%=h customer.company_name %></td>
- <td><%=h customer.tel_number %></td>
- <td><%=h customer.email %></td>
- <td><%=h customer.full_name %></td>
- <td><%= link_to 'Zeigen', customer %></td>
- <td><%= link_to 'Bearbeiten', edit_customer_path(customer) %></td>
- <td><%= link_to 'Löschen', customer, :confirm => 'Sind Sie sicher?', :method => :delete %></td>
- </tr>
- <% end %>
- </table>
+ <% for customer in @customers %>
+ <tr class="<%= cycle('list-line-odd', 'list-line-even') %>">
+ <td><%=h customer.customer_num %></td>
+ <td><%=h customer.company_name %></td>
+ <td><%=h customer.full_name %></td>
+ <td><%= mail_to customer.email %></td>
+ <td><%=h customer.tel_number %></td>
+ <td><%= link_to 'Zeigen', customer %></td>
+ <td><%= link_to 'Bearbeiten', edit_customer_path(customer) %></td>
+ <td><%= link_to 'Löschen', customer, :confirm => 'Sind Sie sicher?', :method => :delete %></td>
+ </tr>
+ <% end %>
+ </table>
</div>
View
134 app/views/customers/show.html.erb
@@ -1,82 +1,58 @@
<h2 class="head">Kontaktdaten</h2>
<div id="list">
- <p>
- <b>Kundennummer:</b>
- <%=h @customer.customer_num %>
- </p>
-
- <p>
- <b>Firmenname:</b>
- <%=h @customer.company_name %>
- </p>
-
- <p>
- <b>Staat:</b>
- <%=h @customer.state %>
- </p>
-
- <p>
- <b>Stadt:</b>
- <%=h @customer.city %>
- </p>
-
- <p>
- <b>Postleitzahl:</b>
- <%=h @customer.zipcode %>
- </p>
-
- <p>
- <b>Straße:</b>
- <%=h @customer.street %>
- </p>
-
- <p>
- <b>Telefonnummer:</b>
- <%=h @customer.tel_number %>
- </p>
-
- <p>
- <b>Email:</b>
- <%=h @customer.email %>
- </p>
-
- <p>
- <b>Web:</b>
- <%=h @customer.web %>
- </p>
-
- <p>
- <b>Kontaktname:</b>
- <%=h @customer.full_name %>
- </p>
-
- <%= link_to 'Bearbeiten', edit_customer_path(@customer) %> |
- <%= link_to 'Zurück', customers_path %>
-
- <br /><br />
- <div id="list">
- <h3>Rechnungsliste:</h2>
- <table>
- <tr>
- <th>Rechnungsnummer</th>
- <th>Rechnungssumme</th>
- <th>Rechnungsdatum</th>
- <th>Pdf</th>
- <th>Doc</th>
- </tr>
-
- <% for invoice in @customer.invoices %>
- <tr class="<%= cycle('list-line-odd', 'list-line-even') %>">
- <td><%=h invoice.invoice_num %></td>
- <td><%=h invoice.sum %></td>
- <td><%=h invoice.date %></td>
- <td><%if invoice.pdf%><%= link_to image_tag("acroread.png"), invoice.pdf.public_filename %><%end%></td>
- <td><%if invoice.doc%><%= link_to image_tag("word.png"), invoice.doc.public_filename%><%end%></td>
- <td><%= link_to 'Zeigen', invoice %></td>
- <td><%= link_to 'Bearbeiten', edit_invoice_path(invoice) %></td>
- <td><%= link_to 'Löschen', invoice, :confirm => 'Sind Sie sicher?', :method => :delete %></td>
- </tr>
- <% end %>
- </table>
- </div>
+ <p>
+ <b>Kundennummer:</b>
+ <%=h @customer.customer_num %>
+ </p>
+
+ <p>
+ <b>Firmenname:</b>
+ <%=h @customer.company_name %>
+ </p>
+
+ <p>
+ <b>Staat:</b>
+ <%=h @customer.state %>
+ </p>
+
+ <p>
+ <b>Stadt:</b>
+ <%=h @customer.city %>
+ </p>
+
+ <p>
+ <b>Postleitzahl:</b>
+ <%=h @customer.zipcode %>
+ </p>
+
+ <p>
+ <b>Straße:</b>
+ <%=h @customer.street %>
+ </p>
+
+ <p>
+ <b>Telefonnummer:</b>
+ <%=h @customer.tel_number %>
+ </p>
+
+ <p>
+ <b>Email:</b>
+ <%=h @customer.email %>
+ </p>
+
+ <p>
+ <b>Web:</b>
+ <%=h @customer.web %>
+ </p>
+
+ <p>
+ <b>Kontaktname:</b>
+ <%=h @customer.full_name %>
+ </p>
+
+ <%= link_to 'Bearbeiten', edit_customer_path(@customer) %> |
+ <%= link_to 'Zurück', customers_path %>
+
+ <br /><br />
+ <%= render :partial => "invoices/invoices", :object => @customer.invoices %>
</div>
View
23 app/views/invoices/_invoices.html.erb
@@ -0,0 +1,23 @@
+<table>
+ <tr>
+ <th class="right">#</th>
+ <th>Firmenname</th>
+ <th>Rechnungssumme</th>
+ <th>Rechnungsdatum</th>
+ <th>Pdf</th>
+ <th>Doc</th>
+ </tr>
+ <%- for invoice in invoices -%>
+ <tr class="<%= cycle('list-line-odd', 'list-line-even') %>">
+ <td class="right"><%= h invoice.invoice_num %></td>
+ <td class="right"><%= link_to invoice.customer.company_name, customer_url(invoice.customer) %></td>
+ <td class="right"><%= number_to_currency_with_euro(invoice.sum) %></td>
+ <td class="right"><%= l invoice.date, :format => :long %></td>
+ <td><% if invoice.pdf%><%= link_to image_tag("acroread.png"), invoice.pdf.public_filename %><% end %></td>
+ <td><% if invoice.doc%><%= link_to image_tag("word.png"), invoice.doc.public_filename%><% end %></td>
+ <td><%= link_to 'Zeigen', invoice %></td>
+ <td><%= link_to 'Bearbeiten', edit_invoice_path(invoice) %></td>
+ <td><%= link_to 'Löschen', invoice, :confirm => 'Sind Sie sicher?', :method => :delete %></td>
+ </tr>
+ <%- end -%>
+</table>
View
2  app/views/invoices/edit.html.erb
@@ -9,7 +9,7 @@
</p>
<p>
<%= f.label :date, 'Rechnungsdatum' %><br />
- <%= f.text_field :date %>
+ <%= f.date_select :date %>
</p>
<p>
<%= f.label :customer_id, 'Kundenummer' %><br />
View
25 app/views/invoices/index.html.erb
@@ -1,27 +1,4 @@
<h2 class="head">Rechnungsliste</h2>
<div id="list">
- <table>
- <tr>
- <th>Rechnungsnummer</th>
- <th>Firmenname</th>
- <th>Rechnungssumme</th>
- <th>Rechnungsdatum</th>
- <th>Pdf</th>
- <th>Doc</th>
- </tr>
-
- <% for invoice in @invoices %>
- <tr class="<%= cycle('list-line-odd', 'list-line-even') %>">
- <td><%=h invoice.invoice_num %></td>
- <td><%= link_to invoice.customer.company_name, customer_url(invoice.customer) %></td>
- <td><%=h invoice.sum %></td>
- <td><%=h invoice.date %></td>
- <td><%if invoice.pdf%><%= link_to image_tag("acroread.png"), invoice.pdf.public_filename %><%end%></td>
- <td><%if invoice.doc%><%= link_to image_tag("word.png"), invoice.doc.public_filename%><%end%></td>
- <td><%= link_to 'Zeigen', invoice %></td>
- <td><%= link_to 'Bearbeiten', edit_invoice_path(invoice) %></td>
- <td><%= link_to 'Löschen', invoice, :confirm => 'Sind Sie sicher?', :method => :delete %></td>
- </tr>
- <% end %>
- </table>
+ <%= render :partial => "invoices" %>
</div>
View
4 app/views/invoices/show.html.erb
@@ -7,7 +7,7 @@
<p>
<b>Rechnungsdatum:</b>
- <%= h @invoice.date %>
+ <%= l @invoice.date, :format => :long %>
</p>
<p>
<b>Kundennummer:</b>
@@ -15,7 +15,7 @@
</p>
<p>
<b>Rechnungssumme:</b>
- <%= h @invoice.sum %>
+ <%= number_to_currency_with_euro @invoice.sum %>
</p>
<p>
<b>Rechnung-Pdf:</b>
View
16 config/initializers/number_to_currency_euro.rb
@@ -0,0 +1,16 @@
+module ActionView
+ module Helpers
+ module NumberHelper
+ def number_to_currency_with_euro(number, options = {})
+ defaults = {
+ :unit => "&euro;", #obvious
+ :precision => 2, #digits after separator
+ :separator => ",",
+ :delimiter => ".", #thousands delimiter
+ :format => "%n %u" } #put a space between number (%n) and unit (%u) and unit is after number
+ s = number_to_currency_without_euro(number, defaults.merge(options))
+ end
+ alias_method_chain :number_to_currency, :euro
+ end
+ end
+end
View
5 public/stylesheets/invoice.css
@@ -166,6 +166,7 @@ a:hover {
#list table {
border-collapse: collapse;
+ width: 100%;
}
#list table tr th {
@@ -178,6 +179,10 @@ a:hover {
vertical-align: middle;
}
+#list table tr .right {
+ text-align: right;
+}
+
#list .list-line-even {
background-color: #CCDDFF;
}
Please sign in to comment.
Something went wrong with that request. Please try again.