<div class="modal-content">
	<div class="modal-header bg-red-sunglo">
		<button type="button" class="close" data-dismiss="modal"></button>
		<h4 class="modal-title font-white"><i class="icon-book-open"></i> 個人點數紀錄</h4>
	</div>
	<div class="modal-body">
		<div>
			<button id="view_back_to_point" class="btn blue" style="margin-bottom:10px;margin-left:1%;">回上一頁 (點數管理)</button>
		</div>
		<div class="col-md-3">
			<div class="panel panel-success">
				<div class="panel-heading">
					<h3 class="panel-title"><?php echo e($user->name); ?>(<?php echo e($user->username); ?>)</h3>
				</div>
				<div class="panel-body">
					 <p><?php echo app('translator')->get('messages.tel2'); ?> : <?php echo e($user->tel); ?></p>
					 <p><?php echo app('translator')->get('messages.mobile'); ?> : <?php echo e($user->mobile); ?></p>
				</div>
				<ul class="list-group">
					<li class="list-group-item">
						 <?php echo app('translator')->get('messages.left_pt'); ?> <span id="point_free" class="badge badge-success"><?php echo e($user->point_free); ?></span>
					</li>
					<li class="list-group-item">
						 <?php echo app('translator')->get('messages.buy_left_pt'); ?> <span id="point_buy" class="badge badge-success"><?php echo e($user->point_buy); ?></span>
					</li>
				</ul>
			</div>
			<button type="button" class="btn green-meadow btn-block btn_point" style="margin-left:0px;" data-type="give_free"><?php echo app('translator')->get('messages.issue_pt_desc1'); ?></button>
			<button type="button" class="btn blue-madison btn-block btn_point" style="margin-left:0px;" data-type="give_buy"><?php echo app('translator')->get('messages.issue_pt_desc2'); ?></button>
			<hr>
			<button type="button" class="btn green-seagreen btn-block btn_point" style="margin-left:0px;" data-type="cost_free"><?php echo app('translator')->get('messages.issue_pt_desc3'); ?></button>
			<button type="button" class="btn blue-steel btn-block btn_point" style="margin-left:0px;" data-type="cost_buy"><?php echo app('translator')->get('messages.issue_pt_desc4'); ?></button>
		</div>
		<div class="col-md-9">
					<!-- BEGIN EXAMPLE TABLE PORTLET-->
					<div class="portlet light bordered">
						<div class="portlet-title">
							<div class="caption">
								<i class="fa fa-gift"></i><?php echo app('translator')->get('messages.pt_record'); ?>
							</div>
							<ul class="nav nav-tabs">
								<li class="active">
									<a href="#tab_1" data-toggle="tab">
									<?php echo app('translator')->get('messages.given_pt'); ?> </a>
								</li>
								<li>
									<a href="#tab_2" data-toggle="tab">
									<?php echo app('translator')->get('messages.buy_pt'); ?> </a>
								</li>
							</ul>
						</div>
						<div class="portlet-body">
							<div class="tab-content">
								<div class="tab-pane active" id="tab_1">
									<table class="table table-striped table-bordered table-hover datatable">
									<thead>
									<tr>
										<th>
											 <?php echo app('translator')->get('messages.time'); ?>
										</th>
										<th>
											 <?php echo app('translator')->get('messages.type'); ?>
										</th>
										<th>
											 <?php echo app('translator')->get('messages.income'); ?>
										</th>
										<th>
											 <?php echo app('translator')->get('messages.outcome'); ?>
										</th>
										<th>
											 <?php echo app('translator')->get('messages.left_money'); ?>
										</th>
										<th>
											 <?php echo app('translator')->get('messages.note'); ?>
										</th>
									</tr>
									</thead>
									<tbody>
									<?php foreach($free_list as $one): ?>
									<tr class="odd gradeX">
										<td>
											<?php echo e($one['created_at']); ?>

										</td>
										<?php if($one['type'] == 'income'): ?>
										<td>
											<span class="label label-primary"><?php echo app('translator')->get('messages.income'); ?></span>
										</td>
										<td>
											<?php echo e($one['point']); ?>

										</td>
										<td>
											
										</td>
										<?php else: ?>
										<td>
											<span class="label label-info"><?php echo app('translator')->get('messages.outcome'); ?></span>
										</td>
										<td>
											
										</td>
										<td>
											<?php echo e($one['point']); ?>

										</td>
										<?php endif; ?>
										<td>
											<?php echo e($one['left_point']); ?>

										</td>
										<td>
											<?php echo $one['memo']; ?>

										</td>
									</tr>
									<?php endforeach; ?>
									</tbody>
									</table>
								</div>
								<div class="tab-pane" id="tab_2">
									<table class="table table-striped table-bordered table-hover datatable">
									<thead>
									<tr>
										<th>
											 <?php echo app('translator')->get('messages.time'); ?>
										</th>
										<th>
											 <?php echo app('translator')->get('messages.type'); ?>
										</th>
										<th>
											 <?php echo app('translator')->get('messages.income'); ?>
										</th>
										<th>
											 <?php echo app('translator')->get('messages.outcome'); ?>
										</th>
										<th>
											 <?php echo app('translator')->get('messages.left_money'); ?>
										</th>
										<th>
											 <?php echo app('translator')->get('messages.note'); ?>
										</th>
									</tr>
									</thead>
									<tbody>
									<?php foreach($buy_list as $one): ?>
									<tr class="odd gradeX">
										<td>
											<?php echo e($one['created_at']); ?>

										</td>
										<?php if($one['type'] == 'income'): ?>
										<td>
											<span class="label label-primary"><?php echo app('translator')->get('messages.income'); ?></span>
										</td>
										<td>
											<?php echo e($one['point']); ?>

										</td>
										<td>
											
										</td>
										<?php else: ?>
										<td>
											<span class="label label-info"><?php echo app('translator')->get('messages.outcome'); ?></span>
										</td>
										<td>
											
										</td>
										<td>
											<?php echo e($one['point']); ?>

										</td>
										<?php endif; ?>
										<td>
											<?php echo e($one['left_point']); ?>

										</td>
										<td>
											<?php echo $one['memo']; ?>

										</td>
									</tr>
									<?php endforeach; ?>
									</tbody>
									</table>
								</div>
							</div>
							
						</div>
					</div>
					<!-- END EXAMPLE TABLE PORTLET-->
				</div>
				<input type="hidden" id="point_user_id" name="user_id" value="<?php echo e($user->id); ?>"/>
	</div>
	<div class="modal-footer">
		<button type="button" class="btn default" data-dismiss="modal"><?php echo app('translator')->get('messages.close'); ?></button>
	</div>
</div>

<script type="text/javascript">
$(document).ready(function(){
	$('.datatable').dataTable({
		// Internationalisation. For more info refer to http://datatables.net/manual/i18n
		"language": {
		    "aria": {
		        "sortAscending": ": activate to sort column ascending",
		        "sortDescending": ": activate to sort column descending"
		    },
		    "emptyTable": "<?php echo app('translator')->get('messages.datatable_no_data'); ?>",
		    "info": "<?php echo app('translator')->get('messages.display_from'); ?> _START_ <?php echo app('translator')->get('messages.display_to'); ?> _END_ <?php echo app('translator')->get('messages.then_total'); ?> _TOTAL_ <?php echo app('translator')->get('messages.records'); ?>",
		    "infoEmpty": "<?php echo app('translator')->get('messages.no_match'); ?>",
		    "infoFiltered": "(<?php echo app('translator')->get('messages.from'); ?> _MAX_ <?php echo app('translator')->get('messages.records_filter'); ?>)",
		    "lengthMenu": "<?php echo app('translator')->get('messages.show'); ?> _MENU_ <?php echo app('translator')->get('messages.records'); ?>",
		    "search": "<?php echo app('translator')->get('messages.quick_filter'); ?>:",
		    "zeroRecords": "<?php echo app('translator')->get('messages.no_data'); ?>",
		    "paginate": {
		        "previous":"<?php echo app('translator')->get('messages.last_page'); ?>",
		        "next": "<?php echo app('translator')->get('messages.next_page'); ?>",
		        "last": "<?php echo app('translator')->get('messages.lastest'); ?>",
		        "first": "<?php echo app('translator')->get('messages.most_previous'); ?>"
		    }
		},
		"lengthMenu": [
		    [10, 20, 50, -1],
		    [10, 20, 50, "All"] // change per page values here
		],
		// set the initial value
		"pageLength": 10,            
		"pagingType": "bootstrap_full_number",
        "order": [
            [0, "desc"]
        ] // set first column as a default sort by asc
	});
});

$(document).on('click','.btn_point',function(){
	$.ajax({
		type : 'GET',
		url  : '<?php echo e(action("ConsoleController@point_view_edit")); ?>',
		data : {
			type : $(this).data('type'),
			id : $('#point_user_id').val()
		},
		success : function(sendback){
			$('#modal_function_point_view_edit_content').html(sendback);
			$('#modal_function_point_view_edit').modal('show');		
		},
		error : function(sendback){
			toastr['error'](sendback.title);
		}
	});
});

$(document).on('click','#view_back_to_point',function(){
	$.ajax({
		type:'GET',
		url:'<?php echo e(route("console::function")); ?>',
		data:{
			function : 'point',
			card_no  : 'nodata',
			type     : 'card'
		},
		success:function(sendback){
			$(document).off('click','#btn_setting');
			$(document).off('click','#btn_point_view');
			$(document).off('click','#btn_allgive_list');
			$(document).off('click','#btn_allgive');
			$('.modal_function_point_view').modal('hide');
			$('#modal_function_point_content').html(sendback);
			$('#modal_function_point').modal('show');		
		},
		error:function(sendback){
			toastr['error']('<?php echo app('translator')->get('messages.error_contact_developer'); ?>');
		}
	});
});
</script>