<?xml version="1.0" encoding="utf-8"?>
<openerp>
	<data>

    <record id="view_hr_holidays_report_tree" model="ir.ui.view">
        <field name="name">hr.holidays.report.tree</field>
        <field name="model">hr.holidays.report</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree colors="blue:state in ('draft');black:state in ('confirm','refuse','validate');gray:state in('cancel')" string="Leaves Statistics">
                <field name="date" invisible="1"/>
                <field name="employee_id" invisible="1"/>
                <field name="category_id" invisible="1"/>
                <field name="user_id" invisible="1"/>
                <field name="date_from" invisible="1"/>
                <field name="date_to" invisible="1"/>
                <field name="number_of_days_temp" sum="#Days"/>
                <field name="delay_approve"/>
                <field name="holiday_status_id" invisible="1"/>
                <field name="department_id" invisible="1"/>
                <field name="year" invisible="1"/>
                <field name="day" invisible="1"/>
                <field name="month" invisible="1"/>
                <field name="state" invisible="1"/>
            </tree>
        </field>
    </record>

    <record id="view_hr_holidays_report_graph" model="ir.ui.view">
         <field name="name">hr.holidays.report.graph</field>
         <field name="model">hr.holidays.report</field>
         <field name="type">graph</field>
         <field name="arch" type="xml">
             <graph string="Leaves Statistics" type="bar">
                 <field name="employee_id"/>
                 <field name="number_of_days_temp" operator="+"/>
                 <field name="state" group = "True"/>
             </graph>
         </field>
    </record>

    <record id="view_hr_holidays_report_search" model="ir.ui.view">
        <field name="name">hr.holidays.report.search</field>
        <field name="model">hr.holidays.report</field>
        <field name="type">search</field>
        <field name="arch" type="xml">
            <search string="Leaves">
            	<group>
	            	<filter icon="terp-go-year" string=" Year "
                    	domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-01-01'))]" help="Leaves taken in current year"/>
                    <filter icon="terp-go-month" string=" Month " name="month" domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-%%m-01'))]" help="Leaves taken in current month"/>
	                <filter icon="terp-go-month" string="    Month-1    " separator="1"
                       domain="[('date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]" help="Leaves taken in last month"/>
	                <separator orientation="vertical"/>
	                <filter string="Future Leaves" icon="terp-gtk-media-pause" domain="[('state', 'in' ,('draft','confirm'))]"
	                	help = "Draft and Confirmed leaves"/>
	               	<filter string="Validated" icon="terp-camera_test" domain="[('state','=','validate')]"
	               		help = "Pending Leaves"/>
                  <filter icon="gtk-cancel" string="Cancelled" domain="[('state','=','cancel')]"/>
					<separator orientation="vertical"/>
                    <field name="department_id"/>
					<field name="employee_id"/>
	            </group>
	            <newline/>
                <group expand="0" string="Extended Filters..." colspan="10" col="12">
                    <field name="holiday_status_id"/>
                    <field name="category_id"/>
                    <separator orientation="vertical"/>
                    <field name="user_id"/>
                    <newline/>
                    <field name="date_from"/>
                    <field name="date_to"/>
                </group>
                <newline/>
                <group expand="1" string="Group By..." colspan="10" col="12">
                    <filter icon="terp-personal" string="Employee" name="Employee" context="{'group_by':'employee_id'}"
                            help="Leaves by empolyee"/>
                    <filter string="User" name="User" icon="terp-personal" context="{'group_by':'user_id'}"/>
                    <separator orientation="vertical"/>
                     <filter string="Department" name="department" icon="terp-personal+" context="{'group_by':'department_id'}"/>
                    <separator orientation="vertical"/>
                    <filter icon="terp-stock_symbol-selection" string="Category" context="{'group_by':'category_id'}"
                            help="Leaves by category"/>
                    <filter string="Type" icon="terp-stock_symbol-selection" context="{'group_by':'holiday_status_id'}"/>
                    <separator orientation="vertical"/>
                    <filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
                    <separator orientation="vertical"/>
                     <filter string="Day" icon="terp-go-today" context="{'group_by':'day'}" help="Group by create date"/>
                    <filter string="Month" icon="terp-go-month" context="{'group_by':'month'}" help="Group by month of create date"/>
                    <filter string="Year" icon="terp-go-year" context="{'group_by':'year'}" help="Group by year of create date"/>
                </group>
            </search>
        </field>
    </record>

    <record id="action_hr_holidays_report_all" model="ir.actions.act_window">
        <field name="name">Leaves</field>
        <field name="res_model">hr.holidays.report</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,graph</field>
        <field name="context">{"search_default_user_id": uid, 'search_default_month':1, 'search_default_department':1, 'group_by':[], 'group_by_no_leaf':1} </field>
        <field name="search_view_id" ref="view_hr_holidays_report_search"/>
    </record>

    <menuitem action="action_hr_holidays_report_all" id="menu_hr_holidays_report_all" parent="menu_hr_reporting_holidays" sequence="0"/>

	<record id="view_hr_holidays_remaining_leaves_user_tree" model="ir.ui.view">
        <field name="name">hr.holidays.remaining.leaves.user.tree</field>
        <field name="model">hr.holidays.remaining.leaves.user</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Leaves by Type">
                <field name="name"/>
                <field name="leave_type"/>
                <field name="no_of_leaves"/>
            </tree>
        </field>
    </record>

    <record id="view_hr_holidays_remaining_leaves_user_graph" model="ir.ui.view">
        <field name="name">hr.holidays.remaining.leaves.user.graph</field>
        <field name="model">hr.holidays.remaining.leaves.user</field>
        <field name="type">graph</field>
        <field name="arch" type="xml">
            <graph string="Leaves by Type" orientation = "horizontal" type="bar">
                <field name="name" />
                <field name="no_of_leaves" operator = "+"/>
                <field name="leave_type" group = "True"/>
            </graph>
        </field>
    </record>

    </data>
</openerp>
