mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Multi-db fixes
This commit is contained in:
parent
7510ddd3b9
commit
27d1c13e79
@ -23,7 +23,7 @@ class AnalyticsListener
|
||||
$invoice = $payment->invoice;
|
||||
$account = $payment->account;
|
||||
|
||||
if (! in_array($account->account_key, [NINJA_ACCOUNT_KEY, NINJA_LICENSE_ACCOUNT_KEY])) {
|
||||
if ($account->isNinjaAccount() || $account->account_key == NINJA_LICENSE_ACCOUNT_KEY) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -938,7 +938,7 @@ class Account extends Eloquent
|
||||
*/
|
||||
public function isNinjaAccount()
|
||||
{
|
||||
return $this->account_key === NINJA_ACCOUNT_KEY;
|
||||
return strpos($this->account_key, 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx7') === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -314,7 +314,7 @@ class BasePaymentDriver
|
||||
$payment = $this->createPayment($ref, $paymentMethod);
|
||||
|
||||
// TODO move this to stripe driver
|
||||
if ($this->invitation->invoice->account->account_key == NINJA_ACCOUNT_KEY) {
|
||||
if ($this->invitation->invoice->account->isNinjaAccount()) {
|
||||
Session::flash('trackEventCategory', '/account');
|
||||
Session::flash('trackEventAction', '/buy_pro_plan');
|
||||
Session::flash('trackEventAmount', $payment->amount);
|
||||
@ -642,7 +642,7 @@ class BasePaymentDriver
|
||||
$this->createLicense($payment);
|
||||
// TODO move this code
|
||||
// enable pro plan for hosted users
|
||||
} elseif ($accountKey == NINJA_ACCOUNT_KEY) {
|
||||
} elseif ($invoice->account->isNinjaAccount()) {
|
||||
foreach ($invoice->invoice_items as $invoice_item) {
|
||||
// Hacky, but invoices don't have meta fields to allow us to store this easily
|
||||
if (1 == preg_match('/^Plan - (.+) \((.+)\)$/', $invoice_item->product_key, $matches)) {
|
||||
|
@ -335,7 +335,7 @@ class AccountRepository
|
||||
|
||||
public function getNinjaAccount()
|
||||
{
|
||||
$account = Account::whereAccountKey(NINJA_ACCOUNT_KEY)->first();
|
||||
$account = Account::where('account_key', 'LIKE', substr(NINJA_ACCOUNT_KEY, 0, 30) . '%')->orderBy('id')->first();
|
||||
|
||||
if ($account) {
|
||||
return $account;
|
||||
|
@ -279,7 +279,7 @@ class InvoiceRepository extends BaseRepository
|
||||
->where('invoices.is_recurring', '=', false)
|
||||
->where('invoices.is_public', '=', true)
|
||||
// Only show paid invoices for ninja accounts
|
||||
->whereRaw(sprintf("((accounts.account_key != '%s' and accounts.account_key != '%s') or invoices.invoice_status_id = %d)", env('NINJA_LICENSE_ACCOUNT_KEY'), NINJA_ACCOUNT_KEY, INVOICE_STATUS_PAID))
|
||||
->whereRaw(sprintf("((accounts.account_key != '%s' and accounts.account_key not like '%s') or invoices.invoice_status_id = %d)", env('NINJA_LICENSE_ACCOUNT_KEY'), substr(NINJA_ACCOUNT_KEY, 0, 30), INVOICE_STATUS_PAID))
|
||||
->select(
|
||||
DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'),
|
||||
DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'),
|
||||
|
@ -117,8 +117,9 @@
|
||||
try {
|
||||
return getPDFString(refreshPDFCB, force);
|
||||
} catch (exception) {
|
||||
console.warn('Failed to generate PDF');
|
||||
var href = location.href;
|
||||
if (href.indexOf('/view/') && href.indexOf('phantomjs') == -1) {
|
||||
if (href.indexOf('/view/') > 0 && href.indexOf('phantomjs') == -1) {
|
||||
var url = href.replace('/view/', '/download/') + '?base64=true';
|
||||
$.get(url, function(result) {
|
||||
refreshPDFCB(result);
|
||||
|
@ -242,7 +242,7 @@
|
||||
var fileName = invoice.is_quote ? invoiceLabels.quote : invoiceLabels.invoice;
|
||||
doc.save(fileName + '-' + invoice.invoice_number + '.pdf');
|
||||
} catch (exception) {
|
||||
if (location.href.indexOf('/view/')) {
|
||||
if (location.href.indexOf('/view/') > 0) {
|
||||
location.href = location.href.replace('/view/', '/download/');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user