<?php $__env->startSection('content'); ?>
<div class="breadcrumbbar">
    <div class="row align-items-center">
        <div class="col-md-8 col-lg-8">
            <h4 class="page-title">Edit Borrow Transaction</h4>
            <div class="breadcrumb-list">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Home</a></li>
                    <li class="breadcrumb-item"><a href="<?php echo e(route('borrows.index')); ?>">Borrows</a></li>
                    <li class="breadcrumb-item active" aria-current="page">Edit Borrow</li>
                </ol>
            </div>
        </div>
    </div>          
</div>
<div class="row justify-content-center">
    <div class="col-lg-7">
        <div class="card m-b-30">
            <div class="card-header">
                <h5 class="card-title mb-0">Edit Borrow Transaction</h5>
            </div>
            <div class="card-body">
                <form method="POST" action="<?php echo e(route('borrows.update', $borrow)); ?>">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>
                    <div class="row g-3">
                        <div class="col-md-6">
                            <label class="form-label" for="agent_id">Agent</label>
                            <select class="form-select" id="agent_id" name="agent_id" required>
                                <option value="">Select agent</option>
                                <?php $__currentLoopData = $agents; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $agent): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($agent->id); ?>" <?php if(old('agent_id', $borrow->agent_id) == $agent->id): echo 'selected'; endif; ?>>
                                        <?php echo e($agent->name); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label" for="currency_id">Currency</label>
                            <select class="form-select" id="currency_id" name="currency_id" required>
                                <option value="">Select currency</option>
                                <?php $__currentLoopData = $currencies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $currency): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($currency->id); ?>" <?php if(old('currency_id', $borrow->currency_id) == $currency->id): echo 'selected'; endif; ?>>
                                        <?php echo e($currency->code); ?> - <?php echo e($currency->name); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="col-md-12">
                            <label class="form-label" for="target_account_id">Target Account (To receive borrowed currency)</label>
                            <select class="form-select" id="target_account_id" name="target_account_id" required>
                                <option value="">Select target account</option>
                                <?php $__currentLoopData = $accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($account->id); ?>" <?php if(old('target_account_id', $borrow->account_id) == $account->id): echo 'selected'; endif; ?>>
                                        <?php echo e($account->name); ?> - <?php echo e(number_format((float) $account->balance, 2)); ?> <?php echo e($account->currency->code); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label" for="quantity">Quantity Borrowed</label>
                            <input class="form-control text-end atm-decimal" id="quantity" name="quantity" inputmode="numeric" placeholder="0.00" value="<?php echo e(old('quantity', $borrow->quantity)); ?>" required>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label" for="rate">Agreed Rate</label>
                            <input class="form-control text-end atm-decimal" id="rate" name="rate" inputmode="numeric" placeholder="0.00" value="<?php echo e(old('rate', $borrow->rate)); ?>" required>
                        </div>
                    </div>
                    <div class="d-flex justify-content-end gap-2 mt-4">
                        <button class="btn btn-primary" type="submit">Update Borrow Transaction</button>
                        <button type="button" class="btn btn-danger" onclick="if(confirm('Are you sure you want to delete this borrow transaction? This will reverse the account balance addition.')) document.getElementById('delete-transaction-form').submit();">Delete Transaction</button>
                    </div>
                </form>

                <form id="delete-transaction-form" action="<?php echo e(route('transactions.destroy', $borrow)); ?>" method="POST" style="display:none;">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('DELETE'); ?>
                </form>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH F:\christopher\currencychangerui\resources\views/borrows/edit.blade.php ENDPATH**/ ?>