diff --git a/modules/zencrm_entities/src/Entity/CaseEntity.php b/modules/zencrm_entities/src/Entity/CaseEntity.php index 7c46fe2..50ee000 100644 --- a/modules/zencrm_entities/src/Entity/CaseEntity.php +++ b/modules/zencrm_entities/src/Entity/CaseEntity.php @@ -51,7 +51,7 @@ use Drupal\user\UserInterface; * links = { * "canonical" = "/admin/structure/case_entity/{case_entity}", * "add-page" = "/admin/structure/case_entity/add", - * "add-form" = "/admin/structure/case_entity/add/{case_entity_type}", + * "add-form" = "/zencrm/case/add/{case_entity_type}", * "edit-form" = "/admin/structure/case_entity/{case_entity}/edit", * "delete-form" = "/admin/structure/case_entity/{case_entity}/delete", * "collection" = "/admin/structure/case_entity", diff --git a/src/Plugin/Block/PersonPanel.php b/src/Plugin/Block/PersonPanel.php index 3affd5c..b13bd8d 100644 --- a/src/Plugin/Block/PersonPanel.php +++ b/src/Plugin/Block/PersonPanel.php @@ -9,6 +9,7 @@ use Drupal\Core\Block\BlockBase; * If the person has no contact details it advises to create them. * Hats cannot be created without contact details. * If they have contact details but no hats, it advises to create a hat. + * Otherwise display the case view for each hat, and links to create new cases. * * @Block( * id = "person_panel", @@ -24,6 +25,7 @@ class PersonPanel extends BlockBase { $person_id = \Drupal::routeMatch()->getParameter('person')->id(); $markup = ""; $person = \Drupal::entityTypeManager()->getStorage('person')->load($person_id); + // If the person has no contact details, suggest they create some $link_to_add = "/zencrm/contact_details/$person_id/add?destination=/zencrm/person/$person_id"; @@ -47,6 +49,12 @@ class PersonPanel extends BlockBase { $plugin_manager = \Drupal::service('plugin.manager.block'); $block = $plugin_manager->createInstance('hat_creator', array()); $markup .= render($block->build()); + } else { + + // they have hats, so display the case view for each hat. + foreach($hats as $hat) { + $markup .= $this->show_cases_for_hat($hat); + } } } @@ -54,8 +62,16 @@ class PersonPanel extends BlockBase { '#cache' => [ 'max-age' => 0, ], - '#markup' => "
$markup
" + '#markup' => "
$markup
" ]; } + + private function show_cases_for_hat($hat) { + $markup = ''; + $markup .= "

" . $hat->name->getString() . "

"; + $markup .= drupal_render(views_embed_view('this_hat_s_cases', 'block_1', $hat->id())); + error_log(print_r(views_embed_view('this_hat_s_cases', 'block_1', $hat->id()), true)); + return $markup; + } }