# -*- encoding : utf-8 -*-

class Admin::PStatsController < ApplicationController
  layout "admin"
  before_filter :auth_admin

  before_filter :admin_space
  

  def admin_space
    @admin_space = "statistiques"
  end

  def index
    
    @start_at = params[:start_at] ? Date.parse(params[:start_at]) : Date.today.beginning_of_month
    
    @end_at = params[:end_at] ? Date.parse(params[:end_at]) : Date.today.end_of_month
    
    
    @p_customer_sheets = PCustomerSheet.where("created_at >= ? and created_at <= ?",@start_at, @end_at).order("id DESC").all

    @sans_marges = PSheetLine.where(:p_customer_sheet_id => @p_customer_sheets.ids).where(:externe => false, :stock_done => false, :shiped => true)

    @finished = @p_customer_sheets.where(:state => ["livrée","facturée"])
   
  end

  
  
  
end
