2018-11-02 11:54:46 +01:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2018-11-02 11:54:46 +01:00
|
|
|
|
|
|
|
namespace App\Models\Presenters;
|
|
|
|
|
2019-12-16 12:34:38 +01:00
|
|
|
use App\Models\Country;
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class CompanyPresenter.
|
2019-01-27 00:22:57 +01:00
|
|
|
*/
|
2018-11-02 11:54:46 +01:00
|
|
|
class CompanyPresenter extends EntityPresenter
|
|
|
|
{
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-11-02 11:54:46 +01:00
|
|
|
public function name()
|
|
|
|
{
|
2020-02-05 05:06:03 +01:00
|
|
|
$settings = $this->entity->settings;
|
|
|
|
|
|
|
|
return $this->settings->name ?: ctrans('texts.untitled_account');
|
|
|
|
|
|
|
|
//return $this->entity->name ?: ctrans('texts.untitled_account');
|
2018-11-02 11:54:46 +01:00
|
|
|
}
|
|
|
|
|
2019-12-16 12:34:38 +01:00
|
|
|
public function logo($settings = null)
|
2019-09-04 03:45:53 +02:00
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! $settings) {
|
2019-12-16 12:34:38 +01:00
|
|
|
$settings = $this->entity->settings;
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-12-16 12:34:38 +01:00
|
|
|
|
2020-06-18 01:25:08 +02:00
|
|
|
return (strlen($settings->company_logo) > 0) ? $settings->company_logo : 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png';
|
2019-09-04 03:45:53 +02:00
|
|
|
}
|
|
|
|
|
2019-12-16 12:34:38 +01:00
|
|
|
public function address($settings = null)
|
2019-08-21 06:29:07 +02:00
|
|
|
{
|
2019-08-21 23:46:11 +02:00
|
|
|
$str = '';
|
|
|
|
$company = $this->entity;
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! $settings) {
|
2019-12-16 12:34:38 +01:00
|
|
|
$settings = $this->entity->settings;
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-12-16 12:34:38 +01:00
|
|
|
|
|
|
|
if ($address1 = $settings->address1) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$str .= e($address1).'<br/>';
|
2019-08-21 23:46:11 +02:00
|
|
|
}
|
2019-12-16 12:34:38 +01:00
|
|
|
if ($address2 = $settings->address2) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$str .= e($address2).'<br/>';
|
2019-08-21 23:46:11 +02:00
|
|
|
}
|
2019-12-16 12:34:38 +01:00
|
|
|
if ($cityState = $this->getCompanyCityState($settings)) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$str .= e($cityState).'<br/>';
|
2019-08-21 23:46:11 +02:00
|
|
|
}
|
2020-08-07 23:44:49 +02:00
|
|
|
if ($country = Country::find($settings->country_id)) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$str .= e($country->name).'<br/>';
|
2019-08-21 23:46:11 +02:00
|
|
|
}
|
2019-12-16 12:34:38 +01:00
|
|
|
if ($settings->phone) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$str .= ctrans('texts.work_phone').': '.e($settings->phone).'<br/>';
|
2019-08-21 23:46:11 +02:00
|
|
|
}
|
2019-12-16 12:34:38 +01:00
|
|
|
if ($settings->email) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$str .= ctrans('texts.work_email').': '.e($settings->email).'<br/>';
|
2019-08-21 23:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $str;
|
2019-08-21 06:29:07 +02:00
|
|
|
}
|
|
|
|
|
2019-12-16 12:34:38 +01:00
|
|
|
public function getCompanyCityState($settings = null)
|
2019-10-04 14:37:40 +02:00
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! $settings) {
|
2019-12-16 12:34:38 +01:00
|
|
|
$settings = $this->entity->settings;
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-12-16 12:34:38 +01:00
|
|
|
|
|
|
|
$country = Country::find($settings->country_id)->first();
|
2019-10-04 14:37:40 +02:00
|
|
|
|
2019-12-16 12:34:38 +01:00
|
|
|
$swap = $country && $country->swap_postal_code;
|
2019-10-04 14:37:40 +02:00
|
|
|
|
2019-12-16 12:34:38 +01:00
|
|
|
$city = e($settings->city);
|
|
|
|
$state = e($settings->state);
|
|
|
|
$postalCode = e($settings->postal_code);
|
2019-10-04 14:37:40 +02:00
|
|
|
|
|
|
|
if ($city || $state || $postalCode) {
|
|
|
|
return $this->cityStateZip($city, $state, $postalCode, $swap);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2018-11-02 11:54:46 +01:00
|
|
|
}
|