mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-05 04:34:36 -04:00
Fixes for deleting a company. (#3454)
* Fix for typo * wind back self updater repo * fixes for client settings * Add current version to the account transformer * fixes for deleting a company
This commit is contained in:
parent
2e76341e18
commit
d60c179da7
@ -34,7 +34,7 @@ class CompanyFactory
|
|||||||
//$company->custom_fields = (object) ['invoice1' => '1', 'invoice2' => '2', 'client1'=>'3'];
|
//$company->custom_fields = (object) ['invoice1' => '1', 'invoice2' => '2', 'client1'=>'3'];
|
||||||
$company->custom_fields = (object) [];
|
$company->custom_fields = (object) [];
|
||||||
$company->subdomain = '';
|
$company->subdomain = '';
|
||||||
$company->enabled_modules = 2047;
|
$company->enabled_modules = 4096;
|
||||||
|
|
||||||
return $company;
|
return $company;
|
||||||
}
|
}
|
||||||
|
@ -479,10 +479,10 @@ class CompanyController extends BaseController
|
|||||||
$company->delete();
|
$company->delete();
|
||||||
|
|
||||||
//If we are deleting the default companies, we'll need to make a new company the default.
|
//If we are deleting the default companies, we'll need to make a new company the default.
|
||||||
if($account->default_company == $company_id){
|
if($account->default_company_id == $company_id){
|
||||||
|
|
||||||
$account->fresh();
|
$new_default_company = Company::whereAccountId($account->id)->first();
|
||||||
$account->default_company = $account->companies->first()->id();
|
$account->default_company_id = $new_default_company->id;
|
||||||
$account->save();
|
$account->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ use Hashids\Hashids;
|
|||||||
use Illuminate\Contracts\Translation\HasLocalePreference;
|
use Illuminate\Contracts\Translation\HasLocalePreference;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
use Laracasts\Presenter\PresentableTrait;
|
use Laracasts\Presenter\PresentableTrait;
|
||||||
|
|
||||||
@ -272,9 +271,9 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
*/
|
*/
|
||||||
public function getSetting($setting)
|
public function getSetting($setting)
|
||||||
{
|
{
|
||||||
/*Client Settings*/
|
|
||||||
if ($this->settings && (property_exists($this->settings, $setting) !== false) && (isset($this->settings->{$setting}) !== false)) {
|
|
||||||
|
|
||||||
|
/*Client Settings*/
|
||||||
|
if ($this->settings && property_exists($this->settings, $setting) && isset($this->settings->{$setting}) ) {
|
||||||
/*need to catch empty string here*/
|
/*need to catch empty string here*/
|
||||||
if (is_string($this->settings->{$setting}) && (iconv_strlen($this->settings->{$setting}) >=1)) {
|
if (is_string($this->settings->{$setting}) && (iconv_strlen($this->settings->{$setting}) >=1)) {
|
||||||
return $this->settings->{$setting};
|
return $this->settings->{$setting};
|
||||||
@ -287,7 +286,7 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Company Settings*/
|
/*Company Settings*/
|
||||||
if ((property_exists($this->company->settings, $setting) != false) && (isset($this->company->settings->{$setting}) !== false)) {
|
else if ((property_exists($this->company->settings, $setting) != false) && (isset($this->company->settings->{$setting}) !== false)) {
|
||||||
return $this->company->settings->{$setting};
|
return $this->company->settings->{$setting};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,10 +467,11 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
|
|
||||||
public function setCompanyDefaults($data, $entity_name)
|
public function setCompanyDefaults($data, $entity_name)
|
||||||
{
|
{
|
||||||
if(isset($data['terms']) && strlen($data['terms']) == 0)
|
|
||||||
|
if(!(array_key_exists('terms', $data) && strlen($data['terms']) > 1))
|
||||||
$data['terms'] = $this->getSetting($entity_name.'_terms');
|
$data['terms'] = $this->getSetting($entity_name.'_terms');
|
||||||
|
|
||||||
if(isset($data['footer']) && strlen($data['footer']) == 0)
|
if(!(array_key_exists('footer', $data) && strlen($data['footer']) > 1))
|
||||||
$data['footer'] = $this->getSetting($entity_name.'_footer');
|
$data['footer'] = $this->getSetting($entity_name.'_footer');
|
||||||
|
|
||||||
if(strlen($this->public_notes) >=1)
|
if(strlen($this->public_notes) >=1)
|
||||||
|
@ -60,8 +60,9 @@ class Company extends BaseModel
|
|||||||
const ENTITY_VENDOR = 'vendor';
|
const ENTITY_VENDOR = 'vendor';
|
||||||
const ENTITY_TICKET = 'ticket';
|
const ENTITY_TICKET = 'ticket';
|
||||||
const ENTITY_PROPOSAL = 'proposal';
|
const ENTITY_PROPOSAL = 'proposal';
|
||||||
const ENTITY_RECURRING_EXPENSE = 'expense';
|
const ENTITY_RECURRING_EXPENSE = 'recurring_expense';
|
||||||
const ENTITY_RECURRING_TASK = 'task';
|
const ENTITY_RECURRING_TASK = 'task';
|
||||||
|
const ENTITY_RECURRING_QUOTE = 'recurring_quote';
|
||||||
|
|
||||||
protected $presenter = 'App\Models\Presenters\CompanyPresenter';
|
protected $presenter = 'App\Models\Presenters\CompanyPresenter';
|
||||||
|
|
||||||
@ -124,6 +125,7 @@ class Company extends BaseModel
|
|||||||
self::ENTITY_PROPOSAL => 256,
|
self::ENTITY_PROPOSAL => 256,
|
||||||
self::ENTITY_RECURRING_EXPENSE => 512,
|
self::ENTITY_RECURRING_EXPENSE => 512,
|
||||||
self::ENTITY_RECURRING_TASK => 1024,
|
self::ENTITY_RECURRING_TASK => 1024,
|
||||||
|
self::ENTITY_RECURRING_QUOTE => 2048,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getCompanyIdAttribute()
|
public function getCompanyIdAttribute()
|
||||||
|
@ -34,6 +34,7 @@ class CompanyUser extends Pivot
|
|||||||
'created_at' => 'timestamp',
|
'created_at' => 'timestamp',
|
||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
'settings' => 'object',
|
'settings' => 'object',
|
||||||
|
'notifications' => 'object',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
@ -61,6 +61,7 @@ class AccountTransformer extends EntityTransformer
|
|||||||
'default_url' => config('ninja.site_url'),
|
'default_url' => config('ninja.site_url'),
|
||||||
'plan' => $account->getPlan(),
|
'plan' => $account->getPlan(),
|
||||||
'latest_version' => (string)$account->latest_version,
|
'latest_version' => (string)$account->latest_version,
|
||||||
|
'current_version' => (string)config('ninja.app_version'),
|
||||||
'updated_at' => (int)$account->updated_at,
|
'updated_at' => (int)$account->updated_at,
|
||||||
'archived_at' => (int)$account->deleted_at,
|
'archived_at' => (int)$account->deleted_at,
|
||||||
];
|
];
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
"php": ">=7.3",
|
"php": ">=7.3",
|
||||||
"anahkiasen/former": "^4.2",
|
"anahkiasen/former": "^4.2",
|
||||||
"asgrim/ofxparser": "^1.2",
|
"asgrim/ofxparser": "^1.2",
|
||||||
"codedge/laravel-selfupdater": "^2.4",
|
"codedge/laravel-selfupdater": "^2.5.1",
|
||||||
"dacastro4/laravel-gmail": "^3.2",
|
"dacastro4/laravel-gmail": "^3.2",
|
||||||
"davejamesmiller/laravel-breadcrumbs": "5.x",
|
"davejamesmiller/laravel-breadcrumbs": "5.x",
|
||||||
"fideloper/proxy": "^4.0",
|
"fideloper/proxy": "^4.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user