mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 08:14:35 -04:00
Add option to copy billing details on the client check page
This commit is contained in:
parent
ab7d1b096b
commit
c25c7b3370
@ -158,6 +158,37 @@ class RequiredClientInfo extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function showCopyBillingCheckbox(): bool
|
||||||
|
{
|
||||||
|
$fields = [];
|
||||||
|
|
||||||
|
collect($this->fields)->map(function ($field) use (&$fields) {
|
||||||
|
if (! array_key_exists('filled', $field)) {
|
||||||
|
$fields[] = $field['name'];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
if (Str::startsWith($field, 'client_shipping')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleCopyBilling(): void
|
||||||
|
{
|
||||||
|
$this->emit('update-shipping-data', [
|
||||||
|
'client_shipping_address_line_1' => $this->contact->client->address1,
|
||||||
|
'client_shipping_address_line_2' => $this->contact->client->address2,
|
||||||
|
'client_shipping_city' => $this->contact->client->city,
|
||||||
|
'client_shipping_state' => $this->contact->client->state,
|
||||||
|
'client_shipping_postal_code' => $this->contact->client->postal_code,
|
||||||
|
'client_shipping_country_id' => $this->contact->client->country_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
count($this->fields) > 0
|
count($this->fields) > 0
|
||||||
|
@ -35,6 +35,16 @@
|
|||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
@if($this->showCopyBillingCheckbox())
|
||||||
|
@component('portal.ninja2020.components.general.card-element-single')
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<button type="button" class="bg-gray-100 px-2 py-1 text-sm rounded" wire:click="handleCopyBilling">
|
||||||
|
{{ ctrans('texts.copy_billing') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endcomponent
|
||||||
|
@endif
|
||||||
|
|
||||||
@component('portal.ninja2020.components.general.card-element-single')
|
@component('portal.ninja2020.components.general.card-element-single')
|
||||||
<div class="flex flex-col items-end">
|
<div class="flex flex-col items-end">
|
||||||
<button class="button button-primary bg-primary">
|
<button class="button button-primary bg-primary">
|
||||||
|
@ -58,6 +58,16 @@
|
|||||||
.scrollIntoView({behavior: "smooth"});
|
.scrollIntoView({behavior: "smooth"});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Livewire.on('update-shipping-data', (event) => {
|
||||||
|
for (field in event) {
|
||||||
|
let element = document.querySelector(`input[name=${field}]`);
|
||||||
|
|
||||||
|
if (element) {
|
||||||
|
element.value = event[field];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
let toggleWithToken = document.querySelector('.toggle-payment-with-token');
|
let toggleWithToken = document.querySelector('.toggle-payment-with-token');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user