Merge pull request #5112 from turbo124/v5-stable

5.1.22
This commit is contained in:
David Bomba 2021-03-13 15:20:43 +11:00 committed by GitHub
commit c0b6d1e490
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 76 additions and 34 deletions

View File

@ -1 +1 @@
5.1.21 5.1.22

View File

@ -27,14 +27,9 @@ class StoreSetupRequest extends Request
public function rules() public function rules()
{ {
return [ $rules = [
/*System*/ /*System*/
'url' => 'required', 'url' => 'required',
/*Database*/
'db_host' => 'required',
'db_database' => 'required',
'db_username' => 'required',
'db_password' => '',
/*Mail driver*/ /*Mail driver*/
'mail_driver' => 'required', 'mail_driver' => 'required',
'encryption' => 'required_unless:mail_driver,log', 'encryption' => 'required_unless:mail_driver,log',
@ -51,6 +46,18 @@ class StoreSetupRequest extends Request
'email' => 'required|email:rfc,dns', 'email' => 'required|email:rfc,dns',
'password' => 'required', 'password' => 'required',
]; ];
if ( ! config( 'ninja.preconfigured_install' ) ) {
$rules = array_merge( $rules, [
/*Database*/
'db_host' => 'required',
'db_database' => 'required',
'db_username' => 'required',
'db_password' => '',
] );
}
return $rules;
} }
protected function prepareForValidation() protected function prepareForValidation()

View File

@ -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;
} }

View File

@ -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
);
}
} }

View File

@ -99,10 +99,13 @@ trait MakesDates
public function translateDate($date, $format, $locale) public function translateDate($date, $format, $locale)
{ {
Carbon::setLocale($locale); Carbon::setLocale($locale);
try {
return Carbon::parse($date)->translatedFormat($format); return Carbon::parse($date)->translatedFormat($format);
} catch(\Exception $e) {
return 'Invalid date!';
}
} }
} }

View File

@ -13,7 +13,7 @@ return [
'require_https' => env('REQUIRE_HTTPS', true), 'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', ''), 'app_domain' => env('APP_DOMAIN', ''),
'app_version' => '5.1.21', 'app_version' => '5.1.22',
'minimum_client_version' => '5.0.16', 'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1', 'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false), 'api_secret' => env('API_SECRET', false),

View File

@ -154,8 +154,7 @@
<div id="body"> <div id="body">
<div class="header-wrapper"> <div class="header-wrapper">
<p>$company.name</p> <div id="company-details"></div>
<div id="company-address"></div> <div id="company-address"></div>
<div> <div>