Sha256: 9a82987d1f0c27e6b703bee3dfd3235c3973dbaa0495cd6d242ac1410b3f1953

Contents?: true

Size: 1.82 KB

Versions: 22

Compression:

Stored size: 1.82 KB

Contents

require_dependency "educode_sales/application_controller"

module EducodeSales
  class SalesController < ApplicationController
    # load_and_authorize_resource
    # authorize_resource class: false

    def index
      authorize! :sales, Staff
      respond_to do |format|
        format.html do
        end
        format.json do
          common = Common.find_by(clazz: 'staff_type', name: '销售')
          @a_clazz = Common.find_by(clazz: 'business_type', name: 'A类')
          @b_clazz = Common.find_by(clazz: 'business_type', name: 'B类')
          @step_ids = Common.where(name: %w(已中标 已签单 已验收 回款中 服务中 已结束), clazz: 'business_step').pluck(:id)
          
          @staffs = Staff.where(job_type: common.id).page(params[:page]).per(params[:limit])
        end
      end
    end

    def trends
      authorize! :trends, SaleTrend
      @year = params[:year] ? params[:year] : Time.now.year
      @sale_trend = SaleTrend.find_or_create_by(year: @year)
    end

    def sale_trends
      authorize! :sale_trends, SaleTrend
      sale_trend = SaleTrend.find_by(year: params[:year])
      if sale_trend.update(sale_trend_params)
        render_success
      else
        render_failure sale_trend
      end
    end

    def operations
      authorize! :operations, Staff
      respond_to do |format|
        format.html do
        end
        format.json do
          common_id = Common.where(clazz: 'staff_type', name: ['销售', '运营']).pluck(:id)
          @staffs = Staff.where(job_type: common_id).page(params[:page]).per(params[:limit])
        end
      end
    end

    def school
      render layout: false
    end

    def xschool
      render layout: false
    end

    private

    def sale_trend_params
      params.permit(:chance_money, :ballot_money, :sign_money, :returned_money)
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
educode_sales-0.3.8 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.3.7 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.3.6 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.3.5 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.3.4 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.3.3 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.3.2 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.3.1 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.3.0 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.2.9 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.2.8 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.2.7 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.2.6 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.2.5 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.2.4 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.2.3 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.2.2 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.2.1 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.2.0 app/controllers/educode_sales/sales_controller.rb
educode_sales-0.1.8 app/controllers/educode_sales/sales_controller.rb