Skip to content

Commit

Permalink
Recurring component development sent automatically send email feature..
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Mar 22, 2023
1 parent 31c5891 commit 96f2b4d
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/Traits/Recurring.php
Expand Up @@ -23,6 +23,7 @@ public function createRecurring($request)
$limit_by = !empty($request['recurring_limit']) ? $request['recurring_limit'] : 'count';
$limit_count = isset($request['recurring_limit_count']) ? (int) $request['recurring_limit_count'] : 0;
$limit_date = !empty($request['recurring_limit_date']) ? $request['recurring_limit_date'] : null;
$auto_send = !empty($request['recurring_send_email']) ? $request['recurring_send_email'] : 0;
$source = !empty($request['created_from']) ? $request['created_from'] : source_name();
$owner = !empty($request['created_by']) ? $request['created_by'] : user_id();

Expand All @@ -35,6 +36,7 @@ public function createRecurring($request)
'limit_by' => $limit_by,
'limit_count' => $limit_count,
'limit_date' => $limit_date,
'auto_send' => $auto_send,
'created_from' => $source,
'created_by' => $owner,
]);
Expand All @@ -54,6 +56,7 @@ public function updateRecurring($request)
$limit_by = !empty($request['recurring_limit']) ? $request['recurring_limit'] : 'count';
$limit_count = isset($request['recurring_limit_count']) ? (int) $request['recurring_limit_count'] : 0;
$limit_date = !empty($request['recurring_limit_date']) ? $request['recurring_limit_date'] : null;
$auto_send = !empty($request['recurring_send_email']) ? $request['recurring_send_email'] : 0;

$recurring = $this->recurring();
$model_exists = $recurring->count();
Expand All @@ -66,6 +69,7 @@ public function updateRecurring($request)
'limit_by' => $limit_by,
'limit_count' => $limit_count,
'limit_date' => $limit_date,
'auto_send' => $auto_send,
];

if (! empty($request['recurring_status'])) {
Expand Down
27 changes: 27 additions & 0 deletions app/View/Components/Form/Group/Recurring.php
Expand Up @@ -22,6 +22,9 @@ class Recurring extends Component
public $limitCount = '';
public $limitDateValue = '';

public $sendEmailShow;
public $sendEmail;

/**
* Create a new component instance.
*
Expand All @@ -41,6 +44,9 @@ public function __construct(
$startedValue = '',
$limitCount = '',
$limitDateValue = '',

$sendEmailShow = true,
$sendEmail = false
) {
$this->type = $this->getType($type);
$this->frequency = $this->getFrequency($frequency);
Expand All @@ -55,6 +61,9 @@ public function __construct(
$this->startedValue = $this->getStartedValue($startedValue);
$this->limitCount = $this->getLimitCount($limitCount);
$this->limitDateValue = $this->getLimitDateValue($limitDateValue);

$this->sendEmailShow = $this->getSendEmailShow($sendEmailShow);
$this->sendEmail = $this->getSendEmail($sendEmail);
}

/**
Expand Down Expand Up @@ -171,4 +180,22 @@ protected function getLimitDateValue($limitDateValue)

return Date::now()->toDateString();
}

protected function getSendEmailShow($sendEmailShow)
{
if (! empty($sendEmailShow)) {
return $sendEmailShow;
}

return false;
}

protected function getSendEmail($sendEmail)
{
if (! empty($sendEmail)) {
return $sendEmail;
}

return false;
}
}
47 changes: 47 additions & 0 deletions resources/assets/js/components/AkauntingRecurring.vue
Expand Up @@ -126,6 +126,22 @@
<div class="text-red text-sm mt-1 ml-2 block" v-if="limitDateError" v-html="limitDateError"></div>
</div>
</div>

<div v-if="sendEmailShow" class="flex flex-wrap lg:flex-nowrap items-center space-y-1 lg:space-y-0">
<div class="w-24 sm:w-60 px-0 sm:px-2 text-sm">
{{ sendEmailText }}
</div>

<div class="flex items-center mt-1">
<label @click="sendEmail=1;change();" v-bind:class="[sendEmail == 1 ? ['bg-green-500','text-white'] : 'bg-black-100']" class="relative w-10 ltr:rounded-tl-lg ltr:rounded-bl-lg rtl:rounded-tr-lg rtl:rounded-br-lg py-2 px-1 text-sm text-center transition-all cursor-pointer">
{{ sendEmailYesText }}
</label>

<label @click="sendEmail=0;change();"v-bind:class="[sendEmail == 0 ? ['bg-red-500','text-white'] : 'bg-black-100']" class="relative w-10 ltr:rounded-tr-lg ltr:rounded-br-lg rtl:rounded-tl-lg rtl:rounded-bl-lg py-2 px-1 text-sm text-center transition-all cursor-pointer">
{{ sendEmailNoText }}
</label>
</div>
</div>
</div>
</template>

Expand Down Expand Up @@ -246,6 +262,32 @@ export default {
default: 'dd MM yyyy',
description: "Default date format"
},
sendEmailShow: {
type: Number,
default: 1,
description: "Created recurring model send automatically option"
},
sendEmailText: {
type: String,
default: 'Send email automatically',
description: "Created recurring model send automatically option"
},
sendEmailYesText: {
type: String,
default: 'Yes',
description: "Send email option yes text"
},
sendEmailNoText: {
type: String,
default: 'No',
description: "Send email option no text"
},
sendEmailValue: {
type: [Number, String],
default: 0,
description: "Send Email value"
}
},
data() {
Expand All @@ -258,6 +300,7 @@ export default {
limitCount: 0,
limitDate: '',
formatDate: 'dd MM YYYY',
sendEmail: 0,
}
},
Expand All @@ -284,6 +327,8 @@ export default {
this.limit = 'on';
}
this.sendEmail = this.sendEmailValue;
setTimeout(function() {
this.change();
}.bind(this), 800);
Expand Down Expand Up @@ -315,6 +360,8 @@ export default {
this.$emit('limit_count', 0);
break;
}
this.$emit('send_email', this.sendEmail);
},
convertToDarteFormat(format) {
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en-GB/recurring.php
Expand Up @@ -29,6 +29,7 @@
'child' => ':url was automatically created on :date',
'message' => 'This is a recurring :type and the next :type will be automatically generated on :date',
'message_parent' => 'This :type was automatically generated from :link',
'send_email_auto' => 'Send email automatically',

'frequency_type' => 'Repeat this :type',
'limit_date' => 'Create first :type on',
Expand Down
12 changes: 12 additions & 0 deletions resources/views/components/form/group/recurring.blade.php
Expand Up @@ -3,6 +3,9 @@
:date-range-text="{{ json_encode(trans('general.date_range')) }}"
middle-text="{!! trans('recurring.limit_middle') !!}"
end-text="{{ Str::plural(Str::replace('-recurring', '', $type)) }}"
send-email-text="{{ trans('recurring.send_email_auto') }}"
send-email-yes-text="{{ trans('general.yes') }}"
send-email-no-text="{{ trans('general.no') }}"

:frequencies="{{ json_encode($frequencies) }}"
frequency-text="{!! trans('recurring.frequency_type', ['type' => Str::replace('-recurring', '', $type)]) !!}"
Expand Down Expand Up @@ -65,6 +68,15 @@
@endif
:limit-date-error="form.errors.get('recurring_limit_date')"

send-email-show="{{ $sendEmailShow }}"
send-email-value="{{ $sendEmail }}"
@if ($attributes->has('@send_email'))
@send_email="form.recurring_send_email = $event;{{ $attributes['@send_email'] }}"
@else
@send_email="form.recurring_send_email = $event"
@endif
:send-email-error="form.errors.get('recurring_send_email')"

date-format="{{ company_date_format() }}"

{{ $attributes }}
Expand Down

0 comments on commit 96f2b4d

Please sign in to comment.