@extends('layouts.app')
<?php
    use App\Models\Incident; $incident = array();
    $request = request();
    $posturl = url("indicator/processincident");
    $successurl = url("indicator/incidents");
    $successurlnxt = url('indicator/incidents');
    $gotosuccess = true;
    $id = "";  $successmessage = $failureurl = $name = $code = $notes ="";
    if(!empty($request->id)){
        $id = $request->id;
        $posturl = url("indicator/updateincident");
        $successurl = url("indicator/incidents");
        $successurlnxt = url('indicator/incidents');
        $gotosuccess = true;
        $incident = Incident::where('id', $id)->get();
        foreach ($incident as $incident) {
            $name = $incident['name'];
            $code = $incident['code'];
            $notes = $incident['notes'];
        }
    }
?>
@section('content')
<div class="pcoded-content">
    <div class="pcoded-inner-content">
        <div class="main-body">
            <div class="page-wrapper">
                <!-- Page-header start -->
                <div class="page-header card page-body">
                    <div class="row align-items-end">
                        <div class="col-lg-8">
                            <div class="page-header-title">
                                <i class="icofont icofont icofont icofont-file-document bg-c-pink"></i>
                                <div class="d-inline">
                                    <h4>Incident Category</h4>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-4">
                            <div class="page-header-breadcrumb">
                                <ul class="breadcrumb-title">
                                    <li class="breadcrumb-item">
                                        <a href="index.html">
                                            <i class="icofont icofont-home"></i>
                                        </a>
                                    </li>
                                    <li class="breadcrumb-item"><a href="#!">Incident</a>
                                    </li>
                                    <li class="breadcrumb-item"><a href="#!">Incident Category</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                        <hr>
                        <div class="row">
                            <div class="col-sm-12">
                                <form id="indexform" class="form-horizontal" method="POST" action="<?php echo $posturl; ?>">
                                    @csrf
                                    <input name="entityname" id="entityname" type="hidden" value="Incident" />
                                    <input type="hidden" id="action" name="action"value="" />
                                    <input type="hidden" id="id" name="id" value="<?php echo $id; ?>" />
                                    <input name="successmessage" id="successmessage" type="hidden" value="<?php echo $successmessage; ?>" />  
                                    <input type="hidden" id="<?php echo "SUCCESS_MESSAGE"; ?>" name="<?php echo "SUCCESS_MESSAGE"; ?>" value="<?php echo $successmessage; ?>" /> 
                                    <input type="hidden" id="<?php echo "URL_SUCCESS"; ?>" name="successurl" value="<?php echo base64_encode($successurl); ?>" /> 
                                    <input type="hidden" id="<?php echo "URL_FAILURE"; ?>" name="failureurl" value="<?php echo base64_encode($failureurl); ?>" />

                                    <div class="form-group row">
                                        <label class="col-sm-2 col-form-label">Incident Name</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="name" placeholder="Incident Category" required="required" value="<?php echo $name; ?>">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-2 col-form-label">Code</label>
                                        <div class="col-sm-4">
                                            <input type="text" class="form-control"
                                            placeholder="Code" name="code" value="<?php echo $code; ?>">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-2 col-form-label">Notes</label>
                                        <div class="col-sm-10">
                                            <textarea rows="5" cols="5" class="form-control" name="notes" 
                                            placeholder="Default textarea"><?php echo $notes; ?></textarea>
                                        </div>
                                    </div>
                                    
                                    <div class="form-group row">
                                        <label class="col-sm-10 col-form-label"></label>
                                        <button type="submit" class="col-sm-2 btn btn-primary">Submit</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    
                </div>
                <!-- Page-header end -->
            </div>
        </div>
        <div id="styleSelector">

        </div>
    </div>
</div>
@endsection
