<?php

use App\Models\Maladie;
use App\Models\ReportQuarter;
use App\Services\RepportService;
use Livewire\Component;

new class extends Component
{
    public $data = [];
    public $input = [];
    public $classes = [];
    public $school;
    public $cutting;

    public function mount() {
        $report = ReportQuarter::where('school_id', $this->school)->where('cutting_school_year_id', $this->cutting)->first();
        $dts = $report ? Maladie::where('report_quarter_id', $report->id)->orderBy('order')->get():[];
        $this->data = $dts;
    }

    public function myInput(RepportService $service) {
        $this->input = $this->data;
        $this->classes = $service->getClass($this->school, $this->cutting);
    }
};
?>

<div>
    <div class="card-header my-0 pb-0">
        <div class="d-flex justify-content-between">
            <h6>c - Les Cas de Maladie</h6>
            <span>
                <button wire:click="myInput" class="btn btn-inverse btn-outline-inverse btn-sm py-1 mt-0" title="Edit Info" data-toggle="modal" data-target="#malModal">
                <i class="fas fa-pen m-0"></i>
                </button>
            </span>
        </div>
    </div>
    <div class="card-body table-border-style mt-2">
        <div class="table-responsive">
            <table class="table table-bordered" style="width: 100%">
                <thead>
                    <tr>
                        <th class="text-center">N°</th>
                        <th>Matricule</th>
                        <th>Nom et Prénons</th>
                        <th>Sexe</th>
                        <th>Age</th>
                        <th>Classe</th>
                        <th>Date dépot <br> du certificat médical</th>
                        <th>Type de maladie</th>
                        <th>Durée de la maladie</th>
                    </tr>
                </thead>
                <tbody>
                <?php $i = 1; ?>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                    <tr>
                    <th class="text-center"><?php echo e($i < 10 ? '0'.$i++:$i++); ?></th>
                    <td class="text-center"><?php echo e($item->inscription->student->matricule); ?></td>
                    <td>
                        <?php echo e(strtoupper($item->inscription->student->first_name).' '.ucwords($item->inscription->student->last_name)); ?>

                    </td>
                    <td class="text-center"><?php echo e($item->inscription->student->sexe); ?></td>
                    <td class="text-center"><?php echo e($item->inscription->student->age.' ans'); ?></td>
                    <td><?php echo e(ucfirst($item->classe->libelle)); ?></td>
                    <td><?php echo e(date('d/m/Y', strtotime($item->date))); ?></td>
                    <td><?php echo e(ucfirst($item->maladie)); ?></td>
                    <td><?php echo e(ucfirst($item->dure)); ?></td>
                    </tr> 
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                    <tr>
                    <td colspan="10" class="text-center">Underdefined data</td>
                    </tr>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
    <!-- @Modal -->
    <div wire:ignore.self class="modal fade" id="malModal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-lg modal-dialog-centered" role="document" style="max-width: 50%;">
            <div class="modal-content">
                <div class="modal-header bg-dark py-2">
                    <h4 class="modal-title">Cas de Maladie</h4>
                    <strong style="font-size: 17px">
                        <?php echo e(sizeof($input) ? 'Edit':'Add'); ?>

                        <i class="fas fa-pencil-alt my-0"></i>
                    </strong>
                </div>
                <form action="<?php echo e(route('chapter_3.malad')); ?>" method="post">
                    <?php echo csrf_field(); ?>
                    <div class="modal-body">
                        <button type="button" class="btn mb-1 p-0 btnMalad" style="width: 25px; float: right; border: 1px solid grey">+</button>
                        <table class="table table-bordered mt-" id="myTableMalad" style="width: 100%">
                        <tbody>
                            <?php $i = 1; ?>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $input; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                            <tr>
                                <td style="width: 100%">
                                    <div class="row">
                                        <div class="col-sm-6">
                                            <label class="col-form-label" for="class_ml_<?php echo e($i); ?>">Classe<span class="text-danger">*</span> :</label>
                                            <select name="tab1[]" id="class_ml_<?php echo e($i); ?>" class="form-control getClass" data-id="<?php echo e($i); ?>" data-lib="c_mal">
                                                <option value="">Select ...</option>
                                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $classes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $classe): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                                                <option value="<?php echo e($classe->id); ?>" <?php echo e($classe->id == $item->classe_id  ? 'selected':null); ?>><?php echo e(ucfirst($classe->libelle)); ?></option>
                                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                                            </select>
                                        </div>
                                        <div class="col-sm-6">
                                            <label class="col-form-label" for="std_mal_<?php echo e($i); ?>">Elève<span class="text-danger">*</span> :</label>
                                            <select name="tab2[]" id="std_mal_<?php echo e($i); ?>" class="form-control">
                                                <option class="<?php echo e('opt_mal_'.$i); ?>" value="<?php echo e($item->inscription_id); ?>">
                                                    <?php echo e(strtoupper($item->inscription->student->first_name).' '.ucwords($item->inscription->student->last_name)); ?>

                                                </option>
                                            </select>
                                        </div>
                                        <div class="col-sm-6">
                                            <label class="col-form-label" for="dte_ml_<?php echo e($i); ?>">Date dépot du certificat médical<span class="text-danger">*</span> :</label>
                                            <input type="date" name="tab3[]" id="dte_ml_<?php echo e($i); ?>" class="form-control" value="<?php echo e($item->date); ?>">
                                        </div>
                                        <div class="col-sm-6">
                                            <label class="col-form-label" for="mld_<?php echo e($i); ?>">Type de maladie<span class="text-danger">*</span> :</label>
                                            <input type="text" name="tab4[]" id="mld_<?php echo e($i); ?>" class="form-control" value="<?php echo e($item->maladie); ?>">
                                        </div>
                                        <div class="col-sm-12">
                                            <label class="col-form-label" for="dure_<?php echo e($i); ?>">Durée de la maladie<span class="text-danger">*</span> :</label>
                                            <input type="text" name="tab5[]" id="dure_<?php echo e($i); ?>" class="form-control" value="<?php echo e($item->dure); ?>">
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <?php $i++ ?>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                            <tr>
                                <td style="width: 100%">
                                    <div class="row">
                                        <div class="col-sm-6">
                                            <label class="col-form-label" for="class_ml_1">Classe<span class="text-danger">*</span> :</label>
                                            <select name="tab1[]" id="class_ml_1" class="form-control getClass" data-id="1" data-lib="c_mal">
                                                <option value="">Select ...</option>
                                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $classes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $classe): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                                                <option value="<?php echo e($classe->id); ?>"><?php echo e(ucfirst($classe->libelle)); ?></option>
                                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                                            </select>
                                        </div>
                                        <div class="col-sm-6">
                                            <label class="col-form-label" for="std_mal_1">Elève<span class="text-danger">*</span> :</label>
                                            <select name="tab2[]" id="std_mal_1" class="form-control">
                                                <option value="">Select ...</option>
                                            </select>
                                        </div>
                                        <div class="col-sm-6">
                                            <label class="col-form-label" for="dte_ml_1">Date dépot du certificat médical<span class="text-danger">*</span> :</label>
                                            <input type="date" name="tab3[]" id="dte_ml_1" class="form-control" placeholder="---">
                                        </div>
                                        <div class="col-sm-6">
                                            <label class="col-form-label" for="mld_1">Type de maladie<span class="text-danger">*</span> :</label>
                                            <input type="text" name="tab4[]" id="mld_1" class="form-control" placeholder="---">
                                        </div>
                                        <div class="col-sm-12">
                                            <label class="col-form-label" for="dure_1">Durée de la maladie<span class="text-danger">*</span> :</label>
                                            <input type="text" name="tab5[]" id="dure_1" class="form-control" placeholder="---">
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </tbody>
                        </table>
                    </div>
                    <div class="modal-footer">
                        <input type="hidden" name="school" value="<?php echo e($school); ?>">
                        <input type="hidden" name="cutting" value="<?php echo e($cutting); ?>">
                        <button class="btn btn-inverse btn-outline-inverse btn-sm py-1 mx-2" data-dismiss="modal">Fermer</button>
                        <button class="btn btn-inverse btn-outline-inverse btn-sm py-1 mx-2">Valider</button>
                    </div>
                    </form>
            </div>
        </div>
    </div>
</div><?php /**PATH C:\Users\EDUCAS\Desktop\App\V4_001\resources\views\components\chapter3\maladie.blade.php ENDPATH**/ ?>