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/hrms-production/resources/views/admin/EmployeeProfile/previous-job-detail.blade.php
@extends('admin.include.master')

@section('content')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="container-fluid">
            {{-- <div class="row mb-2">
                <div class="col-sm-6">
                    <h1>All Employees</h1>
                </div>
                <div class="col-sm-6 text-right">
                    <button type="button" class="btn btn-sm btn-outline-info mx-1" data-toggle="modal"
                        data-target="#">Add Prev</button>
                </div>
            </div> --}}
        </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">

            {{-- Previous Job Detail --}}
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h5>Employee Previous Job Detail</h5>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <form class="form-horizontal" id="empPreviousJobForm">
                                <input type="hidden" name="_token" id="csrf_token" value="{{ csrf_token() }}">
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="form-group row mb-0">
                                            <label for="EmployeeCode" class="col-sm-4 col-form-label text-right"><span
                                                    class="text-danger">*</span> Employee Code:</label>
                                            <div class="col-sm-8">
                                                <select class="form-control form-control-sm select2"
                                                    style="width: 100%;" aria-hidden="true" name="EmployeeCode"
                                                    id="EmployeeCode" data-placeholder="Employee Code">
                                                    <option value="" selected disabled>Employee Code</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="DDO" class="col-sm-4 col-form-label text-right">
                                                Previous DDO:</label>
                                            <div class="col-sm-8">
                                                <input type="text" id="DDO" name="DDO"
                                                    class="form-control form-control-sm">
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="ControllingOfficer"
                                                class="col-sm-4 col-form-label text-right">Controlling Officer:</label>
                                            <div class="col-sm-8">
                                                <input type="text" id="ControllingOfficer" name="ControllingOfficer"
                                                    class="form-control form-control-sm">
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="PrevSanctionPost"
                                                class="col-sm-4 col-form-label text-right">Prev Sanction Post:</label>
                                            <div class="col-sm-8">
                                                <input type="text" id="SanctionPost" name="PrevSanctionPost"
                                                    class="form-control form-control-sm">
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="PrevPayScale" class="col-sm-4 col-form-label text-right">Prev
                                                Pay Scale:</label>
                                            <div class="col-sm-8">
                                                <select class="form-control form-control-sm select2"
                                                    style="width: 100%;" aria-hidden="true" name="PrevPayScale"
                                                    id="PrevPayScale" data-placeholder="Select PayScale">
                                                    <option value="" selected disabled>Select PayScale</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0" id="PayBandId_field" style="display: none;">
                                            <label for="PayBandId" class="col-sm-4 col-form-label text-right">Prev Pay
                                                Band:</label>
                                            <div class="col-sm-8">
                                                <select class="form-control form-control-sm select2"
                                                    style="width: 100%;" aria-hidden="true" name="PayBandId"
                                                    id="PayBandId" data-placeholder="Select PayBand">
                                                    <option value="" disabled selected>Select PayBand</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0" id="GradePayId_field" style="display: none;">
                                            <label for="PrevGradePay" class="col-sm-4 col-form-label text-right">Prev
                                                Grade Pay:</label>
                                            <div class="col-sm-8">
                                                <select class="form-control form-control-sm select2"
                                                    style="width: 100%;" aria-hidden="true" name="PrevGradePay"
                                                    id="GradePayId" data-placeholder="Select GradePay">
                                                    <option value="" disabled selected>Select GradePay</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0" id="PayLevelId_field" style="display: none;">
                                            <label for="PrevPayLevel" class="col-sm-4 col-form-label text-right">Prev
                                                PayLevel</label>
                                            <div class="col-sm-8">
                                                <select class="form-control form-control-sm select2"
                                                    style="width: 100%;" aria-hidden="true" name="PayLevelId"
                                                    id="PayLevelId" data-placeholder="Select PayLevel">
                                                    <option value="" disabled selected>Select PayLevel</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0" id="PayLevelAmount_field">
                                            <label for="PrevPayLevelAmount"
                                                class="col-sm-4 col-form-label text-right">Prev BasicPay + GP:</label>
                                            <div class="col-sm-8">
                                                <input type="text" id="PayLevelAmount" name="PayLevelAmount"
                                                    class="form-control form-control-sm">
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0" id="PayLevelAmountId_field"
                                            style="display: none;">
                                            <label for="PayLevelAmount" class="col-sm-4 col-form-label text-right">Basic
                                                Pay</label>
                                            <div class="col-sm-8">
                                                <select class="form-control form-control-sm select2"
                                                    style="width: 100%;" aria-hidden="true" name="PayLevelAmountId"
                                                    id="PayLevelAmountId" data-placeholder="Select PayLevel">
                                                    <option value="" disabled selected>Select PayLevel Amount</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="PromotionDate" class="col-sm-4 col-form-label text-right"><span
                                                    class="text-danger">*</span> From
                                                Date:</label>
                                            <div class="col-sm-8">
                                                <div class="form-group mb-2">
                                                    <div class="input-group date" id="jobFromDate"
                                                        data-target-input="nearest">
                                                        <input type="text" id="fromDate" name="jobFromDate"
                                                            class="form-control form-control-sm datetimepicker-input"
                                                            data-target="#fromDate" placeholder="DD/MM/YYYY" required />
                                                        <div class="input-group-append" data-target="#fromDate"
                                                            data-toggle="datetimepicker">
                                                            <div class="input-group-text"><i class="fa fa-calendar"></i>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="Station"
                                                class="col-sm-4 col-form-label text-right">Station:</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control form-control-sm" name="Station"
                                                    id="station">
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="DA" class="col-sm-4 col-form-label text-right">DA:</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control form-control-sm"
                                                    name="DearnessAllowance" id="dearnessAllowance">
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="ReasonForLeavingJob"
                                                class="col-sm-4 col-form-label text-right">Reason For Leaving
                                                Job:</label>
                                            <div class="col-sm-8">
                                                <textarea type="text" class="form-control form-control-sm"
                                                    name="ReasonForLeavingJob" id="reasonForLeavingJob"></textarea>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group row mb-0">
                                            <label for="EmployeeName"
                                                class="col-sm-4 col-form-label text-right">Employee Name:</label>
                                            <div class="col-sm-8">
                                                <div class="input-group">
                                                    <div class="input-group-prepend">
                                                        <span class="input-group-text"><i class="fas fa-pen"></i></span>
                                                    </div>
                                                    <input type="text" class="form-control form-control-sm"
                                                        name="EmployeeName" id="employeeName" readonly>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="form-group row mb-0">
                                            <label for="PreviousLocation"
                                                class="col-sm-4 col-form-label text-right">Previous Location:</label>
                                            <div class="col-sm-8">
                                                <input type="text" id="PreviousLocation" name="PreviousLocation"
                                                    class="form-control form-control-sm">
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="Department" class="col-sm-4 col-form-label text-right">Prev
                                                Department:</label>
                                            <div class="col-sm-8">
                                                <input type="text" id="Department" name="Department"
                                                    class="form-control form-control-sm">
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="PrevGroup" class="col-sm-4 col-form-label text-right">Prev
                                                Group:</label>
                                            <div class="col-sm-8">
                                                <input type="text" id="Group" name="Group"
                                                    class="form-control form-control-sm">
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="PrevCadre" class="col-sm-4 col-form-label text-right">Prev
                                                Cadre:</label>
                                            <div class="col-sm-8">
                                                <input type="text" id="Cadre" name="Cadre"
                                                    class="form-control form-control-sm">
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="PrevDesignation" class="col-sm-4 col-form-label text-right">Prev
                                                Designation:</label>
                                            <div class="col-sm-8">
                                                <input type="text" id="Designation" name="Designation"
                                                    class="form-control form-control-sm">
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="ToDate" class="col-sm-4 col-form-label text-right"><span
                                                    class="text-danger">*</span> To
                                                Date:</label>
                                            <div class="col-sm-8">
                                                <div class="form-group mb-2">
                                                    <div class="input-group date" id="jobToDate"
                                                        data-target-input="nearest">
                                                        <input type="text" id="toDate" name="jobToDate"
                                                            class="form-control form-control-sm datetimepicker-input"
                                                            data-target="#toDate" placeholder="DD/MM/YYYY" required />
                                                        <div class="input-group-append" data-target="#toDate"
                                                            data-toggle="datetimepicker">
                                                            <div class="input-group-text"><i class="fa fa-calendar"></i>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="InService" class="col-sm-4 col-form-label text-right">In
                                                Service:</label>
                                            <div class="col-sm-8">
                                                <div class="icheck-primary">
                                                    <input type="checkbox" name="InService" id="InService">
                                                    <label for="InService"></label>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="LastPayCertificate"
                                                class="col-sm-4 col-form-label text-right">Last pay certificate:</label>
                                            <div class="col-sm-8">
                                                <div class="input-group input-group-sm">
                                                    <div class="custom-file">
                                                        <input type="file" class="custom-file-input"
                                                            name="LastPayCertificate" id="lastPayCertificate"
                                                            accept="image/*, .pdf">
                                                        <label class="custom-file-label" for="LastPayCertificate">Choose
                                                            file</label>
                                                    </div>
                                                    <div class="input-group-append">
                                                        <button type="button" id="removeLastPayCertificate"
                                                            class="btn btn-warning text-white">Remove file</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="SubmittedResignation"
                                                class="col-sm-4 col-form-label text-right">Submitted
                                                Resignation:</label>
                                            <div class="col-sm-8">
                                                <div class="input-group input-group-sm mt-3">
                                                    <div class="custom-file">
                                                        <input type="file" class="custom-file-input"
                                                            name="SubmittedResignation" id="submittedResignation"
                                                            accept="image/*, .pdf">
                                                        <label class="custom-file-label"
                                                            for="SubmittedResignation">Choose
                                                            file</label>
                                                    </div>
                                                    <div class="input-group-append">
                                                        <button type="button" id="removeSubmittedResignation"
                                                            class="btn btn-warning text-white">Remove file</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group row mb-0">
                                            <label for="text" class="col-sm-4 col-form-label text-right"></label>
                                            <div class="col-sm-8">
                                                <small class="text-danger mt-3">(Size should not be greater than
                                                    20MB)</small><br />
                                                <small class="text-danger mt-3">(Supported file types are .jpg, .jpeg,
                                                    .pjpeg, .bmp, .gif, .png and .pdf)</small>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <div class="form-group row">
                                            <button type="submit" id="btn-save-job-detail"
                                                class="btn btn-warning text-white">Save</button> &nbsp;&nbsp;
                                            <button type="button" onclick="formReset();"
                                                class="btn btn-warning text-white">Reset</button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <!-- /.card-body -->
                    </div>
                    <!-- /.card -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </div>
        <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
</div>

{{-- JS Start Here --}}

{{-- Reset Form Button --}}
<script>
    function formReset()
  { 
    Swal.fire({
            title: 'Do you want to reset form?',
            text: "Are you sure you want to reset this form!",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, reset it!'
        }).then(function() {
            $('form#empPreviousJobForm').each(function() {
                    this.reset();
                });
            });
  }

  // Remove File

  $("#removeLastPayCertificate").on("click", function() {
    
    var fileName = $('#lastPayCertificate').val();
    
    if(fileName) { 
        Swal.fire({
            title: 'Do you want to remove file?',
            text: "Are you sure you want to remove this file!",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, remove it!'
        }).then(function() {
            $('#lastPayCertificate').val('');
        });
    } else {
        Swal.fire({
            icon: 'error',
            title: 'Oops! There is no file.',
            showConfirmButton: false,
            timer: 2000
            });
    }
    });
</script>

<script>
    $(function() {
            $("#emplaoyeeTable").DataTable({
                "responsive": true,
                "lengthChange": true,
                "autoWidth": false,
                "lengthMenu": [10, 20, 50, 100, 250, 500],
                //"buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
            }).buttons().container().appendTo('#userTable_wrapper .col-md-6:eq(0)');
        });
</script>

{{-- Employee List --}}
<script>
    $(document).ready(function() {
        $.ajax({
          type: "GET",
          url: "{{ url('/employee-list') }}",
          dataType: "json",
          success: function(response) {
            var json = response.EmployeeList;
            $.each(json, function(i, employee) {
              $("#EmployeeCode").append("<option value='" + employee.EmployeeId + "'>" + employee.EmployeeCode + " (" + employee.EmployeeName + ") " + "</option>");
              $('#EmployeeCode').trigger('change');
            });
          }
        });
    });

    // Get Employee Details
    $('#EmployeeCode').on('select2:select', function (e) {
        var data = e.params.data;
        var EmployeeId = data.id;
        getEmployeeDetail(EmployeeId);
        //getEmpQualificationList(EmployeeId);
        // Reset field on change Employee Code
     //   $('.select2').val(null).trigger('change');
    });

    function getEmployeeDetail(EmployeeId){
        var EmployeeId = EmployeeId;
            $.ajax({
            type: "post",
            url: "{{ url('/') }}/get-employee-current-detail",
            dataType: "json",
            data: { 
                    _token: "{{csrf_token()}}",
                    EmployeeId: EmployeeId,
                },
            success: function(response) {
                var json = response.GetEmpCurrentDetail;
                $('#EmployeeId').val(json.EmployeeId);
                $('#EmpCode').val(json.EmployeeCode);
                $('#employeeName').val(json.EmployeeName);
                $('#employeeDepartment').val(json.DepartmentName);
                $('#employeeDesignation').val(json.DesignationName);
                $('span#EmployeeTableTitle').html('#' +json.EmployeeName+ ' (' +json.EmployeeCode+ ')' );
            }
        });
    }
</script>
{{-- Master Data List assign to field --}}
<script>
    // PayScale List
    $(document).ready(function() {
          $.ajax({
            type: "GET",
            url: "{{ url('/payscale-list') }}",
            dataType: "json",
            success: function(response) {
              var json = response.PayScale;
              $.each(json, function(i, payscale) {
                $("#PrevPayScale").append("<option value='" + payscale.PayScaleId + "'>" + payscale.PayScaleName + "</option>");
                $('#PrevPayScale').trigger('change');
              });
            }
          });
      });
  
    // PayBand List
    $(document).ready(function() {
          $.ajax({
            type: "GET",
            url: "{{ url('/payband-list') }}",
            dataType: "json",
            success: function(response) {
              var json = response.PayBand;
              $.each(json, function(i, payband) {
                $("#PayBandId").append("<option value='" + payband.PayBandId + "'>" + payband.PayBandName + "</option>");
                $('#PayBandId').trigger('change');
              });
            }
          });
      });
</script>

{{-- Change Field based payscale --}}
<script>
    $(document).ready(function() {
          $("#PrevPayScale").change(function() {
              //alert($(this).val())
                  $('#PayBandId').val(null).trigger('change');
                  $('#GradePayId').empty();
                  $('#PayLevelId').val(null).trigger('change');
                  $('#PayLevelAmount').val('');
                  $('#PayLevelAmountId').empty();
              if ($(this).val() == "l7Is9HD8Yr2nMQKmSwm189AEr3yawtvPrZrn4") { // 6th payscale
                  $("#PayLevelId_field").css('display', 'none');
                  //$("#PayLevelId").prop('required', false);
                  $("#PayLevelAmountId_field").css('display', 'none');
                  //$("#PayLevelAmountId").prop('required', false);
                  $("#PayBandId_field").css('display', '');
                  //$("#PayBandId").prop('required', true);
                  $("#GradePayId_field").css('display', '');
                  //$("#GradePayId").prop('required', true);
                  $("#PayLevelAmount_field").css('display', '');
                  $("#PayLevelAmount").prop('required', true);
              } else if ($(this).val() == "KmmsPcY7uGEnMyRYmSYlD66z6dwLsMtqG19Qs") { // 7th payscale
                  $("#PayLevelId_field").css('display', '');
                  //$("#PayLevelId").prop('required', true);
                  $("#PayLevelAmountId_field").css('display', '');
                  //$("#PayLevelAmountId").prop('required', true);
                  $("#PayBandId_field").css('display', 'none');
                  $("#PayBandId").prop('required', false);
                  $("#GradePayId_field").css('display', 'none');
                  $("#GradePayId").prop('required', false);
                  //$("#PayLevelAmount_field").css('display', 'none');
                  $("#PayLevelAmount").prop('required', false);
              } else if ($(this).val() == "jpWwVaivsVq9dys2kPocbd0kfmQeM7FM8DuRm" || $(this).val() == "aJd0V3oRX2YI5G8hVN6PTDU1WrSIjOE9oQmSU") {
                  $("#PayLevelId_field").css('display', 'none');
                  $("#PayLevelId").prop('required', false);
                  $("#PayLevelAmountId_field").css('display', 'none');
                  $("#PayLevelAmountId").prop('required', false);
                  $("#PayBandId_field").css('display', 'none');
                  $("#PayBandId").prop('required', false);
                  $("#GradePayId_field").css('display', 'none');
                  $("#GradePayId").prop('required', false);
                  $("#PayLevelAmount_field").css('display', '');
                  $("#PayLevelAmount").prop('required', true);
              }
          });
      });
</script>

{{-- PayScale / PayGrade / PayLevel / PayLevel Amount--}}
<script>
    $('#PayBandId').on('select2:select', function (e) {
        //alert(e.params.data);
          var data = e.params.data;
          var PayBandId = data.id;
          getGradePayList(PayBandId);
      });
      function getGradePayList(PayBandId){
          var PayBandId = PayBandId;
          $('#PrevGradePayId').empty();
              $.ajax({
              type: "GET",
              url: "{{ url('/') }}/get-gradepay-list/" +PayBandId,
              dataType: "json",
              success: function(response) {
                  var json = response.GradePay;
                  $.each(json, function(i, gradepay) {
                      $("#GradePayId").append("<option value='" + gradepay.GradePayId + "'>" + gradepay.GradePayName + "</option>");
                      $('#GradePayId').val(null).trigger('change');
                  });
              }
          });
      }
      // Get PayLevel List based on PayScale
      $('#PrevPayScale').on('select2:select', function (e) {
        //alert(e.params.data);
          var data = e.params.data;
          var PayScaleId = data.id;
          getPayLevelList(PayScaleId);
      });
      function getPayLevelList(PayScaleId){
          var PayScaleId = PayScaleId;
          $('#PayLevelId').empty();
              $.ajax({
              type: "GET",
              url: "{{ url('/') }}/get-paylevel-list/" +PayScaleId,
              dataType: "json",
              success: function(response) {
                  var json = response.PayLevel;
                  $.each(json, function(i, paylevel) {
                      $("#PayLevelId").append("<option value='" + paylevel.PayLevelId + "'>" + paylevel.PayLevelName + " (" + paylevel.AmountRange + ")" +"</option>");
                      $('#PayLevelId').val(null).trigger('change');
                  });
              }
          });
      }
      // PayLevel Amount on select PayLevel
      $('#PayLevelId').on('select2:select', function (e) {
        //alert(e.params.data);
          var data = e.params.data;
          var PayLevelId = data.id;
          getPayLevelAmountList(PayLevelId);
      });
      function getPayLevelAmountList(PayLevelId){
          var PayLevelId = PayLevelId;
          $('#PayLevelAmountId').empty();
              $.ajax({
              type: "GET",
              url: "{{ url('/') }}/get-paylevel-amount-list/" +PayLevelId,
              dataType: "json",
              success: function(response) {
                  var json = response.PayLevelAmount;
                  $.each(json, function(i, paylevelamount) {
                      $("#PayLevelAmountId").append("<option value='" + paylevelamount.PayLevelAmountId + "'>" + paylevelamount.PayLevelAmount + "</option>");
                      $('#PayLevelAmountId').val(null).trigger('change');
                  });
              }
          });
      }
      
</script>

{{-- Validate form and Save data --}}
<script>
    $(function () {
      $.validator.setDefaults({
        submitHandler: function () {
            event.preventDefault();
            // Get Form Data
        var token = $("#csrf_token").val();
        var EmpCode = $('#EmployeeCode').find('option:selected').text();
        var EmployeeCode = EmpCode.split(' ')[0];
        var EmployeeId = $('#EmployeeCode :selected').val();
        var EmployeeName = $('#employeeName').val();
        
        var Ddo = $('#DDO').val();
        var controllingOfficer = $('#ControllingOfficer').val();
        var PrevSanctionPost = $('#SanctionPost').val();
        var previousLocation = $('#PreviousLocation').val();
        var Department = $('#Department').val();
        var PrevGroup = $('#Group').val();
        var PrevCadre = $('#Cadre').val();
        var PrevDesignation = $('#Designation').val();

        var PrevPayScale = $('#PrevPayScale :selected').val();
        var PayBandId = $('#PayBandId :selected').val();
        var GradePayId = $('#GradePayId :selected').val();
        var PayLevelId = $('#PayLevelId :selected').val();
        var PayLevelAmount = $('#PayLevelAmount').val();
        var PayLevelAmountId = $('#PayLevelAmountId :selected').val();
        var fromDate = $('#fromDate').val();
        var toDate = $('#toDate').val();
        var station = $('#station').val();
        var dearnessAllowance = $('#dearnessAllowance').val();
        var reasonForLeavingJob = $('#reasonForLeavingJob').val();
        
        var InService = '';
        if($('#InService').is(":checked"))
            {
                InService = '1';
            } 
        else
            {
                InService = '0';
            }
        var lastPayCertificate = $('#lastPayCertificate')[0].files;
        var submittedResignation = $('#submittedResignation')[0].files;
        
        var fd = new FormData();
            fd.append('_token',token);
            fd.append('EmployeeId',EmployeeId);
            fd.append('EmployeeCode',EmployeeCode);
            fd.append('DDO',Ddo);
            fd.append('ControllingOfficer',controllingOfficer);
            fd.append('SanctionPost',PrevSanctionPost);
            fd.append('PayScaleId',PrevPayScale);
            fd.append('PayBandId',PayBandId);
            fd.append('GradePayId',GradePayId);
            fd.append('PayLevelId',PayLevelId);
            fd.append('PayLevelAmount',PayLevelAmount);
            fd.append('PayLevelAmountId',PayLevelAmountId);
            fd.append('fromDate',fromDate);
            fd.append('Station',station);
            fd.append('ReasonForLeavingJob',reasonForLeavingJob);
            fd.append('ActualWorkPlace',previousLocation);
            fd.append('Department',Department);
            fd.append('Group',PrevGroup);
            fd.append('Cadre',PrevCadre);
            fd.append('Designation',PrevDesignation);
            fd.append('DearnessAllowance',dearnessAllowance);
            fd.append('toDate',toDate);
            fd.append('InService',InService);
            // files data
            fd.append('lastPayCertificate',lastPayCertificate[0]);
            fd.append('submittedResignation',submittedResignation[0]);

        $.ajax({
                type: "post",
                url: "{{ url('store-previous-job-detail') }}",
                data: fd,
                contentType: false,
                processData: false,
                success: function(response) {
                  const Toast = Swal.mixin({
                      toast: true,
                      position: 'top-end',
                      showConfirmButton: false,
                      timer: 2000,
                      timerProgressBar: true,
                      didOpen: (toast) => {
                        toast.addEventListener('mouseenter', Swal.stopTimer)
                        toast.addEventListener('mouseleave', Swal.resumeTimer)
                      }
                    })
                    Toast.fire({
                      icon: 'success',
                      title: 'Job added successfully!'
                    });
                    // Get EmployeeId and Member List
                    var EmployeeId = $('#EmployeeCode :selected').val();
                    $('form#empPreviousJobForm').each(function() {
                    this.reset();
                    $('#ddo_name, #controlling_officer_name, #sanction_post_name, #location_name, #department_name, #cadre_name, #designation_name').css('display', 'none');
                    $('#ddo_list, #controlling_officer_list, #sanction_post_list, #location_list, #department_list, #cadre_list, #designation_list').css('display', '');
                    $('#EmployeeCode').val(null).trigger('change');
                });
                },
                error: function(data) {
                  const Toast = Swal.mixin({
                      toast: true,
                      position: 'top-end',
                      showConfirmButton: false,
                      timer: 2000,
                      timerProgressBar: true,
                      didOpen: (toast) => {
                        toast.addEventListener('mouseenter', Swal.stopTimer)
                        toast.addEventListener('mouseleave', Swal.resumeTimer)
                      }
                    })
                    Toast.fire({
                      icon: 'error',
                      title: 'Something went wrong!'
                    });
                }
            });
        }
      });
      $('#empPreviousJobForm').validate({
        rules: {
            EmployeeCode: {
            required: true,
          },
          fromDate: {
            required: true,
          },
          toDate: {
            required: true,
          },
          lastPayCertificate: {
            //required: true,
            accept: "image/*, pdf",
            //filesize: 2,
          },
          submittedResignation: {
            //required: true,
            accept: "image/*, pdf",
            //filesize: 2,
          },
        },
        messages: {
            EmployeeCode: {
            required: "Please select employee code.",
          },
        lastPayCertificate: {
                accept: "Only image and pdf file is allowed.",
                filesize: "Maximum 2MB of file is allowed."
            },
        submittedResignation: {
                accept: "Only image and pdf file is allowed.",
                filesize: "Maximum 2MB of file is allowed."
            },
        },
        errorElement: 'span',
        errorPlacement: function (error, element) {
          error.addClass('invalid-feedback');
          element.closest('.form-group').append(error);
        },
        highlight: function (element, errorClass, validClass) {
          $(element).addClass('is-invalid');
        },
        unhighlight: function (element, errorClass, validClass) {
          $(element).removeClass('is-invalid');
        }
      });
    });
</script>
<!-- /.content-wrapper -->
@endsection