<?php $__env->startSection('content_header'); ?>
    <h1>User</h1>
<?php $__env->stopSection(); ?>
<script src="//code.jquery.com/jquery.js"></script>
<?php $__env->startSection('content'); ?>
<?php echo notifyCss(); ?>
<?php echo notifyJs(); ?> 
<?php if($errors->any()): ?>
    <div class="alert alert-danger">
        <ul>
            <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <li><?php echo e($error); ?></li>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </ul>
    </div>
<?php endif; ?>
<?php if(session('status')): ?>
    <div class="alert alert-success">
        <?php echo e(session('status')); ?>

    </div>
<?php endif; ?>
<?php echo $__env->make('notify::messages', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<div class="row">
    <!--row starts-->
    <div class="col-md-12">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">
                   User Registration
                </h3>
            </div>
            <div class="panel-body">
                <form class="form-horizontal" action="<?php echo e(url('userpost')); ?>" method="post" id="user" onsubmit="return validation();">
                    <!-- CSRF Token -->
                    <input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
                    <!-- Name input-->
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="name">Full Name<span style="color: red;">*</span></label>
                        <div class="col-md-6" >
                            <input id="name" name="name" type="text" maxlength="100" placeholder="Enter the full name" class="form-control" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="name">Email<span style="color: red;">*</span></label>
                        <div class="col-md-6">
                            <input id="email" name="email" type="text" placeholder="Enter the email" class="form-control" maxlength="250" onchange="validateEmail(this,'Email');" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="name">Password<span style="color: red;">*</span></label>
                        <div class="col-md-6">
                            <input id="password" name="password" type="password" placeholder="Enter the password" class="form-control" maxlength="20" onchange="password_check();" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="name">Retype Password<span style="color: red;">*</span></label>
                        <div class="col-md-6">
                            <input id="password_confirmation" name="password_confirmation" type="password" placeholder="Retype password" class="form-control" maxlength="20" onchange="password_check();" required>
                        </div>
                    </div>
                    <div class="form-position">
                        <div class="col-md-5 text-right">
                            <button type="submit" class="btn btn-responsive btn-primary btn-sm" id="btn" >Submit</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="panel panel-body">
            <table class="table table-bordered" id="users_table">
                <thead>
                    <tr>
                        <th>Id</th>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Seat</th>
                        <th>Role</th>
                        <th>Actions</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
    <!--md-12 ends-->
</div> 
<script>
    ////////////////email checking/////////////////
    function validateEmail(emailField, fieldname)
    {
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

        if (reg.test(emailField.value) == false) 
        {
            alert("Please enter correct email ID");
            emailField.value="";
            emailField.focus();
            return false;
        }
    }
    ///////////////////////////////////////////////////////////////////
    //////password check////////////////////////////////
    function password_check()
    {
      var pwd;
      var cpwd;
      pwd = document.getElementById("password").value;
      cpwd = document.getElementById("password_confirmation").value;
      if(pwd && cpwd)
      {
        if(pwd!=cpwd)
        {
            alert("Password and Confirm Password should be same.")
            document.getElementById("password_confirmation").value="";
            document.getElementById("password").value="";
            document.getElementById("password").focus();
            return false;
        }
      }
      return true;
    }
   /////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////
    $(function() {
        $('#users_table').DataTable({
            processing: true,
            serverSide: true,
            ajax: '<?php echo url('userpostdata'); ?>',
            columns: [
                { data: 'id', name: 'id' },
                { data: 'name', name: 'name' },
                { data: 'email', name: 'email' },
                { data: 'seat_name', name: 'seat_name' },
                { data: 'role_name', name: 'role_name' },
                { data: 'action', name: 'action' }
            ]
        });
    });

    function validation()
    {
        if(document.getElementById('email').value=="")
        {
            alert(" Please Enter the Email");
            document.getElementById('email').focus();
            return false;
        }
        if(document.getElementById('name').value=="")
        {
            alert(" Please Enter the Full Name");
            document.getElementById('name').focus();
            return false;
        }
        if(document.getElementById('password').value=="")
        {
            alert(" Please Enter the Password");
            document.getElementById('password').focus();
            return false;
        }
        if(document.getElementById('password_confirmation').value=="")
        {
            alert(" Please Retype the Password");
            document.getElementById('password_confirmation').focus();
            return false;
        }
        document.getElementById("btn").disabled='true';         
        return true;
    }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('adminlte::page', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>