Exemple #1
0
 function getTemplateFileName()
 {
     $profID = CRM_Utils_Request::retrieve('gid', 'String', $this);
     $this->_params['contact_type'] = 'Individual';
     $selector = new CRM_Profile_Selector_Listings($this->_params, $this->_customFields, $profID, $this->_map, FALSE, 0);
     $extraWhereClause = NULL;
     $grpParams = array('name' => 'HRJobContract_Summary');
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomGroup', $grpParams, $cGrp);
     $fdParams = array('name' => 'Final_Termination_Date', 'custom_group_id' => $cGrp['id']);
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $fdParams, $fdField);
     $idParams = array('name' => 'Initial_Join_Date', 'custom_group_id' => $cGrp['id']);
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $idParams, $idField);
     $extraWhereClause = " (({$cGrp['table_name']}.{$fdField['column_name']} >= CURDATE() OR {$cGrp['table_name']}.{$fdField['column_name']} IS NULL) AND\n      ({$cGrp['table_name']}.{$idField['column_name']} IS NOT NULL AND {$cGrp['table_name']}.{$idField['column_name']} <= CURDATE()))";
     $column = $columnHeaders = $selector->getColumnHeaders();
     $rows = $selector->getRows(4, 0, 0, NULL, NULL, $extraWhereClause);
     CRM_Utils_Hook::searchColumns('profile', $columnHeaders, $rows, $this);
     $this->assign('aaData', json_encode($rows));
     /* to bring column names in [
     			{ "sTitle": "Engine" },
     			{ "sTitle": "Browser" },] format*/
     $colunmH = "[";
     foreach ($column as $k => $v) {
         if (!empty($v['name'])) {
             $name = '{"sTitle":"' . $v['name'] . '"}';
         } else {
             $name = '{"bSortable": false}';
         }
         $colunmH .= $name . ",";
     }
     $colunmH .= "]";
     $this->assign('aaColumn', $colunmH);
     return 'CRM/HRProfile/Page/HRProfile.tpl';
 }
Exemple #2
0
 /**
  * Set default values for the form.
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $defaults = array();
     $defaults = array();
     if (isset($this->_id)) {
         $title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'title');
         CRM_Utils_System::setTitle(ts('Personal Campaign Page Settings (%1)', array(1 => $title)));
         $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
         CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $defaults);
         $defaults['pcp_active'] = CRM_Utils_Array::value('is_active', $defaults);
         // Assign contribution page ID to pageId for referencing in PCP.hlp - since $id is overwritten there. dgg
         $this->assign('pageId', $this->_id);
     }
     if (empty($defaults['id'])) {
         $defaults['target_entity_type'] = 'event';
         $defaults['is_approval_needed'] = 1;
         $defaults['is_tellfriend_enabled'] = 1;
         $defaults['tellfriend_limit'] = 5;
         $defaults['link_text'] = ts('Promote this event with a personal campaign page');
         $defaults['owner_notify_id'] = CRM_Core_OptionGroup::getDefaultValue('pcp_owner_notify');
         if ($this->_id && ($ccReceipt = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'cc_receipt'))) {
             $defaults['notify_email'] = $ccReceipt;
         }
     }
     return $defaults;
 }
Exemple #3
0
 /**  
  * 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);
 }
 /**
  * Pre processing work done here.
  *
  * gets session variables for group or field id
  *
  * @return void
  */
 public function preProcess()
 {
     // get the controller vars
     $this->_groupId = $this->get('groupId');
     $this->_fieldId = $this->get('fieldId');
     if ($this->_fieldId) {
         // field preview
         $defaults = array();
         $params = array('id' => $this->_fieldId);
         $fieldDAO = new CRM_Core_DAO_CustomField();
         CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $defaults);
         if (!empty($defaults['is_view'])) {
             CRM_Core_Error::statusBounce(ts('This field is view only so it will not display on edit form.'));
         } elseif (CRM_Utils_Array::value('is_active', $defaults) == 0) {
             CRM_Core_Error::statusBounce(ts('This field is inactive so it will not display on edit form.'));
         }
         $groupTree = array();
         $groupTree[$this->_groupId]['id'] = 0;
         $groupTree[$this->_groupId]['fields'] = array();
         $groupTree[$this->_groupId]['fields'][$this->_fieldId] = $defaults;
         $this->_groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $this);
         $this->assign('preview_type', 'field');
     } else {
         $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail($this->_groupId);
         $this->_groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, TRUE, $this);
         $this->assign('preview_type', 'group');
     }
 }
   public function preProcess()
   {
       $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
       $this->_entityId = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
       $pcomponent = CRM_Utils_Request::retrieve('pcomponent', 'String', $this, TRUE);
       if (in_array($pcomponent, array('contribute', 'event'))) {
           $values = array();
           $params = array('id' => $this->_entityId);
           CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $values, array('title', 'campaign_id'));
           $this->_title = CRM_Utils_Array::value('title', $values);
           $this->_campaignId = CRM_Utils_Array::value('campaign_id', $values);
           $this->_entityTable = 'civicrm_contribution_page';
           if ($pcomponent == 'event') {
               $this->_entityTable = 'civicrm_event';
           }
       } elseif ($pcomponent == 'pcp') {
           $this->_pcpBlockId = CRM_Utils_Request::retrieve('blockId', 'Positive', $this, TRUE);
           $values = array();
           $params = array('id' => $this->_pcpBlockId);
           CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $values, array('is_tellfriend_enabled', 'tellfriend_limit'));
           if (!CRM_Utils_Array::value('is_tellfriend_enabled', $values)) {
               CRM_Core_Error::fatal(ts('Tell Friend is disable for this Personal Campaign Page'));
           }
           $this->_mailLimit = $values['tellfriend_limit'];
           $this->_entityTable = 'civicrm_pcp';
           $sql = '
  SELECT  pcp.title, 
          contrib.campaign_id
 FROM  civicrm_pcp pcp
   INNER JOIN  civicrm_contribution_page contrib ON ( pcp.page_id = contrib.id AND pcp.page_type = "contribute" )  
 WHERE  pcp.id = %1';
           $pcp = CRM_Core_DAO::executeQuery($sql, array(1 => array($this->_entityId, 'Positive')));
           while ($pcp->fetch()) {
               $this->_title = $pcp->title;
               $this->_campaignId = $pcp->campaign_id;
               $pcp->free();
           }
           $this->assign('pcpTitle', $this->_title);
       } else {
           CRM_Core_Error::fatal(ts('page argument missing or invalid'));
       }
       $this->assign('context', $pcomponent);
       $session = CRM_Core_Session::singleton();
       $this->_contactID = $session->get('userID');
       if (!$this->_contactID) {
           $this->_contactID = $session->get('transaction.userID');
       }
       if (!$this->_contactID) {
           CRM_Core_Error::fatal(ts('Could not get the contact ID'));
       }
       // we do not want to display recently viewed items, so turn off
       $this->assign('displayRecent', FALSE);
   }
 function setDefaultValues()
 {
     $defaults = array();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return $defaults;
     }
     if ($this->_id) {
         $params = array('id' => $this->_id);
         $defaults = array();
         CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_OptionValue', $params, $defaults);
     } else {
         $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $this->_opID));
     }
     return $defaults;
 }
Exemple #7
0
 static function setValues($id, &$values)
 {
     $params = array('id' => $id);
     CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $values);
     // get the amounts and the label
     require_once 'CRM/Core/OptionGroup.php';
     $values['amount'] = array();
     CRM_Core_OptionGroup::getAssoc("civicrm_contribution_page.amount.{$id}", $values['amount'], true);
     // get the profile ids
     require_once 'CRM/Core/BAO/UFJoin.php';
     $ufJoinParams = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $id);
     list($values['custom_pre_id'], $values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
     // add an accounting code also
     if ($values['contribution_type_id']) {
         $values['accountingCode'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionType', $values['contribution_type_id'], 'accounting_code');
     }
 }
 static function setValues($id, &$values)
 {
     $params = array('id' => $id);
     CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $values);
     // get the profile ids
     $ufJoinParams = array('module' => 'CiviContribute', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $id);
     list($values['custom_pre_id'], $customPostIds) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
     if (!empty($customPostIds)) {
         $values['custom_post_id'] = $customPostIds[0];
     } else {
         $values['custom_post_id'] = '';
     }
     // add an accounting code also
     if (CRM_Utils_Array::value('contribution_type_id', $values)) {
         $values['accountingCode'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionType', $values['contribution_type_id'], 'accounting_code');
     }
 }
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     // current contribution page id
     $this->_id = $this->get('id');
     // get all the values from the dao object
     $params = array('id' => $this->_id);
     $this->_values = array();
     CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $this->_values);
     // get the amounts and the label
     require_once 'CRM/Core/BAO/CustomOption.php';
     CRM_Core_BAO_CustomOption::getAssoc('civicrm_contribution_page', $this->_id, $this->_values);
     // get the profile ids
     require_once 'CRM/Core/BAO/UFJoin.php';
     $ufJoinParams = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id, 'weight' => 1);
     $this->_values['custom_pre_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
     $ufJoinParams['weight'] = 2;
     $this->_values['custom_post_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
 }
Exemple #10
0
 /**
  * This function sets the default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  * @return void
  */
 function setDefaultValues()
 {
     $title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title');
     CRM_Utils_System::setTitle(ts('Personal Campaign Page Settings (%1)', array(1 => $title)));
     $defaults = array();
     if (isset($this->_id)) {
         $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_contribution_page');
         CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_PCPBlock', $params, $defaults);
         // Assign contribution page ID to pageId for referencing in PCP.hlp - since $id is overwritten there. dgg
         $this->assign('pageId', $this->_id);
     }
     if (!CRM_Utils_Array::value('id', $defaults)) {
         $defaults['is_approval_needed'] = 1;
         $defaults['is_tellfriend_enabled'] = 1;
         $defaults['tellfriend_limit'] = 5;
         $defaults['link_text'] = ts('Create your own fundraising page');
         if ($ccReceipt = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'cc_receipt')) {
             $defaults['notify_email'] = $ccReceipt;
         }
     }
     return $defaults;
 }
 /**
  * pre processing work done here.
  * 
  * gets session variables for group or field id
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 function preProcess()
 {
     // get the controller vars
     $groupId = $this->get('groupId');
     $fieldId = $this->get('fieldId');
     if ($fieldId) {
         // field preview
         $defaults = array();
         $params = array('id' => $fieldId);
         $fieldDAO =& new CRM_Core_DAO_CustomField();
         CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $defaults);
         $this->_groupTree = array();
         $this->_groupTree[0]['id'] = 0;
         $this->_groupTree[0]['fields'] = array();
         $this->_groupTree[0]['fields'][$fieldId] = $defaults;
         $this->assign('preview_type', 'field');
     } else {
         // group preview
         $this->_groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail($groupId);
         $this->assign('preview_type', 'group');
     }
 }
Exemple #12
0
 public function preProcess()
 {
     parent::preProcess();
     $this->assign('currentEventId', $this->_id);
     $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
     //If this ID has parent, send parent id
     if ($checkParentExistsForThisId) {
         /**
          * Get connected event information list
          */
         //Get all connected event ids
         $allEventIdsArray = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($checkParentExistsForThisId, 'civicrm_event');
         $allEventIds = array();
         if (!empty($allEventIdsArray)) {
             foreach ($allEventIdsArray as $key => $val) {
                 $allEventIds[] = $val['id'];
             }
             if (!empty($allEventIds)) {
                 $params = array();
                 $query = "\n            SELECT *\n            FROM civicrm_event\n            WHERE id IN (" . implode(",", $allEventIds) . ")\n            ORDER BY start_date asc\n             ";
                 $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event');
                 $permissions = CRM_Event_BAO_Event::checkPermission();
                 while ($dao->fetch()) {
                     if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) {
                         $manageEvent[$dao->id] = array();
                         CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]);
                     }
                 }
             }
             $this->assign('rows', $manageEvent);
         }
     }
     $parentEventParams = array('id' => $this->_id);
     $parentEventValues = array();
     $parentEventReturnProperties = array('start_date', 'end_date');
     $parentEventAttributes = CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $parentEventParams, $parentEventValues, $parentEventReturnProperties);
     $this->_parentEventStartDate = $parentEventAttributes->start_date;
     $this->_parentEventEndDate = $parentEventAttributes->end_date;
 }
 /**
  * Set default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $defaults = array();
     if (isset($this->_id)) {
         $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_contribution_page');
         CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $defaults);
         $defaults['pcp_active'] = CRM_Utils_Array::value('is_active', $defaults);
         // Assign contribution page ID to pageId for referencing in PCP.hlp - since $id is overwritten there. dgg
         $this->assign('pageId', $this->_id);
     }
     if (empty($defaults['id'])) {
         $defaults['target_entity_type'] = 'contribute';
         $defaults['is_approval_needed'] = 1;
         $defaults['is_tellfriend_enabled'] = 1;
         $defaults['tellfriend_limit'] = 5;
         $defaults['link_text'] = ts('Create your own fundraising page');
         $defaults['owner_notify_id'] = CRM_Core_OptionGroup::getDefaultValue('pcp_owner_notify');
         if ($ccReceipt = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'cc_receipt')) {
             $defaults['notify_email'] = $ccReceipt;
         }
     }
     return $defaults;
 }
Exemple #14
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     // build profiles first so that we can determine address fields etc
     // and then show copy address checkbox
     if (empty($this->_ccid)) {
         $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
         $this->buildCustom($this->_values['custom_post_id'], 'customPost');
         // CRM-18399: used by template to pass pre profile id as a url arg
         $this->assign('custom_pre_id', $this->_values['custom_pre_id']);
         $this->buildComponentForm($this->_id, $this);
     }
     // Build payment processor form
     CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
     $config = CRM_Core_Config::singleton();
     $contactID = $this->getContactID();
     if ($contactID) {
         $this->assign('contact_id', $contactID);
         $this->assign('display_name', CRM_Contact_BAO_Contact::displayName($contactID));
     }
     $this->applyFilter('__ALL__', 'trim');
     if (empty($this->_ccid)) {
         $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60, 'class' => 'email'), TRUE);
         $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
     } else {
         $this->addElement('hidden', "email-{$this->_bltID}", 1);
         $this->add('text', 'total_amount', ts('Total Amount'), array('readonly' => TRUE), FALSE);
     }
     $pps = array();
     //@todo - this should be replaced by a check as to whether billing fields are set
     $onlinePaymentProcessorEnabled = FALSE;
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $key => $name) {
             if ($name['billing_mode'] == 1) {
                 $onlinePaymentProcessorEnabled = TRUE;
             }
             $pps[$key] = $name['name'];
         }
     }
     if (!empty($this->_values['is_pay_later'])) {
         $pps[0] = $this->_values['pay_later_text'];
     }
     if (count($pps) > 1) {
         $this->addRadio('payment_processor_id', ts('Payment Method'), $pps, NULL, "&nbsp;");
     } elseif (!empty($pps)) {
         $key = array_keys($pps);
         $key = array_pop($key);
         $this->addElement('hidden', 'payment_processor_id', $key);
         if ($key === 0) {
             $this->assign('is_pay_later', $this->_values['is_pay_later']);
             $this->assign('pay_later_text', $this->_values['pay_later_text']);
         }
     }
     $contactID = $this->getContactID();
     if ($this->getContactID() === 0) {
         $this->addCidZeroOptions($onlinePaymentProcessorEnabled);
     }
     //build pledge block.
     $this->_useForMember = 0;
     //don't build membership block when pledge_id is passed
     if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
         $this->_separateMembershipPayment = FALSE;
         if (in_array('CiviMember', $config->enableComponents)) {
             $isTest = 0;
             if ($this->_action & CRM_Core_Action::PREVIEW) {
                 $isTest = 1;
             }
             if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
                 $this->_useForMember = 1;
                 $this->set('useForMember', $this->_useForMember);
             }
             $this->_separateMembershipPayment = $this->buildMembershipBlock($this->_membershipContactID, TRUE, NULL, FALSE, $isTest);
         }
         $this->set('separateMembershipPayment', $this->_separateMembershipPayment);
     }
     $this->assign('useForMember', $this->_useForMember);
     // If we configured price set for contribution page
     // we are not allow membership signup as well as any
     // other contribution amount field, CRM-5095
     if (isset($this->_priceSetId) && $this->_priceSetId) {
         $this->add('hidden', 'priceSetId', $this->_priceSetId);
         // build price set form.
         $this->set('priceSetId', $this->_priceSetId);
         if (empty($this->_ccid)) {
             CRM_Price_BAO_PriceSet::buildPriceSet($this);
         }
         if ($this->_values['is_monetary'] && $this->_values['is_recur'] && empty($this->_values['pledge_id'])) {
             self::buildRecur($this);
         }
     }
     if ($this->_priceSetId && empty($this->_ccid)) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             $this->_useForMember = 0;
             $this->set('useForMember', $this->_useForMember);
         }
     }
     //we allow premium for pledge during pledge creation only.
     if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
         CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
     }
     //don't build pledge block when mid is passed
     if (!$this->_mid && empty($this->_ccid)) {
         $config = CRM_Core_Config::singleton();
         if (in_array('CiviPledge', $config->enableComponents) && !empty($this->_values['pledge_block_id'])) {
             CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
         }
     }
     //to create an cms user
     if (!$this->_contactID && empty($this->_ccid)) {
         $createCMSUser = FALSE;
         if ($this->_values['custom_pre_id']) {
             $profileID = $this->_values['custom_pre_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if (!$createCMSUser && $this->_values['custom_post_id']) {
             if (!is_array($this->_values['custom_post_id'])) {
                 $profileIDs = array($this->_values['custom_post_id']);
             } else {
                 $profileIDs = $this->_values['custom_post_id'];
             }
             foreach ($profileIDs as $pid) {
                 if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
                     $profileID = $pid;
                     $createCMSUser = TRUE;
                     break;
                 }
             }
         }
         if ($createCMSUser) {
             CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
         }
     }
     if ($this->_pcpId && empty($this->_ccid)) {
         if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) {
             $pcp_supporter_text = ts('This contribution is being made thanks to the effort of <strong>%1</strong>, who supports our campaign.', array(1 => $pcpSupporter));
             // Only tell people that can also create a PCP if the contribution page has a non-empty value in the "Create Personal Campaign Page link" field.
             $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($this->_id, 'contribute');
             if (!empty($text)) {
                 $pcp_supporter_text .= ts("You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!");
             }
             $this->assign('pcpSupporterText', $pcp_supporter_text);
         }
         $prms = array('id' => $this->_pcpId);
         CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
         if ($pcpInfo['is_honor_roll']) {
             $this->assign('isHonor', TRUE);
             $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
             $extraOption = array('onclick' => "return pcpAnonymous( );");
             $elements = array();
             $elements[] =& $this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
             $elements[] =& $this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
             $this->addGroup($elements, 'pcp_is_anonymous', NULL, '&nbsp;&nbsp;&nbsp;');
             $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
             $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
         }
     }
     if (empty($this->_values['fee']) && empty($this->_ccid)) {
         CRM_Core_Error::fatal(ts('This page does not have any price fields configured or you may not have permission for them. Please contact the site administrator for more details.'));
     }
     //we have to load confirm contribution button in template
     //when multiple payment processor as the user
     //can toggle with payment processor selection
     $billingModePaymentProcessors = 0;
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $key => $values) {
             if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) {
                 $billingModePaymentProcessors++;
             }
         }
     }
     if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) {
         $allAreBillingModeProcessors = TRUE;
     } else {
         $allAreBillingModeProcessors = FALSE;
     }
     if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) {
         $submitButton = array('type' => 'upload', 'name' => CRM_Utils_Array::value('is_confirm_enabled', $this->_values) ? ts('Confirm Contribution') : ts('Contribute'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE);
         // Add submit-once behavior when confirm page disabled
         if (empty($this->_values['is_confirm_enabled'])) {
             $submitButton['js'] = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
         }
         //change button name for updating contribution
         if (!empty($this->_ccid)) {
             $submitButton['name'] = ts('Confirm Payment');
         }
         $this->addButtons(array($submitButton));
     }
     $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
 }
Exemple #15
0
 function where()
 {
     parent::where();
     $params = array('name' => 'HRJobContract_Summary');
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomGroup', $params, $cGrp);
     $params = array('name' => 'Final_Termination_Date', 'custom_group_id' => $cGrp['id']);
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $cField);
     $dbAlias = $this->_columns[$cGrp['table_name']]['fields']["custom_{$cField['id']}"]['dbAlias'];
     if (!$this->isFieldSelected($this->_columns[$cGrp['table_name']])) {
         $whereClauses[] = "({$dbAlias} >= CURDATE() OR {$dbAlias} IS NULL)";
     }
     $params = array('name' => 'Initial_Join_Date', 'custom_group_id' => $cGrp['id']);
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $cField);
     $dbAlias = $this->_columns[$cGrp['table_name']]['fields']["custom_{$cField['id']}"]['dbAlias'];
     $addWhereClauses = "({$this->_aliases['civicrm_hrjobcontract']}.is_primary IS NULL AND {$dbAlias} IS NOT NULL AND {$dbAlias} <= CURDATE())";
     if (!empty($this->_params['current_employee_value'])) {
         $whereClauses[] = "(({$this->_aliases['civicrm_hrjobcontract']}.is_primary = 1 OR {$this->_aliases['civicrm_hrjobcontract']}.is_primary IS NULL) AND ({$this->_aliases['civicrm_hrjobcontract_details']}.period_start_date IS NOT NULL AND {$this->_aliases['civicrm_hrjobcontract_details']}.period_start_date <= CURDATE()))";
         $this->_where = str_replace("AND ( hrjobcontract_civireport.current_employee = 1 )", '', $this->_where);
     }
     $whereClauses[] = "{$this->_aliases['civicrm_contact']}.contact_type = 'Individual'";
     $where = implode(' AND ', $whereClauses);
     if ($this->_where == "WHERE ( 1 )") {
         $this->_where = $where;
     } else {
         $this->_where .= " AND {$where}";
     }
 }
Exemple #16
0
 /**
  * Function to convert mysql to date plugin format.
  *
  * @param string $mysqlDate
  *   Date string.
  *
  * @param null $formatType
  * @param null $format
  * @param null $timeFormat
  *
  * @return array
  *   and time
  */
 public static function setDateDefaults($mysqlDate = NULL, $formatType = NULL, $format = NULL, $timeFormat = NULL)
 {
     // if date is not passed assume it as today
     if (!$mysqlDate) {
         $mysqlDate = date('Y-m-d G:i:s');
     }
     $config = CRM_Core_Config::singleton();
     if ($formatType) {
         // get actual format
         $params = array('name' => $formatType);
         $values = array();
         CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_PreferencesDate', $params, $values);
         if ($values['date_format']) {
             $format = $values['date_format'];
         }
         if (isset($values['time_format'])) {
             $timeFormat = $values['time_format'];
         }
     }
     // now we set display date using js, hence we should always setdefault
     // 'm/d/Y' format. So that submitted value is alwats mm/dd/YY format
     // note that for date display we dynamically create text field
     /*
         if ( !$format ) {
         $format = $config->dateInputFormat;
         }
     
         // get actual format
         $actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats( );
         $dateFormat       = CRM_Utils_Array::value( $format, $actualPHPFormats );
     */
     $dateFormat = 'm/d/Y';
     $date = date($dateFormat, strtotime($mysqlDate));
     if (!$timeFormat) {
         $timeFormat = $config->timeInputFormat;
     }
     $actualTimeFormat = "g:iA";
     $appendZeroLength = 7;
     if ($timeFormat > 1) {
         $actualTimeFormat = "G:i";
         $appendZeroLength = 5;
     }
     $time = date($actualTimeFormat, strtotime($mysqlDate));
     // need to append zero for hours < 10
     if (strlen($time) < $appendZeroLength) {
         $time = '0' . $time;
     }
     return array($date, $time);
 }
Exemple #17
0
 /**
  * Send notfication email to supporter
  * 1. when their PCP status is changed by site admin.
  * 2. when supporter initially creates a Personal Campaign Page ($isInitial set to true).
  *
  * @param int $pcpId
  *   Campaign page id.
  * @param int $newStatus
  *   Pcp status id.
  * @param bool|int $isInitial is it the first time, campaign page has been created by the user
  *
  * @param string $component
  *
  * @throws Exception
  * @return null
  */
 public static function sendStatusUpdate($pcpId, $newStatus, $isInitial = FALSE, $component = 'contribute')
 {
     $pcpStatusName = CRM_Core_OptionGroup::values("pcp_status", FALSE, FALSE, FALSE, NULL, 'name');
     $pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
     $config = CRM_Core_Config::singleton();
     if (!isset($pcpStatus[$newStatus])) {
         return FALSE;
     }
     require_once 'Mail/mime.php';
     //set loginUrl
     $loginURL = $config->userSystem->getLoginURL();
     // used in subject templates
     $contribPageTitle = self::getPcpPageTitle($pcpId, $component);
     $tplParams = array('loginUrl' => $loginURL, 'contribPageTitle' => $contribPageTitle, 'pcpId' => $pcpId);
     //get the default domain email address.
     list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
     if (!$domainEmailAddress || $domainEmailAddress == '*****@*****.**') {
         $fixUrl = CRM_Utils_System::url("civicrm/admin/domain", 'action=update&reset=1');
         CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM &raquo; Communications &raquo; FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
     }
     $receiptFrom = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>';
     // get recipient (supporter) name and email
     $params = array('id' => $pcpId);
     CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo);
     list($name, $address) = CRM_Contact_BAO_Contact_Location::getEmailDetails($pcpInfo['contact_id']);
     // get pcp block info
     list($blockId, $eid) = self::getPcpBlockEntityId($pcpId, $component);
     $params = array('id' => $blockId);
     CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $pcpBlockInfo);
     // assign urls required in email template
     if ($pcpStatusName[$newStatus] == 'Approved') {
         $tplParams['isTellFriendEnabled'] = $pcpBlockInfo['is_tellfriend_enabled'];
         if ($pcpBlockInfo['is_tellfriend_enabled']) {
             $pcpTellFriendURL = CRM_Utils_System::url('civicrm/friend', "reset=1&eid={$pcpId}&blockId={$blockId}&pcomponent=pcp", TRUE, NULL, FALSE, TRUE);
             $tplParams['pcpTellFriendURL'] = $pcpTellFriendURL;
         }
     }
     $pcpInfoURL = CRM_Utils_System::url('civicrm/pcp/info', "reset=1&id={$pcpId}", TRUE, NULL, FALSE, TRUE);
     $tplParams['pcpInfoURL'] = $pcpInfoURL;
     $tplParams['contribPageTitle'] = $contribPageTitle;
     if ($emails = CRM_Utils_Array::value('notify_email', $pcpBlockInfo)) {
         $emailArray = explode(',', $emails);
         $tplParams['pcpNotifyEmailAddress'] = $emailArray[0];
     }
     // get appropriate message based on status
     $tplParams['pcpStatus'] = $pcpStatus[$newStatus];
     $tplName = $isInitial ? 'pcp_supporter_notify' : 'pcp_status_change';
     list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => $tplName, 'contactId' => $pcpInfo['contact_id'], 'tplParams' => $tplParams, 'from' => $receiptFrom, 'toName' => $name, 'toEmail' => $address));
     return $sent;
 }
Exemple #18
0
 /**
  * Function to authenticate pledge user during online payment.
  *
  * @access public
  *
  * @return None
  */
 public function authenticatePledgeUser()
 {
     //get the userChecksum and contact id
     $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this);
     $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     //get pledge status and contact id
     $pledgeValues = array();
     $pledgeParams = array('id' => $this->_values['pledge_id']);
     $returnProperties = array('contact_id', 'status_id');
     CRM_Core_DAO::commonRetrieve('CRM_Pledge_DAO_Pledge', $pledgeParams, $pledgeValues, $returnProperties);
     //get all status
     $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $validStatus = array(array_search('Pending', $allStatus), array_search('In Progress', $allStatus), array_search('Overdue', $allStatus));
     $validUser = FALSE;
     if ($this->_userID && $this->_userID == $pledgeValues['contact_id']) {
         //check for authenticated  user.
         $validUser = TRUE;
     } elseif ($userChecksum && $pledgeValues['contact_id']) {
         //check for anonymous user.
         $validUser = CRM_Contact_BAO_Contact_Utils::validChecksum($pledgeValues['contact_id'], $userChecksum);
         //make sure cid is same as pledge contact id
         if ($validUser && $pledgeValues['contact_id'] != $contactID) {
             $validUser = FALSE;
         }
     }
     if (!$validUser) {
         CRM_Core_Error::fatal(ts("Oops. It looks like you have an incorrect or incomplete link (URL). Please make sure you've copied the entire link, and try again. Contact the site administrator if this error persists."));
     }
     //check for valid pledge status.
     if (!in_array($pledgeValues['status_id'], $validStatus)) {
         CRM_Core_Error::fatal(ts('Oops. You cannot make a payment for this pledge - pledge status is %1.', array(1 => CRM_Utils_Array::value($pledgeValues['status_id'], $allStatus))));
     }
 }
 /**
  * Takes a bunch of params that are needed to match certain criteria and
  * retrieves the relevant objects. Typically the valid params are only
  * contact_id. We'll tweak this function to be more full featured over a period
  * of time. This is the inverse function of create. It also stores all the retrieved
  * values in the default array
  *
  * @param array $params   (reference ) an assoc array of name/value pairs
  * @param array $defaults (reference ) an assoc array to hold the flattened values
  *
  * @return object CRM_Price_DAO_PriceField object
  * @access public
  * @static
  */
 static function retrieve(&$params, &$defaults)
 {
     return CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceField', $params, $defaults);
 }
 static function retrieve(&$params, &$defaults)
 {
     CRM_Core_DAO::commonRetrieve('CRM_ACL_DAO_EntityRole', $params, $defaults);
 }
Exemple #21
0
 /**
  * Fetch the custom field help.
  */
 public static function customField()
 {
     $fieldId = CRM_Utils_Type::escape($_REQUEST['id'], 'Integer');
     $params = array('id' => $fieldId);
     $returnProperties = array('help_pre', 'help_post');
     $values = array();
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $values, $returnProperties);
     CRM_Utils_JSON::output($values);
 }
 /**
  * Create() method
  * create various elements of location block
  * with civicrm_loc_block
  */
 public function testCreateWithLocBlock()
 {
     $this->_contactId = $this->individualCreate();
     $event = $this->eventCreate();
     $params = array('address' => array('1' => array('street_address' => 'Saint Helier St', 'supplemental_address_1' => 'Hallmark Ct', 'supplemental_address_2' => 'Jersey Village', 'city' => 'Newark', 'postal_code' => '01903', 'country_id' => 1228, 'state_province_id' => 1029, 'geo_code_1' => '18.219023', 'geo_code_2' => '-105.00973', 'is_primary' => 1, 'location_type_id' => 1)), 'email' => array('1' => array('email' => '*****@*****.**', 'is_primary' => 1, 'location_type_id' => 1)), 'phone' => array('1' => array('phone_type_id' => 1, 'phone' => '303443689', 'is_primary' => 1, 'location_type_id' => 1), '2' => array('phone_type_id' => 2, 'phone' => '9833910234', 'location_type_id' => 1)), 'im' => array('1' => array('name' => 'jane.doe', 'provider_id' => 1, 'location_type_id' => 1, 'is_primary' => 1)));
     $params['entity_id'] = $event['id'];
     $params['entity_table'] = 'civicrm_event';
     //create location block.
     //with various element of location block
     //like address, phone, email, im.
     $location = CRM_Core_BAO_Location::create($params, NULL, TRUE);
     $locBlockId = CRM_Utils_Array::value('id', $location);
     //update event record with location block id
     $eventParams = array('id' => $event['id'], 'loc_block_id' => $locBlockId);
     CRM_Event_BAO_Event::add($eventParams);
     //Now check DB for location block
     $this->assertDBCompareValue('CRM_Event_DAO_Event', $event['id'], 'loc_block_id', 'id', $locBlockId, 'Checking database for the record.');
     $locElementIds = array();
     $locParams = array('id' => $locBlockId);
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_LocBlock', $locParams, $locElementIds);
     //Now check DB for location elements.
     $searchParams = array('id' => CRM_Utils_Array::value('address_id', $locElementIds), 'location_type_id' => 1, 'is_primary' => 1);
     $compareParams = array('street_address' => 'Saint Helier St', 'supplemental_address_1' => 'Hallmark Ct', 'supplemental_address_2' => 'Jersey Village', 'city' => 'Newark', 'postal_code' => '01903', 'country_id' => 1228, 'state_province_id' => 1029, 'geo_code_1' => '18.219023', 'geo_code_2' => '-105.00973');
     $this->assertDBCompareValues('CRM_Core_DAO_Address', $searchParams, $compareParams);
     $searchParams = array('id' => CRM_Utils_Array::value('email_id', $locElementIds), 'location_type_id' => 1, 'is_primary' => 1);
     $compareParams = array('email' => '*****@*****.**');
     $this->assertDBCompareValues('CRM_Core_DAO_Email', $searchParams, $compareParams);
     $searchParams = array('id' => CRM_Utils_Array::value('phone_id', $locElementIds), 'location_type_id' => 1, 'is_primary' => 1, 'phone_type_id' => 1);
     $compareParams = array('phone' => '303443689');
     $this->assertDBCompareValues('CRM_Core_DAO_Phone', $searchParams, $compareParams);
     $searchParams = array('id' => CRM_Utils_Array::value('phone_2_id', $locElementIds), 'location_type_id' => 1, 'phone_type_id' => 2);
     $compareParams = array('phone' => '9833910234');
     $this->assertDBCompareValues('CRM_Core_DAO_Phone', $searchParams, $compareParams);
     $searchParams = array('id' => CRM_Utils_Array::value('im_id', $locElementIds), 'location_type_id' => 1, 'is_primary' => 1);
     $compareParams = array('name' => 'jane.doe', 'provider_id' => 1);
     $this->assertDBCompareValues('CRM_Core_DAO_IM', $searchParams, $compareParams);
     // Cleanup.
     CRM_Core_BAO_Location::deleteLocBlock($locBlockId);
     $this->eventDelete($event['id']);
     $this->contactDelete($this->_contactId);
 }
 /**
  * Function that must have never worked & should be removed.
  *
  * Retrieve DB object based on input parameters.
  *
  * It also stores all the retrieved values in the default array.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param array $defaults
  *   (reference ) an assoc array to hold the flattened values.
  *
  * @return CRM_Core_DAO_WordRepalcement
  */
 public static function retrieve(&$params, &$defaults)
 {
     return CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_WordRepalcement', $params, $defaults);
 }
Exemple #24
0
 /**
  * Function used to send notification mail to pcp owner.
  *
  * This is used by contribution and also event PCPs.
  *
  * @param object $contribution
  * @param object $contributionSoft
  *   Contribution object.
  */
 public static function pcpNotifyOwner($contribution, $contributionSoft)
 {
     $params = array('id' => $contributionSoft->pcp_id);
     CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo);
     $ownerNotifyID = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCPBlock', $pcpInfo['pcp_block_id'], 'owner_notify_id');
     if ($ownerNotifyID != CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'no_notifications', 'name') && ($ownerNotifyID == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'owner_chooses', 'name') && CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $contributionSoft->pcp_id, 'is_notify') || $ownerNotifyID == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'all_owners', 'name'))) {
         $pcpInfoURL = CRM_Utils_System::url('civicrm/pcp/info', "reset=1&id={$contributionSoft->pcp_id}", TRUE, NULL, FALSE, TRUE);
         // set email in the template here
         if (CRM_Core_BAO_LocationType::getBilling()) {
             list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id, FALSE, CRM_Core_BAO_LocationType::getBilling());
         }
         // get primary location email if no email exist( for billing location).
         if (!$email) {
             list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id);
         }
         list($ownerName, $ownerEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contributionSoft->contact_id);
         $tplParams = array('page_title' => $pcpInfo['title'], 'receive_date' => $contribution->receive_date, 'total_amount' => $contributionSoft->amount, 'donors_display_name' => $donorName, 'donors_email' => $email, 'pcpInfoURL' => $pcpInfoURL, 'is_honor_roll_enabled' => $contributionSoft->pcp_display_in_roll, 'currency' => $contributionSoft->currency);
         $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
         $sendTemplateParams = array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'pcp_owner_notify', 'contactId' => $contributionSoft->contact_id, 'toEmail' => $ownerEmail, 'toName' => $ownerName, 'from' => "{$domainValues['0']} <{$domainValues['1']}>", 'tplParams' => $tplParams, 'PDFFilename' => 'receipt.pdf');
         CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
     }
 }
 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     $params = array('id' => $this->_eventId);
     $values = array();
     CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $params, $values, array('title'));
     $buttons = array();
     // only pending status class family able to confirm.
     $statusMsg = NULL;
     if (array_key_exists($this->_participantStatusId, CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'"))) {
         //need to confirm that though participant confirming
         //registration - but is there enough space to confirm.
         $emptySeats = CRM_Event_BAO_Participant::pendingToConfirmSpaces($this->_eventId);
         $additonalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_participantId);
         $requireSpace = 1 + count($additonalIds);
         if ($emptySeats !== NULL && $requireSpace > $emptySeats) {
             $statusMsg = ts("Oops, it looks like there are currently no available spaces for the %1 event.", array(1 => $values['title']));
         } else {
             if ($this->_cc == 'fail') {
                 $statusMsg = '<div class="bold">' . ts('Your Credit Card transaction was not successful. No money has yet been charged to your card.') . '</div><div><br />' . ts('Click the "Confirm Registration" button to complete your registration in %1, or click "Cancel Registration" if you are no longer interested in attending this event.', array(1 => $values['title'])) . '</div>';
             } else {
                 $statusMsg = '<div class="bold">' . ts('Confirm your registration for %1.', array(1 => $values['title'])) . '</div><div><br />' . ts('Click the "Confirm Registration" button to begin, or click "Cancel Registration" if you are no longer interested in attending this event.') . '</div>';
             }
             $buttons = array_merge($buttons, array(array('type' => 'next', 'name' => ts('Confirm Registration'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE)));
         }
     }
     // status class other than Negative should be able to cancel registration.
     if (array_key_exists($this->_participantStatusId, CRM_Event_PseudoConstant::participantStatus(NULL, "class != 'Negative'"))) {
         $cancelConfirm = ts('Are you sure you want to cancel your registration for this event?');
         $buttons = array_merge($buttons, array(array('type' => 'submit', 'name' => ts('Cancel Registration'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'js' => array('onclick' => 'return confirm(\'' . $cancelConfirm . '\');'))));
         if (!$statusMsg) {
             $statusMsg = ts('You can cancel your registration for %1 by clicking "Cancel Registration".', array(1 => $values['title']));
         }
     }
     if (!$statusMsg) {
         $statusMsg = ts("Oops, it looks like your registration for %1 has already been cancelled.", array(1 => $values['title']));
     }
     $this->assign('statusMsg', $statusMsg);
     $this->addButtons($buttons);
 }
Exemple #26
0
 /**
  * Function to send Acknowledgment and create activity.
  *
  * @param object $form form object.
  * @param array  $params (reference ) an assoc array of name/value pairs.
  * @access public
  *
  * @return None.
  */
 function sendAcknowledgment(&$form, $params)
 {
     //handle Acknowledgment.
     $allPayments = $payments = array();
     //get All Payments status types.
     $paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $returnProperties = array('status_id', 'scheduled_amount', 'scheduled_date', 'contribution_id');
     //get all paymnets details.
     CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id', $params['id'], $allPayments, $returnProperties);
     if (!empty($allPayments)) {
         foreach ($allPayments as $payID => $values) {
             $contributionValue = $contributionStatus = array();
             if (isset($values['contribution_id'])) {
                 $contributionParams = array('id' => $values['contribution_id']);
                 $returnProperties = array('contribution_status_id', 'receive_date');
                 CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_Contribution', $contributionParams, $contributionStatus, $returnProperties);
                 $contributionValue = array('status' => CRM_Utils_Array::value('contribution_status_id', $contributionStatus), 'receive_date' => CRM_Utils_Array::value('receive_date', $contributionStatus));
             }
             $payments[$payID] = array_merge($contributionValue, array('amount' => CRM_Utils_Array::value('scheduled_amount', $values), 'due_date' => CRM_Utils_Array::value('scheduled_date', $values)));
             //get the first valid payment id.
             if (!isset($form->paymentId) && ($paymentStatusTypes[$values['status_id']] == 'Pending' || $paymentStatusTypes[$values['status_id']] == 'Overdue')) {
                 $form->paymentId = $values['id'];
             }
         }
     }
     //end
     //assign pledge fields value to template.
     $pledgeFields = array('create_date', 'total_pledge_amount', 'frequency_interval', 'frequency_unit', 'installments', 'frequency_day', 'scheduled_amount', 'currency');
     foreach ($pledgeFields as $field) {
         if (CRM_Utils_Array::value($field, $params)) {
             $form->assign($field, $params[$field]);
         }
     }
     //assign all payments details.
     if ($payments) {
         $form->assign('payments', $payments);
     }
     //assign honor fields.
     $honor_block_is_active = FALSE;
     //make sure we have values for it
     if (CRM_Utils_Array::value('honor_type_id', $params) && (!empty($params['honor_first_name']) && !empty($params['honor_last_name']) || !empty($params['honor_email']))) {
         $honor_block_is_active = TRUE;
         $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
         $honor = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id');
         $form->assign('honor_type', $honor[$params['honor_type_id']]);
         $form->assign('honor_prefix', $prefix[$params['honor_prefix_id']]);
         $form->assign('honor_first_name', $params['honor_first_name']);
         $form->assign('honor_last_name', $params['honor_last_name']);
         $form->assign('honor_email', $params['honor_email']);
     }
     $form->assign('honor_block_is_active', $honor_block_is_active);
     //handle domain token values
     $domain = CRM_Core_BAO_Domain::getDomain();
     $tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens());
     $domainValues = array();
     foreach ($tokens['domain'] as $token) {
         $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
     }
     $form->assign('domain', $domainValues);
     //handle contact token values.
     $ids = array($params['contact_id']);
     $fields = array_merge(array_keys(CRM_Contact_BAO_Contact::importableFields()), array('display_name', 'checksum', 'contact_id'));
     foreach ($fields as $key => $val) {
         $returnProperties[$val] = TRUE;
     }
     $details = CRM_Utils_Token::getTokenDetails($ids, $returnProperties, TRUE, TRUE, NULL, $tokens, get_class($form));
     $form->assign('contact', $details[0][$params['contact_id']]);
     //handle custom data.
     if (CRM_Utils_Array::value('hidden_custom', $params)) {
         $groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', CRM_Core_DAO::$_nullObject, $params['id']);
         $pledgeParams = array(array('pledge_id', '=', $params['id'], 0, 0));
         $customGroup = array();
         // retrieve custom data
         foreach ($groupTree as $groupID => $group) {
             $customFields = $customValues = array();
             if ($groupID == 'info') {
                 continue;
             }
             foreach ($group['fields'] as $k => $field) {
                 $field['title'] = $field['label'];
                 $customFields["custom_{$k}"] = $field;
             }
             //to build array of customgroup & customfields in it
             CRM_Core_BAO_UFGroup::getValues($params['contact_id'], $customFields, $customValues, FALSE, $pledgeParams);
             $customGroup[$group['title']] = $customValues;
         }
         $form->assign('customGroup', $customGroup);
     }
     //handle acknowledgment email stuff.
     list($pledgerDisplayName, $pledgerEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($params['contact_id']);
     //check for online pledge.
     $session = CRM_Core_Session::singleton();
     if (CRM_Utils_Array::value('receipt_from_email', $params)) {
         $userName = CRM_Utils_Array::value('receipt_from_name', $params);
         $userEmail = CRM_Utils_Array::value('receipt_from_email', $params);
     } elseif (CRM_Utils_Array::value('from_email_id', $params)) {
         $receiptFrom = $params['from_email_id'];
     } elseif ($userID = $session->get('userID')) {
         //check for loged in user.
         list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
     } else {
         //set the domain values.
         $userName = CRM_Utils_Array::value('name', $domainValues);
         $userEmail = CRM_Utils_Array::value('email', $domainValues);
     }
     if (!isset($receiptFrom)) {
         $receiptFrom = "{$userName} <{$userEmail}>";
     }
     list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_pledge', 'valueName' => 'pledge_acknowledge', 'contactId' => $params['contact_id'], 'from' => $receiptFrom, 'toName' => $pledgerDisplayName, 'toEmail' => $pledgerEmail));
     //check if activity record exist for this pledge
     //Acknowledgment, if exist do not add activity.
     $activityType = 'Pledge Acknowledgment';
     $activity = new CRM_Activity_DAO_Activity();
     $activity->source_record_id = $params['id'];
     $activity->activity_type_id = CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name');
     $config = CRM_Core_Config::singleton();
     $details = 'Total Amount ' . CRM_Utils_Money::format($params['total_pledge_amount'], CRM_Utils_Array::value('currency', $params)) . ' To be paid in ' . $params['installments'] . ' installments of ' . CRM_Utils_Money::format($params['scheduled_amount'], CRM_Utils_Array::value('currency', $params)) . ' every ' . $params['frequency_interval'] . ' ' . $params['frequency_unit'] . '(s)';
     if (!$activity->find()) {
         $activityParams = array('subject' => $subject, 'source_contact_id' => $params['contact_id'], 'source_record_id' => $params['id'], 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'activity_date_time' => CRM_Utils_Date::isoToMysql($params['acknowledge_date']), 'is_test' => $params['is_test'], 'status_id' => 2, 'details' => $details, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params));
         //lets insert assignee record.
         if (CRM_Utils_Array::value('contact_id', $params)) {
             $activityParams['assignee_contact_id'] = $params['contact_id'];
         }
         if (is_a(CRM_Activity_BAO_Activity::create($activityParams), 'CRM_Core_Error')) {
             CRM_Core_Error::fatal("Failed creating Activity for acknowledgment");
         }
     }
 }
 /**
  * returns all the rows in the given offset and rowCount
  *
  * @param enum   $action   the action being performed
  * @param int    $offset   the row number to start from
  * @param int    $rowCount the number of rows to return
  * @param string $sort     the sql string that describes the sort order
  * @param enum   $output   what should the result set include (web/email/csv)
  *
  * @return int   the total number of rows for this action
  */
 function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
 {
     $config = CRM_Core_Config::singleton();
     if (($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') {
         $includeContactIds = TRUE;
     } else {
         $includeContactIds = FALSE;
     }
     // note the formvalues were given by CRM_Contact_Form_Search to us
     // and contain the search criteria (parameters)
     // note that the default action is basic
     if ($rowCount) {
         $cacheKey = $this->buildPrevNextCache($sort);
         $result = $this->_query->getCachedContacts($cacheKey, $offset, $rowCount, $includeContactIds);
     } else {
         $result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, $includeContactIds);
     }
     // process the result of the query
     $rows = array();
     $permissions = array(CRM_Core_Permission::getPermission());
     if (CRM_Core_Permission::check('delete contacts')) {
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     $mask = CRM_Core_Action::mask($permissions);
     // mask value to hide map link if there are not lat/long
     $mapMask = $mask & 4095;
     if ($this->_searchContext == 'smog') {
         $gc = CRM_Core_SelectValues::groupContactStatus();
     }
     if ($this->_ufGroupID) {
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
         $names = array();
         static $skipFields = array('group', 'tag');
         foreach ($this->_fields as $key => $field) {
             if (!empty($field['in_selector']) && !in_array($key, $skipFields)) {
                 if (strpos($key, '-') !== FALSE) {
                     list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $key, 3);
                     if ($id == 'Primary') {
                         $locationTypeName = 1;
                     } else {
                         $locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
                         if (!$locationTypeName) {
                             continue;
                         }
                     }
                     $locationTypeName = str_replace(' ', '_', $locationTypeName);
                     if (in_array($fieldName, array('phone', 'im', 'email'))) {
                         if ($type) {
                             $names[] = "{$locationTypeName}-{$fieldName}-{$type}";
                         } else {
                             $names[] = "{$locationTypeName}-{$fieldName}";
                         }
                     } else {
                         $names[] = "{$locationTypeName}-{$fieldName}";
                     }
                 } else {
                     $names[] = $field['name'];
                 }
             }
         }
         $names[] = "status";
     } elseif (!empty($this->_returnProperties)) {
         $names = self::makeProperties($this->_returnProperties);
     } else {
         $names = self::$_properties;
     }
     $multipleSelectFields = array('preferred_communication_method' => 1);
     $links = self::links($this->_context, $this->_contextMenu, $this->_key);
     //check explicitly added contact to a Smart Group.
     $groupID = CRM_Utils_Array::key('1', $this->_formValues['group']);
     $pseudoconstants = array();
     // for CRM-3157 purposes
     if (in_array('world_region', $names)) {
         $pseudoconstants['world_region'] = array('dbName' => 'world_region_id', 'values' => CRM_Core_PseudoConstant::worldRegion());
     }
     $seenIDs = array();
     while ($result->fetch()) {
         $row = array();
         $this->_query->convertToPseudoNames($result);
         // the columns we are interested in
         foreach ($names as $property) {
             if ($property == 'status') {
                 continue;
             }
             if ($cfID = CRM_Core_BAO_CustomField::getKeyID($property)) {
                 $row[$property] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$property}, $cfID, $this->_options, $result->contact_id);
             } elseif ($multipleSelectFields && array_key_exists($property, $multipleSelectFields)) {
                 $key = $property;
                 $paramsNew = array($key => $result->{$property});
                 $name = array($key => array('newName' => $key, 'groupName' => $key));
                 CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
                 $row[$key] = $paramsNew[$key];
             } elseif (strpos($property, '-im')) {
                 $row[$property] = $result->{$property};
                 if (!empty($result->{$property})) {
                     $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
                     $providerId = $property . "-provider_id";
                     $providerName = $imProviders[$result->{$providerId}];
                     $row[$property] = $result->{$property} . " ({$providerName})";
                 }
             } elseif (in_array($property, array('addressee', 'email_greeting', 'postal_greeting'))) {
                 $greeting = $property . '_display';
                 $row[$property] = $result->{$greeting};
             } elseif (isset($pseudoconstants[$property])) {
                 $row[$property] = CRM_Utils_Array::value($result->{$pseudoconstants[$property]['dbName']}, $pseudoconstants[$property]['values']);
             } elseif (strpos($property, '-url') !== FALSE) {
                 $websiteUrl = '';
                 $websiteKey = 'website-1';
                 $propertyArray = explode('-', $property);
                 $websiteFld = $websiteKey . '-' . array_pop($propertyArray);
                 if (!empty($result->{$websiteFld})) {
                     $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
                     $websiteType = $websiteTypes[$result->{"{$websiteKey}-website_type_id"}];
                     $websiteValue = $result->{$websiteFld};
                     $websiteUrl = "<a href=\"{$websiteValue}\">{$websiteValue}  ({$websiteType})</a>";
                 }
                 $row[$property] = $websiteUrl;
             } else {
                 $row[$property] = isset($result->{$property}) ? $result->{$property} : NULL;
             }
         }
         if (!empty($result->postal_code_suffix)) {
             $row['postal_code'] .= "-" . $result->postal_code_suffix;
         }
         if ($output != CRM_Core_Selector_Controller::EXPORT && $this->_searchContext == 'smog') {
             if (empty($result->status) && $groupID) {
                 $contactID = $result->contact_id;
                 if ($contactID) {
                     $gcParams = array('contact_id' => $contactID, 'group_id' => $groupID);
                     $gcDefaults = array();
                     CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_GroupContact', $gcParams, $gcDefaults);
                     if (empty($gcDefaults)) {
                         $row['status'] = ts('Smart');
                     } else {
                         $row['status'] = $gc[$gcDefaults['status']];
                     }
                 } else {
                     $row['status'] = NULL;
                 }
             } else {
                 $row['status'] = $gc[$result->status];
             }
         }
         if ($output != CRM_Core_Selector_Controller::EXPORT) {
             $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contact_id;
             if (!empty($this->_formValues['deleted_contacts']) && CRM_Core_Permission::check('access deleted contacts')) {
                 $links = array(array('name' => ts('View'), 'url' => 'civicrm/contact/view', 'qs' => 'reset=1&cid=%%id%%', 'class' => 'no-popup', 'title' => ts('View Contact Details')), array('name' => ts('Restore'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&restore=1', 'title' => ts('Restore Contact')));
                 if (CRM_Core_Permission::check('delete contacts')) {
                     $links[] = array('name' => ts('Delete Permanently'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&skip_undelete=1', 'title' => ts('Permanently Delete Contact'));
                 }
                 $row['action'] = CRM_Core_Action::formLink($links, NULL, array('id' => $result->contact_id), ts('more'), FALSE, 'contact.selector.row', 'Contact', $result->contact_id);
             } elseif (is_numeric(CRM_Utils_Array::value('geo_code_1', $row)) || $config->mapGeoCoding && !empty($row['city']) && CRM_Utils_Array::value('state_province', $row)) {
                 $row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $result->contact_id), ts('more'), FALSE, 'contact.selector.row', 'Contact', $result->contact_id);
             } else {
                 $row['action'] = CRM_Core_Action::formLink($links, $mapMask, array('id' => $result->contact_id), ts('more'), FALSE, 'contact.selector.row', 'Contact', $result->contact_id);
             }
             // allow components to add more actions
             CRM_Core_Component::searchAction($row, $result->contact_id);
             $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
             $row['contact_type_orig'] = $result->contact_sub_type ? $result->contact_sub_type : $result->contact_type;
             $row['contact_sub_type'] = $result->contact_sub_type ? CRM_Contact_BAO_ContactType::contactTypePairs(FALSE, $result->contact_sub_type, ', ') : $result->contact_sub_type;
             $row['contact_id'] = $result->contact_id;
             $row['sort_name'] = $result->sort_name;
             if (array_key_exists('id', $row)) {
                 $row['id'] = $result->contact_id;
             }
         }
         // Dedupe contacts
         if (in_array($row['contact_id'], $seenIDs) === FALSE) {
             $seenIDs[] = $row['contact_id'];
             $rows[] = $row;
         }
     }
     return $rows;
 }
Exemple #28
0
 /**
  * Takes an associative array and creates a friend object.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @return void
  */
 public static function create(&$params)
 {
     $transaction = new CRM_Core_Transaction();
     $mailParams = array();
     //create contact corresponding to each friend
     foreach ($params['friend'] as $key => $details) {
         if ($details["first_name"]) {
             $contactParams[$key] = array('first_name' => $details["first_name"], 'last_name' => $details["last_name"], 'contact_source' => ts('Tell a Friend') . ": {$params['title']}", 'email-Primary' => $details["email"]);
             $displayName = $details["first_name"] . " " . $details["last_name"];
             $mailParams['email'][$displayName] = $details["email"];
         }
     }
     $frndParams = array();
     $frndParams['entity_id'] = $params['entity_id'];
     $frndParams['entity_table'] = $params['entity_table'];
     self::getValues($frndParams);
     $activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', 'Tell a Friend', 'value', 'name');
     //create activity
     $activityParams = array('source_contact_id' => $params['source_contact_id'], 'source_record_id' => NULL, 'activity_type_id' => $activityTypeId, 'title' => $params['title'], 'activity_date_time' => date("YmdHis"), 'subject' => ts('Tell a Friend') . ": {$params['title']}", 'details' => $params['suggested_message'], 'status_id' => 2, 'is_test' => $params['is_test'], 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params));
     //activity creation
     $activity = CRM_Activity_BAO_Activity::create($activityParams);
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
     //friend contacts creation
     foreach ($contactParams as $key => $value) {
         //create contact only if it does not exits in db
         $value['email'] = $value['email-Primary'];
         $value['check_permission'] = FALSE;
         $contact = CRM_Core_BAO_UFGroup::findContact($value, NULL, 'Individual');
         if (!$contact) {
             $contact = self::add($value);
         }
         // attempt to save activity targets
         $targetParams = array('activity_id' => $activity->id, 'contact_id' => $contact, 'record_type_id' => $targetID);
         // See if it already exists
         $activityContact = new CRM_Activity_DAO_ActivityContact();
         $activityContact->activity_id = $activity->id;
         $activityContact->contact_id = $contact;
         $activityContact->find(TRUE);
         if (empty($activityContact->id)) {
             $resultTarget = CRM_Activity_BAO_ActivityContact::create($targetParams);
         }
     }
     $transaction->commit();
     //process sending of mails
     $mailParams['title'] = CRM_Utils_Array::value('title', $params);
     $mailParams['general_link'] = CRM_Utils_Array::value('general_link', $frndParams);
     $mailParams['message'] = CRM_Utils_Array::value('suggested_message', $params);
     // get domain
     $domainDetails = CRM_Core_BAO_Domain::getNameAndEmail();
     list($username, $mailParams['domain']) = explode('@', $domainDetails[1]);
     $default = array();
     $findProperties = array('id' => $params['entity_id']);
     if ($params['entity_table'] == 'civicrm_contribution_page') {
         $returnProperties = array('receipt_from_email', 'is_email_receipt');
         CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $findProperties, $default, $returnProperties);
         //if is_email_receipt is set then take receipt_from_email
         //as from_email
         if (!empty($default['is_email_receipt']) && !empty($default['receipt_from_email'])) {
             $mailParams['email_from'] = $default['receipt_from_email'];
         }
         $urlPath = 'civicrm/contribute/transact';
         $mailParams['module'] = 'contribute';
     } elseif ($params['entity_table'] == 'civicrm_event') {
         $returnProperties = array('confirm_from_email', 'is_email_confirm');
         CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $findProperties, $default, $returnProperties);
         $mailParams['email_from'] = $domainDetails['1'];
         //if is_email_confirm is set then take confirm_from_email
         //as from_email
         if (!empty($default['is_email_confirm']) && !empty($default['confirm_from_email'])) {
             $mailParams['email_from'] = $default['confirm_from_email'];
         }
         $urlPath = 'civicrm/event/info';
         $mailParams['module'] = 'event';
     } elseif ($params['entity_table'] == 'civicrm_pcp') {
         $mailParams['email_from'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $params['source_contact_id'], 'email', 'contact_id');
         $urlPath = 'civicrm/pcp/info';
         $mailParams['module'] = 'contribute';
     }
     $mailParams['page_url'] = CRM_Utils_System::url($urlPath, "reset=1&id={$params['entity_id']}", TRUE, NULL, FALSE, TRUE);
     //send mail
     self::sendMail($params['source_contact_id'], $mailParams);
 }
Exemple #29
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->_dedupeButtonName = $this->getButtonName('refresh', 'dedupe');
     $this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
     CRM_Core_Resources::singleton()->addStyleFile('civicrm', 'css/contactSummary.css', 2, 'html-header');
     $session = CRM_Core_Session::singleton();
     if ($this->_action == CRM_Core_Action::ADD) {
         // check for add contacts permissions
         if (!CRM_Core_Permission::check('add contacts')) {
             CRM_Utils_System::permissionDenied();
             CRM_Utils_System::civiExit();
         }
         $this->_contactType = CRM_Utils_Request::retrieve('ct', 'String', $this, TRUE, NULL, 'REQUEST');
         if (!in_array($this->_contactType, array('Individual', 'Household', 'Organization'))) {
             CRM_Core_Error::statusBounce(ts('Could not get a contact id and/or contact type'));
         }
         $this->_isContactSubType = FALSE;
         if ($this->_contactSubType = CRM_Utils_Request::retrieve('cst', 'String', $this)) {
             $this->_isContactSubType = TRUE;
         }
         if ($this->_contactSubType && !CRM_Contact_BAO_ContactType::isExtendsContactType($this->_contactSubType, $this->_contactType, TRUE)) {
             CRM_Core_Error::statusBounce(ts("Could not get a valid contact subtype for contact type '%1'", array(1 => $this->_contactType)));
         }
         $this->_gid = CRM_Utils_Request::retrieve('gid', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
         $this->_tid = CRM_Utils_Request::retrieve('tid', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
         $typeLabel = CRM_Contact_BAO_ContactType::contactTypePairs(TRUE, $this->_contactSubType ? $this->_contactSubType : $this->_contactType);
         $typeLabel = implode(' / ', $typeLabel);
         CRM_Utils_System::setTitle(ts('New %1', array(1 => $typeLabel)));
         $session->pushUserContext(CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
         $this->_contactId = NULL;
     } else {
         //update mode
         if (!$this->_contactId) {
             $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
         }
         if ($this->_contactId) {
             $defaults = array();
             $params = array('id' => $this->_contactId);
             $returnProperities = array('id', 'contact_type', 'contact_sub_type', 'modified_date', 'is_deceased');
             CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_Contact', $params, $defaults, $returnProperities);
             if (empty($defaults['id'])) {
                 CRM_Core_Error::statusBounce(ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId)));
             }
             $this->_contactType = CRM_Utils_Array::value('contact_type', $defaults);
             $this->_contactSubType = CRM_Utils_Array::value('contact_sub_type', $defaults);
             // check for permissions
             $session = CRM_Core_Session::singleton();
             if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
                 CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
             }
             $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
             if ($defaults['is_deceased']) {
                 $displayName .= '  <span class="crm-contact-deceased">(deceased)</span>';
             }
             $displayName = ts('Edit %1', array(1 => $displayName));
             // Check if this is default domain contact CRM-10482
             if (CRM_Contact_BAO_Contact::checkDomainContact($this->_contactId)) {
                 $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($displayName);
             $context = CRM_Utils_Request::retrieve('context', 'String', $this);
             $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
             $urlParams = 'reset=1&cid=' . $this->_contactId;
             if ($context) {
                 $urlParams .= "&context={$context}";
             }
             if (CRM_Utils_Rule::qfKey($qfKey)) {
                 $urlParams .= "&key={$qfKey}";
             }
             $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view', $urlParams));
             $values = $this->get('values');
             // get contact values.
             if (!empty($values)) {
                 $this->_values = $values;
             } else {
                 $params = array('id' => $this->_contactId, 'contact_id' => $this->_contactId, 'noRelationships' => TRUE, 'noNotes' => TRUE, 'noGroups' => TRUE);
                 $contact = CRM_Contact_BAO_Contact::retrieve($params, $this->_values, TRUE);
                 $this->set('values', $this->_values);
             }
         } else {
             CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
         }
     }
     // parse street address, CRM-5450
     $this->_parseStreetAddress = $this->get('parseStreetAddress');
     if (!isset($this->_parseStreetAddress)) {
         $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options');
         $this->_parseStreetAddress = FALSE;
         if (!empty($addressOptions['street_address']) && !empty($addressOptions['street_address_parsing'])) {
             $this->_parseStreetAddress = TRUE;
         }
         $this->set('parseStreetAddress', $this->_parseStreetAddress);
     }
     $this->assign('parseStreetAddress', $this->_parseStreetAddress);
     $this->_editOptions = $this->get('contactEditOptions');
     if (CRM_Utils_System::isNull($this->_editOptions)) {
         $this->_editOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 0');
         $this->set('contactEditOptions', $this->_editOptions);
     }
     // build demographics only for Individual contact type
     if ($this->_contactType != 'Individual' && array_key_exists('Demographics', $this->_editOptions)) {
         unset($this->_editOptions['Demographics']);
     }
     // in update mode don't show notes
     if ($this->_contactId && array_key_exists('Notes', $this->_editOptions)) {
         unset($this->_editOptions['Notes']);
     }
     $this->assign('editOptions', $this->_editOptions);
     $this->assign('contactType', $this->_contactType);
     $this->assign('contactSubType', $this->_contactSubType);
     //build contact subtype form element, CRM-6864
     $buildContactSubType = TRUE;
     if ($this->_contactSubType && $this->_action & CRM_Core_Action::ADD) {
         $buildContactSubType = FALSE;
     }
     $this->assign('buildContactSubType', $buildContactSubType);
     // get the location blocks.
     $this->_blocks = $this->get('blocks');
     if (CRM_Utils_System::isNull($this->_blocks)) {
         $this->_blocks = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 1');
         $this->set('blocks', $this->_blocks);
     }
     $this->assign('blocks', $this->_blocks);
     // this is needed for custom data.
     $this->assign('entityID', $this->_contactId);
     // also keep the convention.
     $this->assign('contactId', $this->_contactId);
     // location blocks.
     CRM_Contact_Form_Location::preProcess($this);
     // retain the multiple count custom fields value
     if (!empty($_POST['hidden_custom'])) {
         $customGroupCount = CRM_Utils_Array::value('hidden_custom_group_count', $_POST);
         if ($contactSubType = CRM_Utils_Array::value('contact_sub_type', $_POST)) {
             $paramSubType = implode(',', $contactSubType);
         }
         $this->_getCachedTree = FALSE;
         unset($customGroupCount[0]);
         foreach ($customGroupCount as $groupID => $groupCount) {
             if ($groupCount > 1) {
                 $this->set('groupID', $groupID);
                 //loop the group
                 for ($i = 0; $i <= $groupCount; $i++) {
                     CRM_Custom_Form_CustomData::preProcess($this, NULL, $contactSubType, $i, $this->_contactType);
                     CRM_Contact_Form_Edit_CustomData::buildQuickForm($this);
                 }
             }
         }
         //reset all the ajax stuff, for normal processing
         if (isset($this->_groupTree)) {
             $this->_groupTree = NULL;
         }
         $this->set('groupID', NULL);
         $this->_getCachedTree = TRUE;
     }
     // execute preProcess dynamically by js else execute normal preProcess
     if (array_key_exists('CustomData', $this->_editOptions)) {
         //assign a parameter to pass for sub type multivalue
         //custom field to load
         if ($this->_contactSubType || isset($paramSubType)) {
             $paramSubType = isset($paramSubType) ? $paramSubType : str_replace(CRM_Core_DAO::VALUE_SEPARATOR, ',', trim($this->_contactSubType, CRM_Core_DAO::VALUE_SEPARATOR));
             $this->assign('paramSubType', $paramSubType);
         }
         if (CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject)) {
             CRM_Contact_Form_Edit_CustomData::preProcess($this);
         } else {
             $contactSubType = $this->_contactSubType;
             // need contact sub type to build related grouptree array during post process
             if (!empty($_POST['contact_sub_type'])) {
                 $contactSubType = $_POST['contact_sub_type'];
             }
             //only custom data has preprocess hence directly call it
             CRM_Custom_Form_CustomData::preProcess($this, NULL, $contactSubType, 1, $this->_contactType, $this->_contactId);
             $this->assign('customValueCount', $this->_customValueCount);
         }
     }
 }
Exemple #30
0
 /**
  * Add date.
  *
  * @code
  * // if you need time
  * $attributes = array(
  *   'addTime' => true,
  *   'formatType' => 'relative' or 'birth' etc check advanced date settings
  * );
  * @endcode
  *
  * @param string $name
  *   Name of the element.
  * @param string $label
  *   Label of the element.
  * @param bool $required
  *   True if required.
  * @param array $attributes
  *   Key / value pair.
  */
 public function addDate($name, $label, $required = FALSE, $attributes = NULL)
 {
     if (!empty($attributes['formatType'])) {
         // get actual format
         $params = array('name' => $attributes['formatType']);
         $values = array();
         // cache date information
         static $dateFormat;
         $key = "dateFormat_" . str_replace(' ', '_', $attributes['formatType']);
         if (empty($dateFormat[$key])) {
             CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_PreferencesDate', $params, $values);
             $dateFormat[$key] = $values;
         } else {
             $values = $dateFormat[$key];
         }
         if ($values['date_format']) {
             $attributes['format'] = $values['date_format'];
         }
         if (!empty($values['time_format'])) {
             $attributes['timeFormat'] = $values['time_format'];
         }
         $attributes['startOffset'] = $values['start'];
         $attributes['endOffset'] = $values['end'];
     }
     $config = CRM_Core_Config::singleton();
     if (empty($attributes['format'])) {
         $attributes['format'] = $config->dateInputFormat;
     }
     if (!isset($attributes['startOffset'])) {
         $attributes['startOffset'] = 10;
     }
     if (!isset($attributes['endOffset'])) {
         $attributes['endOffset'] = 10;
     }
     $this->add('text', $name, $label, $attributes);
     if (!empty($attributes['addTime']) || !empty($attributes['timeFormat'])) {
         if (!isset($attributes['timeFormat'])) {
             $timeFormat = $config->timeInputFormat;
         } else {
             $timeFormat = $attributes['timeFormat'];
         }
         // 1 - 12 hours and 2 - 24 hours, but for jquery widget it is 0 and 1 respectively
         if ($timeFormat) {
             $show24Hours = TRUE;
             if ($timeFormat == 1) {
                 $show24Hours = FALSE;
             }
             //CRM-6664 -we are having time element name
             //in either flat string or an array format.
             $elementName = $name . '_time';
             if (substr($name, -1) == ']') {
                 $elementName = substr($name, 0, strlen($name) - 1) . '_time]';
             }
             $this->add('text', $elementName, ts('Time'), array('timeFormat' => $show24Hours));
         }
     }
     if ($required) {
         $this->addRule($name, ts('Please select %1', array(1 => $label)), 'required');
         if (!empty($attributes['addTime']) && !empty($attributes['addTimeRequired'])) {
             $this->addRule($elementName, ts('Please enter a time.'), 'required');
         }
     }
 }