﻿<div x-data="{ open: {{ request()->routeIs('banking.*') ? 'true' : 'false' }} }" class="mb-1">
    <button @click="open = !open" class="group flex items-center p-3 py-2 text-base font-medium rounded-md
        {{ request()->routeIs('banking.*') ? 'bg-red-100 text-red-800' : 'text-gray-700 hover:bg-red-50 hover:text-red-800' }}">
        <svg xxmlns="http://www.w3.org/2000/svg" class="ml-3 flex-shrink-0 h-6 w-6
            {{ request()->routeIs('banking.*') ? 'text-red-700' : 'text-gray-500 group-hover:text-red-700' }}"
            fill="none" viewBox="0 0 24 24" stroke="currentColor">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                d="M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3" />
        </svg>
        <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Banking System', __('Banking System')) }}</span>
        <svg :class="{'rotate-180': open, 'rotate-0': !open}" class="mr-auto h-5 w-5 transform transition-transform duration-200"
            xxmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
            <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
        </svg>
    </button>
    <div x-show="open" x-transition class="pr-4 mr-4 border-r border-gray-200">
        @permission('banking.view')
        <a href="{{ route('banking.banks.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('banking.banks.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.banks.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Banks', __('Banks')) }}</span>
        </a>
        @endpermission

        @permission('banking.create')
        <a href="{{ route('banking.banks.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('banking.banks.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.banks.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Bank', __('Add New Bank')) }}</span>
        </a>
        @endpermission

        @permission('banking.accounts.view')
        <a href="{{ route('banking.accounts.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('banking.accounts.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.accounts.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Bank Accounts', __('Bank Accounts')) }}</span>
        </a>
        @endpermission

        @permission('banking.deposits.view')
        <a href="{{ route('banking.deposits.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('banking.deposits.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.deposits.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Bank Deposits', __('Bank Deposits')) }}</span>
        </a>
        @endpermission

        @permission('banking.withdrawals.view')
        <div x-data="{ openWithdrawals: {{ request()->routeIs('banking.withdrawals.*') ? 'true' : 'false' }} }">
            <button @click="openWithdrawals = !openWithdrawals" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                {{ request()->routeIs('banking.withdrawals.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.withdrawals.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Bank Withdrawals', __('Bank Withdrawals')) }}</span>
                <svg :class="{'rotate-180': openWithdrawals, 'rotate-0': !openWithdrawals}" class="mr-auto h-4 w-4 transform transition-transform duration-200"
                    xxmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
                    <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                </svg>
            </button>
            <div x-show="openWithdrawals" x-transition class="pr-4 mr-4 border-r border-gray-200">
                <a href="{{ route('banking.withdrawals.index') }}" class="group flex items-center p-3 py-2 text-s font-medium rounded-md
                    {{ request()->routeIs('banking.withdrawals.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                    <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.withdrawals.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                    <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('All Withdrawals', __('All Withdrawals')) }}</span>
                </a>
                @permission('banking.withdrawals.create')
                <a href="{{ route('banking.withdrawals.create') }}" class="group flex items-center p-3 py-2 text-s font-medium rounded-md
                    {{ request()->routeIs('banking.withdrawals.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                    <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.withdrawals.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                    <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Withdrawal Bond', __('Add New Withdrawal Bond')) }}</span>
                </a>
                @endpermission
            </div>
        </div>
        @endpermission

        @permission('banking.checks.view')
        <div x-data="{ openChecks: {{ request()->routeIs('banking.checks.*') ? 'true' : 'false' }} }">
            <button @click="openChecks = !openChecks" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                {{ request()->routeIs('banking.checks.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.checks.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Checks', __('Checks')) }}</span>
                <svg :class="{'rotate-180': openChecks, 'rotate-0': !openChecks}" class="mr-auto h-4 w-4 transform transition-transform duration-200"
                    xxmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
                    <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                </svg>
            </button>
            <div x-show="openChecks" x-transition class="pr-4 mr-4 border-r border-gray-200">
                <a href="{{ route('banking.checks.index') }}" class="group flex items-center p-3 py-2 text-s font-medium rounded-md
                    {{ request()->routeIs('banking.checks.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                    <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.checks.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                    <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('All Checks', __('All Checks')) }}</span>
                </a>
                <a href="{{ route('banking.checks.portfolio') }}" class="group flex items-center p-3 py-2 text-s font-medium rounded-md
                    {{ request()->routeIs('banking.checks.portfolio') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                    <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.checks.portfolio') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                    <span class="font-bold text-blue-700">{{ \App\Helpers\TranslationHelper::transFromDatabase('Cheque Portfolio', __('Cheque Portfolio')) }}</span>
                </a>
                <a href="{{ route('banking.checks.incoming') }}" class="group flex items-center p-3 py-2 text-s font-medium rounded-md
                    {{ request()->routeIs('banking.checks.incoming') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                    <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.checks.incoming') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                    <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Incoming Checks', __('Incoming Checks')) }}</span>
                </a>
                <a href="{{ route('banking.checks.outgoing') }}" class="group flex items-center p-3 py-2 text-s font-medium rounded-md
                    {{ request()->routeIs('banking.checks.outgoing') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                    <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.checks.outgoing') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                    <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Outgoing Checks', __('Outgoing Checks')) }}</span>
                </a>
                @permission('banking.checks.create')
                <a href="{{ route('banking.checks.create') }}" class="group flex items-center p-3 py-2 text-s font-medium rounded-md
                    {{ request()->routeIs('banking.checks.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                    <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.checks.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                    <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Check', __('Add New Check')) }}</span>
                </a>
                @endpermission
            </div>
        </div>
        @endpermission

        @permission('banking.reconciliations.view')
        <a href="{{ route('banking.reconciliations.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('banking.reconciliations.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.reconciliations.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Bank Reconciliations', __('Bank Reconciliations')) }}</span>
        </a>
        @endpermission

        @permission('banking.reports.view')
        <a href="{{ route('banking.reports.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('banking.reports.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('banking.reports.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Banking Reports', __('Banking Reports')) }}</span>
        </a>
        @endpermission
    </div>
</div>
