@extends('adminlte::page') @section('content')
<?php Fun::lang();?>
<style>
    .content-wrapper{
        height: 100% !important;
    }
</style>
<div class="modal fade bs-modal-md" id="create-ceremony" tabindex="-1" role="dialog" aria-hidden="true" >
    <div class="modal-dialog modal-md modal-md" >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h3>Create Ceremony</h3>
            </div>
            <br />
            <form class="form-horizontal" role="form" action="{{ route('promotion.ceremony_store') }}" method="post">
                @csrf
                <div class="col-sm-12">
                    <label class="required">Ceremony Name</label>
                    <input type="text" name="name" class="form-control" placeholder="Ceremony Name" required>
                </div>
                <br>
                <div class="col-sm-12">
                    <br/>
                    <label>Description</label>
                    <textarea name="description" class="form-control" placeholder="Description"></textarea>
                    <br/>
                </div>

                <div class="modal-footer">
                    <br/>
                    <button type="button" data-dismiss="modal" class="button_danger"><i class="fa fa-close"></i> No</button>
                    <button type="submit" class="button_success" data-toggle="modal"><i class="fa fa-save"></i> Save</button>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<div class="modal fade bs-modal-md" id="edit-ceremony" tabindex="-1" role="dialog" aria-hidden="true" >
    <div class="modal-dialog modal-md modal-md" >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h3>Edit Ceremony</h3>
            </div>
            <br />
            <form class="form-horizontal" role="form" action="{{ route('promotion.ceremony_update') }}" method="post">
                @csrf
                <div class="col-sm-12">
                    <label class="required">Ceremony Name</label>
                    <input type="text" name="name" class="form-control" placeholder="Ceremony Name" id="edit-name" required>
                </div>
                <br>
                <div class="col-sm-12">
                    <br/>
                    <label>Description</label>
                    <textarea name="description" class="form-control" placeholder="Description" id="edit-description"></textarea>
                    <br/>
                </div>

                <div class="modal-footer">
                    <br/>
                    <input type="hidden" name="id" id = "edit-id">
                    <button type="button" data-dismiss="modal" class="button_danger"><i class="fa fa-close"></i> No</button>
                    <button type="submit" class="button_success" data-toggle="modal"><i class="fa fa-save"></i> Save</button>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<div class="title-page">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li><a href="#">Operation</a></li>
            <li><a href="#">Manage Promotion</a></li>
            <li><a href="#">Ceremony</a></li>
        </ul>
    </div>
</div>
    <div class="page">
        <div class="top-content">
            <div class="row">
                <div class="col-sm-12 col-xs-12">
                    <div class="title-page">
                        <div class="pull-left">
                            <h3>Ceremony List</h3>
                        </div>
                    </div>
                    <div class="pull-right">
                        @can('Ceremony-Create')
                        <a class="button_sm button_primary" href="#create-ceremony" onclick="create_ceremony()" data-toggle="modal"><span class="fa fa-plus"></span>  Create New</a>
                        @endcan
                    </div>
                </div>
            </div>
        </div>
        <div class="box-body table-responsive">
                        
            <table id="datatable_ceremony" class="table table-striped table-bordered table-hover nowrap">
                <thead>
                    <tr>
                        <th>NO</th>
                        <th>Name</th>
                        <th>Description</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                        {!! $tr !!}
                </tbody>
            </table>
        </div>
    </div>
    @endsection
    @section('js')
    <script type="text/javascript">
            $(document).ready(function(){
                $("#datatable_ceremony").DataTable();
            });
            function edit(obj)
            {
                $("#edit-id").val($(obj).data("id"));
                $("#edit-name").val($(obj).data("name"));
                $("#edit-description").val($(obj).data("description"));
                $("#edit-ceremony").modal("show");
            }
            function delete_ceremony(obj)
            {
                var id = $(obj).data("id");
                $.confirm({
                    title:'Are you sure ?',
                    content:'',
                    theme:'modern',
                    buttons:{
                        cancel:{
                            btnClass:'btn btn-primary',
                            text:'Cancel',
                            action:function () {

                            }
                        },
                        submit:{
                            btnClass:'btn btn-danger',
                            text:"Delete",
                            action:function () {
                                    window.location.replace('{{route("promotion.ceremony_delete")}}?id='+id);
                            }
                        },
                    },
                });
            }
    </script>
    @endsection
<style>
    .modal-lg {
        width: 800px;
    }
</style>