changes in employee module

This commit is contained in:
vadivel J 2024-10-24 12:47:26 +05:30
parent 1be49e8aea
commit bbba0d4de7
3 changed files with 30 additions and 112 deletions

View File

@ -199,37 +199,7 @@ class Employeedetails extends BaseController
* This function is used to save the new Employee form in the database
*/
/**
* This function is used to save the new Employee form in the database
*/
/**
* This function is used to save the new Employee form in the database
*/
/**
* This function is used to save the new Employee form in the database
*/
/**
* This function is used to save the new Employee form in the database
*/
/**
* This function is used to save the new Employee form in the database
*/
/**
* This function is used to save the new Employee form in the database
*/
/**
* This function is used to save the new Employee form in the database
*/
/**
* This function is used to save the new Employee form in the database
*/
/**
* This function is used to save the new Employee form in the database
*/
/**
* This function is used to save the new Employee form in the database
*/
/**
* This function is used to save the new Employee form in the database
*/
@ -249,6 +219,10 @@ class Employeedetails extends BaseController
$photo->move($uploadDir, $newName);
$Picture = $newName;
}
else{
echo "Incorrect file format provided";
return false;
}
}
}
// $Profile = $this->request->getPost('photo');
@ -661,38 +635,7 @@ class Employeedetails extends BaseController
}
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
/* To Update the employee details*/
function UpdateEmployee()
@ -700,41 +643,12 @@ class Employeedetails extends BaseController
$EmpId = $this->request->getGet('empId');
$PictureName = $this->request->getPost('Image');
$ModifyPictureName = $this->request->getPost('ModifyImage');
//if it is empty it means the default image is selected
$oldPictureName = $this->request->getPost('oldImageName');
$Picture = "";
if ($PictureName != '') {
if (strlen((string)$ModifyPictureName) == 0) {
$Picture = $PictureName;
} else {
$photo = $this->request->getFile('ModifyImage');
if (!$photo || !$photo->isValid()) {
$photo = $this->request->getFile('photo');
}
if (isset($photo)) {
if ($photo->isValid() && !$photo->hasMoved()) {
$uploadDir = ROOTPATH . 'public/uploads/images/';
$allowedTypes = ['jpg', 'jpeg', 'png', 'gif'];
if (in_array($photo->getExtension(), $allowedTypes)) {
$newName = $photo->getRandomName();
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
$photo->move($uploadDir, $newName);
$Picture = $newName;
}
}
}
}
} else {
//echo 'Not Exists';
$photo = $this->request->getFile('photo');
if (isset($photo)) {
if ($photo->isValid() && !$photo->hasMoved()) {
$photo = $this->request->getFile('photo');
if (isset($photo) && $photo->isValid() && !$photo->hasMoved()) {
$uploadDir = ROOTPATH . 'public/uploads/images/';
$allowedTypes = ['jpg', 'jpeg', 'png', 'gif'];
if (in_array($photo->getExtension(), $allowedTypes)) {
@ -745,10 +659,11 @@ class Employeedetails extends BaseController
$photo->move($uploadDir, $newName);
$Picture = $newName;
}
}
}else{
$Picture=$oldPictureName;
}
}
//echo $Picture;
$FirstName = $this->request->getPost('FirstName');
$LastName = $this->request->getPost('LastName');

View File

@ -430,7 +430,7 @@
<div class="tab-pane active" id="first">
<form id="accountForm" method="post" action="#" class="form-horizontal">
<form id="accountForm" method="post" enctype="multipart/form-data" action="#" class="form-horizontal">
<div class="row">
<div class="col-md-2">
@ -439,7 +439,7 @@
<div class="box-header">
<img id="profilepicture"
src="<?php echo base_url(); ?>public/assets/dist/img/avatar.png"
alt="your image" style="width: 139px;" /><br />
alt="your image" style="width: 139px;" /><br/>
</div>

View File

@ -109,10 +109,13 @@ if (!empty($EmpDetails)) {
}
$isactive = $Emp->IsActive;
$ProfilePicPath='';
if (!empty($Emp->ProfilePic)) {
$ProfilePic = 'public/uploads/images/' . $Emp->ProfilePic;
$ProfilePicPath = base_url().'public/uploads/images/' . $Emp->ProfilePic;
} else {
$ProfilePic = 'public/assets/dist/img/avatar.png';
$ProfilePicPath = base_url().'public/assets/dist/img/avatar.png';
}
$Reference_Name = $Emp->Reference_Name;
$Reference_ContactNumber = $Emp->Reference_ContactNumber;
@ -199,7 +202,9 @@ if (!empty($EmpDetails)) {
<div class="tab-pane active" id="first">
<form id="accountForm" method="post" action="#" class="form-horizontal">
<form id="accountForm" method="post" action="#"
enctype="multipart/form-data"
class="form-horizontal">
<div class="row">
<div class="col-md-2">
@ -208,7 +213,7 @@ if (!empty($EmpDetails)) {
<div class="box-header">
<img id="profilepicture"
src="<?php echo base_url() . $ProfilePic; ?>"
src="<?php echo $ProfilePicPath; ?>"
alt="your image" style="width: 139px;" />
@ -229,15 +234,13 @@ if (!empty($EmpDetails)) {
<br>
<input type='file' onchange="readURL(this);" id="photo"
value="<?php echo base_url() . $ProfilePic; ?>"
name="photo" />
<input type="hidden" name="Image" id="Image"
value="<?php echo $ProfilePic; ?>" class="form-control"
readonly>
<input type="hidden" name="ModifyImage" id="ModifyImage"
class="form-control" readonly>
<input type="hidden" name="oldImageName" id="Image"
value="<?php echo $Emp->ProfilePic; ?>" class="form-control"
readonly>
</div>