-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from dhanasingh/dev
v2.3
- Loading branch information
Showing
48 changed files
with
1,438 additions
and
345 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
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 |
---|---|---|
@@ -1,49 +1,18 @@ | ||
class WkbaseController < ApplicationController | ||
unloadable | ||
unloadable | ||
include WkattendanceHelper | ||
|
||
|
||
|
||
def updateClockInOut | ||
if !findLastAttnEntry.blank? | ||
@lastAttnEntry = findLastAttnEntry[0] | ||
lastAttnEntries = findLastAttnEntry(true) | ||
if !lastAttnEntries.blank? | ||
@lastAttnEntry = lastAttnEntries[0] | ||
end | ||
currentDate = (DateTime.parse params[:startdate]) | ||
if params[:str] != "start" #&& isAccountUser | ||
entrydate = @lastAttnEntry.start_time | ||
start_local = entrydate.localtime | ||
if ((Date.parse params[:startdate]) != @lastAttnEntry.start_time.to_date) | ||
endtime = start_local.change({ hour: "23:59".to_time.strftime("%H"), min: "23:59".to_time.strftime("%M"), sec: '59' }) | ||
addNewAttendance | ||
else | ||
endtime = start_local.change({ hour: currentDate.to_time.strftime("%H"), min:currentDate.to_time.strftime("%M"), sec: currentDate.to_time.strftime("%S") }) | ||
end | ||
@lastAttnEntry.end_time = endtime | ||
@lastAttnEntry.hours = computeWorkedHours(@lastAttnEntry.start_time,@lastAttnEntry.end_time, true) | ||
@lastAttnEntry.save() | ||
else | ||
addNewAttendance | ||
end | ||
entryTime = Time.parse("#{currentDate.to_date.to_s} #{currentDate.utc.to_time.to_s} ").localtime | ||
@lastAttnEntry = saveAttendance(@lastAttnEntry, entryTime, nil, User.current.id, false) | ||
ret = 'done' | ||
respond_to do |format| | ||
format.text { render :text => ret } | ||
end | ||
end | ||
|
||
def addNewAttendance | ||
wkattendance = WkAttendance.new | ||
currentDate = DateTime.parse params[:startdate] | ||
entrydate = Date.parse params[:startdate] | ||
wkattendance.user_id = params[:user_id].to_i | ||
if params[:str] != "start" | ||
wkattendance.start_time = Time.parse("#{entrydate.to_s} 00:00:00 ").localtime.to_s | ||
wkattendance.end_time = currentDate | ||
endtime = currentDate | ||
wkattendance.hours = computeWorkedHours(wkattendance.start_time,wkattendance.end_time, true) | ||
else | ||
wkattendance.start_time = currentDate | ||
endtime = nil | ||
end | ||
wkattendance.user_id = User.current.id | ||
wkattendance.save() | ||
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,29 @@ | ||
class WkimportattendanceController < WkattendanceController | ||
unloadable | ||
|
||
include WkimportattendanceHelper | ||
|
||
before_filter :require_login | ||
require 'csv' | ||
|
||
def new | ||
end | ||
|
||
def show | ||
file = params[:file] | ||
unless file.blank? | ||
filePath = file.path | ||
begin | ||
isSuccess = importAttendance(filePath, false) | ||
#redirect_to :action => 'show' | ||
rescue Exception => e | ||
@errorMsg = "Import failed: #{e.message}" | ||
flash[:error] = @errorMsg | ||
redirect_to :action => 'new' | ||
end | ||
else | ||
redirect_to :action => 'new' | ||
end | ||
end | ||
|
||
end |
Oops, something went wrong.