Send email to the admin when a new patron joins

This commit is contained in:
Alex Cabal 2022-07-09 12:26:32 -05:00
parent e2a1dbb1e5
commit fa8fa4f7eb
5 changed files with 70 additions and 0 deletions

View file

@ -40,6 +40,14 @@ class Patron extends PropertiesBase{
$em->Body = Template::EmailPatronsCircleWelcome(['isAnonymous' => $this->IsAnonymous, 'isReturning' => $isReturning]);
$em->TextBody = Template::EmailPatronsCircleWelcomeText(['isAnonymous' => $this->IsAnonymous, 'isReturning' => $isReturning]);
$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();
}
}

View file

@ -2,12 +2,32 @@
use Ramsey\Uuid\Uuid;
use Safe\DateTime;
/**
* @property Array<Payment> $Payments
*/
class User extends PropertiesBase{
public $UserId;
public $Name;
public $Email;
public $Created;
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;
}
// *******

View file

@ -163,6 +163,7 @@ try{
$patron = new Patron();
$patron->UserId = $payment->UserId;
$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->IsSubscribedToEmails = $patron->User !== null && $patron->User->Email !== null;

View 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>

View 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) ?>