'dimanche', 1 => 'lundi', 2 => 'mardi', 3 => 'mercredi', 4 => 'jeudi', 5 => 'vendredi', 6 => 'samedi'];
$champs_horaires_point_vente = 'horaires_' . $arr_jour_semaine[$num_jour_semaine];
$html = '' ;
// par point de vente
foreach ($points_vente as $pv) {
if (count($pv->order) && strlen($pv->$champs_horaires_point_vente)) {
$html .= '
'.$pv->name.'
' ;
$col_credit_pain = '' ;
if($pv->credit) {
$col_credit = 'Rappel crédit | ' ;
}
$html .= ''
. ''
. ''
. 'Client | '
. 'Produits | '
. 'Commentaire | '
. $col_credit
. 'Montant | '
. '
'
. '';
foreach ($pv->orders as $c) {
$html .= '' ;
$str_user = '';
// username
if ($c->user) {
$str_user = $c->user->name . " " . $c->user->lastname;
} else {
$str_user = $c->username;
}
if(strlen($c->comment_point_sale))
{
$str_user .= '
'.$c->comment_point_sale.'' ;
}
// téléphone
if (isset($c->user) && strlen($c->user->phone)) {
$str_user .= '
' . $c->user->phone . '';
}
$html .= ''.$str_user.' | ';
// produits
$str_produits = '';
foreach ($produits as $p) {
$add = false;
foreach ($c->productOrder as $cp) {
if ($p->id == $cp->id_product) {
$str_produits .= $cp->quantity . ' ' . $p->name . ', ';
$add = true;
}
}
}
$html .= ''.substr($str_produits, 0, strlen($str_produits) - 2).' | ';
$html .= ''.$c->comment.' | ';
if($pv->credit) {
$credit = '' ;
if(isset($c->user) && isset($c->user->userProducer)) {
$credit = number_format($c->user->userProducer[0]->credit,2).' €' ;
}
$html .= ''.$credit.' | ' ;
}
$html .= ''.number_format($c->amount, 2) . ' € ';
if($c->getStatusPayment() == Order::PAYMENT_PAID)
{
$html .= '(payé)' ;
}
elseif($c->getStatusPayment() == Order::PAYMENT_UNPAID && $c->getAmount(Order::AMOUNT_PAID))
{
$html .= '(reste '.$c->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ;
}
elseif($c->getStatusPayment() == Order::PAYMENT_SURPLUS)
{
$html .= '(surplus : '.$c->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ;
}
$html .= ' | ' ;
$html .= '
' ;
}
$html .= 'Total | ' ;
$str_produits = '';
foreach ($produits as $p) {
$quantite = Order::getProductQuantity($p->id, $pv->orders);
$str_quantite = '';
if ($quantite) {
$str_quantite = $quantite;
$str_produits .= $str_quantite .' '. $p->name . ', ';
}
}
$str_produits = substr($str_produits, 0, strlen($str_produits) - 2) ;
$html .= ''.$str_produits.' | | ' ;
if($pv->credit) {
$html .= ' | ' ;
}
$html .= ''.number_format($pv->revenues, 2) . ' € | ';
$html .= '
' ;
}
}
// par point de vente
$html .= 'Points de vente
' ;
$html .= ''
. ''
. ''
. 'Point de vente | '
. 'Produits | '
. 'Montant | '
. '
'
. '';
$recettes = 0 ;
foreach ($points_vente as $pv)
{
if (count($pv->orders) && strlen($pv->$champs_horaires_point_vente))
{
$html .= ''.$pv->name.' | ' ;
foreach ($produits as $p) {
$quantite = Order::getProductQuantity($p->id, $pv->orders);
$str_quantite = '';
if ($quantite) {
$str_quantite = $quantite;
}
if(strlen($str_quantite)) {
$html .= $str_quantite . ' '.$p->name.', ' ;
}
}
$html = substr($html, 0, strlen($html) - 2) ;
$html .= ' | '.number_format($pv->revenues, 2).' € |
' ;
$recettes += $pv->revenues ;
}
}
// total
$html .= 'Total | ' ;
foreach ($produits as $p) {
$quantite = Order::getProductQuantity($p->id, $orders);
if($quantite) {
$html .= $quantite . ' '.$p->name.', ' ;
}
}
$html = substr($html, 0, strlen($html) - 2) ;
$html .= ' | '.number_format($recettes, 2).' € |
' ;
$html .= '
' ;
echo $html ;
?>