<?xml version="1.0"?>
<odoo>

    <record id="calendar_appointment_type_view_kanban" model="ir.ui.view">
        <field name="name">calendar.appointment.type.kanban</field>
        <field name="model">calendar.appointment.type</field>
        <field name="arch" type="xml">
            <kanban class="o_kanban_dashboard">
                <field name="id" invisible="1" />
                <templates>
                    <t t-name="kanban-box">
                        <div>
                            <div class="o_kanban_manage_button_section">
                                <t t-if="widget.editable"><a class="o_kanban_manage_toggle_button" href="#"><i class="fa fa-ellipsis-v" role="img" aria-label="Manage" title="Manage"/></a></t>
                            </div>
                            <div t-attf-class="o_kanban_card_header">
                                <div class="o_kanban_card_header_title">
                                    <div class="o_primary"><field name="name" /></div>
                                    <div class="o_secondary">
                                        <field name="location" /><br/>
                                        <field name="appointment_tz" />
                                    </div>
                                </div>
                            </div>
                            <div class="container o_kanban_card_content">
                            <div class="col-12">
                                <div class="row">
                                    <button class="btn btn-primary" name="action_calendar_meetings" type="object"><field name="appointment_count"/> SCHEDULED</button>
                                </div>
                                </div>
                            </div>
                            <div class="o_kanban_card_manage_pane dropdown-menu" role="menu">
                                <a role="menuitem" type="edit" class="dropdown-item">Edit</a>
                            </div>
                        </div>
                    </t>
                </templates>
            </kanban>
        </field>
    </record>

    <record id="calendar_appointment_type_view_tree" model="ir.ui.view">
        <field name="name">calendar.appointment.type.tree</field>
        <field name="model">calendar.appointment.type</field>
        <field name="arch" type="xml">
            <tree string="Appointment Type" multi_edit="1">
                <field name="sequence" widget="handle"/>
                <field name="name" readonly="1"/>
                <field name="location"/>
                <field name="appointment_tz"/>
                <field name="employee_ids" widget="many2many_tags"/>
            </tree>
        </field>
    </record>

    <record id="calendar_appointment_type_view_form" model="ir.ui.view">
        <field name="name">calendar.appointment.type.form</field>
        <field name="model">calendar.appointment.type</field>
        <field name="arch" type="xml">
            <form string="Appointment Type">
                <field name="website_url" invisible="1"/>
                <sheet>
                    <div class="oe_button_box" name="button_box" groups="base.group_user">
                        <button class="oe_stat_button" type="object"
                            name="action_calendar_meetings"
                            icon="fa-calendar">
                            <field string="Appointments" name="appointment_count" widget="statinfo"/>
                        </button>
                        <field name="is_published" widget="website_redirect_button"/>
                    </div>
                    <div class="oe_title">
                        <label class="oe_edit_only" for="name"/>
                        <h1><field name="name" placeholder="e.g. Schedule a demo"/></h1>
                    </div>
                    <notebook>
                        <page string="Scheduling &amp; Availability" name="schedule_availability">
                            <group>
                                <group name="left_details">
                                    <label for="appointment_duration"/>
                                    <div>
                                          <field name="appointment_duration" class="oe_inline" widget="float_time"/><span> hours</span>
                                    </div>
                                    <label for="min_schedule_hours" string="Schedule Appointment"/>
                                    <div>
                                        <div>
                                          <span>at least </span><field name="min_schedule_hours" class="oe_inline" widget="float_time"/><span> hours before</span>
                                        </div>
                                        <div>
                                          <span>and not after </span><field name="max_schedule_days" class="oe_inline"/><span> days</span>
                                        </div>
                                    </div>
                                    <label for="min_cancellation_hours" string="Allow Cancelling"/>
                                    <div>
                                        <div>
                                          <span>until </span><field name="min_cancellation_hours" class="oe_inline" widget="float_time"/><span> hours before</span>
                                        </div>
                                    </div>
                                </group>
                                <group name="right_details">
                                    <field name="appointment_tz"/>
                                    <field name="reminder_ids" widget="many2many_tags"/>
                                    <field name="location"/>
                                    <field name="assignation_method"/>
                                    <field name="country_ids" widget="many2many_tags" groups="base.group_no_one"/>
                                </group>
                            </group>
                            <separator string="Available Employees"/>
                            <field name="employee_ids">
                                <tree string="Employees">
                                    <field name="name"/>
                                    <field name="resource_calendar_id"/>
                                    <field name="id" widget="appointment_employee_url" string="Individual Appointment Link" context="{'url': parent.website_url}" readonly="1"/>
                                </tree>
                            </field>
                        </page>
                        <page string="Slots" name="slots">
                            <field name="slot_ids">
                                <tree editable="bottom">
                                    <field name="weekday"/>
                                    <field name="hour" string="Starting Hour (0:00 - 24:00)" widget="float_time"/>
                                </tree>
                            </field>
                        </page>
                        <page string="Questions" name="questions">
                            <field name="question_ids">
                                <tree>
                                    <field name="sequence" widget="handle"/>
                                    <field name="name"/>
                                    <field name="question_type"/>
                                    <field name="question_required"/>
                                </tree>
                                <form string="Questions" name="question_form">
                                    <group>
                                        <group name="question_form_left">
                                            <field name="name"/>
                                            <field name="question_type" widget="radio"/>
                                        </group>
                                        <group name="question_form_right">
                                            <field name="answer_ids" widget="many2many_tags" options="{'no_create_edit': True}"
                                                   attrs="{'invisible': [('question_type','in',('char','text'))], 'required':[('question_type','in',('select','radio','checkbox'))]}"/>
                                            <field name="placeholder" attrs="{'invisible': [('question_type','in',('select','radio','checkbox'))]}"/>
                                            <field name="question_required"/>
                                        </group>
                                    </group>
                                </form>
                            </field>
                        </page>
                        <page string="Messages" name="messages">
                            <separator string="Appointment Introduction"/>
                            <field name="message_intro"/>
                            <separator string="Appointment Confirmation"/>
                            <field name="message_confirmation"/>
                        </page>
                    </notebook>
                </sheet>
                <div class="oe_chatter">
                    <field name="message_follower_ids"/>
                    <field name="message_ids"/>
                </div>
            </form>
        </field>
    </record>

    <record id="calendar_appointment_answer_view_form" model="ir.ui.view">
        <field name="name">calendar.appointment.answer.form</field>
        <field name="model">calendar.appointment.answer</field>
        <field name="arch" type="xml">
            <form string="Answer">
                <group>
                    <field name="name"/>
                </group>
            </form>
        </field>
    </record>

    <record id="calendar_appointment_type_action" model="ir.actions.act_window">
        <field name="name">Online Appointments</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">calendar.appointment.type</field>
        <field name="view_mode">kanban,tree,form</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Create a new appointment type
            </p><p>
                Allow your customers to book an appointment on your website
                by creating appointment types here.
            </p>
        </field>
    </record>

    <menuitem
        id="calendar_appointment_type_menu_action"
        parent="calendar.mail_menu_calendar"
        name="Calendar"
        sequence="3"
        action="calendar.action_calendar_event"
        groups="base.group_user"/>

    <menuitem
        id="appointment_type_menu"
        parent="calendar.mail_menu_calendar"
        action="calendar_appointment_type_action"
        sequence="10"/>

    <menuitem
        id="website_appointment_type_menu"
        parent="website.menu_website_global_configuration"
        action="calendar_appointment_type_action"
        sequence="200"/>

</odoo>
