<div class="col-md-4">
<form action="" method="post" id="addform">
    <input type="hidden" name="user" value="<?php echo $user->ag_id;?>" id="user" />
    <input type="hidden" name="wallet_state_id" value="<?php echo $user->ag_state;?>"/>
    <input type="hidden" name="staff_id" value="<?php echo $user->staff_id;?>"/>
    <div class="form-group">
        <label>Type</label>
        <select class="form-control" name="type" required>
            <option value="Credit">Credit</option>
            <option value="Debit">Debit</option>
        </select>
    </div>
	<div class="form-group">
    	<label>Amount</label>
        <input type="number" class="form-control" required name="amount" />
    </div>
    <div class="form-group">
    	<label>Remarks</label>
        <textarea class="form-control" rows="3" name="trans_remarks"></textarea>
    </div>
    <button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<div class="col-md-8">
<h6 class="text-danger">Transactions</h6>
<table class="table table-bordered">
	<thead><tr bgcolor="#CCCCCC"><th>S.No.</th><th>TransDate</th><th>Credit</th><td>Debit</th><th>Balance</th></tr></thead>
    <tbody>
    	<?php $this->db->order_by("wid","desc");$this->db->limit(20);
		$trans=$this->db->get_where("wallet",array("did"=>$user->ag_id))->result();
		$i=1;foreach($trans as $tr){?>
        <tr><td><?php echo $i;?></td>
        	<td><?php echo $tr->trans_date;?></td>
            <td><?php if($tr->trans_type=='Credit'){echo $tr->trans_amt.'<br/><span class="badge badge-success">'.$tr->trans_remarks.'</label>';}?></td>
            <td><?php if($tr->trans_type=='Debit'){echo $tr->trans_amt.'<br/><span class="badge badge-warning">'.$tr->order_no.'</label>';}?></td>
            <td><?php echo $tr->wallet_amt;?></td></tr><?php $i++;}?>
    </tbody>
</table>
</div>
<script>
	    $("#addform").submit(function(e){e.preventDefault();
		var formdata=$(this).serialize();
		//console.log(formdata);return false;
		$.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>admin/add_money_submit',
				 data: {formdata:formdata},
				 success: function(response){
					 alert(response);
					}
			});
		});
	  </script>