<?php 

use common\models\Commande ;
use yii\helpers\Html ;

?>

<h2>Global</h2>

<div class="alert alert-warning">
    <strong>Potentiel :</strong> <?= number_format($ca_potentiel,2); ?> € (<?= $poids_total ?> kg)<br />
    <strong>Commandé :</strong> <?= number_format($recettes_pain,2); ?> € (<?= $poids_pain ?> kg)
</div>

<table class="table table-bordered table-condensed tab-content table-produits">
<tbody>
    <?php
    foreach ($produits as $p) {
        if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) {
            echo '<tr>' ;

            $quantite = Commande::getQuantiteProduit($p->id, $commandes);
            $str_quantite = '';
            if ($quantite)
                $str_quantite = $quantite;

            $classe = 'center total';
            if ($str_quantite > $produits_selec[$p->id]['quantite_max'] && !$produits_selec[$p->id]['vrac']) {
                $classe .= ' depasse';
            }

            if ($p->vrac) {
                $classe .= ' vrac';
            }

            echo '<td class="' . $classe . '"><strong>' . $str_quantite . ' <span>';

            if ($produits_selec[$p->id]['quantite_max'] && $str_quantite)
                echo '/ ' . $produits_selec[$p->id]['quantite_max'] . '</span></strong></td>';

            echo '<td>'.Html::encode($p->getLibelleAdmin()).'</td></tr>' ;
        }
    }
    ?>

    <tr class="tr-total">
        <td class="td-total"></td>
        <td></td>
    </tr>
</tbody>
</table>