Skip to content

Commit

Permalink
Contact email address check added.
Browse files Browse the repository at this point in the history
  • Loading branch information
CihanSenturk committed Oct 9, 2023
1 parent 4732fd4 commit 8581637
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Modals/DocumentTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function create(Document $document)
'send' => [
'text' => trans('general.save_and_send'),
'class' => 'disabled:bg-green-100',
'disabled' => ! empty($document->contact_email) ? false : true,
'disabled' => empty($document->contact->has_email) ? true : false,
],
'confirm' => [
'text' => trans('general.save'),
Expand Down
15 changes: 14 additions & 1 deletion app/Models/Common/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -283,6 +283,19 @@ public function getOverdueAttribute()

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()
{
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Document/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ public function getLineActionsAttribute()
} 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'),
Expand Down
6 changes: 6 additions & 0 deletions resources/assets/js/components/AkauntingContactCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export default {
id: 0,
name: '',
email: '',
has_email: '',
tax_number: '',
currency_code: '',
phone: '',
Expand Down Expand Up @@ -286,6 +287,7 @@ export default {
id: 0,
name: '',
email: '',
has_email: '',
tax_number: '',
currency_code: '',
phone: '',
Expand Down Expand Up @@ -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 : '',
Expand Down Expand Up @@ -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 : '',
Expand Down Expand Up @@ -589,6 +593,7 @@ export default {
id: key,
name: value,
email: '',
has_email: '',
tax_number: '',
currency_code: '',
phone: '',
Expand All @@ -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 : '',
Expand Down
1 change: 1 addition & 0 deletions resources/assets/js/mixins/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/documents/show/send.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Expand Down

0 comments on commit 8581637

Please sign in to comment.