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

Merge pull request #4009 from turbo124/v2

Fixes for demo mode
This commit is contained in:
David Bomba 2020-08-23 19:22:43 +10:00 committed by GitHub
commit 0b34fd0738
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 253 additions and 146 deletions

View File

@ -70,6 +70,31 @@ class DemoMode extends Command
{
set_time_limit(0);
$cached_tables = config('ninja.cached_tables');
foreach ($cached_tables as $name => $class) {
if (! Cache::has($name)) {
// check that the table exists in case the migration is pending
if (! Schema::hasTable((new $class())->getTable())) {
continue;
}
if ($name == 'payment_terms') {
$orderBy = 'num_days';
} elseif ($name == 'fonts') {
$orderBy = 'sort_order';
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
$orderBy = 'name';
} else {
$orderBy = 'id';
}
$tableData = $class::orderBy($orderBy)->get();
if ($tableData->count()) {
Cache::forever($name, $tableData);
}
}
}
$this->info("Migrating");
Artisan::call('migrate:fresh --force');
@ -257,7 +282,7 @@ class DemoMode extends Command
'company_id' => $company->id
]);
factory(\App\Models\ClientContact::class, 1)->create([
factory(\App\Models\ClientContact::class)->create([
'user_id' => $user->id,
'client_id' => $client->id,
'company_id' => $company->id,
@ -301,7 +326,7 @@ class DemoMode extends Command
]);
factory(\App\Models\VendorContact::class, 1)->create([
factory(\App\Models\VendorContact::class)->create([
'user_id' => $client->user->id,
'vendor_id' => $vendor->id,
'company_id' => $client->company_id,

View File

@ -151,7 +151,14 @@ class EmailTemplateDefaults
public static function emailPaymentTemplate()
{
return Parsedown::instance()->line(self::transformText('payment_message'));
$converter = new CommonMarkConverter([
'html_input' => 'strip',
'allow_unsafe_links' => false,
]);
return $converter->convertToHtml(self::transformText('payment_message'));
// return Parsedown::instance()->line(self::transformText('payment_message'));
}
public static function emailReminder1Subject()

View File

@ -667,7 +667,7 @@ class QuoteController extends BaseController
//return response()->download(TempFile::path($quote->pdf_file_path()), basename($quote->pdf_file_path()));
break;
case 'archive':
$this->invoice_repo->archive($quote);
$this->quote_repo->archive($quote);
return $this->listResponse($quote);
break;
case 'delete':

View File

@ -34,7 +34,7 @@ class ProductController extends BaseController
*/
public function index(Request $request)
{
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first();
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->firstOrFail();
if(!$company->enable_shop_api)
return response()->json(['message' => 'Shop is disabled', 'errors' => new \stdClass],403);
@ -46,7 +46,7 @@ class ProductController extends BaseController
public function show(Request $request, string $product_key)
{
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first();
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->firstOrFail();
if(!$company->enable_shop_api)
return response()->json(['message' => 'Shop is disabled', 'errors' => new \stdClass],403);

View File

@ -0,0 +1,66 @@
<?php
namespace App\Observers;
use App\Models\CompanyGateway;
class CompanyGatewayObserver
{
/**
* Handle the company gateway "created" event.
*
* @param \App\CompanyGateway $company_gateway
* @return void
*/
public function created(CompanyGateway $company_gateway)
{
if(!$company_gateway->label){
$company_gateway->label = $company_gateway->gateway->name;
$company_gateway->save();
}
}
/**
* Handle the company gateway "updated" event.
*
* @param \App\CompanyGateway $company_gateway
* @return void
*/
public function updated(CompanyGateway $company_gateway)
{
//
}
/**
* Handle the company gateway "deleted" event.
*
* @param \App\CompanyGateway $company_gateway
* @return void
*/
public function deleted(CompanyGateway $company_gateway)
{
//
}
/**
* Handle the company gateway "restored" event.
*
* @param \App\CompanyGateway $company_gateway
* @return void
*/
public function restored(CompanyGateway $company_gateway)
{
//
}
/**
* Handle the company gateway "force deleted" event.
*
* @param \App\CompanyGateway $company_gateway
* @return void
*/
public function forceDeleted(CompanyGateway $company_gateway)
{
//
}
}

View File

@ -15,6 +15,7 @@ use App\Helpers\Language\DecoratedTranslator;
use App\Models\Account;
use App\Models\Client;
use App\Models\Company;
use App\Models\CompanyGateway;
use App\Models\CompanyToken;
use App\Models\Expense;
use App\Models\Invoice;
@ -26,6 +27,7 @@ use App\Models\Task;
use App\Models\User;
use App\Observers\AccountObserver;
use App\Observers\ClientObserver;
use App\Observers\CompanyGatewayObserver;
use App\Observers\CompanyObserver;
use App\Observers\CompanyTokenObserver;
use App\Observers\ExpenseObserver;
@ -68,6 +70,7 @@ class AppServiceProvider extends ServiceProvider
Account::observe(AccountObserver::class);
Client::observe(ClientObserver::class);
Company::observe(CompanyObserver::class);
CompanyGateway::observe(CompanyGatewayObserver::class);
CompanyToken::observe(CompanyTokenObserver::class);
Expense::observe(ExpenseObserver::class);
Invoice::observe(InvoiceObserver::class);

View File

@ -122,8 +122,8 @@ class HtmlEngine
$data['$number'] = ['value' => $this->entity->number ?: '&nbsp;', 'label' => ctrans('texts.invoice_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: '&nbsp;', 'label' => ctrans('texts.invoice_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
$data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
$data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
// $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
}
@ -132,8 +132,8 @@ class HtmlEngine
$data['$number'] = ['value' => $this->entity->number ?: '&nbsp;', 'label' => ctrans('texts.quote_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: '&nbsp;', 'label' => ctrans('texts.quote_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.view_quote')];
$data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_quote')];
$data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.view_quote')];
// $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_quote')];
}
if ($this->entity_string == 'credit') {
@ -141,8 +141,8 @@ class HtmlEngine
$data['$number'] = ['value' => $this->entity->number ?: '&nbsp;', 'label' => ctrans('texts.credit_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: '&nbsp;', 'label' => ctrans('texts.credit_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_credit').'</a>', 'label' => ctrans('texts.view_credit')];
$data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_credit')];
$data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_credit').'</a>', 'label' => ctrans('texts.view_credit')];
// $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_credit')];
}
$data['$entity_number'] = &$data['$number'];

View File

@ -215,8 +215,8 @@ trait MakesInvoiceValues
$data['$number'] = ['value' => $this->number ?: '&nbsp;', 'label' => ctrans('texts.invoice_number')];
$data['$entity.terms'] = ['value' => $this->terms ?: '&nbsp;', 'label' => ctrans('texts.invoice_terms')];
$data['$terms'] = &$data['$entity.terms'];
//$data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
$data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
$data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
// $data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
}
if ($this instanceof Quote) {
@ -224,8 +224,8 @@ trait MakesInvoiceValues
$data['$number'] = ['value' => $this->number ?: '&nbsp;', 'label' => ctrans('texts.quote_number')];
$data['$entity.terms'] = ['value' => $this->terms ?: '&nbsp;', 'label' => ctrans('texts.quote_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.view_quote')];
$data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_quote')];
$data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.view_quote')];
// $data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_quote')];
}
if ($this instanceof Credit) {
@ -233,8 +233,8 @@ trait MakesInvoiceValues
$data['$number'] = ['value' => $this->number ?: '&nbsp;', 'label' => ctrans('texts.credit_number')];
$data['$entity.terms'] = ['value' => $this->terms ?: '&nbsp;', 'label' => ctrans('texts.credit_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_credit').'</a>', 'label' => ctrans('texts.view_credit')];
$data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_credit')];
$data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_credit').'</a>', 'label' => ctrans('texts.view_credit')];
// $data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_credit')];
}
$data['$entity_number'] = &$data['$number'];

View File

@ -24,7 +24,13 @@ class AddIsPublicToDocumentsTable extends Migration
Schema::table('company_gateways', function (Blueprint $table) {
$table->enum('token_billing', ['off', 'always','optin','optout'])->default('off');
$table->string('label', 255)->nullable();
});
Schema::table('payments', function (Blueprint $table) {
$table->text('meta')->nullable();
});
}
/**

256
package-lock.json generated

File diff suppressed because it is too large Load Diff