<div class="vn-descriptor">
    <div class="header">
        <a translate-attr="{title: 'Return to module index'}" ui-sref="ticket.index">
            <vn-icon icon="chevron_left"></vn-icon>
        </a>
        <a translate-attr="{title: 'Preview'}" ui-sref="ticket.card.summary({id: $ctrl.ticket.id})">
            <vn-icon icon="desktop_windows"></vn-icon>
        </a>
        <vn-icon-menu
            vn-id="more-button"
            icon="more_vert"
            show-filter="false"
            value-field="callback"
            translate-fields="['name']"
            data="$ctrl.moreOptions"
            on-change="$ctrl.onMoreChange(value)"
            on-open="$ctrl.onMoreOpen()">
        </vn-icon-menu>
    </div>
    <div class="body">
        <div class="attributes">
            <h5>{{::$ctrl.client.name}}</h5>
            <vn-label-value label="Id" 
                value="{{$ctrl.ticket.id}}">
            </vn-label-value>
            <vn-label-value label="Client" 
                value="{{$ctrl.ticket.client.name}}">
            </vn-label-value>
            <vn-label-value label="State" 
                value="{{$ctrl.ticket.state.state.name}}">
            </vn-label-value>
            <vn-label-value label="Sales person"
                value="{{$ctrl.ticket.client.salesPerson.user.nickname}}">
            </vn-label-value>
            <vn-label-value label="Shipped"
                value="{{$ctrl.ticket.shipped | date: 'dd/MM/yyyy HH:mm' }}">
            </vn-label-value>
            <vn-label-value label="Agency"
                value="{{$ctrl.ticket.agencyMode.name}}">
            </vn-label-value>
            <vn-label-value label="Warehouse"
                value="{{$ctrl.ticket.warehouse.name}}">
            </vn-label-value>
            <vn-label-value label="Alias"
                value="{{$ctrl.ticket.nickname}}">
            </vn-label-value>
        </div>
        <div class="icons">
            <vn-icon vn-one
                vn-tooltip="Client inactive"
                icon="icon-disabled"
                ng-class="{bright: $ctrl.ticket.client.isActive == false}">
            </vn-icon>
            <vn-icon vn-one
                vn-tooltip="Client frozen"
                icon="icon-frozen"
                ng-class="{bright: $ctrl.ticket.client.isFreezed == true}">
            </vn-icon>
            <vn-icon vn-one
                vn-tooltip="Client has debt"
                icon="icon-risk"
                ng-class="{bright: $ctrl.ticket.client.debt > $ctrl.ticket.client.credit}">
            </vn-icon>
            <vn-icon vn-one
                vn-tooltip="Client not checked"
                icon="icon-no036"
                ng-class="{bright: $ctrl.ticket.client.isTaxDataChecked == false}">
            </vn-icon>
            <vn-icon vn-one
                vn-tooltip="Deleted ticket"
                icon="icon-deletedTicket"
                ng-class="{bright: $ctrl.ticket.isDeleted == true}">
            </vn-icon>
        </div>
        <vn-quick-links
            links="$ctrl.quicklinks">
        </vn-quick-links>
        <div style="text-align: center">
            <vn-button-menu
                ng-if="$ctrl.ticket.ship.length > 1"
                vn-id="stowaways-button"
                icon="icon-stowaway"
                show-filter="false"
                show-field="id"
                value-field="id"
                vn-tooltip="Ship stowaways"
                tooltip-position="up"
                data="$ctrl.ticket.ship"
                on-change="$ctrl.goToTicket(value)">
            </vn-button-menu>
        </div>
    </div>
</div>
<vn-popup vn-id="addTurn">
    <div class="vn-pa-md">
        <h5 style="text-align: center">
            <span translate>In which day you want to add the ticket?</span>
        </h5>
        <vn-tool-bar class="vn-mt-md">
            <vn-button
                label="Monday" 
                ng-click="$ctrl.addTurn(0)">
            </vn-button>
            <vn-button
                label="Tuesday" 
                ng-click="$ctrl.addTurn(1)">
            </vn-button>
            <vn-button
                label="Wednesday" 
                ng-click="$ctrl.addTurn(2)">
            </vn-button>
            <vn-button
                label="Thursday" 
                ng-click="$ctrl.addTurn(3)">
            </vn-button>
            <vn-button
                label="Friday" 
                ng-click="$ctrl.addTurn(4)">
            </vn-button>
            <vn-button
                label="Saturday" 
                ng-click="$ctrl.addTurn(5)">
            </vn-button>
            <vn-button
                label="Sunday" 
                ng-click="$ctrl.addTurn(6)">
            </vn-button>
        </vn-tool-bar>
    </div>
</vn-popup>
<vn-confirm
    vn-id="deleteConfirmation"
    on-response="$ctrl.deleteTicket($response)"
    question="You are going to delete this ticket"
    message="This ticket will be removed from current route! Continue anyway?">
</vn-confirm>
<vn-add-stowaway
    vn-id="addStowaway" 
    card-reload="$ctrl.cardReload()" 
    ticket="$ctrl.ticket">
</vn-add-stowaway>
<vn-remove-stowaway
    vn-id="removeStowaway" 
    card-reload="$ctrl.cardReload()"
    ticket="$ctrl.ticket">
</vn-remove-stowaway>
<vn-confirm
    vn-id="confirm-dialog"
    on-response="$ctrl.returnDialog($response)"
    question="Pickup order"
    message="Do you want to send it directly?">
</vn-confirm>
<vn-dialog
    vn-id="changeShippedDialog"
    on-response="$ctrl.changeShipped($response)">
    <tpl-body>
        <div>
            <h5 style="text-align: center">
                <span translate>Change shipped hour</span>
            </h5>
            <vn-input-time
                vn-id="newShipped"
                vn-one
                ng-model="$ctrl.newShipped"
                label="Shipped hour"
                vn-focus>
            </vn-input-time>
        </div>
    </tpl-body>
    <tpl-buttons>
        <input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
        <button response="accept" translate>Save</button>
    </tpl-buttons>
</vn-dialog>

<!-- Make invoice dialog -->
<vn-confirm
    vn-id="makeInvoiceConfirmation"
    on-response="$ctrl.makeInvoice($response)"
    question="You are going to invoice this ticket"
    message="Are you sure you want to invoice this ticket?">
</vn-confirm>
<!-- Make invoice dialog -->

<!-- Regenerate invoice dialog -->
<vn-confirm
    vn-id="regenerateInvoiceConfirmation"
    on-response="$ctrl.regenerateInvoice($response)"
    question="You are going to regenerate the invoice"
    message="Are you sure you want to regenerate the invoice?">
</vn-confirm>
<!-- Regenerate invoice dialog -->

<!-- SMS Dialog -->
<vn-client-sms vn-id="sms" sms="$ctrl.newSMS"></vn-client-sms>
<!-- SMS Dialog -->

<vn-confirm
    vn-id="confirm-delivery-note"
    on-accept="$ctrl.sendDeliveryNote()"
    question="Are you sure you want to send it?"
    message="Send Delivery Note">
</vn-confirm>

<vn-confirm
    vn-id="recalculate-components-confirmation"
    on-accept="$ctrl.recalculateComponents()"
    question="Are you sure you want to recalculate the components?"
    message="Recalculate components">
</vn-confirm>