<script>
    $(document).ready(function () {
        $('#type-list').select2();
        $('#category-list').select2();
        $('#current-asset-list').select2();

        $('#type-list').on('change', function (){
            let type = $(this).val();
            $('#type-label').addClass('error');
            if(type != ""){
                if(type == 'BS'){
                    $('#bs-account-div').show();
                    $('#pl-account-div').hide();

                }else if(type == 'PL'){
                    $('#pl-account-div').show();
                    $('#bs-account-div').hide();
                }
                $('#type-label').removeClass('error');
            }
        });

        $('#bs-name').on('input paste', function (){
            let br = $(this).val();
            $('#BS-label').addClass('error');
            if(br != ""){
                $('#BS-label').removeClass('error');
            }
        });
        $('#pl-name').on('input paste', function (){
            let pl = $(this).val();
            $('#PL-label').addClass('error');
            if(pl != ""){
                $('#PL-label').removeClass('error');
            }
        });

        $('#category-list').on('change', function (){
            let category = $(this).val();
            $('#category-label').removeClass('error');

            if(category != ""){
                $('#category-label').removeClass('error');
                $('#current-asset-type').hide();
                if(category == 'c_asset') {
                    $('#current-asset-type').show();
                }
            }
        });
        $('#current-asset-list').on('change', function (){
            let type = $(this).val();
            $('#current-asset-label').addClass('error');
            if(type != ""){
                $('#current-asset-label').removeClass('error');
            }
        });

    });
</script>
<?php echo Form::open(['action'=>['CompanyFinancialMainAccountController@store'], 'method'=>'POST', 'id'=>'add-company-main-accounts']); ?>

<div class="error" style="text-align: center;">On this Window, You can Add a New Company Main Account</div>
<div class="guestDetails_inputDivider"></div>
<button type="submit" disabled style="display: none" aria-hidden="true"></button>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('type', 'Select the Main Type of Account:', ['id'=>'type-label', 'class'=>'error']); ?>

        <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <select name="type" id="type-list" style="width: 180px">
            <option value="">--Select Account Type--</option>
            <option value="BS">Balance Sheet Account</option>
            <option value="PL">Profit & Loss Account</option>
        </select>
    </div>
</div>
<div class="guestDetails_input" id="bs-account-div" style="display: none">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('BS-account', 'Enter Balance Sheet Account Name:', ['id'=>'BS-label', 'class'=>'error']); ?>

        <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <?php echo Form::text('bs-name', '', ['size'=>30, 'list'=>'bs-list', 'id'=>'bs-name', 'class'=>'input-text-height']); ?>

        <datalist id="bs-list">
            <option value="Fixed Asset">
            <option value="Current Asset">
            <option value="Current Liability">
            <option value="Non Current Liability">
            <option value="Equity">
            <option value="Investment">
            <option value="Accumulated Depreciation">
        </datalist>
    </div>
</div>

<div class="guestDetails_input" id="pl-account-div" style="display: none">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('PL-account', 'Enter Profit & Loss Account Name:', ['id'=>'PL-label', 'class'=>'error']); ?>

        <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <?php echo Form::text('pl-name', '', ['size'=>30, 'list'=>'pl-list', 'id'=>'pl-name', 'class'=>'input-text-height']); ?>

        <datalist id="pl-list">
            <option value="Income">
            <option value="Finance Expenditure">
            <option value="Administration Expenditure">
            <option value="Marketing Expenditure">
            <option value="Accumulated Depreciation Expenditure">
        </datalist>
    </div>
</div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('category', 'Select Account Category:', ['class'=>'error', 'id'=>'category-label']); ?> <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <select name="category" id="category-list" style="width: 150px">
            <option value="">--Select Specific Category--</option>
            <optgroup label="Balance Sheet Accounts"></optgroup>
            <option value="non_c_asset">Fixed Assets</option>
            <option value="c_asset">Current Assets</option>
            
            <option value="c_liability">Current Liabilities</option>
            <option value="non_c_liability">Non Current Liabilities</option>
            <option value="equity">Equity Account</option>
            <option value="investment">Investments Accounts</option>
            <option value="acc_dep_asset">Accumulated Depreciation(Negative Asset)</option>
            <optgroup label="Profit & Loss Accounts"></optgroup>
            <option value="income">Income</option>
            <option value="expense">Expense</option>
        </select>
    </div>
</div>
<div id="current-asset-type" style="display: none">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('current-asset', 'Select Current Asset Type:', ['class'=>'error', 'id'=>'current-asset-label']); ?> <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <select name="current-asset" id="current-asset-list" style="width: 140px">
            <option value="">--Select Specific Type--</option>
            <option value="LA">Current Asset</option>
            <option value="CB">Bank Account</option>
            <option value="PC">Petty Cash</option>
        </select>
    </div>

</div>


<?php echo Form::close(); ?>

<?php /**PATH C:\xampp\htdocs\finewood\resources\views/adds/add-company-main-account.blade.php ENDPATH**/ ?>