Reversed order of door log, added date column

This commit is contained in:
Will Bradley 2012-09-15 22:52:17 -07:00
parent d73ea31625
commit daa202131c
3 changed files with 14 additions and 11 deletions

View File

@ -5,7 +5,7 @@ class DoorLogsController < ApplicationController
# GET /door_logs
# GET /door_logs.json
def index
@door_logs = DoorLog.all
@door_logs = DoorLog.find(:all, :order => "created_at DESC")
respond_to do |format|
format.html # index.html.erb

View File

@ -7,6 +7,7 @@ class UsersController < ApplicationController
def index
#@users = User.all
#authorize! :read, @users
@users = @users.sort_by{|e| e[:card_id]}
respond_to do |format|
format.html # index.html.erb

View File

@ -3,6 +3,7 @@
<%= link_to 'Download Door Logs', download_path %>
<table>
<tr>
<th>Date</th>
<th>Key</th>
<th>Data</th>
<th></th>
@ -10,28 +11,29 @@
<th></th>
</tr>
<% @modulo_tmp = nil %>
<% @divided_tmp = nil %>
<% @door_logs.each do |door_log| %>
<tr>
<td><%= door_log.created_at %></td>
<td><%= door_log.key %></td>
<td><%= door_log.data %></td>
<%
if door_log.key == 'R' || door_log.key == 'D' ||door_log.key == 'G'
@modulo_tmp = door_log.data.to_i
elsif (door_log.key == 'r' || door_log.key == 'd' || door_log.key == 'g') && !@modulo_tmp.nil? %>
if door_log.key == 'r' || door_log.key == 'd' ||door_log.key == 'g'
@divided_tmp = door_log.data.to_i
elsif (door_log.key == 'R' || door_log.key == 'D' || door_log.key == 'G') && !@divided_tmp.nil? %>
<td>
<%= case door_log.key
when 'r'
when 'R'
"Read"
when 'd'
when 'D'
"Denied"
when 'g'
when 'G'
"Granted"
end %>
<%= "Card: "+(@modulo_tmp+(door_log.data.to_i*32767)).to_s(16) %>
<%= "Card: "+(door_log.data.to_i+(@divided_tmp*32767)).to_s(16) %>
</td>
<% else
@modulo_tmp = nil
@divided_tmp = nil
end %>
</tr>
<% end %>