public function setDefaultValues() { $defaults = array(); $dao = new CRM_PCP_DAO_PCP(); if ($this->_pageId) { $dao->id = $this->_pageId; if ($dao->find(TRUE)) { CRM_Core_DAO::storeValues($dao, $defaults); } // fix the display of the monetary value, CRM-4038 if (isset($defaults['goal_amount'])) { $defaults['goal_amount'] = CRM_Utils_Money::format($defaults['goal_amount'], NULL, '%a'); } $defaults['pcp_title'] = CRM_Utils_Array::value('title', $defaults); $defaults['pcp_intro_text'] = CRM_Utils_Array::value('intro_text', $defaults); } if ($this->get('action') & CRM_Core_Action::ADD) { $defaults['is_active'] = 1; $defaults['is_honor_roll'] = 1; $defaults['is_thermometer'] = 1; $defaults['is_notify'] = 1; } $this->_contactID = CRM_Utils_Array::value('contact_id', $defaults); $this->_contriPageId = CRM_Utils_Array::value('page_id', $defaults); return $defaults; }
function setDefaultValues() { $dafaults = array(); $dao = new CRM_PCP_DAO_PCP(); if ($this->_pageId) { $dao->id = $this->_pageId; if ($dao->find(TRUE)) { CRM_Core_DAO::storeValues($dao, $defaults); } // fix the display of the monetary value, CRM-4038 if (isset($defaults['goal_amount'])) { $defaults['goal_amount'] = CRM_Utils_Money::format($defaults['goal_amount'], NULL, '%a'); } $defaults['pcp_title'] = CRM_Utils_Array::value('title', $defaults); $defaults['pcp_intro_text'] = CRM_Utils_Array::value('intro_text', $defaults); } if ($this->get('action') & CRM_Core_Action::ADD) { $defaults['is_active'] = 1; $defaults['is_honor_roll'] = 1; $defaults['is_thermometer'] = 1; } $this->_contactID = CRM_Utils_Array::value('contact_id', $defaults); $this->_contriPageId = CRM_Utils_Array::value('page_id', $defaults); //MV: to set customData default values; if (CRM_Core_Permission::check('administer CiviCRM')) { $customDataDefaults = CRM_Custom_Form_CustomData::setDefaultValues($this); $defaults += $customDataDefaults; } //END return $defaults; }
/** * Delete the campaign page. * * @param int $id * Campaign page id. * * @return; */ public static function deleteById($id) { CRM_Utils_Hook::pre('delete', 'Campaign', $id, CRM_Core_DAO::$_nullArray); $transaction = new CRM_Core_Transaction(); // delete from pcp table $pcp = new CRM_PCP_DAO_PCP(); $pcp->id = $id; $pcp->delete(); $transaction->commit(); CRM_Utils_Hook::post('delete', 'Campaign', $id, $pcp); }
/** * Apply variables for message to smarty template - this function is part of analysing what is in the huge * function & breaking it down into manageable chunks. Eventually it will be refactored into something else * Note we send directly from this function in some cases because it is only partly refactored * Don't call this function directly as the signature will change * * @param $values * @param $input * @param CRM_Core_SMARTY $template * @param bool $recur * @param bool $returnMessageText * * @return mixed */ public function _assignMessageVariablesToTemplate(&$values, $input, &$template, $recur = FALSE, $returnMessageText = TRUE) { $template->assign('first_name', $this->_relatedObjects['contact']->first_name); $template->assign('last_name', $this->_relatedObjects['contact']->last_name); $template->assign('displayName', $this->_relatedObjects['contact']->display_name); if (!empty($values['lineItem']) && !empty($this->_relatedObjects['membership'])) { $template->assign('useForMember', TRUE); } //assign honor information to receipt message $softRecord = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id); if (isset($softRecord['soft_credit'])) { //if id of contribution page is present if (!empty($values['id'])) { $values['honor'] = array('honor_profile_values' => array(), 'honor_profile_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFJoin', $values['id'], 'uf_group_id', 'entity_id'), 'honor_id' => $softRecord['soft_credit'][1]['contact_id']); $softCreditTypes = CRM_Core_OptionGroup::values('soft_credit_type'); $template->assign('soft_credit_type', $softRecord['soft_credit'][1]['soft_credit_type_label']); $template->assign('honor_block_is_active', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFJoin', $values['id'], 'is_active', 'entity_id')); } else { //offline contribution $softCreditTypes = $softCredits = array(); foreach ($softRecord['soft_credit'] as $key => $softCredit) { $softCreditTypes[$key] = $softCredit['soft_credit_type_label']; $softCredits[$key] = array('Name' => $softCredit['contact_name'], 'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency'])); } $template->assign('softCreditTypes', $softCreditTypes); $template->assign('softCredits', $softCredits); } } $dao = new CRM_Contribute_DAO_ContributionProduct(); $dao->contribution_id = $this->id; if ($dao->find(TRUE)) { $premiumId = $dao->product_id; $template->assign('option', $dao->product_option); $productDAO = new CRM_Contribute_DAO_Product(); $productDAO->id = $premiumId; $productDAO->find(TRUE); $template->assign('selectPremium', TRUE); $template->assign('product_name', $productDAO->name); $template->assign('price', $productDAO->price); $template->assign('sku', $productDAO->sku); } $template->assign('title', CRM_Utils_Array::value('title', $values)); $amount = CRM_Utils_Array::value('total_amount', $input, CRM_Utils_Array::value('amount', $input), NULL); if (empty($amount) && isset($this->total_amount)) { $amount = $this->total_amount; } $template->assign('amount', $amount); // add the new contribution values if (strtolower($this->_component) == 'contribute') { //PCP Info $softDAO = new CRM_Contribute_DAO_ContributionSoft(); $softDAO->contribution_id = $this->id; if ($softDAO->find(TRUE)) { $template->assign('pcpBlock', TRUE); $template->assign('pcp_display_in_roll', $softDAO->pcp_display_in_roll); $template->assign('pcp_roll_nickname', $softDAO->pcp_roll_nickname); $template->assign('pcp_personal_note', $softDAO->pcp_personal_note); //assign the pcp page title for email subject $pcpDAO = new CRM_PCP_DAO_PCP(); $pcpDAO->id = $softDAO->pcp_id; if ($pcpDAO->find(TRUE)) { $template->assign('title', $pcpDAO->title); } } } if ($this->financial_type_id) { $values['financial_type_id'] = $this->financial_type_id; } $template->assign('trxn_id', $this->trxn_id); $template->assign('receive_date', CRM_Utils_Date::mysqlToIso($this->receive_date)); $template->assign('contributeMode', 'notify'); $template->assign('action', $this->is_test ? 1024 : 1); $template->assign('receipt_text', CRM_Utils_Array::value('receipt_text', $values)); $template->assign('is_monetary', 1); $template->assign('is_recur', (bool) $recur); $template->assign('currency', $this->currency); $template->assign('address', CRM_Utils_Address::format($input)); if (!empty($values['customGroup'])) { $template->assign('customGroup', $values['customGroup']); } if ($this->_component == 'event') { $template->assign('title', $values['event']['title']); $participantRoles = CRM_Event_PseudoConstant::participantRole(); $viewRoles = array(); foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_relatedObjects['participant']->role_id) as $k => $v) { $viewRoles[] = $participantRoles[$v]; } $values['event']['participant_role'] = implode(', ', $viewRoles); $template->assign('event', $values['event']); $template->assign('participant', $values['participant']); $template->assign('location', $values['location']); $template->assign('customPre', $values['custom_pre_id']); $template->assign('customPost', $values['custom_post_id']); $isTest = FALSE; if ($this->_relatedObjects['participant']->is_test) { $isTest = TRUE; } $values['params'] = array(); //to get email of primary participant. $primaryEmail = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $this->_relatedObjects['participant']->contact_id, 'email', 'contact_id'); $primaryAmount[] = array('label' => $this->_relatedObjects['participant']->fee_level . ' - ' . $primaryEmail, 'amount' => $this->_relatedObjects['participant']->fee_amount); //build an array of cId/pId of participants $additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($this->_relatedObjects['participant']->id, NULL, $this->_relatedObjects['contact']->id, $isTest, TRUE); unset($additionalIDs[$this->_relatedObjects['participant']->id]); //send receipt to additional participant if exists if (count($additionalIDs)) { $template->assign('isPrimary', 0); $template->assign('customProfile', NULL); //set additionalParticipant true $values['params']['additionalParticipant'] = TRUE; foreach ($additionalIDs as $pId => $cId) { $amount = array(); //to change the status pending to completed $additional = new CRM_Event_DAO_Participant(); $additional->id = $pId; $additional->contact_id = $cId; $additional->find(TRUE); $additional->register_date = $this->_relatedObjects['participant']->register_date; $additional->status_id = 1; $additionalParticipantInfo = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $additional->contact_id, 'email', 'contact_id'); //if additional participant dont have email //use display name. if (!$additionalParticipantInfo) { $additionalParticipantInfo = CRM_Contact_BAO_Contact::displayName($additional->contact_id); } $amount[0] = array('label' => $additional->fee_level, 'amount' => $additional->fee_amount); $primaryAmount[] = array('label' => $additional->fee_level . ' - ' . $additionalParticipantInfo, 'amount' => $additional->fee_amount); $additional->save(); $additional->free(); $template->assign('amount', $amount); CRM_Event_BAO_Event::sendMail($cId, $values, $pId, $isTest, $returnMessageText); } } //build an array of custom profile and assigning it to template $customProfile = CRM_Event_BAO_Event::buildCustomProfile($this->_relatedObjects['participant']->id, $values, NULL, $isTest); if (count($customProfile)) { $template->assign('customProfile', $customProfile); } // for primary contact $values['params']['additionalParticipant'] = FALSE; $template->assign('isPrimary', 1); $template->assign('amount', $primaryAmount); $template->assign('register_date', CRM_Utils_Date::isoToMysql($this->_relatedObjects['participant']->register_date)); if ($this->payment_instrument_id) { $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument(); $template->assign('paidBy', $paymentInstrument[$this->payment_instrument_id]); } // carry paylater, since we did not created billing, // so need to pull email from primary location, CRM-4395 $values['params']['is_pay_later'] = $this->_relatedObjects['participant']->is_pay_later; } return $template; }
/** * returns the list of fields that can be exported * * @access public * return array * @static */ static function &export($prefix = false) { if (!self::$_export) { self::$_export = array(); $fields = self::fields(); foreach ($fields as $name => $field) { if (CRM_Utils_Array::value('export', $field)) { if ($prefix) { self::$_export['pcp'] =& $fields[$name]; } else { self::$_export[$name] =& $fields[$name]; } } } } return self::$_export; }
static function getPcpIdByContactAndEvent($eventId, $contactId, $component = 'event') { if (empty($eventId) || empty($contactId)) { return null; } $dao = new CRM_PCP_DAO_PCP(); $dao->contact_id = $contactId; $dao->page_id = $eventId; $dao->page_type = $component; $dao->find(TRUE); return $dao->id; }