当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_Date::unformat方法代码示例

本文整理汇总了PHP中CRM_Utils_Date::unformat方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Date::unformat方法的具体用法?PHP CRM_Utils_Date::unformat怎么用?PHP CRM_Utils_Date::unformat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_Date的用法示例。


在下文中一共展示了CRM_Utils_Date::unformat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     $parent = $this->controller->getParent();
     if (!empty($params)) {
         $fields = array('mailing_name', 'mailing_from', 'mailing_to', 'sort_name');
         foreach ($fields as $field) {
             if (isset($params[$field]) && !CRM_Utils_System::isNull($params[$field])) {
                 if (substr($field, 7) != 'name') {
                     $parent->set($field, CRM_Utils_Date::unformat(CRM_Utils_Date::processDate($params[$field]), ''));
                 } else {
                     $parent->set($field, $params[$field]);
                 }
             } else {
                 $parent->set($field, null);
             }
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:19,代码来源:Search.php

示例2: postProcess

 function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     $parent = $this->controller->getParent();
     $parent->set('searchResult', 1);
     if (!empty($params)) {
         $fields = array('title', 'event_type_id', 'start_date', 'end_date', 'eventsByDates');
         foreach ($fields as $field) {
             if (isset($params[$field]) && !CRM_Utils_System::isNull($params[$field])) {
                 if (substr($field, -4) == 'date') {
                     $parent->set($field, CRM_Utils_Date::unformat(CRM_Utils_Date::processDate($params[$field]), ''));
                 } else {
                     $parent->set($field, $params[$field]);
                 }
             } else {
                 $parent->set($field, null);
             }
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:20,代码来源:SearchEvent.php

示例3: dateParam

 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);
     }
     if (!($from || $to)) {
         return false;
     } else {
         if ($from || $to || $relative) {
             // unset other criteria
             self::unsetFilters($defaults);
         }
     }
     $defaults["{$fieldName}_from"] = CRM_Utils_Date::unformat($from, '');
     $defaults["{$fieldName}_to"] = CRM_Utils_Date::unformat($to, '');
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:22,代码来源:Get.php

示例4: extractGetParams

 /**
  * Function to extract the get params from the url, validate
  * and store it in session
  *
  * @param CRM_Core_Form $form the form object
  * @param string        $type the type of custom group we are using
  * @return void
  * @access public
  * @static
  */
 function extractGetParams(&$form, $type)
 {
     // if not GET params return
     if (empty($_GET)) {
         return;
     }
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree($type);
     $customFields =& CRM_Core_BAO_CustomField::getFields($type);
     $customValue = array();
     $htmlType = array('CheckBox', 'Multi-Select', 'Select', 'Radio');
     foreach ($groupTree as $group) {
         foreach ($group['fields'] as $key => $field) {
             $fieldName = 'custom_' . $key;
             $value = CRM_Utils_Request::retrieve($fieldName, $form);
             if ($value) {
                 if (!in_array($customFields[$key][3], $htmlType) || $customFields[$key][2] == 'Boolean') {
                     $valid = CRM_Core_BAO_CustomValue::typecheck($customFields[$key][2], $value);
                 }
                 if ($customFields[$key][3] == 'CheckBox' || $customFields[$key][3] == 'Multi-Select') {
                     $value = str_replace("|", ",", $value);
                     $mulValues = explode(',', $value);
                     $customOption = CRM_Core_BAO_CustomOption::getCustomOption($key, true);
                     $val = array();
                     foreach ($mulValues as $v1) {
                         foreach ($customOption as $v2) {
                             if (strtolower(trim($v2['label'])) == strtolower(trim($v1))) {
                                 $val[$v2['value']] = 1;
                             }
                         }
                     }
                     if (!empty($val)) {
                         $value = $val;
                         $valid = true;
                     } else {
                         $value = null;
                     }
                 } else {
                     if ($customFields[$key][3] == 'Select' || $customFields[$key][3] == 'Radio' && $customFields[$key][2] != 'Boolean') {
                         $customOption = CRM_Core_BAO_CustomOption::getCustomOption($key, true);
                         foreach ($customOption as $v2) {
                             if (strtolower(trim($v2['label'])) == strtolower(trim($value))) {
                                 $value = $v2['value'];
                                 $valid = true;
                             }
                         }
                     } else {
                         if ($customFields[$key][2] == 'Date') {
                             require_once 'CRM/Utils/Date.php';
                             if (is_numeric($value)) {
                                 $value = CRM_Utils_Date::unformat($value, null);
                             } else {
                                 $value = CRM_Utils_Date::unformat($value, $separator = '-');
                             }
                             $valid = true;
                         }
                     }
                 }
                 if ($valid) {
                     $customValue[$fieldName] = $value;
                 }
             }
         }
     }
     $form->set('customGetValues', $customValue);
     $form->set('groupTree', $groupTree);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:76,代码来源:CustomGroup.php

示例5: fixFormValues

 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 :)
     // we fix date_to here if set to be the end of the day, i.e. 23:59:59
     if (!CRM_Utils_System::isNull($this->_formValues['contribution_date_to'])) {
         $this->_formValues['contribution_date_to']['H'] = 23;
         $this->_formValues['contribution_date_to']['i'] = 59;
         $this->_formValues['contribution_date_to']['s'] = 59;
     }
     if (!$this->_force) {
         return;
     }
     $nullObject = null;
     $status = CRM_Utils_Request::retrieve('status', $nullObject);
     if ($status) {
         switch ($status) {
             case 'Valid':
             case 'Cancelled':
             case 'All':
                 $this->_formValues['contribution_status'] = $status;
                 $this->_defaults['contribution_status'] = $status;
                 break;
         }
     }
     $cid = CRM_Utils_Request::retrieve('cid', $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', $nullObject);
     if ($fromDate) {
         $fromDate = CRM_Utils_Type::escape($fromDate, 'Timestamp');
         $date = CRM_Utils_Date::unformat($fromDate, '');
         $this->_formValues['contribution_date_from'] = $date;
         $this->_defaults['contribution_date_from'] = $date;
     }
     $toDate = CRM_Utils_Request::retrieve('end', $nullObject);
     if ($toDate) {
         $toDate = CRM_Utils_Type::escape($toDate, 'Timestamp');
         $date = CRM_Utils_Date::unformat($toDate, '');
         $this->_formValues['contribution_date_to'] = $date;
         $this->_defaults['contribution_date_to'] = $date;
         $this->_formValues['contribution_date_to']['H'] = 23;
         $this->_formValues['contribution_date_to']['i'] = 59;
         $this->_formValues['contribution_date_to']['s'] = 59;
     }
     $this->_limit = CRM_Utils_Request::retrieve('limit', $this);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:56,代码来源:Search.php

示例6: formatCustomDate

 /**
  * convert any given date string to default date array.
  *
  * @param array  $params     has given date-format
  * @param array  $formatted  store formatted date in this array
  * @param int    $dateType   type of date  
  * @param string $dateParam  index of params
  * @static
  */
 function formatCustomDate(&$params, &$formatted, $dateType, $dateParam)
 {
     //fix for CRM-2687
     CRM_Utils_Date::convertToDefaultDate($params, $dateType, $dateParam);
     if ($dateType == 1) {
         if (strstr($params[$dateParam], '-')) {
             $formatted[$dateParam] = CRM_Utils_Date::unformat($params[$dateParam]);
         } else {
             $formatted[$dateParam] = CRM_Utils_Date::unformat(CRM_Utils_Date::mysqlToIso($params[$dateParam]));
         }
     } else {
         $formatted[$dateParam] = CRM_Utils_Date::unformat(CRM_Utils_Date::mysqlToIso($params[$dateParam]));
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:23,代码来源:Contact.php

示例7: getDefaultValue

 /**
  * Given a custom field value, its id and the set of options
  * find the default value for this field
  *
  * @param  mixed  $value     the custom field value
  * @param  int    $id        the custom field id
  * @param  int    $options   the assoc array of option name/value pairs
  *
  * @return   mixed   the default value
  * @static
  * @access public
  */
 function getDefaultValue($value, $id, &$options)
 {
     $option =& $options[$id];
     $attributes =& $option['attributes'];
     $html_type = $attributes['html_type'];
     $index = $attributes['label'];
     $default = $value;
     switch ($html_type) {
         case "CheckBox":
             $checkedData = explode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $value);
             $default = array();
             foreach ($checkedData as $val) {
                 $default[$val] = 1;
             }
             break;
         case "Select Date":
             $default = CRM_Utils_Date::unformat($value);
             break;
     }
     return $default;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:33,代码来源:CustomField.php

示例8: getDefaultValue

 /**
  * Given a custom field value, its id and the set of options
  * find the default value for this field
  *
  * @param  mixed  $value     the custom field value
  * @param  int    $id        the custom field id
  * @param  int    $options   the assoc array of option name/value pairs
  *
  * @return   mixed   the default value
  * @static
  * @access public
  */
 function getDefaultValue($value, $id, &$options)
 {
     $option =& $options[$id];
     $attributes =& $option['attributes'];
     $html_type = $attributes['html_type'];
     $default = $value;
     switch ($html_type) {
         case "CheckBox":
             $checkedData = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($value, 1, -1));
             $default = array();
             foreach ($checkedData as $val) {
                 $default[$val] = 1;
             }
             break;
         case "Select Date":
             $default = CRM_Utils_Date::unformat($value);
             break;
     }
     return $default;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:32,代码来源:CustomField.php

示例9: alterDisplay

 function alterDisplay(&$rows)
 {
     // custom code to alter rows
     $entryFound = false;
     foreach ($rows as $rowNum => $row) {
         // make count columns point to detail report
         if (CRM_Utils_Array::value('join_date', $this->_params['group_bys']) && CRM_Utils_Array::value('civicrm_membership_join_date_start', $row) && $row['civicrm_membership_join_date_start'] && $row['civicrm_membership_join_date_subtotal']) {
             $dateStart = CRM_Utils_Date::customFormat($row['civicrm_membership_join_date_start'], '%Y%m%d');
             $dateEnd = CRM_Utils_Date::unformat($dateStart, '');
             switch (strtolower($this->_params['group_bys_freq']['join_date'])) {
                 case 'month':
                     $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] + 1, $dateEnd['d'] - 1, $dateEnd['Y']));
                     break;
                 case 'year':
                     $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'], $dateEnd['d'] - 1, $dateEnd['Y'] + 1));
                     break;
                 case 'yearweek':
                     $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'], $dateEnd['d'] + 6, $dateEnd['Y']));
                     break;
                 case 'quarter':
                     $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] + 3, $dateEnd['d'] - 1, $dateEnd['Y']));
                     break;
             }
             $url = CRM_Report_Utils_Report::getNextUrl('member/detail', "reset=1&force=1&join_date_from={$dateStart}&join_date_to={$dateEnd}", $this->_absoluteUrl, $this->_id);
             $row['civicrm_membership_join_date_start'] = CRM_Utils_Date::format($row['civicrm_membership_join_date_start']);
             $rows[$rowNum]['civicrm_membership_join_date_start_link'] = $url;
             $rows[$rowNum]['civicrm_membership_join_date_start_hover'] = ts("Lists Summary of Memberships for this date unit.");
             $entryFound = true;
         }
         // handle Membership Types
         if (array_key_exists('civicrm_membership_membership_type_id', $row)) {
             if ($value = $row['civicrm_membership_membership_type_id']) {
                 $value = explode(',', $value);
                 foreach ($value as $key => $id) {
                     $value[$key] = CRM_Member_PseudoConstant::membershipType($id, false);
                 }
                 $rows[$rowNum]['civicrm_membership_membership_type_id'] = implode(' , ', $value);
             }
             $entryFound = true;
         }
         // make subtotals look nicer
         if (array_key_exists('civicrm_membership_join_date_subtotal', $row) && !$row['civicrm_membership_join_date_subtotal']) {
             $this->fixSubTotalDisplay($rows[$rowNum], $this->_statFields);
             $entryFound = true;
         }
         // skip looking further in rows, if first row itself doesn't
         // have the column we need
         if (!$entryFound) {
             break;
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:52,代码来源:Summary.php

示例10: createActivity

 function createActivity($activityTypeXML, &$params)
 {
     $activityTypeName = (string) $activityTypeXML->name;
     $activityTypes =& $this->allActivityTypes();
     $activityTypeInfo = CRM_Utils_Array::value($activityTypeName, $activityTypes);
     if (!$activityTypeInfo) {
         require_once 'CRM/Utils/System.php';
         $docLink = CRM_Utils_System::docURL2("CiviCase Configuration");
         CRM_Core_Error::fatal(ts('Activity type %1, found in case configuration file, is not present in the database %2', array(1 => $activityTypeName, 2 => $docLink)));
         return false;
     }
     $activityTypeID = $activityTypeInfo['id'];
     if (isset($activityTypeXML->status)) {
         $statusName = (string) $activityTypeXML->status;
     } else {
         $statusName = 'Scheduled';
     }
     require_once 'CRM/Core/OptionGroup.php';
     if ($activityTypeName == 'Open Case') {
         $activityParams = array('activity_type_id' => $activityTypeID, 'source_contact_id' => $params['creatorID'], 'is_auto' => false, 'is_current_revision' => 1, 'subject' => CRM_Utils_Array::value('subject', $params) ? $params['subject'] : $activityTypeName, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', $statusName, 'name'), 'target_contact_id' => $params['clientID'], 'medium_id' => CRM_Utils_Array::value('medium_id', $params), 'location' => CRM_Utils_Array::value('location', $params), 'details' => CRM_Utils_Array::value('details', $params), 'duration' => CRM_Utils_Array::value('duration', $params));
     } else {
         $activityParams = array('activity_type_id' => $activityTypeID, 'source_contact_id' => $params['creatorID'], 'is_auto' => true, 'is_current_revision' => 1, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', $statusName, 'name'), 'target_contact_id' => $params['clientID']);
     }
     if ($activityTypeName == 'Open Case') {
         // we don't set activity_date_time for auto generated
         // activities, but we want it to be set for open case.
         $activityParams['activity_date_time'] = $params['activity_date_time'];
         if (array_key_exists('custom', $params) && is_array($params['custom'])) {
             $activityParams['custom'] = $params['custom'];
         }
     } else {
         $activityDate = null;
         //get date of reference activity if set.
         if ($referenceActivityName = (string) $activityTypeXML->reference_activity) {
             //we skip open case as reference activity.CRM-4374.
             if (CRM_Utils_Array::value('resetTimeline', $params) && $referenceActivityName == 'Open Case') {
                 $activityDate = $params['activity_date_time'];
             } else {
                 $referenceActivityInfo = CRM_Utils_Array::value($referenceActivityName, $activityTypes);
                 if ($referenceActivityInfo['id']) {
                     $caseActivityParams = array('activity_type_id' => $referenceActivityInfo['id']);
                     //if reference_select is set take according activity.
                     if ($referenceSelect = (string) $activityTypeXML->reference_select) {
                         $caseActivityParams[$referenceSelect] = 1;
                     }
                     require_once 'CRM/Case/BAO/Case.php';
                     $referenceActivity = CRM_Case_BAO_Case::getCaseActivityDates($params['caseID'], $caseActivityParams, true);
                     if (is_array($referenceActivity)) {
                         foreach ($referenceActivity as $aId => $details) {
                             $activityDate = CRM_Utils_Array::value('activity_date', $details);
                             break;
                         }
                     }
                 }
             }
         }
         if (!$activityDate) {
             $activityDate = $params['activity_date_time'];
         }
         $datetime = new DateTime($activityDate);
         $activityDateTime = CRM_Utils_Date::unformat($datetime->format('Y:m:d:H:i:s'), ':');
         //add reference offset to date.
         if ((int) $activityTypeXML->reference_offset) {
             $activityDateTime = CRM_Utils_Date::intervalAdd('day', (int) $activityTypeXML->reference_offset, $activityDateTime);
         }
         $activityParams['activity_date_time'] = CRM_Utils_Date::format($activityDateTime);
     }
     // if same activity is already there, skip and dont touch
     $params['activityTypeID'] = $activityTypeID;
     $params['activityTypeName'] = $activityTypeName;
     if ($this->isActivityPresent($params)) {
         return true;
     }
     $activityParams['case_id'] = $params['caseID'];
     if (CRM_Utils_Array::value('is_auto', $activityParams)) {
         $activityParams['skipRecentView'] = true;
     }
     require_once 'CRM/Activity/BAO/Activity.php';
     $activity = CRM_Activity_BAO_Activity::create($activityParams);
     if (!$activity) {
         CRM_Core_Error::fatal();
         return false;
     }
     // create case activity record
     $caseParams = array('activity_id' => $activity->id, 'case_id' => $params['caseID']);
     require_once 'CRM/Case/BAO/Case.php';
     CRM_Case_BAO_Case::processCaseActivity($caseParams);
     return true;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:89,代码来源:Process.php

示例11: buildQuickForm

 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     require_once 'CRM/Utils/Money.php';
     $this->addYesNo('is_monetary', ts('Paid Event'), null, null, array('onclick' => "return showHideByValue('is_monetary','0','event-fees','block','radio',false);"));
     require_once 'CRM/Contribute/PseudoConstant.php';
     $paymentProcessor =& CRM_Core_PseudoConstant::paymentProcessor();
     $this->assign('paymentProcessor', $paymentProcessor);
     $this->add('select', 'payment_processor_id', ts('Payment Processor'), array('' => ts('- select -')) + $paymentProcessor);
     $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
     // 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->addElement('textarea', 'pay_later_receipt', ts('Pay Later Instructions'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_receipt'), false);
     $this->add('text', 'fee_label', ts('Fee Label'));
     require_once 'CRM/Price/BAO/Set.php';
     $this->add('select', 'price_set_id', ts('Price Set'), array('' => ts('- none -')) + CRM_Price_BAO_Set::getAssoc(false, 'Event'), null, array('onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);"));
     $default = array();
     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'));
         // 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);
     require_once 'CRM/Core/ShowHideBlocks.php';
     // 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]) && array_values($this->_submitValues['discount_end_date'][$i]) && $i < self::NUM_DISCOUNT - 1) {
             $end_date = CRM_Utils_Date::format($this->_submitValues['discount_end_date'][$i], '-');
             if (!empty($this->_submitValues['discount_end_date'][$i + 1]['M']) && empty($this->_submitValues['discount_start_date'][$i + 1]['M'])) {
                 $this->_submitValues['discount_start_date'][$i + 1] = CRM_Utils_Date::unformat(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]) && array_values($this->_submitValues['discount_start_date'][$i])) {
             $start_date = CRM_Utils_Date::format($this->_submitValues['discount_start_date'][$i], '-');
             if (!empty($this->_submitValues['discount_start_date'][$i]['M']) && empty($this->_submitValues['discount_end_date'][$i - 1]['M'])) {
                 $this->_submitValues['discount_end_date'][$i - 1] = CRM_Utils_Date::unformat(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_Core_DAO_OptionValue', 'label'));
         //discount start date
         $this->add('date', 'discount_start_date[' . $i . ']', ts('Discount Start Date'), CRM_Core_SelectValues::date('activityDate'));
         //discount end date
         $this->add('date', 'discount_end_date[' . $i . ']', ts('Discount End Date'), CRM_Core_SelectValues::date('activityDate'));
     }
     $_showHide->addToTemplate();
     $this->addElement('submit', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'), array('class' => 'form-submit'));
     $this->buildAmountLabel();
     parent::buildQuickForm();
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:74,代码来源:Fee.php

示例12: fixFormValues

 function fixFormValues()
 {
     if (!$this->_force) {
         return;
     }
     // set pledge payment related fields
     $status = CRM_Utils_Request::retrieve('status', 'String', CRM_Core_DAO::$_nullObject);
     if ($status) {
         $this->_formValues['pledge_payment_status_id'] = array($status => 1);
         $this->_defaults['pledge_payment_status_id'] = array($status => 1);
     }
     $fromDate = CRM_Utils_Request::retrieve('start', 'Date', CRM_Core_DAO::$_nullObject);
     if ($fromDate) {
         $date = CRM_Utils_Date::unformat($fromDate, '');
         $this->_formValues['pledge_payment_date_low'] = $date;
         $this->_defaults['pledge_payment_date_low'] = $date;
     }
     $toDate = CRM_Utils_Request::retrieve('end', 'Date', CRM_Core_DAO::$_nullObject);
     if ($toDate) {
         $date = CRM_Utils_Date::unformat($toDate, '');
         $this->_formValues['pledge_payment_date_high'] = $date;
         $this->_defaults['pledge_payment_date_high'] = $date;
     }
     // set pledge related fields
     $pledgeStatus = CRM_Utils_Request::retrieve('pstatus', 'String', CRM_Core_DAO::$_nullObject);
     if ($pledgeStatus) {
         require_once 'CRM/Contribute/PseudoConstant.php';
         $statusValues = CRM_Contribute_PseudoConstant::contributionStatus();
         // Remove status values that are only used for recurring contributions for now (Failed).
         unset($statusValues['4']);
         // we need set all statuses except Cancelled
         unset($statusValues[$pledgeStatus]);
         $statuses = array();
         foreach ($statusValues as $statusId => $value) {
             $statuses[$statusId] = 1;
         }
         $this->_formValues['pledge_status_id'] = $statuses;
         $this->_defaults['pledge_status_id'] = $statuses;
     }
     $pledgeFromDate = CRM_Utils_Request::retrieve('pstart', 'Date', CRM_Core_DAO::$_nullObject);
     if ($pledgeFromDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($pledgeFromDate);
         $this->_formValues['pledge_create_date_low'] = $this->_defaults['pledge_create_date_low'] = $date;
     }
     $pledgeToDate = CRM_Utils_Request::retrieve('pend', 'Date', CRM_Core_DAO::$_nullObject);
     if ($pledgeToDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($pledgeToDate);
         $this->_formValues['pledge_create_date_high'] = $this->_defaults['pledge_create_date_high'] = $date;
     }
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if ($cid) {
         $cid = CRM_Utils_Type::escape($cid, 'Integer');
         if ($cid > 0) {
             require_once 'CRM/Contact/BAO/Contact.php';
             $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;
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:62,代码来源:Search.php

示例13: create

 static function create($params)
 {
     require_once 'CRM/Contribute/PseudoConstant.php';
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $scheduled_date = CRM_Utils_Date::unformat($params['scheduled_date'], '');
     $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
     //calculation of schedule date according to frequency day of period
     //frequency day is not applicable for daily installments
     if ($params['frequency_unit'] != 'day') {
         if ($params['frequency_unit'] != 'week') {
             //for month use day of next month & for year use day of month Jan of next year as next payment date
             $scheduled_date['d'] = $params['frequency_day'];
             if ($params['frequency_unit'] == 'year') {
                 $scheduled_date['M'] = 1;
             }
         } else {
             if ($params['frequency_unit'] == 'week') {
                 //for week calculate day of week ie. Sunday,Monday etc. as next payment date
                 $dayOfWeek = date('w', mktime(0, 0, 0, $scheduled_date['M'], $scheduled_date['d'], $scheduled_date['Y']));
                 $frequencyDay = $params['frequency_day'] - $dayOfWeek;
                 $scheduleDate = explode("-", date('n-j-Y', mktime(0, 0, 0, $scheduled_date['M'], $scheduled_date['d'] + $frequencyDay, $scheduled_date['Y'])));
                 $scheduled_date['M'] = $scheduleDate[0];
                 $scheduled_date['d'] = $scheduleDate[1];
                 $scheduled_date['Y'] = $scheduleDate[2];
             }
         }
     }
     //calculate the scheduled date for every installment
     $now = date('Ymd');
     $prevScheduledDate = array();
     $statues = array();
     $prevScheduledDate[1] = CRM_Utils_Date::format($params['scheduled_date']);
     if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($prevScheduledDate[1], '%Y%m%d'), $now)) {
         $statues[1] = array_search('Overdue', $contributionStatus);
     } else {
         $statues[1] = array_search('Pending', $contributionStatus);
     }
     for ($i = 1; $i < $params['installments']; $i++) {
         $prevScheduledDate[$i + 1] = CRM_Utils_Date::format(CRM_Utils_Date::intervalAdd($params['frequency_unit'], $i * $params['frequency_interval'], $scheduled_date));
         if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($prevScheduledDate[$i + 1], '%Y%m%d'), $now)) {
             $statues[$i + 1] = array_search('Overdue', $contributionStatus);
         } else {
             $statues[$i + 1] = array_search('Pending', $contributionStatus);
         }
     }
     if ($params['installment_amount']) {
         $params['scheduled_amount'] = $params['installment_amount'];
     } else {
         $params['scheduled_amount'] = round($params['amount'] / $params['installments'], 2);
     }
     for ($i = 1; $i <= $params['installments']; $i++) {
         //calculate the scheduled amount for every installment.
         if ($i == $params['installments']) {
             $params['scheduled_amount'] = $params['amount'] - ($i - 1) * $params['scheduled_amount'];
         }
         if (!isset($params['contribution_id']) && $params['installments'] > 1) {
             $params['status_id'] = $statues[$i];
         }
         $params['scheduled_date'] = $prevScheduledDate[$i];
         $payment = self::add($params);
         if (is_a($payment, 'CRM_Core_Error')) {
             $transaction->rollback();
             return $payment;
         }
         // we should add contribution id to only first payment record
         if (isset($params['contribution_id'])) {
             unset($params['contribution_id']);
         }
     }
     //update pledge status
     self::updatePledgePaymentStatus($params['pledge_id']);
     $transaction->commit();
     return $payment;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:75,代码来源:Payment.php

示例14: getValues

 /**
  * Given the list of params in the params array, fetch the object
  * and store the values in the values array
  *
  * @param array $params input parameters to find object
  * @param array $values output values of the object
  * @param array $ids    the array that holds all the db ids
  *
  * @return CRM_Contact_BAO_Contact|null the found object or null
  * @access public
  * @static
  */
 static function getValues(&$params, &$values, &$ids)
 {
     $individual =& new CRM_Contact_BAO_Individual();
     $individual->copyValues($params);
     if ($individual->find(true)) {
         $ids['individual'] = $individual->id;
         CRM_Core_DAO::storeValues($individual, $values);
         if (isset($individual->birth_date)) {
             $values['birth_date'] = CRM_Utils_Date::unformat($individual->birth_date);
         }
         return $individual;
     }
     return null;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:26,代码来源:Individual.php

示例15: fixFormValues

 function fixFormValues()
 {
     if (!$this->_force) {
         return;
     }
     $caseStatus = CRM_Utils_Request::retrieve('status', 'Positive', CRM_Core_DAO::$_nullObject);
     if ($caseStatus) {
         $this->_formValues['case_status_id'] = $caseStatus;
         $this->_defaults['case_status_id'] = $caseStatus;
     }
     $caseType = CRM_Utils_Request::retrieve('type', 'Positive', CRM_Core_DAO::$_nullObject);
     if ($caseType) {
         $this->_formValues['case_type_id'][$caseType] = 1;
         $this->_defaults['case_type_id'][$caseType] = 1;
     }
     $caseFromDate = CRM_Utils_Request::retrieve('pstart', 'Date', CRM_Core_DAO::$_nullObject);
     if ($caseFromDate) {
         $date = CRM_Utils_Date::unformat($caseFromDate, '');
         $this->_formValues['case_start_date_low'] = $date;
         $this->_defaults['case_start_date_low'] = $date;
     }
     $caseToDate = CRM_Utils_Request::retrieve('pend', 'Date', CRM_Core_DAO::$_nullObject);
     if ($caseToDate) {
         $date = CRM_Utils_Date::unformat($caseToDate, '');
         $this->_formValues['case_start_date_high'] = $date;
         $this->_defaults['case_start_date_high'] = $date;
     }
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if ($cid) {
         $cid = CRM_Utils_Type::escape($cid, 'Integer');
         if ($cid > 0) {
             require_once 'CRM/Contact/BAO/Contact.php';
             $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;
         }
     } else {
         $session =& CRM_Core_Session::singleton();
         if (!CRM_Utils_Request::retrieve('all', 'Positive', $session)) {
             $this->_formValues['case_mycases'] = 0;
             $this->_formValues['case_owner'] = 0;
             $this->_defaults['case_owner'] = 0;
         } else {
             $this->_formValues['case_owner'] = 1;
             $this->_defaults['case_owner'] = 1;
         }
         $caseOwner = CRM_Utils_Request::retrieve('case_owner', 'Boolean', CRM_Core_DAO::$_nullObject);
         if ($caseOwner) {
             $this->_formValues['case_owner'] = 0;
             $this->_defaults['case_owner'] = 0;
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:55,代码来源:Search.php


注:本文中的CRM_Utils_Date::unformat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。