<div class="content-wrapper" >
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <h1>
       <?= $pTitle ?>
        <small><?= $pDescription ?></small>
    </h1>
    <ol class="breadcrumb">
      <li><a href="<?= base_url() ?>"><i class="fa fa-star-o" aria-hidden="true"></i>Home</a></li>
      <li><?= $menu ?></li>
      <li class="active"><?= $smenu ?></li>
    </ol>
  </section>
  <!-- Main content -->
  <section class="content">
    <div class="row">
      <div class="col-md-12">
        <?php if($this->session->flashdata('message')) { 
          $flashdata = $this->session->flashdata('message'); ?>
          <div class="alert alert-<?= $flashdata['class'] ?>">
             <button class="close" data-dismiss="alert" type="button">×</button>
             <?= $flashdata['message'] ?>
          </div>
        <?php } ?>
      </div>
      <div class="col-xs-12">
        <div class="box box-warning">
          <div class="box-header with-border">
            <div class="col-md-6"><h3 class="box-title">Category List</h3></div>
            <div class="col-md-6" align="right">
              <a class="btn btn-sm btn-primary" href="<?= base_url('Category/addCategory') ?>">
                Add New Category
              </a>
              <a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
           </div>
          </div>
          <div class="box-body">
            <table id="mechanicUsers" class="table table-bordered table-striped datatable ">
              <thead>
                <tr>
                  <th class="hidden">ID</th>
                  <th width="50px;">Icon</th>
                  <th width="150px;">Category</th>
                  <th width="250px;">Category Description</th>
                  <th width="70px;">Status</th>
                  <th width="200px;">Action</th>
               </tr>
              </thead> 
              <tbody>
                <?php
                if(!empty($categoryData)){
                  foreach($categoryData as $category) { ?>
                    <tr>
                      <th class="hidden"><?= $category->cat_id ?></th>
                      <th class="center textCenterAlign">
                        <img id="image_id" src="<?= base_url($category->category_image) ?>" 
                             onerror="this.src='<?=base_url("assets/images/no_image_text.png")?>';" 
                             height="50" width="50" />
                      </th>
                      <th class="center"><?= $category->category ?></th>
                      <th class="center"><?= $category->category_description ?></th>
                      <th class="center"><?= ($category->status == 1)?'Active':'De-activate' ?></th>
                      <td class="center">   
                        <a class="btn btn-sm btn-primary" 
                           href="<?= base_url('Category/editCategory/'.encode_param($category->cat_id))?>">
                          <i class="fa fa-fw fa-edit"></i>Edit
                        </a> 
                        <a class="btn btn-sm btn-danger" 
                        href="<?= base_url("Category/changeStatus/".encode_param($category->cat_id))."/2" ?>" 
                            onClick="return doconfirm()">
                          <i class="fa fa-fw fa-trash"></i>Delete
                        </a>    
                        <?php if($category->status == 1){ ?>
                          <a class="btn btn-sm btn-success" style="background-color:#ac2925" href="<?= base_url("Category/changeStatus/".encode_param($category->cat_id))."/0" ?>">
                            <i class="fa fa-cog"></i> De-activate
                          </a>
                        <?php } else { ?>
                          <a class="btn btn-sm btn-success" href="<?= base_url("Category/changeStatus/".encode_param($category->cat_id))."/1" ?>">
                            <i class="fa fa-cog"></i> Activate
                          </a>
                        <?php } ?>
                      </td>
                    </tr>
                <?php } } ?>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </section>
</div>