@extends('base.layout')

@section('content')
<div class="wrapper">
	<div class="container-fluid">
		<div class="row">
			<div class="col-md-12">
				<div class="card-box ribbon-box" id="divawal">
					<div class="ribbon ribbon-primary">Welcome</div>
					<p class="m-b-0"></p>
					<div class="form-group">
                        <label for="noregister" class="text-primary">No. Rekam Medik</label>
                        <input type="text" class="form-control" id="noregister" name="noregister" placeholder="Silahkan diisi kalau ada">
                    </div>
                    <div class="form-group">
                        <div class="input-group clockpicker" data-placement="top" data-align="top" data-autoclose="true">
                            <input type="text" class="form-control" id="tgllahir" placeholder="YYYY-MM-DD">
                            <div class="input-group-append">
                                <span class="input-group-text"><i class="mdi mdi-clock"></i></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <button type="button" class="btn btn-success waves-effect waves-light pull-right" id="btnbbukaportal">Open</button>
                    </div>
                    <div class="row m-t-50">
                        <div class="col-sm-12 text-center">
                            <p class="text-muted">Admin Page <a href="#" id="btnopenloginpage" class="text-dark m-l-5"><b>Sign In</b></a></p>
                        </div>
                    </div>
					<div class="row m-t-50">
                        <div class="col-sm-2 text-center">
                            <img src="data:image/png;base64, {!! $qrcode !!}" alt="QR Code" width="100%">
                        </div>
						<div class="col-sm-10 text-center">
                            <h1>Laman ini bisa diakses dengan menggunakan QR Code</h1>
							<h1>Silahkan scan QR Code disamping untuk mengakses laman ini</h1>
                        </div>
                    </div>
				</div>
                <div class="card-box ribbon-box" id="divhasil">
					<div class="ribbon ribbon-info">Hasil Pemeriksaan</div>
					<p class="m-b-0"></p>
					<div id="hasilpencarian"></div>
				</div>
                <div class="card-box ribbon-box" id="divlogin">
					<div class="ribbon ribbon-danger">Input Credential</div>
					<p class="m-b-0"></p>
					<h2 class="text-uppercase text-center pb-4">
                        <a href="#" class="text-success">
                            <span><img src="{{ asset('radiologi.png') }}" alt="" width="100%"></span>
                        </a>
                    </h2>
                    @if(Session::has('message'))
                        <font color="red">{{ Session('message') }}</font>
                    @else
                        <marquee direction="left" scrollamount="3" align="center">Selamat Datang, Silahkan Login Untuk Melanjutkan</marquee>

                    @endif
                    <form action="{{ url('authenticate') }}" method="POST" class="login100-form validate-form">
                        {{ csrf_field() }}
                        <div class="form-group m-b-20 row">
                            <div class="col-12">
                                <label for="username">Username</label>
                                <input class="form-control" type="text" id="username" name="username" required="" placeholder="Enter your credential" autofocus>
                            </div>
                        </div>
                        <div class="form-group row m-b-20">
                            <div class="col-12">
                                <a href="#" class="text-muted pull-right"><small>Forgot your password?</small></a>
                                <label for="password">Password</label>
                                <input class="form-control" type="password" required="" name="password" id="password" placeholder="Enter your password">
                            </div>
                        </div>
                        <div class="form-group row m-b-20">
                            <div class="col-12">
                                <div class="checkbox checkbox-custom">
                                    <input id="remember" type="checkbox" checked="">
                                    <input type="hidden" name="firebaseid"  class="form-control" value="{{ $firebaseid }}"/>
                                    <label for="remember">
                                        Remember me
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group row text-center m-t-10">
                            <div class="col-12">
                                <button class="btn btn-block btn-custom waves-effect waves-light" type="submit">Sign In</button>
                            </div>
                        </div>
                    </form>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- TOKEN -->
<input type="hidden" name="_token" id="token" value="{{ csrf_token() }}">
@endsection

@push('script')
<script type="text/javascript">
    function btnisiRating(id_periksa, rating_value){
        var rating_container = $('.rating-stars[data-id="' + id_periksa + '"]');
        $.post('{{ route("exCekAksess") }}', { nofoto: 'isirating',id: id_periksa, rating: rating_value, _token: '{{ csrf_token() }}' }, function(data){
            rating_container.html('<small class="text-success">Terima kasih atas penilaian Anda!</small>');
            var stars_html = '';
            for (var i = 1; i <= 5; i++) {
                if (i <= rating_value) {
                    stars_html += '<i class="fa fa-star" style="font-size:18px; color:orange;"></i>';
                } else {
                    stars_html += '<i class="fa fa-star-o" style="font-size:18px; color:orange;"></i>';
                }
            }
            rating_container.html('<small class="text-muted">Rating Anda:</small><br>' + stars_html);
        }).fail(function() {
            swal({
                title	: 'Warning',
                text	: 'Gagal mengirim rating. Silakan coba lagi.',
                type	: 'error',
            });
        });
    }
	$(document).ready(function() {
        $("#tgllahir").datepicker({
			format: 'yyyy-mm-dd'
		});
        $('#btnbbukaportal').click(function () {
            var set01=document.getElementById('noregister').value;
            var set02=document.getElementById('tgllahir').value;
            if (set01 == '' || set02 == ''){
                swal({
                    title	: 'Warning',
                    text	: 'Nomor RM dan Tanggal Lahir wajib di Isi',
                    type	: 'error',
                });
            } else {
                var btn = $(this);
                    btn.addClass('fa fa-spinner fa-spin orange bigger-125').attr('disabled', true);
                $.post('{{ route("exCekAksess") }}', { nofoto: 'noregister', tgllahir: set02, noregister: set01,  _token: '{{ csrf_token() }}' },
                function(data){
                    $('#divlogin').hide();
                    $('#divhasil').show();
                    $('#divawal').hide();
                    $('#hasilpencarian').html(data);
                    btn.removeClass('fa fa-spinner fa-spin orange bigger-125').attr('disabled', false);
                });
            }
        });
        $("#btnopenloginpage").click(function() {
            $('#divlogin').show();
            $('#divhasil').hide();
            $('#divawal').hide();
		});
        $('#divlogin').hide();
        $('#divhasil').hide();
        $('#divawal').show();
    });
</script>
@endpush