<!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" />

    <link href="{{ asset('css/style.css') }}" rel="stylesheet">

    <!-- 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">
    <link href="{{asset('css/style.css')}}" rel="stylesheet" />

    <link href="{{asset('css/css/style.css')}}" rel="stylesheet" />
    <link href="{{asset('css/css/bootstrap.min.css')}}" rel="stylesheet" />
    <link href="{{asset('css/css/form-elements.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>
    <script src="{{asset('js/jquery-3.1.1.js')}}"></script>
    <script src="{{ asset('js/jquery.bootstrap.wizard.min.js') }}"></script>
    <script src="{{ asset('js/script.js') }}"></script>

    <script src="{{ asset('js/jswizrd/jquery.backstretch.min.js') }}"></script>
    <script src="{{ asset('js/jswizrd/retina-1.1.0.min.js') }}"></script>
    <script src="{{ asset('js/jswizrd/scripts.js') }}"></script>
    @show

    <!-- Tahun Ajaran (Tata Usaha) -->

    <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');
      });

      $(document).on('click', '.Add-tahun', function() {
        $('.bs-example-modal-sm1').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>


    <!-- Untuk Ruang -->
    <script type="text/javascript">
            
    $(document).on('click', '.ubah-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', '.hapus-modal', function() {
        $('#id-delete').val($(this).data('id'));
        $('.bs-example-modal-sm3').modal('show');
      });

      $(document).on('click', '.tambah-modal', function() {
        $('.bs-example-modal-sm1').modal('show');
      });
      
      $("#addruang").click(function() {
            $.ajax({
                type: 'post',
                url: 'ruang/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='ubah-modal btn btn-info btn-sm' data-id='" + data.id + "' data-kode='" + data.kode + "' data-keterangan='" + data.keterangan + "'><span class='glyphicon glyphicon-edit'></span>Ubah</button> <button class='delete-modal btn btn-danger btn-sm' data-id='" + data.id + "' data-kode='" + data.kode + "'><span class='glyphicon glyphicon-trash'></span>Hapus</button></td></tr>");
                toastr.success("Data Berhasil Disimpan.");
                    }
                },
            });
            $('#kode').val('');
            $('#keterangan').val('');
        });

        $("#Ubah").click(function() {
            $.ajax({
                type: 'post',
                url: 'ruang/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='ubah-modal btn btn-info btn-sm' data-id='" + data.id + "' data-kode='" + data.kode + "' data-keterangan='" + data.keterangan + "'><span class='glyphicon glyphicon-edit'></span>Ubah</button> <button class='delete-modal btn btn-danger btn-sm' data-id='" + data.id + "' data-kode='" + data.kode + "'><span class='glyphicon glyphicon-trash'></span>Hapus</button></td></tr>");
                    toastr.success("Data Berhasil Diubah.");
                },
            });
        });

        $("#delete").click(function() {
            $.ajax({
                type: 'post',
                url: 'ruang/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>

    <script type="text/javascript">
        $('.addRow').on('click',function(){
            addRow();
        });
        function addRow()
        {
            var tr = '<tr><td><input type="text" name="jenis_prestasi[]" class="form-control jenis_prestasi" placeholder="Jenis Prestasi"></td><td><input type="text" name="nama_prestasi[]" class="form-control nama_prestasi" placeholder="Nama Prestasi"></td><td><input type="text" name="tahun_prestasi[]" class="form-control tahun_prestasi" placeholder="Tahun Prestasi"></td><td><input type="text" name="penyelenggara" class="form-control penyelenggara" placeholder="Penyelenggara"></td><td><a href="#" class="btn btn-danger remove"><i class="glyphicon glyphicon-remove"></i></a></td></tr>';
            $('tbody').append(tr);
        };
        $('body').delegate('.remove','click',function(){
            $(this).parent().parent().remove();
        });
    </script>

</html>
