<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">
		<button id="back_to_point" class="btn blue" style="margin-bottom:10px;">回上一頁 (點數管理)</button>
		<table class="table table-striped table-bordered table-hover" id="table_point_list">
			<thead>
				<tr>
					<th>
						<?php echo app('translator')->get('messages.time'); ?>
					</th>
					<th>
						<?php echo app('translator')->get('messages.title'); ?>
					</th>
					<th>
						<?php echo app('translator')->get('messages.total_people'); ?>
					</th>
					<th>
						<?php echo app('translator')->get('messages.total_points'); ?>
					</th>
					<th>
						<?php echo app('translator')->get('messages.action'); ?>
					</th>
				</tr>
			</thead>
			<tbody>
				<?php foreach($allgives as $allgive ): ?>
					<tr>
						<td>
							<?php echo e($allgive->created_at); ?>

						</td>
						<td>
							<?php echo e($allgive->title); ?>

						</td>
						<td>
							<?php echo e($allgive->count_people); ?>

						</td>
						<td>
							<?php echo e($allgive->count_point); ?>

						</td>
						<td>
							<?php if($allgive->status == 1): ?>
								<button class="btn blue btn-xs btn_allgive_view" uid="<?php echo e($allgive->id); ?>" href="">查看LOG<i class="fa fa-eye"></i></button>
								<a class="btn red btn-xs btn_allgive_delete" uid="<?php echo e($allgive->id); ?>"><?php echo app('translator')->get('messages.del_all_pt'); ?><i class="fa fa-remove"></i></a>
							<?php else: ?>
								<button class="btn blue btn-xs btn_allgive_view" uid="<?php echo e($allgive->id); ?>" href="">查看LOG<i class="fa fa-eye"></i></button>
							<?php endif; ?>	
						</td>
					</tr>
				<?php endforeach; ?>
			</tbody>
		</table>
	</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(){
		$('#table_point_list').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"]
        	] 
		});
	});

$(document).on('click','.btn_allgive_view',function(){
	$.ajax({
		type : 'GET',
		url : '<?php echo e(action('ConsoleController@point_list_view')); ?>',
		data : {
			id : $(this).attr('uid'),
			_token:'<?php echo e(csrf_token()); ?>'
		},
		success : function(sendback){
			$('#modal_function_point_list_view_content').html(sendback);
			$('#modal_function_point_list_view').modal('show');
			$('#modal_function_point_list').modal('hide');
		},
		error : function(sendback){
		}
	});
});

$(document).on('click','.btn_allgive_delete',function(){
	$.ajax({
		type  : 'POST',
		url   : '<?php echo e(action('PointController@alldelete')); ?>',
		dataType : 'json',
		data  : {
			id : $(this).attr('uid'),
			_token:'<?php echo e(csrf_token()); ?>'
		},
		success : function(sendback){
			$.ajax({
				type : 'GET',
				url  : '<?php echo e(action("PointController@allgiveList")); ?>',
				dataType : 'json',
				success : function(sendback){
					toastr['success']('<?php echo app('translator')->get('messages.del_all_issue_pt_success'); ?>');
					window.location.reload();
				},
				error : function(sendback){
					toastr['error']('<?php echo app('translator')->get('messages.error'); ?>');
				}

			});
		},
		error : function(sendback){

		}
	});
});

$(document).on('click','#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_content').html(sendback);
			$('#modal_function_point').modal('show');
			$('#modal_function_point_list').modal('hide');
		},
		error:function(sendback){
			toastr['error']('<?php echo app('translator')->get('messages.error_contact_developer'); ?>');
		}
	});
});
</script>