public function preProcess() { parent::preProcess(); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this); if ($this->_action & CRM_Core_Action::UPDATE) { CRM_Utils_System::setTitle(ts('Configure Survey') . ' - ' . $this->_surveyTitle); } // 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); } if ($this->_name != 'Petition') { $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'); CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey Dashboard'), 'url' => $url))); } $this->_values = $this->get('values'); if (!is_array($this->_values)) { $this->_values = array(); if ($this->_surveyId) { $params = array('id' => $this->_surveyId); CRM_Campaign_BAO_Survey::retrieve($params, $this->_values); } $this->set('values', $this->_values); } $this->assign('action', $this->_action); $this->assign('surveyId', $this->_surveyId); // for custom data $this->assign('entityID', $this->_surveyId); }
public function preProcess() { if (!CRM_Campaign_BAO_Campaign::accessCampaign()) { CRM_Utils_System::permissionDenied(); } $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST'); $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); if ($this->_surveyId) { $this->_single = TRUE; $params = array('id' => $this->_surveyId); CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo); $this->_surveyTitle = $surveyInfo['title']; $this->assign('surveyTitle', $this->_surveyTitle); CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle))); } $this->assign('action', $this->_action); $this->assign('surveyId', $this->_surveyId); // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { $this->set('type', 'Event'); $this->set('entityId', $this->_surveyId); CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } // CRM-11480, CRM-11682 // Preload libraries required by the "Questions" tab CRM_UF_Page_ProfileEditor::registerProfileScripts(); CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel')); CRM_Campaign_Form_Survey_TabHeader::build($this); }
public function preProcess() { if (!CRM_Campaign_BAO_Campaign::accessCampaign()) { CRM_Utils_System::permissionDenied(); } $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this); if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) { $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); if ($this->_action & CRM_Core_Action::UPDATE) { CRM_Utils_System::setTitle(ts('Edit Survey')); } else { CRM_Utils_System::setTitle(ts('Delete Survey')); } } $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); } // 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); } $session = CRM_Core_Session::singleton(); $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'); $session->pushUserContext($url); $this->_values = $this->get('values'); if (!is_array($this->_values)) { $this->_values = array(); if ($this->_surveyId) { $params = array('id' => $this->_surveyId); CRM_Campaign_BAO_Survey::retrieve($params, $this->_values); } $this->set('values', $this->_values); } $this->assign('action', $this->_action); $this->assign('surveyId', $this->_surveyId); // for custom data $this->assign('entityID', $this->_surveyId); if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) { $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); if ($this->_action & CRM_Core_Action::UPDATE) { CRM_Utils_System::setTitle(ts('Edit Petition')); } else { CRM_Utils_System::setTitle(ts('Delete Petition')); } } $session = CRM_Core_Session::singleton(); $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=petition'); $session->pushUserContext($url); CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Petition Dashboard'), 'url' => $url))); }
/** * build the form elements for CustomData object * * @param CRM_Core_Form $form reference to the form object * * @return void * @access public * @static */ static function buildQuickForm(&$form) { CRM_Custom_Form_CustomData::buildQuickForm($form); //build custom data. $contactSubType = NULL; if (CRM_Utils_Array::value("hidden_custom", $_POST) && CRM_Utils_Array::value('contact_sub_type', $_POST)) { $contactSubType = $_POST['contact_sub_type']; } else { $contactSubType = CRM_Utils_Array::value('contact_sub_type', $form->_values); } $form->assign('contactType', $form->_contactType); $form->assign('contactSubType', $contactSubType); }
/** * Set variables up before form is built. */ public function preProcess() { 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 (!empty($_POST['hidden_custom'])) { $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, NULL, $this->_eventType, 1, 'Event', $this->_id); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } }
/** * Build the form object elements for CustomData object. * * @param CRM_Core_Form $form * Reference to the form object. */ public static function buildQuickForm(&$form) { if (!empty($form->_submitValues)) { if ($customValueCount = CRM_Utils_Array::value('hidden_custom_group_count', $form->_submitValues)) { if (is_array($customValueCount)) { if (array_key_exists(0, $customValueCount)) { unset($customValueCount[0]); } $form->_customValueCount = $customValueCount; $form->assign('customValueCount', $customValueCount); } } } CRM_Custom_Form_CustomData::buildQuickForm($form); //build custom data. $contactSubType = NULL; if (!empty($_POST["hidden_custom"]) && !empty($_POST['contact_sub_type'])) { $contactSubType = $_POST['contact_sub_type']; } else { $contactSubType = CRM_Utils_Array::value('contact_sub_type', $form->_values); } $form->assign('contactType', $form->_contactType); $form->assign('contactSubType', $contactSubType); }
/** * Pre-process form. * * @throws \Exception */ public function preProcess() { // This string makes up part of the class names, differentiating them (not sure why) from the membership fields. $this->assign('formClass', 'membershiprenew'); parent::preProcess(); // check for edit permission if (!CRM_Core_Permission::check('edit memberships')) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } $this->assign('endDate', CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'end_date'))); $this->assign('membershipStatus', CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'status_id'), 'name')); if ($this->_mode) { $membershipFee = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee'); if (!$membershipFee) { $statusMsg = ts('Membership Renewal using a credit card requires a Membership fee. Since there is no fee associated with the selected membership type, you can use the normal renewal mode.'); CRM_Core_Session::setStatus($statusMsg, '', 'info'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership")); } } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_memType, 1, 'Membership', $this->_id); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } CRM_Utils_System::setTitle(ts('Renew Membership')); parent::preProcess(); }
/** * Build the form object. */ 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; } if ($this->_context == 'standalone') { $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE); } $showAdditionalInfo = FALSE; $this->_formType = CRM_Utils_Array::value('formType', $_GET); $defaults = array(); $paneNames = array('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 || !empty($_POST["hidden_{$type}"]) || CRM_Utils_Array::value("hidden_{$type}", $defaults)) { $showAdditionalInfo = TRUE; $allPanes[$name]['open'] = 'true'; } $fnName = "build{$type}"; CRM_Contribute_Form_AdditionalInfo::$fnName($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( );"); $currencyFreeze = FALSE; if ($this->_id && !$this->_isPending) { $currencyFreeze = TRUE; } $element = $this->addMoney('amount', ts('Total Pledge Amount'), TRUE, array_merge($attributes['pledge_amount'], $js), TRUE, 'currency', NULL, $currencyFreeze); 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['pledge_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 => $label)); } $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", 0 => 'READONLY')); // add various dates if (!$this->_id || $this->_isPending) { $this->addDate('create_date', ts('Pledge Made'), TRUE); $this->addDate('start_date', ts('Payments Start'), TRUE); } if ($this->_id && !$this->_isPending) { $eachPaymentAmount = $this->_values['original_installment_amount']; $this->assign('currency', $this->_values['currency']); $this->assign('eachPaymentAmount', $eachPaymentAmount); $this->assign('hideCalender', TRUE); } if (CRM_Utils_Array::value('status_id', $this->_values) != array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))) { $this->addElement('checkbox', 'is_acknowledge', ts('Send Acknowledgment?'), NULL, array('onclick' => "showHideByValue( 'is_acknowledge', '', 'acknowledgeDate', 'table-row', 'radio', true); showHideByValue( 'is_acknowledge', '', 'fromEmail', 'table-row', 'radio', false );")); $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails); } $this->addDate('acknowledge_date', ts('Acknowledgment Date')); $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), TRUE); // CRM-7362 --add campaigns. CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values)); $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); $mailingInfo = Civi::settings()->get('mailing_backend'); $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(); } }
/** * Build the form object. * * @return void */ public function buildQuickForm() { $participantStatuses = CRM_Event_PseudoConstant::participantStatus(); $partiallyPaidStatusId = array_search('Partially paid', $participantStatuses); $this->assign('partiallyPaidStatusId', $partiallyPaidStatusId); if ($this->_showFeeBlock) { return CRM_Event_Form_EventFees::buildQuickForm($this); } if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //need to assign custom data type to the template $this->assign('customDataType', 'Participant'); $this->applyFilter('__ALL__', 'trim'); if ($this->_action & CRM_Core_Action::DELETE) { if ($this->_single) { $additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_id, NULL, $this->_contactId, FALSE, TRUE)) - 1; if ($additionalParticipant) { $deleteParticipants = array(1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.')); $this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '<br />'); $this->setDefaults(array('delete_participant' => 1)); $this->assign('additionalParticipant', $additionalParticipant); } } $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } if ($this->_single && $this->_context == 'standalone') { $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE); } $eventFieldParams = array('entity' => 'event', 'select' => array('minimumInputLength' => 0), 'api' => array('extra' => array('campaign_id', 'default_role_id', 'event_type_id'))); if ($this->_mode) { // exclude events which are not monetary when credit card registration is used $eventFieldParams['api']['params']['is_monetary'] = 1; $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE); } $element = $this->addEntityRef('event_id', ts('Event'), $eventFieldParams, TRUE); //frozen the field if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) { if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id')) { $element->freeze(); } } $campaignId = NULL; if ($this->_id) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'campaign_id'); } if (!$campaignId) { $eventId = CRM_Utils_Request::retrieve('eid', 'Positive', $this); if ($eventId) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'campaign_id'); } } CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId); $this->addDateTime('register_date', ts('Registration Date'), TRUE, array('formatType' => 'activityDateTime')); if ($this->_id) { $this->assign('entityID', $this->_id); } $this->addSelect('role_id', array('multiple' => TRUE, 'class' => 'huge'), TRUE); // CRM-4395 $checkCancelledJs = array('onchange' => "return sendNotification( );"); $confirmJS = NULL; if ($this->_onlinePendingContributionId) { $cancelledparticipantStatusId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus()); $cancelledContributionStatusId = array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')); $checkCancelledJs = array('onchange' => "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});"); $participantStatusId = array_search('Pending from pay later', CRM_Event_PseudoConstant::participantStatus()); $contributionStatusId = array_search('Completed', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')); $confirmJS = array('onclick' => "return confirmStatus( {$participantStatusId}, {$contributionStatusId} );"); } // get the participant status names to build special status array which is used to show notification // checkbox below participant status select $participantStatusName = CRM_Event_PseudoConstant::participantStatus(); $notificationStatuses = array('Cancelled', 'Pending from waitlist', 'Pending from approval', 'Expired'); // get the required status and then implode only ids $notificationStatusIds = implode(',', array_keys(array_intersect($participantStatusName, $notificationStatuses))); $this->assign('notificationStatusIds', $notificationStatusIds); $this->_participantStatuses = $statusOptions = CRM_Event_BAO_Participant::buildOptions('status_id', 'create'); // Only show refund status when editing if ($this->_action & CRM_Core_Action::ADD) { $pendingRefundStatusId = array_search('Pending refund', $participantStatusName); if ($pendingRefundStatusId) { unset($statusOptions[$pendingRefundStatusId]); } } $this->addSelect('status_id', $checkCancelledJs + array('options' => $statusOptions, 'option_url' => 'civicrm/admin/participant_status'), TRUE); $this->addElement('checkbox', 'is_notify', ts('Send Notification'), NULL); $this->add('text', 'source', ts('Event Source')); $noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note'); $this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']); $buttons[] = array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, 'js' => $confirmJS); $path = CRM_Utils_System::currentPath(); $excludeForPaths = array('civicrm/contact/search', 'civicrm/group/search'); if (!in_array($path, $excludeForPaths)) { $buttons[] = array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $confirmJS); } $buttons[] = array('type' => 'cancel', 'name' => ts('Cancel')); $this->addButtons($buttons); if ($this->_action == CRM_Core_Action::VIEW) { $this->freeze(); } }
/** * @param string $type * Eg 'Contribution'. * @param string $subType * @param int $entityId */ public function applyCustomData($type, $subType, $entityId) { $this->set('type', $type); $this->set('subType', $subType); $this->set('entityId', $entityId); CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, 1, $type, $entityId); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //need to assign custom data type and subtype to the template $this->assign('entityID', $this->_tableID); $this->assign('groupID', $this->_groupID); // make this form an upload since we dont know if the custom data injected dynamically // is of type file etc $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Build the form object elements for custom data. * * @return void */ public function buildQuickForm() { parent::buildQuickForm(); CRM_Custom_Form_CustomData::buildQuickForm($this); }
public function buildQuickForm() { $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process(); $isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients(); $this->assign('multiClient', $isMultiClient); 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' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Case'); CRM_Custom_Form_CustomData::buildQuickForm($this); // we don't want to show button on top of custom form $this->assign('noPreCustomButton', TRUE); $s = CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'subject'); if (!is_array($s)) { $s = array(); } $this->add('text', 'activity_subject', ts('Subject'), array_merge($s, array('maxlength' => '128')), TRUE); $tags = CRM_Core_BAO_Tag::getTags('civicrm_case'); if (!empty($tags)) { $this->add('select', 'tag', ts('Select Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'title' => ts('- select -'))); } // build tag widget $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case'); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', NULL, FALSE, TRUE); $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}::buildQuickForm( \$this );"); }
/** * Build the form object. */ 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; } // We want the "new group" form to redirect the user if ($this->_action == CRM_Core_Action::ADD) { $this->preventAjaxSubmit(); } $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'title', ts('Name') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), TRUE); $this->add('textarea', 'description', ts('Description') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description')); $groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE); if (isset($this->_id) && !empty($this->_groupValues['saved_search_id'])) { unset($groupTypes['Access Control']); } if (!empty($groupTypes)) { $this->addCheckBox('group_type', ts('Group Type'), $groupTypes, NULL, NULL, NULL, NULL, ' '); } $this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::groupVisibility(), TRUE); //CRM-14190 $parentGroups = self::buildParentGroups($this); if (CRM_Core_Permission::check('administer Multiple Organizations') && CRM_Core_Permission::isMultisiteEnabled()) { //group organization Element $props = array('api' => array('params' => array('contact_type' => 'Organization'))); $this->addEntityRef('organization_id', ts('Organization'), $props); } // is_reserved property CRM-9936 $this->addElement('checkbox', 'is_reserved', ts('Reserved Group?')); if (!CRM_Core_Permission::check('administer reserved groups')) { $this->freeze('is_reserved'); } //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')))); $doParentCheck = FALSE; if (CRM_Core_Permission::isMultisiteEnabled()) { $doParentCheck = $this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id) ? FALSE : TRUE; } $options = array('selfObj' => $this, 'parentGroups' => $parentGroups, 'doParentCheck' => $doParentCheck); $this->addFormRule(array('CRM_Group_Form_Edit', 'formRule'), $options); }
/** * Function to actually build the form * * @param null * * @return void * @access public */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'title'), TRUE); $surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType(); // Activity Type id $this->addSelect('activity_type_id', array(), TRUE); // Campaign id $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value('campaign_id', $this->_values)); $this->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns); // script / instructions $this->addWysiwyg('instructions', ts('Instructions for interviewers'), array('rows' => 5, 'cols' => 40)); // release frequency $this->add('text', 'release_frequency', ts('Release frequency'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency')); $this->addRule('release_frequency', ts('Release Frequency interval should be a positive number.'), 'positiveInteger'); // max reserved contacts at a time $this->add('text', 'default_number_of_contacts', ts('Maximum reserved at one time'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'default_number_of_contacts')); $this->addRule('default_number_of_contacts', ts('Maximum reserved at one time should be a positive number'), 'positiveInteger'); // total reserved per interviewer $this->add('text', 'max_number_of_contacts', ts('Total reserved per interviewer'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'max_number_of_contacts')); $this->addRule('max_number_of_contacts', ts('Total reserved contacts should be a positive number'), 'positiveInteger'); // is active ? $this->add('checkbox', 'is_active', ts('Active?')); // is default ? $this->add('checkbox', 'is_default', ts('Default?')); parent::buildQuickForm(); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Event'); if ($this->_eventType) { $this->assign('customDataSubType', $this->_eventType); } $this->assign('entityId', $this->_id); $this->_first = true; $this->applyFilter('__ALL__', 'trim'); $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event'); if ($this->_isTemplate) { $this->add('text', 'template_title', ts('Template Title'), $attributes['template_title'], true); } if ($this->_action & CRM_Core_Action::ADD) { require_once 'CRM/Event/PseudoConstant.php'; $eventTemplates =& CRM_Event_PseudoConstant::eventTemplates(); if (CRM_Utils_System::isNull($eventTemplates)) { $this->assign('noEventTemplates', true); } else { $this->add('select', 'template_id', ts('From Template'), array('' => ts('- select -')) + $eventTemplates, false, array('onchange' => "reloadWindow( this.value );")); } } // add event title, make required if this is not a template $this->add('text', 'title', ts('Event Title'), $attributes['event_title'], !$this->_isTemplate); require_once 'CRM/Core/OptionGroup.php'; $event = CRM_Core_OptionGroup::values('event_type'); $this->add('select', 'event_type_id', ts('Event Type'), array('' => ts('- select -')) + $event, true, array('onChange' => "buildCustomData( 'Event', this.value );")); $participantRole = CRM_Core_OptionGroup::values('participant_role'); $this->add('select', 'default_role_id', ts('Participant Role'), $participantRole, true); $participantListing = CRM_Core_OptionGroup::values('participant_listing'); $this->add('select', 'participant_listing_id', ts('Participant Listing'), array('' => ts('Disabled')) + $participantListing, false); $this->add('textarea', 'summary', ts('Event Summary'), $attributes['summary']); $this->addWysiwyg('description', ts('Complete Description'), $attributes['event_description']); $this->addElement('checkbox', 'is_public', ts('Public Event?')); $this->addElement('checkbox', 'is_map', ts('Include Map to Event Location?')); $this->addDateTime('start_date', ts('Start Date'), false, array('formatType' => 'activityDateTime')); $this->addDateTime('end_date', ts('End Date / Time'), false, array('formatType' => 'activityDateTime')); $this->add('text', 'max_participants', ts('Max Number of Participants'), array('onchange' => "if (this.value != '') {show('id-waitlist','table-row'); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false); showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); return;} else {hide('id-event_full','table-row'); hide('id-waitlist','table-row'); hide('id-waitlist-text','table-row'); return;}")); $this->addRule('max_participants', ts('Max participants should be a positive number'), 'positiveInteger'); require_once 'CRM/Event/PseudoConstant.php'; $participantStatuses =& CRM_Event_PseudoConstant::participantStatus(); if (in_array('On waitlist', $participantStatuses) and in_array('Pending from waitlist', $participantStatuses)) { $this->addElement('checkbox', 'has_waitlist', ts('Offer a Waitlist?'), null, array('onclick' => "showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false);")); $this->add('textarea', 'waitlist_text', ts('Waitlist Message'), $attributes['waitlist_text']); } $this->add('textarea', 'event_full_text', ts('Message if Event Is Full'), $attributes['event_full_text']); $this->addElement('checkbox', 'is_active', ts('Is this Event Active?')); $this->addFormRule(array('CRM_Event_Form_ManageEvent_EventInfo', 'formRule')); parent::buildQuickForm(); }
/** * Form preProcess function. * * @throws \Exception */ public function preProcess() { // This string makes up part of the class names, differentiating them (not sure why) from the membership fields. $this->assign('formClass', 'membership'); parent::preProcess(); // get price set id. $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET); $this->set('priceSetId', $this->_priceSetId); $this->assign('priceSetId', $this->_priceSetId); 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 $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')); }
/** * 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->add('textarea', 'description', ts('Description') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description')); $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)) { unset($groupTypes['Access Control']); } if (!empty($groupTypes)) { $this->addCheckBox('group_type', ts('Group Type'), $groupTypes, NULL, NULL, NULL, NULL, ' '); } $this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::ufVisibility(TRUE), TRUE); $groupNames = CRM_Core_PseudoConstant::group(); $parentGroups = $parentGroupElements = 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]; if (array_key_exists($parentGroupId, $groupNames)) { $parentGroupElements[$parentGroupId] = $groupNames[$parentGroupId]; $this->addElement('checkbox', "remove_parent_group_{$parentGroupId}", $groupNames[$parentGroupId]); } } } $this->assign_by_ref('parent_groups', $parentGroupElements); if (isset($this->_id)) { $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 (CRM_Core_Permission::isMultisiteEnabled()) { $required = empty($parentGroups) ? TRUE : FALSE; $required = $this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id) || !isset($this->_id) ? FALSE : $required; } else { $required = FALSE; } $this->add('select', 'parents', ts('Add Parent'), $parentGroupSelectValues, $required); } if (CRM_Core_Permission::check('administer Multiple Organizations') && CRM_Core_Permission::isMultisiteEnabled()) { //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')); } // is_reserved property CRM-9936 $this->addElement('checkbox', 'is_reserved', ts('Reserved Group?')); if (!CRM_Core_Permission::check('administer reserved groups')) { $this->freeze('is_reserved'); } //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')))); $doParentCheck = FALSE; if (CRM_Core_Permission::isMultisiteEnabled()) { $doParentCheck = $this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id) ? FALSE : TRUE; } $options = array('selfObj' => $this, 'parentGroups' => $parentGroups, 'doParentCheck' => $doParentCheck); $this->addFormRule(array('CRM_Group_Form_Edit', 'formRule'), $options); }
/** * Build the form object. */ public function buildQuickForm() { //@todo document the purpose of cdType (if still in use) if ($this->_cdType) { CRM_Custom_Form_CustomData::buildQuickForm($this); return; } $allPanes = array(); //tax rate from financialType $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates())); $this->assign('currencies', json_encode(CRM_Core_OptionGroup::values('currencies_enabled'))); // build price set form. $buildPriceSet = FALSE; $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); $this->assign('invoicing', $invoicing); // display tax amount on edit contribution page if ($invoicing && $this->_action & CRM_Core_Action::UPDATE && isset($this->_values['tax_amount'])) { $this->assign('totalTaxAmount', $this->_values['tax_amount']); } if (empty($this->_lineItems) && ($this->_priceSetId || !empty($_POST['price_set_id']))) { $buildPriceSet = TRUE; $getOnlyPriceSetElements = TRUE; if (!$this->_priceSetId) { $this->_priceSetId = $_POST['price_set_id']; $getOnlyPriceSetElements = FALSE; } $this->set('priceSetId', $this->_priceSetId); CRM_Price_BAO_PriceSet::buildPriceSet($this); // get only price set form elements. if ($getOnlyPriceSetElements) { return; } } // use to build form during form rule. $this->assign('buildPriceSet', $buildPriceSet); $showAdditionalInfo = FALSE; $defaults = $this->_values; $additionalDetailFields = array('note', 'thankyou_date', 'invoice_id', 'non_deductible_amount', 'fee_amount', 'net_amount'); foreach ($additionalDetailFields as $key) { if (!empty($defaults[$key])) { $defaults['hidden_AdditionalDetail'] = 1; break; } } if ($this->_productDAO) { if ($this->_productDAO->product_id) { $defaults['hidden_Premium'] = 1; } } if ($this->_noteID && isset($this->_values['note'])) { $defaults['hidden_AdditionalDetail'] = 1; } $paneNames = array(ts('Additional Details') => 'AdditionalDetail'); //Add Premium pane only if Premium is exists. $dao = new CRM_Contribute_DAO_Product(); $dao->is_active = 1; if ($dao->find(TRUE)) { $paneNames[ts('Premium Information')] = 'Premium'; } $billingPanes = array(); if ($this->_mode) { if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE) == TRUE) { $buildRecurBlock = TRUE; foreach ($this->billingPane as $name => $label) { if (!empty($this->billingFieldSets[$name]['fields'])) { // @todo reduce variation so we don't have to convert 'credit_card' to 'CreditCard' $billingPanes[$label] = $this->generatePane(CRM_Utils_String::convertStringToCamel($name), $defaults); } } } } foreach ($paneNames as $name => $type) { $allPanes[$name] = $this->generatePane($type, $defaults); } if (empty($this->_recurPaymentProcessors)) { $buildRecurBlock = FALSE; } if ($buildRecurBlock) { CRM_Contribute_Form_Contribution_Main::buildRecur($this); $this->setDefaults(array('is_recur' => 0)); } $this->assign('buildRecurBlock', $buildRecurBlock); $qfKey = $this->controller->_key; $this->assign('qfKey', $qfKey); $this->assign('billingPanes', $billingPanes); $this->assign('allPanes', $allPanes); $this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this); if ($this->_formType) { $this->assign('formType', $this->_formType); return; } $this->applyFilter('__ALL__', 'trim'); 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; } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Contribution'); $this->assign('customDataSubType', $this->_contributionType); $this->assign('entityID', $this->_id); if ($this->_context == 'standalone') { $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE); } $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution'); $financialType = $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), TRUE, array('onChange' => "CRM.buildCustomData( 'Contribution', this.value );")); $paymentInstrument = FALSE; if (!$this->_mode) { $paymentInstrument = $this->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")); } $trxnId = $this->add('text', 'trxn_id', ts('Transaction ID'), array('class' => 'twelve') + $attributes['trxn_id']); //add receipt for offline contribution $this->addElement('checkbox', 'is_email_receipt', ts('Send Receipt?')); $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails); $status = CRM_Contribute_PseudoConstant::contributionStatus(); // suppressing contribution statuses that are NOT relevant to pledges (CRM-5169) $statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); if ($this->_ppID) { foreach (array('Cancelled', 'Failed', 'In Progress') as $suppress) { unset($status[CRM_Utils_Array::key($suppress, $statusName)]); } } elseif (!$this->_ppID && $this->_id || !$this->_id) { $suppressFlag = FALSE; if ($this->_id) { $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id); if (CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails)) { $suppressFlag = TRUE; } } if (!$suppressFlag) { foreach (array('Overdue', 'In Progress') as $suppress) { unset($status[CRM_Utils_Array::key($suppress, $statusName)]); } } else { unset($status[CRM_Utils_Array::key('Overdue', $statusName)]); } } if ($this->_id) { $contributionStatus = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_id, 'contribution_status_id'); $name = CRM_Utils_Array::value($contributionStatus, $statusName); switch ($name) { case 'Completed': case 'Cancelled': case 'Refunded': unset($status[CRM_Utils_Array::key('In Progress', $statusName)]); unset($status[CRM_Utils_Array::key('Pending', $statusName)]); unset($status[CRM_Utils_Array::key('Failed', $statusName)]); break; case 'Pending': case 'In Progress': unset($status[CRM_Utils_Array::key('Refunded', $statusName)]); break; case 'Failed': foreach (array('Pending', 'Refunded', 'Completed', 'In Progress', 'Cancelled') as $suppress) { unset($status[CRM_Utils_Array::key($suppress, $statusName)]); } break; } } else { unset($status[CRM_Utils_Array::key('Refunded', $statusName)]); } $this->add('select', 'contribution_status_id', ts('Contribution Status'), $status, FALSE); // add various dates $this->addDateTime('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime')); if ($this->_online) { $this->assign('hideCalender', TRUE); } $checkNumber = $this->add('text', 'check_number', ts('Check Number'), $attributes['check_number']); $this->addDateTime('receipt_date', ts('Receipt Date'), FALSE, array('formatType' => 'activityDateTime')); $this->addDateTime('cancel_date', ts('Cancelled / Refunded Date'), FALSE, array('formatType' => 'activityDateTime')); $this->add('textarea', 'cancel_reason', ts('Cancellation / Refund Reason'), $attributes['cancel_reason']); $recurJs = NULL; if ($buildRecurBlock) { $recurJs = array('onChange' => "buildRecurBlock( this.value ); return false;"); } $element = $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, NULL, $recurJs); if ($this->_online) { $element->freeze(); } $totalAmount = NULL; if (empty($this->_lineItems)) { $buildPriceSet = FALSE; $priceSets = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviContribute'); if (!empty($priceSets) && !$this->_ppID) { $buildPriceSet = TRUE; } // don't allow price set for contribution if it is related to participant, or if it is a pledge payment // and if we already have line items for that participant. CRM-5095 if ($buildPriceSet && $this->_id) { $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id); $pledgePaymentId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_id, 'id', 'contribution_id'); if ($pledgePaymentId) { $buildPriceSet = FALSE; } if ($participantID = CRM_Utils_Array::value('participant', $componentDetails)) { $participantLI = CRM_Price_BAO_LineItem::getLineItems($participantID); if (!CRM_Utils_System::isNull($participantLI)) { $buildPriceSet = FALSE; } } } $hasPriceSets = FALSE; if ($buildPriceSet) { $hasPriceSets = TRUE; $element = $this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, NULL, array('onchange' => "buildAmount( this.value );")); if ($this->_online && !($this->_action & CRM_Core_Action::UPDATE)) { $element->freeze(); } } $this->assign('hasPriceSets', $hasPriceSets); $currencyFreeze = FALSE; if (!($this->_action & CRM_Core_Action::UPDATE)) { if ($this->_online || $this->_ppID) { $attributes['total_amount'] = array_merge($attributes['total_amount'], array('READONLY' => TRUE, 'style' => "background-color:#EBECE4")); $optionTypes = array('1' => ts('Adjust Pledge Payment Schedule?'), '2' => ts('Adjust Total Pledge Amount?')); $this->addRadio('option_type', NULL, $optionTypes, array(), '<br/>'); $currencyFreeze = TRUE; } } $totalAmount = $this->addMoney('total_amount', ts('Total Amount'), $hasPriceSets ? FALSE : TRUE, $attributes['total_amount'], TRUE, 'currency', NULL, $currencyFreeze); } $this->add('text', 'source', ts('Source'), CRM_Utils_Array::value('source', $attributes)); // CRM-7362 --add campaigns. CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values)); CRM_Contribute_Form_SoftCredit::buildQuickForm($this); $js = NULL; if (!$this->_mode) { $js = array('onclick' => "return verify( );"); } $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend'); $this->assign('outBound_option', $mailingInfo['outBound_option']); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'js' => $js, 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); // if status is Cancelled freeze Amount, Payment Instrument, Check #, Financial Type, // Net and Fee Amounts are frozen in AdditionalInfo::buildAdditionalDetail if ($this->_id && $this->_values['contribution_status_id'] == array_search('Cancelled', $statusName)) { if ($totalAmount) { $totalAmount->freeze(); } $checkNumber->freeze(); $paymentInstrument->freeze(); $trxnId->freeze(); $financialType->freeze(); } // if contribution is related to membership or participant freeze Financial Type, Amount if ($this->_id && isset($this->_values['tax_amount'])) { $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id); if (CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails)) { if ($totalAmount) { $totalAmount->freeze(); } $financialType->freeze(); $this->assign('freezeFinancialType', TRUE); } } if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); } }
/** * Build the form object. */ public function preProcess() { CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity'); $this->_atypefile = CRM_Utils_Array::value('atypefile', $_GET); $this->assign('atypefile', FALSE); if ($this->_atypefile) { $this->assign('atypefile', TRUE); } $session = CRM_Core_Session::singleton(); $this->_currentUserId = $session->get('userID'); $this->_currentlyViewedContactId = $this->get('contactId'); if (!$this->_currentlyViewedContactId) { $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); } $this->assign('contactId', $this->_currentlyViewedContactId); // Give the context. if (!isset($this->_context)) { $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); if (CRM_Contact_Form_Search::isSearchContext($this->_context)) { $this->_context = 'search'; } elseif (!in_array($this->_context, array('dashlet', 'dashletFullscreen')) && $this->_currentlyViewedContactId) { $this->_context = 'activity'; } $this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this); } $this->assign('context', $this->_context); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this); if ($this->_action & CRM_Core_Action::DELETE) { if (!CRM_Core_Permission::check('delete activities')) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } } // CRM-6957 // When we come from contact search, activity id never comes. // So don't try to get from object, it might gives you wrong one. // if we're not adding new one, there must be an id to // an activity we're trying to work on. if ($this->_action != CRM_Core_Action::ADD && get_class($this->controller) != 'CRM_Contact_Controller_Search') { $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this); } $this->_activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this); $this->assign('atype', $this->_activityTypeId); $this->assign('activityId', $this->_activityId); // Check for required permissions, CRM-6264. if ($this->_activityId && in_array($this->_action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) && !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } if ($this->_action & CRM_Core_Action::VIEW && CRM_Activity_BAO_Activity::checkPermission($this->_activityId, CRM_Core_Action::UPDATE)) { $this->assign('permission', 'edit'); } if (!$this->_activityTypeId && $this->_activityId) { $this->_activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'activity_type_id'); } // Assigning Activity type name. if ($this->_activityTypeId) { $activityTName = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $this->_activityTypeId, 'label'); if ($activityTName[$this->_activityTypeId]) { $this->_activityTypeName = $activityTName[$this->_activityTypeId]; $this->assign('activityTName', $activityTName[$this->_activityTypeId]); } } // Set title. if (isset($activityTName)) { $activityName = CRM_Utils_Array::value($this->_activityTypeId, $activityTName); $this->assign('pageTitle', ts('%1 Activity', array(1 => $activityName))); if ($this->_currentlyViewedContactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_currentlyViewedContactId); // Check if this is default domain contact CRM-10482. if (CRM_Contact_BAO_Contact::checkDomainContact($this->_currentlyViewedContactId)) { $displayName .= ' (' . ts('default organization') . ')'; } CRM_Utils_System::setTitle($displayName . ' - ' . $activityName); } else { CRM_Utils_System::setTitle(ts('%1 Activity', array(1 => $activityName))); } } // Check the mode when this form is called either single or as // search task action. if ($this->_activityTypeId || $this->_context == 'standalone' || $this->_currentlyViewedContactId) { $this->_single = TRUE; $this->assign('urlPath', 'civicrm/activity'); } else { // Set the appropriate action. $url = CRM_Utils_System::currentPath(); $urlArray = explode('/', $url); $searchPath = array_pop($urlArray); $searchType = 'basic'; $this->_action = CRM_Core_Action::BASIC; switch ($searchPath) { case 'basic': $searchType = $searchPath; $this->_action = CRM_Core_Action::BASIC; break; case 'advanced': $searchType = $searchPath; $this->_action = CRM_Core_Action::ADVANCED; break; case 'builder': $searchType = $searchPath; $this->_action = CRM_Core_Action::PROFILE; break; case 'custom': $this->_action = CRM_Core_Action::COPY; $searchType = $searchPath; break; } parent::preProcess(); $this->_single = FALSE; $this->assign('urlPath', "civicrm/contact/search/{$searchType}"); $this->assign('urlPathVar', "_qf_Activity_display=true&qfKey={$this->controller->_key}"); } $this->assign('single', $this->_single); $this->assign('action', $this->_action); if ($this->_action & CRM_Core_Action::VIEW) { // Get the tree of custom fields. $this->_groupTree =& CRM_Core_BAO_CustomGroup::getTree('Activity', $this, $this->_activityId, 0, $this->_activityTypeId); } if ($this->_activityTypeId) { // Set activity type name and description to template. list($this->_activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($this->_activityTypeId); $this->assign('activityTypeName', $this->_activityTypeName); $this->assign('activityTypeDescription', $activityTypeDescription); } // set user context $urlParams = $urlString = NULL; $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this); if (!$qfKey) { $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this); } // Validate the qfKey. if (!CRM_Utils_Rule::qfKey($qfKey)) { $qfKey = NULL; } if ($this->_context == 'fulltext') { $keyName = '&qfKey'; $urlParams = 'force=1'; $urlString = 'civicrm/contact/search/custom'; if ($this->_action == CRM_Core_Action::UPDATE) { $keyName = '&key'; $urlParams .= '&context=fulltext&action=view'; $urlString = 'civicrm/contact/view/activity'; } if ($qfKey) { $urlParams .= "{$keyName}={$qfKey}"; } $this->assign('searchKey', $qfKey); } elseif (in_array($this->_context, array('standalone', 'home', 'dashlet', 'dashletFullscreen'))) { $urlParams = 'reset=1'; $urlString = 'civicrm/dashboard'; } elseif ($this->_context == 'search') { $urlParams = 'force=1'; if ($qfKey) { $urlParams .= "&qfKey={$qfKey}"; } $path = CRM_Utils_System::currentPath(); if ($this->_compContext == 'advanced') { $urlString = 'civicrm/contact/search/advanced'; } elseif ($path == 'civicrm/group/search' || $path == 'civicrm/contact/search' || $path == 'civicrm/contact/search/advanced' || $path == 'civicrm/contact/search/custom' || $path == 'civicrm/group/search') { $urlString = $path; } else { $urlString = 'civicrm/activity/search'; } $this->assign('searchKey', $qfKey); } elseif ($this->_context != 'caseActivity') { $urlParams = "action=browse&reset=1&cid={$this->_currentlyViewedContactId}&selectedChild=activity"; $urlString = 'civicrm/contact/view'; } if ($urlString) { $session->pushUserContext(CRM_Utils_System::url($urlString, $urlParams)); } // hack to retrieve activity type id from post variables if (!$this->_activityTypeId) { $this->_activityTypeId = CRM_Utils_Array::value('activity_type_id', $_POST); } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { // We need to set it in the session for the code below to work. // CRM-3014 // Need to assign custom data subtype to the template. $this->set('type', 'Activity'); $this->set('subType', $this->_activityTypeId); $this->set('entityId', $this->_activityId); CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeId, 1, 'Activity', $this->_activityId); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } // add attachments part CRM_Core_BAO_File::buildAttachment($this, 'civicrm_activity', $this->_activityId, NULL, TRUE); // figure out the file name for activity type, if any if ($this->_activityTypeId && ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, $this->_crmDir))) { $this->assign('activityTypeFile', $this->_activityTypeFile); $this->assign('crmDir', $this->_crmDir); } $this->setFields(); if ($this->_activityTypeFile) { $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}"; $className::preProcess($this); } $this->_values = $this->get('values'); if (!is_array($this->_values)) { $this->_values = array(); if (isset($this->_activityId) && $this->_activityId) { $params = array('id' => $this->_activityId); CRM_Activity_BAO_Activity::retrieve($params, $this->_values); } $this->set('values', $this->_values); } if ($this->_action & CRM_Core_Action::UPDATE) { CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity'); } }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_showFeeBlock) { return CRM_Event_Form_EventFees::buildQuickForm($this); } if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //need to assign custom data type to the template $this->assign('customDataType', 'Participant'); $this->applyFilter('__ALL__', 'trim'); if ($this->_action & CRM_Core_Action::DELETE) { if ($this->_single) { require_once 'CRM/Event/BAO/Event.php'; $additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_participantId, null, $this->_contactID, false, true)) - 1; if ($additionalParticipant) { $this->assign("additionalParticipant", $additionalParticipant); } } $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } if ($this->_single) { $urlPath = 'civicrm/contact/view/participant'; $urlParams = "reset=1&cid={$this->_contactID}&context=participant"; if ($this->_context == 'standalone') { require_once 'CRM/Contact/Form/NewContact.php'; CRM_Contact_Form_NewContact::buildQuickForm($this); $urlParams = "reset=1&context=standalone"; $urlPath = 'civicrm/participant/add'; } if ($this->_participantId) { $urlParams .= "&action=update&id={$this->_participantId}"; } else { $urlParams .= "&action=add"; } if (CRM_Utils_Request::retrieve('past', 'Boolean', $this)) { $urlParams .= "&past=true"; } if ($this->_mode) { $urlParams .= "&mode={$this->_mode}"; } $url = CRM_Utils_System::url($urlPath, $urlParams, false, null, false); } else { $currentPath = CRM_Utils_System::currentPath(); $url = CRM_Utils_System::url($currentPath, '_qf_Participant_display=true', false, null, false); } $this->assign("refreshURL", $url); $url .= "&past=true"; $this->assign("pastURL", $url); $events = array(); $this->assign("past", false); require_once "CRM/Event/BAO/Event.php"; if (CRM_Utils_Request::retrieve('past', 'Boolean', $this) || $this->_action & CRM_Core_Action::UPDATE) { $events = CRM_Event_BAO_Event::getEvents(true); $this->assign("past", true); } else { $events = CRM_Event_BAO_Event::getEvents(); } if ($this->_mode) { //unset the event which are not monetary when credit card //event registration is used foreach ($events as $key => $val) { $isPaid = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $key, 'is_monetary'); if (!$isPaid) { unset($events[$key]); } } $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, true); } $element = $this->add('select', 'event_id', ts('Event'), array('' => ts('- select -')) + $events, true, array('onchange' => "buildFeeBlock( this.value ); buildCustomData( 'Participant', this.value, {$this->_eventNameCustomDataTypeID} );", 'class' => 'huge')); //frozen the field fix for CRM-4171 if ($this->_action & CRM_Core_Action::UPDATE && $this->_participantId) { if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participantId, 'contribution_id', 'participant_id')) { $element->freeze(); } } $this->addDateTime('register_date', ts('Registration Date'), true); if ($this->_participantId) { $this->assign('entityID', $this->_participantId); } $this->add('select', 'role_id', ts('Participant Role'), array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), true, array('onchange' => "buildCustomData( 'Participant', this.value, {$this->_roleCustomDataTypeID} );")); // CRM-4395 $checkCancelledJs = array('onchange' => "return sendNotification( );"); if ($this->_onlinePendingContributionId) { $cancelledparticipantStatusId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus()); $cancelledContributionStatusId = array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(null, 'name')); $checkCancelledJs = array('onchange' => "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});"); } $this->add('select', 'status_id', ts('Participant Status'), array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(null, null, 'label'), true, $checkCancelledJs); $this->addElement('checkbox', 'is_notify', ts('Send Notification'), null); $this->add('text', 'source', ts('Event Source')); $noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note'); $this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']); $confirmJS = null; if ($this->_onlinePendingContributionId) { $participantStatusId = array_search('Pending from pay later', CRM_Event_PseudoConstant::participantStatus()); $contributionStatusId = array_search('Completed', CRM_Contribute_PseudoConstant::contributionStatus(null, 'name')); $confirmJS = array('onclick' => "return confirmStatus( {$participantStatusId}, {$contributionStatusId} );"); } $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => true, 'js' => $confirmJS), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $confirmJS), array('type' => 'cancel', 'name' => ts('Cancel')))); if ($this->_action == CRM_Core_Action::VIEW) { $this->freeze(); } }
public function buildQuickForm() { if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) { //enable form element (ActivityLinks sets this true) $this->assign('suppressForm', FALSE); $button = ts('Delete'); if ($this->_action & CRM_Core_Action::RENEW) { $button = ts('Restore'); } $this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //build other activity links CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this); //enable form element (ActivityLinks sets this true) $this->assign('suppressForm', FALSE); $element =& $this->add('select', 'activity_type_id', ts('Activity Type'), array('' => '- ' . ts('select') . ' -') + $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );", 'class' => 'crm-select2 required')); //freeze for update mode. if ($this->_action & CRM_Core_Action::UPDATE) { $element->freeze(); } //Call to RecurringEntity buildQuickForm for add/update mode if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { CRM_Core_Form_RecurringEntity::buildQuickForm($this); } foreach ($this->_fields as $field => $values) { if (!empty($this->_fields[$field])) { $attribute = CRM_Utils_Array::value('attributes', $values); $required = !empty($values['required']); if ($values['type'] == 'wysiwyg') { $this->addWysiwyg($field, $values['label'], $attribute, $required); } elseif ($values['type'] == 'select' && empty($attribute)) { $this->addSelect($field, array('entity' => 'activity'), $required); } elseif ($values['type'] == 'entityRef') { $this->addEntityRef($field, $values['label'], $attribute, $required); } else { $this->add($values['type'], $field, $values['label'], $attribute, $required, CRM_Utils_Array::value('extra', $values)); } } } //CRM-7362 --add campaigns. CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values)); //add engagement level CRM-7775 $buildEngagementLevel = FALSE; if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) { $buildEngagementLevel = TRUE; $this->addSelect('engagement_level', array('entity' => 'activity')); $this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger'); } $this->assign('buildEngagementLevel', $buildEngagementLevel); // check for survey activity $this->_isSurveyActivity = FALSE; if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) { $this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId); if ($this->_isSurveyActivity) { $surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id'); $responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId); if ($responseOptions) { $this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions)); } $surveyTitle = NULL; if ($surveyId) { $surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title'); } $this->assign('surveyTitle', $surveyTitle); } } $this->assign('surveyActivity', $this->_isSurveyActivity); // this option should be available only during add mode if ($this->_action != CRM_Core_Action::UPDATE) { $this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.')); } $this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger'); $this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime')); //add followup date $this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime')); // Only admins and case-workers can change the activity source if (!CRM_Core_Permission::check('administer CiviCRM') && $this->_context != 'caseActivity') { $this->getElement('source_contact_id')->freeze(); } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Activity'); $this->assign('customDataSubType', $this->_activityTypeId); $this->assign('entityID', $this->_activityId); CRM_Core_BAO_Tag::getTags('civicrm_activity', $tags, NULL, ' ', TRUE); if (!empty($tags)) { $this->add('select', 'tag', ts('Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2 huge')); } // we need to hide activity tagset for special activities $specialActivities = array('Open Case'); if (!in_array($this->_activityTypeName, $specialActivities)) { // build tag widget $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity'); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId); } // if we're viewing, we're assigning different buttons than for adding/editing if ($this->_action & CRM_Core_Action::VIEW) { if (isset($this->_groupTree)) { CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree); } // form should be frozen for view mode $this->freeze(); $buttons = array(); $buttons[] = array('type' => 'cancel', 'name' => ts('Done')); $this->addButtons($buttons); } else { $message = array('completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'), 'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.')); $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");"); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); } if ($this->_activityTypeFile) { $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}"; $className::buildQuickForm($this); $this->addFormRule(array($className, 'formRule'), $this); } $this->addFormRule(array('CRM_Activity_Form_Activity', 'formRule'), $this); if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) { $this->assign('activityAssigneeNotification', TRUE); } else { $this->assign('activityAssigneeNotification', FALSE); } }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } $relTypeID = explode('_', $this->_rtypeId, 3); if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } $callAjax = $this->get('callAjax'); $searchRows = null; if (!$callAjax) { $searchRows = $this->get('searchRows'); } else { $this->addElement('hidden', 'store_contacts', '', array('id' => 'store_contacts')); $sourceUrl = 'snippet=4&relType=' . $this->get('relType'); $sourceUrl .= '&relContact=' . $this->get('relContact'); $sourceUrl .= '&cid=' . $this->_contactId; $this->assign('searchCount', true); // To handle employee of and employer of if (!empty($this->_relationshipTypeId) && !empty($this->_rtype)) { $sourceUrl .= '&typeName=' . $this->_allRelationshipNames[$this->_relationshipTypeId]["name_{$this->_rtype}"]; } $this->assign('sourceUrl', CRM_Utils_System::url('civicrm/ajax/relationshipcontacts', $sourceUrl, false, null, false)); } $this->assign('callAjax', $callAjax); $this->_callAjax = $callAjax; $this->addElement('select', 'relationship_type_id', ts('Relationship Type'), array('' => ts('- select -')) + CRM_Contact_BAO_Relationship::getContactRelationshipType($this->_contactId, $this->_rtype, $this->_relationshipId, null, false, 'label')); // add a ajax facility for searching contacts $dataUrl = CRM_Utils_System::url("civicrm/ajax/search", "reset=1", true, null, false); $this->assign('dataUrl', $dataUrl); $this->add('text', 'rel_contact', ts('Find Target Contact')); $this->add('hidden', "rel_contact_id"); $this->addDate('start_date', ts('Start Date'), false, array('formatType' => 'searchDate')); $this->addDate('end_date', ts('End Date'), false, array('formatType' => 'searchDate')); $this->addElement('advcheckbox', 'is_active', ts('Enabled?'), null, 'setChecked()'); $this->addElement('checkbox', 'is_permission_a_b', ts('Permission for contact a to view and update information for contact b'), null); $this->addElement('checkbox', 'is_permission_b_a', ts('permission for contact b to view and update information for contact a'), null); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Relationship', 'description')); CRM_Contact_Form_Edit_Notes::buildQuickForm($this); $searchCount = $this->get('searchCount'); $duplicateRelationship = $this->get('duplicateRelationship'); $searchDone = $this->get('searchDone'); $isEmployeeOf = $isEmployerOf = false; if (!empty($this->_relationshipTypeId) && !empty($this->_rtype)) { if ($this->_allRelationshipNames[$this->_relationshipTypeId]["name_{$this->_rtype}"] == 'Employee of') { $isEmployeeOf = true; } else { if ($this->_allRelationshipNames[$this->_relationshipTypeId]["name_{$this->_rtype}"] == 'Employer of') { $isEmployerOf = true; } } } $employers = $checkBoxes = $employees = array(); if ($searchRows) { foreach ($searchRows as $id => $row) { $checkBoxes[$id] = $this->createElement('checkbox', $id, null, ''); if ($isEmployeeOf) { $employers[$id] = $this->createElement('radio', null, $id, null, $id); } else { if ($isEmployerOf) { $employees[$id] = $this->createElement('checkbox', $id, null, ''); } } } $this->addGroup($checkBoxes, 'contact_check'); $this->assign('searchRows', $searchRows); } if ($isEmployeeOf) { $this->assign('isEmployeeOf', $isEmployeeOf); if (!$callAjax) { $this->addGroup($employers, 'employee_of'); } } else { if ($isEmployerOf) { $this->assign('isEmployerOf', $isEmployerOf); if (!$callAjax) { $this->addGroup($employees, 'employer_of'); } } } if ($callAjax && ($isEmployeeOf || $isEmployerOf)) { $this->addElement('hidden', 'store_employers', '', array('id' => 'store_employers')); } if ($this->_action & CRM_Core_Action::UPDATE) { $this->addElement('checkbox', 'is_current_employer'); } $this->assign('duplicateRelationship', $duplicateRelationship); $this->assign('searchCount', $searchCount); $this->assign('searchDone', $searchDone); if ($this->get('contact_type')) { require_once 'CRM/Contact/BAO/ContactType.php'; $typeLabel = CRM_Contact_BAO_ContactType::getLabel($this->get('contact_type')); $this->assign('contact_type', $this->get('contact_type')); $this->assign('contact_type_display', $typeLabel); } if ($searchDone) { $searchBtn = ts('Search Again'); } else { $searchBtn = ts('Search'); } $this->addElement('submit', $this->getButtonName('refresh'), $searchBtn, array('class' => 'form-submit', 'id' => 'search-button')); $this->addElement('submit', $this->getButtonName('refresh', 'save'), 'Quick Save', array('class' => 'form-submit', 'id' => 'quick-save')); $this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'form-submit')); $this->addElement('submit', $this->getButtonName('refresh', 'savedetails'), 'Save Relationship', array('class' => 'form-submit hiddenElement', 'id' => 'details-save')); $this->addElement('checkbox', 'add_current_employer', ts('Current Employer'), null); $this->addElement('checkbox', 'add_current_employee', ts('Current Employee'), null); //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Relationship'); $this->assign('customDataSubType', $this->_relationshipTypeId); $this->assign('entityID', $this->_relationshipId); // make this form an upload since we dont know if the custom data injected dynamically // is of type file etc $uploadNames = $this->get( // 'uploadNames' ); $buttonParams = array('type' => 'upload', 'name' => ts('Save Relationship'), 'isDefault' => true); if ($callAjax) { $buttonParams['js'] = array('onclick' => ' submitAjaxData();'); } $this->addButtons(array($buttonParams, array('type' => 'cancel', 'name' => ts('Cancel')))); }
public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } $this->applyFilter('__ALL__', 'trim'); if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //lets assign custom data type and subtype. $this->assign('customDataType', 'Campaign'); $this->assign('entityID', $this->_campaignId); $this->assign('customDataSubType', CRM_Utils_Array::value('campaign_type_id', $this->_values)); $attributes = CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Campaign'); // add comaign title. $this->add('text', 'title', ts('Title'), $attributes['title'], TRUE); // add description $this->add('textarea', 'description', ts('Description'), $attributes['description']); // add campaign start date $this->addDateTime('start_date', ts('Start Date'), TRUE, array('formatType' => 'activityDateTime')); // add campaign end date $this->addDateTime('end_date', ts('End Date'), FALSE, array('formatType' => 'activityDateTime')); // add campaign type $this->addSelect('campaign_type_id', array('onChange' => "CRM.buildCustomData( 'Campaign', this.value );"), TRUE); // add campaign status $this->addSelect('status_id'); // add External Identifier Element $this->add('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Campaign', 'external_identifier'), FALSE); // add Campaign Parent Id $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value('parent_id', $this->_values), $this->_campaignId); if (!empty($campaigns)) { $this->addElement('select', 'parent_id', ts('Parent ID'), array('' => ts('- select Parent -')) + $campaigns, array('class' => 'crm-select2')); } $groups = CRM_Core_PseudoConstant::nestedGroup(); //get the campaign groups. $this->add('select', 'includeGroups', ts('Include Group(s)'), $groups, FALSE, array('multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => ts('- none -'))); $this->addWysiwyg('goal_general', ts('Campaign Goals'), array('rows' => 2, 'cols' => 40)); $this->add('text', 'goal_revenue', ts('Revenue Goal'), array('size' => 8, 'maxlength' => 12)); $this->addRule('goal_revenue', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); // is this Campaign active $this->addElement('checkbox', 'is_active', ts('Is Active?')); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Build the form object. */ public function buildQuickForm() { if ($this->_cdType || $this->_multiRecordDisplay == 'single') { // buttons display for multi-valued fields to perform independednt actions if ($this->_multiRecordDisplay) { $isMultiple = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_groupID, 'is_multiple'); if ($isMultiple) { $this->assign('multiRecordDisplay', $this->_multiRecordDisplay); $saveButtonName = $this->_copyValueId ? ts('Save a Copy') : ts('Save'); $this->addButtons(array(array('type' => 'upload', 'name' => $saveButtonName, 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); } } return CRM_Custom_Form_CustomData::buildQuickForm($this); } //need to assign custom data type and subtype to the template $this->assign('entityID', $this->_tableID); $this->assign('groupID', $this->_groupID); // make this form an upload since we dont know if the custom data injected dynamically // is of type file etc $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Build the form object. * * @return void */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } parent::buildQuickForm(); $defaults = parent::setDefaultValues(); $this->_memType = $defaults['membership_type_id']; $this->assign('customDataType', 'Membership'); $this->assign('customDataSubType', $this->_memType); $this->assign('entityID', $this->_id); $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -'); $allMemberships = CRM_Member_BAO_Membership::buildMembershipTypeValues($this); $allMembershipInfo = $membershipType = array(); //CRM-16950 $taxRates = CRM_Core_PseudoConstant::getTaxRates(); $taxRate = CRM_Utils_Array::value($allMemberships[$defaults['membership_type_id']]['financial_type_id'], $taxRates); $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings'); // auto renew options if enabled for the membership $options = CRM_Core_SelectValues::memberAutoRenew(); foreach ($allMemberships as $key => $values) { if (!empty($values['is_active'])) { $membershipType[$key] = CRM_Utils_Array::value('name', $values); if ($this->_mode && empty($values['minimum_fee'])) { continue; } else { $memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values); if (empty($selMemTypeOrg[$memberOfContactId])) { $selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, 'display_name', 'id'); $selOrgMemType[$memberOfContactId][0] = ts('- select -'); } if (empty($selOrgMemType[$memberOfContactId][$key])) { $selOrgMemType[$memberOfContactId][$key] = CRM_Utils_Array::value('name', $values); } } //CRM-16950 $taxAmount = NULL; $totalAmount = CRM_Utils_Array::value('minimum_fee', $values); if (CRM_Utils_Array::value($values['financial_type_id'], $taxRates)) { $taxAmount = $taxRate / 100 * CRM_Utils_Array::value('minimum_fee', $values); $totalAmount = $totalAmount + $taxAmount; } // build membership info array, which is used to set the payment information block when // membership type is selected. $allMembershipInfo[$key] = array('financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values), 'total_amount' => CRM_Utils_Money::format($totalAmount, NULL, '%a'), 'total_amount_numeric' => $totalAmount, 'tax_message' => $taxAmount ? ts("Includes %1 amount of %2", array(1 => CRM_Utils_Array::value('tax_term', $invoiceSettings), 2 => CRM_Utils_Money::format($taxAmount))) : $taxAmount); if (!empty($values['auto_renew'])) { $allMembershipInfo[$key]['auto_renew'] = $options[$values['auto_renew']]; } } } $this->assign('allMembershipInfo', json_encode($allMembershipInfo)); if ($this->_memType) { $this->assign('orgName', $selMemTypeOrg[$allMemberships[$this->_memType]['member_of_contact_id']]); $this->assign('memType', $allMemberships[$this->_memType]['name']); } // force select of organization by default, if only one organization in // the list if (count($selMemTypeOrg) == 2) { unset($selMemTypeOrg[0], $selOrgMemType[0][0]); } //sort membership organization and type, CRM-6099 natcasesort($selMemTypeOrg); foreach ($selOrgMemType as $index => $orgMembershipType) { natcasesort($orgMembershipType); $selOrgMemType[$index] = $orgMembershipType; } $js = array('onChange' => "setPaymentBlock( ); CRM.buildCustomData( 'Membership', this.value );"); //build the form for auto renew. $recurProcessor = array(); if ($this->_mode || $this->_action & CRM_Core_Action::UPDATE) { //get the valid recurring processors. $test = strtolower($this->_mode) == 'test' ? TRUE : FALSE; $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, $test, 'is_recur = 1'); $recurProcessor = array_intersect_key($this->_processors, $recurring); if (!empty($recurProcessor)) { $autoRenew = array(); if (!empty($membershipType)) { $sql = ' SELECT id, auto_renew, duration_unit, duration_interval FROM civicrm_membership_type WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; $recurMembershipTypes = CRM_Core_DAO::executeQuery($sql); while ($recurMembershipTypes->fetch()) { $autoRenew[$recurMembershipTypes->id] = $recurMembershipTypes->auto_renew; foreach (array('id', 'auto_renew', 'duration_unit', 'duration_interval') as $fld) { $this->_recurMembershipTypes[$recurMembershipTypes->id][$fld] = $recurMembershipTypes->{$fld}; } } } $js = array('onChange' => "setPaymentBlock(); CRM.buildCustomData( 'Membership', this.value );"); $this->assign('autoRenew', json_encode($autoRenew)); } $autoRenewElement = $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'), NULL, array('onclick' => "showHideByValue('auto_renew','','send-receipt','table-row','radio',true); showHideNotice( );")); if ($this->_action & CRM_Core_Action::UPDATE) { $autoRenewElement->freeze(); } } $this->assign('recurProcessor', json_encode($recurProcessor)); $sel =& $this->addElement('hierselect', 'membership_type_id', ts('Renewal Membership Organization and Type'), $js); $sel->setOptions(array($selMemTypeOrg, $selOrgMemType)); $elements = array(); if ($sel) { $elements[] = $sel; } $this->applyFilter('__ALL__', 'trim'); $this->addDate('renewal_date', ts('Date Renewal Entered'), FALSE, array('formatType' => 'activityDate')); $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()); if (CRM_Core_Permission::access('CiviContribute') && !$this->_mode) { $this->addElement('checkbox', 'record_contribution', ts('Record Renewal Payment?'), NULL, array('onclick' => "checkPayment();")); $this->add('text', 'total_amount', ts('Amount')); $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money'); $this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime')); $this->add('text', 'num_terms', ts('Extend Membership by'), array('onchange' => "setPaymentBlock();"), TRUE); $this->addRule('num_terms', ts('Please enter a whole number for how many periods to renew.'), 'integer'); $this->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")); $this->add('text', 'trxn_id', ts('Transaction ID')); $this->addRule('trxn_id', ts('Transaction ID already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id')); $this->add('select', 'contribution_status_id', ts('Payment Status'), CRM_Contribute_PseudoConstant::contributionStatus()); $this->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number')); } else { $this->add('text', 'total_amount', ts('Amount')); $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money'); } $this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), NULL, array('onclick' => "showHideByValue( 'send_receipt', '', 'notice', 'table-row', 'radio', false ); showHideByValue( 'send_receipt', '', 'fromEmail', 'table-row', 'radio',false);")); $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails); $this->add('textarea', 'receipt_text_renewal', ts('Renewal Message')); // Retrieve the name and email of the contact - this will be the TO for receipt email list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID); $this->assign('email', $this->_contributorEmail); $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend'); $this->assign('outBound_option', $mailingInfo['outBound_option']); if (CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'contribution_recur_id')) { if (CRM_Member_BAO_Membership::isCancelSubscriptionSupported($this->_id)) { $this->assign('cancelAutoRenew', CRM_Utils_System::url('civicrm/contribute/unsubscribe', "reset=1&mid={$this->_id}")); } } $this->addFormRule(array('CRM_Member_Form_MembershipRenewal', 'formRule')); if ($this->_context != 'standalone') { //CRM-10223 - allow contribution to be recorded against different contact // causes a conflict in standalone mode so skip in standalone for now $this->addElement('checkbox', 'contribution_contact', ts('Record Payment from a Different Contact?')); $this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft')); $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE)); } }
/** * 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); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_showFeeBlock) { return CRM_Event_Form_EventFees::buildQuickForm($this); } if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //need to assign custom data type to the template $this->assign('customDataType', 'Participant'); $this->applyFilter('__ALL__', 'trim'); if ($this->_action & CRM_Core_Action::DELETE) { if ($this->_single) { $additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_id, NULL, $this->_contactId, FALSE, TRUE)) - 1; if ($additionalParticipant) { $deleteParticipants = array(1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.')); $this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '<br />'); $this->setDefaults(array('delete_participant' => 1)); $this->assign('additionalParticipant', $additionalParticipant); } } $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } if ($this->_single) { $urlPath = 'civicrm/contact/view/participant'; $urlParams = "reset=1&cid={$this->_contactId}&context=participant"; if ($this->_context == 'standalone') { CRM_Contact_Form_NewContact::buildQuickForm($this); $urlParams = 'reset=1&context=standalone'; $urlPath = 'civicrm/participant/add'; } if ($this->_id) { $urlParams .= "&action=update&id={$this->_id}"; } else { $urlParams .= "&action=add"; } if ($this->_mode) { $urlParams .= "&mode={$this->_mode}"; } $url = CRM_Utils_System::url($urlPath, $urlParams, FALSE, NULL, FALSE); } else { $currentPath = CRM_Utils_System::currentPath(); $url = CRM_Utils_System::url($currentPath, '_qf_Participant_display=true', FALSE, NULL, FALSE); } $this->assign('refreshURL', $url); $this->add('hidden', 'past_event'); $events = array(); if ($this->_eID) { $eventEndDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eID, 'end_date'); } $this->assign('past', 0); if ($this->_action & CRM_Core_Action::UPDATE) { $events = CRM_Event_BAO_Event::getEvents(1, FALSE, FALSE); } elseif ($this->getElementValue('past_event') || isset($eventEndDate) && CRM_Utils_Date::currentDBDate() > CRM_Utils_Date::processDate($eventEndDate)) { $pastval = $this->getElementValue('past_event'); $events = CRM_Event_BAO_Event::getEvents($pastval); $this->assign('past', $pastval); } else { $events = CRM_Event_BAO_Event::getEvents(); } if ($this->_mode) { //unset the event which are not monetary when credit card //event registration is used foreach ($events as $key => $val) { $isPaid = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $key, 'is_monetary'); if (!$isPaid) { unset($events[$key]); } } $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE); } // build array(event -> eventType) mapper $query = "\nSELECT civicrm_event.id as id, civicrm_event.event_type_id as event_type_id\nFROM civicrm_event\nWHERE civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0"; $dao = CRM_Core_DAO::executeQuery($query); $eventAndTypeMapping = array(); while ($dao->fetch()) { $eventAndTypeMapping[$dao->id] = $dao->event_type_id; } $eventAndTypeMapping = json_encode($eventAndTypeMapping); // building of mapping ends -- //inherit the campaign from event. $eventCampaigns = array(); $allEventIds = array_keys($events); if (!empty($allEventIds)) { CRM_Core_PseudoConstant::populate($eventCampaigns, 'CRM_Event_DAO_Event', TRUE, 'campaign_id'); } $eventCampaigns = json_encode($eventCampaigns); $element = $this->add('select', 'event_id', ts('Event'), array('' => ts('- select -')) + $events, TRUE, array('onchange' => "buildFeeBlock( this.value ); CRM.buildCustomData( 'Participant', this.value, {$this->_eventNameCustomDataTypeID} ); buildParticipantRole( this.value ); buildEventTypeCustomData( this.value, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' ); loadCampaign( this.value, {$eventCampaigns} );", 'class' => 'huge')); // CRM-6111 // note that embedding JS within PHP files is quite awful, IMO // but we do the same for the onChange element and this form is complex // and i did not want to break it late in the 3.2 cycle $preloadJSSnippet = NULL; if (CRM_Utils_Array::value('reset', $_GET) && $this->_eID) { $preloadJSSnippet = "\ncj(function() {\ncj('#event_id').val( '{$this->_eID}' );\nbuildFeeBlock( {$this->_eID} );\nCRM.buildCustomData( 'Participant', {$this->_eID}, {$this->_eventNameCustomDataTypeID} );\nbuildEventTypeCustomData( {$this->_eID}, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' );\nloadCampaign( {$this->_eID}, {$eventCampaigns} );\n});\n"; } $this->assign('preloadJSSnippet', $preloadJSSnippet); //frozen the field fix for CRM-4171 if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) { if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id')) { $element->freeze(); } } //CRM-7362 --add campaigns. $campaignId = NULL; if ($this->_id) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'campaign_id'); } if (!$campaignId) { $eventId = CRM_Utils_Request::retrieve('eid', 'Positive', $this); if ($eventId) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'campaign_id'); } } CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId); $this->addDateTime('register_date', ts('Registration Date'), TRUE, array('formatType' => 'activityDateTime')); if ($this->_id) { $this->assign('entityID', $this->_id); } $roleids = CRM_Event_PseudoConstant::participantRole(); foreach ($roleids as $rolekey => $rolevalue) { $roleTypes[] = $this->createElement('checkbox', $rolekey, NULL, $rolevalue, array('onclick' => "showCustomData( 'Participant', {$rolekey}, {$this->_roleCustomDataTypeID} );")); } $this->addGroup($roleTypes, 'role_id', ts('Participant Role')); $this->addRule('role_id', ts('Role is required'), 'required'); // CRM-4395 $checkCancelledJs = array('onchange' => "return sendNotification( );"); $confirmJS = NULL; if ($this->_onlinePendingContributionId) { $cancelledparticipantStatusId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus()); $cancelledContributionStatusId = array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')); $checkCancelledJs = array('onchange' => "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});"); $participantStatusId = array_search('Pending from pay later', CRM_Event_PseudoConstant::participantStatus()); $contributionStatusId = array_search('Completed', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')); $confirmJS = array('onclick' => "return confirmStatus( {$participantStatusId}, {$contributionStatusId} );"); } // get the participant status names to build special status array which is used to show notification // checkbox below participant status select $participantStatusName = CRM_Event_PseudoConstant::participantStatus(); $notificationStatuses = array('Cancelled', 'Pending from waitlist', 'Pending from approval', 'Expired'); // get the required status and then implode only ids $notificationStatusIds = implode(',', array_keys(array_intersect($participantStatusName, $notificationStatuses))); $this->assign('notificationStatusIds', $notificationStatusIds); $this->_participantStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); $this->add('select', 'status_id', ts('Participant Status'), array('' => ts('- select -')) + $this->_participantStatuses, TRUE, $checkCancelledJs); $this->addElement('checkbox', 'is_notify', ts('Send Notification'), NULL); $this->add('text', 'source', ts('Event Source')); $noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note'); $this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']); $buttons[] = array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, 'js' => $confirmJS); $path = CRM_Utils_System::currentPath(); $excludeForPaths = array('civicrm/contact/search', 'civicrm/group/search'); if (!in_array($path, $excludeForPaths)) { $buttons[] = array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $confirmJS); } $buttons[] = array('type' => 'cancel', 'name' => ts('Cancel')); $this->addButtons($buttons); if ($this->_action == CRM_Core_Action::VIEW) { $this->freeze(); } }
/** * Build the form object. * * @return void */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates())); $config = CRM_Core_Config::singleton(); $this->assign('currency', $config->defaultCurrencySymbol); $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); if (isset($invoicing)) { $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings)); } // build price set form. $buildPriceSet = FALSE; if ($this->_priceSetId || !empty($_POST['price_set_id'])) { if (!empty($_POST['price_set_id'])) { $buildPriceSet = TRUE; } $getOnlyPriceSetElements = TRUE; if (!$this->_priceSetId) { $this->_priceSetId = $_POST['price_set_id']; $getOnlyPriceSetElements = FALSE; } $this->set('priceSetId', $this->_priceSetId); CRM_Price_BAO_PriceSet::buildPriceSet($this); $optionsMembershipTypes = array(); foreach ($this->_priceSet['fields'] as $pField) { if (empty($pField['options'])) { continue; } foreach ($pField['options'] as $opId => $opValues) { $optionsMembershipTypes[$opId] = CRM_Utils_Array::value('membership_type_id', $opValues, 0); } } $this->assign('autoRenewOption', CRM_Price_BAO_PriceSet::checkAutoRenewForPriceSet($this->_priceSetId)); $this->assign('optionsMembershipTypes', $optionsMembershipTypes); $this->assign('contributionType', CRM_Utils_Array::value('financial_type_id', $this->_priceSet)); // get only price set form elements. if ($getOnlyPriceSetElements) { return; } } // use to build form during form rule. $this->assign('buildPriceSet', $buildPriceSet); if ($this->_action & CRM_Core_Action::ADD) { $buildPriceSet = FALSE; $priceSets = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviMember'); if (!empty($priceSets)) { $buildPriceSet = TRUE; } if ($buildPriceSet) { $this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, NULL, array('onchange' => "buildAmount( this.value );")); } $this->assign('hasPriceSets', $buildPriceSet); } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Membership'); $this->assign('customDataSubType', $this->_memType); $this->assign('entityID', $this->_id); 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; } if ($this->_context == 'standalone') { $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE); } $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -'); $dao = new CRM_Member_DAO_MembershipType(); $dao->domain_id = CRM_Core_Config::domainID(); $dao->find(); // retrieve all memberships $allMemberships = CRM_Member_BAO_Membership::buildMembershipTypeValues($this); $allMembershipInfo = $membershipType = array(); foreach ($allMemberships as $key => $values) { if (!empty($values['is_active'])) { $membershipType[$key] = CRM_Utils_Array::value('name', $values); if ($this->_mode && empty($values['minimum_fee'])) { continue; } else { $memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values); if (empty($selMemTypeOrg[$memberOfContactId])) { $selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, 'display_name', 'id'); $selOrgMemType[$memberOfContactId][0] = ts('- select -'); } if (empty($selOrgMemType[$memberOfContactId][$key])) { $selOrgMemType[$memberOfContactId][$key] = CRM_Utils_Array::value('name', $values); } } // build membership info array, which is used when membership type is selected to: // - set the payment information block // - set the max related block $allMembershipInfo[$key] = array('financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values), 'total_amount' => CRM_Utils_Money::format($values['minimum_fee'], NULL, '%a'), 'total_amount_numeric' => CRM_Utils_Array::value('minimum_fee', $values), 'auto_renew' => CRM_Utils_Array::value('auto_renew', $values), 'has_related' => isset($values['relationship_type_id']), 'max_related' => CRM_Utils_Array::value('max_related', $values)); } } $this->assign('allMembershipInfo', json_encode($allMembershipInfo)); // show organization by default, if only one organization in // the list if (count($selMemTypeOrg) == 2) { unset($selMemTypeOrg[0], $selOrgMemType[0][0]); } //sort membership organization and type, CRM-6099 natcasesort($selMemTypeOrg); foreach ($selOrgMemType as $index => $orgMembershipType) { natcasesort($orgMembershipType); $selOrgMemType[$index] = $orgMembershipType; } $memTypeJs = array('onChange' => "CRM.buildCustomData( 'Membership', this.value );"); //build the form for auto renew. $recurProcessor = $autoRenew = array(); if ($this->_mode || $this->_action & CRM_Core_Action::UPDATE) { $autoRenewElement = $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'), NULL, array('onclick' => "buildReceiptANDNotice( );")); if ($this->_mode) { //get the valid recurring processors. $test = strtolower($this->_mode) == 'test' ? TRUE : FALSE; $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, $test, 'is_recur = 1'); $recurProcessor = array_intersect_key($this->_processors, $recurring); $autoRenew = array(); if (!empty($recurProcessor)) { if (!empty($membershipType)) { $sql = ' SELECT id, auto_renew, duration_unit, duration_interval FROM civicrm_membership_type WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; $recurMembershipTypes = CRM_Core_DAO::executeQuery($sql); while ($recurMembershipTypes->fetch()) { $autoRenew[$recurMembershipTypes->id] = $recurMembershipTypes->auto_renew; foreach (array('id', 'auto_renew', 'duration_unit', 'duration_interval') as $fld) { $this->_recurMembershipTypes[$recurMembershipTypes->id][$fld] = $recurMembershipTypes->{$fld}; } } } $memTypeJs = array('onChange' => "CRM.buildCustomData( 'Membership', this.value ); buildAutoRenew(this.value, null );"); } } } $allowAutoRenew = FALSE; if ($this->_mode && !empty($recurProcessor)) { $allowAutoRenew = TRUE; } $this->assign('allowAutoRenew', $allowAutoRenew); $this->assign('autoRenewOptions', json_encode($autoRenew)); $this->assign('recurProcessor', json_encode($recurProcessor)); // for max_related: a little JS to show/hide & set default value $memTypeJs['onChange'] = "buildMaxRelated(this.value,true); " . $memTypeJs['onChange']; $this->add('text', 'max_related', ts('Max related'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_Membership', 'max_related')); $sel =& $this->addElement('hierselect', 'membership_type_id', ts('Membership Organization and Type'), $memTypeJs); $sel->setOptions(array($selMemTypeOrg, $selOrgMemType)); $elements = array(); if ($sel) { $elements[] = $sel; } $this->applyFilter('__ALL__', 'trim'); if ($this->_action & CRM_Core_Action::ADD) { $this->add('text', 'num_terms', ts('Number of Terms'), array('size' => 6)); } $this->addDate('join_date', ts('Member Since'), FALSE, array('formatType' => 'activityDate')); $this->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'activityDate')); $endDate = $this->addDate('end_date', ts('End Date'), FALSE, array('formatType' => 'activityDate')); if ($endDate) { $elements[] = $endDate; } $this->add('text', 'source', ts('Source'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_Membership', 'source')); //CRM-7362 --add campaigns. $campaignId = NULL; if ($this->_id) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'campaign_id'); } CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId); if (!$this->_mode) { $this->add('select', 'status_id', ts('Membership Status'), array('' => ts('- select -')) + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label')); $statusOverride = $this->addElement('checkbox', 'is_override', ts('Status Override?'), NULL, array('onClick' => 'showHideMemberStatus()')); if ($statusOverride) { $elements[] = $statusOverride; } $this->addElement('checkbox', 'record_contribution', ts('Record Membership Payment?')); $this->add('text', 'total_amount', ts('Amount')); $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money'); $this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime')); $this->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")); $this->add('text', 'trxn_id', ts('Transaction ID')); $this->addRule('trxn_id', ts('Transaction ID already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id')); $allowStatuses = array(); $statuses = CRM_Contribute_PseudoConstant::contributionStatus(); if ($this->_onlinePendingContributionId) { $statusNames = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); foreach ($statusNames as $val => $name) { if (in_array($name, array('In Progress', 'Overdue'))) { continue; } $allowStatuses[$val] = $statuses[$val]; } } else { $allowStatuses = $statuses; } $this->add('select', 'contribution_status_id', ts('Payment Status'), $allowStatuses); $this->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number')); } else { //add field for amount to allow an amount to be entered that differs from minimum $this->add('text', 'total_amount', ts('Amount')); } $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()); //CRM-10223 - allow contribution to be recorded against different contact // causes a conflict in standalone mode so skip in standalone for now $this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different Contact?')); $this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft')); $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE)); $this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), NULL, array('onclick' => "showHideByValue( 'send_receipt', '', 'notice', 'table-row', 'radio', false); showHideByValue( 'send_receipt', '', 'fromEmail', 'table-row', 'radio', false);")); $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails); $this->add('textarea', 'receipt_text_signup', ts('Receipt Message')); // Retrieve the name and email of the contact - this will be the TO for receipt email if ($this->_contactID) { list($this->_memberDisplayName, $this->_memberEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID); $this->assign('emailExists', $this->_memberEmail); $this->assign('displayName', $this->_memberDisplayName); } $isRecur = FALSE; if ($this->_action & CRM_Core_Action::UPDATE) { $recurContributionId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'contribution_recur_id'); if ($recurContributionId && !CRM_Member_BAO_Membership::isSubscriptionCancelled($this->_id)) { $isRecur = TRUE; if (CRM_Member_BAO_Membership::isCancelSubscriptionSupported($this->_id)) { $this->assign('cancelAutoRenew', CRM_Utils_System::url('civicrm/contribute/unsubscribe', "reset=1&mid={$this->_id}")); } foreach ($elements as $elem) { $elem->freeze(); } } } $this->assign('isRecur', $isRecur); $this->addFormRule(array('CRM_Member_Form_Membership', 'formRule'), $this); $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend'); $this->assign('outBound_option', $mailingInfo['outBound_option']); parent::buildQuickForm(); }
/** * Function to actually build the components of the form * * @return void * @access public */ function buildQuickForm() { if (!$this->_mode) { $action = array(CRM_Core_Action::VIEW => 'view', CRM_Core_Action::UPDATE => 'edit'); CRM_Core_Error::fatal(ts('You do not have permission to %1 this absence', array('%1' => $action[$this->_action]))); return; } $this->_cancelURL = CRM_Utils_System::url('civicrm/absences', "cid={$this->_targetContactID}"); $this->_cancelURL = str_replace('&', '&', $this->_cancelURL); $this->addElement('hidden', 'cancelURL', $this->_cancelURL); $session = CRM_Core_Session::singleton(); $session->replaceUserContext($this->_cancelURL); $statusTypes = array_flip(CRM_HRAbsence_BAO_HRAbsenceType::getActivityStatus('name')); $buttons = array('cancel' => array('type' => 'cancel', 'name' => ts('Cancel')), $statusTypes['Scheduled'] => array('type' => 'done', 'name' => ts('Save'), 'subName' => 'save', 'isDefault' => TRUE), $statusTypes['Completed'] => array('type' => 'done', 'name' => ts('Approve'), 'subName' => 'approve'), $statusTypes['Cancelled'] => array('type' => 'done', 'name' => ts('Cancel Absence Request'), 'subName' => 'cancelabsence'), $statusTypes['Rejected'] => array('type' => 'done', 'name' => ts('Reject'), 'subName' => 'reject')); $contactField = $this->addEntityRef('contacts_id', ts('Employee'), array('api' => array('params' => array('contact_type' => 'Individual'))), TRUE); // No edit allowed if ($this->_targetContactID) { $contactField->freeze(); } $activityTypes = CRM_HRAbsence_BAO_HRAbsenceType::getActivityTypes(); $this->_absenceType = $activityTypes[$this->_activityTypeID]; $this->assign('absenceType', $this->_absenceType); $primaryJobContractId = $this->getPrimaryJobContractId($this->_targetContactID); $resultHRJobDetails = null; if ($primaryJobContractId) { $resultHRJobDetails = civicrm_api3('HRJobDetails', 'get', array('sequential' => 1, 'jobcontract_id' => $primaryJobContractId)); } if (!empty($resultHRJobDetails['values'])) { $this->_empPosition = $resultHRJobDetails['values'][0]['position']; $this->assign('emp_position', $this->_empPosition); } $this->assign('emp_name', CRM_Contact_BAO_Contact::displayName($this->_targetContactID)); if ($this->_mode == 'view') { $resultAbsences = civicrm_api3('Activity', 'get', array('source_record_id' => $this->_activityId, 'option_sort' => "activity_date_time ASC", 'option.limit' => 365)); $countDays = $approvedDays = 0; $absenceDateDuration = array(); $actStatus = CRM_Core_OptionGroup::values('activity_status'); foreach ($resultAbsences['values'] as $key => $val) { $convertedDate = date("M d, Y (D)", strtotime($val['activity_date_time'])); if ($val['duration'] == $this->_jobHoursTime['Full_Time'] * 60) { $converteddays = "Full Day"; $countDays = $countDays + 1; if ($val['status_id'] == array_search('Completed', $actStatus)) { $absenceStatus = "Approved"; $approvedDays = $approvedDays + 1; } elseif ($val['status_id'] == array_search('Rejected', $actStatus) || $val['status_id'] == array_search('Scheduled', $actStatus)) { $absenceStatus = "Unapproved"; } elseif ($val['status_id'] == array_search('Cancelled', $actStatus)) { $absenceStatus = "Cancelled"; } } elseif ($val['duration'] == $this->_jobHoursTime['Part_Time'] * 60) { $converteddays = "Half Day"; $countDays = $countDays + 0.5; if ($val['status_id'] == array_search('Completed', $actStatus)) { $absenceStatus = "Approved"; $approvedDays = $approvedDays + 0.5; } elseif ($val['status_id'] == array_search('Rejected', $actStatus) || $val['status_id'] == array_search('Scheduled', $actStatus)) { $absenceStatus = "Unapproved"; } elseif ($val['status_id'] == array_search('Cancelled', $actStatus)) { $absenceStatus = "Cancelled"; } } else { $converteddays = $absenceStatus = "Holiday"; } $absenceDateDuration[$convertedDate] = array('duration' => $converteddays, 'status' => $absenceStatus); } $keys = array_keys($absenceDateDuration); $count = count($keys) - 1; $fromdateVal = explode('(', $keys[0]); $todateVal = explode('(', $keys[$count]); $this->assign('fromDate', date("M j, Y", strtotime($fromdateVal[0]))); $this->assign('toDate', date("M j, Y", strtotime($todateVal[0]))); $this->assign('absenceDateDuration', $absenceDateDuration); $this->_fromDate = $fromdateVal[0]; $this->_toDate = $todateVal[0]; $this->assign('totalDays', $countDays); $this->assign('approvedDays', $approvedDays); } if ($this->_action && (CRM_Core_Action::ADD || CRM_Core_Action::UPDATE) && $this->_mode == 'edit') { $this->assign('customDataSubType', $this->_activityTypeID); if ($this->_customValueCount) { CRM_Custom_Form_CustomData::buildQuickForm($this); } $this->assign('loginUserID', $this->_loginUserID); if (empty($this->_managerContactID)) { $this->_managerContactID = NULL; } $this->add('hidden', 'date_values', '', array('id' => 'date_values')); $this->add('hidden', 'tot_app_days', '', array('id' => 'tot_app_days')); } $this->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'activityDate')); $this->addDate('end_date', ts('End Date / Time'), FALSE, array('formatType' => 'activityDate')); if ($this->_mode == 'edit') { if ($this->_action && $this->_action == CRM_Core_Action::ADD) { $approveButton = array('type' => 'done', 'name' => ts('Save and Approve'), 'subName' => 'saveandapprove', 'isDefault' => TRUE); $this->addButtons(array($approveButton)); } else { $this->add('hidden', 'source_record_id', $this->_aid); $result = civicrm_api3('Activity', 'get', array('sequential' => 1, 'source_record_id' => $this->_aid, 'option_sort' => "activity_date_time ASC", 'option.limit' => 365)); $start_date = date_create($result['values'][0]['activity_date_time']); $end_date = date_create($result['values'][$result['count'] - 1]['activity_date_time']); $this->assign('fromDate', date_format($start_date, 'm/d/Y')); $this->assign('toDate', date_format($end_date, 'm/d/Y')); global $user; $today = time(); $date1 = new DateTime(date("M j, Y", $today)); $intervals = $date1->diff($end_date); if (CRM_Core_Permission::check('administer CiviCRM') || CRM_Core_Permission::check('edit HRAbsences') || $intervals->days >= 0 && $intervals->invert == 0 && (!empty($this->_managerContactID) && in_array($this->_loginUserID, $this->_managerContactID) || self::isContactAccessible($this->_targetContactID) == CRM_Core_Permission::EDIT)) { if ($this->_actStatusId != $statusTypes['Scheduled']) { unset($buttons[$this->_actStatusId]); } } elseif (CRM_Core_Permission::check('manage own HRAbsences') && $this->_targetContactID == $this->_loginUserID) { unset($buttons[$statusTypes['Completed']], $buttons[$statusTypes['Rejected']]); } $this->addButtons($buttons); } } elseif ($this->_mode == 'view') { global $user; $now = time(); $datetime1 = new DateTime(date("M j, Y", $now)); $datetime2 = new DateTime($this->_toDate); $interval = $datetime1->diff($datetime2); $this->addButtons(array($buttons['cancel'])); if ($interval->days >= 0 && $interval->invert == 0 && ($this->_actStatusId == $statusTypes['Scheduled'] || $this->_actStatusId == $statusTypes['Completed']) && $this->_targetContactID == $this->_loginUserID) { $this->addButtons(array($buttons['cancel'], $buttons[$statusTypes['Cancelled']])); } } if ($this->_action == CRM_Core_Action::UPDATE || $this->_action == CRM_Core_Action::ADD) { $this->addFormRule(array('CRM_HRAbsence_Form_AbsenceRequest', 'formRule')); } if (CRM_Core_Permission::check('administer CiviCRM') || CRM_Core_Permission::check('edit HRAbsences') || !empty($this->_managerContactID) && in_array($this->_loginUserID, $this->_managerContactID)) { $this->_showhide = 1; } else { $this->_showhide = 0; } $this->assign('showhide', $this->_showhide); }