<?php echo $__env->make('layouts.commons.errors', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<div>
    <h2 class="pb-2"><?php echo e(isset($tache) ? 'Modifier' : 'Ajouter'); ?> une tâche</h2>
</div>

<div class="container pr-2 pl-2">
    <form method="POST" action="<?php echo e(route('taches.'. (session('route_tache') ?? 'store'), [ isset($projet->id) ? $projet->id : '', isset($tache->id) ? $tache->id : '' ])); ?>">
        <?php echo csrf_field(); ?>
        <?php if(session('route_tache') == "update"): ?> <?php echo e(method_field('PUT')); ?> <?php endif; ?>

        
        <input type="hidden" name="projet_id" value="<?php echo e($projet->id); ?>">
        <input type="hidden" name="tache_id" value="<?php echo e($tache->id ?? ''); ?>">

        <!-- Nom -->
        <div class="form-group row">
            <label for="nom" class="col-md-4 col-form-label text-md-right required">Nom</label>
            <div class="col-md-6">
                <input id="nom" type="text" class="form-control" name="nom" value="<?php echo e(old('nom', $tache->nom ?? '')); ?>" required>
            </div>
        </div>

        <!-- Description -->
        <div class="form-group row">
            <label for="description" class="col-md-4 col-form-label text-md-right">Description</label>
            <div class="col-md-6">
                <input id="description" type="text" class="form-control" name="description" value="<?php echo e(old('description', $tache->description ?? '')); ?>">
            </div>
        </div>

        <!-- Responsable -->
        <div class="form-group row">
            <label for="select-responsable" class="col-md-4 col-form-label text-md-right required">Responsable</label>
            <div class="col-md-6">
                <select id="select-responsable" name="responsable_id" style="width: 100%">
                    <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($u->id); ?>" <?php echo e(old('responsable_id', $tache->responsable_id ?? '') === $u->id ? 'selected' : ''); ?>>
                            <?php echo e($u->nom_complet()); ?><?php if(isset($u->direction)): ?> <?php echo e(' - ' . $u->direction->nom); ?> <?php endif; ?>
                        </option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
        </div>

        <!-- Date de début -->
        <div class="form-group row">
            <label for="date_debut" class="col-md-4 col-form-label text-md-right required">Date de début</label>
            <div class="col-md-6">
                <div class="input-group">
                    <input type="text" class="datepicker form-control flatpickr-input" id="date_debut"
                        name="date_debut"
                        value="<?php echo e(old('date_debut', isset($tache->date_debut) ? date('d/m/Y', strtotime($tache->date_debut)) : '')); ?>">
                    <div class="input-group-append">
                        <span class="input-group-text">
                            <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-calendar3"
                                fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                                <path fill-rule="evenodd"
                                    d="M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857V3.857z" />
                                <path fill-rule="evenodd"
                                    d="M6.5 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2z" />
                            </svg>
                        </span>
                    </div>
                </div>
            </div>
        </div>

        <!-- Date de fin -->
        <div class="form-group row">
            <label for="date_fin" class="col-md-4 col-form-label text-md-right required">Date de fin</label>
            <div class="col-md-6">
                <div class="input-group">
                    <input type="text" class="datepicker form-control flatpickr-input" id="date_fin"
                        name="date_fin"
                        value="<?php echo e(old('date_fin', isset($tache->date_fin) ? date('d/m/Y', strtotime($tache->date_fin)) : '')); ?>">
                    <div class="input-group-append">
                        <span class="input-group-text">
                            <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-calendar3"
                                fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                                <path fill-rule="evenodd"
                                    d="M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857V3.857z" />
                                <path fill-rule="evenodd"
                                    d="M6.5 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2z" />
                            </svg>
                        </span>
                    </div>
                </div>
            </div>
        </div>

        <!-- Charge estimée en nombre de jours -->
        <div class="form-group row">
            <label for="nb_jours" class="col-md-4 col-form-label text-md-right required">Charge estimée en nombre de jours</label>
            <div class="col-md-6">
                <input id="nb_jours" type="number" min="0" max="10000" step="0.01" class="form-control" name="nb_jours" value="<?php echo e(old('nb_jours', $tache->nb_jours ?? '')); ?>" required>
            </div>
        </div>

        <div class="form-group row mb-0">
            <div class="col-md-8 offset-md-4">
                <button type="submit" class="btn btn-outline-success">
                    Sauvegarder
                </button>
                <a href="<?php echo e(route('projets.edit', $projet->id)); ?>" class="btn btn-outline-warning">Annuler</a>
            </div>
        </div>
    </form>
</div>

<script>
    $(document).ready(function() {
        $('#select-responsable').select2();
    });
</script>
<?php /**PATH /var/www/html/resources/views/projets/form/onglets/taches/form.blade.php ENDPATH**/ ?>