<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\CreditHistorique; 
use common\models\Etablissement;
use common\models\Commande;

$this->title = 'Commandes <small>'.Html::encode($user->nom.' '.$user->prenom).'</small>';
$this->params['breadcrumbs'][] = ['label' => 'Clients', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => Html::encode($user->nom.' '.$user->prenom)];
$this->params['breadcrumbs'][] = 'Créditer';

?>

<div class="user-commandes">
    
    <h1><?= $this->title ?> </h1>
    
    <?php if(count($commandes)): ?>
    <table id="historique-commandes" class="table table-striped table-bordered">
        <thead>
            <tr>                         
                <th>Date livraison</th>
                <th>Résumé</th>
                <th>Point de vente</th>
                <th class="montant">Montant</th>
            </tr>
        </thead>
        <tbody>
        <?php foreach($commandes as $c): ?>
            <tr>
                <td><?php echo date('d/m/Y',strtotime($c->production->date)); ?></td>
                <td class="resume"><?= $c->getResumePanier() ; ?></td>
                <td><?= $c->getResumePointVente(); ?></td>
                <td class="montant"><?= $c->getResumeMontant(); ?></td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table> 
    <?php else: ?>
        <div class="alert alert-warning">Aucune commande passée par ce client.</div>
    <?php endif; ?>
</div>