// // End Mod for aMail Plugin // html_redirect("member.php", false, _TPL_NEWSLETTER_INFO_SAVED, _TPL_NEWSLETTER_INFO_UPDATED); exit; } ///////////////////////// MAIN ///////////////////////////////////////// unset($GLOBALS['_trial_days']); // trial handling $_amember_id = $_SESSION['_amember_id']; $vars = get_input_vars(); if ($vars['action'] == 'get_invoice' && $vars['id'] > 0) { $id = intval($vars['id']); if ($config['send_pdf_invoice']) { require_once "{$config['root_dir']}/includes/fpdf/fpdf.php"; $invoice = get_pdf_invoice($id, $_amember_id); header('Cache-Control: maxage=3600'); header('Pragma: public'); header("Cache-control: private"); header("Content-type: application/pdf"); header("Content-Length: " . strlen($invoice['string'])); header("Content-Disposition: attachment; filename=amember-invoice-{$id}.pdf"); print $invoice['string']; exit; } } if ($vars['action'] == 'renew') { do_renew(); } elseif ($vars['action'] == 'cancel_recurring') { $p = $db->get_payment($vars['payment_id']); if ($p['member_id'] != $_amember_id) {
function mail_payment_user($payment_id, $member_id) { global $db, $config, $_AMEMBER_TEMPLATE; $t = new_smarty(); $p = $db->get_payment($payment_id); if ($p['data'][0]['ORIG_ID'] > 0) { return; } // don't sent for child payments if (!($prices = $p['data'][0]['BASKET_PRICES'])) { $prices = array($p['product_id'] => $p['amount']); } $u = $db->get_user($p['member_id']); $subtotal = 0; foreach ($prices as $product_id => $price) { $v = $db->get_product($product_id); $subtotal += $v['price']; //$v['price'] = $price; $pr[$product_id] = $v; } if (!$t) { $t =& new_smarty(); } $total = array_sum($prices); if ($total == 0) { return; } // don't email zero receipt if ($p['receipt_id'] == 'manual') { // ONLY for single product !!! $coupon_discount = $p['data']['COUPON_DISCOUNT']; //$tax_amount = $p['data']['TAX_AMOUNT']; $tax_amount = $p['tax_amount']; if ($subtotal - $coupon_discount + $tax_amount != $total) { foreach ($prices as $product_id => $price) { $v = $db->get_product($product_id); $subtotal = $total - $tax_amount + $coupon_discount; $v['price'] = $subtotal; $pr[$product_id] = $v; } } } $t->assign('total', $total); $t->assign('subtotal', $subtotal); $t->assign('user', $u); $t->assign('payment', $p); $t->assign('products', $pr); $t->assign('config', $config); $attachments = array(); if ($config['send_pdf_invoice']) { require_once "{$config['root_dir']}/includes/fpdf/fpdf.php"; $attachments[] = get_pdf_invoice($payment_id, $p[member_id]); } $et =& new aMemberEmailTemplate(); $et->name = "send_payment_mail"; $et->lang = $u['data']['selected_lang'] ? $u['data']['selected_lang'] : get_default_lang(); // load and find templated if (!$et->find_applicable()) { trigger_error("Cannot find applicable e-mail template for [{$et->name},{$et->lang},{$et->product_id},{$et->day}]", E_USER_WARNING); return false; } $_AMEMBER_TEMPLATE['text'] = $et->get_smarty_template(); $parsed_mail = $t->fetch('memory:text'); unset($_AMEMBER_TEMPLATE['text']); mail_customer($u['email'], $parsed_mail, null, null, $attachments, false, $u['name_f'] . ' ' . $u['name_l']); }