<?php foreach($clientProjects as $project):?>
<div class="card card-body">
    <div class="d-flex justify-content-between align-items-center mb-3">
        <h6 class="fw-bold mb-3">
            Project Approval statuses
            
        </h6>
        <button class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#projectStatusModal">Add Status</button>
    </div>
    
    <?php if (!empty($project->status)): ?>
        <?php foreach ($project->status as $stat): ?>
        <div class="d-flex bd-higlight rounded shadow-sm align-items-center mb-3" style="background:<?= $stat->color; ?>;color:#fff">
            <div class="bd-highlight me-2 p-2">
                <i class="<?= $stat->icon;?>"></i>
            </div>
            <div class="bd-highlight flex-grow-1 p-2">
                <h6 class="text-uppercase small fw-bold mb-0"><?= $stat->name; ?></h6>
                <small><?= nl2br($stat->description ?: $stat->status_description); ?></small>
            </div>
            <div class="bd-highlight p-2">
                <button class="btn btn-sm btn-transparent small" title="Delete" onclick="delete_item(<?= $stat->id ?>, 'statuses')"><i class="bi bi-x-circle-fill text-danger small"></i></button>
            </div>
        </div>
        <?php endforeach; ?>
    <?php else: ?>
        <p>No status listed.</p>
    <?php endif; ?>
</div>     
<?php endforeach;?>


<!-- Modal  Modal -->
<div class="modal fade" id="projectStatusModal" tabindex="-1" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <h5 id="modalTitle" class="modal-title">Add Status</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
      </div>
      <div class="modal-body">
        <form method="POST" action="<?= base_url('administrator/redd/projects/save-items') ?>">
          <input type="hidden" name="project_id" value="<?= $project->id ?>">
          <input type="hidden" name="type" value="statuses">
          <div class="mb-3">
            <select id="newType" name="project_status_id" class="form-select">
                <option value="">-- Select New Status --</option>
                <?php foreach ($statuses as $at): ?>
                    <option value="<?= $at->id ?>"><?= esc($at->name) ?></option>
                <?php endforeach; ?>
            </select>
            </div>
            <div class="mb-3">
                <label for="descr" class="form-label fw-bold mb-0">Status Description</label>
                <textarea name="description" id="descr" class="form-control" rows="3"></textarea>
            </div>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-danger">Add Status</button>
      </div>
       </form>
    </div>
  </div>
</div>