diff --git a/app/config/Migrations/schema-dump-default.lock b/app/config/Migrations/schema-dump-default.lock index d2545033..a10020a6 100644 Binary files a/app/config/Migrations/schema-dump-default.lock and b/app/config/Migrations/schema-dump-default.lock differ diff --git a/app/plugins/Awards/Assets/js/controllers/rec-add-controller.js b/app/plugins/Awards/Assets/js/controllers/rec-add-controller.js index e11ec003..7f9ffca0 100644 --- a/app/plugins/Awards/Assets/js/controllers/rec-add-controller.js +++ b/app/plugins/Awards/Assets/js/controllers/rec-add-controller.js @@ -162,7 +162,9 @@ class AwardsRecommendationAddForm extends Controller { .then(data => { this.callIntoCourtTarget.value = data.additional_info.CallIntoCourt; this.courtAvailabilityTarget.value = data.additional_info.CourtAvailability; - this.personToNotifyTarget.value = data.additional_info.PersonToGiveNoticeTo; + if (data.additional_info.PersonToGiveNoticeTo) { + this.personToNotifyTarget.value = data.additional_info.PersonToGiveNoticeTo; + } if (this.callIntoCourtTarget.value != "") { this.callIntoCourtTarget.disabled = true; } else { diff --git a/app/plugins/Awards/src/Controller/EventsController.php b/app/plugins/Awards/src/Controller/EventsController.php index 058aaf2e..2a6ae862 100644 --- a/app/plugins/Awards/src/Controller/EventsController.php +++ b/app/plugins/Awards/src/Controller/EventsController.php @@ -5,6 +5,7 @@ namespace Awards\Controller; use Awards\Controller\AppController; +use Awards\Model\Entity\Recommendation; /** * Awards Controller @@ -51,11 +52,17 @@ public function view($id = null) 'Branches' => function ($q) { return $q->select(['id', 'name']); }, + ]); + + $currentUser = $this->request->getAttribute('identity'); + if ($currentUser->can("view", "Awards.Recommendations")) { + $event->contain([ 'RecommendationsToGive' => function ($q) { return $q->contain(['Awards'])->select(['id', 'event_id', 'member_sca_name', 'award_id', 'specialty', 'call_into_court', 'court_availability', 'status', 'Awards.abbreviation'])->orderBy(['member_sca_name' => 'ASC']); } - ]) - ->first(); + ]); + } + $event = $event->first(); if (!$event) { throw new \Cake\Http\Exception\NotFoundException(); @@ -144,6 +151,12 @@ public function delete($id = null) $event->name = "Deleted: " . $event->name; if ($this->Events->delete($event)) { $this->Flash->success(__('The Event has been deleted.')); + $recs = $this->Events->RecommendationsToGive->find('all')->where(['event_id' => $event->id])->all(); + foreach ($recs as $rec) { + $rec->event_id = null; + $rec->status = Recommendation::STATUS_NEED_TO_SCHEDULE; + $this->Events->RecommendationsToGive->save($rec); + } } else { $this->Flash->error(__('The Event could not be deleted. Please, try again.')); return $this->redirect(['action' => 'view', $event->id]); diff --git a/app/plugins/Awards/templates/Events/view.php b/app/plugins/Awards/templates/Events/view.php index f9582025..7cc5c2e9 100644 --- a/app/plugins/Awards/templates/Events/view.php +++ b/app/plugins/Awards/templates/Events/view.php @@ -48,31 +48,37 @@ KMP->endBlock() ?> KMP->startBlock("tabButtons") ?> +request->getAttribute('identity'); +if ($currentUser->can("view", "Awards.Recommendations")): ?> + KMP->endBlock() ?> KMP->startBlock("tabContent") ?> +can("view", "Awards.Recommendations")): ?>