Skip to content

Commit

Permalink
Merge pull request #56 from dhanasingh/dev
Browse files Browse the repository at this point in the history
v2.2
  • Loading branch information
dhineshrajasekar authored Jun 22, 2016
2 parents fae5c3e + 8c710d8 commit 54befb9
Show file tree
Hide file tree
Showing 56 changed files with 1,339 additions and 660 deletions.
24 changes: 17 additions & 7 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,24 @@ If an apache passenger module is used then make sure the following settings are
b) RailsAppSpawnerIdleTime 0
c) PassengerPreStart http://rails-app-url/

Release Notes for 2.1.2
Release Notes for 2.2
Features:
- Made compatible with Redmine 3.2.1.
- User filter introduced in Attendance tab.
- Previous and Next link added in attendance detail page.
- Group filter introduced in Reports tab.
- Made compatible with Redmine 3.2.2.
- Clock-in and clock-out widget in all pages.
- Pagination in the report popup.
- Allow TE Admin to Delete entry in attendance.
- Hide Expense, Attendance and Reports modules.
- Configuration for Min/Max hours per week.
- Configuration for non submission mails to group of users.
Bugs:
- Fixed decimals not taken into account when registering expenses.

- Fixed Does not support other language Issue Id Validation Message.
- Fixed Log Time : Approved/submitted sheet don't allow time entry through edit issue screen.
- Fixed Show 'No record to display' if there is no record in attendance report.
- Fixed Mobile web compatibility.
- Fixed Min Hours Per Day : validation for Min Hours is less then Max Hours.
- Fixed Expense total does not show correctly in Deleted Projects.
- Fixed last day of the month not shown in the attendance report.
- Fixed Does not save expense amount greater then 100000.
Customization:
For any Customization/Support, please contact us, our consulting team will be happy to help you

Expand All @@ -99,6 +108,7 @@ Customization:
Here are the Customizations we have done for our clients:
1. Monthly Calendar - Puny Human
2. Supervisor Approvals - Fotonation
3. Hide Modules and Limit Non Submission Mail - Lyra Network

Please provide your rating at http://www.redmine.org/plugins/wk-time

Expand Down
11 changes: 8 additions & 3 deletions app/controllers/wkattendance_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class WkattendanceController < ApplicationController
class WkattendanceController < WkbaseController
unloadable

include WktimeHelper
Expand All @@ -11,6 +11,9 @@ def index
@status = params[:status] || 1
@groups = Group.all.sort
sqlStr = ""
if !findLastAttnEntry.blank?
@lastAttnEntry = findLastAttnEntry[0]
end
lastMonthStartDt = Date.civil(Date.today.year, Date.today.month, 1) << 1
if(Setting.plugin_redmine_wktime['wktime_leave'].blank?)
sqlStr = " select u.id as user_id, u.firstname, u.lastname, u.status, -1 as issue_id from users u where u.type = 'User' "
Expand All @@ -35,6 +38,9 @@ def index
end

def edit
if !findLastAttnEntry.blank?
@lastAttnEntry = findLastAttnEntry[0]
end
sqlStr = getQueryStr + " where i.id in (#{getLeaveIssueIds}) and u.type = 'User' and u.id = #{params[:user_id]} order by i.subject"
@leave_details = WkUserLeave.find_by_sql(sqlStr)
render :action => 'edit'
Expand Down Expand Up @@ -202,6 +208,5 @@ def formPaginationCondition
rangeStr = " LIMIT " + @limit.to_s + " OFFSET " + @offset.to_s
end
rangeStr
end

end
end
87 changes: 87 additions & 0 deletions app/controllers/wkbase_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
class WkbaseController < ApplicationController
unloadable

def findLastAttnEntry
WkAttendance.find_by_sql("select a.* from wk_attendances a inner join ( select max(start_time) as start_time,user_id from wk_attendances where user_id = #{User.current.id} group by user_id ) vw on a.start_time = vw.start_time and a.user_id = vw.user_id order by a.start_time ")
end

def updateClockInOut
if !findLastAttnEntry.blank?
@lastAttnEntry = findLastAttnEntry[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
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

def computeWorkedHours(startTime,endTime, ishours)
currentEntryDate = startTime.localtime
workedHours = endTime-startTime
if !Setting.plugin_redmine_wktime['wktime_break_time'].blank?
Setting.plugin_redmine_wktime['wktime_break_time'].each_with_index do |element,index|
listboxArr = element.split('|')
breakStart = currentEntryDate.change({ hour: listboxArr[0], min:listboxArr[1], sec: '00' })
breakEnd = currentEntryDate.change({ hour: listboxArr[2], min:listboxArr[3], sec: '00' })
if(!(startTime>breakEnd || endTime < breakStart))
if startTime < breakStart
if endTime < breakEnd
workedHours = workedHours - (endTime-breakStart)
else
workedHours = workedHours - (breakEnd-breakStart)
end
else
if endTime > breakEnd
workedHours = workedHours - (breakEnd-startTime)
else
workedHours = nil
end
end
end
end
end
if ishours
workedHours = (workedHours/1.hour).round(2) unless workedHours.blank?
end
workedHours
end

def totalhours
dateStr = getConvertDateStr('start_time')
(WkAttendance.where("user_id = #{User.current.id} and #{dateStr} = '#{Time.now.strftime("%Y-%m-%d")}'").sum(:hours)).round(2)
end
end
7 changes: 7 additions & 0 deletions app/controllers/wkexpense_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ def textfield_size
def showClockInOut
false
end
def maxHourPerWeek
0
end

def minHourPerWeek
0
end
private
def getSpecificField
"amount"
Expand Down
62 changes: 56 additions & 6 deletions app/controllers/wkreport_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class WkreportController < ApplicationController
class WkreportController < WkbaseController
unloadable

include WktimeHelper
Expand All @@ -10,6 +10,9 @@ class WkreportController < ApplicationController

def index
@groups = Group.sorted.all
if !findLastAttnEntry.blank?
@lastAttnEntry = findLastAttnEntry[0]
end
if params[:searchlist].blank? && session[:wkreport].nil?
session[:wkreport] = {:group_id => params[:group_id]}
elsif params[:searchlist] =='wkreport'
Expand All @@ -18,9 +21,21 @@ def index
retrieve_date_range
if params[:report_type] == 'attendance_report'
reportattn
elsif params[:report_type] == 'time_report'
time_rpt
#redirect_to :action => 'time_rpt', :controller => 'wktime'
end
end

def time_rpt
#@user = User.current
#@startday = getStartDay(Date.today)
#@entries = findEntries()

#render :action => 'time_rpt', :controller => 'wktime', :layout => false
redirect_to :action => 'time_rpt', :controller => 'wktime'
end

def reportattn
if !params[:group_id].blank?
group_id = params[:group_id]
Expand All @@ -44,12 +59,13 @@ def reportattn
end
if isAccountUser
leave_entry = TimeEntry.where("issue_id in (#{getLeaveIssueIds}) and spent_on between '#{@from}' and '#{@to}'")
sqlStr = "select user_id,#{dateStr} as spent_on,sum(hours) as hours from wk_attendances where start_time between '#{@from}' and '#{@to}' group by user_id,#{dateStr}"
sqlStr = "select user_id,#{dateStr} as spent_on,sum(hours) as hours from wk_attendances where #{dateStr} between '#{@from}' and '#{@to}' group by user_id,#{dateStr}"
else
leave_entry = TimeEntry.where("issue_id in (#{getLeaveIssueIds}) and spent_on between '#{@from}' and '#{@to}' and user_id = #{User.current.id} " )
sqlStr = "select user_id,#{dateStr} as spent_on,sum(hours) as hours from wk_attendances where start_time between '#{@from}' and '#{@to}' and user_id = #{User.current.id} group by user_id,#{dateStr}"
sqlStr = "select user_id,#{dateStr} as spent_on,sum(hours) as hours from wk_attendances where #{dateStr} between '#{@from}' and '#{@to}' and user_id = #{User.current.id} group by user_id,#{dateStr}"
end
@userlist = User.find_by_sql(userSqlStr)
findBySql(userSqlStr)
#@userlist = User.find_by_sql(userSqlStr)
leave_data = WkUserLeave.find_by_sql(leaveSql)
daily_entries = WkAttendance.find_by_sql(sqlStr)
@attendance_entries = Hash.new
Expand Down Expand Up @@ -89,7 +105,8 @@ def getUserQueryStr(group_id)
if !isAccountUser
queryStr = queryStr + " and u.id = #{User.current.id} "
end
queryStr = queryStr + " order by u.created_on"
#queryStr = queryStr + " order by u.created_on"
queryStr
end

def getReportLeaveIssueIds
Expand Down Expand Up @@ -155,6 +172,39 @@ def retrieve_date_range

end

def findBySql(query)
result = WkUserLeave.find_by_sql("select count(*) as id from (" + query + ") as v2")
@entry_count = result.blank? ? 0 : result[0].id
setLimitAndOffset()
rangeStr = formPaginationCondition()
@userlist = WkUserLeave.find_by_sql(query + " order by u.created_on " + rangeStr )
end

def formPaginationCondition
rangeStr = ""
if ActiveRecord::Base.connection.adapter_name == 'SQLServer'
rangeStr = " OFFSET " + @offset.to_s + " ROWS FETCH NEXT " + @limit.to_s + " ROWS ONLY "
else
rangeStr = " LIMIT " + @limit.to_s + " OFFSET " + @offset.to_s
end
rangeStr
end

def setLimitAndOffset
if api_request?
@offset, @limit = api_offset_and_limit
if !params[:limit].blank?
@limit = params[:limit]
end
if !params[:offset].blank?
@offset = params[:offset]
end
else
@entry_pages = Paginator.new @entry_count, per_page_option, params['page']
@limit = @entry_pages.per_page
@offset = @entry_pages.offset
end
end
def check_perm_and_redirect
unless check_permission
render_403
Expand All @@ -166,6 +216,6 @@ def check_permission
ret = false
ret = params[:user_id].to_i == User.current.id
return (ret || isAccountUser)
end
end

end
57 changes: 41 additions & 16 deletions app/controllers/wktime_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class WktimeController < ApplicationController
class WktimeController < WkbaseController
unloadable

include WktimeHelper
Expand Down Expand Up @@ -37,6 +37,9 @@ def index
status = session[:wktimes][:status]
userfilter = getValidUserCF(session[:wktimes][:filters], user_custom_fields)
end
if !findLastAttnEntry.blank?
@lastAttnEntry = findLastAttnEntry[0]
end

unless userfilter.blank? || @query.blank?
@query.filters = userfilter
Expand Down Expand Up @@ -97,7 +100,9 @@ def edit
@editable = false if @locked
set_edit_time_logs
@entries = findEntries()
@wkattendances = findAttnEntries()
if !findLastAttnEntry.blank?
@lastAttnEntry = findLastAttnEntry[0]
end
if !$tempEntries.blank?
newEntries = $tempEntries - @entries
if !newEntries.blank?
Expand Down Expand Up @@ -376,6 +381,9 @@ def destroy

def new
set_user_projects
if !findLastAttnEntry.blank?
@lastAttnEntry = findLastAttnEntry[0]
end
@selected_project = getSelectedProject(@manage_projects, true)
# get the startday for current week
@startday = getStartDay(Date.today)
Expand Down Expand Up @@ -889,7 +897,12 @@ def updateAttendance
ret += ','
count = 1
end
wkattendance.save()
#wkattendance.save()
if(((wkattendance.start_time.localtime).to_formatted_s(:time)).to_s == "00:00" && ((wkattendance.end_time.localtime).to_formatted_s(:time)).to_s == "00:00" && wkattendance.id != nil)
wkattendance.destroy()
else
wkattendance.save()
end
end until count == 1
ret += wkattendance.id.to_s
ret += ','
Expand All @@ -902,12 +915,7 @@ def updateAttendance
end
end

def showClockInOut
!Setting.plugin_redmine_wktime['wktime_enable_clock_in_out'].blank? &&
Setting.plugin_redmine_wktime['wktime_enable_clock_in_out'].to_i == 1
end

def multipleClockInOut
def findAttnEntries
dateStr = getConvertDateStr('start_time')
WkAttendance.where(" user_id = '#{params[:user_id]}' and #{dateStr} between '#{@startday}' and '#{@startday + 6}' ").order("start_time")
end
Expand All @@ -930,6 +938,29 @@ def getTotalBreakTime
totalBT
end

def time_rpt
@user = User.current
@startday = getStartDay(Date.today)
@entries = findEntries()

render :action => 'time_rpt', :layout => false
end

def showClockInOut
(!Setting.plugin_redmine_wktime['wktime_enable_clock_in_out'].blank? &&
Setting.plugin_redmine_wktime['wktime_enable_clock_in_out'].to_i == 1) && (!Setting.plugin_redmine_wktime['wktime_enable_attendance_module'].blank? && Setting.plugin_redmine_wktime['wktime_enable_attendance_module'].to_i == 1 )
end

def maxHourPerWeek
Setting.plugin_redmine_wktime['wktime_restr_max_hour_week'].to_i == 1 ?
(Setting.plugin_redmine_wktime['wktime_max_hour_week'].blank? ? 0 : Setting.plugin_redmine_wktime['wktime_max_hour_week']) : 0
end

def minHourPerWeek
Setting.plugin_redmine_wktime['wktime_restr_min_hour_week'].to_i == 1 ?
(Setting.plugin_redmine_wktime['wktime_min_hour_week'].blank? ? 0 : Setting.plugin_redmine_wktime['wktime_min_hour_week']) : 0
end

private

def getManager(user, approver)
Expand Down Expand Up @@ -1264,13 +1295,7 @@ def findEntries
setup
cond = getCondition('spent_on', @user.id, @startday, @startday+6)
findEntriesByCond(cond)
end

def findAttnEntries
dateStr = getConvertDateStr('start_time')
dateOrder = getConvertDateStr('end_time')
WkAttendance.find_by_sql("select a.* from wk_attendances a inner join ( select max(start_time) as start_time,user_id from wk_attendances where #{dateStr} between '#{@startday}' and '#{@startday+6}' and user_id = #{params[:user_id]} group by #{dateStr},user_id ) vw on a.start_time = vw.start_time and a.user_id = vw.user_id order by a.start_time ")
end
end

def findWkTE(start_date, end_date=nil)
setup
Expand Down
Loading

0 comments on commit 54befb9

Please sign in to comment.