242 lines
8.6 KiB
PHP
242 lines
8.6 KiB
PHP
|
<main class="common_margin" id="main">
|
||
|
<div class="main-wrap">
|
||
|
<div class="dashboard-cover">
|
||
|
<div class="subject_r">
|
||
|
<div class="subsec_sec">
|
||
|
<div class="subject_r">
|
||
|
<div class="subject_lsec">
|
||
|
<div class="common-heading">
|
||
|
<h2><?php echo $title;?></h2>
|
||
|
</div>
|
||
|
|
||
|
<?php
|
||
|
$name=''; $eid=''; $rid=''; $status='';
|
||
|
if(isset($details) && !empty($details))
|
||
|
{
|
||
|
$name = $details[0]['admin_name'];
|
||
|
$eid = $details[0]['email'];
|
||
|
$rid = $details[0]['admin_role_ids'];
|
||
|
$status = $details[0]['status'];
|
||
|
}
|
||
|
?>
|
||
|
|
||
|
<form action='<?php echo base_url().'add-edit-user/'.$idVal;?>' id="addEditUserForm" method="post">
|
||
|
<input type='hidden' name='id' id='id' value='<?php echo $idVal;?>' />
|
||
|
<div class="subject_lformarea role_formarea">
|
||
|
<div class="form-group">
|
||
|
<label for="">Full Name<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<input type="text" name="admin_name" id="admin_name" value='<?php echo $name;?>' class="form-control" >
|
||
|
<label style="display:none" class="form_err" id='admin_name_error'></label>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label for="">Email ID<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<input type="email" name="email" id="email" value='<?php echo $eid;?>' class="form-control">
|
||
|
<label style="display:none" class="form_err" id='email_error'></label>
|
||
|
</div>
|
||
|
|
||
|
<?php if($idVal == 0){?>
|
||
|
<div class="form-group">
|
||
|
<label for="">Password<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<div class="password-wrp">
|
||
|
<input type="password" name="password" id="password" class="form-control paswd" >
|
||
|
<span class="passwrd-icon icon-y"><i class="far fa-eye"></i></span>
|
||
|
</div>
|
||
|
<label style="display:none" class="form_err" id='password_error'></label>
|
||
|
</div>
|
||
|
|
||
|
<div class="form-group">
|
||
|
<label for="">Confirm Password<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<div class="password-wrp">
|
||
|
<input type="password" id="confirm-password" name="confirm_password" class=" form-control password_hide_c" >
|
||
|
<span class="con-pass icon-y"><i class="far fa-eye"></i></span>
|
||
|
</div>
|
||
|
<label style="display:none" class="form_err" id='confirm-password_error'></label>
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
|
||
|
<div class="form-group">
|
||
|
<label for="">User Role<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="admin_role_ids" id="admin_role_ids" class="form-control">
|
||
|
<option value="">Choose Role</option>
|
||
|
<?php
|
||
|
if(isset($roles) && !empty($roles))
|
||
|
{
|
||
|
foreach($roles as $rs)
|
||
|
{
|
||
|
?>
|
||
|
<option value="<?php echo $rs['id'];?>" <?php if($rs['id'] == $rid){?>selected<?php } ?>><?php echo $rs['role_name'];?></option>
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
?>
|
||
|
</select>
|
||
|
<label style="display:none" class="form_err" id='admin_role_ids_error'></label>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label for="">Status<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="status" id="status" class="form-control">
|
||
|
<option value="">Choose Status</option>
|
||
|
<option value="Active" <?php if($status == 'Active'){?>selected<?php } ?>>Active</option>
|
||
|
<option value="Inactive" <?php if($status == 'Inactive'){?>selected<?php } ?>>Inactive</option>
|
||
|
</select>
|
||
|
<label style="display:none" class="form_err" id='status_error'></label>
|
||
|
</div>
|
||
|
</div>
|
||
|
</form>
|
||
|
<button type="button" type='button' onclick="validate_user_form()" class="subject_addbtn">Save</button>
|
||
|
|
||
|
|
||
|
<a href='<?php echo base_url()."users";?>'>
|
||
|
<button class="btn btn-dark btn-sm">Back</button>
|
||
|
</a>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</main>
|
||
|
<!--End right-top side-->
|
||
|
</div>
|
||
|
<!-- <script src="<?php echo base_url(); ?>assets-bustracking/js/jquery-3.2.1.slim.min.js"></script> -->
|
||
|
<script src="<?php echo base_url(); ?>assets-bustracking/js/jquery-3.4.1.min.js" ></script>
|
||
|
<script src="<?php echo base_url(); ?>assets-bustracking/js/popper.min.js"></script>
|
||
|
<script src="<?php echo base_url(); ?>assets-bustracking/js/bootstrap.min.js"></script>
|
||
|
<script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
|
||
|
<script defer src="<?php echo base_url(); ?>assets-bustracking/js/all.js"></script>
|
||
|
<script defer src="<?php echo base_url(); ?>assets-bustracking/js/main.js"></script>
|
||
|
<script src="<?php echo base_url(); ?>assets-bustracking/owl-carousel/js/owl.carousel.min.js"></script>
|
||
|
<script>
|
||
|
$(document).ready(function(){
|
||
|
$('.user-drpdown').click(function(){
|
||
|
$('.drpdown-items').toggle();
|
||
|
});
|
||
|
});
|
||
|
//table js
|
||
|
$('#tbl').DataTable( {
|
||
|
"lengthMenu": [[5,10, 25, 50, -1], [5,10, 25, 50, "All"]]
|
||
|
} );
|
||
|
//table js end
|
||
|
</script>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
var jsAddOrEdit = '<?php echo $idVal;?>';
|
||
|
$(document).ready(function(){
|
||
|
$(document).on('keypress', function(e){
|
||
|
if(e.which==13)
|
||
|
{
|
||
|
validate_user_form();
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
function hide_all_user_errors()
|
||
|
{
|
||
|
$('#admin_name_error').hide();
|
||
|
$('#email_error').hide();
|
||
|
|
||
|
if(jsAddOrEdit == 0){
|
||
|
$('#password_error').hide();
|
||
|
$('#confirm-password_error').hide();
|
||
|
}
|
||
|
|
||
|
$('#admin_role_ids_error').hide();
|
||
|
$('#status_error').hide();
|
||
|
}
|
||
|
|
||
|
function validate_user_form()
|
||
|
{
|
||
|
hide_all_user_errors();
|
||
|
|
||
|
var errArr = new Array();
|
||
|
|
||
|
var admin_name = $('#admin_name').val().trim();
|
||
|
var $regexname=/^([a-zA-Z]{3,16})$/;
|
||
|
|
||
|
if(admin_name=='')
|
||
|
errArr.push('admin_name_Sep@Str_Please enter the full name.');
|
||
|
|
||
|
if (!admin_name.match($regexname))
|
||
|
errArr.push('admin_name_Sep@Str_Please enter alpha characters only.');
|
||
|
|
||
|
var email = $('#email').val().trim();
|
||
|
|
||
|
if(email=='')
|
||
|
errArr.push('email_Sep@Str_Please enter the Email Id.');
|
||
|
else
|
||
|
{
|
||
|
var regEmailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
|
||
|
if(!regEmailReg.test($('#email').val()))
|
||
|
errArr.push('email_Sep@Str_Please enter a valid email address.');
|
||
|
else
|
||
|
{
|
||
|
var urltogo = '<?php echo base_url();?>'+'BustrackingAdmin/ajaxCheckIsUserEmailAlreadyExists';
|
||
|
var reqdData = 'email='+$('#email').val()+'&id='+$('#id').val();
|
||
|
|
||
|
$.ajax({
|
||
|
type: "POST",
|
||
|
url: urltogo,
|
||
|
data: reqdData,
|
||
|
async: false,
|
||
|
success: function(result)
|
||
|
{
|
||
|
result = result.trim();
|
||
|
//alert(result);
|
||
|
if(result == 'Duplicate Email')
|
||
|
errArr.push('email_Sep@Str_This email id already exists.');
|
||
|
else if(result == 'Insufficient Data')
|
||
|
errArr.push('email_Sep@Str_Insufficient Data Sent. Please check again.');
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if(jsAddOrEdit == 0)
|
||
|
{
|
||
|
var password = $('#password').val().trim();
|
||
|
if(password=='')
|
||
|
errArr.push('password_Sep@Str_Please enter the password.');
|
||
|
else{
|
||
|
var regPwdReg = /(?=.*[a-zA-Z0-9])(?=.*?\W).{6,}/;
|
||
|
if(!regPwdReg.test($('#password').val()))
|
||
|
errArr.push('password_Sep@Str_Password should be minimum 6 characters and should have atleast one special character.');
|
||
|
}
|
||
|
|
||
|
var confirm_password = $('#confirm-password').val().trim();
|
||
|
if(confirm_password=='')
|
||
|
errArr.push('confirm-password_Sep@Str_Please confirm the password.');
|
||
|
|
||
|
if($('#password').val()!='' && $('#confirm-password').val()!='' && ($('#password').val() != $('#confirm-password').val()) )
|
||
|
errArr.push('confirm-password_Sep@Str_Password & confirm Password does not match.');
|
||
|
}
|
||
|
|
||
|
var role_id = $('#admin_role_ids').val().trim();
|
||
|
if(role_id=='')
|
||
|
errArr.push('admin_role_ids_Sep@Str_Please select the user role.');
|
||
|
|
||
|
var status = $('#status').val().trim();
|
||
|
if(status=='')
|
||
|
errArr.push('status_Sep@Str_Please select the user status.');
|
||
|
|
||
|
//var errArr = new Array();
|
||
|
if(errArr.length>0)
|
||
|
{
|
||
|
for(i=0; i<errArr.length; i++)
|
||
|
{
|
||
|
var resArr = errArr[i].split("_Sep@Str_");
|
||
|
$("#"+resArr[0]+"_error").html(resArr[1]);;
|
||
|
$("#"+resArr[0]+"_error").show();
|
||
|
}
|
||
|
var xxxVal = errArr[0].split('_Sep@Str_');
|
||
|
$('#'+xxxVal[0]).focus();
|
||
|
return false;
|
||
|
}
|
||
|
else{
|
||
|
$('#addEditUserForm').submit();
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|