bookyt_projects 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ class TimesheetsController < ApplicationController
2
+ def index
3
+ @employee = Employee.find(params[:employee_id])
4
+ @employment = @employee.employments.current
5
+
6
+ days = (Date.today.beginning_of_month..Date.today.end_of_month).to_a
7
+ @work_days = days.map{|day| WorkDay.new(day, @employment)}
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module BookytProjects
2
+ module Employee
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ has_many :activities, :foreign_key => :person_id
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ class WorkDay
2
+ attr_accessor :date, :employment
3
+
4
+ def initialize(date, employment)
5
+ @date = date
6
+ @employment = employment
7
+ end
8
+
9
+ def hours_due
10
+ case date.wday
11
+ when 6, 0
12
+ 0.0
13
+ else
14
+ employment.daily_workload
15
+ end
16
+ end
17
+
18
+ def hours_worked
19
+ employment.employee.activities.where(:when => date).to_a.sum(&:duration)
20
+ end
21
+
22
+ def overtime
23
+ hours_worked - hours_due
24
+ end
25
+ end
@@ -2,7 +2,7 @@
2
2
  = render 'form'
3
3
 
4
4
  .contextual
5
- = icon_link_to :new, new_project_activity_path(resource), :remote => true
5
+ = icon_link_to :new, new_project_activity_path(resource)
6
6
  %h2= t_title :index, Activity
7
7
 
8
8
  = render 'activities/list', :collection => @project.activities
@@ -0,0 +1,21 @@
1
+ %h1= t_title
2
+
3
+ %table.list
4
+ %tr
5
+ %th Datum
6
+ %th Wochentag
7
+ %th Soll-Stunden
8
+ %th Stunden
9
+ %th Über-/Unterzeit
10
+ %th Saldo
11
+
12
+ - overall_overtime = 0
13
+ - @work_days.each do |day|
14
+ - overall_overtime += day.overtime
15
+ %tr
16
+ %td= day.date
17
+ %td= l(day.date, :format => '%A')
18
+ %td= day.hours_due
19
+ %td= day.hours_worked
20
+ %td= day.overtime
21
+ %td= overall_overtime
data/config/routes.rb CHANGED
@@ -4,7 +4,7 @@ Rails.application.routes.draw do
4
4
  end
5
5
  resources :project_states
6
6
  resources :activities
7
-
7
+
8
8
  resources :employees do
9
9
  resources :timesheets
10
10
  end
@@ -1,8 +1,10 @@
1
1
  require 'bookyt_projects'
2
2
  require 'rails'
3
3
 
4
- module BookytProject
4
+ module BookytProjects
5
5
  class Railtie < Rails::Engine
6
-
6
+ config.to_prepare do
7
+ ::Employee.send :include, BookytProjects::Employee
8
+ end
7
9
  end
8
10
  end
@@ -1,3 +1,3 @@
1
1
  module BookytPos
2
- VERSION = '0.9.0'
2
+ VERSION = '0.10.0'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookyt_projects
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 9
8
+ - 10
9
9
  - 0
10
- version: 0.9.0
10
+ version: 0.10.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roman Simecek (CyT)
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-10-24 00:00:00 +02:00
19
+ date: 2011-10-25 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -107,16 +107,19 @@ files:
107
107
  - app/controllers/activities_controller.rb
108
108
  - app/controllers/project_states_controller.rb
109
109
  - app/controllers/projects_controller.rb
110
+ - app/controllers/timesheets_controller.rb
110
111
  - app/models/activity.rb
112
+ - app/models/bookyt_projects/employee.rb
111
113
  - app/models/project.rb
112
114
  - app/models/project_state.rb
115
+ - app/models/work_day.rb
113
116
  - app/views/activities/_form.html.haml
114
117
  - app/views/activities/_list.html.haml
115
- - app/views/activities/new.js.erb
116
118
  - app/views/project_states/_form.html.haml
117
119
  - app/views/projects/_form.html.haml
118
120
  - app/views/projects/_list.html.haml
119
121
  - app/views/projects/_show.html.haml
122
+ - app/views/timesheets/index.html.haml
120
123
  - config/application.rb
121
124
  - config/boot.rb
122
125
  - config/locales/de.yml
@@ -1,10 +0,0 @@
1
- $('#new_<%= resource.class.name.underscore %>').remove();
2
- var form = '<div id="new_activity_dialog"><%=j render "form" %></div>';
3
- $('#<%= resource.class.name.tableize %>_list').before(form);
4
- $('#new_activity_dialog').dialog({
5
- modal: true,
6
- minWidth: 580,
7
- title: '<%=j t_title :edit, Activity %>'
8
- });
9
-
10
- initializeBehaviours();