<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8"/>
<?php $setting = app('anlutro\LaravelSettings\Facade'); ?>
<title>登入頁面 - <?php echo e($setting::get('company_name','新保科技')); ?> <?php echo app('translator')->get('messages.community_manage'); ?>系統</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta content="" name="description"/>
<meta content="" name="author"/>
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css"/>
<link href="<?php echo e(asset('assets/global/plugins/font-awesome/css/font-awesome.min.css')); ?>" rel="stylesheet" type="text/css"/>
<link href="<?php echo e(asset('assets/global/plugins/simple-line-icons/simple-line-icons.min.css')); ?>" rel="stylesheet" type="text/css"/>
<link href="<?php echo e(asset('assets/global/plugins/bootstrap/css/bootstrap.min.css')); ?>" rel="stylesheet" type="text/css"/>
<link href="<?php echo e(asset('assets/global/plugins/uniform/css/uniform.default.css')); ?>" rel="stylesheet" type="text/css"/>
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL STYLES -->
<link href="<?php echo e(asset('assets/global/plugins/select2/css/select2.min.css')); ?>" rel="stylesheet" type="text/css"/>
<link href="<?php echo e(asset('assets/pages/css/login-4.css')); ?>" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/bootstrap-toastr/toastr.min.css')); ?>"/>
<!-- END PAGE LEVEL SCRIPTS -->
<!-- BEGIN THEME STYLES -->
<link href="<?php echo e(asset('assets/global/css/components-md.css')); ?>" id="style_components" rel="stylesheet" type="text/css"/>
<link href="<?php echo e(asset('assets/global/css/plugins-md.css')); ?>" rel="stylesheet" type="text/css"/>
<link href="<?php echo e(asset('assets/layouts/layout/css/layout.css')); ?>" rel="stylesheet" type="text/css"/>
<link id="style_color" href="<?php echo e(asset('assets/layouts/layout/css/themes/darkblue.css')); ?>" rel="stylesheet" type="text/css"/>
<link href="<?php echo e(asset('assets/layouts/layout/css/custom.css')); ?>" rel="stylesheet" type="text/css"/>
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico"/>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-md login">
<!-- BEGIN LOGO -->
<div class="logo" style="margin: 40px auto 20px auto;">
	<?php $setting = app('anlutro\LaravelSettings\Facade'); ?>
	<a href="javascript:;">
	<img src="<?php echo e($setting::get('logo_big', asset('assets/layouts/layout/img/logo-big.png'))); ?>" alt="" width="125px" height="21px"/>
	</a>
</div>
<!-- END LOGO -->
<!-- BEGIN SIDEBAR TOGGLER BUTTON -->
<div class="menu-toggler sidebar-toggler">
</div>
<!-- END SIDEBAR TOGGLER BUTTON -->
<!-- BEGIN LOGIN -->
<div class="content">
	<!-- BEGIN LOGIN FORM -->
	<form class="login-form" action="login" method="post">
		<?php if(isset($next_url)): ?>
		<input type="hidden" name="next_url" value="<?php echo e($next_url); ?>">
		<?php elseif(session('next_url')): ?>
		<input type="hidden" name="next_url" value="<?php echo e(session('next_url')); ?>">
		<?php else: ?>
		<input type="hidden" name="next_url" value="<?php echo e(old('next_url')); ?>">
		<?php endif; ?>
		<h3 class="form-title" style="text-align:center; font-size:18px;margin-top:10px;">歡迎回來</h3>
		<?php $CommunityPresenter = app('NSST\Presenters\CommunityPresenter'); ?>
		<h3 class="form-title" style="text-align:center;"><?php echo e($CommunityPresenter->comName()); ?></h3>
		<?php echo csrf_field(); ?>

		<div class="alert alert-danger display-hide">
			<button class="close" data-close="alert"></button>
			<span>
			請輸入使用者帳號及密碼 </span>
		</div>
		<?php if($errors->has('fail')): ?>
		<div class="alert alert-danger">
			<button class="close" data-close="alert"></button>
			<span>
			<?php echo e($errors->first('fail')); ?> </span>
		</div>
	    <?php endif; ?>
		<div class="form-group">
			<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
			<label class="control-label visible-ie8 visible-ie9"><?php echo app('translator')->get('messages.user_account'); ?></label>
			<div class="input-icon">
				<i class="fa fa-user"></i>
				<input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="<?php echo app('translator')->get('messages.user_account'); ?>" name="username" value="<?php echo e(old('username')); ?>"/>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label visible-ie8 visible-ie9"><?php echo app('translator')->get('messages.pwd'); ?></label>
			<div class="input-icon">
				<i class="fa fa-lock"></i>
				<input class="form-control placeholder-no-fix" type="password" autocomplete="off" placeholder="<?php echo app('translator')->get('messages.pwd'); ?>" name="password"/>
			</div>
		</div>
		<div class="form-actions">
			<label class="checkbox">
			<input type="checkbox" name="remember"/> 記住我 </label>
			<button type="submit" class="btn blue pull-right">
			<?php echo app('translator')->get('messages.loginnnn'); ?> <i class="m-icon-swapright m-icon-white"></i>
			</button>
		</div>
		<!-- <div class="forget-password">
			<h4>忘記你的密碼了 ?</h4>
			<p>
				別擔心，快點 <a href="javascript:;" id="forget-password">
				這裡 </a>
				來找回你的密碼
			</p>
		</div> -->
		<div class="create-account">
			<a href="javascript:;"  id="btn_usecard" class="btn btn-lg grey-cascade btn-block">使用感應卡登入<i class="fa fa-link"></i></a>
		</div>
	</form>
	<!-- END LOGIN FORM -->
	<!-- BEGIN FORGOT PASSWORD FORM -->
	<!-- <form class="forget-form" action="" method="POST">
		<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
		<h3>忘記你的密碼了嗎 ?</h3>
		<p>
			 請輸入你的Email來找回你的密碼吧。
		</p>
		<div class="form-group">
			<div class="input-icon">
				<i class="fa fa-envelope"></i>
				<input class="form-control placeholder-no-fix" type="email" autocomplete="off" placeholder="Email" name="email"/>
			</div>
		</div>
		<div class="form-actions">
			<button type="button" id="back-btn" class="btn">
			<i class="m-icon-swapleft"></i> 返回 </button>
			<button type="submit" class="btn blue pull-right">
			送出 <i class="m-icon-swapright m-icon-white"></i>
			</button>
		</div>
	</form> -->
	<!-- END FORGOT PASSWORD FORM -->
	<!-- BEGIN REGISTRATION FORM -->
	<form class="usecard-form" action="" method="post" style="display:none;">
		<h3>感應卡刷卡登入</h3>
		<p>
			 請感應您的卡片已進行登入驗證。
		</p>
		<div class="form-group">
			<label class="control-label visible-ie8 visible-ie9">Password</label>
			<div class="input-icon">
				<i class="fa fa-lock"></i>
				<input class="form-control placeholder-no-fix" type="password" autocomplete="off" id="register_password" placeholder="Password" name="password"/>
			</div>
		</div>
		<div class="form-actions">
			<button id="usecard-back-btn" type="button" class="btn">
			<i class="m-icon-swapleft"></i> 返回 </button>
			<button type="submit" id="register-submit-btn" class="btn blue pull-right">
			Sign Up <i class="m-icon-swapright m-icon-white"></i>
			</button>
		</div>
	</form>
	<!-- END REGISTRATION FORM -->
	<from id="usecard_login" action="" method="post" style="position:fixed;bottom:3000px;">
		<input type="password" name="card_no" id="card_no">
		<input type="text" id="_token" name="_token" value="<?php echo e(csrf_token()); ?>">
	</from>
</div>
<!-- END LOGIN -->
<!-- BEGIN COPYRIGHT -->
<div class="copyright">
	<?php echo e($setting::get('copyright_1','2015 © NSST 全方位建築智慧化管理系統')); ?>

</div>
<!-- END COPYRIGHT -->
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->
<!--[if lt IE 9]>
<script src="<?php echo e(asset('assets/global/plugins/respond.min.js')); ?>"></script>
<script src="<?php echo e(asset('assets/global/plugins/excanvas.min.js')); ?>"></script> 
<![endif]-->
<script src="<?php echo e(asset('assets/global/plugins/jquery.min.js')); ?>" type="text/javascript"></script>
<script src="<?php echo e(asset('assets/global/plugins/jquery-migrate.min.js')); ?>" type="text/javascript"></script>
<script src="<?php echo e(asset('assets/global/plugins/bootstrap/js/bootstrap.min.js')); ?>" type="text/javascript"></script>
<script src="<?php echo e(asset('assets/global/plugins/jquery.blockui.min.js')); ?>" type="text/javascript"></script>
<script src="<?php echo e(asset('assets/global/plugins/uniform/jquery.uniform.min.js')); ?>" type="text/javascript"></script>
<script src="<?php echo e(asset('assets/global/plugins/jquery.cokie.min.js')); ?>" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-validation/js/jquery.validate.min.js')); ?>" type="text/javascript"></script>
<script src="<?php echo e(asset('assets/global/plugins/backstretch/jquery.backstretch.min.js')); ?>" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/select2/js/select2.min.js')); ?>"></script>
<script src="<?php echo e(asset('assets/global/plugins/bootstrap-toastr/toastr.min.js')); ?>" type="text/javascript" ></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="<?php echo e(asset('assets/global/scripts/app.js')); ?>" type="text/javascript"></script>
<script src="<?php echo e(asset('assets/layouts/layout/scripts/layout.js')); ?>" type="text/javascript"></script>
<script src="<?php echo e(asset('assets/layouts/layout/scripts/demo.js')); ?>" type="text/javascript"></script>
<!-- END PAGE LEVEL SCRIPTS -->
<script>
jQuery(document).ready(function() {     
	Layout.init(); // init current layout

       // init background slide images
       $.backstretch([
        "<?php echo e(asset('assets/pages/media/bg/1.jpg')); ?>",
        "<?php echo e(asset('assets/pages/media/bg/2.jpg')); ?>",
        "<?php echo e(asset('assets/pages/media/bg/3.jpg')); ?>",
        "<?php echo e(asset('assets/pages/media/bg/4.jpg')); ?>"
        ], {
          fade: 1000,
          duration: 8000
    }
    );
});


$(document).ready(function(){
	//forget-form btn action
	jQuery('#forget-password').click(function () {
        jQuery('.login-form').hide();
        jQuery('.forget-form').show();
    });

    jQuery('#back-btn').click(function () {
        jQuery('.login-form').show();
        jQuery('.forget-form').hide();
    });

	// jQuery('#usecard-btn').click(function () {
	// 	jQuery('.login-form').hide();
	// 	jQuery('.usecard-form').show();
	// });

	// jQuery('#usecard-back-btn').click(function () {
	// 	jQuery('.login-form').show();
	// 	jQuery('.usecard-form').hide();
	// });

	$('.login-form').validate({
        errorElement: 'span', //default input error message container
        errorClass: 'help-block', // default input error message class
        focusInvalid: false, // do not focus the last invalid input
        rules: {
            username: {
                required: true
            },
            password: {
                required: true
            },
            remember: {
                required: false
            }
        },

        messages: {
            username: {
                required: "請輸入使用者帳號"
            },
            password: {
                required: "請輸入密碼"
            }
        },

        invalidHandler: function (event, validator) { //display error alert on form submit   
            $('.alert-danger', $('.login-form')).show();
        },

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

        success: function (label) {
            label.closest('.form-group').removeClass('has-error');
            label.remove();
        },

        errorPlacement: function (error, element) {
            error.insertAfter(element.closest('.input-icon'));
        },

        submitHandler: function (form) {
            form.submit();
        }
    });

    $('.login-form input').keypress(function (e) {
        if (e.which == 13) {
            if ($('.login-form').validate().form()) {
                $('.login-form').submit();
            }
            return false;
        }
    });

    $('#card_no').focus();
    $('#card_no').focusout(function(){
        $('#card_no').val('');
    });  

});

$(document).on('click','#btn_usecard',function(){
    $('#card_no').focus();
});

$('#card_no').keypress(function(e) {
    if ( e.keyCode == 13 && this.value ) {
        $.ajax({
        	type:'POST',
        	url:'<?php echo e(action('LoginController@useCardLogin')); ?>',
        	dataType:'',
        	data:{
        		card_no : $('#card_no').val(),
        		_token : $('#_token').val()
        	},
        	success : function(sendback){
        		toastr['success']('驗證成功');
        		window.location.reload();
        	},
        	error : function(sendback){
        		toastr['error']('很抱歉，此卡號不存在。');
        	}
        });
        $('#card_no').val('');
        $('#card_no').focus();
    }
 });
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>