<?php $__env->startSection('title','تسجيل شركة جديدة'); ?>
<?php $__env->startSection('content'); ?>
<div class="auth-inner my-2">
    <!-- Register basic -->
    <div class="card mb-0">
      <div class="card-body">
        <a href="#" class="brand-logo">
            <img src="<?php echo e(asset('app-assets/images/logo.png')); ?>" alt="logo" class="logo-large" style="width: 40%;heigh: 40%;">

        </a>
        <center>
        <h4 class="card-title mb-1">إنشاء شركة جديدة</h4>
        </center>
        <?php if(session('error')): ?>
        <div class="alert alert-danger">
            <button class="close" data-dismiss="alert" aria-b="Close">×</button>
            <?php echo e(session('error')); ?>

        </div>
         <?php endif; ?>
        <form class="auth-register-3" action="<?php echo e(route('client.register.company')); ?>" method="POST" id="registerForm">
            <?php echo csrf_field(); ?>
            
            <div class="mb-1">
              <b for="" class="form-label">اسم الشركة</b>
              <input  type="text" value="<?php echo e(old('company_name')); ?>" class="form-control" placeholder="اسم الشركة"  name="company_name" />
            </div>

          <div class="mb-1">
            <b for="" class="form-label">اسم مدير الشركة</b>
            <input  type="text" value="<?php echo e(old('name')); ?>" class="form-control" placeholder="اسم مدير النظام"  name="name" />
          </div>

          
            <div class="mb-1">
                <b for="" class="form-label"> رقم الهاتف</b>
            <input value="<?php echo e(old('email')); ?>"  type="text" class="form-control" name="email"  placeholder=" رقم الهاتف"/>
                                                
                </div>
                <div class="mb-1">
                    <b for="" class="form-label"> كلمة المرور </b>
                <input value="<?php echo e(old('password')); ?>"  type="password" class="form-control" name="password" placeholder="كلمة المرور "/>
                                                    
                    </div>

                <br>
          <button class="btn btn-primary w-100" tabindex="5" id="rgbtn">  تسجيل</button>
        </form>

        <p class="text-center mt-2">
          <span>هل لديك حساب  ؟</span>
          <a href="<?php echo e(route('client.login')); ?>">
            <span>دخول</span>
          </a>
        </p>
      </div>
    </div>
    <!-- /Register basic -->
  </div>  
</div>  
<?php $__env->stopSection(); ?>


<?php $__env->startSection('script'); ?>
<script src="<?php echo e(asset('app-assets/js/sweetalert.min.js')); ?>"></script>

<script>
 $(function () {
'use  strict';

var pageLoginForm = $('.auth-register-3');

// jQuery Validation
// --------------------------------------------------------------------
if (pageLoginForm.length) {
  pageLoginForm.validate({
    /*
    * ? To enable validation onkeyup
    onkeyup: function (element) {
      $(element).valid();
    },*/
    /*
    * ? To enable validation on focusout
    onfocusout: function (element) {
      $(element).valid();
    }, */
    rules: {
      'name': {
        required: true,
      },
      'company_name': {
        required: true,
      },
      // 'phone_number': {
      //   required: true,
      //   minlength: 8,
      //   maxlength: 15,


      // },
      'email': {
        // required: true,
        // email: true
        required: true,
        minlength: 8,
        maxlength: 15,
      },
        'password': {
            required: true,
            minlength: 6
        }
    }
  });
}
});


   
$("#registerForm").on('submit',(function(e) {

e.preventDefault();

$.ajax({

url: "<?php echo e(route('client.register.company')); ?>",

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")});}
    $('#rgbtn').text('... جاري المعالجة').prop('disabled', true)
},
success: function(response) {


swal({

title: "تم تسجيل شركتك بنجاح", 
text: "جاري تحويلك إلي لوحه التحكم",

type: "success",
 showCancelButton: false,
showConfirmButton: false,
closeOnConfirm: false
});

setTimeout(function() {
    location.reload();
    }, 2000);
    $('#rgbtn').text('دخول').prop('disabled', false)

},

error: function(response){
      $.each(response.responseJSON.errors, function (key, item) 
      {
         toastr.error(item)
      });
      $('#rgbtn').text('دخول').prop('disabled', false)

},


});

}));

</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('client.layouts.app-login', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/barasys/public_html/resources/views/client/auth/register.blade.php ENDPATH**/ ?>