

<?php $__env->startSection('title','Edit Jadwal Mengajar'); ?>

<?php $__env->startSection('content'); ?>

<div class="container-fluid">

    
    <div class="d-flex justify-content-between align-items-center mb-4">

        <div>

            <h3 class="font-weight-bold mb-1">
                Edit Jadwal Mengajar
            </h3>

            <p class="text-muted mb-0">
                Perbarui data jadwal mengajar guru.
            </p>

        </div>

        <a href="<?php echo e(route('jadwal.index')); ?>"
           class="btn btn-secondary btn-modern">

            <i class="fas fa-arrow-left mr-1"></i>

            Kembali

        </a>

    </div>

    <form action="<?php echo e(route('jadwal.update',$jadwal->id)); ?>" method="POST">

        <?php echo csrf_field(); ?>
        <?php echo method_field('PUT'); ?>

        <div class="card card-modern shadow-sm">

            <div class="card-header bg-white border-0">

                <h5 class="mb-0">

                    <i class="fas fa-edit text-warning mr-2"></i>

                    Form Edit Jadwal

                </h5>

            </div>

            <div class="card-body">

                <div class="row">

                    
                    <div class="col-md-6 mb-3">

                        <label>Guru</label>

                        <select
                            name="guru_id"
                            class="form-control"
                            required>

                            <?php $__currentLoopData = $guru; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $g): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                <option
                                    value="<?php echo e($g->id); ?>"
                                    <?php echo e(old('guru_id',$jadwal->guru_id)==$g->id ? 'selected' : ''); ?>>

                                    <?php echo e($g->nama); ?>


                                </option>

                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        </select>

                    </div>

                    
                    <div class="col-md-6 mb-3">

                        <label>Mata Pelajaran</label>

                        <select
                            name="mata_pelajaran_id"
                            class="form-control"
                            required>

                            <?php $__currentLoopData = $mapel; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $m): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                <option
                                    value="<?php echo e($m->id); ?>"
                                    <?php echo e(old('mata_pelajaran_id',$jadwal->mata_pelajaran_id)==$m->id ? 'selected' : ''); ?>>

                                    <?php echo e($m->nama_mapel); ?>


                                </option>

                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        </select>

                    </div>

                    
                    <div class="col-md-6 mb-3">

                        <label>Kelas</label>

                        <select
                            name="kelas_id"
                            class="form-control"
                            required>

                            <?php $__currentLoopData = $kelas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                <option
                                    value="<?php echo e($k->id); ?>"
                                    <?php echo e(old('kelas_id',$jadwal->kelas_id)==$k->id ? 'selected' : ''); ?>>

                                    <?php echo e($k->nama_kelas); ?>


                                </option>

                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        </select>

                    </div>

                    
                    <div class="col-md-6 mb-3">

                        <label>Hari</label>

                        <select
                            name="hari"
                            class="form-control"
                            required>

                            <?php

                                $hari = [
                                    'Senin',
                                    'Selasa',
                                    'Rabu',
                                    'Kamis',
                                    'Jumat',
                                    'Sabtu'
                                ];

                            ?>

                            <?php $__currentLoopData = $hari; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $h): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                <option
                                    value="<?php echo e($h); ?>"
                                    <?php echo e(old('hari',$jadwal->hari)==$h ? 'selected' : ''); ?>>

                                    <?php echo e($h); ?>


                                </option>

                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        </select>

                    </div>

                    
                    <div class="col-md-4 mb-3">

                        <label>Jam Mulai</label>

                        <input
                            type="time"
                            id="jam_mulai"
                            name="jam_mulai"
                            value="<?php echo e(old('jam_mulai',substr($jadwal->jam_mulai,0,5))); ?>"
                            class="form-control"
                            required>

                    </div>

                    
                    <div class="col-md-4 mb-3">

                        <label>Jam Selesai</label>

                        <input
                            type="time"
                            id="jam_selesai"
                            name="jam_selesai"
                            value="<?php echo e(old('jam_selesai',substr($jadwal->jam_selesai,0,5))); ?>"
                            class="form-control"
                            required>

                    </div>

                    
                    <div class="col-md-4 mb-3">

                        <label>Total Jam Mengajar</label>

                        <div class="input-group">

                            <input
                                type="number"
                                step="0.1"
                                id="jam_mengajar"
                                name="jam_mengajar"
                                value="<?php echo e(old('jam_mengajar',$jadwal->jam_mengajar)); ?>"
                                class="form-control"
                                readonly>

                            <div class="input-group-append">

                                <span class="input-group-text">

                                    Jam

                                </span>

                            </div>

                        </div>

                    </div>

                </div>

            </div>

            <div class="card-footer bg-white">

                <button
                    type="submit"
                    class="btn btn-warning btn-modern">

                    <i class="fas fa-save mr-1"></i>

                    Update Jadwal

                </button>

                <a href="<?php echo e(route('jadwal.index')); ?>"
                   class="btn btn-light btn-modern">

                    Batal

                </a>

            </div>

        </div>

    </form>

</div>

<script>

const mulai = document.getElementById('jam_mulai');
const selesai = document.getElementById('jam_selesai');

mulai.addEventListener('change', hitungJam);
selesai.addEventListener('change', hitungJam);

function hitungJam(){

    if(mulai.value && selesai.value){

        let start = new Date('2000-01-01 ' + mulai.value);
        let end = new Date('2000-01-01 ' + selesai.value);

        let total = (end-start)/(1000*60*60);

        if(total < 0){

            total = 0;

        }

        document.getElementById('jam_mengajar').value = total.toFixed(1);

    }

}

hitungJam();

</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\laragon\www\Presguru\resources\views/jadwal/edit.blade.php ENDPATH**/ ?>