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");
|
throw new Exception("Invoice ID is required");
|
||||||
}
|
}
|
||||||
|
|
||||||
$templatePath = 'pages/Custom_Invoice.html';
|
$template = Lang::getNotifText('email_invoice');
|
||||||
if (!file_exists($templatePath)) {
|
|
||||||
$templatePath = 'pages/Default_Invoice.html';
|
|
||||||
}
|
|
||||||
|
|
||||||
$template = file_get_contents($templatePath);
|
|
||||||
|
|
||||||
if (!$template) {
|
if (!$template) {
|
||||||
throw new Exception("Invoice template not found");
|
throw new Exception("Invoice template not found");
|
||||||
}
|
}
|
||||||
@ -94,7 +88,7 @@ class Invoice
|
|||||||
}, $template);
|
}, $template);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function sendInvoice($userId, $status = "Unpaid")
|
public static function sendInvoice($userId, $package, $status = "Unpaid")
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -148,8 +142,21 @@ class Invoice
|
|||||||
$tax = $config['enable_tax'] ? Package::tax($subtotal) : 0;
|
$tax = $config['enable_tax'] ? Package::tax($subtotal) : 0;
|
||||||
$total = ($tax > 0) ? $subtotal + $tax : $subtotal + $tax;
|
$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 = [
|
$invoiceData = [
|
||||||
'id' => "INV-" . Package::_raid(),
|
'invoice' => "INV-" . Package::_raid(),
|
||||||
'fullname' => $account->fullname,
|
'fullname' => $account->fullname,
|
||||||
'email' => $account->email,
|
'email' => $account->email,
|
||||||
'address' => $account->address,
|
'address' => $account->address,
|
||||||
@ -163,6 +170,8 @@ class Invoice
|
|||||||
'company_name' => $config['CompanyName'],
|
'company_name' => $config['CompanyName'],
|
||||||
'company_phone' => $config['phone'],
|
'company_phone' => $config['phone'],
|
||||||
'logo' => $config['logo'],
|
'logo' => $config['logo'],
|
||||||
|
'company_url' => APP_URL,
|
||||||
|
'payment_link' => $payLink,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!isset($invoiceData['bill_rows']) || empty($invoiceData['bill_rows'])) {
|
if (!isset($invoiceData['bill_rows']) || empty($invoiceData['bill_rows'])) {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -162,43 +162,80 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{if $_c['enable_balance'] == 'yes'}
|
{if $_c['enable_balance'] == 'yes'}
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-2 control-label">{Lang::T('Send Balance')}</label>
|
<label class="col-md-2 control-label">{Lang::T('Send Balance')}</label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<textarea class="form-control" id="balance_send" name="balance_send"
|
<textarea class="form-control" id="balance_send" name="balance_send"
|
||||||
rows="4">{if $_json['balance_send']}{Lang::htmlspecialchars($_json['balance_send'])}{else}{Lang::htmlspecialchars($_default['balance_send'])}{/if}</textarea>
|
rows="4">{if $_json['balance_send']}{Lang::htmlspecialchars($_json['balance_send'])}{else}{Lang::htmlspecialchars($_default['balance_send'])}{/if}</textarea>
|
||||||
</div>
|
|
||||||
<p class="col-md-4 help-block">
|
|
||||||
<b>[[name]]</b> - {Lang::T('Receiver name')}.<br>
|
|
||||||
<b>[[balance]]</b> - {Lang::T('how much balance have been send')}.<br>
|
|
||||||
<b>[[current_balance]]</b> - {Lang::T('Current Balance')}.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
<p class="col-md-4 help-block">
|
||||||
|
<b>[[name]]</b> - {Lang::T('Receiver name')}.<br>
|
||||||
|
<b>[[balance]]</b> - {Lang::T('how much balance have been send')}.<br>
|
||||||
|
<b>[[current_balance]]</b> - {Lang::T('Current Balance')}.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
</div>
|
||||||
<div class="form-group">
|
<div class="panel-body">
|
||||||
<label class="col-md-2 control-label">{Lang::T('Received Balance')}</label>
|
<div class="form-group">
|
||||||
<div class="col-md-6">
|
<label class="col-md-2 control-label">{Lang::T('Received Balance')}</label>
|
||||||
<textarea class="form-control" id="balance_received" name="balance_received"
|
<div class="col-md-6">
|
||||||
rows="4">{if $_json['balance_received']}{Lang::htmlspecialchars($_json['balance_received'])}{else}{Lang::htmlspecialchars($_default['balance_received'])}{/if}</textarea>
|
<textarea class="form-control" id="balance_received" name="balance_received"
|
||||||
</div>
|
rows="4">{if $_json['balance_received']}{Lang::htmlspecialchars($_json['balance_received'])}{else}{Lang::htmlspecialchars($_default['balance_received'])}{/if}</textarea>
|
||||||
<p class="col-md-4 help-block">
|
|
||||||
<b>[[name]]</b> - {Lang::T('Sender name')}.<br>
|
|
||||||
<b>[[balance]]</b> - {Lang::T('how much balance have been received')}.<br>
|
|
||||||
<b>[[current_balance]]</b> - {Lang::T('Current Balance')}.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
<p class="col-md-4 help-block">
|
||||||
|
<b>[[name]]</b> - {Lang::T('Sender name')}.<br>
|
||||||
|
<b>[[balance]]</b> - {Lang::T('how much balance have been received')}.<br>
|
||||||
|
<b>[[current_balance]]</b> - {Lang::T('Current Balance')}.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
{* <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="panel-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button class="btn btn-success btn-block" type="submit">{Lang::T('Save Changes')}</button>
|
<button class="btn btn-success btn-block" type="submit">{Lang::T('Save Changes')}</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
{include file="sections/footer.tpl"}
|
{include file="sections/footer.tpl"}
|
Loading…
x
Reference in New Issue
Block a user