location brought from model
This commit is contained in:
parent
414e405168
commit
6154ff31fd
@ -31,10 +31,6 @@ abstract class DocumentTemplate extends Base
|
|||||||
|
|
||||||
public $logo;
|
public $logo;
|
||||||
|
|
||||||
public $companyLocation;
|
|
||||||
|
|
||||||
public $contactLocation;
|
|
||||||
|
|
||||||
public $backgroundColor;
|
public $backgroundColor;
|
||||||
|
|
||||||
public $hideFooter;
|
public $hideFooter;
|
||||||
@ -127,7 +123,7 @@ abstract class DocumentTemplate extends Base
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$type, $document, $item = false, $documentTemplate = '', $logo = '', $backgroundColor = '', $companyLocation = '', $contactLocation = '',
|
$type, $document, $item = false, $documentTemplate = '', $logo = '', $backgroundColor = '',
|
||||||
bool $hideFooter = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false,
|
bool $hideFooter = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false,
|
||||||
bool $hideCompanyName = false, bool $hideCompanyAddress = false, bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false, bool $hideContactInfo = false,
|
bool $hideCompanyName = false, bool $hideCompanyAddress = false, bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false, bool $hideContactInfo = false,
|
||||||
bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false, bool $hideContactPhone = false, bool $hideContactEmail = false,
|
bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false, bool $hideContactPhone = false, bool $hideContactEmail = false,
|
||||||
@ -143,8 +139,6 @@ abstract class DocumentTemplate extends Base
|
|||||||
$this->documentTemplate = $this->getDocumentTemplate($type, $documentTemplate);
|
$this->documentTemplate = $this->getDocumentTemplate($type, $documentTemplate);
|
||||||
$this->logo = $this->getLogo($logo);
|
$this->logo = $this->getLogo($logo);
|
||||||
$this->backgroundColor = $this->getBackgroundColor($type, $backgroundColor);
|
$this->backgroundColor = $this->getBackgroundColor($type, $backgroundColor);
|
||||||
$this->companyLocation = $this->getCompanyLocation();
|
|
||||||
$this->contactLocation = $this->getContactLocation($document);
|
|
||||||
|
|
||||||
$this->hideFooter = $hideFooter;
|
$this->hideFooter = $hideFooter;
|
||||||
$this->hideCompanyLogo = $hideCompanyLogo;
|
$this->hideCompanyLogo = $hideCompanyLogo;
|
||||||
@ -652,50 +646,4 @@ abstract class DocumentTemplate extends Base
|
|||||||
// @todo what return value invoice or always false??
|
// @todo what return value invoice or always false??
|
||||||
return setting('invoice.hide_amount', $hideAmount);
|
return setting('invoice.hide_amount', $hideAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getCompanyLocation()
|
|
||||||
{
|
|
||||||
$location = [];
|
|
||||||
|
|
||||||
if (setting('company.city')) {
|
|
||||||
$location[] = setting('company.city');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setting('company.zip_code')) {
|
|
||||||
$location[] = setting('company.zip_code');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setting('company.state')) {
|
|
||||||
$location[] = setting('company.state');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setting('company.country')) {
|
|
||||||
$location[] = trans('countries.' . setting('company.country'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode(', ', $location);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getContactLocation($document)
|
|
||||||
{
|
|
||||||
$location = [];
|
|
||||||
|
|
||||||
if ($document->contact->city) {
|
|
||||||
$location[] = $document->contact->city;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($document->contact->zip_code) {
|
|
||||||
$location[] = $document->contact->zip_code;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($document->contact->state) {
|
|
||||||
$location[] = $document->contact->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($document->contact->country) {
|
|
||||||
$location[] = trans('countries.' . $document->contact->country);
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode(', ', $location);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,13 @@ class Company extends Eloquent implements Ownable
|
|||||||
|
|
||||||
protected $table = 'companies';
|
protected $table = 'companies';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The accessors to append to the model's array form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $appends = ['location'];
|
||||||
|
|
||||||
protected $dates = ['deleted_at'];
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
protected $fillable = ['domain', 'enabled', 'created_by'];
|
protected $fillable = ['domain', 'enabled', 'created_by'];
|
||||||
@ -446,6 +453,29 @@ class Company extends Eloquent implements Ownable
|
|||||||
return $this->getMedia('company.logo')->last();
|
return $this->getMedia('company.logo')->last();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLocationAttribute()
|
||||||
|
{
|
||||||
|
$location = [];
|
||||||
|
|
||||||
|
if (setting('company.city')) {
|
||||||
|
$location[] = setting('company.city');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setting('company.zip_code')) {
|
||||||
|
$location[] = setting('company.zip_code');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setting('company.state')) {
|
||||||
|
$location[] = setting('company.state');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setting('company.country')) {
|
||||||
|
$location[] = trans('countries.' . setting('company.country'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(', ', $location);
|
||||||
|
}
|
||||||
|
|
||||||
public function makeCurrent($force = false)
|
public function makeCurrent($force = false)
|
||||||
{
|
{
|
||||||
if (!$force && $this->isCurrent()) {
|
if (!$force && $this->isCurrent()) {
|
||||||
|
@ -19,6 +19,13 @@ class Contact extends Model
|
|||||||
|
|
||||||
protected $table = 'contacts';
|
protected $table = 'contacts';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The accessors to append to the model's array form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $appends = ['location'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attributes that should be mass-assignable.
|
* Attributes that should be mass-assignable.
|
||||||
*
|
*
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
{{ company.address }}
|
{{ company.address }}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="company_data.locations">
|
<tr v-if="company.location">
|
||||||
<th class="text-right p-0">
|
<th class="text-right p-0">
|
||||||
{{ company_data.locations }}
|
{{ company.location }}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="company.tax_number">
|
<tr v-if="company.tax_number">
|
||||||
@ -94,9 +94,6 @@ export default {
|
|||||||
default: {},
|
default: {},
|
||||||
description: 'Company object'
|
description: 'Company object'
|
||||||
},
|
},
|
||||||
countryText: {
|
|
||||||
type: [Array, Object],
|
|
||||||
},
|
|
||||||
companyForm: {
|
companyForm: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: function () {
|
default: function () {
|
||||||
@ -120,7 +117,6 @@ export default {
|
|||||||
buttons: this.companyForm.buttons,
|
buttons: this.companyForm.buttons,
|
||||||
},
|
},
|
||||||
company_html: '',
|
company_html: '',
|
||||||
company_data: this.company,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -247,27 +243,5 @@ export default {
|
|||||||
documentClasses.remove("modal-open");
|
documentClasses.remove("modal-open");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
|
||||||
let locations = [];
|
|
||||||
|
|
||||||
if (this.company.city) {
|
|
||||||
locations.push(this.company.city);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.company.zip_code) {
|
|
||||||
locations.push(this.company.zip_code);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.company.state) {
|
|
||||||
locations.push(this.company.state);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.company.country) {
|
|
||||||
locations.push(this.countryText[this.company.country])
|
|
||||||
}
|
|
||||||
|
|
||||||
this.company.locations = locations.join(', ');
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -88,9 +88,9 @@
|
|||||||
{{ contact.address }}
|
{{ contact.address }}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="contact.locations">
|
<tr v-if="contact.location">
|
||||||
<th class="p-0" style="text-align:left; white-space: normal;">
|
<th class="p-0" style="text-align:left; white-space: normal;">
|
||||||
{{ contact.locations }}
|
{{ contact.location }}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="contact.tax_number">
|
<tr v-if="contact.tax_number">
|
||||||
@ -197,7 +197,7 @@ export default {
|
|||||||
zip_code:'',
|
zip_code:'',
|
||||||
state:'',
|
state:'',
|
||||||
country:'',
|
country:'',
|
||||||
country_name:'',
|
location:'',
|
||||||
reference: ''
|
reference: ''
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -241,10 +241,6 @@ export default {
|
|||||||
default: 'Bill to',
|
default: 'Bill to',
|
||||||
description: ""
|
description: ""
|
||||||
},
|
},
|
||||||
countryText: {
|
|
||||||
type: [Array, Object],
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
taxNumberText: {
|
taxNumberText: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'Tax number',
|
default: 'Tax number',
|
||||||
@ -284,7 +280,6 @@ export default {
|
|||||||
buttons: this.addNew.buttons,
|
buttons: this.addNew.buttons,
|
||||||
},
|
},
|
||||||
add_new_html: '',
|
add_new_html: '',
|
||||||
country_text_data: this.countryText,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -315,7 +310,7 @@ export default {
|
|||||||
zip_code: '',
|
zip_code: '',
|
||||||
state: '',
|
state: '',
|
||||||
country: '',
|
country: '',
|
||||||
countryname: '',
|
location: '',
|
||||||
reference: ''
|
reference: ''
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -345,7 +340,7 @@ export default {
|
|||||||
zip_code: (contact.zip_code) ? contact.zip_code : '',
|
zip_code: (contact.zip_code) ? contact.zip_code : '',
|
||||||
state: (contact.state) ? contact.state : '',
|
state: (contact.state) ? contact.state : '',
|
||||||
country: (contact.country) ? contact.country : '',
|
country: (contact.country) ? contact.country : '',
|
||||||
country_name: (contact.country_name) ? contact.country_name : '',
|
location: (contact.location) ? contact.location : '',
|
||||||
reference: (contact.reference) ? contact.reference : ''
|
reference: (contact.reference) ? contact.reference : ''
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
@ -361,26 +356,6 @@ export default {
|
|||||||
this.contact_list.forEach(function (contact, index) {
|
this.contact_list.forEach(function (contact, index) {
|
||||||
if (contact_id == contact.id) {
|
if (contact_id == contact.id) {
|
||||||
this.contact = contact;
|
this.contact = contact;
|
||||||
|
|
||||||
let locations = [];
|
|
||||||
|
|
||||||
if (this.contact.city) {
|
|
||||||
locations.push(this.contact.city);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.contact.zip_code) {
|
|
||||||
locations.push(this.contact.zip_code);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.contact.state) {
|
|
||||||
locations.push(this.contact.state);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.contact.country) {
|
|
||||||
locations.push(this.country_text_data[this.contact.country]);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.contact.locations = locations.join(', ');
|
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
@ -616,7 +591,7 @@ export default {
|
|||||||
zip_code: '',
|
zip_code: '',
|
||||||
state: '',
|
state: '',
|
||||||
country: '',
|
country: '',
|
||||||
country_name: '',
|
location: '',
|
||||||
reference: ''
|
reference: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -641,30 +616,9 @@ export default {
|
|||||||
zip_code: (contact.zip_code) ? contact.zip_code : '',
|
zip_code: (contact.zip_code) ? contact.zip_code : '',
|
||||||
state: (contact.state) ? contact.state : '',
|
state: (contact.state) ? contact.state : '',
|
||||||
country: (contact.country) ? contact.country : '',
|
country: (contact.country) ? contact.country : '',
|
||||||
country_name: (contact.country_name) ? contact.country_name : '',
|
location: (contact.location) ? contact.location : '',
|
||||||
reference: (contact.reference) ? contact.reference : ''
|
reference: (contact.reference) ? contact.reference : ''
|
||||||
});
|
});
|
||||||
|
|
||||||
let locations = [];
|
|
||||||
|
|
||||||
if (contact.city) {
|
|
||||||
locations.push(contact.city);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contact.zip_code) {
|
|
||||||
locations.push(contact.zip_code);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contact.state) {
|
|
||||||
locations.push(contact.state);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contact.country) {
|
|
||||||
locations.push(this.country_text_data[contact.country])
|
|
||||||
}
|
|
||||||
|
|
||||||
this.contact.locations = locations.join(', ');
|
|
||||||
|
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
<akaunting-company-edit company-id="{{ company_id() }}"
|
<akaunting-company-edit company-id="{{ company_id() }}"
|
||||||
button-text="{{ trans('settings.company.edit_your_business_address') }}"
|
button-text="{{ trans('settings.company.edit_your_business_address') }}"
|
||||||
tax-number-text="{{ trans('general.tax_number') }}"
|
tax-number-text="{{ trans('general.tax_number') }}"
|
||||||
:country-text="{{ json_encode(trans('countries')) }}"
|
|
||||||
:company="{{ json_encode($company) }}"
|
:company="{{ json_encode($company) }}"
|
||||||
:company-form="{{ json_encode([
|
:company-form="{{ json_encode([
|
||||||
'show' => true,
|
'show' => true,
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<p>
|
<p>
|
||||||
{!! nl2br(setting('company.address')) !!}
|
{!! nl2br(setting('company.address')) !!}
|
||||||
<br>
|
<br>
|
||||||
{!! $companyLocation !!}
|
{!! $document->company->location !!}
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@ -115,7 +115,7 @@
|
|||||||
<p>
|
<p>
|
||||||
{!! nl2br($document->contact_address) !!}
|
{!! nl2br($document->contact_address) !!}
|
||||||
<br>
|
<br>
|
||||||
{!! $contactLocation !!}
|
{!! $document->contact->location !!}
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
@stack('address_input_end')
|
@stack('address_input_end')
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<p>
|
<p>
|
||||||
{!! nl2br(setting('company.address')) !!}
|
{!! nl2br(setting('company.address')) !!}
|
||||||
<br>
|
<br>
|
||||||
{!! $companyLocation !!}
|
{!! $document->company->location !!}
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@ -89,7 +89,7 @@
|
|||||||
<p>
|
<p>
|
||||||
{!! nl2br($document->contact_address) !!}
|
{!! nl2br($document->contact_address) !!}
|
||||||
<br>
|
<br>
|
||||||
{!! $contactLocation !!}
|
{!! $document->contact->location !!}
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
@stack('address_input_end')
|
@stack('address_input_end')
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<strong class="text-white">
|
<strong class="text-white">
|
||||||
{!! nl2br(setting('company.address')) !!}
|
{!! nl2br(setting('company.address')) !!}
|
||||||
<br>
|
<br>
|
||||||
{!! $companyLocation !!}
|
{!! $document->company->location !!}
|
||||||
</strong><br><br>
|
</strong><br><br>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@ -89,7 +89,7 @@
|
|||||||
@if (!$hideContactAddress)
|
@if (!$hideContactAddress)
|
||||||
{!! nl2br($document->contact_address) !!}
|
{!! nl2br($document->contact_address) !!}
|
||||||
<br>
|
<br>
|
||||||
{!! $contactLocation !!}
|
{!! $document->contact->location !!}
|
||||||
<br><br>
|
<br><br>
|
||||||
@endif
|
@endif
|
||||||
@stack('address_input_end')
|
@stack('address_input_end')
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
no-matching-data-text="{{ trans('general.no_matching_data') }}"
|
no-matching-data-text="{{ trans('general.no_matching_data') }}"
|
||||||
search-route="{{ $search_route }}"
|
search-route="{{ $search_route }}"
|
||||||
create-route="{{ $create_route }}"
|
create-route="{{ $create_route }}"
|
||||||
:country-text="{{ json_encode(trans('countries')) }}"
|
|
||||||
:contacts="{{ json_encode($contacts) }}"
|
:contacts="{{ json_encode($contacts) }}"
|
||||||
:selected="{{ json_encode($contact) }}"
|
:selected="{{ json_encode($contact) }}"
|
||||||
add-contact-text="{{ is_array($textAddContact) ? trans($textAddContact[0], ['field' => trans_choice($textAddContact[1], 1)]) : trans($textAddContact) }}"
|
add-contact-text="{{ is_array($textAddContact) ? trans($textAddContact[0], ['field' => trans_choice($textAddContact[1], 1)]) : trans($textAddContact) }}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user