IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/holidays/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/holidays/hrms_index.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="header">
                <h2><strong>@if(isset($holiday))Edit @else  Add @endif</strong>Employee Event / Holiday
                </h2>
               
            </div>
            <div class="body">
                @if(isset($holiday))
                {!! Form::model($holiday, ['method' => 'PATCH', 'action' => ['School\HrmsHolidayController@update', $holiday->idHoliday], 'class' => 'form-horizontal']) !!}
                @else
                {!! Form::open(['url' => 'school/hrms-holidays', 'class' => 'form-horizontal']) !!}
                @endif
                <div class="row clearfix">
                <div class="col-sm-3 form-control-label">
                        <label for="classname" class="required">Department</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            @if(isset($holiday))
                            @php $setDepartment = $holiday->department;
                            if($setDepartment == 0) $setDepartment ="All";
                            @endphp
                                @if($setDepartment == "All")
                                {!! Form::select('department',["All" => "All"],$setDepartment,['class' => 'form-control show-tick ms']) !!}
                                @endif
                                @if($setDepartment != "All")
                                {!! Form::select('department',$departments,$setDepartment,['class' => 'form-control show-tick ms']) !!}
                                @endif
                            @else
                            {!! Form::select('department',$departments,null,['class' => 'form-control show-tick ms']) !!}
                            @endif
                            @if ($errors->has('department'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('department') }}</strong>
                            </label>
                            @endif
                        </div>
                    </div>
                    
                    <div class="col-sm-3 form-control-label">
                        <label for="classname" class="required">Designation</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            @if(isset($holiday))
                            @php $setDesignation = $holiday->designation;
                            if($setDesignation == 0) $setDesignation ="All";
                            @endphp
                                @if($setDesignation == "All")
                                {!! Form::select('designation',["All" => "All"],$setDesignation,['class' => 'form-control show-tick ms']) !!}
                                @endif
                                @if($setDesignation != "All")
                                {!! Form::select('designation',$designation,$setDesignation,['class' => 'form-control show-tick ms']) !!}
                                @endif
                            @else 
                            <select class="form-control show-tick ms" name="designation" id="designation" required='required'>
                            </select>
                            @endif
                            @if ($errors->has('designation'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('designation') }}</strong>
                            </label>
                            @endif
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-3 form-control-label">
                        <label for="classname" class="required">Employee</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            @if(isset($employees))
                            {!! 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 apply holiday on whole department or designation.</span>
                            <div id="idEmployee" style="border:1px solid #ccc; width:250px; height: 140px; overflow-y: scroll;">
                                
                            </div>
                            @endif
                        </div>
                    </div>
                    <div class="col-sm-3 form-control-label">
                        <label for="classname" class="required">Select Type</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            {!! Form::select('type',getHolidaytype(),null,['class' => 'form-control show-tick ms']) !!}
                            @if ($errors->has('type'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('type') }}</strong>
                            </label>
                            @endif
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-3 form-control-label">
                        <label for="classname" class="required">Event / Holiday Name</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            {!! Form::text('holidayName',null,['class' => 'form-control show-tick ms']) !!}
                            @if ($errors->has('holidayName'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('holidayName') }}</strong>
                            </label>
                            @endif
                        </div>
                    </div>
                    <div class="col-sm-3 form-control-label">
                        <label for="classname" class="required">From Date</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            {!! Form::text('fromDate',null,['class' => 'form-control datepicker']) !!}
                            @if ($errors->has('fromDate'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('fromDate') }}</strong>
                            </label>
                            @endif
                            <span id='fdate_error'></span>
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-3 form-control-label">
                        <label for="classname" class="required">To Date</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            {!! Form::text('toDate',null,['class' => 'form-control datepicker']) !!}
                            @if ($errors->has('toDate'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('toDate') }}</strong>
                            </label>
                            @endif
                            <span id='todate_error'></span>
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-8 offset-sm-2">
                        @if(isset($holiday))
                        {!! 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 class="col-sm-12">
        <div class="card">
            <div class="header">
                <h2><strong>Holidays</strong></h2>
            </div>
            <div class="body table-responsive">
                <table class="table table-bordered table-striped table-hover js-basic-example dataTable">
                    <thead>
                        <tr>
                            <th>S. No.</th>
                            <th>Department</th>
                            <th>Employee</th>
                            <th>Designation</th>
                            <th>Type</th>
                            <th>Holiday Name</th>
                            <th>From Date</th>
                            <th>To Date</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $i = 1; ?>
                        @foreach($holidays as $var)
                        <tr>
                            <th scope="row">{{$i}}</th>
                            @if(isset($var->department))
                            <td>@if($var->department == 0) All @else {{$var->departmentName}} @endif</td>
                            @else
                            <td></td>
                            @endif
                            @if(isset($var->firstName))
                            <td>{{$var->firstName.'-'.$var->enrollmentNo}}</td>
                            @else
                            <td>All</td>
                            @endif
                            @if(isset($var->designation))
                            <td>@if($var->designation == 0) All @else {{$var->designationName}} @endif</td>
                            @else
                            <td></td>
                            @endif
                            <td>{{$var->type}}</td>
                            <td>{{$var->holidayName}}</td>
                            <td>{{$var->fromDate}}</td>
                            <td>{{$var->toDate}}</td>
                            <td>
                                <a href="{{ url('school/hrms-holidays/' . $var->idHoliday . '/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="{{$var->idHoliday}}" data-type="confirm">DELETE</button>
                           
                            </td>
                        </tr>
                          <?php $i++; ?>
                        @endforeach
                      
                        
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@stop
@section('script')
<script>
$(document).ready(function() {
    $('select[name="department"]').on('change', function() {
        var departmentID = $(this).val();
        if(departmentID) {
            $.ajax({
                url: "{{url('/school/departments') }}"+'/' +departmentID + "/designations",
                type: "GET",
                dataType: "json",
                success:function(data) {
                    $('#designation').empty();
                    $('#designation').append('<option value="">-- Select Designation --</option>');
                    $('#designation').append('<option value="all">All</option>');
                    $.each(data, function(key, value) {
                       $('#designation').append('<option value="'+key+'">'+value+'</option>');

                    });
                }
            });
        }else{
            $('select[name="designation"]').empty();
        }
    });

    $('select[name="designation"]').on('change', function() {
        var designationIds = [];
        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{
            $('select[name="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 Holiday!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes, delete it!",
            closeOnConfirm: true
        },
        function() {
         //   console.log('here');
            $.ajax({
                type: "DELETE",
                url: "{{url('/school/hrms-holidays/')}}" +"/"+id,
                data: {id:id}
                       
            })
            .done(function(data) {
                swal({
                    title: "Deleted", 
                    text: "Holiday has been successfully deleted", 
                    type: "success"
                },function() {
                    location.reload();
                });
            })
            .error(function(data) {
              swal("Oops", "We couldn't connect to the server!", "error");
            });
            return false;
    });
});
</script>
@stop

Copyright © 2021 - 2025 IMMREX7