Module: EmployeesHelper
- Defined in:
- app/helpers/employees_helper.rb
Instance Method Summary collapse
- #employee_command_options(employee) ⇒ Object
- #employee_goals_link(employee = @employee) ⇒ Object
- #employee_tab_options(employee = @employee) ⇒ Object
- #setup_employee(employee) ⇒ Object
- #setup_sales_goal(employee, year) ⇒ Object
- #strength_video(st) ⇒ Object
- #strength_video_link(st) ⇒ Object
Instance Method Details
#employee_command_options(employee) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/employees_helper.rb', line 40 def (employee) [].tap do |links| if can?(:update, employee) links << link_to('Edit Employee Details', edit_employee_path(employee)) links << link_to('Reset Sales Watch', reset_sales_watch_employee_path(employee)) end links << link_to('Edit Preferences', edit_preferences_employee_path(employee)) if can?(:update_preferences, employee) links << link_to('Time Off', user_time_off_path(employee)) if can?(:impersonate, employee) links << link_to(fa_icon('key', text: 'Login as this employee'), become_employee_url(employee)) end end end |
#employee_goals_link(employee = @employee) ⇒ Object
110 111 112 113 114 115 |
# File 'app/helpers/employees_helper.rb', line 110 def employee_goals_link(employee = @employee) title = fa_icon('bullseye', text: 'My Goals') goal_size = employee.open_employee_goals.size title << content_tag(:span, goal_size, class: 'badge bg-secondary') if goal_size > 0 link_to title.html_safe, employee_path(employee, tab: "goals") end |
#employee_tab_options(employee = @employee) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'app/helpers/employees_helper.rb', line 54 def (employee = @employee) tabs_hsh = {} tabs_hsh[:main] = { remote_href: tab_main_employee_path(employee) } tabs_hsh[:praises] = { remote_href: tab_praises_employee_path(employee) } tabs_hsh[:training] = { remote_href: tab_training_employee_path(employee) } tabs_hsh[:goals] = { remote_href: tab_goals_employee_path(employee) } tabs_hsh[:strengths] = { remote_href: tab_strengths_employee_path(employee) } tabs_hsh[:reviews] = { remote_href: tab_reviews_employee_path(employee) } tabs_hsh[:sales_commissions] = { remote_href: tab_sales_commissions_employee_path(employee) } tabs_hsh[:subordinates] = { remote_href: tab_subordinates_employee_path(employee) } if employee.managed_employees.active_employees.present? tabs_hsh[:assets] = { remote_href: tab_assets_employee_path(employee) } tabs_hsh[:public_reviews] = { remote_href: tab_public_reviews_employee_path(employee) } tabs_hsh[:preferences] = { remote_href: tab_preferences_employee_path(employee) } tabs_hsh[:scheduler] = { remote_href: tab_scheduler_employee_path(employee) } tabs_hsh[:system] = { remote_href: tab_system_employee_path(employee) } tabs_hsh[:sms] = { remote_href: (employee), counter: employee..unread.size } tabs_hsh[:login_activity] = { remote_href: employee_login_activities_path(employee), title: 'Login Activity' } # hsh[:communications] = { remote_href: employee_communications_path(employee) } tabs_hsh[:vouchers] = { remote_href: search_and_show_searches_path( type: 'VoucherSearch', set_limit: 30, query_params: { supplier_id_eq: employee.id }, selected_columns: %i[voucher_link state company_name category payment_method invoice_number invoice_date gl_date currency business_unit_name total open_amount due_date prority], sort_columns: ['priority', 'gl_date desc'], links: { 'New Voucher' => new_voucher_path(supplier_id: employee.id) } ) } tabs_hsh[:payments] = { remote_href: search_and_show_searches_path( type: 'OutgoingPaymentSearch', set_limit: 30, query_params: { supplier_id_eq: employee.id }, selected_columns: %i[outgoing_payment_link state company_name category payment_method reference_number payment_date gl_date currency total], sort_columns: ['reference_number desc'], links: { 'New Payment' => new_outgoing_payment_path(supplier_id: employee.id) } ) } tabs_hsh[:receipts] = { remote_href: search_and_show_searches_path( type: 'ReceiptSearch', set_limit: 30, query_params: { customer_id_eq: employee.id }, selected_columns: %i[receipt_link state company_name customer_name reference_number receipt_date currency total], sort_columns: ['id desc'], links: { 'New Receipt' => new_receipt_path(customer_id: employee.id) } ) } tabs_hsh[:attachments] = { counter: employee.all_uploads.size, remote_href: employee_uploads_path(employee) } tabs_hsh[:training][:counter] = employee.assigned_or_requested_employee_topics.size if tabs_hsh[:training] tabs_hsh[:praises][:counter] = employee.praises.size if tabs_hsh[:praises] tabs_hsh[:goals][:counter] = employee.open_employee_goals.size if tabs_hsh[:goals] tabs_hsh[:reviews][:counter] = employee.open_employee_reviews.size if tabs_hsh[:reviews] tabs_hsh.delete_if { |k, _v| cannot?(:"read_#{k}", employee) } end |
#setup_employee(employee) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/employees_helper.rb', line 4 def setup_employee(employee) employee.tap do |emp| emp.inactive = false if emp.inactive.nil? emp.build_employee_record(activities_per_day: EmployeeRecord::DEFAULT_ACTIVITIES_PER_DAY, activities_per_day_priority_tiers: EmployeeRecord::DEFAULT_ACTIVITIES_PER_DAY_PRIORITY_TIERS) unless emp.employee_record emp.build_employee_account(authentication_mode: Account::AUTH_GOOGLE, role_ids: [Role.find_by(name: 'employee').id]) unless emp.employee_account %w[email phone fax].each do |category| emp.contact_points.build(category: category) unless emp.contact_points.any? { |c| c.category == category } end emp.build_billing_address unless emp.billing_address (1..34).to_a.each do |i| emp.employee_record.strength_themes.build(priority: i) unless emp.employee_record.strength_themes.detect { |s| s.priority.to_i == i } end emp.build_employee_phone_status unless emp.employee_phone_status end end |
#setup_sales_goal(employee, year) ⇒ Object
20 21 22 23 24 25 26 |
# File 'app/helpers/employees_helper.rb', line 20 def setup_sales_goal(employee, year) employee.tap do |employee| (1..12).to_a.each do |month| employee.sales_goals.build(month: month, year: year) if employee.sales_goals.all(conditions: { month: month, year: year }).empty? end end end |
#strength_video(st) ⇒ Object
28 29 30 |
# File 'app/helpers/employees_helper.rb', line 28 def strength_video(st) link_to image_tag("//img.youtube.com/vi/#{st.youtube_id}/3.jpg"), "http://www.youtube.com/watch?v=#{st.youtube_id}" end |
#strength_video_link(st) ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/helpers/employees_helper.rb', line 32 def strength_video_link(st) link_to fa_icon('youtube', family: 'fab', text: st.name), "http://www.youtube.com/embed/#{st.youtube_id}?autoplay=1", class: 'various', title: st.description, data: { fancybox: 'strength-videos', type: 'iframe', 'bs-toggle': 'tooltip', placement: 'left' } end |