mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
refactor
This commit is contained in:
parent
5b7be30612
commit
de0bebcd2c
@ -58,16 +58,21 @@ class ContactForgotPasswordController extends Controller
|
||||
*/
|
||||
public function showLinkRequestForm(Request $request)
|
||||
{
|
||||
$account_id = $request->has('account_id') ? $request->get('account_id') : 1;
|
||||
$account = Account::find($account_id);
|
||||
|
||||
if($request->has('company_key'))
|
||||
// $account_id = $request->has('account_id') ? $request->get('account_id') : 1;
|
||||
// $account = Account::find($account_id);
|
||||
$account = false;
|
||||
|
||||
if(Ninja::isHosted() && $request->has('company_key'))
|
||||
{
|
||||
MultiDB::findAndSetDbByCompanyKey($request->input('company_key'));
|
||||
$company = Company::where('company_key', $request->input('company_key'))->first();
|
||||
else
|
||||
$company = $account->companies->first();
|
||||
$account = $company->first();
|
||||
}
|
||||
|
||||
if(!$account)
|
||||
if(!$account){
|
||||
$account = Account::first();
|
||||
$company = $account->companies->first();
|
||||
}
|
||||
|
||||
return $this->render('auth.passwords.request', [
|
||||
'title' => 'Client Password Reset',
|
||||
@ -95,10 +100,7 @@ class ContactForgotPasswordController extends Controller
|
||||
|
||||
$this->validateEmail($request);
|
||||
|
||||
// $user = MultiDB::hasContact($request->input('email'));
|
||||
$company = Company::where('company_key', $request->input('company_key'))->first();
|
||||
//$contact = MultiDB::findContact(['company_id' => $company->id, 'email' => $request->input('email')]);
|
||||
nlog(['company_id' => $company->id, 'email' => $request->input('email')]);
|
||||
$contact = ClientContact::where(['company_id' => $company->id, 'email' => $request->input('email')])->first();
|
||||
|
||||
$response = false;
|
||||
|
@ -68,10 +68,22 @@ class ContactResetPasswordController extends Controller
|
||||
*/
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
{
|
||||
$account_id = $request->has('account_id') ? $request->get('account_id') : 1;
|
||||
$account = Account::find($account_id);
|
||||
$db = $account->companies->first()->db;
|
||||
$company = $account->companies->first();
|
||||
|
||||
if($request->has('company_key')){
|
||||
MultiDB::findAndSetDbByCompanyKey($request->input('company_key'));
|
||||
$company = Company::where('company_key', $request->input('company_key'))->first();
|
||||
$db = $company->db;
|
||||
$account = $company->account;
|
||||
}
|
||||
else {
|
||||
|
||||
$account_id = $request->has('account_id') ? $request->get('account_id') : 1;
|
||||
$account = Account::find($account_id);
|
||||
$db = $account->companies->first()->db;
|
||||
$company = $account->companies->first();
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->render('auth.passwords.reset')->with(
|
||||
['token' => $token, 'email' => $request->email, 'account' => $account, 'db' => $db, 'company' => $company]
|
||||
|
@ -79,8 +79,15 @@ class ForgotPasswordController extends Controller
|
||||
|
||||
public function showLinkRequestForm(Request $request)
|
||||
{
|
||||
$account_id = $request->get('account_id');
|
||||
$account = Account::find($account_id);
|
||||
if($request->has('company_key')){
|
||||
MultiDB::findAndSetDbByCompanyKey($request->input('company_key'));
|
||||
$company = Company::where('company_key', $request->input('company_key'))->first();
|
||||
$account = $company->account;
|
||||
}
|
||||
else{
|
||||
$account_id = $request->get('account_id');
|
||||
$account = Account::find($account_id);
|
||||
}
|
||||
|
||||
return $this->render('auth.passwords.request', ['root' => 'themes', 'account' => $account]);
|
||||
}
|
||||
|
@ -53,8 +53,11 @@ class ResetPasswordController extends Controller
|
||||
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
{
|
||||
$account_id = $request->get('account_id');
|
||||
$account = Account::find($account_id);
|
||||
// $account_id = $request->get('account_id');
|
||||
// $account = Account::find($account_id);
|
||||
MultiDB::findAndSetDbByCompanyKey($request->input('company_key'));
|
||||
$company = Company::where('company_key', $request->input('company_key'))->first();
|
||||
$account = $company->account;
|
||||
|
||||
return $this->render('auth.passwords.reset', ['root' => 'themes', 'token' => $token, 'account' => $account]);
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ class InvoiceController extends Controller
|
||||
*/
|
||||
public function index(ShowInvoicesRequest $request)
|
||||
{
|
||||
// $request->request->remove('account_id');
|
||||
// $request->request->remove('company_key');
|
||||
|
||||
return $this->render('invoices.index');
|
||||
}
|
||||
|
||||
@ -77,7 +80,7 @@ class InvoiceController extends Controller
|
||||
if ($request->query('mode') === 'fullscreen') {
|
||||
return render('invoices.show-fullscreen', $data);
|
||||
}
|
||||
|
||||
// $request->fullUrlWithQuery(['q' => null]);
|
||||
return $this->render('invoices.show', $data);
|
||||
}
|
||||
|
||||
@ -189,9 +192,9 @@ class InvoiceController extends Controller
|
||||
if ($invoices->count() == 1) {
|
||||
$invoice = $invoices->first();
|
||||
$invitation = $invoice->invitations->first();
|
||||
//$file = $invoice->pdf_file_path($invitation);
|
||||
|
||||
$file = $invoice->service()->getInvoicePdf(auth()->user());
|
||||
// return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);;
|
||||
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file), ['Content-Type' => 'application/pdf']);
|
||||
|
@ -40,9 +40,9 @@ class ApiSecretCheck
|
||||
];
|
||||
|
||||
return response()
|
||||
->json($error, 403)
|
||||
->header('X-App-Version', config('ninja.app_version'))
|
||||
->header('X-Minimum-Client-Version', config('ninja.minimum_client_version'));
|
||||
->json($error, 403)
|
||||
->header('X-App-Version', config('ninja.app_version'))
|
||||
->header('X-Minimum-Client-Version', config('ninja.minimum_client_version'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ class ContactAccount
|
||||
|
||||
if(!Ninja::isHosted()) {
|
||||
|
||||
$account_id = Account::first()->id;
|
||||
$request->request->add(['account_id' => $account_id]);
|
||||
$account = Account::first();
|
||||
$request->merge(['account_id' => $account->id, 'account_key' => $account->key]);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,13 @@
|
||||
<?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\Http\Middleware;
|
||||
|
||||
|
@ -50,7 +50,8 @@ class SetDomainNameDb
|
||||
];
|
||||
|
||||
if($company = MultiDB::findAndSetDbByDomain($query)){
|
||||
$request->request->add(['account_id' => $company->account_id, 'company_key' => $company->company_key]);
|
||||
$request->merge(['company_key' => $company->company_key]);
|
||||
// $request->merge(['account_id' => $company->account_id, 'company_key' => $company->company_key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -72,7 +73,8 @@ class SetDomainNameDb
|
||||
];
|
||||
|
||||
if($company = MultiDB::findAndSetDbByDomain($query)){
|
||||
$request->request->add(['account_id' => $company->account_id, 'company_key' => $company->company_key]);
|
||||
$request->merge(['company_key' => $company->company_key]);
|
||||
//$request->merge(['account_id' => $company->account_id, 'company_key' => $company->company_key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -81,7 +83,6 @@ class SetDomainNameDb
|
||||
} else {
|
||||
MultiDB::setDb('db-ninja-01');
|
||||
nlog("I could not set the DB - defaulting to DB1");
|
||||
//abort(400, 'Domain not found');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,6 +283,9 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
{
|
||||
$date_formats = Cache::get('date_formats');
|
||||
|
||||
if(!$date_formats)
|
||||
$this->buildCache(true);
|
||||
|
||||
return $date_formats->filter(function ($item) {
|
||||
return $item->id == $this->getSetting('date_format_id');
|
||||
})->first()->format;
|
||||
|
Loading…
x
Reference in New Issue
Block a user