After_Insert Hook
Posted: 2018-01-12 09:40
I am trying to send an email to admin when a user insert a new record and my code is this
function Aitimata_Asfalisis_after_insert($data, $memberInfo, &$args){
/* send an email notification when a new order is placed */
ob_start(); ?>
<h3>You have a new record:</h3>
<hr>
<table>
<tr><td><b>id</b></td><td><?php echo $data['id']; ?></td></tr>
<tr><td><b>Date</b></td><td><?php echo date('d/m/y', strtotime($data['Hmerominia'])); ?></td></tr>
<tr><td><b>Partner</b></td><td><?php echo sqlValue("select Name from Sinergates where id='" . makeSafe($data['id']) . "'"); ?></td></tr>
<tr><td><b>Customer</b></td><td><?php echo sqlValue("select Name from Pelates where id='" . makeSafe($data['id']) . "'"); ?></td></tr>
<tr><td><b>Company</b></td><td><?php echo sqlValue("select Etaireia from Etaireies where id='" . makeSafe($data['id']) . "'"); ?></td></tr>
</table>
<?php
$mail_body = ob_get_contents();
ob_end_clean();
//$customer_email = sqlValue("select email from customers where CustomerID='" . makeSafe($data['CustomerID']) . "'");
mail(
'[email protected]',
'New order placed ' . $data['id'],
$mail_body,
"From: [email protected]\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-type: text/html; charset=Unicode UTF-8\r\n"
);
return TRUE;
}
Nothing is happening what am i doing wrong?
Thank you
function Aitimata_Asfalisis_after_insert($data, $memberInfo, &$args){
/* send an email notification when a new order is placed */
ob_start(); ?>
<h3>You have a new record:</h3>
<hr>
<table>
<tr><td><b>id</b></td><td><?php echo $data['id']; ?></td></tr>
<tr><td><b>Date</b></td><td><?php echo date('d/m/y', strtotime($data['Hmerominia'])); ?></td></tr>
<tr><td><b>Partner</b></td><td><?php echo sqlValue("select Name from Sinergates where id='" . makeSafe($data['id']) . "'"); ?></td></tr>
<tr><td><b>Customer</b></td><td><?php echo sqlValue("select Name from Pelates where id='" . makeSafe($data['id']) . "'"); ?></td></tr>
<tr><td><b>Company</b></td><td><?php echo sqlValue("select Etaireia from Etaireies where id='" . makeSafe($data['id']) . "'"); ?></td></tr>
</table>
<?php
$mail_body = ob_get_contents();
ob_end_clean();
//$customer_email = sqlValue("select email from customers where CustomerID='" . makeSafe($data['CustomerID']) . "'");
mail(
'[email protected]',
'New order placed ' . $data['id'],
$mail_body,
"From: [email protected]\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-type: text/html; charset=Unicode UTF-8\r\n"
);
return TRUE;
}
Nothing is happening what am i doing wrong?
Thank you