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

    <!-- App Header -->
    <div class="appHeader bg-primary text-light">
        <div class="left">
            <a href="<?php echo base_url('admin/users'); ?>" class="headerButton">
                <ion-icon name="chevron-back-outline"></ion-icon>
            </a>
        </div>
        <div class="pageTitle">Create User</div>
        <div class="right">
            <a href="#" class="headerButton" data-bs-toggle="modal" data-bs-target="#adminSidebar">
                <ion-icon name="menu-outline"></ion-icon>
            </a>
        </div>
    </div>

    <!-- App Capsule -->
    <div id="appCapsule">
        
        <?php if (validation_errors()): ?>
        <div class="section mt-2">
            <div class="alert alert-danger"><?php echo validation_errors(); ?></div>
        </div>
        <?php endif; ?>

        <div class="section mt-2 mb-3">
            <form action="<?php echo base_url('admin/create_user'); ?>" method="POST">
                <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
                
                <div class="card">
                    <div class="card-header">Personal Information</div>
                    <div class="card-body">
                        <div class="form-group basic">
                            <label class="label">First Name *</label>
                            <input type="text" name="first_name" class="form-control" value="<?php echo set_value('first_name'); ?>" required>
                        </div>
                        <div class="form-group basic">
                            <label class="label">Last Name *</label>
                            <input type="text" name="last_name" class="form-control" value="<?php echo set_value('last_name'); ?>" required>
                        </div>
                        <div class="form-group basic">
                            <label class="label">Email *</label>
                            <input type="email" name="email" class="form-control" value="<?php echo set_value('email'); ?>" required>
                        </div>
                        <div class="form-group basic">
                            <label class="label">Phone *</label>
                            <input type="text" name="phone" class="form-control" value="<?php echo set_value('phone'); ?>" required>
                        </div>
                    </div>
                </div>

                <div class="card mt-2">
                    <div class="card-header">Account Settings</div>
                    <div class="card-body">
                        <div class="form-group basic">
                            <label class="label">User Type *</label>
                            <select name="user_type" class="form-control" required>
                                <option value="user" <?php echo set_select('user_type', 'user', TRUE); ?>>Regular User</option>
                                <option value="business" <?php echo set_select('user_type', 'business'); ?>>Business</option>
                                <option value="admin" <?php echo set_select('user_type', 'admin'); ?>>Admin</option>
                            </select>
                        </div>
                        <div class="form-group basic">
                            <label class="label">Password *</label>
                            <input type="password" name="password" class="form-control" required minlength="8">
                            <div class="input-info">Minimum 8 characters</div>
                        </div>
                        <div class="form-group basic">
                            <label class="label">Account Type</label>
                            <select name="account_type" class="form-control">
                                <option value="savings">Savings</option>
                                <option value="current">Current</option>
                            </select>
                        </div>
                        <div class="form-group basic">
                            <label class="label">Initial Balance</label>
                            <input type="number" name="initial_balance" class="form-control" step="0.01" min="0" value="0">
                        </div>
                    </div>
                </div>

                <div class="section mt-2">
                    <button type="submit" class="btn btn-primary btn-block btn-lg">
                        Create User
                    </button>
                </div>
            </form>
        </div>
    </div>

    <!-- Admin Sidebar -->
    <?php $this->load->view('admin/partials/sidebar'); ?>

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