Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-21829: Show Related Cases For Organizations #101

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vinuvarshith
Copy link
Contributor

Overview

This is a continuation of the PR that was initially added to core here. The code is updated to be a part of CiviCase extension. The requirements for the task are as follows.
Within the organisation contact type, we need to add a new tab called "Related Cases"
In this tab, we should display all the cases that are related to any member associated (has a relationship - we will only consider first degree relationships) with that organisation (open and closed just like the normal for a contact)

Before

There is no way to view cases of users related to an organization from organization contact view page.

After

Organization view page has a new tab, Related Cases, which displays cases of contacts related to the organization.


@vinuvarshith vinuvarshith force-pushed the CRM-21829-show-related-cases-for-organizations branch 2 times, most recently from 54dc0d3 to 2b32e73 Compare April 10, 2018 06:25
@vinuvarshith vinuvarshith force-pushed the CRM-21829-show-related-cases-for-organizations branch from 2b32e73 to e209b54 Compare April 10, 2018 06:29
civicase.php Outdated
AND %1 = CASE
WHEN (rtype.contact_type_a = 'Organization') THEN rel.contact_id_a
ELSE rel.contact_id_b
END";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really should have this kind of code in a separate class. That way we could create tests if need be and also help us get rid of the clutter here. Most of the hooks implemented in this extension are slowly starting to get out of control, I think they would really benefit if you could refactor your code into a separate class/classes, as you see fit. The idea is to keep business logic out of the extension's main file and have classes that do the bulk of the work.

</table>
<script type="text/javascript">
cj('form.CRM_Admin_Form_Setting_Case table.form-layout tbody').append(cj('#civicaseRelatedCasesTab'));
</script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing new-line at end of file.

civicase.php Outdated
'id' => 'related_case',
'url' => CRM_Utils_System::url('civicrm/case/contact-case-tab', array(
'cid' => $context['contact_id'],
'related_cids' => implode(',', getOrganizationRelatedCaseContactIds($context['contact_id'])),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could pose problems in the long term, if there's an organization with a lot of members. Like on ATL. And each member could have several related cases. I think it'd be better if you just send a flag to tell if the organization has related cases or not and look for the actual related id's when the form is being built (or preprocessed).

@@ -10,6 +10,10 @@ class CRM_Civicase_Page_ContactCaseTab extends CRM_Core_Page {
public function run() {
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
$this->assign('cid', $cid);
// For Related cases tab (optional)
$related_cids = CRM_Utils_Request::retrieve('related_cids', 'String');
if($related_cids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use braces for if statements, even if they only have a single line.

@vinuvarshith vinuvarshith force-pushed the CRM-21829-show-related-cases-for-organizations branch from eb1c767 to b08c612 Compare April 19, 2018 12:38
@vinuvarshith
Copy link
Contributor Author

@MiyaNoctem
I have addressed all your above comments

@vinuvarshith
Copy link
Contributor Author

@colemanw
Can you pls check this PR?
Let me know if there are any issues and I will help fix them.
Thanks

@colemanw
Copy link
Member

There's no screenshots on this PR but from the description I gather that it is meant to add a new tab to the contact summary screen showing "Related Cases" in addition to "Cases". That seems slightly weird from a UI perspective, kinda particular to one client's workflow perhaps? But it raises the question of why only Organizations get this treatment. Other contact types have relationships too...

swastikpareek pushed a commit to swastikpareek/org.civicrm.civicase that referenced this pull request Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants