mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #4623 from beganovich/v5-setup-add-db-port
(v5) Add support for database port on setup page
This commit is contained in:
commit
98975f7319
@ -12,6 +12,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use \Illuminate\Support\Facades\DB;
|
||||
use App\Http\Requests\Setup\CheckDatabaseRequest;
|
||||
use App\Http\Requests\Setup\CheckMailRequest;
|
||||
use App\Http\Requests\Setup\StoreSetupRequest;
|
||||
@ -22,7 +23,6 @@ use App\Utils\CurlUtils;
|
||||
use App\Utils\SystemHealth;
|
||||
use App\Utils\Traits\AppSetup;
|
||||
use Beganovich\Snappdf\Snappdf;
|
||||
use DB;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
@ -55,7 +55,7 @@ class SetupController extends Controller
|
||||
{
|
||||
try {
|
||||
$check = SystemHealth::check(false);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
nlog(['message' => $e->getMessage(), 'action' => 'SetupController::doSetup()']);
|
||||
|
||||
return response()->json(['message' => $e->getMessage()], 400);
|
||||
@ -71,9 +71,9 @@ class SetupController extends Controller
|
||||
$db = SystemHealth::dbCheck($request);
|
||||
|
||||
if ($db['success'] == false) {
|
||||
throw new \Exception($db['message']);
|
||||
throw new Exception($db['message']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return response([
|
||||
'message' => 'Oops, connection to database was not successful.',
|
||||
'error' => $e->getMessage(),
|
||||
@ -85,10 +85,10 @@ class SetupController extends Controller
|
||||
$smtp = SystemHealth::testMailServer($request);
|
||||
|
||||
if ($smtp['success'] == false) {
|
||||
throw new \Exception($smtp['message']);
|
||||
throw new Exception($smtp['message']);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return response([
|
||||
'message' => 'Oops, connection to mail server was not successful.',
|
||||
'error' => $e->getMessage(),
|
||||
@ -100,9 +100,10 @@ class SetupController extends Controller
|
||||
$env_values = [
|
||||
'APP_URL' => $request->input('url'),
|
||||
'REQUIRE_HTTPS' => $request->input('https') ? 'true' : 'false',
|
||||
'APP_DEBUG' => $request->input('debug') ? 'true' : 'false',
|
||||
'APP_DEBUG' => 'false',
|
||||
|
||||
'DB_HOST1' => $request->input('db_host'),
|
||||
'DB_PORT1' => $request->input('db_port'),
|
||||
'DB_DATABASE1' => $request->input('db_database'),
|
||||
'DB_USERNAME1' => $request->input('db_username'),
|
||||
'DB_PASSWORD1' => $request->input('db_password'),
|
||||
@ -173,7 +174,7 @@ class SetupController extends Controller
|
||||
}
|
||||
|
||||
return response($status, 400);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
nlog(['message' => $e->getMessage(), 'action' => 'SetupController::checkDB()']);
|
||||
|
||||
return response()->json(['message' => $e->getMessage()], 400);
|
||||
@ -203,17 +204,6 @@ class SetupController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
private function failsafeMailCheck($request)
|
||||
{
|
||||
$response = SystemHealth::testMailServer($request);
|
||||
|
||||
if ($response['success']) {
|
||||
true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkPdf(Request $request)
|
||||
{
|
||||
try {
|
||||
@ -231,9 +221,10 @@ class SetupController extends Controller
|
||||
->setHtml('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!')
|
||||
->generate();
|
||||
|
||||
Storage::put('public/test.pdf', $pdf);
|
||||
Storage::disk(config('filesystems.default'))->put('test.pdf', $pdf);
|
||||
Storage::disk('local')->put('test.pdf', $pdf);
|
||||
|
||||
return response(['url' => asset('test.pdf')], 200);
|
||||
return response(['url' => Storage::disk('local')->url('test.pdf')], 200);
|
||||
} catch (Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
|
||||
|
@ -49,16 +49,13 @@ class ActionInvoiceRequest extends Request
|
||||
|
||||
if (!array_key_exists('action', $input)) {
|
||||
$this->error_msg = 'Action is a required field';
|
||||
}
|
||||
elseif(!$this->invoiceDeletable($this->invoice)){
|
||||
} elseif (!$this->invoiceDeletable($this->invoice)) {
|
||||
unset($input['action']);
|
||||
$this->error_msg = 'This invoice cannot be deleted';
|
||||
}
|
||||
elseif(!$this->invoiceCancellable($this->invoice)) {
|
||||
} elseif (!$this->invoiceCancellable($this->invoice)) {
|
||||
unset($input['action']);
|
||||
$this->error_msg = 'This invoice cannot be cancelled';
|
||||
}
|
||||
else if(!$this->invoiceReversable($this->invoice)) {
|
||||
} elseif (!$this->invoiceReversable($this->invoice)) {
|
||||
unset($input['action']);
|
||||
$this->error_msg = 'This invoice cannot be reversed';
|
||||
}
|
||||
@ -72,9 +69,4 @@ class ActionInvoiceRequest extends Request
|
||||
'action' => $this->error_msg,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ class CheckDatabaseRequest extends Request
|
||||
{
|
||||
return [
|
||||
'db_host' => ['required'],
|
||||
'db_port' => ['required'],
|
||||
'db_database' => ['required'],
|
||||
'db_username' => ['required'],
|
||||
];
|
||||
|
@ -16,7 +16,6 @@ use App\Libraries\MultiDB;
|
||||
use App\Models\RecurringInvoice;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RecurringInvoicesCron
|
||||
{
|
||||
|
@ -464,19 +464,16 @@ class Import implements ShouldQueue
|
||||
$client->fresh();
|
||||
$new_contacts = $client->contacts;
|
||||
|
||||
foreach($resource['contacts'] as $key => $old_contact)
|
||||
{
|
||||
foreach ($resource['contacts'] as $key => $old_contact) {
|
||||
$contact_match = $new_contacts->where('contact_key', $old_contact['contact_key'])->first();
|
||||
|
||||
if($contact_match)
|
||||
{
|
||||
if ($contact_match) {
|
||||
$this->ids['client_contacts']['client_contacts_'.$old_contact['id']] = [
|
||||
'old' => $old_contact['id'],
|
||||
'new' => $contact_match->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$key = "clients_{$resource['id']}";
|
||||
@ -629,16 +626,12 @@ class Import implements ShouldQueue
|
||||
|
||||
unset($modified['id']);
|
||||
|
||||
if(array_key_exists('invitations', $resource))
|
||||
{
|
||||
foreach($resource['invitations'] as $key => $invite)
|
||||
{
|
||||
|
||||
if (array_key_exists('invitations', $resource)) {
|
||||
foreach ($resource['invitations'] as $key => $invite) {
|
||||
$resource['invitations'][$key]['client_contact_id'] = $this->transformId('client_contacts', $invite['client_contact_id']);
|
||||
$resource['invitations'][$key]['user_id'] = $modified['user_id'];
|
||||
$resource['invitations'][$key]['company_id'] = $this->company->id;
|
||||
unset($resource['invitations'][$key]['recurring_invoice_id']);
|
||||
|
||||
}
|
||||
|
||||
$modified['invitations'] = $resource['invitations'];
|
||||
@ -694,19 +687,15 @@ class Import implements ShouldQueue
|
||||
|
||||
unset($modified['id']);
|
||||
|
||||
if(array_key_exists('invitations', $resource))
|
||||
{
|
||||
foreach($resource['invitations'] as $key => $invite)
|
||||
{
|
||||
if (array_key_exists('invitations', $resource)) {
|
||||
foreach ($resource['invitations'] as $key => $invite) {
|
||||
$resource['invitations'][$key]['client_contact_id'] = $this->transformId('client_contacts', $invite['client_contact_id']);
|
||||
$resource['invitations'][$key]['user_id'] = $modified['user_id'];
|
||||
$resource['invitations'][$key]['company_id'] = $this->company->id;
|
||||
unset($resource['invitations'][$key]['invoice_id']);
|
||||
|
||||
}
|
||||
|
||||
$modified['invitations'] = $resource['invitations'];
|
||||
|
||||
}
|
||||
$invoice = $invoice_repository->save(
|
||||
$modified,
|
||||
@ -877,7 +866,7 @@ class Import implements ShouldQueue
|
||||
PaymentFactory::create($this->company->id, $modified['user_id'])
|
||||
);
|
||||
|
||||
if($resource['company_gateway_id'] != 'NULL' && $resource['company_gateway_id'] != NULL){
|
||||
if ($resource['company_gateway_id'] != 'NULL' && $resource['company_gateway_id'] != null) {
|
||||
$payment->company_gateway_id = $this->transformId('company_gateways', $resource['company_gateway_id']);
|
||||
$payment->save();
|
||||
}
|
||||
|
@ -23,8 +23,9 @@ class ClientContactPresenter extends EntityPresenter
|
||||
{
|
||||
$contact_name = $this->entity->first_name.' '.$this->entity->last_name;
|
||||
|
||||
if(strlen($contact_name) > 1)
|
||||
if (strlen($contact_name) > 1) {
|
||||
return $contact_name;
|
||||
}
|
||||
|
||||
return $this->entity->client->present()->name();
|
||||
}
|
||||
|
@ -376,8 +376,9 @@ class RecurringInvoice extends BaseModel
|
||||
|
||||
$data = [];
|
||||
|
||||
if(!Carbon::parse($this->next_send_date))
|
||||
if (!Carbon::parse($this->next_send_date)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$next_send_date = Carbon::parse($this->next_send_date)->copy();
|
||||
|
||||
|
@ -123,8 +123,8 @@ use App\Listeners\Invoice\InvoiceArchivedActivity;
|
||||
use App\Listeners\Invoice\InvoiceCancelledActivity;
|
||||
use App\Listeners\Invoice\InvoiceDeletedActivity;
|
||||
use App\Listeners\Invoice\InvoiceEmailActivity;
|
||||
use App\Listeners\Invoice\InvoiceEmailFailedActivity;
|
||||
use App\Listeners\Invoice\InvoiceEmailedNotification;
|
||||
use App\Listeners\Invoice\InvoiceEmailFailedActivity;
|
||||
use App\Listeners\Invoice\InvoicePaidActivity;
|
||||
use App\Listeners\Invoice\InvoiceReminderEmailActivity;
|
||||
use App\Listeners\Invoice\InvoiceRestoredActivity;
|
||||
@ -132,8 +132,8 @@ use App\Listeners\Invoice\InvoiceReversedActivity;
|
||||
use App\Listeners\Invoice\InvoiceViewedActivity;
|
||||
use App\Listeners\Invoice\UpdateInvoiceActivity;
|
||||
use App\Listeners\Misc\InvitationViewedListener;
|
||||
use App\Listeners\Payment\PaymentEmailFailureActivity;
|
||||
use App\Listeners\Payment\PaymentEmailedActivity;
|
||||
use App\Listeners\Payment\PaymentEmailFailureActivity;
|
||||
use App\Listeners\Payment\PaymentNotification;
|
||||
use App\Listeners\Payment\PaymentRestoredActivity;
|
||||
use App\Listeners\Quote\QuoteApprovedActivity;
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@ -37,7 +36,6 @@ class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
//
|
||||
parent::boot();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,11 +92,11 @@ class InvoiceMigrationRepository extends BaseRepository
|
||||
InvoiceInvitation::unguard();
|
||||
RecurringInvoiceInvitation::unguard();
|
||||
|
||||
if($model instanceof RecurringInvoice)
|
||||
if ($model instanceof RecurringInvoice) {
|
||||
$lcfirst_resource_id = 'recurring_invoice_id';
|
||||
}
|
||||
|
||||
foreach($data['invitations'] as $invitation)
|
||||
{
|
||||
foreach ($data['invitations'] as $invitation) {
|
||||
nlog($invitation);
|
||||
|
||||
$new_invitation = $invitation_factory_class::create($model->company_id, $model->user_id);
|
||||
|
@ -63,8 +63,7 @@ class UserRepository extends BaseRepository
|
||||
$user->fill($details);
|
||||
|
||||
//allow users to change only their passwords - not others!
|
||||
if(auth()->user()->id == $user->id && array_key_exists('password', $data) && isset($data['password']))
|
||||
{
|
||||
if (auth()->user()->id == $user->id && array_key_exists('password', $data) && isset($data['password'])) {
|
||||
$user->password = Hash::make($data['password']);
|
||||
}
|
||||
|
||||
|
@ -152,6 +152,7 @@ class SystemHealth
|
||||
|
||||
if ($request) {
|
||||
config(['database.connections.db-ninja-01.host' => $request->input('db_host')]);
|
||||
config(['database.connections.db-ninja-01.port' => $request->input('db_port')]);
|
||||
config(['database.connections.db-ninja-01.database' => $request->input('db_database')]);
|
||||
config(['database.connections.db-ninja-01.username' => $request->input('db_username')]);
|
||||
config(['database.connections.db-ninja-01.password' => $request->input('db_password')]);
|
||||
|
@ -629,7 +629,6 @@ trait GeneratesCounter
|
||||
}
|
||||
|
||||
if ($entity->client || ($entity instanceof Client)) {
|
||||
|
||||
$client = $entity->client ?: $entity;
|
||||
|
||||
$search[] = '{$client_custom1}';
|
||||
|
@ -3,8 +3,6 @@
|
||||
use App\Models\Currency;
|
||||
use App\Utils\Traits\AppSetup;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateCanadianDollarSymbol extends Migration
|
||||
{
|
||||
@ -18,8 +16,9 @@ class UpdateCanadianDollarSymbol extends Migration
|
||||
{
|
||||
$currency = Currency::find(9);
|
||||
|
||||
if($currency)
|
||||
if ($currency) {
|
||||
$currency->update(['symbol' => '$']);
|
||||
}
|
||||
|
||||
$this->buildCache(true);
|
||||
}
|
||||
|
2
public/js/setup/setup.js
vendored
2
public/js/setup/setup.js
vendored
File diff suppressed because one or more lines are too long
@ -15,6 +15,6 @@
|
||||
"/js/clients/quotes/approve.js": "/js/clients/quotes/approve.js?id=85bcae0a646882e56b12",
|
||||
"/js/clients/shared/multiple-downloads.js": "/js/clients/shared/multiple-downloads.js?id=5c35d28cf0a3286e7c45",
|
||||
"/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=fa54bb4229aba6b0817c",
|
||||
"/js/setup/setup.js": "/js/setup/setup.js?id=29e88ab480038cba57df",
|
||||
"/js/setup/setup.js": "/js/setup/setup.js?id=8cb5e2bb0d404725c20a",
|
||||
"/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ad"
|
||||
}
|
||||
|
5
resources/js/setup/setup.js
vendored
5
resources/js/setup/setup.js
vendored
@ -25,6 +25,7 @@ class Setup {
|
||||
handleDatabaseCheck() {
|
||||
let data = {
|
||||
db_host: document.querySelector('input[name="db_host"]').value,
|
||||
db_port: document.querySelector('input[name="db_port"]').value,
|
||||
db_database: document.querySelector('input[name="db_database"]')
|
||||
.value,
|
||||
db_username: document.querySelector('input[name="db_username"]')
|
||||
@ -33,13 +34,15 @@ class Setup {
|
||||
.value,
|
||||
};
|
||||
|
||||
this.checkDbButton.disabled = true;
|
||||
|
||||
Axios.post('/setup/check_db', data)
|
||||
.then((response) =>
|
||||
this.handleSuccess(this.checkDbAlert, 'mail-wrapper')
|
||||
)
|
||||
.catch((e) =>
|
||||
this.handleFailure(this.checkDbAlert, e.response.data.message)
|
||||
);
|
||||
).finally(() => this.checkDbButton.disabled = false);
|
||||
}
|
||||
|
||||
handleSmtpCheck() {
|
||||
|
@ -32,16 +32,6 @@
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
{{ ctrans('texts.debug') }}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<input type="checkbox" class="form-checkbox mr-1" name="debug" {{ old('debug') ? 'checked': '' }}>
|
||||
<span>{{ ctrans('texts.enable') }}</span>
|
||||
<span class="text-gray-600 text-xs ml-2">({{ ctrans('texts.enable_only_for_development') }})</span>
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
{{ ctrans('texts.reports') }}
|
||||
</dt>
|
||||
@ -53,14 +43,14 @@
|
||||
about how we use this.</a>
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
<button type="button" class="button button-primary bg-blue-600 py-2 px-3 text-xs" id="test-pdf">
|
||||
{{ ctrans('texts.test_pdf') }}
|
||||
</button>
|
||||
</dt>
|
||||
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<div class="alert py-2 bg-gray-50" id="test-pdf-response"></div>
|
||||
<div class="alert py-2 bg-white" id="test-pdf-response"></div>
|
||||
</dd>
|
||||
<a target="_blank" class="block text-sm text-gray-900 leading-5 underline"
|
||||
href="https://invoiceninja.github.io/selfhost.html#phantom-js">
|
||||
|
@ -42,6 +42,14 @@ FLUSH PRIVILEGES;
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
{{ ctrans('texts.port') }}*
|
||||
</dt>
|
||||
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<input type="text" class="input w-full" name="db_port" required value="{{ old('db_port') ?: '3306'}}">
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
{{ ctrans('texts.database') }}*
|
||||
</dt>
|
||||
@ -49,15 +57,15 @@ FLUSH PRIVILEGES;
|
||||
<input type="text" class="input w-full" name="db_database" required value="{{ old('database') ?: 'db-ninja-01'}}">
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500" value="{{ old('username') }}">
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
{{ ctrans('texts.username') }}*
|
||||
</dt>
|
||||
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<input type="text" class="input w-full" name="db_username" required value="{{ old('db_username') ?: 'ninja' }}">
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
{{ ctrans('texts.password') }}
|
||||
</dt>
|
||||
@ -65,14 +73,14 @@ FLUSH PRIVILEGES;
|
||||
<input type="password" class="input w-full" name="db_password" value="{{ old('db_password') ?: 'ninja' }}">
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
<button type="button" class="button button-primary bg-blue-600 py-2 px-3 text-xs" id="test-db-connection">
|
||||
{{ ctrans('texts.test_connection') }}
|
||||
</button>
|
||||
</dt>
|
||||
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<div class="alert py-2 bg-gray-50" id="database-response"></div>
|
||||
<div class="alert py-2 bg-white" id="database-response"></div>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
@ -57,7 +57,6 @@ class PreviewTest extends TestCase
|
||||
])->post('/api/v1/preview?html=true', $data);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user