/** * Arrange html message then call utility email * * @param none * @return mixed | customer data table */ protected static function send_email() { $j = json_decode($_POST["args"]); $id = $j->id; $name = $j->name; $email = $j->email; $country = $j->country; //basic information $html = "<p>\n Hello {$name}, <br><br>\n We are pleased to inform you about your latest information on testapp below: \n <br><br> \n </p>\n <h1>Your Current Information at TESTAPP</h1>\n <table>\n <tr>\n <td>ID</td>\n <td>Name</td>\n <td>Email</td>\n <td>Country</td>\n </tr>\n <tr>\n <td>{$id}</td>\n <td>{$name}</td>\n <td>{$email}</td>\n <td>{$country}</td>\n </tr>\n </table>"; //transactions $query = array('stmt' => "SELECT * FROM transactions\n WHERE transactions_customer_id = ?", 'bind' => 'i', 'fields' => $id); $transactions = db::execute_query($query, true); $html .= "<h1>List of all your transactions</h1>\n <table>\n <tr>\n <td>ID</td>\n <td>Item</td>\n <td>Price</td>\n <td>Date</td>\n </tr>"; $total = 0; foreach ($transactions as $t) { $total += $t['transactions_amount']; $html .= "<tr>\n <td>" . $t['transactions_id'] . "</td>\n <td>" . $t['transactions_item'] . "</td>\n <td>" . $t['transactions_amount'] . "</td>\n <td>" . date("M jS\\, Y", strtotime($t["transactions_date"])) . "</td>\n </tr>"; } $html .= "<tr>\n <td></td>\n <td></td>\n <td></td>\n <td style='color:green; font-size:18px; margin:12px 0px; padding-top:5px; border-top:1px dashed #333'>Total: " . number_format($total, 2, '.', ',') . "</td>\n </tr>\n </table>\n <p><br><br>\n Best Regards, <br>\n TestApp Team \n <br><br> \n </p>"; utility::email_data($html, $email); exit; }