<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <!-- Loaner checkout modal template (can be t-called from portal pages) -->
    <template id="loaner_checkout_modal" name="Loaner Checkout Modal">
        <div class="modal fade" id="loanerCheckoutModal" tabindex="-1" role="dialog">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Checkout Loaner Equipment</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal"/>
                    </div>
                    <div class="modal-body">
                        <input type="hidden" id="modal_order_id"/>
                        <input type="hidden" id="modal_client_id"/>
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label class="form-label fw-bold">Category</label>
                                <select id="modal_category_id" class="form-select">
                                    <option value="">All Categories</option>
                                </select>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label fw-bold">Product</label>
                                <select id="modal_product_id" class="form-select">
                                    <option value="">-- Select Product --</option>
                                </select>
                            </div>
                        </div>
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label class="form-label fw-bold">Serial Number</label>
                                <select id="modal_lot_id" class="form-select">
                                    <option value="">-- Select Serial --</option>
                                </select>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label fw-bold">Loan Days</label>
                                <input type="number" id="modal_loan_days" class="form-control" value="7"/>
                            </div>
                        </div>
                        <hr/>
                        <h6>Quick Create Product</h6>
                        <div class="row mb-2">
                            <div class="col-md-4">
                                <select id="modal_new_category_id" class="form-select form-select-sm">
                                    <option value="">-- Category --</option>
                                </select>
                            </div>
                            <div class="col-md-3">
                                <input type="text" id="modal_new_product_name" class="form-control form-control-sm" placeholder="Product Name"/>
                            </div>
                            <div class="col-md-3">
                                <input type="text" id="modal_new_serial" class="form-control form-control-sm" placeholder="Serial Number"/>
                            </div>
                            <div class="col-md-2">
                                <button id="modal_btn_create_product" class="btn btn-sm btn-outline-primary w-100">
                                    <i class="fa fa-plus me-1"/>Create Product
                                </button>
                            </div>
                        </div>
                        <div id="modal_create_result" style="display:none;"/>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                        <button id="modal_btn_checkout" class="btn btn-primary">
                            <i class="fa fa-check me-1"/>Checkout Loaner
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </template>

    <template id="loaner_return_modal" name="Loaner Return Modal">
        <div class="modal fade" id="loanerReturnModal" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Return Loaner Equipment</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal"/>
                    </div>
                    <div class="modal-body">
                        <input type="hidden" id="return_modal_checkout_id"/>
                        <p><strong>Product:</strong> <span id="return_modal_product_name"/></p>
                        <div class="mb-3">
                            <label class="form-label fw-bold">Condition</label>
                            <select id="return_modal_condition" class="form-select">
                                <option value="excellent">Excellent</option>
                                <option value="good" selected="selected">Good</option>
                                <option value="fair">Fair</option>
                                <option value="needs_repair">Needs Repair</option>
                                <option value="damaged">Damaged</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label class="form-label fw-bold">Return Location</label>
                            <select id="return_modal_location_id" class="form-select">
                                <option value="">-- Select Location --</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label class="form-label fw-bold">Notes</label>
                            <textarea id="return_modal_notes" class="form-control" rows="2"/>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                        <button id="return_modal_btn_submit" class="btn btn-success">
                            <i class="fa fa-check me-1"/>Confirm Return
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </template>
</odoo>
