@extends('layouts.master')
@section('content')
<style type="text/css">
    .col-6{
        margin-top: 10px;
    }
    .required{
        font-weight: 800;
        color: red;
    }
    label{
        font-weight: 600;
    }
</style>
<div class="content-wrapper">
    <div class="content-body">
        <!-- Table Hover Animation start -->
        <div class="row" id="table-hover-animation">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <h4 class="card-title">{{ $title }} List</h4>
                        <div class="content-header-right text-md-right col-md-3 col-12 d-md-block d-none">
                            <button class="btn btn-info" data-toggle="modal" data-target="#large"><i class="fa fa-plus"></i> Add {{ $title }}</button>
                        </div>
                    </div>
                    <div class="card-content">
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table table-bordered table-striped table-hover-animation">
                                    <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>Name</th>
                                            <th>Status</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    	@foreach($project as $key => $list)
                                        <tr>
                                            <th>{{ ++$key }}</th>
                                            <td>{{ $list->name }}</td>
                                            <td>
                                            	@if($list->status == 1)
                                            	<button class="btn btn-success btn-sm">Active</button>
                                            	@else
                                            	<button class="btn btn-danger btn-sm">InActive</button>
                                            	@endif
                                            </td>
                                            <td>
                                            	<button onclick="return editData( {{json_encode($list)}} )" class="btn btn-primary btn-sm"><i class="fa fa-edit"></i></button>
                                            	<button type="button" class="btn btn-sm bg-gradient-danger" onclick="return deleteCertification(<?php echo $list->id; ?>)" title="delete"><i class="fa fa-trash-o"></i></button>
				                                <form id="delete-form-{{$list->id}}" action="{{ url('project',$list->id) }}" method="POST" style="display: none;">
				                                    @csrf
				                                    @method('DELETE')
				                                </form>
                                            </td>
                                        </tr>
                                        @endforeach
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Table head options end -->

        <!-- Modal -->
        <div class="modal fade text-left" id="large" role="dialog" aria-labelledby="myModalLabel17" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="myModalLabel17">Add {{$title}}</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <form method="POST" action="{{ url('project') }}">
                    	@csrf
                        <div class="modal-body">
                            <div class="form-group">
                            	<label>Name <span class="required">*</span></label>
                            	<input type="text" name="name" class="form-control" placeholder="Enter Product Name" required="">
                            </div>
                            <div class="form-group">
                            	<label>Status <span class="required">*</span></label>
                            	<select name="status" class="form-control" required="">
                            		<option value="1">Active</option>
                            		<option value="2">InActive</option>
                            	</select>
                            </div>

                        </div>
                        <div class="modal-footer">
                            <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Submit</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <!-- Edit Modal -->
        <div class="modal fade text-left" id="editModal" role="dialog" aria-labelledby="myModalLabel17" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="myModalLabel17">Add {{$title}}</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <form method="POST" action="{{ url('project-update') }}">
                    	@csrf
                        <div class="modal-body">
                            <div class="form-group">
                            	<label>Name <span class="required">*</span></label>
                            	<input type="text" id="name" name="name" class="form-control" placeholder="Enter Product Name" required="">
                            </div>
                            <div class="form-group">
                            	<label>Status <span class="required">*</span></label>
                            	<select name="status" id="status" class="form-control" required="">
                            		<option value="1">Active</option>
                            		<option value="2">InActive</option>
                            	</select>
                            </div>
                            <input type="hidden" name="project_id" id="project_id">
                        </div>
                        <div class="modal-footer">
                            <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Submit</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

    </div>
</div>
@endsection
@push('js')
<script type="text/javascript">
	function editData(value){
		$('#editModal').modal('show');
		$('#project_id').val(value.id)
		$('#name').val(value.name)
		$('#status').val(value.status)
	}
</script>
@endpush