Merge branch 'ajax-controller-save-stat-bug' into 'develop'

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

See merge request ldc-web/projets/mesbr!14
This commit is contained in:
Vincent BRIDIER 2025-11-13 09:03:53 +00:00
commit d4fcdc8df0

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