bbone/application/modules/Employee/views/edit_emp.php

612 lines
24 KiB
PHP

<!-- Body page content -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>/assets/jquery.multi-select.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#people').multiSelect();
});
</script>
<style type="text/css">
.multi-select-container {
display: inline-block;
position: relative;
width: 100%;
}
.multi-select-menu {
position: absolute;
left: 0;
top: 2em;
z-index: 1;
float: left;
min-width: 100%;
background: #fff;
margin: 1em 0;
border: 1px solid #aaa;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
display: none;
}
.multi-select-menuitem {
display: block;
font-size: 0.875em;
padding: 0.6em 1em 0.6em 30px;
white-space: nowrap;
}
.multi-select-menuitem--titled:before {
display: block;
font-weight: bold;
content: attr(data-group-title);
margin: 0 0 0.25em -20px;
}
.multi-select-menuitem--titledsr:before {
display: block;
font-weight: bold;
content: attr(data-group-title);
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.multi-select-menuitem+.multi-select-menuitem {
padding-top: 0;
}
.multi-select-presets {
border-bottom: 1px solid #ddd;
}
.multi-select-menuitem input {
position: absolute;
margin-top: 0.25em;
margin-left: -20px;
}
.multi-select-button {
display: block;
margin-top: 2px;
width: 100%;
max-width: 100% !important;
font-size: 0.875em;
padding: 0.85em 0.6em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: -0.5em;
background-color: #fff;
border: 1px solid #aaa;
cursor: default;
}
.multi-select-button:after {
content: "";
position: absolute;
display: inline-block;
width: 0;
height: 0;
border-style: solid;
border-width: 0.4em 0.4em 0 0.4em;
border-color: #999 transparent transparent transparent;
margin-left: 0.4em;
vertical-align: 0.1em;
right: 5px;
top: 17px;
}
.multi-select-container--open .multi-select-menu {
display: block;
}
.multi-select-container--open .multi-select-button:after {
border-width: 0 0.4em 0.4em 0.4em;
border-color: transparent transparent #999 transparent;
}
.multi-select-container--positioned .multi-select-menu {
/* Avoid border/padding on menu messing with JavaScript width calculation */
box-sizing: border-box;
}
.multi-select-container--positioned .multi-select-menu label {
/* Allow labels to line wrap when menu is artificially narrowed */
white-space: normal;
}
</style>
<div class="">
<div class="page-title">
<div class="title_left">
<h3>Edit Employee</h3>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<!-- <div class="x_title">
<ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
</li>
</ul>
<h6>General Information</h6>
<div class="clearfix"></div>
</div>
<div class="x_content"> -->
<br />
<form id="" data-parsley-validate class="form-horizontal form-label-left" method="post"
action="<?php echo base_url();?>Employee/editEmployees" enctype="multipart/form-data">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>"
value="<?php echo $this->security->get_csrf_hash();?>">
<input type="hidden" name="id" value="<?php echo $editData->id; ?>">
<input type="hidden" name="user_id" value="<?php echo $editData->user_id; ?>">
<div class="x_title">
<h5>Personal Information<a style="color:red;">*</a></h5>
<div class="clearfix"></div>
</div><br />
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Name<a
style="color:red;">*</a> </label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="name" name="name"
value="<?php if(isset($editData)) { echo $editData->name; } ?>" required="required"
class="form-control " onkeypress="validateKeyPress(event)">
</div>
<label class="control-label col-md-1 col-sm-1 " for="email"> Email<a style="color:red;">*</a>
</label>
<div class="col-md-5 col-sm-5 ">
<input id="email" name="email"
value="<?php if(isset($editData)) { echo $editData->email; } ?>" required="required"
class="form-control" type="email"
pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"
oninvalid="setCustomValidity('Enter a Valid E-mail Address.')"
oninput="setCustomValidity('')" onkeyup="check_if_exists(this.id, this.value, this.name)">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="email"> Mobile<a style="color:red;">*</a>
</label>
<div class="col-md-5 col-sm-5 ">
<input id="mobile" name="mobile"
value="<?php if(isset($editData)) { echo $editData->mobile; } ?>"
onkeypress="return matchnum(event)" required="required" class="form-control" type="tel"
pattern="[6-9][0-9]{9}" minlength="10" maxlength="10"
oninvalid="setCustomValidity('cant start with number other than 6,7,8,9 or length must be 10.')"
oninput="setCustomValidity('')" onkeyup="check_if_exists(this.id, this.value, this.name)">
</div>
<label class="control-label col-md-1 col-sm-1 " for="last-name">Department</label>
<div class="col-md-5 col-sm-5 ">
<select id="department" name="department" class="form-control"
placeholder="choose" <?php if(isset($viewData)) { echo "readonly"; } ?>>
<option value="<?php echo $editData->department; ?>">
<?php echo $editData->department; ?></option>
<?php foreach ($departmentData as $key => $value) { ?>
<option value="<?php echo $value->name; ?>"><?php echo $value->name; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="email"> Join Date</label>
<div class="col-md-5 col-sm-5 ">
<input id="j_date" name="j_date"
value="<?php if(isset($editData)) { echo $editData->j_date; } ?>" class="form-control"
type="text" placeholder="DD-MM-YYYY" onkeypress="validateKeyPress(event)"
autocomplete="off">
</div>
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Manager</label>
<div class="col-md-5 col-sm-5 ">
<select id="manager" name="manager" class="form-control">
<?php
if(isset($manager_name[0]->id))
{ foreach ($manager_name as $key => $val) { ?>
<option value="<?php if($val->id !== ''){echo $val->id;}else{echo '';} ?>"><?php if($val->name !== ''){echo $val->name;}else{echo '--select--';} ?></option>
<?php foreach ($manager as $key => $value) { ?>
<?php if ($val->name !== $value->name) { ?>
<option value="<?php echo $value->user_id; ?>"><?php echo $value->name; ?></option>
<?php } }?>
<?php } } else { ?>
<?php foreach ($manager as $key => $value) { ?>
<?php if ($val->name !== $value->name) { ?>
<option value="<?php echo $value->user_id; ?>"><?php echo $value->name; ?></option>
<?php } } } ?>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name">Marital Status</label>
<div class="col-md-5 col-sm-5 ">
<select id="marital_status" name="marital_status" class="form-control"
placeholder="choose" <?php if(isset($viewData)) { echo "readonly"; } ?>>
<option value="<?php echo $editData->marital_status; ?>">
<?php echo ucfirst($editData->marital_status); ?></option>
<?php
if ($editData->marital_status != 'single')
{
echo '<option value="single">Single</option>';
}
if ($editData->marital_status != 'married')
{
echo '<option value="married">Married</option>';
}
if ($editData->marital_status != 'others')
{
echo '<option value="others">Others</option>';
}
?>
</select>
</div>
</div>
</div>
<!-- ----------------------------------------- -->
<div class="x_panel">
<div class="x_title">
<h5>Emergency Contact </h5>
<div class=""></div>
</div><br />
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Name</label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="relation_name" name="relation_name"
value="<?php if(isset($editData)) { echo $editData->relation_name; } ?>"
onkeypress="validateKeyPress(event)" class="form-control ">
</div>
<label class="control-label col-md-1 col-sm-1 " for="email"> Relationship</label>
<div class="col-md-5 col-sm-5 ">
<input id="relationship" name="relationship"
value="<?php if(isset($editData)) { echo $editData->relationship; } ?>" class="form-control"
type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Mobile</label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="relation_mobile" name="relation_mobile"
value="<?php if(isset($editData)) { echo $editData->relation_mobile; } ?>"
class="form-control " onkeypress="return matchnum(event)" class="form-control" type="tel"
pattern="[6-9][0-9]{9}" minlength="10" maxlength="10"
oninvalid="setCustomValidity('cant start with number other than 6,7,8,9 or length must be 10.')"
oninput="setCustomValidity('')">
</div>
<label class="control-label col-md-1 col-sm-1 " for="email"> Home Tel</label>
<div class="col-md-5 col-sm-5 ">
<input id="relation_tel" name="relation_tel"
value="<?php if(isset($editData)) { echo $editData->relation_tel; } ?>"
onkeypress="return matchnum(event)" class="form-control" type="text">
</div>
</div>
</div>
<!-- ------------------------------------------->
<div class="x_panel">
<div class="x_title">
<h5>Address Detail</h5>
<div class=""></div>
</div><br />
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Address</label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="address" name="address"
value="<?php if(isset($editData)) { echo $editData->address; } ?>" class="form-control ">
</div>
<label class="control-label col-md-1 col-sm-1 " for="email"> City</label>
<div class="col-md-5 col-sm-5 ">
<input id="city" name="city" value="<?php if(isset($editData)) { echo $editData->city; } ?>"
class="form-control" type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> State</label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="state" name="state"
value="<?php if(isset($editData)) { echo $editData->state; } ?>" class="form-control ">
</div>
<label class="control-label col-md-1 col-sm-1 " for="email"> Pincode</label>
<div class="col-md-5 col-sm-5 ">
<input id="pincode" name="pincode"
value="<?php if(isset($editData)) { echo $editData->pincode; } ?>"
onkeypress="return matchnum(event)" class="form-control" type="text">
</div>
</div>
</div>
<!-- ----------------------------------------- -->
<div class="x_panel">
<div class="x_title">
<h5>Additional Information</h5>
<div class="clearfix"></div>
</div><br />
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Employee Id</label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="emp_id" name="emp_id"
value="<?php if(isset($editData)) { echo $editData->emp_id; } ?>" class="form-control ">
</div>
<label class="control-label col-md-1 col-sm-1 " for="email"> Salary</label>
<div class="col-md-5 col-sm-5 ">
<input id="salary" name="salary"
value="<?php if(isset($editData)) { echo $editData->salary; } ?>" class="form-control"
type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Comment</label>
<div class="col-md-5 col-sm-5 ">
<input id="comment" name="comment"
value="<?php if(isset($editData)) { echo $editData->comment; } ?>" class="form-control"
type="text">
</div>
<label class="control-label col-md-1 col-sm-1 " for="email"> Gender</label>
<div class="col-md-5 col-sm-5 " style="padding:10px;">
<?php
if ($editData->gender == 'male')
{
echo '<input type="radio" name="gender" value="male" checked/>Male';
echo '&nbsp&nbsp';
echo '<input type="radio" name="gender" value="female" />Female';
}
else
{
echo '<input type="radio" name="gender" value="male"/>Male';
echo '&nbsp&nbsp';
echo '<input type="radio" name="gender" value="female" checked/>Female';
} ?>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Photo Upload</label>
<div class="col-md-5 col-sm-5 ">
<input type="file" id="image" name="image"
value="<?php if(isset($editData->profile_pic)) { echo $editData->profile_pic; } ?>"
class="form-control " onchange="validateFile(this)">
<img class="profilepic__image" style="width: 50%; display: block;padding:10px;"
src="<?php echo base_url();?>/assets/uploads/<?php echo $editData->profile_pic ?>"
alt="Avatar" title="Change the avatar">
</div>
</div>
</div>
<!-- ----------------------------------------- -->
<div class="x_panel">
<div class="x_title">
<h5>Permissions</h5>
<div class=""></div>
</div><br />
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="last-name">Modules List</label>
<div class="col-md-5 col-sm-5 ">
<select id="people" name="group_id[]" class="form-control select2_multiple" multiple>
<?php
$modulesArray = [];
foreach ($get_members_list as $object) {
if (isset($object->group_name)) {
$modulesArray[] = $object->group_name;
}
}
foreach ($get_group_list as $key => $data) { ?>
<?php if(in_array($data->group_name, $modulesArray)) { ?>
<option value="<?php echo $data->id; ?>" selected> <?php echo $data->group_name; ?>
</option>
<?php } else { ?>
<option value="<?php echo $data->id; ?>"><?php echo $data->group_name;?> </option>
<?php } ?>
<?php } ?>
</select>
</div>
</div>
</div>
<!-- <div class="ln_solid"></div> -->
<div class="x_panel"><br>
<div class="item form-group">
<div class=" offset-md-8">
<a href="<?php echo base_url();?>Employee/empList" class="btn btn-secondary">Cancel</a>
<button type="submit" class="btn btn-success">Update</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<br />
<!-- <div id="sub-value" class="col-md-12 col-sm-12">
<?php echo $emp_sub_list_htmlPage; ?>
</div> -->
</div>
</div>
<!-- /Body page content -->
<script>
$('#myDatepicker').datetimepicker({
format: 'DD.MM.YYYY'
});
</script>
<script>
function matchnum(event) {
var charcode;
charcode = event.which || event.keyCode;
if (charcode >= 48 && charcode <= 57) return true; //only numbers
return false;
}
function validateKeyPress(event) {
var key = event.key;
var allowedCharacters = /^[A-Za-z.]$/;
if (!allowedCharacters.test(key)) {
event.preventDefault();
}
}
$(document).on('change', '#image', function() {
const file = this.files[0];
if (file) {
let reader = new FileReader();
reader.onload = function(event) {
$('#image').attr('src', event.target.result);
$('.profilepic__image').attr('src', event.target.result);
}
reader.readAsDataURL(file);
}
});
</script>
<script>
var dateFormat = "dd-mm-yy";
var fromDateInput = $("#j_date");
console.log(fromDateInput);
fromDateInput.datepicker({
dateFormat: dateFormat,
changeYear: true,
changeMonth: true,
maxDate: new Date(),
onSelect: function(dateText, inst) {
}
});
</script>
<script>
function validateFile(input) {
const file = input.files[0];
const allowedExtensions = ["jpg", "jpeg", "png", "pdf"];
const fileExtension = file.name.split(".").pop().toLowerCase();
if (!allowedExtensions.includes(fileExtension)) {
// Invalid file type
new PNotify({
text: 'Invalid file type. Only JPG, JPEG, PNG, and PDF files are allowed.',
type: 'error',
styling: 'bootstrap3'
});
input.value = "";
return;
}
if (fileExtension === "pdf") {
// Preview PDF
const reader = new FileReader();
reader.onload = function(e) {
const pdfObject = `<embed src="${e.target.result}" width="500" height="600" type="application/pdf">`;
document.getElementById("previewContainer").innerHTML = pdfObject;
};
reader.readAsDataURL(file);
} else {
// Preview image
const reader = new FileReader();
reader.onload = function(e) {
const imageObject = `<img src="${e.target.result}" alt="Preview" width="500">`;
document.getElementById("previewContainer").innerHTML = imageObject;
};
reader.readAsDataURL(file);
}
}
</script>
<script>
function check_if_exists(id, value, name) {
// alert(name);
// var data = $(this).val();
$.ajax({
type:"get",
url: "<?php echo base_url(); ?>Employee/checkUniqueValue",
data: { value: value, name: name },
success:function(response)
{
if (response == true)
{
new PNotify({
title: 'Warning',
text: 'That given details Already Exists',
styling: 'bootstrap3'
});
// $("#"+id).val('');
}
}
});
}
</script>