
<?php $__env->startSection('title', 'Unit Admins'); ?>
<?php $__env->startSection('page_title', 'Unit Admins'); ?>

<?php $__env->startSection('content'); ?>

<div class="card">
  <div class="ch">
    <div class="ct">
      <i class="fas fa-user-shield"></i>All Unit Admins
    </div>
    <button class="btn bp bsm" onclick="om('addUAM')">
      <i class="fas fa-plus"></i>Create Unit Admin
    </button>
  </div>
  <div class="tw">
    <table>
      <thead>
        <tr>
          <th>#</th>
          <th>Name</th>
          <th>Email</th>
          <th>Phone</th>
          <th>Unit</th>
          <th>District</th>
          <th>Status</th>
          <th>Actions</th>
        </tr>
      </thead>
      <tbody>
        <?php $__empty_1 = true; $__currentLoopData = $unitAdmins; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ua): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
        <tr>
          <td style="color:var(--text-dim)"><?php echo e($loop->iteration); ?></td>
          <td>
            <div class="mc2">
              <div class="av2"
                style="background:rgba(167,139,250,0.2);
                       color:var(--purple)">
                <?php echo e(strtoupper(substr($ua->user->name,0,2))); ?>

              </div>
              <div class="mn"><?php echo e($ua->user->name); ?></div>
            </div>
          </td>
          <td style="color:var(--text-dim)"><?php echo e($ua->user->email); ?></td>
          <td style="color:var(--text-dim)"><?php echo e($ua->user->phone); ?></td>
          <td><span class="utag"><?php echo e($ua->unit->name); ?></span></td>
          <td style="color:var(--text-dim)">
            <?php echo e($ua->unit->district->name); ?>

          </td>
          <td>
            <span class="badge <?php echo e($ua->user->is_active ? 'bac' : 'brj'); ?>">
              <?php echo e($ua->user->is_active ? 'Active' : 'Inactive'); ?>

            </span>
          </td>
          <td>
            <div class="abr">
              <div class="ab ed"
                onclick="editUA(
                  <?php echo e($ua->id); ?>,
                  '<?php echo e($ua->user->name); ?>',
                  '<?php echo e($ua->user->phone); ?>')">
                <i class="fas fa-edit"></i>
              </div>
              <form method="POST"
                action="<?php echo e(route('admin.unit-admins.reset-password')); ?>"
                style="display:inline">
                <?php echo csrf_field(); ?>
                <input type="hidden" name="id" value="<?php echo e($ua->id); ?>">
                <button type="submit" class="ab"
                  title="Reset Password"
                  onclick="return confirm('Reset password for <?php echo e($ua->user->name); ?>?')">
                  <i class="fas fa-key"></i>
                </button>
              </form>
              <form method="POST"
                action="<?php echo e(route('admin.unit-admins.toggle-status')); ?>"
                style="display:inline">
                <?php echo csrf_field(); ?>
                <input type="hidden" name="id" value="<?php echo e($ua->id); ?>">
                <button type="submit"
                  class="ab <?php echo e($ua->user->is_active ? 'rej' : 'app'); ?>"
                  title="<?php echo e($ua->user->is_active ? 'Deactivate' : 'Activate'); ?>"
                  onclick="return confirm('<?php echo e($ua->user->is_active ? 'Deactivate' : 'Activate'); ?> <?php echo e($ua->user->name); ?>?')">
                  <i class="fas fa-<?php echo e($ua->user->is_active ? 'ban' : 'check'); ?>"></i>
                </button>
              </form>
              <form method="POST"
                action="<?php echo e(route('admin.unit-admins.delete')); ?>"
                style="display:inline"
                onsubmit="return confirm('Delete <?php echo e($ua->user->name); ?>?')">
                <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                <input type="hidden" name="id" value="<?php echo e($ua->id); ?>">
                <button type="submit" class="ab rej">
                  <i class="fas fa-trash"></i>
                </button>
              </form>
            </div>
          </td>
        </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
        <tr>
          <td colspan="8"
            style="text-align:center;color:var(--text-dim);padding:30px;">
            No unit admins yet
          </td>
        </tr>
        <?php endif; ?>
      </tbody>
    </table>
  </div>
</div>

<div id="addUAM" class="mo">
  <div class="md">
    <div class="mh">
      <span class="mt2">Create Unit Admin</span>
      <div class="mc3" onclick="cm('addUAM')">
        <i class="fas fa-times"></i>
      </div>
    </div>
    <form method="POST"
          action="<?php echo e(route('admin.unit-admins.store')); ?>">
      <?php echo csrf_field(); ?>
      <div class="fgrid">
        <div class="fg">
          <label>Full Name</label>
          <input type="text" name="name"
                 placeholder="Enter full name" required>
        </div>
        <div class="fg">
          <label>Email</label>
          <input type="email" name="email"
                 placeholder="Enter email" required>
        </div>
        <div class="fg">
          <label>Phone</label>
          <input type="text" name="phone"
                 placeholder="10 digit number" required>
        </div>
        <div class="fg">
          <label>Assign Unit</label>
          <select name="unit_id" required>
            <option value="">Select Unit</option>
            <?php $__currentLoopData = $units; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $unit): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
              <option value="<?php echo e($unit->id); ?>">
                <?php echo e($unit->name); ?>

                (<?php echo e($unit->district->name); ?>)
              </option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
          </select>
        </div>
      </div>
      <div style="margin:0 18px 14px;padding:10px 12px;
                  background:rgba(79,142,247,0.07);
                  border-radius:8px;font-size:11px;
                  color:var(--text-dim);">
        <i class="fas fa-info-circle"
           style="color:var(--accent)"></i>
        Password will be auto-generated and shown
        in success message. Share it immediately!
      </div>
      <div class="ff">
        <button type="button" class="btn bo"
                onclick="cm('addUAM')">Cancel</button>
        <button type="submit" class="btn bp">
          <i class="fas fa-user-plus"></i>Create
        </button>
      </div>
    </form>
  </div>
</div>

<div id="editUAM" class="mo">
  <div class="md">
    <div class="mh">
      <span class="mt2">Edit Unit Admin</span>
      <div class="mc3" onclick="cm('editUAM')">
        <i class="fas fa-times"></i>
      </div>
    </div>
    <form method="POST"
          action="<?php echo e(route('admin.unit-admins.update')); ?>">
      <?php echo csrf_field(); ?>
      <input type="hidden" name="id" id="editUAId">
      <div class="fgrid">
        <div class="fg">
          <label>Full Name</label>
          <input type="text" name="name"
                 id="editUAName" required>
        </div>
        <div class="fg">
          <label>Phone</label>
          <input type="text" name="phone"
                 id="editUAPhone" required>
        </div>
      </div>
      <div class="ff">
        <button type="button" class="btn bo"
                onclick="cm('editUAM')">Cancel</button>
        <button type="submit" class="btn bp">
          <i class="fas fa-save"></i>Update
        </button>
      </div>
    </form>
  </div>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
function editUA(id, name, phone) {
  document.getElementById('editUAId').value    = id;
  document.getElementById('editUAName').value  = name;
  document.getElementById('editUAPhone').value = phone;
  om('editUAM');
}
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\My PC\Desktop\laravel\eca-api\resources\views/admin/unit-admins.blade.php ENDPATH**/ ?>