Add reminder when adding a kid

This commit is contained in:
Regis Freyd
2017-05-29 22:19:27 -04:00
parent 4e7e93faff
commit aa6bb136f7
3 changed files with 21 additions and 0 deletions
+18
View File
@@ -1001,6 +1001,24 @@ class PeopleController extends Controller
$kidId = $contact->addKid($name, $gender, $birthdateApproximate, $birthdate, $age, Auth::user()->timezone);
// add reminder
if ($birthdateApproximate != 'approximate' and $birthdateApproximate != 'unknown') {
$reminder = new Reminder;
$reminder->title = trans('people.kids_add_birthday_reminder', ['name' => $name, 'contact_firstname' => $contact->getFirstName()]);
$reminder->frequency_type = 'year';
$reminder->frequency_number = 1;
$reminder->next_expected_date = Carbon::createFromFormat('Y-m-d', $birthdate);
$reminder->kid_id = $kidId;
$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.kids_add_success'));
return redirect('/people/'.$contact->id);
+1
View File
@@ -143,6 +143,7 @@ return [
'kids_add_success' => 'The child has been added with success.',
'kids_update_success' => 'The child has been updated with success.',
'kids_delete_success' => 'The child has been successfully deleted.',
'kids_add_birthday_reminder' => 'Wish happy birthday to :name, :contact_firstname\'s child.',
// tasks
'tasks_desc' => 'Keep tracks of things you need to do for :name.',
+2
View File
@@ -120,6 +120,7 @@ return [
'significant_other_add_success' => 'Le conjoint a été ajouté avec succès.',
'significant_other_edit_success' => 'Le conjoint a été mis à jour avec succès.',
'significant_other_delete_success' => 'Le conjoint a été supprimé avec succès.',
'significant_other_add_birthday_reminder' => 'Souhaiter bon anniversaire à :name, conjoint de :contact_firstname.',
// kids
'kids_sidebar_title' => 'Enfants',
@@ -141,6 +142,7 @@ return [
'kids_add_success' => 'L\'enfant a été ajouté avec succès.',
'kids_update_success' => 'L\'enfant a été mis à jour avec succès.',
'kids_delete_success' => 'L\'enfant a été supprimé avec succès.',
'kids_add_birthday_reminder' => 'Souhaiter bon anniversaire à :name, enfant de :contact_firstname.',
// tasks
'tasks_desc' => 'Gardez une trace des choses à faire pour :name.',