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

        <!-- add visibility field to the employee form view -->
        <record id="view_employee_form" model="ir.ui.view">
            <field name="name">portal_hr_employees_form</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr.view_employee_form"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='user_id']" position="after">
                    <field name="visibility"/>
                    <field name="public_info" String="Public Notes" placeholder="Here you can write information about you to be shown in the portal..." attrs='{"invisible":[("visibility", "=", "private")]}'/>
                </xpath>
            </field>
        </record>

        <record id="portal_view_employee_filter" model="ir.ui.view">
            <field name="name">Employees</field>
            <field name="model">hr.employee</field>
            <field name="arch" type="xml">
                <search string="Employees">
                    <field name="name" string="Employees"/>
                    <group expand="0" string="Group By...">
                        <filter string="Manager" icon="terp-personal" domain="[]" context="{'group_by':'parent_id'}"/>
                        <filter string="Coach" icon="terp-personal" domain="[]" context="{'group_by':'coach_id'}"/>
                        <filter string="Department" icon="terp-personal+" domain="[]" context="{'group_by':'department_id'}"/>
                        <filter string="Job" icon="terp-gtk-select-all" domain="[]" context="{'group_by':'job_id'}"/>
                        <filter string="Company" icon="terp-go-home" domain="[]" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                    </group>
                </search>
            </field>
        </record>

        <record model="ir.ui.view" id="portal_hr_kanban_view_employees">
            <field name="name">HR - Employees Kanban (Portal)</field>
            <field name="model">hr.employee</field>
            <field name="priority">32</field>
            <field name="inherit_id" eval="False"/>
            <field name="arch" type="xml">
                <kanban  create="false">
                    <field name="last_login"/>
                    <templates>
                        <t t-name="kanban-box">
                            <div class="oe_employee_vignette">
                                <div class="oe_employee_image">
                                    <a type="open"><img t-att-src="kanban_image('hr.employee', 'image_medium', record.id.value)" class="oe_employee_picture"/></a>
                                </div>
                                <div class="oe_employee_details">
                                    <h4>
                                        <a type="open"><field name="name"/></a>
                                    </h4>
                                    <ul>
                                        <li t-if="record.job_id.raw_value"><field name="job_id"/></li>
                                        <li t-if="record.work_location.raw_value"><field name="work_location"/></li>
                                        <li t-if="record.work_phone.raw_value">Tel: <field name="work_phone"/></li>
                                        <li t-if="record.mobile_phone.raw_value">Mobile: <field name="mobile_phone"/></li>
                                        <li t-if="record.work_email.raw_value"><a t-attf-href="mailto:#{record.work_email.value}"><field name="work_email"/></a></li>
                                        <li t-if="record.public_info.raw_value"><field name="public_info"/></li>
                                    </ul>
                                </div>
                            </div>
                            <script>
                                $('.oe_employee_picture').load(function() { if($(this).width() > $(this).height()) { $(this).addClass('oe_employee_picture_wide') } });
                            </script>
                        </t>
                    </templates>
                </kanban>
            </field>
        </record>

        <record id="action_team" model="ir.actions.act_window">
            <field name="name">Our Team</field>
            <field name="res_model">hr.employee</field>
            <field name="view_id" ref="portal_hr_kanban_view_employees"/>
            <field name="view_mode">kanban</field>
            <field name="view_type">form</field>
            <field name="domain">[('visibility','!=','private')]</field>
            <field name="search_view_id" ref="portal_view_employee_filter"/>
            <field name="target">current</field>
        </record>

        <record id="crm_contact_us" model="ir.ui.view">
            <field name="name">crm_contact_us</field>
            <field name="model">portal_crm.crm_contact_us</field>
            <field name="inherit_id" ref="portal_crm.contact_form_view"/>
            <field name="arch" type="xml">
                <xpath expr="//div[@class='oe_portal_crm_team']" position="inside">
                    <a href="#action=portal_hr_employees.action_team">Our Team</a>
                </xpath>
            </field>
        </record>

        
    </data>
</openerp>
