<template>
    <div class="row m-b-10 parentContainer ">
        <div class="col">
            <div class="row">
                <div class="col">
                    <div class="row align-items-center pointer p-b-10 b-b b-grey" @click="activate()">
                        <div class="col-auto p-r-0">
                            <div class="b-grey b-a fs-10 btn-rounded icon-thumbnail icon-25 m-r-0" :class="[{'bg-primary': active}, {'bg-transparent': !active}]">
                                <i class="fa fa-check text-white fs-12 fa-fw"></i>
                            </div>
                        </div>
                        <div class="col p-t-5 p-b-5">
                            <div class="row">
                                <div class="col">
                                    <div class="row m-b-10">
                                        <div class="col-auto">
                                            <div class="font-heading fs-10 muted all-caps">Date</div>
                                            <div class="font-heading fs-10">
                                                {{item.payment_method === 5 || item.payment_method === 4 ? item.updated_at : item.documents.created_at}}
                                            </div>
                                        </div>
                                        <div class="col text-right">
                                            <div class="font-heading fs-10 muted all-caps">timer</div>
                                            <div class="font-heading fs-12 bold" :class="[{'text-success': item.interval.value === '+'}, {'text-danger': item.interval.value === '-'}]">
                                                {{item.interval.value}}
                                                {{item.interval.duration}}
                                                days
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row m-b-10">
                                        <div class="col-auto">
                                            <div class="font-heading fs-10 muted all-caps">reference</div>
                                            <div class="font-heading fs-10">
                                                <a :href="route('booking.details', item.booking.marking)">{{item.booking.marking}}</a>
                                            </div>
                                        </div>
                                        <div class="col-auto">
                                            <div class="font-heading fs-10 muted all-caps">Marking</div>
                                            <div class="font-heading fs-10">
                                                <a :href="route('customer.profile', item.booking.company.reference)">{{item.booking.company.reference}}</a>
                                            </div>
                                        </div>
                                        <div class="col-auto">
                                            <div class="font-heading fs-10 muted all-caps">Currency</div>
                                            <div class="font-heading fs-10">
                                                <span class="flag-icon" :class="'flag-icon-'+item.original_currency.country.short_code.toLowerCase()"></span> {{item.original_currency.short_code}}
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-auto">
                                            <div class="font-heading fs-10 muted all-caps">Payment Proof</div>
                                            <div class="row no-margin" v-if="item.payment_method !==5 && item.payment_method !==4">
                                                <div v-for="file in item.documents.files" v-bind:key="file.id"  class="col-auto no-padding">
                                                    <document-file-viewer-component :file="file">
                                                        <template slot="button">
                                                            <div class="icon-thumbnail fs-11 text-white icon-25 bg-primary btn-rounded float-left m-r-5">
                                                                <i class="fa fa-file-image-o fs-10"></i>
                                                            </div>
                                                        </template>
                                                    </document-file-viewer-component>
                                                </div>
                                            </div>
                                            <div class="row no-margin" v-if="item.payment_method ===5">
                                                <div class="col no-padding">
                                                    <a :href="route('billplz.bill', item.payment_reference)" target="_blank">
                                                        <div class="icon-thumbnail fs-11 text-white icon-25 bg-complete btn-rounded float-left m-r-5">
                                                            Bz
                                                        </div>
                                                    </a>
                                                </div>
                                            </div>
                                            <div class="row no-margin" v-if="item.payment_method ===4">
                                                <div class="col no-padding">
                                                    <div class="font-heading fs-10">{{item.payment_reference}}</div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-auto">
                                            <div class="font-heading fs-10 muted all-caps">Service</div>
                                            <div class="font-heading fs-10">
                                                {{item.booking.service.name}}
                                            </div>
                                        </div>
                                        <div class="col text-right">
                                            <div class="font-heading fs-10 muted all-caps">Amount</div>
                                            <div class="font-heading fs-14 text-success bold">
                                                {{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import componentHandler from '../../../general/mixins/componentHandler';
    export default {
        data(){
            return {
                active: false,
            }
        },
        methods: {
            activate(){
                this.active = !this.active;
                this.$emit('input', this.item)
            }
        },
        mixins: [componentHandler]
    }
</script>
