<div class="col-md-4">
	<form action="" method="post" id="log_form">
    	<input type="hidden" name="ftype" value="<?php echo $type;?>" />
    	<div class="form-group">
        	<h5 class="text-warning">Add Note</h5>
            <textarea class="form-control" name="remark" required rows="5"></textarea>
        </div>
        <div class="form-group">
        	<label>Next Reminder</label>
            <input type="date" class="form-control" name="nxt_date" />
            <input type="hidden" name="cusid" value="<?php echo $cusid;?>" />
        </div>
        <button type="submit" class="btn btn-block btn-warning">Add Note</button>
    </form>
</div>
<div class="col-md-8"><h5 class="text-warning"> Notes</h5>
	<table class="table table-condensed table-bordered table-striped">
    	<thead><tr><th>S.No.</th><th>Log Date</th><th>Remark</th><th>Next Remind</th><th>Action</th></tr></thead>
        <tbody>
        	<?php $i=1;foreach($logs as $l){?>
            <tr><td><?php echo $i;?></td>
            	<td><?php echo date("d M'Y h:i a",strtotime($l->log_date));?></td>
            	<td><?php echo $l->remark;?></td>
            	<td><?php echo date("d M'Y",strtotime($l->nxt_date));?></td>
                <td><a href="#" id="<?php echo $l->fid;?>" class="btn btn-sm btn-danger log_delete"><i class="fa fa-trash"></i></a></td></tr>
            <?php $i++;}?>
        </tbody>
    </table>
</div>
<script>
$(document).ready(function(){
	$("#log_form").submit(function(e){e.preventDefault();
		var formdata=$(this).serialize();
		$(".logs_div").html("<h3>Please wait while Saving Notes..</h3><img class='center-block img img-responsive' src='https://loading.io/spinners/typing/lg.-text-entering-comment-loader.gif'/>");
		$.ajax({
			 type: "POST",
			 url: '<?php echo base_url();?>admin/ajax_log_form',
			 data: {formdata:formdata},
			 success: function(res){
				if(res!=0){
				$(".logs_div").html(res);
				alert("Note Saved Successfully.");
				}else{alert("Couldnot Save Note.");}
				//$(".res_msg").html(res);
				// $(".followuptab").trigger("click");
			 }
		});
	});
	$(".log_delete").click(function(e){e.preventDefault();
		if(!confirm("Sure you want to delete?")){
			  return false;
		}
		var id=$(this).attr("id");$(this).closest("tr").remove();
		$.ajax({
			 type: "POST",
			 url: '<?php echo base_url();?>admin/ajax_log_delete',
			 data: {id:id},
			 success: function(response){
				 //alert(response);
			 }
		});
	});
});
</script>