Skip to content

Commit

Permalink
Merge branch 'master' into CRM-19464
Browse files Browse the repository at this point in the history
  • Loading branch information
aydun authored Mar 8, 2017
2 parents 07f69d2 + 0ac9d0b commit 5fbfc94
Show file tree
Hide file tree
Showing 138 changed files with 2,377 additions and 1,343 deletions.
44 changes: 11 additions & 33 deletions CRM/Activity/Form/Task/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function buildQuickForm() {
$ufGroupId = $this->get('ufGroupId');

if (!$ufGroupId) {
CRM_Core_Error::fatal('ufGroupId is missing');
throw new CRM_Core_Exception('The profile id is missing');
}
$this->_title = ts('Update multiple activities') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
CRM_Utils_System::setTitle($this->_title);
Expand All @@ -108,7 +108,7 @@ public function buildQuickForm() {
$suppressFields = FALSE;
$removehtmlTypes = array('File', 'Autocomplete-Select');
foreach ($this->_fields as $name => $field) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) &&
if (CRM_Core_BAO_CustomField::getKeyID($name) &&
in_array($this->_fields[$name]['html_type'], $removehtmlTypes)
) {
$suppressFields = TRUE;
Expand Down Expand Up @@ -150,6 +150,10 @@ public function buildQuickForm() {
}

$customFields = CRM_Core_BAO_CustomField::getFields('Activity');
// It is possible to have fields that are required in CiviCRM not be required in the
// profile. Overriding that here. Perhaps a better approach would be to
// make them required in the schema & read that up through getFields functionality.
$requiredFields = array('activity_date_time');

foreach ($this->_activityHolderIds as $activityId) {
$typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id');
Expand All @@ -169,6 +173,9 @@ public function buildQuickForm() {
}
else {
// Handle non custom fields.
if (in_array($field['name'], $requiredFields)) {
$field['is_required'] = TRUE;
}
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
}
}
Expand Down Expand Up @@ -216,10 +223,6 @@ public function postProcess() {
);
$value['id'] = $key;

if (!empty($value['activity_date_time'])) {
$value['activity_date_time'] = CRM_Utils_Date::processDate($value['activity_date_time'], $value['activity_date_time_time']);
}

if (!empty($value['activity_status_id'])) {
$value['status_id'] = $value['activity_status_id'];
}
Expand All @@ -228,10 +231,6 @@ public function postProcess() {
$value['details'] = $value['activity_details'];
}

if (!empty($value['activity_duration'])) {
$value['duration'] = $value['activity_duration'];
}

if (!empty($value['activity_location'])) {
$value['location'] = $value['activity_location'];
}
Expand All @@ -240,30 +239,9 @@ public function postProcess() {
$value['subject'] = $value['activity_subject'];
}

$query = "
SELECT a.activity_type_id, ac.contact_id
FROM civicrm_activity a
JOIN civicrm_activity_contact ac ON ( ac.activity_id = a.id
AND ac.record_type_id = %2 )
WHERE a.id = %1 ";
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$params = array(1 => array($key, 'Integer'), 2 => array($sourceID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
$dao->fetch();

// Get Activity Type ID
$value['activity_type_id'] = $dao->activity_type_id;

// Get Conatct ID
$value['source_contact_id'] = $dao->contact_id;

// make call use API 3
$value['version'] = 3;

$activityId = civicrm_api('activity', 'update', $value);
$activityId = civicrm_api3('activity', 'create', $value);

// add custom field values
// @todo this would be done by the api call above if the parames were passed through.
if (!empty($value['custom']) &&
is_array($value['custom'])
) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Activity/Import/Parser/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function import($onDuplicate, &$values) {
$params['source_contact_id'] = $session->get('userID');
}

$customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $params));
$customFields = CRM_Core_BAO_CustomField::getFields('Activity');

foreach ($params as $key => $val) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Admin/Form/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function buildQuickForm() {
* @return array
*/
public function setDefaultValues() {
$defaults = $this->_defaults;
$defaults = parent::setDefaultValues();
if (isset($this->_id)) {
//Take parent id in object variable to calculate the menu
//weight if menu parent id changed
Expand Down
8 changes: 0 additions & 8 deletions CRM/Admin/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ public static function getNavigationMenu() {
CRM_Utils_System::civiExit();
}

/**
* Return menu tree as json data for editing.
*/
public static function getNavigationList() {
echo CRM_Core_BAO_Navigation::buildNavigation(TRUE, FALSE);
CRM_Utils_System::civiExit();
}

/**
* Process drag/move action for menu tree.
*/
Expand Down
4 changes: 2 additions & 2 deletions CRM/Admin/Page/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public function browse() {

// Add jstree support
CRM_Core_Resources::singleton()
->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
->addScriptFile('civicrm', 'bower_components/jstree/dist/jstree.min.js', 0, 'html-header')
->addStyleFile('civicrm', 'bower_components/jstree/dist/themes/default/style.min.css');
}

}
20 changes: 6 additions & 14 deletions CRM/Batch/BAO/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,11 @@ public static function getBatchFinancialItems($entityID, $returnValues, $notPres
}

$from = "civicrm_financial_trxn
LEFT JOIN civicrm_entity_financial_trxn ON civicrm_entity_financial_trxn.financial_trxn_id = civicrm_financial_trxn.id
INNER JOIN civicrm_entity_financial_trxn ON civicrm_entity_financial_trxn.financial_trxn_id = civicrm_financial_trxn.id
INNER JOIN civicrm_contribution ON (civicrm_contribution.id = civicrm_entity_financial_trxn.entity_id
AND civicrm_entity_financial_trxn.entity_table='civicrm_contribution')
LEFT JOIN civicrm_entity_batch ON civicrm_entity_batch.entity_table = 'civicrm_financial_trxn'
AND civicrm_entity_batch.entity_id = civicrm_financial_trxn.id
LEFT JOIN civicrm_contribution ON civicrm_contribution.id = civicrm_entity_financial_trxn.entity_id
LEFT JOIN civicrm_financial_type ON civicrm_financial_type.id = civicrm_contribution.financial_type_id
LEFT JOIN civicrm_contact contact_a ON contact_a.id = civicrm_contribution.contact_id
LEFT JOIN civicrm_contribution_soft ON civicrm_contribution_soft.contribution_id = civicrm_contribution.id
Expand Down Expand Up @@ -722,24 +723,15 @@ public static function getBatchFinancialItems($entityID, $returnValues, $notPres
}
if (!empty($query->_where[0])) {
$where = implode(' AND ', $query->_where[0]) .
" AND civicrm_entity_batch.batch_id IS NULL
AND civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution'";
" AND civicrm_entity_batch.batch_id IS NULL ";
$where = str_replace('civicrm_contribution.payment_instrument_id', 'civicrm_financial_trxn.payment_instrument_id', $where);
$searchValue = TRUE;
}
else {
$searchValue = FALSE;
}

if (!$searchValue) {
if (!$notPresent) {
$where = " ( civicrm_entity_batch.batch_id = {$entityID}
AND civicrm_entity_batch.entity_table = 'civicrm_financial_trxn'
AND civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution') ";
$where = " civicrm_entity_batch.batch_id = {$entityID} ";
}
else {
$where = " ( civicrm_entity_batch.batch_id IS NULL
AND civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution')";
$where = " civicrm_entity_batch.batch_id IS NULL ";
}
}

Expand Down
9 changes: 1 addition & 8 deletions CRM/Contact/BAO/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2517,6 +2517,7 @@ public static function getValues(&$params, &$values) {
),
);

// @todo This can be figured out from metadata & we can avoid the uncached query.
CRM_Core_OptionGroup::lookupValues($temp, $names, FALSE);

$values['preferred_communication_method'] = $preffComm;
Expand All @@ -2540,14 +2541,6 @@ public static function getValues(&$params, &$values) {
$values['age']['y'] = CRM_Utils_Array::value('years', $age);
$values['age']['m'] = CRM_Utils_Array::value('months', $age);
}

list($values['birth_date']) = CRM_Utils_Date::setDateDefaults($contact->birth_date, 'birth');
$values['birth_date_display'] = $contact->birth_date;
}

if ($contact->deceased_date) {
list($values['deceased_date']) = CRM_Utils_Date::setDateDefaults($contact->deceased_date, 'birth');
$values['deceased_date_display'] = $contact->deceased_date;
}

$contact->contact_id = $contact->id;
Expand Down
Loading

0 comments on commit 5fbfc94

Please sign in to comment.