IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/hrms/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/hrms/salary_generation.blade.php

@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12">
        <!--<div class="card">-->
        <div class="body">
            <button class="btn btn-raised btn-warning btn-round waves-effect" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">Advance Search</button>
            <div class="collapse" id="collapseExample">
                <div class="well">
                    <div class="row clearfix">
                        <div class="col-lg-12 col-md-12 col-sm-12">
                            <div class="card">
                                <div class="header">
                                    <h2><strong>Generate Salary</strong></h2>
                                </div>
                                <div class="body">
                                    {!! Form::open(['method' => 'GET',  'action' => ['School\EmpPaymentController@salaryGeneration'], 'class' => 'form-horizontal']) !!}
                                    <div class="row clearfix">
                                        <div class="col-sm-2 form-control-label required">
                                            <label for="classname">Department</label>
                                        </div>
                                        <div class="col-sm-3">
                                            <div class="form-group">
                                                {!! Form::select('idDepartment',$departments,null,['class' => 'form-control show-tick ms select2']) !!}
                                                @if ($errors->has('idDepartment'))
                                                <label id="minmaxlength-error" class="error" for="minmaxlength">
                                                    <strong>{{ $errors->first('idDepartment') }}</strong>
                                                </label>
                                                @endif
                                                <span id='depterror'></span>
                                            </div>
                                        </div>
                                        <div class="col-sm-2 form-control-label">
                                            <label for="classname">Designation</label>
                                        </div>
                                        <div class="col-sm-3">
                                            <div class="form-group">
                                                <div id="idDesignation" style="border:1px solid #ccc; width:200px; height: 110px; overflow-y: scroll;">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row clearfix">
                                        <div class="col-sm-2 form-control-label">
                                            <label for="classname">EC No.</label>
                                        </div>
                                        <div class="col-sm-3">
                                            <div class="form-group">
                                                <div id="idEmployee" style="border:1px solid #ccc; width:250px; height: 140px; overflow-y: scroll;">

                                                </div>
                                                
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row clearfix">
                                        <div class="col-sm-8 offset-sm-2">
                                            {!! Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
                                            {!! Form::close() !!} 
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--</div>-->
    </div>
</div>
<div class="row clearfix">
    <div class="col-sm-12">
        <div class="card">
            <div class="header">
                <h2><strong>Generate Salary</strong></h2>
            </div>
            <div class="body table-responsive">
                {!! Form::open(['method' => 'GET',  'action' => ['School\EmpPaymentController@salaryGeneration'], 'class' => 'form-horizontal']) !!}
                <div class="row clearfix" style="margin-bottom:30px;">
                    <div class="col-sm-12">
                        <div class="row clearfix">
                            @if ($errors->has('employee'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('employee') }}</strong>
                            </label>
                            @endif
                            <div class="col-sm-2">
                                <label><strong>Select a FY (Financial Year)</strong></label>
                            </div>
                            <div class="col-sm-3">
                                {!! Form::select('fy',fys(),Session::get('idFinancialYear'),['class' => 'form-control show-tick ms','required'=>'required']) !!}
                                @if ($errors->has('fy'))
                                 <label id="minmaxlength-error" class="error" for="minmaxlength">
                                     <strong>{{ $errors->first('fy') }}</strong>
                                 </label>
                                 @endif
                            </div>
                            <div class="col-sm-2">
                                <label><strong>Select a Month &amp; Year</strong></label>
                            </div>
                            <div class="col-sm-3">
                                {!! Form::select('idMonth',getMonths(),null,['class' => 'form-control show-tick ms','required'=>'required']) !!}
                                {!! Form::select('year',['2024'=>'2024','2025'=>'2025','2021'=>'2021',2022=>'2022','2023'=>'2023','2020'=>'2020','2019'=>'2019'],null,['class' => 'form-control show-tick ms']) !!}
                                @if ($errors->has('idMonth'))
                                 <label id="minmaxlength-error" class="error" for="minmaxlength">
                                     <strong>{{ $errors->first('idMonth') }}</strong>
                                 </label>
                                 @endif
                            </div>
                            <div class="col-sm-2">
                                <input type="submit" value="GENERATE" class="btn btn-raised btn-success btn-round waves-effect">
                            </div>
                        </div>
                    </div>
                </div>
                {!! Form::close() !!}
                <?php $employeeId = array(); ?>

                @if(isset($financialYear) && isset($month))
                    <button class="btn btn-raised btn-success btn-round waves-effect" id="print_data" onclick="printData()"> Print Salary Data</button>
                @endif
                @if(isset($financialYear) && isset($month))
                    @foreach($employees as $value)
                    <?php
                        $ifSalaryExists = \App\EmpPayment::where('idMonth',$month)->where('idFinancialYear',$financialYear)->where('idSchool',Auth::guard('school')->user()->idSchool)->where('idEmployee', $value->idEmployee)->first();
                        if($ifSalaryExists == null){
                            $emp_shift = \App\AssignShift::where('idEmployee', '=', $value->idEmployee)->first(); 
                            if( $emp_shift != null){
                                $shift = \App\Shift::where('idShift', '=', $emp_shift->idShift)->first();
                            }
                            $emp_salstr = \App\SalaryStructure::where('idEmployee', '=', $value->idEmployee)->where('idFinancialYear', '=', $financialYear)->first();
                            if($emp_salstr != null){
                                $deductions = \App\SalaryStrDeduction::where('idSalaryStr', '=', $emp_salstr->idSalaryStr)->get();
                                $earnings = \App\SalaryStrAllowances::where('idSalaryStr', '=', $emp_salstr->idSalaryStr)->get();
                                if($emp_shift != null)
                                array_push($employeeId,$value->idEmployee);
                            }
                        }
                    ?>
                    @if($ifSalaryExists == null)
                    <div class="row clearfix" @if($emp_shift == null || $emp_salstr  == null) style="opacity: 0.5;" @endif >
                        <div class="col-md-12">
                            <div class="card project_widget" style="border: solid #c1c1c1 1px;">
                                    <div class="pw_content">
                                        <div class="pw_header row">
                                            <div class="col-md-6">    
                                                <h6>{{$value->firstName}} {{$value->middleName}}  {{$value->lastName}}</h6>
                                                <span style="color:black;">Enrollment No : {{$value->enrollmentNo}}</span><br>
                                                <span style="color:black;">Department :  {{$value->department->departmentName or ''}}</span> | 
                                                <span style="color:black;">Designation :  {{$value->designation->designationName or ''}}</span><br>
                                                <span style="color:black;">Mobile :  {{$value->mobile}}</span><br>
                                                
                                                @if(isset($emp_shift))
                                                    @if(isset($shift))
                                                    <span style="color:black;">Allocates Shift Name :  <b>{{$shift->shiftName}}</b></span>
                                                    @endif
                                                @else
                                                    <span style="color:red;">No shift allocated</span><br>
                                                @endif
                                            </div>
                                            <div class="col-md-6">    
                                                <h6>Earnings</h6>
                                                @if(isset($emp_salstr))
                                                @foreach($earnings as $earning)
                                                    <?php $allowance = \App\Allowance::where('idAllowance', '=', $earning->idAllowance)->first(); ?>
                                                    @if($allowance != null)
                                                    <span style="color:black;">{{ $allowance->allowanceName }} :  {{$earning->amount}}</span><br>
                                                    @endif
                                                @endforeach
                                                
                                                @else
                                                <span style="color:red;">No salary structure found</span><br>
                                                @endif
                                                
                                            </div>
                                        </div>
                                        <div class="pw_meta row">
                                            <div class="col-md-6"> 
                                                <h6>Attendance Summary</h6>  
                                                <span id="{{$value->idEmployee}}_p">Full Present (Including All Holidays) : @if($emp_shift != null && $emp_salstr  != null) <small class="text-muted">Generating please wait..</small> @else NA @endif</span>
                                                <span id="{{$value->idEmployee}}_ab">Total Absent : @if($emp_shift != null && $emp_salstr  != null) <small class="text-muted">Generating please wait..</small> @else NA @endif</span>
                                                <span id="{{$value->idEmployee}}_hf">Half Day : @if($emp_shift != null && $emp_salstr  != null) <small class="text-muted">Generating please wait..</small> @else NA @endif</span>
                                                <span id="{{$value->idEmployee}}_ia">Incomplete Attendance : @if($emp_shift != null && $emp_salstr  != null) <small class="text-muted">Generating please wait..</small> @else NA @endif</span>
                                                <span id="{{$value->idEmployee}}_pl">Paid Leave : @if($emp_shift != null && $emp_salstr  != null) <small class="text-muted">Generating please wait..</small> @else NA @endif</span>
                                                <span id="{{$value->idEmployee}}_leave">Leave :@if($emp_shift != null && $emp_salstr  != null) <small class="text-muted">Generating please wait..</small> @else NA @endif </span>
                                                @if(isset($month))

                                                <a href="{{url('school/empattendance-report')}}?employees[]={{$value->idEmployee}}&year={{$year}}&idMonth={{$month}}" target="_blank">Click here to view attendance</a>
                                                @else
                                                <span style="color:red;">Select a month to view attendance</span>
                                                @endif
                                            </div>    
                                            <div class="col-md-6">   
                                                <h6>Deduction</h6>  
                                                @if(isset($emp_salstr))
                                                @foreach($deductions as $deduction)
                                                    <?php $deductionName = \App\Deduction::where('idDeduction', '=', $deduction->idDeduction)->first(); ?>
                                                    @if($deductionName != null)
                                                    <span style="color:black;">{{ $deductionName->deductionName }} :  {{$deduction->amount}} ({{$deduction->deduction_type or ''}}) </span><br>
                                                    @endif
                                                @endforeach
                                                @else
                                                <span style="color:red;">No salary structure found</span><br>
                                                @endif
                                                <span id="{{$value->idEmployee}}_salary">@if($emp_shift != null && $emp_salstr  != null) <small class="text-muted">Generating please wait..</small> @else NA @endif</span>
                                                <small class="text-muted">Total Payable Amount</small>
                                                <div id="{{$value->idEmployee}}_gen"></div>
                                            </div>    
                                        </div>
                                    </div>
                            </div>
                        </div>
                    </div>
                    @endif
                    @endforeach
                    @endif
            </div>
        </div>
    </div>
</div>
@stop
@section('script')
<script>
@if(isset($financialYear) && isset($month))
function printData(){
    const url = window.location.href;
    window.location.href = url.replace("salgen", "salgen-print");;
}
@endif

function fetchEmployees(posi){
    var idEmployee = <?php echo json_encode($employeeId);?>;
    var createRequestObject = {};
    @if(isset($financialYear))
    createRequestObject["fy"] = "{{$financialYear}}";
    @endif
    @if(isset($month))
    createRequestObject["idMonth"] = "{{$month}}";
    createRequestObject['year'] ="{{$year}}";
    createRequestObject["idEmployee"] = idEmployee[posi];
    createRequestObject["pos"] = posi;
    if(idEmployee.length > posi){
        $.ajax({
            type: "POST",
            beforeSend: function(request) {
                request.setRequestHeader("X-CSRF-TOKEN", "{{csrf_token()}}");
                request.setRequestHeader('Content-Type', 'application/json');
            },
            url: "{{url('/school/salgen') }}",
            data: JSON.stringify({
                fy : createRequestObject["fy"],
                idMonth : createRequestObject["idMonth"],
                idEmployee : createRequestObject["idEmployee"],
                pos : createRequestObject["pos"],
                year :  createRequestObject['year']
            }),
            processData: false,
            success: function(msg) {
                $("#"+msg.data.idEmployee+"_p").html("Full Present (Including All Holidays) : "+msg.data.present);
                $("#"+msg.data.idEmployee+"_ab").html("Total Absent : "+msg.data.absent);
                $("#"+msg.data.idEmployee+"_hf").html("Half Day : "+msg.data.half_day);
                $("#"+msg.data.idEmployee+"_ia").html("Incomplete Attendance : "+msg.data.incomplete);
                $("#"+msg.data.idEmployee+"_pl").html("Paid Leave : "+msg.data.paid_leave);
                $("#"+msg.data.idEmployee+"_leave").html("Leave : "+msg.data.leave);
                $("#"+msg.data.idEmployee+"_salary").html("INR "+msg.data.salary);
                if(msg.data.btEnable == 1){
                    $("#"+msg.data.idEmployee+"_gen").html('<button class="btn btn-primary" id="'+msg.data.idEmployee+'_bt" onclick="generateSalary('+msg.data.idEmployee+','+createRequestObject["idMonth"]+','+createRequestObject["fy"]+','+createRequestObject["year"]+')">Confirm and Generate Salary</button>');
                }else $("#"+msg.data.idEmployee+"_gen").empty();                
                var currentPos = +msg.data.pos + 1;
                fetchEmployees(currentPos);
            }
        });
    }else{
        $('#print_data').show();
    }
    
    @endif
}

function generateSalary(idEmployee,month,fy,year){
    $("#"+idEmployee+"_bt").text('Generating please wait..');
    $("#"+idEmployee+"_bt").prop('disabled', true);
    $.ajax({
            type: "POST",
            beforeSend: function(request) {
                request.setRequestHeader("X-CSRF-TOKEN", "{{csrf_token()}}");
                request.setRequestHeader('Content-Type', 'application/json');
            },
            url: "{{url('/school/pay-salary') }}",
            data: JSON.stringify({
                fy : fy,
                idMonth : month,
                year : year,
                employees : idEmployee
            }),
            processData: false,
            success: function(msg) {
                $("#"+msg.data.idEmployee+"_gen").empty();
                $("#"+msg.data.idEmployee+"_gen").html('<a href="{{url('school/emppayments')}}" target="_blank">Click to view generated salary</a>');
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert("Failed to generate salary");
                $("#"+idEmployee+"_bt").text('Confirm and Generate Salary');
                $("#"+idEmployee+"_bt").prop('disabled', false);
            }
    });
}

$('.selectAll').on('click', function () {
       var checkAll = this.checked;
       if(checkAll === true){
            $('input[type=checkbox]').each(function () {
                 this.checked = checkAll;
            });
        }else{
           $('input[type=checkbox]').each(function () {
                this.checked = checkAll;
            });   
        }
});
$(document).ready(function() {
    $('#print_data').hide();
    $('select[name="idDepartment"]').on('change', function() {
        var departmentID = $(this).val();
        if(departmentID) {
            $.ajax({
                url: "{{url('/school/departments') }}"+'/' +departmentID + "/designations",
                type: "GET",
                dataType: "json",
                success:function(data) {
                    $('#idDesignation').empty();
                    $('#idDesignation').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-all" id="selectall"></div>');
                    $.each(data, function(key, value) {
                       $('#idDesignation').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:100px;">'+value+'</label><input type="checkbox" name="designations[]" value="'+key+'" class="designationclass"></div>');
                        
                    });
                }
            });
        }else{
            $('select[name="idDesignation"]').empty();
        }
    });
    fetchEmployees(0);
});
$(document).on('click', '.select-all', function(){
    var checkAll = this.checked;
        if(checkAll === true){
            $('input[type=checkbox]').each(function () {
                this.checked = checkAll;
            });
            var designationIds = [];
            $("input:checkbox[name='designations[]']:checked").each(function () {
                designationIds.push($(this).val());
            });
            if (designationIds.length > 0) {
                    $.ajax({
                        url: "{{url('/school/designations') }}"+'/' +designationIds + "/employees",
                        type: "GET",
                        dataType: "json",
                        success:function(data) {
                            $('#idEmployee').empty();
                            $('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd"></div>');
                            $.each(data, function(key, value) {
                               $('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:50px;">'+value+'</label><input type="checkbox" name="employees[]" value="'+key+'" class="empallselect"></div>');

                            });
                        }
                    });
                }
        }else{
            $('#idEmployee').empty();
            $('input[type=checkbox]').each(function () {
                this.checked = checkAll;
            });
        }
        
    
});
$(document).on('click', '.designationclass', function(){
    var designationIds = [];
        $("input:checkbox[name='designations[]']:checked").each(function () {
            designationIds.push($(this).val());
        });
        if (designationIds.length > 0) {
                $.ajax({
                        url: "{{url('/school/designations') }}"+'/' +designationIds + "/employees",
                        type: "GET",
                        dataType: "json",
                        success:function(data) {
                            $('#idEmployee').empty();
                            $('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd"></div>');
                            $.each(data, function(key, value) {
                               $('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:50px;">'+value+'</label><input type="checkbox" name="employees[]" value="'+key+'" class="empallselect"></div>');

                            });
                        }
                    });
            }else{
                $('#idEmployee').empty();
            }
});
$(document).on('click', '.select-allstd', function(){
    var checkAllstd = this.checked;
        if(checkAllstd === true){
            $("input:checkbox[name='employees[]']").each(function () {
               this.checked = checkAllstd;
           });
        }else{
            $('.empallselect').each(function () {
                this.checked = checkAllstd;
            });
        }
});


</script>
@stop

Copyright © 2021 - 2025 IMMREX7