@extends('admin.master')

@section('top')
	<div class="top-breadcrumb">
		<h5>招聘分类管理</h5>
    <a class="btn btn-xs btn-default goback" onclick="javascript:history.go(-1);">
      <i class="iconfont icon-back-copy"></i><span>返回</span>
    </a>
	</div>
@endsection


@section('ordersearch')
<div class="order-search mb-10">
	@if(config('managerLang') == config('setting.lang'))
	<div class="top-btn-group">
		<a href="{{ url('admin/job-cate/create') }}" class="btn btn-primary">
			<i class="iconfont icon-plus"></i><span>添加</span>
		</a>
	</div>
	@endif
</div>
@endsection

@section('content')
<div class="form-ajax">
<table class="table table-hover">
	<thead>
		<tr>
			<th width="60" class="text-center">
				<div class="pretty p-default p-smooth">
					<input name="chkAll" type="checkbox" id="chkAll" onclick="checkAll(this, 'id[]')" value="checkbox">
					<div class="state p-success"><label></label></div>
				</div>
			</th>
			<th>分类名称</th>
			<th>排序</th>
			<th>招聘数</th>
			<th width="100">状态</th>
			<th>添加时间</th>
			<th class="text-center">操作</th>
		</tr>
	</thead>
	<tbody>
	@if(!$jobcates->isEmpty())
		@each('admin.common.job_cate_each', $jobcates, 'value')
		<tr>
			<td align="center">
				<div class="pretty p-default p-smooth">
					<input name="chkAll" type="checkbox" id="chkAll" onclick="checkAll(this, 'id[]')" value="checkbox">
					<div class="state p-success"><label></label></div>
				</div>
			</td>
			<td class="text-left" colspan="8">
				<div class="foot-wrap">
					<div class="pull-left">
						@if(config('managerLang') == config('setting.lang'))
						@include('admin.common.translate_models', ['translateModel' => 'jobCate', 'translateModelName' => '招聘分类'])
						@endif
						<input name="btn_del" type="button" value="删 除" class="btn btn-default delet-select">
					</div>
				</div>
			</td>
		</tr>
	@endif
	</tbody>
</table>
@if($jobcates->isEmpty())
	<div class="nodata-wrap">
		<div class="notice-null"><span class="inline-block">暂无数据</span></div>
	</div>
@endif
</div>
@endsection

@section('notice')
<!-- Modal -->
<div class="modal fade" id="dialog" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="true"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">提示</h4>
        </div>
        <div class="modal-body clearfix">
            <div class='col-sm-1 text-center'><i class='iconfont icon-zhuyi'></i></div>
            <div class='col-sm-11 breakall'><p>删除后您将无法恢复，请谨慎操作</p><p class='text-muted'>您确认要删除吗？</p></div>
        </div>
        <div class="modal-footer">
        	<button type="button" class="btn btn-primary btn-modal-ok">确定</button>
        	<button class="btn btn-default btn-modal-cancel btn-modal-close" data-dismiss="modal">取消</button>
        </div>
    </div>
  </div>
</div>
<!-- Modal End -->
<!-- Modal -->
<div class="modal fade" id="dialog-tip" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="true"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">提示</h4>
        </div>
        <div class="modal-body clearfix">
			<div class='col-sm-1 text-center'><i class='fa fa-times-circle text-size-32 text-yellow'></i></div>
			<div class='col-sm-11 breakall'><p class="delete-error">删除失败！</p></div>
		</div>	
        <div class="modal-footer">
			<button class="btn btn-primary btn-modal-close" data-dismiss="modal">确定</button>
        </div>
    </div>
  </div>
</div>
<!-- Modal End -->
<!-- Modal -->
<div class="modal fade" id="dialog-common" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="true"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">提示</h4>
        </div>
        <div class="modal-body clearfix">
            <div class='col-sm-1 text-center'><i class='iconfont icon-zhuyi'></i></div>
            <div class='col-sm-11 breakall'><p class="common">请选择要删除的内容!</p></div>
        </div>
        <div class="modal-footer">
        	<button type="button" class="btn btn-primary btn-modal-common">确定</button>
        </div>
    </div>
  </div>
</div>
<!-- Modal End -->
@endsection

@section('foot')
<script type="text/javascript">
// 删除
$('.delete-item').on('click', function(e) {
	var deleteAction = location.pathname;
	var id = $(this).data('id');
	url = deleteAction + '/' + id;

	$('#dialog').modal('show');
	return false;		
});

//批量删除
$('.delet-select').on('click', function(){	
	var ids = [];
	$('.id:checked').each(function(){
		ids.push(this.value);
	});
	ids = ids.join('-');

	if (!ids) {
		$('.common').text('请选择要删除的内容!');
		$('#dialog-common').modal('show');
		return false;
	}
	url = location.pathname + '/' + ids;

	$('#dialog').modal('show');
	return false;	
});

$('body').on('click', '.btn-modal-common', function(){
	$(this).parents('#dialog-common').modal('hide');
});

$('body').on('click', '.btn-modal-ok', function() {
	$(this).parents('#dialog').modal('hide');
	$.ajax({
		type: "DELETE",
		url: url,
		success: function(data) {
			if (data.status == 'sucess') {
				swal({
					title: "", 
					text: "信息删除成功！",
					type: "success",
					showConfirmButton: false,
					timer: 1200,
				});
				setTimeout("location.reload()", 1200);
			} else {
				$('.delete-error').html(data.message);
				$('#dialog-tip').modal('show');
			}
		}
	});
});
</script>
@endsection