// if we're editing...
if (isset($this->_activityId)) {
- $defaults['source_contact_qid'] = CRM_Utils_Array::value('source_contact_id',
- $defaults);
- $defaults['source_contact_id'] = CRM_Utils_Array::value('source_contact',
- $defaults);
if (!CRM_Utils_Array::crmIsEmptyArray($defaults['target_contact'])) {
$target_contact_value = explode(';', trim($defaults['target_contact_value']));
$this->assign('assignee_contact_value',
CRM_Utils_Array::value('assignee_contact_value', $defaults)
);
- $this->assign('source_contact_value',
- CRM_Utils_Array::value('source_contact', $defaults)
- );
}
// set default tags if exists
$this->_targetContactId = $this->_currentlyViewedContactId;
$target_contact = array();
- $defaults['source_contact_id'] = self::_getDisplayNameById($this->_sourceContactId);
- $defaults['source_contact_qid'] = $this->_sourceContactId;
+ $defaults['source_contact_id'] = $this->_sourceContactId;
if ($this->_context != 'standalone' && isset($this->_targetContactId)) {
$target_contact[$this->_targetContactId] = self::_getDisplayNameById($this->_targetContactId);
}
$element = & $this->add('select', 'activity_type_id', ts('Activity Type'),
$this->_fields['followup_activity_type_id']['attributes'],
FALSE, array(
- 'onchange' =>
- "CRM.buildCustomData( 'Activity', this.value );",
+ 'onchange' => "CRM.buildCustomData( 'Activity', this.value );",
+ 'class' => 'crm-select2',
)
);
if ($values['type'] == 'wysiwyg') {
$this->addWysiwyg($field, $values['label'], $attribute, $required);
}
- else {
+ elseif ($field != 'source_contact_id') {
$this->add($values['type'], $field, $values['label'], $attribute, $required);
}
}
//add followup date
$this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
- //autocomplete url
- $dataUrl = CRM_Utils_System::url("civicrm/ajax/rest",
- "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=activity&reset=1",
- FALSE, NULL, FALSE
- );
- $this->assign('dataUrl', $dataUrl);
-
//tokeninput url
$tokenUrl = CRM_Utils_System::url("civicrm/ajax/checkemail",
"noemail=1",
);
$this->assign('tokenUrl', $tokenUrl);
- $admin = CRM_Core_Permission::check('administer CiviCRM');
- //allow to edit source contact field field if context is civicase.
- if ($this->_context == 'caseActivity') {
- $admin = TRUE;
- }
-
- $this->assign('admin', $admin);
-
- $sourceContactField = & $this->add($this->_fields['source_contact_id']['type'],
+ $sourceContactField = $this->addContactRef(
'source_contact_id',
$this->_fields['source_contact_id']['label'],
- NULL,
- $admin
+ array('class' => 'huge'),
+ TRUE
);
+ // Only admins and case-workers can change the activity source
+ if (!CRM_Core_Permission::check('administer CiviCRM') && $this->_context != 'caseActivity') {
+ $sourceContactField->freeze();
+ }
- $followupAssigneeContactField =& $this->add( 'text', 'followup_assignee_contact_id', ts('assignee') );
-
- $this->add('hidden', 'source_contact_qid', '', array('id' => 'source_contact_qid'));
CRM_Contact_Form_NewContact::buildQuickForm($this);
$this->add('text', 'assignee_contact_id', ts('assignee'));
$this->add( 'text', 'followup_assignee_contact_id', ts('assignee'));
- if ($sourceContactField->getValue()) {
- $this->assign('source_contact', $sourceContactField->getValue());
- }
- elseif ($this->_currentUserId) {
- // we're setting currently LOGGED IN user as source for this activity
- $this->assign('source_contact_value', self::_getDisplayNameById($this->_currentUserId));
- }
-
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Activity');
$this->assign('customDataSubType', $this->_activityTypeId);
if (!empty($tags)) {
$this->add('select', 'tag', ts('Tags'), $tags, FALSE,
- array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2')
+ array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2 huge')
);
}
if (array_key_exists('activity_type_id', $fields) && empty($fields['activity_type_id'])) {
$errors['activity_type_id'] = ts('Activity Type is required field.');
}
- //FIX me temp. comment
- // make sure if associated contacts exist
-
- if ($fields['source_contact_id'] && !is_numeric($fields['source_contact_qid'])) {
- $errors['source_contact_id'] = ts('Source Contact non-existent!');
- }
if (CRM_Utils_Array::value('activity_type_id', $fields) == 3 &&
CRM_Utils_Array::value('status_id', $fields) == 1
if (!$params['source_contact_id']) {
$params['source_contact_id'] = $this->_currentUserId;
}
- else {
- $params['source_contact_id'] = $this->_submitValues['source_contact_qid'];
- }
if (isset($this->_activityId)) {
$params['id'] = $this->_activityId;
}
cj(function( ) {
- {/literal}
- {if $source_contact and $admin and $action neq 4}
- {literal} cj( '#source_contact_id' ).val( "{/literal}{$source_contact}{literal}");{/literal}
- {/if}
- {literal}
-
- var sourceDataUrl = "{/literal}{$dataUrl}{literal}";
var tokenDataUrl_assignee = "{/literal}{$tokenUrl}&context={$tokenContext}_assignee{literal}";
var hintText = "{/literal}{ts escape='js'}Start typing a name or email address.{/ts}{literal}";
cj( "#assignee_contact_id").tokenInput( tokenDataUrl_assignee, { prePopulate: assignee_contact, theme: 'facebook', hintText: hintText });
cj( "#followup_assignee_contact_id").tokenInput( tokenDataUrl_assignee, { prePopulate: followup_assignee_contact, theme: 'facebook', hintText: hintText });
cj( 'ul.token-input-list-facebook, div.token-input-dropdown-facebook' ).css( 'width', '450px' );
- cj('#source_contact_id').autocomplete( sourceDataUrl, { width : 180, selectFirst : false, hintText: hintText, matchContains: true, minChars: 1, max: {/literal}{crmSetting name="search_autocomplete_count" group="Search Preferences"}{literal}
- }).result( function(event, data, formatted) { cj( "#source_contact_qid" ).val( data[1] );
- }).bind( 'click', function( ) { if (!cj("#source_contact_id").val()) { cj( "#source_contact_qid" ).val(''); } });
});
/**