<?php

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

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

    public function __contruct($cutting, $school) {
        $this->cutting = $cutting;
        $this->school = $school;
    }

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

    public function myInput(RepportService $service) {    
        $data = $service->getData($this->school);
        $this->input = $this->data;
        $this->users= $data[0];
        $this->matters = $data[1];
        $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>1 - Directeur des Etudes</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="#myDirectModal">
                <i class="fas fa-pen m-0"></i>
                </button>
            </span>
        </div>
    </div>
    <div class="card-body table-border-style mt-2">
        <?php echo $__env->make('partials._table_visit', ['data' => $data], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    </div>
    <!-- @modal -->
    <div wire:ignore.self class="modal fade" id="myDirectModal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-lg modal-dialog-centered" role="document" style="max-width: 70%;">
            <div class="modal-content">
                <div class="modal-header bg-dark py-2">
                    <h4 class="modal-title">Directeur des Etudes</h4>
                    <strong style="font-size: 17px">
                        <?php echo e($input ? 'Edit':'Add'); ?>

                        <i class="fas fa-pencil-alt my-0"></i>
                    </strong>
                </div>
                <?php echo $__env->make('partials._content_modal',[
                    'str' => 1,
                    'dts' => $input,
                    'btn' => 'btnDirect',
                    'date' => 'dat_d_',
                    'time' => 'tim_d_',
                    'qualit' => 'qlt_d_',
                    'teacher' => 'tchr_d_',
                    'table' => 'tableDirect',
                    'class' => 'class_d_',
                    'disciplin' => 'dpl_d_'
                ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
            </div>
        </div>
    </div>
</div><?php /**PATH C:\Users\EDUCAS\Desktop\App\V4_001\resources\views\components\chapter1\directeur.blade.php ENDPATH**/ ?>