<?php
include_once('../helpers/init.php');
include_once('../header.php');
?>
<div class="row">
	<div class="col-md-12">
		<?php
if(isset($_GET['result']) && $_GET['result']=="success"){
?>
<div class="alert alert-success alert-dismissible">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Success!</strong> Deleted Successfully!
</div>
<?php
}
if(isset($_GET['result']) && $_GET['result']=="failer"){
?>
<div class="alert alert-danger alert-dismissible">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Fail!</strong><?php if(isset($_GET['message'])){echo $_GET['message']; } ?>
</div>
<?php
}
?>
		  <div class="card mb-3">
            <div class="card-header">
              <i class="fas fa-table"></i>
             Product Categories</div>
            <div class="card-body">
              <div class="table-responsive">
                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                  <thead>
                    <tr class="bg-dark text-white">
                       <th style="width: 80px">S.No</th>
                       <th>Name</th>
                     <!--  <th>Parent Category</th> -->
                      <th>Actions</th>
                    </tr>
                  </thead>
                  <tfoot>
                    <tr>
                     <th>S.No</th>
                     <th>Name</th>
                      <!-- <th>Parent Category</th> -->
                      <th style="width: 160px;">Actions</th>
                    </tr>
                  </tfoot>
                  <tbody>
                  	<?php
                  	$categories = get("categories","id","DESC");
                  	$count=1;
                  	foreach($categories as $row){
                  	?>
                    <tr>
                    	<td><?php echo $count; ?></td>
                      <td><?php echo $row['name']; ?></td>
                      <!-- <td><?php $id=$row['parent'];
                      	$parent = getWhere("categories","id",$id);
                      	foreach($parent as $value){echo $value['name'];}
                       ?></td> -->
                      <td>
                      	<div class="btn-group">
                      	<a href="javascript:void(0)" onclick="warning('products/update-category.php?id=<?php echo $row['id']; ?>','Update Category ?')" class="btn btn-sm btn-primary"><span class="fa fa-pencil-square-o"></span> Modify</a>
                      	<a href="javascript:void(0)" onclick="warning('process/category-functions.php?id=<?php echo $row['id']; ?>&action=deleteCategory','Confirm Delete ?')" class="btn btn-sm btn-danger"><span class="fa fa-trash"></span> Delete</a>

                      </div>
                  	</td>
                    </tr>
                <?php $count++; } ?>
                  </tbody>
                </table>
              </div>
            </div>
            <div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div>
          </div>

	</div>
</div>
<?php
include_once('../footer.php');
?>