<section id="breadcrumb-section" class="breadcrumb-section clearfix" style="background-image: url(assets/images/breadcrumb-bg.jpg);">
<div class="overlay-black">
<div class="container">
<h2 class="page-title">Withdrawals</h2>
</div>
</div>
</section>
<div class="breadcrumb-list">
<div class="container">
<ul>
<li class="breadcrumb-item"><a href="<?php echo base_url();?>">Home</a></li>
<li class="breadcrumb-item active">Withdrawals</li>
</ul>
</div>
</div>


<section id="service-section" class="service-section sec-ptb-100 clearfix">
<div class="container">
<div class="row">

<div class="col-lg-3 col-md-12 col-sm-12">
<div class="sidebar-section">

<div class="service-menu mb-30">
<h2 class="sidebar-title">Quick Links</h2>
<ul>
<li>
    <a href="<?php echo base_url();?>dashboard">Dashboard</a>
</li>
<li>
    <a href="<?php echo base_url();?>deposite">Deposite</a>
</li>
<li class="active">
    <a href="#">Withdrawl</a>
</li>
<li>
    <a href="<?php echo base_url();?>transactions">Transactions</a>
</li>
<li>
    <a href="<?php echo base_url();?>account">My Profile</a>
</li>
<li>
    <a href="<?php echo base_url();?>logout">Logout</a>
</li>
</ul>
</div>
</div>
</div>


<div class="col-lg-9 col-md-12 col-sm-12">
<div class="service-details">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-12">
<div class="servicev2 mb-30">
<div class="contant">
<h4 class="service-title title-small mb-15">
<span>
<i class="fa fa-inr"></i>
</span>
<a href="#"><?php 	$this->db->order_by("trid","desc");

					$chk=$this->db->get_where("transaction",array("userid"=>$this->session->userdata("user")));

					if($chk->num_rows()>0){

                    $l=$chk->row();

                    echo $wallet=$l->left_amt;}else{echo $wallet=0;}?></a>
</h4>
<p>Wallet Balance
</p>
</div>
</div>
</div>

<div class="col-lg-6 col-md-6 col-sm-12">
 <?php $this->db->order_by("trid","desc");
              $chk=$this->db->get_where("transaction",array("userid"=>$this->session->userdata("user")));
                if($chk->num_rows()>0){
                    $l=$chk->row();
                    $wallet=$l->left_amt;if($wallet>1000){?>
                                                <div class="form-group">
                                                <small>Enter Amount to Withdraw</small>
<form class="form-inline" action="" method="post" id="wform">
                                                        <input type="text" class="inputted-amount" required name="wamt" value="1000">
                                                        <button type="submit" class="btn btn-warning" style="margin-top:5px;">Withdraw</button>
                                                    </form>
                                                    <?php }}?>
                                                    </div>


</div>

          
</div>
<table id="fullMcxPriceTable" class="table table-condensed table-bordered" style="width:100%">
            <thead><tr><th>S.No.</th><th>Date</th><th>Amount</th><th>Status</th><th>Remarks</th><th>Action</th></tr></thead>
                                <tbody>
                                <?php $this->db->order_by("wid","desc");$this->db->limit(100);
                                      $data=$this->db->get_where("withdrawls",array("uid"=>$this->session->userdata("user")))->result();
                                      $i=1;foreach($data as $d){?>
                                      <tr><td><?php echo $i;?></td>
                                          <td><?php echo date("d-m-Y",strtotime($d->req_date));?></td>
                                          <td><?php echo $d->wamt;?></td>
                                          <td><?php if($d->req_status=='Pending'){echo '<span class="badge badge-warning">Pending</span>';}else
                                          if($d->req_status=='Reject'){echo '<span class="badge badge-danger">Rejected</span>';}else{
                                          echo '<span class="badge badge-success">Approved</span>';}?></td>
                                          <td><?php echo $d->remarks;?></td>
                                          <td>
                                          <?php if($d->req_status=="Pending"){?>
                                          <a class="btn btn-sm btn-danger wdelete" title="delete"  href="#" id="<?php echo $d->wid;?>"><i class="fa fa-times"></i> Cancel</a>
                                          <?php }?></td></tr>
                                      <?php $i++;}?></tbody>
                  </table>
</div>
</div>
</section>
<script>
			$(document).ready(function(){
				$("#wform").submit(function(e){e.preventDefault();
					var formdata=$(this).serialize();
					$.ajax({
					 type: "POST",//dataType:'json',
					 url: '<?php echo base_url();?>home/ajax_wform_submit',
					 data: {formdata:formdata},
					 success: function(res){//alert(res.target);
							alert(res);
						 }
					 });
				});
				
				$(".wdelete").click(function(e){e.preventDefault();



		if (!confirm("Sure you want to cancel withdrawal request?")){



				  return false;



				}



			var id=$(this).attr("id");



			$(this).closest("tr").remove();



			$.ajax({



							 type: "POST",



							 url: '<?php echo base_url();?>home/wdelete',



							 data: {id:id},



							 success: function(response){



								 //alert(response);



							 }



							 });



		});
			});
			</script>