Skip to content

Commit

Permalink
Merge pull request #27 from dhanasingh/dev
Browse files Browse the repository at this point in the history
1.9
  • Loading branch information
suganya-thulasiraman committed Jul 1, 2015
2 parents 3694425 + 6291504 commit 5c586fc
Show file tree
Hide file tree
Showing 33 changed files with 916 additions and 296 deletions.
20 changes: 16 additions & 4 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The following configurations can be made on the plugin
- Allow User filtering to My Issues
- Public holidays can be configured
- 'Approve time log' permission
- T&E Admin groups can be configured

The Time & Expense sheets can be approved/rejected by supervisors after it is submitted by Project Members.
Here is the workflow of Approval system..
Expand Down Expand Up @@ -72,9 +73,20 @@ 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 1.8.1
Release Notes for 1.9
Features:
- Support for code hooks
- Filters will be remembered in list page.
- Permission changes
-- The project member with 'Edit time logs' can edit other member time/expense sheet with his permission.
- TE Admin users is introduced
- Empty time/expense sheet can be viewed.
- Sorting of timesheet rows.
- Allow entering time in different format.
- Non empty icon if detail time entry popup has no values.
- Comment box size increased.
- Name is shown for closed or inactive project, issue and activity.

Bugs:
- Error message is shown if issue is blank when "Allow blank issue" is OFF.
- Closed date is considered instead of updated date for closed issues.

Please provide your review at http://www.redmine.org/plugins/wk-time
Please provide your rating at http://www.redmine.org/plugins/wk-time
47 changes: 32 additions & 15 deletions app/controllers/wkexpense_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def showWorktimeHeader
false
end

def enterCustomFieldInRow(row)
false
end

def maxHour
0
end
Expand Down Expand Up @@ -111,6 +115,9 @@ def deleteEntry
end
end

def textfield_size
6
end
private
def getSpecificField
"amount"
Expand All @@ -120,33 +127,42 @@ def getEntityNames
["#{Wkexpense.table_name}", "#{WkExpenseEntry.table_name}"]
end

def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr)
spField = getSpecificField()
result = WkExpenseEntry.find_by_sql("select count(*) as id from (" + selectStr + sqlStr + wkSqlStr + ") as v2")
@entry_count = result[0].id
def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids)
spField = getSpecificField()
dtRangeForUsrSqlStr = "(" + getAllWeekSql(@from, @to) + ") tmp1"
teSqlStr = "(" + wkSelectStr + " ,exp.currency" + sqlStr + " inner join wk_expense_entries exp on v1.id = exp.id " + wkSqlStr + ") tmp2"
query = "select tmp3.user_id, tmp3.spent_on, tmp3.#{spField}, tmp3.status, tmp3.status_updater, tmp3.created_on, tmp3.currency from (select tmp1.id as user_id, tmp1.created_on, tmp1.selected_date as spent_on, " +
"case when tmp2.#{spField} is null then 0 else tmp2.#{spField} end as #{spField}, " +
"case when tmp2.status is null then 'e' else tmp2.status end as status, tmp2.currency, tmp2.status_updater from "
query = query + dtRangeForUsrSqlStr + " left join " + teSqlStr
query = query + " on tmp1.id = tmp2.user_id and tmp1.selected_date = tmp2.spent_on where tmp1.id in (#{ids}) ) tmp3 "
query = query + " left outer join (select min( #{getDateSqlString('t.spent_on')} ) as min_spent_on, t.user_id as usrid from wk_expense_entries t, users u "
query = query + " where u.id = t.user_id and u.id in (#{ids}) group by t.user_id ) vw on vw.usrid = tmp3.user_id "
query = query + getWhereCond(status)
query = query + " order by tmp3.spent_on desc, tmp3.user_id "

result = WkExpenseEntry.find_by_sql("select count(*) as id from (" + query + ") as v2")
@entry_count = result[0].id
setLimitAndOffset()
rangeStr = formPaginationCondition()

@entries = WkExpenseEntry.find_by_sql(wkSelectStr + " ,exp.currency" + sqlStr +
" inner join wk_expense_entries exp on v1.id = exp.id " + wkSqlStr + rangeStr)

@entries = WkExpenseEntry.find_by_sql(query + rangeStr)
@unit = @entries.blank? ? l('number.currency.format.unit') : @entries[0][:currency]

#@total_hours = TimeEntry.visible.sum(:hours, :include => [:user], :conditions => cond.conditions).to_f

result = WkExpenseEntry.find_by_sql("select sum(v2." + spField + ") as " + spField + " from (" + selectStr + sqlStr + wkSqlStr +") as v2")
result = WkExpenseEntry.find_by_sql("select sum(v2." + spField + ") as " + spField + " from (" + query + ") as v2")
@total_hours = result[0].amount
end

def getTEAllTimeRange(ids)
teQuery = "select #{getDateSqlString('t.spent_on')} as startday " +
"from wk_expense_entries t where user_id in (#{ids}) group by startday order by startday"
teResult = WkExpenseEntry.find_by_sql(teQuery)
end

def findWkTEByCond(cond)
#@wktimes = Wkexpense.find(:all, :conditions => cond)
@wktimes = Wkexpense.where(cond)
end

def findEntriesByCond(cond)
#WkExpenseEntry.find(:all, :conditions => cond, :order => 'project_id, issue_id, activity_id, spent_on')
WkExpenseEntry.where(cond).order('project_id, issue_id, activity_id, spent_on')
WkExpenseEntry.joins(:project).joins(:activity).joins("LEFT OUTER JOIN issues ON issues.id = wk_expense_entries.issue_id").where(cond).order('projects.name, issues.subject, enumerations.name, wk_expense_entries.spent_on')
end

def setValueForSpField(teEntry,spValue,decimal_separator,entry)
Expand Down Expand Up @@ -212,6 +228,7 @@ def validateEntry(stDate)
def getTEName
"expense"
end

# Returns the ExpenseEntry scope for index and report actions
def expense_entry_scope(options={})
scope = @query.results_scope(options)
Expand Down
Loading

0 comments on commit 5c586fc

Please sign in to comment.