<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.8.0/css/bootstrap-datepicker.css" />	
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.8.0/js/bootstrap-datepicker.js"></script>-->
<section role="main" class="content-body">
					<header class="page-header">
						<h2>Closed Auctions</h2>
						<div class="right-wrapper pull-right">
							<ol class="breadcrumbs">
								<li>
									<a href="<?php echo base_url();?>admin">
										<i class="fa fa-home"></i>
									</a>
								</li>
								<li><span>Closed Auctions</span></li>
							</ol>
						</div>
					</header>
						<section class="panel">
							<header class="panel-heading">
				<h2 class="panel-title">List of <b class="text-danger">Closed</b> Auctions</h2>
							</header>
							<div class="panel-body">
                           	 <form class="form-inline" action="<?php echo base_url();?>admin/closed_auction" method="get">
                              
                              <div class="form-group">
                                <input type="date" value="<?php if(isset($_GET['date'])){echo $_GET['date'];}else{echo date("Y-m-d");}?>" class="form-control" name="date">
                              </div>
                              <button type="submit" class="btn btn-primary">Filter</button>
                            </form><br/>
								<table class="table table-bordered table-striped mb-none" data-swf-path="assets/vendor/jquery-datatables/extras/TableTools/swf/copy_csv_xls_pdf.swf">
        									<thead>
												<tr>
						<th>S.No.</th><th>Image</th><th>Product</th><th>Max Bids</th><th>Min Bids</th><th>AuctionsDetails</th><th>Winner</th>
												</tr>
											</thead>
											<tbody>
                                            <?php  $i=1;foreach($auctions as $myad){?>
                                            <tr data-category="active">
												<td data-title=""><?php echo $i;?></td>
                                             <td><img width="50px" src="<?php echo base_url();?>assets/images/products/<?php echo $myad->img;?>" class="img img-responsive"></td>
    <td><h4><?php echo $myad->title;?></h4><label class="label label-default">AUC<?php echo $myad->apid;?></label></td><td>
 <h5>Max Auction Price : <?php echo $myad->max_price;?><br/>
 (<b class="text-danger">MaxBidCoins - <?php echo ceil($myad->max_price/$this->session->userdata("bidrate"));?></b>)<br/>
 (<b class="text-success">MaxBids - <?php echo ceil(ceil($myad->max_price/$this->session->userdata("bidrate"))/$myad->req_credit);?></b>)</h5></td>
 <td><h5>Min Auction Price : <?php echo $myad->min_price;?><br/>
(<b class="text-danger">MinBidCoins - <?php echo ceil($myad->min_price/$this->session->userdata("bidrate"));?></b>)<br/>
(<b class="text-success">MinBids - <?php echo ceil(ceil($myad->min_price/$this->session->userdata("bidrate"))/$myad->req_credit);?></b>)<br/></h5></td>
               <td>
                Total Bids - <b id="prebid<?php echo $myad->apid;?>"><?php echo $this->db->get_where("auctions",array("auc_dayid"=>$myad->apid))->num_rows();?></b><br/>
                Actual Bids - <b id="actual<?php echo $myad->apid;?>"><?php echo $this->db->get_where("auctions",array("auc_dayid"=>$myad->apid,"bid_type"=>""))->num_rows();?></b><br/>
                Virtual Bids -<b id="virtual<?php echo $myad->apid;?>"><?php echo $this->db->get_where("auctions",array("auc_dayid"=>$myad->apid,"bid_type"=>"robot"))->num_rows();?></b>
               </td>
               <td><?php $this->db->select("*");
			   			$this->db->from("auctions");
						$this->db->join("users","auctions.uid=users.id");
						$this->db->where("auctions.auc_dayid",$myad->apid);
						$this->db->order_by("aucid","desc");
						$uu=$this->db->get()->row();echo $uu->username;?>
               <?php ?><br/><a href="#" title="<?php echo $myad->title;?>" id="<?php echo $myad->apid;?>" class="btn btn-success btn-xs viewlive" data-toggle="modal" data-target="#myModal">View Bids</a></td>
                </tr>
                  
                                            <?php $i++;}?>
                                            </tbody>
        						</table>
							</div>
						</section>
				</section>
                <div id="myModal" class="modal fade" role="dialog">
                  <div class="modal-dialog modal-md">
                    <!-- Modal content-->
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">Auction Fields</h4>
                      </div>
                      <div class="modal-body">
                        
                      </div>
                    </div>
                  </div>
                </div>
			  </div>

			
		</section>

		<!-- Vendor -->
        <script>
	$(document).ready(function(){
		$('.date').datepicker({ format: 'yyyy-mm-dd', autoclose: true,});
		$(".viewlive").click(function(){
			var apid=$(this).attr("id");
			$.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>admin/view_live_bid',
				 data: {apid:apid},
				 success: function(response){
					 //alert(response);
					 $(".modal-body").html(response);
				 }
				 });
		});
		
		$(".auction").click(function(){
			var pid=$(this).attr("id");
			var title=$(this).attr("title");
			$(".modal-title").text(title);
			$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/set_auction',
							 data: {pid:pid},
							 success: function(response){
								 //alert(response);
								 $(".modal-body").html(response);
							 }
							 });
		});
		$(".enable").click(function(e){e.preventDefault();
			var st=$(this).text();
			var id=$(this).attr("href");
			if(st=="Enable"){
			$(this).text("Disable");
			}else{
			$(this).text("Enable");	
			}
			$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/proenable',
							 data: {id:id,st:st},
							 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);
							 }
							 });
						});
						$(".buy_now").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/buy_now',
							 data: {v:v,id:id},
							 success: function(response){
								// alert(response);
							 }
							 });
						});
		$(".pro_delete").click(function(e){e.preventDefault();
		if (!confirm("Sure you want to delete?")){
				  return false;
				}
			var id=$(this).attr("href");$(this).closest("tr").remove();
			$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/pro_delete',
							 data: {id:id},
							 success: function(response){
								 //alert(response);
							 }
							 });
		});
	});
</script>
	<script src="<?php echo base_url();?>admin_assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
		<script src="<?php echo base_url();?>admin_assets/vendor/bootstrap/js/bootstrap.js"></script>
		<script src="<?php echo base_url();?>admin_assets/vendor/nanoscroller/nanoscroller.js"></script>
		<script src="<?php echo base_url();?>admin_assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
		<script src="<?php echo base_url();?>admin_assets/vendor/magnific-popup/magnific-popup.js"></script>
		<script src="<?php echo base_url();?>admin_assets/vendor/jquery-placeholder/jquery.placeholder.js"></script>
		
		<!-- Specific Page Vendor -->
		<script src="<?php echo base_url();?>admin_assets/vendor/select2/select2.js"></script>
		<script src="<?php echo base_url();?>admin_assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
		<script src="<?php echo base_url();?>admin_assets/vendor/jquery-datatables/extras/TableTools/js/dataTables.tableTools.min.js"></script>
		<script src="<?php echo base_url();?>admin_assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>
		
		<!-- Theme Base, Components and Settings -->
		<script src="<?php echo base_url();?>admin_assets/javascripts/theme.js"></script>
		
		<!-- Theme Custom -->
		<script src="<?php echo base_url();?>admin_assets/javascripts/theme.custom.js"></script>
		
		<!-- Theme Initialization Files -->
		<script src="<?php echo base_url();?>admin_assets/javascripts/theme.init.js"></script>


		<!-- Examples -->
		<script src="<?php echo base_url();?>admin_assets/javascripts/tables/examples.datatables.default.js"></script>
		<script src="<?php echo base_url();?>admin_assets/javascripts/tables/examples.datatables.row.with.details.js"></script>
		<script src="<?php echo base_url();?>admin_assets/javascripts/tables/examples.datatables.tabletools.js"></script>
</body>
</html>