diff --git a/app/Http/Controllers/PeopleController.php b/app/Http/Controllers/PeopleController.php index ac95e572a..d456ac1bd 100644 --- a/app/Http/Controllers/PeopleController.php +++ b/app/Http/Controllers/PeopleController.php @@ -1159,6 +1159,23 @@ class PeopleController extends Controller $significantOtherId = $contact->addSignificantOther($firstname, $gender, $birthdateApproximate, $birthdate, $age, Auth::user()->timezone); + // add reminder + if ($birthdateApproximate != 'approximate' and $birthdateApproximate != 'unknown') { + $reminder = new Reminder; + + $reminder->title = trans('people.significant_other_add_birthday_reminder', ['name' => $firstname, 'contact_firstname' => $contact->getFirstName()]); + $reminder->frequency_type = 'year'; + $reminder->frequency_number = 1; + $reminder->next_expected_date = Carbon::createFromFormat('Y-m-d', $birthdate); + $reminder->account_id = $contact->account_id; + $reminder->contact_id = $contact->id; + $reminder->save(); + + // date is in the past - we need to calculate next occuring date + $reminder->calculateNextExpectedDate($reminder->next_expected_date, 'year', 1); + $reminder->save(); + } + $request->session()->flash('success', trans('people.significant_other_add_success')); return redirect('/people/'.$contact->id); diff --git a/resources/lang/en/people.php b/resources/lang/en/people.php index 5a6631a68..fb2f9f77f 100644 --- a/resources/lang/en/people.php +++ b/resources/lang/en/people.php @@ -121,6 +121,7 @@ return [ 'significant_other_add_success' => 'The significant other has been added with success.', 'significant_other_edit_success' => 'The significant other has been updated with success.', 'significant_other_delete_success' => 'The significant other has been successfully deleted.', + 'significant_other_add_birthday_reminder' => 'Wish happy birthday to :name, :contact_firstname\'s significant other.', // kids 'kids_sidebar_title' => 'Children',