<?php $__env->startSection('title','تعديل مستخدم'); ?>
<?php $__env->startSection('content'); ?>
  <!-- BEGIN: Content-->
  <div class="app-content content ">
    <div class="content-overlay"></div>
    <div class="header-navbar-shadow"></div>
    <div class="content-wrapper container-xxl p-0">
      <div class="content-header row">
        <div class="content-header-left col-md-9 col-12 mb-2">
          <div class="row breadcrumbs-top">
            <div class="col-12">
              <h2 class="content-header-title float-start mb-0">تعديل مستخدم</h2>
              <div class="breadcrumb-wrapper">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="<?php echo e(route('client.home')); ?>">لوحة التحكم</a>
                  </li>
                  <li class="breadcrumb-item"><a href="<?php echo e(route('client.users.index')); ?>">المستخدمين</a>
                  </li>
                  <li class="breadcrumb-item active"><?php echo e($client->name); ?>

                </li>
                  <li class="breadcrumb-item active">تعديل
                  </li>
                </ol>
              </div>
            </div>
          </div>
        </div>
        <div class="content-header-right text-md-end col-md-3 col-12 d-md-block d-none">
          <div class="mb-1 breadcrumb-right">
            <div class="dropdown">
                <a  href="<?php echo e(route('client.users.index')); ?>">
                    <button class="btn-icon btn btn-primary" type="button"><i data-feather='eye'> </i></button>
                </a>
            </div>
          </div>
        </div>
      </div>
      <div class="content-body">
        <!-- Basic Horizontal form layout section start -->
        <!-- Basic multiple Column Form section start -->
<section id="multiple-column-form">
<div class="row">
  <div class="col-12">
    <div class="card">
      <div class="card-header">
        <h4 class="card-title">البيانات الاساسية</h4>
      </div>
      <div class="card-body">
                    <form  id="addForm" method="post">
                        <?php echo e(csrf_field()); ?>

                        
                        <input  type="hidden" name="id" value="<?php echo e($client->id); ?>">
                        <div class="row ">
                            <div class="col-md-4 col-12">
                                <b> اسم المستخدم </b>
                                <input class="form-control"
                                        name="name" type="text" placeholder="اسم المستخدم" value="<?php echo e($client->name); ?>">
                            </div>
                            <div class="col-md-4 col-12" >
                                <div class="mb-1">
                                <b> رقم الموبايل  </b>
                                <input class="form-control" name="email" type="text" placeholder="رقم الموبايل" value="<?php echo e($client->email); ?>">
                                </div>
                            </div>
                            <div class="col-md-4 col-12" >
                                  <div class="mb-1">
                                <b> كلمة المرور  </b>
                                <input class="form-control" 
                                       name="password"  type="password" placeholder="كلمة المرور">
                                  </div>
                            </div>
                            <div class="col-md-4 col-12" >
                                <div class="mb-1">
                                <b> تأكيد كلمة المرور  </b>
                                <input class="form-control" 
                                       name="confirm-password" type="password" placeholder="تأكيد كلمة المرور">
                                </div>
                            </div>
                            <div class="col-md-4 col-12" >
                                <b class="form-b"> الصلاحية </b>
                                <select name="role_name[]" id="select-beast" class="form-control">
                                <option value="">إختر الصلاحية</option> 
                                <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($role->id); ?>"<?php if(in_array($role->id,$clientRole)): ?>selected <?php endif; ?>><?php echo e($role->name); ?></option> 
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                              </div>
                            <div class="col-md-4 col-12" >
                                <b class="form-b"> الحالة </b>
                                <select name="Status" id="select-beast" class="form-control">
                                    <option value="active"
                                            <?php if($client->Status == 'active'): ?>
                                            selected
                                        <?php endif; ?>
                                    > مفعل
                                    </option>
    
                                    <option value="blocked"
                                            <?php if($client->Status == 'blocked'): ?>
                                            selected
                                        <?php endif; ?>
                                    > معطل
                                    </option>
    
                                </select>
                            </div>
                        </div>
                        <div class="col-12" align="center">
                            <br>
                              <button type="submit" class="btn btn-success me-1">تعديل</button>
                              <button type="button" class="btn btn-outline-danger" onclick="window.history.back()">رجوع</button>
                            </div>
                          </div>
                    </form>
                </div>
            </div>
          </div>
        </div>
        </section>
        <!-- Basic Floating Label Form section end -->
        
              </div>
            </div>
          </div>
          <!-- END: Content-->
        <?php $__env->stopSection(); ?>
        <?php $__env->startSection('script'); ?>
        
            <script>
                
        
                
                var selectForm = $('#addForm');
        
        if (selectForm) {
            selectForm.validate({
        
                rules: {
              'name': {
                required: true,
              },
              'email': {
                required: true,
                // email:true
              },
              'password': {
                required: true,
                minlength: 6
              },
              'confirm-password': {
                required: true,
                minlength: 6
                
              },
              'role_name[]': {
                required: true,
              }
            
            }
          });
        }
        
        
        $("#addForm").on('submit',(function(e) {
        
        e.preventDefault();
        
        $.ajax({
        
          url: "<?php echo e(route('client.users.update')); ?>",
        
          type: "POST",
        
          data:  new FormData(this),
        
          dataType:  'json',
        
          contentType: false,
        
          cache: false,
        
          processData:false,
        
          beforeSend : function (){var ifConnected = window.navigator.onLine;if (!ifConnected) {toastr.info("يتم الآن إعادة الإتصال","لا يوجد إتصال بالإنترنت",{positionClass: "toast-top-right",tapToDismiss: !1,timeOut: 2e3,rtl: $("html").attr("data-textdirection")});}},
        
        
          success: function(response) {
        
            if(response.status){
        
              toastr.success("",response.message,{
                    positionClass: "toast-top-right",
                    tapToDismiss: !1,
                    timeOut: 2e3,
                    rtl: $("html").attr("data-textdirection")
                    });      
        
            } 
        
          },
          error: function(response){
                  $.each(response.responseJSON.errors, function (key, item) 
                  {
                    toastr.error("",item,{
                    positionClass: "toast-top-right",
                    tapToDismiss: !1,
                    timeOut: 2e3,
                    rtl: $("html").attr("data-textdirection")
                    });
        
                  });
          },
        
         });
        
        }));
        
                </script>
        <?php $__env->stopSection(); ?>
        <?php $__env->startSection('style'); ?>
        
        <?php $__env->stopSection(); ?>
        
<?php echo $__env->make('client.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH E:\xampp\htdocs\sales\resources\views/client/clients/edit.blade.php ENDPATH**/ ?>