From b5e937b58d42ccc0e667e5437cfddaa9b06a3d4b Mon Sep 17 00:00:00 2001 From: denisdulici Date: Thu, 26 Apr 2018 18:40:04 +0300 Subject: [PATCH] form stuff done --- app/Http/Controllers/Expenses/Bills.php | 36 ++++++++++++++++ app/Http/Controllers/Expenses/Payments.php | 36 ++++++++++++++++ app/Http/Controllers/Incomes/Invoices.php | 36 ++++++++++++++++ app/Http/Controllers/Incomes/Revenues.php | 36 ++++++++++++++++ app/Http/ViewComposers/Recurring.php | 36 ++++++++++++++++ app/Models/Common/Recurring.php | 10 +++++ app/Models/Expense/Bill.php | 35 ++++++++------- app/Models/Expense/Payment.php | 26 ++++++++--- app/Models/Income/Invoice.php | 6 +-- app/Models/Income/Revenue.php | 12 ++++++ app/Providers/FormServiceProvider.php | 4 ++ app/Providers/ViewComposerServiceProvider.php | 5 +++ ...8_04_26_000000_create_recurrings_table.php | 2 +- resources/lang/en-GB/recurring.php | 8 ++++ .../views/expenses/bills/create.blade.php | 4 +- resources/views/expenses/bills/edit.blade.php | 4 +- .../views/expenses/payments/create.blade.php | 22 +++++----- .../views/expenses/payments/edit.blade.php | 4 +- .../views/incomes/invoices/create.blade.php | 10 ++--- .../views/incomes/invoices/edit.blade.php | 4 +- .../views/incomes/revenues/create.blade.php | 22 +++++----- .../views/incomes/revenues/edit.blade.php | 4 +- .../views/partials/form/recurring.blade.php | 43 +++++++++++++++++++ 23 files changed, 347 insertions(+), 58 deletions(-) create mode 100644 app/Http/ViewComposers/Recurring.php create mode 100644 resources/views/partials/form/recurring.blade.php diff --git a/app/Http/Controllers/Expenses/Bills.php b/app/Http/Controllers/Expenses/Bills.php index f938875a4..e2064a511 100644 --- a/app/Http/Controllers/Expenses/Bills.php +++ b/app/Http/Controllers/Expenses/Bills.php @@ -242,6 +242,20 @@ class Bills extends Controller 'description' => trans('messages.success.added', ['type' => $bill->bill_number]), ]); + // Recurring + if ($request->get('recurring_frequency') != 'no') { + $frequency = ($request['recurring_frequency'] != 'custom') ? $request['recurring_frequency'] : $request['recurring_custom_frequency']; + $interval = ($request['recurring_frequency'] != 'custom') ? 1 : (int) $request['recurring_interval']; + + $bill->recurring()->create([ + 'company_id' => session('company_id'), + 'frequency' => $frequency, + 'interval' => $interval, + 'started_at' => $request['billed_at'], + 'count' => (int) $request['recurring_count'], + ]); + } + // Fire the event to make it extendible event(new BillCreated($bill)); @@ -444,6 +458,28 @@ class Bills extends Controller $bill->totals()->delete(); $this->addTotals($bill, $request, $taxes, $sub_total, $discount_total, $tax_total); + // Recurring + if ($request->get('recurring_frequency') != 'no') { + $frequency = ($request['recurring_frequency'] != 'custom') ? $request['recurring_frequency'] : $request['recurring_custom_frequency']; + $interval = ($request['recurring_frequency'] != 'custom') ? 1 : (int) $request['recurring_interval']; + + if ($bill->has('recurring')->count()) { + $function = 'update'; + } else { + $function = 'create'; + } + + $bill->recurring()->$function([ + 'company_id' => session('company_id'), + 'frequency' => $frequency, + 'interval' => $interval, + 'started_at' => $request['billed_at'], + 'count' => (int) $request['recurring_count'], + ]); + } else { + $bill->recurring()->delete(); + } + // Fire the event to make it extendible event(new BillUpdated($bill)); diff --git a/app/Http/Controllers/Expenses/Payments.php b/app/Http/Controllers/Expenses/Payments.php index 67419e951..1317ed992 100644 --- a/app/Http/Controllers/Expenses/Payments.php +++ b/app/Http/Controllers/Expenses/Payments.php @@ -96,6 +96,20 @@ class Payments extends Controller $payment->attachMedia($media, 'attachment'); } + // Recurring + if ($request->get('recurring_frequency') != 'no') { + $frequency = ($request['recurring_frequency'] != 'custom') ? $request['recurring_frequency'] : $request['recurring_custom_frequency']; + $interval = ($request['recurring_frequency'] != 'custom') ? 1 : (int) $request['recurring_interval']; + + $payment->recurring()->create([ + 'company_id' => session('company_id'), + 'frequency' => $frequency, + 'interval' => $interval, + 'started_at' => $request['paid_at'], + 'count' => (int) $request['recurring_count'], + ]); + } + $message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]); flash($message)->success(); @@ -195,6 +209,28 @@ class Payments extends Controller $payment->attachMedia($media, 'attachment'); } + // Recurring + if ($request->get('recurring_frequency') != 'no') { + $frequency = ($request['recurring_frequency'] != 'custom') ? $request['recurring_frequency'] : $request['recurring_custom_frequency']; + $interval = ($request['recurring_frequency'] != 'custom') ? 1 : (int) $request['recurring_interval']; + + if ($payment->has('recurring')->count()) { + $function = 'update'; + } else { + $function = 'create'; + } + + $payment->recurring()->$function([ + 'company_id' => session('company_id'), + 'frequency' => $frequency, + 'interval' => $interval, + 'started_at' => $request['paid_at'], + 'count' => (int) $request['recurring_count'], + ]); + } else { + $payment->recurring()->delete(); + } + $message = trans('messages.success.updated', ['type' => trans_choice('general.payments', 1)]); flash($message)->success(); diff --git a/app/Http/Controllers/Incomes/Invoices.php b/app/Http/Controllers/Incomes/Invoices.php index 6837ba86a..7d23019ab 100644 --- a/app/Http/Controllers/Incomes/Invoices.php +++ b/app/Http/Controllers/Incomes/Invoices.php @@ -260,6 +260,20 @@ class Invoices extends Controller // Update next invoice number $this->increaseNextInvoiceNumber(); + // Recurring + if ($request->get('recurring_frequency') != 'no') { + $frequency = ($request['recurring_frequency'] != 'custom') ? $request['recurring_frequency'] : $request['recurring_custom_frequency']; + $interval = ($request['recurring_frequency'] != 'custom') ? 1 : (int) $request['recurring_interval']; + + $invoice->recurring()->create([ + 'company_id' => session('company_id'), + 'frequency' => $frequency, + 'interval' => $interval, + 'started_at' => $request['invoiced_at'], + 'count' => (int) $request['recurring_count'], + ]); + } + // Fire the event to make it extendible event(new InvoiceCreated($invoice)); @@ -465,6 +479,28 @@ class Invoices extends Controller $invoice->totals()->delete(); $this->addTotals($invoice, $request, $taxes, $sub_total, $discount_total, $tax_total); + // Recurring + if ($request->get('recurring_frequency') != 'no') { + $frequency = ($request['recurring_frequency'] != 'custom') ? $request['recurring_frequency'] : $request['recurring_custom_frequency']; + $interval = ($request['recurring_frequency'] != 'custom') ? 1 : (int) $request['recurring_interval']; + + if ($invoice->has('recurring')->count()) { + $function = 'update'; + } else { + $function = 'create'; + } + + $invoice->recurring()->$function([ + 'company_id' => session('company_id'), + 'frequency' => $frequency, + 'interval' => $interval, + 'started_at' => $request['invoiced_at'], + 'count' => (int) $request['recurring_count'], + ]); + } else { + $invoice->recurring()->delete(); + } + // Fire the event to make it extendible event(new InvoiceUpdated($invoice)); diff --git a/app/Http/Controllers/Incomes/Revenues.php b/app/Http/Controllers/Incomes/Revenues.php index e617f8cd0..5e4d347e4 100644 --- a/app/Http/Controllers/Incomes/Revenues.php +++ b/app/Http/Controllers/Incomes/Revenues.php @@ -98,6 +98,20 @@ class Revenues extends Controller $revenue->attachMedia($media, 'attachment'); } + // Recurring + if ($request->get('recurring_frequency') != 'no') { + $frequency = ($request['recurring_frequency'] != 'custom') ? $request['recurring_frequency'] : $request['recurring_custom_frequency']; + $interval = ($request['recurring_frequency'] != 'custom') ? 1 : (int) $request['recurring_interval']; + + $revenue->recurring()->create([ + 'company_id' => session('company_id'), + 'frequency' => $frequency, + 'interval' => $interval, + 'started_at' => $request['paid_at'], + 'count' => (int) $request['recurring_count'], + ]); + } + $message = trans('messages.success.added', ['type' => trans_choice('general.revenues', 1)]); flash($message)->success(); @@ -197,6 +211,28 @@ class Revenues extends Controller $revenue->attachMedia($media, 'attachment'); } + // Recurring + if ($request->get('recurring_frequency') != 'no') { + $frequency = ($request['recurring_frequency'] != 'custom') ? $request['recurring_frequency'] : $request['recurring_custom_frequency']; + $interval = ($request['recurring_frequency'] != 'custom') ? 1 : (int) $request['recurring_interval']; + + if ($revenue->has('recurring')->count()) { + $function = 'update'; + } else { + $function = 'create'; + } + + $revenue->recurring()->$function([ + 'company_id' => session('company_id'), + 'frequency' => $frequency, + 'interval' => $interval, + 'started_at' => $request['paid_at'], + 'count' => (int) $request['recurring_count'], + ]); + } else { + $revenue->recurring()->delete(); + } + $message = trans('messages.success.updated', ['type' => trans_choice('general.revenues', 1)]); flash($message)->success(); diff --git a/app/Http/ViewComposers/Recurring.php b/app/Http/ViewComposers/Recurring.php new file mode 100644 index 000000000..81063b117 --- /dev/null +++ b/app/Http/ViewComposers/Recurring.php @@ -0,0 +1,36 @@ + trans('general.no'), + 'daily' => trans('recurring.daily'), + 'weekly' => trans('recurring.weekly'), + 'monthly' => trans('recurring.monthly'), + 'yearly' => trans('recurring.yearly'), + 'custom' => trans('recurring.custom'), + ]; + + $recurring_custom_frequencies = [ + 'daily' => trans('recurring.days'), + 'weekly' => trans('recurring.weeks'), + 'monthly' => trans('recurring.months'), + 'yearly' => trans('recurring.years'), + ]; + + $view->with(['recurring_frequencies' => $recurring_frequencies, 'recurring_custom_frequencies' => $recurring_custom_frequencies]); + } +} diff --git a/app/Models/Common/Recurring.php b/app/Models/Common/Recurring.php index feb8af816..0640d04e6 100644 --- a/app/Models/Common/Recurring.php +++ b/app/Models/Common/Recurring.php @@ -7,6 +7,16 @@ use App\Models\Model; class Recurring extends Model { + protected $table = 'recurrings'; + + /** + * Attributes that should be mass-assignable. + * + * @var array + */ + protected $fillable = ['company_id', 'recurrable_id', 'recurrable_type', 'frequency', 'interval', 'started_at', 'count']; + + /** * Get all of the owning recurrable models. */ diff --git a/app/Models/Expense/Bill.php b/app/Models/Expense/Bill.php index 4d060814f..1ac8ed36d 100644 --- a/app/Models/Expense/Bill.php +++ b/app/Models/Expense/Bill.php @@ -58,26 +58,21 @@ class Bill extends Model * * @var array */ - protected $cloneable_relations = ['items', 'totals']; + protected $cloneable_relations = ['items', 'recurring', 'totals']; public function category() { return $this->belongsTo('App\Models\Setting\Category'); } - public function vendor() - { - return $this->belongsTo('App\Models\Expense\Vendor'); - } - public function currency() { return $this->belongsTo('App\Models\Setting\Currency', 'currency_code', 'code'); } - public function status() + public function histories() { - return $this->belongsTo('App\Models\Expense\BillStatus', 'bill_status_code', 'code'); + return $this->hasMany('App\Models\Expense\BillHistory'); } public function items() @@ -85,19 +80,29 @@ class Bill extends Model return $this->hasMany('App\Models\Expense\BillItem'); } - public function totals() - { - return $this->hasMany('App\Models\Expense\BillTotal'); - } - public function payments() { return $this->hasMany('App\Models\Expense\BillPayment'); } - public function histories() + public function recurring() { - return $this->hasMany('App\Models\Expense\BillHistory'); + return $this->morphOne('App\Models\Common\Recurring', 'recurrable'); + } + + public function status() + { + return $this->belongsTo('App\Models\Expense\BillStatus', 'bill_status_code', 'code'); + } + + public function totals() + { + return $this->hasMany('App\Models\Expense\BillTotal'); + } + + public function vendor() + { + return $this->belongsTo('App\Models\Expense\Vendor'); } public function scopeDue($query, $date) diff --git a/app/Models/Expense/Payment.php b/app/Models/Expense/Payment.php index 36e7e5074..46d1ed8f2 100644 --- a/app/Models/Expense/Payment.php +++ b/app/Models/Expense/Payment.php @@ -44,24 +44,31 @@ class Payment extends Model 'description' , ]; + /** + * Clonable relationships. + * + * @var array + */ + protected $cloneable_relations = ['recurring']; + public function account() { return $this->belongsTo('App\Models\Banking\Account'); } - public function currency() - { - return $this->belongsTo('App\Models\Setting\Currency', 'currency_code', 'code'); - } - public function category() { return $this->belongsTo('App\Models\Setting\Category'); } - public function vendor() + public function currency() { - return $this->belongsTo('App\Models\Expense\Vendor'); + return $this->belongsTo('App\Models\Setting\Currency', 'currency_code', 'code'); + } + + public function recurring() + { + return $this->morphOne('App\Models\Common\Recurring', 'recurrable'); } public function transfers() @@ -69,6 +76,11 @@ class Payment extends Model return $this->hasMany('App\Models\Banking\Transfer'); } + public function vendor() + { + return $this->belongsTo('App\Models\Expense\Vendor'); + } + /** * Get only transfers. * diff --git a/app/Models/Income/Invoice.php b/app/Models/Income/Invoice.php index 139323f98..f1b149872 100644 --- a/app/Models/Income/Invoice.php +++ b/app/Models/Income/Invoice.php @@ -59,7 +59,7 @@ class Invoice extends Model * * @var array */ - protected $cloneable_relations = ['items', 'totals']; + protected $cloneable_relations = ['items', 'recurring', 'totals']; public function category() { @@ -91,9 +91,9 @@ class Invoice extends Model return $this->hasMany('App\Models\Income\InvoicePayment'); } - public function recurrings() + public function recurring() { - return $this->morphMany('App\Models\Common\Recurring', 'recurrable'); + return $this->morphOne('App\Models\Common\Recurring', 'recurrable'); } public function status() diff --git a/app/Models/Income/Revenue.php b/app/Models/Income/Revenue.php index 5ee965c0b..0a61a25f5 100644 --- a/app/Models/Income/Revenue.php +++ b/app/Models/Income/Revenue.php @@ -45,6 +45,13 @@ class Revenue extends Model 'notes' => 2, ]; + /** + * Clonable relationships. + * + * @var array + */ + protected $cloneable_relations = ['recurring']; + public function user() { return $this->belongsTo('App\Models\Auth\User', 'customer_id', 'id'); @@ -70,6 +77,11 @@ class Revenue extends Model return $this->belongsTo('App\Models\Income\Customer'); } + public function recurring() + { + return $this->morphOne('App\Models\Common\Recurring', 'recurrable'); + } + public function transfers() { return $this->hasMany('App\Models\Banking\Transfer'); diff --git a/app/Providers/FormServiceProvider.php b/app/Providers/FormServiceProvider.php index b4d9daf88..39e66eb40 100644 --- a/app/Providers/FormServiceProvider.php +++ b/app/Providers/FormServiceProvider.php @@ -62,6 +62,10 @@ class FormServiceProvider extends ServiceProvider Form::component('saveButtons', 'partials.form.save_buttons', [ 'cancel', 'col' => 'col-md-12', ]); + + Form::component('recurring', 'partials.form.recurring', [ + 'page', 'model' => null, + ]); } /** diff --git a/app/Providers/ViewComposerServiceProvider.php b/app/Providers/ViewComposerServiceProvider.php index 97e01dc2e..18609e7a7 100644 --- a/app/Providers/ViewComposerServiceProvider.php +++ b/app/Providers/ViewComposerServiceProvider.php @@ -39,6 +39,11 @@ class ViewComposerServiceProvider extends ServiceProvider 'modules.*', 'App\Http\ViewComposers\Modules' ); + // Add recurring + View::composer( + ['partials.form.recurring',], 'App\Http\ViewComposers\Recurring' + ); + // Add logo View::composer( ['incomes.invoices.invoice', 'expenses.bills.bill'], 'App\Http\ViewComposers\Logo' diff --git a/database/migrations/2018_04_26_000000_create_recurrings_table.php b/database/migrations/2018_04_26_000000_create_recurrings_table.php index 518e921ff..1d50638d2 100644 --- a/database/migrations/2018_04_26_000000_create_recurrings_table.php +++ b/database/migrations/2018_04_26_000000_create_recurrings_table.php @@ -19,7 +19,7 @@ class CreateRecurringsTable extends Migration $table->string('frequency'); $table->integer('interval')->default(1); $table->date('started_at'); - $table->integer('count')->default(1); + $table->integer('count')->default(0); $table->timestamps(); $table->softDeletes(); }); diff --git a/resources/lang/en-GB/recurring.php b/resources/lang/en-GB/recurring.php index 5b97bdeed..52f9afada 100644 --- a/resources/lang/en-GB/recurring.php +++ b/resources/lang/en-GB/recurring.php @@ -3,9 +3,17 @@ return [ 'recurring' => 'Recurring', + 'every' => 'Every', + 'period' => 'Period', + 'times' => 'Times', + 'daily' => 'Daily', 'weekly' => 'Weekly', 'monthly' => 'Monthly', 'yearly' => 'Yearly', 'custom' => 'Custom', + 'days' => 'Day(s)', + 'weeks' => 'Week(s)', + 'months' => 'Month(s)', + 'years' => 'Year(s)', ]; diff --git a/resources/views/expenses/bills/create.blade.php b/resources/views/expenses/bills/create.blade.php index e340e50db..9890f8a09 100644 --- a/resources/views/expenses/bills/create.blade.php +++ b/resources/views/expenses/bills/create.blade.php @@ -98,6 +98,8 @@ + {{ Form::textareaGroup('notes', trans_choice('general.notes', 2)) }} +
{!! Form::label('category_id', trans_choice('general.categories', 1), ['class' => 'control-label']) !!}
@@ -110,7 +112,7 @@ {!! $errors->first('category_id', '

:message

') !!}
- {{ Form::textareaGroup('notes', trans_choice('general.notes', 2)) }} + {{ Form::recurring('create') }} {{ Form::fileGroup('attachment', trans('general.attachment'),[]) }}
diff --git a/resources/views/expenses/bills/edit.blade.php b/resources/views/expenses/bills/edit.blade.php index 2409cd649..3f9f57f73 100644 --- a/resources/views/expenses/bills/edit.blade.php +++ b/resources/views/expenses/bills/edit.blade.php @@ -114,9 +114,11 @@ + {{ Form::textareaGroup('notes', trans_choice('general.notes', 2)) }} + {{ Form::selectGroup('category_id', trans_choice('general.categories', 1), 'folder-open-o', $categories) }} - {{ Form::textareaGroup('notes', trans_choice('general.notes', 2)) }} + {{ Form::recurring('edit', $bill) }} {{ Form::fileGroup('attachment', trans('general.attachment'),[]) }} diff --git a/resources/views/expenses/payments/create.blade.php b/resources/views/expenses/payments/create.blade.php index 11536a1e2..46eccb0ea 100644 --- a/resources/views/expenses/payments/create.blade.php +++ b/resources/views/expenses/payments/create.blade.php @@ -24,6 +24,17 @@ +
+ {!! Form::label('vendor_id', trans_choice('general.vendors', 1), ['class' => 'control-label']) !!} +
+
+ {!! Form::select('vendor_id', $vendors, null, array_merge(['id' => 'vendor_id', 'class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.vendors', 1)])])) !!} + + + +
+
+ {{ Form::textareaGroup('description', trans('general.description')) }}
@@ -38,16 +49,7 @@ {!! $errors->first('category_id', '

:message

') !!}
-
- {!! Form::label('vendor_id', trans_choice('general.vendors', 1), ['class' => 'control-label']) !!} -
-
- {!! Form::select('vendor_id', $vendors, null, array_merge(['id' => 'vendor_id', 'class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.vendors', 1)])])) !!} - - - -
-
+ {{ Form::recurring('create') }} {{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods, setting('general.default_payment_method')) }} diff --git a/resources/views/expenses/payments/edit.blade.php b/resources/views/expenses/payments/edit.blade.php index c7b82ffc2..ba25a42c0 100644 --- a/resources/views/expenses/payments/edit.blade.php +++ b/resources/views/expenses/payments/edit.blade.php @@ -29,11 +29,13 @@ + {{ Form::selectGroup('vendor_id', trans_choice('general.vendors', 1), 'user', $vendors, null, []) }} + {{ Form::textareaGroup('description', trans('general.description')) }} {{ Form::selectGroup('category_id', trans_choice('general.categories', 1), 'folder-open-o', $categories) }} - {{ Form::selectGroup('vendor_id', trans_choice('general.vendors', 1), 'user', $vendors, null, []) }} + {{ Form::recurring('edit', $payment) }} {{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods) }} diff --git a/resources/views/incomes/invoices/create.blade.php b/resources/views/incomes/invoices/create.blade.php index 7233a6114..0bc6f6323 100644 --- a/resources/views/incomes/invoices/create.blade.php +++ b/resources/views/incomes/invoices/create.blade.php @@ -98,6 +98,8 @@ + {{ Form::textareaGroup('notes', trans_choice('general.notes', 2)) }} +
{!! Form::label('category_id', trans_choice('general.categories', 1), ['class' => 'control-label']) !!}
@@ -110,9 +112,7 @@ {!! $errors->first('category_id', '

:message

') !!}
- {{ Form::selectGroup('recurring_id', trans('recurring.recurring'), 'refresh', $recurrings, 0, []) }} - - {{ Form::textareaGroup('notes', trans_choice('general.notes', 2)) }} + {{ Form::recurring('create') }} {{ Form::fileGroup('attachment', trans('general.attachment')) }}
@@ -212,10 +212,6 @@ placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}" }); - $("#recurring_id").select2({ - placeholder: "{{ trans('general.form.select.field', ['field' => trans('recurring.recurring')]) }}" - }); - $('#attachment').fancyfile({ text : '{{ trans('general.form.select.file') }}', style : 'btn-default', diff --git a/resources/views/incomes/invoices/edit.blade.php b/resources/views/incomes/invoices/edit.blade.php index a159593c8..0f778a659 100644 --- a/resources/views/incomes/invoices/edit.blade.php +++ b/resources/views/incomes/invoices/edit.blade.php @@ -113,9 +113,11 @@ + {{ Form::textareaGroup('notes', trans_choice('general.notes', 2)) }} + {{ Form::selectGroup('category_id', trans_choice('general.categories', 1), 'folder-open-o', $categories) }} - {{ Form::textareaGroup('notes', trans_choice('general.notes', 2)) }} + {{ Form::recurring('edit', $invoice) }} {{ Form::fileGroup('attachment', trans('general.attachment')) }} diff --git a/resources/views/incomes/revenues/create.blade.php b/resources/views/incomes/revenues/create.blade.php index d1b11eb1a..70e3c1b4c 100644 --- a/resources/views/incomes/revenues/create.blade.php +++ b/resources/views/incomes/revenues/create.blade.php @@ -24,6 +24,17 @@ +
+ {!! Form::label('customer_id', trans_choice('general.customers', 1), ['class' => 'control-label']) !!} +
+
+ {!! Form::select('customer_id', $customers, null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.customers', 1)])])) !!} + + + +
+
+ {{ Form::textareaGroup('description', trans('general.description')) }}
@@ -38,16 +49,7 @@ {!! $errors->first('category_id', '

:message

') !!}
-
- {!! Form::label('customer_id', trans_choice('general.customers', 1), ['class' => 'control-label']) !!} -
-
- {!! Form::select('customer_id', $customers, null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.customers', 1)])])) !!} - - - -
-
+ {{ Form::recurring('create') }} {{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods, setting('general.default_payment_method')) }} diff --git a/resources/views/incomes/revenues/edit.blade.php b/resources/views/incomes/revenues/edit.blade.php index 633cd6c59..40e18bbba 100644 --- a/resources/views/incomes/revenues/edit.blade.php +++ b/resources/views/incomes/revenues/edit.blade.php @@ -29,11 +29,13 @@ + {{ Form::selectGroup('customer_id', trans_choice('general.customers', 1), 'user', $customers, null, []) }} + {{ Form::textareaGroup('description', trans('general.description')) }} {{ Form::selectGroup('category_id', trans_choice('general.categories', 1), 'folder-open-o', $categories) }} - {{ Form::selectGroup('customer_id', trans_choice('general.customers', 1), 'user', $customers, null, []) }} + {{ Form::recurring('edit', $revenue) }} {{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods) }} diff --git a/resources/views/partials/form/recurring.blade.php b/resources/views/partials/form/recurring.blade.php new file mode 100644 index 000000000..ed39abd4e --- /dev/null +++ b/resources/views/partials/form/recurring.blade.php @@ -0,0 +1,43 @@ +@php + if (($page == 'create') || !$model->has('recurring')->count()) { + $frequency = 'no'; + $interval = 1; + $custom_frequency = 'monthly'; + $count = 0; + } else { + $r = $model->recurring; + $frequency = $r->frequency; + $interval = $r->interval; + $custom_frequency = $r->frequency; + $count = $r->count; + } +@endphp + +
+
+ {!! Form::label('recurring_frequency', trans('recurring.recurring'), ['class' => 'control-label']) !!} +
+
+ {!! Form::select('recurring_frequency', $recurring_frequencies, $frequency, ['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans('recurring.recurring')])]) !!} +
+ {!! $errors->first('recurring_frequency', '

:message

') !!} +
+ + + + + + +
\ No newline at end of file