mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #8335 from turbo124/v5-develop
Fixes for React Settings Cast
This commit is contained in:
commit
3a9bd78789
28043
_ide_helper.php
28043
_ide_helper.php
File diff suppressed because it is too large
Load Diff
@ -13,8 +13,10 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
use App\Models\Backup;
|
use App\Models\Backup;
|
||||||
|
use App\Models\Client;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
|
use App\Models\GroupSetting;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
@ -76,41 +78,126 @@ class BackupUpdate extends Command
|
|||||||
//logos
|
//logos
|
||||||
Company::cursor()
|
Company::cursor()
|
||||||
->each(function ($company) {
|
->each(function ($company) {
|
||||||
$company_logo = $company->present()->logo();
|
$company_logo_path = $company->settings->company_logo;
|
||||||
|
|
||||||
if ($company_logo == 'https://invoicing.co/images/new_logo.png') {
|
if ($company_logo_path == 'https://invoicing.co/images/new_logo.png' || $company_logo_path == '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$logo = @file_get_contents($company_logo);
|
$logo = @file_get_contents($company_logo_path);
|
||||||
|
$extension = @pathinfo($company->settings->company_logo, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
if ($logo) {
|
if ($logo && $extension) {
|
||||||
$path = str_replace("https://objects.invoicing.co/", "", $company->present()->logo());
|
$path = "{$company->company_key}/{$company->company_key}.{$extension}";
|
||||||
$path = str_replace("https://v5-at-backup.us-southeast-1.linodeobjects.com/", "", $path);
|
|
||||||
|
|
||||||
Storage::disk($this->option('disk'))->put($path, $logo);
|
Storage::disk($this->option('disk'))->put($path, $logo);
|
||||||
|
|
||||||
|
$url = Storage::disk($this->option('disk'))->url($path);
|
||||||
|
|
||||||
|
nlog("Company - Moving {$company_logo_path} logo to {$this->option('disk')} final URL = {$url}}");
|
||||||
|
|
||||||
|
$settings = $company->settings;
|
||||||
|
$settings->company_logo = $url;
|
||||||
|
$company->settings = $settings;
|
||||||
|
;
|
||||||
|
$company->save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Client::withTrashed()
|
||||||
|
->whereNotNull('settings->company_logo')
|
||||||
|
->cursor()
|
||||||
|
->each(function ($client) {
|
||||||
|
$company_logo_path = $client->settings->company_logo;
|
||||||
|
|
||||||
|
$logo = @file_get_contents($company_logo_path);
|
||||||
|
$extension = @pathinfo($company_logo_path, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
if ($logo && $extension) {
|
||||||
|
$path = "{$client->company->company_key}/{$client->client_hash}.{$extension}";
|
||||||
|
|
||||||
|
Storage::disk($this->option('disk'))->put($path, $logo);
|
||||||
|
|
||||||
|
$url = Storage::disk($this->option('disk'))->url($path);
|
||||||
|
|
||||||
|
nlog("Client - Moving {$company_logo_path} logo to {$this->option('disk')} final URL = {$url}}");
|
||||||
|
|
||||||
|
$settings = $client->settings;
|
||||||
|
$settings->company_logo = $url;
|
||||||
|
$client->settings = $settings;
|
||||||
|
;
|
||||||
|
$client->saveQuietly();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
GroupSetting::withTrashed()
|
||||||
|
->whereNotNull('settings->company_logo')
|
||||||
|
->orWhere('settings->company_logo', '!=', '')
|
||||||
|
->cursor()
|
||||||
|
->each(function ($group) {
|
||||||
|
$company_logo_path = $group->settings->company_logo;
|
||||||
|
|
||||||
|
if (!$company_logo_path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$logo = @file_get_contents($company_logo_path);
|
||||||
|
$extension = @pathinfo($company_logo_path, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
if ($logo && $extension) {
|
||||||
|
$path = "{$group->company->company_key}/{$group->hashed_id}.{$extension}";
|
||||||
|
|
||||||
|
Storage::disk($this->option('disk'))->put($path, $logo);
|
||||||
|
|
||||||
|
$url = Storage::disk($this->option('disk'))->url($path);
|
||||||
|
|
||||||
|
nlog("Group - Moving {$company_logo_path} logo to {$this->option('disk')} final URL = {$url}}");
|
||||||
|
|
||||||
|
$settings = $group->settings;
|
||||||
|
$settings->company_logo = $url;
|
||||||
|
$group->settings = $settings;
|
||||||
|
;
|
||||||
|
$group->saveQuietly();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//documents
|
//documents
|
||||||
Document::cursor()
|
Document::cursor()
|
||||||
->each(function ($document) {
|
->each(function (Document $document) {
|
||||||
|
$doc_bin = false;
|
||||||
|
|
||||||
|
try {
|
||||||
$doc_bin = $document->getFile();
|
$doc_bin = $document->getFile();
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
nlog($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
if ($doc_bin) {
|
if ($doc_bin) {
|
||||||
Storage::disk($this->option('disk'))->put($document->url, $doc_bin);
|
Storage::disk($this->option('disk'))->put($document->url, $doc_bin);
|
||||||
|
|
||||||
|
$document->disk = $this->option('disk');
|
||||||
|
$document->saveQuietly();
|
||||||
|
|
||||||
|
nlog("Documents - Moving {$document->url} to {$this->option('disk')}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//backups
|
//backups
|
||||||
Backup::cursor()
|
Backup::whereNotNull('filename')
|
||||||
|
->where('filename', '!=', '')
|
||||||
|
->cursor()
|
||||||
->each(function ($backup) {
|
->each(function ($backup) {
|
||||||
|
|
||||||
$backup_bin = Storage::disk('s3')->get($backup->filename);
|
$backup_bin = Storage::disk('s3')->get($backup->filename);
|
||||||
|
|
||||||
if ($backup_bin) {
|
if ($backup_bin) {
|
||||||
Storage::disk($this->option('disk'))->put($backup->filename, $backup_bin);
|
Storage::disk($this->option('disk'))->put($backup->filename, $backup_bin);
|
||||||
|
|
||||||
|
nlog("Backups - Moving {$backup->filename} to {$this->option('disk')}");
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -163,10 +163,19 @@ class ImportController extends Controller
|
|||||||
$bestDelimiter = ' ';
|
$bestDelimiter = ' ';
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($delimiters as $delimiter) {
|
foreach ($delimiters as $delimiter) {
|
||||||
if (substr_count($csvfile, $delimiter) > $count) {
|
|
||||||
|
// if (substr_count($csvfile, $delimiter) > $count) {
|
||||||
|
// $count = substr_count($csvfile, $delimiter);
|
||||||
|
// $bestDelimiter = $delimiter;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (substr_count(strstr($csvfile,"\n",true), $delimiter) > $count) {
|
||||||
$count = substr_count($csvfile, $delimiter);
|
$count = substr_count($csvfile, $delimiter);
|
||||||
$bestDelimiter = $delimiter;
|
$bestDelimiter = $delimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return $bestDelimiter;
|
return $bestDelimiter;
|
||||||
}
|
}
|
||||||
|
@ -123,14 +123,20 @@ class BaseImport
|
|||||||
|
|
||||||
public function detectDelimiter($csvfile)
|
public function detectDelimiter($csvfile)
|
||||||
{
|
{
|
||||||
$delimiters = [',', '.', ';'];
|
$delimiters = [',', '.', ';', '|'];
|
||||||
$bestDelimiter = ' ';
|
$bestDelimiter = ',';
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($delimiters as $delimiter) {
|
foreach ($delimiters as $delimiter) {
|
||||||
if (substr_count($csvfile, $delimiter) > $count) {
|
// if (substr_count($csvfile, $delimiter) > $count) {
|
||||||
|
// $count = substr_count($csvfile, $delimiter);
|
||||||
|
// $bestDelimiter = $delimiter;
|
||||||
|
// }
|
||||||
|
if (substr_count(strstr($csvfile,"\n",true), $delimiter) > $count) {
|
||||||
$count = substr_count($csvfile, $delimiter);
|
$count = substr_count($csvfile, $delimiter);
|
||||||
$bestDelimiter = $delimiter;
|
$bestDelimiter = $delimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return $bestDelimiter;
|
return $bestDelimiter;
|
||||||
}
|
}
|
||||||
@ -659,10 +665,9 @@ class BaseImport
|
|||||||
//sort the array by key
|
//sort the array by key
|
||||||
$keys = $this->column_map[$entity_type];
|
$keys = $this->column_map[$entity_type];
|
||||||
ksort($keys);
|
ksort($keys);
|
||||||
nlog($keys);
|
|
||||||
|
|
||||||
$data = array_map(function ($row) use ($keys) {
|
$data = array_map(function ($row) use ($keys) {
|
||||||
nlog($row);
|
|
||||||
$row_count = count($row);
|
$row_count = count($row);
|
||||||
$key_count = count($keys);
|
$key_count = count($keys);
|
||||||
|
|
||||||
|
@ -178,6 +178,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
$this->export_data['company_users'] = $this->company->company_users()->without(['user','account'])->cursor()->map(function ($company_user) {
|
$this->export_data['company_users'] = $this->company->company_users()->without(['user','account'])->cursor()->map(function ($company_user) {
|
||||||
$company_user = $this->transformArrayOfKeys($company_user, ['company_id', 'account_id', 'user_id']);
|
$company_user = $this->transformArrayOfKeys($company_user, ['company_id', 'account_id', 'user_id']);
|
||||||
|
|
||||||
|
// return $company_user->makeHidden(['react_settings']);
|
||||||
return $company_user;
|
return $company_user;
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
|
@ -40,6 +40,6 @@ class UpdateContactLastLogin implements ShouldQueue
|
|||||||
$client_contact->last_login = now();
|
$client_contact->last_login = now();
|
||||||
$client_contact->client->last_login = now();
|
$client_contact->client->last_login = now();
|
||||||
|
|
||||||
$client_contact->save();
|
$client_contact->push();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
'updated_at' => 'timestamp',
|
'updated_at' => 'timestamp',
|
||||||
'created_at' => 'timestamp',
|
'created_at' => 'timestamp',
|
||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
|
'last_login' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $touches = [];
|
protected $touches = [];
|
||||||
|
@ -50,10 +50,13 @@ class RecurringService
|
|||||||
|
|
||||||
public function start()
|
public function start()
|
||||||
{
|
{
|
||||||
if ($this->recurring_entity->remaining_cycles == 0) {
|
if ($this->recurring_entity->remaining_cycles == 0 || $this->recurring_entity->is_deleted) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->recurring_entity->trashed())
|
||||||
|
$this->recurring_entity->restore();
|
||||||
|
|
||||||
$this->setStatus(RecurringInvoice::STATUS_ACTIVE);
|
$this->setStatus(RecurringInvoice::STATUS_ACTIVE);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -44,7 +44,7 @@ class CompanyUserTransformer extends EntityTransformer
|
|||||||
'permissions' => $company_user->permissions ?: '',
|
'permissions' => $company_user->permissions ?: '',
|
||||||
'notifications' => $company_user->notifications ? (object) $company_user->notifications : $blank_obj,
|
'notifications' => $company_user->notifications ? (object) $company_user->notifications : $blank_obj,
|
||||||
'settings' => $company_user->settings ? (object) $company_user->settings : $blank_obj,
|
'settings' => $company_user->settings ? (object) $company_user->settings : $blank_obj,
|
||||||
'react_settings' => $company_user->react_settings ? (object) $company_user->react_settings : $blank_obj,
|
'react_settings' => $company_user->react_settings ? $company_user->react_settings : [],
|
||||||
'is_owner' => (bool) $company_user->is_owner,
|
'is_owner' => (bool) $company_user->is_owner,
|
||||||
'is_admin' => (bool) $company_user->is_admin,
|
'is_admin' => (bool) $company_user->is_admin,
|
||||||
'is_locked' => (bool) $company_user->is_locked,
|
'is_locked' => (bool) $company_user->is_locked,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user