     <link rel="stylesheet" href="<?php echo base_url();?>newadminassets/plugins/datatables/dataTables.bootstrap.min.css">
    <link rel="stylesheet" href="<?php echo base_url();?>newadminassets/plugins/datatables/responsive.bootstrap.min.css">
<div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                   Manage Ads
                </h1>
              <ol class="breadcrumb">
                    <li><a href="<?php echo base_url();?>admin"><i class="fa fa-home"></i>Home</a></li>
                    <li class="active">Manage Ads</li><li class="active">Ads Listings</li>
                </ol>
            </section>
            <!-- Main content -->
            <div class="content">
           
                <div class="container-fluid">
                 
                    <!-- Tabs -->
                    <!-- third row  -->
                    <div class="row"> 
                       <div class="col-md-12 col-sm-12">
                       <?php if($this->session->flashdata("msg")!==""){?>
                          <!--<div class="alert alert-info">
                                            <strong><?php echo $this->session->flashdata("msg");?>!</strong> 
                                        </div>--><?php }?>
                            <div class="panel panel-primary">
							
      <div class="panel-heading">Listing All Posted Ads</div>
      <div class="panel-body">
        <table class="table table-striped table-responsive table-bordered dataTable" id="example-2">
        	<thead>
												<tr>
													<th>S.No.</th>
													<th>Photo</th>
													<th>Title</th>
													<th>Category</th>
													<th>Ad Status</th>
													<th>Price &amp; Location</th>
													<th>Date</th>
													<th>Action</th>
												</tr>
											</thead>
			<tbody>
                                            <?php  $i=1;foreach($ads as $myad){?>
                                            <tr data-category="active">
													<td data-title=""><?php echo $i;?></td><?php $img=explode(",",$myad->imgs);?>
             <td data-title="Photo"><img style="width:100px;" src="<?php echo base_url();?>assets/images/ads/<?php echo $img[0];?>" alt=""></td>
                            <td data-title="Title">
                                <h4><?php echo $myad->title;?></h4>
                                <span>Ad ID: AD<?php echo $myad->aid;?><br/>
                                 <input type="checkbox" name="in_trend" <?php if($myad->feat!=""){echo "checked";}?> value="<?php echo $myad->aid;?>" class="in_feat" /> In <?php if($myad->feat!=""){?><span class="label label-warning">featured</span><?php }else{echo "Featured";}?></span>
                            </td>
                            <td data-title="Category"><span class="tg-adcategories"><?php echo $myad->cat_name.'-'.$myad->subcat_name;?></span></td>
                           
                        <td data-title="Ad Status">
                         <input type="checkbox" name="in_trend" <?php if($myad->ad_status!=""){echo "checked";}?> value="<?php echo $myad->aid;?>" class="ad_status" /> <?php if($myad->ad_status!=""){?><span class="label label-success">Active</span><?php }else{echo "Inactive";}?></span>
                        </td>
                        <td data-title="Price &amp; Location">
                            <h4>DA <?php echo $myad->price;?></h4>
                            <address><?php echo $myad->address;?></address>
                        </td>
                        <td data-title="Date">
                            <time datetime="2017-08-08"><?php echo date("d M Y",strtotime($myad->post_date));?></time>
                            <span>Published</span>
                        </td>
                        <td data-title="Action">
<div class="tg-btnsactions">
    <a class="btn btn-xs btn-success" href="<?php echo base_url();?>home/ad_detail/<?php echo str_replace(" ","-",$myad->title);?>/<?php echo $myad->aid;?>" target="_new"><i class="fa fa-eye"></i></a>
    <a class="btn btn-xs btn-danger ad_delete" href="<?php echo $myad->aid;?>"><i class="fa fa-trash"></i></a>
    <a href="#" id="<?php echo $myad->aid;?>" class="btn btn-xs btn-primary view_offer" data-toggle="modal" data-target="#md-colored"><i class="fa fa-comments"></i></a>
</div>
                        </td>
												</tr>
                                            <?php $i++;}?>
                                            </tbody>
        </table>
        <div class="modal fade colored-header" id="md-colored" tabindex="-1" role="dialog">
                                <div class="modal-dialog">
                                    <div class="modal-content" id="response">
                                        <div class="modal-header">
                                            <h3>Custom Colored Header</h3>
                                            <button class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                        </div>
                                        <div class="modal-body">
                                            <div class="text-center">
                                                <div class="modal-icon"><i class="fa fa-snowflake-o"></i></div>
                                                <h4>Cool!</h4>
                                                <p>Do any kindda stuff here </p>
                                            </div>
                                        </div>
                                        <div class="modal-footer">
                                            <button class="btn btn-default" data-dismiss="modal">Cancel</button>
                                            <button class="btn btn-primary" data-dismiss="modal">Save</button>
                                        </div>
                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal-dialog -->
                            </div>
      </div>
    </div>
                        </div>
                        
                        
                    </div>
                    
                    
                </div>
            </div>
            <!-- /.content -->
        </div>
  <footer class="main-footer">
            <!-- To the right -->
           <!-- <div class="pull-right hidden-xs">
                Developed by <i class="fa fa-heart"></i> Floatin
            </div>-->
            <!-- Default to the left -->
            <strong>Copyright &copy; 2017 <a href="#">dz48</a>.</strong> All rights reserved.
        </footer>
    </div>
   <script>
	$(document).ready(function(){
		$(".view_offer").click(function(){
				//$(".firstmsg").html('');
				var aid=$(this).attr('id');
				$.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>admin/offerusers',
				 data: {aid:aid},
				 success: function(res){
				//alert(res);
				$("#response").html(res);
				}
				 }); 
			});
		$(".ad_status").click(function(){
							var id=$(this).val();
							var v="";
							if ($(this).is(':checked')) {
								var v='yes';
							}
							//alert(v);
							$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/ad_status',
							 data: {v:v,id:id},
							 success: function(response){
								// alert(response);
							 }
							 });
						});
		$(".in_feat").click(function(){
							var id=$(this).val();
							var v="";
							if ($(this).is(':checked')) {
								var v='yes';
							}
							//alert(v);
							$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/in_feat',
							 data: {v:v,id:id},
							 success: function(response){
								// alert(response);
							 }
							 });
						});
		$(".ad_delete").click(function(e){e.preventDefault();
			var id=$(this).attr("href");$(this).closest("tr").remove();
			$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/ad_delete',
							 data: {id:id},
							 success: function(response){
								 //alert(response);
							 }
							 });
		});
	});
</script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/jquery-3.1.1.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/bootstrap.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/material.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/ripples.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/jquery.slimscroll.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/dataTables.responsive.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/dataTables.bootstrap.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/dataTables.buttons.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/jszip.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/pdfmake.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/vfs_fonts.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/buttons.html5.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/buttons.print.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/buttons.colVis.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/js/datatables.js"></script>
    <script src="<?php echo base_url();?>newadminassets/js/app.js"></script>
  

</body>

