/** * Performs the search. * * Stashes the results in $this->searchResults. * * @return array $this->searchResults */ public function search() { $projects = CRM_Volunteer_BAO_Project::retrieve($this->searchParams['project']); foreach ($projects as $project) { $results = array(); $flexibleNeed = civicrm_api3('VolunteerNeed', 'getsingle', array('id' => $project->flexible_need_id)); if ($flexibleNeed['visibility_id'] === CRM_Core_OptionGroup::getValue('visibility', 'public', 'name')) { $needId = $flexibleNeed['id']; $results[$needId] = $flexibleNeed; } $openNeeds = $project->open_needs; foreach ($openNeeds as $key => $need) { if ($this->needFitsSearchCriteria($need)) { $results[$key] = $need; } } if (!empty($results)) { $this->projects[$project->id] = array(); } $this->searchResults += $results; } $this->getSearchResultsProjectData(); usort($this->searchResults, array($this, "usortDateAscending")); return $this->searchResults; }
/** * Retrieve records. */ public static function getBatchList() { $sortMapper = array(0 => 'batch.title', 1 => 'batch.type_id', 2 => '', 3 => 'batch.total', 4 => 'batch.status_id', 5 => ''); $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0; $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25; $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL; $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc'; $context = isset($_REQUEST['context']) ? CRM_Utils_Type::escape($_REQUEST['context'], 'String') : NULL; $params = $_REQUEST; if ($sort && $sortOrder) { $params['sortBy'] = $sort . ' ' . $sortOrder; } $params['page'] = $offset / $rowCount + 1; $params['rp'] = $rowCount; if ($context != 'financialBatch') { // data entry status batches $params['status_id'] = CRM_Core_OptionGroup::getValue('batch_status', 'Data Entry', 'name'); } $params['context'] = $context; // get batch list $batches = CRM_Batch_BAO_Batch::getBatchListSelector($params); $iFilteredTotal = $iTotal = $params['total']; if ($context == 'financialBatch') { $selectorElements = array('check', 'batch_name', 'payment_instrument', 'item_count', 'total', 'status', 'created_by', 'links'); } else { $selectorElements = array('batch_name', 'type', 'item_count', 'total', 'status', 'created_by', 'links'); } CRM_Utils_System::setHttpHeader('Content-Type', 'application/json'); echo CRM_Utils_JSON::encodeDataTableSelector($batches, $sEcho, $iTotal, $iFilteredTotal, $selectorElements); CRM_Utils_System::civiExit(); }
/** * Adjust Metadata for Create action * * The metadata is used for setting defaults, documentation & validation * @param array $params array or parameters determined by getfields */ function _civicrm_api3_volunteer_need_create_spec(&$params) { $params['project_id']['api.required'] = 1; $params['is_flexible']['api.default'] = 0; $params['is_active']['api.default'] = 1; $params['visibility_id']['api.default'] = CRM_Core_OptionGroup::getValue('visibility', 'public', 'name'); }
/** * Common form elements. */ public function buildQuickForm() { $config = CRM_Core_Config::singleton(); $uploadFileSize = CRM_Utils_Number::formatUnitSize($config->maxFileSize . 'm', TRUE); $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $this->assign('uploadSize', $uploadSize); $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $this->setMaxFileSize($uploadFileSize); $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); $this->add('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2), TRUE); $this->setDefaults(array('fieldSeparator' => $config->fieldSeparator)); //get the saved mapping details $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import ' . static::IMPORT_ENTITY, 'name')); $this->assign('savedMapping', $mappingArray); $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); if ($loadedMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadedMapping); $this->setDefaults(array('savedMapping' => $loadedMapping)); } //build date formats CRM_Core_Form_Date::buildAllowedDateFormats($this); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Test simple create via API */ function testCreateNeed() { $project = CRM_Core_DAO::createTestObject('CRM_Volunteer_BAO_Project'); $this->assertObjectHasAttribute('id', $project, 'Failed to prepopulate Volunteer Project'); $params = array("project_id" => $project->id, "start_time" => "2013-12-17 16:00:00", "duration" => 240, "is_flexible" => 0, "quantity" => 1, "visibility_id" => CRM_Core_OptionGroup::getValue('visibility', 'public', 'name'), "role_id" => 1, "is_active" => 1); $this->callAPIAndDocument('VolunteerNeed', 'create', $params, __FUNCTION__, __FILE__); }
/** * @param CRM_Core_Form $form */ public static function preProcess(&$form) { //get multi client case configuration $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process(); $form->_allowMultiClient = (bool) $xmlProcessorProcess->getAllowMultipleCaseClients(); if ($form->_context == 'caseActivity') { $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $form); $atype = CRM_Core_OptionGroup::getValue('activity_type', 'Change Case Start Date', 'name'); $caseId = CRM_Utils_Array::first($form->_caseId); $form->assign('changeStartURL', CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$contactID}&caseid={$caseId}&atype={$atype}")); return; } $form->_context = CRM_Utils_Request::retrieve('context', 'String', $form); $form->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $form); $form->assign('context', $form->_context); // check if the case type id passed in url is a valid one $caseTypeId = CRM_Utils_Request::retrieve('ctype', 'Positive', $form); $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('case_status_id', '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); $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url('civicrm/case', 'reset=1')); }
/** * Build the form object. * * @return void */ public function buildQuickForm() { //Setting Upload File Size $config = CRM_Core_Config::singleton(); $uploadFileSize = CRM_Core_Config_Defaults::formatUnitSize($config->maxFileSize . 'm', TRUE); $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $this->assign('uploadSize', $uploadSize); $this->setMaxFileSize($uploadFileSize); $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); $duplicateOptions = array(); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Fill'), CRM_Import_Parser::DUPLICATE_FILL); $this->addGroup($duplicateOptions, 'onDuplicate', ts('On duplicate entries')); //get the saved mapping details $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Activity', 'name')); $this->assign('savedMapping', $mappingArray); $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); if ($loadeMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadeMapping); $this->setDefaults(array('savedMapping' => $loadeMapping)); } $this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP)); //build date formats CRM_Core_Form_Date::buildAllowedDateFormats($this); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Create a new Activity. * * Creates a new Activity record and returns the newly created * activity object (including the contact_id property). Minimum * required data values for the various contact_type are: * * Properties which have administratively assigned sets of values * If an unrecognized value is passed, an error * will be returned. * * Modules may invoke crm_get_contact_values($contactID) to * retrieve a list of currently available values for a given * property. * @param array $params Associative array of property name/value * pairs to insert in new contact. * @param string $activity_type Which class of contact is being created. * Valid values = 'SMS', 'Meeting', 'Event', 'PhoneCall'. * {@schema Activity/Activity.xml} * * @return CRM_Activity|CRM_Error Newly created Activity object * */ function &civicrm_activity_create(&$params) { _civicrm_initialize(); $errors = array(); // check for various error and required conditions $errors = _civicrm_activity_check_params($params, true); if (!empty($errors)) { return $errors; } // processing for custom data $values = array(); _civicrm_custom_format_params($params, $values, 'Activity'); if (!empty($values['custom'])) { $params['custom'] = $values['custom']; } if (!CRM_Utils_Array::value('activity_type_id', $params)) { $params['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', $params['activity_name'], 'name'); } // create activity $activity = CRM_Activity_BAO_Activity::create($params); if (!is_a($activity, 'CRM_Core_Error') && isset($activity->id)) { $activityArray = array('is_error' => 0); } else { $activityArray = array('is_error' => 1); } _civicrm_object_to_array($activity, $activityArray); return $activityArray; }
/** * Implementation of hook_civicrm_install */ function hrvisa_civicrm_install() { if (!CRM_Core_OptionGroup::getValue('activity_type', 'Visa Expiration', 'name')) { // create activity_type 'Visa Expiration' $params = array('weight' => 1, 'label' => 'Visa Expiration', 'filter' => 0, 'is_active' => 1, 'is_default' => 0); $result = civicrm_api3('activity_type', 'create', $params); if (CRM_Utils_Array::value('is_error', $result, FALSE)) { CRM_Core_Error::debug_var("Failed to create activity type 'Visa Expiration'", $result); throw new CRM_Core_Exception('Failed to create activity type \'Visa Expiration\''); } $activityTypeId = $result['values'][$result['id']]['value']; } else { $activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Visa Expiration', 'name'); } // set weekly reminder for Visa Expiration activities (not active) // will be active when extension is enabled if (!empty($activityTypeId)) { $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); // schedule reminder for Visa Expiration Creation $result = civicrm_api3('action_schedule', 'get', array('name' => 'Visa Expiration Reminder')); if (empty($result['id'])) { $params = array('name' => 'Visa Expiration Reminder', 'title' => 'Visa Expiration Reminder', 'recipient' => $targetID, 'limit_to' => 1, 'entity_value' => $activityTypeId, 'entity_status' => CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name'), 'start_action_offset' => 1, 'start_action_unit' => 'week', 'start_action_condition' => 'before', 'start_action_date' => 'activity_date_time', 'is_repeat' => 0, 'is_active' => 0, 'body_html' => '<p>Your latest visa expiries on {activity.activity_date_time}</p>', 'subject' => 'Reminder for Visa Expiration', 'record_activity' => 1, 'mapping_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', 'activity_type', 'id', 'entity_value')); $result = civicrm_api3('action_schedule', 'create', $params); } } return _hrvisa_civix_civicrm_install(); }
/** * create a mandate * * @author endres -at- systopia.de * @return array with mandate data */ function createMandate($mandate_parms = array(), $contrib_parms = array()) { // read the payment instrument ids $payment_instrument_OOFF = (int) CRM_Core_OptionGroup::getValue('payment_instrument', 'OOFF', 'name'); $this->assertNotEmpty($payment_instrument_OOFF, "Could not find the 'OOFF' payment instrument."); $payment_instrument_RCUR = (int) CRM_Core_OptionGroup::getValue('payment_instrument', 'RCUR', 'name'); $this->assertNotEmpty($payment_instrument_RCUR, "Could not find the 'RCUR' payment instrument."); $contribution_status_pending = (int) CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name'); $this->assertNotEmpty($contribution_status_pending, "Could not find the 'Pending' contribution status."); $mode = empty($mandate_parms['type']) ? 'OOFF' : $mandate_parms['type']; $this->assertTrue($mode == 'OOFF' || $mode == 'RCUR', "Mandat can only be of type 'OOFF' or 'RCUR'!"); $contribution_entity = $mode == 'OOFF' ? 'Contribution' : 'ContributionRecur'; $contribution_table = $mode == 'OOFF' ? 'civicrm_contribution' : 'civicrm_contribution_recur'; // create a contribution $create_contribution = array('contact_id' => empty($contrib_parms['contact_id']) ? $this->individualCreate() : $contrib_parms['contact_id'], 'financial_type_id' => empty($contrib_parms['financial_type_id']) ? 1 : $contrib_parms['financial_type_id'], 'currency' => empty($contrib_parms['currency']) ? 'EUR' : $contrib_parms['currency'], 'contribution_status_id' => empty($contrib_parms['contribution_status_id']) ? $contribution_status_pending : $contrib_parms['contribution_status_id'], 'is_test' => empty($contrib_parms['is_test']) ? 0 : $contrib_parms['is_test']); if ($mode == 'RCUR') { $create_contribution['payment_instrument_id'] = $payment_instrument_RCUR; $create_contribution['amount'] = empty($contrib_parms['amount']) ? '6.66' : $contrib_parms['amount']; $create_contribution['start_date'] = empty($contrib_parms['start_date']) ? date("Ymd") : $contrib_parms['start_date']; $create_contribution['end_date'] = empty($contrib_parms['end_date']) ? NULL : $contrib_parms['end_date']; $create_contribution['frequency_interval'] = empty($contrib_parms['frequency_interval']) ? 1 : $contrib_parms['frequency_interval']; $create_contribution['frequency_unit'] = empty($contrib_parms['frequency_unit']) ? 'month' : $contrib_parms['frequency_unit']; $create_contribution['cycle_day'] = empty($contrib_parms['cycle_day']) ? date("d", strtotime("+14 days")) : $contrib_parms['cycle_day']; } else { $create_contribution['payment_instrument_id'] = $payment_instrument_OOFF; $create_contribution['total_amount'] = empty($contrib_parms['total_amount']) ? '6.66' : $contrib_parms['total_amount']; $create_contribution['receive_date'] = empty($contrib_parms['receive_date']) ? date('YmdHis') : $contrib_parms['receive_date']; } $contribution = $this->callAPISuccess($contribution_entity, "create", $create_contribution); // create a mandate $create_mandate = array("type" => empty($mandate_parms['type']) ? 'OOFF' : $mandate_parms['type'], "status" => empty($mandate_parms['status']) ? 'INIT' : $mandate_parms['status'], "reference" => empty($mandate_parms['reference']) ? md5(microtime()) : $mandate_parms['reference'], "source" => empty($mandate_parms['source']) ? "TestSource" : $mandate_parms['source'], "date" => empty($mandate_parms['date']) ? date("YmdHis") : $mandate_parms['date'], "creditor_id" => empty($mandate_parms['creditor_id']) ? $this->getCreditor() : $mandate_parms['creditor_id'], "contact_id" => empty($mandate_parms['contact_id']) ? $create_contribution['contact_id'] : $mandate_parms['contact_id'], "iban" => empty($mandate_parms['iban']) ? "DE89370400440532013000" : $mandate_parms['iban'], "bic" => empty($mandate_parms['bic']) ? "INGDDEFFXXX" : $mandate_parms['bic'], "creation_date" => empty($mandate_parms['creation_date']) ? date("YmdHis") : $mandate_parms['creation_date'], "entity_table" => $contribution_table, "entity_id" => $contribution['id']); $mandate = $this->callAPISuccess("SepaMandate", "create", $create_mandate); return $mandate['values'][$mandate['id']]; }
function __construct() { $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE), 'gender_id' => array('title' => ts('Gender'), 'default' => TRUE), 'birth_date' => array('title' => ts('Birthdate'), 'default' => FALSE), 'id' => array('no_display' => TRUE, 'required' => TRUE)), 'filters' => array('sort_name' => array('title' => ts('Contact Name'), 'operatorType' => CRM_Report_Form::OP_STRING), 'contact_type' => array('title' => ts('Contact Type'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('-select-'), 'Individual' => ts('Individual'), 'Organization' => ts('Organization'), 'Household' => ts('Household')), 'default' => 'Individual'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', 'fields' => array('street_address' => array('default' => FALSE), 'city' => array('default' => TRUE), 'postal_code' => NULL, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'), 'default' => FALSE))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => NULL), 'grouping' => 'contact-fields'), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('id' => array('title' => ts('Activity ID'), 'no_display' => TRUE, 'required' => TRUE))), 'civicrm_case' => array('dao' => 'CRM_Case_DAO_Case', 'fields' => array('id' => array('title' => ts('Case ID'), 'required' => TRUE), 'start_date' => array('title' => ts('Case Start'), 'required' => TRUE), 'end_date' => array('title' => ts('Case End'), 'required' => TRUE)), 'filters' => array('case_id_filter' => array('name' => 'id', 'title' => ts('Cases?'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array(1 => ts('Exclude non-case'), 2 => ts('Exclude cases'), 3 => ts('Include Both')), 'default' => 3), 'start_date' => array('title' => ts('Case Start'), 'operatorType' => CRM_Report_Form::OP_DATE), 'end_date' => array('title' => ts('Case End'), 'operatorType' => CRM_Report_Form::OP_DATE))), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_Group', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::group())))); $this->_tagFilter = TRUE; $open_case_val = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name'); $crmDAO =& CRM_Core_DAO::executeQuery("SELECT cg.table_name, cg.extends AS ext, cf.label, cf.column_name FROM civicrm_custom_group cg INNER JOIN civicrm_custom_field cf ON cg.id = cf.custom_group_id\nwhere (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_column_value='{$open_case_val}') AND cg.is_active=1 AND cf.is_active=1 ORDER BY cg.table_name"); $curTable = ''; $curExt = ''; $curFields = array(); while ($crmDAO->fetch()) { if ($curTable == '') { $curTable = $crmDAO->table_name; $curExt = $crmDAO->ext; } elseif ($curTable != $crmDAO->table_name) { // dummy DAO $this->_columns[$curTable] = array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => $curFields, 'ext' => $curExt); $curTable = $crmDAO->table_name; $curExt = $crmDAO->ext; $curFields = array(); } $curFields[$crmDAO->column_name] = array('title' => $crmDAO->label); } if (!empty($curFields)) { // dummy DAO $this->_columns[$curTable] = array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => $curFields, 'ext' => $curExt); } $this->_genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); parent::__construct(); }
public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } $this->add('text', 'title', ts('Petition Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'title'), TRUE); $attributes = CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey'); $petitionTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'petition', 'name'); $this->addElement('hidden', 'activity_type_id', $petitionTypeID); // script / instructions / description of petition purpose $this->addWysiwyg('instructions', ts('Introduction'), $attributes['instructions']); // Campaign id $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value('campaign_id', $this->_values)); $this->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns); $customContactProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Individual')); // custom group id $this->add('select', 'contact_profile_id', ts('Contact Profile'), array('' => ts('- select -')) + $customContactProfiles, TRUE); $customProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Activity')); // custom group id $this->add('select', 'profile_id', ts('Activity Profile'), array('' => ts('- select -')) + $customProfiles); // thank you title and text (html allowed in text) $this->add('text', 'thankyou_title', ts('Thank-you Page Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'thankyou_title')); $this->addWysiwyg('thankyou_text', ts('Thank-you Message'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'thankyou_text')); // bypass email confirmation? $this->add('checkbox', 'bypass_confirm', ts('Bypass email confirmation')); // is active ? $this->add('checkbox', 'is_active', ts('Is Active?')); // is default ? $this->add('checkbox', 'is_default', ts('Is Default?')); // add buttons $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); // add a form rule to check default value $this->addFormRule(array('CRM_Campaign_Form_Survey', 'formRule'), $this); }
public function creatNewShortcut(&$shortCuts) { if (CRM_Core_Permission::check('access all cases and activities') || CRM_Core_Permission::check('add cases')) { $atype = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name'); if ($atype) { $shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/case/add', 'query' => "reset=1&action=add&atype={$atype}&context=standalone", 'ref' => 'new-case', 'title' => ts('Case')))); } } }
/** * Tests CRM_Volunteer_BAO_Assignment::createVolunteerActivity() to ensure * that the project beneficiary is made the activity target. */ function testActivityTarget() { $beneficiaryContactId = $need = $project = $volunteerContactId = NULL; extract($this->setUpProject(), EXTR_IF_EXISTS); $projectContact = CRM_Core_DAO::createTestObject('CRM_Volunteer_BAO_ProjectContact', array('contact_id' => $beneficiaryContactId, 'project_id' => $project->id, 'relationship_type_id' => CRM_Core_OptionGroup::getValue('volunteer_project_relationship', 'volunteer_beneficiary', 'name'))); $this->assertObjectHasAttribute('id', $projectContact, 'Failed to prepopulate VolunteerContact'); $assignmentId = CRM_Volunteer_BAO_Assignment::createVolunteerActivity(array('assignee_contact_id' => $volunteerContactId, 'source_contact_id' => $volunteerContactId, 'volunteer_need_id' => $need->id)); $targetContactId = civicrm_api3('ActivityContact', 'getvalue', array('activity_id' => $assignmentId, 'record_type_id' => 'Activity Targets', 'return' => 'contact_id')); $this->assertEquals($beneficiaryContactId, $targetContactId); }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { require_once 'CRM/Event/BAO/Participant.php'; $values = $ids = array(); $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, true); $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true); $params = array('id' => $participantID); CRM_Event_BAO_Participant::getValues($params, $values, $ids); if (empty($values)) { require_once 'CRM/Core/Error.php'; CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).')); } CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]); if (CRM_Utils_Array::value('fee_level', $values[$participantID])) { CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']); } if ($values[$participantID]['is_test']) { $values[$participantID]['status'] .= ' (test) '; } // Get Note $noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant'); $values[$participantID]['note'] = array_values($noteValue); require_once 'CRM/Price/BAO/LineItem.php'; // Get Line Items $lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID); if (!CRM_Utils_System::isNull($lineItem)) { $values[$participantID]['lineItem'][] = $lineItem; } $values[$participantID]['totalAmount'] = $values[$participantID]['fee_amount']; // get the option value for custom data type $roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name'); $eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name'); $eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name'); $roleGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['role_id'], $roleCustomDataTypeID); $eventGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['event_id'], $eventNameCustomDataTypeID); $eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id'); $eventTypeGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $eventTypeID, $eventTypeCustomDataTypeID); $groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree); $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree); $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID)); CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree); $this->assign($values[$participantID]); // add viewed participant to recent items list require_once 'CRM/Utils/Recent.php'; require_once 'CRM/Contact/BAO/Contact.php'; $url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home"); $participantRoles = CRM_Event_PseudoConstant::participantRole(); $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title'); $displayName = CRM_Contact_BAO_Contact::displayName($contactID); $this->assign('displayName', $displayName); $title = $displayName . ' (' . $participantRoles[$values[$participantID]['role_id']] . ' - ' . $eventTitle . ')'; // add Participant to Recent Items CRM_Utils_Recent::add($title, $url, $values[$participantID]['id'], 'Participant', $values[$participantID]['contact_id'], null); }
static function sync($contactId) { // get visa required value $getInfo = array('entity_id' => $contactId, 'return.Extended_Demographics:Is_Visa_Required' => 1); $isVisaRequired = civicrm_api3('custom_value', 'get', $getInfo); $isVisaRequired = $isVisaRequired['count'] ? $isVisaRequired['values']["{$isVisaRequired['id']}"][0] : 0; // this api call will get visa expiration date // of immigration records for the contact $getInfo = array('entity_id' => $contactId, 'return.Immigration:End_Date' => 1); $immigrationDateInfo = civicrm_api3('custom_value', 'get', $getInfo); $lastestVisaExpirationDate = NULL; if ($immigrationDateInfo['count'] > 0) { $lastestVisaExpirationDate = $immigrationDateInfo['values']["{$immigrationDateInfo['id']}"]['latest']; } // activity processing if immigration data found if ($immigrationDateInfo['count']) { // get 'Visa Expiration' activity for this contact $activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Visa Expiration', 'name'); $activityStatuses = CRM_Core_OptionGroup::values('activity_status', FALSE, FALSE, FALSE, NULL, 'name'); // to check if visa expiration activity exists for the input target_contact_id $activityGetParams = array('contact_id' => $contactId, 'activity_type_id' => $activityTypeId, 'sequential' => 1); // note : using filter 'activity_type_id' in combination with 'contact_id' filter doesn't work $activities = civicrm_api3('activity', 'get', $activityGetParams); $activityId = NULL; $count = 0; foreach ($activities['values'] as $val) { if ($val['activity_type_id'] != $activityTypeId || !array_key_exists('targets', $val)) { continue; } $activityId = $val['id']; $count++; } if ($count) { $activityParams = array(); $activityParams['status_id'] = $isVisaRequired ? CRM_Utils_Array::key('Scheduled', $activityStatuses) : CRM_Utils_Array::key('Cancelled', $activityStatuses); $activityParams['activity_date_time'] = $lastestVisaExpirationDate; // check if count is one, if not log a error if ($count > 1) { // update the last activity and log a error $logError = "Multiple 'Visa Expiration' activities exists for target contact with id : {$contactId}, so updating last activity with id : {$activityId}"; CRM_Core_Error::debug_log_message($logError); } $activityParams['id'] = $activityId; $result = civicrm_api3('activity', 'create', $activityParams); } else { // if no activity create a new one only if 'visa is required' if ($isVisaRequired) { $activityParams = array('target_contact_id' => $contactId, 'activity_type_id' => $activityTypeId, 'subject' => 'Visa Expiration', 'activity_date_time' => $lastestVisaExpirationDate, 'status_id' => CRM_Utils_Array::key('Scheduled', $activityStatuses), 'details' => 'Visa Expiration'); $result = civicrm_api3('activity', 'create', $activityParams); } } } // end of if for immgration info check }
/** * Test simple get via API */ function testGetProjectContactById() { $relTypeId = CRM_Core_OptionGroup::getValue(CRM_Volunteer_BAO_ProjectContact::RELATIONSHIP_OPTION_GROUP, 'volunteer_owner', 'name'); $relTypeLabel = CRM_Core_OptionGroup::getLabel(CRM_Volunteer_BAO_ProjectContact::RELATIONSHIP_OPTION_GROUP, $relTypeId); $dao = CRM_Core_DAO::createTestObject('CRM_Volunteer_BAO_ProjectContact', array('relationship_type_id' => $relTypeId)); $this->assertObjectHasAttribute('id', $dao, 'Failed to prepopulate Volunteer Project Contact'); $api = $this->callAPIAndDocument('VolunteerProjectContact', 'get', array('id' => $dao->id), __FUNCTION__, __FILE__); // make sure the label and machine name are returned $vpc = $api['values'][1]; $this->assertEquals('volunteer_owner', $vpc['relationship_type_name']); $this->assertEquals($relTypeLabel, $vpc['relationship_type_label']); }
/** * Function to actually build the form * * @return None * @access public */ public function buildQuickForm() { //Setting Upload File Size $config = CRM_Core_Config::singleton(); if ($config->maxImportFileSize >= 8388608) { $uploadFileSize = 8388608; } else { $uploadFileSize = $config->maxImportFileSize; } $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $this->assign('uploadSize', $uploadSize); $this->add('file', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=60', true); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $this->setMaxFileSize($uploadFileSize); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); $duplicateOptions = array(); $duplicateOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Insert new contributions'), CRM_Contribute_Import_Parser::DUPLICATE_SKIP); $duplicateOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Update existing contributions'), CRM_Contribute_Import_Parser::DUPLICATE_UPDATE); $this->addGroup($duplicateOptions, 'onDuplicate', ts('Import mode')); //get the saved mapping details require_once "CRM/Core/BAO/Mapping.php"; require_once "CRM/Core/OptionGroup.php"; $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contribution', 'name')); $this->assign('savedMapping', $mappingArray); $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); $this->addElement('submit', 'loadMapping', ts('Load Mapping'), null, array('onclick' => 'checkSelect()')); if ($loadeMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadeMapping); $this->setDefaults(array('savedMapping' => $loadeMapping)); } $this->setDefaults(array('onDuplicate' => CRM_Contribute_Import_Parser::DUPLICATE_SKIP)); //contact types option require_once 'CRM/Contact/BAO/ContactType.php'; $contactOptions = array(); if (CRM_Contact_BAO_ContactType::isActive('Individual')) { $contactOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Individual'), CRM_Contribute_Import_Parser::CONTACT_INDIVIDUAL); } if (CRM_Contact_BAO_ContactType::isActive('Household')) { $contactOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Household'), CRM_Contribute_Import_Parser::CONTACT_HOUSEHOLD); } if (CRM_Contact_BAO_ContactType::isActive('Organization')) { $contactOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Organization'), CRM_Contribute_Import_Parser::CONTACT_ORGANIZATION); } $this->addGroup($contactOptions, 'contactType', ts('Contact Type')); $this->setDefaults(array('contactType' => CRM_Contribute_Import_Parser::CONTACT_INDIVIDUAL)); //build date formats require_once 'CRM/Core/Form/Date.php'; CRM_Core_Form_Date::buildAllowedDateFormats($this); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { //Setting Upload File Size $config = CRM_Core_Config::singleton(); if ($config->maxImportFileSize >= 8388608) { $uploadFileSize = 8388608; } else { $uploadFileSize = $config->maxImportFileSize; } $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $this->assign('uploadSize', $uploadSize); $this->add('file', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $this->setMaxFileSize($uploadFileSize); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); $duplicateOptions = array(); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK); // for contributions NOCHECK == SKIP // $duplicateOptions[] = $this->createElement('radio', // null, null, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK); $this->addGroup($duplicateOptions, 'onDuplicate', ts('On Duplicate Entries')); //get the saved mapping details $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Participant', 'name')); $this->assign('savedMapping', $mappingArray); $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); if ($loadeMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadeMapping); $this->setDefaults(array('savedMapping' => $loadeMapping)); } $this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP)); //contact types option $contactOptions = array(); if (CRM_Contact_BAO_ContactType::isActive('Individual')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Individual'), CRM_Import_Parser::CONTACT_INDIVIDUAL); } if (CRM_Contact_BAO_ContactType::isActive('Household')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Household'), CRM_Import_Parser::CONTACT_HOUSEHOLD); } if (CRM_Contact_BAO_ContactType::isActive('Organization')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Organization'), CRM_Import_Parser::CONTACT_ORGANIZATION); } $this->addGroup($contactOptions, 'contactType', ts('Contact Type')); $this->setDefaults(array('contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL)); //build date formats CRM_Core_Form_Date::buildAllowedDateFormats($this); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Returns value of the field * * @param object CRM_Civirules_TriggerData_TriggerData $triggerData * @return mixed * @access protected */ protected function getFieldValue(CRM_Civirules_TriggerData_TriggerData $triggerData) { $completed_status_id = CRM_Core_OptionGroup::getValue('contribution_status', 'completed', 'name'); $contact_id = $triggerData->getContactId(); $params[1] = array($completed_status_id, 'Integer'); $params[2] = array($contact_id, 'Integer'); $last_date = CRM_Core_DAO::singleValueQuery("SELECT MAX(`receive_date`) FROM `civicrm_contribution` WHERE `contribution_status_id` = %1 AND `contact_id` = %2", $params); if ($last_date) { $last_date = new DateTime($last_date); return $last_date->diff(new DateTime('now'))->days; } return false; //undefined contribution date }
static function preProcess(&$form) { //get multi client case configuration $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process(); $form->_allowMultiClient = (bool) $xmlProcessorProcess->getAllowMultipleCaseClients(); if ($form->_context == 'caseActivity') { $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $form); $atype = CRM_Core_OptionGroup::getValue('activity_type', 'Change Case Start Date', 'name'); $form->assign('changeStartURL', CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$contactID}&caseid={$form->_caseId}&atype={$atype}")); return; } $form->_context = CRM_Utils_Request::retrieve('context', 'String', $form); $form->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $form); $form->assign('context', $form->_context); }
/** * creates a varible amount of contributions * * @author endres -at- systopia.de * bochan -at- systopia.de * @return array with contribution ids */ function generateContributions($count = 2) { $contribution_status_pending = (int) CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name'); $this->assertNotEmpty($contribution_status_pending, "Could not find the 'Pending' contribution status."); $create_contribution = array('contact_id' => $this->individualCreate(), 'financial_type_id' => 1, 'currency' => 'EUR', 'contribution_status_id' => $contribution_status_pending, 'is_test' => 0); $create_contribution['payment_instrument_id'] = 1; $result = array(); for ($c = 0; $c < $count; $c++) { $create_contribution['total_amount'] = number_format((double) rand(1, 1000), 2, '.', ''); $create_contribution['receive_date'] = date('YmdHis'); $contribution = $this->callAPISuccess("Contribution", "create", $create_contribution); $result[] = $contribution['id']; } return $result; }
protected function saveProject($params) { $this->minimumProjectParams($params); $this->_project = CRM_Volunteer_BAO_Project::create($params); // if we created a project: if (!key_exists('id', $params)) { $form = $this->getSubmitValues(); if (CRM_Utils_Array::value('is_active', $form, 0) === '1') { // create the flexible need $need = array('project_id' => $this->_project->id, 'is_flexible' => '1', 'visibility_id' => CRM_Core_OptionGroup::getValue('visibility', 'public', 'name')); CRM_Volunteer_BAO_Need::create($need); } } return $this->_project; }
/** * Tests the project_contacts parameter to the create API, i.e., tests the * ability to specify at project creation the contacts related to the project. */ function testCreateProjectWithContacts() { $contactId1 = $this->individualCreate(); $contactId2 = $this->individualCreate(); $contactId3 = $this->individualCreate(); $projectContacts = array('volunteer_owner' => array($contactId1), 'volunteer_manager' => array($contactId2, $contactId3)); $params = array('entity_id' => 1, 'entity_table' => 'civicrm_event', 'is_active' => 1, 'project_contacts' => $projectContacts, 'title' => 'Unit Testing for CiviVolunteer (How Meta)'); $this->callAPIAndDocument('VolunteerProject', 'create', $params, __FUNCTION__, __FILE__); $bao = new CRM_Volunteer_BAO_ProjectContact(); $bao->project_id = 1; $bao->relationship_type_id = CRM_Core_OptionGroup::getValue(CRM_Volunteer_BAO_ProjectContact::RELATIONSHIP_OPTION_GROUP, 'volunteer_owner', 'name'); $this->assertEquals(count($projectContacts['volunteer_owner']), $bao->find()); $bao->relationship_type_id = CRM_Core_OptionGroup::getValue(CRM_Volunteer_BAO_ProjectContact::RELATIONSHIP_OPTION_GROUP, 'volunteer_manager', 'name'); $this->assertEquals(count($projectContacts['volunteer_manager']), $bao->find()); }
/** * Test create with scheduled dates. */ public function testActionScheduleWithScheduledDatesCreate() { $oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule'); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $scheduledStatus = CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name'); $activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', "Meeting", 'name'); $title = "simpleActionSchedule" . substr(sha1(rand()), 0, 7); $params = array('title' => $title, 'recipient' => $assigneeID, 'limit_to' => 1, 'entity_value' => $activityTypeId, 'entity_status' => $scheduledStatus, 'is_active' => 1, 'record_activity' => 1, 'mapping_id' => CRM_Activity_ActionMapping::ACTIVITY_MAPPING_ID, 'start_action_offset' => 3, 'start_action_unit' => 'day', 'start_action_condition' => 'before', 'start_action_date' => 'activity_date_time', 'is_repeat' => 1, 'repetition_frequency_unit' => 'day', 'repetition_frequency_interval' => 3, 'end_frequency_unit' => 'hour', 'end_frequency_interval' => 0, 'end_action' => 'before', 'end_date' => 'activity_date_time', 'body_html' => 'Test description', 'subject' => 'Test subject'); $actionSchedule = $this->callAPISuccess('action_schedule', 'create', $params); $this->assertTrue(is_numeric($actionSchedule['id'])); $this->assertTrue($actionSchedule['id'] > 0); $this->assertEquals($actionSchedule['values'][$actionSchedule['id']]['start_action_offset'][0], $params['start_action_offset']); $newCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule'); $this->assertEquals($oldCount + 1, $newCount); }
public function postProcess() { // check if mailing tab is enabled, if not prompt user to enable the tab if "write_activity_record" is disabled $params = $this->controller->exportValues($this->_name); if (empty($params['write_activity_record'])) { $existingViewOptions = Civi::settings()->get('contact_view_options'); $displayValue = CRM_Core_OptionGroup::getValue('contact_view_options', 'CiviMail', 'name'); $viewOptions = explode(CRM_Core_DAO::VALUE_SEPARATOR, $existingViewOptions); if (!in_array($displayValue, $viewOptions)) { $existingViewOptions .= $displayValue . CRM_Core_DAO::VALUE_SEPARATOR; Civi::settings()->set('contact_view_options', $existingViewOptions); CRM_Core_Session::setStatus(ts('We have automatically enabled the Mailings tab for the Contact Summary screens so that you can view mailings sent to each contact.'), ts('Saved'), 'success'); } } parent::postProcess(); }
public function run() { $this->preProcess(); // get the class name from the participantListingID $className = CRM_Core_OptionGroup::getValue('participant_listing', $this->_participantListingID, 'value', 'Integer', 'description'); if ($className == 'CRM_Event_Page_ParticipantListing') { CRM_Core_Error::fatal(ts("Participant listing code file cannot be '%1'", array(1 => $className))); } $classFile = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; $error = (include_once $classFile); if ($error == FALSE) { CRM_Core_Error::fatal('Participant listing code file: ' . $classFile . ' does not exist. Please verify your custom particpant listing settings in CiviCRM administrative panel.'); } $participantListingClass = new $className(); $participantListingClass->preProcess(); $participantListingClass->run(); }
/** * Set new activity status for Scheduled activity. * * @param int $activity_id * @param string $status * * @throws CiviCRM_API3_Exception */ public function setActivityStatus($activity_id, $status = 'optout') { if ($activity_id > 0) { $scheduled_id = CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name', 'String', 'value'); $params = array('sequential' => 1, 'id' => $activity_id, 'status_id' => $scheduled_id); CRM_Core_Error::debug_var('$paramsActivityGet', $params, false, true); $result = civicrm_api3('Activity', 'get', $params); CRM_Core_Error::debug_var('$resultActivityGet', $result, false, true); if ($result['count'] == 1) { $new_status_id = CRM_Core_OptionGroup::getValue('activity_status', $status, 'name', 'String', 'value'); $params['status_id'] = $new_status_id; CRM_Core_Error::debug_var('$paramsActivity-create', $params, false, true); $result = civicrm_api3('Activity', 'create', $params); CRM_Core_Error::debug_var('$resultActivity-create', $result, false, true); } } }
/** * Returns value of the field * * @param object CRM_Civirules_EventData_EventData $eventData * @return mixed * @access protected */ protected function getFieldValue(CRM_Civirules_EventData_EventData $eventData) { $completed_status_id = CRM_Core_OptionGroup::getValue('contribution_status', 'completed', 'name'); $contact_id = $eventData->getContactId(); $sql = "SELECT SUM(`total_amount`)\n FROM `civicrm_contribution`\n WHERE `contribution_status_id` = %1 AND `contact_id` = %2"; $params[1] = array($completed_status_id, 'Integer'); $params[2] = array($contact_id, 'Integer'); $periodStartDate = CRM_CivirulesConditions_Utils_Period::convertPeriodToStartDate($this->conditionParams); $periodEndDate = CRM_CivirulesConditions_Utils_Period::convertPeriodToEndDate($this->conditionParams); if ($periodStartDate) { $sql .= " AND DATE(`receive_date`) >= '" . $periodStartDate->format('Y-m-d') . "'"; } if ($periodEndDate) { $sql .= " AND DATE(`receive_date`) <= '" . $periodEndDate->format('Y-m-d') . "'"; } $total_amount = (double) CRM_Core_DAO::singleValueQuery($sql, $params); return $total_amount; }
/** * @param $self */ public static function commonBuildQuickForm($self) { $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $self); if (!$contactId) { $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST); } $urlParams = "action=add&reset=1&cid={$contactId}&selectedChild=activity&atype="; $activityTypes = $urls = array(); $emailTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'); $letterTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name'); $SMSId = CRM_Core_OptionGroup::getValue('activity_type', 'Text Message (SMS)', 'label'); if (CRM_Utils_Mail::validOutBoundMail() && $contactId) { list($name, $email, $doNotEmail, $onHold, $isDeseased) = CRM_Contact_BAO_Contact::getContactDetails($contactId); if (!$doNotEmail && $email && !$isDeseased) { $activityTypes = array($emailTypeId => ts('Send an Email')); } } if ($contactId && CRM_SMS_BAO_Provider::activeProviderCount()) { // Check for existence of a mobile phone and ! do not SMS privacy setting $mobileTypeID = CRM_Core_OptionGroup::getValue('phone_type', 'Mobile', 'name'); list($name, $phone, $doNotSMS) = CRM_Contact_BAO_Contact_Location::getPhoneDetails($contactId, $mobileTypeID); if (!$doNotSMS && $phone) { $sendSMS = array($SMSId => ts('Send SMS')); $activityTypes += $sendSMS; } } // this returns activity types sorted by weight $otherTypes = CRM_Core_PseudoConstant::activityType(FALSE); $activityTypes += $otherTypes; foreach (array_keys($activityTypes) as $typeId) { if ($typeId == $emailTypeId) { $urls[$typeId] = CRM_Utils_System::url('civicrm/activity/email/add', "{$urlParams}{$typeId}", FALSE, NULL, FALSE); } elseif ($typeId == $SMSId) { $urls[$typeId] = CRM_Utils_System::url('civicrm/activity/sms/add', "{$urlParams}{$typeId}", FALSE, NULL, FALSE); } elseif ($typeId == $letterTypeId) { $urls[$typeId] = CRM_Utils_System::url('civicrm/activity/pdf/add', "{$urlParams}{$typeId}", FALSE, NULL, FALSE); } else { $urls[$typeId] = CRM_Utils_System::url('civicrm/activity/add', "{$urlParams}{$typeId}", FALSE, NULL, FALSE); } } $self->assign('activityTypes', $activityTypes); $self->assign('urls', $urls); $self->assign('suppressForm', TRUE); }