--HR-321 Simplify case-activity forms and add case_status as a url param
authorPoonam <poonam@poonam.(none)>
Wed, 2 Apr 2014 06:16:50 +0000 (11:46 +0530)
committerPoonam <poonam@poonam.(none)>
Thu, 3 Apr 2014 05:55:32 +0000 (11:25 +0530)
CRM/Activity/Form/Activity.php
CRM/Case/Form/Activity/OpenCase.php
templates/CRM/Case/Form/Activity.tpl

index 8faebedf7e326762f9db44c13bd424198875dfb2..fb9bad8ea6cafb086af18d622086acc1a4415732 100644 (file)
@@ -152,7 +152,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       ),
       'details' => array(
         'type' => 'wysiwyg',
-        'label' => ts('Details'),
+        'label' => ts('Notes'),
         // forces a smaller edit window
         'attributes' => array('rows' => 4, 'cols' => 60),
         'required' => FALSE
index aa7467a8a886e63ff0b831c055b4eddcd3b8dc15..dd324fcfac1a791563876e4b26663e771e434dc8 100644 (file)
@@ -74,6 +74,11 @@ class CRM_Case_Form_Activity_OpenCase {
     $caseTypes = CRM_Case_PseudoConstant::caseType();
     $form->_caseTypeId = array_key_exists($caseTypeId, $caseTypes) ? $caseTypeId : NULL;
 
+    // check if the case status id passed in url is a valid one
+    $caseStatusId = CRM_Utils_Request::retrieve('cStatus', 'Positive', $form);
+    $caseStatus = CRM_Case_PseudoConstant::caseStatus();
+    $form->_caseStatusId = array_key_exists($caseStatusId, $caseStatus) ? $caseStatusId : NULL;
+
     // Add attachments
     CRM_Core_BAO_File::buildAttachment( $form, 'civicrm_activity', $form->_activityId );
   }
@@ -95,10 +100,16 @@ class CRM_Case_Form_Activity_OpenCase {
     list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
 
     // set default case status, case type, encounter medium, location type and phone type defaults are set in DB
-    $caseStatus = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, 'AND is_default = 1');
-    if (count($caseStatus) == 1) {
-      $defaults['status_id'] = key($caseStatus);
+    if ($form->_caseStatusId) {
+      $caseStatus = $form->_caseStatusId;
     }
+    else {
+      $caseStatus = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, 'AND is_default = 1');
+      if (count($caseStatus) == 1) {
+        $caseStatus = key($caseStatus); //$defaults['status_id'] = key($caseStatus);
+      }
+    }
+    $defaults['status_id'] = $caseStatus;
 
     // set default case type passed in url
     if ($form->_caseTypeId) {
@@ -152,7 +163,10 @@ class CRM_Case_Form_Activity_OpenCase {
       $element->freeze();
     }
 
-    $form->addSelect('status_id', array(), TRUE);
+    $csElement = $form->addSelect('status_id', array(), TRUE);
+    if ($form->_caseStatusId) {
+      $csElement->freeze();
+    }
 
     $form->add('text', 'duration', ts('Activity Duration'), array('size' => 4, 'maxlength' => 8));
     $form->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
index f5c044f6c8cb0e94f96615d7dea211d170223a57..8e9284a5ee03f696a5ff58aea5881add2e905503 100644 (file)
         <div id="help">{$activityTypeDescription}</div>
       </tr>
     {/if}
-    <tr id="with-clients" class="crm-case-activity-form-block-client_name">
-      <td class="label font-size12pt">{ts}Client{/ts}</td>
-      <td class="view-value">
-        <span class="font-size12pt">
-          {foreach from=$client_names item=client name=clients}
-            {$client.display_name}{if not $smarty.foreach.clients.last}; &nbsp; {/if}
-          {/foreach}
-        </span>
-
-        {if $action eq 1 or $action eq 2}
-          <br />
-          <a href="#" class="crm-with-contact">&raquo; {ts}With other contact(s){/ts}</a>
-        {/if}
-      </td>
-    </tr>
-
-    {if $action eq 1 or $action eq 2}
-      <tr class="crm-case-activity-form-block-target_contact_id hide-block" id="with-contacts-widget">
-        <td class="label font-size10pt">{ts}With Contact{/ts}</td>
+    {if $activityTypeFile}
+      {include file="CRM/Case/Form/Activity/$activityTypeFile.tpl"}
+      <tr class="crm-case-activity-form-block-details">
+        <td class="label">{$form.details.label}</td>
         <td class="view-value">
-          {$form.target_contact_id.html}
-          <br/>
-          <a href="#" class="crm-with-contact">
-            &raquo; {if not $multiClient}{ts}With client{/ts}{else}{ts}With client(s){/ts}{/if}
-          </a>
+          {* If using plain textarea, assign class=huge to make input large enough. *}
+          {if $defaultWysiwygEditor eq 0}{$form.details.html|crmAddClass:huge}{else}{$form.details.html}{/if}
         </td>
       </tr>
     {/if}
+    <tr class="crm-case-activity-form-block-activity-details">
+      <td colspan="2">
+        <div id="activity-details" class="crm-accordion-wrapper collapsed">
+          <div class="crm-accordion-header">
+            {ts} Activity Details{/ts}
+          </div><!-- /.crm-accordion-header -->
+          <div class="crm-accordion-body">
+            <table class="form-layout-compressed">
+              <tbody>
+                <tr id="with-clients" class="crm-case-activity-form-block-client_name">
+                  <td class="label font-size12pt">{ts}Client{/ts}</td>
+                  <td class="view-value">
+                    <span class="font-size12pt">
+                      {foreach from=$client_names item=client name=clients}
+                        {$client.display_name}{if not $smarty.foreach.clients.last}; &nbsp; {/if}
+                      {/foreach}
+                    </span>
 
-    <tr class="crm-case-activity-form-block-activityTypeName">
-      <td class="label">{ts}Activity Type{/ts}</td>
-      <td class="view-value bold">{$activityTypeName|escape}</td>
-    </tr>
-    <tr class="crm-case-activity-form-block-source_contact_id">
-      <td class="label">{$form.source_contact_id.label}</td>
-      <td class="view-value">{$form.source_contact_id.html}</td>
-    </tr>
-    <tr class="crm-case-activity-form-block-assignee_contact_id">
-      <td class="label">
-        {$form.assignee_contact_id.label}
-        {edit}{help id="assignee_contact_id" title=$form.assignee_contact_id.label file="CRM/Activity/Form/Activity"}{/edit}
-      </td>
-      <td>{$form.assignee_contact_id.html}
-        {if $activityAssigneeNotification}
-          <br />
-          <span class="description"><span class="icon email-icon"></span>{ts}A copy of this activity will be emailed to each Assignee.{/ts}</span>
-        {/if}
-      </td>
-    </tr>
+                   {if $action eq 1 or $action eq 2}
+                      <br />
+                      <a href="#" class="crm-with-contact">&raquo; {ts}With other contact(s){/ts}</a>
+                    {/if}
+                  </td>
+                </tr>
 
-  {* Include special processing fields if any are defined for this activity type (e.g. Change Case Status / Change Case Type). *}
-    {if $activityTypeFile}
-    {include file="CRM/Case/Form/Activity/$activityTypeFile.tpl"}
-    {/if}
-    {if $activityTypeFile neq 'ChangeCaseStartDate'}
-      <tr class="crm-case-activity-form-block-subject">
-        <td class="label">{$form.subject.label}</td><td class="view-value">{$form.subject.html|crmAddClass:huge}</td>
-      </tr>
-    {/if}
-    <tr class="crm-case-activity-form-block-medium_id">
-      <td class="label">{$form.medium_id.label}</td>
-      <td class="view-value">{$form.medium_id.html}&nbsp;&nbsp;&nbsp;{$form.location.label} &nbsp;{$form.location.html|crmAddClass:huge}</td>
-    </tr>
-    <tr class="crm-case-activity-form-block-activity_date_time">
-      <td class="label">{$form.activity_date_time.label}</td>
-      {if $action eq 2 && $activityTypeFile eq 'OpenCase'}
-        <td class="view-value">{$current_activity_date_time|crmDate}
-          <div class="description">Use a <a href="{$changeStartURL}">Change Start Date</a> activity to change the date</div>
-        {* avoid errors about missing field *}
-          <div style="display: none;">{include file="CRM/common/jcalendar.tpl" elementName=activity_date_time}</div>
-        </td>
-        {else}
-        <td class="view-value">{include file="CRM/common/jcalendar.tpl" elementName=activity_date_time}</td>
-      {/if}
-    </tr>
-    <tr>
-      <td colspan="2"><div id="customData"></div></td>
-    </tr>
-    <tr class="crm-case-activity-form-block-details">
-      <td class="label">{$form.details.label}</td>
-      <td class="view-value">
-      {* If using plain textarea, assign class=huge to make input large enough. *}
-        {if $defaultWysiwygEditor eq 0}{$form.details.html|crmAddClass:huge}{else}{$form.details.html}{/if}
+                {if $action eq 1 or $action eq 2}
+                  <tr class="crm-case-activity-form-block-target_contact_id hide-block" id="with-contacts-widget">
+                    <td class="label font-size10pt">{ts}With Contact{/ts}</td>
+                    <td class="view-value">
+                      {$form.target_contact_id.html}
+                      <br/>
+                      <a href="#" class="crm-with-contact">
+                        &raquo; {if not $multiClient}{ts}With client{/ts}{else}{ts}With client(s){/ts}{/if}
+                      </a>
+                    </td>
+                  </tr>
+                {/if}
+
+                <tr class="crm-case-activity-form-block-activityTypeName">
+                  <td class="label">{ts}Activity Type{/ts}</td>
+                  <td class="view-value bold">{$activityTypeName|escape}</td>
+                </tr>
+                <tr class="crm-case-activity-form-block-source_contact_id">
+                  <td class="label">{$form.source_contact_id.label}</td>
+                  <td class="view-value">{$form.source_contact_id.html}</td>
+                </tr>
+                <tr class="crm-case-activity-form-block-assignee_contact_id">
+                  <td class="label">
+                    {$form.assignee_contact_id.label}
+                    {edit}{help id="assignee_contact_id" title=$form.assignee_contact_id.label file="CRM/Activity/Form/Activity"}{/edit}
+                  </td>
+                  <td>{$form.assignee_contact_id.html}
+                    {if $activityAssigneeNotification}
+                      <br />
+                      <span class="description"><span class="icon email-icon"></span>{ts}A copy of this activity will be emailed to each Assignee.{/ts}</span>
+                    {/if}
+                  </td>
+                </tr>
+
+              {* Include special processing fields if any are defined for this activity type (e.g. Change Case Status / Change Case Type). *}
+    
+              {if $activityTypeFile neq 'ChangeCaseStartDate'}
+                <tr class="crm-case-activity-form-block-subject">
+                  <td class="label">{$form.subject.label}</td><td class="view-value">{$form.subject.html|crmAddClass:huge}</td>
+                </tr>
+              {/if}
+              <tr class="crm-case-activity-form-block-medium_id">
+                <td class="label">{$form.medium_id.label}</td>
+                <td class="view-value">{$form.medium_id.html}&nbsp;&nbsp;&nbsp;{$form.location.label} &nbsp;{$form.location.html|crmAddClass:huge}</td>
+              </tr>
+              <tr class="crm-case-activity-form-block-activity_date_time">
+                <td class="label">{$form.activity_date_time.label}</td>
+                {if $action eq 2 && $activityTypeFile eq 'OpenCase'}
+                  <td class="view-value">{$current_activity_date_time|crmDate}
+                    <div class="description">Use a <a href="{$changeStartURL}">Change Start Date</a> activity to change the date</div>
+                    {* avoid errors about missing field *}
+                    <div style="display: none;">{include file="CRM/common/jcalendar.tpl" elementName=activity_date_time}</div>
+                  </td>
+                {else}
+                  <td class="view-value">{include file="CRM/common/jcalendar.tpl" elementName=activity_date_time}</td>
+                {/if}
+              </tr>
+              <tr>
+                <td colspan="2"><div id="customData"></div></td>
+              </tr>
+              {if NOT $activityTypeFile}
+                <tr class="crm-case-activity-form-block-details">
+                  <td class="label">{$form.details.label}</td>
+                  <td class="view-value">
+                  {* If using plain textarea, assign class=huge to make input large enough. *}
+                    {if $defaultWysiwygEditor eq 0}{$form.details.html|crmAddClass:huge}{else}{$form.details.html}{/if}
+                  </td>
+                </tr>
+              {/if}
+              <tr class="crm-case-activity-form-block-duration">
+                <td class="label">{$form.duration.label}</td>
+                <td class="view-value">
+                  {$form.duration.html}
+                  <span class="description">{ts}minutes{/ts}</span>
+                </td>
+              </tr>
+            </table>
+          </div><!-- /.crm-accordion-body -->
+        </div><!-- /.crm-accordion-wrapper -->
       </td>
     </tr>
     <tr class="crm-case-activity-form-block-attachment">
       </div><!-- /.crm-accordion-wrapper -->
     </td>
   </tr>
-  <tr class="crm-case-activity-form-block-duration">
-    <td class="label">{$form.duration.label}</td>
-    <td class="view-value">
-      {$form.duration.html}
-      <span class="description">{ts}minutes{/ts}
-    </td>
-  </tr>
   {* Suppress activity status and priority for changes to status, case type and start date. PostProc will force status to completed. *}
     {if $activityTypeFile NEQ 'ChangeCaseStatus'
     && $activityTypeFile NEQ 'ChangeCaseType'