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/components/confidential-report-modal.blade.php
{{-- Add Confidential Report --}}
<div class="modal fade" id="addConfidentialReport">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">Confidential Report </h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <!-- Main content -->
                <form id="addConfidentialReportform">
                    <input type="hidden" name="_token" id="token" value="{{ csrf_token() }}">
                    <input type="hidden" name="EmployeeId" id="EmployeeId">
                    <input type="hidden" name="EmpCode" id="EmpCode">
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group mb-2">
                                    <label class="mb-0" for="EmployeeCode">Employee Code. <span
                                            class="text-danger">*</span></label>
                                    <select class="form-control form-control-sm select2" style="width: 100%;"
                                        aria-hidden="true" name="EmployeeCode" id="EmployeeCode"
                                        data-placeholder="Employee Code" required>
                                        <option selected="selected" disabled>Employee Code</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group mb-2">
                                    <label class="mb-0" for="EmployeeName">Employee Name </label>
                                    <input type="text" class="form-control form-control-sm" name="EmployeeName"
                                        id="EmployeeName" readonly>
                                </div>

                            </div>
                            <div class="col-md-6">
                                <div class="form-group mt-0">
                                    <label class="mb-0" for="FinancialYear">Financial Year <span
                                            class="text-danger">*</span></label>
                                    <select class="form-control form-control-sm select2" style="width: 100%;"
                                        aria-hidden="true" name="ConfidentialReportYear" id="ConfidentialReportYear"
                                        data-placeholder="Select Year">
                                        <option value="" disabled selected>Select Year</option>
                                    </select>
                                </div>

                            </div>

                        </div>

                        <hr />
                        <div class="row">
                            <div class="col-12">
                                <div class="d-flex align-items-center justify-content-center">
                                    <button type="button" class="btn btn-sm btn-outline-secondary mx-1"
                                        data-dismiss="modal" aria-label="Close">Cancel</button>
                                    <button type="submit" id="btn-save-name" name="Save" value="Save"
                                        class="btn btn-sm btn-info mx-1">Save</button>
                                </div>
                            </div>
                        </div>
                </form>
            </div>
        </div>
    </div>
    <!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->

{{-- Update Confidential Report --}}
<div class="modal fade" id="UpdateConfidentialReport">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">Confidential Report <span id="CREmployeeName" class="text-info"></span></h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <!-- Main content -->
                <form id="updateConfidentialReportform">
                    <input type="hidden" name="_token" id="token" value="{{ csrf_token() }}">
                    <input type="hidden" name="ConfidentialReportId" id="ConfidentialReportId">
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group mt-0">
                                    <label class="mb-0" for="FinancialYear">Financial Year <span
                                            class="text-danger">*</span></label>
                                    <select class="form-control form-control-sm select2" style="width: 100%;" aria-hidden="true" name="ConfidentialReportYear" id="EditConfidentialReportYear" data-placeholder="Select Year">
                                        <option value="" disabled selected>Select Year</option>
                                    </select>
                                </div>

                            </div>

                        </div>

                        <hr />
                        <div class="row">
                            <div class="col-12">
                                <div class="d-flex align-items-center justify-content-center">
                                    <button type="button" class="btn btn-sm btn-outline-secondary mx-1"
                                        data-dismiss="modal" aria-label="Close">Cancel</button>
                                    <button type="submit" class="btn btn-sm btn-info mx-1">Update</button>
                                </div>
                            </div>
                        </div>
                </form>
            </div>
        </div>
    </div>
    <!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->

{{-- JS Start Here --}}
<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;
        $('#EmpId').val('');
        $('#EmpCode').val('');
        getEmployeeDetail(EmployeeId);
        // Reset Form field on change Employee Code
        $('#ConfidentialReportYear').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);
            }
        });
    }
</script>

{{-- Edit Confidential Report Modal --}}
<script>
    function editConfidentialReport(ConfidentialReportId)
  {
      var ConfidentialReportId = ConfidentialReportId;
      $('#UpdateConfidentialReport').modal('show');
      $.ajax({
          type: "POST",
          url: "{{ url('/') }}/edit-confidential-report",
          dataType: 'json',
          data: {
            ConfidentialReportId: ConfidentialReportId,
            _token: "{{ csrf_token() }}",
          },
          success: function (response) {
              $('span#CREmployeeName').html('#' +response.GetConfidentialReport.EmployeeName);
              $('#ConfidentialReportId').val(response.GetConfidentialReport.ConfidentialReportId);
              $('#EditConfidentialReportYear').val(response.GetConfidentialReport.ConfidentialReportYear);
              $('#EditConfidentialReportYear').trigger('change');
          }
      });
  }
</script>

{{-- Validate form and Save data --}}
<script>
    $(function () {
      $.validator.setDefaults({
        submitHandler: function () {
            event.preventDefault();
            // Get Form Data
        $.ajax({
                type: "post",
                url: "{{ url('store-confidential-report') }}",
                data: $('#addConfidentialReportform').serialize(),
                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: 'Report added successfully!'
                    });
                    setTimeout(function(){
                    window.location.reload(1);
                  }, 2000);
                },
                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!'
                    });
                }
            });
        }
      });
      $('#addConfidentialReportform').validate({
        rules: {
            EmployeeCode: {
            required: true,
          },
          ConfidentialReportYear: {
            required: true,
          },
        },
        messages: {
            EmployeeCode: {
            required: "Employee Code is required.",
          }, 
          ConfidentialReportYear: {
            required: "Please select the financial year.",
          }, 
        },
        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>

{{-- Validate form and Update data --}}
<script>
    $(function () {
      $.validator.setDefaults({
        submitHandler: function () {
            event.preventDefault();
            // Get Form Data
        $.ajax({
                type: "post",
                url: "{{ url('update-confidential-report') }}",
                data: $('#updateConfidentialReportform').serialize(),
                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: 'Report updated successfully!'
                    });
                    setTimeout(function(){
                    window.location.reload(1);
                  }, 2000);
                },
                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!'
                    });
                }
            });
        }
      });
      $('#updateConfidentialReportform').validate({
        rules: {
          ConfidentialReportYear: {
            required: true,
          },
        },
        messages: {
          ConfidentialReportYear: {
            required: "Please select the financial year.",
          }, 
        },
        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>

{{-- Delete Promotion Detail --}}
<script>
    function deleteConfidentialReport(ConfidentialReportId) {
        var ConfidentialReportId = ConfidentialReportId;
                Swal.fire({
                    title: "Delete Record?",
                    text: "Are you sure you want to delete this Record?",
                    icon: "warning",
                    icon: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#3085d6",
                    cancelButtonColor: "#d33",
                    confirmButtonText: "Yes, delete it!",
                }).then((result) => {
                    if (result.isConfirmed) {
                        $.ajax({
                            type: "post",
                            url: "{{ url('/') }}/delete-confidential-report",
                            dataType: "json",
                            data: {
                                _token: "{{csrf_token()}}",
                                ConfidentialReportId: ConfidentialReportId,
                            },
                            success: function (response) {
                                Swal.fire({
                                    icon: "success",
                                    title: "Record has been deleted!",
                                    showConfirmButton: false,
                                    timer: 1500,
                                }).then(function () {
                                    location.reload();
                                });
                            },
                        });
                    }
                });
    }
</script>