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

Re-Fix Case form task (export/print not working) (replace quick fix with proper fix) #11936

Merged
merged 4 commits into from
May 7, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Further fixes to export
mattwire committed May 7, 2018
commit 7348eee442f83a9fbe1c23cc58cddab0440c8f70
131 changes: 71 additions & 60 deletions CRM/Export/Form/Select.php
Original file line number Diff line number Diff line change
@@ -112,6 +112,67 @@ public function preProcess() {
$formName = CRM_Utils_System::getClassName($stateMachine);
$isStandalone = $formName == 'CRM_Export_StateMachine_Standalone';

// we need to determine component export
$componentName = explode('_', $formName);
$components = array('Contact', 'Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity');

if ($isStandalone) {
$componentName = array('CRM', $this->controller->get('entity'));
}

$componentMode = $this->controller->get('component_mode');
// FIXME: This should use a modified version of CRM_Contact_Form_Search::getModeValue but it doesn't have all the contexts
switch ($componentMode) {
case CRM_Contact_BAO_Query::MODE_CONTRIBUTE:
$entityShortname = 'Contribute';
break;

case CRM_Contact_BAO_Query::MODE_MEMBER:
$entityShortname = 'Member';
$entityDAOName = 'Membership';
break;

case CRM_Contact_BAO_Query::MODE_EVENT:
$entityShortname = 'Event';
break;

case CRM_Contact_BAO_Query::MODE_PLEDGE:
$entityShortname = 'Pledge';
break;

case CRM_Contact_BAO_Query::MODE_CASE:
$entityShortname = 'Case';
break;

case CRM_Contact_BAO_Query::MODE_GRANT:
$entityShortname = 'Grant';
break;

case CRM_Contact_BAO_Query::MODE_ACTIVITY:
$entityShortname = 'Activity';
break;

default:
$entityShortname = $componentName[1]; // Contact
break;
}

if (in_array($entityShortname, $components)) {
$this->_exportMode = constant('CRM_Export_Form_Select::' . strtoupper($entityShortname) . '_EXPORT');
$formTaskClassName = "CRM_{$entityShortname}_Form_Task";
$taskClassName = "CRM_{$entityShortname}_Task";
if (isset($formTaskClassName::$entityShortname)) {
$this::$entityShortname = $formTaskClassName::$entityShortname;
if (isset($formTaskClassName::$tableName)) {
$this::$tableName = $formTaskClassName::$tableName;
}
}
else {
$this::$entityShortname = $entityShortname;
$this::$tableName = CRM_Core_DAO_AllCoreTables::getTableForClass(CRM_Core_DAO_AllCoreTables::getFullName($entityDAOName));
}
}

// get the submitted values based on search
if ($this->_action == CRM_Core_Action::ADVANCED) {
$values = $this->controller->exportValues('Advanced');
@@ -123,20 +184,7 @@ public function preProcess() {
$values = $this->controller->exportValues('Custom');
}
else {
// we need to determine component export
$componentName = explode('_', $formName);
$components = array('Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity');

if ($isStandalone) {
$componentName = array('CRM', $this->controller->get('entity'));
}

if (in_array($componentName[1], $components)) {
$this->_exportMode = constant('CRM_Export_Form_Select::' . strtoupper($componentName[1]) . '_EXPORT');
$className = "CRM_{$componentName[1]}_Form_Task";
$this::$entityShortname = $className::$entityShortname;
$this::$tableName = $className::$tableName;
$className::preProcessCommon($this, !$isStandalone);
if (in_array($entityShortname, $components)) {
$values = $this->controller->exportValues('Search');
}
else {
@@ -158,53 +206,17 @@ public function preProcess() {
}
}

$componentMode = $this->get('component_mode');
switch ($componentMode) {
case 2:
CRM_Contribute_Form_Task::preProcessCommon($this, !$isStandalone);
$this->_exportMode = self::CONTRIBUTE_EXPORT;
$componentName = array('', 'Contribute');
break;

case 3:
CRM_Event_Form_Task::preProcessCommon($this, !$isStandalone);
$this->_exportMode = self::EVENT_EXPORT;
$componentName = array('', 'Event');
break;

case 4:
CRM_Activity_Form_Task::preProcessCommon($this, !$isStandalone);
$this->_exportMode = self::ACTIVITY_EXPORT;
$componentName = array('', 'Activity');
break;

case 5:
CRM_Member_Form_Task::preProcessCommon($this, !$isStandalone);
$this->_exportMode = self::MEMBER_EXPORT;
$componentName = array('', 'Member');
break;
$formTaskClassName::preProcessCommon($this, !$isStandalone);

case 6:
CRM_Case_Form_Task::preProcessCommon($this, !$isStandalone);
$this->_exportMode = self::CASE_EXPORT;
$componentName = array('', 'Case');
break;
}
// $component is used on CRM/Export/Form/Select.tpl to display extra information for contact export
($this->_exportMode == self::CONTACT_EXPORT) ? $component = FALSE : $component = TRUE;
$this->assign('component', $component);

// Set the task title
$componentTasks = $taskClassName::taskTitles();
$this->_task = $values['task'];
if ($this->_exportMode == self::CONTACT_EXPORT) {
$contactTasks = CRM_Contact_Task::taskTitles();
$taskName = $contactTasks[$this->_task];
$component = FALSE;
CRM_Contact_Form_Task::preProcessCommon($this, !$isStandalone);
}
else {
$this->assign('taskName', "Export $componentName[1]");
$className = "CRM_{$componentName[1]}_Task";
$componentTasks = $className::tasks();
$taskName = $componentTasks[$this->_task];
$component = TRUE;
}
$taskName = $componentTasks[$this->_task];
$this->assign('taskName', $taskName);

if ($this->_componentTable) {
$query = "
@@ -217,8 +229,7 @@ public function preProcess() {
$totalSelectedRecords = count($this->_componentIds);
}
$this->assign('totalSelectedRecords', $totalSelectedRecords);
$this->assign('taskName', $taskName);
$this->assign('component', $component);

// all records actions = save a search
if (($values['radio_ts'] == 'ts_all') || ($this->_task == CRM_Contact_Task::SAVE_SEARCH)) {
$this->_selectAll = TRUE;