<?php 
session_start();
$title = "Article Categories";
$group = "category";
$menu = "category";
include('header.php');
$_SESSION['isEdit']=false;
?>
<script>
function confirmDelete()
{
	if(!confirm("Are you sure you want to delete this category?"))
	{
		return false;
	}
	return true;
}
</script>

<div class="content-body">
        	<div class="row">
                    <div id="recent-transactions" class="col-12">
                        <div class="card">
                            <div class="card-header">
                                <h4 class="card-title">Article List</h4>
                            </div>
                            <div class="card-content">
                            <div class="row row-pad">
                                <div class="col-md-12"><a class="btn btn-info pull-right" href="category_setup">Add new</a></div>
                            </div>
                            <div class="row row-pad">
                                <div class="col-lg-12 table-responsive">
                                   <table class="table table-striped table-bordered table-hover table-advanced">
                                        <thead>
                                            <tr>
                                                <th>S/N</th>
                                                <th>Category Code</th>
                                                <th>Category Name</th>  
                                                <th>Status</th>  
                                                <th colspan="2">Actions</th>                             
                                            </tr>
                                        </thead>
                                        <tbody>
                                                <?php 
                                                    $sql="select * from news_category order by name";
                                                    $r=$con->run_select_query($sql);
                                                    $sn=1;
                                                    foreach($r as $value)
                                                    {
                                                        if($value['status']==1)
                                                        {
                                                            $status="<span class='label label-primary'>Active</span>";
                                                        }
                                                        else
                                                        {
                                                            $status="<span class='label label-default'>Inactive</span>";
                                                        }
                                                       
                                                        echo '<tr>
                                                                <td style="font-size:12px;">'.$sn.'</td>
                                                                <td>'.$value['code'].'</td>
                                                                <td>'.$value['name'].'</td>
                                                                <td>'.$status.'</td>
                                                                <td>
                                                                    <form method="post" action="../admin/category_setup">
                                                                        <input type="hidden" name="catid" value="'.$value['id'].'"/>
                                                                        <input type="submit" name="cat" value="Edit" class="btn btn-warning btn-sm"/>
                                                                    </form>
                                                                </td>
                                                                <td>
                                                                    <form method="post" action="../admin/category_list" onsubmit="return confirmDelete()">
                                                                        <input type="hidden" name="bankid" value="'.$value['id'].'"/>
                                                                        <input type="hidden" name="delete" value="deletebank"/>
                                                                        <input type="submit" name="bank" value="Delete" class="btn btn-danger btn-sm"/>
                                                                    </form>
                                                                </td>
                                                            </tr>';
                                                        $sn++;
                                                    } 
                
                                                    include('../include/delete.php');
                                                ?>
                                            </tbody>
                                   </table>
                                </div>
                            </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--/ Recent Transactions -->

   </div>
     
    <?php include('footer.php');?>

   
