function setDefaultValues() { $defaults = array('include_morning' => $this->_includeMorning, 'show_details' => $this->_showDetails, 'not_signed_out' => $this->_notSignedOut); list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($this->_startDate); list($defaults['end_date'], $defaults['end_date_time']) = CRM_Utils_Date::setDateDefaults($this->_endDate); return $defaults; }
public function setDefaultValues($freez = 1) { $defaults = array(); if ($this->_objectID) { $sql = "SELECT * FROM {$this->_tableName} WHERE id={$this->_objectID}"; $dao = CRM_Core_DAO::executeQuery($sql); if ($this->_action & CRM_Core_Action::DELETE) { if ($this->_object != 'fee') { while ($dao->fetch()) { $this->assign('class', $dao->class); } } return $defaults; } while ($dao->fetch()) { foreach ($this->_customFields as $field) { if (property_exists($dao, $field)) { if (in_array($field, array('signin_time', 'signout_time', 'fee_date'))) { list($defaults[$field], $defaults[$field . '_time']) = CRM_Utils_Date::setDateDefaults($dao->{$field}); } else { $defaults[$field] = $dao->{$field}; } } } } } elseif ($id = CRM_Utils_Request::retrieve('id', 'Integer', $this, false)) { $defaults['entity_id'] = $id; } return $defaults; }
/** * This function sets the default values for the form. For edit/view mode * the default values are retrieved from the database * * @access public * * @return None */ function setDefaultValues(&$form) { $defaults = array(); if ($form->_context == 'caseActivity') { return $defaults; } list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(); // set default case status, case type, encounter medium, location type and phone type defaults are set in DB $caseStatus = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, 'AND is_default = 1'); if (count($caseStatus) == 1) { $defaults['status_id'] = key($caseStatus); } $caseType = CRM_Core_OptionGroup::values('case_type', FALSE, FALSE, FALSE, 'AND is_default = 1'); if (count($caseType) == 1) { $defaults['case_type_id'] = key($caseType); } $medium = CRM_Core_OptionGroup::values('encounter_medium', FALSE, FALSE, FALSE, 'AND is_default = 1'); if (count($medium) == 1) { $defaults['medium_id'] = key($medium); } $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); if ($defaultLocationType->id) { $defaults['location[1][location_type_id]'] = $defaultLocationType->id; } $phoneType = CRM_Core_OptionGroup::values('phone_type', FALSE, FALSE, FALSE, 'AND is_default = 1'); if (count($phoneType) == 1) { $defaults['location[1][phone][1][phone_type_id]'] = key($phoneType); } return $defaults; }
/** * Set the default form values. * * @return array * the default array reference */ public function setDefaultValues() { $defaults = array(); // note we intentionally overwrite value since we use it as defaults // and its all pass by value // we need to figure out the type, so we can either set an array element // or a scalar -- FIX ME sometime please foreach ($_GET as $key => $value) { if (substr($key, 0, 7) == 'custom_' || $key == "preferred_communication_method") { if (strpos($value, CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE) { $v = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); $value = array(); foreach ($v as $item) { if ($item) { $value[$item] = $item; } } } } elseif ($key == 'group' || $key == 'tag') { $v = explode(',', $value); $value = array(); foreach ($v as $item) { $value[$item] = 1; } } elseif (in_array($key, array('birth_date', 'deceased_date'))) { list($value) = CRM_Utils_Date::setDateDefaults($value); } $defaults[$key] = $value; } return $defaults; }
/** * @param string $fieldName * @param $field * @param $defaults * * @return bool */ public static function dateParam($fieldName, &$field, &$defaults) { // type = 12 (datetime) is not recognized by Utils_Type::escape() method, // and therefore the below hack $type = 4; $from = self::getTypedValue("{$fieldName}_from", $type); $to = self::getTypedValue("{$fieldName}_to", $type); $relative = CRM_Utils_Array::value("{$fieldName}_relative", $_GET); if ($relative) { list($from, $to) = CRM_Report_Form::getFromTo($relative, NULL, NULL); $from = substr($from, 0, 8); $to = substr($to, 0, 8); } if (!($from || $to)) { return FALSE; } if ($from !== NULL) { $dateFrom = CRM_Utils_Date::setDateDefaults($from); if ($dateFrom !== NULL && !empty($dateFrom[0])) { $defaults["{$fieldName}_from"] = $dateFrom[0]; } } if ($to !== NULL) { $dateTo = CRM_Utils_Date::setDateDefaults($to); if ($dateTo !== NULL && !empty($dateTo[0])) { $defaults["{$fieldName}_to"] = $dateTo[0]; } } }
public function setDefaultValues() { $defaults = array(); try { $defaults['rood_mtype'] = civicrm_api3('MembershipType', 'getvalue', array('return' => 'id', 'name' => 'Lid SP en ROOD')); } catch (Exception $e) { //do nothing } try { $defaults['rood_mstatus'] = civicrm_api3('MembershipStatus', 'getvalue', array('return' => 'id', 'name' => 'Correctie')); } catch (Exception $e) { //do nothing } try { $defaults['sp_mtype'] = civicrm_api3('MembershipType', 'getvalue', array('return' => 'id', 'name' => 'Lid SP')); } catch (Exception $e) { //do nothing } try { $status = civicrm_api3('MembershipStatus', 'getvalue', array('return' => 'id', 'name' => 'current')); $defaults['member_status_id'][$status] = $status; } catch (Exception $e) { //do nothing } $date = new DateTime(); $date->modify('-26 years'); $date->modify('first day of this year'); list($defaults['birth_date_from']) = CRM_Utils_Date::setDateDefaults($date->format('Y-m-d')); $date->modify('last day of this year'); list($defaults['birth_date_to']) = CRM_Utils_Date::setDateDefaults($date->format('Y-m-d')); $minimum_fee = CRM_Core_BAO_Setting::getItem('nl.sp.rood', 'minimum_fee', null, '5.00'); $defaults['minimum_fee'] = $minimum_fee; return $defaults; }
/** * This function sets the default values for the form. For edit/view mode * the default values are retrieved from the database * * @access public * @return None */ function setDefaultValues(&$form) { $defaults = array(); if ($form->_context == 'caseActivity') { return $defaults; } require_once 'CRM/Utils/Date.php'; list($defaults['start_date']) = CRM_Utils_Date::setDateDefaults(); // set case status to 'ongoing' $defaults['status_id'] = 1; // set default encounter medium, location type and phone type defaults are set in DB require_once "CRM/Core/OptionGroup.php"; $medium = CRM_Core_OptionGroup::values('encounter_medium', false, false, false, 'AND is_default = 1'); if (count($medium) == 1) { $defaults['medium_id'] = key($medium); } require_once 'CRM/Core/BAO/LocationType.php'; $defaultLocationType =& CRM_Core_BAO_LocationType::getDefault(); if ($defaultLocationType->id) { $defaults['location[1][location_type_id]'] = $defaultLocationType->id; } $phoneType = CRM_Core_OptionGroup::values('phone_type', false, false, false, 'AND is_default = 1'); if (count($phoneType) == 1) { $defaults['location[1][phone][1][phone_type_id]'] = key($phoneType); } return $defaults; }
/** * Set default values for the form. For edit/view mode * the default values are retrieved from the database * * * @return array */ public function setDefaultValues() { $defaults = array(); //Always pass current event's start date by default $currentEventStartDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'start_date', 'id'); list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($currentEventStartDate, 'activityDateTime'); $recurringEntityDefaults = CRM_Core_Form_RecurringEntity::setDefaultValues(); return array_merge($defaults, $recurringEntityDefaults); }
/** * This function sets the default values for the form. For edit/view mode * the default values are retrieved from the database * * @access public * * @return None */ static function setDefaultValues(&$form) { $defaults = array(); $defaults['is_reset_timeline'] = 1; $defaults['reset_date_time'] = array(); list($defaults['reset_date_time'], $defaults['reset_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime'); $defaults['case_type_id'] = $form->_caseTypeId; return $defaults; }
/** * This function sets the default values for the form. For edit/view mode * the default values are retrieved from the database * * @access public * @return None */ function setDefaultValues(&$form) { $defaults = array(); $defaults['is_reset_timeline'] = 1; $defaults['reset_date_time'] = array(); list($defaults['reset_date_time'], $defaults['reset_date_time_time']) = CRM_Utils_Date::setDateDefaults(null, 'activityDateTime'); $caseType = CRM_Case_PseudoConstant::caseTypeName($form->_caseId); $defaults['case_type_id'] = $caseType['id']; return $defaults; }
function setDefaultValues() { $defaults = array(); if ($this->_id) { $defaults = CRM_HRAbsence_BAO_HRAbsencePeriod::getDefaultValues($this->_id); list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['start_date'], 'activityDateTime'); list($defaults['end_date'], $defaults['end_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['end_date'], 'activityDateTime'); } return $defaults; }
/** * This function sets the default values for the form. * the default values are retrieved from the database * * @access public * @return None */ function setDefaultValues() { $defaults = array(); if ($this->_id) { $params['id'] = $this->_id; require_once 'CRM/Pledge/BAO/Payment.php'; CRM_Pledge_BAO_Payment::retrieve($params, $defaults); list($defaults['scheduled_date']) = CRM_Utils_Date::setDateDefaults($defaults['scheduled_date']); $statuses = CRM_Contribute_PseudoConstant::contributionStatus(); $this->assign('status', $statuses[$defaults['status_id']]); } return $defaults; }
function setDefaultValues() { $defaults = array(); list($defaults['ptc_date'], $defaults['ptc_date_time']) = CRM_Utils_Date::setDateDefaults(date("Y-m-d", time() + 14 * 24 * 60 * 60)); $defaults['ptc_duration'] = 25; for ($i = 1; $i < 6; $i++) { $time = (int) ($i + 1) / 2; $defaults["ptc_date_{$i}_time"] = "{$time}:00 PM"; $i++; $defaults["ptc_date_{$i}_time"] = "{$time}:30 PM"; } return $defaults; }
/** * This function is called prior to building and submitting the form and after the preProcess */ function setDefaultValues() { $defaults = array(); $defaults = $this->_values; // current employer id $defaults['current_employer_id'] = trim($defaults['employer_id']); // datum in dienst if (isset($defaults['Datum_in_dienst'])) { list($defaults['Datum_in_dienst']) = CRM_Utils_Date::setDateDefaults($defaults['Datum_in_dienst']); // list is needed or else it does not work } return $defaults; }
/** * Set default values for the form. * the default values are retrieved from the database * * * @return void */ public function setDefaultValues() { $defaults = array(); if ($this->_id) { $params['id'] = $this->_id; CRM_Pledge_BAO_PledgePayment::retrieve($params, $defaults); list($defaults['scheduled_date']) = CRM_Utils_Date::setDateDefaults($defaults['scheduled_date']); if (isset($defaults['contribution_id'])) { $this->assign('pledgePayment', TRUE); } $status = CRM_Contribute_PseudoConstant::contributionStatus($defaults['status_id']); $this->assign('status', $status); } $defaults['option_type'] = 1; return $defaults; }
function setDefaultValues() { $defaults = array(); if ($this->_id) { $params = array('id' => $this->_id); CRM_Activity_BAO_Activity::retrieve($params, $defaults); if (!CRM_Utils_Array::value('activity_date_time', $defaults)) { list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime'); } list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime'); $status = CRM_Core_PseudoConstant::activityStatus(); $defaults['status_id'] = $defaults['status_id'] == array_search('Scheduled', $status) ? 1 : 0; } else { $defaults['status_id'] = 1; } return $defaults; }
/** * This function sets the default values for the form. For edit/view mode * the default values are retrieved from the database * * @access public * * @return None */ function setDefaultValues(&$form) { $defaults = array(); $openCaseActivityType = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name'); $openCaseParams = array('activity_type_id' => $openCaseActivityType); $openCaseInfo = CRM_Case_BAO_Case::getCaseActivityDates($form->_caseId, $openCaseParams, TRUE); if (empty($openCaseInfo)) { list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(); } else { // We know there can only be one result $openCaseInfo = current($openCaseInfo); // store activity id for updating it later $form->openCaseActivityId = $openCaseInfo['id']; list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($openCaseInfo['activity_date']); } return $defaults; }
/** * Overridden parent method to set default values * * @return array $defaultValues * @access public */ public function setDefaultValues() { $defaultValues = parent::setDefaultValues(); $defaultValues['rule_action_id'] = $this->ruleActionId; if (!empty($this->ruleAction->action_params)) { $data = unserialize($this->ruleAction->action_params); } if (!empty($data['number_of_days'])) { $defaultValues['number_of_days'] = $data['number_of_days']; } if (empty($data['thank_you_radio'])) { $defaultValues['thank_you_radio'] = 0; } else { $defaultValues['thank_you_radio'] = $data['thank_you_radio']; } if (empty($data['thank_you_date'])) { list($defaultValues['thank_you_date']) = CRM_Utils_Date::setDateDefaults(date('Y-m-d')); } else { list($defaultValues['thank_you_date']) = CRM_Utils_Date::setDateDefaults($data['thank_you_date']); } return $defaultValues; }
public function setDefaultValues($freez = 1) { $defaults = array(); if ($this->_action & (CRM_Core_Action::DISABLE | CRM_Core_Action::ENABLE | CRM_Core_Action::ADD)) { return $defaults; } if ($this->_indexID) { $params = array(1 => array($this->_indexID, 'Integer')); $sql = "SELECT * FROM sfschool_extended_care_source WHERE id=%1"; $dao = CRM_Core_DAO::executeQuery($sql, $params); while ($dao->fetch()) { foreach ($this->_customFields as $field => $type) { if (property_exists($dao, $field)) { if (in_array($field, array('start_date', 'end_date'))) { list($defaults[$field], $defaults[$field . '_time']) = CRM_Utils_Date::setDateDefaults($dao->{$field}); } else { $defaults[$field] = $dao->{$field}; } } } } } return $defaults; }
function setDefaultValues() { $origID = NULL; $defaults = array(); if ($this->_action & CRM_Core_Action::COPY) { $origID = $this->_cloneID; } else { if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) { $origID = $this->_id; } } if ($origID) { $params = array('id' => $origID); CRM_CiviDiscount_BAO_Item::retrieve($params, $defaults); } $defaults['is_active'] = $origID ? CRM_Utils_Array::value('is_active', $defaults) : 1; $defaults['autodiscount_active_only'] = $origID ? CRM_Utils_Array::value('autodiscount_active_only', $defaults) : 1; $defaults['discount_msg_enabled'] = $origID ? CRM_Utils_Array::value('discount_msg_enabled', $defaults) : 0; $defaults['count_max'] = empty($defaults['count_max']) ? '' : $defaults['count_max']; // assign the defaults to smarty so delete can use it $this->assign('discountValue', $defaults); $this->applyFilterDefaults($defaults); $this->applyAutoDiscountDefaults($defaults); foreach ($this->_multiValued as $mv => $info) { if (!empty($defaults[$mv])) { $v = substr($defaults[$mv], 1, -1); $values = explode(CRM_Core_DAO::VALUE_SEPARATOR, $v); $defaults[$mv] = array(); if (!empty($values)) { foreach ($values as $val) { $defaults[$mv][] = $val; } } } } if (!empty($defaults['active_on'])) { list($defaults['active_on']) = CRM_Utils_Date::setDateDefaults($defaults['active_on']); } if (!empty($defaults['expire_on'])) { list($defaults['expire_on']) = CRM_Utils_Date::setDateDefaults($defaults['expire_on']); } if (!empty($defaults['organization_id'])) { $this->_orgID = $defaults['organization_id']; } // Convert if using html if (!empty($defaults['discount_msg'])) { $defaults['discount_msg'] = html_entity_decode($defaults['discount_msg']); } return $defaults; }
/** * Build the form object. */ public function buildQuickForm() { $this->addYesNo('is_monetary', ts('Paid Event'), NULL, NULL, array('onclick' => "return showHideByValue('is_monetary','0','event-fees','block','radio',false);")); //add currency element. $this->addCurrency('currency', ts('Currency'), FALSE); $paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(); $this->assign('paymentProcessor', $paymentProcessor); $this->addEntityRef('payment_processor', ts('Payment Processor'), array('entity' => 'PaymentProcessor', 'multiple' => TRUE, 'select' => array('minimumInputLength' => 0))); // financial type if (!CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() || CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && CRM_Core_Permission::check('administer CiviCRM Financial Types')) { $this->addSelect('financial_type_id'); } else { CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, CRM_Core_Action::ADD); $this->addSelect('financial_type_id', array('context' => 'search', 'options' => $financialTypes)); } // add pay later options $this->addElement('checkbox', 'is_pay_later', ts('Enable Pay Later option?'), NULL, array('onclick' => "return showHideByValue('is_pay_later','','payLaterOptions','block','radio',false);")); $this->addElement('textarea', 'pay_later_text', ts('Pay Later Label'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_text'), FALSE); $this->add('wysiwyg', 'pay_later_receipt', ts('Pay Later Instructions'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_receipt')); $this->addElement('checkbox', 'is_billing_required', ts('Billing address required')); $this->add('text', 'fee_label', ts('Fee Label')); $price = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviEvent'); if (CRM_Utils_System::isNull($price)) { $this->assign('price', FALSE); } else { $this->assign('price', TRUE); } $this->add('select', 'price_set_id', ts('Price Set'), array('' => ts('- none -')) + $price, NULL, array('onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);")); $default = array($this->createElement('radio', NULL, NULL, NULL, 0)); $this->add('hidden', 'price_field_id', '', array('id' => 'price_field_id')); for ($i = 1; $i <= self::NUM_OPTION; $i++) { // label $this->add('text', "label[{$i}]", ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label')); $this->add('hidden', "price_field_value[{$i}]", '', array('id' => "price_field_value[{$i}]")); // value $this->add('text', "value[{$i}]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value')); $this->addRule("value[{$i}]", ts('Please enter a valid money value for this field (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); // default $default[] = $this->createElement('radio', NULL, NULL, NULL, $i); } $this->addGroup($default, 'default'); $this->addElement('checkbox', 'is_discount', ts('Discounts by Signup Date?'), NULL, array('onclick' => "warnDiscountDel(); return showHideByValue('is_discount','','discount','block','radio',false);")); $discountSection = $this->get('discountSection'); $this->assign('discountSection', $discountSection); // form fields of Discount sets $defaultOption = array(); $_showHide = new CRM_Core_ShowHideBlocks('', ''); for ($i = 1; $i <= self::NUM_DISCOUNT; $i++) { //the show hide blocks $showBlocks = 'discount_' . $i; if ($i > 2) { $_showHide->addHide($showBlocks); } else { $_showHide->addShow($showBlocks); } //Increment by 1 of start date of previous end date. if (is_array($this->_submitValues) && !empty($this->_submitValues['discount_name'][$i]) && !empty($this->_submitValues['discount_name'][$i + 1]) && isset($this->_submitValues['discount_end_date']) && isset($this->_submitValues['discount_end_date'][$i]) && $i < self::NUM_DISCOUNT - 1) { $end_date = CRM_Utils_Date::processDate($this->_submitValues['discount_end_date'][$i]); if (!empty($this->_submitValues['discount_end_date'][$i + 1]) && empty($this->_submitValues['discount_start_date'][$i + 1])) { list($this->_submitValues['discount_start_date'][$i + 1]) = CRM_Utils_Date::setDateDefaults(date('Y-m-d', strtotime("+1 days {$end_date}"))); } } //Decrement by 1 of end date from next start date. if ($i > 1 && is_array($this->_submitValues) && !empty($this->_submitValues['discount_name'][$i]) && !empty($this->_submitValues['discount_name'][$i - 1]) && isset($this->_submitValues['discount_start_date']) && isset($this->_submitValues['discount_start_date'][$i])) { $start_date = CRM_Utils_Date::processDate($this->_submitValues['discount_start_date'][$i]); if (!empty($this->_submitValues['discount_start_date'][$i]) && empty($this->_submitValues['discount_end_date'][$i - 1])) { list($this->_submitValues['discount_end_date'][$i - 1]) = CRM_Utils_Date::setDateDefaults(date('Y-m-d', strtotime("-1 days {$start_date}"))); } } //discount name $this->add('text', 'discount_name[' . $i . ']', ts('Discount Name'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceSet', 'title')); $this->add('hidden', "discount_price_set[{$i}]", '', array('id' => "discount_price_set[{$i}]")); //discount start date $this->addDate('discount_start_date[' . $i . ']', ts('Discount Start Date'), FALSE, array('formatType' => 'activityDate')); //discount end date $this->addDate('discount_end_date[' . $i . ']', ts('Discount End Date'), FALSE, array('formatType' => 'activityDate')); } $_showHide->addToTemplate(); $this->addElement('submit', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'), array('class' => 'crm-form-submit cancel')); $this->buildAmountLabel(); parent::buildQuickForm(); }
/** * This function sets the default values for the form. * * @access public * * @return void */ function setDefaultValues() { if (empty($this->_fields)) { return; } // for add mode set smart defaults if ($this->_action & CRM_Core_Action::ADD) { list($currentDate, $currentTime) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime'); //get all status $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $completeStatus = array_search('Completed', $allStatus); $specialFields = array('join_date' => $currentDate, 'receive_date' => $currentDate, 'receive_date_time' => $currentTime, 'contribution_status_id' => $completeStatus); for ($rowNumber = 1; $rowNumber <= $this->_batchInfo['item_count']; $rowNumber++) { foreach ($specialFields as $key => $value) { $defaults['field'][$rowNumber][$key] = $value; } } } else { // get the cached info from data column of civicrm_batch $data = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', $this->_batchId, 'data'); $defaults = json_decode($data, TRUE); $defaults = $defaults['values']; } return $defaults; }
/** * Set default values for the form. MobileProvider that in edit/view mode * the default values are retrieved from the database * * * @return void */ public function setDefaultValues() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::setDefaultValues($this); } if ($this->_priceSetId) { return CRM_Price_BAO_PriceSet::setDefaultPriceSet($this, $defaults); } $defaults = parent::setDefaultValues(); //setting default join date and receive date list($now, $currentTime) = CRM_Utils_Date::setDateDefaults(); if ($this->_action == CRM_Core_Action::ADD) { $defaults['receive_date'] = $now; $defaults['receive_date_time'] = $currentTime; } if (is_numeric($this->_memType)) { $defaults['membership_type_id'] = array(); $defaults['membership_type_id'][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'member_of_contact_id', 'id'); $defaults['membership_type_id'][1] = $this->_memType; } else { $defaults['membership_type_id'] = $this->_memType; } $defaults['num_terms'] = 1; if (!empty($defaults['id'])) { if ($this->_onlinePendingContributionId) { $defaults['record_contribution'] = $this->_onlinePendingContributionId; } else { $contributionId = CRM_Core_DAO::singleValueQuery("\n SELECT contribution_id\n FROM civicrm_membership_payment\n WHERE membership_id = {$this->_id}\n ORDER BY contribution_id\n DESC limit 1"); if ($contributionId) { $defaults['record_contribution'] = $contributionId; } } } //set Soft Credit Type to Gift by default $scTypes = CRM_Core_OptionGroup::values("soft_credit_type"); $defaults['soft_credit_type_id'] = CRM_Utils_Array::value(ts('Gift'), array_flip($scTypes)); if (!empty($defaults['record_contribution']) && !$this->_mode) { $contributionParams = array('id' => $defaults['record_contribution']); $contributionIds = array(); //keep main object campaign in hand. $memberCampaignId = CRM_Utils_Array::value('campaign_id', $defaults); CRM_Contribute_BAO_Contribution::getValues($contributionParams, $defaults, $contributionIds); //get back original object campaign id. $defaults['campaign_id'] = $memberCampaignId; if (!empty($defaults['receive_date'])) { list($defaults['receive_date']) = CRM_Utils_Date::setDateDefaults($defaults['receive_date']); } // Contribution::getValues() over-writes the membership record's source field value - so we need to restore it. if (!empty($defaults['membership_source'])) { $defaults['source'] = $defaults['membership_source']; } } //CRM-13420 if (empty($defaults['payment_instrument_id'])) { $defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1')); } // User must explicitly choose to send a receipt in both add and update mode. $defaults['send_receipt'] = 0; if ($this->_action & CRM_Core_Action::UPDATE) { // in this mode by default uncheck this checkbox unset($defaults['record_contribution']); } if (!empty($defaults['id'])) { $subscriptionCancelled = CRM_Member_BAO_Membership::isSubscriptionCancelled($this->_id); } $alreadyAutoRenew = FALSE; if (!empty($defaults['contribution_recur_id']) && !$subscriptionCancelled) { $defaults['auto_renew'] = 1; $alreadyAutoRenew = TRUE; } $this->assign('alreadyAutoRenew', $alreadyAutoRenew); $this->assign('member_is_test', CRM_Utils_Array::value('member_is_test', $defaults)); $this->assign('membership_status_id', CRM_Utils_Array::value('status_id', $defaults)); if (!empty($defaults['is_pay_later'])) { $this->assign('is_pay_later', TRUE); } if ($this->_mode) { // set default country from config if no country set $config = CRM_Core_Config::singleton(); if (empty($defaults["billing_country_id-{$this->_bltID}"])) { $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry; } if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) { $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince; } $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID); $defaults = array_merge($defaults, $billingDefaults); // // hack to simplify credit card entry for testing // $defaults['credit_card_type'] = 'Visa'; // $defaults['credit_card_number'] = '4807731747657838'; // $defaults['cvv2'] = '000'; // $defaults['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' ); } $dates = array('join_date', 'start_date', 'end_date'); foreach ($dates as $key) { if (!empty($defaults[$key])) { list($defaults[$key]) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value($key, $defaults)); } } //setting default join date if there is no join date if (empty($defaults['join_date'])) { $defaults['join_date'] = $now; } if (!empty($defaults['membership_end_date'])) { $this->assign('endDate', $defaults['membership_end_date']); } return $defaults; }
function fixFormValues() { // if this search has been forced // then see if there are any get values, and if so over-ride the post values // note that this means that GET over-rides POST :) if (!$this->_force) { return; } $status = CRM_Utils_Request::retrieve('status', 'String', CRM_Core_DAO::$_nullObject); if ($status) { $status = explode(',', $status); $tempStatus = array(); foreach ($status as $value) { $tempStatus[$value] = 1; } $this->_formValues['member_status_id'] = $tempStatus; $this->_defaults['member_status_id'] = $tempStatus; } $membershipType = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject); if ($membershipType) { $this->_formValues['member_membership_type_id'] = array($membershipType => 1); $this->_defaults['member_membership_type_id'] = array($membershipType => 1); } $cid = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject); if ($cid) { $cid = CRM_Utils_Type::escape($cid, 'Integer'); if ($cid > 0) { $this->_formValues['contact_id'] = $cid; list($display, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($cid); $this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name'); // also assign individual mode to the template $this->_single = TRUE; } } $fromDate = CRM_Utils_Request::retrieve('start', 'Date', CRM_Core_DAO::$_nullObject); if ($fromDate) { list($date) = CRM_Utils_Date::setDateDefaults($fromDate); $this->_formValues['member_start_date_low'] = $this->_defaults['member_start_date_low'] = $date; } $toDate = CRM_Utils_Request::retrieve('end', 'Date', CRM_Core_DAO::$_nullObject); if ($toDate) { list($date) = CRM_Utils_Date::setDateDefaults($toDate); $this->_formValues['member_start_date_high'] = $this->_defaults['member_start_date_high'] = $date; } $joinDate = CRM_Utils_Request::retrieve('join', 'Date', CRM_Core_DAO::$_nullObject); if ($joinDate) { list($date) = CRM_Utils_Date::setDateDefaults($joinDate); $this->_formValues['member_join_date_low'] = $this->_defaults['member_join_date_low'] = $date; } $joinEndDate = CRM_Utils_Request::retrieve('joinEnd', 'Date', CRM_Core_DAO::$_nullObject); if ($joinEndDate) { list($date) = CRM_Utils_Date::setDateDefaults($joinEndDate); $this->_formValues['member_join_date_high'] = $this->_defaults['member_join_date_high'] = $date; } $this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this); //LCD also allow restrictions to membership owner via GET $owner = CRM_Utils_Request::retrieve('owner', 'String', CRM_Core_DAO::$_nullObject); if ($owner) { $this->_formValues['member_is_primary'] = $this->_defaults['member_is_primary'] = 2; } }
/** * This function sets the default values for the form in edit/view mode * the default values are retrieved from the database * * * @return void */ public function setDefaultValues() { if ($this->_showFeeBlock) { return CRM_Event_Form_EventFees::setDefaultValues($this); } $defaults = array(); if ($this->_action & CRM_Core_Action::DELETE) { return $defaults; } if ($this->_id) { $ids = array(); $params = array('id' => $this->_id); CRM_Event_BAO_Participant::getValues($params, $defaults, $ids); $sep = CRM_Core_DAO::VALUE_SEPARATOR; if ($defaults[$this->_id]['role_id']) { $roleIDs = explode($sep, $defaults[$this->_id]['role_id']); } $this->_contactId = $defaults[$this->_id]['contact_id']; $this->_statusId = $defaults[$this->_id]['participant_status_id']; //set defaults for note $noteDetails = CRM_Core_BAO_Note::getNote($this->_id, 'civicrm_participant'); $defaults[$this->_id]['note'] = array_pop($noteDetails); // Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true (CRM-4859) if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) { $this->assign('additionalParticipants', CRM_Event_BAO_Participant::getAdditionalParticipants($this->_id)); } // Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859) if (!empty($defaults[$this->_id]['participant_registered_by_id'])) { $registered_by_contact_id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $defaults[$this->_id]['participant_registered_by_id'], 'contact_id', 'id'); $this->assign('participant_registered_by_id', $defaults[$this->_id]['participant_registered_by_id']); $this->assign('registered_by_contact_id', $registered_by_contact_id); $this->assign('registered_by_display_name', CRM_Contact_BAO_Contact::displayName($registered_by_contact_id)); } } if ($this->_action & (CRM_Core_Action::VIEW | CRM_Core_Action::BROWSE)) { $inactiveNeeded = TRUE; $viewMode = TRUE; } else { $viewMode = FALSE; $inactiveNeeded = FALSE; } //setting default register date if ($this->_action == CRM_Core_Action::ADD) { $statuses = array_flip($this->_participantStatuses); $defaults[$this->_id]['status_id'] = CRM_Utils_Array::value(ts('Registered'), $statuses); if (!empty($defaults[$this->_id]['event_id'])) { $contributionTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $defaults[$this->_id]['event_id'], 'financial_type_id'); if ($contributionTypeId) { $defaults[$this->_id]['financial_type_id'] = $contributionTypeId; } } if ($this->_mode) { $fields["email-{$this->_bltID}"] = 1; $fields['email-Primary'] = 1; if ($this->_contactId) { CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactId, $fields, $defaults); } if (empty($defaults["email-{$this->_bltID}"]) && !empty($defaults['email-Primary'])) { $defaults[$this->_id]["email-{$this->_bltID}"] = $defaults['email-Primary']; } } $submittedRole = $this->getElementValue('role_id'); if (!empty($submittedRole[0])) { $roleID = $submittedRole[0]; } $submittedEvent = $this->getElementValue('event_id'); if (!empty($submittedEvent[0])) { $eventID = $submittedEvent[0]; } } else { $defaults[$this->_id]['record_contribution'] = 0; if ($defaults[$this->_id]['participant_is_pay_later']) { $this->assign('participant_is_pay_later', TRUE); } $this->assign('participant_status_id', $defaults[$this->_id]['participant_status_id']); $eventID = $defaults[$this->_id]['event_id']; $this->_eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventID, 'event_type_id', 'id'); $this->_discountId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'discount_id'); if ($this->_discountId) { $this->set('discountId', $this->_discountId); } } list($defaults[$this->_id]['register_date'], $defaults[$this->_id]['register_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('register_date', $defaults[$this->_id]), 'activityDateTime'); //assign event and role id, this is needed for Custom data building $sep = CRM_Core_DAO::VALUE_SEPARATOR; if (!empty($defaults[$this->_id]['participant_role_id'])) { $roleIDs = explode($sep, $defaults[$this->_id]['participant_role_id']); } if (isset($_POST['event_id'])) { $eventID = $_POST['event_id']; } if ($this->_eID) { $eventID = $this->_eID; //@todo - rationalise the $this->_eID with $POST['event_id'], $this->_eid is set when eid=x is in the url $roleID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eID, 'default_role_id'); if (empty($roleIDs)) { $roleIDs = (array) ($defaults[$this->_id]['participant_role_id'] = $roleID); } $defaults[$this->_id]['event_id'] = $eventID; } if (!empty($eventID)) { $this->_eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventID, 'event_type_id', 'id'); } //these should take precedence so we state them last $urlRoleIDS = CRM_Utils_Request::retrieve('roles', 'String'); if ($urlRoleIDS) { $roleIDs = explode(',', $urlRoleIDS); } if (isset($roleIDs)) { $defaults[$this->_id]['role_id'] = implode(',', $roleIDs); } if (isset($eventID)) { $this->assign('eventID', $eventID); $this->set('eventId', $eventID); } if (isset($this->_eventTypeId)) { $this->assign('eventTypeID', $this->_eventTypeId); } $this->assign('event_is_test', CRM_Utils_Array::value('event_is_test', $defaults[$this->_id])); return $defaults[$this->_id]; }
/** * This function sets the default values for the form in edit/view mode * the default values are retrieved from the database * * * @param CRM_Core_Form $form * * @return void */ public static function setDefaultValues(&$form) { $defaults = array(); if ($form->_eventId) { //get receipt text and financial type $returnProperities = array('confirm_email_text', 'financial_type_id', 'campaign_id', 'start_date'); $details = array(); CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $form->_eventId, $details, $returnProperities); if (!empty($details[$form->_eventId]['financial_type_id'])) { $defaults[$form->_pId]['financial_type_id'] = $details[$form->_eventId]['financial_type_id']; } } if ($form->_pId) { $ids = array(); $params = array('id' => $form->_pId); CRM_Event_BAO_Participant::getValues($params, $defaults, $ids); if ($form->_action == CRM_Core_Action::UPDATE) { $discounts = array(); if (!empty($form->_values['discount'])) { foreach ($form->_values['discount'] as $key => $value) { $value = current($value); $discounts[$key] = $value['name']; } } if ($form->_discountId && !empty($discounts[$defaults[$form->_pId]['discount_id']])) { $form->assign('discount', $discounts[$defaults[$form->_pId]['discount_id']]); } $form->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId])); $form->assign('fee_level', CRM_Utils_Array::value('fee_level', $defaults[$form->_pId])); } $defaults[$form->_pId]['send_receipt'] = 0; } else { $defaults[$form->_pId]['send_receipt'] = strtotime(CRM_Utils_Array::value('start_date', $details[$form->_eventId])) >= time() ? 1 : 0; if ($form->_eventId && !empty($details[$form->_eventId]['confirm_email_text'])) { //set receipt text $defaults[$form->_pId]['receipt_text'] = $details[$form->_eventId]['confirm_email_text']; } list($defaults[$form->_pId]['receive_date']) = CRM_Utils_Date::setDateDefaults(); } //CRM-11601 we should keep the record contribution //true by default while adding participant if ($form->_action == CRM_Core_Action::ADD && !$form->_mode && $form->_isPaidEvent) { $defaults[$form->_pId]['record_contribution'] = 1; } //CRM-13420 if (empty($defaults['payment_instrument_id'])) { $defaults[$form->_pId]['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1')); } if ($form->_mode) { $config = CRM_Core_Config::singleton(); // set default country from config if no country set if (empty($defaults[$form->_pId]["billing_country_id-{$form->_bltID}"])) { $defaults[$form->_pId]["billing_country_id-{$form->_bltID}"] = $config->defaultContactCountry; } if (empty($defaults["billing_state_province_id-{$form->_bltID}"])) { $defaults[$form->_pId]["billing_state_province_id-{$form->_bltID}"] = $config->defaultContactStateProvince; } $billingDefaults = $form->getProfileDefaults('Billing', $form->_contactId); $defaults[$form->_pId] = array_merge($defaults[$form->_pId], $billingDefaults); // // hack to simplify credit card entry for testing // $defaults[$form->_pId]['credit_card_type'] = 'Visa'; // $defaults[$form->_pId]['credit_card_number'] = '4807731747657838'; // $defaults[$form->_pId]['cvv2'] = '000'; // $defaults[$form->_pId]['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' ); } // if user has selected discount use that to set default if (isset($form->_discountId)) { $defaults[$form->_pId]['discount_id'] = $form->_discountId; //hack to set defaults for already selected discount value if ($form->_action == CRM_Core_Action::UPDATE && !$form->_originalDiscountId) { $form->_originalDiscountId = $defaults[$form->_pId]['discount_id']; if ($form->_originalDiscountId) { $defaults[$form->_pId]['discount_id'] = $form->_originalDiscountId; } } $discountId = $form->_discountId; } else { $discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event'); } if ($discountId) { $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Discount', $discountId, 'price_set_id'); } else { $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $form->_eventId); } if ($form->_action == CRM_Core_Action::ADD && $form->_eventId && $discountId) { // this case is for add mode, where we show discount automatically $defaults[$form->_pId]['discount_id'] = $discountId; } if ($priceSetId) { // get price set default values, CRM-4090 if (in_array(get_class($form), array('CRM_Event_Form_Participant', 'CRM_Event_Form_Registration_Register', 'CRM_Event_Form_Registration_AdditionalParticipant'))) { $priceSetValues = self::setDefaultPriceSet($form->_pId, $form->_eventId); if (!empty($priceSetValues)) { $defaults[$form->_pId] = array_merge($defaults[$form->_pId], $priceSetValues); } } if ($form->_action == CRM_Core_Action::ADD && !empty($form->_priceSet['fields'])) { foreach ($form->_priceSet['fields'] as $key => $val) { foreach ($val['options'] as $keys => $values) { if ($values['is_default']) { if (get_class($form) != 'CRM_Event_Form_Participant' && !empty($values['is_full'])) { continue; } if ($val['html_type'] == 'CheckBox') { $defaults[$form->_pId]["price_{$key}"][$keys] = 1; } else { $defaults[$form->_pId]["price_{$key}"] = $keys; } } } } } $form->assign('totalAmount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId])); if ($form->_action == CRM_Core_Action::UPDATE) { $fee_level = $defaults[$form->_pId]['fee_level']; CRM_Event_BAO_Participant::fixEventLevel($fee_level); $form->assign('fee_level', $fee_level); $form->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId])); } } //CRM-4453 if (!empty($defaults[$form->_pId]['participant_fee_currency'])) { $form->assign('fee_currency', $defaults[$form->_pId]['participant_fee_currency']); } // CRM-4395 if ($contriId = $form->get('onlinePendingContributionId')) { $contribution = new CRM_Contribute_DAO_Contribution(); $contribution->id = $contriId; $contribution->find(TRUE); foreach (array('financial_type_id', 'payment_instrument_id', 'contribution_status_id', 'receive_date', 'total_amount') as $f) { if ($f == 'receive_date') { list($defaults[$form->_pId]['receive_date']) = CRM_Utils_Date::setDateDefaults($contribution->{$f}); } else { $defaults[$form->_pId][$f] = $contribution->{$f}; } } } return $defaults[$form->_pId]; }
function setDefaultValues() { if ($this->_action & CRM_Core_Action::ADD) { $defaults['is_active'] = 1; } else { $defaults = $this->_values; $entityValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('entity_value', $defaults)); $entityStatus = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('entity_status', $defaults)); $defaults['entity'][0] = CRM_Utils_Array::value('mapping_id', $defaults); $defaults['entity'][1] = $entityValue; $defaults['entity'][2] = $entityStatus; if ($absoluteDate = CRM_Utils_Array::value('absolute_date', $defaults)) { list($date, $time) = CRM_Utils_Date::setDateDefaults($absoluteDate); $defaults['absolute_date'] = $date; } if ($recipientListing = CRM_Utils_Array::value('recipient_listing', $defaults)) { $defaults['recipient_listing'] = explode(CRM_Core_DAO::VALUE_SEPARATOR, $recipientListing); } $defaults['text_message'] = CRM_Utils_Array::value('body_text', $defaults); $defaults['html_message'] = CRM_Utils_Array::value('body_html', $defaults); $defaults['template'] = CRM_Utils_Array::value('msg_template_id', $defaults); if (CRM_Utils_Array::value('group_id', $defaults)) { $defaults['recipient'] = 'group'; } elseif (CRM_Utils_Array::value('recipient_manual', $defaults)) { $defaults['recipient'] = 'manual'; $recipients = array(); foreach (explode(',', $defaults['recipient_manual']) as $cid) { $recipients[$cid] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name'); } $this->assign('recipients', $recipients); } } return $defaults; }
/** * Set default values. * * @return array */ public function setDefaultValues() { $defaults = $this->_values; // Set defaults for pledge payment. if ($this->_ppID) { $defaults['total_amount'] = CRM_Utils_Array::value('scheduled_amount', $this->_pledgeValues['pledgePayment']); $defaults['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_pledgeValues); $defaults['currency'] = CRM_Utils_Array::value('currency', $this->_pledgeValues); $defaults['option_type'] = 1; } if ($this->_action & CRM_Core_Action::DELETE) { return $defaults; } $defaults['frequency_interval'] = 1; $defaults['frequency_unit'] = 'month'; // Set soft credit defaults. CRM_Contribute_Form_SoftCredit::setDefaultValues($defaults, $this); if ($this->_mode) { $config = CRM_Core_Config::singleton(); // Set default country from config if no country set. if (empty($defaults["billing_country_id-{$this->_bltID}"])) { $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry; } if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) { $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince; } $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID); $defaults = array_merge($defaults, $billingDefaults); } if ($this->_id) { $this->_contactID = $defaults['contact_id']; } // Set $newCredit variable in template to control whether link to credit card mode is included. $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()); // Fix the display of the monetary value, CRM-4038. if (isset($defaults['total_amount'])) { if (!empty($defaults['tax_amount'])) { $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id); if (!(CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails))) { $defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'] - $defaults['tax_amount'], NULL, '%a'); } } else { $defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'], NULL, '%a'); } } if (isset($defaults['non_deductible_amount'])) { $defaults['non_deductible_amount'] = CRM_Utils_Money::format($defaults['non_deductible_amount'], NULL, '%a'); } if (isset($defaults['fee_amount'])) { $defaults['fee_amount'] = CRM_Utils_Money::format($defaults['fee_amount'], NULL, '%a'); } if (isset($defaults['net_amount'])) { $defaults['net_amount'] = CRM_Utils_Money::format($defaults['net_amount'], NULL, '%a'); } if ($this->_contributionType) { $defaults['financial_type_id'] = $this->_contributionType; } if (empty($defaults['payment_instrument_id'])) { $defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1')); } if (!empty($defaults['is_test'])) { $this->assign('is_test', TRUE); } $this->assign('showOption', TRUE); // For Premium section. if ($this->_premiumID) { $this->assign('showOption', FALSE); $options = isset($this->_options[$this->_productDAO->product_id]) ? $this->_options[$this->_productDAO->product_id] : ""; if (!$options) { $this->assign('showOption', TRUE); } $options_key = CRM_Utils_Array::key($this->_productDAO->product_option, $options); if ($options_key) { $defaults['product_name'] = array($this->_productDAO->product_id, trim($options_key)); } else { $defaults['product_name'] = array($this->_productDAO->product_id); } if ($this->_productDAO->fulfilled_date) { list($defaults['fulfilled_date']) = CRM_Utils_Date::setDateDefaults($this->_productDAO->fulfilled_date); } } if (isset($this->userEmail)) { $this->assign('email', $this->userEmail); } if (!empty($defaults['is_pay_later'])) { $this->assign('is_pay_later', TRUE); } $this->assign('contribution_status_id', CRM_Utils_Array::value('contribution_status_id', $defaults)); $dates = array('receive_date', 'receipt_date', 'cancel_date', 'thankyou_date'); foreach ($dates as $key) { if (!empty($defaults[$key])) { list($defaults[$key], $defaults[$key . '_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value($key, $defaults), 'activityDateTime'); } } if (!$this->_id && empty($defaults['receive_date'])) { list($defaults['receive_date'], $defaults['receive_date_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime'); } $this->assign('receive_date', CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $defaults), CRM_Utils_Array::value('receive_date_time', $defaults))); $currency = CRM_Utils_Array::value('currency', $defaults); $this->assign('currency', $currency); // Hack to get currency info to the js layer. CRM-11440. CRM_Utils_Money::format(1); $this->assign('currencySymbol', CRM_Utils_Array::value($currency, CRM_Utils_Money::$_currencySymbols)); $this->assign('totalAmount', CRM_Utils_Array::value('total_amount', $defaults)); // Inherit campaign from pledge. if ($this->_ppID && !empty($this->_pledgeValues['campaign_id'])) { $defaults['campaign_id'] = $this->_pledgeValues['campaign_id']; } $this->_defaults = $defaults; return $defaults; }
/** * Set default values for the form. * * For edit/view mode the default values are retrieved from the database. * * @return array */ public function setDefaultValues() { $defaults = $this->_values + CRM_Core_Form_RecurringEntity::setDefaultValues(); // if we're editing... if (isset($this->_activityId)) { if (empty($defaults['activity_date_time'])) { list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime'); } elseif ($this->_action & CRM_Core_Action::UPDATE) { $this->assign('current_activity_date_time', $defaults['activity_date_time']); list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime'); list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime'); } if ($this->_context != 'standalone') { $this->assign('target_contact_value', CRM_Utils_Array::value('target_contact_value', $defaults)); $this->assign('assignee_contact_value', CRM_Utils_Array::value('assignee_contact_value', $defaults)); } // Fixme: why are we getting the wrong keys from upstream? $defaults['target_contact_id'] = CRM_Utils_Array::value('target_contact', $defaults); $defaults['assignee_contact_id'] = CRM_Utils_Array::value('assignee_contact', $defaults); // set default tags if exists $defaults['tag'] = CRM_Core_BAO_EntityTag::getTag($this->_activityId, 'civicrm_activity'); } else { // if it's a new activity, we need to set default values for associated contact fields $this->_sourceContactId = $this->_currentUserId; $this->_targetContactId = $this->_currentlyViewedContactId; $defaults['source_contact_id'] = $this->_sourceContactId; $defaults['target_contact_id'] = $this->_targetContactId; list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime'); } if ($this->_activityTypeId) { $defaults['activity_type_id'] = $this->_activityTypeId; } if (!$this->_single && !empty($this->_contactIds)) { $defaults['target_contact_id'] = $this->_contactIds; } // CRM-15472 - 50 is around the practical limit of how many items a select2 entityRef can handle if (!empty($defaults['target_contact_id'])) { $count = count(is_array($defaults['target_contact_id']) ? $defaults['target_contact_id'] : explode(',', $defaults['target_contact_id'])); if ($count > 50) { $this->freeze(array('target_contact_id')); } } if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) { $this->assign('delName', CRM_Utils_Array::value('subject', $defaults)); } if ($this->_activityTypeFile) { $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}"; $defaults += $className::setDefaultValues($this); } if (empty($defaults['priority_id'])) { $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); $defaults['priority_id'] = array_search('Normal', $priority); } if (empty($defaults['status_id'])) { $defaults['status_id'] = CRM_Core_OptionGroup::getDefaultValue('activity_status'); } return $defaults; }
/** * Set default values for the form. * * For edit/view mode he default values are retrieved from the database. */ public function setDefaultValues() { $defaults = parent::setDefaultValues(); // in update mode, we need to set custom data subtype to tpl if (!empty($defaults['event_type_id'])) { $this->assign('customDataSubType', $defaults['event_type_id']); } $this->_showHide = new CRM_Core_ShowHideBlocks(); // Show waitlist features or event_full_text if max participants set if (!empty($defaults['max_participants'])) { $this->_showHide->addShow('id-waitlist'); if (!empty($defaults['has_waitlist'])) { $this->_showHide->addShow('id-waitlist-text'); $this->_showHide->addHide('id-event_full'); } else { $this->_showHide->addHide('id-waitlist-text'); $this->_showHide->addShow('id-event_full'); } } else { $this->_showHide->addHide('id-event_full'); $this->_showHide->addHide('id-waitlist'); $this->_showHide->addHide('id-waitlist-text'); } $this->_showHide->addToTemplate(); $this->assign('elemType', 'table-row'); $this->assign('description', CRM_Utils_Array::value('description', $defaults)); // Provide suggested text for event full and waitlist messages if they're empty $defaults['event_full_text'] = CRM_Utils_Array::value('event_full_text', $defaults, ts('This event is currently full.')); $defaults['waitlist_text'] = CRM_Utils_Array::value('waitlist_text', $defaults, ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.')); list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('start_date', $defaults), 'activityDateTime'); if (!empty($defaults['end_date'])) { list($defaults['end_date'], $defaults['end_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['end_date'], 'activityDateTime'); } return $defaults; }