<template>
    <v-card
        tile
        flat
        :height="app.height"
        :width="app.width"
        class="mx-auto overflow-x-auto overflow-y-hidden"
    >  
        <v-card-title class="pa-1">
            <image-icon 
                :src="app.url + 'imgs/blue-icons/contract.png'"
            />
            {{ __('Contracte') }}

            <v-spacer></v-spacer>
            
            <cs-quick-search 
                :dataprovider="dataprovider" 
                class="mr-2"
            />

            <cs-records-count 
                :dataprovider="dataprovider"
                field="itemsCount"
            >
                <cs-btn-reload 
                    :dataprovider="dataprovider" 
                />
            </cs-records-count>
        </v-card-title>

        <v-card-subtitle class="pl-12 py-0 my-0">
            {{ __('Lista contractelor') }}
        </v-card-subtitle>

        <cs-toolbar 
            :toolbar="toolbar"
        >
            <v-sheet 
                max-width="200"
                class="transparent text-truncate text-orange font-weight-bold"
            >
               {{ activeContract ? activeContract.number : '' }}
            </v-sheet>
        </cs-toolbar>

        <v-sheet
            :height="app.height - 114"
            :width="app.width"
        >
            <contracte-datatable 
                :app="app"
                :dataprovider="dataprovider"
                :height="app.height  - 114"
                :width="app.width"
            />
        </v-sheet>
    </v-card>
</template>

<script>
    export default {
        props: {
            app: {required: true},
        },

        computed: {
            dataprovider() {
                return this.app.dataSession.Contracte;
            },

            toolbar() {
                return this.app.menus.Contractetoolbar;
            },

            activeContract() {
                return this.app.classes.Controller.activeContract;
            }
        },

        components: {
            ImageIcon: require('@CsVueComp/helpers/images/ImageIcon').default,
            CsRecordsCount: require('@CsVueComp/dataprovider/CsRecordsCount').default,
            CsQuickSearch: require('@CsVueComp/dataprovider/CsQuickSearch').default,
            CsBtnReload: require('@CsVueComp/buttons/CsBtnReload').default,
            CsToolbar: require('@CsVueComp/menus/toolbar/CsToolbar').default,
        },

        name: 'ContractePage',
    }
</script>