1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #7212 from turbo124/v5-develop

Set defaults for client filters
This commit is contained in:
David Bomba 2022-02-17 07:15:23 +11:00 committed by GitHub
commit 0085c83cfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
84 changed files with 493 additions and 171 deletions

View File

@ -80,12 +80,12 @@ class ClientFilters extends QueryFilters
}
public function id_number(string $id_number):Builder
public function id_number(string $id_number = ''):Builder
{
return $this->builder->where('id_number', $id_number);
}
public function number(string $number):Builder
public function number(string $number = ''):Builder
{
return $this->builder->where('number', $number);
}

View File

@ -163,7 +163,7 @@ class CreditFilters extends QueryFilters
*/
public function entityFilter()
{
if (auth('contact')->user()) {
if (auth()->guard('contact')->user()) {
return $this->contactViewFilter();
} else {
return $this->builder->company();
@ -181,7 +181,7 @@ class CreditFilters extends QueryFilters
private function contactViewFilter() : Builder
{
return $this->builder
->whereCompanyId(auth('contact')->user()->company->id)
->whereCompanyId(auth()->guard('contact')->user()->company->id)
->whereNotIn('status_id', [Credit::STATUS_DRAFT]);
}
}

View File

@ -148,6 +148,10 @@ class InvoiceFilters extends QueryFilters
{
$sort_col = explode('|', $sort);
//catch invalid explode array count
if(count($sort_col) == 1)
return $this->builder;
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
}
@ -173,7 +177,7 @@ class InvoiceFilters extends QueryFilters
*/
public function entityFilter()
{
if (auth('contact')->user()) {
if (auth()->guard('contact')->user()) {
return $this->contactViewFilter();
} else {
return $this->builder->company()->with(['invitations.company'], ['documents.company']);
@ -191,7 +195,7 @@ class InvoiceFilters extends QueryFilters
private function contactViewFilter() : Builder
{
return $this->builder
->whereCompanyId(auth('contact')->user()->company->id)
->whereCompanyId(auth()->guard('contact')->user()->company->id)
->whereNotIn('status_id', [Invoice::STATUS_DRAFT, Invoice::STATUS_CANCELLED]);
}
}

View File

@ -119,7 +119,7 @@ class PaymentFilters extends QueryFilters
*/
public function entityFilter()
{
if (auth('contact')->user()) {
if (auth()->guard('contact')->user()) {
return $this->contactViewFilter();
} else {
return $this->builder->company();
@ -135,7 +135,7 @@ class PaymentFilters extends QueryFilters
private function contactViewFilter() : Builder
{
return $this->builder
->whereCompanyId(auth('contact')->user()->company->id)
->whereCompanyId(auth()->guard('contact')->user()->company->id)
->whereIsDeleted(false);
}
}

View File

@ -161,8 +161,8 @@ abstract class QueryFilters
*/
public function clientFilter()
{
if (auth('contact')->user()) {
return $this->builder->whereClientId(auth('contact')->user()->client->id);
if (auth()->guard('contact')->user()) {
return $this->builder->whereClientId(auth()->guard('contact')->user()->client->id);
}
}

View File

@ -34,7 +34,7 @@ class CreditController extends Controller
$data = [
'credit' => $credit,
'key' => $invitation->key
'key' => $invitation ? $invitation->key : false
];
if ($invitation && auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) {

View File

@ -71,11 +71,11 @@ class DocumentController extends Controller
public function downloadMultiple(DownloadMultipleDocumentsRequest $request)
{
$documents = Document::whereIn('id', $this->transformKeys($request->file_hash))
->where('company_id', auth('contact')->user()->company->id)
->where('company_id', auth()->guard('contact')->user()->company->id)
->get();
$documents->map(function ($document) {
if (auth()->user('contact')->client->id != $document->documentable->id) {
if (auth()->guard('contact')->user()->client->id != $document->documentable->id) {
abort(401, 'Permission denied');
}
});

View File

@ -61,7 +61,7 @@ class InvoiceController extends Controller
$invoice->service()->removeUnpaidGatewayFees()->save();
$invitation = $invoice->invitations()->where('client_contact_id', auth()->user()->id)->first();
$invitation = $invoice->invitations()->where('client_contact_id', auth()->guard('contact')->user()->id)->first();
if ($invitation && auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) {
@ -74,7 +74,7 @@ class InvoiceController extends Controller
$data = [
'invoice' => $invoice,
'key' => $invitation->key
'key' => $invitation ? $invitation->key : false
];
if ($request->query('mode') === 'fullscreen') {

View File

@ -100,7 +100,7 @@ class NinjaPlanController extends Controller
}
$recurring_invoice = RecurringInvoice::on('db-ninja-01')
->where('client_id', auth('contact')->user()->client->id)
->where('client_id', auth()->guard('contact')->user()->client->id)
->where('company_id', Auth::guard('contact')->user()->company->id)
->whereNotNull('subscription_id')
->where('status_id', RecurringInvoice::STATUS_ACTIVE)

View File

@ -130,7 +130,7 @@ class PaymentMethodController extends Controller
try {
event(new MethodDeleted($payment_method, auth('contact')->user()->company, Ninja::eventVars(auth('contact')->user()->id)));
event(new MethodDeleted($payment_method, auth()->guard('contact')->user()->company, Ninja::eventVars(auth()->guard('contact')->user()->id)));
$payment_method->delete();

View File

@ -63,7 +63,7 @@ class QuoteController extends Controller
$data = [
'quote' => $quote,
'key' => $invitation->key,
'key' => $invitation ? $invitation->key : false,
];
if ($invitation && auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) {
@ -160,8 +160,8 @@ class QuoteController extends Controller
protected function approve(array $ids, $process = false)
{
$quotes = Quote::whereIn('id', $ids)
->where('client_id', auth('contact')->user()->client->id)
->where('company_id', auth('contact')->user()->client->company_id)
->where('client_id', auth()->guard('contact')->user()->client->id)
->where('company_id', auth()->guard('contact')->user()->client->company_id)
->whereIn('status_id', [Quote::STATUS_DRAFT, Quote::STATUS_SENT])
->withTrashed()
->get();
@ -175,7 +175,7 @@ class QuoteController extends Controller
if ($process) {
foreach ($quotes as $quote) {
$quote->service()->approve(auth()->user())->save();
event(new QuoteWasApproved(auth('contact')->user(), $quote, $quote->company, Ninja::eventVars()));
event(new QuoteWasApproved(auth()->guard('contact')->user(), $quote, $quote->company, Ninja::eventVars()));
if (request()->has('signature') && !is_null(request()->signature) && !empty(request()->signature)) {
InjectSignature::dispatch($quote, request()->signature);

View File

@ -26,8 +26,8 @@ class SubscriptionController extends Controller
$count = RecurringInvoice::query()
->where('client_id', auth('contact')->user()->client->id)
->where('company_id', auth('contact')->user()->client->company_id)
->where('client_id', auth()->guard('contact')->user()->client->id)
->where('company_id', auth()->guard('contact')->user()->client->company_id)
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
->where('is_deleted', 0)
->whereNotNull('subscription_id')
@ -35,7 +35,7 @@ class SubscriptionController extends Controller
->count();
if($count == 0)
return redirect()->route('client.ninja_contact_login', ['contact_key' => auth('contact')->user()->contact_key, 'company_key' => auth('contact')->user()->company->company_key]);
return redirect()->route('client.ninja_contact_login', ['contact_key' => auth()->guard('contact')->user()->contact_key, 'company_key' => auth()->guard('contact')->user()->company->company_key]);
}

View File

@ -26,7 +26,7 @@ class TaskController extends Controller
public function index(ShowTasksRequest $request)
{
\Carbon\Carbon::setLocale(
auth('contact')->user()->preferredLocale()
auth()->guard('contact')->user()->preferredLocale()
);
return render('tasks.index');

View File

@ -81,6 +81,7 @@ class ImportController extends Controller {
/** @var UploadedFile $file */
foreach ( $request->files->get( 'files' ) as $entityType => $file ) {
$contents = file_get_contents( $file->getPathname() );
// $contents = mb_convert_encoding($contents, 'UTF-16LE', 'UTF-8');
// Store the csv in cache with an expiry of 10 minutes
Cache::put( $hash . '-' . $entityType, base64_encode( $contents ), 600 );

View File

@ -36,7 +36,7 @@ class CreditsTable extends Component
{
$query = Credit::query()
->where('client_id', auth('contact')->user()->client->id)
->where('client_id', auth()->guard('contact')->user()->client->id)
->where('company_id', $this->company->id)
->where('status_id', '<>', Credit::STATUS_DRAFT)
->where('is_deleted', 0)

View File

@ -75,7 +75,7 @@ class InvoicesTable extends Component
}
$query = $query
->where('client_id', auth('contact')->user()->client->id)
->where('client_id', auth()->guard('contact')->user()->client->id)
->where('status_id', '<>', Invoice::STATUS_DRAFT)
->where('status_id', '<>', Invoice::STATUS_CANCELLED)
->withTrashed()

View File

@ -43,7 +43,7 @@ class PaymentsTable extends Component
->with('type', 'client')
->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING, Payment::STATUS_REFUNDED, Payment::STATUS_PARTIALLY_REFUNDED])
->where('company_id', $this->company->id)
->where('client_id', auth('contact')->user()->client->id)
->where('client_id', auth()->guard('contact')->user()->client->id)
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc')
->withTrashed()
->paginate($this->per_page);

View File

@ -37,7 +37,7 @@ class General extends Component
public function mount()
{
$profile = auth()->user('contact');
$profile = auth()->guard('contact')->user();
$this->fill([
'profile' => $profile,

View File

@ -25,11 +25,11 @@ class NameWebsiteLogo extends Component
public function mount()
{
$this->fill([
'profile' => auth()->user('contact')->client,
'name' => auth()->user('contact')->client->present()->name,
'vat_number' => auth()->user('contact')->client->present()->vat_number,
'website' => auth()->user('contact')->client->present()->website,
'phone' => auth()->user('contact')->client->present()->phone,
'profile' => auth()->guard('contact')->user()->client,
'name' => auth()->guard('contact')->user()->client->present()->name,
'vat_number' => auth()->guard('contact')->user()->client->present()->vat_number,
'website' => auth()->guard('contact')->user()->client->present()->website,
'phone' => auth()->guard('contact')->user()->client->present()->phone,
'saved' => ctrans('texts.save'),
]);
}

View File

@ -31,13 +31,13 @@ class PersonalAddress extends Component
public function mount($countries)
{
$this->fill([
'profile' => auth()->user('contact')->client,
'address1' => auth()->user('contact')->client->address1,
'address2' => auth()->user('contact')->client->address2,
'city' => auth()->user('contact')->client->city,
'state' => auth()->user('contact')->client->state,
'postal_code' => auth()->user('contact')->client->postal_code,
'country_id' => auth()->user('contact')->client->country_id,
'profile' => auth()->guard('contact')->user()->client,
'address1' => auth()->guard('contact')->user()->client->address1,
'address2' => auth()->guard('contact')->user()->client->address2,
'city' => auth()->guard('contact')->user()->client->city,
'state' => auth()->guard('contact')->user()->client->state,
'postal_code' => auth()->guard('contact')->user()->client->postal_code,
'country_id' => auth()->guard('contact')->user()->client->country_id,
'countries' => $countries,
'saved' => ctrans('texts.save'),

View File

@ -31,13 +31,13 @@ class ShippingAddress extends Component
public function mount($countries)
{
$this->fill([
'profile' => auth()->user('contact')->client,
'shipping_address1' => auth()->user('contact')->client->shipping_address1,
'shipping_address2' => auth()->user('contact')->client->shipping_address2,
'shipping_city' => auth()->user('contact')->client->shipping_city,
'shipping_state' => auth()->user('contact')->client->shipping_state,
'shipping_postal_code' => auth()->user('contact')->client->shipping_postal_code,
'shipping_country_id' => auth()->user('contact')->client->shipping_country_id,
'profile' => auth()->guard('contact')->user()->client,
'shipping_address1' => auth()->guard('contact')->user()->client->shipping_address1,
'shipping_address2' => auth()->guard('contact')->user()->client->shipping_address2,
'shipping_city' => auth()->guard('contact')->user()->client->shipping_city,
'shipping_state' => auth()->guard('contact')->user()->client->shipping_state,
'shipping_postal_code' => auth()->guard('contact')->user()->client->shipping_postal_code,
'shipping_country_id' => auth()->guard('contact')->user()->client->shipping_country_id,
'countries' => $countries,
'saved' => ctrans('texts.save'),

View File

@ -75,7 +75,7 @@ class QuotesTable extends Component
$query = $query
->where('company_id', $this->company->id)
->where('client_id', auth('contact')->user()->client->id)
->where('client_id', auth()->guard('contact')->user()->client->id)
->where('status_id', '<>', Quote::STATUS_DRAFT)
// ->where(function ($query){
// $query->whereDate('due_date', '>=', now())

View File

@ -40,7 +40,7 @@ class RecurringInvoicesTable extends Component
$query = RecurringInvoice::query();
$query = $query
->where('client_id', auth('contact')->user()->client->id)
->where('client_id', auth()->guard('contact')->user()->client->id)
->where('company_id', $this->company->id)
->whereIn('status_id', [RecurringInvoice::STATUS_ACTIVE])
->orderBy('status_id', 'asc')

View File

@ -35,7 +35,7 @@ class SubscriptionRecurringInvoicesTable extends Component
public function render()
{
$query = RecurringInvoice::query()
->where('client_id', auth('contact')->user()->client->id)
->where('client_id', auth()->guard('contact')->user()->client->id)
->where('company_id', $this->company->id)
->whereNotNull('subscription_id')
->where('is_deleted', false)

View File

@ -37,7 +37,7 @@ class TasksTable extends Component
$query = Task::query()
->where('company_id', $this->company->id)
->where('is_deleted', false)
->where('client_id', auth('contact')->user()->client->id);
->where('client_id', auth()->guard('contact')->user()->client->id);
if ($this->company->getSetting('show_all_tasks_client_portal') === 'invoiced') {
$query = $query->whereNotNull('invoice_id');

View File

@ -31,7 +31,7 @@ class CheckClientExistence
$multiple_contacts = ClientContact::query()
->with('client.gateway_tokens','company')
->where('email', auth('contact')->user()->email)
->where('email', auth()->guard('contact')->user()->email)
->whereNotNull('email')
->where('email', '<>', '')
// ->whereNull('deleted_at')
@ -42,7 +42,7 @@ class CheckClientExistence
return $query->where('is_deleted', false);
})
->whereHas('company', function ($query){
return $query->where('id', auth('contact')->user()->client->company_id);
return $query->where('id', auth()->guard('contact')->user()->client->company_id);
})
->get();

View File

@ -32,8 +32,8 @@ class Locale
if ($request->has('lang')) {
$locale = $request->input('lang');
App::setLocale($locale);
} elseif (auth('contact')->user()) {
App::setLocale(auth('contact')->user()->client->locale());
} elseif (auth()->guard('contact')->user()) {
App::setLocale(auth()->guard('contact')->user()->client->locale());
} elseif (auth()->user()) {
try{

View File

@ -25,7 +25,6 @@ use Illuminate\Validation\Rule;
class StoreClientRequest extends Request
{
use MakesHash;
/**
* Determine if the user is authorized to make this request.
*
@ -89,7 +88,7 @@ class StoreClientRequest extends Request
protected function prepareForValidation()
{
$input = $this->all();
$settings = ClientSettings::defaults();
if (array_key_exists('settings', $input) && ! empty($input['settings'])) {

View File

@ -15,7 +15,7 @@ class ShowCreditRequest extends FormRequest
public function authorize()
{
return !$this->credit->is_deleted
&& auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS;
&& auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS;
}
/**

View File

@ -19,7 +19,7 @@ class ShowCreditsRequest extends FormRequest
{
public function authorize()
{
return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS;
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS;
}
public function rules()

View File

@ -27,9 +27,9 @@ class ShowDocumentRequest extends FormRequest
*/
public function authorize()
{
return auth()->user('contact')->client->id == $this->document->documentable_id
|| $this->document->documentable->client_id == auth()->user('contact')->client->id
|| $this->document->company_id == auth()->user('contact')->company->id;
return auth()->guard('contact')->user()->client_id == $this->document->documentable_id
|| $this->document->documentable->client_id == auth()->guard('contact')->user()->client_id
|| $this->document->company_id == auth()->guard('contact')->user()->company_id;
}
/**

View File

@ -19,7 +19,7 @@ class ProcessInvoicesInBulkRequest extends FormRequest
{
public function authorize()
{
return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
}
public function rules()

View File

@ -23,7 +23,7 @@ class ShowInvoiceRequest extends Request
*/
public function authorize() : bool
{
return auth('contact')->user()->client->id == $this->invoice->client_id
&& auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
return auth()->guard('contact')->user()->client_id == $this->invoice->client_id
&& auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
}
}

View File

@ -19,7 +19,7 @@ class ShowInvoicesRequest extends FormRequest
{
public function authorize()
{
return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
}
public function rules()

View File

@ -20,7 +20,7 @@ class ProcessQuotesInBulkRequest extends FormRequest
{
public function authorize()
{
return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES;
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES;
}
public function rules()

View File

@ -20,7 +20,7 @@ class ShowQuoteRequest extends FormRequest
public function authorize()
{
return auth()->user()->client->id === $this->quote->client_id
&& auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES;
&& auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES;
}
public function rules()

View File

@ -19,7 +19,7 @@ class ShowQuotesRequest extends FormRequest
{
public function authorize()
{
return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES;
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES;
}
public function rules()

View File

@ -9,7 +9,7 @@ class RequestCancellationRequest extends FormRequest
{
public function authorize()
{
return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES;
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES;
}
public function rules()

View File

@ -18,8 +18,8 @@ class ShowRecurringInvoiceRequest extends Request
{
public function authorize() : bool
{
return auth('contact')->user()->client->id === $this->recurring_invoice->client_id
&& auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES;
return auth()->guard('contact')->user()->client->id === $this->recurring_invoice->client_id
&& auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES;
}
public function rules()

View File

@ -19,7 +19,7 @@ class ShowRecurringInvoicesRequest extends FormRequest
{
public function authorize()
{
return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES;
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES;
}
public function rules()

View File

@ -44,6 +44,6 @@ class ShowStatementRequest extends FormRequest
public function client(): Client
{
return auth('contact')->user()->client;
return auth()->guard('contact')->user()->client;
}
}

View File

@ -23,7 +23,7 @@ class ShowTasksRequest extends FormRequest
*/
public function authorize()
{
return (bool)auth()->user('contact')->client->getSetting('enable_client_portal_tasks');
return (bool)auth()->guard('contact')->user()->client->getSetting('enable_client_portal_tasks');
}
/**

View File

@ -13,7 +13,7 @@ class StoreUploadRequest extends FormRequest
*/
public function authorize()
{
return (bool) auth('contact')->user()->client->getSetting('client_portal_enable_uploads');
return (bool) auth()->guard('contact')->user()->client->getSetting('client_portal_enable_uploads');
}
/**

View File

@ -30,7 +30,7 @@ class ActionInvoiceRequest extends Request
private $invoice;
public function authorize() : bool
{
{
return auth()->user()->can('edit', $this->invoice);
}

View File

@ -11,6 +11,7 @@
namespace App\Http\Requests;
use App\Http\Requests\RuntimeFormRequest;
use App\Http\ValidationRules\User\RelatedUserRule;
use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Http\FormRequest;
@ -18,7 +19,7 @@ use Illuminate\Foundation\Http\FormRequest;
class Request extends FormRequest
{
use MakesHash;
use RuntimeFormRequest;
/**
* Get the validation rules that apply to the request.
*
@ -163,9 +164,18 @@ class Request extends FormRequest
}
}
if (array_key_exists('email', $contact))
$input['contacts'][$key]['email'] = trim($contact['email']);
}
}
return $input;
}
protected function prepareForValidation()
{
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Http\Requests;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
trait RuntimeFormRequest
{
public static function runFormRequest($value)
{
$value = self::getMockedRequestByParameters($value);
$validator = self::createFrom($value, new self());
$validator->setContainer(app());
$validator->prepareForValidation();
$validator->setValidator(Validator::make($validator->all(), $validator->rules()));
$instance = $validator->getValidatorInstance();
return $instance;
// if ($instance->fails()) {
// return $instance->errors();
// }
// $validator->passedValidation();
// return $validator->all();
}
protected static function getMockedRequestByParameters($paramters)
{
$mockRequest = Request::create('', 'POST');
$mockRequest->merge($paramters);
return $mockRequest;
}
}

View File

@ -51,10 +51,10 @@ class PortalComposer
$view->with($this->portalData());
if (auth('contact')->user()) {
if (auth()->guard('contact')->user()) {
App::forgetInstance('translator');
$t = app('translator');
$t->replace(Ninja::transformTranslations(auth('contact')->user()->client->getMergedSettings()));
$t->replace(Ninja::transformTranslations(auth()->guard('contact')->user()->client->getMergedSettings()));
}
}
@ -63,21 +63,21 @@ class PortalComposer
*/
private function portalData() :array
{
if (! auth('contact')->user()) {
if (! auth()->guard('contact')->user()) {
return [];
}
$this->settings = auth('contact')->user()->client->getMergedSettings();
$this->settings = auth()->guard('contact')->user()->client->getMergedSettings();
$data['sidebar'] = $this->sidebarMenu();
$data['header'] = [];
$data['footer'] = [];
$data['countries'] = TranslationHelper::getCountries();
$data['company'] = auth('contact')->user()->company;
$data['client'] = auth('contact')->user()->client;
$data['company'] = auth()->guard('contact')->user()->company;
$data['client'] = auth()->guard('contact')->user()->client;
$data['settings'] = $this->settings;
$data['currencies'] = TranslationHelper::getCurrencies();
$data['contact'] = auth('contact')->user();
$data['contact'] = auth()->guard('contact')->user();
$data['multiple_contacts'] = session()->get('multiple_contacts') ?: collect();
@ -86,7 +86,7 @@ class PortalComposer
private function sidebarMenu() :array
{
$enabled_modules = auth('contact')->user()->company->enabled_modules;
$enabled_modules = auth()->guard('contact')->user()->company->enabled_modules;
$data = [];
// TODO: Enable dashboard once it's completed.
@ -114,13 +114,13 @@ class PortalComposer
$data[] = ['title' => ctrans('texts.payment_methods'), 'url' => 'client.payment_methods.index', 'icon' => 'shield'];
$data[] = ['title' => ctrans('texts.documents'), 'url' => 'client.documents.index', 'icon' => 'download'];
if (auth('contact')->user()->client->getSetting('enable_client_portal_tasks')) {
if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_tasks')) {
$data[] = ['title' => ctrans('texts.tasks'), 'url' => 'client.tasks.index', 'icon' => 'clock'];
}
$data[] = ['title' => ctrans('texts.statement'), 'url' => 'client.statement', 'icon' => 'activity'];
if(Ninja::isHosted() && auth('contact')->user()->company->id == config('ninja.ninja_default_company_id'))
if(Ninja::isHosted() && auth()->guard('contact')->user()->company->id == config('ninja.ninja_default_company_id'))
$data[] = ['title' => ctrans('texts.plan'), 'url' => 'client.plan', 'icon' => 'credit-card'];
else
$data[] = ['title' => ctrans('texts.subscriptions'), 'url' => 'client.subscriptions.index', 'icon' => 'calendar'];

View File

@ -372,11 +372,13 @@ class CSVImport implements ShouldQueue {
$entity = $transformer->transform( $record );
/** @var \App\Http\Requests\Request $request */
$request = new $request_name();
// $request = new $request_name();
// $request->prepareForValidation();
// Pass entity data to request so it can be validated
$request->query = $request->request = new ParameterBag( $entity );
$validator = Validator::make( $entity, $request->rules() );
// $request->query = $request->request = new ParameterBag( $entity );
// $validator = Validator::make( $entity, $request->rules() );
$validator = $request_name::runFormRequest($entity);
if ( $validator->fails() ) {
$this->error_array[ $entity_type ][] =

View File

@ -78,7 +78,8 @@ class ProcessPostmarkWebhook implements ShouldQueue
if(!$this->invitation)
return;
$this->invitation->email_error = $this->request['Details'];
if(array_key_exists('Details', $this->request))
$this->invitation->email_error = $this->request['Details'];
switch ($this->request['RecordType'])
{

View File

@ -458,14 +458,13 @@ class RecurringInvoice extends BaseModel
public function calculateDueDate($date)
{
//if nothing is set, assume we are using terms.
if(!$this->due_date_days)
return $this->calculateDateFromTerms($date);
switch ($this->due_date_days) {
case 'terms':
case '':
return $this->calculateDateFromTerms($date);
break;
default:
return $this->setDayOfMonth($date, $this->due_date_days);
break;

View File

@ -22,6 +22,10 @@ use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\AuthorizePaymentDriver;
use App\Utils\Traits\MakesHash;
use net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest;
use net\authorize\api\contract\v1\DeleteCustomerProfileRequest;
use net\authorize\api\controller\DeleteCustomerPaymentProfileController;
use net\authorize\api\controller\DeleteCustomerProfileController;
/**
* Class AuthorizeCreditCard.
@ -69,21 +73,59 @@ class AuthorizeCreditCard
$payment_profile = $authorise_payment_method->addPaymentMethodToClient($gateway_customer_reference, $data);
$payment_profile_id = $payment_profile->getPaymentProfile()->getCustomerPaymentProfileId();
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile_id, $data['amount_with_fee']);
if ($request->has('store_card') && $request->input('store_card') === true) {
$authorise_payment_method->payment_method = GatewayType::CREDIT_CARD;
$client_gateway_token = $authorise_payment_method->createClientGatewayToken($payment_profile, $gateway_customer_reference);
}
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile_id, $data['amount_with_fee']);
else{
//remove the payment profile if we are not storing tokens in our system
$this->removePaymentProfile($gateway_customer_reference, $payment_profile_id);
}
return $this->handleResponse($data, $request);
}
private function removePaymentProfile($customer_profile_id, $customer_payment_profile_id)
{
$request = new DeleteCustomerPaymentProfileRequest();
$request->setMerchantAuthentication($this->authorize->merchant_authentication);
$request->setCustomerProfileId($customer_profile_id);
$request->setCustomerPaymentProfileId($customer_payment_profile_id);
$controller = new DeleteCustomerPaymentProfileController($request);
$response = $controller->executeWithApiResponse($this->authorize->mode());
if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") )
{
nlog("SUCCESS: Delete Customer Payment Profile SUCCESS");
}
else
nlog("unable to delete profile {$customer_profile_id} with payment id {$customer_payment_profile_id}");
// Delete a customer profile
// $request = new DeleteCustomerProfileRequest();
// $request->setMerchantAuthentication($this->authorize->merchant_authentication);
// $request->setCustomerProfileId( $customer_profile_id );
// $controller = new DeleteCustomerProfileController($request);
// $response = $controller->executeWithApiResponse($this->authorize->mode());
// if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") )
// {
// nlog("SUCCESS: Delete Customer Payment Profile SUCCESS");
// }
// else
// nlog("unable to delete profile {$customer_profile_id}");
}
private function processTokenPayment($request)
{
$client_gateway_token = ClientGatewayToken::query()
->where('id', $this->decodePrimaryKey($request->token))
->where('company_id', auth('contact')->user()->client->company->id)
->where('company_id', auth()->guard('contact')->user()->client->company->id)
->first();
if (!$client_gateway_token) {

View File

@ -0,0 +1,200 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\Authorize;
use App\Exceptions\GenericPaymentDriverFailure;
use App\Factory\ClientContactFactory;
use App\Factory\ClientFactory;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use App\PaymentDrivers\AuthorizePaymentDriver;
use Illuminate\Support\Facades\Cache;
use net\authorize\api\contract\v1\CreateCustomerProfileRequest;
use net\authorize\api\contract\v1\CustomerProfileType;
use net\authorize\api\contract\v1\GetCustomerProfileIdsRequest;
use net\authorize\api\contract\v1\GetCustomerProfileRequest;
use net\authorize\api\controller\CreateCustomerProfileController;
use net\authorize\api\controller\GetCustomerProfileController;
use net\authorize\api\controller\GetCustomerProfileIdsController;
/**
* Class AuthorizeCustomer.
*/
class AuthorizeCustomer
{
public $authorize;
public function __construct(AuthorizePaymentDriver $authorize)
{
$this->authorize = $authorize;
}
private function getCustomerProfileIds()
{
// Get all existing customer profile ID's
$request = new GetCustomerProfileIdsRequest();
$request->setMerchantAuthentication($this->authorize->merchant_authentication);
$controller = new GetCustomerProfileIdsController($request);
$response = $controller->executeWithApiResponse($this->authorize->mode());
if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") )
{
return $response->getIds();
}
else
{
return [];
nlog( "GetCustomerProfileId's ERROR : Invalid response");
$errorMessages = $response->getMessages()->getMessage();
nlog( "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText());
}
}
private function getCustomerProfile($customer_profile_id)
{
$request = new GetCustomerProfileRequest();
$request->setMerchantAuthentication($this->authorize->merchant_authentication);
$request->setCustomerProfileId($customer_profile_id);
$controller = new GetCustomerProfileController($request);
$response = $controller->executeWithApiResponse($this->authorize->mode());
if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") )
{
$profileSelected = $response->getProfile();
$paymentProfilesSelected = $profileSelected->getPaymentProfiles();
return [
'email' => $profileSelected->getEmail(),
'payment_profiles' => $paymentProfilesSelected,
'error' => ''
];
}
else
{
nlog("ERROR : GetCustomerProfile: Invalid response");
$errorMessages = $response->getMessages()->getMessage();
nlog("Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText());
return [
'profile' => NULL,
'payment_profiles' => NULL,
'error' => $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText(),
];
}
}
public function importCustomers()
{
$auth_customers = $this->getCustomerProfileIds();
$company = $this->authorize->company_gateway->company;
$user = $company->owner();
foreach($auth_customers as $gateway_customer_reference)
{
$profile = $this->getCustomerProfile($gateway_customer_reference);
//if the profile ID already exists in ClientGatewayToken we continue else - add.
if($client_gateway_token = ClientGatewayToken::where('company_id', $company->id)->where('gateway_customer_reference', $gateway_customer_reference)->first()){
// nlog("found client");
$client = $client_gateway_token->client;
}
elseif($client_contact = ClientContact::where('company_id', $company->id)->where('email', $profile['email'])->first()){
$client = $client_contact->client;
// nlog("found client through contact");
}
else {
// nlog("creating client");
$first_payment_profile = $profile['payment_profiles'][0];
if(!$first_payment_profile)
continue;
$client = ClientFactory::create($company->id, $user->id);
$billTo = $first_payment_profile->getBillTo();
$client->address1 = $billTo->getAddress();
$client->city = $billTo->getCity();
$client->state = $billTo->getState();
$client->postal_code = $billTo->getZip();
$client->country_id = $billTo->getCountry() ? $this->getCountryCode($billTo->getCountry()) : $company->settings->country_id;
$client->save();
$client_contact = ClientContactFactory::create($company->id, $user->id);
$client_contact->client_id = $client->id;
$client_contact->first_name = $billTo->getFirstName();
$client_contact->last_name = $billTo->getLastName();
$client_contact->email = $profile['email'];
$client_contact->phone = $billTo->getPhoneNumber();
$client_contact->save();
}
if($client && is_array($profile['payment_profiles'])){
$this->authorize->setClient($client);
foreach($profile['payment_profiles'] as $payment_profile)
{
$token_exists = ClientGatewayToken::where('company_id', $company->id)
->where('token', $payment_profile->getCustomerPaymentProfileId())
->where('gateway_customer_reference', $gateway_customer_reference)
->exists();
if($token_exists)
continue;
// $expiry = $payment_profile->getPayment()->getCreditCard()->getExpirationDate();
$payment_meta = new \stdClass;
$payment_meta->exp_month = 'xx';
$payment_meta->exp_year = 'xx';
$payment_meta->brand = (string) $payment_profile->getPayment()->getCreditCard()->getCardType();
$payment_meta->last4 = (string) $payment_profile->getPayment()->getCreditCard()->getCardNumber();
$payment_meta->type = GatewayType::CREDIT_CARD;
$data['payment_method_id'] = GatewayType::CREDIT_CARD;
$data['payment_meta'] = $payment_meta;
$data['token'] = $payment_profile->getCustomerPaymentProfileId();
$additional['gateway_customer_reference'] = $gateway_customer_reference;
$this->authorize->storeGatewayToken($data, $additional);
}
}
}
}
private function getCountryCode($country_code)
{
$countries = Cache::get('countries');
$country = $countries->filter(function ($item) use ($country_code) {
return $item->iso_3166_2 == $country_code || $item->iso_3166_3 == $country_code;
})->first();
return (string) $country->id;
}
}

View File

@ -130,6 +130,7 @@ class AuthorizePaymentMethod
public function buildPaymentMethod($payment_profile)
{
$payment_meta = new stdClass;
$payment_meta->exp_month = 'xx';
$payment_meta->exp_year = 'xx';

View File

@ -18,6 +18,7 @@ use App\Models\Payment;
use App\Models\PaymentHash;
use App\Models\SystemLog;
use App\PaymentDrivers\Authorize\AuthorizeCreditCard;
use App\PaymentDrivers\Authorize\AuthorizeCustomer;
use App\PaymentDrivers\Authorize\AuthorizePaymentMethod;
use App\PaymentDrivers\Authorize\RefundTransaction;
use net\authorize\api\constants\ANetEnvironment;
@ -159,4 +160,9 @@ class AuthorizePaymentDriver extends BaseDriver
{
return (new AuthorizePaymentMethod($this))->deletePaymentProfile($token->gateway_customer_reference, $token->token);
}
public function import()
{
return (new AuthorizeCustomer($this))->importCustomers();
}
}

View File

@ -182,7 +182,10 @@ class BaseDriver extends AbstractPaymentDriver
{
}
public function setClient(Client $client)
{
$this->client = $client;
}
/************************** Helper methods *************************************/
public function setPaymentHash(PaymentHash $payment_hash)

View File

@ -109,7 +109,7 @@ class ACH implements MethodInterface
$customer = $this->braintree->findOrCreateCustomer();
$token = ClientGatewayToken::query()
->where('client_id', auth('contact')->user()->client->id)
->where('client_id', auth()->guard('contact')->user()->client->id)
->where('id', $this->decodePrimaryKey($request->source))
->firstOrFail();

View File

@ -145,7 +145,7 @@ class CreditCard implements MethodInterface
{
$cgt = ClientGatewayToken::query()
->where('id', $this->decodePrimaryKey($request->input('token')))
->where('company_id', auth('contact')->user()->client->company->id)
->where('company_id', auth()->guard('contact')->user()->client->company->id)
->first();
if (!$cgt) {

View File

@ -64,12 +64,12 @@ class ACH implements MethodInterface
'session_token' => $session_token,
]),
"prefilled_customer" => [
"given_name" => auth('contact')->user()->first_name,
"family_name" => auth('contact')->user()->last_name,
"email" => auth('contact')->user()->email,
"address_line1" => auth('contact')->user()->client->address1,
"city" => auth('contact')->user()->client->city,
"postal_code" => auth('contact')->user()->client->postal_code,
"given_name" => auth()->guard('contact')->user()->first_name,
"family_name" => auth()->guard('contact')->user()->last_name,
"email" => auth()->guard('contact')->user()->email,
"address_line1" => auth()->guard('contact')->user()->client->address1,
"city" => auth()->guard('contact')->user()->client->city,
"postal_code" => auth()->guard('contact')->user()->client->postal_code,
],
],
]);

View File

@ -62,12 +62,12 @@ class DirectDebit implements MethodInterface
'session_token' => $session_token,
]),
'prefilled_customer' => [
'given_name' => auth('contact')->user()->first_name,
'family_name' => auth('contact')->user()->last_name,
'email' => auth('contact')->user()->email,
'address_line1' => auth('contact')->user()->client->address1,
'city' => auth('contact')->user()->client->city,
'postal_code' => auth('contact')->user()->client->postal_code,
'given_name' => auth()->guard('contact')->user()->first_name,
'family_name' => auth()->guard('contact')->user()->last_name,
'email' => auth()->guard('contact')->user()->email,
'address_line1' => auth()->guard('contact')->user()->client->address1,
'city' => auth()->guard('contact')->user()->client->city,
'postal_code' => auth()->guard('contact')->user()->client->postal_code,
],
],
]);

View File

@ -63,12 +63,12 @@ class SEPA implements MethodInterface
'session_token' => $session_token,
]),
'prefilled_customer' => [
'given_name' => auth('contact')->user()->first_name,
'family_name' => auth('contact')->user()->last_name,
'email' => auth('contact')->user()->email,
'address_line1' => auth('contact')->user()->client->address1,
'city' => auth('contact')->user()->client->city,
'postal_code' => auth('contact')->user()->client->postal_code,
'given_name' => auth()->guard('contact')->user()->first_name,
'family_name' => auth()->guard('contact')->user()->last_name,
'email' => auth()->guard('contact')->user()->email,
'address_line1' => auth()->guard('contact')->user()->client->address1,
'city' => auth()->guard('contact')->user()->client->city,
'postal_code' => auth()->guard('contact')->user()->client->postal_code,
],
],
]);

View File

@ -74,13 +74,13 @@ class ACH
$mailer = new NinjaMailerObject();
$mailer->mailable = new ACHVerificationNotification(
auth('contact')->user()->client->company,
route('client.contact_login', ['contact_key' => auth('contact')->user()->contact_key, 'next' => $verification])
auth()->guard('contact')->user()->client->company,
route('client.contact_login', ['contact_key' => auth()->guard('contact')->user()->contact_key, 'next' => $verification])
);
$mailer->company = auth('contact')->user()->client->company;
$mailer->settings = auth('contact')->user()->client->company->settings;
$mailer->to_user = auth('contact')->user();
$mailer->company = auth()->guard('contact')->user()->client->company;
$mailer->settings = auth()->guard('contact')->user()->client->company->settings;
$mailer->to_user = auth()->guard('contact')->user();
NinjaMailerJob::dispatch($mailer);
@ -210,7 +210,7 @@ class ACH
$source = ClientGatewayToken::query()
->where('id', $this->decodePrimaryKey($request->source))
->where('company_id', auth('contact')->user()->client->company->id)
->where('company_id', auth()->guard('contact')->user()->client->company->id)
->first();
if (!$source) {

View File

@ -66,13 +66,13 @@ class ACSS
$mailer = new NinjaMailerObject();
$mailer->mailable = new ACHVerificationNotification(
auth('contact')->user()->client->company,
route('client.contact_login', ['contact_key' => auth('contact')->user()->contact_key, 'next' => $verification])
auth()->guard('contact')->user()->client->company,
route('client.contact_login', ['contact_key' => auth()->guard('contact')->user()->contact_key, 'next' => $verification])
);
$mailer->company = auth('contact')->user()->client->company;
$mailer->settings = auth('contact')->user()->client->company->settings;
$mailer->to_user = auth('contact')->user();
$mailer->company = auth()->guard('contact')->user()->client->company;
$mailer->settings = auth()->guard('contact')->user()->client->company->settings;
$mailer->to_user = auth()->guard('contact')->user();
NinjaMailerJob::dispatch($mailer);

View File

@ -41,10 +41,5 @@ class MailCssInlinerServiceProvider extends ServiceProvider
$this->app->singleton(CssInlinerPlugin::class, function ($app) {
return new CssInlinerPlugin([]);
});
// $this->app->afterResolving('mail.manager', function (MailManager $mailManager) {
// $mailManager->getSwiftMailer()->registerPlugin($this->app->make(CssInlinerPlugin::class));
// return $mailManager;
// });
}
}

View File

@ -91,7 +91,7 @@ class SubscriptionService
'invoice' => $this->encodePrimaryKey($payment_hash->fee_invoice_id),
'client' => $recurring_invoice->client->hashed_id,
'subscription' => $this->subscription->hashed_id,
'contact' => auth('contact')->user() ? auth('contact')->user()->hashed_id : $recurring_invoice->client->contacts()->first()->hashed_id,
'contact' => auth()->guard('contact')->user() ? auth()->guard('contact')->user()->hashed_id : $recurring_invoice->client->contacts()->first()->hashed_id,
'account_key' => $recurring_invoice->client->custom_value2,
];
@ -452,7 +452,7 @@ class SubscriptionService
'credit' => $credit ? $credit->hashed_id : null,
'client' => $new_recurring_invoice->client->hashed_id,
'subscription' => $target_subscription->hashed_id,
'contact' => auth('contact')->user()->hashed_id,
'contact' => auth()->guard('contact')->user()->hashed_id,
'account_key' => $new_recurring_invoice->client->custom_value2,
];
@ -573,7 +573,7 @@ class SubscriptionService
'invoice' => $this->encodePrimaryKey($payment_hash->fee_invoice_id),
'client' => $recurring_invoice->client->hashed_id,
'subscription' => $this->subscription->hashed_id,
'contact' => auth('contact')->user()->hashed_id,
'contact' => auth()->guard('contact')->user()->hashed_id,
'account_key' => $recurring_invoice->client->custom_value2,
];
@ -921,7 +921,7 @@ class SubscriptionService
'subscription' => $this->subscription->hashed_id,
'recurring_invoice' => $recurring_invoice->hashed_id,
'client' => $recurring_invoice->client->hashed_id,
'contact' => auth('contact')->user()->hashed_id,
'contact' => auth()->guard('contact')->user()->hashed_id,
'account_key' => $recurring_invoice->client->custom_value2,
];

View File

@ -71,7 +71,7 @@ class ZeroCostProduct extends AbstractService
'invoice' => $invoice->hashed_id,
'client' => $recurring_invoice->client->hashed_id,
'subscription' => $this->subscription->hashed_id,
'contact' => auth('contact')->user()->hashed_id,
'contact' => auth()->guard('contact')->user()->hashed_id,
'redirect_url' => "/client/recurring_invoices/{$recurring_invoice->hashed_id}",
];

View File

@ -327,6 +327,7 @@ class HtmlEngine
$data['$client_address'] = ['value' => $this->client->present()->address() ?: '&nbsp;', 'label' => ctrans('texts.address')];
$data['$client.address'] = &$data['$client_address'];
$data['$client.postal_code'] = ['value' => $this->client->postal_code ?: '&nbsp;', 'label' => ctrans('texts.postal_code')];
$data['$client.public_notes'] = ['value' => $this->client->public_notes ?: '&nbsp;', 'label' => ctrans('texts.notes')];
$data['$client.city'] = ['value' => $this->client->city ?: '&nbsp;', 'label' => ctrans('texts.city')];
$data['$client.state'] = ['value' => $this->client->state ?: '&nbsp;', 'label' => ctrans('texts.state')];
$data['$client.id_number'] = &$data['$id_number'];
@ -490,7 +491,8 @@ class HtmlEngine
//$data['$entity_footer'] = ['value' => $this->client->getSetting("{$this->entity_string}_footer"), 'label' => ''];
$data['$entity_footer'] = ['value' => Helpers::processReservedKeywords(\nl2br($this->entity->footer), $this->client), 'label' => ''];
$data['$footer'] = &$data['$entity_footer'];
$data['$page_size'] = ['value' => $this->settings->page_size, 'label' => ''];
$data['$page_layout'] = ['value' => property_exists($this->settings, 'page_layout') ? $this->settings->page_layout : 'Portrait', 'label' => ''];

View File

@ -2,7 +2,7 @@
@section('meta_title', ctrans('texts.purchase'))
@section('body')
@livewire('billing-portal-purchase', ['subscription' => $subscription, 'company' => $subscription->company, 'contact' => auth('contact')->user(), 'hash' => $hash, 'request_data' => $request_data, 'campaign' => request()->query('campaign') ?? null])
@livewire('billing-portal-purchase', ['subscription' => $subscription, 'company' => $subscription->company, 'contact' => auth()->guard('contact')->user(), 'hash' => $hash, 'request_data' => $request_data, 'campaign' => request()->query('campaign') ?? null])
@stop
@push('footer')

View File

@ -1,7 +1,7 @@
<footer class="bg-white px-4 py-5 shadow px-4 sm:px-6 md:px-8 flex justify-center border-t border-gray-200 justify-between items-center" x-data="{ privacy: false, tos: false }">
<section>
@if(auth('contact')->user() && auth('contact')->user()->user->account->isPaid())
<span class="text-xs md:text-sm text-gray-700">{{ ctrans('texts.footer_label', ['company' => auth('contact')->user()->company->present()->name(), 'year' => date('Y')]) }}</span>
@if(auth()->guard('contact')->user() && auth()->guard('contact')->user()->user->account->isPaid())
<span class="text-xs md:text-sm text-gray-700">{{ ctrans('texts.footer_label', ['company' => auth()->guard('contact')->user()->company->present()->name(), 'year' => date('Y')]) }}</span>
@else
<span href="https://invoiceninja.com" target="_blank" class="text-xs md:text-sm text-gray-700">
{{ ctrans('texts.copyright') }} &copy; {{ date('Y') }}
@ -26,7 +26,7 @@
</div>
</section>
@if(auth('contact')->user()->user && !auth('contact')->user()->user->account->isPaid())
@if(auth()->guard('contact')->user()->user && !auth()->guard('contact')->user()->user->account->isPaid())
<a href="https://invoiceninja.com" target="_blank">
<img class="h-8" src="{{ asset('images/invoiceninja-black-logo-2.png') }}" alt="Invoice Ninja Logo">
</a>

View File

@ -2,8 +2,8 @@
<div class="flex flex-col w-64">
<div class="flex items-center h-16 flex-shrink-0 px-4 bg-white border-r justify-center z-10">
<a href="{{ route('client.dashboard') }}">
<img class="h-10 w-auto" src="{!! auth('contact')->user()->company->present()->logo($settings) !!}"
alt="{{ auth('contact')->user()->company->present()->name() }} logo"/>
<img class="h-10 w-auto" src="{!! auth()->guard('contact')->user()->company->present()->logo($settings) !!}"
alt="{{ auth()->guard('contact')->user()->company->present()->name() }} logo"/>
</a>
</div>
<div class="h-0 flex-1 flex flex-col overflow-y-auto z-0 border-r">
@ -24,7 +24,7 @@
@endforeach
</nav>
@if(!auth('contact')->user()->user->account->isPaid())
@if(!auth()->guard('contact')->user()->user->account->isPaid())
<div class="flex-shrink-0 flex bg-white p-4 justify-center">
<div class="flex items-center">
<a target="_blank" href="https://www.facebook.com/invoiceninja/">

View File

@ -12,7 +12,7 @@
<div>
<span class="rounded shadow-sm">
<button x-on:click="open = !open" x-on:click.away="open = false" type="button" class="inline-flex justify-center w-full rounded-md border border-gray-300 px-4 py-2 bg-white text-sm leading-5 font-medium text-gray-700 hover:text-gray-500 focus:outline-none focus:border-blue-300 focus:ring-blue active:bg-gray-50 active:text-gray-800 transition ease-in-out duration-150">
<span class="hidden md:block mr-1">{{ auth('contact')->user()->company->present()->name }}</span>
<span class="hidden md:block mr-1">{{ auth()->guard('contact')->user()->company->present()->name }}</span>
<svg class="md:-mr-1 md:ml-2 h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
@ -37,8 +37,8 @@
<div>
<button data-ref="client-profile-dropdown" @click="open = !open"
class="max-w-xs flex items-center text-sm rounded-full focus:outline-none focus:ring">
<img class="h-8 w-8 rounded-full" src="{{ auth('contact')->user()->avatar() }}" alt=""/>
<span class="ml-2 hidden sm:block">{{ auth('contact')->user()->present()->name() }}</span>
<img class="h-8 w-8 rounded-full" src="{{ auth()->guard('contact')->user()->avatar() }}" alt=""/>
<span class="ml-2 hidden sm:block">{{ auth()->guard('contact')->user()->present()->name() }}</span>
</button>
</div>
<div x-show="open" style="display:none;" x-transition:enter="transition ease-out duration-100"
@ -50,7 +50,7 @@
class="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg">
<div class="py-1 rounded-md bg-white ring-1 ring-black ring-opacity-5">
<a data-ref="client-profile-dropdown-settings"
href="{{ route('client.profile.edit', ['client_contact' => auth('contact')->user()->hashed_id]) }}"
href="{{ route('client.profile.edit', ['client_contact' => auth()->guard('contact')->user()->hashed_id]) }}"
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 transition ease-in-out duration-150">
{{ ctrans('texts.profile') }}
</a>

View File

@ -9,7 +9,7 @@
</button>
</div>
<div class="flex-shrink-0 flex items-center px-4">
<img class="h-8 w-auto" src="{!! auth('contact')->user()->company->present()->logo($settings) !!}" alt="{{ auth('contact')->user()->company->present()->name() }} logo" />
<img class="h-8 w-auto" src="{!! auth()->guard('contact')->user()->company->present()->logo($settings) !!}" alt="{{ auth()->guard('contact')->user()->company->present()->name() }} logo" />
</div>
<div class="mt-5 flex-1 h-0 overflow-y-auto">
<nav class="flex-1 pb-4 pt-0 bg-white">
@ -28,7 +28,7 @@
@endforeach
</nav>
@if(!auth('contact')->user()->user->account->isPaid())
@if(!auth()->guard('contact')->user()->user->account->isPaid())
<div class="flex-shrink-0 flex bg-white p-4 justify-center">
<div class="flex items-center">
<a target="_blank" href="https://www.facebook.com/invoiceninja/">

View File

@ -17,12 +17,14 @@
{{ ctrans('texts.entity_number_placeholder', ['entity' => ctrans('texts.credit'), 'entity_number' => $credit->number]) }}
</h3>
<div class="btn" data-clipboard-text="{{url("client/credit/{$key}")}}" aria-label="Copied!">
@if($key)
<div class="btn hidden md:block" data-clipboard-text="{{url("client/credit/{$key}")}}" aria-label="Copied!">
<div class="flex text-sm leading-6 font-medium text-gray-500">
<p class="mr-2">{{url("client/credit/{$key}")}}</p>
<p><img class="h-5 w-5" src="{{ asset('assets/clippy.svg') }}" alt="Copy to clipboard"></p>
</div>
</div>
@endif
</div>
</div>

View File

@ -70,7 +70,7 @@
@component('portal.ninja2020.components.general.card-element-single')
<input type="checkbox" class="form-checkbox mr-1" id="accept-terms" required>
<label for="accept-terms" class="cursor-pointer">{{ ctrans('texts.ach_authorization', ['company' => auth()->user()->company->present()->name, 'email' => auth('contact')->user()->client->company->settings->email]) }}</label>
<label for="accept-terms" class="cursor-pointer">{{ ctrans('texts.ach_authorization', ['company' => auth()->user()->company->present()->name, 'email' => auth()->guard('contact')->user()->client->company->settings->email]) }}</label>
@endcomponent
@component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'save-button'])

View File

@ -70,7 +70,7 @@
@component('portal.ninja2020.components.general.card-element-single')
<input type="checkbox" class="form-checkbox mr-1" id="accept-terms" required>
<label for="accept-terms" class="cursor-pointer">{{ ctrans('texts.ach_authorization', ['company' => auth()->user()->company->present()->name, 'email' => auth('contact')->user()->client->company->settings->email]) }}</label>
<label for="accept-terms" class="cursor-pointer">{{ ctrans('texts.ach_authorization', ['company' => auth()->user()->company->present()->name, 'email' => auth()->guard('contact')->user()->client->company->settings->email]) }}</label>
@endcomponent
@component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'save-button'])

View File

@ -70,7 +70,7 @@
@component('portal.ninja2020.components.general.card-element-single')
<input type="checkbox" class="form-checkbox mr-1" id="accept-terms" required>
<label for="accept-terms" class="cursor-pointer">{{ ctrans('texts.ach_authorization', ['company' => auth()->user()->company->present()->name, 'email' => auth('contact')->user()->client->company->settings->email]) }}</label>
<label for="accept-terms" class="cursor-pointer">{{ ctrans('texts.ach_authorization', ['company' => auth()->user()->company->present()->name, 'email' => auth()->guard('contact')->user()->client->company->settings->email]) }}</label>
@endcomponent
@component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'save-button'])

View File

@ -70,7 +70,7 @@
@component('portal.ninja2020.components.general.card-element-single')
<input type="checkbox" class="form-checkbox mr-1" id="accept-terms" required>
<label for="accept-terms" class="cursor-pointer">{{ ctrans('texts.ach_authorization', ['company' => auth()->user()->company->present()->name, 'email' => auth('contact')->user()->client->company->settings->email]) }}</label>
<label for="accept-terms" class="cursor-pointer">{{ ctrans('texts.ach_authorization', ['company' => auth()->user()->company->present()->name, 'email' => auth()->guard('contact')->user()->client->company->settings->email]) }}</label>
@endcomponent
@component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'save-button'])

View File

@ -40,12 +40,15 @@
- {{ ctrans('texts.unpaid') }}
</h3>
<div class="btn" data-clipboard-text="{{url("client/invoice/{$key}")}}" aria-label="Copied!">
@if($key)
<div class="btn hidden md:block" data-clipboard-text="{{url("client/invoice/{$key}")}}" aria-label="Copied!">
<div class="flex text-sm leading-6 font-medium text-gray-500">
<p class="mr-2">{{url("client/invoice/{$key}")}}</p>
<p><img class="h-5 w-5" src="{{ asset('assets/clippy.svg') }}" alt="Copy to clipboard"></p>
</div>
</div>
@endif
</div>
<div class="mt-5 sm:mt-0 sm:ml-6 flex justify-end">
@ -74,12 +77,14 @@
- {{ \App\Models\Invoice::stringStatus($invoice->status_id) }}
</h3>
<div class="btn" data-clipboard-text="{{url("client/invoice/{$key}")}}" aria-label="Copied!">
@if($key)
<div class="btn hidden md:block" data-clipboard-text="{{url("client/invoice/{$key}")}}" aria-label="Copied!">
<div class="flex text-sm leading-6 font-medium text-gray-500">
<p class="pr-10">{{url("client/invoice/{$key}")}}</p>
<p><img class="h-5 w-5" src="{{ asset('assets/clippy.svg') }}" alt="Copy to clipboard"></p>
</div>
</div>
@endif
</div>
</div>
</div>

View File

@ -57,7 +57,7 @@
<!-- Styles -->
<link href="{{ mix('css/app.css') }}" rel="stylesheet">
@if(!auth('contact')->user()->user->account->isPaid())
@if(!auth()->guard('contact')->user()->user->account->isPaid())
<link href="{{ asset('favicon.png') }}" rel="shortcut icon" type="image/png">
@endif

View File

@ -32,7 +32,7 @@
<!-- Title -->
@auth()
<title>@yield('meta_title', '') {{ auth('contact')->user()->user->account->isPaid() ? auth('contact')->user()->company->present()->name() : 'Invoice Ninja' }}</title>
<title>@yield('meta_title', '') {{ auth()->guard('contact')->user()->user->account->isPaid() ? auth()->guard('contact')->user()->company->present()->name() : 'Invoice Ninja' }}</title>
@endauth
@guest

View File

@ -11,7 +11,7 @@
@endpush
@section('body')
@livewire('required-client-info', ['fields' => method_exists($gateway, 'getClientRequiredFields') ? $gateway->getClientRequiredFields() : [], 'contact' => auth('contact')->user(), 'countries' => $countries, 'company' => $company])
@livewire('required-client-info', ['fields' => method_exists($gateway, 'getClientRequiredFields') ? $gateway->getClientRequiredFields() : [], 'contact' => auth()->guard('contact')->user(), 'countries' => $countries, 'company' => $company])
<div class="container mx-auto grid grid-cols-12 opacity-25 pointer-events-none" data-ref="gateway-container">
<div class="col-span-12 lg:col-span-6 lg:col-start-4 overflow-hidden bg-white shadow rounded-lg">

View File

@ -15,7 +15,7 @@
{{ ctrans('texts.approve') }}
</h3>
<div class="btn" data-clipboard-text="{{url("client/quote/{$key}")}}" aria-label="Copied!">
<div class="btn hidden md:block" data-clipboard-text="{{url("client/quote/{$key}")}}" aria-label="Copied!">
<div class="flex text-sm leading-6 font-medium text-gray-500">
<p class="mr-2">{{url("client/quote/{$key}")}}</p>
<p><img class="h-5 w-5" src="{{ asset('assets/clippy.svg') }}" alt="Copy to clipboard"></p>

View File

@ -35,12 +35,15 @@
{{ ctrans('texts.approved') }}
</h3>
<div class="btn" data-clipboard-text="{{url("client/quote/{$key}")}}" aria-label="Copied!">
@if($key)
<div class="btn hidden md:block" data-clipboard-text="{{url("client/quote/{$key}")}}" aria-label="Copied!">
<div class="flex text-sm leading-6 font-medium text-gray-500">
<p class="mr-2">{{url("client/quote/{$key}")}}</p>
<p><img class="h-5 w-5" src="{{ asset('assets/clippy.svg') }}" alt="Copy to clipboard"></p>
</div>
</div>
@endif
</div>
</div>
</div>
@ -56,12 +59,14 @@
{{ ctrans('texts.approved') }}
</h3>
<div class="btn" data-clipboard-text="{{url("client/quote/{$key}")}}" aria-label="Copied!">
@if($key)
<div class="btn hidden md:block" data-clipboard-text="{{url("client/quote/{$key}")}}" aria-label="Copied!">
<div class="flex text-sm leading-6 font-medium text-gray-500">
<p class="mr-2">{{url("client/quote/{$key}")}}</p>
<p><img class="h-5 w-5" src="{{ asset('assets/clippy.svg') }}" alt="Copy to clipboard"></p>
</div>
</div>
@endif
</div>
</div>
</div>
@ -76,12 +81,14 @@
{{ ctrans('texts.expired') }}
</h3>
<div class="btn" data-clipboard-text="{{url("client/quote/{$key}")}}" aria-label="Copied!">
@if($key)
<div class="btn hidden md:block" data-clipboard-text="{{url("client/quote/{$key}")}}" aria-label="Copied!">
<div class="flex text-sm leading-6 font-medium text-gray-500">
<p class="mr-2">{{url("client/quote/{$key}")}}</p>
<p><img class="h-5 w-5" src="{{ asset('assets/clippy.svg') }}" alt="Copy to clipboard"></p>
</div>
</div>
@endif
</div>
</div>
</div>

View File

@ -32,7 +32,7 @@
<!-- Title -->
@auth()
<title>@yield('meta_title', '') {{ auth('contact')->user()->user->account->isPaid() ? auth('contact')->user()->company->present()->name() : 'Invoice Ninja' }}</title>
<title>@yield('meta_title', '') {{ auth()->guard('contact')->user()->user->account->isPaid() ? auth()->guard('contact')->user()->company->present()->name() : 'Invoice Ninja' }}</title>
@endauth
@guest

View File

@ -18,7 +18,7 @@ Route::post('client/password/reset', 'Auth\ContactResetPasswordController@reset'
Route::get('view/{entity_type}/{invitation_key}', 'ClientPortal\EntityViewController@index')->name('client.entity_view');
Route::get('view/{entity_type}/{invitation_key}/password', 'ClientPortal\EntityViewController@password')->name('client.entity_view.password');
Route::post('view/{entity_type}/{invitation_key}/password', 'ClientPortal\EntityViewController@handlePassword');
Route::post('set_password', 'ClientPortal\EntityViewController@handlePasswordSet')->name('client.set_password');
Route::post('set_password', 'ClientPortal\EntityViewController@handlePasswordSet')->name('client.set_password')->middleware('domain_db');
Route::get('tmp_pdf/{hash}', 'ClientPortal\TempRouteController@index')->name('tmp_pdf');