<vn-descriptor-content
    module="client"
    description="$ctrl.client.name"
    summary="$ctrl.$.summary">
    <slot-menu>
        <a class="vn-item"
            ui-sref="ticket.create({clientFk: $ctrl.client.id})"
            name="simpleTicket"
            translate>
            Simple ticket
        </a>
        <vn-item
            ng-click="$ctrl.showSMSDialog()"
            translate>
            Send SMS
        </vn-item>
    </slot-menu>
    <slot-body>
        <div class="attributes">
            <vn-label-value
                label="Pay method" 
                value="{{$ctrl.client.payMethod.name}}">
            </vn-label-value>
            <vn-label-value
                label="Credit" 
                value="{{$ctrl.client.credit | currency: 'EUR': 2}}">
            </vn-label-value>
            <vn-label-value
                label="Secured credit" 
                value="{{$ctrl.client.creditInsurance | currency: 'EUR': 2}}">
            </vn-label-value>
            <vn-label-value
                label="Risk" 
                value="{{$ctrl.client.debt | currency: 'EUR':2}}"
                ng-class="{alert: $ctrl.client.debt > $ctrl.client.credit}"
                info="Invoices minus payments  plus orders not yet invoiced">  
            </vn-label-value>
            <vn-label-value
                label="Sales person">
                <span 
                    ng-click="workerDescriptor.show($event, $ctrl.client.salesPersonFk)"
                    class="link">
                    {{$ctrl.client.salesPersonUser.name}}
                </span>
            </vn-label-value>
        </div>
        <div class="icons">
            <vn-icon
                vn-tooltip="Client inactive"
                icon="icon-disabled"
                ng-if="$ctrl.client.isActive == false">
            </vn-icon>
            <vn-icon
                vn-tooltip="Client frozen"
                icon="icon-frozen"
                ng-if="$ctrl.client.isFreezed == true">
            </vn-icon>
            <vn-icon
                vn-tooltip="Web Account inactive"
                icon="icon-noweb"
                ng-if="$ctrl.client.account.active == false">
            </vn-icon>
            <vn-icon
                vn-tooltip="Client has debt"
                icon="icon-risk"
                ng-if="$ctrl.client.debt > $ctrl.client.credit">
            </vn-icon>
            <vn-icon
                vn-tooltip="Client not checked"
                icon="icon-no036"
                ng-if="$ctrl.client.isTaxDataChecked == false">
            </vn-icon>
        </div>
        <div class="quicklinks">
            <div ng-transclude="btnOne">
                <vn-quick-link
                    tooltip="Client ticket list"
                    state="['ticket.index', {q: $ctrl.filter}]"
                    icon="icon-ticket">
                </vn-quick-link>
            </div>
            <div ng-transclude="btnTwo">
                <vn-quick-link
                    tooltip="Client invoices list"
                    state="['invoiceOut.index', {q: $ctrl.filter}]"
                    icon="icon-invoice">
                </vn-quick-link>
            </div>
            <div ng-transclude="btnThree">
                <vn-quick-link
                    tooltip="New order"
                    state="['order.create', {clientFk: $ctrl.id}]"
                    icon="icon-basketadd">
                </vn-quick-link>
            </div>
            <div ng-transclude="btnFour">
                <vn-quick-link
                    vn-acl="hr"
                    vn-acl-action="remove"
                    tooltip="Go to user"
                    state="['account.card.summary', {id: $ctrl.id}]"
                    icon="face">
                </vn-quick-link>
            </div>
            <div ng-transclude="btnFive">
                <vn-quick-link
                    ng-if="$ctrl.client.supplier.nif"
                    tooltip="Go to supplier"
                    state="['supplier.card.summary', {id: $ctrl.client.supplier.id}]"
                    icon="icon-supplier">
                </vn-quick-link>
            </div>
        </div>
    </slot-body>
</vn-descriptor-content>
<vn-client-sms
    vn-id="sms"
    sms="$ctrl.newSMS">
</vn-client-sms>
<vn-worker-descriptor-popover 
    vn-id="workerDescriptor">
</vn-worker-descriptor-popover>
<vn-popup vn-id="summary">
    <vn-client-summary client="$ctrl.client"></vn-client-summary>
</vn-popup>