2009-01-13 19:01:56 +01:00
|
|
|
# == Schema Information
|
2009-01-29 21:28:22 +01:00
|
|
|
# Schema version: 20090120184410
|
2009-01-13 19:01:56 +01:00
|
|
|
#
|
|
|
|
# Table name: groups
|
|
|
|
#
|
2009-02-02 16:35:43 +01:00
|
|
|
# id :integer not null, primary key
|
2009-01-13 19:01:56 +01:00
|
|
|
# type :string(255) default(""), not null
|
|
|
|
# name :string(255) default(""), not null
|
|
|
|
# description :string(255)
|
2009-02-02 16:35:43 +01:00
|
|
|
# account_balance :decimal(, ) default(0.0), not null
|
2009-01-13 19:01:56 +01:00
|
|
|
# account_updated :datetime
|
|
|
|
# created_on :datetime not null
|
2009-02-02 16:35:43 +01:00
|
|
|
# role_admin :boolean not null
|
|
|
|
# role_suppliers :boolean not null
|
|
|
|
# role_article_meta :boolean not null
|
|
|
|
# role_finance :boolean not null
|
|
|
|
# role_orders :boolean not null
|
|
|
|
# weekly_task :boolean
|
|
|
|
# weekday :integer
|
2009-01-13 19:01:56 +01:00
|
|
|
# task_name :string(255)
|
|
|
|
# task_description :string(255)
|
2009-02-02 16:35:43 +01:00
|
|
|
# task_required_users :integer default(1)
|
2009-01-29 21:28:22 +01:00
|
|
|
# deleted_at :datetime
|
2009-02-02 16:35:43 +01:00
|
|
|
# contact_person :string(255)
|
|
|
|
# contact_phone :string(255)
|
|
|
|
# contact_address :string(255)
|
2009-01-13 19:01:56 +01:00
|
|
|
#
|
|
|
|
|
|
|
|
class Workgroup < Group
|
|
|
|
|
|
|
|
has_many :tasks
|
|
|
|
# returns all non-finished tasks
|
|
|
|
has_many :open_tasks, :class_name => 'Task', :conditions => ['done = ?', false], :order => 'due_date ASC'
|
|
|
|
|
|
|
|
def self.weekdays
|
|
|
|
[["Montag", "1"], ["Dienstag", "2"], ["Mittwoch","3"],["Donnerstag","4"],["Freitag","5"],["Samstag","6"],["Sonntag","0"]]
|
|
|
|
end
|
|
|
|
|
|
|
|
# Returns an Array with date-objects to represent the next weekly-tasks
|
|
|
|
def next_weekly_tasks(number = 8)
|
|
|
|
# our system starts from 0 (sunday) to 6 (saturday)
|
|
|
|
# get difference between groups weekday and now
|
|
|
|
diff = self.weekday - Time.now.wday
|
|
|
|
if diff >= 0
|
|
|
|
# weektask is in current week
|
|
|
|
nextTask = diff.day.from_now
|
|
|
|
else
|
|
|
|
# weektask is in the next week
|
|
|
|
nextTask = (diff + 7).day.from_now
|
|
|
|
end
|
|
|
|
# now generate the Array
|
|
|
|
nextTasks = Array.new
|
|
|
|
number.times do
|
|
|
|
nextTasks << nextTask
|
|
|
|
nextTask = 1.week.from_now(nextTask)
|
|
|
|
end
|
|
|
|
return nextTasks
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|