<% content_for :head do %> <% end %> <%=render(:partial => "filters_stats") %>

Заработная плата:

<% fines = 0%> <% all_cl_w = 0%> <% all_cl_m = 0%> <% employees_with_clients_size = @reports.select{|i| i.category == 24}.map{|i| i.employees}.flatten.uniq.size %> <% @employees.each do |e| %> <% reps = @reports.select{|i| i.employees.include? e} %> <% @payroll = @payrolls.select{|i| i[:employee_id] == e.id}[0] %> <% reps_only_clients = reps.select{|i| i.category == 24}%> <% all_count_w = reps.select{|i| i.total_sum_works.to_f > 0}.count%> <% all_count_m = reps.select{|i| i.total_sum_materials.to_f > 0}.count%> <% fines_de = reps.select{|i| i.zp_fine_sum.to_f > 0} %> <% sum_for_works = reps.select{|i| i.weld != 1}.map{|i| i.done_employees}.flatten.select{|i| i.empl_id == e.id}.sum{|i| i.sum.to_f} %> <% bonus_for_mats = reps.select{|i| i.weld != 1}.map{|i| i.done_materials}.flatten.select{|i| i.employee_id == e.id}.sum{|i| i.bonus_sale.to_f} %> <% fines += f %> <% all_cl_w += cl_w.to_f %> <% all_cl_m += cl_m.to_f %> <% end -%> <% all_count_w = @reports.select{|i| i.total_sum_works.to_f > 0}.count%><% all_count_m = @reports.select{|i| i.total_sum_materials.to_f > 0}.count%>
Сотрудник Кол-во мастер смен в СГ-фаст Кол-во дисп. смен СГ-фаст Кол-во СГ-фаст отчетов СГ-фаст бонус
за переработку
Кол-во софт отчетов Всего отчетов Кол-во б/п заявок Всего получено денег За работы За оборудование З/п диспетчера Средний чек за работы Средний чек за оборудование СГ-фаст (руб) Обычные заявки (руб) Премии за продажу об. З/П итого (руб) Штрафы
<%=link_to e.login, soft_index_path(:filter_empl => e.id, :filter_month => @date.to_date.month, :filter_year => @date.to_date.year, :filter_status => 2, :filter_weld => params[:filter_weld]), :target => '_blank' %> <%= @payroll[:smen_work] if @payroll%> <%= @payroll[:smen_disp] if @payroll %> <%= @payroll[:rep_count] if @payroll %> <%= @payroll[:bonus] if @payroll %> <%= reps.select{|i| i.weld != 1}.size %> <%= reps.size %> <%=link_to reps.select{|i| i.total_sum_get_money.to_i == 0}.count, soft_index_path(:filter_empl => e.id, :filter_month => @date.to_date.month, :filter_year => @date.to_date.year, :filter_status => 2, :sum_works_to => 0), :target => '_blank' %> <%=n reps.sum{|i| i.total_sum_get_money.to_f} %> <%=n all_money_w=reps.sum{|i| i.total_sum_works.to_f} %> <%=n all_money_m=reps.sum{|i| i.total_sum_materials.to_f} %> <%=n reps.sum{|i| i.disp_wage.to_f} %> <%= cl_w = (reps_only_clients.sum{|i| i.total_sum_works.to_f}/reps_only_clients.select{|i| i.total_sum_works.to_f > 0}.size).to_i if reps_only_clients.select{|i| i.total_sum_works.to_f > 0}.size > 0 %> <%= cl_m = (reps_only_clients.sum{|i| i.total_sum_materials.to_f}/reps_only_clients.select{|i| i.total_sum_materials.to_f > 0}.size).to_i if reps_only_clients.select{|i| i.total_sum_materials.to_f > 0}.size > 0 %> <%=n (if @payroll then fast = @payroll[:sum] else fast = 0 end)%> <%=n sum_for_works.to_f - bonus_for_mats.to_f %> <%=n bonus_for_mats + (if @payroll then @payroll[:bonus_sale].to_f else 0 end)%> <%=n fast + sum_for_works.to_f + (if @payroll then @payroll[:bonus_sale].to_f + @payroll[:bonus].to_f else 0 end) %> <%=n f = ( fines_de.size > 0 ? (fines_de.sum{|i| i.zp_fine_sum.to_f}) : 0) %>
<%= link_to "Итого", soft_index_path(:filter_month => @date.to_date.month, :filter_year => @date.to_date.year, :filter_status => 2), :target => '_blank'%> <%=n @payrolls.map{|i| i[:smen_work]}.sum %> <%=n @payrolls.map{|i| i[:smen_disp]}.sum %> <%=n @payrolls.map{|i| i[:rep_count]}.sum %> <%=n @payrolls.map{|i| i[:bonus]}.sum %> <%=n @reports.select{|i| i.weld != 1}.flatten.size%> <%=n @reports.size%> <%=link_to @reports.select{|i| i.total_sum_get_money.to_i == 0}.count, soft_index_path(:filter_month => @date.to_date.month, :filter_year => @date.to_date.year, :filter_status => 2, :sum_works_to => 0), :target => '_blank'%> <%=n @reports.sum{|i| i.total_sum_get_money.to_f} %> <%=n all_money_w=@reports.sum{|i| i.total_sum_works.to_f} %> <%=n all_money_m=@reports.sum{|i| i.total_sum_materials.to_f} %> <%=n @reports.sum{|i| i.disp_wage.to_f} %> <%= (all_cl_w.to_f / employees_with_clients_size).to_i if employees_with_clients_size > 0 %> <%= (all_cl_m.to_f / employees_with_clients_size).to_i if employees_with_clients_size > 0 %> <%=n @payrolls.map{|i| i[:sum]}.sum%> <%=n @reports.sum(&:sum) - @reports.map{|i| i.done_materials.map{|i| i.bonus_sale.to_f}}.flatten.sum %> <%=n @payrolls.map{|i| i[:bonus_sale]}.sum + @reports.map{|i| i.done_materials.map{|i| i.bonus_sale.to_f}}.flatten.sum %> <%=n @reports.sum(&:sum)+@payrolls.map{|i| i[:bonus_sale]}.sum%> <%=n fines%>
<% if @managers %>

Бонус - Заявка от:

<% s = 0%> <% sum2 = 0 %> <% @managers.each do |m| %> <% sum2 += s %> <%end-%> <%end-%>
Менеджер Бонус, руб.
<%=Employee.find(m.manager_id).login %> <%= s = m.sum %>
Итого: <%=sum2%>
<% if @leadgens %>

Бонус Лидогенератору:

<% s = 0%> <% sum2 = 0 %> <% @leadgens.each do |m| %> <% sum2 += s %> <%end-%> <%end-%>
Лидогенератор Бонус, руб.
<%=Employee.find(m.leadgen_id).login %> <%= s = m.sum %>
Итого: <%=sum2%>