<script>
    $(document).ready(function (){
        $('#branch').select2();
        $('#expense-ledgers').select2();
        $('#vendor-list').select2();
        $('#account-list').select2();

        /**When Changing the Account Type**/
        $('#account-list').on('change', function (){
            let accountType = $(this).val();

            if(accountType != ""){
                $.ajax({
                    method: 'GET',
                    url: '/get-account-type-list/'+accountType,
                    data: accountType,
                    success: function (res){
                        $('#ledger-account-list').html(res);
                    }
                });
            }else{
                alert('You need to Select a Specific Account Type to Proceed');
            }

        });
    });
</script>
<?php echo Form::open(['action'=>'Finance\AccBillsManagerController@storeNewBill', 'id'=>'add-new-bill', 'method'=>'POST']); ?>

<?php if(count(app('CompanyBranches')) > 0): ?>
    <div class="guestDetails_input">
        <div class="guestDetails_inputLabel" >Branch:<span class="error">*</span></div>
        <div class="guestDetails_input">
            <select id="branch" name="branch" style="min-width: 150px">
                
                <?php $__currentLoopData = app('CompanyBranches'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $branch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($branch->id); ?>"><?php echo e($branch->name); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
        </div>
    </div>
<?php endif; ?>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('vendor', 'Select a Vendor'); ?><span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <select id="vendor-list" name="vendor" style="min-width: 500px">
            <option value="">Select a Vendor</option>
            <?php $__currentLoopData = $vendors; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $vendor): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($vendor->id); ?>"><?php echo e(strtoupper($vendor->name)); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
    </div>
</div>
<div class="guestDetails_inputDivider"></div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel" >Account:<span class="error">*</span></div>
    <div class="guestDetails_input">
        <select id="account-list" name="account" style="min-width: 150px">
            <option value="">--Select Account Type--</option>
            <option value="expense">Expense</option>
            <option value="purchases">Purchases</option>
            <option value="c_asset">C.Asset</option>
            <option value="non_c_asset">N.C Asset</option>
        </select>
    </div>
</div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('ledger', 'Select Ledger Account'); ?><span class="error">*</span>
    </div>
    <div class="guestDetails_input" id="ledger-account-list"></div>
</div>
<div class="guestDetails_inputDivider"></div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('gross-amount', 'Bill Gross Amount'); ?><span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <?php echo Form::number('bill-gross-amount', '', ['style'=>'width:150px', 'class'=>'input-text-height']); ?>

    </div>
</div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('ref-no', 'Bill REF No/Invoice Number'); ?><span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <?php echo Form::text('ref', '', ['size'=>'35', 'class'=>'input-text-height']); ?>

    </div>
</div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('date', 'Billing Date'); ?><span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <?php echo Form::date('bill-date', date('Y-m-d'), ['style'=>'width:120px', 'class'=>'input-text-height']); ?>

    </div>
</div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('date', 'Bill Due Date'); ?><span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <?php echo Form::date('bill-due-date', '', ['style'=>'width:120px', 'class'=>'input-text-height']); ?>

    </div>
</div>
<div class="guestDetails_inputDivider"></div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('narration', 'Narration'); ?><span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <?php echo Form::textarea('narration', '', ['style'=>'width:680px; height:50px']); ?>

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


<?php /**PATH /home/zedarroot/public_html/edwulp/resources/views/finance/bills/add-new-bill.blade.php ENDPATH**/ ?>