コード例 #1
0
 /**
  * @param int $id
  *
  * @return bool
  */
 public static function deleteParticipantStatusType($id)
 {
     // return early if there are participants with this status
     $participant = new CRM_Event_DAO_Participant();
     $participant->status_id = $id;
     if ($participant->find()) {
         return FALSE;
     }
     CRM_Utils_Weight::delWeight('CRM_Event_DAO_ParticipantStatusType', $id);
     $dao = new CRM_Event_DAO_ParticipantStatusType();
     $dao->id = $id;
     $dao->find(TRUE);
     $dao->delete();
     return TRUE;
 }
コード例 #2
0
 static function deleteParticipantStatusType($id)
 {
     // return early if there are participants with this status
     require_once 'CRM/Event/DAO/Participant.php';
     $participant = new CRM_Event_DAO_Participant();
     $participant->status_id = $id;
     if ($participant->find()) {
         return false;
     }
     require_once 'CRM/Utils/Weight.php';
     CRM_Utils_Weight::delWeight('CRM_Event_DAO_ParticipantStatusType', $id);
     $dao = new CRM_Event_DAO_ParticipantStatusType();
     $dao->id = $id;
     $dao->find(true);
     $dao->delete();
     return true;
 }
コード例 #3
0
ファイル: Delete.php プロジェクト: agloa/tournament
 /**
  * Process the form when submitted.
  *
  * @return void
  */
 public function postProcess()
 {
     $participant = new CRM_Event_DAO_Participant();
     $participant->event_id = $this->_id;
     if ($participant->find()) {
         $searchURL = CRM_Utils_System::url('civicrm/event/search', 'reset=1');
         CRM_Core_Session::setStatus(ts('This event cannot be deleted because there are participant records linked to it. If you want to delete this event, you must first find the participants linked to this event and delete them. You can use use <a href=\'%1\'> CiviEvent >> Find Participants page </a>.', array(1 => $searchURL)), ts('Deletion Error'), 'error');
         return;
     }
     CRM_Event_BAO_Event::del($this->_id);
     if ($this->_isTemplate) {
         CRM_Core_Session::setStatus(ts("'%1' has been deleted.", array(1 => $this->_title)), ts('Template Deleted'), 'success');
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1'));
     } else {
         CRM_Core_Session::setStatus(ts("'%1' has been deleted.", array(1 => $this->_title)), ts('Event Deleted'), 'success');
     }
 }
コード例 #4
0
 /**
  * Delete participants of contact.
  *
  * CRM-12155
  *
  * @param int $contactId
  *   Contact id.
  *
  */
 public static function deleteContactParticipant($contactId)
 {
     $participant = new CRM_Event_DAO_Participant();
     $participant->contact_id = $contactId;
     $participant->find();
     while ($participant->fetch()) {
         self::deleteParticipant($participant->id);
     }
 }
コード例 #5
0
ファイル: OptionValue.php プロジェクト: kidaa30/yes
 /**
  * Updates contacts affected by the option value passed.
  *
  * @param int $optionValueId
  *   The option value id.
  * @param int $action
  *   The action describing whether prefix/suffix was UPDATED or DELETED.
  *
  * @return bool
  */
 public static function updateRecords(&$optionValueId, $action)
 {
     //finding group name
     $optionValue = new CRM_Core_DAO_OptionValue();
     $optionValue->id = $optionValueId;
     $optionValue->find(TRUE);
     $optionGroup = new CRM_Core_DAO_OptionGroup();
     $optionGroup->id = $optionValue->option_group_id;
     $optionGroup->find(TRUE);
     // group name
     $gName = $optionGroup->name;
     // value
     $value = $optionValue->value;
     // get the proper group name & affected field name
     // todo: this may no longer be needed for individuals - check inputs
     $individuals = array('gender' => 'gender_id', 'individual_prefix' => 'prefix_id', 'individual_suffix' => 'suffix_id', 'communication_style' => 'communication_style_id');
     $contributions = array('payment_instrument' => 'payment_instrument_id');
     $activities = array('activity_type' => 'activity_type_id');
     $participant = array('participant_role' => 'role_id');
     $eventType = array('event_type' => 'event_type_id');
     $aclRole = array('acl_role' => 'acl_role_id');
     $all = array_merge($individuals, $contributions, $activities, $participant, $eventType, $aclRole);
     $fieldName = '';
     foreach ($all as $name => $id) {
         if ($gName == $name) {
             $fieldName = $id;
         }
     }
     if ($fieldName == '') {
         return TRUE;
     }
     if (array_key_exists($gName, $individuals)) {
         $contactDAO = new CRM_Contact_DAO_Contact();
         $contactDAO->{$fieldName} = $value;
         $contactDAO->find();
         while ($contactDAO->fetch()) {
             if ($action == CRM_Core_Action::DELETE) {
                 $contact = new CRM_Contact_DAO_Contact();
                 $contact->id = $contactDAO->id;
                 $contact->find(TRUE);
                 // make sure dates doesn't get reset
                 $contact->birth_date = CRM_Utils_Date::isoToMysql($contact->birth_date);
                 $contact->deceased_date = CRM_Utils_Date::isoToMysql($contact->deceased_date);
                 $contact->{$fieldName} = 'NULL';
                 $contact->save();
             }
         }
         return TRUE;
     }
     if (array_key_exists($gName, $contributions)) {
         $contribution = new CRM_Contribute_DAO_Contribution();
         $contribution->{$fieldName} = $value;
         $contribution->find();
         while ($contribution->fetch()) {
             if ($action == CRM_Core_Action::DELETE) {
                 $contribution->{$fieldName} = 'NULL';
                 $contribution->save();
             }
         }
         return TRUE;
     }
     if (array_key_exists($gName, $activities)) {
         $activity = new CRM_Activity_DAO_Activity();
         $activity->{$fieldName} = $value;
         $activity->find();
         while ($activity->fetch()) {
             $activity->delete();
         }
         return TRUE;
     }
     //delete participant role, type and event type option value
     if (array_key_exists($gName, $participant)) {
         $participantValue = new CRM_Event_DAO_Participant();
         $participantValue->{$fieldName} = $value;
         if ($participantValue->find(TRUE)) {
             return FALSE;
         }
         return TRUE;
     }
     //delete event type option value
     if (array_key_exists($gName, $eventType)) {
         $event = new CRM_Event_DAO_Event();
         $event->{$fieldName} = $value;
         if ($event->find(TRUE)) {
             return FALSE;
         }
         return TRUE;
     }
     //delete acl_role option value
     if (array_key_exists($gName, $aclRole)) {
         $entityRole = new CRM_ACL_DAO_EntityRole();
         $entityRole->{$fieldName} = $value;
         $aclDAO = new CRM_ACL_DAO_ACL();
         $aclDAO->entity_id = $value;
         if ($entityRole->find(TRUE) || $aclDAO->find(TRUE)) {
             return FALSE;
         }
         return TRUE;
     }
 }
コード例 #6
0
 private function addLineItemParticipants()
 {
     $participant = new CRM_Event_DAO_Participant();
     $participant->query("INSERT INTO civicrm_line_item (`entity_table`, `entity_id`, contribution_id, `price_field_id`, `label`, `qty`, `unit_price`, `line_total`, `participant_count`, `price_field_value_id`, `financial_type_id`)\nSELECT 'civicrm_participant', cp.id, cpp.contribution_id, cpfv.price_field_id, cpfv.label, 1, cpfv.amount, cpfv.amount as line_total, 0, cpfv.id, cpfv.financial_type_id FROM civicrm_participant cp LEFT JOIN civicrm_participant_payment cpp ON cpp.participant_id = cp.id\nLEFT JOIN civicrm_price_set_entity cpe ON cpe.entity_id = cp.event_id LEFT JOIN civicrm_price_field cpf ON cpf.price_set_id = cpe.price_set_id LEFT JOIN civicrm_price_field_value cpfv ON cpfv.price_field_id = cpf.id WHERE cpfv.label = cp.fee_level");
 }
コード例 #7
0
 /**
  * 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;
 }
コード例 #8
0
ファイル: Event.php プロジェクト: hampelm/Ginsberg-CiviDemo
 function checkRegistration($params)
 {
     $alreadyRegistered = false;
     if (!CRM_Utils_Array::value('contact_id', $params)) {
         return $alreadyRegistered;
     }
     require_once 'CRM/Event/PseudoConstant.php';
     require_once 'CRM/Event/DAO/Participant.php';
     $statusTypes = CRM_Event_PseudoConstant::participantStatus(null, "is_counted = 1");
     $participant = new CRM_Event_DAO_Participant();
     $participant->copyValues($params);
     $participant->is_test = CRM_Utils_Array::value('is_test', $params, 0);
     $participant->selectAdd();
     $participant->selectAdd('status_id');
     if ($participant->find(true) && array_key_exists($participant->status_id, $statusTypes)) {
         $alreadyRegistered = true;
     }
     return $alreadyRegistered;
 }
コード例 #9
0
ファイル: Event.php プロジェクト: prashantgajare/civicrm-core
 /**
  * @param $params
  *
  * @return bool
  */
 static function checkRegistration($params)
 {
     $alreadyRegistered = FALSE;
     if (empty($params['contact_id'])) {
         return $alreadyRegistered;
     }
     $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
     $participant = new CRM_Event_DAO_Participant();
     $participant->copyValues($params);
     $participant->is_test = CRM_Utils_Array::value('is_test', $params, 0);
     $participant->selectAdd();
     $participant->selectAdd('status_id');
     if ($participant->find(TRUE) && array_key_exists($participant->status_id, $statusTypes)) {
         $alreadyRegistered = TRUE;
     }
     return $alreadyRegistered;
 }
コード例 #10
0
ファイル: BaseIPN.php プロジェクト: hampelm/Ginsberg-CiviDemo
 function sendMail(&$input, &$ids, &$objects, &$values, $recur = false, $returnMessageText = false)
 {
     $contribution =& $objects['contribution'];
     $membership =& $objects['membership'];
     $participant =& $objects['participant'];
     $event =& $objects['event'];
     if (empty($values)) {
         $values = array();
         $contribID = $ids['contribution'];
         if ($input['component'] == 'contribute') {
             require_once 'CRM/Contribute/BAO/ContributionPage.php';
             if (isset($contribution->contribution_page_id)) {
                 CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
             } else {
                 // Handle re-print receipt for offline contributions (call from PDF.php - no contribution_page_id)
                 $values['is_email_receipt'] = 1;
                 $values['title'] = 'Contribution';
             }
             // set lineItem for contribution
             require_once 'CRM/Price/BAO/Set.php';
             if ($contribID && ($pId = CRM_Price_BAO_Set::getFor('civicrm_contribution', $contribID))) {
                 require_once 'CRM/Price/BAO/LineItem.php';
                 $values['lineItem'][0] = CRM_Price_BAO_LineItem::getLineItems($contribID, 'contribution');
                 $values['priceSetID'] = $pId;
             }
             require_once 'CRM/Contribute/BAO/Contribution.php';
             $relatedContact = CRM_Contribute_BAO_Contribution::getOnbehalfIds($contribID, $contribution->contact_id);
             // if this is onbehalf of contribution then set related contact
             if ($relatedContactId = $relatedContact['individual_id']) {
                 $values['related_contact'] = $ids['related_contact'] = $relatedContactId;
             }
         } else {
             // event
             $eventParams = array('id' => $objects['event']->id);
             $values['event'] = array();
             require_once 'CRM/Event/BAO/Event.php';
             CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
             //get location details
             $locationParams = array('entity_id' => $objects['event']->id, 'entity_table' => 'civicrm_event');
             require_once 'CRM/Core/BAO/Location.php';
             require_once 'CRM/Event/Form/ManageEvent/Location.php';
             $values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
             require_once 'CRM/Core/BAO/UFJoin.php';
             $ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'weight' => 1);
             $values['custom_pre_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
             $ufJoinParams['weight'] = 2;
             $values['custom_post_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
             // set lineItem for event contribution
             if ($contribID) {
                 require_once 'CRM/Event/BAO/Participant.php';
                 $participantIds = CRM_Event_BAO_Participant::getParticipantIds($contribID);
                 require_once 'CRM/Price/BAO/LineItem.php';
                 if (!empty($participantIds)) {
                     foreach ($participantIds as $pIDs) {
                         $lineItem = CRM_Price_BAO_LineItem::getLineItems($pIDs);
                         if (!CRM_Utils_System::isNull($lineItem)) {
                             $values['lineItem'][] = $lineItem;
                         }
                     }
                 }
             }
         }
         // set receipt from e-mail and name in value
         if (!$returnMessageText) {
             require_once 'CRM/Contact/BAO/Contact/Location.php';
             $session = CRM_Core_Session::singleton();
             $userID = $session->get('userID');
             list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
             $values['receipt_from_email'] = $userEmail;
             $values['receipt_from_name'] = $userName;
         }
         // set display address of contributor
         if ($contribution->address_id) {
             require_once 'CRM/Core/BAO/Address.php';
             $addressParams = array('id' => $contribution->address_id);
             $addressDetails = CRM_Core_BAO_Address::getValues($addressParams, false, 'id');
             $addressDetails = array_values($addressDetails);
             $values['address'] = $addressDetails[0]['display'];
         }
     }
     $template =& CRM_Core_Smarty::singleton();
     // CRM_Core_Error::debug('tpl',$template);
     //assign honor infomation to receiptmessage
     if ($honarID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribution->id, 'honor_contact_id')) {
         $honorDefault = array();
         $honorIds = array();
         $honorIds['contribution'] = $contribution->id;
         $idParams = array('id' => $honarID, 'contact_id' => $honarID);
         require_once "CRM/Contact/BAO/Contact.php";
         CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $honorIds);
         require_once "CRM/Core/PseudoConstant.php";
         $honorType = CRM_Core_PseudoConstant::honor();
         $prefix = CRM_Core_PseudoConstant::individualPrefix();
         $template->assign('honor_block_is_active', 1);
         $template->assign('honor_prefix', $prefix[$honorDefault["prefix_id"]]);
         $template->assign('honor_first_name', CRM_Utils_Array::value("first_name", $honorDefault));
         $template->assign('honor_last_name', CRM_Utils_Array::value("last_name", $honorDefault));
         $template->assign('honor_email', CRM_Utils_Array::value("email", $honorDefault["email"][1]));
         $template->assign('honor_type', $honorType[$contribution->honor_type_id]);
     }
     require_once 'CRM/Contribute/DAO/ContributionProduct.php';
     $dao = new CRM_Contribute_DAO_ContributionProduct();
     $dao->contribution_id = $contribution->id;
     if ($dao->find(true)) {
         $premiumId = $dao->product_id;
         $template->assign('option', $dao->product_option);
         require_once 'CRM/Contribute/DAO/Product.php';
         $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);
     }
     // add the new contribution values
     if ($input['component'] == 'contribute') {
         $template->assign('title', $values['title']);
         $template->assign('amount', $input['amount']);
         //PCP Info
         require_once 'CRM/Contribute/DAO/ContributionSoft.php';
         $softDAO = new CRM_Contribute_DAO_ContributionSoft();
         $softDAO->contribution_id = $contribution->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
             require_once 'CRM/Contribute/DAO/PCP.php';
             $pcpDAO = new CRM_Contribute_DAO_PCP();
             $pcpDAO->id = $softDAO->pcp_id;
             if ($pcpDAO->find(true)) {
                 $template->assign('title', $pcpDAO->title);
             }
         }
     } else {
         $template->assign('title', $values['event']['title']);
         $template->assign('totalAmount', $input['amount']);
     }
     if ($contribution->contribution_type_id) {
         $values['contribution_type_id'] = $contribution->contribution_type_id;
     }
     $template->assign('trxn_id', $contribution->trxn_id);
     $template->assign('receive_date', CRM_Utils_Date::mysqlToIso($contribution->receive_date));
     $template->assign('contributeMode', 'notify');
     $template->assign('action', $contribution->is_test ? 1024 : 1);
     $template->assign('receipt_text', CRM_Utils_Array::value('receipt_text', $values));
     $template->assign('is_monetary', 1);
     $template->assign('is_recur', $recur);
     $template->assign('currency', $contribution->currency);
     if ($recur) {
         require_once 'CRM/Core/Payment.php';
         $paymentObject =& CRM_Core_Payment::singleton($contribution->is_test ? 'test' : 'live', $objects['paymentProcessor']);
         if (!empty($membership) && $membership->id) {
             $url = $paymentObject->cancelSubscriptionURL($membership->id, 'membership');
         } else {
             $url = $paymentObject->cancelSubscriptionURL();
         }
         $template->assign('cancelSubscriptionUrl', $url);
         if ($objects['paymentProcessor']['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) {
             //direct mode showing billing block, so use directIPN for temporary
             $template->assign('contributeMode', 'directIPN');
         }
     }
     require_once 'CRM/Utils/Address.php';
     $template->assign('address', CRM_Utils_Address::format($input));
     if ($input['component'] == 'event') {
         require_once 'CRM/Core/OptionGroup.php';
         $participant_role = CRM_Core_OptionGroup::values('participant_role');
         $values['event']['participant_role'] = $participant_role[$participant->role_id];
         $template->assign('event', $values['event']);
         $template->assign('location', $values['location']);
         $template->assign('customPre', $values['custom_pre_id']);
         $template->assign('customPost', $values['custom_post_id']);
         $isTest = false;
         if ($participant->is_test) {
             $isTest = true;
         }
         $values['params'] = array();
         require_once "CRM/Event/BAO/Event.php";
         //to get email of primary participant.
         $primaryEmail = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $participant->contact_id, 'email', 'contact_id');
         $primaryAmount[] = array('label' => $participant->fee_level . ' - ' . $primaryEmail, 'amount' => $participant->fee_amount);
         //build an array of cId/pId of participants
         $additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($participant->id, null, $ids['contact'], $isTest, true);
         unset($additionalIDs[$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 = $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) {
                     require_once "CRM/Contact/BAO/Contact.php";
                     $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($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($participant->register_date));
         if ($contribution->payment_instrument_id) {
             require_once 'CRM/Contribute/PseudoConstant.php';
             $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
             $template->assign('paidBy', $paymentInstrument[$contribution->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'] = $participant->is_pay_later;
         return CRM_Event_BAO_Event::sendMail($ids['contact'], $values, $participant->id, $isTest, $returnMessageText);
     } else {
         if ($membership) {
             $values['membership_id'] = $membership->id;
             // need to set the membership values here
             $template->assign('membership_assign', 1);
             require_once 'CRM/Member/PseudoConstant.php';
             $template->assign('membership_name', CRM_Member_PseudoConstant::membershipType($membership->membership_type_id));
             $template->assign('mem_start_date', $membership->start_date);
             $template->assign('mem_end_date', $membership->end_date);
             // if separate payment there are two contributions recorded and the
             // admin will need to send a receipt for each of them separately.
             // we dont link the two in the db (but can potentially infer it if needed)
             $template->assign('is_separate_payment', 0);
         }
         $values['contribution_id'] = $contribution->id;
         if (CRM_Utils_Array::value('related_contact', $ids)) {
             $values['related_contact'] = $ids['related_contact'];
             if (isset($ids['onbehalf_dupe_alert'])) {
                 $values['onbehalf_dupe_alert'] = $ids['onbehalf_dupe_alert'];
             }
             require_once 'CRM/Core/BAO/Address.php';
             $entityBlock = array('contact_id' => $ids['contact'], 'location_type_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', 'Home', 'id', 'name'));
             $address = CRM_Core_BAO_Address::getValues($entityBlock);
             $template->assign('onBehalfAddress', $address[$entityBlock['location_type_id']]['display']);
         }
         $isTest = false;
         if ($contribution->is_test) {
             $isTest = true;
         }
         // CRM_Core_Error::debug('val',$values);
         require_once 'CRM/Contribute/BAO/ContributionPage.php';
         return CRM_Contribute_BAO_ContributionPage::sendMail($ids['contact'], $values, $isTest, $returnMessageText);
     }
 }
コード例 #11
0
/**
 * take the input parameter list as specified in the data model and
 * convert it into the same format that we use in QF and BAO object
 *
 * @param array $params
 *   Associative array of property name/value.
 *                             pairs to insert in new contact.
 * @param array $values
 *   The reformatted properties that we can use internally.
 *
 * @param array|bool $create Is the formatted Values array going to
 *                             be used for CRM_vent_BAO_Participant:create()
 *
 * @return array|CRM_Error
 */
function _civicrm_api3_deprecated_participant_formatted_param($params, &$values, $create = FALSE)
{
    $fields = CRM_Event_DAO_Participant::fields();
    _civicrm_api3_store_values($fields, $params, $values);
    require_once 'CRM/Core/OptionGroup.php';
    $customFields = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, NULL, FALSE, FALSE, FALSE);
    foreach ($params as $key => $value) {
        // ignore empty values or empty arrays etc
        if (CRM_Utils_System::isNull($value)) {
            continue;
        }
        // Handling Custom Data
        if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
            $values[$key] = $value;
            $type = $customFields[$customFieldID]['html_type'];
            if ($type == 'CheckBox' || $type == 'Multi-Select') {
                $mulValues = explode(',', $value);
                $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
                $values[$key] = array();
                foreach ($mulValues as $v1) {
                    foreach ($customOption as $customValueID => $customLabel) {
                        $customValue = $customLabel['value'];
                        if (strtolower(trim($customLabel['label'])) == strtolower(trim($v1)) || strtolower(trim($customValue)) == strtolower(trim($v1))) {
                            if ($type == 'CheckBox') {
                                $values[$key][$customValue] = 1;
                            } else {
                                $values[$key][] = $customValue;
                            }
                        }
                    }
                }
            } elseif ($type == 'Select' || $type == 'Radio') {
                $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
                foreach ($customOption as $customFldID => $customValue) {
                    $val = CRM_Utils_Array::value('value', $customValue);
                    $label = CRM_Utils_Array::value('label', $customValue);
                    $label = strtolower($label);
                    $value = strtolower(trim($value));
                    if ($value == $label || $value == strtolower($val)) {
                        $values[$key] = $val;
                    }
                }
            }
        }
        switch ($key) {
            case 'participant_contact_id':
                if (!CRM_Utils_Rule::integer($value)) {
                    return civicrm_api3_create_error("contact_id not valid: {$value}");
                }
                $dao = new CRM_Core_DAO();
                $qParams = array();
                $svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = {$value}", $qParams);
                if (!$svq) {
                    return civicrm_api3_create_error("Invalid Contact ID: There is no contact record with contact_id = {$value}.");
                }
                $values['contact_id'] = $values['participant_contact_id'];
                unset($values['participant_contact_id']);
                break;
            case 'participant_register_date':
                if (!CRM_Utils_Rule::dateTime($value)) {
                    return civicrm_api3_create_error("{$key} not a valid date: {$value}");
                }
                break;
            case 'event_title':
                $id = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $value, 'id', 'title');
                $values['event_id'] = $id;
                break;
            case 'event_id':
                if (!CRM_Utils_Rule::integer($value)) {
                    return civicrm_api3_create_error("Event ID is not valid: {$value}");
                }
                $dao = new CRM_Core_DAO();
                $qParams = array();
                $svq = $dao->singleValueQuery("SELECT id FROM civicrm_event WHERE id = {$value}", $qParams);
                if (!$svq) {
                    return civicrm_api3_create_error("Invalid Event ID: There is no event record with event_id = {$value}.");
                }
                break;
            case 'participant_status_id':
                if (!CRM_Utils_Rule::integer($value)) {
                    return civicrm_api3_create_error("Event Status ID is not valid: {$value}");
                }
                break;
            case 'participant_status':
                $status = CRM_Event_PseudoConstant::participantStatus();
                $values['participant_status_id'] = CRM_Utils_Array::key($value, $status);
                break;
            case 'participant_role_id':
            case 'participant_role':
                $role = CRM_Event_PseudoConstant::participantRole();
                $participantRoles = explode(",", $value);
                foreach ($participantRoles as $k => $v) {
                    $v = trim($v);
                    if ($key == 'participant_role') {
                        $participantRoles[$k] = CRM_Utils_Array::key($v, $role);
                    } else {
                        $participantRoles[$k] = $v;
                    }
                }
                require_once 'CRM/Core/DAO.php';
                $values['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $participantRoles);
                unset($values[$key]);
                break;
            default:
                break;
        }
    }
    if (array_key_exists('participant_note', $params)) {
        $values['participant_note'] = $params['participant_note'];
    }
    if ($create) {
        // CRM_Event_BAO_Participant::create() handles register_date,
        // status_id and source. So, if $values contains
        // participant_register_date, participant_status_id or participant_source,
        // convert it to register_date, status_id or source
        $changes = array('participant_register_date' => 'register_date', 'participant_source' => 'source', 'participant_status_id' => 'status_id', 'participant_role_id' => 'role_id', 'participant_fee_level' => 'fee_level', 'participant_fee_amount' => 'fee_amount', 'participant_id' => 'id');
        foreach ($changes as $orgVal => $changeVal) {
            if (isset($values[$orgVal])) {
                $values[$changeVal] = $values[$orgVal];
                unset($values[$orgVal]);
            }
        }
    }
    return NULL;
}
コード例 #12
0
 /**
  * check for whether participant is primary or not
  *
  * @param $participantId
  *
  * @return true if participant is primary
  * @access public
  */
 static function isPrimaryParticipant($participantId)
 {
     $participant = new CRM_Event_DAO_Participant();
     $participant->registered_by_id = $participantId;
     if ($participant->find(TRUE)) {
         return TRUE;
     }
     return FALSE;
 }
コード例 #13
0
ファイル: Participant.php プロジェクト: ksecor/civicrm
 /**                          
  * Delete the record that are associated with this participation
  * 
  * @param  int  $id id of the participation to delete                                                                           
  * 
  * @return void
  * @access public 
  * @static 
  */
 static function deleteParticipant($id)
 {
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     //delete activity record
     require_once "CRM/Activity/BAO/Activity.php";
     $params = array('source_record_id' => $id, 'activity_type_id' => 5);
     // activity type id for event registration
     CRM_Activity_BAO_Activity::deleteActivity($params);
     // delete the participant payment record
     // we need to do this since the cascaded constraints
     // dont work with join tables
     require_once 'CRM/Event/BAO/ParticipantPayment.php';
     $p = array('participant_id' => $id);
     CRM_Event_BAO_ParticipantPayment::deleteParticipantPayment($p);
     // cleanup line items.
     require_once 'CRM/Price/BAO/LineItem.php';
     CRM_Price_BAO_LineItem::deleteLineItems($id, 'civicrm_participant');
     $participant = new CRM_Event_DAO_Participant();
     $participant->id = $id;
     $participant->delete();
     $transaction->commit();
     // delete the recently created Activity
     require_once 'CRM/Utils/Recent.php';
     CRM_Utils_Recent::del($id);
     return $participant;
 }
コード例 #14
0
ファイル: Participant.php プロジェクト: agroknow/mermix
 /**
  * Returns the list of fields that can be exported
  *
  * @param bool $prefix
  *
  * @return array
  */
 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['participant'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }
コード例 #15
0
 /** 
  * check for whether participant is primary or not
  * @param $participantId  
  * @return true if participant is primary 
  * @access public 
  */
 static function isPrimaryParticipant($participantId)
 {
     $participant = new CRM_Event_DAO_Participant();
     $participant->registered_by_id = $participantId;
     if ($participant->find(true)) {
         return true;
     }
     return false;
 }
コード例 #16
0
ファイル: Registration.php プロジェクト: nyimbi/civicrm-core
 /**
  * Process the participant.
  *
  * @param CRM_Core_Form $form
  * @param int $contactID
  *
  * @return \CRM_Event_BAO_Participant
  */
 public static function addParticipant(&$form, $contactID)
 {
     if (empty($form->_params)) {
         return NULL;
     }
     $params = $form->_params;
     $transaction = new CRM_Core_Transaction();
     $groupName = 'participant_role';
     $query = "\nSELECT  v.label as label ,v.value as value\nFROM   civicrm_option_value v,\n       civicrm_option_group g\nWHERE  v.option_group_id = g.id\n  AND  g.name            = %1\n  AND  v.is_active       = 1\n  AND  g.is_active       = 1\n";
     $p = array(1 => array($groupName, 'String'));
     $dao = CRM_Core_DAO::executeQuery($query, $p);
     if ($dao->fetch()) {
         $roleID = $dao->value;
     }
     // handle register date CRM-4320
     $registerDate = NULL;
     if (!empty($form->_allowConfirmation) && $form->_participantId) {
         $registerDate = $params['participant_register_date'];
     } elseif (!empty($params['participant_register_date']) && is_array($params['participant_register_date']) && !empty($params['participant_register_date'])) {
         $registerDate = CRM_Utils_Date::format($params['participant_register_date']);
     }
     $participantFields = CRM_Event_DAO_Participant::fields();
     $participantParams = array('id' => CRM_Utils_Array::value('participant_id', $params), 'contact_id' => $contactID, 'event_id' => $form->_eventId ? $form->_eventId : $params['event_id'], 'status_id' => CRM_Utils_Array::value('participant_status', $params, 1), 'role_id' => CRM_Utils_Array::value('participant_role_id', $params, $roleID), 'register_date' => $registerDate ? $registerDate : date('YmdHis'), 'source' => CRM_Utils_String::ellipsify(isset($params['participant_source']) ? CRM_Utils_Array::value('participant_source', $params) : CRM_Utils_Array::value('description', $params), $participantFields['participant_source']['maxlength']), 'fee_level' => CRM_Utils_Array::value('amount_level', $params), 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'fee_amount' => CRM_Utils_Array::value('fee_amount', $params), 'registered_by_id' => CRM_Utils_Array::value('registered_by_id', $params), 'discount_id' => CRM_Utils_Array::value('discount_id', $params), 'fee_currency' => CRM_Utils_Array::value('currencyID', $params), 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params));
     if ($form->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') {
         $participantParams['is_test'] = 1;
     } else {
         $participantParams['is_test'] = 0;
     }
     if (!empty($form->_params['note'])) {
         $participantParams['note'] = $form->_params['note'];
     } elseif (!empty($form->_params['participant_note'])) {
         $participantParams['note'] = $form->_params['participant_note'];
     }
     // reuse id if one already exists for this one (can happen
     // with back button being hit etc)
     if (!$participantParams['id'] && !empty($params['contributionID'])) {
         $pID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $params['contributionID'], 'participant_id', 'contribution_id');
         $participantParams['id'] = $pID;
     }
     $participantParams['discount_id'] = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
     if (!$participantParams['discount_id']) {
         $participantParams['discount_id'] = "null";
     }
     $participant = CRM_Event_BAO_Participant::create($participantParams);
     $transaction->commit();
     return $participant;
 }
コード例 #17
0
/**
 * take the input parameter list as specified in the data model and
 * convert it into the same format that we use in QF and BAO object
 *
 * @param array  $params       Associative array of property name/value
 *                             pairs to insert in new contact.
 * @param array  $values       The reformatted properties that we can use internally
 *
 * @param array  $create       Is the formatted Values array going to
 *                             be used for CRM_Event_BAO_Participant:create()
 *
 * @return array|CRM_Error
 * @access public
 */
function _civicrm_participant_formatted_param(&$params, &$values, $create = FALSE)
{
    $fields = CRM_Event_DAO_Participant::fields();
    _civicrm_store_values($fields, $params, $values);
    require_once 'CRM/Core/OptionGroup.php';
    $customFields = CRM_Core_BAO_CustomField::getFields('Participant');
    foreach ($params as $key => $value) {
        // ignore empty values or empty arrays etc
        if (CRM_Utils_System::isNull($value)) {
            continue;
        }
        //Handling Custom Data
        _civicrm_generic_handle_custom_data($key, $value, $values, $customFields);
        switch ($key) {
            case 'participant_contact_id':
                if (!CRM_Utils_Rule::integer($value)) {
                    return civicrm_create_error("contact_id not valid: {$value}");
                }
                $dao = new CRM_Core_DAO();
                $qParams = array();
                $svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = {$value}", $qParams);
                if (!$svq) {
                    return civicrm_create_error("Invalid Contact ID: There is no contact record with contact_id = {$value}.");
                }
                $values['contact_id'] = $values['participant_contact_id'];
                unset($values['participant_contact_id']);
                break;
            case 'participant_register_date':
                if (!CRM_Utils_Rule::date($value)) {
                    return civicrm_create_error("{$key} not a valid date: {$value}");
                }
                break;
            case 'event_title':
                $id = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $value, 'id', 'title');
                $values['event_id'] = $id;
                break;
            case 'event_id':
                if (!CRM_Utils_Rule::integer($value)) {
                    return civicrm_create_error("Event ID is not valid: {$value}");
                }
                $dao = new CRM_Core_DAO();
                $qParams = array();
                $svq = $dao->singleValueQuery("SELECT id FROM civicrm_event WHERE id = {$value}", $qParams);
                if (!$svq) {
                    return civicrm_create_error("Invalid Event ID: There is no event record with event_id = {$value}.");
                }
                break;
            case 'participant_status':
                $values['status_id'] = $values['participant_status_id'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantStatusType', $value, 'id', 'label');
                break;
            case 'participant_status_id':
                if ((int) $value) {
                    $values['status_id'] = $values[$key] = $value;
                } else {
                    $id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantStatusType', $value, 'id', 'label');
                    $values['status_id'] = $values[$key] = $id;
                }
                break;
            case 'participant_role_id':
            case 'participant_role':
                $role = CRM_Event_PseudoConstant::participantRole();
                $participantRoles = explode(",", $value);
                foreach ($participantRoles as $k => $v) {
                    $v = trim($v);
                    if ($key == 'participant_role') {
                        $participantRoles[$k] = CRM_Utils_Array::key($v, $role);
                    } else {
                        $participantRoles[$k] = $v;
                    }
                }
                require_once 'CRM/Core/DAO.php';
                $values['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $participantRoles);
                unset($values[$key]);
                break;
            default:
                break;
        }
    }
    if (array_key_exists('participant_note', $params)) {
        $values['participant_note'] = $params['participant_note'];
    }
    if ($create) {
        // CRM_Event_BAO_Participant::create() handles register_date,
        // status_id and source. So, if $values contains
        // participant_register_date, participant_status_id or participant_source,
        // convert it to register_date, status_id or source
        $changes = array('participant_register_date' => 'register_date', 'participant_source' => 'source', 'participant_status_id' => 'status_id', 'participant_role_id' => 'role_id', 'participant_fee_level' => 'fee_level', 'participant_fee_amount' => 'fee_amount', 'participant_id' => 'id');
        foreach ($changes as $orgVal => $changeVal) {
            if (isset($values[$orgVal])) {
                $values[$changeVal] = $values[$orgVal];
                unset($values[$orgVal]);
            }
        }
    }
    return NULL;
}