<?php $__env->startSection('unique-css'); ?>
    <link href="<?php echo e(asset('css/projets/planning/planning.css')); ?>" rel="stylesheet">
<?php $__env->stopSection(); ?>

<?php
    $onglet_disabled = (Request::is('projets/create') || Request::routeIs('bibliotheque_projets.*')) ? 'disabled' : '';
?>

<?php $__env->startSection('content'); ?>
    <div id="ecran-projet" class="container">
        <h2 class="pb-2">
            <?php if(Request::routeIs('bibliotheque_projets.show')): ?>
                Fiche référentiel projet
            <?php elseif(Request::routeIs('bibliotheque_projets.create')): ?>
                Ajouter un projet à la bibliothèque
            <?php elseif(Request::is('projets/create')): ?> 
                Ajouter un projet
            <?php else: ?> 
                Modifier le projet
            <?php endif; ?> 
        </h2>

        <ul class="nav nav-tabs mt-4" id="myTab" role="tablist">
            <li class="nav-item">
                <a class="nav-link <?php if(Session::get('active') === null): ?> active <?php endif; ?>" id="creation-tab" data-toggle="tab" href="#creation" role="tab"
                   aria-controls="creation" aria-selected="true">Informations générales</a>
            </li>

            <li class="nav-item">
                <a class="nav-link <?php echo e($onglet_disabled); ?>

                <?php if(Session::get('active') === 'leviers'): ?> active <?php endif; ?>" id="leviers-tab" data-toggle="tab"
                   href="#leviers" role="tab" aria-controls="leviers" aria-selected="false">Leviers</a>
            </li>

            <?php if( (isset($projet) && $projet->type_calcul_gains === TYPE_CALCUL_GAINS::ACHATS_RECURRENTS) || !isset($projet)): ?>
                <li class="nav-item">
                    <a class="nav-link <?php echo e($onglet_disabled); ?>

                    <?php if(Session::get('active') === 'achats_simples'): ?> active <?php endif; ?>" id="achats-simples-tab"
                    data-toggle="tab" href="#achats-simples" role="tab" aria-controls="achats-simples"
                    aria-selected="false">Achats récurrents</a>
                </li>
            <?php endif; ?>

            <?php if( (isset($projet) && $projet->type_calcul_gains === TYPE_CALCUL_GAINS::ACHATS_COMPLEXES)): ?>
                <li class="nav-item">
                    <a class="nav-link <?php echo e($onglet_disabled); ?>

                    <?php if(Session::get('active') === 'achats_complexes'): ?> active <?php endif; ?> id="achats-complexes-tab"
                    data-toggle="tab" href="#achats-complexes" role="tab" aria-controls="achats-complexes"
                    aria-selected="false">Achats complexes</a>
                </li>
            <?php endif; ?>

            <?php if( (isset($projet) && $projet->type_calcul_gains === TYPE_CALCUL_GAINS::ACHATS_INVESTISSEMENT)): ?>
                <li class="nav-item">
                    <a class="nav-link <?php echo e($onglet_disabled); ?>

                    <?php if(Session::get('active') === 'achats_investissements'): ?> active <?php endif; ?> id="achats-investissements-tab"
                    data-toggle="tab" href="#achats-investissements" role="tab" aria-controls="achats-investissements"
                    aria-selected="false">Achats ponctuels</a>
                </li>
            <?php endif; ?>

            <li class="nav-item">
                <a class="nav-link <?php echo e($onglet_disabled); ?>

                <?php if(Session::get('active') === 'resp.soc.env'): ?> active <?php endif; ?>" id="respsocenv-tab" data-toggle="tab"
                   href="#respsocenv" role="tab" aria-controls="respsocenv" aria-selected="false">Resp.Soc.Env.</a>
            </li>

            <li class="nav-item">
                <a class="nav-link <?php echo e($onglet_disabled); ?>

                <?php if(Session::get('active') === 'statuts'): ?> active <?php endif; ?>" id="statuts-tab" data-toggle="tab"
                   href="#statuts" role="tab" aria-controls="status" aria-selected="false">Statuts</a>
            </li>

            <li class="nav-item">
                <a class="nav-link <?php echo e($onglet_disabled); ?>

                <?php if(str_starts_with(Session::get('active') ?? '', 'gestion_projet')): ?> active <?php endif; ?>" id="gestion-projet-tab" data-toggle="tab"
                   href="#gestionprojet" role="tab" aria-controls="gestionprojet" aria-selected="false">Gestion projet</a>
            </li>

            <li class="nav-item">
                <a class="nav-link <?php echo e($onglet_disabled); ?>

                <?php if(in_array(Session::get('active'), array('planification', 'planification.create', 'planification.edit'))): ?> active <?php endif; ?>" id="planification-tab" data-toggle="tab"
                   href="#planification" role="tab" aria-controls="planification" aria-selected="false">Planification</a>
            </li>

            <li class="nav-item">
                <a class="nav-link <?php echo e($onglet_disabled); ?>

                <?php if(Session::get('active') === 'suivi'): ?> active <?php endif; ?>" id="suivi-tab" data-toggle="tab"
                   href="#suivi" role="tab" aria-controls="suivi" aria-selected="false">Suivi</a>
            </li>

            <li class="nav-item">
                <a class="nav-link <?php echo e($onglet_disabled); ?>

                <?php if(in_array(Session::get('active'), array('messages', 'messages.create', 'messages.edit'))): ?> active <?php endif; ?>" id="messages-tab" data-toggle="tab"
                   href="#messages" role="tab" aria-controls="messages" aria-selected="false">Messages</a>
            </li>

            <li class="nav-item">
                <a class="nav-link <?php echo e($onglet_disabled); ?>

                <?php if(in_array(Session::get('active'), array('fichiers', 'fichiers.create', 'fichiers.edit'))): ?> active <?php endif; ?>" id="fichiers-tab" data-toggle="tab"
                   href="#fichiers" role="tab" aria-controls="fichiers" aria-selected="false">Fichiers</a>
            </li>
        </ul>

        <div class="tab-content p-4" id="myTabContent">
            <!-- Onglet Création -->
            <div class="tab-pane fade <?php if(Session::get('active') === null): ?> show active <?php endif; ?>" id="creation" role="tabpanel" aria-labelledby="creation-tab">
                <?php echo $__env->make('projets.form.onglets.creation', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
            </div>

            
            <?php if(!Request::is('projets/create') && !Request::routeIs('bibliotheque_projets.*')): ?>
                <!-- Onglet Leviers -->
                <div class="tab-pane fade <?php if(Session::get('active') === 'leviers'): ?> show active <?php endif; ?>" id="leviers" role="tabpanel" aria-labelledby="leviers-tab">
                    <?php echo $__env->make('projets.form.onglets.leviers', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                </div>

                <!-- Onglet Achats simples -->
                <?php if( (isset($projet) && $projet->type_calcul_gains === TYPE_CALCUL_GAINS::ACHATS_RECURRENTS) || !isset($projet)): ?>
                    <div class="tab-pane fade <?php if(Session::get('active') === 'achats_simples'): ?> show active <?php endif; ?>" id="achats-simples" role="tabpanel" aria-labelledby="achats-simples-tab">
                        <?php echo $__env->make('projets.form.onglets.achats.achats-simples', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                    </div>
                <?php endif; ?>

                <!-- Onglet Achats complexes -->
                <?php if( (isset($projet) && $projet->type_calcul_gains === TYPE_CALCUL_GAINS::ACHATS_COMPLEXES)): ?>
                    <div class="tab-pane fade <?php if(Session::get('active') === 'achats_complexes'): ?> show active <?php endif; ?>" id="achats-complexes" role="tabpanel" aria-labelledby="achats-complexes-tab">
                        
                        <?php if($projet->structure->type_achat_cout_global == 1): ?>
                            <?php echo $__env->make('projets.form.onglets.achats.achats-complexes', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                        
                        <?php elseif($projet->structure->type_achat_cout_global == 2): ?>
                            <?php echo $__env->make('projets.form.onglets.achats.achats-complexes-dgos', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                        <?php endif; ?>
                    </div>
                <?php endif; ?>

                <!-- Onglet Achats investissement -->
                <?php if( (isset($projet) && $projet->type_calcul_gains === TYPE_CALCUL_GAINS::ACHATS_INVESTISSEMENT)): ?>
                    <div class="tab-pane fade <?php if(Session::get('active') === 'achats_investissements'): ?> show active <?php endif; ?>" id="achats-investissements" role="tabpanel" aria-labelledby="achats-investissements-tab">
                        <?php echo $__env->make('projets.form.onglets.achats.achats-investissements', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                    </div>
                <?php endif; ?>

                <!-- Onglet Resp.Soc.Env. -->
                <div class="tab-pane fade <?php if(Session::get('active') === 'resp.soc.env'): ?> show active <?php endif; ?>" id="respsocenv" role="tabpanel" aria-labelledby="contact-tab">
                    <?php echo $__env->make('projets.form.onglets.resp-soc-env', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                </div>

                <!-- Onglet Statuts -->
                <div class="tab-pane fade <?php if(Session::get('active') === 'statuts'): ?> show active <?php endif; ?>" id="statuts" role="tabpanel" aria-labelledby="statuts-tab">
                    <?php echo $__env->make('projets.form.onglets.statut', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                </div>

                <!-- Onglet Gestion projet -->
                <div class="tab-pane fade <?php if(Session::get('active') === 'gestion_projet'): ?> show active <?php endif; ?>" id="gestionprojet" aria-labelledby="gestionprojet-tab">
                    <?php echo $__env->make('projets.form.onglets.gestion-projet', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                </div>
                <div class="tab-pane fade <?php if(Session::get('active') === 'gestion_projet.form'): ?> show active <?php endif; ?>" id="gestionprojet-form" role="tabpanel" aria-labelledby="gestionprojet-form-tab">
                    <?php echo $__env->make('projets.form.onglets.taches.form', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                </div>

                <!-- Onglet planification -->
                <div class="tab-pane fade <?php if(Session::get('active') === 'planification'): ?> show active <?php endif; ?>" id="planification" role="tabpanel" aria-labelledby="contact-tab">
                    <?php echo $__env->make('projets.form.onglets.planification.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                </div>

                <!-- Onglet Suivi -->
                <div class="tab-pane fade <?php if(Session::get('active') === 'suivi'): ?> show active <?php endif; ?>" id="suivi" role="tabpanel" aria-labelledby="contact-tab">
                    <?php echo $__env->make('projets.form.onglets.suivi', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                </div>

                <!-- Onglet Messages -->
                <div class="tab-pane fade <?php if(Session::get('active') === 'messages'): ?> show active <?php endif; ?>" id="messages" role="tabpanel" aria-labelledby="messages-tab">
                    <?php echo $__env->make('projets.form.onglets.messages', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                </div>

                <!-- Onglet Fichier -->
                <div class="tab-pane fade <?php if(Session::get('active') === 'fichiers'): ?> show active <?php endif; ?>" id="fichiers" role="tabpanel" aria-labelledby="contact-tab">
                    <?php echo $__env->make('projets.form.onglets.fichiers.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                </div>
                <div class="tab-pane fade <?php if(Session::get('active') === 'fichiers.create'): ?> show active <?php endif; ?>" id="fichiers" role="tabpanel" aria-labelledby="contact-tab">
                    <?php echo $__env->make('projets.form.onglets.fichiers.create', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                </div>
                
                <?php if(isset($fichier)): ?>
                    <div class="tab-pane fade <?php if(Session::get('active') === 'fichiers.edit'): ?> show active <?php endif; ?>" id="fichiers" role="tabpanel" aria-labelledby="contact-tab">
                        <?php echo $__env->make('projets.form.onglets.fichiers.edit', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                    </div>
                <?php endif; ?>
            <?php endif; ?>
        </div>
    </div>

    <script>
        
        $('a[data-toggle="tab"]').on('shown.bs.tab', function () {
            $('.alert-success').hide();
            $('.alert-danger').hide();
        });
    </script>
    <script src="<?php echo e(asset('js/projets/planning/planning.js')); ?>"></script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/resources/views/projets/form/form.blade.php ENDPATH**/ ?>