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


<div class="custom-frame mt-4 p-3">
    <div class="row">
        <div class="col-12">
            <h5>Performance économique des actions achats</h5><br>
        </div>
    </div>
    <div class="row text-center">
        <div class="col">
            <h4><span class="autonumeric"><?php if(isset($gains_cibles)): ?> <?php echo e($gains_cibles); ?> <?php else: ?> 0 <?php endif; ?></span><span class="text-primary"> €</span></h4>
            <h6 class="font-weight-bold mb-1">Gains cibles</h6>
        </div>
        <div class="col">
            <h4><span class="autonumeric"><?php if(isset($gains_notifies)): ?> <?php echo e($gains_notifies); ?> <?php else: ?> 0 <?php endif; ?></span><span class="text-primary"> €</span></h4>
            <h6 class="font-weight-bold mb-1">Gains notifiés</h6>
        </div>
        <div class="col">
            <h4><?php if(isset($nombre_projets)): ?> <?php echo e($nombre_projets); ?> <?php else: ?> 0 <?php endif; ?></h4>
            <h6 class="font-weight-bold mb-1">Nombre total de projets</h6>
        </div>
        <div class="col">
            <h4><?php if(isset($gains_notifies, $gains_cibles)): ?> <?php if($gains_cibles > 0): ?> <?php echo e(round($gains_notifies/$gains_cibles, 2)); ?> <?php else: ?> 0 <?php endif; ?> <?php else: ?> 0 <?php endif; ?><span class="text-primary"> %</span></h4>
            <h6 class="font-weight-bold mb-1">Taux de transformation</h6>
        </div>
        <div class="col">
            <h4><span class="autonumeric"><?php if(isset($montant_depenses_traitees)): ?> <?php echo e($montant_depenses_traitees); ?> <?php else: ?> 0 <?php endif; ?></span><span class="text-primary"> €</span></h4>
            <h6 class="font-weight-bold mb-1">Montant des dépenses traitées</h6>
        </div>
    </div>
</div>

<div class="row">
    
    <div class="col-md-8">
        <div class="custom-frame pl-3 pr-3">
            <h5>Top 10 des projets achats</h5>
            <br>
            <?php if(sizeof($top_10_projets) > 0): ?>
                <table class="table table-striped mt-3">
                    <?php $__currentLoopData = $top_10_projets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t10p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($loop->index + 1); ?></td>
                            <td><?php echo e($t10p->objet); ?></td>
                            <td>
                                <div class="multi-step col-6">
                                    <ul class="multi-step-list">
                                        <?php for($i = 1; $i <= ETAPE_PROJET::NOMBRE_ETAPE; $i++): ?>
                                            <li class="multi-step-item progress-<?php echo e($i); ?> <?php if(isset($t10p)): ?> <?php if(in_array(ETAPE_PROJET::ETAPES_ORDERED[$i - 1], $t10p->etapes())): ?> current <?php endif; ?> <?php endif; ?>">
                                                <div class="item-wrap">
                                                    <p class="item-title"><?php echo e($i); ?></p>
                                                </div>
                                            </li>
                                        <?php endfor; ?>
                                    </ul>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>Montant de référence : <span class="autonumeric"><?php echo e($t10p->montant_reference ?? 0); ?></span> €</td>
                            <td>Gains cibles : <span class="autonumeric"><?php echo e($t10p->gains_cible ?? 0); ?></span> €</td>
                            <td>Gains notifiés : <span class="autonumeric"><?php echo e($t10p->gains_notifie ?? 0); ?></span> €</td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </table>
            <?php else: ?>
                <div class="pt-2">
                    <h4>Pas de données disponible.</h4>
                </div>
            <?php endif; ?>
        </div>
    </div>
    
    <div class="col-md-4">
        <div class="custom-frame pl-3 pr-3">
            <h5>Directions</h5>
            <br>
            <?php if(sizeof(array_keys($graphe_directions)) > 0): ?>
                <canvas id="directions-chart" width="400" height="400"></canvas>
            <?php else: ?>
                <span>Pas de données disponible.</span>
            <?php endif; ?>
            <h5>Leviers</h5>
            <br>
            <?php if(sizeof(array_keys($graphe_leviers)) > 0): ?>
                <canvas id="leviers-chart" width="400" height="400"></canvas>
            <?php else: ?>
                <span>Pas de données disponible.</span>
            <?php endif; ?>
        </div>
    </div>
</div>


<script>
    <?php if(sizeof(array_keys($graphe_directions)) > 0 || sizeof(array_keys($graphe_leviers)) > 0): ?>
        
        var backgroundColor = ["rgba(54,144,220,0.6)","rgba(70,191,189,0.6)","rgba(253,180,92,0.6)","rgba(238,130,81,0.6)","rgba(99,83,141,0.6)","rgba(90,151,130,0.6)","rgba(118,111,85,0.6)","rgba(231,104,110,0.6)","rgba(233,170,226,0.6)","rgba(77,83,96,0.6)","rgba(225,238,158,0.6)","rgba(106,131,118,0.6)","rgba(176,232,222,0.6)"];
        var borderColor = ["rgb(54,144,220)","rgb(70,191,189)","rgb(253,180,92)","rgb(238,130,81)","rgb(99,83,141)","rgb(90,151,130)","rgb(118,111,85)","rgb(231,104,110)","rgb(233,170,226)","rgb(77,83,96)","rgb(225,238,158)","rgb(106,131,118)","rgb(176,232,222)"];
    <?php endif; ?>

    
    <?php if(sizeof(array_keys($graphe_directions)) > 0): ?>
        var directionsData = {
            datasets: [{
                data: [<?php echo e(implode(',', array_values($graphe_directions))); ?>],
                backgroundColor: backgroundColor,
                borderColor: borderColor
            }],
            labels: [<?php echo '"' . implode('","', array_keys($graphe_directions)) . '"'; ?>]
        };

        var ctxDirections = document.getElementById('directions-chart').getContext('2d');
        new Chart(ctxDirections, {
            type: 'doughnut',
            data: directionsData,
            options: {
                responsive: true,
                plugins: {
                    labels: {
                        render: 'percentage',
                        fontSize: 14,
                        fontStyle: 'bold',
                        fontColor: '#fff',
                    }
                }
            },
        });
    <?php endif; ?>

    
    <?php if(sizeof(array_keys($graphe_leviers)) > 0): ?>
        
        <?php if(sizeof(array_keys($graphe_leviers)) > 2): ?>
            var leviersData = {
                datasets: [{
                    label: 'Leviers',
                    data: [<?php echo e(implode(',', array_values($graphe_leviers))); ?>],
                    backgroundColor: backgroundColor,
                    borderColor: borderColor
                }],
                labels: [<?php echo '"' . implode('","', array_keys($graphe_leviers)) . '"'; ?>]
            };

            var ctxLeviers = document.getElementById('leviers-chart').getContext('2d');
            new Chart(ctxLeviers, {
                type: 'radar',
                data: leviersData,
                options: {
                    responsive: true,
                    maintainAspectRatio: true,
                    scale: {
                        ticks: {
                            beginAtZero: true,
                            max: 5
                        }
                    }
                }
            });
        <?php else: ?>
            var leviersData = {
                datasets: [{
                    data: [<?php echo e(implode(',', array_values($graphe_leviers))); ?>],
                    backgroundColor: backgroundColor,
                    borderColor: borderColor
                }],
                labels: [<?php echo '"' . implode('","', array_keys($graphe_leviers)) . '"'; ?>]
            };

            var ctxLeviers = document.getElementById('leviers-chart').getContext('2d');
            new Chart(ctxLeviers, {
                type: 'doughnut',
                data: leviersData,
                options: {
                    responsive: true,
                    plugins: {
                        labels: {
                            render: 'percentage',
                            fontSize: 14,
                            fontStyle: 'bold',
                            fontColor: '#fff',
                        }
                    }
                },
            });
        <?php endif; ?>
    <?php endif; ?>
</script>
<?php /**PATH /var/www/html/resources/views/projets/index/layouts/onglets/performance.blade.php ENDPATH**/ ?>