First commit
Bu işleme şunda yer alıyor:
işleme
c6e2478c40
13918 değiştirilmiş dosya ile 2303184 ekleme ve 0 silme
412
sites/all/modules/civicrm/CRM/Grant/BAO/Grant.php
Normal dosya
412
sites/all/modules/civicrm/CRM/Grant/BAO/Grant.php
Normal dosya
|
|
@ -0,0 +1,412 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
|
||||
|
||||
/**
|
||||
* Static field for all the grant information that we can potentially export.
|
||||
* @var array
|
||||
*/
|
||||
static $_exportableFields = NULL;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get events Summary.
|
||||
*
|
||||
*
|
||||
* @param bool $admin
|
||||
*
|
||||
* @return array
|
||||
* Array of event summary values
|
||||
*/
|
||||
public static function getGrantSummary($admin = FALSE) {
|
||||
$query = "
|
||||
SELECT status_id, count(id) as status_total
|
||||
FROM civicrm_grant GROUP BY status_id";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
$status = array();
|
||||
$summary = array();
|
||||
$summary['total_grants'] = NULL;
|
||||
$status = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
|
||||
|
||||
foreach ($status as $id => $name) {
|
||||
$stats[$id] = array(
|
||||
'label' => $name,
|
||||
'total' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$stats[$dao->status_id] = array(
|
||||
'label' => $status[$dao->status_id],
|
||||
'total' => $dao->status_total,
|
||||
);
|
||||
$summary['total_grants'] += $dao->status_total;
|
||||
}
|
||||
|
||||
$summary['per_status'] = $stats;
|
||||
return $summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get events Summary.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
* Array of event summary values
|
||||
*/
|
||||
public static function getGrantStatusOptGroup() {
|
||||
|
||||
$params = array();
|
||||
$params['name'] = CRM_Grant_BAO_Grant::$statusGroupName;
|
||||
|
||||
$defaults = array();
|
||||
|
||||
$og = CRM_Core_BAO_OptionGroup::retrieve($params, $defaults);
|
||||
if (!$og) {
|
||||
CRM_Core_Error::fatal('No option group for grant statuses - database discrepancy! Make sure you loaded civicrm_data.mysql');
|
||||
}
|
||||
|
||||
return $og;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch object based on array of properties.
|
||||
*
|
||||
* @param array $params
|
||||
* (reference ) an assoc array of name/value pairs.
|
||||
* @param array $defaults
|
||||
* (reference ) an assoc array to hold the flattened values.
|
||||
*
|
||||
* @return CRM_Grant_BAO_ManageGrant
|
||||
*/
|
||||
public static function retrieve(&$params, &$defaults) {
|
||||
$grant = new CRM_Grant_DAO_Grant();
|
||||
$grant->copyValues($params);
|
||||
if ($grant->find(TRUE)) {
|
||||
CRM_Core_DAO::storeValues($grant, $defaults);
|
||||
return $grant;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add grant.
|
||||
*
|
||||
* @param array $params
|
||||
* Reference array contains the values submitted by the form.
|
||||
* @param array $ids
|
||||
* Reference array contains the id.
|
||||
*
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function add(&$params, &$ids) {
|
||||
|
||||
if (!empty($ids['grant_id'])) {
|
||||
CRM_Utils_Hook::pre('edit', 'Grant', $ids['grant_id'], $params);
|
||||
}
|
||||
else {
|
||||
CRM_Utils_Hook::pre('create', 'Grant', NULL, $params);
|
||||
}
|
||||
|
||||
// first clean up all the money fields
|
||||
$moneyFields = array(
|
||||
'amount_total',
|
||||
'amount_granted',
|
||||
'amount_requested',
|
||||
);
|
||||
foreach ($moneyFields as $field) {
|
||||
if (isset($params[$field])) {
|
||||
$params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
|
||||
}
|
||||
}
|
||||
// convert dates to mysql format
|
||||
$dates = array(
|
||||
'application_received_date',
|
||||
'decision_date',
|
||||
'money_transfer_date',
|
||||
'grant_due_date',
|
||||
);
|
||||
|
||||
foreach ($dates as $d) {
|
||||
if (isset($params[$d])) {
|
||||
$params[$d] = CRM_Utils_Date::processDate($params[$d], NULL, TRUE);
|
||||
}
|
||||
}
|
||||
$grant = new CRM_Grant_DAO_Grant();
|
||||
$grant->id = CRM_Utils_Array::value('grant_id', $ids);
|
||||
|
||||
$grant->copyValues($params);
|
||||
|
||||
// set currency for CRM-1496
|
||||
if (!isset($grant->currency)) {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$grant->currency = $config->defaultCurrency;
|
||||
}
|
||||
|
||||
$result = $grant->save();
|
||||
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view/grant',
|
||||
"action=view&reset=1&id={$grant->id}&cid={$grant->contact_id}&context=home"
|
||||
);
|
||||
|
||||
$grantTypes = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
|
||||
if (empty($params['skipRecentView'])) {
|
||||
if (!isset($grant->contact_id) || !isset($grant->grant_type_id)) {
|
||||
$grant->find(TRUE);
|
||||
}
|
||||
$title = CRM_Contact_BAO_Contact::displayName($grant->contact_id) . ' - ' . ts('Grant') . ': ' . $grantTypes[$grant->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={$grant->id}&cid={$grant->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={$grant->id}&cid={$grant->contact_id}&context=home"
|
||||
);
|
||||
}
|
||||
|
||||
// add the recently created Grant
|
||||
CRM_Utils_Recent::add($title,
|
||||
$url,
|
||||
$grant->id,
|
||||
'Grant',
|
||||
$grant->contact_id,
|
||||
NULL,
|
||||
$recentOther
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($ids['grant'])) {
|
||||
CRM_Utils_Hook::post('edit', 'Grant', $grant->id, $grant);
|
||||
}
|
||||
else {
|
||||
CRM_Utils_Hook::post('create', 'Grant', $grant->id, $grant);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the event.
|
||||
*
|
||||
* @param array $params
|
||||
* Reference array contains the values submitted by the form.
|
||||
* @param array $ids
|
||||
* Reference array contains the id.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function create(&$params, &$ids) {
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
$grant = self::add($params, $ids);
|
||||
|
||||
if (is_a($grant, 'CRM_Core_Error')) {
|
||||
$transaction->rollback();
|
||||
return $grant;
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$id = $session->get('userID');
|
||||
if (!$id) {
|
||||
$id = CRM_Utils_Array::value('contact_id', $params);
|
||||
}
|
||||
if (!empty($params['note']) || CRM_Utils_Array::value('id', CRM_Utils_Array::value('note', $ids))) {
|
||||
$noteParams = array(
|
||||
'entity_table' => 'civicrm_grant',
|
||||
'note' => $params['note'] = $params['note'] ? $params['note'] : "null",
|
||||
'entity_id' => $grant->id,
|
||||
'contact_id' => $id,
|
||||
'modified_date' => date('Ymd'),
|
||||
);
|
||||
|
||||
CRM_Core_BAO_Note::add($noteParams, (array) CRM_Utils_Array::value('note', $ids));
|
||||
}
|
||||
// Log the information on successful add/edit of Grant
|
||||
$logParams = array(
|
||||
'entity_table' => 'civicrm_grant',
|
||||
'entity_id' => $grant->id,
|
||||
'modified_id' => $id,
|
||||
'modified_date' => date('Ymd'),
|
||||
);
|
||||
|
||||
CRM_Core_BAO_Log::add($logParams);
|
||||
|
||||
// add custom field values
|
||||
if (!empty($params['custom']) && is_array($params['custom'])) {
|
||||
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_grant', $grant->id);
|
||||
}
|
||||
|
||||
// check and attach and files as needed
|
||||
CRM_Core_BAO_File::processAttachment($params,
|
||||
'civicrm_grant',
|
||||
$grant->id
|
||||
);
|
||||
|
||||
$transaction->commit();
|
||||
|
||||
return $grant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the Contact.
|
||||
*
|
||||
* @param int $id
|
||||
* Contact id.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
public static function deleteContact($id) {
|
||||
$grant = new CRM_Grant_DAO_Grant();
|
||||
$grant->contact_id = $id;
|
||||
$grant->delete();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the grant.
|
||||
*
|
||||
* @param int $id
|
||||
* Grant id.
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public static function del($id) {
|
||||
CRM_Utils_Hook::pre('delete', 'Grant', $id, CRM_Core_DAO::$_nullArray);
|
||||
|
||||
$grant = new CRM_Grant_DAO_Grant();
|
||||
$grant->id = $id;
|
||||
|
||||
$grant->find();
|
||||
|
||||
// delete the recently created Grant
|
||||
$grantRecent = array(
|
||||
'id' => $id,
|
||||
'type' => 'Grant',
|
||||
);
|
||||
CRM_Utils_Recent::del($grantRecent);
|
||||
|
||||
if ($grant->fetch()) {
|
||||
$results = $grant->delete();
|
||||
CRM_Utils_Hook::post('delete', 'Grant', $grant->id, $grant);
|
||||
return $results;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine all the exportable fields from the lower levels object.
|
||||
*
|
||||
* @return array
|
||||
* array of exportable Fields
|
||||
*/
|
||||
public static function &exportableFields() {
|
||||
if (!self::$_exportableFields) {
|
||||
if (!self::$_exportableFields) {
|
||||
self::$_exportableFields = array();
|
||||
}
|
||||
|
||||
$grantFields = array(
|
||||
'grant_status' => array(
|
||||
'title' => ts('Grant Status'),
|
||||
'name' => 'grant_status',
|
||||
'data_type' => CRM_Utils_Type::T_STRING,
|
||||
),
|
||||
'grant_type' => array(
|
||||
'title' => ts('Grant Type'),
|
||||
'name' => 'grant_type',
|
||||
'data_type' => CRM_Utils_Type::T_STRING,
|
||||
),
|
||||
'grant_money_transfer_date' => array(
|
||||
'title' => ts('Grant Money Transfer Date'),
|
||||
'name' => 'grant_money_transfer_date',
|
||||
'data_type' => CRM_Utils_Type::T_DATE,
|
||||
),
|
||||
'grant_amount_requested' => array(
|
||||
'title' => ts('Grant Amount Requested'),
|
||||
'name' => 'grant_amount_requested',
|
||||
'data_type' => CRM_Utils_Type::T_FLOAT,
|
||||
),
|
||||
'grant_application_received_date' => array(
|
||||
'title' => ts('Grant Application Received Date'),
|
||||
'name' => 'grant_application_received_date',
|
||||
'data_type' => CRM_Utils_Type::T_DATE,
|
||||
),
|
||||
);
|
||||
|
||||
$fields = CRM_Grant_DAO_Grant::export();
|
||||
$grantNote = array(
|
||||
'grant_note' => array(
|
||||
'title' => ts('Grant Note'),
|
||||
'name' => 'grant_note',
|
||||
'data_type' => CRM_Utils_Type::T_TEXT,
|
||||
),
|
||||
);
|
||||
$fields = array_merge($fields, $grantFields, $grantNote,
|
||||
CRM_Core_BAO_CustomField::getFieldsForImport('Grant')
|
||||
);
|
||||
self::$_exportableFields = $fields;
|
||||
}
|
||||
|
||||
return self::$_exportableFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get grant record count for a Contact.
|
||||
*
|
||||
* @param int $contactID
|
||||
*
|
||||
* @return int
|
||||
* count of grant records
|
||||
*/
|
||||
public static function getContactGrantCount($contactID) {
|
||||
$query = "SELECT count(*) FROM civicrm_grant WHERE civicrm_grant.contact_id = {$contactID} ";
|
||||
return CRM_Core_DAO::singleValueQuery($query);
|
||||
}
|
||||
|
||||
}
|
||||
353
sites/all/modules/civicrm/CRM/Grant/BAO/Query.php
Normal dosya
353
sites/all/modules/civicrm/CRM/Grant/BAO/Query.php
Normal dosya
|
|
@ -0,0 +1,353 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_BAO_Query extends CRM_Core_BAO_Query {
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function &getFields() {
|
||||
$fields = array();
|
||||
$fields = CRM_Grant_BAO_Grant::exportableFields();
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build select for CiviGrant.
|
||||
*
|
||||
* @param $query
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function select(&$query) {
|
||||
if (!empty($query->_returnProperties['grant_status_id'])) {
|
||||
$query->_select['grant_status_id'] = 'grant_status.id as grant_status_id';
|
||||
$query->_element['grant_status'] = 1;
|
||||
$query->_tables['grant_status'] = $query->_whereTables['grant_status'] = 1;
|
||||
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['grant_status'])) {
|
||||
$query->_select['grant_status'] = 'grant_status.label as grant_status';
|
||||
$query->_element['grant_status'] = 1;
|
||||
$query->_tables['grant_status'] = $query->_whereTables['grant_status'] = 1;
|
||||
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['grant_type_id'])) {
|
||||
$query->_select['grant_type_id'] = 'grant_type.id as grant_type_id';
|
||||
$query->_element['grant_type'] = 1;
|
||||
$query->_tables['grant_type'] = $query->_whereTables['grant_type'] = 1;
|
||||
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['grant_type'])) {
|
||||
$query->_select['grant_type'] = 'grant_type.label as grant_type';
|
||||
$query->_element['grant_type'] = 1;
|
||||
$query->_tables['grant_type'] = $query->_whereTables['grant_type'] = 1;
|
||||
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['grant_note'])) {
|
||||
$query->_select['grant_note'] = "civicrm_note.note as grant_note";
|
||||
$query->_element['grant_note'] = 1;
|
||||
$query->_tables['grant_note'] = 1;
|
||||
}
|
||||
|
||||
if ($query->_mode & CRM_Contact_BAO_Query::MODE_GRANT) {
|
||||
$query->_select['grant_amount_requested'] = 'civicrm_grant.amount_requested as grant_amount_requested';
|
||||
$query->_select['grant_amount_granted'] = 'civicrm_grant.amount_granted as grant_amount_granted';
|
||||
$query->_select['grant_amount_total'] = 'civicrm_grant.amount_total as grant_amount_total';
|
||||
$query->_select['grant_application_received_date'] = 'civicrm_grant.application_received_date as grant_application_received_date ';
|
||||
$query->_select['grant_report_received'] = 'civicrm_grant.grant_report_received as grant_report_received';
|
||||
$query->_select['grant_money_transfer_date'] = 'civicrm_grant.money_transfer_date as grant_money_transfer_date';
|
||||
$query->_element['grant_type_id'] = 1;
|
||||
$query->_element['grant_status_id'] = 1;
|
||||
$query->_tables['civicrm_grant'] = 1;
|
||||
$query->_whereTables['civicrm_grant'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a list of conditions in params generate the required.
|
||||
* where clause
|
||||
*
|
||||
* @param $query
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function where(&$query) {
|
||||
foreach ($query->_params as $id => $values) {
|
||||
if (!is_array($values) || count($values) != 5) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (substr($values[0], 0, 6) == 'grant_') {
|
||||
self::whereClauseSingle($values, $query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $values
|
||||
* @param $query
|
||||
*/
|
||||
public static function whereClauseSingle(&$values, &$query) {
|
||||
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
|
||||
list($name, $op, $value, $grouping, $wildcard) = $values;
|
||||
$val = $names = array();
|
||||
switch ($name) {
|
||||
case 'grant_money_transfer_date_low':
|
||||
case 'grant_money_transfer_date_high':
|
||||
$query->dateQueryBuilder($values, 'civicrm_grant',
|
||||
'grant_money_transfer_date', 'money_transfer_date',
|
||||
'Money Transfer Date'
|
||||
);
|
||||
return;
|
||||
|
||||
case 'grant_money_transfer_date_notset':
|
||||
$query->_where[$grouping][] = "civicrm_grant.money_transfer_date IS NULL";
|
||||
$query->_qill[$grouping][] = ts("Grant Money Transfer Date is NULL");
|
||||
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
|
||||
return;
|
||||
|
||||
case 'grant_application_received_date_low':
|
||||
case 'grant_application_received_date_high':
|
||||
$query->dateQueryBuilder($values, 'civicrm_grant',
|
||||
'grant_application_received_date',
|
||||
'application_received_date', 'Application Received Date'
|
||||
);
|
||||
return;
|
||||
|
||||
case 'grant_application_received_notset':
|
||||
$query->_where[$grouping][] = "civicrm_grant.application_received_date IS NULL";
|
||||
$query->_qill[$grouping][] = ts("Grant Application Received Date is NULL");
|
||||
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
|
||||
return;
|
||||
|
||||
case 'grant_due_date_low':
|
||||
case 'grant_due_date_high':
|
||||
$query->dateQueryBuilder($values, 'civicrm_grant',
|
||||
'grant_due_date',
|
||||
'grant_due_date', 'Grant Due Date'
|
||||
);
|
||||
return;
|
||||
|
||||
case 'grant_due_date_notset':
|
||||
$query->_where[$grouping][] = "civicrm_grant.grant_due_date IS NULL";
|
||||
$query->_qill[$grouping][] = ts("Grant Due Date is NULL");
|
||||
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
|
||||
return;
|
||||
|
||||
case 'grant_decision_date_low':
|
||||
case 'grant_decision_date_high':
|
||||
$query->dateQueryBuilder($values, 'civicrm_grant',
|
||||
'grant_decision_date',
|
||||
'decision_date', 'Grant Decision Date'
|
||||
);
|
||||
return;
|
||||
|
||||
case 'grant_decision_date_notset':
|
||||
$query->_where[$grouping][] = "civicrm_grant.decision_date IS NULL";
|
||||
$query->_qill[$grouping][] = ts("Grant Decision Date is NULL");
|
||||
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
|
||||
return;
|
||||
|
||||
case 'grant_type_id':
|
||||
case 'grant_type':
|
||||
case 'grant_status_id':
|
||||
case 'grant_status':
|
||||
|
||||
if (strstr($name, 'type')) {
|
||||
$name = 'grant_type_id';
|
||||
$label = 'Grant Type(s)';
|
||||
}
|
||||
else {
|
||||
$name = 'status_id';
|
||||
$label = 'Grant Status(s)';
|
||||
}
|
||||
|
||||
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_grant.$name", $op, $value, "Integer");
|
||||
|
||||
list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Grant_DAO_Grant', $name, $value, $op);
|
||||
$query->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $label, 2 => $qillop, 3 => $qillVal));
|
||||
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
|
||||
|
||||
return;
|
||||
|
||||
case 'grant_report_received':
|
||||
|
||||
if ($value == 1) {
|
||||
$yesNo = 'Yes';
|
||||
$query->_where[$grouping][] = "civicrm_grant.grant_report_received $op $value";
|
||||
}
|
||||
elseif ($value == 0) {
|
||||
$yesNo = 'No';
|
||||
$query->_where[$grouping][] = "civicrm_grant.grant_report_received IS NULL";
|
||||
}
|
||||
|
||||
$query->_qill[$grouping][] = "Grant Report Received = $yesNo ";
|
||||
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
|
||||
|
||||
return;
|
||||
|
||||
case 'grant_amount':
|
||||
case 'grant_amount_low':
|
||||
case 'grant_amount_high':
|
||||
$query->numberRangeBuilder($values,
|
||||
'civicrm_grant', 'grant_amount', 'amount_total', 'Total Amount'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param $mode
|
||||
* @param $side
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public static function from($name, $mode, $side) {
|
||||
$from = NULL;
|
||||
switch ($name) {
|
||||
case 'civicrm_grant':
|
||||
$from = " $side JOIN civicrm_grant ON civicrm_grant.contact_id = contact_a.id ";
|
||||
break;
|
||||
|
||||
case 'grant_status':
|
||||
$from .= " $side JOIN civicrm_option_group option_group_grant_status ON (option_group_grant_status.name = 'grant_status')";
|
||||
$from .= " $side JOIN civicrm_option_value grant_status ON (civicrm_grant.status_id = grant_status.value AND option_group_grant_status.id = grant_status.option_group_id ) ";
|
||||
break;
|
||||
|
||||
case 'grant_type':
|
||||
$from .= " $side JOIN civicrm_option_group option_group_grant_type ON (option_group_grant_type.name = 'grant_type')";
|
||||
if ($mode & CRM_Contact_BAO_Query::MODE_GRANT) {
|
||||
$from .= " INNER JOIN civicrm_option_value grant_type ON (civicrm_grant.grant_type_id = grant_type.value AND option_group_grant_type.id = grant_type.option_group_id ) ";
|
||||
}
|
||||
else {
|
||||
$from .= " $side JOIN civicrm_option_value grant_type ON (civicrm_grant.grant_type_id = grant_type.value AND option_group_grant_type.id = grant_type.option_group_id ) ";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'grant_note':
|
||||
$from .= " $side JOIN civicrm_note ON ( civicrm_note.entity_table = 'civicrm_grant' AND
|
||||
civicrm_grant.id = civicrm_note.entity_id )";
|
||||
break;
|
||||
}
|
||||
return $from;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $mode
|
||||
* @param bool $includeCustomFields
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public static function defaultReturnProperties(
|
||||
$mode,
|
||||
$includeCustomFields = TRUE
|
||||
) {
|
||||
$properties = NULL;
|
||||
if ($mode & CRM_Contact_BAO_Query::MODE_GRANT) {
|
||||
$properties = array(
|
||||
'contact_type' => 1,
|
||||
'contact_sub_type' => 1,
|
||||
'sort_name' => 1,
|
||||
'grant_id' => 1,
|
||||
'grant_type' => 1,
|
||||
'grant_status' => 1,
|
||||
'grant_amount_requested' => 1,
|
||||
'grant_application_received_date' => 1,
|
||||
'grant_report_received' => 1,
|
||||
'grant_money_transfer_date' => 1,
|
||||
'grant_note' => 1,
|
||||
);
|
||||
}
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the elements shared between grant search and advanaced search.
|
||||
*
|
||||
*
|
||||
* @param CRM_Core_Form $form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function buildSearchForm(&$form) {
|
||||
|
||||
$grantType = CRM_Core_OptionGroup::values('grant_type');
|
||||
$form->add('select', 'grant_type_id', ts('Grant Type'), $grantType, FALSE,
|
||||
array('id' => 'grant_type_id', 'multiple' => 'multiple', 'class' => 'crm-select2')
|
||||
);
|
||||
|
||||
$grantStatus = CRM_Core_OptionGroup::values('grant_status');
|
||||
$form->add('select', 'grant_status_id', ts('Grant Status'), $grantStatus, FALSE,
|
||||
array('id' => 'grant_status_id', 'multiple' => 'multiple', 'class' => 'crm-select2')
|
||||
);
|
||||
|
||||
$form->addDate('grant_application_received_date_low', ts('App. Received Date - From'), FALSE, array('formatType' => 'searchDate'));
|
||||
$form->addDate('grant_application_received_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
|
||||
|
||||
$form->addElement('checkbox', 'grant_application_received_notset', '', NULL);
|
||||
|
||||
$form->addDate('grant_money_transfer_date_low', ts('Money Sent Date - From'), FALSE, array('formatType' => 'searchDate'));
|
||||
$form->addDate('grant_money_transfer_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
|
||||
|
||||
$form->addElement('checkbox', 'grant_money_transfer_date_notset', '', NULL);
|
||||
|
||||
$form->addDate('grant_due_date_low', ts('Report Due Date - From'), FALSE, array('formatType' => 'searchDate'));
|
||||
$form->addDate('grant_due_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
|
||||
|
||||
$form->addElement('checkbox', 'grant_due_date_notset', '', NULL);
|
||||
|
||||
$form->addDate('grant_decision_date_low', ts('Grant Decision Date - From'), FALSE, array('formatType' => 'searchDate'));
|
||||
$form->addDate('grant_decision_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
|
||||
|
||||
$form->addElement('checkbox', 'grant_decision_date_notset', '', NULL);
|
||||
|
||||
$form->addYesNo('grant_report_received', ts('Grant report received?'), TRUE);
|
||||
|
||||
$form->add('text', 'grant_amount_low', ts('Minimum Amount'), array('size' => 8, 'maxlength' => 8));
|
||||
$form->addRule('grant_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
|
||||
|
||||
$form->add('text', 'grant_amount_high', ts('Maximum Amount'), array('size' => 8, 'maxlength' => 8));
|
||||
$form->addRule('grant_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
|
||||
|
||||
self::addCustomFormFields($form, array('Grant'));
|
||||
|
||||
$form->assign('validGrant', TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
70
sites/all/modules/civicrm/CRM/Grant/Controller/Search.php
Normal dosya
70
sites/all/modules/civicrm/CRM/Grant/Controller/Search.php
Normal dosya
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used by the Search functionality.
|
||||
*
|
||||
* - the search controller is used for building/processing multiform
|
||||
* searches.
|
||||
*
|
||||
* Typically the first form will display the search criteria and its results
|
||||
*
|
||||
* The second form is used to process search results with the associated actions
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_Controller_Search extends CRM_Core_Controller {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param string $title
|
||||
* @param bool|int $action
|
||||
* @param bool $modal
|
||||
*/
|
||||
public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE) {
|
||||
|
||||
parent::__construct($title, $modal);
|
||||
|
||||
$this->_stateMachine = new CRM_Grant_StateMachine_Search($this, $action);
|
||||
|
||||
// create and instantiate the pages
|
||||
$this->addPages($this->_stateMachine, $action);
|
||||
|
||||
// add all the actions
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$this->addActions();
|
||||
}
|
||||
|
||||
}
|
||||
534
sites/all/modules/civicrm/CRM/Grant/DAO/Grant.php
Normal dosya
534
sites/all/modules/civicrm/CRM/Grant/DAO/Grant.php
Normal dosya
|
|
@ -0,0 +1,534 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Grant/Grant.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:600fc71093543f1c7b31ad663f2325c6)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Grant_DAO_Grant constructor.
|
||||
*/
|
||||
class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_grant';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = true;
|
||||
/**
|
||||
* Unique Grant id
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Contact ID of contact record given grant belongs to.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $contact_id;
|
||||
/**
|
||||
* Date on which grant application was received by donor.
|
||||
*
|
||||
* @var date
|
||||
*/
|
||||
public $application_received_date;
|
||||
/**
|
||||
* Date on which grant decision was made.
|
||||
*
|
||||
* @var date
|
||||
*/
|
||||
public $decision_date;
|
||||
/**
|
||||
* Date on which grant money transfer was made.
|
||||
*
|
||||
* @var date
|
||||
*/
|
||||
public $money_transfer_date;
|
||||
/**
|
||||
* Date on which grant report is due.
|
||||
*
|
||||
* @var date
|
||||
*/
|
||||
public $grant_due_date;
|
||||
/**
|
||||
* Yes/No field stating whether grant report was received by donor.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $grant_report_received;
|
||||
/**
|
||||
* Type of grant. Implicit FK to civicrm_option_value in grant_type option_group.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $grant_type_id;
|
||||
/**
|
||||
* Requested grant amount, in default currency.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public $amount_total;
|
||||
/**
|
||||
* Requested grant amount, in original currency (optional).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public $amount_requested;
|
||||
/**
|
||||
* Granted amount, in default currency.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public $amount_granted;
|
||||
/**
|
||||
* 3 character string, value from config setting or input via user.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $currency;
|
||||
/**
|
||||
* Grant rationale.
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $rationale;
|
||||
/**
|
||||
* Id of Grant status.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $status_id;
|
||||
/**
|
||||
* FK to Financial Type.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $financial_type_id;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_grant';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_type_id', 'civicrm_financial_type', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'grant_id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Grant ID') ,
|
||||
'description' => 'Unique Grant id',
|
||||
'required' => true,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_grant.id',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'grant_contact_id' => array(
|
||||
'name' => 'contact_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Contact ID') ,
|
||||
'description' => 'Contact ID of contact record given grant belongs to.',
|
||||
'required' => true,
|
||||
'export' => true,
|
||||
'where' => 'civicrm_grant.contact_id',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
'html' => array(
|
||||
'type' => 'EntityRef',
|
||||
) ,
|
||||
) ,
|
||||
'application_received_date' => array(
|
||||
'name' => 'application_received_date',
|
||||
'type' => CRM_Utils_Type::T_DATE,
|
||||
'title' => ts('Application received date') ,
|
||||
'description' => 'Date on which grant application was received by donor.',
|
||||
'export' => true,
|
||||
'where' => 'civicrm_grant.application_received_date',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'decision_date' => array(
|
||||
'name' => 'decision_date',
|
||||
'type' => CRM_Utils_Type::T_DATE,
|
||||
'title' => ts('Decision date') ,
|
||||
'description' => 'Date on which grant decision was made.',
|
||||
'import' => true,
|
||||
'where' => 'civicrm_grant.decision_date',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select Date',
|
||||
) ,
|
||||
) ,
|
||||
'grant_money_transfer_date' => array(
|
||||
'name' => 'money_transfer_date',
|
||||
'type' => CRM_Utils_Type::T_DATE,
|
||||
'title' => ts('Grant Money transfer date') ,
|
||||
'description' => 'Date on which grant money transfer was made.',
|
||||
'import' => true,
|
||||
'where' => 'civicrm_grant.money_transfer_date',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select Date',
|
||||
) ,
|
||||
) ,
|
||||
'grant_due_date' => array(
|
||||
'name' => 'grant_due_date',
|
||||
'type' => CRM_Utils_Type::T_DATE,
|
||||
'title' => ts('Grant Due Date') ,
|
||||
'description' => 'Date on which grant report is due.',
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select Date',
|
||||
) ,
|
||||
) ,
|
||||
'grant_report_received' => array(
|
||||
'name' => 'grant_report_received',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Grant report received') ,
|
||||
'description' => 'Yes/No field stating whether grant report was received by donor.',
|
||||
'import' => true,
|
||||
'where' => 'civicrm_grant.grant_report_received',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'CheckBox',
|
||||
) ,
|
||||
) ,
|
||||
'grant_type_id' => array(
|
||||
'name' => 'grant_type_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Grant Type') ,
|
||||
'description' => 'Type of grant. Implicit FK to civicrm_option_value in grant_type option_group.',
|
||||
'required' => true,
|
||||
'export' => true,
|
||||
'where' => 'civicrm_grant.grant_type_id',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'grant_type',
|
||||
'optionEditPath' => 'civicrm/admin/options/grant_type',
|
||||
)
|
||||
) ,
|
||||
'amount_total' => array(
|
||||
'name' => 'amount_total',
|
||||
'type' => CRM_Utils_Type::T_MONEY,
|
||||
'title' => ts('Total Amount') ,
|
||||
'description' => 'Requested grant amount, in default currency.',
|
||||
'required' => true,
|
||||
'precision' => array(
|
||||
20,
|
||||
2
|
||||
) ,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_grant.amount_total',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '/^\d+(\.\d{2})?$/',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'amount_requested' => array(
|
||||
'name' => 'amount_requested',
|
||||
'type' => CRM_Utils_Type::T_MONEY,
|
||||
'title' => ts('Amount Requested') ,
|
||||
'description' => 'Requested grant amount, in original currency (optional).',
|
||||
'precision' => array(
|
||||
20,
|
||||
2
|
||||
) ,
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'amount_granted' => array(
|
||||
'name' => 'amount_granted',
|
||||
'type' => CRM_Utils_Type::T_MONEY,
|
||||
'title' => ts('Amount granted') ,
|
||||
'description' => 'Granted amount, in default currency.',
|
||||
'precision' => array(
|
||||
20,
|
||||
2
|
||||
) ,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_grant.amount_granted',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '/^\d+(\.\d{2})?$/',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'currency' => array(
|
||||
'name' => 'currency',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Grant Currency') ,
|
||||
'description' => '3 character string, value from config setting or input via user.',
|
||||
'required' => true,
|
||||
'maxlength' => 3,
|
||||
'size' => CRM_Utils_Type::FOUR,
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'table' => 'civicrm_currency',
|
||||
'keyColumn' => 'name',
|
||||
'labelColumn' => 'full_name',
|
||||
'nameColumn' => 'name',
|
||||
)
|
||||
) ,
|
||||
'rationale' => array(
|
||||
'name' => 'rationale',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Grant Rationale') ,
|
||||
'description' => 'Grant rationale.',
|
||||
'rows' => 4,
|
||||
'cols' => 60,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_grant.rationale',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'TextArea',
|
||||
) ,
|
||||
) ,
|
||||
'grant_status_id' => array(
|
||||
'name' => 'status_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Grant Status') ,
|
||||
'description' => 'Id of Grant status.',
|
||||
'required' => true,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_grant.status_id',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'export' => false,
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'grant_status',
|
||||
'optionEditPath' => 'civicrm/admin/options/grant_status',
|
||||
)
|
||||
) ,
|
||||
'financial_type_id' => array(
|
||||
'name' => 'financial_type_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Financial Type') ,
|
||||
'description' => 'FK to Financial Type.',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_grant',
|
||||
'entity' => 'Grant',
|
||||
'bao' => 'CRM_Grant_BAO_Grant',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Financial_DAO_FinancialType',
|
||||
'pseudoconstant' => array(
|
||||
'table' => 'civicrm_financial_type',
|
||||
'keyColumn' => 'id',
|
||||
'labelColumn' => 'name',
|
||||
)
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'grant', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'grant', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array(
|
||||
'index_grant_type_id' => array(
|
||||
'name' => 'index_grant_type_id',
|
||||
'field' => array(
|
||||
0 => 'grant_type_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_grant::0::grant_type_id',
|
||||
) ,
|
||||
'index_status_id' => array(
|
||||
'name' => 'index_status_id',
|
||||
'field' => array(
|
||||
0 => 'status_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_grant::0::status_id',
|
||||
) ,
|
||||
);
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
||||
326
sites/all/modules/civicrm/CRM/Grant/Form/Grant.php
Normal dosya
326
sites/all/modules/civicrm/CRM/Grant/Form/Grant.php
Normal dosya
|
|
@ -0,0 +1,326 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for processing a case
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_Form_Grant extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* The id of the case that we are proceessing.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_id;
|
||||
|
||||
/**
|
||||
* The id of the contact associated with this contribution.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_contactID;
|
||||
|
||||
protected $_context;
|
||||
|
||||
/**
|
||||
* Explicitly declare the entity api name.
|
||||
*/
|
||||
public function getDefaultEntity() {
|
||||
return 'Grant';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
|
||||
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
|
||||
$this->_grantType = NULL;
|
||||
if ($this->_id) {
|
||||
$this->_grantType = CRM_Core_DAO::getFieldValue('CRM_Grant_DAO_Grant', $this->_id, 'grant_type_id');
|
||||
}
|
||||
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
|
||||
$this->assign('action', $this->_action);
|
||||
$this->assign('context', $this->_context);
|
||||
|
||||
//check permission for action.
|
||||
if (!CRM_Core_Permission::checkActionPermission('CiviGrant', $this->_action)) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
|
||||
$this->setPageTitle(ts('Grant'));
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_noteId = NULL;
|
||||
if ($this->_id) {
|
||||
$noteDAO = new CRM_Core_BAO_Note();
|
||||
$noteDAO->entity_table = 'civicrm_grant';
|
||||
$noteDAO->entity_id = $this->_id;
|
||||
if ($noteDAO->find(TRUE)) {
|
||||
$this->_noteId = $noteDAO->id;
|
||||
}
|
||||
}
|
||||
|
||||
// when custom data is included in this page
|
||||
if (!empty($_POST['hidden_custom'])) {
|
||||
$grantTypeId = empty($_POST['grant_type_id']) ? NULL : $_POST['grant_type_id'];
|
||||
$this->set('type', 'Grant');
|
||||
$this->set('subType', $grantTypeId);
|
||||
$this->set('entityId', $this->_id);
|
||||
CRM_Custom_Form_CustomData::preProcess($this, NULL, $grantTypeId, 1, 'Grant', $this->_id);
|
||||
CRM_Custom_Form_CustomData::buildQuickForm($this);
|
||||
CRM_Custom_Form_CustomData::setDefaultValues($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
|
||||
$defaults = parent::setDefaultValues();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
$params['id'] = $this->_id;
|
||||
if ($this->_noteId) {
|
||||
$defaults['note'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note');
|
||||
}
|
||||
if ($this->_id) {
|
||||
CRM_Grant_BAO_Grant::retrieve($params, $defaults);
|
||||
|
||||
// fix the display of the monetary value, CRM-4038
|
||||
if (isset($defaults['amount_total'])) {
|
||||
$defaults['amount_total'] = CRM_Utils_Money::format($defaults['amount_total'], NULL, '%a');
|
||||
}
|
||||
if (isset($defaults['amount_requested'])) {
|
||||
$defaults['amount_requested'] = CRM_Utils_Money::format($defaults['amount_requested'], NULL, '%a');
|
||||
}
|
||||
if (isset($defaults['amount_granted'])) {
|
||||
$defaults['amount_granted'] = CRM_Utils_Money::format($defaults['amount_granted'], NULL, '%a');
|
||||
}
|
||||
|
||||
$dates = array(
|
||||
'application_received_date',
|
||||
'decision_date',
|
||||
'money_transfer_date',
|
||||
'grant_due_date',
|
||||
);
|
||||
|
||||
foreach ($dates as $key) {
|
||||
if (!empty($defaults[$key])) {
|
||||
list($defaults[$key]) = CRM_Utils_Date::setDateDefaults($defaults[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
list($defaults['application_received_date']) = CRM_Utils_Date::setDateDefaults();
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Delete'),
|
||||
'spacing' => ' ',
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = CRM_Core_DAO::getAttribute('CRM_Grant_DAO_Grant');
|
||||
$this->addSelect('grant_type_id', array('onChange' => "CRM.buildCustomData( 'Grant', this.value );"), TRUE);
|
||||
|
||||
//need to assign custom data type and subtype to the template
|
||||
$this->assign('customDataType', 'Grant');
|
||||
$this->assign('customDataSubType', $this->_grantType);
|
||||
$this->assign('entityID', $this->_id);
|
||||
|
||||
$this->addSelect('status_id', array(), TRUE);
|
||||
|
||||
$this->addDate('application_received_date', ts('Application Received'), FALSE, array('formatType' => 'custom'));
|
||||
$this->addDate('decision_date', ts('Grant Decision'), FALSE, array('formatType' => 'custom'));
|
||||
$this->addDate('money_transfer_date', ts('Money Transferred'), FALSE, array('formatType' => 'custom'));
|
||||
$this->addDate('grant_due_date', ts('Grant Report Due'), FALSE, array('formatType' => 'custom'));
|
||||
|
||||
$this->addElement('checkbox', 'grant_report_received', ts('Grant Report Received?'), NULL);
|
||||
$this->add('textarea', 'rationale', ts('Rationale'), $attributes['rationale']);
|
||||
$this->add('text', 'amount_total', ts('Amount Requested'), NULL, TRUE);
|
||||
$this->addRule('amount_total', ts('Please enter a valid amount.'), 'money');
|
||||
|
||||
$this->add('text', 'amount_granted', ts('Amount Granted'));
|
||||
$this->addRule('amount_granted', ts('Please enter a valid amount.'), 'money');
|
||||
|
||||
$this->add('text', 'amount_requested', ts('Amount Requested<br />(original currency)'));
|
||||
$this->addRule('amount_requested', ts('Please enter a valid amount.'), 'money');
|
||||
|
||||
$noteAttrib = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
|
||||
$this->add('textarea', 'note', ts('Notes'), $noteAttrib['note']);
|
||||
|
||||
// add attachments part
|
||||
CRM_Core_BAO_File::buildAttachment($this,
|
||||
'civicrm_grant',
|
||||
$this->_id
|
||||
);
|
||||
|
||||
// make this form an upload since we dont know if the custom data injected dynamically
|
||||
// is of type file etc $uploadNames = $this->get( 'uploadNames' );
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'upload',
|
||||
'name' => ts('Save'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'upload',
|
||||
'name' => ts('Save and New'),
|
||||
'js' => array('onclick' => "return verify( );"),
|
||||
'subName' => 'new',
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if ($this->_context == 'standalone') {
|
||||
$this->addEntityRef('contact_id', ts('Applicant'), array('create' => TRUE), TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Grant_BAO_Grant::del($this->_id);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$ids['grant_id'] = $this->_id;
|
||||
}
|
||||
|
||||
// get the submitted form values.
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
if (empty($params['grant_report_received'])) {
|
||||
$params['grant_report_received'] = "null";
|
||||
}
|
||||
|
||||
// set the contact, when contact is selected
|
||||
if ($this->_context == 'standalone') {
|
||||
$this->_contactID = $params['contact_id'];
|
||||
}
|
||||
|
||||
$params['contact_id'] = $this->_contactID;
|
||||
$ids['note'] = array();
|
||||
if ($this->_noteId) {
|
||||
$ids['note']['id'] = $this->_noteId;
|
||||
}
|
||||
|
||||
// build custom data getFields array
|
||||
$customFieldsGrantType = CRM_Core_BAO_CustomField::getFields('Grant', FALSE, FALSE,
|
||||
CRM_Utils_Array::value('grant_type_id', $params)
|
||||
);
|
||||
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsGrantType,
|
||||
CRM_Core_BAO_CustomField::getFields('Grant', FALSE, FALSE, NULL, NULL, TRUE)
|
||||
);
|
||||
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params,
|
||||
$this->_id,
|
||||
'Grant'
|
||||
);
|
||||
|
||||
// add attachments as needed
|
||||
CRM_Core_BAO_File::formatAttachment($params,
|
||||
$params,
|
||||
'civicrm_grant',
|
||||
$this->_id
|
||||
);
|
||||
|
||||
$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"
|
||||
));
|
||||
}
|
||||
}
|
||||
elseif ($buttonName == $this->getButtonName('upload', 'new')) {
|
||||
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/grant',
|
||||
"reset=1&action=add&context=grant&cid={$this->_contactID}"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
145
sites/all/modules/civicrm/CRM/Grant/Form/GrantView.php
Normal dosya
145
sites/all/modules/civicrm/CRM/Grant/Form/GrantView.php
Normal dosya
|
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for processing a Grant
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_Form_GrantView extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
CRM_Grant_BAO_Grant::retrieve($params, $values);
|
||||
$grantType = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
|
||||
$grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
|
||||
$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)) {
|
||||
$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
|
||||
$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
|
||||
);
|
||||
|
||||
$attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
|
||||
$this->assign('attachment', $attachment);
|
||||
|
||||
$grantType = CRM_Core_DAO::getFieldValue("CRM_Grant_DAO_Grant", $this->_id, "grant_type_id");
|
||||
$groupTree = CRM_Core_BAO_CustomGroup::getTree("Grant", NULL, $this->_id, 0, $grantType);
|
||||
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id);
|
||||
|
||||
$this->assign('id', $this->_id);
|
||||
|
||||
$this->setPageTitle(ts('Grant'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Done'),
|
||||
'spacing' => ' ',
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
322
sites/all/modules/civicrm/CRM/Grant/Form/Search.php
Normal dosya
322
sites/all/modules/civicrm/CRM/Grant/Form/Search.php
Normal dosya
|
|
@ -0,0 +1,322 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Files required
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file is for civigrant search
|
||||
*/
|
||||
class CRM_Grant_Form_Search extends CRM_Core_Form_Search {
|
||||
|
||||
/**
|
||||
* The params that are sent to the query.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_queryParams;
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_limit = NULL;
|
||||
|
||||
/**
|
||||
* Prefix for the controller.
|
||||
*/
|
||||
protected $_prefix = "grant_";
|
||||
|
||||
/**
|
||||
* Processing needed for buildForm and later.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
/**
|
||||
* set the button names
|
||||
*/
|
||||
$this->_searchButtonName = $this->getButtonName('refresh');
|
||||
$this->_actionButtonName = $this->getButtonName('next', 'action');
|
||||
|
||||
$this->_done = FALSE;
|
||||
$this->defaults = array();
|
||||
|
||||
/*
|
||||
* we allow the controller to set force/reset externally, useful when we are being
|
||||
* driven by the wizard framework
|
||||
*/
|
||||
|
||||
$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
|
||||
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
|
||||
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
|
||||
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'search');
|
||||
|
||||
$this->assign("context", $this->_context);
|
||||
|
||||
// get user submitted values
|
||||
// get it from controller only if form has been submitted, else preProcess has set this
|
||||
if (!empty($_POST)) {
|
||||
$this->_formValues = $this->controller->exportValues($this->_name);
|
||||
}
|
||||
else {
|
||||
$this->_formValues = $this->get('formValues');
|
||||
}
|
||||
|
||||
if (empty($this->_formValues)) {
|
||||
if (isset($this->_ssID)) {
|
||||
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_force) {
|
||||
$this->postProcess();
|
||||
$this->set('force', 0);
|
||||
}
|
||||
|
||||
$sortID = NULL;
|
||||
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
|
||||
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
|
||||
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
|
||||
);
|
||||
}
|
||||
|
||||
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
|
||||
$selector = new CRM_Grant_Selector_Search($this->_queryParams,
|
||||
$this->_action,
|
||||
NULL,
|
||||
$this->_single,
|
||||
$this->_limit,
|
||||
$this->_context
|
||||
);
|
||||
$prefix = NULL;
|
||||
if ($this->_context == 'user') {
|
||||
$prefix = $this->_prefix;
|
||||
}
|
||||
|
||||
$this->assign("{$prefix}limit", $this->_limit);
|
||||
$this->assign("{$prefix}single", $this->_single);
|
||||
|
||||
$controller = new CRM_Core_Selector_Controller($selector,
|
||||
$this->get(CRM_Utils_Pager::PAGE_ID),
|
||||
$sortID,
|
||||
CRM_Core_Action::VIEW,
|
||||
$this,
|
||||
CRM_Core_Selector_Controller::TRANSFER,
|
||||
$prefix
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->moveFromSessionToTemplate();
|
||||
|
||||
$this->assign('summary', $this->get('summary'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
$this->addSortNameField();
|
||||
|
||||
CRM_Grant_BAO_Query::buildSearchForm($this);
|
||||
|
||||
$rows = $this->get('rows');
|
||||
if (is_array($rows)) {
|
||||
if (!$this->_single) {
|
||||
$this->addRowSelectors($rows);
|
||||
}
|
||||
|
||||
$permission = CRM_Core_Permission::getPermission();
|
||||
|
||||
$this->addTaskMenu(CRM_Grant_Task::permissionedTaskTitles($permission));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The post processing of the form gets done here.
|
||||
*
|
||||
* Key things done during post processing are
|
||||
* - check for reset or next request. if present, skip post procesing.
|
||||
* - now check if user requested running a saved search, if so, then
|
||||
* the form values associated with the saved search are used for searching.
|
||||
* - if user has done a submit with new values the regular post submissing is
|
||||
* done.
|
||||
* The processing consists of using a Selector / Controller framework for getting the
|
||||
* search results.
|
||||
*
|
||||
* @param
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_done) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_done = TRUE;
|
||||
|
||||
$this->_formValues = $this->controller->exportValues($this->_name);
|
||||
$this->fixFormValues();
|
||||
|
||||
if (isset($this->_ssID) && empty($_POST)) {
|
||||
// if we are editing / running a saved search and the form has not been posted
|
||||
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
|
||||
}
|
||||
|
||||
CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
|
||||
|
||||
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
|
||||
|
||||
$this->set('formValues', $this->_formValues);
|
||||
$this->set('queryParams', $this->_queryParams);
|
||||
|
||||
$buttonName = $this->controller->getButtonName();
|
||||
if ($buttonName == $this->_actionButtonName) {
|
||||
// check actionName and if next, then do not repeat a search, since we are going to the next page
|
||||
|
||||
// hack, make sure we reset the task values
|
||||
$stateMachine = $this->controller->getStateMachine();
|
||||
$formName = $stateMachine->getTaskFormName();
|
||||
$this->controller->resetPage($formName);
|
||||
return;
|
||||
}
|
||||
|
||||
$sortID = NULL;
|
||||
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
|
||||
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
|
||||
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
|
||||
);
|
||||
}
|
||||
|
||||
$selector = new CRM_Grant_Selector_Search($this->_queryParams,
|
||||
$this->_action,
|
||||
NULL,
|
||||
$this->_single,
|
||||
$this->_limit,
|
||||
$this->_context
|
||||
);
|
||||
$selector->setKey($this->controller->_key);
|
||||
|
||||
$prefix = NULL;
|
||||
if ($this->_context == 'basic' || $this->_context == 'user') {
|
||||
$prefix = $this->_prefix;
|
||||
}
|
||||
|
||||
$controller = new CRM_Core_Selector_Controller($selector,
|
||||
$this->get(CRM_Utils_Pager::PAGE_ID),
|
||||
$sortID,
|
||||
CRM_Core_Action::VIEW,
|
||||
$this,
|
||||
CRM_Core_Selector_Controller::SESSION,
|
||||
$prefix
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
|
||||
$query = &$selector->getQuery();
|
||||
if ($this->_context == 'user') {
|
||||
$query->setSkipPermission(TRUE);
|
||||
}
|
||||
$controller->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default form values.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
* the default array reference
|
||||
*/
|
||||
public function &setDefaultValues() {
|
||||
return $this->_formValues;
|
||||
}
|
||||
|
||||
public function fixFormValues() {
|
||||
// if this search has been forced
|
||||
// then see if there are any get values, and if so over-ride the post values
|
||||
// note that this means that GET over-rides POST :)
|
||||
|
||||
if (!$this->_force) {
|
||||
return;
|
||||
}
|
||||
|
||||
$status = CRM_Utils_Request::retrieve('status', 'String');
|
||||
if ($status) {
|
||||
$this->_formValues['grant_status_id'] = $status;
|
||||
$this->_defaults['grant_status_id'] = $status;
|
||||
}
|
||||
|
||||
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
|
||||
|
||||
if ($cid) {
|
||||
$cid = CRM_Utils_Type::escape($cid, 'Integer');
|
||||
if ($cid > 0) {
|
||||
$this->_formValues['contact_id'] = $cid;
|
||||
|
||||
// also assign individual mode to the template
|
||||
$this->_single = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getFormValues() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a descriptive name for the page, used in wizard header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return ts('Find Grants');
|
||||
}
|
||||
|
||||
}
|
||||
173
sites/all/modules/civicrm/CRM/Grant/Form/Task.php
Normal dosya
173
sites/all/modules/civicrm/CRM/Grant/Form/Task.php
Normal dosya
|
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates task actions for CiviEvent
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_Form_Task extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* The task being performed.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_task;
|
||||
|
||||
/**
|
||||
* The additional clause that we restrict the search with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_componentClause = NULL;
|
||||
|
||||
/**
|
||||
* The array that holds all the component ids.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_componentIds;
|
||||
|
||||
/**
|
||||
* The array that holds all the grant ids.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_grantIds;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @param
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
self::preProcessCommon($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CRM_Core_Form $form
|
||||
* @param bool $useTable
|
||||
*/
|
||||
public static function preProcessCommon(&$form, $useTable = FALSE) {
|
||||
$form->_grantIds = array();
|
||||
|
||||
$values = $form->controller->exportValues('Search');
|
||||
|
||||
$form->_task = $values['task'];
|
||||
$grantTasks = CRM_Grant_Task::tasks();
|
||||
$form->assign('taskName', $grantTasks[$form->_task]);
|
||||
|
||||
$ids = array();
|
||||
if ($values['radio_ts'] == 'ts_sel') {
|
||||
foreach ($values as $name => $value) {
|
||||
if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
|
||||
$ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$queryParams = $form->get('queryParams');
|
||||
$sortOrder = NULL;
|
||||
if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
|
||||
$sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
|
||||
}
|
||||
$query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE,
|
||||
CRM_Contact_BAO_Query::MODE_GRANT
|
||||
);
|
||||
$query->_distinctComponentClause = ' civicrm_grant.id';
|
||||
$query->_groupByComponentClause = ' GROUP BY civicrm_grant.id ';
|
||||
$result = $query->searchQuery(0, 0, $sortOrder);
|
||||
while ($result->fetch()) {
|
||||
$ids[] = $result->grant_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($ids)) {
|
||||
$form->_componentClause = ' civicrm_grant.id IN ( ' . implode(',', $ids) . ' ) ';
|
||||
$form->assign('totalSelectedGrants', count($ids));
|
||||
}
|
||||
|
||||
$form->_grantIds = $form->_componentIds = $ids;
|
||||
|
||||
//set the context for redirection for any task actions
|
||||
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
|
||||
$urlParams = 'force=1';
|
||||
if (CRM_Utils_Rule::qfKey($qfKey)) {
|
||||
$urlParams .= "&qfKey=$qfKey";
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->replaceUserContext(CRM_Utils_System::url('civicrm/grant/search', $urlParams));
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the grant id, compute the contact id
|
||||
* since its used for things like send email
|
||||
*/
|
||||
public function setContactIDs() {
|
||||
$this->_contactIds = &CRM_Core_DAO::getContactIDsFromComponent($this->_grantIds,
|
||||
'civicrm_grant'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple shell that derived classes can call to add buttons to.
|
||||
* the form with a customized title for the main Submit
|
||||
*
|
||||
* @param string $title
|
||||
* Title of the main button.
|
||||
* @param string $nextType
|
||||
* @param string $backType
|
||||
*
|
||||
* @param bool $submitOnce
|
||||
*/
|
||||
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => $nextType,
|
||||
'name' => $title,
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => $backType,
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
102
sites/all/modules/civicrm/CRM/Grant/Form/Task/Delete.php
Normal dosya
102
sites/all/modules/civicrm/CRM/Grant/Form/Task/Delete.php
Normal dosya
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to delete a group of
|
||||
* participations. This class provides functionality for the actual
|
||||
* deletion.
|
||||
*/
|
||||
class CRM_Grant_Form_Task_Delete extends CRM_Grant_Form_Task {
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. deleting one
|
||||
* specific participation?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
|
||||
//check permission for delete.
|
||||
if (!CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addDefaultButtons(ts('Delete Grants'), 'done');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
105
sites/all/modules/civicrm/CRM/Grant/Form/Task/Print.php
Normal dosya
105
sites/all/modules/civicrm/CRM/Grant/Form/Task/Print.php
Normal dosya
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to grant list
|
||||
*/
|
||||
class CRM_Grant_Form_Task_Print extends CRM_Grant_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preprocess();
|
||||
|
||||
// set print view, so that print templates are called
|
||||
$this->controller->setPrint(1);
|
||||
|
||||
// get the formatted params
|
||||
$queryParams = $this->get('queryParams');
|
||||
|
||||
$sortID = NULL;
|
||||
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
|
||||
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
|
||||
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
|
||||
);
|
||||
}
|
||||
|
||||
$selector = new CRM_Grant_Selector_Search($queryParams, $this->_action, $this->_componentClause);
|
||||
$controller = new CRM_Core_Selector_Controller($selector, NULL, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object - it consists of
|
||||
* - displaying the QILL (query in local language)
|
||||
* - displaying elements for saving the search
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
//
|
||||
// just need to add a javacript to popup the window for printing
|
||||
//
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Print Grant List'),
|
||||
'js' => array('onclick' => 'window.print()'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'back',
|
||||
'name' => ts('Done'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess() {
|
||||
// redirect to the main search page after printing is over
|
||||
}
|
||||
|
||||
}
|
||||
83
sites/all/modules/civicrm/CRM/Grant/Form/Task/Result.php
Normal dosya
83
sites/all/modules/civicrm/CRM/Grant/Form/Task/Result.php
Normal dosya
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Used for displaying results
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_Form_Task_Result extends CRM_Grant_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
$session = CRM_Core_Session::singleton();
|
||||
|
||||
$this->set('searchRows', '');
|
||||
|
||||
$ssID = $this->get('ssID');
|
||||
if (isset($ssID)) {
|
||||
$urlParams = 'reset=1&force=1&ssID=' . $ssID;
|
||||
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
|
||||
if (CRM_Utils_Rule::qfKey($qfKey)) {
|
||||
$urlParams .= "&qfKey=$qfKey";
|
||||
}
|
||||
|
||||
$url = CRM_Utils_System::url('civicrm/grant/search', $urlParams);
|
||||
$session->replaceUserContext($url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'done',
|
||||
'name' => ts('Done'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to save a search
|
||||
* Saved Searches are used for saving frequently used queries
|
||||
*/
|
||||
class CRM_Grant_Form_Task_SearchTaskHookSample extends CRM_Grant_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$rows = array();
|
||||
// display name and grant details of all selectced contacts
|
||||
$grantIDs = implode(',', $this->_grantIds);
|
||||
|
||||
$query = "
|
||||
SELECT grt.decision_date as decision_date,
|
||||
grt.amount_total as amount_total,
|
||||
grt.amount_granted as amount_granted,
|
||||
ct.display_name as display_name
|
||||
FROM civicrm_grant grt
|
||||
INNER JOIN civicrm_contact ct ON ( grt.contact_id = ct.id )
|
||||
WHERE grt.id IN ( $grantIDs )";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$rows[] = array(
|
||||
'display_name' => $dao->display_name,
|
||||
'decision_date' => $dao->decision_date,
|
||||
'amount_requested' => $dao->amount_total,
|
||||
'amount_granted' => $dao->amount_granted,
|
||||
);
|
||||
}
|
||||
$this->assign('rows', $rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'done',
|
||||
'name' => ts('Done'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
113
sites/all/modules/civicrm/CRM/Grant/Form/Task/Update.php
Normal dosya
113
sites/all/modules/civicrm/CRM/Grant/Form/Task/Update.php
Normal dosya
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to update a group of
|
||||
* grants. This class provides functionality for the actual
|
||||
* update.
|
||||
*/
|
||||
class CRM_Grant_Form_Task_Update extends CRM_Grant_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
|
||||
//check permission for update.
|
||||
if (!CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
|
||||
$this->addElement('select', 'status_id', ts('Grant Status'), array('' => '') + $grantStatus);
|
||||
|
||||
$this->addElement('text', 'amount_granted', ts('Amount Granted'));
|
||||
$this->addRule('amount_granted', ts('Please enter a valid amount.'), 'money');
|
||||
|
||||
$this->addDate('decision_date', ts('Grant Decision'), FALSE, array('formatType' => 'custom'));
|
||||
|
||||
$this->assign('elements', array('status_id', 'amount_granted', 'decision_date'));
|
||||
$this->assign('totalSelectedGrants', count($this->_grantIds));
|
||||
|
||||
$this->addDefaultButtons(ts('Update Grants'), 'done');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*
|
||||
*
|
||||
* @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));
|
||||
}
|
||||
|
||||
}
|
||||
162
sites/all/modules/civicrm/CRM/Grant/Info.php
Normal dosya
162
sites/all/modules/civicrm/CRM/Grant/Info.php
Normal dosya
|
|
@ -0,0 +1,162 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class introduces component to the system and provides all the
|
||||
* information about it. It needs to extend CRM_Core_Component_Info
|
||||
* abstract class.
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_Info extends CRM_Core_Component_Info {
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $keyword = 'grant';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return array
|
||||
*/
|
||||
public function getInfo() {
|
||||
return array(
|
||||
'name' => 'CiviGrant',
|
||||
'translatedName' => ts('CiviGrant'),
|
||||
'title' => 'CiviCRM Grant Management Engine',
|
||||
'path' => 'CRM_Grant_',
|
||||
'search' => 1,
|
||||
'showActivitiesInCore' => 1,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param bool $getAllUnconditionally
|
||||
* @param bool $descriptions
|
||||
* Whether to return permission descriptions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
|
||||
$permissions = array(
|
||||
'access CiviGrant' => array(
|
||||
ts('access CiviGrant'),
|
||||
ts('View all grants'),
|
||||
),
|
||||
'edit grants' => array(
|
||||
ts('edit grants'),
|
||||
ts('Create and update grants'),
|
||||
),
|
||||
'delete in CiviGrant' => array(
|
||||
ts('delete in CiviGrant'),
|
||||
ts('Delete grants'),
|
||||
),
|
||||
);
|
||||
|
||||
if (!$descriptions) {
|
||||
foreach ($permissions as $name => $attr) {
|
||||
$permissions[$name] = array_shift($attr);
|
||||
}
|
||||
}
|
||||
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return null
|
||||
*/
|
||||
public function getUserDashboardElement() {
|
||||
// no dashboard element for this component
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return null
|
||||
*/
|
||||
public function getUserDashboardObject() {
|
||||
// no dashboard element for this component
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return array
|
||||
*/
|
||||
public function registerTab() {
|
||||
return array(
|
||||
'title' => ts('Grants'),
|
||||
'url' => 'grant',
|
||||
'weight' => 50,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return array
|
||||
*/
|
||||
public function registerAdvancedSearchPane() {
|
||||
return array(
|
||||
'title' => ts('Grants'),
|
||||
'weight' => 50,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return null
|
||||
*/
|
||||
public function getActivityTypes() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* add shortcut to Create New.
|
||||
* @param $shortCuts
|
||||
*/
|
||||
public function creatNewShortcut(&$shortCuts) {
|
||||
if (CRM_Core_Permission::check('access CiviGrant') &&
|
||||
CRM_Core_Permission::check('edit grants')
|
||||
) {
|
||||
$shortCuts = array_merge($shortCuts, array(
|
||||
array(
|
||||
'path' => 'civicrm/grant/add',
|
||||
'query' => "reset=1&action=add&context=standalone",
|
||||
'ref' => 'new-grant',
|
||||
'title' => ts('Grant'),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
77
sites/all/modules/civicrm/CRM/Grant/Page/DashBoard.php
Normal dosya
77
sites/all/modules/civicrm/CRM/Grant/Page/DashBoard.php
Normal dosya
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is page is for Grant Dashboard
|
||||
*/
|
||||
class CRM_Grant_Page_DashBoard extends CRM_Core_Page {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* the main function that is called when the page loads,
|
||||
* it decides the which action has to be taken for the page.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function run() {
|
||||
$this->preProcess();
|
||||
|
||||
$controller = new CRM_Core_Controller_Simple('CRM_Grant_Form_Search', ts('grants'), NULL);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->reset();
|
||||
$controller->set('limit', 10);
|
||||
$controller->set('force', 1);
|
||||
$controller->set('context', 'dashboard');
|
||||
$controller->process();
|
||||
$controller->run();
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
||||
207
sites/all/modules/civicrm/CRM/Grant/Page/Tab.php
Normal dosya
207
sites/all/modules/civicrm/CRM/Grant/Page/Tab.php
Normal dosya
|
|
@ -0,0 +1,207 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class handle grant related functions
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_Page_Tab extends CRM_Contact_Page_View {
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
public $_permission = NULL;
|
||||
public $_contactId = NULL;
|
||||
|
||||
/**
|
||||
* called when action is browse.
|
||||
*
|
||||
*/
|
||||
public function browse() {
|
||||
$controller = new CRM_Core_Controller_Simple('CRM_Grant_Form_Search', ts('Grants'), $this->_action);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->reset();
|
||||
$controller->set('cid', $this->_contactId);
|
||||
$controller->set('context', 'grant');
|
||||
$controller->process();
|
||||
$controller->run();
|
||||
|
||||
if ($this->_contactId) {
|
||||
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
|
||||
$this->assign('displayName', $displayName);
|
||||
$this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('grant', $this->_contactId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* called when action is view.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function view() {
|
||||
$controller = new CRM_Core_Controller_Simple('CRM_Grant_Form_GrantView', 'View Grant', $this->_action);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->set('id', $this->_id);
|
||||
$controller->set('cid', $this->_contactId);
|
||||
|
||||
return $controller->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* called when action is update or new.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function edit() {
|
||||
$controller = new CRM_Core_Controller_Simple('CRM_Grant_Form_Grant', 'Create grant', $this->_action);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->set('id', $this->_id);
|
||||
$controller->set('cid', $this->_contactId);
|
||||
|
||||
return $controller->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
|
||||
|
||||
if ($context == 'standalone') {
|
||||
$this->_action = CRM_Core_Action::ADD;
|
||||
}
|
||||
else {
|
||||
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
|
||||
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
|
||||
$this->assign('contactId', $this->_contactId);
|
||||
$this->assign('displayName', $displayName);
|
||||
|
||||
// check logged in url permission
|
||||
CRM_Contact_Page_View::checkUserPermission($this);
|
||||
}
|
||||
$this->assign('action', $this->_action);
|
||||
|
||||
if ($this->_permission == CRM_Core_Permission::EDIT && !CRM_Core_Permission::check('edit grants')) {
|
||||
// demote to view since user does not have edit grant rights
|
||||
$this->_permission = CRM_Core_Permission::VIEW;
|
||||
$this->assign('permission', 'view');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* the main function that is called when the page loads,
|
||||
* it decides the which action has to be taken for the page.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function run() {
|
||||
$this->preProcess();
|
||||
|
||||
$this->setContext();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::VIEW) {
|
||||
$this->view();
|
||||
}
|
||||
elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) {
|
||||
$this->edit();
|
||||
}
|
||||
else {
|
||||
$this->browse();
|
||||
}
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
public 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_Grant_BAO_Grant::del($this->_id);
|
||||
CRM_Utils_System::redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
425
sites/all/modules/civicrm/CRM/Grant/Selector/Search.php
Normal dosya
425
sites/all/modules/civicrm/CRM/Grant/Selector/Search.php
Normal dosya
|
|
@ -0,0 +1,425 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used to retrieve and display a range of
|
||||
* contacts that match the given criteria (specifically for
|
||||
* results of advanced search options.
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
|
||||
|
||||
/**
|
||||
* This defines two actions- View and Edit.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* We use desc to remind us what that column is, name is used in the tpl
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_columnHeaders;
|
||||
|
||||
/**
|
||||
* Properties of contact we're interested in displaying
|
||||
* @var array
|
||||
*/
|
||||
static $_properties = array(
|
||||
'contact_id',
|
||||
'contact_type',
|
||||
'sort_name',
|
||||
'grant_id',
|
||||
'grant_status_id',
|
||||
'grant_status',
|
||||
'grant_type_id',
|
||||
'grant_type',
|
||||
'grant_amount_total',
|
||||
'grant_amount_requested',
|
||||
'grant_amount_granted',
|
||||
'grant_application_received_date',
|
||||
'grant_report_received',
|
||||
'grant_money_transfer_date',
|
||||
);
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_limit = NULL;
|
||||
|
||||
/**
|
||||
* What context are we being invoked from.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = NULL;
|
||||
|
||||
/**
|
||||
* QueryParams is the array returned by exportValues called on.
|
||||
* the HTML_QuickForm_Controller for that page.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_queryParams;
|
||||
|
||||
/**
|
||||
* Represent the type of selector.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_action;
|
||||
|
||||
/**
|
||||
* The additional clause that we restrict the search with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_grantClause = NULL;
|
||||
|
||||
/**
|
||||
* The query object.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_query;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param array $queryParams
|
||||
* Array of parameters for query.
|
||||
* @param \const|int $action - action of search basic or advanced.
|
||||
* @param string $grantClause
|
||||
* If the caller wants to further restrict the search.
|
||||
* @param bool $single
|
||||
* Are we dealing only with one contact?.
|
||||
* @param int $limit
|
||||
* How many participations do we want returned.
|
||||
*
|
||||
* @param string $context
|
||||
*
|
||||
* @return \CRM_Grant_Selector_Search
|
||||
*/
|
||||
public function __construct(
|
||||
&$queryParams,
|
||||
$action = CRM_Core_Action::NONE,
|
||||
$grantClause = NULL,
|
||||
$single = FALSE,
|
||||
$limit = NULL,
|
||||
$context = 'search'
|
||||
) {
|
||||
// submitted form values
|
||||
$this->_queryParams = &$queryParams;
|
||||
|
||||
$this->_single = $single;
|
||||
$this->_limit = $limit;
|
||||
$this->_context = $context;
|
||||
|
||||
$this->_grantClause = $grantClause;
|
||||
|
||||
// type of selector
|
||||
$this->_action = $action;
|
||||
|
||||
$this->_query = new CRM_Contact_BAO_Query($this->_queryParams, NULL, NULL, FALSE, FALSE,
|
||||
CRM_Contact_BAO_Query::MODE_GRANT
|
||||
);
|
||||
$this->_query->_distinctComponentClause = " civicrm_grant.id";
|
||||
$this->_query->_groupByComponentClause = " GROUP BY civicrm_grant.id ";
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the links that are given for each search row.
|
||||
* currently the links added for each row are
|
||||
*
|
||||
* - View
|
||||
* - Edit
|
||||
*
|
||||
* @param string|null $key
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &links($key = NULL) {
|
||||
$cid = CRM_Utils_Request::retrieve('cid', 'Integer');
|
||||
$extraParams = ($key) ? "&key={$key}" : NULL;
|
||||
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::VIEW => array(
|
||||
'name' => ts('View'),
|
||||
'url' => 'civicrm/contact/view/grant',
|
||||
'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=view&context=%%cxt%%&selectedChild=grant' . $extraParams,
|
||||
'title' => ts('View Grant'),
|
||||
),
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => 'civicrm/contact/view/grant',
|
||||
'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams,
|
||||
'title' => ts('Edit Grant'),
|
||||
),
|
||||
);
|
||||
|
||||
if ($cid) {
|
||||
$delLink = array(
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => 'civicrm/contact/view/grant',
|
||||
'qs' => 'action=delete&reset=1&cid=%%cid%%&id=%%id%%&selectedChild=grant' . $extraParams,
|
||||
'title' => ts('Delete Grant'),
|
||||
),
|
||||
);
|
||||
self::$_links = self::$_links + $delLink;
|
||||
}
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for array of the parameters required for creating pager.
|
||||
*
|
||||
* @param $action
|
||||
* @param array $params
|
||||
*/
|
||||
public function getPagerParams($action, &$params) {
|
||||
$params['status'] = ts('Grant') . ' %%StatusMessage%%';
|
||||
$params['csvString'] = NULL;
|
||||
if ($this->_limit) {
|
||||
$params['rowCount'] = $this->_limit;
|
||||
}
|
||||
else {
|
||||
$params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
|
||||
}
|
||||
|
||||
$params['buttonTop'] = 'PagerTopButton';
|
||||
$params['buttonBottom'] = 'PagerBottomButton';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns total number of rows for the query.
|
||||
*
|
||||
* @param int $action
|
||||
*
|
||||
* @return int
|
||||
* Total number of rows
|
||||
*/
|
||||
public function getTotalCount($action) {
|
||||
return $this->_query->searchQuery(0, 0, NULL,
|
||||
TRUE, FALSE,
|
||||
FALSE, FALSE,
|
||||
FALSE,
|
||||
$this->_grantClause
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the rows in the given offset and rowCount *
|
||||
*
|
||||
* @param string $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 string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @return int
|
||||
* the total number of rows for this action
|
||||
*/
|
||||
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
|
||||
$result = $this->_query->searchQuery($offset, $rowCount, $sort,
|
||||
FALSE, FALSE,
|
||||
FALSE, FALSE,
|
||||
FALSE,
|
||||
$this->_grantClause
|
||||
);
|
||||
|
||||
// process the result of the query
|
||||
$rows = array();
|
||||
|
||||
//CRM-4418 check for view, edit, delete
|
||||
$permissions = array(CRM_Core_Permission::VIEW);
|
||||
if (CRM_Core_Permission::check('edit grants')) {
|
||||
$permissions[] = CRM_Core_Permission::EDIT;
|
||||
}
|
||||
if (CRM_Core_Permission::check('delete in CiviGrant')) {
|
||||
$permissions[] = CRM_Core_Permission::DELETE;
|
||||
}
|
||||
$mask = CRM_Core_Action::mask($permissions);
|
||||
|
||||
while ($result->fetch()) {
|
||||
$row = array();
|
||||
// the columns we are interested in
|
||||
foreach (self::$_properties as $property) {
|
||||
if (isset($result->$property)) {
|
||||
$row[$property] = $result->$property;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_context == 'search') {
|
||||
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->grant_id;
|
||||
}
|
||||
|
||||
$row['action'] = CRM_Core_Action::formLink(self::links($this->_key),
|
||||
$mask,
|
||||
array(
|
||||
'id' => $result->grant_id,
|
||||
'cid' => $result->contact_id,
|
||||
'cxt' => $this->_context,
|
||||
),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'grant.selector.row',
|
||||
'Grant',
|
||||
$result->grant_id
|
||||
);
|
||||
|
||||
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id
|
||||
);
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getQILL() {
|
||||
return $this->_query->qill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column headers as an array of tuples:
|
||||
* (name, sortName (key to the sort array))
|
||||
*
|
||||
* @param string $action
|
||||
* The action being performed.
|
||||
* @param string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @return array
|
||||
* the column headers that need to be displayed
|
||||
*/
|
||||
public function &getColumnHeaders($action = NULL, $output = NULL) {
|
||||
if (!isset(self::$_columnHeaders)) {
|
||||
self::$_columnHeaders = array(
|
||||
array(
|
||||
'name' => ts('Status'),
|
||||
'sort' => 'grant_status',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Type'),
|
||||
'sort' => 'grant_type_id',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Requested'),
|
||||
'sort' => 'grant_amount_total',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Granted'),
|
||||
'sort' => 'grant_amount_granted',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Application Received'),
|
||||
'sort' => 'grant_application_received_date',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Report Received'),
|
||||
'sort' => 'grant_report_received',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Money Transferred'),
|
||||
'sort' => 'money_transfer_date',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array('desc' => ts('Actions')),
|
||||
);
|
||||
|
||||
if (!$this->_single) {
|
||||
$pre = array(
|
||||
array('desc' => ts('Contact Type')),
|
||||
array(
|
||||
'name' => ts('Name'),
|
||||
'sort' => 'sort_name',
|
||||
'direction' => CRM_Utils_Sort::ASCENDING,
|
||||
),
|
||||
);
|
||||
self::$_columnHeaders = array_merge($pre, self::$_columnHeaders);
|
||||
}
|
||||
}
|
||||
return self::$_columnHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function &getQuery() {
|
||||
return $this->_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of export file.
|
||||
*
|
||||
* @param string $output
|
||||
* Type of output.
|
||||
*
|
||||
* @return string
|
||||
* name of the file
|
||||
*/
|
||||
public function getExportFileName($output = 'csv') {
|
||||
return ts('CiviCRM Grant Search');
|
||||
}
|
||||
|
||||
}
|
||||
108
sites/all/modules/civicrm/CRM/Grant/StateMachine/Search.php
Normal dosya
108
sites/all/modules/civicrm/CRM/Grant/StateMachine/Search.php
Normal dosya
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_StateMachine_Search extends CRM_Core_StateMachine {
|
||||
|
||||
/**
|
||||
* The task that the wizard is currently processing.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_task;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param object $controller
|
||||
* @param \const|int $action
|
||||
*/
|
||||
public function __construct($controller, $action = CRM_Core_Action::NONE) {
|
||||
parent::__construct($controller, $action);
|
||||
|
||||
$this->_pages = array();
|
||||
|
||||
$this->_pages['CRM_Grant_Form_Search'] = NULL;
|
||||
list($task, $result) = $this->taskName($controller, 'Search');
|
||||
$this->_task = $task;
|
||||
|
||||
if (is_array($task)) {
|
||||
foreach ($task as $t) {
|
||||
$this->_pages[$t] = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->_pages[$task] = NULL;
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
$this->_pages['CRM_Grant_Form_Task_Result'] = NULL;
|
||||
}
|
||||
|
||||
$this->addSequentialPages($this->_pages, $action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the form name based on the action. This allows us
|
||||
* to avoid using conditional state machine, much more efficient
|
||||
* and simpler
|
||||
*
|
||||
* @param CRM_Core_Controller $controller
|
||||
* The controller object.
|
||||
*
|
||||
* @param string $formName
|
||||
*
|
||||
* @return string
|
||||
* the name of the form that will handle the task
|
||||
*/
|
||||
public function taskName($controller, $formName = 'Search') {
|
||||
// total hack, check POST vars and then session to determine stuff
|
||||
$value = CRM_Utils_Array::value('task', $_POST);
|
||||
if (!isset($value)) {
|
||||
$value = $this->_controller->get('task');
|
||||
}
|
||||
$this->_controller->set('task', $value);
|
||||
|
||||
return CRM_Grant_Task::getTask($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the form name of the task.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTaskFormName() {
|
||||
return CRM_Utils_String::getClassName($this->_task);
|
||||
}
|
||||
|
||||
}
|
||||
167
sites/all/modules/civicrm/CRM/Grant/Task.php
Normal dosya
167
sites/all/modules/civicrm/CRM/Grant/Task.php
Normal dosya
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* class to represent the actions that can be performed on a group of contacts
|
||||
* used by the search forms
|
||||
*
|
||||
*/
|
||||
class CRM_Grant_Task {
|
||||
const DELETE_GRANTS = 1, PRINT_GRANTS = 2, EXPORT_GRANTS = 3, UPDATE_GRANTS = 4;
|
||||
|
||||
/**
|
||||
* The task array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_tasks = NULL;
|
||||
|
||||
/**
|
||||
* The optional task array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_optionalTasks = NULL;
|
||||
|
||||
/**
|
||||
* These tasks are the core set of tasks that the user can perform
|
||||
* on a contact / group of contacts
|
||||
*
|
||||
* @return array
|
||||
* the set of tasks for a group of contacts
|
||||
*/
|
||||
public static function &tasks() {
|
||||
if (!(self::$_tasks)) {
|
||||
self::$_tasks = array(
|
||||
1 => array(
|
||||
'title' => ts('Delete grants'),
|
||||
'class' => 'CRM_Grant_Form_Task_Delete',
|
||||
'result' => FALSE,
|
||||
),
|
||||
2 => array(
|
||||
'title' => ts('Print selected rows'),
|
||||
'class' => 'CRM_Grant_Form_Task_Print',
|
||||
'result' => FALSE,
|
||||
),
|
||||
3 => array(
|
||||
'title' => ts('Export grants'),
|
||||
'class' => array(
|
||||
'CRM_Export_Form_Select',
|
||||
'CRM_Export_Form_Map',
|
||||
),
|
||||
'result' => FALSE,
|
||||
),
|
||||
4 => array(
|
||||
'title' => ts('Update grants'),
|
||||
'class' => 'CRM_Grant_Form_Task_Update',
|
||||
'result' => FALSE,
|
||||
),
|
||||
);
|
||||
|
||||
if (!CRM_Core_Permission::check('delete in CiviGrant')) {
|
||||
unset(self::$_tasks[1]);
|
||||
}
|
||||
|
||||
CRM_Utils_Hook::searchTasks('grant', self::$_tasks);
|
||||
asort(self::$_tasks);
|
||||
}
|
||||
|
||||
return self::$_tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* These tasks are the core set of task titles
|
||||
*
|
||||
* @return array
|
||||
* the set of task titles
|
||||
*/
|
||||
public static function &taskTitles() {
|
||||
self::tasks();
|
||||
$titles = array();
|
||||
foreach (self::$_tasks as $id => $value) {
|
||||
$titles[$id] = $value['title'];
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show tasks selectively based on the permission level
|
||||
* of the user
|
||||
*
|
||||
* @param int $permission
|
||||
*
|
||||
* @return array
|
||||
* set of tasks that are valid for the user
|
||||
*/
|
||||
public static function &permissionedTaskTitles($permission) {
|
||||
$tasks = array();
|
||||
if (($permission == CRM_Core_Permission::EDIT)
|
||||
|| CRM_Core_Permission::check('edit grants')
|
||||
) {
|
||||
$tasks = self::taskTitles();
|
||||
}
|
||||
else {
|
||||
$tasks = array(
|
||||
3 => self::$_tasks[3]['title'],
|
||||
);
|
||||
//CRM-4418,
|
||||
if (CRM_Core_Permission::check('delete in CiviGrant')) {
|
||||
$tasks[1] = self::$_tasks[1]['title'];
|
||||
}
|
||||
}
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* These tasks are the core set of tasks that the user can perform
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return array
|
||||
* the set of tasks for a group of contacts
|
||||
*/
|
||||
public static function getTask($value) {
|
||||
self::tasks();
|
||||
if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) {
|
||||
// make the print task by default
|
||||
$value = 2;
|
||||
}
|
||||
return array(
|
||||
self::$_tasks[$value]['class'],
|
||||
self::$_tasks[$value]['result'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
40
sites/all/modules/civicrm/CRM/Grant/xml/Menu/Grant.xml
Normal dosya
40
sites/all/modules/civicrm/CRM/Grant/xml/Menu/Grant.xml
Normal dosya
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1" ?>
|
||||
|
||||
<menu>
|
||||
<item>
|
||||
<path>civicrm/grant</path>
|
||||
<title>CiviGrant Dashboard</title>
|
||||
<page_callback>CRM_Grant_Page_DashBoard</page_callback>
|
||||
<access_arguments>access CiviGrant</access_arguments>
|
||||
<page_type>1</page_type>
|
||||
<weight>1000</weight>
|
||||
<component>CiviGrant</component>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/grant/info</path>
|
||||
<access_arguments>access CiviGrant</access_arguments>
|
||||
<weight>0</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/grant/search</path>
|
||||
<title>Find Grants</title>
|
||||
<page_callback>CRM_Grant_Controller_Search</page_callback>
|
||||
<access_arguments>access CiviGrant</access_arguments>
|
||||
<page_type>1</page_type>
|
||||
<weight>1010</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/grant/add</path>
|
||||
<title>New Grant</title>
|
||||
<page_callback>CRM_Grant_Page_Tab</page_callback>
|
||||
<path_arguments>action=add</path_arguments>
|
||||
<access_arguments>access CiviGrant</access_arguments>
|
||||
<page_type>1</page_type>
|
||||
<component>CiviGrant</component>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/contact/view/grant</path>
|
||||
<page_callback>CRM_Grant_Page_Tab</page_callback>
|
||||
<access_arguments>access CiviGrant</access_arguments>
|
||||
</item>
|
||||
</menu>
|
||||
Yükleniyor…
Tablo ekle
Add a link
Yeni konuda referans