1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Merge pull request #6194 from turbo124/master

Minor fixes for resources
This commit is contained in:
David Bomba 2021-07-03 08:57:37 +10:00 committed by GitHub
commit d9ce3467ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 122 additions and 0 deletions

View File

@ -101,6 +101,7 @@ class ExportMigrations extends Command
'expenses' => $this->getExpenses(),
'tasks' => $this->getTasks(),
'documents' => $this->getDocuments(),
'ninja_tokens' => $this->getNinjaToken(),
];
$file = storage_path("migrations/{$fileName}.zip");

View File

@ -0,0 +1,82 @@
<?php
namespace App\Console\Commands;
use App\Libraries\Utils;
use App\Models\Company;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Auth;
class SyncAccounts extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ninja:sync-v5';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Sync accounts to v5 - (Hosted function only)';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if(!Utils::isNinjaProd())
return;
config(['database.default' => DB_NINJA_1]);
$this->updateAccounts();
config(['database.default' => DB_NINJA_2]);
$this->updateAccounts();
}
private function updateAccounts()
{
$data = [];
$a = Company::whereIn('plan', ['pro', 'enterprise'])
->with('accounts')
->cursor()->each(function ($company) use ($data){
$accounts = $company->accounts->pluck('account_key');
$data[] = [
'plan' => $company->plan,
'plan_term' => $company->plan_term,
'plan_started' => $company->plan_started,
'plan_paid' => $company->plan_paid,
'plan_expires' => $company->plan_expires,
'num_users' => $company->num_users,
'accounts' => $accounts
];
});
//post DATA
}
}

View File

@ -32,6 +32,7 @@ class Kernel extends ConsoleKernel
'App\Console\Commands\CalculatePayouts',
'App\Console\Commands\UpdateKey',
'App\Console\Commands\ExportMigrations',
'App\Console\Commands\SyncAccounts',
];
/**
@ -55,5 +56,15 @@ class Kernel extends ConsoleKernel
->command('ninja:send-reminders --force')
->sendOutputTo($logFile)
->daily();
if(Utils::isNinjaProd())
{
$schedule
->command('ninja:sync-v5')
->withoutOverlapping()
->daily();
}
}
}

View File

@ -631,6 +631,8 @@ if (! defined('APP_NAME')) {
define('INVOICE_FIELDS_PRODUCT', 'product_fields');
define('INVOICE_FIELDS_TASK', 'task_fields');
define('NINJA_V5_TOKEN', env('NINJA_V5_TOKEN',false));
$creditCards = [
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'],

View File

@ -245,9 +245,35 @@ info("get company");
'schedule_reminder3' => $this->buildReminderString($this->account->direction_reminder3, $this->account->field_reminder3),
'endless_reminder_frequency_id' => $this->account->account_email_settings->reset_counter_frequency_id ? $this->transformFrequencyId($this->account->account_email_settings->reset_counter_frequency_id) : 0,
'email_signature' => $this->account->email_footer ?: '',
'email_style' => $this->getEmailStyle($this->account->email_design_id),
'custom_message_dashboard' => $this->account->customMessage('dashboard'),
'custom_message_unpaid_invoice' => $this->account->customMessage('unpaid_invoice'),
'custom_message_paid_invoice' => $this->account->customMessage('paid_invoice'),
'custom_message_unapproved_quote' => $this->account->customMessage('unapproved_quote'),
];
}
private function getEmailStyle($id){
switch ($id) {
case 1:
return 'plain';
break;
case 2:
return 'light';
break;
case 3:
return 'dark';
break;
default:
return 'light';
break;
}
}
private function buildReminderString($direction, $field)
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB