<?php $__env->startSection('css_page_level'); ?>
<link href="<?php echo e(asset('assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.css')); ?>" rel="stylesheet" type="text/css"/>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page-content-wrapper'); ?>
	<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">
			<!-- BEGIN PAGE HEADER-->
			<h3 class="page-title">
			<?php $setting = app('anlutro\LaravelSettings\Facade'); ?>
			<?php echo e($setting::get('system_name','全方位建築智慧化管理系統')); ?> <small><?php echo e($setting::get('company_name','新保科技')); ?></small>
			</h3>
			<div class="page-bar">
				<ul class="page-breadcrumb">
					<li>
						<i class="fa fa-home"></i>
						<a href="index.html"><?php echo app('translator')->get('messages.homepage'); ?></a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="#"><?php echo app('translator')->get('messages.members_manage'); ?></a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="#"><?php echo app('translator')->get('messages.batch_import'); ?></a>
					</li>
				</ul>
				<div class="page-toolbar">

				</div>
			</div>
			<!-- END PAGE HEADER-->
			<!-- BEGIN PAGE CONTENT-->
			<div class="row">
				<div class="col-md-12">
					<!-- Begin: life time stats -->
					<div class="portlet light bordered">
						<div class="portlet-title tabbable-line">
							<div class="caption">
								<i class="fa fa-home"></i><?php echo app('translator')->get('messages.batch_import'); ?>
							</div>
							<ul class="nav nav-tabs">
								<li class="active">
									<a href="#tab_0" data-toggle="tab">
									<?php echo app('translator')->get('messages.batch_import_record'); ?> </a>
								</li>
								<li>
									<a href="#tab_1" data-toggle="tab">
									<?php echo app('translator')->get('messages.batch_importing'); ?> </a>
								</li>
							</ul>
						</div>
						<div class="portlet-body">
							<div class="tabbable">
								<div class="tab-content">
									<div class="tab-pane active" id="tab_0">
										<div class="row">
											<div class="col-md-12">
												<div class="tabbable">
													<table class="table table-striped table-bordered table-advance table-hover">
													<thead>
													<tr>
														<th>
															<i class="fa fa-calendar-o"></i> <?php echo app('translator')->get('messages.time'); ?>
														</th>
														<th class="hidden-xs">
															<i class="fa fa-text"></i> <?php echo app('translator')->get('messages.mark'); ?>
														</th>
														<th>
															<?php echo app('translator')->get('messages.success_import_item'); ?>
														</th>
														<th>
															<?php echo app('translator')->get('messages.fail_import_item'); ?>
														</th>
														<th>
														</th>
													</tr>
													</thead>
													<tbody>
													<?php foreach($imports as $import): ?>
													<tr>
														<td>
															<?php echo e($import->created_at); ?>

														</td>
														<td class="hidden-xs">
															<?php echo e($import->title); ?>

														</td>
														<td>
															<?php echo e($import->import_success); ?>

														</td>
														<td>
															<?php echo e($import->import_failed); ?>

														</td>
														<td>
															<div class="btn-group">
																<button class="btn btn-default btn-xs dropdown-toggle" type="button" data-toggle="dropdown">
																<?php echo app('translator')->get('messages.action'); ?> <i class="fa fa-angle-down"></i>
																</button>
																<ul class="dropdown-menu pull-right" role="menu">
																	<li>
																		<a href="<?php echo e(action('Manage\UserController@printPwd',['id'=>$import->id])); ?>">
																		<i class="fa fa-print"></i>
																		<?php echo app('translator')->get('messages.print_pwd'); ?></a>
																	</li>
																	<li>
																		<a href="<?php echo e(action('Manage\UserController@downloadExcel',['id'=>$import->id])); ?>">
																		<i class="fa fa-file"></i>
																		<?php echo app('translator')->get('messages.down_this_xls'); ?></a>
																	</li>
																	<li class="divider">
																	</li>
																	<li>
																		<a class="btn_destroy_import" url="<?php echo e(action('Manage\UserController@destroyImport',['id'=>$import->id])); ?>">
																		<i class="fa fa-trash-o"></i>
																		<?php echo app('translator')->get('messages.del_all_this_import'); ?> </a>
																	</li>
																</ul>
															</div>
														</td>
													</tr>
													<?php endforeach; ?>
													</tbody>
													</table>
												</div>
											</div>
										</div>
									</div>
									<div class="tab-pane" id="tab_1">
										<div class="row">
											<div class="col-md-12">
												<h4><?php echo app('translator')->get('messages.batch_importing'); ?></h4>
												<form id="form_import" action="<?php echo e(route('manage::user::import')); ?>" method="POST" enctype="multipart/form-data">
												<input type="hidden" id="_token" name="_token" value="<?php echo e(csrf_token()); ?>">
												<div class="portlet light">
													<div class="portlet-title">
														<div class="caption">
															<i class="icon-bar-chart font-green-sharp hide"></i>
															<span class="caption-subject font-green-sharp bold uppercase">Step 1. <?php echo app('translator')->get('messages.first_down_xls'); ?></span>
														</div>
													</div>
													<div class="portlet-body">
														<p><?php echo app('translator')->get('messages.batch_import_xls'); ?></p>
														<p><?php echo app('translator')->get('messages.remind_rule'); ?>:</p>
														<ul>
															<li><?php echo app('translator')->get('messages.dont_double_account'); ?></li>
															<li><?php echo app('translator')->get('messages.unlimit_file_name'); ?></li>
															<li><?php echo app('translator')->get('messages.type_shouldb_xls'); ?></li>
															<li><?php echo app('translator')->get('messages.card_num_setting_usebla'); ?></li>
															<li><?php echo app('translator')->get('messages.import_shouldb_value'); ?></li>
															<li><?php echo app('translator')->get('messages.setting_pwd_logoimg_2where'); ?></li>
														</ul>
														<p><a class="btn blue btn-block" href="<?php echo e(url('import/sample.xls')); ?>"><?php echo app('translator')->get('messages.download_sample'); ?> sample.xls</a></p>
													</div>
												</div>
												<div class="portlet light">
													<div class="portlet-title">
														<div class="caption">
															<i class="icon-bar-chart font-green-sharp hide"></i>
															<span class="caption-subject font-green-sharp bold uppercase">Step 2. <?php echo app('translator')->get('messages.upload_en_build'); ?></span>
														</div>
													</div>
													<div class="portlet-body">
														<p><?php echo app('translator')->get('messages.upload_xls_here'); ?></p>
														<div class="fileinput fileinput-new" data-provides="fileinput">
															<div class="input-group input-large">
																<div class="form-control uneditable-input input-fixed input-medium" data-trigger="fileinput">
																	<i class="fa fa-file fileinput-exists"></i>&nbsp; <span class="fileinput-filename">
																	</span>
																</div>
																<span class="input-group-addon btn default btn-file">
																<span class="fileinput-new">
																<?php echo app('translator')->get('messages.select_file'); ?> </span>
																<span class="fileinput-exists">
																<?php echo app('translator')->get('messages.change'); ?> </span>
																<input type="file" name="import_file">
																</span>
																<a href="javascript:;" class="input-group-addon btn red fileinput-exists" data-dismiss="fileinput">
																<?php echo app('translator')->get('messages.remove'); ?> </a>
															</div>
														</div>
													</div>
												</div>
												<div class="portlet light">
													<div class="portlet-title">
														<div class="caption">
															<i class="icon-bar-chart font-green-sharp hide"></i>
															<span class="caption-subject font-green-sharp bold uppercase">Step 3. <?php echo app('translator')->get('messages.batch_setting'); ?></span>
														</div>
													</div>
													<div class="portlet-body">
														<p><?php echo app('translator')->get('messages.mark4_this_batch'); ?></p>
														<form action="#" class="form-horizontal">
															<div class="form-body">
																<div class="form-group">
																	<label class="col-md-3 control-label"><?php echo app('translator')->get('messages.this_batch_name'); ?></label>
																	<div class="col-md-9">
																		<input name="title" type="text" class="form-control input-circle" placeholder="20150901 <?php echo app('translator')->get('messages.found_file'); ?>">
																		<span class="help-block">
																		<?php echo app('translator')->get('messages.plz_mark_when_upload'); ?></span>
																	</div>
																</div>
															</div>
															<div class="form-actions">
																<div class="row">
																	<div class="col-md-offset-3 col-md-9">
																		<button type="submit" class="btn btn-circle blue"><?php echo app('translator')->get('messages.submit'); ?></button>
																		<button type="button" class="btn btn-circle default"><?php echo app('translator')->get('messages.reset'); ?></button>
																	</div>
																</div>
															</div>
														</form>
													</div>
												</div>
												<div class="clearfix"></div>
												</form>
												
												<?php if(Sentinel::check()->username === 'door'): ?>	
												<form id="form_import" action="<?php echo e(route('manage::user::excel_import')); ?>" method="POST" enctype="multipart/form-data">
												<input type="hidden" id="_token" name="_token" value="<?php echo e(csrf_token()); ?>">
													<div class="portlet-title">
															<div class="caption">
																<i class="icon-bar-chart font-green-sharp hide"></i>
																<span class="caption-subject font-green-sharp bold uppercase">門牌對應</span>
															</div>
													</div>
													<p>請先下載舊版帳號對應新版門牌之EXCEL檔</p>
													<p><a class="btn blue btn-block" target="_blank" href="<?php echo e(action('Manage\UserController@username_doorplates')); ?>">下載舊版帳號對應新版門牌 username_doorplates_sample.xls</a></p>
													<p></p>
													<p>請將舊版帳號對應新版門牌Excel檔於此處上傳。</p>
													<div class="fileinput fileinput-new" data-provides="fileinput">
														<div class="input-group input-large">
															<div class="form-control uneditable-input input-fixed input-medium" data-trigger="fileinput">
																<i class="fa fa-file fileinput-exists"></i>&nbsp; <span class="fileinput-filename">
																</span>
															</div>
															<span class="input-group-addon btn default btn-file">
															<span class="fileinput-new">選擇檔案</span>
															<span class="fileinput-exists">更換</span>
															<input type="file" name="import_file">
															</span>
															<a href="javascript:;" class="input-group-addon btn red fileinput-exists" data-dismiss="fileinput">移除</a>
														</div>
													</div>
													<div class="form-actions">
															<div class="row">
																<div class="col-md-offset-3 col-md-9">
																	<button type="submit" class="btn btn-circle blue">對應門牌</button>
																</div>
															</div>
													</div>
												</form>
												<?php endif; ?>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<!-- End: life time stats -->
				</div>
			</div>

			<div class="row">
				<div class="col-md-6">
					
				</div>
			</div>
			<!-- END PAGE CONTENT-->
		</div>
	</div>
	<!-- END CONTENT -->
	<input type="hidden" id="_token" name="_token" value="<?php echo e(csrf_token()); ?>">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('plugins_page_level'); ?>
<script type="text/javascript" src="../../assets/global/plugins/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/jquery-validation/js/jquery.validate.min.js')); ?>"></script>
<script src="<?php echo e(asset('assets/global/plugins/jquery.pulsate.min.js')); ?>" type="text/javascript"></script>
<script src="<?php echo e(asset('assets/global/plugins/bootstrap-daterangepicker/moment.min.js')); ?>" type="text/javascript"></script>
<script src="<?php echo e(asset('assets/global/plugins/bootstrap-daterangepicker/daterangepicker.js')); ?>" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/datatables/media/js/jquery.dataTables.min.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js')); ?>"></script>
<script src="<?php echo e(asset('assets/global/plugins/bootstrap-confirmation/bootstrap-confirmation.min.js')); ?>" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/bootbox/bootbox.min.js')); ?>"></script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js_page_level'); ?>
<script type="text/javascript">
$(document).ready(function(){
	$('#form_import').validate({
		errorElement: 'span', //default input error message container
        errorClass: 'help-block help-block-error', // default input error message class
        focusInvalid: false, // do not focus the last invalid input
        ignore: "",  // validate all fields including form hidden input
		rules:{
			import_file:{
				required:true,
			},
			title:{
				required: true,
				minlength: 4,
				maxlength: 25,
			}
		},
		messages:{
			import_file:{
				required:'<?php echo app('translator')->get('messages.least_upload_1xls'); ?>'
			},
			title:{
				required: '<?php echo app('translator')->get('messages.enter_batch_name'); ?>',
				minlength: '<?php echo app('translator')->get('messages.batch_name_min4'); ?>',
				maxlength: '<?php echo app('translator')->get('messages.batch_name_max25'); ?>'
			}
		},

        invalidHandler: function (event, validator) { //display error alert on form submit   

        },

        highlight: function (element) { // hightlight error inputs
           $(element)
                .closest('.form-group').addClass('has-error'); // set error class to the control group
        },

        unhighlight: function (element) { // revert the change done by hightlight
            $(element)
                .closest('.form-group').removeClass('has-error'); // set error class to the control group
        },

        success: function (label) {
            label
                .closest('.form-group').removeClass('has-error'); // set success class to the control group
        },

        submitHandler: function (form) {
        	form[0].submit();
        }
	});
});

$(document).on('click','.btn_destroy_import',function(){
	var url = $(this).attr('url');
	bootbox.confirm("<h3 style='font-weight:bold;'><i class='fa fa-exclamation-triangle font-red-mint'></i> <?php echo app('translator')->get('messages.sure_del_batch_import'); ?></h3><br><div class='alert alert-danger'><strong><?php echo app('translator')->get('messages.warning'); ?>!</strong> <?php echo app('translator')->get('messages.cant_back_first'); ?> </div>", function(result) {
		if(result == true){
			$.ajax({
				type  : 'DELETE',
				url   : url,
				dataType:'json',
				data  : {
					_token   : '<?php echo e(csrf_token()); ?>',
				},
				success : function(sendback){
					toastr['success']('<?php echo app('translator')->get('messages.del_success'); ?>');
					window.location.reload();
				},
				error : function(sendback){
					toastr['error']('<?php echo app('translator')->get('messages.del_failll'); ?>');
				}
			});	
		}
	}); 
});
</script>


<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout.manage', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>