<?php if(!empty($trades)){?>
<tr bgcolor="#eee"><th>S.No.</th><th>Pair</th><th>Sell</th><th>Buy</th><th>LotSize</th><th>Profit/Loss</th><th>TGT/SL</th><!--<th>Action</th>--></tr>
<?php $i=1;
//echo "<pre>";print_r($trades);exit;
foreach($trades as $allt){?>
<tr><td><?php echo $i;?></td>
	<td><?php echo $allt->cpair;?></td>
	<td><?php echo $allt->sell_price;?></td>
	<td><?php echo $allt->buy_price;?></td>
	<td><?php echo $allt->lotsize;?></td>
	<td><?php echo $allt->profit_loss;?></td>
	<td><?php echo 'TGT: '.$allt->target.'<br/>SL: '.$allt->stoploss;?></td>
    <!--<td><?php //if($allt->trade_status!="EXIT"){?>
    <button id="<?php //echo $allt->trade_id;?>" type="button" class="btn btn-sm btn-info edit_trade" data-toggle="modal" data-target="#edit_modal">EDIT</button>
    <button id="<?php //echo $allt->trade_id;?>" type="button" class="btn btn-sm btn-warning exit">EXIT</button><?php //}?>
    </td>-->
    </tr>
<?php $i++;}?>
<script>
$(".exit").click(function(){
	var id=$(this).attr("id");
	if (!confirm("Sure you want to Square-Off?")){
	  return false;
	}$(this).closest("tr").remove();
	
	$.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>home/ajax_close_trade',
				 data: {id:id},
				 success: function(res){
					 //console.log(res);
					 //$(".exit_trades").html(res);
				 }
			 });
			 
});
$(".edit_trade").click(function(){
	var id=$(this).attr("id");
	$.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>home/ajax_edit_trade',
				 data: {id:id},
				 success: function(res){
					 $(".trade_data").html(res);
					 //$(".exit_trades").html(res);
				 }
			 });
			 
});
</script>
<?php }else{?>
<h3 class="text-center text-danger" style="margin:50px;">No Active Trades</h3>
<?php }?>