fix: use saveStat method from trait instead of creating a new Statistique in AjaxController

This commit is contained in:
Noah Lancien 2025-11-13 09:52:47 +01:00
parent c6186b725a
commit 0c5eeff0d4

View file

@ -134,11 +134,7 @@ class AjaxController extends Controller
$mur->save();
// Sauvegarde de stat
$stat = new Statistique();
$stat->stat_campId = $campagne->camp_id;
$stat->stat_couponId = $cp->coupon_id;
$stat->stat_couponPrinted = 1;
$stat->save();
$this->saveStat($campagne, $cp);
}//end if
}//end foreach
} elseif ($campagne->camp_type->equals(CampaignTypes::panier())) {
@ -171,11 +167,7 @@ class AjaxController extends Controller
array_push($couponsPrinted, ['cp_code' => $cp->coupon_code, 'qty' => $panierContent->panier_content_quantity]);
// Sauvegarde de stat
$stat = new Statistique();
$stat->stat_campId = $campagne->camp_id;
$stat->stat_couponId = $cp->coupon_id;
$stat->stat_couponPrinted = $panierContent->panier_content_quantity;
$stat->save();
$this->saveStat($campagne, $cp);
} else {
if ($panierContent->panier_content_quantity > 0) {
$coupons .= '<img src="' . $imgCoupon . '" border="0" style="display:block;width:165mm;"/>';
@ -188,11 +180,7 @@ class AjaxController extends Controller
array_push($couponsPrinted, ['cp_code' => $cp->coupon_code, 'qty' => 1]);
// Sauvegarde de stat
$stat = new Statistique();
$stat->stat_campId = $campagne->camp_id;
$stat->stat_couponId = $cp->coupon_id;
$stat->stat_couponPrinted = 1;
$stat->save();
$this->saveStat($campagne, $cp);
}
}//end if
// ---- Mémorise l'impression
@ -233,11 +221,7 @@ class AjaxController extends Controller
$mur->save();
// Sauvegarde de stat
$stat = new Statistique();
$stat->stat_campId = $campagne->camp_id;
$stat->stat_couponId = $cp->coupon_id;
$stat->stat_couponPrinted = 1;
$stat->save();
$this->saveStat($campagne, $cp);
}//end if
}//end foreach
} elseif ($campagne->camp_type->equals(CampaignTypes::paniers())) {
@ -265,11 +249,7 @@ class AjaxController extends Controller
$newQtyPrinted = $panierContent->panier_content_printed + 1;
// Sauvegarde de stat
$stat = new Statistique();
$stat->stat_campId = $campagne->camp_id;
$stat->stat_couponId = $cp->coupon_id;
$stat->stat_couponPrinted = 1;
$stat->save();
$this->saveStat($campagne, $cp);
}
array_push($couponsPrinted, ['cp_code' => $cp->coupon_code, 'qty' => 1]);
// ---- Mémorise l'impression