
@extends('adminlte::page')
 
@section('content')
<?php Fun::lang()?>
<div class="title-add">
    <div class="page-bar"> 
        <ul class="page-breadcrumb"> 
            <li> <a class="ng-binding" href="#"><i class="fa fa-dashboard"></i> Dashboard</a> </li>
            <li><a href="#">Agency Group</a></li>
            <li><a href="#">Create Agency Group</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>Create Agency Group</h3>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12 col-xs-12">
            <div class="from-wrapper">
                {!! Form::open(array('route' => 'agency-group.store','method'=>'POST')) !!}
                <div class="row">
                    <div class="form-group col-sm-6 col-xs-6">
                        <label class="required">Group Name</label>
                        {!! Form::text('agency_group_name', null, array('placeholder' => 'Group Name','class' => 'form-control','required')) !!}
                    </div>
                    <div class="form-group col-sm-6 col-xs-6">
                        <label class="required">Agency Amount</label>
                        {!! Form::text('agency_group_amount_get', null, array('placeholder' => 'Group Amount','class' => 'form-control number-only','required')) !!}
                    </div>
                    <div class="form-group col-sm-6 col-xs-6" id="condition_com_option">
                        <label class="required">Group Condition</label>
                        {!! Form::select('agency_group_conid',$condition,null, array('class' => 'form-control input-sm select2 ')) !!}
                        <input type="hidden" name="agency_group_condition" class="form-control agency_group_condition" >
                    </div>
                    <div class="form-group col-sm-6 col-xs-6">
                        <label class="required">Group Commission</label>
                        {!! Form::select('agency_group_percentage',$commission,null, array('class' => 'form-control input-sm select2 conditions')) !!}
                    </div>
                    <div class="col-sm-12 col-xs-12">
                        <div class="form-group">
                                <button type="submit" class="button_sm button_primary pull-right"><span class="fa fa-save"></span> Save</button>
                                <button type="button"  onClick="javascript:history.go(-1)" class="button_sm button_warning pull-right">
                                <span class=" fa fa-arrow-circle-left"></span> Back</button>
                        </div>
                    </div>
                </div>
                {!! Form::close() !!}
            </div>
        </div>
    </div>
</div>
@endsection
@section('js')
    <script type="text/javascript">

        $(document).on('change', '#condition_com_option', function() {
            var id = $(this).find(':selected').val();
            $(".conditions").empty();
            $.ajax({
                type: 'post',
                url: "{{route('get_commission_network_condition')}}",
                dataType: 'json',
                data: {
                    "_token": "{{ csrf_token() }}",
                    "id": id,
                },
                success: function(data) {
                    $(".conditions").empty();
                    var opt = '<option>please select</option>';

                    $.each(data, function(index, value) {
                        opt = '<option value="' + value.commission + '">' + value.commission + '</option>';
                        $('.agency_group_condition').val(value.condition);
                    });
                    $('.conditions').append(opt);

                }
            });

        });
    </script>
@endsection
	
	