Example #1
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public
  */
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('action', $this->_action);
     $this->assign('context', $this->_context);
     //check permission for action.
     if (!CRM_Core_Permission::checkActionPermission('CiviGrant', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->_noteId = null;
     if ($this->_id) {
         require_once 'CRM/Core/BAO/Note.php';
         $noteDAO = new CRM_Core_BAO_Note();
         $noteDAO->entity_table = 'civicrm_grant';
         $noteDAO->entity_id = $this->_id;
         if ($noteDAO->find(true)) {
             $this->_noteId = $noteDAO->id;
         }
     }
     //build custom data
     CRM_Custom_Form_Customdata::preProcess($this, null, null, 1, 'Grant', $this->_id);
 }
Example #2
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     if (!CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     parent::preProcess();
 }
Example #3
0
 /**
  * Function to set variables up before form is built
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function preProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         //check permission for action.
         if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
             CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
         }
         $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'title');
         $this->assign('title', $this->_title);
         parent::preProcess();
     }
     if (!$this->_action) {
         $action = CRM_Utils_Array::value('action', $_GET);
         $id = CRM_Utils_Array::value('id', $_GET);
         switch ($action) {
             case 'delete':
                 require_once 'CRM/Contribute/BAO/PCP.php';
                 $title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $id, 'title');
                 CRM_Contribute_BAO_PCP::delete($id);
                 CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been deleted.", array(1 => $title)));
                 break;
             case 'disable':
                 require_once 'CRM/Contribute/BAO/PCP.php';
                 CRM_Contribute_BAO_PCP::setDisable($id, '0');
                 break;
             case 'enable':
                 require_once 'CRM/Contribute/BAO/PCP.php';
                 CRM_Contribute_BAO_PCP::setDisable($id, '1');
                 break;
         }
         $session =& CRM_Core_Session::singleton();
         CRM_Utils_System::redirect($session->popUserContext());
     }
 }
 /**
  * This function is called prior to building and submitting the form
  */
 function preProcess()
 {
     // check contact_id
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if (empty($this->_contactId)) {
         CRM_Core_Error::statusBounce(ts('Could not get a contact id.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
         // this also redirects to the default civicrm page
     }
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviMember', 'update')) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     // get request
     $this->_request = CRM_Utils_Request::retrieve('request', 'String', $this, FALSE, 'choose');
     // get session
     $session = CRM_Core_Session::singleton();
     // get values
     $this->_configMembership = CRM_Lidmaatschapwijziging_ConfigMembership::singleton($this->_contactId);
     $this->_values = $this->_configMembership->getContact();
     // set display name
     $this->_display_name = $this->_values['display_name'];
     // set contact id
     $this->_values['contact_id'] = $this->_contactId;
     // set request
     $this->_values['request'] = $this->_request;
     // set title
     CRM_Utils_System::setTitle('LidmaatschapWijziging - Lidmaatschap - ' . $this->_values['display_name']);
     // request
     if ('empty' == $this->_request) {
     }
     if ('choose' == $this->_request) {
         // if there is no memberships then the options are empty, we
         // show a message that there are no memebrships and a submit butten to
         // go to the relationship, first we redirect them to request empty
         $memberships = $this->_configMembership->getMemberships();
         if (empty($memberships)) {
             // redirect user
             $url = CRM_Utils_System::url('civicrm/lidmaatschapwijziging/membership', 'reset=1&request=empty&cid=' . $this->_contactId);
             CRM_Utils_System::redirect($url);
         }
     }
     if ('update' == $this->_request) {
         // get membership id
         $this->_membershipId = CRM_Utils_Request::retrieve('membership_id', 'Positive', $this);
         $this->_values['membership_id'] = $this->_membershipId;
         // get membership
         $membership = $this->_configMembership->getMembership($this->_membershipId);
         $this->_values = array_merge($this->_values, $membership);
         // get source, source is overritten by the contact source and not the membership source, i
         // override it here
         $this->_values['source'] = $membership['source'];
         // This is diffrent from the LidmaatschapWijzigingContact because the custom field values are already send with the membership
         // We have to set the _values of the custom field like huppeldepup and not custom_35, so we
         // loop through the custom field and change the custom_35 values to huppeldepup
         foreach ($this->_configMembership->getMembershipCustomFields() as $key => $field) {
             $this->_values[$field['name']] = $this->_values['custom_' . $field['id']];
         }
     }
 }
Example #5
0
 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     parent::preProcess();
     //check permission for delete.
     if (!CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
 }
Example #6
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     //check for delete
     if (!CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     parent::preProcess();
 }
Example #7
0
 /**
  * These tasks are the core set of tasks that the user can perform
  * on a contact / group of contacts
  *
  * @return array the set of tasks for a group of contacts
  * @static
  * @access public
  */
 static function &tasks()
 {
     if (!self::$_tasks) {
         if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) {
             self::$_tasks = array(1 => ts('Delete Grants'));
         }
     }
     return self::$_tasks;
 }
Example #8
0
 /**
  * Function to set variables up before form is built
  *
  * @param null
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         //check permission for action.
         if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) {
             CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
         }
         $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $this->_id, 'title');
         $this->assign('title', $this->_title);
         parent::preProcess();
     }
     if (!$this->_action) {
         $this->_action = CRM_Utils_Array::value('action', $_GET);
         $this->_id = CRM_Utils_Array::value('id', $_GET);
     } else {
         $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     }
     //give the context.
     if (!isset($this->_context)) {
         $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     }
     $this->assign('context', $this->_context);
     $session = CRM_Core_Session::singleton();
     $context = $session->popUserContext();
     $userID = $session->get('userID');
     //do not allow destructive actions without permissions
     $permission = FALSE;
     if (CRM_Core_Permission::check('administer CiviCRM') || $userID && CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $this->_id, 'contact_id') == $userID) {
         $permission = TRUE;
     }
     if ($permission && $this->_id) {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $this->_id, 'title');
         switch ($this->_action) {
             case CRM_Core_Action::DELETE:
             case 'delete':
                 CRM_PCP_BAO_PCP::deleteById($this->_id);
                 CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been deleted.", array(1 => $this->_title)), ts('Page Deleted'), 'success');
                 break;
             case CRM_Core_Action::DISABLE:
             case 'disable':
                 CRM_PCP_BAO_PCP::setDisable($this->_id, '0');
                 CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been disabled.", array(1 => $this->_title)), ts('Page Disabled'), 'success');
                 break;
             case CRM_Core_Action::ENABLE:
             case 'enable':
                 CRM_PCP_BAO_PCP::setDisable($this->_id, '1');
                 CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been enabled.", array(1 => $this->_title)), ts('Page Enabled'), 'success');
                 break;
         }
         if ($context) {
             CRM_Utils_System::redirect($context);
         }
     }
 }
Example #9
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     // check for action permissions.
     if (!CRM_Core_Permission::checkActionPermission('CiviPledge', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     $this->assign('action', $this->_action);
     $this->assign('context', $this->_context);
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->userDisplayName = $this->userEmail = NULL;
     if ($this->_contactID) {
         list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
         $this->assign('displayName', $this->userDisplayName);
         // set title to "Pledge - "+Contact Name
         $displayName = $this->userDisplayName;
         $pageTitle = ts('Pledge by') . ' ' . $displayName;
         $this->assign('pageTitle', $pageTitle);
         CRM_Utils_System::setTitle($pageTitle);
     }
     //build custom data
     CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Pledge', $this->_id);
     $this->_values = array();
     // current pledge id
     if ($this->_id) {
         //get the contribution id
         $this->_contributionID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_id, 'contribution_id', 'pledge_id');
         $params = array('id' => $this->_id);
         CRM_Pledge_BAO_Pledge::getValues($params, $this->_values);
         $paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
         //check for pending pledge.
         if (CRM_Utils_Array::value('status_id', $this->_values) == array_search('Pending', $paymentStatusTypes)) {
             $this->_isPending = TRUE;
         } elseif (CRM_Utils_Array::value('status_id', $this->_values) == array_search('Overdue', $paymentStatusTypes)) {
             $allPledgePayments = array();
             CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id', $this->_id, $allPledgePayments, array('status_id'));
             foreach ($allPledgePayments as $key => $value) {
                 $allStatus[$value['id']] = $paymentStatusTypes[$value['status_id']];
             }
             if (count(array_count_values($allStatus)) <= 2) {
                 if (CRM_Utils_Array::value('Pending', array_count_values($allStatus))) {
                     $this->_isPending = TRUE;
                 }
             }
         }
     }
     //get the pledge frequency units.
     $this->_freqUnits = CRM_Core_OptionGroup::values('recur_frequency_units');
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
 }
Example #10
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if (!CRM_Core_Permission::checkActionPermission('CiviAuction', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if (($this->_action & CRM_Core_Action::VIEW || $this->_action & CRM_Core_Action::UPDATE || $this->_action & CRM_Core_Action::DELETE) && !$this->_id) {
         CRM_Core_Error::fatal();
     }
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $values = $ids = array();
     $params = array('id' => $this->get('id'));
     CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids);
     $values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit']));
     if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) {
         $sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"];
         $dao = new CRM_Core_DAO();
         $dao->query($sql);
         if ($dao->fetch()) {
             $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
             $values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>";
         }
         $honor = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id');
         $values['honor_type'] = $honor[$values['honor_type_id']];
     }
     //handle custom data.
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     if (!empty($values['contribution_page_id'])) {
         $values['contribution_page'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $values['contribution_page_id'], 'title');
     }
     $values['financial_type'] = CRM_Utils_Array::value($values['financial_type_id'], CRM_Contribute_PseudoConstant::financialType());
     if ($values['status_id']) {
         $values['pledge_status'] = CRM_Utils_Array::value($values['status_id'], CRM_Contribute_PseudoConstant::contributionStatus());
     }
     $url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     $displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
     $this->assign('displayName', $displayName);
     $title = $displayName . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($values['pledge_amount']) . ' - ' . $values['financial_type'] . ')';
     // add Pledge to Recent Items
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Pledge', $values['contact_id'], NULL, $recentOther);
     // Check if this is default domain contact CRM-10482
     if (CRM_Contact_BAO_Contact::checkDomainContact($values['contact_id'])) {
         $displayName .= ' (' . ts('default organization') . ')';
     }
     // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
     CRM_Utils_System::setTitle(ts('View Pledge by') . ' ' . $displayName);
     //do check for campaigns
     if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
         $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
         $values['campaign'] = $campaigns[$campaignId];
     }
     $this->assign($values);
 }
Example #12
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     //check for delete
     if (!CRM_Core_Permission::checkActionPermission('CiviEvent', CRM_Core_Action::DELETE)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     parent::preProcess();
     foreach ($this->_participantIds as $participantId) {
         if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantId)) {
             $this->assign('additionalParticipants', TRUE);
         }
     }
 }
Example #13
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     parent::preProcess();
     //check for delete
     if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_isTemplate) {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'template_title');
     } else {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'title');
     }
 }
Example #14
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     //Check if there are contributions related to Contribution Page
     parent::preProcess();
     //check for delete
     if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     $dao = new CRM_Contribute_DAO_Contribution();
     $dao->contribution_page_id = $this->_id;
     if ($dao->find(TRUE)) {
         $this->_relatedContributions = TRUE;
         $this->assign('relatedContributions', TRUE);
     }
 }
Example #15
0
 /**
  * Heart of the viewing process. The runner gets all the meta data for
  * the contact and calls the appropriate type of page to view.
  *
  * @return void
  * @access public
  *
  */
 function preProcess()
 {
     $this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     // check for action permissions.
     if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     require_once 'CRM/Mailing/BAO/Mailing.php';
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $this->_mailingId;
     if ($mailing->find(true)) {
         $this->assign('subject', $mailing->subject);
     }
 }
Example #16
0
 public function preProcess()
 {
     // Check for edit permission.
     if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     parent::preProcess();
     $params = array();
     $params['context'] = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'membership');
     $params['id'] = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $params['mode'] = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->setContextVariables($params);
     $this->assign('context', $this->_context);
     $this->assign('membershipMode', $this->_mode);
 }
Example #17
0
 /**
  * Heart of the viewing process. The runner gets all the meta data for
  * the contact and calls the appropriate type of page to view.
  *
  * @return void
  */
 public function preProcess()
 {
     $this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     // check for action permissions.
     if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $this->_mailingId;
     $subject = '';
     if ($mailing->find(TRUE)) {
         $subject = $mailing->subject;
     }
     $this->assign('subject', $subject);
 }
Example #18
0
 /**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $context);
     $values = array();
     $params['id'] = $this->_id;
     CRM_Grant_BAO_Grant::retrieve($params, $values);
     $grantType = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
     $grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
     $this->assign('grantType', $grantType[$values['grant_type_id']]);
     $this->assign('grantStatus', $grantStatus[$values['status_id']]);
     $grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
     foreach ($grantTokens as $token) {
         $this->assign($token, CRM_Utils_Array::value($token, $values));
     }
     if (isset($this->_id)) {
         $noteDAO = new CRM_Core_BAO_Note();
         $noteDAO->entity_table = 'civicrm_grant';
         $noteDAO->entity_id = $this->_id;
         if ($noteDAO->find(TRUE)) {
             $this->_noteId = $noteDAO->id;
         }
     }
     if (isset($this->_noteId)) {
         $this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note'));
     }
     // add Grant to Recent Items
     $url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], NULL, $recentOther);
     $attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
     $this->assign('attachment', $attachment);
     $grantType = CRM_Core_DAO::getFieldValue("CRM_Grant_DAO_Grant", $this->_id, "grant_type_id");
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0, $grantType);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id);
     $this->assign('id', $this->_id);
     $this->setPageTitle(ts('Grant'));
 }
Example #19
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     //custom data related code
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         CRM_Custom_Form_CustomData::preProcess($this);
         return;
     }
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_grantType = NULL;
     if ($this->_id) {
         $this->_grantType = CRM_Core_DAO::getFieldValue('CRM_Grant_DAO_Grant', $this->_id, 'grant_type_id');
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('action', $this->_action);
     $this->assign('context', $this->_context);
     //check permission for action.
     if (!CRM_Core_Permission::checkActionPermission('CiviGrant', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     $this->setPageTitle(ts('Grant'));
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->_noteId = NULL;
     if ($this->_id) {
         $noteDAO = new CRM_Core_BAO_Note();
         $noteDAO->entity_table = 'civicrm_grant';
         $noteDAO->entity_id = $this->_id;
         if ($noteDAO->find(TRUE)) {
             $this->_noteId = $noteDAO->id;
         }
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         $this->set('type', 'Grant');
         $this->set('subType', CRM_Utils_Array::value('grant_type_id', $_POST));
         $this->set('entityId', $this->_id);
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
 }
Example #20
0
 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     require_once 'CRM/Pledge/BAO/Pledge.php';
     $values = $ids = array();
     $params = array('id' => $this->get('id'));
     CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids);
     $values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit']));
     if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) {
         $sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"];
         $dao = new CRM_Core_DAO();
         $dao->query($sql);
         if ($dao->fetch()) {
             $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
             $values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>";
         }
         $honor = CRM_Core_PseudoConstant::honor();
         $values['honor_type'] = $honor[$values['honor_type_id']];
     }
     //handle custom data.
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     if (CRM_Utils_Array::value('contribution_page_id', $values)) {
         $values['contribution_page'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $values['contribution_page_id'], 'title');
     }
     $values['contribution_type'] = CRM_Utils_Array::value($values['contribution_type_id'], CRM_Contribute_PseudoConstant::contributionType());
     if ($values['status_id']) {
         $values['pledge_status'] = CRM_Utils_Array::value($values['status_id'], CRM_Contribute_PseudoConstant::contributionStatus());
     }
     require_once 'CRM/Utils/Recent.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     $url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     require_once 'CRM/Utils/Money.php';
     $displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
     $this->assign('displayName', $displayName);
     $title = $displayName . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($values['pledge_amount']) . ' - ' . $values['contribution_type'] . ')';
     // add Pledge to Recent Items
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Pledge', $values['contact_id'], null, $recentOther);
     $this->assign($values);
 }
Example #21
0
 /**
  * Create case contact record.
  *
  * @param array $params
  *   case_id, contact_id
  *
  * @return CRM_Case_BAO_CaseContact
  */
 public static function create($params)
 {
     $caseContact = new self();
     $caseContact->copyValues($params);
     $caseContact->save();
     // add to recently viewed
     $caseType = CRM_Case_BAO_Case::getCaseType($caseContact->case_id);
     $url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home");
     $title = CRM_Contact_BAO_Contact::displayName($caseContact->contact_id) . ' - ' . $caseType;
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/case', "action=delete&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home");
     }
     // add the recently created case
     CRM_Utils_Recent::add($title, $url, $caseContact->case_id, 'Case', $caseContact->contact_id, NULL, $recentOther);
     return $caseContact;
 }
Example #22
0
 public function preProcess()
 {
     // Check for edit permission.
     if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     parent::preProcess();
     $params = array();
     $params['context'] = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'membership');
     $params['id'] = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $params['mode'] = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->setContextVariables($params);
     $this->assign('context', $this->_context);
     $this->assign('membershipMode', $this->_mode);
     $this->allMembershipTypeDetails = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, array(), TRUE);
     foreach ($this->allMembershipTypeDetails as $index => $membershipType) {
         if ($membershipType['auto_renew']) {
             $this->_recurMembershipTypes[$index] = $membershipType;
             $this->membershipTypeRenewalStatus[$index] = $membershipType['auto_renew'];
         }
     }
 }
Example #23
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     // check for action permissions.
     if (!CRM_Core_Permission::checkActionPermission('CiviPledge', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     $this->assign('action', $this->_action);
     $this->assign('context', $this->_context);
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->userDisplayName = $this->userEmail = NULL;
     if ($this->_contactID) {
         list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
         $this->assign('displayName', $this->userDisplayName);
     }
     $this->setPageTitle(ts('Pledge'));
     // build custom data
     CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Pledge', $this->_id);
     $this->_values = array();
     // current pledge id
     if ($this->_id) {
         // get the contribution id
         $this->_contributionID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_id, 'contribution_id', 'pledge_id');
         $params = array('id' => $this->_id);
         CRM_Pledge_BAO_Pledge::getValues($params, $this->_values);
         $this->_isPending = CRM_Pledge_BAO_Pledge::pledgeHasFinancialTransactions($this->_id, CRM_Utils_Array::value('status_id', $this->_values)) ? FALSE : TRUE;
     }
     // get the pledge frequency units.
     $this->_freqUnits = CRM_Core_OptionGroup::values('recur_frequency_units');
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
 }
 /**
  * takes an associative array and creates a contribution object
  *
  * @param array $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contribute_BAO_Contribution object 
  * @access public
  * @static
  */
 static function &create(&$params, &$ids)
 {
     require_once 'CRM/Utils/Money.php';
     require_once 'CRM/Utils/Date.php';
     require_once 'CRM/Contribute/PseudoConstant.php';
     // FIXME: a cludgy hack to fix the dates to MySQL format
     $dateFields = array('receive_date', 'cancel_date', 'receipt_date', 'thankyou_date');
     foreach ($dateFields as $df) {
         if (isset($params[$df])) {
             $params[$df] = CRM_Utils_Date::isoToMysql($params[$df]);
         }
     }
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $contribution = self::add($params, $ids);
     if (is_a($contribution, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $contribution;
     }
     $params['contribution_id'] = $contribution->id;
     if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom'])) {
         require_once 'CRM/Core/BAO/CustomValueTable.php';
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution', $contribution->id);
     }
     $session =& CRM_Core_Session::singleton();
     if (CRM_Utils_Array::value('note', $params)) {
         require_once 'CRM/Core/BAO/Note.php';
         $noteParams = array('entity_table' => 'civicrm_contribution', 'note' => $params['note'], 'entity_id' => $contribution->id, 'contact_id' => $session->get('userID'), 'modified_date' => date('Ymd'));
         if (!$noteParams['contact_id']) {
             $noteParams['contact_id'] = $params['contact_id'];
         }
         CRM_Core_BAO_Note::add($noteParams, CRM_Utils_Array::value('note', $ids));
     }
     // check if activity record exist for this contribution, if
     // not add activity
     require_once "CRM/Activity/DAO/Activity.php";
     $activity = new CRM_Activity_DAO_Activity();
     $activity->source_record_id = $contribution->id;
     $activity->activity_type_id = CRM_Core_OptionGroup::getValue('activity_type', 'Contribution', 'name');
     if (!$activity->find()) {
         require_once "CRM/Activity/BAO/Activity.php";
         CRM_Activity_BAO_Activity::addActivity($contribution, 'Offline');
     }
     if (CRM_Utils_Array::value('soft_credit_to', $params)) {
         $csParams = array();
         if ($id = CRM_Utils_Array::value('softID', $params)) {
             $csParams['id'] = $params['softID'];
         }
         $csParams['pcp_display_in_roll'] = $params['pcp_display_in_roll'] ? 1 : 0;
         foreach (array('pcp_roll_nickname', 'pcp_personal_note') as $val) {
             if (CRM_Utils_Array::value($val, $params)) {
                 $csParams[$val] = $params[$val];
             }
         }
         $csParams['contribution_id'] = $contribution->id;
         $csParams['contact_id'] = $params['soft_credit_to'];
         // first stage: we register whole amount as credited to given person
         $csParams['amount'] = $contribution->total_amount;
         self::addSoftContribution($csParams);
     }
     $transaction->commit();
     // do not add to recent items for import, CRM-4399
     if (!CRM_Utils_Array::value('skipRecentView', $params)) {
         require_once 'CRM/Utils/Recent.php';
         require_once 'CRM/Contribute/PseudoConstant.php';
         require_once 'CRM/Contact/BAO/Contact.php';
         $url = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=view&reset=1&id={$contribution->id}&cid={$contribution->contact_id}&context=home");
         $contributionTypes = CRM_Contribute_PseudoConstant::contributionType();
         $title = CRM_Contact_BAO_Contact::displayName($contribution->contact_id) . ' - (' . CRM_Utils_Money::format($contribution->total_amount, $contribution->currency) . ' ' . ' - ' . $contributionTypes[$contribution->contribution_type_id] . ')';
         $recentOther = array();
         if (CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::UPDATE)) {
             $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=update&reset=1&id={$contribution->id}&cid={$contribution->contact_id}&context=home");
         }
         if (CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::DELETE)) {
             $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=delete&reset=1&id={$contribution->id}&cid={$contribution->contact_id}&context=home");
         }
         // add the recently created Contribution
         CRM_Utils_Recent::add($title, $url, $contribution->id, 'Contribution', $contribution->contact_id, null, $recentOther);
     }
     return $contribution;
 }
Example #25
0
 /**
  * Takes an associative array and creates a membership object.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param array $ids
  *   The array that holds all the db ids.
  * @param bool $skipRedirect
  * @param string $activityType
  *
  * @throws CRM_Core_Exception
  *
  * @return CRM_Member_BAO_Membership|CRM_Core_Error
  */
 public static function create(&$params, &$ids, $skipRedirect = FALSE, $activityType = 'Membership Signup')
 {
     // always calculate status if is_override/skipStatusCal is not true.
     // giving respect to is_override during import.  CRM-4012
     // To skip status calculation we should use 'skipStatusCal'.
     // eg pay later membership, membership update cron CRM-3984
     if (empty($params['is_override']) && empty($params['skipStatusCal'])) {
         $dates = array('start_date', 'end_date', 'join_date');
         // Declare these out of courtesy as IDEs don't pick up the setting of them below.
         $start_date = $end_date = $join_date = NULL;
         foreach ($dates as $date) {
             ${$date} = $params[$date] = CRM_Utils_Date::processDate(CRM_Utils_Array::value($date, $params), NULL, TRUE, 'Ymd');
         }
         //fix for CRM-3570, during import exclude the statuses those having is_admin = 1
         $excludeIsAdmin = CRM_Utils_Array::value('exclude_is_admin', $params, FALSE);
         //CRM-3724 always skip is_admin if is_override != true.
         if (!$excludeIsAdmin && empty($params['is_override'])) {
             $excludeIsAdmin = TRUE;
         }
         $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($start_date, $end_date, $join_date, 'today', $excludeIsAdmin, CRM_Utils_Array::value('membership_type_id', $params), $params);
         if (empty($calcStatus)) {
             // Redirect the form in case of error
             // @todo this redirect in the BAO layer is really bad & should be moved to the form layer
             // however since we have no idea how (if) this is triggered we can't safely move / remove it
             // NB I tried really hard to trigger this error from backoffice membership form in order to test it
             // and am convinced form validation is complete on that form WRT this error.
             $errorParams = array('message_title' => ts('No valid membership status for given dates.'), 'legacy_redirect_path' => 'civicrm/contact/view', 'legacy_redirect_query' => "reset=1&force=1&cid={$params['contact_id']}&selectedChild=member");
             throw new CRM_Core_Exception(ts("The membership cannot be saved because the status cannot be calculated for start_date: {$start_date} end_date {$end_date} join_date {$join_date} as at " . date('Y-m-d H:i:s')), 0, $errorParams);
         }
         $params['status_id'] = $calcStatus['id'];
     }
     // data cleanup only: all verifications on number of related memberships are done upstream in:
     // CRM_Member_BAO_Membership::createRelatedMemberships()
     // CRM_Contact_BAO_Relationship::relatedMemberships()
     if (isset($params['owner_membership_id'])) {
         unset($params['max_related']);
     } else {
         // if membership allows related, default max_related to value in membership_type
         if (!array_key_exists('max_related', $params) && !empty($params['membership_type_id'])) {
             $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($params['membership_type_id']);
             if (isset($membershipType['relationship_type_id'])) {
                 $params['max_related'] = CRM_Utils_Array::value('max_related', $membershipType);
             }
         }
     }
     $transaction = new CRM_Core_Transaction();
     $membership = self::add($params, $ids);
     if (is_a($membership, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $membership;
     }
     // add custom field values
     if (!empty($params['custom']) && is_array($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_membership', $membership->id);
     }
     $params['membership_id'] = $membership->id;
     if (isset($ids['membership'])) {
         $ids['contribution'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $membership->id, 'contribution_id', 'membership_id');
     }
     $params['skipLineItem'] = TRUE;
     //record contribution for this membership
     if (!empty($params['contribution_status_id']) && empty($params['relate_contribution_id'])) {
         $memInfo = array_merge($params, array('membership_id' => $membership->id));
         $params['contribution'] = self::recordMembershipContribution($memInfo, $ids);
     }
     if (!empty($params['lineItems'])) {
         $params['line_item'] = $params['lineItems'];
     }
     //do cleanup line  items if membership edit the Membership type.
     if (empty($ids['contribution']) && !empty($ids['membership'])) {
         CRM_Price_BAO_LineItem::deleteLineItems($ids['membership'], 'civicrm_membership');
     }
     if (!empty($params['line_item']) && empty($ids['contribution'])) {
         CRM_Price_BAO_LineItem::processPriceSet($membership->id, $params['line_item'], CRM_Utils_Array::value('contribution', $params));
     }
     //insert payment record for this membership
     if (!empty($params['relate_contribution_id'])) {
         CRM_Member_BAO_MembershipPayment::create(array('membership_id' => $membership->id, 'membership_type_id' => $membership->membership_type_id, 'contribution_id' => $params['relate_contribution_id']));
     }
     // add activity record only during create mode and renew mode
     // also add activity if status changed CRM-3984 and CRM-2521
     if (empty($ids['membership']) || $activityType == 'Membership Renewal' || !empty($params['createActivity'])) {
         if (!empty($ids['membership'])) {
             $data = array();
             CRM_Core_DAO::commonRetrieveAll('CRM_Member_DAO_Membership', 'id', $membership->id, $data, array('contact_id', 'membership_type_id', 'source'));
             $membership->contact_id = $data[$membership->id]['contact_id'];
             $membership->membership_type_id = $data[$membership->id]['membership_type_id'];
             $membership->source = CRM_Utils_Array::value('source', $data[$membership->id]);
         }
         // since we are going to create activity record w/
         // individual contact as a target in case of on behalf signup,
         // so get the copy of organization id, CRM-5551
         $realMembershipContactId = $membership->contact_id;
         // create activity source = individual, target = org CRM-4027
         $targetContactID = NULL;
         if (!empty($params['is_for_organization'])) {
             $targetContactID = $membership->contact_id;
             $membership->contact_id = CRM_Utils_Array::value('userId', $ids);
         }
         if (empty($membership->contact_id) && !empty($membership->owner_membership_id)) {
             $membership->contact_id = $realMembershipContactId;
         }
         if (!empty($ids['membership']) && $activityType != 'Membership Signup') {
             CRM_Activity_BAO_Activity::addActivity($membership, $activityType, $targetContactID);
         } elseif (empty($ids['membership'])) {
             CRM_Activity_BAO_Activity::addActivity($membership, $activityType, $targetContactID);
         }
         // we might created activity record w/ individual
         // contact as target so update membership object w/
         // original organization id, CRM-5551
         $membership->contact_id = $realMembershipContactId;
     }
     $transaction->commit();
     self::createRelatedMemberships($params, $membership);
     // do not add to recent items for import, CRM-4399
     if (empty($params['skipRecentView'])) {
         $url = CRM_Utils_System::url('civicrm/contact/view/membership', "action=view&reset=1&id={$membership->id}&cid={$membership->contact_id}&context=home");
         if (empty($membership->membership_type_id)) {
             // ie in an update situation.
             $membership->find(TRUE);
         }
         $membershipTypes = CRM_Member_PseudoConstant::membershipType();
         $title = CRM_Contact_BAO_Contact::displayName($membership->contact_id) . ' - ' . ts('Membership Type:') . ' ' . $membershipTypes[$membership->membership_type_id];
         $recentOther = array();
         if (CRM_Core_Permission::checkActionPermission('CiviMember', CRM_Core_Action::UPDATE)) {
             $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership', "action=update&reset=1&id={$membership->id}&cid={$membership->contact_id}&context=home");
         }
         if (CRM_Core_Permission::checkActionPermission('CiviMember', CRM_Core_Action::DELETE)) {
             $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership', "action=delete&reset=1&id={$membership->id}&cid={$membership->contact_id}&context=home");
         }
         // add the recently created Membership
         CRM_Utils_Recent::add($title, $url, $membership->id, 'Membership', $membership->contact_id, NULL, $recentOther);
     }
     return $membership;
 }
Example #26
0
 public function preProcess()
 {
     //custom data related code
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     parent::preProcess();
     // get price set id.
     $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
     $this->set('priceSetId', $this->_priceSetId);
     $this->assign('priceSetId', $this->_priceSetId);
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         $contributionID = CRM_Member_BAO_Membership::getMembershipContributionId($this->_id);
         // check delete permission for contribution
         if ($this->_id && $contributionID && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
             CRM_Core_Error::fatal(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
         }
     }
     if ($this->_action & CRM_Core_Action::ADD) {
         if (!CRM_Member_BAO_Membership::statusAvailabilty($this->_contactID)) {
             // all possible statuses are disabled - redirect back to contact form
             CRM_Core_Error::statusBounce(ts('There are no configured membership statuses. You cannot add this membership until your membership statuses are correctly configured'));
         }
         if ($this->_contactID) {
             //check whether contact has a current membership so we can alert user that they may want to do a renewal instead
             $contactMemberships = array();
             $memParams = array('contact_id' => $this->_contactID);
             CRM_Member_BAO_Membership::getValues($memParams, $contactMemberships, TRUE);
             $cMemTypes = array();
             foreach ($contactMemberships as $mem) {
                 $cMemTypes[] = $mem['membership_type_id'];
             }
             if (count($cMemTypes) > 0) {
                 $memberorgs = CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes($cMemTypes);
                 $mems_by_org = array();
                 foreach ($contactMemberships as $memid => $mem) {
                     $mem['member_of_contact_id'] = CRM_Utils_Array::value($mem['membership_type_id'], $memberorgs);
                     if (!empty($mem['membership_end_date'])) {
                         $mem['membership_end_date'] = CRM_Utils_Date::customformat($mem['membership_end_date']);
                     }
                     $mem['membership_type'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $mem['membership_type_id'], 'name', 'id');
                     $mem['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $mem['status_id'], 'label', 'id');
                     $mem['renewUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$mem['id']}&context=membership&selectedChild=member" . ($this->_mode ? '&mode=live' : ''));
                     $mem['membershipTab'] = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=member");
                     $mems_by_org[$mem['member_of_contact_id']] = $mem;
                 }
                 $this->assign('existingContactMemberships', $mems_by_org);
             }
         } else {
             // In standalone mode we don't have a contact id yet so lookup will be done client-side with this script:
             $resources = CRM_Core_Resources::singleton();
             $resources->addScriptFile('civicrm', 'templates/CRM/Member/Form/MembershipStandalone.js');
             $passthru = array('typeorgs' => CRM_Member_BAO_MembershipType::getMembershipTypeOrganization(), 'memtypes' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'membership_type_id'), 'statuses' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'status_id'));
             $resources->addSetting(array('existingMems' => $passthru));
         }
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = NULL;
     if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Membership');
     }
     $this->assign('onlinePendingContributionId', $this->_onlinePendingContributionId);
     $this->setPageTitle(ts('Membership'));
 }
Example #27
0
 /**
  * Takes an associative array and creates a contribution object.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param array $ids
  *   The array that holds all the db ids.
  *
  * @return CRM_Contribute_BAO_Contribution
  */
 public static function create(&$params, $ids = array())
 {
     $dateFields = array('receive_date', 'cancel_date', 'receipt_date', 'thankyou_date');
     foreach ($dateFields as $df) {
         if (isset($params[$df])) {
             $params[$df] = CRM_Utils_Date::isoToMysql($params[$df]);
         }
     }
     $transaction = new CRM_Core_Transaction();
     $contribution = self::add($params, $ids);
     if (is_a($contribution, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $contribution;
     }
     $params['contribution_id'] = $contribution->id;
     if (!empty($params['custom']) && is_array($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution', $contribution->id);
     }
     $session = CRM_Core_Session::singleton();
     if (!empty($params['note'])) {
         $noteParams = array('entity_table' => 'civicrm_contribution', 'note' => $params['note'], 'entity_id' => $contribution->id, 'contact_id' => $session->get('userID'), 'modified_date' => date('Ymd'));
         if (!$noteParams['contact_id']) {
             $noteParams['contact_id'] = $params['contact_id'];
         }
         CRM_Core_BAO_Note::add($noteParams);
     }
     // make entry in batch entity batch table
     if (!empty($params['batch_id'])) {
         // in some update cases we need to get extra fields - ie an update that doesn't pass in all these params
         $titleFields = array('contact_id', 'total_amount', 'currency', 'financial_type_id');
         $retrieveRequired = 0;
         foreach ($titleFields as $titleField) {
             if (!isset($contribution->{$titleField})) {
                 $retrieveRequired = 1;
                 break;
             }
         }
         if ($retrieveRequired == 1) {
             $contribution->find(TRUE);
         }
     }
     // Handle soft credit and / or link to personal campaign page
     $softIDs = CRM_Contribute_BAO_ContributionSoft::getSoftCreditIds($contribution->id);
     $pcpId = CRM_Contribute_BAO_ContributionSoft::getSoftCreditIds($contribution->id, TRUE);
     if ($pcp = CRM_Utils_Array::value('pcp', $params)) {
         $softParams = array();
         $softParams['id'] = $pcpId ? $pcpId : NULL;
         $softParams['contribution_id'] = $contribution->id;
         $softParams['pcp_id'] = $pcp['pcp_made_through_id'];
         $softParams['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcp['pcp_made_through_id'], 'contact_id');
         $softParams['currency'] = $contribution->currency;
         $softParams['amount'] = $contribution->total_amount;
         $softParams['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcp);
         $softParams['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcp);
         $softParams['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcp);
         $softParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
         $contributionSoft = CRM_Contribute_BAO_ContributionSoft::add($softParams);
         //Send notification to owner for PCP
         if ($contributionSoft->pcp_id && empty($pcpId)) {
             CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
         }
     } elseif (array_key_exists('pcp', $params) && $pcpId) {
         $deleteParams = array('id' => $pcpId);
         CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
     }
     if (isset($params['soft_credit'])) {
         $softParams = $params['soft_credit'];
         foreach ($softParams as $softParam) {
             if (!empty($softIDs)) {
                 $key = key($softIDs);
                 $softParam['id'] = $softIDs[$key];
                 unset($softIDs[$key]);
             }
             $softParam['contribution_id'] = $contribution->id;
             $softParam['currency'] = $contribution->currency;
             //case during Contribution Import when we assign soft contribution amount as contribution's total_amount by default
             if (empty($softParam['amount'])) {
                 $softParam['amount'] = $contribution->total_amount;
             }
             CRM_Contribute_BAO_ContributionSoft::add($softParam);
         }
         if (!empty($softIDs)) {
             foreach ($softIDs as $softID) {
                 if (!in_array($softID, $params['soft_credit_ids'])) {
                     $deleteParams = array('id' => $softID);
                     CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
                 }
             }
         }
     }
     $transaction->commit();
     // check if activity record exist for this contribution, if
     // not add activity
     $activity = new CRM_Activity_DAO_Activity();
     $activity->source_record_id = $contribution->id;
     $activity->activity_type_id = CRM_Core_OptionGroup::getValue('activity_type', 'Contribution', 'name');
     if (!$activity->find(TRUE)) {
         if (empty($contribution->contact_id)) {
             $contribution->find(TRUE);
         }
         CRM_Activity_BAO_Activity::addActivity($contribution, 'Offline');
     } else {
         // CRM-13237 : if activity record found, update it with campaign id of contribution
         CRM_Core_DAO::setFieldValue('CRM_Activity_BAO_Activity', $activity->id, 'campaign_id', $contribution->campaign_id);
     }
     // do not add to recent items for import, CRM-4399
     if (empty($params['skipRecentView'])) {
         $url = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=view&reset=1&id={$contribution->id}&cid={$contribution->contact_id}&context=home");
         // in some update cases we need to get extra fields - ie an update that doesn't pass in all these params
         $titleFields = array('contact_id', 'total_amount', 'currency', 'financial_type_id');
         $retrieveRequired = 0;
         foreach ($titleFields as $titleField) {
             if (!isset($contribution->{$titleField})) {
                 $retrieveRequired = 1;
                 break;
             }
         }
         if ($retrieveRequired == 1) {
             $contribution->find(TRUE);
         }
         $contributionTypes = CRM_Contribute_PseudoConstant::financialType();
         $title = CRM_Contact_BAO_Contact::displayName($contribution->contact_id) . ' - (' . CRM_Utils_Money::format($contribution->total_amount, $contribution->currency) . ' ' . ' - ' . $contributionTypes[$contribution->financial_type_id] . ')';
         $recentOther = array();
         if (CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::UPDATE)) {
             $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=update&reset=1&id={$contribution->id}&cid={$contribution->contact_id}&context=home");
         }
         if (CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::DELETE)) {
             $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=delete&reset=1&id={$contribution->id}&cid={$contribution->contact_id}&context=home");
         }
         // add the recently created Contribution
         CRM_Utils_Recent::add($title, $url, $contribution->id, 'Contribution', $contribution->contact_id, NULL, $recentOther);
     }
     return $contribution;
 }
Example #28
0
 /**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET);
     $this->assign('showFeeBlock', FALSE);
     $this->assign('feeBlockPaid', FALSE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->_eID = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     if ($this->_contactId) {
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
         $this->assign('displayName', $displayName);
         $this->setPageTitle(ts('Event Registration for %1', array(1 => $displayName)));
     } else {
         $this->setPageTitle(ts('Event Registration'));
     }
     // check the current path, if search based, then dont get participantID
     // CRM-5792
     $path = CRM_Utils_System::currentPath();
     if (strpos($path, 'civicrm/contact/search') === 0 || strpos($path, 'civicrm/group/search') === 0) {
         $this->_id = NULL;
     } else {
         $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     }
     if ($this->_id) {
         $this->assign('participantId', $this->_id);
         $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'id', 'participant_id');
         $this->assign('hasPayment', $this->_paymentId);
         // CRM-12615 - Get payment information from the primary registration
         if (!$this->_paymentId && $this->_action == CRM_Core_Action::UPDATE) {
             $registered_by_id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'registered_by_id', 'id');
             if ($registered_by_id) {
                 $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $registered_by_id, 'id', 'participant_id');
                 $this->assign('registeredByParticipantId', $registered_by_id);
             }
         }
     }
     // get the option value for custom data type
     $this->_roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
     $this->_eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
     $this->_eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
     $this->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID);
     $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
     $this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID);
     if ($this->_mode) {
         $this->assign('participantMode', $this->_mode);
         $this->assignPaymentRelatedVariables();
     }
     if ($this->_showFeeBlock) {
         $this->assign('showFeeBlock', TRUE);
         $isMonetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_showFeeBlock, 'is_monetary');
         if ($isMonetary) {
             $this->assign('feeBlockPaid', TRUE);
         }
         return CRM_Event_Form_EventFees::preProcess($this);
     }
     //check the mode when this form is called either single or as
     //search task action
     if ($this->_id || $this->_contactId || $this->_context == 'standalone') {
         $this->_single = TRUE;
         $this->assign('urlPath', 'civicrm/contact/view/participant');
         if (!$this->_id && !$this->_contactId) {
             $breadCrumbs = array(array('title' => ts('CiviEvent Dashboard'), 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1')));
             CRM_Utils_System::appendBreadCrumb($breadCrumbs);
         }
     } else {
         //set the appropriate action
         $context = $this->get('context');
         $urlString = 'civicrm/contact/search';
         $this->_action = CRM_Core_Action::BASIC;
         switch ($context) {
             case 'advanced':
                 $urlString = 'civicrm/contact/search/advanced';
                 $this->_action = CRM_Core_Action::ADVANCED;
                 break;
             case 'builder':
                 $urlString = 'civicrm/contact/search/builder';
                 $this->_action = CRM_Core_Action::PROFILE;
                 break;
             case 'basic':
                 $urlString = 'civicrm/contact/search/basic';
                 $this->_action = CRM_Core_Action::BASIC;
                 break;
             case 'custom':
                 $urlString = 'civicrm/contact/search/custom';
                 $this->_action = CRM_Core_Action::COPY;
                 break;
         }
         CRM_Contact_Form_Task::preProcessCommon($this);
         $this->_single = FALSE;
         $this->_contactId = NULL;
         //set ajax path, this used for custom data building
         $this->assign('urlPath', $urlString);
         $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     if (!$this->_id) {
         $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     }
     $this->assign('action', $this->_action);
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         // check delete permission for contribution
         if ($this->_id && $this->_paymentId && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
             CRM_Core_Error::fatal(ts("This Participant is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
         }
         return;
     }
     if ($this->_id) {
         // assign participant id to the template
         $this->assign('participantId', $this->_id);
         $this->_roleId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'role_id');
     }
     // when fee amount is included in form
     if (!empty($_POST['hidden_feeblock']) || !empty($_POST['send_receipt'])) {
         CRM_Event_Form_EventFees::preProcess($this);
         CRM_Event_Form_EventFees::buildQuickForm($this);
         CRM_Event_Form_EventFees::setDefaultValues($this);
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         // Custom data of type participant role
         // Note: Some earlier commits imply $_POST['role_id'] could be a comma separated string,
         //       not sure if that ever really happens
         if (!empty($_POST['role_id'])) {
             foreach ($_POST['role_id'] as $roleID) {
                 CRM_Custom_Form_CustomData::preProcess($this, $this->_roleCustomDataTypeID, $roleID, 1, 'Participant', $this->_id);
                 CRM_Custom_Form_CustomData::buildQuickForm($this);
                 CRM_Custom_Form_CustomData::setDefaultValues($this);
             }
         }
         //custom data of type participant event
         CRM_Custom_Form_CustomData::preProcess($this, $this->_eventNameCustomDataTypeID, $_POST['event_id'], 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
         // custom data of type participant event type
         $eventTypeId = NULL;
         if ($eventId = CRM_Utils_Array::value('event_id', $_POST)) {
             $eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'event_type_id', 'id');
         }
         CRM_Custom_Form_CustomData::preProcess($this, $this->_eventTypeCustomDataTypeID, $eventTypeId, 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
         //custom data of type participant, ( we 'null' to reset subType and subName)
         CRM_Custom_Form_CustomData::preProcess($this, 'null', 'null', 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = NULL;
     if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Event');
     }
     $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId);
 }
Example #29
0
 /**
  * takes an associative array and creates a pledge object
  *
  * @param array $params (reference ) an assoc array of name/value pairs
  *
  * @return object CRM_Pledge_BAO_Pledge object
  * @access public
  * @static
  */
 static function &create(&$params)
 {
     //FIXME: a cludgy hack to fix the dates to MySQL format
     $dateFields = array('start_date', 'create_date', 'acknowledge_date', 'modified_date', 'cancel_date', 'end_date');
     foreach ($dateFields as $df) {
         if (isset($params[$df])) {
             $params[$df] = CRM_Utils_Date::isoToMysql($params[$df]);
         }
     }
     $transaction = new CRM_Core_Transaction();
     $paymentParams = array();
     $paymentParams['status_id'] = CRM_Utils_Array::value('status_id', $params);
     if (CRM_Utils_Array::value('installment_amount', $params)) {
         $params['amount'] = $params['installment_amount'] * $params['installments'];
     }
     //get All Payments status types.
     $paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     //update the pledge status only if it does NOT come from form
     if (!isset($params['pledge_status_id'])) {
         if (isset($params['contribution_id'])) {
             if ($params['installments'] > 1) {
                 $params['status_id'] = array_search('In Progress', $paymentStatusTypes);
             }
         } else {
             if (!empty($params['id'])) {
                 $params['status_id'] = CRM_Pledge_BAO_PledgePayment::calculatePledgeStatus($params['id']);
             } else {
                 $params['status_id'] = array_search('Pending', $paymentStatusTypes);
             }
         }
     }
     $pledge = self::add($params);
     if (is_a($pledge, 'CRM_Core_Error')) {
         $pledge->rollback();
         return $pledge;
     }
     //handle custom data.
     if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_pledge', $pledge->id);
     }
     // skip payment stuff inedit mode
     if (!isset($params['id']) || CRM_Utils_Array::value('is_pledge_pending', $params)) {
         //if pledge is pending delete all payments and recreate.
         if (CRM_Utils_Array::value('is_pledge_pending', $params)) {
             CRM_Pledge_BAO_PledgePayment::deletePayments($pledge->id);
         }
         //building payment params
         $paymentParams['pledge_id'] = $pledge->id;
         $paymentKeys = array('amount', 'installments', 'scheduled_date', 'frequency_unit', 'currency', 'frequency_day', 'frequency_interval', 'contribution_id', 'installment_amount', 'actual_amount');
         foreach ($paymentKeys as $key) {
             $paymentParams[$key] = CRM_Utils_Array::value($key, $params, NULL);
         }
         CRM_Pledge_BAO_PledgePayment::create($paymentParams);
     }
     $transaction->commit();
     $url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$pledge->id}&cid={$pledge->contact_id}&context=home");
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$pledge->id}&cid={$pledge->contact_id}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$pledge->id}&cid={$pledge->contact_id}&context=home");
     }
     $contributionTypes = CRM_Contribute_PseudoConstant::financialType();
     $title = CRM_Contact_BAO_Contact::displayName($pledge->contact_id) . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($pledge->amount, $pledge->currency) . ' - ' . CRM_Utils_Array::value($pledge->financial_type_id, $contributionTypes) . ')';
     // add the recently created Pledge
     CRM_Utils_Recent::add($title, $url, $pledge->id, 'Pledge', $pledge->contact_id, NULL, $recentOther);
     return $pledge;
 }
Example #30
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     // Check permission for action.
     if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     parent::preProcess();
     $this->_formType = CRM_Utils_Array::value('formType', $_GET);
     // Get price set id.
     $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
     $this->set('priceSetId', $this->_priceSetId);
     $this->assign('priceSetId', $this->_priceSetId);
     // Get the pledge payment id
     $this->_ppID = CRM_Utils_Request::retrieve('ppid', 'Positive', $this);
     $this->assign('action', $this->_action);
     // Get the contribution id if update
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if (!empty($this->_id)) {
         $this->assign('contribID', $this->_id);
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     $this->_compId = CRM_Utils_Request::retrieve('compId', 'Positive', $this);
     $this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
     //set the contribution mode.
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->assign('contributionMode', $this->_mode);
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->assign('showCheckNumber', TRUE);
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     $this->assignPaymentRelatedVariables();
     if (in_array('CiviPledge', CRM_Core_Config::singleton()->enableComponents) && !$this->_formType) {
         $this->preProcessPledge();
     }
     if ($this->_id) {
         $this->showRecordLinkMesssage($this->_id);
     }
     $this->_values = array();
     // Current contribution id.
     if ($this->_id) {
         $this->assignPremiumProduct($this->_id);
         $this->buildValuesAndAssignOnline_Note_Type($this->_id, $this->_values);
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         $this->applyCustomData('Contribution', CRM_Utils_Array::value('financial_type_id', $_POST), $this->_id);
     }
     $this->_lineItems = array();
     if ($this->_id) {
         if (!empty($this->_compId) && $this->_compContext == 'participant') {
             $this->assign('compId', $this->_compId);
             $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_compId);
         } else {
             $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution', 1, TRUE, TRUE);
         }
         empty($lineItem) ? NULL : ($this->_lineItems[] = $lineItem);
     }
     $this->assign('lineItem', empty($this->_lineItems) ? FALSE : $this->_lineItems);
     // Set title
     if ($this->_mode) {
         $this->setPageTitle($this->_ppID ? ts('Credit Card Pledge Payment') : ts('Credit Card Contribution'));
     } else {
         $this->setPageTitle($this->_ppID ? ts('Pledge Payment') : ts('Contribution'));
     }
     if ($this->_id) {
         CRM_Contribute_Form_SoftCredit::preprocess($this);
     }
 }