@extends('layouts.backend')

@section('content-header')
    <h1>
        Modification d'entreprise
    </h1>
@endsection
@section('content')
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="box box-primary">
                <!-- form start -->
                {!! Form::model($company, ['route' => ['backend.companies.update', $company->id], 'class' => '', 'method' => 'PUT', 'files' => true]) !!}
                    @include('backend.companies._form')
                {!! Form::close() !!}
            </div>
        </div>
    </div>
@endsection

@section('scripts')
    <script>
        $(function(){
            $('#wilaya_id').on('change', function(){
                var $id_wilaya = $(this).val();
                console.log($id_wilaya);
                $('#communes_container').load('/admin/companies/wilayas/'+$id_wilaya+'/communes/select', function() {
                    //$('.select2').select2();
                })
            });

            // $('body').on('change', '#commune_id',function(){
                
            // });

            $('input[name="optionsGroupe"]').click(function(){
                if ($(this).val() == 'ultime') { // filiale
                    $('#container_groupes').hide();
                    $('#groupe_id').attr('required', false);
                    $('#groupe_id').val(null);
                }else{
                    $('#container_groupes').show();
                    $('#groupe_id').attr('required', true);
                    $('.select2').select2();
                }
            });       
        })
    </script>
@endsection