Mail notif
This commit is contained in:
parent
2d81aeb64c
commit
3e2f85ef31
4 changed files with 10 additions and 36 deletions
|
|
@ -44,7 +44,6 @@ class Kernel extends ConsoleKernel
|
|||
$sendMail = false;
|
||||
$users = array();
|
||||
$couponSeuil = array();
|
||||
$couponValidity = array();
|
||||
$couponDiffusion = array();
|
||||
|
||||
$coupons = Coupon::where(['coupon_siteId' => $site->id])->get();
|
||||
|
|
@ -56,15 +55,8 @@ class Kernel extends ConsoleKernel
|
|||
array_push($couponSeuil, $coupon);
|
||||
$couponAlert = true;
|
||||
}
|
||||
|
||||
// --- Check Max date validity
|
||||
if(strtotime($coupon->coupon_maxdatevalidity) > (time() - (7*24*60*60))){ //Fin de validité dans moins d'une semaine
|
||||
array_push($couponValidity, $coupon);
|
||||
$couponAlert = true;
|
||||
}
|
||||
|
||||
// --- Check MaxDateDiffusion
|
||||
if(strtotime($coupon->coupon_maxdatediffusion) > (time() - (7*24*60*60))){ //Fin de diffusion dans moins d'une semaine
|
||||
if(strtotime($coupon->coupon_maxdatediffusion) < (time() + (30*24*60*60))){ //Fin de diffusion dans moins de 30jours
|
||||
array_push($couponDiffusion, $coupon);
|
||||
$couponAlert = true;
|
||||
}
|
||||
|
|
@ -86,7 +78,7 @@ class Kernel extends ConsoleKernel
|
|||
}
|
||||
}
|
||||
if($sendMail){
|
||||
Mail::to($users)->send(new AlertBr($couponSeuil, $couponDiffusion, $couponValidity));
|
||||
Mail::to($users)->send(new AlertBr($couponSeuil, $couponDiffusion, $site->name));
|
||||
}
|
||||
}
|
||||
})->everyMinute();
|
||||
|
|
|
|||
|
|
@ -14,18 +14,19 @@ class AlertBr extends Mailable
|
|||
|
||||
public $couponSeuil;
|
||||
public $couponDiffusion;
|
||||
public $couponValidity;
|
||||
public $sitename;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($couponSeuil, $couponDiffusion, $couponValidity)
|
||||
public function __construct($couponSeuil, $couponDiffusion, $sitename)
|
||||
{
|
||||
$this->couponSeuil = $couponSeuil;
|
||||
$this->couponDiffusion = $couponDiffusion;
|
||||
$this->couponValidity = $couponValidity;
|
||||
$this->sitename = $sitename;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -35,6 +36,6 @@ class AlertBr extends Mailable
|
|||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->view('mail.alert')->with(['couponSeuil' => $this->couponSeuil, 'couponDiffusion' => $this->couponDiffusion, 'couponValidity' => $this->couponValidity]);
|
||||
return $this->view('mail.alert')->subject('Notification mes BR : '.$this->sitename)->with(['couponSeuil' => $this->couponSeuil, 'couponDiffusion' => $this->couponDiffusion]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ trait CouponTrait {
|
|||
}
|
||||
|
||||
// ---- Contrôle la date de validité
|
||||
if($coupon->coupon_maxdatevalidity != null){
|
||||
if(strtotime(date('Y-m-d')) > strtotime($coupon->coupon_maxdatevalidity)){
|
||||
if($coupon->coupon_maxdatediffusion != null){
|
||||
if(strtotime(date('Y-m-d')) > strtotime($coupon->coupon_maxdatediffusion)){
|
||||
$coupons->forget($key);
|
||||
}
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ trait CouponTrait {
|
|||
$available = true;
|
||||
|
||||
// ---- Contrôle le nombre limite d'impression
|
||||
if($coupon->coupon_enablelimitquantity == 1){
|
||||
if($coupon->coupon_enablelimitquantity == 1 && $coupon->coupon_enablelimitquantity > 0){
|
||||
$stat = Mur::where([
|
||||
'mur_campId' => $campagne->camp_id,
|
||||
'mur_contactId' => $contact->contact_id,
|
||||
|
|
|
|||
|
|
@ -47,25 +47,6 @@
|
|||
@endforeach
|
||||
</table><br/>
|
||||
@endif
|
||||
{{-- Alerte de max date validity --}}
|
||||
@if (!empty($couponValidity))
|
||||
<p style='font-family: arial; font-size:15px; color: #393939; font-weight: bold;'>Coupons en fin de validité d'ici 7 jours :<p><br/>
|
||||
|
||||
<table align='center' cellpadding='0' cellspacing='0'style='font-family:arial; color: #3F3F3F; font-size:13px;' >
|
||||
<tr>
|
||||
<td style='border-bottom: 1px solid #ddd; width: 200px; padding: 8px; font-weight: bold;'>Code du coupon</td>
|
||||
<td style='border-bottom: 1px solid #ddd; font-weight: bold; width: 200px; padding: 8px;'>Nom du coupon</td>
|
||||
<td style='font-weight: bold; border-bottom: 1px solid #ddd; width: 200px; padding: 8px;'>Date de fin de validité</td>
|
||||
</tr>
|
||||
@foreach ($couponValidity as $cpvalidity)
|
||||
<tr>
|
||||
<td style='border-bottom: 1px solid #ddd; width: 200px; padding: 8px;'>{{ $cpvalidity->coupon_code }}</td>
|
||||
<td style='border-bottom: 1px solid #ddd;width: 200px; padding: 8px;'>{{ $cpvalidity->coupon_name }}</td>
|
||||
<td style='border-bottom: 1px solid #ddd; width: 200px; padding: 8px;'>{{ $cpvalidity->coupon_maxdatevalidity }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table><br/>
|
||||
@endif
|
||||
<div style='height:20px; background-color: #393939;'></div>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue