File: /var/www/html/dev-hrms/app/Http/Controllers/EmployeePromotionController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\EmployeeProfile;
use App\Models\Profiles;
use App\Models\Approval;
use App\Models\EmployeeAddress;
use App\Models\Course;
use App\Models\Subjects;
use App\Models\FamilyMember;
use App\Models\EmployeeTrainingDetail;
use App\Models\EmployeeDisciplinaryAction;
use App\Models\ForeignVisit;
use App\Models\DivisionGrade;
use App\Models\EmployeeQualifications;
use App\Models\NameChange;
use App\Models\AssetsLiability;
use App\Models\ConfidentialReport;
use App\Models\DeputationDetail;
use App\Models\EmployeePromotion;
use App\Models\EmployeePensionScheme;
use App\Models\EmployeeProbationPeriod;
use App\Library\UserLib;
use App\Models\EmployeeNomineeDetail;
use App\Models\EmployeePayMatrix;
use App\Models\PensionScheme;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
class EmployeePromotionController extends Controller
{
protected $userLib;
protected $UserSessionId;
protected $TeamList = array();
protected $LevelList = array();
protected $ViewProfileIds = array();
protected $ViewApprovalUsers = array();
public function __construct(UserLib $userLib)
{
$this->userLib = $userLib;
}
public function getAccessUserProfileList($ProfileId = '')
{
$users = Profiles::select('*')
->leftJoin('tbl_roles', 'tbl_roles.RoleId', '=', 'tbl_profiles.RoleId')
->where('tbl_roles.ReadPermission', 'like', '1')
->where('tbl_roles.WritePermission', 'like', '1')
->where('tbl_roles.UpdatePermission', 'like', '1')
->where('tbl_roles.ApprovalPermission', 'like', '1')
->where('tbl_profiles.ServiceBookApprovalPermission', 'like', 'YES')
->where('tbl_profiles.ProfileId', 'like', $ProfileId) //check not equal to user profile
->get();
if ($users->count() > 0) { //email is exist
foreach ($users as $key => $UValue) {
$ProfileId = $UValue['ProfileId'];
$ProfileName = $UValue['ProfileName'];
$ParentId = $UValue['ParentId'];
$this->TeamList[] = $UValue;
$this->ViewProfileIds[] = $ProfileId;
if ($ParentId) {
$this->getAccessUserProfileList($ParentId);
}
}
}
return $responseData = $this->ViewProfileIds;
//return response()->json($responseData);
}
// Get Approval User
public function getApprovalUserLevel($ProfileId = '', $Level = 1)
{
$users = Profiles::select('*')
->leftJoin('tbl_roles', 'tbl_roles.RoleId', '=', 'tbl_profiles.RoleId')
->where('tbl_roles.ReadPermission', 'like', '1')
->where('tbl_roles.WritePermission', 'like', '1')
->where('tbl_roles.UpdatePermission', 'like', '1')
->where('tbl_roles.ApprovalPermission', 'like', '1')
//->where('tbl_profiles.ServiceBookApprovalPermission','like','YES')
->where('tbl_profiles.ProfileId', 'like', $ProfileId) //check not equal to user profile
->get();
// echo $users;
//exit;
if ($users->count() > 0) { //email is exist
foreach ($users as $key => $UValue) {
$ProfileId = $UValue['ProfileId'];
$ProfileName = $UValue['ProfileName'];
$ParentId = $UValue['ParentId'];
$this->TeamList[] = $UValue;
$this->ViewApprovalUsers[] = $ProfileId;
//$this->LevelList[] = $Level;
//echo $Level.'-'.$ParentId.'<br/>';
if ($Level >= 2) {
continue;
}
if ($ParentId) {
$Level++;
$this->getApprovalUserLevel($ParentId, $Level);
}
}
}
return $this->ViewApprovalUsers;
}
public function employeePromotion()
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
return view('admin.EmployeeProfile.employee-promotion');
}
### Promotion Transfer List
public function empPromotionTransferList()
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$EmpTransferList = EmployeePromotion::select('tbl_employees_promotion_transfer.*', 'tbl_employees.EmployeeName as EmployeeName', 'tbl_transfer_status.TransferStatusName as AppointmentStatus', 'tbl_admin.FirstName as Updated_by', 'tbl_admin.FirstName as Created_by')
->leftJoin('tbl_admin', 'tbl_employees_promotion_transfer.Updated_by', '=', 'tbl_admin.UserId')
->leftJoin('tbl_employees', 'tbl_employees_promotion_transfer.EmployeeId', '=', 'tbl_employees.EmployeeId')
->leftJoin('tbl_transfer_status', 'tbl_employees_promotion_transfer.AppointmentStatus', '=', 'tbl_transfer_status.TransferStatusId')
->where('tbl_employees_promotion_transfer.IsDeleted', '=', '0')
->where('tbl_employees_promotion_transfer.PromotionTransferCode', '!=', '')
->orderBy('tbl_employees.EmployeeName', 'ASC')
->get();
return view('admin.EmployeeProfile.employee-promotion-list', ['EmpTransferList' => $EmpTransferList]);
}
### Emp Reversion List
public function empReversionList()
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$CurrentDate = date('Y-m-d');
$EmpReversionList = EmployeePromotion::select('tbl_employees_promotion_transfer.*', 'tbl_employees.EmployeeName as EmployeeName', 'tbl_transfer_status.TransferStatusName as AppointmentStatus', 'tbl_admin.FirstName as Updated_by', 'tbl_admin.FirstName as Created_by')
->leftJoin('tbl_admin', 'tbl_employees_promotion_transfer.Updated_by', '=', 'tbl_admin.UserId')
->leftJoin('tbl_employees', 'tbl_employees_promotion_transfer.EmployeeId', '=', 'tbl_employees.EmployeeId')
->leftJoin('tbl_transfer_status', 'tbl_employees_promotion_transfer.AppointmentStatus', '=', 'tbl_transfer_status.TransferStatusId')
->where('tbl_employees_promotion_transfer.IsDeleted', '=', '0')
->where('tbl_employees_promotion_transfer.PromotionTransferCode', '!=', '')
->where('tbl_employees_promotion_transfer.ReversionDate', '!=', '')
->where('tbl_employees_promotion_transfer.ReversionDate', '<', $CurrentDate)
->orderBy('tbl_employees_promotion_transfer.ReversionDate', 'DESC')
->get();
return view('admin.EmployeeProfile.employee-reversion-list', ['EmpReversionList' => $EmpReversionList]);
}
#### View Employee Promotion
public function viewEmpPromotion($PromotionTransferId)
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$ViewEmpOrder = EmployeePromotion::select('tbl_employees_promotion_transfer.*', 'tbl_employees.EmployeeName as EmployeeName', 'tbl_ddo.DDOName as DDOName', 'tbl_controlling_officer.ControllingOfficerName as ControllingOfficer', 'tbl_department.DepartmentName as DepartmentName', 'tbl_designation.DesignationName as DesignationName', 'tbl_actual_work_place.ActualWorkPlaceName as ActualWorkPlace', 'tbl_group.GroupName as Group', 'tbl_cadre.CadreName as Cadre', 'tbl_scheme_name.NameOfScheme as SchemeName', 'tbl_sanction_post.SanctionPostName as SanctionPost', 'tbl_faculty.FacultyName as Faculty', 'tbl_transfer_status.TransferStatusName as AppointmentStatus')
->where('tbl_employees_promotion_transfer.PromotionTransferId', '=', $PromotionTransferId)
->leftJoin('tbl_employees', 'tbl_employees_promotion_transfer.EmployeeId', '=', 'tbl_employees.EmployeeId')
->leftJoin('tbl_ddo', 'tbl_employees_promotion_transfer.DDOId', '=', 'tbl_ddo.DDOId')
->leftJoin('tbl_controlling_officer', 'tbl_employees_promotion_transfer.ControllingOfficerId', '=', 'tbl_controlling_officer.ControllingOfficerId')
->leftJoin('tbl_department', 'tbl_employees_promotion_transfer.DepartmentId', '=', 'tbl_department.DepartmentId')
->leftJoin('tbl_designation', 'tbl_employees_promotion_transfer.DesignationId', '=', 'tbl_designation.DesignationId')
->leftJoin('tbl_actual_work_place', 'tbl_employees_promotion_transfer.ActualWorkPlaceId', '=', 'tbl_actual_work_place.ActualWorkPlaceId')
->leftJoin('tbl_cadre', 'tbl_employees_promotion_transfer.CadreId', '=', 'tbl_cadre.CadreId')
->leftJoin('tbl_group', 'tbl_employees_promotion_transfer.GroupId', '=', 'tbl_cadre.GroupId')
->leftJoin('tbl_sanction_post', 'tbl_employees_promotion_transfer.SanctionPostId', '=', 'tbl_sanction_post.SanctionPostId')
->leftJoin('tbl_scheme_name', 'tbl_employees_promotion_transfer.SchemeNameId', '=', 'tbl_scheme_name.SchemeNameId')
->leftJoin('tbl_faculty', 'tbl_employees_promotion_transfer.FacultyId', '=', 'tbl_faculty.FacultyId')
->leftJoin('tbl_transfer_status', 'tbl_employees_promotion_transfer.AppointmentStatus', '=', 'tbl_transfer_status.TransferStatusId')
->get()->first();
// Get Employee Past Position
$EmployeeId = $ViewEmpOrder->EmployeeId;
$EmpTotalRecords = EmployeePromotion::where('EmployeeId', $EmployeeId)->count();
$EmpPastPosition = EmployeePromotion::select('tbl_employees_promotion_transfer.*', 'tbl_employees.EmployeeName as EmployeeName', 'tbl_ddo.DDOName as DDOName', 'tbl_controlling_officer.ControllingOfficerName as ControllingOfficer', 'tbl_department.DepartmentName as DepartmentName', 'tbl_designation.DesignationName as DesignationName', 'tbl_actual_work_place.ActualWorkPlaceName as ActualWorkPlace', 'tbl_group.GroupName as Group', 'tbl_cadre.CadreName as Cadre', 'tbl_scheme_name.NameOfScheme as SchemeName', 'tbl_sanction_post.SanctionPostName as SanctionPost', 'tbl_faculty.FacultyName as Faculty', 'tbl_transfer_status.TransferStatusName as AppointmentStatus')
->where('tbl_employees_promotion_transfer.EmployeeId', $EmployeeId)
->where('tbl_employees_promotion_transfer.IsDeleted', '=', '0')
->orderBy('tbl_employees_promotion_transfer.id', 'DESC')
->leftJoin('tbl_employees', 'tbl_employees_promotion_transfer.EmployeeId', '=', 'tbl_employees.EmployeeId')
->leftJoin('tbl_ddo', 'tbl_employees_promotion_transfer.DDOId', '=', 'tbl_ddo.DDOId')
->leftJoin('tbl_controlling_officer', 'tbl_employees_promotion_transfer.ControllingOfficerId', '=', 'tbl_controlling_officer.ControllingOfficerId')
->leftJoin('tbl_department', 'tbl_employees_promotion_transfer.DepartmentId', '=', 'tbl_department.DepartmentId')
->leftJoin('tbl_designation', 'tbl_employees_promotion_transfer.DesignationId', '=', 'tbl_designation.DesignationId')
->leftJoin('tbl_actual_work_place', 'tbl_employees_promotion_transfer.ActualWorkPlaceId', '=', 'tbl_actual_work_place.ActualWorkPlaceId')
->leftJoin('tbl_cadre', 'tbl_employees_promotion_transfer.CadreId', '=', 'tbl_cadre.CadreId')
->leftJoin('tbl_group', 'tbl_employees_promotion_transfer.GroupId', '=', 'tbl_cadre.GroupId')
->leftJoin('tbl_sanction_post', 'tbl_employees_promotion_transfer.SanctionPostId', '=', 'tbl_sanction_post.SanctionPostId')
->leftJoin('tbl_scheme_name', 'tbl_employees_promotion_transfer.SchemeNameId', '=', 'tbl_scheme_name.SchemeNameId')
->leftJoin('tbl_faculty', 'tbl_employees_promotion_transfer.FacultyId', '=', 'tbl_faculty.FacultyId')
->leftJoin('tbl_transfer_status', 'tbl_employees_promotion_transfer.AppointmentStatus', '=', 'tbl_transfer_status.TransferStatusId')
->skip($EmpTotalRecords - 1)->take(1)->get()->first();
// print_r(json_encode($EmpPastPosition));
// print_r(json_encode($ViewEmpOrder));
// exit;
// return response()->json([
// 'status' => 200,
// 'ViewEmpOrder' => $ViewEmpOrder,
// 'EmpPastPosition' => $EmpPastPosition,
// ]);
return view('admin.EmployeeProfile.view-employee-promotion', ['ViewEmpOrder' => $ViewEmpOrder, 'EmpPastPosition' => $EmpPastPosition]);
}
#### View Employee Transfer
public function viewEmpTransfer($PromotionTransferId)
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$ViewEmpTransfer = EmployeePromotion::select('tbl_employees_promotion_transfer.*', 'tbl_employees.EmployeeName as EmployeeName', 'tbl_ddo.DDOName as DDOName', 'tbl_controlling_officer.ControllingOfficerName as ControllingOfficer', 'tbl_department.DepartmentName as DepartmentName', 'tbl_designation.DesignationName as DesignationName', 'tbl_actual_work_place.ActualWorkPlaceName as ActualWorkPlace', 'tbl_group.GroupName as Group', 'tbl_cadre.CadreName as Cadre', 'tbl_scheme_name.NameOfScheme as SchemeName', 'tbl_sanction_post.SanctionPostName as SanctionPost', 'tbl_faculty.FacultyName as Faculty', 'tbl_transfer_status.TransferStatusName as AppointmentStatus')
->where('tbl_employees_promotion_transfer.PromotionTransferId', '=', $PromotionTransferId)
->leftJoin('tbl_employees', 'tbl_employees_promotion_transfer.EmployeeId', '=', 'tbl_employees.EmployeeId')
->leftJoin('tbl_ddo', 'tbl_employees_promotion_transfer.DDOId', '=', 'tbl_ddo.DDOId')
->leftJoin('tbl_controlling_officer', 'tbl_employees_promotion_transfer.ControllingOfficerId', '=', 'tbl_controlling_officer.ControllingOfficerId')
->leftJoin('tbl_department', 'tbl_employees_promotion_transfer.DepartmentId', '=', 'tbl_department.DepartmentId')
->leftJoin('tbl_designation', 'tbl_employees_promotion_transfer.DesignationId', '=', 'tbl_designation.DesignationId')
->leftJoin('tbl_actual_work_place', 'tbl_employees_promotion_transfer.ActualWorkPlaceId', '=', 'tbl_actual_work_place.ActualWorkPlaceId')
->leftJoin('tbl_cadre', 'tbl_employees_promotion_transfer.CadreId', '=', 'tbl_cadre.CadreId')
->leftJoin('tbl_group', 'tbl_employees_promotion_transfer.GroupId', '=', 'tbl_cadre.GroupId')
->leftJoin('tbl_sanction_post', 'tbl_employees_promotion_transfer.SanctionPostId', '=', 'tbl_sanction_post.SanctionPostId')
->leftJoin('tbl_scheme_name', 'tbl_employees_promotion_transfer.SchemeNameId', '=', 'tbl_scheme_name.SchemeNameId')
->leftJoin('tbl_faculty', 'tbl_employees_promotion_transfer.FacultyId', '=', 'tbl_faculty.FacultyId')
->leftJoin('tbl_transfer_status', 'tbl_employees_promotion_transfer.AppointmentStatus', '=', 'tbl_transfer_status.TransferStatusId')
->get()->first();
// Get Employee Past Position
$EmployeeId = $ViewEmpTransfer->EmployeeId;
$EmpTotalRecords = EmployeePromotion::where('EmployeeId', $EmployeeId)->count();
$EmpPastPosition = EmployeePromotion::select('tbl_employees_promotion_transfer.*', 'tbl_employees.EmployeeName as EmployeeName', 'tbl_ddo.DDOName as DDOName', 'tbl_controlling_officer.ControllingOfficerName as ControllingOfficer', 'tbl_department.DepartmentName as DepartmentName', 'tbl_designation.DesignationName as DesignationName', 'tbl_actual_work_place.ActualWorkPlaceName as ActualWorkPlace', 'tbl_group.GroupName as Group', 'tbl_cadre.CadreName as Cadre', 'tbl_scheme_name.NameOfScheme as SchemeName', 'tbl_sanction_post.SanctionPostName as SanctionPost', 'tbl_faculty.FacultyName as Faculty', 'tbl_transfer_status.TransferStatusName as AppointmentStatus')
->where('tbl_employees_promotion_transfer.EmployeeId', $EmployeeId)
->where('tbl_employees_promotion_transfer.IsDeleted', '=', '0')
->orderBy('tbl_employees_promotion_transfer.id', 'DESC')
->leftJoin('tbl_employees', 'tbl_employees_promotion_transfer.EmployeeId', '=', 'tbl_employees.EmployeeId')
->leftJoin('tbl_ddo', 'tbl_employees_promotion_transfer.DDOId', '=', 'tbl_ddo.DDOId')
->leftJoin('tbl_controlling_officer', 'tbl_employees_promotion_transfer.ControllingOfficerId', '=', 'tbl_controlling_officer.ControllingOfficerId')
->leftJoin('tbl_department', 'tbl_employees_promotion_transfer.DepartmentId', '=', 'tbl_department.DepartmentId')
->leftJoin('tbl_designation', 'tbl_employees_promotion_transfer.DesignationId', '=', 'tbl_designation.DesignationId')
->leftJoin('tbl_actual_work_place', 'tbl_employees_promotion_transfer.ActualWorkPlaceId', '=', 'tbl_actual_work_place.ActualWorkPlaceId')
->leftJoin('tbl_cadre', 'tbl_employees_promotion_transfer.CadreId', '=', 'tbl_cadre.CadreId')
->leftJoin('tbl_group', 'tbl_employees_promotion_transfer.GroupId', '=', 'tbl_cadre.GroupId')
->leftJoin('tbl_sanction_post', 'tbl_employees_promotion_transfer.SanctionPostId', '=', 'tbl_sanction_post.SanctionPostId')
->leftJoin('tbl_scheme_name', 'tbl_employees_promotion_transfer.SchemeNameId', '=', 'tbl_scheme_name.SchemeNameId')
->leftJoin('tbl_faculty', 'tbl_employees_promotion_transfer.FacultyId', '=', 'tbl_faculty.FacultyId')
->leftJoin('tbl_transfer_status', 'tbl_employees_promotion_transfer.AppointmentStatus', '=', 'tbl_transfer_status.TransferStatusId')
->skip($EmpTotalRecords - 1)->take(1)->get()->first();
// print_r(json_encode($EmpPastPosition));
// print_r(json_encode($ViewEmpOrder));
// exit;
// return response()->json([
// 'status' => 200,
// 'ViewEmpOrder' => $ViewEmpOrder,
// 'EmpPastPosition' => $EmpPastPosition,
// ]);
return view('admin.EmployeeProfile.view-employee-transfer', ['ViewEmpTransfer' => $ViewEmpTransfer, 'EmpPastPosition' => $EmpPastPosition]);
}
### Store Employee Promotion
public function storeEmployeePromotion(Request $request)
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$EmployeeId = $request->input('EmployeeId');
$EmployeeCode = $request->input('EmpCode');
$TransferStatus = $request->input('TransferStatus');
$PrevRelievingDate = '';
if ($request->input('PrevRelievingDate')) {
$Relieving = str_replace('/', '-', $request->input('PrevRelievingDate'));
}
$PrevRelievingDate = date('Y-m-d', strtotime($Relieving));
$PromotionOrderDate = '';
if ($request->input('promotionOrderDate')) {
$OrderDate = str_replace('/', '-', $request->input('promotionOrderDate'));
}
$PromotionOrderDate = date('d-m-Y', strtotime($OrderDate));
$PromotionTransferDate = '';
if ($request->input('EmpPromotionDate')) {
$TransferDate = str_replace('/', '-', $request->input('EmpPromotionDate'));
}
$PromotionTransferDate = date('Y-m-d', strtotime($TransferDate));
$ProbationPeriod = '';
if ($request->input('ProbationPeriod')) {
$ProbationPeriod = '1';
} else {
$ProbationPeriod = '0';
}
$PromoProbationPeriodClearDate = '';
if ($request->input('PromoProbationPeriodDate')) {
$ProbationPeriodDate = str_replace('/', '-', $request->input('PromoProbationPeriodDate'));
$PromoProbationPeriodClearDate = date('Y-m-d', strtotime($ProbationPeriodDate));
$emp_promotion['PromoProbationPeriodClearDate'] = $PromoProbationPeriodClearDate;
}
$EmpReversionDate = '';
if ($request->input('EmpReversionDate')) {
$ReversionDate = str_replace('/', '-', $request->input('EmpReversionDate'));
$EmpReversionDate = date('Y-m-d', strtotime($ReversionDate));
$emp_promotion['ReversionDate'] = $EmpReversionDate;
}
// Pay Matrix
$PayFixationAfterOrder = '';
if ($request->input('PayFixationOrder')) {
$PayFixationAfterOrder = '1';
} else {
$PayFixationAfterOrder = '0';
}
$emp_paymatrix['PayMatrixId'] = $this->userLib->useridGenrator();
$emp_paymatrix['EmployeeId'] = $EmployeeId;
$emp_paymatrix['EmployeeCode'] = $EmployeeCode;
$emp_paymatrix['PayScaleId'] = $request->input('NewPayScale');
$emp_paymatrix['PayBandId'] = $request->input('PayBandId');
$emp_paymatrix['GradePayId'] = $request->input('NewGradePay');
$emp_paymatrix['PayLevelId'] = $request->input('PayLevelId');
$emp_paymatrix['PayLevelAmount'] = $request->input('PayLevelAmount');
$emp_paymatrix['PayMatrixScale'] = $request->input('PayMatrixScale');
$emp_paymatrix['PayLevelAmountId'] = $request->input('PayLevelAmountId');
$emp_paymatrix['EffectiveDate'] = $PromotionTransferDate;
$emp_paymatrix['PayFixationId'] = $TransferStatus;
$emp_paymatrix['PayFixationAfterOrder'] = $PayFixationAfterOrder;
// Lower Scale
$emp_paymatrix['LowerPayScale'] = $request->input('LowerPayScale');
$emp_paymatrix['LowerPayBand'] = $request->input('LowerPayBand');
$emp_paymatrix['LowerGradePay'] = $request->input('LowerGradePay');
$emp_paymatrix['LowerPayLevel'] = $request->input('LowerPayLevel');
$emp_paymatrix['LowerPayLevelAmount'] = $request->input('LowerPayLevelAmount');
$emp_paymatrix['LowerPayMatrixScale'] = $request->input('LowerPayMatrixScale');
//$emp_paymatrix['LowerPayLevelAmountId'] = $request->input('LowerPayLevelAmountId');
$emp_paymatrix['IsDeleted'] = 0;
$emp_paymatrix['Status'] = 1;
$emp_paymatrix['Created_by'] = session('UserId');
$emp_paymatrix['Created_at'] = date('Y-m-d H:i:s', time());
$emp_paymatrix['Updated_by'] = session('UserId');
$emp_paymatrix['Updated_at'] = date('Y-m-d H:i:s', time());
// Promotion and Transfer Table
$emp_promotion['PromotionTransferId'] = $this->userLib->useridGenrator();
$emp_promotion['PromotionTransferCode'] = $request->input('PromotionCode');
$emp_promotion['PromotionOrderDate'] = $PromotionOrderDate;
$emp_promotion['EmployeeId'] = $EmployeeId;
$emp_promotion['EmployeeCode'] = $EmployeeCode;
$emp_promotion['AppointmentStatus'] = $TransferStatus;
$emp_promotion['DDOId'] = $request->input('NewDDO');
$emp_promotion['ControllingOfficerId'] = $request->input('NewControllingOfficer');
$emp_promotion['ActualWorkPlaceId'] = $request->input('NewWorkPlace');
$emp_promotion['DepartmentId'] = $request->input('NewDepartment');
$emp_promotion['GroupId'] = $request->input('NewGroup');
$emp_promotion['CadreId'] = $request->input('NewCadre');
$emp_promotion['DesignationId'] = $request->input('NewDesignation');
$emp_promotion['SanctionPostId'] = $request->input('NewSanctionPost');
$emp_promotion['FacultyId'] = $request->input('NewFaculty');
$emp_promotion['SchemeNameId'] = $request->input('NewScheme');
$emp_promotion['PromotionTransferDate'] = $PromotionTransferDate;
$emp_promotion['ProbationPeriod'] = $ProbationPeriod;
$emp_promotion['PromotionTransferTime'] = $request->input('JoiningTime');
$emp_promotion['Remarks'] = $request->input('PromotionRemark');
// Previous Detail Position
$emp_promotion['PrevDDO'] = $request->input('PrevDDO');
$emp_promotion['PrevControllingOfficer'] = $request->input('PrevControllingOfficer');
$emp_promotion['PrevActualWorkPlace'] = $request->input('PrevActualWorkPlace');
$emp_promotion['PrevDepartment'] = $request->input('PrevDepartment');
$emp_promotion['PrevGroup'] = $request->input('PrevGroup');
$emp_promotion['PrevCadre'] = $request->input('PrevCadre');
$emp_promotion['PrevDesignation'] = $request->input('PrevDesignation');
$emp_promotion['PrevRelievingDate'] = $PrevRelievingDate;
$emp_promotion['PrevRelievingTime'] = $request->input('RelievingTime');
$emp_promotion['IsTenurePeriod'] = $request->input('IsTenurePeriod');
$emp_promotion['IsCurrentPosition'] = 1;
$emp_promotion['IsDeleted'] = 0;
$emp_promotion['Status'] = 1;
$emp_promotion['Created_by'] = session('UserId');
$emp_promotion['Created_at'] = date('Y-m-d H:i:s', time());
$emp_promotion['Updated_by'] = session('UserId');
$emp_promotion['Updated_at'] = date('Y-m-d H:i:s', time());
// Probation Period Date Table
if ($ProbationPeriod == '1') {
$probation_data['ProbationPeriodId'] = $this->userLib->useridGenrator();
$probation_data['EmployeeId'] = $EmployeeId;
$probation_data['EmployeeCode'] = $EmployeeCode;
$probation_data['JoiningDate'] = $PromotionTransferDate;
$probation_data['JoiningTime'] = $request->input('JoiningTime');
$probation_data['ProbationPeriodClearDate'] = $PromoProbationPeriodClearDate;
$probation_data['Created_by'] = session('UserId');
$probation_data['Created_at'] = date('Y-m-d H:i:s', time());
$probation_data['Updated_by'] = session('UserId');
$probation_data['Updated_at'] = date('Y-m-d H:i:s', time());
$EmpProbationPeriod = EmployeeProbationPeriod::insert($probation_data);
// if ($EmpProbationPeriod) {
// echo 'success_probation, ';
// } else {
// echo 'failed_probation, ';
// }
}
if ($TransferStatus == 'bTM9MUJXKKhGHezyrMP85rUv0tLHV8crYg0Ob' || $TransferStatus == 'W8whXFgWakAvkHU6OTgvgXBVPZgmQNveI48YY' || $TransferStatus == 'KAIimsIbfk3894uaj89sj7nudk909m0923HJAasImsd') { // Nomination or Promotion Ids
$ChangeStatus = array();
$ChangeStatus['Status'] = 0;
$ChangeStatus['Updated_by'] = session('UserId');
$ChangeStatus['Updated_at'] = date('Y-m-d H:i:s', time());
$ChangeStatusData = EmployeePayMatrix::where('EmployeeId', $EmployeeId)->where('Status', '1')->update($ChangeStatus);
if ($ChangeStatusData) {
$insert_paymatrix = EmployeePayMatrix::insert($emp_paymatrix);
// if ($insert_paymatrix) {
// echo 'success_paymatrix, ';
// } else {
// echo 'failed_paymatrix, ';
// }
}
}
/*** Change Current Position to 0 before store new record ***/
$update_position = EmployeePromotion::where('EmployeeId', $EmployeeId)
->where('IsCurrentPosition', 1)
->update(['IsCurrentPosition' => 0]);
$insert_promotion = EmployeePromotion::insert($emp_promotion);
if ($insert_promotion) {
return response()->json('success_promotion');
} else {
return response()->json('failed_promotion');
}
}
### Edit Employee Promotion
public function editPromotionDetail(Request $request)
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$PromotionTransferId = $request->input('PromotionTransferId');
$GetPromotionDetail = EmployeePromotion::select('tbl_employees_promotion_transfer.*', 'tbl_employees.EmployeeName as EmployeeName')
->where('tbl_employees_promotion_transfer.PromotionTransferId', '=', $PromotionTransferId)
->leftJoin('tbl_employees', 'tbl_employees_promotion_transfer.EmployeeId', '=', 'tbl_employees.EmployeeId')
->leftJoin('tbl_transfer_status', 'tbl_employees_promotion_transfer.AppointmentStatus', '=', 'tbl_transfer_status.TransferStatusId')
->get()->first();
// $EmployeeId = $GetPromotionDetail->EmployeeId;
// $GetEmpPayMatrix = EmployeePayMatrix::select('tbl_employees_paymatrix.*', 'tbl_payscale.PayScaleName as PayScale', 'tbl_payband.PayBandName as PayBand', 'tbl_gradepay.GradePayName as GradePay', 'tbl_paylevel.PayLevelName as PayLevel', 'tbl_paylevel_amount.PayLevelAmount as LevelAmount', 'tbl_pay_fixation.PayFixation as PayFixation')
// ->leftJoin('tbl_payscale', 'tbl_employees_paymatrix.PayScaleId', '=', 'tbl_payscale.PayScaleId')
// ->leftJoin('tbl_payband', 'tbl_employees_paymatrix.PayBandId', '=', 'tbl_payband.PayBandId')
// ->leftJoin('tbl_gradepay', 'tbl_employees_paymatrix.GradePayId', '=', 'tbl_gradepay.GradePayId')
// ->leftJoin('tbl_paylevel', 'tbl_employees_paymatrix.PayLevelId', '=', 'tbl_paylevel.PayLevelId')
// ->leftJoin('tbl_paylevel_amount', 'tbl_employees_paymatrix.PayLevelAmountId', '=', 'tbl_paylevel_amount.PayLevelAmountId')
// ->leftJoin('tbl_pay_fixation', 'tbl_employees_paymatrix.PayFixationId', '=', 'tbl_pay_fixation.PayFixationId')
// ->where('tbl_employees_paymatrix.EmployeeId', $EmployeeId)
// ->where('tbl_employees_paymatrix.Status', '1')
// ->where('tbl_employees_paymatrix.IsDeleted', '0')
// ->orderBy('tbl_employees_paymatrix.id', 'DESC')
// ->get()->first();
return response()->json([
'Status' => 200,
'GetPromotionDetail' => $GetPromotionDetail,
//'GetEmpPayMatrix' => $GetEmpPayMatrix,
]);
}
### Update Employee Promotion
public function updateEmployeePromotion(Request $request)
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$PromotionTransferId = $request->input('PromotionTransferId');
$PromotionOrderDate = '';
if ($request->input('promotionOrderDate')) {
$OrderDate = str_replace('/', '-', $request->input('promotionOrderDate'));
$PromotionOrderDate = date('d-m-Y', strtotime($OrderDate));
$update_promotion['PromotionOrderDate'] = $PromotionOrderDate;
}
$PrevRelievingDate = '';
if ($request->input('PrevRelievingDate')) {
$Relieving = str_replace('/', '-', $request->input('PrevRelievingDate'));
$PrevRelievingDate = date('Y-m-d', strtotime($Relieving));
$update_promotion['PrevRelievingDate'] = $PrevRelievingDate;
}
$PromotionTransferDate = '';
if ($request->input('EmpPromotionDate')) {
$TransferDate = str_replace('/', '-', $request->input('EmpPromotionDate'));
$PromotionTransferDate = date('Y-m-d', strtotime($TransferDate));
$update_promotion['PromotionTransferDate'] = $PromotionTransferDate;
}
$ProbationPeriod = '';
if ($request->input('ProbationPeriod')) {
$ProbationPeriod = '1';
} else {
$ProbationPeriod = '0';
}
$IsCurrentPosition = '';
if ($request->input('IsCurrentPosition')) {
$IsCurrentPosition = 1;
} else {
$IsCurrentPosition = 0;
}
$PromoProbationPeriodClearDate = '';
if ($request->input('PromoProbationPeriodDate')) {
$ProbationPeriodDate = str_replace('/', '-', $request->input('PromoProbationPeriodDate'));
$PromoProbationPeriodClearDate = date('Y-m-d', strtotime($ProbationPeriodDate));
$update_promotion['PromoProbationPeriodClearDate'] = $PromoProbationPeriodClearDate;
}
$EmpReversionDate = '';
if ($request->input('EmpReversionDate')) {
$ReversionDate = str_replace('/', '-', $request->input('EmpReversionDate'));
$EmpReversionDate = date('Y-m-d', strtotime($ReversionDate));
$update_promotion['ReversionDate'] = $EmpReversionDate;
}
$EmployeeId = $request->input('EmployeeId');
// Get Previous Position Detail
$GetPrevDetail = EmployeePromotion::select('tbl_employees_promotion_transfer.*', 'tbl_ddo.DDOName as DDOName', 'tbl_controlling_officer.ControllingOfficerName as ControllingOfficer', 'tbl_department.DepartmentName as DepartmentName', 'tbl_designation.DesignationName as DesignationName', 'tbl_actual_work_place.ActualWorkPlaceName as ActualWorkPlace', 'tbl_group.GroupName as Group', 'tbl_cadre.CadreName as Cadre', 'tbl_scheme_name.NameOfScheme as SchemeName', 'tbl_sanction_post.SanctionPostName as SanctionPost', 'tbl_faculty.FacultyName as Faculty', 'tbl_transfer_status.TransferStatusName as AppointmentStatus')
->where('tbl_employees_promotion_transfer.EmployeeId', $EmployeeId)
->where('tbl_employees_promotion_transfer.PromotionTransferId', '!=', $PromotionTransferId)
->where('tbl_employees_promotion_transfer.PromotionTransferDate', '<', $PromotionTransferDate)
->leftJoin('tbl_ddo', 'tbl_employees_promotion_transfer.DDOId', '=', 'tbl_ddo.DDOId')
->leftJoin('tbl_controlling_officer', 'tbl_employees_promotion_transfer.ControllingOfficerId', '=', 'tbl_controlling_officer.ControllingOfficerId')
->leftJoin('tbl_department', 'tbl_employees_promotion_transfer.DepartmentId', '=', 'tbl_department.DepartmentId')
->leftJoin('tbl_designation', 'tbl_employees_promotion_transfer.DesignationId', '=', 'tbl_designation.DesignationId')
->leftJoin('tbl_actual_work_place', 'tbl_employees_promotion_transfer.ActualWorkPlaceId', '=', 'tbl_actual_work_place.ActualWorkPlaceId')
->leftJoin('tbl_cadre', 'tbl_employees_promotion_transfer.CadreId', '=', 'tbl_cadre.CadreId')
->leftJoin('tbl_group', 'tbl_employees_promotion_transfer.GroupId', '=', 'tbl_group.GroupId')
->leftJoin('tbl_sanction_post', 'tbl_employees_promotion_transfer.SanctionPostId', '=', 'tbl_sanction_post.SanctionPostId')
->leftJoin('tbl_scheme_name', 'tbl_employees_promotion_transfer.SchemeNameId', '=', 'tbl_scheme_name.SchemeNameId')
->leftJoin('tbl_faculty', 'tbl_employees_promotion_transfer.FacultyId', '=', 'tbl_faculty.FacultyId')
->leftJoin('tbl_transfer_status', 'tbl_employees_promotion_transfer.AppointmentStatus', '=', 'tbl_transfer_status.TransferStatusId')
->orderBy('tbl_employees_promotion_transfer.PromotionTransferDate', 'DESC')
->get()
->first();
//echo $GetPrevDetail->ActualWorkPlace;
// print_r(json_encode($GetPrevDetail));
// exit;
if ($GetPrevDetail) {
$update_promotion['PrevDDO'] = $GetPrevDetail->DDOName;
$update_promotion['PrevControllingOfficer'] = $GetPrevDetail->ControllingOfficer;
$update_promotion['PrevActualWorkPlace'] = $GetPrevDetail->ActualWorkPlace;
$update_promotion['PrevDepartment'] = $GetPrevDetail->DepartmentName;
$update_promotion['PrevGroup'] = $GetPrevDetail->Group;
$update_promotion['PrevCadre'] = $GetPrevDetail->Cadre;
$update_promotion['PrevDesignation'] = $GetPrevDetail->DesignationName;
}
$update_promotion['PromotionTransferCode'] = $request->input('PromotionCode');
$update_promotion['AppointmentStatus'] = $request->input('TransferStatus');
$update_promotion['DDOId'] = $request->input('NewDDO');
$update_promotion['ControllingOfficerId'] = $request->input('NewControllingOfficer');
$update_promotion['ActualWorkPlaceId'] = $request->input('NewWorkPlace');
$update_promotion['DepartmentId'] = $request->input('NewDepartment');
$update_promotion['GroupId'] = $request->input('NewGroup');
$update_promotion['CadreId'] = $request->input('NewCadre');
$update_promotion['DesignationId'] = $request->input('NewDesignation');
$update_promotion['SanctionPostId'] = $request->input('NewSanctionPost');
$update_promotion['FacultyId'] = $request->input('NewFaculty');
$update_promotion['SchemeNameId'] = $request->input('NewScheme');
$update_promotion['ProbationPeriod'] = $ProbationPeriod;
$update_promotion['PromotionTransferTime'] = $request->input('JoiningTime');
$update_promotion['PrevRelievingTime'] = $request->input('RelievingTime');
$update_promotion['Remarks'] = $request->input('PromotionRemark');
$update_promotion['IsCurrentPosition'] = $IsCurrentPosition;
$update_promotion['Updated_by'] = session('UserId');
$update_promotion['Updated_at'] = date('Y-m-d H:i:s', time());
$promotion_update = EmployeePromotion::where('PromotionTransferId', $PromotionTransferId)->update($update_promotion);
if ($promotion_update) {
return response()->json('success');
} else {
return response()->json('failed');
}
}
#### Delete Employee Promotion
public function deleteEmpPromotion(Request $request)
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$PromotionTransferId = $request->input('PromotionTransferId');
$Updated_at = date('Y-m-d H:i:s', time());
$value = array();
$value['Updated_at'] = $Updated_at;
$value['Updated_by'] = session('UserId');
$value['IsDeleted'] = '1';
$value['Status'] = '0';
$delete_department = EmployeePromotion::where('PromotionTransferId', $PromotionTransferId)->update($value);
if ($delete_department) {
return response()->json('status_success');
} else {
return response()->json('status_failed');
}
}
#### Restore EmployeePromotion
public function restoreEmployeePromotion(Request $request)
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$PromotionTransferId = $request->input('PromotionTransferId');
$Updated_at = date('Y-m-d H:i:s', time());
$value = array();
$value['Updated_at'] = $Updated_at;
$value['Updated_by'] = session('UserId');
$value['IsDeleted'] = '0';
$value['Status'] = '1';
$restore_department = EmployeePromotion::where('PromotionTransferId', $PromotionTransferId)->update($value);
if ($restore_department) {
return response()->json('status_success');
} else {
return response()->json('status_failed');
}
}
#### Delete Permanent EmployeePromotion
public function destroyEmpPromotion(Request $request)
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$PromotionTransferId = $request->input('PromotionTransferId');
$destroyData = EmployeePromotion::where('PromotionTransferId', $PromotionTransferId);
$destroyData->delete();
if ($destroyData) {
return response()->json('status_success');
} else {
return response()->json('status_failed');
}
}
#### Change Employee Current Position
public function changeCurrentPosition(Request $request)
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$PromotionTransferId = $request->input('PromotionTransferId');
$GetEmployeeId = EmployeePromotion::where('PromotionTransferId', $PromotionTransferId)
->get()
->first();
$EmployeeId = $GetEmployeeId->EmployeeId;
/*** Update all record of that employee with status 0 to Current postion NO ***/
$update_position = EmployeePromotion::where('EmployeeId', $EmployeeId)
->update(['IsCurrentPosition' => 0]);
$Updated_at = date('Y-m-d H:i:s', time());
$value = array();
$value['IsCurrentPosition'] = 1;
$value['Updated_at'] = $Updated_at;
$value['Updated_by'] = session('UserId');
if ($update_position) {
$change_position = EmployeePromotion::where('PromotionTransferId', $PromotionTransferId)->update($value);
if ($change_position) {
return response()->json('status_success');
} else {
return response()->json('status_failed');
}
} else {
return response()->json('status_failed_update_position');
}
}
#### Submit For Approval
public function SubmitEmpPromotionApproval(Request $request, $ProfileId = '')
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$data = array();
$EmployeeId = $request->input('EmployeeId');
$ProfileId = $request->input('ProfileId');
$UserId = $request->input('UserId');
$ApprovalRemark = $request->input('ApprovalRemark');
// In case of Farward for review
$ModuleId = $request->input('ModuleId');
$data['ApprovalStatus'] = 0;
$data['Updated_by'] = session('UserId');
$data['Updated_at'] = date('Y-m-d H:i:s', time());
if ($ModuleId) {
$GetNoOfApproval = EmployeePromotion::where('EmployeeId', $EmployeeId)
->where('ApprovalLock', '1')
->where('ApprovalStatus', '0')
->where('IsDeleted', '0')
->get();
foreach ($GetNoOfApproval as $key => $ApprovalCount) {
$NoOfApproval = $ApprovalCount->NoOfApproval + 1;
// Update Employee EmployeePromotion Table in case of Farward for review
$data['NoOfApproval'] = $NoOfApproval;
$ApprovalRequest = EmployeePromotion::where('EmployeeId', $EmployeeId)
->where('ApprovalLock', '1')
->where('ApprovalStatus', '0')
->where('IsDeleted', '0')
->update($data);
}
// Update Approval Table in case of Farward for review
$update_approval['ApprovalStatus'] = '3'; // Approve = 1, Reject = 2, Forward = 3.
$update_approval['ApprovalLevel'] = $NoOfApproval;
$update_approval['Updated_by'] = session('UserId');
$update_approval['Updated_at'] = date('Y-m-d H:i:s', time());
$Update_Approval_Module = Approval::where('ModuleId', $ModuleId)
->where('ProfileId', session('ProfileId'))
->where('UserId', session('UserId'))
->where('ApprovalStatus', '=', '0')
->update($update_approval);
if ($Update_Approval_Module) {
$approval = array();
$approval['ModuleId'] = $ModuleId;
$approval['EmployeeId'] = $EmployeeId;
$approval['ModuleTitle'] = 'Promotion/Transfer';
$approval['ApprovalStatus'] = '0';
$approval['ApprovalComments'] = $ApprovalRemark;
$approval['ApprovalFrom'] = session('UserId');
$approval['ProfileId'] = $ProfileId;
$approval['UserId'] = $UserId;
//$approval['ApprovalLevel'] = '';
$approval['Created_at'] = date('Y-m-d H:i:s', time());
$approval['Created_by'] = session('UserId');
$approval['Updated_by'] = session('UserId');
$approval['Updated_at'] = date('Y-m-d H:i:s', time());
$Approval_Module_New = Approval::insert($approval);
if ($Approval_Module_New) {
return response()->json('status_success');
} else {
return response()->json('status_fail');
}
}
} else {
$data['ApprovalLock'] = 1;
$data['NoOfApproval'] = 0;
$data['ApprovalComment'] = '';
$ApprovalRequest = EmployeePromotion::where('EmployeeId', $EmployeeId)
->where('ApprovalStatus', '=', '0')
->where('ApprovalLock', '0')
->where('IsDeleted', '0')
->update($data);
if ($ApprovalRequest) {
$approval = array();
$approval['ModuleId'] = $this->userLib->useridGenrator();
$approval['EmployeeId'] = $EmployeeId;
$approval['ModuleTitle'] = 'Promotion/Transfer';
$approval['ApprovalStatus'] = '0';
$approval['ApprovalComments'] = $ApprovalRemark;
$approval['ApprovalFrom'] = session('UserId');
$approval['ProfileId'] = $ProfileId;
$approval['UserId'] = $UserId;
//$approval['ApprovalLevel'] = '';
$approval['Created_at'] = date('Y-m-d H:i:s', time());
$approval['Created_by'] = session('UserId');
$approval['Updated_at'] = date('Y-m-d H:i:s', time());
$approval['Updated_by'] = session('UserId');
$Approval_Module = Approval::insert($approval);
if ($Approval_Module) {
return response()->json('status_success');
} else {
return response()->json('status_fail');
}
}
}
}
#### Approve Employee Promotion/Transfer
public function ApproveEmpPromotion(Request $request, $EmployeeId = '', $ModuleId = '')
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$LoginUserProfileId = session('ProfileId');
$UserId = session('UserId');
$EmployeeId = $request->input('EmployeeId');
$ModuleId = $request->input('ModuleId');
$ApprovalStatusTbl = $request->input('ApprovalStatus');
$GetNoOfApproval = EmployeePromotion::select('NoOfApproval')
->where('EmployeeId', $EmployeeId)
->where('ApprovalStatus', '0')
->where('ApprovalLock', '1')
//->where('NoOfApproval', '!=', '0')
->where('IsDeleted', '0')
->orderBy('id', 'DESC')
->get()
->first();
$NoOfApproval = $GetNoOfApproval->NoOfApproval + 1;
$approval = array();
$approval['ApprovalStatus'] = $ApprovalStatusTbl;
$approval['ApprovalLevel'] = $NoOfApproval;
$approval['Updated_by'] = session('UserId');
$approval['Updated_at'] = date('Y-m-d H:i:s', time());
$ApprovalUpdate = Approval::where('ModuleId', $ModuleId)->where('EmployeeId', $EmployeeId)->where('ProfileId', $LoginUserProfileId)->where('UserId', $UserId)->update($approval);
if ($ApprovalUpdate) {
// Update Promotion/Transfer Table
$data = array();
$data['ApprovalStatus'] = 1;
$data['NoOfApproval'] = $NoOfApproval;
$data['Updated_by'] = session('UserId');
$data['Updated_at'] = date('Y-m-d H:i:s', time());
$approveData = EmployeePromotion::where('EmployeeId', $EmployeeId)
->where('ApprovalLock', '1')
->where('ApprovalStatus', '0')
->where('IsDeleted', '0')
->update($data);
return response()->json('status_success');
} else {
return response()->json('status_failed');
}
}
#### Reject Employee Promotion/Transfer
public function RejectEmpPromotion(Request $request)
{
$this->UserSessionId = session('UserId');
if (empty($this->UserSessionId)) {
return redirect('/');
}
$data = array();
$EmployeeId = $request->input('EmployeeId');
$Comment = $request->input('RejectComment');
$LoginUserProfileId = session('ProfileId');
$UserId = session('UserId');
$ModuleId = $request->input('ModuleId');
$ApprovalStatusTbl = $request->input('ApprovalStatus');
$GetNoOfApproval = EmployeePromotion::select('NoOfApproval')
->where('EmployeeId', $EmployeeId)
->where('ApprovalStatus', '0')
->where('ApprovalLock', '1')
//->where('NoOfApproval', '!=', '0')
->where('IsDeleted', '0')
->orderBy('id', 'DESC')
->get()
->first();
$NoOfApproval = $GetNoOfApproval->NoOfApproval + 1;
// Rejected = 2,
$data['ApprovalStatus'] = $ApprovalStatusTbl;
$data['ApprovalLock'] = 0;
$data['NoOfApproval'] = $NoOfApproval;
$data['ApprovalComment'] = $Comment;
$data['Updated_by'] = session('UserId');
$data['Updated_at'] = date('Y-m-d H:i:s', time());
$approval = array();
$approval['ApprovalStatus'] = $ApprovalStatusTbl;
$approval['ApprovalLevel'] = $NoOfApproval;
$approval['ApprovalComments'] = $Comment;
$approval['Updated_by'] = session('UserId');
$approval['Updated_at'] = date('Y-m-d H:i:s', time());
$ApprovalUpdate = Approval::where('ModuleId', $ModuleId)->where('EmployeeId', $EmployeeId)->where('ProfileId', $LoginUserProfileId)->where('UserId', $UserId)->update($approval);
if ($ApprovalUpdate) {
$rejectData = EmployeePromotion::where('EmployeeId', $EmployeeId)
->where('ApprovalLock', '1')
->where('ApprovalStatus', '0')
->where('IsDeleted', '0')->update($data);
if ($rejectData) {
return response()->json('status_success');
} else {
return response()->json('status_failed');
}
} else {
return response()->json('status_failed');
}
}
}