@extends('layouts.app')
<?php
    use App\Models\AgeGroup; $agegroups = array();
    $request = request();
    $posturl = url("indicator/processage");
    $successurl = url("indicator/agegroups");
    $successurlnxt = url('indicator/agegroups');
    $gotosuccess = true;
    $id = "";  $successmessage = $failureurl = $name = $min = $max ="";
    if(!empty($request->id)){
        $id = $request->id;
        $posturl = url("indicator/updateagegroups");
        $successurl = url("indicator/agegroups");
        $successurlnxt = url('indicator/agegroups');
        $gotosuccess = true;
        $agegroups = AgeGroup::where('id', $id)->get();
        foreach ($agegroups as $agegroup) {
            $name = $agegroup['name'];
            $min = $agegroup['min'];
            $max = $agegroup['max'];
        }
    }
?>
@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">
                                <a href="<?php echo url('indicator/list?tab=age'); ?>"><i class="icofont icofont icofont icofont-file-document bg-c-pink"></i></a>
                                <div class="d-inline">
                                    <h4>Age Group</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="#!">Indicator</a>
                                    </li>
                                    <li class="breadcrumb-item"><a href="#!">Age Group</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="AgeGroup" />
                                    <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">Name</label>
                                        <div class="col-sm-8">
                                            <input type="text" name="name" required="required" class="form-control" value="<?php echo $name; ?>">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-2 col-form-label">Min Value</label>
                                        <div class="col-sm-3">
                                            <input type="number" class="form-control" placeholder="0" name="min" value="<?php echo $min; ?>">
                                        </div>
                                        <label class="col-sm-2 col-form-label">Max Value</label>
                                        <div class="col-sm-3">
                                            <input type="number" class="form-control" placeholder="75" name="max" value="<?php echo $max; ?>" maxlength="3">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-8 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
