function run() { $contactID = CRM_Utils_Request::retrieve('cid', 'Integer'); if (!empty($contactID)) { if (!self::checkPermissions($contactID, 'viewWidget')) { CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm')); CRM_Core_Error::statusBounce(ts('You do not have permission to access this page')); } CRM_Utils_System::setTitle(ts('Absences for %1', array(1 => CRM_Contact_BAO_Contact::displayName($contactID)))); self::registerResources($contactID); } else { $session = CRM_Core_Session::singleton(); if (is_numeric($session->get('userID'))) { if (!self::checkPermissions($session->get('userID'), 'viewWidget')) { CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm')); CRM_Core_Error::statusBounce(ts('You do not have permission to access this page')); } CRM_Utils_System::setTitle(ts('My Absences')); self::registerResources($session->get('userID')); } else { throw new CRM_Core_Exception("Failed to determine contact ID"); } } parent::run(); }
/** * Build all the data structures needed to build the form. */ public function preProcess() { $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); $context = CRM_Utils_Request::retrieve('context', 'String', $this); //get current client name. $this->assign('currentClientName', CRM_Contact_BAO_Contact::displayName($cid)); //set the context. $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$cid}&selectedChild=case"); if ($context == 'search') { $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this); //validate the qfKey $urlParams = 'force=1'; if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams .= "&qfKey={$qfKey}"; } $url = CRM_Utils_System::url('civicrm/case/search', $urlParams); } elseif ($context == 'dashboard') { $url = CRM_Utils_System::url('civicrm/case', 'reset=1'); } elseif (in_array($context, array('dashlet', 'dashletFullscreen'))) { $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1'); } $session = CRM_Core_Session::singleton(); $session->pushUserContext($url); }
/** * build all the data structures needed to build the form * * @return void * @access public */ public function preProcess() { $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->_caseId = CRM_Utils_Request::retrieve('id', 'Positive', $this); $context = CRM_Utils_Request::retrieve('context', 'String', $this); //get current client name. require_once 'CRM/Contact/BAO/Contact.php'; $this->assign('currentClientName', CRM_Contact_BAO_Contact::displayName($this->_contactId)); //set the context. $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactId}&selectedChild=case"); if ($context == 'search') { $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this); //validate the qfKey require_once 'CRM/Utils/Rule.php'; $urlParams = 'force=1'; if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams .= "&qfKey={$qfKey}"; } $url = CRM_Utils_System::url('civicrm/case/search', $urlParams); } else { if ($context == 'dashboard') { $url = CRM_Utils_System::url('civicrm/case', 'reset=1'); } } $session = CRM_Core_Session::singleton(); $session->pushUserContext($url); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { $cid = CRM_Utils_Request::retrieve('cid', $this, false); if ($cid) { // not sure why this is needed :( // also add the cid params to the Menu array CRM_Utils_Menu::addParam('cid', $cid); // create menus .. $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view'); $startWeight++; CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight); $this->_contactIds = array($cid); $this->_single = true; $smsNumbers = CRM_Contact_BAO_Contact::allPhones($cid, 'Mobile'); $this->_emails = array(); $toName = CRM_Contact_BAO_Contact::displayName($cid); foreach ($smsNumbers as $number => $item) { $this->_smsNumbers[$number] = '"' . $toName . '" <' . $number . '> ' . $item['locationType']; if ($item['is_primary']) { $this->_smsNumbers[$number] .= ' ' . ts('(preferred)'); } $this->_smsNumbers[$number] = htmlspecialchars($this->_emails[$email]); } } else { parent::preProcess(); } $this->assign('single', $this->_single); }
function buildLineItems() { foreach ($this->cart->events_in_carts as $event_in_cart) { $event_in_cart->load_location(); } $line_items = $this->get('line_items'); foreach ($line_items as $line_item) { $event_in_cart = $this->cart->get_event_in_cart_by_event_id($line_item['event_id']); $not_waiting_participants = array(); foreach ($event_in_cart->not_waiting_participants() as $participant) { $not_waiting_participants[] = array('display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id)); } $waiting_participants = array(); foreach ($event_in_cart->waiting_participants() as $participant) { $waiting_participants[] = array('display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id)); } $line_item['event'] = $event_in_cart->event; $line_item['num_participants'] = count($not_waiting_participants); $line_item['participants'] = $not_waiting_participants; $line_item['num_waiting_participants'] = count($waiting_participants); $line_item['waiting_participants'] = $waiting_participants; $line_item['location'] = $event_in_cart->location; $line_item['class'] = $event_in_cart->event->parent_event_id ? 'subevent' : NULL; $this->sub_total += $line_item['amount']; $this->line_items[] = $line_item; } $this->assign('line_items', $this->line_items); }
static function postProcess(&$form) { $values = $form->exportValues(); $teamId = $values['pcp_team_contact']; $teampcpId = CRM_Pcpteams_Utils::getPcpIdByContactAndEvent($form->get('component_page_id'), $teamId); $userId = CRM_Pcpteams_Utils::getloggedInUserId(); // Create Team Member of relation to this Team $cfpcpab = CRM_Pcpteams_Utils::getPcpABCustomFieldId(); $cfpcpba = CRM_Pcpteams_Utils::getPcpBACustomFieldId(); $customParams = array("custom_{$cfpcpab}" => $form->get('page_id'), "custom_{$cfpcpba}" => $teampcpId); CRM_Pcpteams_Utils::createTeamRelationship($userId, $teamId, $customParams); $form->_teamName = CRM_Contact_BAO_Contact::displayName($teamId); $form->set('teamName', $form->_teamName); $form->set('teamContactID', $teamId); $form->set('teamPcpId', $teampcpId); $teamAdminId = CRM_Pcpteams_Utils::getTeamAdmin($teampcpId); // Team Join: create activity $actParams = array('target_contact_id' => $teamId, 'assignee_contact_id' => $teamAdminId); CRM_Pcpteams_Utils::createPcpActivity($actParams, CRM_Pcpteams_Constant::C_AT_REQ_MADE); CRM_Core_Session::setStatus(ts('A notification has been sent to the team. Once approved, team should be visible on your page.'), ts('Team Request Sent')); //send email once the team request has done. list($teamAdminName, $teamAdminEmail) = CRM_Contact_BAO_Contact::getContactDetails($teamAdminId); $contactDetails = civicrm_api('Contact', 'get', array('version' => 3, 'sequential' => 1, 'id' => $userId)); $emailParams = array('tplParams' => array('teamAdminName' => $teamAdminName, 'userFirstName' => $contactDetails['values'][0]['first_name'], 'userlastName' => $contactDetails['values'][0]['last_name'], 'teamName' => $form->_teamName, 'pageURL' => CRM_Utils_System::url('civicrm/pcp/manage', "reset=1&id={$teampcpId}", TRUE, NULL, FALSE, TRUE)), 'email' => array($teamAdminName => array('first_name' => $teamAdminName, 'last_name' => $teamAdminName, 'email-Primary' => $teamAdminEmail, 'display_name' => $teamAdminName)), 'valueName' => CRM_Pcpteams_Constant::C_MSG_TPL_JOIN_REQUEST); $sendEmail = CRM_Pcpteams_Utils::sendMail($userId, $emailParams); }
/** * View details of a relationship * * @return void * * @access public */ function view() { require_once 'CRM/Core/DAO.php'; $viewRelationship = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, null, null, null, $this->_id); //To check whether selected contact is a contact_id_a in //relationship type 'a_b' in relationship table, if yes then //revert the permissionship text in template $relationship =& new CRM_Contact_DAO_Relationship(); $relationship->id = $viewRelationship[$this->_id]['id']; if ($relationship->find(true)) { if ($viewRelationship[$this->_id]['rtype'] == 'a_b' && $this->_contactId == $relationship->contact_id_a) { $this->assign("is_contact_id_a", true); } } $relType = $viewRelationship[$this->_id]['civicrm_relationship_type_id']; $this->assign('viewRelationship', $viewRelationship); $viewNote = CRM_Core_BAO_Note::getNote($this->_id); $this->assign('viewNote', $viewNote); $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Relationship', $this, $this->_id, 0, $relType); CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree); // add viewed contribution to recent items list require_once 'CRM/Utils/Recent.php'; $url = CRM_Utils_System::url('civicrm/contact/view/rel', "action=view&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&context=home"); $title = CRM_Contact_BAO_Contact::displayName($this->_contactId) . ' (' . $viewRelationship[$this->_id]['relation'] . ' ' . CRM_Contact_BAO_Contact::displayName($viewRelationship[$this->_id]['cid']) . ')'; // add the recently viewed Relationship CRM_Utils_Recent::add($title, $url, $viewRelationship[$this->_id]['id'], 'Relationship', $this->_contactId, null); }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { $this->_contactID = $this->get('cid'); $this->_caseID = $this->get('id'); $this->assign('caseID', $this->_caseID); $this->assign('contactID', $this->_contactID); //retrieve details about case $params = array('id' => $this->_caseID); $returnProperties = array('case_type_id', 'subject', 'status_id', 'start_date'); CRM_Core_DAO::commonRetrieve('CRM_Case_BAO_Case', $params, $values, $returnProperties); $values['case_type_id'] = explode(CRM_Case_BAO_Case::VALUE_SEPERATOR, CRM_Utils_Array::value('case_type_id', $values)); $statuses = CRM_Case_PseudoConstant::caseStatus(); $caseTypeName = CRM_Case_PseudoConstant::caseTypeName($this->_caseID); $caseType = CRM_Core_OptionGroup::getLabel('case_type', $caseTypeName['id']); $this->_caseDetails = array('case_type' => $caseType, 'case_status' => $statuses[$values['case_status_id']], 'case_subject' => CRM_Utils_Array::value('subject', $values), 'case_start_date' => $values['case_start_date']); $this->_caseType = $caseTypeName['name']; $this->assign('caseDetails', $this->_caseDetails); $newActivityUrl = CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype=", false, null, false); $this->assign('newActivityUrl', $newActivityUrl); $reportUrl = CRM_Utils_System::url('civicrm/case/report', "reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&asn=", false, null, false); $this->assign('reportUrl', $reportUrl); // add to recently viewed require_once 'CRM/Utils/Recent.php'; require_once 'CRM/Contact/BAO/Contact.php'; $url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home"); $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID); $this->assign('displayName', $displayName); $title = $displayName . ' - ' . $caseType; // add the recently created case CRM_Utils_Recent::add($title, $url, $this->_caseID, 'Case', $this->_contactID, null); }
/** * Build the form object. * * @return void */ public function buildQuickForm() { parent::buildQuickForm(); $this->setPageTitle(ts('Financial Batch')); if (isset($this->_id)) { $this->_title = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $this->_id, 'title'); CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Accounting Batch')); $this->assign('batchTitle', $this->_title); $contactID = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $this->_id, 'created_id'); $contactName = CRM_Contact_BAO_Contact::displayName($contactID); $this->assign('contactName', $contactName); } $this->applyFilter('__ALL__', 'trim'); $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')))); if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) { $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id'); //unset exported status $exportedStatusId = CRM_Utils_Array::key('Exported', $batchStatus); unset($batchStatus[$exportedStatusId]); $this->add('select', 'status_id', ts('Batch Status'), array('' => ts('- select -')) + $batchStatus, TRUE); $this->freeze(array('status_id')); } $attributes = CRM_Core_DAO::getAttribute('CRM_Batch_DAO_Batch'); $this->add('text', 'title', ts('Batch Name'), $attributes['name'], TRUE); $this->add('textarea', 'description', ts('Description'), $attributes['description']); $this->add('select', 'payment_instrument_id', ts('Payment Method'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE); $this->add('text', 'total', ts('Total Amount'), $attributes['total']); $this->add('text', 'item_count', ts('Number of Transactions'), $attributes['item_count']); $this->addFormRule(array('CRM_Financial_Form_FinancialBatch', 'formRule'), $this); }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { parent::preProcess(); $details = CRM_Booking_BAO_Booking::getBookingDetails($this->_id); $this->_values['slots'] = CRM_Utils_Array::value('slots', $details); $this->_values['sub_slots'] = CRM_Utils_Array::value('sub_slots', $details); $this->_values['adhoc_charges'] = CRM_Utils_Array::value('adhoc_charges', $details); $this->_values['cancellation_charges'] = CRM_Utils_Array::value('cancellation_charges', $details); $this->_values['contribution'] = CRM_Utils_Array::value('contribution', $details); $this->_values['sub_total'] = CRM_Utils_Array::value('total_amount', $this->_values) + CRM_Utils_Array::value('discount_amount', $this->_values); //total_amount has been deducted from discount $this->assign($this->_values); $displayName = CRM_Contact_BAO_Contact::displayName($this->_values['primary_contact_id']); $secondaryContactDisplayName = CRM_Contact_BAO_Contact::displayName(CRM_Utils_Array::value('secondary_contact_id', $this->_values)); $this->assign('displayName', $displayName); $this->assign('secondaryContactDisplayName', $secondaryContactDisplayName); $this->assign('contact_id', $this->_cid); $params = array('option_group_name' => CRM_Booking_Utils_Constants::OPTION_BOOKING_STATUS, 'name' => CRM_Booking_Utils_Constants::OPTION_VALUE_CANCELLED); $result = civicrm_api3('OptionValue', 'get', $params); $this->_cancelStatusId = $cancelStatus = CRM_Utils_Array::value('value', CRM_Utils_Array::value($result['id'], $result['values'])); if ($this->_values['status_id'] == $cancelStatus) { $this->assign('is_cancelled', TRUE); } // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container CRM_Utils_System::setTitle(ts('View Booking for') . ' ' . $displayName); self::registerScripts($this); }
/** * @inheritDoc */ public function createUser(&$params, $mail) { $baseDir = JPATH_SITE; require_once $baseDir . '/components/com_users/models/registration.php'; $userParams = JComponentHelper::getParams('com_users'); $model = new UsersModelRegistration(); $ufID = NULL; // get the default usertype $userType = $userParams->get('new_usertype'); if (!$userType) { $userType = 2; } if (isset($params['name'])) { $fullname = trim($params['name']); } elseif (isset($params['contactID'])) { $fullname = trim(CRM_Contact_BAO_Contact::displayName($params['contactID'])); } else { $fullname = trim($params['cms_name']); } // Prepare the values for a new Joomla user. $values = array(); $values['name'] = $fullname; $values['username'] = trim($params['cms_name']); $values['password1'] = $values['password2'] = $params['cms_pass']; $values['email1'] = $values['email2'] = trim($params[$mail]); $lang = JFactory::getLanguage(); $lang->load('com_users', $baseDir); $register = $model->register($values); $ufID = JUserHelper::getUserId($values['username']); return $ufID; }
public function preProcess() { $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); $this->assign('contactId', $this->_contactId); $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); // check logged in url permission CRM_Contact_Page_View::checkUserPermission($this); }
/** * Given an array of contributionIDs, add them to a batch * * @param array $contributionIDs (reference ) the array of contribution ids to be added * @param int $batchID - the batchID to be added to * * @return array (total, added, notAdded) ids of contributions added to the batch * @access public * @static */ static function addContributionToBatch($contributionIDs, $batchID) { $date = date('YmdHis'); $contributionsAdded = array(); $contributionsNotAdded = array(); require_once "GiftAid/Utils/GiftAid.php"; require_once "CRM/Contribute/BAO/Contribution.php"; require_once 'CRM/Core/DAO/EntityBatch.php'; require_once "CRM/Core/BAO/Address.php"; require_once "CRM/Contact/BAO/Contact.php"; require_once "CRM/Utils/Address.php"; $charityColumnExists = CRM_Core_DAO::checkFieldExists('civicrm_value_gift_aid_submission', 'charity'); foreach ($contributionIDs as $contributionID) { $batchContribution =& new CRM_Core_DAO_EntityBatch(); $batchContribution->entity_table = 'civicrm_contribution'; $batchContribution->entity_id = $contributionID; // check if the selected contribution id already in a batch // if not, add to batchContribution else keep the count of contributions that are not added if ($batchContribution->find(true)) { $contributionsNotAdded[] = $contributionID; continue; } // get additional info // get contribution details from Contribution using contribution id $params = array('id' => $contributionID); CRM_Contribute_BAO_Contribution::retrieve($params, $contribution, $ids); $contactId = $contribution['contact_id']; // check if contribution is valid for gift aid if (GiftAid_Utils_GiftAid::isEligibleForGiftAid($contactId, $contribution['receive_date'], $contributionID)) { $batchContribution->batch_id = $batchID; $batchContribution->save(); // get display name $displayName = CRM_Contact_BAO_Contact::displayName($contactId); // get Address & Postal Code from Address $params = array('contact_id' => $contactId, 'is_primary' => 1); $address = CRM_Core_BAO_Address::getValues($params); $address = $address[1]; //adds all address lines to the report $fullFormatedAddress = CRM_Utils_Address::format($address); // get gift aid amount $giftAidAmount = self::_calculateGiftAidAmt($contribution['total_amount']); // FIXME: check if there is customTable method $query = "\nINSERT INTO civicrm_value_gift_aid_submission \n(entity_id, eligible_for_gift_aid, name, address, post_code, amount, gift_aid_amount) \nVALUES \n ( %1, 1, %2, %3, %4, %5, %6 )\nON DUPLICATE KEY UPDATE \nname = %2, \naddress = %3,\npost_code = %4,\namount = %5,\ngift_aid_amount = %6\n"; $sqlParams = array(1 => array($contributionID, 'Integer'), 2 => array($displayName, 'String'), 3 => array($fullFormatedAddress, 'String'), 4 => array($address['postal_code'], 'String'), 5 => array($contribution['total_amount'], 'Money'), 6 => array($giftAidAmount, 'Money')); CRM_Core_DAO::executeQuery($query, $sqlParams); $contributionsAdded[] = $contributionID; } else { $contributionsNotAdded[] = $contributionID; } } if (!empty($contributionsAdded)) { // if there is any extra work required to be done for contributions that are batched, // should be done via hook GiftAid_Utils_Hook::batchContributions($batchID, $contributionsAdded); } return array(count($contributionIDs), count($contributionsAdded), count($contributionsNotAdded)); }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { $values = $ids = array(); $params = array('id' => $this->get('id')); CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids); $values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit'])); if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) { $sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"]; $dao = new CRM_Core_DAO(); $dao->query($sql); if ($dao->fetch()) { $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}"); $values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>"; } $honor = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id'); $values['honor_type'] = $honor[$values['honor_type_id']]; } //handle custom data. $groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']); CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree); if (!empty($values['contribution_page_id'])) { $values['contribution_page'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $values['contribution_page_id'], 'title'); } $values['financial_type'] = CRM_Utils_Array::value($values['financial_type_id'], CRM_Contribute_PseudoConstant::financialType()); if ($values['status_id']) { $values['pledge_status'] = CRM_Utils_Array::value($values['status_id'], CRM_Contribute_PseudoConstant::contributionStatus()); } $url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"); $recentOther = array(); if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"); } if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) { $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"); } $displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']); $this->assign('displayName', $displayName); $title = $displayName . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($values['pledge_amount']) . ' - ' . $values['financial_type'] . ')'; // add Pledge to Recent Items CRM_Utils_Recent::add($title, $url, $values['id'], 'Pledge', $values['contact_id'], NULL, $recentOther); // Check if this is default domain contact CRM-10482 if (CRM_Contact_BAO_Contact::checkDomainContact($values['contact_id'])) { $displayName .= ' (' . ts('default organization') . ')'; } // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container CRM_Utils_System::setTitle(ts('View Pledge by') . ' ' . $displayName); //do check for campaigns if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) { $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId); $values['campaign'] = $campaigns[$campaignId]; } $this->assign($values); }
/** * Build all the data structures needed to build the form. */ public function preProcess() { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('contactId', $this->_contactId); $this->assign('displayName', $displayName); // Check logged in url permission. CRM_Contact_Page_View::checkUserPermission($this); CRM_Utils_System::setTitle(ts('Mailings sent to %1', array(1 => $displayName))); }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $context); $values = array(); $params['id'] = $this->_id; require_once 'CRM/Grant/BAO/Grant.php'; CRM_Grant_BAO_Grant::retrieve($params, $values); require_once 'CRM/Grant/PseudoConstant.php'; $grantType = CRM_Grant_PseudoConstant::grantType(); $grantStatus = CRM_Grant_PseudoConstant::grantStatus(); $this->assign('grantType', $grantType[$values['grant_type_id']]); $this->assign('grantStatus', $grantStatus[$values['status_id']]); $grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date'); foreach ($grantTokens as $token) { $this->assign($token, CRM_Utils_Array::value($token, $values)); } if (isset($this->_id)) { require_once 'CRM/Core/BAO/Note.php'; $noteDAO = new CRM_Core_BAO_Note(); $noteDAO->entity_table = 'civicrm_grant'; $noteDAO->entity_id = $this->_id; if ($noteDAO->find(true)) { $this->_noteId = $noteDAO->id; } } if (isset($this->_noteId)) { $this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note')); } // add Grant to Recent Items require_once 'CRM/Utils/Recent.php'; require_once 'CRM/Contact/BAO/Contact.php'; require_once 'CRM/Utils/Money.php'; $url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"); $title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')'; $recentOther = array(); if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"); } if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) { $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"); } CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], null, $recentOther); require_once 'CRM/Core/BAO/File.php'; $attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id); $this->assign('attachment', $attachment); $groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0); CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree); $this->assign('id', $this->_id); }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Event_Form_Search', ts('Events'), $this->_action); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('context', 'participant'); $controller->process(); $controller->run(); if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); } }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Search', ts('Pledges'), $this->_action); $controller->setEmbedded(true); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('context', 'pledge'); $controller->process(); $controller->run(); if ($this->_contactId) { require_once 'CRM/Contact/BAO/Contact.php'; $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); } }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Search', ts('Pledges'), $this->_action); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('context', 'pledge'); $controller->process(); $controller->run(); if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('pledge', $this->_contactId); } }
static function relatedContactInfo($contactId) { $return = array(); if (empty($contactId)) { return $return; } $phone = CRM_Core_BAO_Phone::allPhones($contactId, TRUE, NULL, array('is_primary' => 1)); $contactSubType = CRM_Contact_BAO_Contact::getContactSubType($contactId); $contactType = CRM_Contact_BAO_ContactType::getLabel($contactSubType[0]); $gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'PCP_Supporter_Profile', 'id', 'name'); $updateURL = CRM_Utils_System::url('civicrm/profile/edit', "reset=1&gid={$gid}&cid={$contactId}"); // $updateURL =CRM_Utils_System::url('civicrm/pcp/support', "action=browse&component=event&id={$params['pcpId']}"); $return = array('name' => CRM_Contact_BAO_Contact::displayName($contactId), 'type' => $contactType, 'email' => CRM_Contact_BAO_Contact::getPrimaryEmail($contactId), 'phone' => !empty($phone) && isset($phone[1]['phone']) ? $phone[1]['phone'] : NULL, 'action' => "<a href={$updateURL}>Update Contact Information</a>"); return $return; }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Booking_Form_Search', ts('Booking'), $this->_action); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('context', 'booking'); $controller->process(); $controller->run(); if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); } $bookings = CRM_Booking_BAO_Booking::getContactAssociatedBooking($this->_contactId); $this->assign('associatedBooking', $bookings); }
/** * Create case contact record. * * @param array $params * case_id, contact_id * * @return CRM_Case_BAO_CaseContact */ public static function create($params) { $caseContact = new self(); $caseContact->copyValues($params); $caseContact->save(); // add to recently viewed $caseType = CRM_Case_BAO_Case::getCaseType($caseContact->case_id); $url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home"); $title = CRM_Contact_BAO_Contact::displayName($caseContact->contact_id) . ' - ' . $caseType; $recentOther = array(); if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) { $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/case', "action=delete&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home"); } // add the recently created case CRM_Utils_Recent::add($title, $url, $caseContact->case_id, 'Case', $caseContact->contact_id, NULL, $recentOther); return $caseContact; }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Event_Form_Search', ts('Events'), $this->_action); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('context', 'participant'); $controller->process(); $controller->run(); if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('participant', $this->_contactId); // Refresh other tabs with related data $this->ajaxResponse['updateTabs'] = array('#tab_contribute' => CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId), '#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId)); } }
function postProcess() { $values = $this->exportValues(); $branchId = $values['pcp_branch_contact']; if ($branchId && $this->get('page_id')) { // $branchCfId = CRM_Pcpteams_Utils::getBranchorPartnerCustomFieldId(); $params = array('version' => 3, 'entity_id' => $this->get('page_id'), "org_id" => $branchId); $result = civicrm_api3('pcpteams', 'customcreate', $params); if (!civicrm_error($result)) { $branchName = CRM_Contact_BAO_Contact::displayName($branchId); // Group Join: create activity $actParams = array('target_contact_id' => $branchId); CRM_Pcpteams_Utils::createPcpActivity($actParams, CRM_Pcpteams_Constant::C_AT_GROUP_JOIN); CRM_Core_Session::setStatus(ts("Successfully added to the branch {$branchName}"), '', 'success'); } } }
function run() { $this->ruleId = CRM_Utils_Request::retrieve('rule_id', 'Integer'); $this->rule = new CRM_Civirules_BAO_Rule(); if (!empty($this->ruleId)) { $this->rule->id = $this->ruleId; if (!$this->rule->find(TRUE)) { throw new Exception('Civirules could not find rule'); } } else { throw new Exception('Civirules could not find rule'); } // Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml CRM_Utils_System::setTitle(ts('View log for rule: "%1"', array(1 => $this->rule->label))); $this->assign('rule', $this->rule); $total = CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM `civirule_civiruleslogger_log` WHERE `rule_id` = %1", array(1 => array($this->ruleId, 'Integer'))); $params['total'] = $total; $params['currentPage'] = $this->get(CRM_Utils_Pager::PAGE_ID); $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT; $params['status'] = ts('Log entries %%StatusMessage%%'); $this->_pager = new CRM_Utils_Pager($params); $this->assign_by_ref('pager', $this->_pager); list($this->_pagerOffset, $this->_pagerRowCount) = $this->_pager->getOffsetAndRowCount(); $logEntries = array(); $queryParams = array(1 => array($this->ruleId, 'Integer'), 2 => array($this->_pagerOffset, 'Integer'), 3 => array($this->_pagerRowCount, 'Integer')); $dao = CRM_Core_DAO::executeQuery("SELECT * FROM `civirule_civiruleslogger_log` WHERE `rule_id` = %1 ORDER BY `timestamp` DESC LIMIT %2, %3", $queryParams); while ($dao->fetch()) { $entry = array(); $entry['id'] = $dao->id; $entry['message'] = $dao->message; $entry['context'] = print_r(json_decode($dao->context, true), true); $entry['level'] = $dao->level; $timestamp = new DateTime($dao->timestamp); $entry['timestamp'] = $timestamp->format('Y-m-d H:i'); $entry['contact_id'] = $dao->contact_id; $entry['display_name'] = CRM_Contact_BAO_Contact::displayName($dao->contact_id); $entry['contact_link'] = ''; if (!empty($entry['display_name'])) { $entry['contact_link'] = CRM_Utils_System::url('civicrm/contact/view', array('reset' => 1, 'cid' => $dao->contact_id)); } $logEntries[] = $entry; } $this->assign('logEntries', $logEntries); parent::run(); }
/** * Get the list of voters (respondents, yet to record survey response) for a survey * * @param array $params (reference ) input parameters * * @return array (reference ) contact_id * @static void * @access public */ function &civicrm_api3_survey_voter_get($params) { civicrm_api3_verify_one_mandatory($params, 'CRM_Campaign_BAO_Survey', array('survey_id', 'id')); if (array_key_exists('status_id', $params)) { $status_id = $params['status_id']; } else { $status_id = null; } $surveyID = empty($params['survey_id']) ? $params['id'] : $params['survey_id']; require_once 'CRM/Campaign/BAO/Survey.php'; $survey = new CRM_Campaign_BAO_Survey(); $voters = $survey->getSurveyVoterInfo($surveyID); require_once 'CRM/Contact/BAO/Contact.php'; foreach ($voters as $key => $voterArray) { $voters[$key]['voter_name'] = CRM_Contact_BAO_Contact::displayName($voterArray['voter_id']); } return civicrm_api3_create_success($voters, $params); }
/** * 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(); $params = array('id' => $this->get('id')); CRM_Event_BAO_Participant::getValues($params, $values, $ids); CRM_Event_BAO_Participant::resolveDefaults($values[$params['id']]); if (CRM_Utils_Array::value('fee_level', $values[$params['id']])) { CRM_Event_BAO_Participant::fixEventLevel($values[$params['id']]['fee_level']); } if ($values[$params['id']]['is_test']) { $values[$params['id']]['status'] .= ' (test) '; } // Get Note $noteValue = CRM_Core_BAO_Note::getNote($values[$params['id']]['id'], 'civicrm_participant'); $values[$params['id']]['note'] = array_values($noteValue); require_once 'CRM/Price/BAO/LineItem.php'; // Get Line Items $lineItem = CRM_Price_BAO_LineItem::getLineItems($params['id']); if (!CRM_Utils_System::isNull($lineItem)) { $values[$params['id']]['lineItem'][] = $lineItem; } $values[$params['id']]['totalAmount'] = $values[$params['id']]['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'); $roleGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $params['id'], null, $values[$params['id']]['role_id'], $roleCustomDataTypeID); $eventGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $params['id'], null, $values[$params['id']]['event_id'], $eventNameCustomDataTypeID); $groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree); $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $params['id'])); CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree); $this->assign($values[$params['id']]); // 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[$params['id']]['id']}&cid={$values[$params['id']]['contact_id']}"); $participantRoles = CRM_Event_PseudoConstant::participantRole(); $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$params['id']]['event_id'], 'title'); $title = CRM_Contact_BAO_Contact::displayName($values[$params['id']]['contact_id']) . ' (' . $participantRoles[$values[$params['id']]['role_id']] . ' - ' . $eventTitle . ')'; // add the recently created Activity CRM_Utils_Recent::add($title, $url, $values[$params['id']]['id'], 'Participant', $values[$params['id']]['contact_id'], null); }
function postProcess() { $values = $this->exportValues(); $tributeId = $values['pcp_tribute_contact']; if ($tributeId && $this->_tributeReason) { // $tributeCfId = CRM_Pcpteams_Utils::getPcpTypeCustomFieldId(); // $tributeContactCfId = CRM_Pcpteams_Utils::getPcpTypeContactCustomFieldId(); $selectedReason = CRM_Core_OptionGroup::getValue(CRM_Pcpteams_Constant::C_PCP_TYPE, $this->_tributeReason, 'name'); $tributeContatparams = array('version' => 3, 'entity_id' => $this->get('page_id'), "tribute" => $selectedReason, "tribute_contact_id" => $tributeId); $result = civicrm_api3('pcpteams', 'customcreate', $tributeContatparams); if (!civicrm_error($result)) { $tributeName = CRM_Contact_BAO_Contact::displayName($tributeId); // Tribute Join: create activity $actParams = array('target_contact_id' => $tributeId, 'reason' => $this->_tributeReason); CRM_Pcpteams_Utils::createPcpActivity($actParams, CRM_Pcpteams_Constant::C_AT_TRIBUTE_JOIN); CRM_Core_Session::setStatus(ts("Successfully added to {$this->_tributeReason} of {$tributeName}"), '', 'success'); } } //FIXME: need to discuss with DS, to redirect the after completed the form entries CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/pcp/page', 'reset=1&id=' . $this->get('page_id'))); }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { require_once 'CRM/Pledge/BAO/Pledge.php'; $values = $ids = array(); $params = array('id' => $this->get('id')); CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids); $values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit'])); $values['eachPaymentAmount'] = floor($values['amount'] / $values['installments']); if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) { $sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"]; $dao =& new CRM_Core_DAO(); $dao->query($sql); if ($dao->fetch()) { $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}"); $values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>"; } $honor = CRM_Core_PseudoConstant::honor(); $values['honor_type'] = $honor[$values['honor_type_id']]; } //handle custom data. $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']); CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree); if (CRM_Utils_Array::value('contribution_page_id', $values)) { $values['contribution_page'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $values['contribution_page_id'], 'title'); } $values['contribution_type'] = CRM_Utils_Array::value($values['contribution_type_id'], CRM_Contribute_PseudoConstant::contributionType()); if ($values['status_id']) { $values['pledge_status'] = CRM_Utils_Array::value($values['status_id'], CRM_Contribute_PseudoConstant::contributionStatus()); } require_once 'CRM/Utils/Recent.php'; require_once 'CRM/Contact/BAO/Contact.php'; $url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"); require_once 'CRM/Utils/Money.php'; $displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']); $this->assign('displayName', $displayName); $title = $displayName . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($values['pledge_amount']) . ' - ' . $values['contribution_type'] . ')'; // add Pledge to Recent Items CRM_Utils_Recent::add($title, $url, $values['id'], 'Pledge', $values['contact_id'], null); $this->assign($values); }
function preProcess() { parent::preProcess(); $matches = array(); preg_match("/.*_(\\d+)_(\\d+)/", $this->getAttribute('name'), $matches); $event_id = $matches[1]; $participant_id = $matches[2]; $event_in_cart = $this->cart->get_event_in_cart_by_event_id($event_id); $this->conference_event = $event_in_cart->event; $this->main_participant = $event_in_cart->get_participant_by_id($participant_id); $this->contact_id = $this->main_participant->contact_id; $this->main_participant->display_name = CRM_Contact_BAO_Contact::displayName($this->contact_id); $events = new CRM_Event_BAO_Event(); $query = <<<EOS \t SELECT civicrm_event.*, slot.label AS slot_label FROM civicrm_event JOIN civicrm_option_value slot ON civicrm_event.slot_label_id = slot.value JOIN civicrm_option_group og ON slot.option_group_id = og.id \t WHERE \t\tparent_event_id = {$this->conference_event->id} AND civicrm_event.is_active = 1 AND COALESCE(civicrm_event.is_template, 0) = 0 AND og.name = 'conference_slot' \t ORDER BY \t\tslot.weight, start_date EOS; $events->query($query); while ($events->fetch()) { if (!array_key_exists($events->slot_label, $this->events_by_slot)) { $this->events_by_slot[$events->slot_label] = array(); } $this->events_by_slot[$events->slot_label][] = clone $events; } }