mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for admin URLs
This commit is contained in:
parent
baaa39c1fa
commit
055596cfe6
@ -144,12 +144,12 @@ class AdjustProductInventory implements ShouldQueue
|
||||
private function notifyStocklevels(Product $product, string $notification_level)
|
||||
{
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new InventoryNotificationObject($product, $notification_level))->build());
|
||||
$nmo->company = $this->company;
|
||||
$nmo->settings = $this->company->settings;
|
||||
|
||||
$this->company->company_users->each(function ($cu) use ($product, $nmo) {
|
||||
$this->company->company_users->each(function ($cu) use ($product, $nmo, $notification_level) {
|
||||
if ($this->checkNotificationExists($cu, $product, ['inventory_all', 'inventory_user', 'inventory_threshold_all', 'inventory_threshold_user'])) {
|
||||
$nmo->mailable = new NinjaMailer((new InventoryNotificationObject($product, $notification_level, $cu->portalType()))->build());
|
||||
$nmo->to_user = $cu->user;
|
||||
NinjaMailerJob::dispatch($nmo);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class PaymentFailedMailer implements ShouldQueue
|
||||
if (($key = array_search('mail', $methods)) !== false) {
|
||||
unset($methods[$key]);
|
||||
|
||||
$mail_obj = (new PaymentFailureObject($this->client, $this->error, $this->company, $amount, $this->payment_hash))->build();
|
||||
$mail_obj = (new PaymentFailureObject($this->client, $this->error, $this->company, $amount, $this->payment_hash, $company_user->portalType()))->build();
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer($mail_obj);
|
||||
|
@ -64,7 +64,7 @@ class InvoiceEmailedNotification implements ShouldQueue
|
||||
unset($methods[$key]);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, 'invoice', $event->template))->build());
|
||||
$nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, 'invoice', $event->template, $company_user->portalType()))->build());
|
||||
$nmo->company = $invoice->company;
|
||||
$nmo->settings = $invoice->company->settings;
|
||||
$nmo->to_user = $user;
|
||||
|
@ -76,7 +76,7 @@ class PaymentNotification implements ShouldQueue
|
||||
unset($methods[$key]);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new EntityPaidObject($payment))->build());
|
||||
$nmo->mailable = new NinjaMailer((new EntityPaidObject($payment, $company_user->portalType()))->build());
|
||||
$nmo->company = $event->company;
|
||||
$nmo->settings = $event->company->settings;
|
||||
$nmo->to_user = $user;
|
||||
@ -108,7 +108,7 @@ class PaymentNotification implements ShouldQueue
|
||||
unset($methods[$key]);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new EntityPaidObject($payment))->build());
|
||||
$nmo->mailable = new NinjaMailer((new EntityPaidObject($payment, $company_user->portalType()))->build());
|
||||
$nmo->company = $event->company;
|
||||
$nmo->settings = $event->company->settings;
|
||||
$nmo->to_user = $user;
|
||||
@ -161,11 +161,12 @@ class PaymentNotification implements ShouldQueue
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param string $url
|
||||
*/
|
||||
private function sendAnalytics($data)
|
||||
private function sendAnalytics($url)
|
||||
{
|
||||
$data = utf8_encode($data);
|
||||
$data = mb_convert_encoding($url, 'UTF-8');
|
||||
// $data = utf8_encode($data);
|
||||
$curl = curl_init();
|
||||
|
||||
$opts = [
|
||||
|
@ -62,7 +62,7 @@ class PurchaseOrderEmailedNotification implements ShouldQueue
|
||||
unset($methods[$key]);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, 'purchase_order', 'purchase_order'))->build());
|
||||
$nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, 'purchase_order', 'purchase_order', $company_user->portalType()))->build());
|
||||
$nmo->company = $purchase_order->company;
|
||||
$nmo->settings = $purchase_order->company->settings;
|
||||
$nmo->to_user = $user;
|
||||
|
@ -54,7 +54,7 @@ class QuoteEmailedNotification implements ShouldQueue
|
||||
unset($methods[$key]);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, 'quote', $event->template))->build());
|
||||
$nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, 'quote', $event->template, $company_user->portalType()))->build());
|
||||
$nmo->company = $quote->company;
|
||||
$nmo->settings = $quote->company->settings;
|
||||
$nmo->to_user = $user;
|
||||
|
@ -30,7 +30,7 @@ class EntityPaidObject
|
||||
|
||||
public $settings;
|
||||
|
||||
public function __construct(public Payment $payment)
|
||||
public function __construct(public Payment $payment, protected bool $use_react_url)
|
||||
{
|
||||
$this->payment = $payment;
|
||||
$this->company = $payment->company;
|
||||
@ -98,7 +98,7 @@ class EntityPaidObject
|
||||
'invoice' => $invoice_texts,
|
||||
]
|
||||
),
|
||||
'url' => config('ninja.app_url'),
|
||||
'url' => $this->payment->portalUrl($this->use_react_url),
|
||||
'button' => ctrans('texts.view_payment'),
|
||||
'signature' => $settings->email_signature,
|
||||
'logo' => $this->company->present()->logo(),
|
||||
@ -117,4 +117,5 @@ class EntityPaidObject
|
||||
|
||||
return $signature;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
namespace App\Mail\Admin;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Product;
|
||||
use App\Utils\Ninja;
|
||||
use Illuminate\Support\Facades\App;
|
||||
@ -20,19 +19,9 @@ use stdClass;
|
||||
|
||||
class InventoryNotificationObject
|
||||
{
|
||||
public Product $product;
|
||||
|
||||
public Company $company;
|
||||
|
||||
public $settings;
|
||||
|
||||
public string $notification_level;
|
||||
|
||||
public function __construct(Product $product, string $notification_level)
|
||||
public function __construct(protected Product $product, public string $notification_level, protected bool $use_react_url)
|
||||
{
|
||||
$this->product = $product;
|
||||
$this->company = $product->company;
|
||||
$this->settings = $this->company->settings;
|
||||
}
|
||||
|
||||
public function build()
|
||||
@ -41,16 +30,16 @@ class InventoryNotificationObject
|
||||
/* Init a new copy of the translator*/
|
||||
$t = app('translator');
|
||||
/* Set the locale*/
|
||||
App::setLocale($this->company->getLocale());
|
||||
App::setLocale($this->product->company->getLocale());
|
||||
/* Set customized translations _NOW_ */
|
||||
$t->replace(Ninja::transformTranslations($this->company->settings));
|
||||
$t->replace(Ninja::transformTranslations($this->product->company->settings));
|
||||
|
||||
$mail_obj = new stdClass;
|
||||
$mail_obj->amount = $this->getAmount();
|
||||
$mail_obj->subject = $this->getSubject();
|
||||
$mail_obj->data = $this->getData();
|
||||
$mail_obj->markdown = 'email.admin.generic';
|
||||
$mail_obj->tag = $this->company->company_key;
|
||||
$mail_obj->tag = $this->product->company->company_key;
|
||||
|
||||
return $mail_obj;
|
||||
}
|
||||
@ -79,12 +68,12 @@ class InventoryNotificationObject
|
||||
'product' => $this->product->product_key.': '.$this->product->notes,
|
||||
]
|
||||
),
|
||||
'url' => config('ninja.app_url'),
|
||||
'button' => ctrans('texts.login'),
|
||||
'signature' => $this->settings->email_signature,
|
||||
'logo' => $this->company->present()->logo(),
|
||||
'settings' => $this->settings,
|
||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||
'url' => $this->product->portalUrl($this->use_react_url),
|
||||
'button' => $this->use_react_url ? ctrans('texts.product_library') : ctrans('ninja.app_url'),
|
||||
'signature' => $this->product->company->settings->email_signature,
|
||||
'logo' => $this->product->company->present()->logo(),
|
||||
'settings' => $this->product->company->settings,
|
||||
'whitelabel' => $this->product->company->account->isPaid() ? true : false,
|
||||
];
|
||||
|
||||
return $data;
|
||||
|
@ -24,17 +24,6 @@ class PaymentFailureObject
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
public Client $client;
|
||||
|
||||
public string $error;
|
||||
|
||||
public Company $company;
|
||||
|
||||
public $amount;
|
||||
|
||||
public ?PaymentHash $payment_hash;
|
||||
// private $invoices;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
@ -43,19 +32,8 @@ class PaymentFailureObject
|
||||
* @param $company
|
||||
* @param $amount
|
||||
*/
|
||||
public function __construct(Client $client, string $error, Company $company, $amount, ?PaymentHash $payment_hash)
|
||||
public function __construct(public Client $client, public string $error, public Company $company, public float $amount, public ?PaymentHash $payment_hash, protected bool $use_react_url)
|
||||
{
|
||||
$this->client = $client;
|
||||
|
||||
$this->error = $error;
|
||||
|
||||
$this->company = $company;
|
||||
|
||||
$this->amount = $amount;
|
||||
|
||||
$this->company = $company;
|
||||
|
||||
$this->payment_hash = $payment_hash;
|
||||
}
|
||||
|
||||
public function build()
|
||||
@ -115,8 +93,8 @@ class PaymentFailureObject
|
||||
'logo' => $this->company->present()->logo(),
|
||||
'settings' => $this->client->getMergedSettings(),
|
||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||
'url' => config('ninja.app_url'),
|
||||
'button' => ctrans('texts.login'),
|
||||
'url' => $this->client->portalUrl($this->use_react_url),
|
||||
'button' => $this->use_react_url ? ctrans('texts.view_client') : ctrans('texts.login'),
|
||||
'additional_info' => $this->error,
|
||||
];
|
||||
|
||||
|
@ -865,4 +865,9 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
{
|
||||
return ctrans('texts.client');
|
||||
}
|
||||
|
||||
public function portalUrl(bool $use_react_url): string
|
||||
{
|
||||
return $use_react_url ? config('ninja.react_url'). "/clients/{$this->hashed_id}": config('ninja.app_url');
|
||||
}
|
||||
}
|
||||
|
@ -557,4 +557,10 @@ class Payment extends BaseModel
|
||||
{
|
||||
return ctrans('texts.payment');
|
||||
}
|
||||
|
||||
public function portalUrl($use_react_url)
|
||||
{
|
||||
return $use_react_url ? config('ninja.react_url')."/payments/{$this->hashed_id}/edit" : config('ninja.app_url');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -200,4 +200,9 @@ class Product extends BaseModel
|
||||
|
||||
return $converter->convert($this->notes);
|
||||
}
|
||||
|
||||
public function portalUrl($use_react_url): string
|
||||
{
|
||||
return $use_react_url ? config('ninja.react_url') . "/products/{$this->hashed_id}/edit" : config('ninja.app_url');
|
||||
}
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
}
|
||||
|
||||
public function processWebhookRequest(PaymentWebhookRequest $request)
|
||||
{
|
||||
{nlog($request->all());
|
||||
if ($request->type === 'customer.source.updated') {
|
||||
$ach = new ACH($this);
|
||||
$ach->updateBankAccount($request->all());
|
||||
|
Loading…
x
Reference in New Issue
Block a user