<?php

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

new class extends Component
{
    public $data = [];
    public $input = [];
    public $matters = [];
    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 ? UpActivite::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->matters = $data[1];
    }
};
?>

<div>
    <div class="card-header my-0 pb-0">
        <div class="d-flex justify-content-between">
            <h6>b2 - Tableau Récapitulatif des Activités des (UP)</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="#myUpModal">
                <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_ce_up',[
            'data' => $data,
            'type' => 'time',
        ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    </div>
    <!-- @modal -->
    <div wire:ignore.self class="modal fade" id="myUpModal" 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">Activités des (UP)</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._madaol_content',[
                    'str' => 1,
                    'btn' => 'btnUp',
                    'table' => 'tableUp',
                    'val1' => 'activite_up_',
                    'val2' => 'theme_up_',
                    'val3' => 'select_up_',
                    'val4' => 'time_up_',
                    'val5' => 'date_up_',
                    'val6' => 'content_up_',
                    'type' => 'time',
                    'dts' => $input
                ], 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\activite_up.blade.php ENDPATH**/ ?>