From 96f2b4de9dbdfaad7649144853068d5499d99052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Wed, 22 Mar 2023 14:18:12 +0300 Subject: [PATCH] Recurring component development sent automatically send email feature.. --- app/Traits/Recurring.php | 4 ++ app/View/Components/Form/Group/Recurring.php | 27 +++++++++++ .../js/components/AkauntingRecurring.vue | 47 +++++++++++++++++++ resources/lang/en-GB/recurring.php | 1 + .../components/form/group/recurring.blade.php | 12 +++++ 5 files changed, 91 insertions(+) diff --git a/app/Traits/Recurring.php b/app/Traits/Recurring.php index 73db9134018..f6780168535 100644 --- a/app/Traits/Recurring.php +++ b/app/Traits/Recurring.php @@ -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(); @@ -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, ]); @@ -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(); @@ -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'])) { diff --git a/app/View/Components/Form/Group/Recurring.php b/app/View/Components/Form/Group/Recurring.php index 6dcb043ceff..68b5873cf6a 100644 --- a/app/View/Components/Form/Group/Recurring.php +++ b/app/View/Components/Form/Group/Recurring.php @@ -22,6 +22,9 @@ class Recurring extends Component public $limitCount = ''; public $limitDateValue = ''; + public $sendEmailShow; + public $sendEmail; + /** * Create a new component instance. * @@ -41,6 +44,9 @@ public function __construct( $startedValue = '', $limitCount = '', $limitDateValue = '', + + $sendEmailShow = true, + $sendEmail = false ) { $this->type = $this->getType($type); $this->frequency = $this->getFrequency($frequency); @@ -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); } /** @@ -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; + } } diff --git a/resources/assets/js/components/AkauntingRecurring.vue b/resources/assets/js/components/AkauntingRecurring.vue index 19af1608b21..d9ed1211c85 100644 --- a/resources/assets/js/components/AkauntingRecurring.vue +++ b/resources/assets/js/components/AkauntingRecurring.vue @@ -126,6 +126,22 @@
+ +
+
+ {{ sendEmailText }} +
+ +
+ + + +
+
@@ -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() { @@ -258,6 +300,7 @@ export default { limitCount: 0, limitDate: '', formatDate: 'dd MM YYYY', + sendEmail: 0, } }, @@ -284,6 +327,8 @@ export default { this.limit = 'on'; } + this.sendEmail = this.sendEmailValue; + setTimeout(function() { this.change(); }.bind(this), 800); @@ -315,6 +360,8 @@ export default { this.$emit('limit_count', 0); break; } + + this.$emit('send_email', this.sendEmail); }, convertToDarteFormat(format) { diff --git a/resources/lang/en-GB/recurring.php b/resources/lang/en-GB/recurring.php index 588cdf8dc3f..75d8cb49e09 100644 --- a/resources/lang/en-GB/recurring.php +++ b/resources/lang/en-GB/recurring.php @@ -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', diff --git a/resources/views/components/form/group/recurring.blade.php b/resources/views/components/form/group/recurring.blade.php index 8e1ee0a9e7d..69f65db1ffe 100644 --- a/resources/views/components/form/group/recurring.blade.php +++ b/resources/views/components/form/group/recurring.blade.php @@ -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)]) !!}" @@ -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 }}