本文整理汇总了PHP中CRM_Utils_Date::overdue方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Date::overdue方法的具体用法?PHP CRM_Utils_Date::overdue怎么用?PHP CRM_Utils_Date::overdue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Date
的用法示例。
在下文中一共展示了CRM_Utils_Date::overdue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContactActivitySelector
/**
* Wrapper for ajax activity selector.
*
* @param array $params
* Associated array for params record id.
*
* @return array
* Associated array of contact activities
*/
public static function getContactActivitySelector(&$params)
{
// Format the params.
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['rowCount'] = $params['rp'];
$params['sort'] = CRM_Utils_Array::value('sortBy', $params);
$params['caseId'] = NULL;
$context = CRM_Utils_Array::value('context', $params);
// Get contact activities.
$activities = CRM_Activity_BAO_Activity::getActivities($params);
// Add total.
$params['total'] = CRM_Activity_BAO_Activity::getActivitiesCount($params);
// Format params and add links.
$contactActivities = array();
if (!empty($activities)) {
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
// Check logged in user for permission.
$page = new CRM_Core_Page();
CRM_Contact_Page_View::checkUserPermission($page, $params['contact_id']);
$permissions = array($page->_permission);
if (CRM_Core_Permission::check('delete activities')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
foreach ($activities as $activityId => $values) {
$activity = array();
$activity['DT_RowId'] = $activityId;
// Add class to this row if overdue.
$activity['DT_RowClass'] = 'crm-entity';
if (CRM_Utils_Date::overdue(CRM_Utils_Array::value('activity_date_time', $values)) && CRM_Utils_Array::value('status_id', $values) == 1) {
$activity['DT_RowClass'] .= ' status-overdue';
} else {
$activity['DT_RowClass'] .= ' status-ontime';
}
$activity['DT_RowAttr'] = array();
$activity['DT_RowAttr']['data-entity'] = 'activity';
$activity['DT_RowAttr']['data-id'] = $activityId;
$activity['activity_type'] = $values['activity_type'];
$activity['subject'] = $values['subject'];
$activity['source_contact_name'] = '';
if ($params['contact_id'] == $values['source_contact_id']) {
$activity['source_contact_name'] = $values['source_contact_name'];
} elseif ($values['source_contact_id']) {
$activity['source_contact_name'] = CRM_Utils_System::href($values['source_contact_name'], 'civicrm/contact/view', "reset=1&cid={$values['source_contact_id']}");
} else {
$activity['source_contact_name'] = '<em>n/a</em>';
}
$activity['target_contact_name'] = '';
if (isset($values['mailingId']) && !empty($values['mailingId'])) {
$activity['target_contact'] = CRM_Utils_System::href($values['recipients'], 'civicrm/mailing/report/event', "mid={$values['source_record_id']}&reset=1&event=queue&cid={$params['contact_id']}&context=activitySelector");
} elseif (!empty($values['recipients'])) {
$activity['target_contact_name'] = $values['recipients'];
} elseif (isset($values['target_contact_counter']) && $values['target_contact_counter']) {
$activity['target_contact_name'] = '';
foreach ($values['target_contact_name'] as $tcID => $tcName) {
$activity['target_contact_name'] .= CRM_Utils_System::href($tcName, 'civicrm/contact/view', "reset=1&cid={$tcID}");
}
if ($extraCount = $values['target_contact_counter'] - 1) {
$activity['target_contact_name'] .= ";<br />" . "(" . ts('%1 more', array(1 => $extraCount)) . ")";
}
} elseif (!$values['target_contact_name']) {
$activity['target_contact_name'] = '<em>n/a</em>';
}
$activity['assignee_contact_name'] = '';
if (empty($values['assignee_contact_name'])) {
$activity['assignee_contact_name'] = '<em>n/a</em>';
} elseif (!empty($values['assignee_contact_name'])) {
$count = 0;
$activity['assignee_contact_name'] = '';
foreach ($values['assignee_contact_name'] as $acID => $acName) {
if ($acID && $count < 5) {
$activity['assignee_contact_name'] .= CRM_Utils_System::href($acName, 'civicrm/contact/view', "reset=1&cid={$acID}");
$count++;
if ($count) {
$activity['assignee_contact_name'] .= "; ";
}
if ($count == 4) {
$activity['assignee_contact_name'] .= "(" . ts('more') . ")";
break;
}
}
}
}
$activity['activity_date_time'] = CRM_Utils_Date::customFormat($values['activity_date_time']);
$activity['status_id'] = $activityStatus[$values['status_id']];
// build links
$activity['links'] = '';
$accessMailingReport = FALSE;
if (!empty($values['mailingId'])) {
$accessMailingReport = TRUE;
}
//.........这里部分代码省略.........
示例2: getCaseActivity
/**
* Function to get Case Activities
*
* @param int $caseID case id
* @param array $params posted params
* @param int $contactID contact id
*
* @param null $context
* @param null $userID
* @param null $type
*
* @return returns case activities
*
* @static
*/
static function getCaseActivity($caseID, &$params, $contactID, $context = NULL, $userID = NULL, $type = NULL)
{
$values = array();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
// CRM-5081 - formatting the dates to omit seconds.
// Note the 00 in the date format string is needed otherwise later on it thinks scheduled ones are overdue.
$select = "SELECT count(ca.id) as ismultiple, ca.id as id,\n ca.activity_type_id as type,\n ca.activity_type_id as activity_type_id,\n cc.sort_name as reporter,\n cc.id as reporter_id,\n acc.sort_name AS assignee,\n acc.id AS assignee_id,\n DATE_FORMAT(IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value,\n ca.activity_date_time,\n DATE_ADD(NOW(), INTERVAL 1 YEAR)\n ), '%Y%m%d%H%i00') as overdue_date,\n DATE_FORMAT(ca.activity_date_time, '%Y%m%d%H%i00') as display_date,\n ca.status_id as status,\n ca.subject as subject,\n ca.is_deleted as deleted,\n ca.priority_id as priority,\n ca.weight as weight,\n GROUP_CONCAT(ef.file_id) as attachment_ids ";
$from = "\n FROM civicrm_case_activity cca\n INNER JOIN civicrm_activity ca ON ca.id = cca.activity_id\n INNER JOIN civicrm_activity_contact cac ON cac.activity_id = ca.id AND cac.record_type_id = {$sourceID}\n INNER JOIN civicrm_contact cc ON cc.id = cac.contact_id\n INNER JOIN civicrm_option_group cog ON cog.name = 'activity_type'\n INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id\n AND cov.value = ca.activity_type_id AND cov.is_active = 1\n LEFT JOIN civicrm_entity_file ef on ef.entity_table = 'civicrm_activity' AND ef.entity_id = ca.id\n LEFT OUTER JOIN civicrm_option_group og ON og.name = 'activity_status'\n LEFT OUTER JOIN civicrm_option_value ov ON ov.option_group_id=og.id AND ov.name = 'Scheduled'\n LEFT JOIN civicrm_activity_contact caa\n ON caa.activity_id = ca.id AND caa.record_type_id = {$assigneeID}\n LEFT JOIN civicrm_contact acc ON acc.id = caa.contact_id ";
$where = 'WHERE cca.case_id= %1
AND ca.is_current_revision = 1';
if (!empty($params['reporter_id'])) {
$where .= " AND cac.contact_id = " . CRM_Utils_Type::escape($params['reporter_id'], 'Integer');
}
if (!empty($params['status_id'])) {
$where .= " AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer');
}
if (!empty($params['activity_deleted'])) {
$where .= " AND ca.is_deleted = 1";
} else {
$where .= " AND ca.is_deleted = 0";
}
if (!empty($params['activity_type_id'])) {
$where .= " AND ca.activity_type_id = " . CRM_Utils_Type::escape($params['activity_type_id'], 'Integer');
}
if (!empty($params['activity_date_low'])) {
$fromActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_low']), 'Date');
}
if (!empty($params['activity_date_high'])) {
$toActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_high']), 'Date');
$toActivityDate = $toActivityDate ? $toActivityDate + 235959 : NULL;
}
if (!empty($fromActivityDate)) {
$where .= " AND ca.activity_date_time >= '{$fromActivityDate}'";
}
if (!empty($toActivityDate)) {
$where .= " AND ca.activity_date_time <= '{$toActivityDate}'";
}
// hack to handle to allow initial sorting to be done by query
if (CRM_Utils_Array::value('sortname', $params) == 'undefined') {
$params['sortname'] = NULL;
}
if (CRM_Utils_Array::value('sortorder', $params) == 'undefined') {
$params['sortorder'] = NULL;
}
$sortname = CRM_Utils_Array::value('sortname', $params);
$sortorder = CRM_Utils_Array::value('sortorder', $params);
$groupBy = " GROUP BY ca.id ";
if (!$sortname and !$sortorder) {
// CRM-5081 - added id to act like creation date
$orderBy = " ORDER BY overdue_date ASC, display_date DESC, weight DESC";
} else {
$sort = "{$sortname} {$sortorder}";
$sort = CRM_Utils_Type::escape($sort, 'String');
$orderBy = " ORDER BY {$sort} ";
if ($sortname != 'display_date') {
$orderBy .= ', display_date DESC';
}
}
$page = CRM_Utils_Array::value('page', $params);
$rp = CRM_Utils_Array::value('rp', $params);
if (!$page) {
$page = 1;
}
if (!$rp) {
$rp = 10;
}
$start = ($page - 1) * $rp;
$query = $select . $from . $where . $groupBy . $orderBy;
$params = array(1 => array($caseID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
$params['total'] = $dao->N;
//FIXME: need to optimize/cache these queries
$limit = " LIMIT {$start}, {$rp}";
$query .= $limit;
//EXIT;
$dao = CRM_Core_DAO::executeQuery($query, $params);
$activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE);
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$activityPriority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id');
$url = CRM_Utils_System::url("civicrm/case/activity", "reset=1&cid={$contactID}&caseid={$caseID}", FALSE, NULL, FALSE);
$contextUrl = '';
if ($context == 'fulltext') {
//.........这里部分代码省略.........
示例3: getContactActivitySelector
/**
* This function is a wrapper for ajax activity selector
*
* @param array $params associated array for params record id.
*
* @return array $contactActivities associated array of contact activities
* @access public
*/
public static function getContactActivitySelector(&$params)
{
// format the params
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['rowCount'] = $params['rp'];
$params['sort'] = CRM_Utils_Array::value('sortBy', $params);
$params['caseId'] = NULL;
$context = CRM_Utils_Array::value('context', $params);
// get contact activities
$activities = CRM_Activity_BAO_Activity::getActivities($params);
// add total
$params['total'] = CRM_Activity_BAO_Activity::getActivitiesCount($params);
// format params and add links
$contactActivities = array();
if (!empty($activities)) {
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
// check logged in user for permission
$page = new CRM_Core_Page();
CRM_Contact_Page_View::checkUserPermission($page, $params['contact_id']);
$permissions = array($page->_permission);
if (CRM_Core_Permission::check('delete activities')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
foreach ($activities as $activityId => $values) {
$contactActivities[$activityId]['activity_type'] = $values['activity_type'];
$contactActivities[$activityId]['subject'] = $values['subject'];
if ($params['contact_id'] == $values['source_contact_id']) {
$contactActivities[$activityId]['source_contact'] = $values['source_contact_name'];
} elseif ($values['source_contact_id']) {
$contactActivities[$activityId]['source_contact'] = CRM_Utils_System::href($values['source_contact_name'], 'civicrm/contact/view', "reset=1&cid={$values['source_contact_id']}");
} else {
$contactActivities[$activityId]['source_contact'] = '<em>n/a</em>';
}
if (isset($values['mailingId']) && !empty($values['mailingId'])) {
$contactActivities[$activityId]['target_contact'] = CRM_Utils_System::href($values['recipients'], 'civicrm/mailing/report/event', "mid={$values['source_record_id']}&reset=1&event=queue&cid={$params['contact_id']}&context=activitySelector");
} elseif (CRM_Utils_Array::value('recipients', $values)) {
$contactActivities[$activityId]['target_contact'] = $values['recipients'];
} elseif (!$values['target_contact_name']) {
$contactActivities[$activityId]['target_contact'] = '<em>n/a</em>';
} elseif (!empty($values['target_contact_name'])) {
$count = 0;
$contactActivities[$activityId]['target_contact'] = '';
foreach ($values['target_contact_name'] as $tcID => $tcName) {
if ($tcID && $count < 5) {
$contactActivities[$activityId]['target_contact'] .= CRM_Utils_System::href($tcName, 'civicrm/contact/view', "reset=1&cid={$tcID}");
$count++;
if ($count) {
$contactActivities[$activityId]['target_contact'] .= "; ";
}
if ($count == 4) {
$contactActivities[$activityId]['target_contact'] .= "(" . ts('more') . ")";
break;
}
}
}
}
if (empty($values['assignee_contact_name'])) {
$contactActivities[$activityId]['assignee_contact'] = '<em>n/a</em>';
} elseif (!empty($values['assignee_contact_name'])) {
$count = 0;
$contactActivities[$activityId]['assignee_contact'] = '';
foreach ($values['assignee_contact_name'] as $acID => $acName) {
if ($acID && $count < 5) {
$contactActivities[$activityId]['assignee_contact'] .= CRM_Utils_System::href($acName, 'civicrm/contact/view', "reset=1&cid={$acID}");
$count++;
if ($count) {
$contactActivities[$activityId]['assignee_contact'] .= "; ";
}
if ($count == 4) {
$contactActivities[$activityId]['assignee_contact'] .= "(" . ts('more') . ")";
break;
}
}
}
}
$contactActivities[$activityId]['activity_date'] = CRM_Utils_Date::customFormat($values['activity_date_time']);
$contactActivities[$activityId]['status'] = $activityStatus[$values['status_id']];
// add class to this row if overdue
$contactActivities[$activityId]['class'] = '';
if (CRM_Utils_Date::overdue(CRM_Utils_Array::value('activity_date_time', $values)) && CRM_Utils_Array::value('status_id', $values) == 1) {
$contactActivities[$activityId]['class'] = 'status-overdue';
} else {
$contactActivities[$activityId]['class'] = 'status-ontime';
}
// build links
$contactActivities[$activityId]['links'] = '';
$accessMailingReport = FALSE;
if (CRM_Utils_Array::value('mailingId', $values)) {
$accessMailingReport = TRUE;
}
$actionLinks = CRM_Activity_Selector_Activity::actionLinks(CRM_Utils_Array::value('activity_type_id', $values), CRM_Utils_Array::value('source_record_id', $values), $accessMailingReport, CRM_Utils_Array::value('activity_id', $values));
//.........这里部分代码省略.........
示例4: updatePledgeStatus
public static function updatePledgeStatus($params)
{
$returnMessages = array();
$sendReminders = CRM_Utils_Array::value('send_reminders', $params, FALSE);
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
//unset statues that we never use for pledges
foreach (array('Completed', 'Cancelled', 'Failed') as $statusKey) {
if ($key = CRM_Utils_Array::key($statusKey, $allStatus)) {
unset($allStatus[$key]);
}
}
$statusIds = implode(',', array_keys($allStatus));
$updateCnt = 0;
$query = "\nSELECT pledge.contact_id as contact_id,\n pledge.id as pledge_id,\n pledge.amount as amount,\n payment.scheduled_date as scheduled_date,\n pledge.create_date as create_date,\n payment.id as payment_id,\n pledge.currency as currency,\n pledge.contribution_page_id as contribution_page_id,\n payment.reminder_count as reminder_count,\n pledge.max_reminders as max_reminders,\n payment.reminder_date as reminder_date,\n pledge.initial_reminder_day as initial_reminder_day,\n pledge.additional_reminder_day as additional_reminder_day,\n pledge.status_id as pledge_status,\n payment.status_id as payment_status,\n pledge.is_test as is_test,\n pledge.campaign_id as campaign_id,\n SUM(payment.scheduled_amount) as amount_due,\n ( SELECT sum(civicrm_pledge_payment.actual_amount)\n FROM civicrm_pledge_payment\n WHERE civicrm_pledge_payment.status_id = 1\n AND civicrm_pledge_payment.pledge_id = pledge.id\n ) as amount_paid\n FROM civicrm_pledge pledge, civicrm_pledge_payment payment\n WHERE pledge.id = payment.pledge_id\n AND payment.status_id IN ( {$statusIds} ) AND pledge.status_id IN ( {$statusIds} )\n GROUP By payment.id\n ";
$dao = CRM_Core_DAO::executeQuery($query);
$now = date('Ymd');
$pledgeDetails = $contactIds = $pledgePayments = $pledgeStatus = array();
while ($dao->fetch()) {
$checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($dao->contact_id);
$pledgeDetails[$dao->payment_id] = array('scheduled_date' => $dao->scheduled_date, 'amount_due' => $dao->amount_due, 'amount' => $dao->amount, 'amount_paid' => $dao->amount_paid, 'create_date' => $dao->create_date, 'contact_id' => $dao->contact_id, 'pledge_id' => $dao->pledge_id, 'checksumValue' => $checksumValue, 'contribution_page_id' => $dao->contribution_page_id, 'reminder_count' => $dao->reminder_count, 'max_reminders' => $dao->max_reminders, 'reminder_date' => $dao->reminder_date, 'initial_reminder_day' => $dao->initial_reminder_day, 'additional_reminder_day' => $dao->additional_reminder_day, 'pledge_status' => $dao->pledge_status, 'payment_status' => $dao->payment_status, 'is_test' => $dao->is_test, 'currency' => $dao->currency, 'campaign_id' => $dao->campaign_id);
$contactIds[$dao->contact_id] = $dao->contact_id;
$pledgeStatus[$dao->pledge_id] = $dao->pledge_status;
if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($dao->scheduled_date, '%Y%m%d'), $now) && $dao->payment_status != array_search('Overdue', $allStatus)) {
$pledgePayments[$dao->pledge_id][$dao->payment_id] = $dao->payment_id;
}
}
// process the updating script...
foreach ($pledgePayments as $pledgeId => $paymentIds) {
// 1. update the pledge /pledge payment status. returns new status when an update happens
$returnMessages[] = "Checking if status update is needed for Pledge Id: {$pledgeId} (current status is {$allStatus[$pledgeStatus[$pledgeId]]})";
$newStatus = CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, $paymentIds, array_search('Overdue', $allStatus), NULL, 0, FALSE, TRUE);
if ($newStatus != $pledgeStatus[$pledgeId]) {
$returnMessages[] = "- status updated to: {$allStatus[$newStatus]}";
$updateCnt += 1;
}
}
if ($sendReminders) {
// retrieve domain tokens
$domain = CRM_Core_BAO_Domain::getDomain();
$tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens());
$domainValues = array();
foreach ($tokens['domain'] as $token) {
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
//get the domain email address, since we don't carry w/ object.
$domainValue = CRM_Core_BAO_Domain::getNameAndEmail();
$domainValues['email'] = $domainValue[1];
// retrieve contact tokens
// this function does NOT return Deceased contacts since we don't want to send them email
list($contactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, $tokens, 'CRM_UpdatePledgeRecord');
// assign domain values to template
$template = CRM_Core_Smarty::singleton();
$template->assign('domain', $domainValues);
//set receipt from
$receiptFrom = '"' . $domainValues['name'] . '" <' . $domainValues['email'] . '>';
foreach ($pledgeDetails as $paymentId => $details) {
if (array_key_exists($details['contact_id'], $contactDetails)) {
$contactId = $details['contact_id'];
$pledgerName = $contactDetails[$contactId]['display_name'];
} else {
continue;
}
if (empty($details['reminder_date'])) {
$nextReminderDate = new DateTime($details['scheduled_date']);
$nextReminderDate->modify("-" . $details['initial_reminder_day'] . "day");
$nextReminderDate = $nextReminderDate->format("Ymd");
} else {
$nextReminderDate = new DateTime($details['reminder_date']);
$nextReminderDate->modify("+" . $details['additional_reminder_day'] . "day");
$nextReminderDate = $nextReminderDate->format("Ymd");
}
if ($details['reminder_count'] < $details['max_reminders'] && $nextReminderDate <= $now) {
$toEmail = $doNotEmail = $onHold = NULL;
if (!empty($contactDetails[$contactId]['email'])) {
$toEmail = $contactDetails[$contactId]['email'];
}
if (!empty($contactDetails[$contactId]['do_not_email'])) {
$doNotEmail = $contactDetails[$contactId]['do_not_email'];
}
if (!empty($contactDetails[$contactId]['on_hold'])) {
$onHold = $contactDetails[$contactId]['on_hold'];
}
// 2. send acknowledgement mail
if ($toEmail && !($doNotEmail || $onHold)) {
//assign value to template
$template->assign('amount_paid', $details['amount_paid'] ? $details['amount_paid'] : 0);
$template->assign('contact', $contactDetails[$contactId]);
$template->assign('next_payment', $details['scheduled_date']);
$template->assign('amount_due', $details['amount_due']);
$template->assign('checksumValue', $details['checksumValue']);
$template->assign('contribution_page_id', $details['contribution_page_id']);
$template->assign('pledge_id', $details['pledge_id']);
$template->assign('scheduled_payment_date', $details['scheduled_date']);
$template->assign('amount', $details['amount']);
$template->assign('create_date', $details['create_date']);
$template->assign('currency', $details['currency']);
list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_pledge', 'valueName' => 'pledge_reminder', 'contactId' => $contactId, 'from' => $receiptFrom, 'toName' => $pledgerName, 'toEmail' => $toEmail));
// 3. update pledge payment details
if ($mailSent) {
CRM_Pledge_BAO_PledgePayment::updateReminderDetails($paymentId);
//.........这里部分代码省略.........
示例5: postProcess
/**
* Process the form submission.
*
*
* @return void
*/
public function postProcess()
{
//get the submitted form values.
$formValues = $this->controller->exportValues($this->_name);
$params = array();
$formValues['scheduled_date'] = CRM_Utils_Date::processDate($formValues['scheduled_date']);
$params['scheduled_date'] = CRM_Utils_Date::format($formValues['scheduled_date']);
$params['currency'] = CRM_Utils_Array::value('currency', $formValues);
$now = date('Ymd');
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($params['scheduled_date'], '%Y%m%d'), $now)) {
$params['status_id'] = array_search('Overdue', $contributionStatus);
} else {
$params['status_id'] = array_search('Pending', $contributionStatus);
}
$params['id'] = $this->_id;
$pledgeId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $params['id'], 'pledge_id');
CRM_Pledge_BAO_PledgePayment::add($params);
$adjustTotalAmount = FALSE;
if (CRM_Utils_Array::value('option_type', $formValues) == 2) {
$adjustTotalAmount = TRUE;
}
$pledgeScheduledAmount = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $params['id'], 'scheduled_amount', 'id');
$oldestPaymentAmount = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeId, 2);
if ($oldestPaymentAmount['count'] != 1 && $oldestPaymentAmount['id'] == $params['id']) {
$oldestPaymentAmount = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeId);
}
if ($formValues['scheduled_amount'] - $pledgeScheduledAmount >= $oldestPaymentAmount['amount']) {
$adjustTotalAmount = TRUE;
}
//update pledge status
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, array($params['id']), $params['status_id'], NULL, $formValues['scheduled_amount'], $adjustTotalAmount);
$statusMsg = ts('Pledge Payment Schedule has been updated.');
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
}
示例6: create
/**
* @param array $params
*
* @return pledge
*/
public static function create($params)
{
$transaction = new CRM_Core_Transaction();
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
//calculate the scheduled date for every installment
$now = date('Ymd') . '000000';
$statues = $prevScheduledDate = array();
$prevScheduledDate[1] = CRM_Utils_Date::processDate($params['scheduled_date']);
if (CRM_Utils_Date::overdue($prevScheduledDate[1], $now)) {
$statues[1] = array_search('Overdue', $contributionStatus);
} else {
$statues[1] = array_search('Pending', $contributionStatus);
}
for ($i = 1; $i < $params['installments']; $i++) {
$prevScheduledDate[$i + 1] = self::calculateNextScheduledDate($params, $i);
if (CRM_Utils_Date::overdue($prevScheduledDate[$i + 1], $now)) {
$statues[$i + 1] = array_search('Overdue', $contributionStatus);
} else {
$statues[$i + 1] = array_search('Pending', $contributionStatus);
}
}
if ($params['installment_amount']) {
$params['scheduled_amount'] = $params['installment_amount'];
} else {
$params['scheduled_amount'] = round($params['amount'] / $params['installments'], 2);
}
for ($i = 1; $i <= $params['installments']; $i++) {
// calculate the scheduled amount for every installment.
if ($i == $params['installments']) {
$params['scheduled_amount'] = $params['amount'] - ($i - 1) * $params['scheduled_amount'];
}
if (!isset($params['contribution_id']) && $params['installments'] > 1) {
$params['status_id'] = $statues[$i];
}
$params['scheduled_date'] = $prevScheduledDate[$i];
$payment = self::add($params);
if (is_a($payment, 'CRM_Core_Error')) {
$transaction->rollback();
return $payment;
}
// we should add contribution id to only first payment record
if (isset($params['contribution_id'])) {
unset($params['contribution_id']);
unset($params['actual_amount']);
}
}
// update pledge status
self::updatePledgePaymentStatus($params['pledge_id']);
$transaction->commit();
return $payment;
}
示例7: alterDisplay
//.........这里部分代码省略.........
$cid = $rows[$rowNum]['civicrm_contact_contact_source_id'];
}
$actActionLinks = CRM_Activity_Selector_Activity::actionLinks($row['civicrm_activity_activity_type_id'], CRM_Utils_Array::value('civicrm_activity_source_record_id', $rows[$rowNum]), FALSE, $rows[$rowNum]['civicrm_activity_id']);
$actLinkValues = array('id' => $rows[$rowNum]['civicrm_activity_id'], 'cid' => $cid, 'cxt' => $context);
$actUrl = CRM_Utils_System::url($actActionLinks[CRM_Core_Action::VIEW]['url'], CRM_Core_Action::replace($actActionLinks[CRM_Core_Action::VIEW]['qs'], $actLinkValues), TRUE);
}
if (array_key_exists('civicrm_contact_contact_source', $row)) {
if ($value = $row['civicrm_contact_contact_source_id']) {
if ($viewLinks) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_contact_source_link'] = $url;
$rows[$rowNum]['civicrm_contact_contact_source_hover'] = $onHover;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_assignee', $row)) {
$assigneeNames = explode(';', $row['civicrm_contact_contact_assignee']);
if ($value = $row['civicrm_contact_contact_assignee_id']) {
$assigneeContactIds = explode(';', $value);
$link = array();
if ($viewLinks) {
foreach ($assigneeContactIds as $id => $value) {
if (isset($value) && isset($assigneeNames[$id])) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$assigneeNames[$id]}</a>";
}
}
$rows[$rowNum]['civicrm_contact_contact_assignee'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_target', $row)) {
$targetNames = explode(';', $row['civicrm_contact_contact_target']);
if ($value = $row['civicrm_contact_contact_target_id']) {
$targetContactIds = explode(';', $value);
$link = array();
if ($viewLinks) {
foreach ($targetContactIds as $id => $value) {
if (isset($value) && isset($targetNames[$id])) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$targetNames[$id]}</a>";
}
}
$rows[$rowNum]['civicrm_contact_contact_target'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_activity_type_id', $row)) {
if ($value = $row['civicrm_activity_activity_type_id']) {
$rows[$rowNum]['civicrm_activity_activity_type_id'] = $activityType[$value];
if ($viewLinks) {
$rows[$rowNum]['civicrm_activity_activity_type_id_link'] = $actUrl;
$rows[$rowNum]['civicrm_activity_activity_type_id_hover'] = $onHoverAct;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_status_id', $row)) {
if ($value = $row['civicrm_activity_status_id']) {
$rows[$rowNum]['civicrm_activity_status_id'] = $activityStatus[$value];
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_details', $row) && $this->_outputMode == 'html') {
if ($value = $row['civicrm_activity_details']) {
$fullDetails = $rows[$rowNum]['civicrm_activity_details'];
$rows[$rowNum]['civicrm_activity_details'] = substr($fullDetails, 0, strrpos(substr($fullDetails, 0, 80), ' '));
if ($actUrl) {
$rows[$rowNum]['civicrm_activity_details'] .= " <a href='{$actUrl}' title='{$onHoverAct}'>(more)</a>";
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_campaign_id', $row)) {
if ($value = $row['civicrm_activity_campaign_id']) {
$rows[$rowNum]['civicrm_activity_campaign_id'] = $this->activeCampaigns[$value];
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_engagement_level', $row)) {
if ($value = $row['civicrm_activity_engagement_level']) {
$rows[$rowNum]['civicrm_activity_engagement_level'] = $this->engagementLevels[$value];
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_activity_date_time', $row) && array_key_exists('civicrm_activity_status_id', $row)) {
if (CRM_Utils_Date::overdue($rows[$rowNum]['civicrm_activity_activity_date_time']) && $activityStatus[$row['civicrm_activity_status_id']] != 'Completed') {
$rows[$rowNum]['class'] = "status-overdue";
$entryFound = TRUE;
}
}
$entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'activity', 'List all activities for this ') ? TRUE : $entryFound;
if (!$entryFound) {
break;
}
}
}
示例8: getCaseActivity
/**
* Get Case Activities.
*
* @param int $caseID
* Case id.
* @param array $params
* Posted params.
* @param int $contactID
* Contact id.
*
* @param null $context
* @param int $userID
* @param null $type
*
* @return array
* Array of case activities
*
*/
public static function getCaseActivity($caseID, &$params, $contactID, $context = NULL, $userID = NULL, $type = NULL)
{
$values = array();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
// CRM-5081 - formatting the dates to omit seconds.
// Note the 00 in the date format string is needed otherwise later on it thinks scheduled ones are overdue.
$select = "\n SELECT COUNT(ca.id) AS ismultiple,\n ca.id AS id,\n ca.activity_type_id AS type,\n ca.activity_type_id AS activity_type_id,\n tcc.sort_name AS target_contact_name,\n tcc.id AS target_contact_id,\n scc.sort_name AS source_contact_name,\n scc.id AS source_contact_id,\n acc.sort_name AS assignee_contact_name,\n acc.id AS assignee_contact_id,\n DATE_FORMAT(\n IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value,\n ca.activity_date_time,\n DATE_ADD(NOW(), INTERVAL 1 YEAR)\n ), '%Y%m%d%H%i00') AS overdue_date,\n DATE_FORMAT(ca.activity_date_time, '%Y%m%d%H%i00') AS display_date,\n ca.status_id AS status,\n ca.subject AS subject,\n ca.is_deleted AS deleted,\n ca.priority_id AS priority,\n ca.weight AS weight,\n GROUP_CONCAT(ef.file_id) AS attachment_ids ";
$from = "\n FROM civicrm_case_activity cca\n INNER JOIN civicrm_activity ca\n ON ca.id = cca.activity_id\n INNER JOIN civicrm_activity_contact cas\n ON cas.activity_id = ca.id\n AND cas.record_type_id = {$sourceID}\n INNER JOIN civicrm_contact scc\n ON scc.id = cas.contact_id\n LEFT JOIN civicrm_activity_contact caa\n ON caa.activity_id = ca.id\n AND caa.record_type_id = {$assigneeID}\n LEFT JOIN civicrm_contact acc\n ON acc.id = caa.contact_id\n LEFT JOIN civicrm_activity_contact cat\n ON cat.activity_id = ca.id\n AND cat.record_type_id = {$targetID}\n LEFT JOIN civicrm_contact tcc\n ON tcc.id = cat.contact_id\n INNER JOIN civicrm_option_group cog\n ON cog.name = 'activity_type'\n INNER JOIN civicrm_option_value cov\n ON cov.option_group_id = cog.id\n AND cov.value = ca.activity_type_id\n AND cov.is_active = 1\n LEFT JOIN civicrm_entity_file ef\n ON ef.entity_table = 'civicrm_activity'\n AND ef.entity_id = ca.id\n LEFT OUTER JOIN civicrm_option_group og\n ON og.name = 'activity_status'\n LEFT OUTER JOIN civicrm_option_value ov\n ON ov.option_group_id=og.id\n AND ov.name = 'Scheduled'";
$where = '
WHERE cca.case_id= %1
AND ca.is_current_revision = 1';
if (!empty($params['source_contact_id'])) {
$where .= "\n AND cas.contact_id = " . CRM_Utils_Type::escape($params['source_contact_id'], 'Integer');
}
if (!empty($params['status_id'])) {
$where .= "\n AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer');
}
if (!empty($params['activity_deleted'])) {
$where .= "\n AND ca.is_deleted = 1";
} else {
$where .= "\n AND ca.is_deleted = 0";
}
if (!empty($params['activity_type_id'])) {
$where .= "\n AND ca.activity_type_id = " . CRM_Utils_Type::escape($params['activity_type_id'], 'Integer');
}
if (!empty($params['activity_date_low'])) {
$fromActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_low']), 'Date');
}
if (!empty($fromActivityDate)) {
$where .= "\n AND ca.activity_date_time >= '{$fromActivityDate}'";
}
if (!empty($params['activity_date_high'])) {
$toActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_high']), 'Date');
$toActivityDate = $toActivityDate ? $toActivityDate + 235959 : NULL;
}
if (!empty($toActivityDate)) {
$where .= "\n AND ca.activity_date_time <= '{$toActivityDate}'";
}
$groupBy = "\n GROUP BY ca.id ";
$sortBy = CRM_Utils_Array::value('sortBy', $params);
if (!$sortBy) {
// CRM-5081 - added id to act like creation date
$orderBy = "\n ORDER BY overdue_date ASC, display_date DESC, weight DESC";
} else {
$sortBy = CRM_Utils_Type::escape($sortBy, 'String');
$orderBy = " ORDER BY {$sortBy} ";
}
$page = CRM_Utils_Array::value('page', $params);
$rp = CRM_Utils_Array::value('rp', $params);
if (!$page) {
$page = 1;
}
if (!$rp) {
$rp = 10;
}
$start = ($page - 1) * $rp;
$limit = " LIMIT {$start}, {$rp}";
$query = $select . $from . $where . $groupBy . $orderBy . $limit;
$queryParams = array(1 => array($caseID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $queryParams);
$activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE);
$activityStatuses = CRM_Core_PseudoConstant::activityStatus();
$url = CRM_Utils_System::url("civicrm/case/activity", "reset=1&cid={$contactID}&caseid={$caseID}", FALSE, NULL, FALSE);
$contextUrl = '';
if ($context == 'fulltext') {
$contextUrl = "&context={$context}";
}
$editUrl = "{$url}&action=update{$contextUrl}";
$deleteUrl = "{$url}&action=delete{$contextUrl}";
$restoreUrl = "{$url}&action=renew{$contextUrl}";
$viewTitle = ts('View activity');
$statusTitle = ts('Edit Status');
$emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name'));
$emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name'));
$caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted');
// define statuses which are handled like Completed status (others are assumed to be handled like Scheduled status)
$compStatusValues = array();
$compStatusNames = array('Completed', 'Left Message', 'Cancelled', 'Unreachable', 'Not Required');
foreach ($compStatusNames as $name) {
//.........这里部分代码省略.........
示例9: alterDisplay
function alterDisplay(&$rows)
{
// custom code to alter rows
$entryFound = FALSE;
$activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$volunteerRoles = CRM_Volunteer_BAO_Need::buildOptions('role_id', 'create');
$viewLinks = FALSE;
$seperator = CRM_CORE_DAO::VALUE_SEPARATOR;
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'report');
if (CRM_Core_Permission::check('access CiviCRM')) {
$viewLinks = TRUE;
$onHover = ts('View Contact Summary for this Contact', array('domain' => 'org.civicrm.volunteer'));
$onHoverAct = ts('View Activity Record', array('domain' => 'org.civicrm.volunteer'));
}
foreach ($rows as $rowNum => $row) {
if (array_key_exists('civicrm_contact_contact_source', $row)) {
if ($value = $row['civicrm_activity_assignment_contact_id']) {
if ($viewLinks) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_contact_source_link'] = $url;
$rows[$rowNum]['civicrm_contact_contact_source_hover'] = $onHover;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_assignee', $row)) {
$assigneeNames = explode($seperator, $row['civicrm_contact_contact_assignee']);
if ($value = $row['civicrm_activity_assignment_contact_id']) {
$assigneeContactIds = explode($seperator, $value);
$link = array();
if ($viewLinks) {
foreach ($assigneeContactIds as $id => $value) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$assigneeNames[$id]}</a>";
}
$rows[$rowNum]['civicrm_contact_contact_assignee'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_target', $row)) {
$targetNames = explode($seperator, $row['civicrm_contact_contact_target']);
if ($value = $row['civicrm_activity_target_contact_id']) {
$targetContactIds = explode($seperator, $value);
$link = array();
if ($viewLinks) {
foreach ($targetContactIds as $id => $value) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$targetNames[$id]}</a>";
}
$rows[$rowNum]['civicrm_contact_contact_target'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_activity_type_id', $row)) {
if ($value = $row['civicrm_activity_activity_type_id']) {
$rows[$rowNum]['civicrm_activity_activity_type_id'] = $activityType[$value];
if ($viewLinks) {
// Check for assignee contact id(s) (since they are the volunteer and use the first contact id in that list for view activity link if found,
// else use source contact id
if (!empty($rows[$rowNum]['civicrm_activity_assignment_contact_id'])) {
$targets = explode($seperator, $rows[$rowNum]['civicrm_activity_assignment_contact_id']);
$cid = $targets[0];
} else {
$cid = $rows[$rowNum]['civicrm_activity_source_contact_id'];
}
$actionLinks = CRM_Activity_Selector_Activity::actionLinks($row['civicrm_activity_activity_type_id'], CRM_Utils_Array::value('civicrm_activity_source_record_id', $rows[$rowNum]), FALSE, $rows[$rowNum]['civicrm_activity_id']);
$linkValues = array('id' => $rows[$rowNum]['civicrm_activity_id'], 'cid' => $cid, 'cxt' => $context);
$url = CRM_Utils_System::url($actionLinks[CRM_Core_Action::VIEW]['url'], CRM_Core_Action::replace($actionLinks[CRM_Core_Action::VIEW]['qs'], $linkValues), TRUE);
$rows[$rowNum]['civicrm_activity_activity_type_id_link'] = $url;
$rows[$rowNum]['civicrm_activity_activity_type_id_hover'] = $onHoverAct;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_status_id', $row)) {
if ($value = $row['civicrm_activity_status_id']) {
$rows[$rowNum]['civicrm_activity_status_id'] = $activityStatus[$value];
$entryFound = TRUE;
}
}
if (array_key_exists('role_role', $row)) {
if ($value = $row['role_role']) {
$rows[$rowNum]['role_role'] = $volunteerRoles[$value];
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_activity_date_time', $row)) {
$rows[$rowNum]['civicrm_activity_activity_date_time'] = CRM_Utils_Date::customFormat($row['civicrm_activity_activity_date_time']);
// Display overdue marker
if (array_key_exists('civicrm_activity_status_id', $row) && CRM_Utils_Date::overdue($rows[$rowNum]['civicrm_activity_activity_date_time']) && $activityStatus[$row['civicrm_activity_status_id']] != 'Completed') {
$rows[$rowNum]['class'] = "status-overdue";
$entryFound = TRUE;
}
}
$entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'activity', 'List all activities for this ') ? TRUE : $entryFound;
if (!$entryFound) {
break;
//.........这里部分代码省略.........
示例10: getCaseActivity
/**
* Function to get Case Activities
*
* @param int $caseID case id
* @param array $params posted params
* @param int $contactID contact id
*
* @return returns case activities
*
* @static
*/
static function getCaseActivity($caseID, &$params, $contactID)
{
$values = array();
$select = 'SELECT count(ca.id) as ismultiple, ca.id as id,
ca.activity_type_id as type,
cc.sort_name as reporter,
cc.id as reporter_id,
acc.sort_name AS assignee,
acc.id AS assignee_id,
IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value,
ca.activity_date_time,
DATE_ADD(NOW(), INTERVAL 1 YEAR)
) as overdue_date,
ca.activity_date_time as display_date,
ca.status_id as status,
ca.subject as subject,
ca.is_deleted as deleted,
ca.priority_id as priority ';
$from = 'FROM civicrm_case_activity cca
INNER JOIN civicrm_activity ca ON ca.id = cca.activity_id
INNER JOIN civicrm_contact cc ON cc.id = ca.source_contact_id
LEFT OUTER JOIN civicrm_option_group og ON og.name="activity_status"
LEFT OUTER JOIN civicrm_option_value ov ON ov.option_group_id=og.id AND ov.name="Scheduled"
LEFT JOIN civicrm_activity_assignment caa
ON caa.activity_id = ca.id
LEFT JOIN civicrm_contact acc ON acc.id = caa.assignee_contact_id ';
$where = 'WHERE cca.case_id= %1
AND ca.is_current_revision = 1';
if (CRM_Utils_Array::value('reporter_id', $params)) {
$where .= " AND ca.source_contact_id = " . CRM_Utils_Type::escape($params['reporter_id'], 'Integer');
}
if (CRM_Utils_Array::value('status_id', $params)) {
$where .= " AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer');
}
if (CRM_Utils_Array::value('activity_deleted', $params)) {
$where .= " AND ca.is_deleted = 1";
} else {
$where .= " AND ca.is_deleted = 0";
}
if (CRM_Utils_Array::value('activity_type_id', $params)) {
$where .= " AND ca.activity_type_id = " . CRM_Utils_Type::escape($params['activity_type_id'], 'Integer');
}
if (CRM_Utils_Array::value('activity_date_low', $params)) {
$fromActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_low']), 'Date');
}
if (CRM_Utils_Array::value('activity_date_high', $params)) {
$toActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_high']), 'Date');
$toActivityDate = $toActivityDate ? $toActivityDate + 235959 : null;
}
if (!empty($fromActivityDate)) {
$where .= " AND ca.activity_date_time >= '{$fromActivityDate}'";
}
if (!empty($toActivityDate)) {
$where .= " AND ca.activity_date_time <= '{$toActivityDate}'";
}
// hack to handle to allow initial sorting to be done by query
if (CRM_Utils_Array::value('sortname', $params) == 'undefined') {
$params['sortname'] = null;
}
if (CRM_Utils_Array::value('sortorder', $params) == 'undefined') {
$params['sortorder'] = null;
}
$sortname = CRM_Utils_Array::value('sortname', $params);
$sortorder = CRM_Utils_Array::value('sortorder', $params);
$groupBy = " GROUP BY ca.id ";
if (!$sortname and !$sortorder) {
$orderBy = " ORDER BY overdue_date ASC, display_date DESC";
} else {
$orderBy = " ORDER BY {$sortname} {$sortorder}, display_date DESC";
}
$page = CRM_Utils_Array::value('page', $params);
$rp = CRM_Utils_Array::value('rp', $params);
if (!$page) {
$page = 1;
}
if (!$rp) {
$rp = 10;
}
$start = ($page - 1) * $rp;
$query = $select . $from . $where . $groupBy . $orderBy;
$params = array(1 => array($caseID, 'Integer'));
$dao =& CRM_Core_DAO::executeQuery($query, $params);
$params['total'] = $dao->N;
//FIXME: need to optimize/cache these queries
$limit = " LIMIT {$start}, {$rp}";
$query .= $limit;
$dao =& CRM_Core_DAO::executeQuery($query, $params);
$activityTypes = CRM_Case_PseudoConstant::activityType(false, true);
require_once "CRM/Utils/Date.php";
//.........这里部分代码省略.........
示例11: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
//get the submitted form values.
$formValues = $this->controller->exportValues($this->_name);
$params = array();
$formValues['scheduled_date'] = CRM_Utils_Date::processDate($formValues['scheduled_date']);
$params['scheduled_date'] = CRM_Utils_Date::format($formValues['scheduled_date']);
$now = date('Ymd');
if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($params['scheduled_date'], '%Y%m%d'), $now)) {
$params['status_id'] = array_search('Overdue', CRM_Contribute_PseudoConstant::contributionStatus());
} else {
$params['status_id'] = array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus());
}
$params['id'] = $this->_id;
$pledgeId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Payment', $params['id'], 'pledge_id');
require_once 'CRM/Pledge/BAO/Payment.php';
CRM_Pledge_BAO_Payment::add($params);
//update pledge status
CRM_Pledge_BAO_Payment::updatePledgePaymentStatus($pledgeId);
$statusMsg = ts('Pledge Payment Schedule has been updated.<br />');
CRM_Core_Session::setStatus($statusMsg);
}
示例12: create
static function create($params)
{
require_once 'CRM/Contribute/PseudoConstant.php';
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$date = array();
$scheduled_date = CRM_Utils_Date::processDate($params['scheduled_date']);
$date['year'] = (int) substr($scheduled_date, 0, 4);
$date['month'] = (int) substr($scheduled_date, 4, 2);
$date['day'] = (int) substr($scheduled_date, 6, 2);
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
//calculation of schedule date according to frequency day of period
//frequency day is not applicable for daily installments
if ($params['frequency_unit'] != 'day') {
if ($params['frequency_unit'] != 'week') {
//for month use day of next month & for year use day of month Jan of next year as next payment date
$date['day'] = $params['frequency_day'];
if ($params['frequency_unit'] == 'year') {
$date['month'] = '1';
}
} else {
if ($params['frequency_unit'] == 'week') {
//for week calculate day of week ie. Sunday,Monday etc. as next payment date
$dayOfWeek = date('w', mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
$frequencyDay = $params['frequency_day'] - $dayOfWeek;
$scheduleDate = explode("-", date('n-j-Y', mktime(0, 0, 0, $date['month'], $date['day'] + $frequencyDay, $date['year'])));
$date['month'] = $scheduleDate[0];
$date['day'] = $scheduleDate[1];
$date['year'] = $scheduleDate[2];
}
}
}
//calculate the scheduled date for every installment
$now = date('Ymd') . '000000';
$statues = $prevScheduledDate = array();
$prevScheduledDate[1] = $scheduled_date;
if (CRM_Utils_Date::overdue($prevScheduledDate[1], $now)) {
$statues[1] = array_search('Overdue', $contributionStatus);
} else {
$statues[1] = array_search('Pending', $contributionStatus);
}
$newDate = date('YmdHis', mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
for ($i = 1; $i < $params['installments']; $i++) {
$prevScheduledDate[$i + 1] = CRM_Utils_Date::format(CRM_Utils_Date::intervalAdd($params['frequency_unit'], $i * $params['frequency_interval'], $newDate));
if (CRM_Utils_Date::overdue($prevScheduledDate[$i + 1], $now)) {
$statues[$i + 1] = array_search('Overdue', $contributionStatus);
} else {
$statues[$i + 1] = array_search('Pending', $contributionStatus);
}
}
if ($params['installment_amount']) {
$params['scheduled_amount'] = $params['installment_amount'];
} else {
$params['scheduled_amount'] = round($params['amount'] / $params['installments'], 2);
}
for ($i = 1; $i <= $params['installments']; $i++) {
//calculate the scheduled amount for every installment.
if ($i == $params['installments']) {
$params['scheduled_amount'] = $params['amount'] - ($i - 1) * $params['scheduled_amount'];
}
if (!isset($params['contribution_id']) && $params['installments'] > 1) {
$params['status_id'] = $statues[$i];
}
$params['scheduled_date'] = $prevScheduledDate[$i];
$payment = self::add($params);
if (is_a($payment, 'CRM_Core_Error')) {
$transaction->rollback();
return $payment;
}
// we should add contribution id to only first payment record
if (isset($params['contribution_id'])) {
unset($params['contribution_id']);
}
}
//update pledge status
self::updatePledgePaymentStatus($params['pledge_id']);
$transaction->commit();
return $payment;
}
示例13: alterDisplay
//.........这里部分代码省略.........
$sql .= "\n HAVING ((to_days({$durationFromDate}) <= to_days(Min(activity_date_time))) AND\n (to_days(Max(activity_date_time)) <= to_days({$durationToDate})))\n ";
}
$data = array();
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$data[$dao->source_record_id]['start_date'] = $dao->start_date;
$data[$dao->source_record_id]['end_date'] = $dao->end_date;
$data[$dao->source_record_id]['qty'] = round($dao->qty, 1);
}
}
foreach ($rows as $rowNum => $row) {
if (!array_key_exists($rows[$rowNum]['civicrm_activity_id'], $data)) {
unset($rows[$rowNum]);
continue;
}
if (array_key_exists($row['civicrm_activity_id'], $data)) {
$rows[$rowNum]['start_date'] = $data[$row['civicrm_activity_id']]['start_date'];
$rows[$rowNum]['end_date'] = $data[$row['civicrm_activity_id']]['end_date'];
$rows[$rowNum]['qty'] = $data[$row['civicrm_activity_id']]['qty'];
}
if (array_key_exists('civicrm_contact_contact_source', $row)) {
if ($value = $row['civicrm_contact_contact_source_id']) {
if ($viewLinks) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_contact_source_link'] = $url;
$rows[$rowNum]['civicrm_contact_contact_source_hover'] = $onHover;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_assignee', $row)) {
$assigneeNames = explode(';', $row['civicrm_contact_contact_assignee']);
if ($value = $row['civicrm_contact_contact_assignee_id']) {
$assigneeContactIds = explode(';', $value);
$link = array();
if ($viewLinks) {
foreach ($assigneeContactIds as $id => $value) {
if (isset($value) && isset($assigneeNames[$id])) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$assigneeNames[$id]}</a>";
}
}
$rows[$rowNum]['civicrm_contact_contact_assignee'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_target', $row)) {
$targetNames = explode(';', $row['civicrm_contact_contact_target']);
if ($value = $row['civicrm_contact_contact_target_id']) {
$targetContactIds = explode(';', $value);
$link = array();
if ($viewLinks) {
foreach ($targetContactIds as $id => $value) {
if (isset($value) && isset($targetNames[$id])) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$targetNames[$id]}</a>";
}
}
$rows[$rowNum]['civicrm_contact_contact_target'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_activity_type_id', $row)) {
if ($value = $row['civicrm_activity_activity_type_id']) {
$rows[$rowNum]['civicrm_activity_activity_type_id'] = $this->activityTypes[$value];
if ($viewLinks) {
// Check for target contact id(s) and use the first contact id in that list for view activity link if found,
// else use source contact id
if (!empty($rows[$rowNum]['civicrm_contact_contact_target_id'])) {
$targets = explode(';', $rows[$rowNum]['civicrm_contact_contact_target_id']);
$cid = $targets[0];
} else {
$cid = $rows[$rowNum]['civicrm_contact_contact_source_id'];
}
$url = CRM_Utils_System::url('civicrm/absence/set', 'reset=1&action=view&aid=' . $rows[$rowNum]['civicrm_activity_id'], $this->_absoluteUrl);
$rows[$rowNum]['civicrm_activity_activity_type_id_link'] = $url;
$rows[$rowNum]['civicrm_activity_activity_type_id_hover'] = $onHoverAct;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_status_id', $row)) {
if ($value = $row['civicrm_activity_status_id']) {
$rows[$rowNum]['civicrm_activity_status_id'] = $this->activityStatus[$value];
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_activity_date_time', $row) && array_key_exists('civicrm_activity_status_id', $row)) {
if (CRM_Utils_Date::overdue($rows[$rowNum]['civicrm_activity_activity_date_time']) && $this->activityStatus[$row['civicrm_activity_status_id']] != 'Approved') {
$rows[$rowNum]['class'] = "status-overdue";
$entryFound = TRUE;
}
}
if (!$entryFound) {
break;
}
}
}
示例14: array
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = null, $case = null)
{
$params['contact_id'] = $this->_contactId;
$config = CRM_Core_Config::singleton();
$rows =& CRM_Activity_BAO_Activity::getActivities($params, $offset, $rowCount, $sort, $this->_admin, $case, $this->_context);
if (empty($rows)) {
return $rows;
}
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
//CRM-4418
$permissions = array($this->_permission);
if (CRM_Core_Permission::check('delete activities')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
foreach ($rows as $k => $row) {
$row =& $rows[$k];
// DRAFTING: provide a facility for db-stored strings
// localize the built-in activity names for display
// (these are not enums, so we can't use any automagic here)
switch ($row['activity_type']) {
case 'Meeting':
$row['activity_type'] = ts('Meeting');
break;
case 'Phone Call':
$row['activity_type'] = ts('Phone Call');
break;
case 'Email':
$row['activity_type'] = ts('Email');
break;
case 'SMS':
$row['activity_type'] = ts('SMS');
break;
case 'Event':
$row['activity_type'] = ts('Event');
break;
}
// add class to this row if overdue
if (CRM_Utils_Date::overdue(CRM_Utils_Array::value('activity_date_time', $row)) && CRM_Utils_Array::value('status_id', $row) == 1) {
$row['overdue'] = 1;
$row['class'] = 'status-overdue';
} else {
$row['overdue'] = 0;
$row['class'] = 'status-ontime';
}
$row['status'] = $row['status_id'] ? $activityStatus[$row['status_id']] : null;
//CRM-3553
$accessMailingReport = false;
if (CRM_Utils_Array::value('mailingId', $row)) {
$accessMailingReport = true;
}
$actionLinks = $this->actionLinks(CRM_Utils_Array::value('activity_type_id', $row), CRM_Utils_Array::value('source_record_id', $row), $accessMailingReport, CRM_Utils_Array::value('activity_id', $row), $this->_key);
$actionMask = array_sum(array_keys($actionLinks)) & $mask;
if ($output != CRM_Core_Selector_Controller::EXPORT && $output != CRM_Core_Selector_Controller::SCREEN) {
$row['action'] = CRM_Core_Action::formLink($actionLinks, $actionMask, array('id' => $row['activity_id'], 'cid' => $this->_contactId, 'cxt' => $this->_context, 'caseid' => CRM_Utils_Array::value('case_id', $row)));
}
unset($row);
}
return $rows;
}
示例15: getCaseActivity
/**
* Function to get Case Activities
*
* @param int $caseID case id
* @param array $params posted params
* @param int $contactID contact id
*
* @return returns case activities
*
* @static
*/
static function getCaseActivity($caseID, &$params, $contactID, $context = null, $userID = null, $type = null)
{
$values = array();
// CRM-5081 - formatting the dates to omit seconds.
// Note the 00 in the date format string is needed otherwise later on it thinks scheduled ones are overdue.
$select = "SELECT count(ca.id) as ismultiple, ca.id as id, \n ca.activity_type_id as type,\n ca.activity_type_id as activity_type_id, \n cc.sort_name as reporter,\n cc.id as reporter_id,\n acc.sort_name AS assignee,\n acc.id AS assignee_id,\n DATE_FORMAT(IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value,\n ca.activity_date_time,\n DATE_ADD(NOW(), INTERVAL 1 YEAR)\n ), '%Y%m%d%H%i00') as overdue_date,\n DATE_FORMAT(ca.activity_date_time, '%Y%m%d%H%i00') as display_date,\n ca.status_id as status, \n ca.subject as subject, \n ca.is_deleted as deleted,\n ca.priority_id as priority ";
$from = 'FROM civicrm_case_activity cca
INNER JOIN civicrm_activity ca ON ca.id = cca.activity_id
INNER JOIN civicrm_contact cc ON cc.id = ca.source_contact_id
INNER JOIN civicrm_option_group cog ON cog.name = "activity_type"
INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id
AND cov.value = ca.activity_type_id AND cov.is_active = 1
LEFT OUTER JOIN civicrm_option_group og ON og.name="activity_status"
LEFT OUTER JOIN civicrm_option_value ov ON ov.option_group_id=og.id AND ov.name="Scheduled"
LEFT JOIN civicrm_activity_assignment caa
ON caa.activity_id = ca.id
LEFT JOIN civicrm_contact acc ON acc.id = caa.assignee_contact_id ';
$where = 'WHERE cca.case_id= %1
AND ca.is_current_revision = 1';
if (CRM_Utils_Array::value('reporter_id', $params)) {
$where .= " AND ca.source_contact_id = " . CRM_Utils_Type::escape($params['reporter_id'], 'Integer');
}
if (CRM_Utils_Array::value('status_id', $params)) {
$where .= " AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer');
}
if (CRM_Utils_Array::value('activity_deleted', $params)) {
$where .= " AND ca.is_deleted = 1";
} else {
$where .= " AND ca.is_deleted = 0";
}
if (CRM_Utils_Array::value('activity_type_id', $params)) {
$where .= " AND ca.activity_type_id = " . CRM_Utils_Type::escape($params['activity_type_id'], 'Integer');
}
if (CRM_Utils_Array::value('activity_date_low', $params)) {
$fromActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_low']), 'Date');
}
if (CRM_Utils_Array::value('activity_date_high', $params)) {
$toActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_high']), 'Date');
$toActivityDate = $toActivityDate ? $toActivityDate + 235959 : null;
}
if (!empty($fromActivityDate)) {
$where .= " AND ca.activity_date_time >= '{$fromActivityDate}'";
}
if (!empty($toActivityDate)) {
$where .= " AND ca.activity_date_time <= '{$toActivityDate}'";
}
// hack to handle to allow initial sorting to be done by query
if (CRM_Utils_Array::value('sortname', $params) == 'undefined') {
$params['sortname'] = null;
}
if (CRM_Utils_Array::value('sortorder', $params) == 'undefined') {
$params['sortorder'] = null;
}
$sortname = CRM_Utils_Array::value('sortname', $params);
$sortorder = CRM_Utils_Array::value('sortorder', $params);
$groupBy = " GROUP BY ca.id ";
if (!$sortname and !$sortorder) {
// CRM-5081 - added id to act like creation date
$orderBy = " ORDER BY overdue_date ASC, display_date DESC, ca.id DESC";
} else {
$orderBy = " ORDER BY {$sortname} {$sortorder}";
if ($sortname != 'display_date') {
$orderBy .= ', display_date DESC';
}
}
$page = CRM_Utils_Array::value('page', $params);
$rp = CRM_Utils_Array::value('rp', $params);
if (!$page) {
$page = 1;
}
if (!$rp) {
$rp = 10;
}
$start = ($page - 1) * $rp;
$query = $select . $from . $where . $groupBy . $orderBy;
$params = array(1 => array($caseID, 'Integer'));
$dao =& CRM_Core_DAO::executeQuery($query, $params);
$params['total'] = $dao->N;
//FIXME: need to optimize/cache these queries
$limit = " LIMIT {$start}, {$rp}";
$query .= $limit;
$dao =& CRM_Core_DAO::executeQuery($query, $params);
require_once "CRM/Utils/Date.php";
require_once "CRM/Core/PseudoConstant.php";
require_once 'CRM/Case/PseudoConstant.php';
$activityTypes = CRM_Case_PseudoConstant::activityType(false, true);
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$activityPriority = CRM_Core_PseudoConstant::priority();
$url = CRM_Utils_System::url("civicrm/case/activity", "reset=1&cid={$contactID}&caseid={$caseID}", false, null, false);
//.........这里部分代码省略.........