<?php $__env->startSection('content'); ?>
<div class="side-title">
    <h3><?php echo e($head ?? ''); ?></h3>
</div>

<div class="border-item">
    <form class="form-row" method="post" action="<?php echo e($action); ?>" enctype="multipart/form-data">
        <?php if($member ?? ''  && $member->id): ?>
            <?php echo method_field('PUT'); ?>
        <?php endif; ?>
        <?php echo csrf_field(); ?>

        <div class="form-group col-lg-6">
            <label><?php echo e(meta('name', getCurrentLocale()) ?? __('members.name')); ?> </label>
            <input type="text" class="form-control <?php echo e($errors->has('name') ? 'is-invalid' : ''); ?>" name="name" placeholder="<?php echo e(meta('name', getCurrentLocale()) ??__('members.name')); ?>" value='<?php echo e(old("name", $member->name ?? "")); ?>'/>
        </div>

        <div class="form-group col-lg-6">
            <label><?php echo e(meta('email', getCurrentLocale()) ?? __('members.email')); ?> </label>
            <input type="text" class="form-control <?php echo e($errors->has('email') ? 'is-invalid' : ''); ?>" name="email" placeholder="<?php echo e(meta('email', getCurrentLocale()) ?? __('members.email')); ?>" value='<?php echo e(old("email", $member->email ?? "")); ?>'/>
        </div>

        <div class="form-group col-lg-6">
            <label><?php echo e(meta('phone', getCurrentLocale()) ?? __('members.phone')); ?> </label>
            <input type="number" class="form-control <?php echo e($errors->has('phone') ? 'is-invalid' : ''); ?>" name="phone" placeholder="<?php echo e(meta('phone', getCurrentLocale()) ?? __('members.phone')); ?>" value='<?php echo e(old("phone", $member->phone ?? "")); ?>'/>
        </div>
       
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('age', getCurrentLocale()) ?? __('members.age')); ?> </label>
            <input type="number" class="form-control <?php echo e($errors->has('age') ? 'is-invalid' : ''); ?>" name="age" placeholder="<?php echo e(meta('age', getCurrentLocale()) ?? __('members.age')); ?>" value='<?php echo e(old("age", $member->age ?? "")); ?>'/>
        </div>

        
     
<div class="col-lg-6">
            <label><?php echo e(meta('gender', getCurrentLocale()) ??  __('members.gender')); ?> </label>
            
                        <select  class="form-control <?php echo e($errors->has('gender') ? 'is-invalid' : ''); ?>" onchange="changetype(this)" name="gender">
                         <option <?php if($member ?? ''  && $member->id): ?> <?php if($member->gender == 'male'): ?> selected <?php endif; ?> <?php endif; ?>  value="male"><?php echo e(__('web.male')); ?></option>
                         <option <?php if($member ?? ''  && $member->id): ?> <?php if($member->gender == 'female'): ?> selected <?php endif; ?> <?php endif; ?>  value="female"><?php echo e(__('web.female')); ?></option>
                          </select>
                        </div>
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('password', getCurrentLocale()) ?? __('members.password')); ?> </label>
            <input type="password" class="form-control <?php echo e($errors->has('password') ? 'is-invalid' : ''); ?>" name="password" placeholder="<?php echo e(meta('password', getCurrentLocale()) ?? __('members.password')); ?>" value='<?php echo e(old("password", "")); ?>'/>
        </div>
 <div class="form-group col-lg-6">
           <label><?php echo e(meta('city_id', getCurrentLocale()) ?? __('members.cities')); ?></label>
            <select name="city_id" onchange="cities(this)" id="city_id" class="form-control my-editor <?php echo e($errors->has('city_id') ? 'is-invalid' : ''); ?>">
                <option value=""><?php echo e(meta('city_id', getCurrentLocale()) ?? __('members.select')); ?></option>
            
                <?php $__currentLoopData = $cities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option <?php if($member ?? ''  && $member->id): ?>  <?php if($member->city_id == $row->id): ?> selected <?php endif; ?> <?php endif; ?> value="<?php echo e($row->id); ?>"><?php echo e(cityname($row->id)); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                
            </select>
        </div>
       <div class="form-group col-lg-6">
            <label><?php echo e(meta('area_id', getCurrentLocale()) ?? __('members.area_id')); ?></label>
            <select name="area_id"  id="area_id" class="form-control my-editor <?php echo e($errors->has('area_id') ? 'is-invalid' : ''); ?>">
                <option value=""><?php echo e(meta('area_id', getCurrentLocale()) ?? __('members.selectcity')); ?></option>
                     <?php if($member ?? ''  && $member->id): ?>
                <?php $__currentLoopData = $areas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $area): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option <?php echo e(old("area_id", $member->area_id ?? "") == $area->id ? 'selected': ''); ?> value="<?php echo e($area->id); ?>"><?php echo e(areaname($area->id)); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php endif; ?>
            </select>
            </div>
       
  
             
        <div class="form-group col-lg-12">
            <label><?php echo e(meta('photo', getCurrentLocale()) ?? __('members.photo')); ?> </label>
            <input id="image_thumbnail" class="image_thumbnail" type="hidden" name="photo" value="<?php echo e(old("photo", $member->photo ?? "")); ?>"/>

            <div class="photos main_photo <?php echo e(old('photo', $member->photo ?? '') ? ' wow fadeInUp' : 'hide'); ?>">
                <div class="col-lg-4">
                    <div class="items">
                        <div class="img">
                            <a href="#" id="lfm" data-input=".image_thumbnail" data-preview=".image_holder" class="lfm" data-hide=".pick_button">
                                <img src="<?php echo e(asset(old('photo', $member->photo ?? ''))); ?> "  id="image_holder" class="image_holder"/>
                            </a>
                        </div>
                        <a href="#" class="showHide resetImage close" data-empty=".image_thumbnail" data-hide=".main_photo" data-show=".pick_button"><i class="fas fa-times"></i></a>
                    </div>
                </div>
            </div>

            <div class="clearfix"></div>
            <span class="input-group-btn pick_button <?php echo e(old('photo', $member->photo ?? '') ? 'hide' : ''); ?> ">
                <a id="lfm" data-input=".image_thumbnail" data-preview=".image_holder" data-show=".main_photo" data-hide=".pick_button" class="lfm btn btn-primary text-light">
                    <i class="fas fa-camera-retro"></i> Choose
                </a>
            </span>
        </div>
        
        

        <div class="text-center mt-5 col-12">
            <button class="butn"><span><?php echo e(__('dashboard.save')); ?></span></button>
        </div>
    </form>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('inner_js'); ?>
<script>



function addexperience(elem){
    var num = $(elem).attr('data-id');
        
        var newrow = parseInt(num)+1; 
        $(elem).attr('data-id', newrow);
        
        $.ajax({
          url : urls_exper+'/'+num,
          type : 'GET',
          data : 'nothing',
          success:function(data)
          {
            $('#experiences').append(data);
          }
        }) 
}

function remove(elem){
            $(elem).closest('.row').remove();
        }
function addcertification(elem){
     var num = $(elem).attr('data-id');
        
        var newrow = parseInt(num)+1; 
        $(elem).attr('data-id', newrow);
        
        $.ajax({
          url : urls+'/'+num,
          type : 'GET',
          data : 'nothing',
          success:function(data)
          {
            $('#certifications').append(data);
          }
        }) 
}
    function changetype(elem){
        let valuedata = $(elem).val();
        if(valuedata == 'member'){
            $('#member').css('display','block');
            $('#consult').css('display','none');
        }
        else{
            $('#consult').css('display','block');
            $('#member').css('display','none');
        }
        

    }
</script>
  <script>
        function initImageUpload(box) {
            let uploadField = box.querySelector('.image-upload');

            uploadField.addEventListener('change', getFile);

            function getFile(e) {
                let file = e.currentTarget.files[0];
                checkType(file);
            }

            function previewImage(file) {
                let thumb = box.querySelector('.js--image-preview'),
                    reader = new FileReader();

                reader.onload = function() {
                    thumb.style.backgroundImage = 'url(' + reader.result + ')';
                }
                reader.readAsDataURL(file);
                thumb.className += ' js--no-default';
            }

            function checkType(file) {
                let imageType = /image.*/;
                if (!file.type.match(imageType)) {
                    throw 'Datei ist kein Bild';
                } else if (!file) {
                    throw 'Kein Bild gew채hlt';
                } else {
                    previewImage(file);
                }
            }

        }

        // initialize box-scope
        var boxes = document.querySelectorAll('.box');

        for (let i = 0; i < boxes.length; i++) {
            let box = boxes[i];
            initDropEffect(box);
            initImageUpload(box);
        }



        /// drop-effect
        function initDropEffect(box) {
            let area, drop, areaWidth, areaHeight, maxDistance, dropWidth, dropHeight, x, y;

            // get clickable area for drop effect
            area = box.querySelector('.js--image-preview');
            area.addEventListener('click', fireRipple);

            function fireRipple(e) {
                area = e.currentTarget
                    // create drop
                if (!drop) {
                    drop = document.createElement('span');
                    drop.className = 'drop';
                    this.appendChild(drop);
                }
                // reset animate class
                drop.className = 'drop';

                // calculate dimensions of area (longest side)
                areaWidth = getComputedStyle(this, null).getPropertyValue("width");
                areaHeight = getComputedStyle(this, null).getPropertyValue("height");
                maxDistance = Math.max(parseInt(areaWidth, 10), parseInt(areaHeight, 10));

                // set drop dimensions to fill area
                drop.style.width = maxDistance + 'px';
                drop.style.height = maxDistance + 'px';

                // calculate dimensions of drop
                dropWidth = getComputedStyle(this, null).getPropertyValue("width");
                dropHeight = getComputedStyle(this, null).getPropertyValue("height");

                // calculate relative coordinates of click
                // logic: click coordinates relative to page - parent's position relative to page - half of self height/width to make it controllable from the center
                x = e.pageX - this.offsetLeft - (parseInt(dropWidth, 10) / 2);
                y = e.pageY - this.offsetTop - (parseInt(dropHeight, 10) / 2) - 30;

                // position drop and animate
                drop.style.top = y + 'px';
                drop.style.left = x + 'px';
                drop.className += ' animate';
                e.stopPropagation();

            }
        }
    </script>
    	
    <script>
        $(".form-group").delegate( ".edit_btn", "click", function() {
            $(this).parentsUntil(".form-group").siblings(".box").toggleClass("d-block");
        })
        
function cities(elem){
     var data = $(elem).val();
         
        
        
         $.ajax({
          url : url_area+'/'+data,
          type : 'GET',
          data : 'nothing',
          
          success:function(data)
          {
            $('#area_id').html(data);
          }
        })   
}
    </script>
    <!-- Editor JS files -->

            <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
    <script>
        var route_prefix = "<?php echo e(url(config('lfm.prefix'))); ?>",
            url = "<?php echo e(url('/')); ?>",
            url_area = <?php echo json_encode(url(getCurrentLocale().'/admin/city/')); ?>,
            urls = "<?php echo e(url('/')); ?>/admin/addcertification",
            urls_exper = "<?php echo e(url('/')); ?>/admin/addexperience",
            imagePath = "<?php echo e(asset('')); ?>";
    </script>
    <script src="<?php echo e(asset('assets/admin/js/editor.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/admin/js/lfm.js')); ?>"></script>
    


<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/omaralyomhost/public_html/4u/resources/views/admin/members/form.blade.php ENDPATH**/ ?>