Prev | Current Page 690 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

',
'Exception: "' . $e->getMessage() . '" on ' .
$e->getFile() . ' line ' . $e->getLine(),
$this->_mOrderProcessStage);
$this->CreateAudit('Order Processing error occurred.', 10002);
throw new Exception('Error occurred, order aborted. ' .
'Details mailed to administrator.');
}
Regardless of whether processing is successful, we add a final audit entry saying that the processing has
completed:
$this->CreateAudit('Order Processor finished.', 10001);
}
Let??™s now look at the MailAdmin() method that simply takes a few parameters for the basic e-mail properties:
// Builds e-mail message
public function MailAdmin($subject, $message, $sourceStage)
{
$to = ADMIN_EMAIL;
$headers = 'From: ' . ORDER_PROCESSOR_EMAIL . "\r\n";
$body = 'Message: ' . $message . "\n" .
'Source: ' . $sourceStage . "\n" .
'Order ID: ' . $this->mOrderInfo['order_id'];
$result = mail($to, $subject, $body, $headers);
if ($result === false)
{
throw new Exception ('Failed sending this mail to administrator:' .
"\n" . $body);
}
}
The CreateAudit() method is also a simple one and calls the Orders::CreateAudit() business tier method
shown earlier:
// Adds audit message
public function CreateAudit($message, $code)
CHAPTER 18 ?–  IMPLEMENTING THE ORDER PIPELINE: PART 1 584
{
Orders::CreateAudit($this->mOrderInfo['order_id'], $message, $code);
}
At this point, it??™s worth examining the code scheme we??™ve chosen for order-processing audits.


Pages:
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
torba do notebooka Gallery of Bialowieza Pozycjonowanie ośrodek wypoczynkowy pozycjonownie