<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
	<t t-extend='mail.ChatThread.Message'>
        <t t-jquery='div:first-child' t-operation='replace'>
            <t t-if="is_cloudoffix">
                <div t-att-class="'o_thread_message' + (message.expanded ? ' o_message_expanded '  : ' ') + (message.is_selected ? 'o_thread_selected_message' : '')"
                 t-att-data-message-id="message.id">
                <div t-att-class="'o_thread_message_core' + (message.is_note ? ' o_mail_note' : '')">
                    <t t-if="message.tracking_value_ids &amp;&amp; message.tracking_value_ids.length &gt; 0">
                        <t t-if="message.subtype_description">
                            <p t-esc="message.subtype_description"/>
                        </t>
                        <t t-call="mail.ChatThread.MessageTracking"/>
                    </t>
                    <p t-if="options.display_subject &amp;&amp; message.display_subject" class="o_mail_subject">
                        Subject:
                        <t t-esc="message.subject"/>
                    </p>

                    <t t-if="!(message.tracking_value_ids &amp;&amp; message.tracking_value_ids.length &gt; 0)">
                        <t t-raw="message.body"/>
                    </t>

                    <t t-foreach="message.attachment_ids" t-as="attachment">
                        <t t-call="mail.Cloudoffix_Attachment"/>
                    </t>

                    <div class="chat_time">
                        <small>
                            <p t-if="message.display_author" class="o_mail_info">
                                <t t-if="message.is_note">
                                    Note by
                                </t>

                                <strong t-if="message.mailto">
                                    <a class="o_mail_mailto" t-attf-href="mailto:#{message.mailto}?subject=Re: #{message.subject}">
                                        <t t-esc="message.mailto"/>
                                    </a>
                                </strong>

                                <strong t-if="!message.mailto &amp;&amp; message.author_id[0] &amp;&amp; message.message_type=='notification'"
                                        data-oe-model="res.partner"
                                        t-att-data-oe-id="message.author_redirect ? message.author_id[0] : ''"
                                        t-attf-class="#{message.author_redirect ? 'o_mail_redirect' : ''}">
                                    <t t-set="display_author_name" t-value="message.displayed_author.split(',')"/>
                                    <t t-set="position" t-value="display_author_name.length -1"/>
                                    <t t-if="display_author_name[position]" t-esc="display_author_name[position]"/>
                                </strong>

                                <t t-if="message.model &amp;&amp; (message.model != 'mail.channel') &amp;&amp; options.display_document_link">
                                    on <a t-att-href="message.url" t-att-data-oe-model="message.model"
                                          t-att-data-oe-id="message.res_id"><t t-esc="message.record_name"/></a>
                                </t>
                                <t t-if="message.origin_id &amp;&amp; (message.origin_id !== options.channel_id)">
                                    (from <a t-att-data-oe-id="message.origin_id" href="#">#<t t-esc="message.origin_name"/></a>
                                    )
                                </t>
                                <span t-if="options.display_email_icon &amp;&amp; message.customer_email_data &amp;&amp; message.customer_email_data.length"
                                      class="o_thread_tooltip_container">
                                    <i t-att-class="'o_thread_tooltip o_thread_message_email o_thread_message_email_' + message.customer_email_status + ' fa fa-envelope-o'"/>
                                    <span class="o_thread_tooltip_content">
                                        <t t-foreach="message.customer_email_data" t-as="customer">
                                            <span>
                                                <t t-if="customer[2] == 'sent'"><i class='fa fa-check'/></t>
                                                <t t-if="customer[2] == 'bounce'"><i class='fa fa-exclamation'/></t>
                                                <t t-if="customer[2] == 'exception'"><i class='fa fa-exclamation'/></t>
                                                <t t-if="customer[2] == 'ready'"><i class='fa fa-send-o'/></t>
                                                <t t-esc="customer[1]"/>
                                            </span>
                                            <br/>
                                        </t>
                                    </span>
                                </span>
                                <span>
                                    <i t-if="options.display_stars &amp;&amp; !message.is_system_notification"
                                       t-att-class="'fa fa-lg o_thread_message_star ' + (message.is_starred ? 'fa-star' : 'fa-star-o')"
                                       t-att-data-message-id="message.id" title="Mark as Todo"/>
                                    <i t-if="message.record_name &amp;&amp; message.model != 'mail.channel' &amp;&amp; options.display_reply_icon"
                                       class="fa fa-reply o_thread_message_reply"
                                       t-att-data-message-id="message.id" title="Reply"/>
                                    <i t-if="message.is_needaction &amp;&amp; options.display_needactions"
                                       class="fa fa-check o_thread_message_needaction"
                                       t-att-data-message-id="message.id" title="Mark as Read"/>
                                </span>
                            </p>
                        </small>
                        <small class="o_mail_timestamp" t-att-title="message.date">
                            <t t-if="message.message_type!='notification'">
                                 <t t-esc="message.hour"/>
                            </t>
                            <t t-else="">
                                <t t-esc="message.date"/>
                            </t>

                        </small>
                    </div>
                </div>
            </div>
            </t>
            <t t-else="">
                <div t-att-class="'o_thread_message' + (message.expanded ? ' o_message_expanded '  : ' ') + (message.is_selected ? 'o_thread_selected_message' : '')" t-att-data-message-id="message.id">
            <div t-if="options.display_avatar" class="o_thread_message_sidebar">
                <t t-if="!message.mailto and message.author_id[0]">
                    <img t-if="message.avatar_src and message.display_author"
                        t-att-src="message.avatar_src"
                        data-oe-model="res.partner"
                        t-att-data-oe-id="message.author_redirect ? message.author_id[0] : ''"
                        t-attf-class="o_thread_message_avatar img-circle #{message.author_redirect ? 'o_mail_redirect' : ''}"/>
                </t>
                <t t-if="message.mailto || !message.author_id[0]">
                    <img t-if="message.avatar_src and message.display_author"
                        t-att-src="message.avatar_src"
                        class="o_thread_message_avatar img-circle"/>
                </t>
                <span t-if="!message.display_author" t-att-title="message.date.format(date_format)" class="o_thread_message_side_date">
                    <t t-esc="message.date.format('hh:mm')"/>
                </span>
                <i t-if="!message.display_author and options.display_stars and message.message_type != 'notification'"
                    t-att-class="'fa o_thread_message_star o_thread_icon ' + (message.is_starred ? 'fa-star' : 'fa-star-o')"
                    t-att-data-message-id="message.id" title="Mark as Todo"/>
            </div>
            <div t-att-class="'o_thread_message_core' + (message.is_note ? ' o_mail_note' : '') + (message.is_from_outlook ? ' o_mail_outlook' : '')">
                <p t-if="message.display_author" class="o_mail_info">
                    <t t-if="message.is_note">
                        Note by
                    </t>

                    <t t-if="message.is_from_outlook">
                        Sent from outlook add-in
                    </t>

                    <strong t-if="message.mailto">
                        <a class="o_mail_mailto" t-attf-href="mailto:#{message.mailto}?subject=Re: #{message.subject}">
                            <t t-esc="message.mailto"/>
                        </a>
                    </strong>
                    <strong t-if="!message.mailto and message.author_id[0]"
                            data-oe-model="res.partner" t-att-data-oe-id="message.author_redirect ? message.author_id[0] : ''"
                            t-attf-class="o_thread_author #{message.author_redirect ? 'o_mail_redirect' : ''}">
                        <t t-esc="message.displayed_author"/>
                    </strong>
                    <strong t-if="!message.mailto and !message.author_id[0]" class="o_thread_author">
                        <t t-esc="message.displayed_author"/>
                    </strong>

                    - <small class="o_mail_timestamp" t-att-title="message.date.format(date_format)"><t t-esc="message.hour"/></small>
                    <t t-if="message.model and (message.model != 'mail.channel') and options.display_document_link">
                        on <a t-att-href="message.url" t-att-data-oe-model="message.model" t-att-data-oe-id="message.res_id" class="o_document_link"><t t-esc="message.record_name"/></a>
                    </t>
                    <t t-if="message.origin_id and (message.origin_id !== options.channel_id)">
                        (from <a t-att-data-oe-id="message.origin_id" href="#">#<t t-esc="message.origin_name"/></a>)
                    </t>
                    <span t-if="options.display_email_icon and message.customer_email_data and message.customer_email_data.length" class="o_thread_tooltip_container">
                        <i t-att-class="'o_thread_tooltip o_thread_message_email o_thread_message_email_' + message.customer_email_status + ' fa fa-envelope-o'"/>
                        <span class="o_thread_tooltip_content">
                            <t t-foreach="message.customer_email_data" t-as="customer">
                                <span>
                                    <t t-if="customer[2] == 'sent'"><i class='fa fa-check'/></t>
                                    <t t-if="customer[2] == 'bounce'"><i class='fa fa-exclamation'/></t>
                                    <t t-if="customer[2] == 'exception'"><i class='fa fa-exclamation'/></t>
                                    <t t-if="customer[2] == 'ready'"><i class='fa fa-send-o'/></t>
                                    <t t-esc="customer[1]"/>
                                </span>
                                <br />
                            </t>
                        </span>
                    </span>
                    <span t-attf-class="o_thread_icons">
                        <i t-if="options.display_stars &amp;&amp; !message.is_system_notification"
                            t-att-class="'fa fa-lg o_thread_icon o_thread_message_star ' + (message.is_starred ? 'fa-star' : 'fa-star-o')"
                            t-att-data-message-id="message.id" title="Mark as Todo"/>
                       <i t-if="message.record_name &amp;&amp; message.model != 'mail.channel' &amp;&amp; options.display_reply_icon"
                           class="fa fa-reply o_thread_icon o_thread_message_reply"
                           t-att-data-message-id="message.id" title="Reply"/>
                        <i t-if="message.is_needaction &amp;&amp; options.display_needactions"
                           class="fa fa-check o_thread_icon o_thread_message_needaction"
                           t-att-data-message-id="message.id" title="Mark as Read"/>
                    </span>
                </p>
                <div class="o_thread_message_content">
                    <t t-raw="message.body"/>
                    <t t-if="message.tracking_value_ids and message.tracking_value_ids.length &gt; 0">
                        <t t-if="message.subtype_description">
                            <p><t t-esc="message.subtype_description"/></p>
                        </t>
                        <t t-call="mail.ChatThread.MessageTracking"/>
                    </t>
                    <p t-if="options.display_subject and message.display_subject" class="o_mail_subject">Subject: <t t-esc="message.subject"/></p>
                     <t t-foreach="message.attachment_ids" t-as="attachment">
                         <t t-call="mail.Attachment"/>
                     </t>
                </div>
            </div>
        </div>
            </t>
        </t>
    </t>


    <t t-name="mail.Cloudoffix_Attachment">
        <t t-set="type" t-value="attachment.mimetype and attachment.mimetype.split('/').shift()"/>
        <div t-attf-class="o_attachment #{attachment.upload ? 'o_attachment_uploading' : ''}"
             t-att-title="attachment.name">
            <div class="o_image_box">
                <div class="o_image" t-att-data-mimetype="attachment.mimetype"/>
                <div t-attf-class="o_image_overlay">
                    <a class="o_attachment_download" t-att-href='attachment.url' target="_blank">
                        <i t-attf-class="fa fa-2x fa-arrow-circle-o-down" title="Download this attachment"
                           aria-hidden="true"/>
                    </a>
                </div>
            </div>
            <div class="caption">
                <a t-att-href='attachment.url' target="_blank">
                    <t t-esc='attachment.name'/>
                </a>
            </div>
            <t t-if="editable">
                <div class="o_attachment_delete">
                    <i class='fa fa-times-circle' title="Delete this attachment" t-att-data-id="attachment.id"/>
                </div>
                <div class="o_attachment_progress_bar">
                    Uploading
                </div>
            </t>
        </div>
    </t>

    <t t-name="mail.ChatComposer.Attachments.Cloudoffix">
        <div t-if="attachments.length > 0" class="o_attachments">
            <t t-foreach="attachments" t-as='attachment'>
                <t t-call="mail.Cloudoffix_Attachment">
                     <t t-set="editable" t-value="true"/>
                </t>
            </t>
        </div>
    </t>
</templates>
