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

    <record id="dashboard_sales_action_id" model="ir.actions.act_window">
        <field name="name">Folios</field>
        <field name="res_model">hotel.dashboard</field>
    </record>

    <record id="dashboard_sales_order_action_id" model="ir.actions.act_window">
        <field name="name">Folios</field>
        <field name="res_model">hotel.dashboard</field>
    </record>

    <record id="dashboard_sales_done_action_id" model="ir.actions.act_window">
        <field name="name">Folios</field>
        <field name="res_model">hotel.dashboard</field>
    </record>

    <record id="dashboard_sales_cancel_action_id" model="ir.actions.act_window">
        <field name="name">Folios</field>
        <field name="res_model">hotel.dashboard</field>
    </record>

    <record id="hotel_dashboard_kanban_view" model="ir.ui.view">
        <field name="name">hotel.dashboard.view</field>
        <field name="model">hotel.dashboard</field>
        <field name="arch" type="xml">
            <kanban create="false" class="oe_background_grey o_kanban_dashboard o_account_kanban">
                <field name="id"/>
                <field name="name"/>
                <field name="graph_type"/>
                <field name="show_on_dashboard"/>
                <field name="kanban_dashboard"/>
                <templates>
                    <t t-name="kanban-box">
                        <div t-attf-class="#{kanban_color(0)}">
                            <t t-value="JSON.parse(record.kanban_dashboard.raw_value)" t-set="dashboard"/>
                            <t t-value="record.type.raw_value" t-set="journal_type"/>
                            <t t-value="record.name.raw_value" t-set="dashboard_name"/>
                            <t t-value="record.graph_type.raw_value" t-set="graph_type"/>
                            <t t-call="JournalTop"/>
                            <div class="container o_kanban_card_content o_visible">
                                <div class="row">
                                    <t t-if="dashboard_name == 'Chekins Dashboard'" t-call="JournalBodySalePurchase"/>
                                    <t t-if="dashboard_name != 'Chekins Dashboard'" t-call="JournalBodySalePurchase"/>
                                </div>
                                <t t-call="JournalBodyGraph"/>
                            </div><div class="container o_kanban_card_manage_pane o_invisible">
                                <t t-call="JournalManage"/>
                            </div>
                        </div>
                    </t>

                    <t t-name="JournalTop">
                        <div class="o_kanban_card_header">
                            <div class="o_kanban_card_header_title">
                                <div class="o_primary">
                                    <a type="object" name="open_action"><field name="name"/></a>
                                </div>
                                <div class="o_secondary" t-att-title="dashboard.title">
                                    <field name="type"/>
                                </div>
                            </div>
                            <div class="o_kanban_manage_button_section">
                                <a class="o_kanban_manage_toggle_button" href="#">More <i class="fa fa-caret-down"/></a>
                            </div>
                        </div>
                    </t>

                    <t t-name="JournalManage">
                        <div class="row">
                             <div class="col-xs-4 o_kanban_card_manage_section o_kanban_manage_view">
                                <div class="o_kanban_card_manage_title">
                                    <span>View</span>
                                </div>
                                <div>
                                    <a>
                                        <span>Invoices</span>
                                    </a>
                                </div>
                                <div>
                                    <a>
                                        <span>Refunds</span>
                                    </a>
                                </div>
                                <div>
                                    <a>Payments Matching</a>
                                </div>
                                <div>
                                    <a>Journal Items</a>
                                </div>
                            </div>

                             <div class="col-xs-4 o_kanban_card_manage_section o_kanban_manage_new">
                                <div class="o_kanban_card_manage_title">
                                    <span>New</span>
                                </div>
                                <div>
                                    <a>
                                        <span>Invoice</span>
                                    </a>
                                </div>
                                <div>
                                    <a>
                                        <span>Refund</span>
                                    </a>
                                </div>
                            </div>

                             <div class="col-xs-4 o_kanban_card_manage_section o_kanban_manage_reports">
                                <div class="o_kanban_card_manage_title">
                                    <span>Reports</span>
                                </div>
                                <div>
                                    <a>Invoices Analysis</a>
                                </div>
                            </div>
                        </div>
                         <div class="row o_kanban_card_settings">
                            <div class="col-xs-6">
                                <a><i t-attf-class="fa o_dashboard_star #{record.show_on_dashboard.raw_value ? 'fa-star' : 'fa-star-o'}" title="Click to add/remove from favorite"/> Favorite</a>
                            </div>
                            <div class="col-xs-6 text-right">
                                <a type="edit">Settings</a>
                            </div>
                        </div>
                    </t>


                    <t t-name="JournalBodySalePurchase">
                        <div class="col-xs-6 o_kanban_primary_left">
                            <t>
                                <button type="object" name="action_create_new" class="btn btn-primary btn-sm o_invoice_new">
                                    <span>New</span>
                                </button>
                            </t>
                        </div>
                        <div class="col-xs-6 o_kanban_primary_right">
                            <div class="row">
                                <div class="col-xs-6">
                                    <a type="object" name="open_action" context="{'search_default_draft': '1', 'search_default_proforma': '1'}">
                                        <span> Draft</span>
                                    </a>
                                </div>
                                <div class="col-xs-6 text-right">
                                    <span><t t-esc="dashboard.sum_draft"/></span>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-6">
                                    <a type="object" name="open_action" context="{'search_default_unpaid': '1'}">
                                        <span> Payments to do</span>
                                    </a>
                                </div>
                                <div class="col-xs-6 text-right">
                                    <span><t t-esc="dashboard.sum_waiting"/></span>
                                </div>
                            </div>
                        </div>
                    </t>
                    <t t-name="JournalBodyGraph">

                        <div class="o_kanban_graph_section">
                            <span t-if="graph_type == 'line'">
                                <field name="kanban_dashboard_graph" t-att-graph_type="'line'" widget="dashboard_graph"/>
                            </span>
                            <span t-if="graph_type == 'bar'">
                                <field name="kanban_dashboard_graph" t-att-graph_type="'bar'" widget="dashboard_graph"/>
                            </span>
                        </div>

                    </t>
                </templates>
            </kanban>
        </field>
    </record>

        <record id="hotel_dashboard_action" model="ir.actions.act_window">
            <field name="name">Hotel Dashboard</field>
            <field name="res_model">hotel.dashboard</field>
            <field name="type">ir.actions.act_window</field>
            <field name="view_type">form</field>
            <field name="context">{}</field>
            <field name="view_mode">kanban</field>
            <field name="view_id" ref="hotel_dashboard_kanban_view"/>
        </record>

        <menuitem  id="employees_dashboard_menu"
            parent="hotel_management_menu"
            sequence="1"
            name="Dashboard"
            action="hotel_dashboard_action"/>


    <data noupdate="0">
       <record model="hotel.dashboard" id="chekins_dashboard">
            <field name="name">Chekins Dashboard</field>
            <field name="type">sales</field>
            <field name="graph_type">bar</field>
            <field name="show_on_dashboard">1</field>
        </record>
        <record model="hotel.dashboard" id="onboard_dashboard">
            <field name="name">On Board</field>
            <field name="type">sales</field>
            <field name="graph_type">line</field>
            <field name="show_on_dashboard">1</field>
        </record>
    </data>

</odoo>
