<?php $this->load->view('admin/header_list'); ?>
<div class="wrapper">
<?php $this->load->view('admin/top'); ?>
<?php $this->load->view('admin/side'); ?>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        <?php echo $page_title; ?>
      </h1>
    </section>

    <!-- Main content -->
    <section class="content">

      <!-- Default box -->
      <div class="box">
		<?php echo form_open('studio/delete_main_page_banners', array('class'=>'form-horizontal','name'=>'bulk_action_form','onsubmit'=>'return deleteConfirm();'));?>
        <div class="box-header with-border">
          <h3 class="box-title"><?php echo $page_title; ?></h3>

          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
              <i class="fa fa-minus"></i></button>
            <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
              <i class="fa fa-times"></i></button>
          </div>
        </div>
		<div class="box-header with-border">
          <a href="<?php echo base_url(); ?>studio/add_main_page_banners" class="btn btn-primary">Add Main Page Banner Images</a>
		  <button type="submit" class="btn" name="bulk_delete_submit">Delete Seleted Main Page Banner Images</button><br><br>
		  <div id="message"><?php echo $message;?></div>
        </div>
        <div class="box-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
				  <th><input type="checkbox" id="select_all" onclick='select_all_check()'></th>
                  <th>S.No</th>
                  <th>Name</th>
                  <th>Img</th>
                  <th>Options</th>
                </tr>
                </thead>
                <tbody>
				<?php 
					$this->db->select('*');
					$this->db->from('main_page_banners');
					$this->db->where('main_page_banners.status','yes');
					$religion_list = $this->db->get();
						if($religion_list->num_rows()>0){
							$i=1;
							foreach($religion_list->result() as $row){
								echo "<tr>
									    <td style='width:10px;'><input type='checkbox' name='checked_id[]' class='checkbox' value='".$row->main_page_banners_id."'/></td> 
										<td style='width:50px;'>".$i."</td>
										<td>".$row->name."</td>
										<td><img src='".base_url()."uploads/main_page_banners/".$row->url."' class='img-responsive' style='height:80px;width:80px;'></td>
										<td style='width:225px;'>
										<a href='".base_url()."studio/main_page_banners_view/".$row->main_page_banners_id."' class='label label-success'><i class='fa fa-tv'></i> View</a>
										<a href='#' title='Delete' onclick='delete_record(".$row->main_page_banners_id.")' class='label label-danger'><i class='fa fa-ban'></i> Delete</a>
										</td>
									  </tr>";
									  //<a href='#' title='Delete' onclick='delete_record(".$row->religion_id.")' class='label label-danger'><i class='fa fa-ban'></i> Delete</a>
								$i++;
							}
							
						}
						?>
                </tbody>
                <tfoot>
                <tr>
				  <th></th>
                  <th>S.No</th>
                  <th>Name</th>
                  <th>Img</th>
                  <th>Options</th>
                </tr>
                </tfoot>
              </table>
            </div>
        <!-- /.box-body -->
        <div class="box-footer">
        </div>
		<?php echo form_close();?>
        <!-- /.box-footer-->
      </div>
      <!-- /.box -->

    </section>
    <!-- /.content -->
  </div>
  <script type="text/javascript">
		function delete_record(id)
		{
			$.msgBox({
				title: "Confirm !",
				content: "Are you sure you want to delete this?",
				type: "confirm",
				buttons: [{ value: "Confirm" }, { value: "Cancel"}],
				success: function (result) {
					if (result == "Confirm") {
						var form_data = {
							main_page_banners_id : id,					
							ajax : '1'
						};
						$.ajax({
							url: '<?php echo base_url(); ?>studio/delete_main_page_banners',
							type: 'POST',
							async : false,
							data: form_data,
							success: function(msg) {
								setTimeout(function () {
								   window.location.href = "<?php echo base_url();?>studio/main_page_banners_list"; //will redirect to your blog page (an ex: blog.html)
								}, 2000);
								$('#message').html(msg);
							}
						});
						return false;
					}
				}
			});
		}
	</script>
	<script type="text/javascript">
	function deleteConfirm(){
		var result = confirm("Are you sure to delete users?");
		if(result){
			return true;
		}else{
			return false;
		}
		/*$.msgBox({
				title: "Confirm !",
				content: "Are you sure you want to delete this?",
				type: "confirm",
				buttons: [{ value: "Confirm" }, { value: "Cancel"}],
				success: function (result) {
					if (result == "Confirm") {
						return true;
					}else{
						return false;
					}
				}
			});*/
	}
	
	function select_all_check(){
		$("#select_all").change(function () {
			$("input:checkbox").prop('checked', $(this).prop("checked"));
		});
	}
	</script>
 <?php $this->load->view('admin/footer_list'); ?>