<!-- Quill rich text editor — फक्त ह्याच form साठी load केलं आहे -->
<link href="https://cdn.jsdelivr.net/npm/quill@1.3.7/dist/quill.snow.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/quill@1.3.7/dist/quill.min.js"></script>

<div class="row justify-content-center">
<div class="col-12">
<div class="card-box">

    <div class="card-box-header">
        <h5>
            <i class="fa-solid fa-file-contract" style="color:#7c3aed;"></i>
            <?php if(!empty($reportheaderdata)) echo 'Edit Report Header'; else echo 'Add New Report Header'; ?>
        </h5>
        <a href="<?php echo site_url('report_header'); ?>" class="btn btn-sm" style="background:#f1f5f9;color:#374151;">
            <i class="fa-solid fa-arrow-left me-1"></i> Back to List
        </a>
    </div>

    <form method="post" id="Form">

        <input type="hidden" name="id" id="id" value="<?php if(!empty($reportheaderdata)) echo $reportheaderdata[0]->id; ?>">
        <input type="hidden" name="terms_condition" id="terms_condition" value="<?php if(!empty($reportheaderdata)) echo htmlspecialchars($reportheaderdata[0]->terms_condition); ?>">
        <input type="hidden" name="bank_details" id="bank_details" value="<?php if(!empty($reportheaderdata)) echo htmlspecialchars($reportheaderdata[0]->bank_details); ?>">
        <input type="hidden" name="signature" id="signature" value="<?php if(!empty($reportheaderdata)) echo htmlspecialchars($reportheaderdata[0]->signature); ?>">

        <div class="row g-3">

            <div class="col-md-4">
                <label class="form-label">Report Header Name <span class="required-star">*</span></label>
                <select name="report_header_name" id="report_header_name" class="form-select select2 select2-no-search">
                    <option value="">— Select —</option>
                    <option value="Invoice"    <?php if(!empty($reportheaderdata) && $reportheaderdata[0]->report_header_name == 'Invoice') echo 'selected'; ?>>Invoice</option>
                    <option value="Quotation"  <?php if(!empty($reportheaderdata) && $reportheaderdata[0]->report_header_name == 'Quotation') echo 'selected'; ?>>Quotation</option>
                </select>
            </div>

            <div class="col-md-4">
                <label class="form-label">Status</label>
                <select name="status" id="status" class="form-select select2 select2-no-search">
                    <option value="1" <?php if(!empty($reportheaderdata) && $reportheaderdata[0]->status == 1) echo 'selected'; ?>>Active</option>
                    <option value="0" <?php if(!empty($reportheaderdata) && $reportheaderdata[0]->status == 0) echo 'selected'; ?>>Inactive</option>
                </select>
            </div>

        </div>

        <div class="rh-field">
            <label class="form-label d-block">Terms and Condition</label>
            <div id="terms_editor" class="rh-editor"><?php if(!empty($reportheaderdata)) echo $reportheaderdata[0]->terms_condition; ?></div>
        </div>

        <div class="rh-field">
            <label class="form-label d-block">Bank Details</label>
            <div id="bank_editor" class="rh-editor"><?php if(!empty($reportheaderdata)) echo $reportheaderdata[0]->bank_details; ?></div>
        </div>

        <div class="rh-field">
            <label class="form-label d-block">Signature</label>
            <div id="signature_editor" class="rh-editor"><?php if(!empty($reportheaderdata)) echo $reportheaderdata[0]->signature; ?></div>
        </div>

        <div class="d-flex gap-2 mt-4">
            <button type="button" id="btn_savee" class="btn btn-primary px-4">
                <i class="fa-solid fa-floppy-disk me-1"></i> Save
            </button>
            <a href="<?php echo site_url('report_header'); ?>" class="btn" style="background:#f1f5f9;color:#374151;">Cancel</a>
        </div>

    </form>
</div>
</div>
</div>

<style>
    .rh-field { width:100%; display:block; margin-top:20px; clear:both; }
    .rh-field .form-label { font-weight:700; font-size:13.5px; color:#374151; margin-bottom:8px; }
    .rh-editor { background:#fff; border-radius:9px; clear:both; }
    .rh-editor .ql-toolbar { border:1.5px solid #e2e8f0; border-bottom:none; border-radius:9px 9px 0 0; background:#f8fafc; }
    .rh-editor .ql-container { border:1.5px solid #e2e8f0; border-radius:0 0 9px 9px; min-height:120px; font-size:13.5px; }
</style>

<script>
    var quillTerms = new Quill('#terms_editor',     { theme: 'snow', placeholder: 'Terms and condition लिहा...' });
    var quillBank  = new Quill('#bank_editor',      { theme: 'snow', placeholder: 'Bank details लिहा...' });
    var quillSign  = new Quill('#signature_editor', { theme: 'snow', placeholder: 'Signature details लिहा...' });
</script>