-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
53 changed files
with
1,428 additions
and
443 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 |
---|---|---|
|
@@ -27,5 +27,5 @@ config/settings/server.conf | |
|
||
dump.rdb | ||
|
||
public/uploads/ | ||
public/uploads/**/* | ||
public/tmp/ |
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
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
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,7 @@ | ||
// Place all the behaviors and hooks related to the matching controller here. | ||
// All this logic will automatically be available in application.js. | ||
jQuery(document).ready(function($) { | ||
$('table').DataTable({ | ||
paging: false | ||
}); | ||
}); |
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,87 @@ | ||
# Controller for lobbytrack report | ||
class LobbytrackReportsController < ApplicationController | ||
load_and_authorize_resource | ||
|
||
def index | ||
@lobbytrack_reports = LobbytrackReport.new | ||
end | ||
|
||
def visits | ||
id = params[:lobbytrack_report][:visit_id] | ||
begin | ||
@lobbytrack_reports = LobbytrackReport.query_visits(id) | ||
rescue TinyTds::Error => e | ||
flash[:error] = e | ||
end | ||
|
||
return if @lobbytrack_reports&.any? | ||
|
||
if Settings.lobbytrack_ips.include?(client_ip.to_s) | ||
flash[:error] = 'You cannot access Lobbytrack from the current client IP address' | ||
elsif id | ||
flash[:warning] = "There is no attendance history for id #{id}" | ||
end | ||
redirect_to lobbytrack_reports_path | ||
end | ||
|
||
def checkins | ||
id = params[:lobbytrack_report][:checkin_id] | ||
|
||
begin | ||
@lobbytrack_reports = LobbytrackReport.query_checkins(id) | ||
rescue TinyTds::Error => e | ||
flash[:error] = e | ||
end | ||
|
||
return if @lobbytrack_reports&.any? | ||
|
||
if Settings.lobbytrack_ips.include?(client_ip.to_s) | ||
flash[:error] = 'You cannot access Lobbytrack from the current client IP address' | ||
elsif id | ||
flash[:warning] = "There is no attendance history for id #{id}" | ||
end | ||
redirect_to lobbytrack_reports_path | ||
end | ||
|
||
def visit_dates | ||
date1 = params[:lobbytrack_report][:visit_date1] | ||
date2 = params[:lobbytrack_report][:visit_date2] | ||
@dates = "#{date1} to #{date2}" | ||
|
||
begin | ||
@lobbytrack_reports = LobbytrackReport.query_visit_dates(date1, date2) | ||
rescue TinyTds::Error => e | ||
flash[:error] = e | ||
end | ||
|
||
return if @lobbytrack_reports&.any? | ||
|
||
if Settings.lobbytrack_ips.include?(client_ip.to_s) | ||
flash[:error] = 'You cannot access Lobbytrack from the current client IP address' | ||
elsif @dates | ||
flash[:warning] = "There is no attendance history between the dates #{@dates}" | ||
end | ||
redirect_to lobbytrack_reports_path | ||
end | ||
|
||
def checkin_dates | ||
date1 = params[:lobbytrack_report][:checkin_date1] | ||
date2 = params[:lobbytrack_report][:checkin_date2] | ||
@dates = "#{date1} to #{date2}" | ||
|
||
begin | ||
@lobbytrack_reports = LobbytrackReport.query_checkin_dates(date1, date2) | ||
rescue TinyTds::Error => e | ||
flash[:error] = e | ||
end | ||
|
||
return if @lobbytrack_reports&.any? | ||
|
||
if Settings.lobbytrack_ips.include?(client_ip.to_s) | ||
flash[:error] = 'You cannot access Lobbytrack from the current client IP address' | ||
elsif @dates | ||
flash[:warning] = "There is no attendance history between the dates #{@dates}" | ||
end | ||
redirect_to lobbytrack_reports_path | ||
end | ||
end |
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,53 @@ | ||
# Class to connect to Lobbytrack | ||
class LobbytrackReport | ||
include ActiveModel::Model | ||
|
||
attr_accessor :visit_id, :checkin_id, :visit_date1, :visit_date2, :checkin_date1, :checkin_date2 | ||
require 'tiny_tds' | ||
|
||
def self.client | ||
TinyTds::Client.new username: Settings.lobbytrack_user, password: Settings.lobbytrack_password, | ||
host: Settings.lobbytrack_host, port: Settings.lobbytrack_port, | ||
database: Settings.lobbytrack_db, login_timeout: 5 | ||
end | ||
|
||
def self.query_visits(visit_id) | ||
client.active? ? client.execute(visits(visit_id)).each : client.close | ||
end | ||
|
||
def self.query_visit_dates(date1, date2) | ||
client.active? ? client.execute(visits_for_dates(date1, date2)).each : client.close | ||
end | ||
|
||
def self.query_checkins(visit_id) | ||
client.active? ? client.execute(checkins(visit_id)).each : client.close | ||
end | ||
|
||
def self.query_checkin_dates(date1, date2) | ||
client.active? ? client.execute(checkins_for_dates(date1, date2)).each : client.close | ||
end | ||
|
||
def self.visits(id) | ||
'SELECT CardHolderID, DateIn, ReportField1, ReportField2, LookupField1' \ | ||
' FROM Jolly.dbo.logAttendance' \ | ||
" WHERE CardHolderID = '#{id}'" | ||
end | ||
|
||
def self.visits_for_dates(date1, date2) | ||
'SELECT CardHolderID, DateIn, ReportField1, ReportField2, LookupField1' \ | ||
' FROM Jolly.dbo.logAttendance' \ | ||
" WHERE DateIn between '#{date1} 00:00:00' and '#{date2} 23:59:59'" | ||
end | ||
|
||
def self.checkins(id) | ||
'SELECT CardHolderID, DateOfEvent, ReportField1, ReportField2, LookupField1' \ | ||
' FROM Jolly.dbo.logPerson' \ | ||
" WHERE CardHolderID = '#{id}'" | ||
end | ||
|
||
def self.checkins_for_dates(date1, date2) | ||
'SELECT CardHolderID, DateOfEvent, ReportField1, ReportField2, LookupField1' \ | ||
' FROM Jolly.dbo.logPerson' \ | ||
" WHERE DateOfEvent between '#{date1} 00:00:00' and '#{date2} 23:59:59'" | ||
end | ||
end |
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
Oops, something went wrong.