IMMREX7

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

@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
    <div class="col-sm-12">
        <div class="card">
            <div class="header">
                <h2><strong>Pay Header</strong></h2>
            </div>
            <div class="body" style="padding-top:1px;">
                @if(isset($salstr))
                {!! Form::model($salstr, ['method' => 'PATCH', 'action' => ['School\SalaryStructureController@update', $salstr->idSalaryStr], 'class' => 'form-horizontal']) !!}
                @else
                {!! Form::open(['url' => 'school/salarystr', 'class' => 'form-horizontal','id'=>'form']) !!}
                @endif
                <div class="row clearfix">
                    <div class="col-sm-6">
                        <div class="row clearfix">
                            <div class="col-sm-5 form-control-label required">
                                <label for="classname">Department</label>
                            </div>
                            <div class="col-sm-7">
                                <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>
                        <div class="row clearfix">
                            <div class="col-sm-5 form-control-label">
                                <label for="classname" class="required">Designation</label>
                            </div>
                            <div class="col-sm-7">
                                <div class="form-group">
                                    @if(isset($salstr))
                                    {!! Form::select('idDesignation',$designations,null,['class' => 'form-control show-tick ms']) !!}
                                    @else
                                    <div id="idDesignation" style="border:1px solid #ccc; width:220px; height: 110px; overflow-y: scroll;">

                                    </div>
                                    @endif
                                    @if ($errors->has('idDesignation'))
                                    <label id="minmaxlength-error" class="error" for="minmaxlength">
                                        <strong>{{ $errors->first('idDesignation') }}</strong>
                                    </label>
                                    @endif
                                    <span id='desigerror'></span>
                                </div>
                            </div>
                        </div>
                        <div class="row clearfix">
                            <div class="col-sm-5 form-control-label">
                                <label for="classname">EC No.</label>
                            </div>
                            <div class="col-sm-7">
                                <div class="form-group">
                                    @if(isset($salstr))
                                    {!! Form::select('idEmployee',$employees,null,['class' => 'form-control show-tick ms']) !!}
                            
                                    @else
                                    <span style="color:red; font-size: 12px;">Please don't select this list if you want to assign a pay header on whole department or designation.</span>
                                    <div id="idEmployee" style="border:1px solid #ccc; width:220px; height: 110px; overflow-y: scroll;">

                                    </div>
                                    @if ($errors->has('ecNO'))
                                    <label id="minmaxlength-error" class="error" for="minmaxlength">
                                        <strong>{{ $errors->first('ecNO') }}</strong>
                                    </label>
                                    @endif
                                    @endif
                                </div>
                            </div>
                        </div>
                        
                    </div>
                    <div class="col-sm-6">
                        
                        <div class="row clearfix">
                           <div class="col-sm-12">
                                <table class="table table-bordered">
                                    <thead>
                                        <tr>
                                            <th colspan="3">Earnings</th>
                                        </tr>
                                    </thead>
                                    <tbody id="allowance_list">
                                        @if(isset($salstr) && (count($salstr->allowances)>0))
                                            <?php $p =1;?>
                                            @foreach($salstr->allowances as $a)
                                            <tr>
                                                <td class="sno">{{$p}}</td>
                                                <td>
                                                    {!! Form::select('allowances['.$p.'][idAllowance]',$allowances,$a->idAllowance,['class' => 'form-control show-tick ms']) !!}
                                                    <input type="hidden" name="allowances[{{$p}}][idSalAllowance]" value="{{$a->idSalAllowance}}">
                                                </td>
                                                <td>
                                                    {!! Form::text('allowances['.$p.'][amount]',$a->amount,['class' => 'form-control']) !!}
                                                </td>
                                            </tr>
                                            <?php $p++ ; ?>
                                            @endforeach
                                            @else
                                            <?php $i =1;?>
                                            <tr>
                                                <td class="sno">{{$i}}</td>
                                                <td> {!! Form::select('allowances[1][idAllowance]',$allowances,null,['class' => 'form-control show-tick ms']) !!}</td>
                                                <td>{!! Form::text('allowances[1][amount]',null,['class' => 'form-control','placeholder'=>'Amount']) !!}</td>
                                            </tr>
                                            <?php $i++ ; ?>
                                            @endif
                                    </tbody>
                                    <tr>
                                        <td colspan="3" style="text-align: right; padding: 0px;"><input type="button" class="add-row-allowance btn btn-sm btn-success" value="Add Row"></td>
                                    </tr>
                                        
                                   
                                </table>
                            </div>
                        </div>
                        <div class="row clearfix">
                            <div class="col-sm-12">
                                <table class="table table-bordered">
                                    <thead>
                                        <tr>
                                            <th colspan="4">Deductions</th>
                                        </tr>
                                    </thead>
                                    <tbody id="deduction_list">
                                        @if(isset($salstr)&& (count($salstr->deductions)>0))
                                            <?php $q =1;?>
                                            @foreach($salstr->deductions as $a)
                                            <tr>
                                                <td class="s_no">{{$q}}</td>
                                                <td>
                                                    {!! Form::select('deductions['.$q.'][idDeduction]',$deductions,$a->idDeduction,['class' => 'form-control show-tick ms']) !!}
                                                    <input type="hidden" name="deductions[{{$q}}][idSalDeduction]" value="{{$a->idSalDeduction}}">
                                                </td>
                                                <td>
                                                    {!! Form::text('deductions['.$q.'][amount]',$a->amount,['class' => 'form-control']) !!}
                                                </td>
                                                <td>
                                                    <input type="radio" id="fixed" name="deductions[{{$q}}][deduction_type]" value="fixed" @if($a->deduction_type == "fixed") checked @endif>
                                                    <label for="fixed">Fixed</label><br>
                                                    <input type="radio" id="dynamic" name="deductions[{{$q}}][deduction_type]" value="dynamic" @if($a->deduction_type == "dynamic") checked @endif>
                                                    <label for="dynamic">Dynamic</label><br>
                                                </td>
                                            </tr>
                                            <?php $q++ ; ?>
                                            @endforeach
                                            @else
                                            <?php $j =1;?>
                                            <tr>
                                                <td class="s_no">{{$j}}</td>
                                                <td> {!! Form::select('deductions[1][idDeduction]',$deductions,null,['class' => 'form-control show-tick ms']) !!}</td>
                                                <td>{!! Form::text('deductions[1][amount]',null,['class' => 'form-control','placeholder'=>'Amount']) !!}</td>
                                                <td>
                                                    <input type="radio" id="fixed" name="deductions[1][deduction_type]" value="fixed">
                                                    <label for="fixed">Fixed</label><br>
                                                    <input type="radio" id="dynamic" name="deductions[1][deduction_type]" value="dynamic">
                                                    <label for="dynamic">Dynamic</label><br>
                                                </td>
                                            </tr>
                                            <?php $j++ ; ?>
                                            @endif
                                    </tbody>
                                    <tr>
                                        <td colspan="4" style="text-align: right; padding: 0px;"><input type="button" class="add-row-deduction btn btn-sm btn-success" value="Add Row"></td>
                                    </tr>
                                   
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-8 col-sm-offset-2">
                        @if(isset($salstr))
                        {!! Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
                        @else
                        {!! Form::submit('SAVE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
                        @endif
                        {!! Form::close() !!} 
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row clearfix">
    <div class="col-sm-12">
        <div class="card">
            <div class="header">
                <h2><strong>Pay Header List</strong></h2>
            </div>
            <div class="body table-responsive">
                {!! Form::open(['method' => 'GET',  'action' => ['School\SalaryStructureController@index'], 'class' => 'form-horizontal']) !!}
                <div class="row clearfix">
                    <div class="col-sm-2"></div>
                    <div class="col-sm-2 form-control-label">
                        <label for="classname">Financial Year</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                           {!! Form::select('idFinancialYear',fys(),null,['class' => 'form-control show-tick ms']) !!}
                        </div>
                    </div>
                    <div class="col-sm-2">
                        {!! Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
                    </div>
                </div>
                {!! Form::close() !!} 
                <br>
                <table class="table table-bordered table-striped table-hover js-basic-example dataTable">
                    <thead>
                        <tr>
                            <th>S. No.</th>
                            <th>Department</th>
                            <th>Designation</th>
                            <th>Ec No</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $i = 1; ?>
                        @foreach($salstrs as $value)
                        <tr>
                            <th scope="row">{{$i}}</th>
                            <td>{{$value->department->departmentName}}</td>
                            <td>{{$value->designation->designationName}}</td>
                            <td>{{$value->employee->enrollmentNo or ''}}</td>
                            <td>
                                <a href="{{ url('school/salarystr/' . $value->idSalaryStr) }}" class="btn btn-raised btn-primary waves-effect btn-round">View</a>
                                <a href="{{ url('school/salarystr/' . $value->idSalaryStr . '/edit') }}"  class="btn btn-raised btn-info waves-effect btn-round">Edit </a>
                                <button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$value->idSalaryStr}}" data-type="confirm">DELETE</button>
                            </td>
                        </tr>
                        <?php $i++; ?>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@stop
@section('script')
<script>
$(document).ready(function() {
    var i = $('.sno:last').text();
    $(".add-row-allowance").click(function(){
        i++;  
        var markup = '<tr><td class="sno">'+i+'</td>\
                <td><select name="allowances['+i+'][idAllowance]" class = "form-control show-tick ms">@foreach($allowances as $key=>$value)<option value="{{$key}}">{{$value}}</option>@endforeach</select></td>\n\
\n\             <td><input class="form-control" type="text" name="allowances['+i+'][amount]" required="required" placeholder="Amount"></td>\n\
                <td style="text-align:right;vertical-align: middle;"><input type="button" class="btn btn-sm btn-danger" value="Delete" id="remove_row_allowances"></td></tr>';
            
            $("#allowance_list").append(markup);
    });
    
    $('#allowance_list').on('click', 'input[type="button"]', function () {
        $(this).closest('tr').remove();
         i = $('.sno:last').text();
         
    });
    
    var j = $('.s_no:last').text();
    $(".add-row-deduction").click(function(){
        j++;  
        var markup = '<tr><td class="s_no">'+j+'</td>\
                <td><select name="deductions['+j+'][idDeduction]" class = "form-control show-tick ms">@foreach($deductions as $key=>$value)<option value="{{$key}}">{{$value}}</option>@endforeach</select></td>\n\
                <td><input class="form-control" type="text" name="deductions['+j+'][amount]" required="required" placeholder="Amount"></td>\n\
                <td><input type="radio" id="fixed" name="deductions['+j+'][deduction_type]" value="fixed">'+
                '<label for="fixed">Fixed</label><br>'+
                                                    '<input type="radio" id="dynamic" name="deductions['+j+'][deduction_type]" value="dynamic">'+
                                                    '<label for="dynamic">Dynamic</label><br></td>'+
                '<td style="text-align:right;vertical-align: middle;"><input type="button" class="btn btn-sm btn-danger" value="Delete" id="remove_row_deduction"></td></tr>';
            
            $("#deduction_list").append(markup);
    });
    
    $('#deduction_list').on('click', 'input[type="button"]', function () {
        $(this).closest('tr').remove();
         j = $('.s_no:last').text();
         
    });
    //Add Input field if others is selecyted
});
$(document).ready(function() {
    $('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();
        }
    });
});
$(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;
            });
        }
});
$(document).on('click', '.js-sweetalert', function (e) {
    $.ajaxSetup({
        headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
    e.preventDefault();
    var id = $(this).data('id');
    swal({
            title: "Are you sure?",
            text: "Are You sure you want to delete this Structure!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes, delete it!",
            closeOnConfirm: true
        },
        function() {
         //   console.log('here');
            $.ajax({
                type: "DELETE",
                url: "{{url('/school/salarystr/')}}" +"/"+id,
                data: {id:id}
                       
            })
            .done(function(data) {
                swal({
                    title: "Deleted", 
                    text: "Salary Structure has been successfully deleted", 
                    type: "success"
                },function() {
                    location.reload();
                });
            })
            .error(function(data) {
              swal("Oops", "We couldn't connect to the server!", "error");
            });
            return false;
    });
});
// Saving form data
$('#form').on('submit',function(e){
    $.ajaxSetup({
    header:$('meta[name="_token"]').attr('content')
});
 var formData =  new FormData($('#form')[0]);
 $("#submit-btn").prop('disabled', true);
    $.ajax({
        type:"POST",
        url: "{{url('school/salarystr') }}",
        processData: false,
        contentType: false,
        data:formData,
        dataType: 'json',
        success:function(data){
            if( data[Object.keys(data)[0]] === 'SUCCESS' ){
                $("#submit-btn").prop('disabled', true);
                window.location = "{{url('school/salarystr')}}";
            }
            else {                  //False Case: With error msg
            $("#msg").html(data);   //$msg is the id of empty msg
            }

        },

        error: function(data){
                    if( data.status === 422 ) {
                        $("#submit-btn").prop('disabled', false);
                        var errors = data.responseJSON.errors;
                        var errorHtml = '<div class="alert alert-danger"><ul>';
                           $('#formerrors').html(errorHtml);
                                if(errors['idDepartment']=== undefined){
                                    $( '#depterror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['idDepartment']+'</strong></span>';
                                   $( '#depterror' ).html( errorname );
                                }
                                if(errors['idDesignation']=== undefined){
                                    $( '#desigerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['idDesignation']+'</strong></span>';
                                   $( '#desigerror' ).html( errorname );
                                }
                    }
            }
    });
    return false;
});
</script>
@stop

Copyright © 2021 - 2025 IMMREX7