mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 18:34:30 -04:00
Support for custom fields in company details section
This commit is contained in:
parent
d15c9d23ca
commit
7c01b3bb64
@ -137,6 +137,10 @@ class Design extends BaseDesign
|
|||||||
$elements[] = ['element' => 'p', 'content' => $variable, 'show_empty' => false, 'properties' => ['data-ref' => 'company_details-' . substr($variable, 1)]];
|
$elements[] = ['element' => 'p', 'content' => $variable, 'show_empty' => false, 'properties' => ['data-ref' => 'company_details-' . substr($variable, 1)]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (['company1', 'company2', 'company3', 'company4'] as $field) {
|
||||||
|
$elements[] = ['element' => 'p', 'content' => $this->getCustomFieldValue($field), 'show_empty' => false, 'properties' => ['data-ref' => 'company_details-' . $field]];
|
||||||
|
}
|
||||||
|
|
||||||
return $elements;
|
return $elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +12,7 @@
|
|||||||
|
|
||||||
namespace App\Services\PdfMaker\Designs\Utilities;
|
namespace App\Services\PdfMaker\Designs\Utilities;
|
||||||
|
|
||||||
use App\Models\Task;
|
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Carbon\Carbon;
|
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use DOMXPath;
|
use DOMXPath;
|
||||||
use Exception;
|
use Exception;
|
||||||
@ -273,4 +271,35 @@ trait DesignHelpers
|
|||||||
array_splice($this->context['pdf_variables']["{$type}_columns"], $key + 1, 0, $custom_columns);
|
array_splice($this->context['pdf_variables']["{$type}_columns"], $key + 1, 0, $custom_columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCustomFieldValue(string $field): string
|
||||||
|
{
|
||||||
|
// In custom_fields column we store fields like: company1-4,
|
||||||
|
// while in settings, they're stored in custom_value1-4 format.
|
||||||
|
// That's why we need this mapping.
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'company1' => 'custom_value1',
|
||||||
|
'company2' => 'custom_value2',
|
||||||
|
'company3' => 'custom_value3',
|
||||||
|
'company4' => 'custom_value4',
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!array_key_exists($field, $fields)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!property_exists($this->client->company->custom_fields, $field)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = $this->client->company->getSetting($fields[$field]);
|
||||||
|
|
||||||
|
return (new \App\Utils\Helpers)->formatCustomFieldValue(
|
||||||
|
$this->client->company->custom_fields,
|
||||||
|
$field,
|
||||||
|
$value,
|
||||||
|
$this->client
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user