<?php include('add_header.php'); ?>


<div class="container">
  <div class="col-lg-12 col-sm-12 col-xs-12 text-right" style="margin: 20px 0 0 0;">

<a class="btn btn-primary" href="<?php base_url(); ?>add_article" role="button">Add Article</a>
</div>
<div class="col-lg-12 col-sm-12 col-xs-12 text-center">
<?php if ($feedback =$this->session->flashdata('feedback')): 
      $feedback_class=$this->session->flashdata('feedback_class');

?>
<div class="alert <?php echo $feedback_class; ?>">
  <?php echo "$feedback"; ?>
</div>
<?php endif; ?>
</div>
	<table class="table">
  <thead>
    <tr>
      <th>Sr No.</th>
      <th>Title</th>     
      <th>Action</th>      
    </tr>
  </thead>
  <tbody>
  	<?php if (count($articles)):
    $count= 0;

    ?>  	

<?php  foreach ($articles as $article ): ?>
	
    <tr>
      <th scope="row"><?= ++$count; ?></th>
      <td><?= $article->title ?></td>
      
<td>
  <div class="col-lg-12 col-sm-12 col-xs-12 text-left">
    <div class="col-lg-2 col-sm-4 col-xs-4">
        <?= anchor("adminpanel/editarticle/{$article->id}",'Edit',['class'=>'btn btn-primary']); ?>
     
       <!-- <a class="btn btn-primary" href="#" role="button">Edit</a> -->

</div>
       <!--  <a class="btn btn-danger" href="#" role="button">Delete</a> -->
       <div class="col-lg-2 col-sm-4 col-xs-4">       
        <?= 
          form_open('adminpanel/deletearticle/', array('onsubmit'=>'return confirm(\'Are you sure want to delete this article?? \')')),
          form_hidden('article_id', $article->id),
          form_submit(['name'=>'submit','value'=>'Delete','class'=>'btn btn-danger']),                    
          form_close();
        ?>
      </div>
      </div>
      </td>      
    </tr>

 <?php  endforeach;  ?>
<?php else: ?>
	<tr>
      <th colspan="3">No records fonud</th>
  </tr>
<?php endif;  ?>
  </tbody>
</table>
<?=  $this->pagination->create_links(); ?>

</div>

<?php include('add_footer.php'); ?>
