240 lines
13 KiB
PHP
Executable File
240 lines
13 KiB
PHP
Executable File
<div class="content-page">
|
||
<div class="content">
|
||
<!-- Start Content-->
|
||
<div class="container-fluid">
|
||
<!-- start page title -->
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="page-title-box page-title-box-alt">
|
||
<h4 class="page-title ">Add User Details</h4>
|
||
<a class="btn btn-secondary" href="<?php echo base_url(); ?>userListing"><span class="bold">Back</span></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- end page title -->
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="p-2">
|
||
<form role="form" id="addUser" action="<?php echo base_url() ?>addNewUser" method="post">
|
||
<div class="box-body">
|
||
<!-- Supplier Information -->
|
||
<div class="col-md-12" style="margin-bottom: 27px;">
|
||
<div class="form-row">
|
||
<div class=" col-md-3">
|
||
<label class="col-form-label" for="EmployeeID">Employee ID</label>
|
||
<select class="form-control required select" id="EmpList" name="EmpList" required>
|
||
<option value="">Select Emp ID</option>
|
||
<?php
|
||
if (!empty($EmpList)) {
|
||
foreach ($EmpList as $EID) {
|
||
$EmpID = $EID->EmpID;
|
||
// if ($_POST['EmpList'] == $EmpID) {
|
||
// echo "<option value=\"".$EmpID."\" selected=\"selected\">".$EmpID.' - '. $EID->FirstName."</option>";
|
||
// } else{
|
||
echo "<option value=\"" . $EmpID . "\">" . $EmpID . ' - ' . $EID->FirstName . "</option>";
|
||
// }
|
||
}
|
||
}
|
||
?>
|
||
</select>
|
||
</div>
|
||
<div class="col-md-3">
|
||
<label class="col-form-label" for="FirstName">First Name</label>
|
||
<input type="text" class="form-control required" readonly id="FirstName" name="FirstName" maxlength="128">
|
||
</div>
|
||
|
||
<div class="col-md-3">
|
||
<label class="col-form-label" for="Designation">Designation</label>
|
||
<input type="text" class="form-control required " readonly id="Designation" name="Designation" maxlength="128">
|
||
</div>
|
||
<div class="col-md-3">
|
||
<label for="Emailaddress">Email address</label><span class="badge">*</span>
|
||
<input type="text" class="form-control required " id="MailID" name="MailID" maxlength="128">
|
||
</div>
|
||
</div>
|
||
<div class="form-row" style="margin-top:20px">
|
||
|
||
<div class="col-md-3">
|
||
<label for="ContactNumber">Contact Number</label>
|
||
<input type="text" class="form-control required digits" readonly id="ContactNo" name="ContactNo" minlength="10" maxlength="10">
|
||
</div>
|
||
<div class="col-md-3">
|
||
<label for="Role">Role</label>
|
||
<select class="form-control required" id="role" name="role" required>
|
||
<option value="0">Select Role</option>
|
||
<?php
|
||
if (!empty($roles)) {foreach ($roles as $rl) { ?>
|
||
<option value="<?php echo $rl->roleId ?>"><?php echo $rl->role ?></option>
|
||
<?php } }?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="col-md-3">
|
||
<label for="Password">Password</label>
|
||
<input type="password" class="form-control required" id="password" required name="password" maxlength="10">
|
||
</div>
|
||
<div class="col-md-3">
|
||
<label for="ConfirmPassword">Confirm Password</label>
|
||
<input type="password" class="form-control required equalTo" required id="cpassword" name="cpassword" maxlength="10">
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="col-md-12 text-right">
|
||
<input type="reset" id="reset" class="btn btn-reset" style="background-color: red;color: white; margin-right: 15px;width: 80px;" value="Reset" />
|
||
<input type="submit" onclick="return Validate();" value="Submit" class="btn btn-success">
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<?php
|
||
$listErrors = session()->getFlashdata('listErrors');
|
||
if ($listErrors) {
|
||
?>
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="alert alert-danger alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('listErrors'); ?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<?php } ?>
|
||
|
||
</div>
|
||
<?php
|
||
helper('form');
|
||
$error = session()->getFlashdata('error');
|
||
if ($error) {
|
||
?>
|
||
<div class="alert alert-danger alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('error'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
|
||
<?php
|
||
$success = session()->getFlashdata('success');
|
||
if ($success) {
|
||
?>
|
||
<div class="alert alert-success alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('success'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
<!-- end row -->
|
||
</div>
|
||
</div> <!-- end card -->
|
||
</div><!-- end col -->
|
||
</div>
|
||
<!-- end row -->
|
||
</div> <!-- container -->
|
||
</div> <!-- content -->
|
||
</div>
|
||
|
||
|
||
<!-- <script src="<?php echo base_url(); ?>public/assets/js/addUser.js" type="text/javascript"></script> -->
|
||
<script>
|
||
$(document).ready(function() {
|
||
$('#EmpList').select2();
|
||
|
||
$("#EmpList").change(function() {
|
||
var empID = $(this).val();
|
||
console.log(empID);
|
||
|
||
if (empID) {
|
||
$('#loader').show();
|
||
$.ajax({
|
||
url: "<?php echo base_url() ?>fetchEmployeeDetails",
|
||
type: 'POST',
|
||
data: {
|
||
EmpID: empID
|
||
},
|
||
success: function(data) {
|
||
if (data.success) {
|
||
$("#FirstName").val(data.userInfo[0].FirstName);
|
||
$("#Designation").val(data.userInfo[0].Designation);
|
||
$("#ContactNo").val(data.userInfo[0].ContactNumber);
|
||
$('#loader').hide();
|
||
} else {
|
||
$('#loader').hide();
|
||
alert('Employee not found');
|
||
}
|
||
},
|
||
error: function() {
|
||
$('#loader').hide();
|
||
alert('Failed to fetch employee details');
|
||
}
|
||
});
|
||
} else {
|
||
// Clear fields if no employee ID is selected
|
||
$("#FirstName").val('');
|
||
$("#Designation").val('');
|
||
$("#MailID").val('');
|
||
$("#ContactNo").val('');
|
||
}
|
||
});
|
||
});
|
||
|
||
$('#addPop').click(function() {
|
||
if ($('#distriList option:selected').val() != null) {
|
||
if ($('#distriList option:selected').val() == 0) {} else {
|
||
var tempSelect = $('#distriList option:selected').val();
|
||
var tempText = $('#distriList option:selected').text();
|
||
var o = new Option(tempText, tempSelect);
|
||
var hidval = tempSelect;
|
||
var Selectedval = ''
|
||
if (orgVal != '') {
|
||
Selectedval = orgVal + ':' + hidval;
|
||
} else {
|
||
Selectedval = hidval
|
||
}
|
||
$(o).html(tempText);
|
||
$("#selectDistriList").append(o);
|
||
$('#distriList option:selected').remove();
|
||
$("#distriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
|
||
$("#selectDistriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
|
||
tempSelect = '';
|
||
tempText = '';
|
||
Selectedval = '';
|
||
}
|
||
} else {
|
||
alert("Before add please select any position.");
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<script>
|
||
function Validate() {
|
||
var isValid = true;
|
||
|
||
var fname = document.getElementById('FirstName').value;
|
||
if (!fname) {
|
||
alert('First Name is required');
|
||
isValid = false;
|
||
}
|
||
|
||
var email = document.getElementById('MailID').value;
|
||
var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||
if (!emailPattern.test(email)) {
|
||
alert('Invalid email address');
|
||
isValid = false;
|
||
}
|
||
|
||
var password = document.getElementById('password').value;
|
||
var cpassword = document.getElementById('cpassword').value;
|
||
if (password !== cpassword) {
|
||
alert('Passwords do not match');
|
||
isValid = false;
|
||
}
|
||
|
||
return isValid;
|
||
}
|
||
</script>
|