<!--
Copyright 2020 Netsyms Technologies.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->

<div class="page" data-name="machine">

    <div class="navbar">
        <div class="navbar-bg"></div>
        <div class="navbar-inner">
            <div class="left">
                <a href="#" class="link icon-only back">
                    <i class="icon icon-back"></i>
                </a>
            </div>
            <div class="title"><i class="{{icon}}"></i> {{type.label}} #{{machineid}}</div>
            <div class="right">
                <a href="#" class="link icon-only" onclick="router.refreshPage()">
                    <i class="icon material-icons">refresh</i>
                </a>
            </div>
        </div>
    </div>

    {{#if editable}}
    <div class="fab fab-extended fab-right-bottom color-green" id="event-fab">
        <a href="#" onclick="openEventAddScreen('{{machineid}}');">
            <!-- Icons For iOS Theme -->
            <i class="icon f7-icons if-not-md">plus</i>
            <!-- Icons For MD Theme -->
            <i class="icon material-icons md-only">add</i>
            <div class="fab-text">Add Event</div>
        </a>
    </div>

    <div class="fab fab-left-bottom">
        <a href="#">
            <!-- Icons For iOS Theme -->
            <i class="icon f7-icons if-not-md">plus</i>
            <i class="icon f7-icons if-not-md">xmark</i>
            <!-- Icons For MD Theme -->
            <i class="icon material-icons md-only">more_vert</i>
            <i class="icon material-icons md-only">close</i>
        </a>
        <div class="fab-buttons fab-buttons-top">
            <a href="/machineeditor/{{machineid}}" class="fab-label-button">
                <span class="material-icons">edit</span>
                <span class="fab-label">Edit</span>
            </a>
            <a href="/labels/{{machineid}}" class="fab-label-button">
                <span class="material-icons">print</span>
                <span class="fab-label">Labels</span>
            </a>
        </div>
    </div>
    {{else}}
    <div class="fab fab-left-bottom" id="label-fab">
        <a href="#">
            <span class="material-icons">print</span>
        </a>
    </div>
    {{/if}}

    <div class="toolbar tabbar toolbar-top">
        <div class="toolbar-inner">
            <a href="#tab-info" class="tab-link tab-link-active">Info</a>
            <a href="#tab-events" class="tab-link">Events</a>
            <a href="#tab-client" class="tab-link">Client</a>
        </div>
    </div>

    <div class="tabs-swipeable-wrap">
        <div class="tabs">
            <div id="tab-info" class="page-content tab tab-active">
                <div class="list no-margin-top">
                    <ul>
                        {{#each machineprops}}
                        {{#if value}}
                        <li>
                            <div class="item-content">
                                <div class="item-inner">
                                    <div class="item-title" style="white-space: normal !important;">
                                        <div class="item-header"><i class="{{icon}}"></i> {{label}}</div>
                                        {{value}}
                                    </div>
                                </div>
                            </div>
                        </li>
                        {{/if}}
                        {{/each}}
                    </ul>
                </div>
            </div>

            <div id="tab-events" class="page-content tab">
                <div class="list accordion-list no-margin-top">
                    <ul>
                        {{#each events}}
                        <li class="accordion-item">
                            <a href="#" class="item-content item-link">
                                <div class="item-inner">
                                    <div class="item-title">{{name}}</div>
                                    <div class="item-after">{{shortdate}}</div>
                                </div>
                            </a>
                            <div class="accordion-item-content">
                                <div class="list">
                                    <ul>
                                        <li>
                                            <div class="item-content">
                                                <div class="item-inner">
                                                    <div class="item-title" style="white-space: normal !important;">
                                                        <div class="item-header">Date/Time</div>
                                                        {{date}}
                                                    </div>
                                                </div>
                                            </div>
                                        </li>
                                        {{#if privatenotes}}
                                        <li>
                                            <div class="item-content">
                                                <div class="item-inner">
                                                    <div class="item-title" style="white-space: normal !important;">
                                                        <div class="item-header">Private Notes</div>
                                                        {{privatenotes}}
                                                    </div>
                                                </div>
                                            </div>
                                        </li>
                                        {{/if}}
                                        {{#if publicnotes}}
                                        <li>
                                            <div class="item-content">
                                                <div class="item-inner">
                                                    <div class="item-title" style="white-space: normal !important;">
                                                        <div class="item-header">Public Notes</div>
                                                        {{publicnotes}}
                                                    </div>
                                                </div>
                                            </div>
                                        </li>
                                        {{/if}}
                                    </ul>
                                </div>
                            </div>
                        </li>
                        {{/each}}
                    </ul>
                </div>
            </div>

            <div id="tab-client" class="page-content tab">
                {{#if clientinfo}}
                {{#with clientinfo}}
                <div class="list no-margin-top">
                    <ul>
                        <li>
                            <div class="item-content">
                                <div class="item-inner">
                                    <div class="item-title">
                                        <div class="item-header">Name</div>
                                        {{name}}
                                    </div>
                                </div>
                            </div>
                        </li>
                        {{#if phone}}
                        <li>
                            <a class="item-content item-link" href="tel:{{phonestripped}}" target="_system">
                                <div class="item-inner">
                                    <div class="item-title">
                                        <div class="item-header">Phone</div>
                                        {{phone}}
                                    </div>
                                </div>
                            </a>
                        </li>
                        {{/if}}
                        {{#if billingaddress}}
                        <li>
                            <div class="item-content">
                                <div class="item-inner">
                                    <div class="item-title">
                                        <div class="item-header">Billing Address</div>
                                        {{billingaddress}}
                                    </div>
                                </div>
                            </div>
                        </li>
                        {{/if}}
                        {{#if mailingaddress}}
                        <li>
                            <div class="item-content">
                                <div class="item-inner">
                                    <div class="item-title">
                                        <div class="item-header">Mailing Address</div>
                                        {{mailingaddress}}
                                    </div>
                                </div>
                            </div>
                        </li>
                        {{/if}}
                    </ul>
                </div>
                {{/with}}
                {{else}}
                <div class="block">No client has been linked.</div>
                {{/if}}
            </div>
        </div>
    </div>

    <script>
        var machineid = "{{machineid}}";
    </script>
</div>