diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.php index f7f5d06712..52e12bf7c7 100644 --- a/app/Http/Controllers/Recurring/CreateController.php +++ b/app/Http/Controllers/Recurring/CreateController.php @@ -74,6 +74,13 @@ class CreateController extends Controller $tomorrow = new Carbon; $tomorrow->addDay(); + // types of repetitions: + $typesOfRepetitions = [ + 'forever' => trans('firefly.repeat_forever'), + 'until_date' => trans('firefly.repeat_until_date'), + 'times' => trans('firefly.repeat_times'), + ]; + // flash some data: $preFilled = [ 'first_date' => $tomorrow->format('Y-m-d'), @@ -83,7 +90,7 @@ class CreateController extends Controller ]; $request->session()->flash('preFilled', $preFilled); - return view('recurring.create', compact('tomorrow', 'preFilled', 'defaultCurrency','budgets')); + return view('recurring.create', compact('tomorrow', 'preFilled','typesOfRepetitions', 'defaultCurrency', 'budgets')); } } \ No newline at end of file diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.php index 8cde8b238f..74f948415c 100644 --- a/app/Http/Controllers/Recurring/IndexController.php +++ b/app/Http/Controllers/Recurring/IndexController.php @@ -63,6 +63,20 @@ class IndexController extends Controller ); } + /** + * @param Request $request + * + * @return string + */ + public function calendar(Request $request) + { + $date = new Carbon; + $daysOfWeek = ['S', 'M', 'T', 'W', 'T', 'F', 'S']; + //$firstDayOfMonth = mktime(0, 0, 0, $month, 1, $year); + + return view('recurring.calendar'); + } + /** * @param Request $request * diff --git a/database/migrations/2018_06_08_200526_changes_for_v475.php b/database/migrations/2018_06_08_200526_changes_for_v475.php index 053a6e676b..db5cfbebe7 100644 --- a/database/migrations/2018_06_08_200526_changes_for_v475.php +++ b/database/migrations/2018_06_08_200526_changes_for_v475.php @@ -44,6 +44,7 @@ class ChangesForV475 extends Migration $table->date('first_date'); $table->date('repeat_until')->nullable(); $table->date('latest_date')->nullable(); + $table->smallInteger('repetitions', false, true); $table->boolean('apply_rules')->default(true); $table->boolean('active')->default(true); diff --git a/public/js/ff/recurring/create.js b/public/js/ff/recurring/create.js index 78ff8264b6..ba79cd4e4e 100644 --- a/public/js/ff/recurring/create.js +++ b/public/js/ff/recurring/create.js @@ -32,12 +32,44 @@ $(document).ready(function () { initializeButtons(); initializeAutoComplete(); respondToFirstDateChange(); + respondToRepetitionEnd(); $('.switch-button').on('click', switchTransactionType); + $('#ffInput_repetition_end').on('change', respondToRepetitionEnd); $('#ffInput_first_date').on('change', respondToFirstDateChange); - + $('#calendar-link').on('click', showRepCalendar); }); +function showRepCalendar() { + + // fill model with calendar: + + + $('#defaultModal').modal({}); + return false; +} + +function respondToRepetitionEnd() { + var obj = $('#ffInput_repetition_end'); + var value = obj.val(); + switch (value) { + case 'forever': + $('#repeat_until_holder').hide(); + $('#repetitions_holder').hide(); + break; + case 'until_date': + $('#repeat_until_holder').show(); + $('#repetitions_holder').hide(); + break; + case 'times': + $('#repeat_until_holder').hide(); + $('#repetitions_holder').show(); + break; + } + + +} + function respondToFirstDateChange() { var obj = $('#ffInput_first_date'); var select = $('#ffInput_repetition_type'); diff --git a/resources/lang/en_US/demo.php b/resources/lang/en_US/demo.php index 640ab10298..e56f6f24c6 100644 --- a/resources/lang/en_US/demo.php +++ b/resources/lang/en_US/demo.php @@ -34,4 +34,6 @@ return [ 'transactions-index' => 'These expenses, deposits and transfers are not particularly imaginative. They have been generated automatically.', 'piggy-banks-index' => 'As you can see, there are three piggy banks. Use the plus and minus buttons to influence the amount of money in each piggy bank. Click the name of the piggy bank to see the administration for each piggy bank.', 'import-index' => 'Any CSV file can be imported into Firefly III. It also supports importing data from bunq and Spectre. Other banks and financial aggregators will be implemented in the future. As a demo-user however, you can only see the "fake"-provider in action. It will generate some random transactions to show you how the process works.', + 'recurring-index' => 'Please note that this feature is under active development and may not work as expected.', + 'recurring-create' => 'Please note that this feature is under active development and may not work as expected.', ]; diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index af9109e153..e839af9f50 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -1235,6 +1235,10 @@ return [ 'optional_for_transaction' => 'Optional transaction information', 'change_date_other_options' => 'Change the "first date" to see more options.', 'mandatory_fields_for_tranaction' => 'The values here will end up in the transaction(s) being created', + 'click_for_calendar' => 'Click here for a calendar that shows you when the transaction would repeat.', + 'repeat_forever' => 'Repeat forever', + 'repeat_until_date' => 'Repeat until date', + 'repeat_times' => 'Repeat a number of times', ]; diff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.php index 172fc28ccb..9445534e2a 100644 --- a/resources/lang/en_US/form.php +++ b/resources/lang/en_US/form.php @@ -230,5 +230,8 @@ return [ 'recurring_description' => 'Recurring transaction description', 'repetition_type' => 'Type of repetition', 'foreign_currency_id' => 'Foreign currency', + 'repetition_end' => 'Repetition ends', + 'repetitions' => 'Repetitions', + 'calendar' => 'Calendar', ]; diff --git a/resources/views/recurring/create.twig b/resources/views/recurring/create.twig index 3329ae2208..70b1a034e2 100644 --- a/resources/views/recurring/create.twig +++ b/resources/views/recurring/create.twig @@ -6,129 +6,163 @@