In the CiviCRM system I work on, activities created for a specific case can have the priority "normal" or "urgent". This attribute is set by the user when creating the activity inside the CaseView. Internally, the "priority_id" of this activity is set to 1 == "urgent" or 2 == "normal". Now, I want to mark the activities with priority "urgent" in another color when listed in the CaseView as well as in the Case Overview (Cases > My Cases). I started with the first task (changing the activity layout in the CaseView activity list).
I tried modifying the sites/all/modules/civicrm/templates/CRM/Case/Form/ActivityToCase.tpl at line 23, added the following if-clause. This template is included in sites/all/modules/civicrm/templates/CRM/Case/Form/CaseView.tpl in line 259, which seemed like the correct place in the CaseView.tpl for the activities to appear. I added:
{if $form.priority_id == 1}
<td class="label urgent">{$form.file_on_case_activity_subject.label}</td>
{elseif $form.priority_id == 2}
<td class="label">{$form.file_on_case_activity_subject.label}</td>
{/if}
where before we only had:
<td class="label">{$form.file_on_case_activity_subject.label}</td>
When this didn't work, I tried to set an "urgent" class to the $form.file_on_case_activity_subject.html as well:
{if $form.priority_id == 1}
<td class="label urgent">{$form.file_on_case_activity_subject.label}</td>
<td class="urgent">{$form.file_on_case_activity_subject.html}<br />
<span class="description">{ts}You can modify the activity subject before filing.{/ts}</span>
</td>
{elseif $form.priority_id == 2}
<td class="label">{$form.file_on_case_activity_subject.label}</td>
<td>{$form.file_on_case_activity_subject.html}<br />
<span class="description">{ts}You can modify the activity subject before filing.{/ts}</span>
</td>
{/if}
where before we only had:
<td class="label">{$form.file_on_case_activity_subject.label}</td>
<td>{$form.file_on_case_activity_subject.html}<br />
<span class="description">{ts}You can modify the activity subject before filing.{/ts}</span>
</td>
As this didn't work either, I suppose I am modifying the wrong place. Any hint anyone?
Edit: I created an extension with the following code, but it doesn't work yet:
function mark_urgent_activities_civicrm_buildForm($formName, &$form) {
if ($formName == 'CRM_Case_Form_CaseView') {
CRM_Core_Resources::singleton()->addStyle('#crm-container table.nestedActivitySelector tr.priority-urgent {background-color: orange;}');
}
}
Edit2: Accessing the elements with priority-urgent class works in the css file, both as
.priority-urgent {
font-weight: bold;
}
and
#crm-container table.nestedActivitySelector tr.priority-urgent {
font-weight: bold;
}
The (background / font) color doesn't work yet, but I suppose that's only because element cannot have background color.