mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improvements for showing required fields
This commit is contained in:
parent
108ca2633d
commit
50e211104d
@ -77,6 +77,8 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
/*Set the correct database*/
|
/*Set the correct database*/
|
||||||
MultiDB::setDb($this->nmo->company->db);
|
MultiDB::setDb($this->nmo->company->db);
|
||||||
|
|
||||||
|
nlog("nn");
|
||||||
|
|
||||||
/* Serializing models from other jobs wipes the primary key */
|
/* Serializing models from other jobs wipes the primary key */
|
||||||
$this->company = Company::query()->where('company_key', $this->nmo->company->company_key)->first();
|
$this->company = Company::query()->where('company_key', $this->nmo->company->company_key)->first();
|
||||||
|
|
||||||
@ -87,7 +89,6 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
if (!$this->company || $this->preFlightChecksFail()) {
|
if (!$this->company || $this->preFlightChecksFail()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run time we set Reply To Email*/
|
/* Run time we set Reply To Email*/
|
||||||
if (strlen($this->nmo->settings->reply_to_email) > 1) {
|
if (strlen($this->nmo->settings->reply_to_email) > 1) {
|
||||||
if (property_exists($this->nmo->settings, 'reply_to_name')) {
|
if (property_exists($this->nmo->settings, 'reply_to_name')) {
|
||||||
|
@ -79,7 +79,8 @@ class RequiredClientInfo extends Component
|
|||||||
public $client_custom_value2;
|
public $client_custom_value2;
|
||||||
public $client_custom_value3;
|
public $client_custom_value3;
|
||||||
public $client_custom_value4;
|
public $client_custom_value4;
|
||||||
|
private ?CompanyGateway $company_gateway;
|
||||||
|
private int $unfilled_fields = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mappings for updating the database. Left side is mapping from gateway,
|
* Mappings for updating the database. Left side is mapping from gateway,
|
||||||
@ -194,6 +195,7 @@ class RequiredClientInfo extends Component
|
|||||||
MultiDB::setDb($this->db);
|
MultiDB::setDb($this->db);
|
||||||
$contact = ClientContact::withTrashed()->find($this->contact_id);
|
$contact = ClientContact::withTrashed()->find($this->contact_id);
|
||||||
$company = $contact->company;
|
$company = $contact->company;
|
||||||
|
$this->company_gateway = CompanyGateway::withTrashed()->find($this->company_gateway_id);
|
||||||
|
|
||||||
$this->client_name = $contact->client->name;
|
$this->client_name = $contact->client->name;
|
||||||
$this->contact_first_name = $contact->first_name;
|
$this->contact_first_name = $contact->first_name;
|
||||||
@ -215,8 +217,6 @@ class RequiredClientInfo extends Component
|
|||||||
$this->client_custom_value3 = $contact->client->custom_value3;
|
$this->client_custom_value3 = $contact->client->custom_value3;
|
||||||
$this->client_custom_value4 = $contact->client->custom_value4;
|
$this->client_custom_value4 = $contact->client->custom_value4;
|
||||||
|
|
||||||
// $this->client = $this->contact->client;
|
|
||||||
|
|
||||||
if ($company->settings->show_accept_invoice_terms && request()->query('hash')) {
|
if ($company->settings->show_accept_invoice_terms && request()->query('hash')) {
|
||||||
$this->show_terms = true;
|
$this->show_terms = true;
|
||||||
$this->terms_accepted = false;
|
$this->terms_accepted = false;
|
||||||
@ -230,18 +230,12 @@ class RequiredClientInfo extends Component
|
|||||||
$this->invoice_terms = $invoice->terms;
|
$this->invoice_terms = $invoice->terms;
|
||||||
}
|
}
|
||||||
|
|
||||||
count($this->fields) > 0 || $this->show_terms
|
if(!$this->company_gateway->always_show_required_fields)
|
||||||
? $this->checkFields()
|
$this->checkFields();
|
||||||
: $this->show_form = false;
|
|
||||||
|
|
||||||
if (request()->query('source') === 'subscriptions') {
|
if($this->unfilled_fields > 0 || $this->company_gateway->always_show_required_fields)
|
||||||
$this->show_form = false;
|
$this->show_form = true;
|
||||||
|
|
||||||
$this->dispatch(
|
|
||||||
'passed-required-fields-check',
|
|
||||||
client_postal_code: $this->contact->client->postal_code
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Computed]
|
#[Computed]
|
||||||
@ -327,26 +321,26 @@ class RequiredClientInfo extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$_contact->first_name = $this->contact_first_name;
|
$_contact->first_name = $this->contact_first_name;
|
||||||
$_contact->last_name = $this->contact_last_name;
|
$_contact->last_name = $this->contact_last_name;
|
||||||
$_contact->client->name = $this->client_name;
|
$_contact->client->name = $this->client_name;
|
||||||
$_contact->email = $this->contact_email;
|
$_contact->email = $this->contact_email;
|
||||||
$_contact->client->phone = $this->client_phone;
|
$_contact->client->phone = $this->client_phone;
|
||||||
$_contact->client->address1 = $this->client_address_line_1;
|
$_contact->client->address1 = $this->client_address_line_1;
|
||||||
$_contact->client->city = $this->client_city;
|
$_contact->client->city = $this->client_city;
|
||||||
$_contact->client->state = $this->client_state;
|
$_contact->client->state = $this->client_state;
|
||||||
$_contact->client->country_id = $this->client_country_id;
|
$_contact->client->country_id = $this->client_country_id;
|
||||||
$_contact->client->postal_code = $this->client_postal_code;
|
$_contact->client->postal_code = $this->client_postal_code;
|
||||||
$_contact->client->shipping_address1 = $this->client_shipping_address_line_1;
|
$_contact->client->shipping_address1 = $this->client_shipping_address_line_1;
|
||||||
$_contact->client->shipping_city = $this->client_shipping_city;
|
$_contact->client->shipping_city = $this->client_shipping_city;
|
||||||
$_contact->client->shipping_state = $this->client_shipping_state;
|
$_contact->client->shipping_state = $this->client_shipping_state;
|
||||||
$_contact->client->shipping_postal_code = $this->client_shipping_postal_code;
|
$_contact->client->shipping_postal_code = $this->client_shipping_postal_code;
|
||||||
$_contact->client->shipping_country_id = $this->client_shipping_country_id;
|
$_contact->client->shipping_country_id = $this->client_shipping_country_id;
|
||||||
$_contact->client->custom_value1 = $this->client_custom_value1;
|
$_contact->client->custom_value1 = $this->client_custom_value1;
|
||||||
$_contact->client->custom_value2 = $this->client_custom_value2;
|
$_contact->client->custom_value2 = $this->client_custom_value2;
|
||||||
$_contact->client->custom_value3 = $this->client_custom_value3;
|
$_contact->client->custom_value3 = $this->client_custom_value3;
|
||||||
$_contact->client->custom_value4 = $this->client_custom_value4;
|
$_contact->client->custom_value4 = $this->client_custom_value4;
|
||||||
$_contact->push();
|
$_contact->push();
|
||||||
|
|
||||||
|
|
||||||
$contact_update = $_contact
|
$contact_update = $_contact
|
||||||
@ -378,44 +372,39 @@ $_contact->push();
|
|||||||
public function checkFields()
|
public function checkFields()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->show_form = true;
|
MultiDB::setDb($this->db);
|
||||||
//@todo - need to make this optional
|
$_contact = ClientContact::withTrashed()->find($this->contact_id);
|
||||||
// MultiDB::setDb($this->db);
|
|
||||||
// $_contact = ClientContact::withTrashed()->find($this->contact_id);
|
|
||||||
|
|
||||||
// foreach ($this->fields as $index => $field) {
|
foreach ($this->fields as $index => $field) {
|
||||||
// $_field = $this->mappings[$field['name']];
|
$_field = $this->mappings[$field['name']];
|
||||||
|
|
||||||
// if (Str::startsWith($field['name'], 'client_')) {
|
if (Str::startsWith($field['name'], 'client_')) {
|
||||||
// if (empty($_contact->client->{$_field})
|
if (empty($_contact->client->{$_field})
|
||||||
// || is_null($_contact->client->{$_field})
|
|| is_null($_contact->client->{$_field})
|
||||||
// // || in_array($_field, $this->client_address_array)
|
) {
|
||||||
// ) {
|
// $this->show_form = true;
|
||||||
// $this->show_form = true;
|
$this->unfilled_fields++;
|
||||||
// } else {
|
} else {
|
||||||
// $this->fields[$index]['filled'] = true;
|
// $this->fields[$index]['filled'] = true;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (Str::startsWith($field['name'], 'contact_')) {
|
if (Str::startsWith($field['name'], 'contact_')) {
|
||||||
// if (empty($_contact->{$_field}) || is_null($_contact->{$_field}) || str_contains($_contact->{$_field}, '@example.com')) {
|
if (empty($_contact->{$_field}) || is_null($_contact->{$_field}) || str_contains($_contact->{$_field}, '@example.com')) {
|
||||||
// $this->show_form = true;
|
$this->unfilled_fields++;
|
||||||
// } else {
|
} else {
|
||||||
// $this->fields[$index]['filled'] = true;
|
// $this->fields[$index]['filled'] = true;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $left = collect($this->fields)
|
if ($this->unfilled_fields === 0 && !$this->company_gateway->always_show_required_fields) {
|
||||||
// ->filter(fn ($field) => !array_key_exists('filled', $field))
|
$this->dispatch(
|
||||||
// ->count();
|
'passed-required-fields-check',
|
||||||
|
client_postal_code: $this->contact->client->postal_code
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// if ($left === 0) {
|
|
||||||
// $this->dispatch(
|
|
||||||
// 'passed-required-fields-check',
|
|
||||||
// client_postal_code: $this->contact->client->postal_code
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showCopyBillingCheckbox(): bool
|
public function showCopyBillingCheckbox(): bool
|
||||||
|
@ -125,7 +125,7 @@
|
|||||||
@if(!$show_form)
|
@if(!$show_form)
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
document.querySelector('div[data-ref="required-fields-container"]').classList.add('hidden');
|
// document.querySelector('div[data-ref="required-fields-container"]').classList.add('hidden');
|
||||||
document.querySelector('div[data-ref="gateway-container"]').classList.remove('opacity-25');
|
document.querySelector('div[data-ref="gateway-container"]').classList.remove('opacity-25');
|
||||||
document.querySelector('div[data-ref="gateway-container"]').classList.remove('pointer-events-none');
|
document.querySelector('div[data-ref="gateway-container"]').classList.remove('pointer-events-none');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user