Merge pull request #3066 from CihanSenturk/document-payment-save&sent--issue
If the contact email is empty, save&sent will be disabled.
This commit is contained in:
commit
539cc913cd
|
|
@ -81,7 +81,8 @@ class DocumentTransactions extends Controller
|
|||
],
|
||||
'send' => [
|
||||
'text' => trans('general.save_and_send'),
|
||||
'class' => 'disabled:bg-green-100'
|
||||
'class' => 'disabled:bg-green-100',
|
||||
'disabled' => empty($document->contact->has_email) ? true : false,
|
||||
],
|
||||
'confirm' => [
|
||||
'text' => trans('general.save'),
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class Contact extends Model
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = ['location', 'logo', 'initials'];
|
||||
protected $appends = ['location', 'logo', 'initials', 'has_email'];
|
||||
|
||||
/**
|
||||
* Attributes that should be mass-assignable.
|
||||
|
|
@ -283,6 +283,19 @@ class Contact extends Model
|
|||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
public function getHasEmailAttribute()
|
||||
{
|
||||
if (! empty($this->email)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->contact_persons()->whereNotNull('email')->count()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getLocationAttribute()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -620,7 +620,7 @@ class Document extends Model
|
|||
} catch (\Exception $e) {}
|
||||
|
||||
try {
|
||||
if (! empty($this->contact) && $this->contact->email && ($this->type == 'invoice')) {
|
||||
if (! empty($this->contact) && $this->contact->has_email && ($this->type == 'invoice')) {
|
||||
$actions[] = [
|
||||
'type' => 'button',
|
||||
'title' => trans('invoices.send_mail'),
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ export default {
|
|||
id: 0,
|
||||
name: '',
|
||||
email: '',
|
||||
has_email: '',
|
||||
tax_number: '',
|
||||
currency_code: '',
|
||||
phone: '',
|
||||
|
|
@ -286,6 +287,7 @@ export default {
|
|||
id: 0,
|
||||
name: '',
|
||||
email: '',
|
||||
has_email: '',
|
||||
tax_number: '',
|
||||
currency_code: '',
|
||||
phone: '',
|
||||
|
|
@ -319,6 +321,7 @@ export default {
|
|||
id: contact.id,
|
||||
name: (contact.title) ? contact.title : (contact.display_name) ? contact.display_name : contact.name,
|
||||
email: (contact.email) ? contact.email : '',
|
||||
has_email: (contact.has_email) ? contact.has_email : '',
|
||||
tax_number: (contact.tax_number) ? contact.tax_number : '',
|
||||
currency_code: (contact.currency_code) ? contact.currency_code : '',
|
||||
phone: (contact.phone) ? contact.phone : '',
|
||||
|
|
@ -529,6 +532,7 @@ export default {
|
|||
id: contact.id,
|
||||
name: (contact.title) ? contact.title : (contact.display_name) ? contact.display_name : contact.name,
|
||||
email: (contact.email) ? contact.email : '',
|
||||
has_email: (contact.has_email) ? contact.has_email : '',
|
||||
tax_number: (contact.tax_number) ? contact.tax_number : '',
|
||||
currency_code: (contact.currency_code) ? contact.currency_code : '',
|
||||
phone: (contact.phone) ? contact.phone : '',
|
||||
|
|
@ -589,6 +593,7 @@ export default {
|
|||
id: key,
|
||||
name: value,
|
||||
email: '',
|
||||
has_email: '',
|
||||
tax_number: '',
|
||||
currency_code: '',
|
||||
phone: '',
|
||||
|
|
@ -614,6 +619,7 @@ export default {
|
|||
id: contact.id,
|
||||
name: (contact.title) ? contact.title : (contact.display_name) ? contact.display_name : contact.name,
|
||||
email: (contact.email) ? contact.email : '',
|
||||
has_email: (contact.has_email) ? contact.has_email : '',
|
||||
tax_number: (contact.tax_number) ? contact.tax_number : '',
|
||||
currency_code: (contact.currency_code) ? contact.currency_code : '',
|
||||
phone: (contact.phone) ? contact.phone : '',
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
<span :class="[{'opacity-0': form.loading}]">{{ buttons.confirm.text }}</span>
|
||||
</button>
|
||||
|
||||
<button v-if="buttons.send" :disabled="form.loading" type="button" class="relative px-6 py-1.5 bg-green hover:bg-green-700 text-white rounded-lg" :class="buttons.send.class" @click="onSubmitViaSendEmail">
|
||||
<button v-if="buttons.send" :disabled="buttons.send.disabled||form.loading" type="button" class="relative px-6 py-1.5 bg-green hover:bg-green-700 text-white rounded-lg" :class="buttons.send.class" @click="onSubmitViaSendEmail">
|
||||
<i v-if="form.loading" class="animate-submit delay-[0.28s] absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto before:absolute before:w-2 before:h-2 before:rounded-full before:animate-submit before:delay-[0.14s] after:absolute after:w-2 after:h-2 after:rounded-full after:animate-submit before:-left-3.5 after:-right-3.5 after:delay-[0.42s]"></i>
|
||||
<span :class="[{'opacity-0': form.loading}]">{{ buttons.send.text }}</span>
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -830,6 +830,7 @@ export default {
|
|||
this.form.contact_id = contact.id;
|
||||
this.form.contact_name = (contact.title) ? contact.title : (contact.display_name) ? contact.display_name : contact.name;
|
||||
this.form.contact_email = (contact.email) ? contact.email : '';
|
||||
this.form.contact_has_email = (contact.has_email) ? true : false;
|
||||
this.form.contact_tax_number = (contact.tax_number) ? contact.tax_number : '';
|
||||
this.form.contact_phone = (contact.phone) ? contact.phone : '';
|
||||
this.form.contact_address = (contact.address) ? contact.address : '';
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
id="invoice-send-to"
|
||||
class="relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 ltr:ml-2 rtl:mr-2 text-base rounded-lg disabled:bg-green-100"
|
||||
override="class"
|
||||
::disabled="form.loading || (this.form.contact_email == undefined || form.contact_email == '')"
|
||||
::disabled="form.loading || (this.form.contact_has_email == undefined || form.contact_has_email == '')"
|
||||
@click="onSubmitViaSendEmail"
|
||||
>
|
||||
<i v-if="send_to && form.loading" class="animate-submit delay-[0.28s] absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto before:absolute before:w-2 before:h-2 before:-left-3.5 before:rounded-full before:animate-submit before:delay-[0.14s] after:absolute after:w-2 after:h-2 after:-right-3.5 after:rounded-full after:animate-submit after:delay-[0.42s]"></i>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<x-slot name="body">
|
||||
<div class="flex flex-wrap space-x-3 rtl:space-x-reverse">
|
||||
@if (! $hideEmail)
|
||||
@if ($document->contact_email)
|
||||
@if ($document->contact->has_email)
|
||||
@if ($document->status != 'cancelled')
|
||||
<x-button id="show-slider-actions-send-email-{{ $document->type }}" kind="secondary" @click="onSendEmail('{{ route($emailRoute, $document->id) }}')">
|
||||
{{ trans($textEmail) }}
|
||||
|
|
|
|||
Loading…
Reference in New Issue