本文整理汇总了PHP中CRM_Grant_BAO_Grant类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Grant_BAO_Grant类的具体用法?PHP CRM_Grant_BAO_Grant怎么用?PHP CRM_Grant_BAO_Grant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Grant_BAO_Grant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*
* @return void
* @access public
*
*/
function preProcess()
{
$admin = CRM_Core_Permission::check('administer CiviCRM');
$grantSummary = CRM_Grant_BAO_Grant::getGrantSummary($admin);
$this->assign('grantAdmin', $admin);
$this->assign('grantSummary', $grantSummary);
}
示例2: array
static function &getFields()
{
$fields = array();
require_once 'CRM/Grant/BAO/Grant.php';
$fields = CRM_Grant_BAO_Grant::exportableFields();
return $fields;
}
示例3: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return void
*/
public function postProcess()
{
$deletedGrants = 0;
foreach ($this->_grantIds as $grantId) {
if (CRM_Grant_BAO_Grant::del($grantId)) {
$deletedGrants++;
}
}
CRM_Core_Session::setStatus(ts('Deleted Grant(s): %1', array(1 => $deletedGrants)), '', 'info');
CRM_Core_Session::setStatus(ts('Total Selected Grant(s): %1', array(1 => count($this->_grantIds))), '', 'info');
}
示例4: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
public function postProcess()
{
$deletedGrants = 0;
require_once 'CRM/Grant/BAO/Grant.php';
foreach ($this->_grantIds as $grantId) {
if (CRM_Grant_BAO_Grant::del($grantId)) {
$deletedGrants++;
}
}
$status = array(ts('Deleted Grant(s): %1', array(1 => $deletedGrants)), ts('Total Selected Grant(s): %1', array(1 => count($this->_grantIds))));
CRM_Core_Session::setStatus($status);
}
示例5: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $context);
$values = array();
$params['id'] = $this->_id;
require_once 'CRM/Grant/BAO/Grant.php';
CRM_Grant_BAO_Grant::retrieve($params, $values);
require_once 'CRM/Grant/PseudoConstant.php';
$grantType = CRM_Grant_PseudoConstant::grantType();
$grantStatus = CRM_Grant_PseudoConstant::grantStatus();
$this->assign('grantType', $grantType[$values['grant_type_id']]);
$this->assign('grantStatus', $grantStatus[$values['status_id']]);
$grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
foreach ($grantTokens as $token) {
$this->assign($token, CRM_Utils_Array::value($token, $values));
}
if (isset($this->_id)) {
require_once 'CRM/Core/BAO/Note.php';
$noteDAO = new CRM_Core_BAO_Note();
$noteDAO->entity_table = 'civicrm_grant';
$noteDAO->entity_id = $this->_id;
if ($noteDAO->find(true)) {
$this->_noteId = $noteDAO->id;
}
}
if (isset($this->_noteId)) {
$this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note'));
}
// add Grant to Recent Items
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
require_once 'CRM/Utils/Money.php';
$url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
$title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], null, $recentOther);
require_once 'CRM/Core/BAO/File.php';
$attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
$this->assign('attachment', $attachment);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign('id', $this->_id);
}
示例6: postProcess
/**
* Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess()
{
$deleted = $failed = 0;
foreach ($this->_grantIds as $grantId) {
if (CRM_Grant_BAO_Grant::del($grantId)) {
$deleted++;
} else {
$failed++;
}
}
if ($deleted) {
$msg = ts('%count grant deleted.', array('plural' => '%count grants deleted.', 'count' => $deleted));
CRM_Core_Session::setStatus($msg, ts('Removed'), 'success');
}
if ($failed) {
CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error');
}
}
示例7: getCountComponent
/**
* Given the component name and returns
* the count of participation of contact
*
* @param string $component input component name
* @param integer $contactId input contact id
* @param string $tableName optional tableName if component is custom group
*
* @return total number of count of occurence in database
* @access public
* @static
*/
static function getCountComponent($component, $contactId, $tableName = null)
{
$object = null;
switch ($component) {
case 'tag':
require_once 'CRM/Core/BAO/EntityTag.php';
return CRM_Core_BAO_EntityTag::getContactTags($contactId, true);
case 'rel':
require_once 'CRM/Contact/BAO/Relationship.php';
return count(CRM_Contact_BAO_Relationship::getRelationship($contactId));
case 'group':
require_once 'CRM/Contact/BAO/GroupContact.php';
return CRM_Contact_BAO_GroupContact::getContactGroup($contactId, null, null, true);
case 'log':
require_once 'CRM/Core/BAO/Log.php';
return CRM_Core_BAO_Log::getContactLogCount($contactId);
case 'note':
require_once 'CRM/Core/BAO/Note.php';
return CRM_Core_BAO_Note::getContactNoteCount($contactId);
case 'contribution':
require_once 'CRM/Contribute/BAO/Contribution.php';
return CRM_Contribute_BAO_Contribution::contributionCount($contactId);
case 'membership':
require_once 'CRM/Member/BAO/Membership.php';
return CRM_Member_BAO_Membership::getContactMembershipCount($contactId);
case 'participant':
require_once 'CRM/Event/BAO/Participant.php';
return CRM_Event_BAO_Participant::getContactParticipantCount($contactId);
case 'pledge':
require_once 'CRM/Pledge/BAO/Pledge.php';
return CRM_Pledge_BAO_Pledge::getContactPledgeCount($contactId);
case 'case':
require_once 'CRM/Case/BAO/Case.php';
return CRM_Case_BAO_Case::caseCount($contactId);
case 'grant':
require_once 'CRM/Grant/BAO/Grant.php';
return CRM_Grant_BAO_Grant::getContactGrantCount($contactId);
case 'activity':
require_once 'CRM/Activity/BAO/Activity.php';
return CRM_Activity_BAO_Activity::getActivitiesCount($contactId, false, null, null);
default:
$custom = explode('_', $component);
if ($custom['0'] = 'custom') {
require_once 'CRM/Core/DAO/CustomGroup.php';
if (!$tableName) {
$tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $custom['1'], 'table_name');
}
$queryString = "SELECT count(id) FROM {$tableName} WHERE entity_id = {$contactId}";
return CRM_Core_DAO::singleValueQuery($queryString);
}
}
}
示例8: getCountComponent
/**
* Given the component name and returns the count of participation of contact.
*
* @param string $component
* Input component name.
* @param int $contactId
* Input contact id.
* @param string $tableName
* Optional tableName if component is custom group.
*
* @return int
* total number in database
*/
public static function getCountComponent($component, $contactId, $tableName = NULL)
{
$object = NULL;
switch ($component) {
case 'tag':
return CRM_Core_BAO_EntityTag::getContactTags($contactId, TRUE);
case 'rel':
$result = CRM_Contact_BAO_Relationship::getRelationship($contactId, CRM_Contact_BAO_Relationship::CURRENT, 0, 1);
return $result;
case 'group':
return CRM_Contact_BAO_GroupContact::getContactGroup($contactId, "Added", NULL, TRUE);
case 'log':
if (CRM_Core_BAO_Log::useLoggingReport()) {
return FALSE;
}
return CRM_Core_BAO_Log::getContactLogCount($contactId);
case 'note':
return CRM_Core_BAO_Note::getContactNoteCount($contactId);
case 'contribution':
return CRM_Contribute_BAO_Contribution::contributionCount($contactId);
case 'membership':
return CRM_Member_BAO_Membership::getContactMembershipCount($contactId, TRUE);
case 'participant':
return CRM_Event_BAO_Participant::getContactParticipantCount($contactId);
case 'pledge':
return CRM_Pledge_BAO_Pledge::getContactPledgeCount($contactId);
case 'case':
return CRM_Case_BAO_Case::caseCount($contactId);
case 'grant':
return CRM_Grant_BAO_Grant::getContactGrantCount($contactId);
case 'activity':
$input = array('contact_id' => $contactId, 'admin' => FALSE, 'caseId' => NULL, 'context' => 'activity');
return CRM_Activity_BAO_Activity::getActivitiesCount($input);
case 'mailing':
$params = array('contact_id' => $contactId);
return CRM_Mailing_BAO_Mailing::getContactMailingsCount($params);
default:
$custom = explode('_', $component);
if ($custom['0'] = 'custom') {
if (!$tableName) {
$tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $custom['1'], 'table_name');
}
$queryString = "SELECT count(id) FROM {$tableName} WHERE entity_id = {$contactId}";
return CRM_Core_DAO::singleValueQuery($queryString);
}
}
}
示例9: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
require_once 'CRM/Grant/BAO/Grant.php';
CRM_Grant_BAO_Grant::del($this->_id);
return;
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$ids['grant'] = $this->_id;
}
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
if (!$params['grant_report_received']) {
$params['grant_report_received'] = "null";
}
// set the contact, when contact is selected
if (CRM_Utils_Array::value('contact_select_id', $params)) {
$this->_contactID = $params['contact_select_id'][1];
}
$params['contact_id'] = $this->_contactID;
$dates = array('application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
foreach ($dates as $d) {
$params[$d] = CRM_Utils_Date::processDate($params[$d], null, true);
}
$ids['note'] = array();
if ($this->_noteId) {
$ids['note']['id'] = $this->_noteId;
}
// process custom data
$customFields = CRM_Core_BAO_CustomField::getFields('Grant');
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Grant');
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_grant', $this->_id);
require_once 'CRM/Grant/BAO/Grant.php';
$grant = CRM_Grant_BAO_Grant::create($params, $ids);
$buttonName = $this->controller->getButtonName();
$session = CRM_Core_Session::singleton();
if ($this->_context == 'standalone') {
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/grant/add', 'reset=1&action=add&context=standalone'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=grant"));
}
} else {
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/grant', "reset=1&action=add&context=grant&cid={$this->_contactID}"));
}
}
}
示例10: array
static function &getFields()
{
$fields = array();
$fields = CRM_Grant_BAO_Grant::exportableFields();
return $fields;
}
示例11: setContext
function setContext()
{
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this);
$session = CRM_Core_Session::singleton();
$qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
//validate the qfKey
if (!CRM_Utils_Rule::qfKey($qfKey)) {
$qfKey = NULL;
}
switch ($context) {
case 'search':
$urlParams = 'force=1';
if ($qfKey) {
$urlParams .= "&qfKey={$qfKey}";
}
$this->assign('searchKey', $qfKey);
$url = CRM_Utils_System::url('civicrm/grant/search', $urlParams);
break;
case 'dashboard':
$url = CRM_Utils_System::url('civicrm/grant', 'reset=1');
break;
case 'edit':
$url = CRM_utils_System::url('civicrm/contact/view/grant', 'reset=1&id=' . $this->_id . '&cid=' . $this->_contactId . '&action=view&context=grant&selectedChild=grant');
break;
case 'grant':
$url = CRM_Utils_System::url('civicrm/contact/view', 'action=browse&selectedChild=grant&cid=' . $this->_contactId);
break;
case 'standalone':
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
break;
default:
$cid = NULL;
if ($this->_contactId) {
$cid = '&cid=' . $this->_contactId;
}
$url = CRM_Utils_System::url('civicrm/grant/search', 'reset=1&force=1' . $cid);
break;
}
$session->pushUserContext($url);
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
CRM_Grant_BAO_Grant::del($this->_id);
CRM_Utils_System::redirect($url);
}
}
示例12: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return void
*/
public function postProcess()
{
$updatedGrants = 0;
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
$qfKey = $params['qfKey'];
foreach ($params as $key => $value) {
if ($value == '' || $key == 'qfKey') {
unset($params[$key]);
}
}
if (!empty($params)) {
foreach ($params as $key => $value) {
$values[$key] = $value;
}
foreach ($this->_grantIds as $grantId) {
$ids['grant_id'] = $grantId;
CRM_Grant_BAO_Grant::add($values, $ids);
$updatedGrants++;
}
}
$status = ts('Updated Grant(s): %1 (Total Selected: %2)', array(1 => $updatedGrants, 2 => count($this->_grantIds)));
CRM_Core_Session::setStatus($status, '', 'info');
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/grant/search', 'force=1&qfKey=' . $qfKey));
}
示例13: setContext
function setContext()
{
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this);
$session =& CRM_Core_Session::singleton();
switch ($context) {
case 'search':
$url = CRM_Utils_System::url('civicrm/grant/search', 'force=1');
break;
case 'dashboard':
$url = CRM_Utils_System::url('civicrm/grant', 'reset=1');
break;
case 'edit':
$url = CRM_utils_System::url('civicrm/contact/view/grant', 'reset=1&id=' . $this->_id . '&cid=' . $this->_contactId . '&action=view&context=grant&selectedChild=grant');
break;
case 'grant':
$url = CRM_Utils_System::url('civicrm/contact/view', 'action=browse&selectedChild=grant&cid=' . $this->_contactId);
break;
case 'standalone':
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
break;
default:
$cid = null;
if ($this->_contactId) {
$cid = '&cid=' . $this->_contactId;
}
$url = CRM_Utils_System::url('civicrm/grant/search', 'reset=1&force=1' . $cid);
break;
}
$session->pushUserContext($url);
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
require_once 'CRM/Grant/BAO/Grant.php';
CRM_Grant_BAO_Grant::del($this->_id);
CRM_Utils_System::redirect($url);
}
}
示例14: getGrantStatuses
static function getGrantStatuses()
{
$og = CRM_Grant_BAO_Grant::getGrantStatusOptGroup();
require_once 'CRM/Core/BAO/OptionValue.php';
$dao = new CRM_Core_DAO_OptionValue();
$dao->option_group_id = $og->id;
$dao->find();
$statuses = array();
while ($dao->fetch()) {
$statuses[$dao->id] = $dao->label;
}
return $statuses;
}
示例15: buildMappingForm
//.........这里部分代码省略.........
foreach (CRM_Export_BAO_Export::componentPaymentFields() as $payField => $payTitle) {
$componentPaymentFields[$payField] = array('title' => $payTitle);
}
$fields['Participant'] = array_merge($fields['Participant'], $componentPaymentFields);
}
$compArray['Participant'] = ts('Participant');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::MEMBER_EXPORT) {
if (CRM_Core_Permission::access('CiviMember')) {
$fields['Membership'] = CRM_Member_BAO_Membership::getMembershipFields($exportMode);
unset($fields['Membership']['membership_contact_id']);
$compArray['Membership'] = ts('Membership');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::PLEDGE_EXPORT) {
if (CRM_Core_Permission::access('CiviPledge')) {
$fields['Pledge'] = CRM_Pledge_BAO_Pledge::exportableFields();
unset($fields['Pledge']['pledge_contact_id']);
$compArray['Pledge'] = ts('Pledge');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
if (CRM_Core_Permission::access('CiviCase')) {
$fields['Case'] = CRM_Case_BAO_Case::exportableFields();
$compArray['Case'] = ts('Case');
$fields['Activity'] = CRM_Activity_BAO_Activity::exportableFields('Case');
$compArray['Activity'] = ts('Case Activity');
unset($fields['Case']['case_contact_id']);
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::GRANT_EXPORT) {
if (CRM_Core_Permission::access('CiviGrant')) {
$fields['Grant'] = CRM_Grant_BAO_Grant::exportableFields();
unset($fields['Grant']['grant_contact_id']);
if ($mappingType == 'Search Builder') {
unset($fields['Grant']['grant_type_id']);
}
$compArray['Grant'] = ts('Grant');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
$fields['Activity'] = CRM_Activity_BAO_Activity::exportableFields('Activity');
$compArray['Activity'] = ts('Activity');
}
//Contact Sub Type For export
$contactSubTypes = array();
$subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($subTypes as $subType => $val) {
//adding subtype specific relationships CRM-5256
$csRelationships = array();
if ($mappingType == 'Export') {
$subTypeRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], FALSE, 'label', TRUE, $subType);
foreach ($subTypeRelationshipTypes as $key => $var) {
if (!array_key_exists($key, $fields[$val['parent']])) {
list($type) = explode('_', $key);
$csRelationships[$key]['title'] = $var;
$csRelationships[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/';
$csRelationships[$key]['export'] = TRUE;
$csRelationships[$key]['relationship_type_id'] = $type;
$csRelationships[$key]['related'] = TRUE;
$csRelationships[$key]['hasRelationType'] = 1;
}
}
}
$fields[$subType] = $fields[$val['parent']] + $csRelationships;