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


PHP CRM_Utils_Date::isoToMysql方法代码示例

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


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

示例1: alterDisplay

 /**
  * @param $rows
  */
 function alterDisplay(&$rows)
 {
     // cache for id → is_deleted mapping
     $isDeleted = array();
     $newRows = array();
     foreach ($rows as $key => &$row) {
         if (!isset($isDeleted[$row['log_civicrm_entity_altered_contact_id']])) {
             $isDeleted[$row['log_civicrm_entity_altered_contact_id']] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['log_civicrm_entity_altered_contact_id'], 'is_deleted') !== '0';
         }
         if (!empty($row['log_civicrm_entity_altered_contact']) && !$isDeleted[$row['log_civicrm_entity_altered_contact_id']]) {
             $row['log_civicrm_entity_altered_contact_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_entity_altered_contact_id']);
             $row['log_civicrm_entity_altered_contact_hover'] = ts("Go to contact summary");
             $entity = $this->getEntityValue($row['log_civicrm_entity_id'], $row['log_civicrm_entity_log_type'], $row['log_civicrm_entity_log_date']);
             if ($entity) {
                 $row['log_civicrm_entity_altered_contact'] = $row['log_civicrm_entity_altered_contact'] . " [{$entity}]";
             }
         }
         $row['altered_by_contact_display_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_entity_log_user_id']);
         $row['altered_by_contact_display_name_hover'] = ts("Go to contact summary");
         if ($row['log_civicrm_entity_is_deleted'] and 'Update' == CRM_Utils_Array::value('log_civicrm_entity_log_action', $row)) {
             $row['log_civicrm_entity_log_action'] = ts('Delete (to trash)');
         }
         if ('Contact' == CRM_Utils_Array::value('log_type', $this->_logTables[$row['log_civicrm_entity_log_type']]) && CRM_Utils_Array::value('log_civicrm_entity_log_action', $row) == 'Insert') {
             $row['log_civicrm_entity_log_action'] = ts('Update');
         }
         if ($newAction = $this->getEntityAction($row['log_civicrm_entity_id'], $row['log_civicrm_entity_log_conn_id'], $row['log_civicrm_entity_log_type'], CRM_Utils_Array::value('log_civicrm_entity_log_action', $row))) {
             $row['log_civicrm_entity_log_action'] = $newAction;
         }
         $row['log_civicrm_entity_log_type'] = $this->getLogType($row['log_civicrm_entity_log_type']);
         $date = CRM_Utils_Date::isoToMysql($row['log_civicrm_entity_log_date']);
         if ('Update' == CRM_Utils_Array::value('log_civicrm_entity_log_action', $row)) {
             $q = "reset=1&log_conn_id={$row['log_civicrm_entity_log_conn_id']}&log_date=" . $date;
             if ($this->cid) {
                 $q .= '&cid=' . $this->cid;
             }
             $q .= !empty($row['log_civicrm_entity_altered_contact']) ? '&alteredName=' . $row['log_civicrm_entity_altered_contact'] : '';
             $q .= !empty($row['altered_by_contact_display_name']) ? '&alteredBy=' . $row['altered_by_contact_display_name'] : '';
             $q .= !empty($row['log_civicrm_entity_log_user_id']) ? '&alteredById=' . $row['log_civicrm_entity_log_user_id'] : '';
             $url1 = CRM_Report_Utils_Report::getNextUrl('logging/contact/detail', "{$q}&snippet=4&section=2&layout=overlay", FALSE, TRUE);
             $url2 = CRM_Report_Utils_Report::getNextUrl('logging/contact/detail', "{$q}&section=2", FALSE, TRUE);
             $row['log_civicrm_entity_log_action'] = "<a href='{$url1}' class='crm-summary-link'><div class='icon details-icon'></div></a>&nbsp;<a title='View details for this update' href='{$url2}'>" . ts('Update') . '</a>';
         }
         $key = $date . '_' . $row['log_civicrm_entity_log_type'] . '_' . $row['log_civicrm_entity_log_conn_id'] . '_' . $row['log_civicrm_entity_log_user_id'] . '_' . $row['log_civicrm_entity_altered_contact_id'];
         $newRows[$key] = $row;
         unset($row['log_civicrm_entity_log_user_id']);
         unset($row['log_civicrm_entity_log_conn_id']);
     }
     krsort($newRows);
     $rows = $newRows;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:53,代码来源:LoggingSummary.php

示例2: testCreateGet

 /**
  * create() method (create and update modes)
  */
 function testCreateGet()
 {
     $permissionIndividual1Id = Contact::createIndividual();
     $permissionIndividual2Id = Contact::createIndividual();
     $stages = array_keys(CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, " AND grouping = 'Vacancy'"));
     $params = array('position' => 'Senior Support Specialist', 'location' => 'Headquaters', 'salary' => '$110-$130k/yr', 'description' => 'Answer phone calls and emails from irate customers.', 'benefits' => 'Have a place to park', 'requirements' => 'Pro-actively looks to build cross discipline experience and increase knowledge.', 'stages' => $stages, 'application_profile' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'application_profile', 'id', 'name'), 'evaluation_profile' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'evaluation_profile', 'id', 'name'), 'status_id' => '4', 'start_date' => '20140425151100', 'end_date' => '20140426231100', 'permission' => array('manage Applicants', 'administer Vacancy'), 'permission_contact_id' => array($permissionIndividual1Id, $permissionIndividual2Id));
     $vacancy = CRM_HRRecruitment_BAO_HRVacancy::create($params);
     $getValues = array();
     $getParams = array('id' => $vacancy->id);
     CRM_HRRecruitment_BAO_HRVacancy::retrieve($getParams, $getValues);
     //stage array index always starts with 1 so in order to make changes in
     //$getValues['stages'] in order to just match the value
     $getValues['stages'] = array_values($getValues['stages']);
     $getValues['permission'] = array_values($getValues['permission']);
     $getValues['permission_contact_id'] = array_values($getValues['permission_contact_id']);
     //process date back to mysql format
     $getValues['start_date'] = CRM_Utils_Date::isoToMysql($getValues['start_date']);
     $getValues['end_date'] = CRM_Utils_Date::isoToMysql($getValues['end_date']);
     foreach ($params as $column => $value) {
         $this->assertEquals($params[$column], $getValues[$column], "Check for Job {$column}.");
     }
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:25,代码来源:HRVacancyTest.php

示例3: printPDF

 /**
  * Process the PDf and email with activity and attachment.
  * on click of Print Invoices
  *
  * @param array $contribIDs
  *   Contribution Id.
  * @param array $params
  *   Associated array of submitted values.
  * @param array $contactIds
  *   Contact Id.
  * @param CRM_Core_Form $form
  *   Form object.
  */
 public static function printPDF($contribIDs, &$params, $contactIds, &$form)
 {
     // get all the details needed to generate a invoice
     $messageInvoice = array();
     $invoiceTemplate = CRM_Core_Smarty::singleton();
     $invoiceElements = CRM_Contribute_Form_Task_PDF::getElements($contribIDs, $params, $contactIds);
     // gives the status id when contribution status is 'Refunded'
     $contributionStatusID = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $refundedStatusId = CRM_Utils_Array::key('Refunded', $contributionStatusID);
     // getting data from admin page
     $prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
     foreach ($invoiceElements['details'] as $contribID => $detail) {
         $input = $ids = $objects = array();
         if (in_array($detail['contact'], $invoiceElements['excludeContactIds'])) {
             continue;
         }
         $input['component'] = $detail['component'];
         $ids['contact'] = $detail['contact'];
         $ids['contribution'] = $contribID;
         $ids['contributionRecur'] = NULL;
         $ids['contributionPage'] = NULL;
         $ids['membership'] = CRM_Utils_Array::value('membership', $detail);
         $ids['participant'] = CRM_Utils_Array::value('participant', $detail);
         $ids['event'] = CRM_Utils_Array::value('event', $detail);
         if (!$invoiceElements['baseIPN']->validateData($input, $ids, $objects, FALSE)) {
             CRM_Core_Error::fatal();
         }
         $contribution =& $objects['contribution'];
         $input['amount'] = $contribution->total_amount;
         $input['invoice_id'] = $contribution->invoice_id;
         $input['receive_date'] = $contribution->receive_date;
         $input['contribution_status_id'] = $contribution->contribution_status_id;
         $input['organization_name'] = $contribution->_relatedObjects['contact']->organization_name;
         $objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date);
         $addressParams = array('contact_id' => $contribution->contact_id);
         $addressDetails = CRM_Core_BAO_Address::getValues($addressParams);
         // to get billing address if present
         $billingAddress = array();
         foreach ($addressDetails as $key => $address) {
             if (isset($address['is_billing']) && $address['is_billing'] == 1 && (isset($address['is_primary']) && $address['is_primary'] == 1) && $address['contact_id'] == $contribution->contact_id) {
                 $billingAddress[$address['contact_id']] = $address;
                 break;
             } elseif ($address['is_billing'] == 0 && $address['is_primary'] == 1 || isset($address['is_billing']) && $address['is_billing'] == 1 && $address['contact_id'] == $contribution->contact_id) {
                 $billingAddress[$address['contact_id']] = $address;
             }
         }
         if (!empty($billingAddress[$contribution->contact_id]['state_province_id'])) {
             $stateProvinceAbbreviation = CRM_Core_PseudoConstant::stateProvinceAbbreviation($billingAddress[$contribution->contact_id]['state_province_id']);
         } else {
             $stateProvinceAbbreviation = '';
         }
         if ($contribution->contribution_status_id == $refundedStatusId) {
             $creditNoteId = CRM_Utils_Array::value('credit_notes_prefix', $prefixValue) . "" . $contribution->id;
         }
         $invoiceId = CRM_Utils_Array::value('invoice_prefix', $prefixValue) . "" . $contribution->id;
         //to obtain due date for PDF invoice
         $contributionReceiveDate = date('F j,Y', strtotime(date($input['receive_date'])));
         $invoiceDate = date("F j, Y");
         $dueDate = date('F j ,Y', strtotime($contributionReceiveDate . "+" . $prefixValue['due_date'] . "" . $prefixValue['due_date_period']));
         if ($input['component'] == 'contribute') {
             $eid = $contribID;
             $etable = 'contribution';
             $lineItem = CRM_Price_BAO_LineItem::getLineItems($eid, $etable, NULL, TRUE, TRUE);
         } else {
             $eid = $contribution->_relatedObjects['participant']->id;
             $etable = 'participant';
             $lineItem = CRM_Price_BAO_LineItem::getLineItems($eid, $etable);
         }
         //TO DO: Need to do changes for partially paid to display amount due on PDF invoice
         $amountDue = $input['amount'] - $input['amount'];
         // retreiving the subtotal and sum of same tax_rate
         $dataArray = array();
         $subTotal = 0;
         foreach ($lineItem as $entity_id => $taxRate) {
             if (isset($dataArray[(string) $taxRate['tax_rate']])) {
                 $dataArray[(string) $taxRate['tax_rate']] = $dataArray[(string) $taxRate['tax_rate']] + CRM_Utils_Array::value('tax_amount', $taxRate);
             } else {
                 $dataArray[(string) $taxRate['tax_rate']] = CRM_Utils_Array::value('tax_amount', $taxRate);
             }
             $subTotal += CRM_Utils_Array::value('subTotal', $taxRate);
         }
         // to email the invoice
         $mailDetails = array();
         $values = array();
         if ($contribution->_component == 'event') {
             $daoName = 'CRM_Event_DAO_Event';
             $pageId = $contribution->_relatedObjects['event']->id;
//.........这里部分代码省略.........
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:101,代码来源:Invoice.php

示例4: renewMembership

 /**
  * @param int $contactID
  * @param int $membershipTypeID
  * @param bool $is_test
  * @param $changeToday
  * @param int $modifiedID
  * @param $customFieldsFormatted
  * @param $numRenewTerms
  * @param int $membershipID
  * @param $pending
  * @param int $contributionRecurID
  * @param $membershipSource
  * @param $isPayLater
  * @param int $campaignId
  * @param array $formDates
  *
  * @throws CRM_Core_Exception
  * @return array
  */
 public static function renewMembership($contactID, $membershipTypeID, $is_test, $changeToday, $modifiedID, $customFieldsFormatted, $numRenewTerms, $membershipID, $pending, $contributionRecurID, $membershipSource, $isPayLater, $campaignId, $formDates = array())
 {
     $renewalMode = $updateStatusId = FALSE;
     $allStatus = CRM_Member_PseudoConstant::membershipStatus();
     $format = '%Y%m%d';
     $statusFormat = '%Y-%m-%d';
     $membershipTypeDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipTypeID);
     $dates = array();
     // CRM-7297 - allow membership type to be be changed during renewal so long as the parent org of new membershipType
     // is the same as the parent org of an existing membership of the contact
     $currentMembership = CRM_Member_BAO_Membership::getContactMembership($contactID, $membershipTypeID, $is_test, $membershipID, TRUE);
     if ($currentMembership) {
         $activityType = 'Membership Renewal';
         $renewalMode = TRUE;
         // Do NOT do anything.
         //1. membership with status : PENDING/CANCELLED (CRM-2395)
         //2. Paylater/IPN renew. CRM-4556.
         if ($pending || in_array($currentMembership['status_id'], array(array_search('Pending', $allStatus), array_search('Cancelled', CRM_Member_PseudoConstant::membershipStatus(NULL, " name = 'Cancelled' ", 'name', FALSE, TRUE))))) {
             $membership = new CRM_Member_DAO_Membership();
             $membership->id = $currentMembership['id'];
             $membership->find(TRUE);
             // CRM-8141 create a membership_log entry so that we will know the membership_type_id to change to when payment completed
             $format = '%Y%m%d';
             // note that we are logging the requested new membership_type_id that may be different than current membership_type_id
             // it will be used when payment is received to update the membership_type_id to what was paid for
             $logParams = array('membership_id' => $membership->id, 'status_id' => $membership->status_id, 'start_date' => CRM_Utils_Date::customFormat($membership->start_date, $format), 'end_date' => CRM_Utils_Date::customFormat($membership->end_date, $format), 'modified_date' => CRM_Utils_Date::customFormat(date('Ymd'), $format), 'membership_type_id' => $membershipTypeID, 'max_related' => !empty($membershipTypeDetails['max_related']) ? $membershipTypeDetails['max_related'] : NULL);
             $session = CRM_Core_Session::singleton();
             // If we have an authenticated session, set modified_id to that user's contact_id, else set to membership.contact_id
             if ($session->get('userID')) {
                 $logParams['modified_id'] = $session->get('userID');
             } else {
                 $logParams['modified_id'] = $membership->contact_id;
             }
             CRM_Member_BAO_MembershipLog::add($logParams);
             if ($contributionRecurID) {
                 CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $membership->id, 'contribution_recur_id', $contributionRecurID);
             }
             return array($membership, $renewalMode, $dates);
         }
         // Check and fix the membership if it is STALE
         self::fixMembershipStatusBeforeRenew($currentMembership, $changeToday);
         // Now Renew the membership
         if (!$currentMembership['is_current_member']) {
             // membership is not CURRENT
             // CRM-7297 Membership Upsell - calculate dates based on new membership type
             $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($currentMembership['id'], $changeToday, $membershipTypeID, $numRenewTerms);
             $currentMembership['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
             foreach (array('start_date', 'end_date') as $dateType) {
                 $currentMembership[$dateType] = CRM_Utils_Array::value($dateType, $formDates);
                 if (empty($currentMembership[$dateType])) {
                     $currentMembership[$dateType] = CRM_Utils_Array::value($dateType, $dates);
                 }
             }
             $currentMembership['is_test'] = $is_test;
             if (!empty($membershipSource)) {
                 $currentMembership['source'] = $membershipSource;
             } else {
                 $currentMembership['source'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $currentMembership['id'], 'source');
             }
             if (!empty($currentMembership['id'])) {
                 $ids['membership'] = $currentMembership['id'];
             }
             $memParams = $currentMembership;
             $memParams['membership_type_id'] = $membershipTypeID;
             //set the log start date.
             $memParams['log_start_date'] = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
         } else {
             // CURRENT Membership
             $membership = new CRM_Member_DAO_Membership();
             $membership->id = $currentMembership['id'];
             $membership->find(TRUE);
             // CRM-7297 Membership Upsell - calculate dates based on new membership type
             $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday, $membershipTypeID, $numRenewTerms);
             // Insert renewed dates for CURRENT membership
             $memParams = array();
             $memParams['join_date'] = CRM_Utils_Date::isoToMysql($membership->join_date);
             $memParams['start_date'] = CRM_Utils_Date::isoToMysql($membership->start_date);
             $memParams['end_date'] = CRM_Utils_Array::value('end_date', $formDates);
             if (empty($memParams['end_date'])) {
                 $memParams['end_date'] = CRM_Utils_Array::value('end_date', $dates);
             }
//.........这里部分代码省略.........
开发者ID:konadave,项目名称:civicrm-core,代码行数:101,代码来源:Membership.php

示例5: completeTransaction

 function completeTransaction(&$input, &$ids, &$objects, &$transaction, $recur = FALSE)
 {
     $contribution =& $objects['contribution'];
     $primaryContributionID = isset($contribution->id) ? $contribution->id : $objects['first_contribution']->id;
     $memberships =& $objects['membership'];
     if (is_numeric($memberships)) {
         $memberships = array($objects['membership']);
     }
     $participant =& $objects['participant'];
     $event =& $objects['event'];
     $changeToday = CRM_Utils_Array::value('trxn_date', $input, self::$_now);
     $recurContrib =& $objects['contributionRecur'];
     $values = array();
     if (isset($input['is_email_receipt'])) {
         $values['is_email_receipt'] = $input['is_email_receipt'];
     }
     $source = NULL;
     if ($input['component'] == 'contribute') {
         if ($contribution->contribution_page_id) {
             CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
             $source = ts('Online Contribution') . ': ' . $values['title'];
         } elseif ($recurContrib && $recurContrib->id) {
             $contribution->contribution_page_id = NULL;
             $values['amount'] = $recurContrib->amount;
             $values['financial_type_id'] = $objects['contributionType']->id;
             $values['title'] = $source = ts('Offline Recurring Contribution');
             $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
             $values['receipt_from_name'] = $domainValues[0];
             $values['receipt_from_email'] = $domainValues[1];
         }
         if ($recurContrib && $recurContrib->id && !isset($input['is_email_receipt'])) {
             //CRM-13273 - is_email_receipt setting on recurring contribution should take precedence over contribution page setting
             // but CRM-16124 if $input['is_email_receipt'] is set then that should not be overridden.
             $values['is_email_receipt'] = $recurContrib->is_email_receipt;
         }
         $contribution->source = $source;
         if (CRM_Utils_Array::value('is_email_receipt', $values)) {
             $contribution->receipt_date = self::$_now;
         }
         if (!empty($memberships)) {
             $membershipsUpdate = array();
             foreach ($memberships as $membershipTypeIdKey => $membership) {
                 if ($membership) {
                     $format = '%Y%m%d';
                     $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id, $membership->membership_type_id, $membership->is_test, $membership->id);
                     // CRM-8141 update the membership type with the value recorded in log when membership created/renewed
                     // this picks up membership type changes during renewals
                     $sql = "\nSELECT    membership_type_id\nFROM      civicrm_membership_log\nWHERE     membership_id={$membership->id}\nORDER BY  id DESC\nLIMIT 1;";
                     $dao = new CRM_Core_DAO();
                     $dao->query($sql);
                     if ($dao->fetch()) {
                         if (!empty($dao->membership_type_id)) {
                             $membership->membership_type_id = $dao->membership_type_id;
                             $membership->save();
                         }
                         // else fall back to using current membership type
                     }
                     // else fall back to using current membership type
                     $dao->free();
                     $num_terms = $contribution->getNumTermsByContributionAndMembershipType($membership->membership_type_id, $primaryContributionID);
                     if ($currentMembership) {
                         /*
                          * Fixed FOR CRM-4433
                          * In BAO/Membership.php(renewMembership function), we skip the extend membership date and status
                          * when Contribution mode is notify and membership is for renewal )
                          */
                         CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday);
                         // @todo - we should pass membership_type_id instead of null here but not
                         // adding as not sure of testing
                         $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday, NULL, $num_terms);
                         $dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
                     } else {
                         $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id, NULL, NULL, NULL, $num_terms);
                     }
                     //get the status for membership.
                     $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', TRUE, $membership->membership_type_id, (array) $membership);
                     $formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, 2), 'join_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('join_date', $dates), $format), 'start_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $dates), $format), 'end_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $dates), $format));
                     //we might be renewing membership,
                     //so make status override false.
                     $formatedParams['is_override'] = FALSE;
                     $membership->copyValues($formatedParams);
                     $membership->save();
                     //updating the membership log
                     $membershipLog = array();
                     $membershipLog = $formatedParams;
                     $logStartDate = $formatedParams['start_date'];
                     if (CRM_Utils_Array::value('log_start_date', $dates)) {
                         $logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
                         $logStartDate = CRM_Utils_Date::isoToMysql($logStartDate);
                     }
                     $membershipLog['start_date'] = $logStartDate;
                     $membershipLog['membership_id'] = $membership->id;
                     $membershipLog['modified_id'] = $membership->contact_id;
                     $membershipLog['modified_date'] = date('Ymd');
                     $membershipLog['membership_type_id'] = $membership->membership_type_id;
                     CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
                     //update related Memberships.
                     CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
                     //update the membership type key of membership relatedObjects array
                     //if it has changed after membership update
//.........这里部分代码省略.........
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:101,代码来源:BaseIPN.php

示例6: updateMembershipStatus

 /**
  * Update membership status to deceased.
  * function return the status message for updated membership.
  *
  * @param array $deceasedParams
  *   having contact id and deceased value.
  *
  * @return null|string
  *   $updateMembershipMsg string  status message for updated membership.
  */
 public function updateMembershipStatus($deceasedParams)
 {
     $updateMembershipMsg = NULL;
     $contactId = CRM_Utils_Array::value('contact_id', $deceasedParams);
     $deceasedDate = CRM_Utils_Array::value('deceased_date', $deceasedParams);
     // process to set membership status to deceased for both active/inactive membership
     if ($contactId && $this->_contactType == 'Individual' && !empty($deceasedParams['is_deceased'])) {
         $session = CRM_Core_Session::singleton();
         $userId = $session->get('userID');
         if (!$userId) {
             $userId = $contactId;
         }
         // get deceased status id
         $allStatus = CRM_Member_PseudoConstant::membershipStatus();
         $deceasedStatusId = array_search('Deceased', $allStatus);
         if (!$deceasedStatusId) {
             return $updateMembershipMsg;
         }
         $today = time();
         if ($deceasedDate && strtotime($deceasedDate) > $today) {
             return $updateMembershipMsg;
         }
         // get non deceased membership
         $dao = new CRM_Member_DAO_Membership();
         $dao->contact_id = $contactId;
         $dao->whereAdd("status_id != {$deceasedStatusId}");
         $dao->find();
         $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
         $allStatus = CRM_Member_PseudoConstant::membershipStatus();
         $memCount = 0;
         while ($dao->fetch()) {
             // update status to deceased (for both active/inactive membership )
             CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $dao->id, 'status_id', $deceasedStatusId);
             // add membership log
             $membershipLog = array('membership_id' => $dao->id, 'status_id' => $deceasedStatusId, 'start_date' => CRM_Utils_Date::isoToMysql($dao->start_date), 'end_date' => CRM_Utils_Date::isoToMysql($dao->end_date), 'modified_id' => $userId, 'modified_date' => date('Ymd'), 'membership_type_id' => $dao->membership_type_id, 'max_related' => $dao->max_related);
             CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
             //create activity when membership status is changed
             $activityParam = array('subject' => "Status changed from {$allStatus[$dao->status_id]} to {$allStatus[$deceasedStatusId]}", 'source_contact_id' => $userId, 'target_contact_id' => $dao->contact_id, 'source_record_id' => $dao->id, 'activity_type_id' => array_search('Change Membership Status', $activityTypes), 'status_id' => 2, 'version' => 3, 'priority_id' => 2, 'activity_date_time' => date('Y-m-d H:i:s'), 'is_auto' => 0, 'is_current_revision' => 1, 'is_deleted' => 0);
             $activityResult = civicrm_api('activity', 'create', $activityParam);
             $memCount++;
         }
         // set status msg
         if ($memCount) {
             $updateMembershipMsg = ts("%1 Current membership(s) for this contact have been set to 'Deceased' status.", array(1 => $memCount));
         }
     }
     return $updateMembershipMsg;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:58,代码来源:Contact.php

示例7: recur

 function recur(&$input, &$ids, &$objects, $first)
 {
     if (!isset($input['txnType'])) {
         CRM_Core_Error::debug_log_message("Could not find txn_type in input request");
         echo "Failure: Invalid parameters<p>";
         return false;
     }
     if ($input['txnType'] == 'subscr_payment' && $input['paymentStatus'] != 'Completed') {
         CRM_Core_Error::debug_log_message("Ignore all IPN payments that are not completed");
         echo "Failure: Invalid parameters<p>";
         return false;
     }
     $recur =& $objects['contributionRecur'];
     // make sure the invoice ids match
     // make sure the invoice is valid and matches what we have in the contribution record
     if ($recur->invoice_id != $input['invoice']) {
         CRM_Core_Error::debug_log_message("Invoice values dont match between database and IPN request");
         echo "Failure: Invoice values dont match between database and IPN request<p>";
         return false;
     }
     $now = date('YmdHis');
     // fix dates that already exist
     $dates = array('create', 'start', 'end', 'cancel', 'modified');
     foreach ($dates as $date) {
         $name = "{$date}_date";
         if ($recur->{$name}) {
             $recur->{$name} = CRM_Utils_Date::isoToMysql($recur->{$name});
         }
     }
     $sendNotification = false;
     $subscriptionPaymentStatus = null;
     require_once 'CRM/Core/Payment.php';
     //set transaction type
     $txnType = $_POST['txn_type'];
     switch ($txnType) {
         case 'subscr_signup':
             $recur->create_date = $now;
             //some times subscr_signup response come after the
             //subscr_payment and set to pending mode.
             $statusID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionRecur', $recur->id, 'contribution_status_id');
             if ($statusID != 5) {
                 $recur->contribution_status_id = 2;
             }
             $recur->processor_id = $_POST['subscr_id'];
             $recur->trxn_id = $recur->processor_id;
             $sendNotification = true;
             $subscriptionPaymentStatus = CRM_Core_Payment::RECURRING_PAYMENT_START;
             break;
         case 'subscr_eot':
             $recur->contribution_status_id = 1;
             $recur->end_date = $now;
             $sendNotification = true;
             $subscriptionPaymentStatus = CRM_Core_Payment::RECURRING_PAYMENT_END;
             break;
         case 'subscr_cancel':
             $recur->contribution_status_id = 3;
             $recur->cancel_date = $now;
             break;
         case 'subscr_failed':
             $recur->contribution_status_id = 4;
             $recur->cancel_date = $now;
             break;
         case 'subscr_modify':
             CRM_Core_Error::debug_log_message("We do not handle modifications to subscriptions right now");
             echo "Failure: We do not handle modifications to subscriptions right now<p>";
             return false;
         case 'subscr_payment':
             if ($first) {
                 $recur->start_date = $now;
             } else {
                 $recur->modified_date = $now;
             }
             // make sure the contribution status is not done
             // since order of ipn's is unknown
             if ($recur->contribution_status_id != 1) {
                 $recur->contribution_status_id = 5;
             }
             break;
     }
     $recur->save();
     if ($sendNotification) {
         //send recurring Notification email for user
         require_once 'CRM/Contribute/BAO/ContributionPage.php';
         CRM_Contribute_BAO_ContributionPage::recurringNofify($subscriptionPaymentStatus, $ids['contact'], $ids['contributionPage'], $recur);
     }
     if ($txnType != 'subscr_payment') {
         return;
     }
     if (!$first) {
         // create a contribution and then get it processed
         $contribution =& new CRM_Contribute_DAO_Contribution();
         $contribution->contact_id = $ids['contact'];
         $contribution->contribution_type_id = $objects['contributionType']->id;
         $contribution->contribution_page_id = $ids['contributionPage'];
         $contribution->contribution_recur_id = $ids['contributionRecur'];
         $contribution->receive_date = $now;
         $contribution->currency = $objects['contribution']->currency;
         $contribution->payment_instrument_id = $objects['contribution']->payment_instrument_id;
         $contribution->amount_level = $objects['contribution']->amount_level;
         $objects['contribution'] =& $contribution;
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:PayPalIPN.php

示例8: sendTransitionParticipantMail

 /**
  * Send mail and create activity
  * when participant status changed.
  *
  * @param int $participantId
  *   Participant id.
  * @param array $participantValues
  *   Participant detail values. status id for participants.
  * @param array $eventDetails
  *   Required event details.
  * @param array $contactDetails
  *   Required contact details.
  * @param array $domainValues
  *   Required domain values.
  * @param string $mailType
  *   (eg 'approval', 'confirm', 'expired' ).
  *
  * @return bool
  */
 public static function sendTransitionParticipantMail($participantId, $participantValues, $eventDetails, $contactDetails, &$domainValues, $mailType)
 {
     //send emails.
     $mailSent = FALSE;
     //don't send confirmation mail to additional
     //since only primary able to confirm registration.
     if (!empty($participantValues['registered_by_id']) && $mailType == 'Confirm') {
         return $mailSent;
     }
     $toEmail = CRM_Utils_Array::value('email', $contactDetails);
     if ($toEmail) {
         $contactId = $participantValues['contact_id'];
         $participantName = $contactDetails['display_name'];
         //calculate the checksum value.
         $checksumValue = NULL;
         if ($mailType == 'Confirm' && !$participantValues['registered_by_id']) {
             $checksumLife = 'inf';
             $endDate = CRM_Utils_Array::value('end_date', $eventDetails);
             if ($endDate) {
                 $checksumLife = (CRM_Utils_Date::unixTime($endDate) - time()) / (60 * 60);
             }
             $checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactId, NULL, $checksumLife);
         }
         //take a receipt from as event else domain.
         $receiptFrom = $domainValues['name'] . ' <' . $domainValues['email'] . '>';
         if (!empty($eventDetails['confirm_from_name']) && !empty($eventDetails['confirm_from_email'])) {
             $receiptFrom = $eventDetails['confirm_from_name'] . ' <' . $eventDetails['confirm_from_email'] . '>';
         }
         list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'participant_' . strtolower($mailType), 'contactId' => $contactId, 'tplParams' => array('contact' => $contactDetails, 'domain' => $domainValues, 'participant' => $participantValues, 'event' => $eventDetails, 'paidEvent' => CRM_Utils_Array::value('is_monetary', $eventDetails), 'isShowLocation' => CRM_Utils_Array::value('is_show_location', $eventDetails), 'isAdditional' => $participantValues['registered_by_id'], 'isExpired' => $mailType == 'Expired', 'isConfirm' => $mailType == 'Confirm', 'checksumValue' => $checksumValue), 'from' => $receiptFrom, 'toName' => $participantName, 'toEmail' => $toEmail, 'cc' => CRM_Utils_Array::value('cc_confirm', $eventDetails), 'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventDetails)));
         // 3. create activity record.
         if ($mailSent) {
             $now = date('YmdHis');
             $activityType = 'Event Registration';
             $activityParams = array('subject' => $subject, 'source_contact_id' => $contactId, 'source_record_id' => $participantId, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'activity_date_time' => CRM_Utils_Date::isoToMysql($now), 'due_date_time' => CRM_Utils_Date::isoToMysql($participantValues['register_date']), 'is_test' => $participantValues['is_test'], 'status_id' => 2);
             if (is_a(CRM_Activity_BAO_Activity::create($activityParams), 'CRM_Core_Error')) {
                 CRM_Core_Error::fatal('Failed creating Activity for expiration mail');
             }
         }
     }
     return $mailSent;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:60,代码来源:Participant.php

示例9: transitionComponents


//.........这里部分代码省略.........
             }
             if ($participant) {
                 $updatedStatusId = array_search('Cancelled', $participantStatuses);
                 CRM_Event_BAO_Participant::updateParticipantStatus($participant->id, $oldStatus, $updatedStatusId, true);
                 $updateResult['updatedComponents']['CiviEvent'] = $updatedStatusId;
                 if ($processContributionObject) {
                     $processContribution = true;
                 }
             }
             if ($pledgePayment) {
                 CRM_Pledge_BAO_Payment::updatePledgePaymentStatus($pledgeID, $pledgePaymentIDs, $contributionStatusId);
                 $updateResult['updatedComponents']['CiviPledge'] = $contributionStatusId;
                 if ($processContributionObject) {
                     $processContribution = true;
                 }
             }
         } else {
             if ($contributionStatusId == array_search('Completed', $contributionStatuses)) {
                 // only pending contribution related object processed.
                 if ($previousContriStatusId && $previousContriStatusId != array_search('Pending', $contributionStatuses)) {
                     // this is case when we already processed contribution object.
                     return $updateResult;
                 } else {
                     if (!$previousContriStatusId && $contribution->contribution_status_id != array_search('Pending', $contributionStatuses)) {
                         // this is case when we will going to process contribution object.
                         return $updateResult;
                     }
                 }
                 if ($membership) {
                     $format = '%Y%m%d';
                     require_once 'CRM/Member/BAO/MembershipType.php';
                     //CRM-4523
                     $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id, $membership->membership_type_id, $membership->is_test, $membership->id);
                     if ($currentMembership) {
                         CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday = null);
                         $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday = null);
                         $dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
                     } else {
                         $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id);
                     }
                     //get the status for membership.
                     require_once 'CRM/Member/BAO/MembershipStatus.php';
                     $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', true);
                     $formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, array_search('Current', $membershipStatuses)), 'join_date' => CRM_Utils_Date::customFormat($dates['join_date'], $format), 'start_date' => CRM_Utils_Date::customFormat($dates['start_date'], $format), 'end_date' => CRM_Utils_Date::customFormat($dates['end_date'], $format), 'reminder_date' => CRM_Utils_Date::customFormat($dates['reminder_date'], $format));
                     $membership->copyValues($formatedParams);
                     $membership->save();
                     //updating the membership log
                     $membershipLog = array();
                     $membershipLog = $formatedParams;
                     $logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
                     $logStartDate = $logStartDate ? CRM_Utils_Date::isoToMysql($logStartDate) : $formatedParams['start_date'];
                     $membershipLog['start_date'] = $logStartDate;
                     $membershipLog['membership_id'] = $membership->id;
                     $membershipLog['modified_id'] = $membership->contact_id;
                     $membershipLog['modified_date'] = date('Ymd');
                     require_once 'CRM/Member/BAO/MembershipLog.php';
                     CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
                     //update related Memberships.
                     CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
                     $updateResult['membership_end_date'] = CRM_Utils_Date::customFormat($dates['end_date'], '%B %E%f, %Y');
                     $updateResult['updatedComponents']['CiviMember'] = $membership->status_id;
                     if ($processContributionObject) {
                         $processContribution = true;
                     }
                 }
                 if ($participant) {
                     $updatedStatusId = array_search('Registered', $participantStatuses);
                     CRM_Event_BAO_Participant::updateParticipantStatus($participant->id, $oldStatus, $updatedStatusId, true);
                     $updateResult['updatedComponents']['CiviEvent'] = $updatedStatusId;
                     if ($processContributionObject) {
                         $processContribution = true;
                     }
                 }
                 if ($pledgePayment) {
                     CRM_Pledge_BAO_Payment::updatePledgePaymentStatus($pledgeID, $pledgePaymentIDs, $contributionStatusId);
                     $updateResult['updatedComponents']['CiviPledge'] = $contributionStatusId;
                     if ($processContributionObject) {
                         $processContribution = true;
                     }
                 }
             }
         }
     }
     // process contribution object.
     if ($processContribution) {
         require_once 'CRM/Contribute/BAO/Contribution.php';
         $contributionParams = array();
         $fields = array('contact_id', 'total_amount', 'receive_date', 'is_test', 'payment_instrument_id', 'trxn_id', 'invoice_id', 'contribution_type_id', 'contribution_status_id', 'non_deductible_amount', 'receipt_date', 'check_number');
         foreach ($fields as $field) {
             if (!CRM_Utils_Array::value($field, $params)) {
                 continue;
             }
             $contributionParams[$field] = $params[$field];
         }
         $ids = array('contribution' => $contributionId);
         require_once 'CRM/Contribute/BAO/Contribution.php';
         $contribution =& CRM_Contribute_BAO_Contribution::create($contributionParams, $ids);
     }
     return $updateResult;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Contribution.php

示例10: addActivityForPayment

 /**
  * @param $entityObj
  * @param $trxnObj
  * @param $activityType
  * @param $component
  * @param int $contributionId
  *
  * @throws CRM_Core_Exception
  */
 public static function addActivityForPayment($entityObj, $trxnObj, $activityType, $component, $contributionId)
 {
     if ($component == 'event') {
         $date = CRM_Utils_Date::isoToMysql($trxnObj->trxn_date);
         $paymentAmount = CRM_Utils_Money::format($trxnObj->total_amount, $trxnObj->currency);
         $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Event', $entityObj->event_id, 'title');
         $subject = "{$paymentAmount} - Offline {$activityType} for {$eventTitle}";
         $targetCid = $entityObj->contact_id;
         // source record id would be the contribution id
         $srcRecId = $contributionId;
     }
     // activity params
     $activityParams = array('source_contact_id' => $targetCid, 'source_record_id' => $srcRecId, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'subject' => $subject, 'activity_date_time' => $date, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'), 'skipRecentView' => TRUE);
     // create activity with target contacts
     $session = CRM_Core_Session::singleton();
     $id = $session->get('userID');
     if ($id) {
         $activityParams['source_contact_id'] = $id;
         $activityParams['target_contact_id'][] = $targetCid;
     }
     CRM_Activity_BAO_Activity::create($activityParams);
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:31,代码来源:Contribution.php

示例11: completeRecur

 function completeRecur($input, $ids, $objects)
 {
     if ($ids['contributionRecur']) {
         $recur =& $objects['contributionRecur'];
         $contributionCount = CRM_Core_DAO::singleValueQuery("\nSELECT count(*)\nFROM   civicrm_contribution\nWHERE  contribution_recur_id = {$ids['contributionRecur']}\n");
         $autoRenewMembership = FALSE;
         if ($recur->id && isset($ids['membership']) && $ids['membership']) {
             $autoRenewMembership = TRUE;
         }
         if ($recur->installments && $contributionCount >= $recur->installments) {
             $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
             $recur->create_date = CRM_Utils_Date::isoToMysql($recur->create_date);
             $recur->start_date = CRM_Utils_Date::isoToMysql($recur->start_date);
             $recur->cancel_date = CRM_Utils_Date::isoToMysql($recur->cancel_date);
             $recur->end_date = date('YmdHis');
             $recur->modified_date = date('YmdHis');
             $recur->contribution_status_id = array_search('Completed', $contributionStatus);
             $recur->trnx_id = $dataRoot['google-order-number']['VALUE'];
             $recur->save();
             //send recurring Notification email for user
             CRM_Contribute_BAO_ContributionPage::recurringNotify(CRM_Core_Payment::RECURRING_PAYMENT_END, $ids['contact'], $ids['contributionPage'], $recur, $autoRenewMembership);
         } elseif ($contributionCount == 1) {
             CRM_Contribute_BAO_ContributionPage::recurringNotify(CRM_Core_Payment::RECURRING_PAYMENT_START, $ids['contact'], $ids['contributionPage'], $recur, $autoRenewMembership);
         }
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:26,代码来源:GoogleIPN.php

示例12: add

 /**
  * Add the financial items and financial trxn.
  *
  * @param object $lineItem
  *   Line item object.
  * @param object $contribution
  *   Contribution object.
  * @param bool $taxTrxnID
  *
  * @return void
  */
 public static function add($lineItem, $contribution, $taxTrxnID = FALSE, $trxnId = NULL)
 {
     $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
     $itemStatus = NULL;
     if ($contribution->contribution_status_id == array_search('Completed', $contributionStatuses) || $contribution->contribution_status_id == array_search('Pending refund', $contributionStatuses)) {
         $itemStatus = array_search('Paid', $financialItemStatus);
     } elseif ($contribution->contribution_status_id == array_search('Pending', $contributionStatuses) || $contribution->contribution_status_id == array_search('In Progress', $contributionStatuses)) {
         $itemStatus = array_search('Unpaid', $financialItemStatus);
     } elseif ($contribution->contribution_status_id == array_search('Partially paid', $contributionStatuses)) {
         $itemStatus = array_search('Partially paid', $financialItemStatus);
     }
     $params = array('transaction_date' => CRM_Utils_Date::isoToMysql($contribution->receive_date), 'contact_id' => $contribution->contact_id, 'amount' => $lineItem->line_total, 'currency' => $contribution->currency, 'entity_table' => 'civicrm_line_item', 'entity_id' => $lineItem->id, 'description' => ($lineItem->qty != 1 ? $lineItem->qty . ' of ' : '') . ' ' . $lineItem->label, 'status_id' => $itemStatus);
     if ($taxTrxnID) {
         $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
         $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
         $params['amount'] = $lineItem->tax_amount;
         $params['description'] = $taxTerm;
         $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
     } else {
         $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
     }
     if ($lineItem->financial_type_id) {
         $searchParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $lineItem->financial_type_id, 'account_relationship' => $accountRel);
         $result = array();
         CRM_Financial_BAO_FinancialTypeAccount::retrieve($searchParams, $result);
         $params['financial_account_id'] = CRM_Utils_Array::value('financial_account_id', $result);
     }
     if (empty($trxnId)) {
         $trxn = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution->id, 'ASC', TRUE);
         $trxnId['id'] = $trxn['financialTrxnId'];
     }
     return self::create($params, NULL, $trxnId);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:45,代码来源:FinancialItem.php

示例13: deliver

 /**
  * Send the mailing.
  *
  * @param object $mailer
  *   A Mail object to send the messages.
  *
  * @param array $testParams
  *
  * @return void
  */
 public function deliver(&$mailer, $testParams = NULL)
 {
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $this->mailing_id;
     $mailing->find(TRUE);
     $mailing->free();
     $eq = new CRM_Mailing_Event_BAO_Queue();
     $eqTable = CRM_Mailing_Event_BAO_Queue::getTableName();
     $emailTable = CRM_Core_BAO_Email::getTableName();
     $phoneTable = CRM_Core_DAO_Phone::getTableName();
     $contactTable = CRM_Contact_BAO_Contact::getTableName();
     $edTable = CRM_Mailing_Event_BAO_Delivered::getTableName();
     $ebTable = CRM_Mailing_Event_BAO_Bounce::getTableName();
     $query = "  SELECT      {$eqTable}.id,\n                                {$emailTable}.email as email,\n                                {$eqTable}.contact_id,\n                                {$eqTable}.hash,\n                                NULL as phone\n                    FROM        {$eqTable}\n                    INNER JOIN  {$emailTable}\n                            ON  {$eqTable}.email_id = {$emailTable}.id\n                    INNER JOIN  {$contactTable}\n                            ON  {$contactTable}.id = {$emailTable}.contact_id\n                    LEFT JOIN   {$edTable}\n                            ON  {$eqTable}.id = {$edTable}.event_queue_id\n                    LEFT JOIN   {$ebTable}\n                            ON  {$eqTable}.id = {$ebTable}.event_queue_id\n                    WHERE       {$eqTable}.job_id = " . $this->id . "\n                        AND     {$edTable}.id IS null\n                        AND     {$ebTable}.id IS null\n                        AND    {$contactTable}.is_opt_out = 0";
     if ($mailing->sms_provider_id) {
         $query = "\n                    SELECT      {$eqTable}.id,\n                                {$phoneTable}.phone as phone,\n                                {$eqTable}.contact_id,\n                                {$eqTable}.hash,\n                                NULL as email\n                    FROM        {$eqTable}\n                    INNER JOIN  {$phoneTable}\n                            ON  {$eqTable}.phone_id = {$phoneTable}.id\n                    INNER JOIN  {$contactTable}\n                            ON  {$contactTable}.id = {$phoneTable}.contact_id\n                    LEFT JOIN   {$edTable}\n                            ON  {$eqTable}.id = {$edTable}.event_queue_id\n                    LEFT JOIN   {$ebTable}\n                            ON  {$eqTable}.id = {$ebTable}.event_queue_id\n                    WHERE       {$eqTable}.job_id = " . $this->id . "\n                        AND     {$edTable}.id IS null\n                        AND     {$ebTable}.id IS null\n                        AND    ( {$contactTable}.is_opt_out = 0\n                        OR       {$contactTable}.do_not_sms = 0 )";
     }
     $eq->query($query);
     $config = NULL;
     if ($config == NULL) {
         $config = CRM_Core_Config::singleton();
     }
     $job_date = CRM_Utils_Date::isoToMysql($this->scheduled_date);
     $fields = array();
     if (!empty($testParams)) {
         $mailing->subject = ts('[CiviMail Draft]') . ' ' . $mailing->subject;
     }
     CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
     // get and format attachments
     $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
     if (defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY) {
         CRM_Core_Smarty::registerStringResource();
     }
     // CRM-12376
     // This handles the edge case scenario where all the mails
     // have been delivered in prior jobs
     $isDelivered = TRUE;
     // make sure that there's no more than $config->mailerBatchLimit mails processed in a run
     while ($eq->fetch()) {
         // if ( ( $mailsProcessed % 100 ) == 0 ) {
         // CRM_Utils_System::xMemory( "$mailsProcessed: " );
         // }
         if ($config->mailerBatchLimit > 0 && self::$mailsProcessed >= $config->mailerBatchLimit) {
             if (!empty($fields)) {
                 $this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
             }
             $eq->free();
             return FALSE;
         }
         self::$mailsProcessed++;
         $fields[] = array('id' => $eq->id, 'hash' => $eq->hash, 'contact_id' => $eq->contact_id, 'email' => $eq->email, 'phone' => $eq->phone);
         if (count($fields) == self::MAX_CONTACTS_TO_PROCESS) {
             $isDelivered = $this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
             if (!$isDelivered) {
                 $eq->free();
                 return $isDelivered;
             }
             $fields = array();
         }
     }
     $eq->free();
     if (!empty($fields)) {
         $isDelivered = $this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
     }
     return $isDelivered;
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:76,代码来源:MailingJob.php

示例14: getEntityValue

 function getEntityValue($id, $entity, $logDate)
 {
     if (CRM_Utils_Array::value('bracket_info', $this->_logTables[$entity])) {
         if (CRM_Utils_Array::value('entity_column', $this->_logTables[$entity]['bracket_info'])) {
             $logTable = CRM_Utils_Array::value('table_name', $this->_logTables[$entity]) ? $this->_logTables[$entity]['table_name'] : $entity;
             $sql = "\nSELECT {$this->_logTables[$entity]['bracket_info']['entity_column']}\n  FROM `{$this->loggingDB}`.{$logTable}\n WHERE  log_date <= %1 AND id = %2 ORDER BY log_date DESC LIMIT 1";
             $entityID = CRM_Core_DAO::singleValueQuery($sql, array(1 => array(CRM_Utils_Date::isoToMysql($logDate), 'Timestamp'), 2 => array($id, 'Integer')));
         } else {
             $entityID = $id;
         }
         // since case_type_id is a varchar field with separator
         if ($entity == 'log_civicrm_case') {
             $entityID = explode(CRM_Case_BAO_Case::VALUE_SEPARATOR, $entityID);
             $entityID = CRM_Utils_Array::value(1, $entityID);
         }
         if ($entityID && $logDate && array_key_exists('table', $this->_logTables[$entity]['bracket_info'])) {
             $sql = "\nSELECT {$this->_logTables[$entity]['bracket_info']['column']}\nFROM  `{$this->loggingDB}`.{$this->_logTables[$entity]['bracket_info']['table']}\nWHERE  log_date <= %1 AND id = %2 ORDER BY log_date DESC LIMIT 1";
             return CRM_Core_DAO::singleValueQuery($sql, array(1 => array(CRM_Utils_Date::isoToMysql($logDate), 'Timestamp'), 2 => array($entityID, 'Integer')));
         } else {
             if (array_key_exists('options', $this->_logTables[$entity]['bracket_info']) && $entityID) {
                 return CRM_Utils_Array::value($entityID, $this->_logTables[$entity]['bracket_info']['options']);
             }
         }
     }
     return NULL;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:26,代码来源:ReportSummary.php

示例15: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  *
  * @return void
  */
 public function postProcess()
 {
     // get all the details needed to generate a receipt
     $contribIDs = implode(',', $this->_contributionIds);
     $details = CRM_Contribute_Form_Task_Status::getDetails($contribIDs);
     $baseIPN = new CRM_Core_Payment_BaseIPN();
     $message = array();
     $template = CRM_Core_Smarty::singleton();
     $params = $this->controller->exportValues($this->_name);
     $createPdf = FALSE;
     if ($params['output'] == "pdf_receipt") {
         $createPdf = TRUE;
     }
     $excludeContactIds = array();
     if (!$createPdf) {
         $returnProperties = array('email' => 1, 'do_not_email' => 1, 'is_deceased' => 1, 'on_hold' => 1);
         list($contactDetails) = CRM_Utils_Token::getTokenDetails($this->_contactIds, $returnProperties, FALSE, FALSE);
         $suppressedEmails = 0;
         foreach ($contactDetails as $id => $values) {
             if (empty($values['email']) || !empty($values['do_not_email']) || CRM_Utils_Array::value('is_deceased', $values) || !empty($values['on_hold'])) {
                 $suppressedEmails++;
                 $excludeContactIds[] = $values['contact_id'];
             }
         }
     }
     foreach ($details as $contribID => $detail) {
         $input = $ids = $objects = array();
         if (in_array($detail['contact'], $excludeContactIds)) {
             continue;
         }
         $input['component'] = $detail['component'];
         $ids['contact'] = $detail['contact'];
         $ids['contribution'] = $contribID;
         $ids['contributionRecur'] = NULL;
         $ids['contributionPage'] = NULL;
         $ids['membership'] = CRM_Utils_Array::value('membership', $detail);
         $ids['participant'] = CRM_Utils_Array::value('participant', $detail);
         $ids['event'] = CRM_Utils_Array::value('event', $detail);
         if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) {
             CRM_Core_Error::fatal();
         }
         $contribution =& $objects['contribution'];
         // CRM_Core_Error::debug('o',$objects);
         // set some fake input values so we can reuse IPN code
         $input['amount'] = $contribution->total_amount;
         $input['is_test'] = $contribution->is_test;
         $input['fee_amount'] = $contribution->fee_amount;
         $input['net_amount'] = $contribution->net_amount;
         $input['trxn_id'] = $contribution->trxn_id;
         $input['trxn_date'] = isset($contribution->trxn_date) ? $contribution->trxn_date : NULL;
         // CRM_Contribute_BAO_Contribution::composeMessageArray expects mysql formatted date
         $objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date);
         // CRM_Core_Error::debug('input',$input);
         $values = array();
         $mail = $baseIPN->sendMail($input, $ids, $objects, $values, FALSE, $createPdf);
         if ($mail['html']) {
             $message[] = $mail['html'];
         } else {
             $message[] = nl2br($mail['body']);
         }
         // reset template values before processing next transactions
         $template->clearTemplateVars();
     }
     if ($createPdf) {
         CRM_Utils_PDF_Utils::html2pdf($message, 'civicrmContributionReceipt.pdf', FALSE, $params['pdf_format_id']);
         CRM_Utils_System::civiExit();
     } else {
         if ($suppressedEmails) {
             $status = ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', array(1 => $suppressedEmails));
             $msgTitle = ts('Email Error');
             $msgType = 'error';
         } else {
             $status = ts('Your mail has been sent.');
             $msgTitle = ts('Sent');
             $msgType = 'success';
         }
         CRM_Core_Session::setStatus($status, $msgTitle, $msgType);
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:86,代码来源:PDF.php


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