<?php
$page = 'News';
?>
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Admin</title>

    <!-- Bootstrap Core CSS -->
    <link href="<?php echo base_url(); ?>assets/Backend/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="<?php echo base_url(); ?>assets/Backend/css/sb-admin.css" rel="stylesheet">
    <!-- Morris Charts CSS -->
    <link href="<?php echo base_url(); ?>assets/Backend/css/plugins/morris.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/Backend/font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
	
	
	<link href="<?php echo base_url(); ?>assets/Backend/bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
	<link href="<?php echo base_url(); ?>assets/Backend/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet">
	<link href="<?php echo base_url(); ?>assets/Backend/bower_components/datatables-responsive/css/dataTables.responsive.css" rel="stylesheet">
	<link href="<?php echo base_url(); ?>assets/Backend/dist/css/sb-admin-2.css" rel="stylesheet">
	<link href="<?php echo base_url(); ?>assets/Backend/bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
	<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
	
	<script language="javascript" type="text/javascript">
		function checkDelete()
		{
          return confirm('Delete News Details. Are you Sure?');
        }
		
	</script>
	<style>
		.tr,th ,td {
			text-align: center;
		}
	</style>
	
</head>

<body>

    <div id="wrapper">

        <!-- Navigation -->
        <?php
		include "include/header.php";
		?>
        

        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Blogs
                            <a href="<?php echo base_url(); ?>App/new_news" class="btn btn-primary pull-right"> Add</a>
                        </h1>
						<?php if($this->session->flashdata('success_news'))
							{ ?>
							<div class="alert alert-danger alert-dismissable" style="font-size:12px;">
			                 <button type="button" class="close" data-dismiss="alert" aria-hidden="true" >×</button>
								<?php echo $this->session->flashdata('success_news');?>
							</div>
							<?php }?>
							<?php if($this->session->flashdata('delete_news'))
							{ ?>
							<div class="alert alert-danger alert-dismissable" style="font-size:12px;">
			                 <button type="button" class="close" data-dismiss="alert" aria-hidden="true" >×</button>
								<?php echo $this->session->flashdata('delete_news');?>
							</div>
							
							<?php }?>
                          
                    </div>
                </div>
                
                <!-- /.row -->

				<div class="row">
					<div class="panel-body">
				<div class="dataTable_wrapper">
                <table class="table table-striped table-bordered table-hover" >
                <thead>
                <tr style="background-color:#fff;">
                <th width="8%">Sr No.</th>
                <th width="20%">Title</th>
                <th width="15%">Date</th>
                <th width="20%">Image</th>
                <th width="8%"> Action</th>
                </tr>
                </thead>
                <tbody>
                <?php
				$cnt=0;
				foreach($news as $row):
				$n_id = $row->n_id;
				$cnt+=1;
                date_default_timezone_set("Asia/Bangkok");
				?>
                <tr>
                <td style="text-align: center;"><?php echo $cnt; ?></td>
                <td><?php echo $row->n_title;?></td>
                <td><?php echo date("d-m-Y",strtotime($row->n_date));?></td>
                <td>
					<?php $count = $row->n_image_count;
									if($count > 0)
									{
									 for($i=1;$i<=$count;$i++)
									 {
										if($i == 1) {
									?>
					<img src="<?php echo base_url();?>assets/uploads/news/news_<?php echo $row->n_id.'_'.$i.'.jpg';?>" width="200px" height="150px">
					
				</td>
				<?php } } } ?>
                <td>
                   
				  <a href="<?php echo base_url(); ?>Delete/del_news/<?php echo $n_id;?>" onclick="return checkDelete()" class="btn btn-danger">Delete</a>
				  
				</td>
                </tr>
                <?php
				endforeach;
				?>
                </tbody>
                </table>
				
					
				</div>
					</div>
            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- jQuery Version 1.11.0 -->
    <script src="<?php echo base_url(); ?>assets/Backend/js/jquery-1.11.0.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="<?php echo base_url(); ?>assets/Backend/js/bootstrap.min.js"></script>
	
	<script src="<?php echo base_url(); ?>assets/Backend/bower_components/jquery/dist/jquery.min.js"></script>
	<script src="<?php echo base_url(); ?>assets/Backend/bower_components/metisMenu/dist/metisMenu.min.js"></script>
    <!-- Bootstrap Core JavaScript -->
    <script src="<?php echo base_url(); ?>assets/Backend/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
	
	<script src="<?php echo base_url(); ?>assets/Backend/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/Backend/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
	<script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
                responsive: true
        });
    });
    </script>
    </body>

</html>
