1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00
invoiceninja/app/Models/Presenters/CompanyPresenter.php

114 lines
3.1 KiB
PHP
Raw Normal View History

<?php
2019-05-11 05:32:07 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
2019-05-11 05:32:07 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2019-05-11 05:32:07 +02:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2019-05-11 05:32:07 +02:00
*/
namespace App\Models\Presenters;
use App\Models\Country;
2019-01-27 00:22:57 +01:00
/**
* Class CompanyPresenter.
2019-01-27 00:22:57 +01:00
*/
class CompanyPresenter extends EntityPresenter
{
2019-01-27 00:22:57 +01:00
/**
* @return string
*/
public function name()
{
$settings = $this->entity->settings;
return $this->settings->name ?: ctrans('texts.untitled_account');
//return $this->entity->name ?: ctrans('texts.untitled_account');
}
public function logo($settings = null)
2019-09-04 03:45:53 +02:00
{
if (! $settings) {
$settings = $this->entity->settings;
}
2021-03-09 21:56:23 +01:00
if(strlen($settings->company_logo) >= 1 && (strpos($settings->company_logo, 'http') !== false))
2021-03-01 21:15:28 +01:00
return $settings->company_logo;
else if(strlen($settings->company_logo) >= 1)
return url('') . $settings->company_logo;
2021-03-01 12:00:07 +01:00
else
2021-06-21 07:01:15 +02:00
return asset('images/new_logo.png');
2021-03-01 12:00:07 +01:00
2019-09-04 03:45:53 +02:00
}
public function address($settings = null)
2019-08-21 06:29:07 +02:00
{
$str = '';
$company = $this->entity;
if (! $settings) {
$settings = $this->entity->settings;
}
if ($address1 = $settings->address1) {
$str .= e($address1).'<br/>';
}
if ($address2 = $settings->address2) {
$str .= e($address2).'<br/>';
}
if ($cityState = $this->getCompanyCityState($settings)) {
$str .= e($cityState).'<br/>';
}
2020-08-07 23:44:49 +02:00
if ($country = Country::find($settings->country_id)) {
$str .= e($country->name).'<br/>';
}
if ($settings->phone) {
$str .= ctrans('texts.work_phone').': '.e($settings->phone).'<br/>';
}
if ($settings->email) {
$str .= ctrans('texts.work_email').': '.e($settings->email).'<br/>';
}
return $str;
2019-08-21 06:29:07 +02:00
}
public function getCompanyCityState($settings = null)
{
if (! $settings) {
$settings = $this->entity->settings;
}
$country = Country::find($settings->country_id);
$swap = $country && $country->swap_postal_code;
$city = e($settings->city);
$state = e($settings->state);
$postalCode = e($settings->postal_code);
if ($city || $state || $postalCode) {
return $this->cityStateZip($city, $state, $postalCode, $swap);
} else {
return false;
}
}
2021-01-21 13:34:21 +01:00
2021-03-26 20:30:46 +01:00
public function getSpcQrCode($client_currency, $invoice_number, $balance_due_raw, $user_iban)
2021-01-21 13:34:21 +01:00
{
$settings = $this->entity->settings;
2021-06-21 07:01:15 +02:00
return
2021-01-21 13:34:21 +01:00
2021-03-26 20:21:47 +01:00
"SPC\n0200\n1\n{$user_iban}\nK\n{$this->name}\n{$settings->address1}\n{$settings->postal_code} {$settings->city}\n\n\nCH\n\n\n\n\n\n\n\n{$balance_due_raw}\n{$client_currency}\n\n\n\n\n\n\n\nNON\n\n{$invoice_number}\nEPD\n";
2021-01-21 13:34:21 +01:00
}
2021-05-06 06:39:18 +02:00
public function size()
{
return $this->entity->size ? $this->entity->size->name : '';
}
}