<?php $__env->startSection('content'); ?>
    <section class="section">
        <div class="card col-6 m-auto">
            <div class="card-header">
                <h4 class="card-title text-center"><img style="width: 15%;" src="/site/assets/images/Group_542.svg" alt="" /></h4>
            </div>
            <div class="card-content">
                <div class="card-body">
                    <?php if(!isset($form)): ?>
                        <form class="form form-vertical" method="post" action="<?php echo e(route('site.need-homes.store')); ?>"><?php echo csrf_field(); ?>
                    <?php endif; ?>
                        <div class="form-body">
                            <div class="row px-3">
                                <div class="col-12">
                                    <h4>Deprem Yardım Formu:</h4>
                                    <hr />
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="text" class="form-control" placeholder="Ad Soyad" name="name" <?php if(isset($form)): ?> value="<?php echo e($form->name); ?>" disabled <?php endif; ?> required id="first-name-icon" />
                                            <div class="form-control-icon">
                                                <i class="bi bi-person"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="text" class="form-control" placeholder="Telefon Numarası" name="telephone" <?php if(isset($form)): ?> value="<?php echo e($form->telephone); ?>" disabled <?php endif; ?> required id="email-id-icon" />
                                            <div class="form-control-icon">
                                                <i class="bi bi-telephone"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="text" class="form-control" placeholder="Depremi Yaşadığın Bölge:" disabled id="email-id-icon" />
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-12 px-4 city-box my-3">
                                    <span>
                                        <input type="radio" id="adana" name="city_id" value="1" <?php if(isset($form) && $form->city_id == '1'): ?> checked disabled <?php endif; ?> />
                                        <label for="adana">Adana</label>
                                    </span>
                                    <span>
                                        <input type="radio" id="adiyaman" name="city_id" value="2" <?php if(isset($form) && $form->city_id == '2'): ?> checked disabled <?php endif; ?> />
                                        <label for="adiyaman">Adıyaman</label>
                                    </span>
                                    <span>
                                        <input type="radio" id="diyarbakir" name="city_id" value="21" <?php if(isset($form) && $form->city_id == '21'): ?> checked disabled <?php endif; ?> />
                                        <label for="diyarbakir">Diyarbakır</label>
                                    </span>
                                    <span>
                                        <input type="radio" id="gaziantep" name="city_id" value="27" <?php if(isset($form) && $form->city_id == '27'): ?> checked disabled <?php endif; ?> />
                                        <label for="gaziantep">Gaziantep</label>
                                    </span>
                                    <span>
                                        <input type="radio" id="hatay" name="city_id" value="31" <?php if(isset($form) && $form->city_id == '31'): ?> checked disabled <?php endif; ?> />
                                        <label for="hatay">Hatay</label>
                                    </span>
                                    <span>
                                        <input type="radio" id="maras" name="city_id" value="46" <?php if(isset($form) && $form->city_id == '46'): ?> checked disabled <?php endif; ?> />
                                        <label for="maras">Kahramanmaraş</label>
                                    </span>
                                    <span>
                                        <input type="radio" id="kilis" name="city_id" value="79" <?php if(isset($form) && $form->city_id == '79'): ?> checked disabled <?php endif; ?> />
                                        <label for="kilis">Kilis</label>
                                    </span>
                                    <span>
                                        <input type="radio" id="malatya" name="city_id" value="44" <?php if(isset($form) && $form->city_id == '44'): ?> checked disabled <?php endif; ?> />
                                        <label for="malatya">Malatya</label>
                                    </span>
                                    <span>
                                        <input type="radio" id="osmaniye" name="city_id" value="80" <?php if(isset($form) && $form->city_id == '80'): ?> checked disabled <?php endif; ?> />
                                        <label for="osmaniye">Osmaniye</label>
                                    </span>
                                    <span>
                                        <input type="radio" id="sanliurfa" name="city_id" value="63" <?php if(isset($form) && $form->city_id == '63'): ?> checked disabled <?php endif; ?> />
                                        <label for="sanliurfa">Şanlıurfa</label>
                                    </span>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <?php if(isset($form)): ?>
                                                <select class="form-control" disabled>
                                                    <option value="0"><?php echo e(\App\Models\Town::where('ilce_id',$form->town_id)->first()->ilce_adi); ?></option>
                                                </select>
                                            <?php else: ?>
                                                <select class="form-control" name="town_id">
                                                    <option value="0">İlçe</option>
                                                </select>
                                            <?php endif; ?>
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <?php if(isset($form)): ?>
                                                <select class="form-control" disabled>
                                                    <option value="0"><?php echo e(\App\Models\District::where('mahalle_id',$form->district_id)->first()->mahalle_adi); ?></option>
                                                </select>
                                            <?php else: ?>
                                                <select class="form-control" name="district_id">
                                                    <option value="0">Mahalle</option>
                                                </select>
                                            <?php endif; ?>
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <?php if(isset($form)): ?>
                                                <select class="form-control" disabled>
                                                    <option value="0"><?php echo e(\App\Models\Street::where('sokak_id',$form->street_id)->first()->sokak_adi); ?></option>
                                                </select>
                                            <?php else: ?>
                                                <select class="form-control" name="street_id">
                                                    <option value="0">Sokak</option>
                                                </select>
                                            <?php endif; ?>
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="text" class="form-control" placeholder="Bina No" name="apartment_no" <?php if(isset($form)): ?> value="<?php echo e($form->apartment_no); ?>" disabled <?php endif; ?> required id="email-id-icon" />
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="text" class="form-control" placeholder="Kat" name="floor" <?php if(isset($form)): ?> value="<?php echo e($form->floor); ?>" disabled <?php endif; ?> required id="email-id-icon" />
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="text" class="form-control" placeholder="Daire" name="apartment" <?php if(isset($form)): ?> value="<?php echo e($form->apartment); ?>" disabled <?php endif; ?> required id="email-id-icon" />
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-12 my-3">
                                    <hr />
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="number" min="0" class="form-control" placeholder="Yanında Kaç Kişi Var?" name="person_count" <?php if(isset($form)): ?> value="<?php echo e(\App\Models\Site\NeedHomePerson::where('need_home_id',$form->id)->count()); ?>" disabled <?php endif; ?> id="email-id-icon" />
                                        </div>
                                    </div>
                                </div>
                                <?php if(isset($form)): ?>
                                    <?php $__currentLoopData = \App\Models\Site\NeedHomePerson::where('need_home_id',$form->id)->get(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <div class="col-12 person-item"><h5><?php echo e($key+1); ?>.Kişi</h5></div>
                                        <div class="col-6 person-item">
                                            <div class="form-group has-icon-right">
                                                <div class="position-relative">
                                                    <input type="text" class="form-control" placeholder="Ad Soyad" name="person_name[]" value="<?php echo e($item->name); ?>" disabled required id="first-name-icon" />
                                                    <div class="form-control-icon">
                                                        <i class="bi bi-person"></i>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-6 person-item">
                                            <div class="form-group has-icon-right">
                                                <div class="position-relative">
                                                    <input type="text" class="form-control" placeholder="Telefon Numarası" name="person_telephone[]" value="<?php echo e($item->telephone); ?>" disabled id="email-id-icon" />
                                                    <div class="form-control-icon">
                                                        <i class="bi bi-telephone"></i>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <?php else: ?>
                                    <div class="col-12 person-item"><h5>1.Kişi</h5></div>
                                    <div class="col-6 person-item">
                                        <div class="form-group has-icon-right">
                                            <div class="position-relative">
                                                <input type="text" class="form-control" placeholder="Ad Soyad" name="person_name[]" required id="first-name-icon" />
                                                <div class="form-control-icon">
                                                    <i class="bi bi-person"></i>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-6 person-item">
                                        <div class="form-group has-icon-right">
                                            <div class="position-relative">
                                                <input type="text" class="form-control" placeholder="Telefon Numarası" name="person_telephone[]" id="email-id-icon" />
                                                <div class="form-control-icon">
                                                    <i class="bi bi-telephone"></i>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-12 d-flex person-item justify-content-end mt-3">
                                        <button type="submit" class="btn btn-secondary me-1 mb-1 px-5" style="border-radius: 15px;">Başvur</button>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    <?php if(!isset($form)): ?>
                        </form>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </section>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('js'); ?>
    <script>
        $('input[name="city_id"]').on('change',function (){
            $.ajax({
                url: "<?php echo e(route('getTownsFromCity')); ?>",
                type: "post",
                data: {'_token':'<?php echo e(csrf_token()); ?>','city_id':$('input[name="city_id"]:checked').val()} ,
                success: function (response) {
                    $('select[name="town_id"]').empty().append('<option value="0">İlçe</option>');
                    $('select[name="district_id"]').empty().append('<option value="0">Mahalle</option>');
                    $('select[name="street_id"]').empty().append('<option value="0">Sokak</option>');
                    $.each(response.towns,function (index,item){
                        $('select[name="town_id"]').append('<option value="'+item.ilce_id+'">'+item.ilce_adi+'</option>');
                    })
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    console.log(textStatus, errorThrown);
                }
            });
        })

        $('select[name="town_id"]').on('change',function (){
            $.ajax({
                url: "<?php echo e(route('getDistrictsFromTown')); ?>",
                type: "post",
                data: {'_token':'<?php echo e(csrf_token()); ?>','town_id':$('select[name="town_id"]').val()} ,
                success: function (response) {
                    $('select[name="district_id"]').empty().append('<option value="0">Mahalle</option>');
                    $('select[name="street_id"]').empty().append('<option value="0">Sokak</option>');
                    $.each(response.districts,function (index,item){
                        $('select[name="district_id"]').append('<option value="'+item.mahalle_id+'">'+item.mahalle_adi+'</option>');
                    })
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    console.log(textStatus, errorThrown);
                }
            });
        })

        $('select[name="district_id"]').on('change',function (){
            $.ajax({
                url: "<?php echo e(route('getStreetsFromDistrict')); ?>",
                type: "post",
                data: {'_token':'<?php echo e(csrf_token()); ?>','district_id':$('select[name="district_id"]').val()} ,
                success: function (response) {
                    $('select[name="street_id"]').empty().append('<option value="0">Sokak</option>');
                    $.each(response.streets,function (index,item){
                        $('select[name="street_id"]').append('<option value="'+item.sokak_id+'">'+item.sokak_adi+'</option>');
                    })
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    console.log(textStatus, errorThrown);
                }
            });
        })

        $('input[name="person_count"]').on('change',function (){
            if ($('input[name="person_count"]').val() > 0){
                $('.person-item').remove()
                let html = ''
                for (let a = 0; a < $('input[name="person_count"]').val();a++){
                    html += '<div class="col-12 person-item"><h5>'+ (a+1) +'.Kişi</h5></div>'
                    html += '<div class="col-6 person-item">'
                    html += '<div class="form-group has-icon-right">'
                    html += '<div class="position-relative">'
                    html += '<input type="text" class="form-control" placeholder="Ad Soyad" name="person_name[]" required id="first-name-icon" />'
                    html += '<div class="form-control-icon">'
                    html += '<i class="bi bi-person"></i>'
                    html += '</div>'
                    html += '</div>'
                    html += '</div>'
                    html += '</div>'
                    html += '<div class="col-6 person-item">'
                    html += '<div class="form-group has-icon-right">'
                    html += '<div class="position-relative">'
                    html += '<input type="text" class="form-control" placeholder="Telefon Numarası" name="person_telephone[]" id="email-id-icon" />'
                    html += '<div class="form-control-icon">'
                    html += '<i class="bi bi-telephone"></i>'
                    html += '</div>'
                    html += '</div>'
                    html += '</div>'
                    html += '</div>'
                }
                html += '<div class="col-12 d-flex person-item justify-content-end mt-3">'
                html += '<button type="submit" class="btn btn-secondary me-1 mb-1 px-5" style="border-radius: 15px;">Başvur</button>'
                html += '</div>'

                $('.row.px-3').append(html)
            }
        })
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('site.pages.build', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\kardesyuvan\resources\views/site/pages/deprem_yardim_formu.blade.php ENDPATH**/ ?>