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/workshift.blade.php

@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
    <div class="col-lg-6 col-md-6 col-sm-6">
        <div class="card">
            <div class="header">
                <h2><strong>@if(isset($shift))Edit @else  Add @endif</strong>Shift</h2>
            </div>
            <div class="body">
                @if(isset($shift))
                {!! Form::model( $shift, ['route' => ['shifts.update', $shift->idShift], 'method' => 'put','class'=>'form-horizontal'] ) !!}
                @else
                {!! Form::open(['url' => 'school/shifts','class'=>'form-horizontal']) !!}
                @endif

                <div class="row clearfix">
                    <div class="col-sm-4 form-control-label required">
                        <label for="classname">Shift Name</label>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            {!! Form::text('shiftName',null,['class' => 'form-control','required'=>'required']) !!}
                            @if ($errors->has('shiftName'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('shiftName') }}</strong>
                            </label>
                            @endif
                        </div>
                    </div>
                </div>
                <div class="row clearfix demo-masked-input">
                    <table class="table">
                        <thead>
                            <tr>
                                <th>Weekdays</th>
                                <th>From</th>
                                <th></th>
                                <th>To</th>
                                <th></th>
                                <th>Weekly Off</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if(isset($shift))
                            @foreach($shift->details as $det)
                            <tr>
                                <td>{{$det->weekday->dayName}}</td>
                                <td>{!! Form::text('shifts['.$det->idWeekday.'][fromTime]',$det->fromTime,['class' => 'form-control time24']) !!}</td>
                                <td>
                                    <input type="radio" id="fam_{{$det->idWeekday}}" name="shifts[{{$det->idWeekday}}][shift_from]" value="am" @if($det->shift_from == 'am') checked @endif />
                                    <label for="fam_{{$det->idWeekday}}">AM</label>
                                    <input type="radio" id="fpm_{{$det->idWeekday}}" name="shifts[{{$det->idWeekday}}][shift_from]" value="pm" @if($det->shift_from == 'pm') checked @endif />
                                    <label for="fpm_{{$det->idWeekday}}">PM</label>
                                </td>
                                <td>
                                    {!! Form::text('shifts['.$det->idWeekday.'][toTime]',$det->toTime,['class' => 'form-control time24']) !!}
                                </td>
                                <td>
                                    <input type="radio" id="tam_{{$det->idWeekday}}" name="shifts[{{$det->idWeekday}}][shift_to]" value="am" @if($det->shift_to == 'am') checked @endif />
                                    <label for="tam_{{$det->idWeekday}}">AM</label>
                                    <input type="radio" id="tpm_{{$det->idWeekday}}" name="shifts[{{$det->idWeekday}}][shift_to]" value="pm" @if($det->shift_to == 'pm') checked @endif />
                                    <label for="tpm_{{$det->idWeekday}}">PM</label>
                                </td>
                                <td><input type="radio" name="shifts[{{$det->idWeekday}}][weekOff]" @if($det->weekOff == 'Y') checked @endif></td>
                                
                            </tr>
                            @endforeach
                            @else
                            @foreach($weekdays as $key=>$var)
                            <tr>
                                <td>{{$var}}</td>
                                <td>{!! Form::text('shifts['.$key.'][fromTime]',null,['class' => 'form-control time24']) !!}</td>

                                <td><input type="radio" id="fam_{{$key}}" name="shifts[{{$key}}][shift_from]" value="am"/>
                                <label for="fam_{{$key}}">AM</label>
                                <input type="radio" id="fpm_{{$key}}" name="shifts[{{$key}}][shift_from]" value="pm"/>
                                <label for="fpm_{{$key}}">PM</label></td>

                                <td>
                                    {!! Form::text('shifts['.$key.'][toTime]',null,['class' => 'form-control time24']) !!}
                                </td>
                                <td><input type="radio" id="tam_{{$key}}" name="shifts[{{$key}}][shift_to]" value="am"/>
                                <label for="tam_{{$key}}">AM</label>
                                <input type="radio" id="tpm_{{$key}}" name="shifts[{{$key}}][shift_to]" value="pm"/>
                                <label for="tpm_{{$key}}">PM</label></td>

                                <td><input type="radio" name="shifts[{{$key}}][weekOff]" id="weekday"></td>                                
                            </tr>
                            @endforeach
                            @endif
                        </tbody>
                    </table>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-8 offset-sm-2">
                        @if(isset($shift))
                        {!! 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="col-sm-6">
    <div class="card">
        <div class="header">
            <h2><strong>List Of Shifts</strong></h2>
        </div>
        <div class="body table-responsive">
            {!! Form::open(['method' => 'GET',  'action' => ['School\ShiftController@index'], 'class' => 'form-horizontal']) !!}
                <div class="row clearfix">
                    <div class="col-sm-3 form-control-label">
                        <label for="classname">Financial Year</label>
                    </div>
                    <div class="col-sm-5">
                        <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>Shift</th>
                        <th>Details</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $i = 1; ?>
                    @foreach($shifts as $var)
                    <tr>
                        <td>{{$i}}</td>
                        <td>{{$var->shiftName}}</td>
                        <td>
                            @if(count($var->details)>0)
                            <table class="table table-bordered">
                                <thead>
                                    <tr>
                                        <th>Weekday</th>
                                        <th>From Time</th>
                                        <th>To Time</th>
                                        <th>Week Off</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($var->details as $det)
                                    <tr>
                                        <td>{{$det->weekday->dayName}}</td>
                                        <td>{{$det->fromTime}} @if($det->weekOff != 'Y') {{$det->shift_from}} @endif</td>
                                        <td>{{$det->toTime}} @if($det->weekOff != 'Y') {{$det->shift_to}} @endif</td>
                                        <td>@if($det->weekOff == 'Y') Yes @else No @endif</td>
                                    </tr>
                                    @endforeach
                                </tbody>
                            </table>
                            @endif
                            </td>
                        <td>
                            <a href='{{url('/school/shifts/'.$var->idShift.'/edit')}}'  class="btn btn-raised btn-info waves-effect btn-round"><i class="fa fa-edit"></i>Edit</a>
                            <button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$var->idShift}}" data-type="confirm">DELETE</button>
                        </td>
                    </tr>
                    <?php $i++; ?>
                    @endforeach

                </tbody>
            </table>
        </div>
    </div>
</div>
</div>
@stop
@section('script')
<script>
$(function(){
    $("[name='shifts[7][weekOff]']").on("change", function (e) {
       if(this.value == "on"){
            $('#fam_7').prop('checked', false);
            $('#fpm_7').prop('checked', false);
            $('#tam_7').prop('checked', false);
            $('#tpm_7').prop('checked', false);
       }
    });
    $('input[type=radio]').click(function(){
        if (this.previous) {
            this.checked = false;
        }
        this.previous = this.checked;
    });
})    
$(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 Shift !",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes, delete it!",
            closeOnConfirm: true
        },
        function() {
         //   console.log('here');
            $.ajax({
                type: "DELETE",
                url: "{{url('/school/shifts/')}}" +"/"+id,
                data: {id:id}
                       
            })
            .done(function(data) {
                swal({
                    title: "Deleted", 
                    text: "Shift 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