/** * Build all the data structures needed to build the form. */ public function preProcess() { parent::preProcess(); $session = CRM_Core_Session::singleton(); $this->_userContext = $session->readUserContext(); CRM_Utils_System::setTitle(ts('File on Case')); }
function postProcess() { // define some stats $activities_total = count($this->_activityHolderIds); $activities_processed = 0; $activities_detected = 0; $activities_fixed = 0; // filter for relevant activities $activity_type_id = (int) CRM_Householdmerge_Logic_Configuration::getCheckHouseholdActivityTypeID(); $activity_status_ids = CRM_Householdmerge_Logic_Configuration::getFixableActivityStatusIDs(); $activity_ids = implode(',', $this->_activityHolderIds); $filter_query = "SELECT id AS activity_id FROM civicrm_activity\n WHERE civicrm_activity.activity_type_id = {$activity_type_id} \n AND civicrm_activity.status_id IN ({$activity_status_ids})\n AND civicrm_activity.id IN ({$activity_ids});"; $filtered_activities = CRM_Core_DAO::executeQuery($filter_query); // go through all activites and try to fix them while ($filtered_activities->fetch()) { $activities_processed += 1; $problem = CRM_Householdmerge_Logic_Problem::extractProblem($filtered_activities->activity_id); if ($problem) { $activities_detected += 1; if ($problem->fix()) { $activities_fixed += 1; } } } // show stats CRM_Core_Session::setStatus(ts('%1 of the %2 selected activities were processed, %3 of them could be fixed.', array(1 => $activities_detected, 2 => $activities_total, 3 => $activities_fixed, 'domain' => 'de.systopia.householdmerge')), ts('%1 Household Problems Fixed', array(1 => $activities_fixed, 'domain' => 'de.systopia.householdmerge')), $activities_fixed > 0 ? 'info' : 'warn'); parent::postProcess(); }
/** * Build all the data structures needed to build the form. */ public function preProcess() { CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this); parent::preProcess(); // we have all the contribution ids, so now we get the contact ids parent::setContactIDs(); $this->assign('single', $this->_single); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { parent::preProcess(); $rows = array(); // display name and activity details of all selected contacts $activityIDs = implode(',', $this->_activityHolderIds); $query = "\n SELECT at.subject as subject,\n ov.label as activity_type,\n at.activity_date_time as activity_date, \n ct.display_name as display_name\n FROM civicrm_activity at\nINNER JOIN civicrm_contact ct ON ( at.source_contact_id = ct.id ) \n LEFT JOIN civicrm_option_group og ON ( og.name = 'activity_type' )\n LEFT JOIN civicrm_option_value ov ON (at.activity_type_id = ov.value AND og.id = ov.option_group_id ) \n WHERE at.id IN ( {$activityIDs} )"; $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); while ($dao->fetch()) { $rows[] = array('subject' => $dao->subject, 'activity_type' => $dao->activity_type, 'activity_date' => $dao->activity_date, 'display_name' => $dao->display_name); } $this->assign('rows', $rows); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { /* * initialize the task and row fields */ parent::preProcess(); //get the contact read only fields to display. $readOnlyFields = array_merge(array('sort_name' => ts('Added By'), 'target_sort_name' => ts('With Contact')), CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE)); //get the read only field data. $returnProperties = array_fill_keys(array_keys($readOnlyFields), 1); $contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_activityHolderIds, 'Activity', $returnProperties); $this->assign('contactDetails', $contactDetails); $this->assign('readOnlyFields', $readOnlyFields); }
/** * Build all the data structures needed to build the form. */ public function preProcess() { parent::preProcess(); $rows = array(); // display name and activity details of all selected contacts $activityIDs = implode(',', $this->_activityHolderIds); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $query = "\n SELECT at.subject as subject,\n ov.label as activity_type,\n at.activity_date_time as activity_date,\n ct.display_name as display_name\n FROM civicrm_activity at\nLEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = at.id AND ac.record_type_id = {$sourceID} )\nINNER JOIN civicrm_contact ct ON ( ac.contact_id = ct.id )\n LEFT JOIN civicrm_option_group og ON ( og.name = 'activity_type' )\n LEFT JOIN civicrm_option_value ov ON (at.activity_type_id = ov.value AND og.id = ov.option_group_id )\n WHERE at.id IN ( {$activityIDs} )"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $rows[] = array('subject' => $dao->subject, 'activity_type' => $dao->activity_type, 'activity_date' => $dao->activity_date, 'display_name' => $dao->display_name); } $this->assign('rows', $rows); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { parent::preprocess(); // set print view, so that print templates are called $this->controller->setPrint(1); // get the formatted params $queryParams = $this->get('queryParams'); $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $selector = new CRM_Activity_Selector_Search($queryParams, $this->_action, $this->_componentClause); $controller = new CRM_Core_Selector_Controller($selector, NULL, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN); $controller->setEmbedded(TRUE); $controller->run(); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { /* * initialize the task and row fields */ parent::preProcess(); //get the contact read only fields to display. require_once 'CRM/Core/BAO/Preferences.php'; $readOnlyFields = array_merge(array('sort_name' => ts('Name')), CRM_Core_BAO_Preferences::valueOptions('contact_autocomplete_options', true, null, false, 'name', true)); //get the read only field data. $returnProperties = array_fill_keys(array_keys($readOnlyFields), 1); require_once 'CRM/Contact/BAO/Contact/Utils.php'; $contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_activityHolderIds, 'Activity', $returnProperties); $this->assign('contactDetails', $contactDetails); $this->assign('readOnlyFields', $readOnlyFields); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { /* * initialize the task and row fields */ parent::preProcess(); $session = CRM_Core_Session::singleton(); $this->_userContext = $session->readUserContext(); CRM_Utils_System::setTitle(ts('File on Case')); $validationFailed = FALSE; // insert validations here // then redirect if ($validationFailed) { CRM_Utils_System::redirect($this->_userContext); } }
/** * Build all the data structures needed to build the form. */ public function preProcess() { // Initialize the task and row fields. parent::preProcess(); $session = CRM_Core_Session::singleton(); $this->_userContext = $session->readUserContext(); CRM_Utils_System::setTitle(ts('Update multiple activities')); $validate = FALSE; // Validations. if (count($this->_activityHolderIds) > $this->_maxActivities) { CRM_Core_Session::setStatus(ts("The maximum number of activities you can select for Update multiple activities is %1. You have selected %2. Please select fewer Activities from your search results and try again.", array(1 => $this->_maxActivities, 2 => count($this->_activityHolderIds))), ts('Maximum Exceeded'), 'error'); $validate = TRUE; } // Then redirect. if ($validate) { CRM_Utils_System::redirect($this->_userContext); } }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { /* * initialize the task and row fields */ parent::preProcess(); $session = CRM_Core_Session::singleton(); $this->_userContext = $session->readUserContext(); CRM_Utils_System::setTitle(ts('Batch Profile Update for Activities')); $validate = false; //validations if (count($this->_activityHolderIds) > $this->_maxActivities) { CRM_Core_Session::setStatus("The maximum number of Activities you can select for Batch Update is {$this->_maxActivities}. You have selected " . count($this->_activityHolderIds) . ". Please select fewer Activities from your search results and try again."); $validate = true; } if ($validate) { // than redirect CRM_Utils_System::redirect($this->_userContext); } }
/** * Build all the data structures needed to build the form. */ public function preProcess() { // Initialize the task and row fields. parent::preProcess(); // Get the contact read only fields to display. $readOnlyFields = array_merge(array('sort_name' => ts('Added By'), 'target_sort_name' => ts('With Contact')), CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE)); // Get the read only field data. $returnProperties = array_fill_keys(array_keys($readOnlyFields), 1); $contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_activityHolderIds, 'Activity', $returnProperties); $readOnlyFields['assignee_display_name'] = ts('Assigned to'); if (!empty($contactDetails)) { foreach ($contactDetails as $key => $value) { $assignee = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($key); foreach ($assignee as $keys => $values) { $assigneeContact[] = CRM_Contact_BAO_Contact::displayname($values); } $contactDetails[$key]['assignee_display_name'] = !empty($assigneeContact) ? implode(';', $assigneeContact) : NULL; } } $this->assign('contactDetails', $contactDetails); $this->assign('readOnlyFields', $readOnlyFields); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { parent::preProcess(); CRM_Contact_Form_Task_SMSCommon::preProcessProvider($this); $this->assign('single', $this->_single); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { parent::preProcess(); }
/** * build all the data structures needed to build the form * * @param * @return void * @access public */ function preProcess() { //special case for custom search, directly give option to download csv file $customSearchID = $this->get('customSearchID'); if ($customSearchID) { require_once 'CRM/Export/BAO/Export.php'; CRM_Export_BAO_Export::exportCustom($this->get('customSearchClass'), $this->get('formValues'), $this->get(CRM_Utils_Sort::SORT_ORDER)); } $this->_selectAll = false; $this->_exportMode = self::CONTACT_EXPORT; // get the submitted values based on search if ($this->_action == CRM_Core_Action::ADVANCED) { $values = $this->controller->exportValues('Advanced'); } else { if ($this->_action == CRM_Core_Action::PROFILE) { $values = $this->controller->exportValues('Builder'); } else { if ($this->_action == CRM_Core_Action::COPY) { $values = $this->controller->exportValues('Custom'); } else { // we need to determine component export $stateMachine =& $this->controller->getStateMachine(); $formName = CRM_Utils_System::getClassName($stateMachine); $componentName = explode('_', $formName); $components = array('Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity'); if (in_array($componentName[1], $components)) { eval('$this->_exportMode = self::' . strtoupper($componentName[1]) . '_EXPORT;'); require_once "CRM/{$componentName[1]}/Form/Task.php"; eval('CRM_' . $componentName[1] . '_Form_Task::preProcessCommon( $this, true );'); $values = $this->controller->exportValues('Search'); } else { $values = $this->controller->exportValues('Basic'); } } } } $componentMode = $this->get('component_mode'); switch ($componentMode) { case 2: require_once "CRM/Contribute/Form/Task.php"; CRM_Contribute_Form_Task::preProcessCommon($this, true); $this->_exportMode = self::CONTRIBUTE_EXPORT; $componentName = array('', 'Contribute'); break; case 3: require_once "CRM/Event/Form/Task.php"; CRM_Event_Form_Task::preProcessCommon($this, true); $this->_exportMode = self::EVENT_EXPORT; $componentName = array('', 'Event'); break; case 4: require_once "CRM/Activity/Form/Task.php"; CRM_Activity_Form_Task::preProcessCommon($this, true); $this->_exportMode = self::ACTIVITY_EXPORT; $componentName = array('', 'Activity'); break; } require_once 'CRM/Contact/Task.php'; $this->_task = $values['task']; if ($this->_exportMode == self::CONTACT_EXPORT) { $contactTasks = CRM_Contact_Task::taskTitles(); $taskName = $contactTasks[$this->_task]; require_once "CRM/Contact/Form/Task.php"; CRM_Contact_Form_Task::preProcessCommon($this, true); } else { $this->assign('taskName', "Export {$componentName['1']}"); eval('$componentTasks = CRM_' . $componentName[1] . '_Task::tasks();'); $taskName = $componentTasks[$this->_task]; } if ($this->_componentTable) { $query = "\nSELECT count(*)\nFROM {$this->_componentTable}\n"; $totalSelectedRecords = CRM_Core_DAO::singleValueQuery($query); } else { $totalSelectedRecords = count($this->_componentIds); } $this->assign('totalSelectedRecords', $totalSelectedRecords); $this->assign('taskName', $taskName); // all records actions = save a search if ($values['radio_ts'] == 'ts_all' || $this->_task == CRM_Contact_Task::SAVE_SEARCH) { $this->_selectAll = true; $this->assign('totalSelectedRecords', $this->get('rowCount')); } $this->set('componentIds', $this->_componentIds); $this->set('selectAll', $this->_selectAll); $this->set('exportMode', $this->_exportMode); $this->set('componentClause', $this->_componentClause); $this->set('componentTable', $this->_componentTable); }
/** * Process the form after the input has been submitted and validated. */ public function postProcess() { // Clear any formRule errors from Email form in case they came back here via Cancel button $this->controller->resetPage('Email'); $params = $this->exportValues(); $this->_contacts = array(); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); // Get assignee contacts. if (!empty($params['assigned_to'])) { foreach ($this->_activityHolderIds as $key => $id) { $ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $assigneeID)); $this->_contacts = array_merge($this->_contacts, $ids); } } // Get target contacts. if (!empty($params['with_contact'])) { foreach ($this->_activityHolderIds as $key => $id) { $ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $targetID)); $this->_contacts = array_merge($this->_contacts, $ids); } } // Get 'Added by' contacts. if (!empty($params['created_by'])) { parent::setContactIDs(); if (!empty($this->_contactIds)) { $this->_contacts = array_merge($this->_contacts, $this->_contactIds); } } $this->_contacts = array_unique($this->_contacts); // Bounce to pick option if no contacts to send to. if (empty($this->_contacts)) { $urlParams = "_qf_PickOption_display=true&qfKey={$params['qfKey']}"; $urlRedirect = CRM_Utils_System::url('civicrm/activity/search', $urlParams); CRM_Core_Error::statusBounce(ts('It appears you have no contacts with email addresses from the selected recipients.'), $urlRedirect); } $this->set('contacts', $this->_contacts); }
/** * process the form after the input has been submitted and validated * * @access public * * @return None */ public function postProcess() { $params = $this->exportValues(); $this->_contacts = array(); //get assignee contacts if ($params['assigned_to']) { foreach ($this->_activityHolderIds as $key => $id) { $ids = array_keys(CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($id)); $this->_contacts = array_merge($this->_contacts, $ids); } } //get target contacts if ($params['with_contact']) { foreach ($this->_activityHolderIds as $key => $id) { $ids = array_keys(CRM_Activity_BAO_ActivityTarget::getTargetNames($id)); $this->_contacts = array_merge($this->_contacts, $ids); } } //get 'Added by' contacts if ($params['created_by']) { parent::setContactIDs(); if (!empty($this->_contactIds)) { $this->_contacts = array_merge($this->_contacts, $this->_contactIds); } } $this->_contacts = array_unique($this->_contacts); //bounce to pick option if no contacts to send to if (empty($this->_contacts)) { $urlParams = "_qf_PickOption_display=true&qfKey={$params['qfKey']}"; $urlRedirect = CRM_Utils_System::url('civicrm/activity/search', $urlParams); CRM_Core_Error::statusBounce(ts('It appears you have no contacts with emails from the selected recipients.'), $urlRedirect); } $this->set('contacts', $this->_contacts); }
/** * Build all the data structures needed to build the form. * * @param * * @return void */ public function preProcess() { //special case for custom search, directly give option to download csv file $customSearchID = $this->get('customSearchID'); if ($customSearchID) { CRM_Export_BAO_Export::exportCustom($this->get('customSearchClass'), $this->get('formValues'), $this->get(CRM_Utils_Sort::SORT_ORDER)); } $this->_selectAll = FALSE; $this->_exportMode = self::CONTACT_EXPORT; $this->_componentIds = array(); $this->_componentClause = NULL; // get the submitted values based on search if ($this->_action == CRM_Core_Action::ADVANCED) { $values = $this->controller->exportValues('Advanced'); } elseif ($this->_action == CRM_Core_Action::PROFILE) { $values = $this->controller->exportValues('Builder'); } elseif ($this->_action == CRM_Core_Action::COPY) { $values = $this->controller->exportValues('Custom'); } else { // we need to determine component export $stateMachine = $this->controller->getStateMachine(); $formName = CRM_Utils_System::getClassName($stateMachine); $componentName = explode('_', $formName); $components = array('Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity'); if (in_array($componentName[1], $components)) { switch ($componentName[1]) { case 'Contribute': $this->_exportMode = self::CONTRIBUTE_EXPORT; break; case 'Member': $this->_exportMode = self::MEMBER_EXPORT; break; case 'Event': $this->_exportMode = self::EVENT_EXPORT; break; case 'Pledge': $this->_exportMode = self::PLEDGE_EXPORT; break; case 'Case': $this->_exportMode = self::CASE_EXPORT; break; case 'Grant': $this->_exportMode = self::GRANT_EXPORT; break; case 'Activity': $this->_exportMode = self::ACTIVITY_EXPORT; break; } $className = "CRM_{$componentName[1]}_Form_Task"; $className::preProcessCommon($this, TRUE); $values = $this->controller->exportValues('Search'); } else { $values = $this->controller->exportValues('Basic'); } } $count = 0; $this->_matchingContacts = FALSE; if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_sel') { foreach ($values as $key => $value) { if (strstr($key, 'mark_x')) { $count++; } if ($count > 2) { $this->_matchingContacts = TRUE; break; } } } $componentMode = $this->get('component_mode'); switch ($componentMode) { case 2: CRM_Contribute_Form_Task::preProcessCommon($this, TRUE); $this->_exportMode = self::CONTRIBUTE_EXPORT; $componentName = array('', 'Contribute'); break; case 3: CRM_Event_Form_Task::preProcessCommon($this, TRUE); $this->_exportMode = self::EVENT_EXPORT; $componentName = array('', 'Event'); break; case 4: CRM_Activity_Form_Task::preProcessCommon($this, TRUE); $this->_exportMode = self::ACTIVITY_EXPORT; $componentName = array('', 'Activity'); break; case 5: CRM_Member_Form_Task::preProcessCommon($this, TRUE); $this->_exportMode = self::MEMBER_EXPORT; $componentName = array('', 'Member'); break; case 6: CRM_Case_Form_Task::preProcessCommon($this, TRUE); $this->_exportMode = self::CASE_EXPORT; $componentName = array('', 'Case'); break; } $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, TRUE); } else { $this->assign('taskName', "Export {$componentName['1']}"); $className = "CRM_{$componentName[1]}_Task"; $componentTasks = $className::tasks(); $taskName = $componentTasks[$this->_task]; $component = TRUE; } if ($this->_componentTable) { $query = "\nSELECT count(*)\nFROM {$this->_componentTable}\n"; $totalSelectedRecords = CRM_Core_DAO::singleValueQuery($query); } else { $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; $rowCount = $this->get('rowCount'); if ($rowCount > 2) { $this->_matchingContacts = TRUE; } $this->assign('totalSelectedRecords', $rowCount); } $this->assign('matchingContacts', $this->_matchingContacts); $this->set('componentIds', $this->_componentIds); $this->set('selectAll', $this->_selectAll); $this->set('exportMode', $this->_exportMode); $this->set('componentClause', $this->_componentClause); $this->set('componentTable', $this->_componentTable); }
/** * process the form after the input has been submitted and validated * * @access public * @return None */ public function postProcess() { $params = $this->exportValues(); $this->_contacts = array(); //get assignee contacts if ($params['assigned_to']) { require_once 'CRM/Activity/BAO/ActivityAssignment.php'; foreach ($this->_activityHolderIds as $key => $id) { $ids = array_keys(CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($id)); $this->_contacts = array_merge($this->_contacts, $ids); } } //get target contacts if ($params['with_contact']) { require_once 'CRM/Activity/BAO/ActivityTarget.php'; foreach ($this->_activityHolderIds as $key => $id) { $ids = array_keys(CRM_Activity_BAO_ActivityTarget::getTargetNames($id)); $this->_contacts = array_merge($this->_contacts, $ids); } } //get 'Added by' contacts if ($params['created_by']) { parent::setContactIDs(); if (!empty($this->_contactIds)) { $this->_contacts = array_merge($this->_contacts, $this->_contactIds); } } $this->_contacts = array_unique($this->_contacts); $this->set('contacts', $this->_contacts); }