<script>
    $(document).ready(function (){
        $('#requisition-list').select2();
        $('#payment-modes').select2();
        $('#account-list').select2();
        $('#currency-option').select2();
        $('#cart-option').select2();
        $('#cart-option-list').select2();

        $('#payment-modes').on('change', function (){
            var modes = $(this).val();
            $('#payment-modes-label').addClass('error');
            if(modes != ""){
                $('#payment-modes-label').removeClass('error');
            }
        });
        //Input on REF Field
        $('#ref-narration-input').on('input paste', function (){
            var ref = $(this).val();
            if(ref != ""){
                $('#ref-label').removeClass('error');
            }else{
                $('#ref-label').addClass('error');
            }
        });

        
        $('#payment-modes').on('change', function (){
            var mode = $(this).val();
            $('#sub-mode-div').hide();

            $('#sub-mode-list').val(null);
            if(mode != ""){
                $('#payment-mode-label').removeClass('error');
                $.ajax({
                    method: 'GET',
                    url: '/sub-modes-of-payments/'+mode,
                    data: mode,
                    success: function (res){
                        if(res != ""){
                            $('#sub-mode-div').show();
                            $('#sub-mode-field').html(res);
                        }else{
                            $('#sub-mode-div').hide();
                        }
                    }
                });
            }else{
                $('#payment-mode-label').addClass('error');
            }

        });

        $('#cart-option').on('change', function (){
            let type = $(this).val();

            $('#available-cart-items').hide();
            if(type == 'yes'){
                $('#available-cart-items').show();
            }
        });
    });
</script>
<?php echo Form::open(['action'=>['Payments\RequisitionController@storePayRequisition', 'id'=>$id], 'id'=>'pay-requisition', 'method'=>'POST']); ?>

<div class="error" style="text-align: center;">On this Window, You can Make a Payment on an Approved Requisition</div>
<div class="guestDetails_inputDivider"></div>
<button type="submit" disabled style="display: none" aria-hidden="true"></button>
<div class="guestDetails_inputDivider1"></div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        Pay from <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <select name="account" id="account-list" style="width: 500px">
            <option value="">--Select Account that we are Paying From--</option>

            <?php if(app('BankAccounts') != null): ?>
                <optgroup label="Bank Accounts"></optgroup>
                <?php $__currentLoopData = app('BankAccounts'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($row->id); ?>"><?php echo e(strtoupper($row->acc_name)); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <optgroup label="Petty Cash Accounts"></optgroup>
                <?php $__currentLoopData = app('PettyCashAccounts'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $petty): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($petty->id); ?>"><?php echo e(strtoupper($petty->acc_name)); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php endif; ?>
        </select>
    </div>
</div>
<div class="guestDetails_inputDivider1"></div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('payment-mode', 'Select Mode of Payment', ['class'=>'error', 'id'=>'payment-mode-label']); ?>

        <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <select name="payment-mode" id="payment-modes" style="width: 250px">
            <option value="">--Select Payment Mode--</option>
            <?php if(app('CompanyPaymentModes') != null): ?>
                <?php $__currentLoopData = app('CompanyPaymentModes'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mode): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($mode->id); ?>"><?php echo e($mode->name); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php endif; ?>
        </select>
    </div>
</div>
<div class="guestDetails_input" id="sub-mode-div" style="display: none">
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('payment-mode', 'Sub-Mode of Payment:', ['class'=>'error', 'id'=>'sub-mode-label']); ?>

        <span class="error">*</span>
    </div>
    <div class="guestDetails_input" id="sub-mode-field"></div>
</div>
<div class="guestDetails_inputDivider"></div>
<div class="guestDetails_input" >
    <div class="guestDetails_inputLabel">
        <?php echo Form::label('payment-ref', 'Enter Ref Number.',['class'=>'error', 'id'=>'ref-label']); ?> <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <?php echo Form::text('ref', '',['size'=>50, 'id'=>'ref-narration-input','class'=>'input-text-height', 'placeholder'=>'Enter REF Details for the Payment']); ?>

    </div>
</div>
<div class="guestDetails_inputDivider1"></div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        Payee <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <?php echo Form::text('payee', $req->payee ?? '', ['class'=>'input-text-height', 'size'=>90]); ?>

    </div>
</div>
<div class="guestDetails_inputDivider1"></div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        Requisition Amount <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <?php echo Form::text('req-amount', $req->amount ?? 0, ['class'=>'input-text-height', 'size'=>15, 'readonly'=>true]); ?>

    </div>
</div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        Currency <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <select name="currency" style="width: 120px" id="currency-option">
            <option value="<?php echo $req->currency; ?>">
                <?php if($req->currencyDetails != null): ?>
                    <?php echo strtoupper($req->currencyDetails->abbr); ?>

                <?php endif; ?>
            </option>
        </select>
    </div>
</div>
<div class="guestDetails_input">
    <div class="guestDetails_inputLabel">
        <i class="" id="conversion-rate-label">Conversion Rate:</i> <span class="error">*</span>
    </div>
    <div class="guestDetails_input">
        <?php echo Form::text('conversion-rate', $req->conversion_rate ?? 0, ['class'=>'input-text-height', 'readonly'=>true,'size'=>10]); ?>

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

    </div>
</div>

<?php if($req->req_type == 'remit-premium'): ?>
    <div class="guestDetails_inputDivider"></div>
    <div id="add-to-a-declared-cart" style="background-color: lightcyan; border-radius: 4px"><br>
        <div class="guestDetails_input">
            <div class="guestDetails_inputLabel">
                Add to an Existing Cart <span class="error">*</span>
            </div>
            <div class="guestDetails_input">
                <select name="add-to-cart" style="width: 150px" id="cart-option">
                    <option value="no">NO</option>
                    <option value="yes">YES</option>
                </select>
            </div>
        </div>

        <div class="guestDetails_input" id="available-cart-items" style="display: none">
            <div class="guestDetails_inputLabel">
                Select your Cart <span class="error">*</span>
            </div>
            <div class="guestDetails_input">
                <select name="cart-id" style="width: 300px" id="cart-option-list">
                    <option value="">--Select an Item--</option>
                    <?php $__currentLoopData = \App\Models\MotorCertificatesDeclaredCart::orderBy('name', 'asc')->get(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo $row->id; ?>"><?php echo $row->name; ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
        </div>
        <div class="guestDetails_inputDivider1"></div>
    </div>
<?php endif; ?>
<div class="guestDetails_inputDivider1"></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', $req->nar ?? '',['style'=>'width:500px; height:60px']); ?>

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

<?php /**PATH /home/zedarroot/public_html/edwulp/resources/views/payments/pay-requisition.blade.php ENDPATH**/ ?>