address field detailed (city, zip_code, state, country)
This commit is contained in:
@@ -31,6 +31,10 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
public $logo;
|
||||
|
||||
public $companyLocation;
|
||||
|
||||
public $contactLocation;
|
||||
|
||||
public $backgroundColor;
|
||||
|
||||
public $hideFooter;
|
||||
@@ -123,7 +127,7 @@ abstract class DocumentTemplate extends Base
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$type, $document, $item = false, $documentTemplate = '', $logo = '', $backgroundColor = '',
|
||||
$type, $document, $item = false, $documentTemplate = '', $logo = '', $backgroundColor = '', $companyLocation = '', $contactLocation = '',
|
||||
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 $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false, bool $hideContactPhone = false, bool $hideContactEmail = false,
|
||||
@@ -139,6 +143,8 @@ abstract class DocumentTemplate extends Base
|
||||
$this->documentTemplate = $this->getDocumentTemplate($type, $documentTemplate);
|
||||
$this->logo = $this->getLogo($logo);
|
||||
$this->backgroundColor = $this->getBackgroundColor($type, $backgroundColor);
|
||||
$this->companyLocation = $this->getCompanyLocation();
|
||||
$this->contactLocation = $this->getContactLocation($document);
|
||||
|
||||
$this->hideFooter = $hideFooter;
|
||||
$this->hideCompanyLogo = $hideCompanyLogo;
|
||||
@@ -646,4 +652,50 @@ abstract class DocumentTemplate extends Base
|
||||
// @todo what return value invoice or always false??
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,11 @@ class Companies extends Controller
|
||||
case 'financial_start':
|
||||
$real_key = 'localisation.' . $key;
|
||||
break;
|
||||
case 'country':
|
||||
$countries = trans('countries');
|
||||
$value = array_search($value, $countries);
|
||||
$real_key = 'company.' . $key;
|
||||
break;
|
||||
default:
|
||||
$real_key = 'company.' . $key;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ class Wizard
|
||||
'logo' => trans('settings.company.logo'),
|
||||
'skip' => trans('general.skip'),
|
||||
'save' => trans('general.save'),
|
||||
'country' => trans_choice('addresses.countries', 1),
|
||||
],
|
||||
|
||||
'currencies' => [
|
||||
|
||||
@@ -100,6 +100,10 @@ class CreateCompany extends Job
|
||||
'company.tax_number' => $this->request->get('tax_number'),
|
||||
'company.phone' => $this->request->get('phone'),
|
||||
'company.address' => $this->request->get('address'),
|
||||
'company.city' => $this->request->get('city'),
|
||||
'company.zip_code' => $this->request->get('zip_code'),
|
||||
'company.state' => $this->request->get('state'),
|
||||
'company.country' => $this->request->get('country'),
|
||||
'default.currency' => $this->request->get('currency'),
|
||||
'default.locale' => $this->request->get('locale', 'en-GB'),
|
||||
]);
|
||||
|
||||
@@ -67,6 +67,22 @@ class UpdateCompany extends Job
|
||||
setting()->set('company.address', $this->request->get('address'));
|
||||
}
|
||||
|
||||
if ($this->request->has('city')) {
|
||||
setting()->set('company.city', $this->request->get('city'));
|
||||
}
|
||||
|
||||
if ($this->request->has('zip_code')) {
|
||||
setting()->set('company.zip_code', $this->request->get('zip_code'));
|
||||
}
|
||||
|
||||
if ($this->request->has('state')) {
|
||||
setting()->set('company.state', $this->request->get('state'));
|
||||
}
|
||||
|
||||
if ($this->request->has('country')) {
|
||||
setting()->set('company.country', $this->request->get('country'));
|
||||
}
|
||||
|
||||
if ($this->request->has('currency')) {
|
||||
setting()->set('default.currency', $this->request->get('currency'));
|
||||
}
|
||||
|
||||
30
app/Listeners/Update/V21/Version2124.php
Normal file
30
app/Listeners/Update/V21/Version2124.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\Update\V21;
|
||||
|
||||
use App\Abstracts\Listeners\Update as Listener;
|
||||
use App\Events\Install\UpdateFinished as Event;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class Version2124 extends Listener
|
||||
{
|
||||
const ALIAS = 'core';
|
||||
|
||||
const VERSION = '2.1.24';
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Event $event)
|
||||
{
|
||||
if ($this->skipThisUpdate($event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,10 @@ class Contact extends Model
|
||||
'tax_number',
|
||||
'phone',
|
||||
'address',
|
||||
'city',
|
||||
'zip_code',
|
||||
'state',
|
||||
'country',
|
||||
'website',
|
||||
'currency_code',
|
||||
'reference',
|
||||
@@ -188,6 +192,30 @@ class Contact extends Model
|
||||
return $amount;
|
||||
}
|
||||
|
||||
|
||||
public function getLocationAttribute()
|
||||
{
|
||||
$location = [];
|
||||
|
||||
if ($this->city) {
|
||||
$location[] = $this->city;
|
||||
}
|
||||
|
||||
if ($this->zip_code) {
|
||||
$location[] = $this->zip_code;
|
||||
}
|
||||
|
||||
if ($this->state) {
|
||||
$location[] = $this->state;
|
||||
}
|
||||
|
||||
if ($this->country) {
|
||||
$location[] = trans('countries.' . $this->country);
|
||||
}
|
||||
|
||||
return implode(', ', $location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user