mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 23:30:35 -04:00
Send email to the admin when a new patron joins
This commit is contained in:
parent
e2a1dbb1e5
commit
fa8fa4f7eb
5 changed files with 70 additions and 0 deletions
|
@ -40,6 +40,14 @@ class Patron extends PropertiesBase{
|
||||||
$em->Body = Template::EmailPatronsCircleWelcome(['isAnonymous' => $this->IsAnonymous, 'isReturning' => $isReturning]);
|
$em->Body = Template::EmailPatronsCircleWelcome(['isAnonymous' => $this->IsAnonymous, 'isReturning' => $isReturning]);
|
||||||
$em->TextBody = Template::EmailPatronsCircleWelcomeText(['isAnonymous' => $this->IsAnonymous, 'isReturning' => $isReturning]);
|
$em->TextBody = Template::EmailPatronsCircleWelcomeText(['isAnonymous' => $this->IsAnonymous, 'isReturning' => $isReturning]);
|
||||||
$em->Send();
|
$em->Send();
|
||||||
|
|
||||||
|
$em = new Email();
|
||||||
|
$em->To = ADMIN_EMAIL_ADDRESS;
|
||||||
|
$em->From = ADMIN_EMAIL_ADDRESS;
|
||||||
|
$em->Subject = 'New Patrons Circle member';
|
||||||
|
$em->Body = Template::EmailAdminNewPatron(['patron' => $this, 'payment' => $this->User->Payments[0]]);
|
||||||
|
$em->TextBody = Template::EmailAdminNewPatronText(['patron' => $this, 'payment' => $this->User->Payments[0]]);;
|
||||||
|
$em->Send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
lib/User.php
20
lib/User.php
|
@ -2,12 +2,32 @@
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
use Safe\DateTime;
|
use Safe\DateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property Array<Payment> $Payments
|
||||||
|
*/
|
||||||
class User extends PropertiesBase{
|
class User extends PropertiesBase{
|
||||||
public $UserId;
|
public $UserId;
|
||||||
public $Name;
|
public $Name;
|
||||||
public $Email;
|
public $Email;
|
||||||
public $Created;
|
public $Created;
|
||||||
public $Uuid;
|
public $Uuid;
|
||||||
|
protected $_Payments = null;
|
||||||
|
|
||||||
|
|
||||||
|
// *******
|
||||||
|
// GETTERS
|
||||||
|
// *******
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<Payment>
|
||||||
|
*/
|
||||||
|
protected function GetPayments(): array{
|
||||||
|
if($this->_Payments === null){
|
||||||
|
$this->_Payments = Db::Query('select * from Payments where UserId = ? order by Created desc', [$this->UserId], 'Payment');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_Payments;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// *******
|
// *******
|
||||||
|
|
|
@ -163,6 +163,7 @@ try{
|
||||||
$patron = new Patron();
|
$patron = new Patron();
|
||||||
$patron->UserId = $payment->UserId;
|
$patron->UserId = $payment->UserId;
|
||||||
$patron->User = $payment->User;
|
$patron->User = $payment->User;
|
||||||
|
$patron->User->Payments = [$payment];
|
||||||
$patron->IsAnonymous = (trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Attribution"]]'))->getText()) == 'Private');
|
$patron->IsAnonymous = (trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Attribution"]]'))->getText()) == 'Private');
|
||||||
$patron->IsSubscribedToEmails = $patron->User !== null && $patron->User->Email !== null;
|
$patron->IsSubscribedToEmails = $patron->User !== null && $patron->User->Email !== null;
|
||||||
|
|
||||||
|
|
32
templates/EmailAdminNewPatron.php
Normal file
32
templates/EmailAdminNewPatron.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>New Patrons Circle member</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Name:</td>
|
||||||
|
<td><?= Formatter::ToPlainText($patron->Name) ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Donation type:</td>
|
||||||
|
<td><? if($payment->IsRecurring){ ?>Recurring<? }else{ ?>One-time<? } ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Donation amount:</td>
|
||||||
|
<td><?= Formatter::ToPlainText(number_format($payment->Amount)) ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Donation fee:</td>
|
||||||
|
<td><?= Formatter::ToPlainText(number_format($payment->Fee)) ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Transaction ID:</td>
|
||||||
|
<td><?= Formatter::ToPlainText($payment->TransactionId) ?></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
9
templates/EmailAdminNewPatronText.php
Normal file
9
templates/EmailAdminNewPatronText.php
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Name: <?= Formatter::ToPlainText($patron->Name) ?>
|
||||||
|
|
||||||
|
Donation type: <? if($payment->IsRecurring){ ?>Recurring<? }else{ ?>One-time<? } ?>
|
||||||
|
|
||||||
|
Donation amount: <?= Formatter::ToPlainText(number_format($payment->Amount)) ?>
|
||||||
|
|
||||||
|
Donation fee: <?= Formatter::ToPlainText(number_format($payment->Fee)) ?>
|
||||||
|
|
||||||
|
Transaction ID: <?= Formatter::ToPlainText($payment->TransactionId) ?>
|
Loading…
Add table
Add a link
Reference in a new issue