diff --git a/app/Console/Commands/RecurringCheck.php b/app/Console/Commands/RecurringCheck.php new file mode 100644 index 000000000..bc10544f0 --- /dev/null +++ b/app/Console/Commands/RecurringCheck.php @@ -0,0 +1,186 @@ + $company->id]); + + // Override settings and currencies + Overrider::load('settings'); + Overrider::load('currencies'); + + $company->setSettings(); + + $recurring = $company->recurring(); + + foreach ($recurring as $recur) { + $schedule = $this->schedule($recur); + + $current = Date::parse($schedule->current()->getStart()); + + // Check if should recur today + if ($today->ne($current)) { + continue; + } + + $type = end(explode('\\', $recur->recurable_type)); + + $model = $type::find($recur->recurable_id); + + if (!$model) { + continue; + } + + switch ($type) { + case 'Bill': + $this->recurBill($company, $model); + break; + case 'Invoice': + $this->recurInvoice($company, $model); + break; + case 'Payment': + case 'Revenue': + $model->duplicate(); + break; + } + } + } + + // Unset company_id + session()->forget('company_id'); + } + + protected function recurInvoice($company, $model) + { + $clone = $model->duplicate(); + + // Add invoice history + InvoiceHistory::create([ + 'company_id' => session('company_id'), + 'invoice_id' => $clone->id, + 'status_code' => 'draft', + 'notify' => 0, + 'description' => trans('messages.success.added', ['type' => $clone->invoice_number]), + ]); + + // Notify the customer + if ($clone->customer && !empty($clone->customer_email)) { + $clone->customer->notify(new InvoiceNotification($clone)); + } + + // Notify all users assigned to this company + foreach ($company->users as $user) { + if (!$user->can('read-notifications')) { + continue; + } + + $user->notify(new InvoiceNotification($clone)); + } + + // Update next invoice number + $this->increaseNextInvoiceNumber(); + } + + protected function recurBill($company, $model) + { + $clone = $model->duplicate(); + + // Add bill history + BillHistory::create([ + 'company_id' => session('company_id'), + 'bill_id' => $clone->id, + 'status_code' => 'draft', + 'notify' => 0, + 'description' => trans('messages.success.added', ['type' => $clone->bill_number]), + ]); + + // Notify all users assigned to this company + foreach ($company->users as $user) { + if (!$user->can('read-notifications')) { + continue; + } + + $user->notify(new BillNotification($clone)); + } + } + + protected function schedule($recur) + { + $config = new ArrayTransformerConfig(); + $config->enableLastDayOfMonthFix(); + + $transformer = new ArrayTransformer(); + $transformer->setConfig($config); + + return $transformer->transform($this->rule($recur)); + } + + protected function rule($recur) + { + $rule = (new Rule()) + ->setStartDate($recur->started_at) + ->setTimezone(setting('general.timezone')) + ->setFreq(strtoupper($recur->frequency)) + ->setInterval($recur->interval) + ->setCount($recur->count); + + return $rule; + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2698c72d2..8aa2e40da 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -18,6 +18,7 @@ class Kernel extends ConsoleKernel Commands\Install::class, Commands\InvoiceReminder::class, Commands\ModuleInstall::class, + Commands\RecurringCheck::class, ]; /** diff --git a/app/Http/Controllers/Expenses/Bills.php b/app/Http/Controllers/Expenses/Bills.php index 5330d572e..b4483352b 100644 --- a/app/Http/Controllers/Expenses/Bills.php +++ b/app/Http/Controllers/Expenses/Bills.php @@ -242,6 +242,9 @@ class Bills extends Controller 'description' => trans('messages.success.added', ['type' => $bill->bill_number]), ]); + // Recurring + $bill->createRecurring(); + // Fire the event to make it extendible event(new BillCreated($bill)); @@ -444,6 +447,9 @@ class Bills extends Controller $bill->totals()->delete(); $this->addTotals($bill, $request, $taxes, $sub_total, $discount_total, $tax_total); + // Recurring + $bill->updateRecurring(); + // Fire the event to make it extendible event(new BillUpdated($bill)); @@ -511,9 +517,7 @@ class Bills extends Controller { $bill = $this->prepareBill($bill); - $logo = $this->getLogo($bill); - - return view($bill->template_path, compact('bill', 'logo')); + return view($bill->template_path, compact('bill')); } /** @@ -527,9 +531,7 @@ class Bills extends Controller { $bill = $this->prepareBill($bill); - $logo = $this->getLogo($bill); - - $html = view($bill->template_path, compact('bill', 'logo'))->render(); + $html = view($bill->template_path, compact('bill'))->render(); $pdf = \App::make('dompdf.wrapper'); $pdf->loadHTML($html); @@ -736,39 +738,4 @@ class Bills extends Controller 'sort_order' => $sort_order, ]); } - - protected function getLogo($bill) - { - $logo = ''; - - $media_id = setting('general.company_logo'); - - if (isset($bill->vendor->logo) && !empty($bill->vendor->logo->id)) { - $media_id = $bill->vendor->logo->id; - } - - $media = Media::find($media_id); - - if (!empty($media)) { - $path = Storage::path($media->getDiskPath()); - - if (!is_file($path)) { - return $logo; - } - } else { - $path = asset('public/img/company.png'); - } - - $image = Image::make($path)->encode()->getEncoded(); - - if (empty($image)) { - return $logo; - } - - $extension = File::extension($path); - - $logo = 'data:image/' . $extension . ';base64,' . base64_encode($image); - - return $logo; - } } diff --git a/app/Http/Controllers/Expenses/Payments.php b/app/Http/Controllers/Expenses/Payments.php index 67419e951..fcb6ac7ed 100644 --- a/app/Http/Controllers/Expenses/Payments.php +++ b/app/Http/Controllers/Expenses/Payments.php @@ -96,6 +96,9 @@ class Payments extends Controller $payment->attachMedia($media, 'attachment'); } + // Recurring + $payment->createRecurring(); + $message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]); flash($message)->success(); @@ -195,6 +198,9 @@ class Payments extends Controller $payment->attachMedia($media, 'attachment'); } + // Recurring + $payment->updateRecurring(); + $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 6dc279ff2..4166520a0 100644 --- a/app/Http/Controllers/Incomes/Invoices.php +++ b/app/Http/Controllers/Incomes/Invoices.php @@ -260,6 +260,9 @@ class Invoices extends Controller // Update next invoice number $this->increaseNextInvoiceNumber(); + // Recurring + $invoice->createRecurring(); + // Fire the event to make it extendible event(new InvoiceCreated($invoice)); @@ -465,6 +468,9 @@ class Invoices extends Controller $invoice->totals()->delete(); $this->addTotals($invoice, $request, $taxes, $sub_total, $discount_total, $tax_total); + // Recurring + $invoice->updateRecurring(); + // Fire the event to make it extendible event(new InvoiceUpdated($invoice)); @@ -546,9 +552,7 @@ class Invoices extends Controller $invoice = $this->prepareInvoice($invoice); - $logo = $this->getLogo(); - - $html = view($invoice->template_path, compact('invoice', 'logo'))->render(); + $html = view($invoice->template_path, compact('invoice'))->render(); $pdf = \App::make('dompdf.wrapper'); $pdf->loadHTML($html); @@ -602,9 +606,7 @@ class Invoices extends Controller { $invoice = $this->prepareInvoice($invoice); - $logo = $this->getLogo(); - - return view($invoice->template_path, compact('invoice', 'logo')); + return view($invoice->template_path, compact('invoice')); } /** @@ -618,9 +620,7 @@ class Invoices extends Controller { $invoice = $this->prepareInvoice($invoice); - $logo = $this->getLogo(); - - $html = view($invoice->template_path, compact('invoice', 'logo'))->render(); + $html = view($invoice->template_path, compact('invoice'))->render(); $pdf = \App::make('dompdf.wrapper'); $pdf->loadHTML($html); @@ -869,39 +869,4 @@ class Invoices extends Controller 'sort_order' => $sort_order, ]); } - - protected function getLogo() - { - $logo = ''; - - $media_id = setting('general.company_logo'); - - if (setting('general.invoice_logo')) { - $media_id = setting('general.invoice_logo'); - } - - $media = Media::find($media_id); - - if (!empty($media)) { - $path = Storage::path($media->getDiskPath()); - - if (!is_file($path)) { - return $logo; - } - } else { - $path = asset('public/img/company.png'); - } - - $image = Image::make($path)->encode()->getEncoded(); - - if (empty($image)) { - return $logo; - } - - $extension = File::extension($path); - - $logo = 'data:image/' . $extension . ';base64,' . base64_encode($image); - - return $logo; - } } diff --git a/app/Http/Controllers/Incomes/Revenues.php b/app/Http/Controllers/Incomes/Revenues.php index e617f8cd0..835968775 100644 --- a/app/Http/Controllers/Incomes/Revenues.php +++ b/app/Http/Controllers/Incomes/Revenues.php @@ -98,6 +98,9 @@ class Revenues extends Controller $revenue->attachMedia($media, 'attachment'); } + // Recurring + $revenue->createRecurring(); + $message = trans('messages.success.added', ['type' => trans_choice('general.revenues', 1)]); flash($message)->success(); @@ -197,6 +200,9 @@ class Revenues extends Controller $revenue->attachMedia($media, 'attachment'); } + // Recurring + $revenue->updateRecurring(); + $message = trans('messages.success.updated', ['type' => trans_choice('general.revenues', 1)]); flash($message)->success(); diff --git a/app/Http/ViewComposers/Logo.php b/app/Http/ViewComposers/Logo.php new file mode 100644 index 000000000..8d3b7f681 --- /dev/null +++ b/app/Http/ViewComposers/Logo.php @@ -0,0 +1,54 @@ +getDiskPath()); + + if (!is_file($path)) { + return $logo; + } + } else { + $path = asset('public/img/company.png'); + } + + $image = Image::make($path)->encode()->getEncoded(); + + if (empty($image)) { + return $logo; + } + + $extension = File::extension($path); + + $logo = 'data:image/' . $extension . ';base64,' . base64_encode($image); + + $view->with(['logo' => $logo]); + } +} 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 new file mode 100644 index 000000000..bb308c77a --- /dev/null +++ b/app/Models/Common/Recurring.php @@ -0,0 +1,27 @@ +morphTo(); + } +} diff --git a/app/Models/Company/Company.php b/app/Models/Company/Company.php index eb9f2190f..a9ecf4ff2 100644 --- a/app/Models/Company/Company.php +++ b/app/Models/Company/Company.php @@ -106,6 +106,11 @@ class Company extends Eloquent return $this->hasMany('App\Models\Expense\Payment'); } + public function recurring() + { + return $this->hasMany('App\Models\Common\Recurring'); + } + public function revenues() { return $this->hasMany('App\Models\Income\Revenue'); diff --git a/app/Models/Expense/Bill.php b/app/Models/Expense/Bill.php index 4d060814f..dba2b8044 100644 --- a/app/Models/Expense/Bill.php +++ b/app/Models/Expense/Bill.php @@ -5,13 +5,14 @@ namespace App\Models\Expense; use App\Models\Model; use App\Traits\Currencies; use App\Traits\DateTime; +use App\Traits\Media; +use App\Traits\Recurring; use Bkwld\Cloner\Cloneable; use Sofa\Eloquence\Eloquence; -use App\Traits\Media; class Bill extends Model { - use Cloneable, Currencies, DateTime, Eloquence, Media; + use Cloneable, Currencies, DateTime, Eloquence, Media, Recurring; protected $table = 'bills'; @@ -58,26 +59,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 +81,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', 'recurable'); + } + + 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..d179d5854 100644 --- a/app/Models/Expense/Payment.php +++ b/app/Models/Expense/Payment.php @@ -6,13 +6,14 @@ use App\Models\Model; use App\Models\Setting\Category; use App\Traits\Currencies; use App\Traits\DateTime; +use App\Traits\Media; +use App\Traits\Recurring; use Bkwld\Cloner\Cloneable; use Sofa\Eloquence\Eloquence; -use App\Traits\Media; class Payment extends Model { - use Cloneable, Currencies, DateTime, Eloquence, Media; + use Cloneable, Currencies, DateTime, Eloquence, Media, Recurring; protected $table = 'payments'; @@ -44,24 +45,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', 'recurable'); } public function transfers() @@ -69,6 +77,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 6f4cd5b21..cbbe8a094 100644 --- a/app/Models/Income/Invoice.php +++ b/app/Models/Income/Invoice.php @@ -6,13 +6,14 @@ use App\Models\Model; use App\Traits\Currencies; use App\Traits\DateTime; use App\Traits\Incomes; +use App\Traits\Media; +use App\Traits\Recurring; use Bkwld\Cloner\Cloneable; use Sofa\Eloquence\Eloquence; -use App\Traits\Media; class Invoice extends Model { - use Cloneable, Currencies, DateTime, Eloquence, Incomes, Media; + use Cloneable, Currencies, DateTime, Eloquence, Incomes, Media, Recurring; protected $table = 'invoices'; @@ -59,26 +60,21 @@ class Invoice 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 customer() - { - return $this->belongsTo('App\Models\Income\Customer'); - } - public function currency() { return $this->belongsTo('App\Models\Setting\Currency', 'currency_code', 'code'); } - public function status() + public function customer() { - return $this->belongsTo('App\Models\Income\InvoiceStatus', 'invoice_status_code', 'code'); + return $this->belongsTo('App\Models\Income\Customer'); } public function items() @@ -86,9 +82,9 @@ class Invoice extends Model return $this->hasMany('App\Models\Income\InvoiceItem'); } - public function totals() + public function histories() { - return $this->hasMany('App\Models\Income\InvoiceTotal'); + return $this->hasMany('App\Models\Income\InvoiceHistory'); } public function payments() @@ -96,9 +92,19 @@ class Invoice extends Model return $this->hasMany('App\Models\Income\InvoicePayment'); } - public function histories() + public function recurring() { - return $this->hasMany('App\Models\Income\InvoiceHistory'); + return $this->morphOne('App\Models\Common\Recurring', 'recurable'); + } + + public function status() + { + return $this->belongsTo('App\Models\Income\InvoiceStatus', 'invoice_status_code', 'code'); + } + + public function totals() + { + return $this->hasMany('App\Models\Income\InvoiceTotal'); } public function scopeDue($query, $date) diff --git a/app/Models/Income/Revenue.php b/app/Models/Income/Revenue.php index 5ee965c0b..95c3d008b 100644 --- a/app/Models/Income/Revenue.php +++ b/app/Models/Income/Revenue.php @@ -6,13 +6,14 @@ use App\Models\Model; use App\Models\Setting\Category; use App\Traits\Currencies; use App\Traits\DateTime; +use App\Traits\Media; +use App\Traits\Recurring; use Bkwld\Cloner\Cloneable; use Sofa\Eloquence\Eloquence; -use App\Traits\Media; class Revenue extends Model { - use Cloneable, Currencies, DateTime, Eloquence, Media; + use Cloneable, Currencies, DateTime, Eloquence, Media, Recurring; protected $table = 'revenues'; @@ -45,6 +46,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 +78,11 @@ class Revenue extends Model return $this->belongsTo('App\Models\Income\Customer'); } + public function recurring() + { + return $this->morphOne('App\Models\Common\Recurring', 'recurable'); + } + 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 fc9574a5e..18609e7a7 100644 --- a/app/Providers/ViewComposerServiceProvider.php +++ b/app/Providers/ViewComposerServiceProvider.php @@ -38,6 +38,16 @@ class ViewComposerServiceProvider extends ServiceProvider View::composer( '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/app/Traits/Recurring.php b/app/Traits/Recurring.php new file mode 100644 index 000000000..ac693787a --- /dev/null +++ b/app/Traits/Recurring.php @@ -0,0 +1,58 @@ +get('recurring_frequency') == 'no') { + return; + } + + $frequency = ($request['recurring_frequency'] != 'custom') ? $request['recurring_frequency'] : $request['recurring_custom_frequency']; + $interval = ($request['recurring_frequency'] != 'custom') ? 1 : (int) $request['recurring_interval']; + $started_at = $request->get('paid_at') ?: ($request->get('invoiced_at') ?: $request->get('billed_at')); + + $this->recurring()->create([ + 'company_id' => session('company_id'), + 'frequency' => $frequency, + 'interval' => $interval, + 'started_at' => $started_at, + 'count' => (int) $request['recurring_count'], + ]); + } + + public function updateRecurring() + { + $request = request(); + + if ($request->get('recurring_frequency') == 'no') { + $this->recurring()->delete(); + return; + } + + $frequency = ($request['recurring_frequency'] != 'custom') ? $request['recurring_frequency'] : $request['recurring_custom_frequency']; + $interval = ($request['recurring_frequency'] != 'custom') ? 1 : (int) $request['recurring_interval']; + $started_at = $request->get('paid_at') ?: ($request->get('invoiced_at') ?: $request->get('billed_at')); + + $recurring = $this->recurring(); + + if ($recurring->count()) { + $function = 'update'; + } else { + $function = 'create'; + } + + $recurring->$function([ + 'company_id' => session('company_id'), + 'frequency' => $frequency, + 'interval' => $interval, + 'started_at' => $started_at, + 'count' => (int) $request['recurring_count'], + ]); + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index 3aaab5d36..5c2b55bf0 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ "nwidart/laravel-modules": "1.*", "plank/laravel-mediable": "2.5.*", "santigarcor/laratrust": "4.0.*", + "simshaun/recurr": "3.0.*", "sofa/eloquence": "5.4.*", "tucker-eric/eloquentfilter": "1.1.*" }, diff --git a/database/migrations/2018_04_26_000000_create_recurring_table.php b/database/migrations/2018_04_26_000000_create_recurring_table.php new file mode 100644 index 000000000..0057ca08d --- /dev/null +++ b/database/migrations/2018_04_26_000000_create_recurring_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->integer('company_id'); + $table->morphs('recurable'); + $table->string('frequency'); + $table->integer('interval')->default(1); + $table->date('started_at'); + $table->integer('count')->default(0); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('recurring'); + } +} diff --git a/public/css/app.css b/public/css/app.css index 2bbb850af..841126099 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -585,3 +585,8 @@ input[type="number"] { .form-small #currency { width: 10%; } + +.input-group-recurring { + padding-left: 0; + padding-right: 0; +} diff --git a/public/js/app.js b/public/js/app.js index bd76950f5..cd85df6ac 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -186,6 +186,11 @@ $(document).ready(function () { disable_input.trigger('change'); } }); + + if (document.getElementById('recurring_frequency')) { + $(".input-group-recurring #recurring_frequency").select2(); + $('.input-group-recurring #recurring_frequency').trigger('change'); + } }); function confirmDelete(form_id, title, message, button_cancel, button_delete) { @@ -249,3 +254,34 @@ $(document).on('click', '.popup', function(e) { } }); }); + +$(document).on('change', '.input-group-recurring #recurring_frequency', function (e) { + var value = $(this).val(); + + var recurring_frequency = $('#recurring_frequency').parent().parent(); + var recurring_interval = $('#recurring_interval').parent(); + var recurring_custom_frequency = $('#recurring_custom_frequency').parent(); + var recurring_count = $('#recurring_count').parent(); + + if (value == 'custom') { + recurring_frequency.removeClass('col-md-12').removeClass('col-md-12').addClass('col-md-4'); + + recurring_interval.removeClass('hidden'); + recurring_custom_frequency.removeClass('hidden'); + recurring_count.removeClass('hidden'); + + $("#recurring_custom_frequency").select2(); + } else if (value == 'no' || value == '') { + recurring_frequency.removeClass('col-md-10').removeClass('col-md-4').addClass('col-md-12'); + + recurring_interval.addClass('hidden'); + recurring_custom_frequency.addClass('hidden'); + recurring_count.addClass('hidden'); + } else { + recurring_frequency.removeClass('col-md-12').removeClass('col-md-4').addClass('col-md-10'); + + recurring_interval.addClass('hidden'); + recurring_custom_frequency.addClass('hidden'); + recurring_count.removeClass('hidden'); + } +}); diff --git a/resources/lang/en-GB/recurring.php b/resources/lang/en-GB/recurring.php new file mode 100644 index 000000000..52f9afada --- /dev/null +++ b/resources/lang/en-GB/recurring.php @@ -0,0 +1,19 @@ + '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..462721caa 100644 --- a/resources/views/expenses/bills/create.blade.php +++ b/resources/views/expenses/bills/create.blade.php @@ -61,7 +61,7 @@
:message
') !!}:message
') !!}:message
') !!}:message
') !!}:message
') !!} +