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

<div>
    <div class="row mt-2 mb-2">
        <div class="col-12">
            <h5>Gains</h5><br>
        </div>
    </div>
    <?php if(sizeof($gains) > 0): ?>
        <table class="table table-striped table-bordered">
            <thead>
                
                <tr>
                    <th colspan="2"></th>
                    <?php for($i = $min_annee; $i < $max_annee + 1; $i++): ?>
                        <th colspan="2"><?php echo e($i); ?></th>
                    <?php endfor; ?>
                </tr>
            </thead>
            <tbody>
                
                <tr>
                    <td>Acheteur</td>
                    <td>Objet</td>
                    <?php for($i = $min_annee; $i < $max_annee + 1; $i++): ?>
                        <td>Gains cibles</td>
                        <td>Gains notifiés</td>
                    <?php endfor; ?>
                </tr>
                
                <?php $__currentLoopData = $gains; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><?php echo e($value['owner']); ?></td>
                        <td><?php echo e($value['objet']); ?></td>
                        <?php for($i = $min_annee; $i < $max_annee + 1; $i++): ?>
                                <td class="cibles_<?php echo e($i); ?> autonumeric"><?php echo e($value['gains'][$i]['cible'] ?? 0); ?></td>
                                <td class="notifies_<?php echo e($i); ?> autonumeric"><?php echo e($value['gains'][$i]['notifie'] ?? 0); ?></td>
                        <?php endfor; ?>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td colspan="2">Totaux</td>
                    <?php for($i = $min_annee; $i < $max_annee + 1; $i++): ?>
                        <td class="totaux_cibles_<?php echo e($i); ?>">0</td>
                        <td class="totaux_notifies_<?php echo e($i); ?>">0</td>
                    <?php endfor; ?>
                </tr>
            </tbody>
        </table>
    <?php else: ?>
        <div class="pt-2">
            <h4>Pas de données disponible.</h4>
        </div>
    <?php endif; ?>
</div>


<?php if(sizeof($gains) > 0): ?>
    <script>
        $(document).ready(function() {
            // Permet de calculer la ligne "totaux"
            var min_annee = <?php echo e($min_annee); ?>;
            var annee_max = <?php echo e($max_annee); ?>;
            for(var i = min_annee; i < annee_max + 1; i++)
            {
                var total_cibles = 0;
                var total_notifies = 0;
                $('.cibles_' + i).each(function() {
                    total_cibles += parseFloat($(this).text().replace(/ /g, ''));
                });
                $('.notifies_' + i).each(function() {
                    total_notifies += parseFloat($(this).text().replace(/ /g, ''));
                });
                $('.totaux_cibles_' + i).html(total_cibles);
                new AutoNumeric($('.totaux_cibles_' + i)[0], autonumericConfig);
                $('.totaux_notifies_' + i).html(total_notifies);
            }
        });
    </script>
<?php endif; ?>
<?php /**PATH /var/www/html/resources/views/projets/index/layouts/onglets/gains.blade.php ENDPATH**/ ?>