<?php $this->load->view('superadmin/layouts/header'); ?>

<!-- Page Header -->
<div class="d-flex justify-content-between align-items-center mb-4">
    <div>
        <h3 class="mb-1">Reassign Data Between Portals</h3>
        <p class="text-muted mb-0">Transfer data from one portal to another</p>
    </div>
    <a href="<?= base_url('superadmin/data') ?>" class="btn btn-outline-secondary">
        <i class="bi bi-arrow-left me-2"></i>Back to Data
    </a>
</div>

<!-- Flash Messages -->
<?php if($this->session->flashdata('error')): ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
    <i class="bi bi-exclamation-circle me-2"></i><?= $this->session->flashdata('error') ?>
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
<?php endif; ?>

<!-- Reassign Form -->
<div class="table-card">
    <div class="card-header">
        <h5><i class="bi bi-arrow-left-right me-2"></i>Reassign Data</h5>
    </div>
    <div class="card-body">
        <form method="post" action="<?= base_url('superadmin/data/reassign') ?>">
            <div class="row">
                <div class="col-md-5 mb-3">
                    <label class="form-label">From Portal <span class="text-danger">*</span></label>
                    <select name="from_portal" class="form-select" required>
                        <option value="">Select source portal...</option>
                        <?php foreach($portals as $portal): ?>
                        <option value="<?= $portal->code ?>"><?= htmlspecialchars($portal->name) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="col-md-2 mb-3 d-flex align-items-center justify-content-center">
                    <i class="bi bi-arrow-right fs-3 text-muted"></i>
                </div>
                <div class="col-md-5 mb-3">
                    <label class="form-label">To Portal <span class="text-danger">*</span></label>
                    <select name="to_portal" class="form-select" required>
                        <option value="">Select destination portal...</option>
                        <?php foreach($portals as $portal): ?>
                        <option value="<?= $portal->code ?>"><?= htmlspecialchars($portal->name) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>

            <div class="row">
                <div class="col-md-6 mb-3">
                    <label class="form-label">Number of Records <span class="text-danger">*</span></label>
                    <input type="number" name="reassign_count" class="form-control" min="1" max="1000000" value="1000" required>
                    <small class="text-muted">Maximum 1,000,000 records per operation</small>
                </div>
            </div>

            <div class="alert alert-warning">
                <i class="bi bi-exclamation-triangle me-2"></i>
                <strong>Warning:</strong> This action will transfer data from one portal to another. The data will no longer be accessible from the source portal.
            </div>

            <hr class="my-4">
            
            <div class="d-flex gap-2">
                <button type="submit" class="btn btn-warning">
                    <i class="bi bi-arrow-left-right me-2"></i>Reassign Data
                </button>
                <a href="<?= base_url('superadmin/data') ?>" class="btn btn-outline-secondary">Cancel</a>
            </div>
        </form>
    </div>
</div>

<?php $this->load->view('superadmin/layouts/footer'); ?>
