<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="0">
    <record id="email_template_media_movement" model="mail.template">
        <field name="name">Media Movement</field>
        <field name="email_from">{{ user.email }}</field>
        <field name="subject">Library Card Renew</field>
        <field name="email_to">{{ object.student_id.user_id.partner_id.id }}</field>
        <field name="partner_to">{{ object.student_id.user_id.partner_id.id }}</field>
        <field name="model_id" ref="openeducat_library.model_op_media_movement"/>
        <field name="auto_delete" eval="True"/>
        <!-- <field name="report_name">Renew</field> -->
        <field name="lang">{{ object.student_id.user_id.partner_id.lang }}</field>
        <field name="body_html" type="html">
            <table border="0" cellpadding="0" cellspacing="0"
                   style="padding-top: 16px; background-color: #F1F1F1; font-family:Verdana, Arial,sans-serif; color: #454748; width: 100%; border-collapse:separate;">
                <tr>
                    <td align="center">
                        <table border="0" cellpadding="0" cellspacing="0" width="590"
                               style="padding: 16px; background-color: white; color: #454748; border-collapse:separate;">
                            <tbody>
                                <tr>
                                    <td align="center" style="min-width: 590px;">
                                        <table border="0" cellpadding="0" cellspacing="0" width="590"
                                               style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
                                            <tr>
                                                <td valign="middle">
                                                    <span style="font-size: 10px;">Library Card Renew</span>
                                                    <br/>
                                                </td>
                                                <td valign="middle" align="right">
                                                    <img t-att-src="'/logo.png?company=%s' % object.company_id.id"
                                                         style="padding: 0px; margin: 0px; height: auto; width: 80px;"
                                                         t-att-alt="'%s' % object.company_id.name"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" style="text-align:center;">
                                                    <hr width="100%"
                                                        style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:16px 0px 16px 0px;"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" style="min-width: 590px;">
                                        <table border="0" cellpadding="0" cellspacing="0" width="590"
                                               style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
                                            <tr>
                                                <td valign="top" style="font-size: 13px;">
                                                    <p>Dear</p>
                                                    <strong>
                                                        <t t-out="object.student_id.name or ''"/>
                                                    </strong>
                                                    <p>Your<t t-out="object.media_type_id.name or ''"/>,
                                                        <strong>
                                                            <t t-out="object.media_id.name or ''"/>
                                                        </strong>
                                                        will
                                                        <t t-if="object.get_diff_day() == 0">
                                                            be expiring
                                                            <strong>today.</strong>
                                                        </t>
                                                        <t t-else="">
                                                            expire in
                                                            <strong>
                                                                <t t-out="object.get_diff_day() or ''"/>
                                                            </strong>
                                                            day(s).
                                                        </t>
                                                        Please return it as soon as possible.
                                                    </p>
                                                    <p>Thank you.</p>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="text-align:center;">
                                                    <hr width="100%"
                                                        style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" style="min-width: 590px;">
                                        <table border="0" cellpadding="0" cellspacing="0" width="590"
                                               style="min-width: 590px; background-color: white; font-size: 11px; padding: 0px 8px 0px 8px; border-collapse:separate;">
                                            <tr>
                                                <td valign="middle" align="left">
                                                    <t t-out="object.company_id.name or ''"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td valign="middle" align="left" style="opacity: 0.7;">
                                                    <t t-out="object.company_id.phone or ''"/>
                                                    <t t-if="object.company_id.email">
                                                        |
                                                        <a href="'mailto:%s' % {{ object.company_id.email }}"
                                                           style="text-decoration:none; color: #454748;">
                                                            <t t-out="object.company_id.email or ''"/>
                                                        </a>
                                                    </t>
                                                    <t t-if="object.company_id.website">
                                                        |
                                                        <a href="'%s' % {{ object.company_id.website }}"
                                                           style="text-decoration:none; color: #454748;">
                                                            <t t-out="object.company_id.website or ''"/>
                                                        </a>
                                                    </t>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </table>
        </field>
    </record>

    <record id="library_card_media_movement_action" model="ir.actions.server">
        <field name="name">Server Actions Media Movement</field>
        <field name="model_id" ref="openeducat_library.model_op_media_movement"/>
        <field name="state">mail_post</field>
        <field name="template_id" ref="email_template_media_movement"/>
    </record>

    <record id="test_rule_media_movement_line_1" model="base.automation">
        <field name="name">Media Movement Line Before 1 Days</field>
        <field name="trigger">on_time</field>
        <field name="model_id" ref="openeducat_library.model_op_media_movement"/>
        <field name="trg_date_id" search="[('model','=','op.media.movement'),('name','=','return_date')]"/>
        <field name="trg_date_range">1</field>
        <field name="trg_date_range_type">day</field>
    </record>

    <record id="email_template_media_movement_after" model="mail.template">
        <field name="name">Media Movement After Due Date Passed</field>
        <field name="email_from">{{ user.email }}</field>
        <field name="subject">Library Card Expired</field>
        <field name="email_to">{{ object.student_id.user_id.partner_id.id }}</field>
        <field name="partner_to">{{ object.student_id.user_id.partner_id.id }}</field>
        <field name="model_id" ref="openeducat_library.model_op_media_movement"/>
        <field name="auto_delete" eval="True"/>
        <!-- <field name="report_name">Library Card Expired</field> -->
        <field name="lang">{{ object.student_id.user_id.partner_id.lang }}</field>
        <field name="body_html" type="html">
            <table border="0" cellpadding="0" cellspacing="0"
                   style="padding-top: 16px; background-color: #F1F1F1; font-family:Verdana, Arial,sans-serif; color: #454748; width: 100%; border-collapse:separate;">
                <tr>
                    <td align="center">
                        <table border="0" cellpadding="0" cellspacing="0" width="590"
                               style="padding: 16px; background-color: white; color: #454748; border-collapse:separate;">
                            <tbody>
                                <tr>
                                    <td align="center" style="min-width: 590px;">
                                        <table border="0" cellpadding="0" cellspacing="0" width="590"
                                               style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
                                            <tr>
                                                <td valign="middle">
                                                    <span style="font-size: 10px;"/>
                                                    <br/>
                                                </td>
                                                <td valign="middle" align="right">
                                                    <img t-att-src="'/logo.png?company=%s' % object.company_id.id"
                                                         style="padding: 0px; margin: 0px; height: auto; width: 80px;"
                                                         t-att-alt="'%s' % object.company_id.name"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" style="text-align:center;">
                                                    <hr width="100%"
                                                        style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:16px 0px 16px 0px;"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" style="min-width: 590px;">
                                        <table border="0" cellpadding="0" cellspacing="0" width="590"
                                               style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
                                            <tr>
                                                <td valign="top" style="font-size: 13px;">
                                                    <p>Dear </p>
                                                    <strong>
                                                         <t t-out="object.student_id.name or ''"/></strong>
                                                    <p>Your  <t t-out="object.media_type_id.name or ''"/>, <strong>
                                                         <t t-out="object.media_id.name or ''"/>
                                                    </strong> has been expired. Please return it as soon as possible.
                                                    </p>
                                                    <p>Thank you.</p>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="text-align:center;">
                                                    <hr width="100%"
                                                        style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" style="min-width: 590px;">
                                        <table border="0" cellpadding="0" cellspacing="0" width="590"
                                               style="min-width: 590px; background-color: white; font-size: 11px; padding: 0px 8px 0px 8px; border-collapse:separate;">
                                            <tr>
                                                <td valign="middle" align="left">
                                                    <t t-out="object.company_id.name or ''"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td valign="middle" align="left" style="opacity: 0.7;">
                                                    <t t-out="object.company_id.phone or ''"/>
                                                    <t t-if="object.company_id.email">
                                                        |
                                                        <a href="'mailto:%s' % {{ object.company_id.email }}"
                                                           style="text-decoration:none; color: #454748;">
                                                            <t t-out="object.company_id.email or ''"/>
                                                        </a>
                                                    </t>
                                                    <t t-if="object.company_id.website">
                                                        |
                                                        <a href="'%s' % {{ object.company_id.website }}"
                                                           style="text-decoration:none; color: #454748;">
                                                            <t t-out="object.company_id.website or ''"/>
                                                        </a>
                                                    </t>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </table>
        </field>
    </record>

    <record id="library_card_media_movement_action_after" model="ir.actions.server">
        <field name="name">Server Actions Media Movement After 1 Days</field>
        <field name="model_id" ref="openeducat_library.model_op_media_movement"/>
        <field name="state">mail_post</field>
        <field name="template_id" ref="email_template_media_movement_after"/>
    </record>

    <record id="test_rule_media_movement_line_after" model="base.automation">
        <field name="name">Media Movement Line After 1 Days</field>
        <field name="trigger">on_time</field>
        <field name="model_id" ref="openeducat_library.model_op_media_movement"/>
        <field name="trg_date_id" search="[('model','=','op.media.movement'),('name','=','return_date')]"/>
        <field name="trg_date_range">1</field>
        <field name="trg_date_range_type">day</field>
    </record>
</odoo>
