<?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-12">
            <label><?php echo e(meta('role', getCurrentLocale()) ??  __('members.role')); ?> </label>
            <div class="clearfix"></div>
            <div class="row">
               
                <div class="form-group col-sm-6">
                   
                    <div class="custom-control custom-checkbox">
                        <select  class="form-control <?php echo e($errors->has('role') ? 'is-invalid' : ''); ?>" onchange="changetype(this)" name="role">
                         <option <?php if($member ?? ''  && $member->id): ?> <?php if($member->role == 'member'): ?> selected <?php endif; ?> <?php endif; ?>  value="member"><?php echo e(__('members.member')); ?></option>
                         <option <?php if($member ?? ''  && $member->id): ?> <?php if($member->role == 'consult'): ?> selected <?php endif; ?> <?php endif; ?>  value="consult"><?php echo e(__('members.consult')); ?></option>
                          </select>
                        </div>
                </div>
               
            </div>
        </div>
        <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('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="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('password_confirmation', getCurrentLocale()) ?? __('members.password_confirmation')); ?> </label>
            <input type="password" class="form-control <?php echo e($errors->has('password_confirmation') ? 'is-invalid' : ''); ?>" name="password_confirmation" placeholder="<?php echo e(meta('password_confirmation', getCurrentLocale()) ?? __('members.password_confirmation')); ?>" value='<?php echo e(old("password_confirmation", "")); ?>'/>
        </div>
        
        <div id="member" class="col-12"  <?php if($member ?? ''  && $member->id): ?>  <?php if( $member->role == 'member'): ?> style="display:block" <?php else: ?> style="display:none" <?php endif; ?> <?php else: ?> style="display:block" <?php endif; ?>>
        <div class="row">
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('relative', getCurrentLocale()) ?? __('members.relative')); ?> </label>
            <input type="text" class="form-control <?php echo e($errors->has('relative') ? 'is-invalid' : ''); ?>" name="relative" placeholder="<?php echo e(meta('relative', getCurrentLocale()) ?? __('members.relative')); ?>" value='<?php echo e(old("relative", $member->relative ?? "")); ?>'/>
        </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="form-group col-sm-6">
                    <div class="custom-control custom-checkbox">
                        <label><?php echo e(__('members.type')); ?></label>
                        <select  class="form-control <?php echo e($errors->has('role') ? 'is-invalid' : ''); ?>" name="type_id">
                            <option selected disabled value=""><?php echo e(__('members.select')); ?></option>
                            <?php $__currentLoopData = $types; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                         <option <?php if($member ?? ''  && $member->id): ?> <?php if($member->type_id == $row->id): ?> selected <?php endif; ?> <?php endif; ?>  value="<?php echo e($row->id); ?>"><?php echo e(typename($row->id)); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                          </select>
                        </div>
                </div>
          
        </div>
         </div>
         <div id="consult" class="col-12"  <?php if($member ?? ''  && $member->id): ?>  <?php if( $member->role == 'consult'): ?> style="display:block" <?php else: ?> style="display:none" <?php endif; ?> <?php else: ?> style="display:none" <?php endif; ?>>
        <div class="row">
            
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('bank_acc', getCurrentLocale()) ?? __('members.bank_acc')); ?> </label>
            <input type="text" class="form-control <?php echo e($errors->has('bank_acc') ? 'is-invalid' : ''); ?>" name="bank_acc" placeholder="<?php echo e(meta('bank_acc', getCurrentLocale()) ?? __('members.bank_acc')); ?>" value='<?php echo e(old("bank_acc", $member->bank_acc ?? "")); ?>'/>
        </div>
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('iban', getCurrentLocale()) ?? __('members.iban')); ?> </label>
            <input type="text" class="form-control <?php echo e($errors->has('iban') ? 'is-invalid' : ''); ?>" name="iban" placeholder="<?php echo e(meta('iban', getCurrentLocale()) ?? __('members.iban')); ?>" value='<?php echo e(old("iban", $member->iban ?? "")); ?>'/>
        </div>
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('bank', getCurrentLocale()) ?? __('members.bank')); ?> </label>
            <input type="text" class="form-control <?php echo e($errors->has('bank') ? 'is-invalid' : ''); ?>" name="bank" placeholder="<?php echo e(meta('bank', getCurrentLocale()) ?? __('members.bank')); ?>" value='<?php echo e(old("bank", $member->bank ?? "")); ?>'/>
        </div>
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('cost', getCurrentLocale()) ?? __('members.cost')); ?> </label>
            <input type="number" class="form-control <?php echo e($errors->has('cost') ? 'is-invalid' : ''); ?>" name="cost" placeholder="<?php echo e(meta('cost', getCurrentLocale()) ?? __('members.cost')); ?>" value='<?php echo e(old("cost", $member->cost ?? "")); ?>'/>
        </div>
        <?php if($member ?? ''  && $member->id): ?>
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('wallet', getCurrentLocale()) ?? __('members.wallet')); ?> </label>
            <input disabled class="form-control" placeholder="<?php echo e(meta('wallet', getCurrentLocale()) ?? __('members.wallet')); ?>" value='<?php echo e(old("wallet", $member->wallet ?? "")); ?>'/>
        </div>
        <?php endif; ?>
        
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('country', getCurrentLocale()) ?? __('members.country')); ?> </label>
            <select  class="form-control <?php echo e($errors->has('country_id') ? 'is-invalid' : ''); ?>" name="country_id">
                <option disabled selected><?php echo e(__('members.select')); ?></option>
                <?php $__currentLoopData = $countries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                         <option <?php if($member ?? ''  && $member->id): ?> <?php if($member->country_id == $row->id): ?> selected <?php endif; ?> <?php endif; ?>  value="<?php echo e($row->id); ?>"><?php echo e(countryname($row->id)); ?></option>
                         <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                          </select>
                        </div>
        
         <div class="form-group col-sm-6">
                    <div class="custom-control custom-checkbox">
                        <label><?php echo e(__('members.gender')); ?></label>
                        <select  class="form-control <?php echo e($errors->has('gender') ? 'is-invalid' : ''); ?>" name="gender">
                            <option selected disabled value=""><?php echo e(__('members.select')); ?></option>
                           <option <?php if($member ?? ''  && $member->id): ?> <?php if($member->gender == '1'): ?> selected <?php endif; ?> <?php endif; ?>  value="1"><?php echo e(__('members.male')); ?></option>
                         <option <?php if($member ?? ''  && $member->id): ?> <?php if($member->gender == '0'): ?> selected <?php endif; ?> <?php endif; ?>  value="0"><?php echo e(__('members.female')); ?></option>
                         
                          </select>
                        </div>
                </div>
                
                 <div class="form-group col-sm-6">
                    <div class="custom-control custom-checkbox">
                        <label><?php echo e(__('members.category')); ?></label>
                        <select  class="form-control <?php echo e($errors->has('category_id') ? 'is-invalid' : ''); ?>" name="category_id">
                            <option selected disabled value=""><?php echo e(__('members.select')); ?></option>
                            <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                         <option <?php if($member ?? ''  && $member->id): ?> <?php if($member->category_id == $row->id): ?> selected <?php endif; ?> <?php endif; ?>  value="<?php echo e($row->id); ?>"><?php echo e(categoryname($row->id)); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                          </select>
                        </div>
                </div>
                
               
        
              <div class="col-12">
        <div class="row" id="experiences">
            <div class="col-12">
                <h5><?php echo e(__('members.experiences')); ?></h5>
            </div>
             <?php if($member ?? ''  && $member->id): ?>
             <div class="col-12">
            <?php $__currentLoopData = $experiences; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="row">
            
          <input type="hidden"  name="experience[<?php echo e($key); ?>][id]"value="<?php echo e($row->id); ?>">
          <input type="hidden"  name="experiences[]"value="<?php echo e($row->id); ?>">
           <?php $__currentLoopData = languages(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $language): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="form-group col-lg-5">
            <label>الخبرات <?php echo e($language->local); ?></label>
            <input type="text" class="form-control" name="experience[<?php echo e($key); ?>][name_<?php echo e($language->local); ?>]" placeholder="الخبرات <?php echo e($language->local); ?>" value="<?php echo e(experincenamelang($row->id,$language->id)); ?>" />
            
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        
        
        <div class="form-group col-lg-2" style="font-size: 30px;margin-top:35px;">
    	<i class="fas fa-times-circle" onclick="remove(this)"></i></div>
    	<div class="col-lg-12">
                <div class="form-group">
                    <div class="input_img">

                        <img src="<?php echo e(asset($row->image)); ?>">
                       
                        <div class="icons">
                           
                            <a href="<?php echo e(asset($row->image)); ?>" class="link" data-fancybox="">
                                <i class="far fa-eye text-warning"></i>
                            </a>
                            <a href="#0" class="edit_btn">
                                <i class="fas fa-pencil-alt text-info"></i>
                            </a>
                        </div>
                    </div>
                    <div class="box">
                        <div class="js--image-preview"></div>
                        <div class="upload-options">
                            <label>
                            <input type="file" name="image" class="image-upload" />
                          </label>
                        </div>
                    </div>
                </div>
            </div>
    	</div>
        
        
             
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
        <?php endif; ?>
        </div>
        </div>
          <div class="col-12">
              <a style="cursor: pointer;" <?php if($member ?? ''  && $member->id): ?>  data-id="<?php echo e(count($experiences)); ?>" <?php else: ?> data-id="0" <?php endif; ?>   onclick="addexperience(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("members.addexperience")); ?></a>
       
          </div>
         <div class="col-12">
        <div class="row" id="certifications">
             <div class="col-12">
                <h5><?php echo e(__('members.certifications')); ?></h5>
            </div>
               <?php if($member ?? ''  && $member->id): ?>
               <div class="col-12">
            <?php $__currentLoopData = $certifications; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="row">
         
          <input type="hidden"  name="certification[<?php echo e($key); ?>][id]"value="<?php echo e($row->id); ?>">
          <input type="hidden"  name="certifications[]"value="<?php echo e($row->id); ?>">
        <?php $__currentLoopData = languages(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $language): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="form-group col-lg-5">
            <label>الشهادات <?php echo e($language->local); ?></label>
            <input type="text" class="form-control" name="certification[<?php echo e($key); ?>][name_<?php echo e($language->local); ?>]" placeholder="الشهادات <?php echo e($row->local); ?>" value="<?php echo e(certificationnamelang($row->id,$language->id)); ?>" />
            
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        
        
        <div class="form-group col-lg-2" style="font-size: 30px;margin-top:35px;">
    	<i class="fas fa-times-circle" onclick="remove(this)"></i></div>
    	
    	 <div class="col-lg-12">
                <div class="form-group">
                    <div class="input_img">
                       
                        <img src="<?php echo e(asset($row->image)); ?>">
                        
                        <div class="icons">
                            
                            <a href="<?php echo e(asset($row->image)); ?>" class="link" data-fancybox="">
                                <i class="far fa-eye text-warning"></i>
                            </a>
                            <a href="#0" class="edit_btn">
                                <i class="fas fa-pencil-alt text-info"></i>
                            </a>
                        </div>
                    </div>
                    <div class="box">
                        <div class="js--image-preview"></div>
                        <div class="upload-options">
                            <label>
                            <input type="file" name="image" class="image-upload" />
                          </label>
                        </div>
                    </div>
                </div>
            </div>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
        <?php endif; ?>
        </div>
        </div>
         <div class="col-12">
                <a style="cursor: pointer;" <?php if($member ?? ''  && $member->id): ?>  data-id="<?php echo e(count($certifications)); ?>" <?php else: ?> data-id="0" <?php endif; ?>   onclick="addcertification(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("members.addcertification")); ?></a>
       
          </div>
        
        </div>
         </div>
           </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");
        })
    </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('/')); ?>",
            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/spne/public_html/resources/views/admin/members/form.blade.php ENDPATH**/ ?>