Пример #1
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access 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();
     if ($this->_id) {
         $this->assign('entityID', $this->_id);
         $eventType = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'event_type_id');
     } else {
         $eventType = 'null';
     }
     $showLocation = false;
     // when custom data is included in this page
     if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         $this->set('type', 'Event');
         $this->set('subType', CRM_Utils_Array::value('event_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);
     }
 }
Пример #2
0
 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);
     }
     $this->_contactId = $this->get('contactId');
     $this->_relationshipId = $this->get('id');
     $this->_rtype = CRM_Utils_Request::retrieve('rtype', 'String', $this);
     $this->_rtypeId = CRM_Utils_Request::retrieve('relTypeId', 'String', $this);
     $this->_display_name_a = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'display_name');
     $this->assign('sort_name_a', $this->_display_name_a);
     $this->_caseId = CRM_Utils_Request::retrieve('caseID', 'Integer', $this);
     //get the relationship values.
     $this->_values = array();
     if ($this->_relationshipId) {
         $params = array('id' => $this->_relationshipId);
         CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_Relationship', $params, $this->_values);
     }
     if (!$this->_rtypeId) {
         $params = $this->controller->exportValues($this->_name);
         if (isset($params['relationship_type_id'])) {
             $this->_rtypeId = $params['relationship_type_id'];
         } else {
             if (!empty($this->_values)) {
                 $this->_rtypeId = $this->_values['relationship_type_id'] . '_' . $this->_rtype;
             }
         }
     }
     //get the relationship type id
     $this->_relationshipTypeId = str_replace(array('_a_b', '_b_a'), array('', ''), $this->_rtypeId);
     //get the relationship type
     if (!$this->_rtype) {
         $this->_rtype = str_replace($this->_relationshipTypeId . '_', '', $this->_rtypeId);
     }
     $this->assign("rtype", $this->_rtype);
     require_once 'CRM/Core/PseudoConstant.php';
     //use name as it remain constant, CRM-3336
     $this->_allRelationshipNames = CRM_Core_PseudoConstant::relationshipType('name');
     // when custom data is included in this page
     if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         CRM_Custom_Form_Customdata::preProcess($this);
         CRM_Custom_Form_Customdata::buildQuickForm($this);
         CRM_Custom_Form_Customdata::setDefaultValues($this);
     }
 }
Пример #3
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 public function preProcess()
 {
     $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET);
     $this->assign('showFeeBlock', false);
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->_participantId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     // 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->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID);
     $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
     if ($this->_mode) {
         $this->assign('participantMode', $this->_mode);
         $this->_paymentProcessor = array('billing_mode' => 1);
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
         foreach ($processors as $ppID => $label) {
             require_once 'CRM/Core/BAO/PaymentProcessor.php';
             require_once 'CRM/Core/Payment.php';
             $paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } else {
                 if ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                     continue;
                 } else {
                     $paymentObject =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $paymentProcessor, $this);
                     $error = $paymentObject->checkConfig();
                     if (empty($error)) {
                         $validProcessors[$ppID] = $label;
                     }
                     $paymentObject = null;
                 }
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
         } else {
             $this->_processors = $validProcessors;
         }
         // also check for billing information
         // get the billing location type
         $locationTypes =& CRM_Core_PseudoConstant::locationType();
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         $this->assign('bltID', $this->_bltID);
         $this->_fields = array();
         require_once 'CRM/Core/Payment/Form.php';
         CRM_Core_Payment_Form::setCreditCardFields($this);
         // this required to show billing block
         $this->assign_by_ref('paymentProcessor', $paymentProcessor);
         $this->assign('hidePayPalExpress', true);
     }
     if ($this->_showFeeBlock) {
         $this->assign('showFeeBlock', true);
         $this->assign('paid', true);
         return CRM_Event_Form_EventFees::preProcess($this);
     }
     //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);
     }
     //check the mode when this form is called either single or as
     //search task action
     if ($this->_participantId || $this->_contactID || $this->_context == 'standalone') {
         $this->_single = true;
         $this->assign('urlPath', 'civicrm/contact/view/participant');
         if (!$this->_participantId && !$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
         $advanced = null;
         $builder = null;
         $session =& CRM_Core_Session::singleton();
         $advanced = $session->get('isAdvanced');
         $builder = $session->get('isSearchBuilder');
         $searchType = "basic";
         if ($advanced == 1) {
             $this->_action = CRM_Core_Action::ADVANCED;
             $searchType = "advanced";
         } else {
             if ($advanced == 2 && ($builder = 1)) {
                 $this->_action = CRM_Core_Action::PROFILE;
                 $searchType = "builder";
             } else {
                 if ($advanced == 3) {
                     $searchType = "custom";
                 }
             }
         }
         parent::preProcess();
         $this->_single = false;
         $this->_contactID = null;
         //set ajax path, this used for custom data building
         $this->assign('urlPath', "civicrm/contact/search/{$searchType}");
         $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     $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) {
         return;
     }
     if ($this->_participantId) {
         // assign participant id to the template
         $this->assign('participantId', $this->_participantId);
         $this->_roleId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $this->_participantId, 'role_id');
     }
     // when fee amount is included in form
     if (CRM_Utils_Array::value('hidden_feeblock', $_POST) || CRM_Utils_Array::value('send_receipt', $_POST)) {
         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 (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         //custom data of type participant role
         CRM_Custom_Form_Customdata::preProcess($this, $this->_roleCustomDataTypeID, $_POST['role_id'], 1, 'Participant', $this->_participantId);
         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->_participantId);
         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->_participantId);
         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->_participantId && $this->_action & CRM_Core_Action::UPDATE) {
         require_once 'CRM/Contribute/BAO/Contribution.php';
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_participantId, 'Event');
     }
     $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId);
 }
Пример #4
0
 /** 
  * Function to build the form 
  * 
  * @return None 
  * @access public 
  */
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => '         ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     require_once 'CRM/Core/OptionGroup.php';
     require_once 'CRM/Grant/BAO/Grant.php';
     $attributes = CRM_Core_DAO::getAttribute('CRM_Grant_DAO_Grant');
     $grantType = CRM_Core_OptionGroup::values('grant_type');
     $this->add('select', 'grant_type_id', ts('Grant Type'), array('' => ts('- select -')) + $grantType, true);
     $grantStatus = CRM_Core_OptionGroup::values('grant_status');
     $this->add('select', 'status_id', ts('Grant Status'), array('' => ts('- select -')) + $grantStatus, true);
     $this->addDate('application_received_date', ts('Application Received'), false, array('formatType' => 'custom'));
     $this->addDate('decision_date', ts('Grant Decision'), false, array('formatType' => 'custom'));
     $this->addDate('money_transfer_date', ts('Money Transferred'), false, array('formatType' => 'custom'));
     $this->addDate('grant_due_date', ts('Grant Report Due'), false, array('formatType' => 'custom'));
     $this->addElement('checkbox', 'grant_report_received', ts('Grant Report Received?'), null);
     $this->add('textarea', 'rationale', ts('Rationale'), $attributes['rationale']);
     $this->add('text', 'amount_total', ts('Amount Requested'), null, true);
     $this->addRule('amount_total', ts('Please enter a valid amount.'), 'money');
     $this->add('text', 'amount_granted', ts('Amount Granted'));
     $this->addRule('amount_granted', ts('Please enter a valid amount.'), 'money');
     $this->add('text', 'amount_requested', ts('Amount Requested<br />(original currency)'));
     $this->addRule('amount_requested', ts('Please enter a valid amount.'), 'money');
     $noteAttrib = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
     $this->add('textarea', 'note', ts('Notes'), $noteAttrib['note']);
     //build custom data
     CRM_Custom_Form_Customdata::buildQuickForm($this);
     // add attachments part
     require_once 'CRM/Core/BAO/File.php';
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_grant', $this->_id);
     // make this form an upload since we dont know if the custom data injected dynamically
     // is of type file etc $uploadNames = $this->get( 'uploadNames' );
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save and New'), 'js' => array('onclick' => "return verify( );"), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     if ($this->_context == 'standalone') {
         require_once 'CRM/Contact/Form/NewContact.php';
         CRM_Contact_Form_NewContact::buildQuickForm($this);
         $this->addFormRule(array('CRM_Grant_Form_Grant', 'formRule'), $this);
     }
 }
Пример #5
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 public function preProcess()
 {
     $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET);
     $this->assign('showFeeBlock', false);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     if ($this->_contactId) {
         require_once 'CRM/Contact/BAO/Contact.php';
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
         $this->assign('displayName', $displayName);
     }
     // 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) {
         $this->_id = null;
     } else {
         $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     }
     require_once 'CRM/Event/DAO/ParticipantPayment.php';
     if ($this->_id) {
         $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'id', 'participant_id');
     }
     // get the option value for custom data type
     require_once 'CRM/Core/OptionGroup.php';
     $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->_paymentProcessor = array('billing_mode' => 1);
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
         foreach ($processors as $ppID => $label) {
             require_once 'CRM/Core/BAO/PaymentProcessor.php';
             require_once 'CRM/Core/Payment.php';
             $paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } else {
                 if ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                     continue;
                 } else {
                     $paymentObject =& CRM_Core_Payment::singleton($this->_mode, $paymentProcessor, $this);
                     $error = $paymentObject->checkConfig();
                     if (empty($error)) {
                         $validProcessors[$ppID] = $label;
                     }
                     $paymentObject = null;
                 }
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
         } else {
             $this->_processors = $validProcessors;
         }
         // also check for billing information
         // get the billing location type
         $locationTypes =& CRM_Core_PseudoConstant::locationType();
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         $this->assign('bltID', $this->_bltID);
         $this->_fields = array();
         require_once 'CRM/Core/Payment/Form.php';
         CRM_Core_Payment_Form::setCreditCardFields($this);
         // this required to show billing block
         $this->assign_by_ref('paymentProcessor', $paymentProcessor);
         $this->assign('hidePayPalExpress', true);
     }
     if ($this->_showFeeBlock) {
         $this->assign('showFeeBlock', true);
         $this->assign('paid', true);
         return CRM_Event_Form_EventFees::preProcess($this);
     }
     //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);
     }
     //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;
         }
         parent::preProcess();
         $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);
     $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) {
         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 (CRM_Utils_Array::value('hidden_feeblock', $_POST) || CRM_Utils_Array::value('send_receipt', $_POST)) {
         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 (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         //custom data of type participant role
         if ($_POST['role_id']) {
             foreach ($_POST['role_id'] as $k => $val) {
                 $roleID = $val;
                 CRM_Custom_Form_Customdata::preProcess($this, $this->_roleCustomDataTypeID, $k, 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) {
         require_once 'CRM/Contribute/BAO/Contribution.php';
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Event');
     }
     $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId);
     $roleIds = CRM_Event_PseudoConstant::participantRole();
     if (!empty($roleIds)) {
         $query = "\nSELECT civicrm_custom_group.name as name, \n       civicrm_custom_group.id as id,\n       extends_entity_column_value as value\n  FROM civicrm_custom_group\n WHERE ( extends_entity_column_value REGEXP '[[:<:]]" . implode('[[:>:]]|[[:<:]]', array_keys($roleIds)) . "[[:>:]]' \n    OR extends_entity_column_value IS NULL )\n   AND extends_entity_column_id = '{$this->_roleCustomDataTypeID}' \n   AND extends = 'Participant'\n   AND is_active = 1";
         $dao =& CRM_Core_DAO::executeQuery($query);
         while ($dao->fetch()) {
             if ($dao->value) {
                 $getRole = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->value);
                 foreach ($getRole as $r) {
                     if (!$r) {
                         continue;
                     }
                     if (isset($this->_participantRoleIds[$r])) {
                         $this->_participantRoleIds[$r] .= ',' . $dao->name;
                     } else {
                         $this->_participantRoleIds[$r] = $dao->name;
                     }
                 }
             } else {
                 if (isset($this->_participantRoleIds[0])) {
                     $this->_participantRoleIds[0] .= ',' . $dao->name;
                 } else {
                     $this->_participantRoleIds[0] = $dao->name;
                 }
             }
         }
         $dao->free();
     }
     foreach ($roleIds as $k => $v) {
         if (!isset($this->_participantRoleIds[$k])) {
             $this->_participantRoleIds[$k] = '';
         }
     }
     $this->assign('participantRoleIds', $this->_participantRoleIds);
 }
Пример #6
0
 /** 
  * Function to build the form 
  * 
  * @return None 
  * @access public 
  */
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     if ($this->_context == 'standalone') {
         require_once 'CRM/Contact/Form/NewContact.php';
         CRM_Contact_Form_NewContact::buildQuickForm($this);
     }
     $showAdditionalInfo = false;
     $this->_formType = CRM_Utils_Array::value('formType', $_GET);
     //fix to load honoree pane on edit.
     $defaults = array();
     if ($this->_honorID) {
         $defaults['hidden_Honoree'] = 1;
     }
     $paneNames = array('Honoree Information' => 'Honoree', 'Payment Reminders' => 'PaymentReminders');
     foreach ($paneNames as $name => $type) {
         $urlParams = "snippet=4&formType={$type}";
         $allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/contact/view/pledge', $urlParams), 'open' => 'false', 'id' => $type);
         //see if we need to include this paneName in the current form
         if ($this->_formType == $type || CRM_Utils_Array::value("hidden_{$type}", $_POST) || CRM_Utils_Array::value("hidden_{$type}", $defaults)) {
             $showAdditionalInfo = true;
             $allPanes[$name]['open'] = 'true';
         }
         eval('CRM_Contribute_Form_AdditionalInfo::build' . $type . '( $this );');
     }
     $this->assign('allPanes', $allPanes);
     $this->assign('showAdditionalInfo', $showAdditionalInfo);
     if ($this->_formType) {
         $this->assign('formType', $this->_formType);
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     //pledge fields.
     $attributes = CRM_Core_DAO::getAttribute('CRM_Pledge_DAO_Pledge');
     $this->assign('isPending', $this->_isPending);
     $js = array('onblur' => "calculatedPaymentAmount( );", 'onkeyup' => "calculatedPaymentAmount( );");
     $element =& $this->add('text', 'amount', ts('Total Pledge Amount'), array_merge($attributes['pledge_amount'], $js), true);
     $this->addRule('amount', ts('Please enter a valid monetary amount.'), 'money');
     if ($this->_id && !$this->_isPending) {
         $element->freeze();
     }
     $element =& $this->add('text', 'installments', ts('To be paid in'), array_merge($attributes['installments'], $js), true);
     $this->addRule('installments', ts('Please enter a valid number of installments.'), 'positiveInteger');
     if ($this->_id && !$this->_isPending) {
         $element->freeze();
     }
     $element =& $this->add('text', 'frequency_interval', ts('every'), $attributes['frequency_interval'], true);
     $this->addRule('frequency_interval', ts('Please enter a number for frequency (e.g. every "3" months).'), 'positiveInteger');
     if ($this->_id && !$this->_isPending) {
         $element->freeze();
     }
     // Fix frequency unit display for use with frequency_interval
     $freqUnitsDisplay = array();
     foreach ($this->_freqUnits as $val => $label) {
         $freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $val));
     }
     $element =& $this->add('select', 'frequency_unit', ts('Frequency'), array('' => ts('- select -')) + $freqUnitsDisplay, true);
     if ($this->_id && !$this->_isPending) {
         $element->freeze();
     }
     $element =& $this->add('text', 'frequency_day', ts('Payments are due on the'), $attributes['frequency_day'], true);
     $this->addRule('frequency_day', ts('Please enter a valid payment due day.'), 'positiveInteger');
     if ($this->_id && !$this->_isPending) {
         $element->freeze();
     }
     $this->add('text', 'eachPaymentAmount', ts('each'), array('size' => 10, 'style' => "background-color:#EBECE4", 'READONLY'));
     //add various dates
     if (!$this->_id || $this->_isPending) {
         $this->addDate('create_date', ts('Pledge Made'));
         $this->addDate('start_date', ts('Payments Start'));
     }
     if ($this->_id && !$this->_isPending) {
         $eachPaymentAmount = floor($this->_values['amount'] / $this->_values['installments']);
         $this->assign("eachPaymentAmount", $eachPaymentAmount);
         $this->assign("hideCalender", true);
     }
     if (CRM_Utils_Array::value('status_id', $this->_values) != array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus())) {
         $this->addElement('checkbox', 'is_acknowledge', ts('Send Acknowledgment?'), null, array('onclick' => "return showHideByValue('is_acknowledge','','acknowledgeDate','table-row','radio',true);"));
     }
     $this->addDate('acknowledge_date', ts('Acknowledgment Date'));
     $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), true);
     $pageIds = array();
     CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgeBlock', 'entity_table', 'civicrm_contribution_page', $pageIds, array('entity_id'));
     $pages = CRM_Contribute_PseudoConstant::contributionPage();
     $pledgePages = array();
     foreach ($pageIds as $key => $value) {
         $pledgePages[$value['entity_id']] = $pages[$value['entity_id']];
     }
     $ele = $this->add('select', 'contribution_page_id', ts('Self-service Payments Page'), array('' => ts('- select -')) + $pledgePages);
     require_once "CRM/Core/BAO/Preferences.php";
     $mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences();
     $this->assign('outBound_option', $mailingInfo['outBound_option']);
     //build custom data
     CRM_Custom_Form_Customdata::buildQuickForm($this);
     // make this form an upload since we dont know if the custom data injected dynamically
     // is of type file etc $uploadNames = $this->get( 'uploadNames' );
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => array('onclick' => "return verify( );"), 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save and New'), 'js' => array('onclick' => "return verify( );"), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->addFormRule(array('CRM_Pledge_Form_Pledge', 'formRule'), $this);
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
     }
 }
Пример #7
0
 /**
  * Function to actually build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_action == CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Group'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'title', ts('Name') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), true);
     $this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $this->_id, 'title'));
     $this->add('textarea', 'description', ts('Description') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
     require_once 'CRM/Core/OptionGroup.php';
     $groupTypes = CRM_Core_OptionGroup::values('group_type', true);
     $config =& CRM_Core_Config::singleton();
     if (isset($this->_id) && CRM_Utils_Array::value('saved_search_id', $this->_groupValues) || $config->userFramework == 'Joomla') {
         unset($groupTypes['Access Control']);
     }
     if (!CRM_Core_Permission::access('CiviMail')) {
         unset($groupTypes['Mailing List']);
     }
     if (!empty($groupTypes)) {
         $this->addCheckBox('group_type', ts('Group Type'), $groupTypes, null, null, null, null, '&nbsp;&nbsp;&nbsp;');
     }
     $this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::ufVisibility(true), true);
     $groupNames =& CRM_Core_PseudoConstant::group();
     $parentGroups = array();
     if (isset($this->_id) && CRM_Utils_Array::value('parents', $this->_groupValues)) {
         $parentGroupIds = explode(',', $this->_groupValues['parents']);
         foreach ($parentGroupIds as $parentGroupId) {
             $parentGroups[$parentGroupId] = $groupNames[$parentGroupId];
             $this->addElement('checkbox', "remove_parent_group_{$parentGroupId}", $groupNames[$parentGroupId]);
         }
     }
     $this->assign_by_ref('parent_groups', $parentGroups);
     if (isset($this->_id)) {
         require_once 'CRM/Contact/BAO/GroupNestingCache.php';
         $potentialParentGroupIds = CRM_Contact_BAO_GroupNestingCache::getPotentialCandidates($this->_id, $groupNames);
     } else {
         $potentialParentGroupIds = array_keys($groupNames);
     }
     $parentGroupSelectValues = array('' => '- ' . ts('select') . ' -');
     foreach ($potentialParentGroupIds as $potentialParentGroupId) {
         if (array_key_exists($potentialParentGroupId, $groupNames)) {
             $parentGroupSelectValues[$potentialParentGroupId] = $groupNames[$potentialParentGroupId];
         }
     }
     if (count($parentGroupSelectValues) > 1) {
         if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE) {
             $required = empty($parentGroups) ? true : false;
             $required = $this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id) ? false : $required;
         } else {
             $required = false;
         }
         $this->add('select', 'parents', ts('Add Parent'), $parentGroupSelectValues, $required);
     }
     if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE && CRM_Core_Permission::check('administer Multiple Organizations')) {
         //group organization Element
         $groupOrgDataURL = CRM_Utils_System::url('civicrm/ajax/search', 'org=1', false, null, false);
         $this->assign('groupOrgDataURL', $groupOrgDataURL);
         $this->addElement('text', 'organization', ts('Organization'), '');
         $this->addElement('hidden', 'organization_id', '', array('id' => 'organization_id'));
     }
     //build custom data
     CRM_Custom_Form_Customdata::buildQuickForm($this);
     $this->addButtons(array(array('type' => 'upload', 'name' => $this->_action == CRM_Core_Action::ADD ? ts('Continue') : ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE) {
         $doParentCheck = $this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id) ? false : true;
     } else {
         $doParentCheck = false;
     }
     if ($doParentCheck) {
         $this->addFormRule(array('CRM_Group_Form_Edit', 'formRule'), $parentGroups);
     }
 }
Пример #8
0
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) {
         $title = 'Delete';
         if ($this->_action & CRM_Core_Action::RENEW) {
             $title = 'Restore';
         }
         $this->addButtons(array(array('type' => 'next', 'name' => $title, 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     CRM_Custom_Form_Customdata::buildQuickForm($this);
     // we don't want to show button on top of custom form
     $this->assign('noPreCustomButton', true);
     $this->add('text', 'activity_subject', ts('Subject'), array_merge(CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'subject'), array('maxlength' => '128')), true);
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}::buildQuickForm( \$this );");
 }
Пример #9
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);
     }
     // action
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     // 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'));
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     if ($this->_id) {
         $this->_memType = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $this->_id, "membership_type_id");
     }
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     if ($this->_mode) {
         $this->assign('membershipMode', $this->_mode);
         $this->_paymentProcessor = array('billing_mode' => 1);
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
         foreach ($processors as $ppID => $label) {
             require_once 'CRM/Core/BAO/PaymentProcessor.php';
             require_once 'CRM/Core/Payment.php';
             $paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } else {
                 if ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                     continue;
                 } else {
                     $paymentObject =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $paymentProcessor, $this);
                     $error = $paymentObject->checkConfig();
                     if (empty($error)) {
                         $validProcessors[$ppID] = $label;
                     }
                     $paymentObject = null;
                 }
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
         } else {
             $this->_processors = $validProcessors;
         }
         // also check for billing information
         // get the billing location type
         $locationTypes =& CRM_Core_PseudoConstant::locationType();
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         $this->assign('bltID', $this->_bltID);
         $this->_fields = array();
         require_once 'CRM/Core/Payment/Form.php';
         CRM_Core_Payment_Form::setCreditCardFields($this);
         // this required to show billing block
         $this->assign_by_ref('paymentProcessor', $paymentProcessor);
         $this->assign('hidePayPalExpress', true);
     }
     //check whether membership status present or not
     if ($this->_action & CRM_Core_Action::ADD) {
         CRM_Member_BAO_Membership::statusAvilability($this->_contactID);
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         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) {
         require_once 'CRM/Contribute/BAO/Contribution.php';
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Membership');
     }
     $this->assign('onlinePendingContributionId', $this->_onlinePendingContributionId);
     parent::preProcess();
 }
Пример #10
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 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'));
     }
     $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);
     }
     $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);
     //get the contact id
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     //get the action.
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
     $this->assign('action', $this->_action);
     //get the contribution id if update
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     //set the contribution mode.
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->assign('contributionMode', $this->_mode);
     $this->_paymentProcessor = array('billing_mode' => 1);
     $this->assign('showCheckNumber', false);
     //ensure that processor has a valid config
     //only valid processors get display to user
     if ($this->_mode) {
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
         foreach ($processors as $ppID => $label) {
             require_once 'CRM/Core/BAO/PaymentProcessor.php';
             require_once 'CRM/Core/Payment.php';
             $paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } else {
                 if ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                     continue;
                 } else {
                     $paymentObject =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $paymentProcessor, $this);
                     $error = $paymentObject->checkConfig();
                     if (empty($error)) {
                         $validProcessors[$ppID] = $label;
                     }
                     $paymentObject = null;
                 }
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('You will need to configure the %1 settings for your Payment Processor before you can submit credit card transactions.', array(1 => $this->_mode)));
         } else {
             $this->_processors = $validProcessors;
         }
     }
     // this required to show billing block
     $this->assign_by_ref('paymentProcessor', $paymentProcessor);
     $this->assign('hidePayPalExpress', true);
     if ($this->_contactID) {
         require_once 'CRM/Contact/BAO/Contact/Location.php';
         list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
         $this->assign('displayName', $this->userDisplayName);
     }
     // also check for billing information
     // get the billing location type
     $locationTypes =& CRM_Core_PseudoConstant::locationType();
     $this->_bltID = array_search('Billing', $locationTypes);
     if (!$this->_bltID) {
         CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
     }
     $this->set('bltID', $this->_bltID);
     $this->assign('bltID', $this->_bltID);
     $this->_fields = array();
     require_once 'CRM/Core/Payment.php';
     require_once 'CRM/Core/Payment/Form.php';
     // payment fields are depending on payment type
     if ($this->_processors['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
         CRM_Core_Payment_Form::setDirectDebitFields($this);
     } else {
         CRM_Core_Payment_Form::setCreditCardFields($this);
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $config =& CRM_Core_Config::singleton();
     if (in_array("CiviPledge", $config->enableComponents) && !$this->_formType) {
         //get the payment values associated with given pledge payment id OR check for payments due.
         $this->_pledgeValues = array();
         if ($this->_ppID) {
             $payParams = array('id' => $this->_ppID);
             require_once "CRM/Pledge/BAO/Payment.php";
             CRM_Pledge_BAO_Payment::retrieve($payParams, $this->_pledgeValues['pledgePayment']);
             $this->_pledgeID = CRM_Utils_Array::value('pledge_id', $this->_pledgeValues['pledgePayment']);
             $paymentStatusID = CRM_Utils_Array::value('status_id', $this->_pledgeValues['pledgePayment']);
             $this->_id = CRM_Utils_Array::value('contribution_id', $this->_pledgeValues['pledgePayment']);
             //get all status
             $allStatus = CRM_Contribute_PseudoConstant::contributionStatus();
             if (!($paymentStatusID == array_search('Pending', $allStatus) || $paymentStatusID == array_search('Overdue', $allStatus))) {
                 CRM_Core_Error::fatal(ts("Pledge payment status should be 'Pending' or  'Overdue'."));
             }
             //get the pledge values associated with given pledge payment.
             require_once 'CRM/Pledge/BAO/Pledge.php';
             $ids = array();
             $pledgeParams = array('id' => $this->_pledgeID);
             CRM_Pledge_BAO_Pledge::getValues($pledgeParams, $this->_pledgeValues, $ids);
             $this->assign('ppID', $this->_ppID);
         } else {
             // Not making a pledge payment, so check if pledge payment(s) are due for this contact so we can alert the user. CRM-5206
             if (isset($this->_contactID)) {
                 require_once "CRM/Pledge/BAO/Pledge.php";
                 $contactPledges = array();
                 $contactPledges = CRM_Pledge_BAO_Pledge::getContactPledges($this->_contactID);
                 if (!empty($contactPledges)) {
                     $payments = null;
                     $paymentsDue = null;
                     $multipleDue = false;
                     require_once "CRM/Pledge/BAO/Payment.php";
                     foreach ($contactPledges as $key => $pledgeId) {
                         $payments = CRM_Pledge_BAO_Payment::getOldestPledgePayment($pledgeId);
                         if ($payments) {
                             if ($paymentsDue) {
                                 $multipleDue = true;
                                 break;
                             } else {
                                 $paymentsDue = $payments;
                             }
                         }
                     }
                     if ($multipleDue) {
                         // Show link to pledge tab since more than one pledge has a payment due
                         $pledgeTab = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=pledge");
                         CRM_Core_Session::setStatus(ts('This contact has pending or overdue pledge payments. <a href="%1">Click here to view their Pledges tab</a> and verify whether this contribution should be applied as a pledge payment.', array(1 => $pledgeTab)));
                     } else {
                         if ($paymentsDue) {
                             // Show user link to oldest Pending or Overdue pledge payment
                             require_once 'CRM/Utils/Date.php';
                             require_once 'CRM/Utils/Money.php';
                             $ppAmountDue = CRM_Utils_Money::format($payments['amount']);
                             $ppSchedDate = CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Payment', $payments['id'], 'scheduled_date'));
                             if ($this->_mode) {
                                 $ppUrl = CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&action=add&cid={$this->_contactID}&ppid={$payments['id']}&context=pledge&mode=live");
                             } else {
                                 $ppUrl = CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&action=add&cid={$this->_contactID}&ppid={$payments['id']}&context=pledge");
                             }
                             CRM_Core_Session::setStatus(ts('This contact has a pending or overdue pledge payment of %2 which is scheduled for %3. <a href="%1">Click here to apply this contribution as a pledge payment<a/>.', array(1 => $ppUrl, 2 => $ppAmountDue, 3 => $ppSchedDate)));
                         }
                     }
                 }
             }
         }
     }
     $this->_values = array();
     // current contribution id
     if ($this->_id) {
         $this->_online = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_FinancialTrxn', $this->_id, 'id', 'contribution_id');
         if ($this->_online) {
             $this->assign('isOnline', true);
         }
         //to get Premium id
         $sql = "\nSELECT *\nFROM   civicrm_contribution_product\nWHERE  contribution_id = {$this->_id}\n";
         $dao = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
         if ($dao->fetch()) {
             $this->_premiumID = $dao->id;
             $this->_productDAO = $dao;
         }
         $dao->free();
         $ids = array();
         $params = array('id' => $this->_id);
         require_once "CRM/Contribute/BAO/Contribution.php";
         CRM_Contribute_BAO_Contribution::getValues($params, $this->_values, $ids);
         //unset the honor type id:when delete the honor_contact_id
         //and edit the contribution, honoree infomation pane open
         //since honor_type_id is present
         if (!CRM_Utils_Array::value('honor_contact_id', $this->_values)) {
             unset($this->_values['honor_type_id']);
         }
         //to get note id
         require_once 'CRM/Core/BAO/Note.php';
         $daoNote =& new CRM_Core_BAO_Note();
         $daoNote->entity_table = 'civicrm_contribution';
         $daoNote->entity_id = $this->_id;
         if ($daoNote->find(true)) {
             $this->_noteID = $daoNote->id;
             $this->_values['note'] = $daoNote->note;
         }
         $this->_contributionType = $this->_values['contribution_type_id'];
         $csParams = array('contribution_id' => $this->_id);
         $softCredit = CRM_Contribute_BAO_Contribution::getSoftContribution($csParams, true);
         if (CRM_Utils_Array::value('soft_credit_to', $softCredit)) {
             $softCredit['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $softCredit['soft_credit_to'], 'sort_name');
         }
         $this->_values['soft_credit_to'] = $softCredit['sort_name'];
         $this->_values['softID'] = $softCredit['soft_credit_id'];
         $this->_values['soft_contact_id'] = $softCredit['soft_credit_to'];
         $this->_values['pcp_made_through_id'] = $softCredit['pcp_id'];
         $this->_values['pcp_display_in_roll'] = $softCredit['pcp_display_in_roll'];
         $this->_values['pcp_roll_nickname'] = $softCredit['pcp_roll_nickname'];
         $this->_values['pcp_personal_note'] = $softCredit['pcp_personal_note'];
         //display check number field only if its having value or its offline mode.
         if (CRM_Utils_Array::value('payment_instrument_id', $this->_values) == CRM_Core_OptionGroup::getValue('payment_instrument', 'Check', 'name') || CRM_Utils_Array::value('check_number', $this->_values)) {
             $this->assign('showCheckNumber', true);
         }
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         $this->set('type', 'Contribution');
         $this->set('subType', $this->_contributionType);
         $this->set('entityId', $this->_id);
         CRM_Custom_Form_Customdata::preProcess($this);
         CRM_Custom_Form_Customdata::buildQuickForm($this);
         CRM_Custom_Form_Customdata::setDefaultValues($this);
     }
     require_once 'CRM/Price/BAO/Set.php';
     $this->_lineItems = array();
     if ($this->_id && ($priceSetId = CRM_Price_BAO_Set::getFor('civicrm_contribution', $this->_id))) {
         $this->_priceSetId = $priceSetId;
         require_once 'CRM/Price/BAO/LineItem.php';
         $this->_lineItems[] = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution');
     }
     $this->assign('lineItem', empty($this->_lineItems) ? false : $this->_lineItems);
 }
Пример #11
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 None
  */
 function setDefaultValues(&$form, &$defaults)
 {
     $defaults += CRM_Custom_Form_Customdata::setDefaultValues($form);
 }