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


PHP CRM_Utils_Date::getToday方法代码示例

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


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

示例1: postProcessStudent

 static function postProcessStudent($pickupName, $studentID, $atSchoolMeeting = false)
 {
     static $_now = null;
     static $_date = null;
     if (!$_now) {
         $_now = CRM_Utils_Date::getToday(null, 'YmdHis');
     }
     if (!$_date) {
         $_date = CRM_Utils_Date::getToday(null, 'Y-m-d');
     }
     $atSchoolMeeting = $atSchoolMeeting ? '1' : '0';
     $sql = "\nSELECT e.id, e.class\nFROM   civicrm_value_extended_care_signout e\nWHERE  entity_id = %1\nAND    DATE(signin_time) = %2\nAND    ( is_morning = 0 OR is_morning IS NULL )\n";
     $params = array(1 => array($studentID, 'Integer'), 2 => array($_date, 'String'));
     $dao = CRM_Core_DAO::executeQuery($sql, $params);
     $params = array(1 => array($studentID, 'Integer'), 2 => array($pickupName, 'String'), 3 => array($_now, 'Timestamp'), 4 => array($atSchoolMeeting, 'Integer'));
     $class = null;
     if ($dao->fetch()) {
         $class = $dao->class;
         $sql = "\nUPDATE civicrm_value_extended_care_signout\nSET    pickup_person_name = %2,\n       signout_time       = %3,\n       at_school_meeting  = %4\nWHERE  id = %5\n";
         $params[5] = array($dao->id, 'Integer');
     } else {
         $sql = "\nINSERT INTO civicrm_value_extended_care_signout\n( entity_id, pickup_person_name, signout_time, at_school_meeting, is_morning )\nVALUES\n( %1, %2, %3, %4, 0 )\n";
     }
     CRM_Core_DAO::executeQuery($sql, $params);
     return $class;
 }
开发者ID:pzingg,项目名称:sfschool,代码行数:26,代码来源:SignOut.php

示例2: setDefaultValues

 /**
  * 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['start_date'] = array();
     $defaults['start_date'] = CRM_Utils_Date::getToday($defaults['start_date'], 'm/d/Y');
     return $defaults;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:14,代码来源:ChangeCaseStartDate.php

示例3: createDir

 function createDir()
 {
     require_once 'CRM/Utils/File.php';
     // ensure that $this->_mailDir is a directory and is writable
     if (!is_dir($this->_mailDir) || !is_readable($this->_mailDir)) {
         echo "Could not read from {$this->_mailDir}\n";
         exit;
     }
     $config =& CRM_Core_Config::singleton();
     $dir = $config->uploadDir . DIRECTORY_SEPARATOR . 'mail';
     $this->_processedDir = $dir . DIRECTORY_SEPARATOR . 'processed';
     CRM_Utils_File::createDir($this->_processedDir);
     $this->_errorDir = $dir . DIRECTORY_SEPARATOR . 'error';
     CRM_Utils_File::createDir($this->_errorDir);
     // create a date string YYYYMMDD
     require_once 'CRM/Utils/Date.php';
     $date = CRM_Utils_Date::getToday(null, 'Ymd');
     $this->_processedDir = $this->_processedDir . DIRECTORY_SEPARATOR . $date;
     CRM_Utils_File::createDir($this->_processedDir);
     $this->_errorDir = $this->_errorDir . DIRECTORY_SEPARATOR . $date;
     CRM_Utils_File::createDir($this->_errorDir);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:22,代码来源:Email2Activity.php

示例4: preProcess

 /**
  * Heart of the viewing process. The runner gets all the meta data for
  * the contact and calls the appropriate type of page to view.
  *
  * @return void
  * @access public
  *
  */
 function preProcess()
 {
     //CRM-13901 don't show dashboard to contacts with limited view writes & it does not relect
     //what they have access to
     //@todo implement acls on dashboard querys (preferably via api to enhance that at the same time)
     if (!CRM_Core_Permission::check(array('view all contacts', 'edit all contacts'))) {
         $this->showMembershipSummary = FALSE;
         $this->assign('membershipSummary', FALSE);
         return;
     }
     $this->assign('membershipSummary', TRUE);
     CRM_Utils_System::setTitle(ts('CiviMember'));
     $membershipSummary = array();
     $preMonth = date("Y-m-d", mktime(0, 0, 0, date("m") - 1, 01, date("Y")));
     $preMonthEnd = date("Y-m-t", mktime(0, 0, 0, date("m") - 1, 01, date("Y")));
     $preMonthYear = mktime(0, 0, 0, substr($preMonth, 4, 2), 1, substr($preMonth, 0, 4));
     $today = getdate();
     $date = CRM_Utils_Date::getToday();
     $isCurrentMonth = 0;
     // You can force the dashboard to display based upon a certain date
     $ym = CRM_Utils_Array::value('date', $_GET);
     if ($ym) {
         if (preg_match('/^\\d{6}$/', $ym) == 0 || !checkdate(substr($ym, 4, 2), 1, substr($ym, 0, 4)) || substr($ym, 0, 1) == 0) {
             CRM_Core_Error::fatal(ts('Invalid date query "%1" in URL (valid syntax is yyyymm).', array(1 => $ym)));
         }
         $isPreviousMonth = 0;
         $isCurrentMonth = substr($ym, 0, 4) == $today['year'] && substr($ym, 4, 2) == $today['mon'];
         $ymd = date('Y-m-d', mktime(0, 0, -1, substr($ym, 4, 2) + 1, 1, substr($ym, 0, 4)));
         $monthStartTs = mktime(0, 0, 0, substr($ym, 4, 2), 1, substr($ym, 0, 4));
         $current = CRM_Utils_Date::customFormat($date, '%Y-%m-%d');
         $ym = substr($ym, 0, 4) . '-' . substr($ym, 4, 2);
     } else {
         $ym = sprintf("%04d-%02d", $today['year'], $today['mon']);
         $ymd = sprintf("%04d-%02d-%02d", $today['year'], $today['mon'], $today['mday']);
         $monthStartTs = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
         $current = CRM_Utils_Date::customFormat($date, '%Y-%m-%d');
         $isCurrentMonth = 1;
         $isPreviousMonth = 1;
     }
     $monthStart = $ym . '-01';
     $yearStart = substr($ym, 0, 4) . '-01-01';
     $membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE);
     // added
     //$membership = new CRM_Member_BAO_Membership;
     foreach ($membershipTypes as $key => $value) {
         $membershipSummary[$key]['premonth']['new'] = array('count' => CRM_Member_BAO_Membership::getMembershipJoins($key, $preMonth, $preMonthEnd), 'name' => $value);
         $membershipSummary[$key]['premonth']['renew'] = array('count' => CRM_Member_BAO_Membership::getMembershipRenewals($key, $preMonth, $preMonthEnd), 'name' => $value);
         $membershipSummary[$key]['premonth']['total'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $preMonth, $preMonthEnd), 'name' => $value);
         $membershipSummary[$key]['month']['new'] = array('count' => CRM_Member_BAO_Membership::getMembershipJoins($key, $monthStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['month']['renew'] = array('count' => CRM_Member_BAO_Membership::getMembershipRenewals($key, $monthStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['month']['total'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $monthStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['year']['new'] = array('count' => CRM_Member_BAO_Membership::getMembershipJoins($key, $yearStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['year']['renew'] = array('count' => CRM_Member_BAO_Membership::getMembershipRenewals($key, $yearStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['year']['total'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $yearStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['current']['total'] = array('count' => CRM_Member_BAO_Membership::getMembershipCount($key, $current), 'name' => $value);
         $membershipSummary[$key]['total']['total'] = array('count' => CRM_Member_BAO_Membership::getMembershipCount($key, $ymd));
         //LCD also get summary stats for membership owners
         $membershipSummary[$key]['premonth_owner']['premonth_owner'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $preMonth, $preMonthEnd, 0, 1), 'name' => $value);
         $membershipSummary[$key]['month_owner']['month_owner'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $monthStart, $ymd, 0, 1), 'name' => $value);
         $membershipSummary[$key]['year_owner']['year_owner'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $yearStart, $ymd, 0, 1), 'name' => $value);
         $membershipSummary[$key]['current_owner']['current_owner'] = array('count' => CRM_Member_BAO_Membership::getMembershipCount($key, $current, 0, 1), 'name' => $value);
         $membershipSummary[$key]['total_owner']['total_owner'] = array('count' => CRM_Member_BAO_Membership::getMembershipCount($key, $ymd, 0, 1));
         //LCD end
     }
     // LCD debug
     //CRM_Core_Error::debug($membershipSummary);
     $status = CRM_Member_BAO_MembershipStatus::getMembershipStatusCurrent();
     $status = implode(',', $status);
     /* Disabled for lack of appropriate search
     
            The Membership search isn't able to properly filter by join or renewal events.
            Until that works properly, the subtotals shouldn't get links.
     
         foreach ($membershipSummary as $typeID => $details) {
           foreach ($details as $key => $value) {
             switch ($key) {
               case 'premonth':
                 $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&join=$preMonth&joinEnd=$preMonthEnd&start=$preMonth&end=$preMonthEnd");
                 $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&joinEnd=$prePreMonthEnd&start=$preMonth&end=$preMonthEnd");
                 $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$preMonth&end=$preMonthEnd");
                 break;
     
               case 'month':
                 $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&join=$monthStart&joinEnd=$ymd&start=$monthStart&end=$ymd");
                 $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&joinEnd=$preMonthStart&start=$monthStart&end=$ymd");
                 $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$monthStart&end=$ymd");
                 break;
     
               case 'year':
                 $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&join=$yearStart&joinEnd=$ymd&start=$yearStart&end=$ymd");
                 $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&joinEnd=$preYearStart&start=$yearStart&end=$ymd");
                 $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$yearStart&end=$ymd");
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:DashBoard.php

示例5: submit

 /**
  * Process form submission.
  *
  * This function is also accessed by a unit test.
  */
 protected function submit()
 {
     $this->storeContactFields($this->_params);
     $this->beginPostProcess();
     $now = CRM_Utils_Date::getToday(NULL, 'YmdHis');
     $this->convertDateFieldsToMySQL($this->_params);
     $this->assign('receive_date', $this->_params['receive_date']);
     $this->processBillingAddress();
     list($userName) = CRM_Contact_BAO_Contact_Location::getEmailDetails(CRM_Core_Session::singleton()->get('userID'));
     $this->_params['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_params, CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee'));
     $this->_membershipId = $this->_id;
     $customFieldsFormatted = CRM_Core_BAO_CustomField::postProcess($this->_params, $this->_id, 'Membership');
     if (empty($this->_params['financial_type_id'])) {
         $this->_params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id');
     }
     $contributionRecurID = NULL;
     $this->assign('membershipID', $this->_id);
     $this->assign('contactID', $this->_contactID);
     $this->assign('module', 'Membership');
     $this->assign('receiptType', 'membership renewal');
     $this->_params['currencyID'] = CRM_Core_Config::singleton()->defaultCurrency;
     $this->_params['invoice_id'] = $this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
     if (!empty($this->_params['send_receipt'])) {
         $this->_params['receipt_date'] = $now;
         $this->assign('receipt_date', CRM_Utils_Date::mysqlToIso($this->_params['receipt_date']));
     } else {
         $this->_params['receipt_date'] = NULL;
     }
     if ($this->_mode) {
         $this->_params['register_date'] = $now;
         $this->_params['description'] = ts("Contribution submitted by a staff person using member's credit card for renewal");
         $this->_params['amount'] = $this->_params['total_amount'];
         // at this point we've created a contact and stored its address etc
         // all the payment processors expect the name and address to be in the passed params
         // so we copy stuff over to first_name etc.
         $paymentParams = $this->_params;
         if (!empty($this->_params['send_receipt'])) {
             $paymentParams['email'] = $this->_contributorEmail;
         }
         $paymentParams['contactID'] = $this->_contributorContactID;
         CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
         $payment = $this->_paymentProcessor['object'];
         if (!empty($this->_params['auto_renew'])) {
             $contributionRecurParams = $this->processRecurringContribution($paymentParams);
             $contributionRecurID = $contributionRecurParams['contributionRecurID'];
             $paymentParams = array_merge($paymentParams, $contributionRecurParams);
         }
         $result = $payment->doPayment($paymentParams);
         $this->_params = array_merge($this->_params, $result);
         $this->_params['contribution_status_id'] = $result['payment_status_id'];
         $this->_params['trxn_id'] = $result['trxn_id'];
         $this->_params['payment_instrument_id'] = 1;
         $this->_params['is_test'] = $this->_mode == 'live' ? 0 : 1;
         $this->set('params', $this->_params);
         $this->assign('trxn_id', $result['trxn_id']);
     }
     $renewalDate = !empty($this->_params['renewal_date']) ? $renewalDate = CRM_Utils_Date::processDate($this->_params['renewal_date']) : NULL;
     // check for test membership.
     $isTestMembership = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_membershipId, 'is_test');
     // chk for renewal for multiple terms CRM-8750
     $numRenewTerms = 1;
     if (is_numeric(CRM_Utils_Array::value('num_terms', $this->_params))) {
         $numRenewTerms = $this->_params['num_terms'];
     }
     //if contribution status is pending then set pay later
     $this->_params['is_pay_later'] = FALSE;
     if ($this->_params['contribution_status_id'] == array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus())) {
         $this->_params['is_pay_later'] = 1;
     }
     // These variable sets prior to renewMembership may not be required for this form. They were in
     // a function this form shared with other forms.
     $membershipSource = NULL;
     if (!empty($this->_params['membership_source'])) {
         $membershipSource = $this->_params['membership_source'];
     }
     $isPending = $this->_params['contribution_status_id'] == 2 ? TRUE : FALSE;
     list($renewMembership) = CRM_Member_BAO_Membership::renewMembership($this->_contactID, $this->_params['membership_type_id'][1], $isTestMembership, $renewalDate, NULL, $customFieldsFormatted, $numRenewTerms, $this->_membershipId, $isPending, $contributionRecurID, $membershipSource, $this->_params['is_pay_later'], CRM_Utils_Array::value('campaign_id', $this->_params));
     $this->endDate = CRM_Utils_Date::processDate($renewMembership->end_date);
     $this->membershipTypeName = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $renewMembership->membership_type_id, 'name');
     if (!empty($this->_params['record_contribution']) || $this->_mode) {
         // set the source
         $this->_params['contribution_source'] = "{$this->membershipTypeName} Membership: Offline membership renewal (by {$userName})";
         //create line items
         $lineItem = array();
         $this->_params = $this->setPriceSetParameters($this->_params);
         CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$this->_priceSetId]);
         //CRM-11529 for quick config backoffice transactions
         //when financial_type_id is passed in form, update the
         //line items with the financial type selected in form
         if ($submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $this->_params)) {
             foreach ($lineItem[$this->_priceSetId] as &$li) {
                 $li['financial_type_id'] = $submittedFinancialType;
             }
         }
         if (!empty($lineItem)) {
//.........这里部分代码省略.........
开发者ID:nyimbi,项目名称:civicrm-core,代码行数:101,代码来源:MembershipRenewal.php

示例6: fixMembershipStatusBeforeRenew

 /**
  * Method to fix membership status of stale membership
  * 
  * This method first checks if the membership is stale. If it is,
  * then status will be updated based on existing start and end
  * dates and log will be added for the status change.
  * 
  * @param  array  $currentMembership   referance to the array
  *                                     containing all values of
  *                                     the current membership
  * @param  array  $changeToday         array of month, day, year
  *                                     values in case today needs
  *                                     to be customised, null otherwise
  * 
  * @return void
  * @static
  */
 static function fixMembershipStatusBeforeRenew(&$currentMembership, $changeToday)
 {
     $today = CRM_Utils_Date::getToday($changeToday);
     require_once 'CRM/Member/BAO/MembershipStatus.php';
     $status = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($currentMembership['start_date'], $currentMembership['end_date'], $currentMembership['join_date'], $today);
     if (empty($status) || empty($status['id'])) {
         CRM_Core_Error::fatal(ts('Oops, it looks like there is no valid membership status corresponding to the membership start and end dates for this membership. Contact the site administrator for assistance.'));
     }
     $currentMembership['today_date'] = $today;
     if ($status['id'] !== $currentMembership['status_id']) {
         $memberDAO = new CRM_Member_BAO_Membership();
         $memberDAO->id = $currentMembership['id'];
         $memberDAO->find(true);
         $memberDAO->status_id = $status['id'];
         $memberDAO->join_date = CRM_Utils_Date::isoToMysql($memberDAO->join_date);
         $memberDAO->start_date = CRM_Utils_Date::isoToMysql($memberDAO->start_date);
         $memberDAO->end_date = CRM_Utils_Date::isoToMysql($memberDAO->end_date);
         $memberDAO->save();
         CRM_Core_DAO::storeValues($memberDAO, $currentMembership);
         $memberDAO->free();
         $currentMembership['is_current_member'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $currentMembership['status_id'], 'is_current_member');
         $format = '%Y%m%d';
         $logParams = array('membership_id' => $currentMembership['id'], 'status_id' => $status['id'], 'start_date' => CRM_Utils_Date::customFormat($currentMembership['start_date'], $format), 'end_date' => CRM_Utils_Date::customFormat($currentMembership['end_date'], $format), 'modified_id' => $currentMembership['contact_id'], 'modified_date' => CRM_Utils_Date::customFormat($currentMembership['today_date'], $format), 'renewal_reminder_date' => CRM_Utils_Date::customFormat($currentMembership['reminder_date'], $format));
         $dontCare = null;
         require_once 'CRM/Member/BAO/MembershipLog.php';
         CRM_Member_BAO_MembershipLog::add($logParams, $dontCare);
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:45,代码来源:Membership.php

示例7: postProcess

 /**
  * Process the renewal form.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     $ids = array();
     $config = CRM_Core_Config::singleton();
     // get the submitted form values.
     $this->_params = $formValues = $this->controller->exportValues($this->_name);
     $this->storeContactFields($formValues);
     // use values from screen
     if ($formValues['membership_type_id'][1] != 0) {
         $defaults['receipt_text_renewal'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $formValues['membership_type_id'][1], 'receipt_text_renewal');
     }
     $now = CRM_Utils_Date::getToday(NULL, 'YmdHis');
     $this->convertDateFieldsToMySQL($formValues);
     $this->assign('receive_date', $formValues['receive_date']);
     if (!empty($this->_params['send_receipt'])) {
         $formValues['receipt_date'] = $now;
         $this->assign('receipt_date', CRM_Utils_Date::mysqlToIso($formValues['receipt_date']));
     } else {
         $formValues['receipt_date'] = NULL;
     }
     if ($this->_mode) {
         $formValues['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_params, CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee'));
         if (empty($formValues['financial_type_id'])) {
             $formValues['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id');
         }
         $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($formValues['payment_processor_id'], $this->_mode);
         $fields = array();
         // set email for primary location.
         $fields['email-Primary'] = 1;
         $formValues['email-5'] = $formValues['email-Primary'] = $this->_contributorEmail;
         $formValues['register_date'] = $now;
         // now set the values for the billing location.
         foreach ($this->_fields as $name => $dontCare) {
             $fields[$name] = 1;
         }
         // also add location name to the array
         $formValues["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_middle_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_last_name', $formValues);
         $formValues["address_name-{$this->_bltID}"] = trim($formValues["address_name-{$this->_bltID}"]);
         $fields["address_name-{$this->_bltID}"] = 1;
         $fields["email-{$this->_bltID}"] = 1;
         $ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type');
         $nameFields = array('first_name', 'middle_name', 'last_name');
         foreach ($nameFields as $name) {
             $fields[$name] = 1;
             if (array_key_exists("billing_{$name}", $formValues)) {
                 $formValues[$name] = $formValues["billing_{$name}"];
                 $formValues['preserveDBName'] = TRUE;
             }
         }
         //here we are setting up the billing contact - if different from the member they are already created
         // but they will get billing details assigned
         CRM_Contact_BAO_Contact::createProfileContact($formValues, $fields, $this->_contributorContactID, NULL, NULL, $ctype);
         // add all the additional payment params we need
         $this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
         $this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
         $this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
         $this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
         $this->_params['description'] = ts('Office Credit Card Membership Renewal Contribution');
         $this->_params['ip_address'] = CRM_Utils_System::ipAddress();
         $this->_params['amount'] = $formValues['total_amount'];
         $this->_params['currencyID'] = $config->defaultCurrency;
         $this->_params['payment_action'] = 'Sale';
         $paymentParams['invoiceID'] = $this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
         // at this point we've created a contact and stored its address etc
         // all the payment processors expect the name and address to be in the passed params
         // so we copy stuff over to first_name etc.
         $paymentParams = $this->_params;
         if (!empty($this->_params['send_receipt'])) {
             $paymentParams['email'] = $this->_contributorEmail;
         }
         $paymentParams['contactID'] = $this->_contributorContactID;
         CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
         $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
         if (!empty($paymentParams['auto_renew'])) {
             $contributionRecurParams = $this->processRecurringContribution($paymentParams);
             $this->_params['contributionRecurID'] = $contributionRecurParams['contributionRecurID'];
             $paymentParams = array_merge($paymentParams, $contributionRecurParams);
         }
         $result = $payment->doDirectPayment($paymentParams);
         if (is_a($result, 'CRM_Core_Error')) {
             CRM_Core_Error::displaySessionError($result);
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership&mode={$this->_mode}"));
         }
         if ($result) {
             $this->_params = array_merge($this->_params, $result);
         }
         $formValues['contribution_status_id'] = 1;
         $formValues['invoice_id'] = $this->_params['invoiceID'];
         $formValues['trxn_id'] = $result['trxn_id'];
         $formValues['payment_instrument_id'] = 1;
         $formValues['is_test'] = $this->_mode == 'live' ? 0 : 1;
         $this->set('params', $this->_params);
         $this->assign('trxn_id', $result['trxn_id']);
     }
//.........这里部分代码省略.........
开发者ID:vincent1892,项目名称:contact_report,代码行数:101,代码来源:MembershipRenewal.php

示例8: buildExtraDataDefaultQuickForm

 protected function buildExtraDataDefaultQuickForm(CRM_Core_Form $form)
 {
     require_once 'CRM/Finance/BAO/BatchType.php';
     require_once 'CRM/Finance/BAO/BankAccount.php';
     require_once 'CRM/Contribute/PseudoConstant.php';
     $form->add('text', 'batch_title', ts('Batch Title'), null, true);
     $form->add('textarea', 'description', ts('Description'), null, false);
     $emptySelect1[''] = '- select -';
     $bankAccounts = CRM_Finance_BAO_BankAccount::getBankAccountsList($emptySelect1);
     $form->add('select', 'banking_account', ts('Bank Account'), $bankAccounts, true);
     //TODO: how to get this in civicrm default format?
     $current = CRM_Utils_Date::getToday(null, 'm/d/Y');
     $form->addDate('banking_date', ts('Banking Date'), true, array('formatType' => 'activityDate', 'value' => $current));
     $form->addElement('checkbox', 'exclude_from_posting', ts('Exclude from posting'), null, null);
     $emptySelect[''] = '- select -';
     $contributionTypes = CRM_Finance_BAO_BatchType::getContributionTypesList($emptySelect);
     $form->add('select', 'contribution_type_id', ts('Contribution Type'), $contributionTypes, true);
     $el = $form->add('select', 'payment_instrument_id', ts('Payment Method'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), true);
     $el->setValue($this->getDefaultPaymentMethodId());
     if (!in_array('campaign_id', $this->hideDefaultFields)) {
         $form->add('text', 'campaign_name', ts('Default Campaign Code'), array('class' => 'form text huge'), true);
         $form->add('hidden', 'campaign_id');
     }
     if (!in_array('received_date', $this->hideDefaultFields)) {
         $form->addDate('received_date', ts('Received date'), true, array('formatType' => 'activityDate', 'value' => $current));
     }
     //$form->add('select', 'contribution_type_id', ts('Contribution Type ID'), array(''=>ts( '- select -' )) + CRM_Contribute_PseudoConstant::contributionType( ), true );
     //matusz: http://support.vedaconsulting.co.uk/issues/81
     //$form->addDate( 'expected_posting_date', ts('Expected posting date'), true, array('formatType' => 'activityDate') );
     $form->addFormRule(array($this, 'extraDataQuickFormRule'));
 }
开发者ID:hoegrammer,项目名称:uk.co.vedaconsulting.module.justgivingImports,代码行数:31,代码来源:SourceAbstract.php

示例9: postProcess

 /**
  * Function to process the renewal form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     require_once 'CRM/Member/BAO/Membership.php';
     require_once 'CRM/Member/BAO/MembershipType.php';
     require_once 'CRM/Member/BAO/MembershipStatus.php';
     // get the submitted form values.
     $this->_params = $formValues = $this->controller->exportValues($this->_name);
     $params = array();
     $ids = array();
     $config =& CRM_Core_Config::singleton();
     $params['contact_id'] = $this->_contactID;
     if ($this->_mode) {
         $formValues['total_amount'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee');
         $formValues['contribution_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'contribution_type_id');
         require_once 'CRM/Core/BAO/PaymentProcessor.php';
         $this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($formValues['payment_processor_id'], $this->_mode);
         require_once "CRM/Contact/BAO/Contact.php";
         $now = CRM_Utils_Date::getToday($now, 'YmdHis');
         $fields = array();
         // set email for primary location.
         $fields["email-Primary"] = 1;
         $formValues["email-5"] = $formValues["email-Primary"] = $this->_contributorEmail;
         $formValues['register_date'] = $now;
         // now set the values for the billing location.
         foreach ($this->_fields as $name => $dontCare) {
             $fields[$name] = 1;
         }
         // also add location name to the array
         $formValues["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_middle_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_last_name', $formValues);
         $formValues["address_name-{$this->_bltID}"] = trim($formValues["address_name-{$this->_bltID}"]);
         $fields["address_name-{$this->_bltID}"] = 1;
         $fields["email-{$this->_bltID}"] = 1;
         $ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type');
         $nameFields = array('first_name', 'middle_name', 'last_name');
         foreach ($nameFields as $name) {
             $fields[$name] = 1;
             if (array_key_exists("billing_{$name}", $formValues)) {
                 $formValues[$name] = $formValues["billing_{$name}"];
                 $formValues['preserveDBName'] = true;
             }
         }
         $contactID = CRM_Contact_BAO_Contact::createProfileContact($formValues, $fields, $this->_contactID, null, null, $ctype);
         // add all the additioanl payment params we need
         $this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
         $this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
         $this->_params['year'] = $this->_params['credit_card_exp_date']['Y'];
         $this->_params['month'] = $this->_params['credit_card_exp_date']['M'];
         $this->_params['ip_address'] = CRM_Utils_System::ipAddress();
         $this->_params['amount'] = $formValues['total_amount'];
         $this->_params['currencyID'] = $config->defaultCurrency;
         $this->_params['payment_action'] = 'Sale';
         $this->_params['invoiceID'] = md5(uniqid(rand(), true));
         // at this point we've created a contact and stored its address etc
         // all the payment processors expect the name and address to be in the
         // so we copy stuff over to first_name etc.
         $paymentParams = $this->_params;
         if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
             $paymentParams['email'] = $this->_contributorEmail;
         }
         require_once 'CRM/Core/Payment/Form.php';
         CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, true);
         $payment =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $this->_paymentProcessor, $this);
         $result =& $payment->doDirectPayment($paymentParams);
         if (is_a($result, 'CRM_Core_Error')) {
             CRM_Core_Error::displaySessionError($result);
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership&mode={$this->_mode}"));
         }
         if ($result) {
             $this->_params = array_merge($this->_params, $result);
         }
         $formValues['contribution_status_id'] = 1;
         $formValues['receive_date'] = $now;
         $formValues['invoice_id'] = $this->_params['invoiceID'];
         $formValues['trxn_id'] = $result['trxn_id'];
         $formValues['payment_instrument_id'] = 1;
         $formValues['is_test'] = $this->_mode == 'live' ? 0 : 1;
         if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
             $formValues['receipt_date'] = $now;
         } else {
             $formValues['receipt_date'] = null;
         }
         $this->set('params', $this->_params);
         $this->assign('trxn_id', $result['trxn_id']);
         $this->assign('receive_date', CRM_Utils_Date::mysqlToIso($formValues['receive_date']));
     }
     $renewalDate = null;
     if ($formValues['renewal_date']) {
         $this->set('renewDate', CRM_Utils_Date::processDate($formValues['renewal_date']));
     }
     $this->_membershipId = $this->_id;
     // check for test membership.
     $isTestMembership = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_membershipId, 'is_test');
     $renewMembership = CRM_Member_BAO_Membership::renewMembership($this->_contactID, $this->_memType, $isTestMembership, $this, null);
     $endDate = CRM_Utils_Date::processDate($renewMembership->end_date);
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:MembershipRenewal.php

示例10: preProcess

 /** 
  * Heart of the viewing process. The runner gets all the meta data for 
  * the contact and calls the appropriate type of page to view. 
  * 
  * @return void 
  * @access public 
  * 
  */
 function preProcess()
 {
     require_once "CRM/Member/BAO/MembershipType.php";
     require_once "CRM/Member/BAO/Membership.php";
     CRM_Utils_System::setTitle(ts('CiviMember'));
     $membershipSummary = array();
     $preMonth = CRM_Utils_Date::customFormat(date("Y-m-d", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d');
     $preMonthEnd = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d');
     $preMonthYear = mktime(0, 0, 0, substr($preMonth, 4, 2), 1, substr($preMonth, 0, 4));
     $today = getdate();
     $date = CRM_Utils_Date::getToday();
     $isCurrentMonth = 0;
     if ($ym = CRM_Utils_Array::value('date', $_GET)) {
         if (preg_match('/^\\d{6}$/', $ym) == 0 || !checkdate(substr($ym, 4, 2), 1, substr($ym, 0, 4)) || substr($ym, 0, 1) == 0) {
             CRM_Core_Error::fatal(ts('Invalid date query "%1" in URL (valid syntax is yyyymm).', array(1 => $ym)));
         }
         $isPreviousMonth = 0;
         $isCurrentMonth = substr($ym, 0, 4) == $today['year'] && substr($ym, 4, 2) == $today['mon'];
         $ymd = date('Ymd', mktime(0, 0, -1, substr($ym, 4, 2) + 1, 1, substr($ym, 0, 4)));
         $monthStartTs = mktime(0, 0, 0, substr($ym, 4, 2), 1, substr($ym, 0, 4));
         $current = CRM_Utils_Date::customFormat($date, '%Y%m%d');
     } else {
         $ym = sprintf("%04d%02d", $today['year'], $today['mon']);
         $ymd = sprintf("%04d%02d%02d", $today['year'], $today['mon'], $today['mday']);
         $monthStartTs = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
         $current = null;
         $isCurrentMonth = 1;
         $isPreviousMonth = 1;
     }
     $monthStart = $ym . '01';
     $yearStart = substr($ym, 0, 4) . '0101';
     $membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes(false);
     //$membership = new CRM_Member_BAO_Membership;//added
     foreach ($membershipTypes as $key => $value) {
         $membershipSummary[$key]['premonth'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $preMonth, $preMonthEnd), 'name' => $value);
         $membershipSummary[$key]['month'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $monthStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['year'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $yearStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['current'] = array('count' => CRM_Member_BAO_Membership::getMembershipCount($key, $current), 'name' => $value);
         $membershipSummary[$key]['total'] = array('count' => CRM_Member_BAO_Membership::getMembershipCount($key, $ymd));
     }
     require_once "CRM/Member/BAO/MembershipStatus.php";
     $status = CRM_Member_BAO_MembershipStatus::getMembershipStatusCurrent();
     $status = implode(',', $status);
     foreach ($membershipSummary as $typeID => $details) {
         foreach ($details as $key => $value) {
             switch ($key) {
                 case 'premonth':
                     $membershipSummary[$typeID][$key]['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&start={$preMonth}&end={$preMonthEnd}");
                     break;
                 case 'month':
                     $membershipSummary[$typeID][$key]['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&start={$monthStart}&end={$ymd}");
                     break;
                 case 'year':
                     $membershipSummary[$typeID][$key]['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&start={$yearStart}&end={$ymd}");
                     break;
                 case 'current':
                     $membershipSummary[$typeID][$key]['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}");
                     break;
                 case 'total':
                     if (!$isCurrentMonth) {
                         $membershipSummary[$typeID][$key]['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&start=&end={$ymd}&status={$status}&type={$typeID}");
                     } else {
                         $membershipSummary[$typeID][$key]['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}");
                     }
                     break;
             }
         }
     }
     $totalCount = array();
     $totalCountPreMonth = $totalCountMonth = $totalCountYear = $totalCountCurrent = $totalCountTotal = 0;
     foreach ($membershipSummary as $key => $value) {
         $totalCountPreMonth = $totalCountPreMonth + $value['premonth']['count'];
         $totalCountMonth = $totalCountMonth + $value['month']['count'];
         $totalCountYear = $totalCountYear + $value['year']['count'];
         $totalCountCurrent = $totalCountCurrent + $value['current']['count'];
         $totalCountTotal = $totalCountTotal + $value['total']['count'];
     }
     $totalCount['premonth'] = array("count" => $totalCountPreMonth, "url" => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&start={$preMonth}&end={$preMonthEnd}"));
     $totalCount['month'] = array("count" => $totalCountMonth, "url" => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&start={$monthStart}&end={$ymd}"));
     $totalCount['year'] = array("count" => $totalCountYear, "url" => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&start={$yearStart}&end={$ymd}"));
     $totalCount['current'] = array("count" => $totalCountCurrent, "url" => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}"));
     $totalCount['total'] = array("count" => $totalCountTotal, "url" => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}"));
     if (!$isCurrentMonth) {
         $totalCount['total'] = array("count" => $totalCountTotal, "url" => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&start=&end={$ymd}"));
     }
     $this->assign('membershipSummary', $membershipSummary);
     $this->assign('totalCount', $totalCount);
     $this->assign('month', date('F', $monthStartTs));
     $this->assign('year', date('Y', $monthStartTs));
     $this->assign('premonth', date('F', $preMonthYear));
     $this->assign('currentMonth', date('F'));
     $this->assign('currentYear', date('Y'));
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:DashBoard.php

示例11: preProcess

 /**
  * Heart of the viewing process. The runner gets all the meta data for
  * the contact and calls the appropriate type of page to view.
  *
  * @return void
  * @access public
  *
  */
 function preProcess()
 {
     CRM_Utils_System::setTitle(ts('CiviMember'));
     $membershipSummary = array();
     $preMonth = CRM_Utils_Date::customFormat(date("Y-m-d", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d');
     $preMonthEnd = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d');
     $prePreMonthEnd = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m") - 2, 01, date("Y"))), '%Y%m%d');
     $preMonthYear = mktime(0, 0, 0, substr($preMonth, 4, 2), 1, substr($preMonth, 0, 4));
     $today = getdate();
     $date = CRM_Utils_Date::getToday();
     $isCurrentMonth = 0;
     $ym = CRM_Utils_Array::value('date', $_GET);
     if ($ym) {
         if (preg_match('/^\\d{6}$/', $ym) == 0 || !checkdate(substr($ym, 4, 2), 1, substr($ym, 0, 4)) || substr($ym, 0, 1) == 0) {
             CRM_Core_Error::fatal(ts('Invalid date query "%1" in URL (valid syntax is yyyymm).', array(1 => $ym)));
         }
         $isPreviousMonth = 0;
         $isCurrentMonth = substr($ym, 0, 4) == $today['year'] && substr($ym, 4, 2) == $today['mon'];
         $ymd = date('Ymd', mktime(0, 0, -1, substr($ym, 4, 2) + 1, 1, substr($ym, 0, 4)));
         $monthStartTs = mktime(0, 0, 0, substr($ym, 4, 2), 1, substr($ym, 0, 4));
         $current = CRM_Utils_Date::customFormat($date, '%Y%m%d');
     } else {
         $ym = sprintf("%04d%02d", $today['year'], $today['mon']);
         $ymd = sprintf("%04d%02d%02d", $today['year'], $today['mon'], $today['mday']);
         $monthStartTs = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
         $current = NULL;
         $isCurrentMonth = 1;
         $isPreviousMonth = 1;
     }
     $monthStart = $ym . '01';
     $yearStart = substr($ym, 0, 4) . '0101';
     // $preMonthStart is the day before $monthStart
     $preMonthStart = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, substr($ym, 4, 2) - 1, 01, substr($ym, 0, 4))), '%Y%m%d');
     // $preYearStart is the day before $yearStart
     $preYearStart = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, 12, 31, substr($ym, 0, 4) - 1)), '%Y%m%d');
     $membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE);
     // added
     //$membership = new CRM_Member_BAO_Membership;
     foreach ($membershipTypes as $key => $value) {
         $membershipSummary[$key]['premonth']['new'] = array('count' => CRM_Member_BAO_Membership::getMembershipJoins($key, $preMonth, $preMonthEnd), 'name' => $value);
         $membershipSummary[$key]['premonth']['renew'] = array('count' => CRM_Member_BAO_Membership::getMembershipRenewals($key, $preMonth, $preMonthEnd), 'name' => $value);
         $membershipSummary[$key]['premonth']['total'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $preMonth, $preMonthEnd), 'name' => $value);
         $membershipSummary[$key]['month']['new'] = array('count' => CRM_Member_BAO_Membership::getMembershipJoins($key, $monthStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['month']['renew'] = array('count' => CRM_Member_BAO_Membership::getMembershipRenewals($key, $monthStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['month']['total'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $monthStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['year']['new'] = array('count' => CRM_Member_BAO_Membership::getMembershipJoins($key, $yearStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['year']['renew'] = array('count' => CRM_Member_BAO_Membership::getMembershipRenewals($key, $yearStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['year']['total'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $yearStart, $ymd), 'name' => $value);
         $membershipSummary[$key]['current']['total'] = array('count' => CRM_Member_BAO_Membership::getMembershipCount($key, $current), 'name' => $value);
         $membershipSummary[$key]['total']['total'] = array('count' => CRM_Member_BAO_Membership::getMembershipCount($key, $ymd));
         //LCD also get summary stats for membership owners
         $membershipSummary[$key]['premonth_owner']['premonth_owner'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $preMonth, $preMonthEnd, 0, 1), 'name' => $value);
         $membershipSummary[$key]['month_owner']['month_owner'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $monthStart, $ymd, 0, 1), 'name' => $value);
         $membershipSummary[$key]['year_owner']['year_owner'] = array('count' => CRM_Member_BAO_Membership::getMembershipStarts($key, $yearStart, $ymd, 0, 1), 'name' => $value);
         $membershipSummary[$key]['current_owner']['current_owner'] = array('count' => CRM_Member_BAO_Membership::getMembershipCount($key, $current, 0, 1), 'name' => $value);
         $membershipSummary[$key]['total_owner']['total_owner'] = array('count' => CRM_Member_BAO_Membership::getMembershipCount($key, $ymd, 0, 1));
         //LCD end
     }
     // LCD debug
     //CRM_Core_Error::debug($membershipSummary);
     $status = CRM_Member_BAO_MembershipStatus::getMembershipStatusCurrent();
     $status = implode(',', $status);
     foreach ($membershipSummary as $typeID => $details) {
         foreach ($details as $key => $value) {
             switch ($key) {
                 case 'premonth':
                     $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&join={$preMonth}&joinEnd={$preMonthEnd}&start={$preMonth}&end={$preMonthEnd}");
                     $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&joinEnd={$prePreMonthEnd}&start={$preMonth}&end={$preMonthEnd}");
                     $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&start={$preMonth}&end={$preMonthEnd}");
                     break;
                 case 'month':
                     $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&join={$monthStart}&joinEnd={$ymd}&start={$monthStart}&end={$ymd}");
                     $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&joinEnd={$preMonthStart}&start={$monthStart}&end={$ymd}");
                     $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&start={$monthStart}&end={$ymd}");
                     break;
                 case 'year':
                     $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&join={$yearStart}&joinEnd={$ymd}&start={$yearStart}&end={$ymd}");
                     $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&joinEnd={$preYearStart}&start={$yearStart}&end={$ymd}");
                     $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}&start={$yearStart}&end={$ymd}");
                     break;
                 case 'current':
                     $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}&type={$typeID}");
                     break;
                 case 'total':
                     if (!$isCurrentMonth) {
                         $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&start=&end={$ymd}&status={$status}&type={$typeID}");
                     } else {
                         $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status={$status}");
                     }
                     break;
                     //LCD add owner urls
                 //LCD add owner urls
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:DashBoard.php

示例12: isActive

 static function isActive($code)
 {
     if (empty($code['active_on'])) {
         return TRUE;
     }
     $time = CRM_Utils_Date::getToday(null, 'Y-m-d H:i:s');
     if (strtotime($time) > abs(strtotime($code['active_on']))) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:11,代码来源:Item.php

示例13: getRenewalDatesForMembershipType

 /**
  * Function to calculate start date and end date for renewal membership 
  * 
  * @param int $membershipId 
  *
  * @return Array array fo the start date, end date and join date of the membership
  * @static
  */
 function getRenewalDatesForMembershipType($membershipId, $changeToday = null)
 {
     require_once 'CRM/Member/BAO/Membership.php';
     require_once 'CRM/Member/BAO/MembershipStatus.php';
     $params = array('id' => $membershipId);
     $membership =& new CRM_Member_BAO_Membership();
     //$membership->copyValues( $params );
     $membership->id = $membershipId;
     $membership->find(true);
     $membershipDetails = CRM_Member_BAO_Membership::getValues($params, $values);
     $statusID = $membershipDetails[$membershipId]->status_id;
     $membershipTypeDetails = self::getMembershipTypeDetails($membershipDetails[$membershipId]->membership_type_id);
     $statusDetails = CRM_Member_BAO_MembershipStatus::getMembershipStatus($statusID);
     if ($statusDetails['is_current_member'] == 1) {
         $startDate = $membershipDetails[$membershipId]->start_date;
         $date = explode('-', $membershipDetails[$membershipId]->end_date);
         $logStartDate = date('Y-m-d', mktime(0, 0, 0, (double) $date[1], (double) ($date[2] + 1), (double) $date[0]));
         $date = explode('-', $logStartDate);
         $year = $date[0];
         $month = $date[1];
         $day = $date[2];
         switch ($membershipTypeDetails['duration_unit']) {
             case 'year':
                 $year = $year + $membershipTypeDetails['duration_interval'];
                 break;
             case 'month':
                 $month = $month + $membershipTypeDetails['duration_interval'];
                 break;
             case 'day':
                 $day = $day + $membershipTypeDetails['duration_interval'];
                 break;
         }
         if ($membershipTypeDetails['duration_unit'] == 'lifetime') {
             $endDate = null;
         } else {
             $endDate = date('Y-m-d', mktime(0, 0, 0, $month, $day - 1, $year));
         }
         $today = date('Y-m-d');
     } else {
         $today = CRM_Utils_Date::getToday($changeToday);
         $rollover = false;
         if ($membershipTypeDetails['period_type'] == 'rolling') {
             $startDate = $logStartDate = $today;
         } else {
             if ($membershipTypeDetails['period_type'] == 'fixed') {
                 // Renewing expired membership is two step process.
                 // 1. Renew the start date
                 // 2. Renew the end date
                 // 1.
                 $date = explode('-', $membershipDetails[$membershipId]->start_date);
                 $yearValue = date('Y');
                 $startDate = $logStartDate = date('Y-m-d', mktime(0, 0, 0, (double) $date[1], (double) $date[2], $yearValue));
                 // before moving to the step 2, check if TODAY is in
                 // rollover window.
                 $rolloverDay = substr($membershipTypeDetails['fixed_period_rollover_day'], -2);
                 $rolloverMonth = substr($membershipTypeDetails['fixed_period_rollover_day'], 0, -2);
                 $fixedStartMonth = substr($membershipTypeDetails['fixed_period_start_day'], 0, -2);
                 if ($rolloverMonth - $fixedStartMonth < 0) {
                     $rolloverDate = date('Ymd', mktime(0, 0, 0, (double) $rolloverMonth, (double) $rolloverDay, $yearValue + 1));
                 } else {
                     $rolloverDate = date('Ymd', mktime(0, 0, 0, (double) $rolloverMonth, (double) $rolloverDay, $yearValue));
                 }
                 if (CRM_Utils_Date::isoToMysql($today) > $rolloverDate) {
                     $rollover = true;
                 }
             }
         }
         // 2.
         $date = explode('-', $startDate);
         $year = (double) $date[0];
         $month = (double) $date[1];
         $day = (double) $date[2];
         switch ($membershipTypeDetails['duration_unit']) {
             case 'year':
                 $year = $year + $membershipTypeDetails['duration_interval'];
                 if ($rollover) {
                     $year = $year + $membershipTypeDetails['duration_interval'];
                 }
                 break;
             case 'month':
                 $month = $month + $membershipTypeDetails['duration_interval'];
                 if ($rollover) {
                     $month = $month + $membershipTypeDetails['duration_interval'];
                 }
                 break;
             case 'day':
                 $day = $day + $membershipTypeDetails['duration_interval'];
                 if ($rollover) {
                     $day = $day + $membershipTypeDetails['duration_interval'];
                 }
                 break;
         }
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:MembershipType.php

示例14: processSignOut

 static function processSignOut($pickupName, $studentID, $atSchoolMeeting = false)
 {
     static $_now = null;
     static $_date = null;
     if (!$_now) {
         $_now = CRM_Utils_Date::getToday(null, 'YmdHis');
     }
     if (!$_date) {
         $_date = CRM_Utils_Date::getToday(null, 'Y-m-d');
     }
     if ($atSchoolMeeting === 'true') {
         $atSchoolMeeting = 1;
     } else {
         if ($atSchoolMeeting === 'false') {
             $atSchoolMeeting = 0;
         }
     }
     $atSchoolMeeting = $atSchoolMeeting ? '1' : '0';
     $sql = "\nSELECT e.id, e.class, s.location\nFROM   civicrm_value_extended_care_signout e\nINNER JOIN sfschool_extended_care_source s ON ( e.class = s.name )\nWHERE  entity_id = %1\nAND    signin_time LIKE '{$_date}%'\nAND    ( is_morning = 0 OR is_morning IS NULL )\nAND    s.day_of_week = DAYNAME( '{$_date}' )\n";
     $params = array(1 => array($studentID, 'Integer'));
     $dao = CRM_Core_DAO::executeQuery($sql, $params);
     $params = array(1 => array($studentID, 'Integer'), 2 => array($pickupName, 'String'), 3 => array($_now, 'Timestamp'), 4 => array($atSchoolMeeting, 'Integer'));
     $class = null;
     if ($dao->fetch()) {
         if ($dao->location) {
             $class = "{$dao->class} ({$dao->location})";
         } else {
             $class = $dao->class;
         }
         $sql = "\nUPDATE civicrm_value_extended_care_signout\nSET    pickup_person_name = %2,\n       signout_time       = %3,\n       at_school_meeting  = %4\nWHERE  id = %5\n";
         $params[5] = array($dao->id, 'Integer');
     } else {
         $sql = "\nINSERT INTO civicrm_value_extended_care_signout\n( entity_id, pickup_person_name, signin_time, signout_time, at_school_meeting, is_morning )\nVALUES\n( %1, %2, %3, %3, %4, 0 )\n";
     }
     CRM_Core_DAO::executeQuery($sql, $params);
     return $class;
 }
开发者ID:pzingg,项目名称:sfschool,代码行数:37,代码来源:ExtendedCare.php

示例15: migrateData

 protected function migrateData()
 {
     CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS civicrm_hrpay_scale");
     CRM_Core_DAO::executeQuery("\n        CREATE TABLE IF NOT EXISTS `civicrm_hrpay_scale` (\n        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n          `pay_scale` VARCHAR(63) DEFAULT NULL,\n          `pay_grade` VARCHAR(63) DEFAULT NULL,\n          `currency` VARCHAR(63) DEFAULT NULL,\n          `amount` DECIMAL(10,2) DEFAULT NULL,\n          `periodicity` VARCHAR(63) DEFAULT NULL,\n          `is_active` tinyint(4) DEFAULT '1',\n          PRIMARY KEY(id)\n        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1\n      ");
     CRM_Core_DAO::executeQuery("\n        INSERT INTO `civicrm_hrpay_scale` (`pay_scale`, `pay_grade`, `currency`, `amount`, `periodicity`, `is_active`) VALUES\n        ('US', 'Senior', 'USD', 38000, 'Year', 1),\n        ('US', 'Junior', 'USD', 24000, 'Year', 1),\n        ('UK', 'Senior', 'GBP', 35000, 'Year', 1),\n        ('UK', 'Junior', 'GBP', 22000, 'Year', 1),\n        ('Not Applicable', NULL, NULL, NULL, NULL, 1)\n    ");
     $tableExists = $this->checkTableExists(array('civicrm_hrjob', 'civicrm_hrjob_health', 'civicrm_hrjob_hour', 'civicrm_hrjob_leave', 'civicrm_hrjob_pay', 'civicrm_hrjob_pension', 'civicrm_hrjob_role', 'civicrm_value_job_summary_10'));
     if (!$tableExists['civicrm_hrjob']) {
         return false;
     }
     $hrJob = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_hrjob ORDER BY id ASC');
     while ($hrJob->fetch()) {
         // Creating Job Contract:
         $insertContractQuery = 'INSERT INTO civicrm_hrjobcontract SET contact_id = %1, is_primary = %2';
         $insertContractParams = array(1 => array($hrJob->contact_id, 'Integer'), 2 => array($hrJob->is_primary, 'Integer'));
         CRM_Core_DAO::executeQuery($insertContractQuery, $insertContractParams);
         $jobContractId = (int) CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()');
         // Creating Job Contract Revision:
         $insertRevisionQuery = 'INSERT INTO civicrm_hrjobcontract_revision SET jobcontract_id = %1';
         $insertRevisionParams = array(1 => array($jobContractId, 'Integer'));
         CRM_Core_DAO::executeQuery($insertRevisionQuery, $insertRevisionParams);
         $revisionId = (int) CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()');
         // Populating data with existing HRJob entities:
         $this->populateTableWithEntity('civicrm_hrjobcontract_details', $hrJob, array('position' => 'String', 'title' => 'String', 'funding_notes' => 'String', 'contract_type' => 'String', 'period_start_date' => 'Date', 'period_end_date' => 'Date', 'notice_amount' => 'Float', 'notice_unit' => 'String', 'notice_amount_employee' => 'Float', 'notice_unit_employee' => 'String', 'location' => 'String'), $revisionId);
         $healthRevisionId = 0;
         if ($tableExists['civicrm_hrjob_health']) {
             $hrJobHealth = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_hrjob_health WHERE job_id = %1', array(1 => array($hrJob->id, 'Integer')));
             while ($hrJobHealth->fetch()) {
                 $this->populateTableWithEntity('civicrm_hrjobcontract_health', $hrJobHealth, array('provider' => 'Integer', 'plan_type' => 'String', 'description' => 'String', 'dependents' => 'String', 'provider_life_insurance' => 'Integer', 'plan_type_life_insurance' => 'String', 'description_life_insurance' => 'String', 'dependents_life_insurance' => 'String'), $revisionId);
                 $healthRevisionId = $revisionId;
             }
         }
         $hourRevisionId = 0;
         if ($tableExists['civicrm_hrjob_hour']) {
             $hrJobHour = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_hrjob_hour WHERE job_id = %1', array(1 => array($hrJob->id, 'Integer')));
             while ($hrJobHour->fetch()) {
                 $this->populateTableWithEntity('civicrm_hrjobcontract_hour', $hrJobHour, array('hours_type' => 'String', 'hours_amount' => 'Float', 'hours_unit' => 'String', 'hours_fte' => 'Float', 'fte_num' => 'Integer', 'fte_denom' => 'Integer'), $revisionId);
                 $hourRevisionId = $revisionId;
             }
         }
         // MULTIPLE
         $leaveRevisionId = 0;
         if ($tableExists['civicrm_hrjob_leave']) {
             $hrJobLeave = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_hrjob_leave WHERE job_id = %1', array(1 => array($hrJob->id, 'Integer')));
             while ($hrJobLeave->fetch()) {
                 $this->populateTableWithEntity('civicrm_hrjobcontract_leave', $hrJobLeave, array('leave_type' => 'Integer', 'leave_amount' => 'Integer'), $revisionId);
                 $leaveRevisionId = $revisionId;
             }
         }
         $payRevisionId = 0;
         if ($tableExists['civicrm_hrjob_pay']) {
             $hrJobPay = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_hrjob_pay WHERE job_id = %1', array(1 => array($hrJob->id, 'Integer')));
             while ($hrJobPay->fetch()) {
                 $payScaleId = $this->getPayScaleId($hrJobPay->pay_scale);
                 $hrJobPay->pay_scale = $payScaleId;
                 $this->populateTableWithEntity('civicrm_hrjobcontract_pay', $hrJobPay, array('pay_scale' => 'String', 'is_paid' => 'Integer', 'pay_amount' => 'Float', 'pay_unit' => 'String', 'pay_currency' => 'String', 'pay_annualized_est' => 'Float', 'pay_is_auto_est' => 'Integer'), $revisionId);
                 $payRevisionId = $revisionId;
             }
         }
         $pensionRevisionId = 0;
         if ($tableExists['civicrm_hrjob_pension']) {
             $hrJobPension = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_hrjob_pension WHERE job_id = %1', array(1 => array($hrJob->id, 'Integer')));
             while ($hrJobPension->fetch()) {
                 $this->populateTableWithEntity('civicrm_hrjobcontract_pension', $hrJobPension, array('is_enrolled' => 'Integer', 'ee_contrib_pct' => 'Float', 'er_contrib_pct' => 'Float', 'pension_type' => 'String', 'ee_contrib_abs' => 'Float', 'ee_evidence_note' => 'String'), $revisionId);
                 $pensionRevisionId = $revisionId;
             }
         }
         // MULTIPLE
         $roleRevisionId = 0;
         if ($tableExists['civicrm_hrjob_role']) {
             $hrJobRole = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_hrjob_role WHERE job_id = %1', array(1 => array($hrJob->id, 'Integer')));
             while ($hrJobRole->fetch()) {
                 $this->populateTableWithEntity('civicrm_hrjobcontract_role', $hrJobRole, array('title' => 'String', 'description' => 'String', 'hours' => 'Float', 'role_hours_unit' => 'String', 'region' => 'String', 'department' => 'String', 'level_type' => 'String', 'manager_contact_id' => 'Integer', 'functional_area' => 'String', 'organization' => 'String', 'cost_center' => 'String', 'funder' => 'String', 'percent_pay_funder' => 'String', 'percent_pay_role' => 'Integer', 'location' => 'String'), $revisionId);
                 $roleRevisionId = $revisionId;
             }
         }
         // Creating entities entries with default values for non existing entities.
         if (!$healthRevisionId) {
             CRM_Core_DAO::executeQuery('INSERT INTO civicrm_hrjobcontract_health SET jobcontract_revision_id = %1', array(1 => array($revisionId, 'Integer')));
         }
         if (!$hourRevisionId) {
             CRM_Core_DAO::executeQuery('INSERT INTO civicrm_hrjobcontract_hour SET jobcontract_revision_id = %1', array(1 => array($revisionId, 'Integer')));
         }
         if (!$payRevisionId) {
             CRM_Core_DAO::executeQuery('INSERT INTO civicrm_hrjobcontract_pay SET jobcontract_revision_id = %1', array(1 => array($revisionId, 'Integer')));
         }
         if (!$pensionRevisionId) {
             CRM_Core_DAO::executeQuery('INSERT INTO civicrm_hrjobcontract_pension SET jobcontract_revision_id = %1', array(1 => array($revisionId, 'Integer')));
         }
         $effectiveDate = null;
         $periodStartDate = explode('-', $hrJob->period_start_date);
         if (count($periodStartDate) === 3) {
             $effectiveDate = array('month' => $periodStartDate[1], 'day' => $periodStartDate[2], 'year' => $periodStartDate[0]);
         }
         // Updating Revision:
         $updateRevisionQuery = 'UPDATE civicrm_hrjobcontract_revision SET ' . 'effective_date = %12,' . 'details_revision_id = %1,' . 'health_revision_id = %2,' . 'hour_revision_id = %3,' . 'leave_revision_id = %4,' . 'pay_revision_id = %5,' . 'pension_revision_id = %6,' . 'role_revision_id = %7,' . 'created_date = %8,' . 'modified_date = %9,' . 'status = %10' . ' WHERE id = %11';
         $updateRevisionParams = array(1 => array($revisionId, 'Integer'), 2 => array($revisionId, 'Integer'), 3 => array($revisionId, 'Integer'), 4 => array($leaveRevisionId, 'Integer'), 5 => array($revisionId, 'Integer'), 6 => array($revisionId, 'Integer'), 7 => array($roleRevisionId, 'Integer'), 8 => array(CRM_Utils_Date::getToday(null, 'YmdHis'), 'Timestamp'), 9 => array(CRM_Utils_Date::getToday(null, 'YmdHis'), 'Timestamp'), 10 => array(1, 'Integer'), 11 => array($revisionId, 'Integer'), 12 => array(CRM_Utils_Date::getToday($effectiveDate, 'Ymd'), 'Timestamp'));
         CRM_Core_DAO::executeQuery($updateRevisionQuery, $updateRevisionParams);
     }
     // Migrating Job_Summary data:
     if ($tableExists['civicrm_value_job_summary_10']) {
//.........这里部分代码省略.........
开发者ID:JoeMurray,项目名称:civihr,代码行数:101,代码来源:Upgrader.php


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