Refactor Email invoice template handling and enhance payment link generation
This commit is contained in:
parent
c45e19189a
commit
2e2d967a5b
@ -11,13 +11,7 @@ class Invoice
|
||||
throw new Exception("Invoice ID is required");
|
||||
}
|
||||
|
||||
$templatePath = 'pages/Custom_Invoice.html';
|
||||
if (!file_exists($templatePath)) {
|
||||
$templatePath = 'pages/Default_Invoice.html';
|
||||
}
|
||||
|
||||
$template = file_get_contents($templatePath);
|
||||
|
||||
$template = Lang::getNotifText('email_invoice');
|
||||
if (!$template) {
|
||||
throw new Exception("Invoice template not found");
|
||||
}
|
||||
@ -94,7 +88,7 @@ class Invoice
|
||||
}, $template);
|
||||
}
|
||||
|
||||
public static function sendInvoice($userId, $status = "Unpaid")
|
||||
public static function sendInvoice($userId, $package, $status = "Unpaid")
|
||||
{
|
||||
global $config;
|
||||
|
||||
@ -148,8 +142,21 @@ class Invoice
|
||||
$tax = $config['enable_tax'] ? Package::tax($subtotal) : 0;
|
||||
$total = ($tax > 0) ? $subtotal + $tax : $subtotal + $tax;
|
||||
|
||||
$token = User::generateToken($account['id'], 1);
|
||||
if (!empty($token['token'])) {
|
||||
$tur = ORM::for_table('tbl_user_recharges')
|
||||
->where('customer_id', $account['id'])
|
||||
->where('namebp', $package)
|
||||
->find_one();
|
||||
if ($tur) {
|
||||
$payLink = '?_route=home&recharge=' . $tur['id'] . '&uid=' . urlencode($token['token']);
|
||||
}
|
||||
} else {
|
||||
$payLink = '?_route=home';
|
||||
}
|
||||
|
||||
$invoiceData = [
|
||||
'id' => "INV-" . Package::_raid(),
|
||||
'invoice' => "INV-" . Package::_raid(),
|
||||
'fullname' => $account->fullname,
|
||||
'email' => $account->email,
|
||||
'address' => $account->address,
|
||||
@ -163,6 +170,8 @@ class Invoice
|
||||
'company_name' => $config['CompanyName'],
|
||||
'company_phone' => $config['phone'],
|
||||
'logo' => $config['logo'],
|
||||
'company_url' => APP_URL,
|
||||
'payment_link' => $payLink,
|
||||
];
|
||||
|
||||
if (!isset($invoiceData['bill_rows']) || empty($invoiceData['bill_rows'])) {
|
||||
|
File diff suppressed because one or more lines are too long
@ -191,7 +191,44 @@
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{* <div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">{Lang::T('PDF Invoice Template')}</label>
|
||||
<div class="col-md-6">
|
||||
<textarea class="form-control" id="email_invoice" name="email_invoice"
|
||||
placeholder="{Lang::T('Template for sending pdf invoice')}" rows="20">
|
||||
{if !empty($_json['email_invoice'])}
|
||||
{Lang::htmlspecialchars($_json['email_invoice'])}
|
||||
{else}
|
||||
{Lang::htmlspecialchars($_default['email_invoice'])}
|
||||
{/if}
|
||||
</textarea>
|
||||
</div>
|
||||
<p class="col-md-4 help-block">
|
||||
<b>[[company_name]]</b> {Lang::T('Your Company Name at Settings')}.<br>
|
||||
<b>[[company_address]]</b> {Lang::T('Your Company Address at Settings')}.<br>
|
||||
<b>[[company_phone]]</b> - {Lang::T('Your Company Phone at Settings')}.<br>
|
||||
<b>[[company_url]]</b> - {Lang::T('Your APP_URL at Settings')}.<br>
|
||||
<b>[[invoice]]</b> - {Lang::T('Invoice number')}.<br>
|
||||
<b>[[created_at]]</b> - {Lang::T('Date invoice created')}.<br>
|
||||
<b>[[payment_gateway]]</b> - {Lang::T('Payment gateway user paid from')}.<br>
|
||||
<b>[[payment_channel]]</b> - {Lang::T('Payment channel user paid from')}.<br>
|
||||
<b>[[bill_rows]]</b> - {Lang::T('Bills table, where bills are listed')}.<br>
|
||||
<b>[[currency]]</b> - {Lang::T('Your currency code at localisation Settings')}.<br>
|
||||
<b>[[status]]</b> - {Lang::T('Invoice status')}.<br>
|
||||
<b>[[fullname]]</b> - {Lang::T('Receiver name')}.<br>
|
||||
<b>[[user_name]]</b> - {Lang::T('Username internet')}.<br>
|
||||
<b>[[email]]</b> - {Lang::T('Customer email')} .<br>
|
||||
<b>[[phone]]</b> - {Lang::T('Customer phone')}. <br>
|
||||
<b>[[address]]</b> - {Lang::T('Customer phone')}. <br>
|
||||
<b>[[expired_date]]</b> - {Lang::T('Expired datetime')}.<br>
|
||||
<b>[[logo]]</b> - {Lang::T('Your company logo at Settings')}.<br>
|
||||
<b>[[due_date]]</b> - {Lang::T('Invoice Due date, 7 Days after invoice created')}.<br>
|
||||
<b>[[payment_link]]</b> - <a href="{$app_url}/docs/#Reminder%20with%20payment%20link"
|
||||
target="_blank">{Lang::T("read documentation")}</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>*}
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
|
Loading…
x
Reference in New Issue
Block a user