add diffused coupons
This commit is contained in:
parent
04efba2974
commit
2f4fa9e6fd
4 changed files with 26 additions and 1 deletions
|
|
@ -43,6 +43,7 @@ class StatistiqueController extends Controller
|
|||
foreach ($coupons as $coupon) {
|
||||
$coupon->quantity = $this->getFullQuantity($coupon);
|
||||
$coupon->remain = $this->getFullQuantity($coupon) - $this->getUsedQuantity($coupon);
|
||||
$coupon->diffused = $this->getDiffusedQuantity($coupon);
|
||||
$coupon->isPrintable = $this->isAvailableToPrint($coupon, $campagne);
|
||||
$coupon->isPaused = $this->isPausedToPrint($coupon, $campagne);
|
||||
}
|
||||
|
|
@ -79,6 +80,7 @@ class StatistiqueController extends Controller
|
|||
foreach ($coupons as $coupon) {
|
||||
$coupon->quantity = $this->getFullQuantity($coupon);
|
||||
$coupon->remain = $this->getFullQuantity($coupon) - $this->getUsedQuantity($coupon);
|
||||
$coupon->diffused = $this->getDiffusedQuantity($coupon);
|
||||
$coupon->isPrintable = $this->isAvailableToPrint($coupon, $campagne);
|
||||
$coupon->isPaused = $this->isPausedToPrint($coupon, $campagne);
|
||||
$coupon->color = $colors[$count];
|
||||
|
|
|
|||
|
|
@ -283,6 +283,26 @@ trait CouponTrait {
|
|||
return $countPrinted;
|
||||
}
|
||||
|
||||
public function getDiffusedQuantity(Coupon $coupon) {
|
||||
$countPrinted = 0;
|
||||
$campagnes = $coupon->campagnes()->get();
|
||||
foreach ($campagnes as $campagne) {
|
||||
if($campagne->camp_type == 0 || $campagne->camp_type == 2) { // Murs
|
||||
$murs = Mur::where(['mur_campid' => $campagne->camp_id, 'mur_couponId' => $coupon->coupon_id])->get();
|
||||
$countPrinted = $countPrinted + count($murs);
|
||||
|
||||
} else { // Paniers
|
||||
$paniers = Panier::where(['panier_campId' => $campagne->camp_id])->get();
|
||||
foreach ($paniers as $key => $panier) {
|
||||
$panierContentCountPrinted = $panier->panierContents->sum('panier_content_printed');
|
||||
$panierContentCountDiffused = $panier->panierContents->sum('panier_content_quantity');
|
||||
$countPrinted = $countPrinted + $panierContentCountPrinted + $panierContentCountDiffused;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $countPrinted;
|
||||
}
|
||||
|
||||
public function getUsedQuantityOnPeriod(Coupon $coupon, $startdate, $enddate) {
|
||||
$countPrinted = 0;
|
||||
$startdate = date('Y-m-d H:i:s', strtotime($startdate));
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@
|
|||
<p><span>Valeur :</span> <span>{{ str_replace('.', ',', number_format($coupon->coupon_value, 2))}} €</span></p>
|
||||
<p><span>Quantité Totale :</span> <span>{{$coupon->quantity}}</span></p>
|
||||
<p><span>Quantité Restante :</span> <span>{{$coupon->remain}}</span></p>
|
||||
<p><span>Quantité Diffusé :</span> <span>{{$coupon->quantity - $coupon->remain}}</span></p>
|
||||
<p><span>Quantité Diffusé :</span> <span>{{$coupon->diffused}}</span></p>
|
||||
<p><span>Quantité Imprimé :</span> <span>{{$coupon->quantity - $coupon->remain}}</span></p>
|
||||
@if($coupon->coupon_mindatediffusion != null)
|
||||
<p><span>Date de début de diffusion :</span> <span>{{ date('d/m/Y', strtotime($coupon->coupon_mindatediffusion)) }}</span></p>
|
||||
@else
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
<th>Qté Totale</th>
|
||||
<th>Qté Restante</th>
|
||||
<th>Qté Diffusé</th>
|
||||
<th>Qté Imp</th>
|
||||
<th>Fin de diffusion</th>
|
||||
<th>Statut</th>
|
||||
</thead>
|
||||
|
|
@ -47,6 +48,7 @@
|
|||
<td>{{ str_replace('.', ',', number_format($coupon->coupon_value, 2))}} €</td>
|
||||
<td>{{$coupon->quantity}}</td>
|
||||
<td>{{$coupon->remain}}</td>
|
||||
<td>{{$coupon->diffused}}</td>
|
||||
<td>{{$coupon->quantity - $coupon->remain}}</td>
|
||||
@if($coupon->coupon_maxdatediffusion != null)
|
||||
<td>{{ date('d/m/Y', strtotime($coupon->coupon_maxdatediffusion)) }}</td>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue