HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/dev-hrms/app/Http/Controllers/MasterDataController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\EmployeeProfile;
use App\Models\ActualWorkPlace;
use App\Models\AppointmentCategory;
use App\Models\BasicCategory;
use App\Models\Cadre;
use App\Models\DDO;
use App\Models\ControllingOfficer;
use App\Models\Group;
use App\Models\Caste;
use App\Models\Department;
use App\Models\Designation;
use App\Models\EmployeeRelation;
use App\Models\Faculty;
use App\Models\Gender;
use App\Models\MaritalStatus;
use App\Models\Appointment;
use App\Models\ParallelReservation;
use App\Models\PayScale;
use App\Models\PayBand;
use App\Models\GradePay;
use App\Models\PayLevel;
use App\Models\PayLevelAmount;
use App\Models\PensionScheme;
use App\Models\Religion;
use App\Models\SanctionPost;
use App\Models\SchemeName;
use App\Models\TransferStatus;
use App\Models\Country;
use App\Models\State;
use App\Models\Qualification;
use App\Models\EmployeePensionScheme;
use App\Models\NameTitle;
use App\Models\AwardNature;
use App\Models\PayFixation;
use App\Models\LoanAllowanceCategory;
use App\Models\EmployeePayMatrix;
use App\Models\SchemeWisePost;
use App\Models\Profiles;
use App\Models\VehicleDetail;
use App\Models\Admin;


use App\Library\UserLib;

class MasterDataController extends Controller
{
    protected $userLib;
    protected $UserSessionId;
    public function __construct(UserLib $userLib)
    {
        $this->userLib = $userLib;
    }

    public function MasterList()
    {
        $this->UserSessionId = session('UserId');
        if(empty($this->UserSessionId))
        {
            return redirect('/'); 
        }
        $ActualWorkPlace = ActualWorkPlace::select('tbl_actual_work_place.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('ActualWorkPlaceName', 'ASC')
            ->get();
        $AppointmentCategory = AppointmentCategory::select('tbl_appointment_category.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('AppointmentCategoryName', 'ASC')
            ->get();
        $Appointment = Appointment::select('tbl_appointment.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('AppointmentByName', 'ASC')
            ->get();
        $BasicCategory = BasicCategory::select('tbl_basic_category.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('BasicCategoryName', 'ASC')
            ->get();
        $Cadre = Cadre::select('tbl_cadre.*', 'tbl_group.GroupName as GroupName')
            ->leftJoin('tbl_group', 'tbl_cadre.GroupId', '=', 'tbl_group.GroupId')
            ->where('tbl_cadre.IsDeleted', '=', '0')
            ->orderBy('CadreName', 'ASC')
            ->get();
        $Caste = Caste::select('tbl_caste.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('CasteName', 'ASC')
            ->get();
        $ControllingOfficer = ControllingOfficer::select('tbl_controlling_officer.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('ControllingOfficerName', 'ASC')
            ->get();
        $DDO = DDO::select('tbl_ddo.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('DDOName', 'ASC')
            ->get();
        $Department = Department::select('tbl_department.*', 'tbl_actual_work_place.ActualWorkPlaceName as ActualWorkPlaceName')
            ->leftJoin('tbl_actual_work_place', 'tbl_department.ActualWorkPlaceId', '=', 'tbl_actual_work_place.ActualWorkPlaceId')
            ->where('tbl_department.IsDeleted', '=', '0')
            ->orderBy('tbl_department.DepartmentName', 'ASC')
            ->get();
        $Designation = Designation::select('tbl_designation.*', 'tbl_cadre.CadreName as CadreName', 'tbl_group.GroupName as GroupName')
            ->leftJoin('tbl_cadre', 'tbl_designation.CadreId', '=', 'tbl_cadre.CadreId')
            ->leftJoin('tbl_group', 'tbl_designation.GroupId', '=', 'tbl_group.GroupId')
            ->where('tbl_designation.IsDeleted', '=', '0')
            ->orderBy('tbl_designation.DesignationName', 'ASC')
            ->get();
        $EmployeeRelation = EmployeeRelation::select('tbl_employee_relation.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('EmployeeRelationName', 'ASC')
            ->get();
        $Faculty = Faculty::select('tbl_faculty.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('FacultyName', 'ASC')
            ->get();
        $Gender = Gender::select('tbl_gender.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('GenderName', 'ASC')
            ->get();
        $Group = Group::select('tbl_group.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('GroupName', 'ASC')
            ->get();
        $MaritalStatus = MaritalStatus::select('tbl_marital_status.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('MaritalStatusName', 'ASC')
            ->get();
        $ParallelReservation = ParallelReservation::select('tbl_parallel_reservation.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('ParallelReservationName', 'ASC')
            ->get();
        $PayScale = PayScale::select('tbl_payscale.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('PayScaleName', 'ASC')
            ->get();
        $PayBand = PayBand::select('tbl_payband.*', 'tbl_payscale.PayScaleName as PayScaleName')
            ->LeftJoin('tbl_payscale', 'tbl_payband.PayScaleId', '=', 'tbl_payscale.PayScaleId')
            ->where('tbl_payband.IsDeleted', '=', '0')
            ->orderBy('tbl_payband.PayBandName', 'ASC')
            ->get();
        $GradePay = GradePay::select('tbl_gradepay.*', 'tbl_payscale.PayScaleName as PayScaleName', 'tbl_payband.PayBandName as PayBandName')
            ->LeftJoin('tbl_payscale', 'tbl_gradepay.PayScaleId', '=', 'tbl_payscale.PayScaleId')
            ->LeftJoin('tbl_payband', 'tbl_gradepay.PayBandId', '=', 'tbl_payband.PayBandId')
            ->where('tbl_gradepay.IsDeleted', '=', '0')
            ->orderBy('tbl_gradepay.GradePayName', 'ASC')
            ->get();
        $PayLevel = PayLevel::select('tbl_paylevel.*', 'tbl_payscale.PayScaleName as PayScaleName', 'tbl_payband.PayBandName as PayBandName', 'tbl_gradepay.GradePayName as GradePayName')
            ->LeftJoin('tbl_payscale', 'tbl_paylevel.PayScaleId', '=', 'tbl_payscale.PayScaleId')
            ->LeftJoin('tbl_payband', 'tbl_paylevel.PayBandId', '=', 'tbl_payband.PayBandId')
            ->LeftJoin('tbl_gradepay', 'tbl_paylevel.GradePayId', '=', 'tbl_gradepay.GradePayId')
            ->where('tbl_paylevel.IsDeleted', '=', '0')
            ->orderBy('tbl_paylevel.PayLevelName', 'ASC')
            ->get();
        $PayLevelAmount = PayLevelAmount::select('tbl_paylevel_amount.*', 'tbl_paylevel.PayLevelName as PayLevelName', 'tbl_paylevel.AmountRange as AmountRange', 'tbl_payscale.PayScaleName as PayScaleName', 'tbl_payband.PayBandName as PayBandName', 'tbl_gradepay.GradePayName as GradePayName')
            ->LeftJoin('tbl_paylevel', 'tbl_paylevel_amount.PayLevelId', '=', 'tbl_paylevel.PayLevelId')
            ->LeftJoin('tbl_payscale', 'tbl_paylevel_amount.PayScaleId', '=', 'tbl_payscale.PayScaleId')
            ->LeftJoin('tbl_payband', 'tbl_paylevel_amount.PayBandId', '=', 'tbl_payband.PayBandId')
            ->LeftJoin('tbl_gradepay', 'tbl_paylevel_amount.GradePayId', '=', 'tbl_gradepay.GradePayId')
            ->where('tbl_paylevel_amount.IsDeleted', '=', '0')
            ->orderBy('tbl_paylevel_amount.PayLevelAmount', 'ASC')
            ->get();
        $PensionScheme = PensionScheme::select('tbl_pension_scheme.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('PensionSchemeName', 'ASC')
            ->get();
        $Religion = Religion::select('tbl_religion.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('ReligionName', 'ASC')
            ->get();
        $SanctionPost = SanctionPost::select('tbl_sanction_post.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('SanctionPostName', 'ASC')
            ->get();
        $SchemeName = SchemeName::select('tbl_scheme_name.*')
            ->where('IsDeleted', '=', '0')
            ->orderBy('NameOfScheme', 'ASC')
            ->get();
        $SchemeWisePost = SchemeWisePost::select('tbl_scheme_wise_post.*', 'tbl_scheme_name.NameOfScheme as SchemeName', 'tbl_cadre.CadreName as Cadre', 'tbl_designation.DesignationName as Designation', 'tbl_group.GroupName as Group')
            ->leftJoin('tbl_scheme_name', 'tbl_scheme_wise_post.SchemeNameId', '=', 'tbl_scheme_name.SchemeNameId')
            ->leftJoin('tbl_designation', 'tbl_scheme_wise_post.DesignationId', '=', 'tbl_designation.DesignationId')
            ->leftJoin('tbl_group', 'tbl_scheme_wise_post.GroupId', '=', 'tbl_group.GroupId')
            ->leftJoin('tbl_cadre', 'tbl_scheme_wise_post.CadreId', '=', 'tbl_cadre.CadreId')
            ->where('tbl_scheme_wise_post.IsDeleted', '=', '0')
            ->orderBy('id', 'ASC')
            ->get();

        return view('admin.master-data', ['ActualWorkPlace' => $ActualWorkPlace, 'AppointmentCategory' => $AppointmentCategory, 'Appointment' => $Appointment, 'BasicCategory' => $BasicCategory, 'Cadre' => $Cadre, 'Caste' => $Caste, 'DDO' => $DDO, 'ControllingOfficer' => $ControllingOfficer, 'Department' => $Department, 'Designation' => $Designation, 'EmployeeRelation' => $EmployeeRelation, 'Faculty' => $Faculty, 'Gender' => $Gender, 'Group' => $Group, 'MaritalStatus' => $MaritalStatus, 'ParallelReservation' => $ParallelReservation, 'PayScale' => $PayScale, 'PayBand' => $PayBand,  'PayLevel' => $PayLevel, 'PayLevelAmount' => $PayLevelAmount, 'PensionScheme' =>$PensionScheme, 'GradePay' => $GradePay, 'Religion' => $Religion, 'SanctionPost' => $SanctionPost, 'SchemeName' => $SchemeName, 'SchemeWisePost' => $SchemeWisePost]);
    }

    ### Master List Start Here
    
    ### Designation Master List
    public function designationList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $DesignationList = Designation::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('DesignationName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'Designation' => $DesignationList,
        ]);
    }
    ### DDO Master List
    public function ddoList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $DDOList = DDO::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('DDOName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'DDOList' => $DDOList,
        ]);
    }
    ### Controlling Officer Master List
    public function controllingOfficerList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $ControllingOfficerList = ControllingOfficer::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('ControllingOfficerName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'ControllingOfficerList' => $ControllingOfficerList,
        ]);
    }
    ### Get Designation List
    public function getDesignationList($CadreId)
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $GetDesignationList = Designation::select('tbl_designation.*')
        ->where('CadreId', $CadreId)
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('DesignationName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'Designation' => $GetDesignationList,
        ]);
    }

    ### Appointment By Master List
    public function appointmentByList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $AppointmentByList = Appointment::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('AppointmentByName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'AppointmentBy' => $AppointmentByList,
        ]);
    }

    ## profileList
    public function profileList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $ProfileList = Profiles::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('Sequence', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'ProfileList' => $ProfileList,
        ]);
    }
    
    ### Actual Work Place Master List
    public function actualWorkPlaceList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $AWPList = ActualWorkPlace::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('ActualWorkPlaceName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'AWPList' => $AWPList,
        ]);
    }

    ### Religion Master List
    public function religionList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $Religion = Religion::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('ReligionName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'Religion' => $Religion,
        ]);
    }
    
    ### Caste Master List
    public function casteList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $Caste = Caste::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('CasteName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'Caste' => $Caste,
        ]);
    }
    
    ### Basic Category Master List
    public function basicCategoryList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $BasicCategory = BasicCategory::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('BasicCategoryName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'BasicCategory' => $BasicCategory,
        ]);
    }

    ### Appointment Category Master List
    public function appointmentCategoryList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $AppointmentCategory = AppointmentCategory::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('AppointmentCategoryName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'AppointmentCategory' => $AppointmentCategory,
        ]);
    }

    ### Parallel Reservation Master List
    public function parallelReservationList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $ParallelReservation = ParallelReservation::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('ParallelReservationName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'ParallelReservation' => $ParallelReservation,
        ]);
    }

    ### Cadre Master List
    public function cadreList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $Cadre = Cadre::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('CadreName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'Cadre' => $Cadre,
        ]);
    }

    ### Get Cadre List by GroupId
    public function getCadreList($GroupId)
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $Cadre = Cadre::select('tbl_cadre.*')
        ->where('GroupId', $GroupId)
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('CadreName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'Cadre' => $Cadre,
        ]);
    }

    ### Sanction Post Master List
    public function sanctionPostList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $SanctionPost = SanctionPost::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('SanctionPostName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'SanctionPost' => $SanctionPost,
        ]);
    }

    ### Faculty Master List
    public function facultyList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $Faculty = Faculty::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('FacultyName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'Faculty' => $Faculty,
        ]);
    }

    ### Department Master List
    public function departmentList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $Department = Department::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('DepartmentName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'Department' => $Department,
        ]);
    }

    ### Get Department List 
    public function getDepartmentList($AwpId)
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $GetDepartment = Department::select('tbl_department.*')
        ->where('ActualWorkPlaceId', $AwpId)
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('DepartmentName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'Department' => $GetDepartment,
        ]);
    }

    ### Gender Master List
    public function genderList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $Gender = Gender::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('GenderName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'Gender' => $Gender,
        ]);
    }

    ### Group Master List
    public function groupList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $Group = Group::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('GroupName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'Group' => $Group,
        ]);
    }

    ### Marital Status Master List
    public function maritalStatusList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $MaritalStatus = MaritalStatus::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('MaritalStatusName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'MaritalStatus' => $MaritalStatus,
        ]);
    }

    ### PayScale Master List
    public function payScaleList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $PayScale = PayScale::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('PayScaleName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'PayScale' => $PayScale,
        ]);
    }

    ### PayBand Master List
    public function payBandList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $PayBand = PayBand::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('PayBandName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'PayBand' => $PayBand,
        ]);
    }

    ### Get PayBand List by PayScaleId
    public function getPayBandList($PayScaleId)
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $GetPayBand = PayBand::select('tbl_payband.*')
        ->where('PayScaleId', $PayScaleId)
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('PayBandName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'PayBand' => $GetPayBand,
        ]);
    }

    ### Get GradePay List by PayBandId
    public function getGradePayList($PayBandId)
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $GetGradePay = GradePay::select('tbl_gradepay.*')
        ->where('PayBandId', $PayBandId)
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('GradePayName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'GradePay' => $GetGradePay,
        ]);
    }

    ### Get PayLevel List by PayScaleId
    public function getPayLevelList($PayScaleId)
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        
        $GetPayLevel = PayLevel::select('tbl_paylevel.*')
        ->where('PayScaleId', $PayScaleId)
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('id', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'PayLevel' => $GetPayLevel,
        ]);
    }

    ### All PayLevel List by PayScaleId
    public function payLevelList(Request $request)
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $PayLevelList = PayLevel::select('tbl_paylevel.*')
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('id', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'PayLevelList' => $PayLevelList,
        ]);
    }

    ### Get PayLevel Amount List by PayLevelId
    public function getPayLevelAmountList($PayLevelId)
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $GetPayLevelAmount = PayLevelAmount::select('tbl_paylevel_amount.*')
        ->where('PayLevelId', $PayLevelId)
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('id', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'PayLevelAmount' => $GetPayLevelAmount,
        ]);
    }

    ### Pension Scheme List  
    public function pensionSchemeList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $PensionScheme = PensionScheme::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('PensionSchemeName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'PensionScheme' => $PensionScheme,
        ]);
    }

    public function getPensionSchemeList(Request $request)
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }

        $EmployeeId = $request->input('EmployeeId');

        $PensionScheme = EmployeePensionScheme::select('tbl_employee_pension_scheme.*', 'tbl_pension_scheme.PensionSchemeName as PensionSchemeName')
        ->leftJoin('tbl_pension_scheme', 'tbl_employee_pension_scheme.PensionSchemeId', '=', 'tbl_pension_scheme.PensionSchemeId')
        ->where('tbl_employee_pension_scheme.EmployeeId', $EmployeeId)
        ->where('tbl_employee_pension_scheme.Status', '1')
        ->where('tbl_employee_pension_scheme.IsDeleted', '0')
        ->orderBy('tbl_pension_scheme.PensionSchemeName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'PensionScheme' => $PensionScheme,
        ]);
    }

    ### Employee Master List 
    public function employeeList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $EmployeeList = EmployeeProfile::select('tbl_employees.*')
        ->where('tbl_employees.Status', '1')
        ->where('tbl_employees.IsDeleted', '0')
        ->orderBy('tbl_employees.id', 'DESC')
        ->get();
        return response()->json([
            'status' => 200,
            'EmployeeList' => $EmployeeList,
        ]);
    }

    
    ### Employee Relation Type Master List 
    public function relationTypeList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $EmployeeRelation = EmployeeRelation::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('EmployeeRelationName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'EmployeeRelation' => $EmployeeRelation,
        ]);
    }

    ### Scheme Name Master List 
    public function schemeNameList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $SchemeNameList = SchemeName::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('NameOfScheme', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'SchemeNameList' => $SchemeNameList,
        ]);
    }

   ### Vehicle Name Master List 
    public function vehicleNameList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $VehicleNameList = VehicleDetail::select()
        ->where('Status', '1')
        ->orderBy('VehicleName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'VehicleNameList' => $VehicleNameList,
        ]);
    }

    ### Transfer Status Master List 
    public function transferStatusList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $TransferStatusList = TransferStatus::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('TransferStatusName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'TransferStatusList' => $TransferStatusList,
        ]);
    }

    ### Qualification Master List 
    public function qualificationList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $QualificationList = Qualification::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('QualificationName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'QualificationList' => $QualificationList,
        ]);
    }

    ### Name Title Master List 
    public function nameTitleList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $NameTitle = NameTitle::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('NameTitle', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'NameTitle' => $NameTitle,
        ]);
    }
    ### Award Nature Master List 
    public function awardNatureList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $AwardNature = AwardNature::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('AwardNature', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'AwardNature' => $AwardNature,
        ]);
    }

    ### Pay Fixation List 
    public function payFixationList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $PayFixation = PayFixation::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('PayFixation', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'PayFixation' => $PayFixation,
        ]);
    }

    ### OrderNo List PayMatrix 
    public function getEmpPayMatrixOrderList(Request $request)
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $EmployeeId = $request->input('EmployeeId');

        $EmpPayMatrixOrder = EmployeePayMatrix::select('tbl_employees_paymatrix.*')
        ->where('EmployeeId', $EmployeeId)
        //->where('Status', '1')
        ->where('IsDeleted', '0')
        ->where('IsCancelled', '0')
        ->where('SanctionedOrderNo', '!=', '')
        ->groupBy('SanctionedOrderNo')
        //->orderBy('EffectiveDate', 'DESC')
        ->get();
        return response()->json([
            'status' => 200,
            'EmpPayMatrixOrder' => $EmpPayMatrixOrder,
        ]);
    }

    ### Loan and Allowances  
    public function loanAllowanceCategoryList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $AllowanceCategoryList = LoanAllowanceCategory::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->orderBy('AllowanceCategoryName', 'ASC')
        ->get();
        return response()->json([
            'status' => 200,
            'AllowanceCategoryList' => $AllowanceCategoryList,
        ]);
    }

    ### Officer Name Master List 
    public function officerNameList()
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $officerNameList = Profiles::select()
        ->where('Status', '1')
        ->where('IsDeleted', '0')
        ->get();
        return response()->json([
            'status' => 200,
            'officerNameList' => $officerNameList,
        ]);
    }
    ### Officer Wise Name  
    public function profileWiseNameList($ProfileId)
    {
        $this->UserSessionId = session('UserId');
        if (empty($this->UserSessionId)) {
            return redirect('/');
        }
        $officerWiseName = Admin::select()
        ->where('isActive', '1')
        ->where('ProfileId', $ProfileId)
        ->get();
        return response()->json([
            'status' => 200,
            'officerWiseName' => $officerWiseName,
        ]);
    }

}