<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<link rel="apple-touch-icon" sizes="76x76" href="{{asset('img/apple-icon.png')}}">
	<link rel="icon" type="image/png" sizes="96x96" href="{{asset('img/favicon.png')}}">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

	<title>SIPSB SMA N 2 Balige</title>

	<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
    <meta name="viewport" content="width=device-width" />


    <!-- Bootstrap core CSS     -->
    <link href="{{asset('css/bootstrap.min.css')}}" rel="stylesheet" />

    <!-- Animation library for notifications   -->
    <link href="{{asset('css/animate.min.css')}}" rel="stylesheet"/>

    <!--  Paper Dashboard core CSS    -->
    <link href="{{asset('css/paper-dashboard.css')}}" rel="stylesheet"/>

    <!--  CSS for Demo Purpose, don't include it in your project     -->
    <link href="{{asset('css/demo.css')}}" rel="stylesheet" />

    <!--  Fonts and icons     -->
    <link href="{{asset('fonts/glyphicons-halflings-regular')}}" rel="stylesheet">

    <link href='https://fonts.googleapis.com/css?family=Muli:400,300' rel='stylesheet' type='text/css'>
    
    <link href="{{asset('css/themify-icons.css')}}" rel="stylesheet">

    
</head>
<body>

<div class="wrapper">
@include('layouts.sidebar')
    <!--
		Tip 1: you can change the color of the sidebar's background using: data-background-color="white | black"
		Tip 2: you can change the color of the active button using the data-active-color="primary | info | success | warning | danger"
	-->

    <div class="main-panel" @if(!Auth::check()) style="width:100%;" @endif>
    @if(Auth::check())
    @include('layouts.header')
    @endif
        <div class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-12">
                        @if (session('info'))
                            <div class="alert alert-success alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close" style="padding-right:30px;"><span aria-hidden="true">&times;</span></button>
                                {{ session('info') }}
                            </div>
                        @endif
                    </div>
                </div><!--/.row-->
                <div class="row">
                    @yield('content')
                </div>
            </div>
        </div>

    @include('layouts.footer')


    </div>
</div>


</body>
    @section('js')
    <!--   Core JS Files   -->
    <script src="{{asset('js/jquery-1.10.2.js')}}" type="text/javascript"></script>
    <script src="{{asset('js/bootstrap.js')}}"></script>
	<!--  Checkbox, Radio & Switch Plugins -->
	<script src="{{asset('js/bootstrap-checkbox-radio.js')}}"></script>

	<!--  Charts Plugin -->
	<script src="{{asset('js/chartist.min.js')}}"></script>

    <!--  Notifications Plugin    -->
    <script src="{{asset('js/bootstrap-notify.js')}}"></script>

    <!--  Google Maps Plugin    -->
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js')}}"></script>

    <!-- Paper Dashboard Core javascript and methods for Demo purpose -->
	<script src="{{asset('js/paper-dashboard.js')}}"></script>

	<!-- Paper Dashboard DEMO methods, don't include it in your project! -->
	<script src="{{asset('js/demo.js')}}"></script>

    <script src="{{asset('js/jquery.min.js') }}"></script>
    <script src="{{asset('js/bootstrap.min.js') }}"></script>

    <script src="{{asset('js/app.js')}}"></script>
    @show





    <script type="text/javascript">
        $(document).on('click','.edit-modal',function(){
    
            $('#footer_action_button').text(" Update");
            $('#footer_action_button').addClass('glyphicon-check');
            $('#footer_action_button').removeClass('glyphicon-trash');
            $('.actionBtn').addClass('btn-success');
            $('.actionBtn').removeClass('btn-danger');
            $('.actionBtn').addClass('edit');
            $('.modal-title').text('Edit');
            $('.deleteContent').hide();
            $('.form-horizontal').show();
            $('#fid').val($(this).data('id'));
            $('#nomor').val($(this).data('nomor'));
            $('#status').val($(this).data('status'));
            $('#myModal').modal('show');
        });
            $('.modal-footer').on('click','.edit',function(){
                $.ajax({
                    type:'post',
                    url:'editItem',
                    data:{
                        '_token' : $('Input[name=_token]').val(),
                        'id':$("#fid").val(),
                        'no_pendaftar':$("#nomor").val(),
                        'status':$('#status').val()
                    },
                    success:function(data){
                        $('.item' + data.id).replaceWith("<tr class='item" + data.id + "'><td><button class='edit-modal btn btn-info' data-id='" + data.id + "'data-status='" + data.status + "'><span class='glyphicon glyphicon-edit'></span>Edit</button><td>" +data.no_pendaftar+"</td><td>" + data.status + "</td><td><button class='delete-modal btn btn-danger'><span class='glyphicon glyphicon-trash'></span>Delete</button>'");
                    }
                });
            });
</script>
















<script type="text/javascript">
        
$(document).on('click', '.update-modal', function() {
    $('#id-edit').val($(this).data('id'));
    $('#kode-edit').val($(this).data('kode'));
    $('#keterangan-edit').val($(this).data('keterangan'));
    $('.bs-example-modal-sm2').modal('show');
  });
  
  $(document).on('click', '.delete-modal', function() {
    $('#id-delete').val($(this).data('id'));
    $('.bs-example-modal-sm3').modal('show');
  });
  
  $("#add").click(function() {
        $.ajax({
            type: 'post',
            url: 'tahunajaran/store',
            data: {
                '_token': $('input[name=_token]').val(),
                'kode': $('input[name=kode]').val(),
                'keterangan': $('input[name=keterangan]').val()
            },
            success: function(data) {
                if ((data.errors)){
                  $('.error').removeClass('hidden');
                    $('.error').text(data.errors.name);
                }
                else {
                    $('.error').remove();
                    $('#table').append("<tr class='item" + data.id + "'><td>" + data.id + "</td><td>" + data.kode + "</td><td>" + data.keterangan + "</td><td><button class='edit-modal btn btn-info btn-sm' data-id='" + data.id + "' data-kode='" + data.kode + "' data-keterangan='" + data.keterangan + "'><span class='glyphicon glyphicon-edit'></span>Edit</button> <button class='delete-modal btn btn-danger btn-sm' data-id='" + data.id + "' data-kode='" + data.kode + "'><span class='glyphicon glyphicon-trash'></span>Delete</button></td></tr>");
            toastr.success("Data Berhasil Disimpan.");
                }
            },
        });
        $('#kode').val('');
        $('#keterangan').val('');
    });

    $("#Ubah").click(function() {
        $.ajax({
            type: 'post',
            url: 'tahunajaran/update',
            data: {
                '_token': $('input[name=_token]').val(),
                'id' : $('input[name=id]').val(),
                'kode': $('input[name=kode-edit]').val(),
                'keterangan': $('input[name=keterangan-edit]').val()
            },
            success: function(data) {
                $('.item' + data.id).replaceWith("<tr class='item" + data.id + "'><td>" + data.id + "</td><td>" + data.kode + "</td><td>" + data.keterangan + "</td><td><button class='edit-modal btn btn-info btn-sm' data-id='" + data.id + "' data-kode='" + data.kode + "' data-keterangan='" + data.keterangan + "'><span class='glyphicon glyphicon-edit'></span>Edit</button> <button class='delete-modal btn btn-danger btn-sm' data-id='" + data.id + "' data-kode='" + data.kode + "'><span class='glyphicon glyphicon-trash'></span>Delete</button></td></tr>");
                toastr.success("Data Berhasil Diubah.");
            },
        });
    });

    $("#delete").click(function() {
        $.ajax({
            type: 'post',
            url: 'tahunajaran/destroy',
            data: {
                '_token': $('input[name=_token]').val(),
                'id' : $('input[name=id-delete]').val()
            },
            success: function(data) {
                $('.item' + data.id).remove();
                toastr.success("Data Berhasil Dihapus.");
            }
        });
    });
</script>
</html>
