Commit f3b5b3a2 authored by Pradeep Nayak's avatar Pradeep Nayak

--updated all files, for RG-108

parent e43e61a6
......@@ -104,12 +104,12 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
);
}
$count = 1;
while ( $dao->fetch( ) ) {
while ($dao->fetch()) {
if ($dao->N == $count) {
$summary['total_grants']['total_requested'] = $dao->amount_requested?CRM_Utils_Money::format($dao->amount_requested):CRM_Utils_Money::format(0);
$summary['total_grants']['total_granted'] = $dao->amount_granted?CRM_Utils_Money::format($dao->amount_granted):CRM_Utils_Money::format(0);
$summary['total_grants']['total_paid'] = $dao->total_paid?CRM_Utils_Money::format($dao->total_paid):CRM_Utils_Money::format(0);
$summary['total_grants']['total_average'] = $dao->average_amount?CRM_Utils_Money::format($dao->average_amount):CRM_Utils_Money::format(0);
$summary['total_grants']['total_requested'] = $dao->amount_requested ? CRM_Utils_Money::format($dao->amount_requested) : CRM_Utils_Money::format(0);
$summary['total_grants']['total_granted'] = $dao->amount_granted ? CRM_Utils_Money::format($dao->amount_granted) : CRM_Utils_Money::format(0);
$summary['total_grants']['total_paid'] = $dao->total_paid ? CRM_Utils_Money::format($dao->total_paid) : CRM_Utils_Money::format(0);
$summary['total_grants']['total_average'] = $dao->average_amount ? CRM_Utils_Money::format($dao->average_amount) : CRM_Utils_Money::format(0);
continue;
}
if (!empty($dao->status_id)) {
......@@ -117,10 +117,10 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
'label' => $stats[$dao->status_id]['label'],
'total' => $dao->status_total,
'value' => $stats[$dao->status_id]['value'],
'amount_requested' => $dao->amount_requested?CRM_Utils_Money::format($dao->amount_requested):CRM_Utils_Money::format(0),
'amount_granted' => $dao->amount_granted?CRM_Utils_Money::format($dao->amount_granted):CRM_Utils_Money::format(0),
'total_paid' => $dao->total_paid?CRM_Utils_Money::format($dao->total_paid):CRM_Utils_Money::format(0),
'average_amount' => $dao->average_amount?CRM_Utils_Money::format($dao->average_amount):CRM_Utils_Money::format(0),
'amount_requested' => $dao->amount_requested ? CRM_Utils_Money::format($dao->amount_requested) : CRM_Utils_Money::format(0),
'amount_granted' => $dao->amount_granted ? CRM_Utils_Money::format($dao->amount_granted) : CRM_Utils_Money::format(0),
'total_paid' => $dao->total_paid ? CRM_Utils_Money::format($dao->total_paid) : CRM_Utils_Money::format(0),
'average_amount' => $dao->average_amount ? CRM_Utils_Money::format($dao->average_amount) : CRM_Utils_Money::format(0),
);
$programs[$dao->label] = $programs[$dao->label] + array_diff_key($status, $programs[$dao->label]); //add the two arrays
ksort($programs[$dao->label]);
......@@ -130,10 +130,10 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
$programs["<b>Subtotal $dao->label </b>"]['subtotal'] = array(
'label' => '',
'total' => $dao->status_total,
'amount_requested' => $dao->amount_requested?CRM_Utils_Money::format($dao->amount_requested):CRM_Utils_Money::format(0),
'amount_granted' => $dao->amount_granted?CRM_Utils_Money::format($dao->amount_granted):CRM_Utils_Money::format(0),
'total_paid' => $dao->total_paid?CRM_Utils_Money::format($dao->total_paid):CRM_Utils_Money::format(0),
'average_amount' => $dao->average_amount?CRM_Utils_Money::format($dao->average_amount):CRM_Utils_Money::format(0),
'amount_requested' => $dao->amount_requested ? CRM_Utils_Money::format($dao->amount_requested) : CRM_Utils_Money::format(0),
'amount_granted' => $dao->amount_granted ? CRM_Utils_Money::format($dao->amount_granted) : CRM_Utils_Money::format(0),
'total_paid' => $dao->total_paid ? CRM_Utils_Money::format($dao->total_paid) : CRM_Utils_Money::format(0),
'average_amount' => $dao->average_amount ? CRM_Utils_Money::format($dao->average_amount) : CRM_Utils_Money::format(0),
);
}
$count++;
......
......@@ -248,7 +248,7 @@ WHERE civicrm_contact.id = $id ";
if (!empty($id)) {
$where .= " AND id = {$id}";
}
$query = "SELECT id, name FROM civicrm_grant_program ".$where;
$query = "SELECT id, name FROM civicrm_grant_program " . $where;
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$grantPrograms[$dao->id] = $dao->name;
......@@ -289,7 +289,7 @@ WHERE civicrm_contact.id = $id ";
}
static function sendMail($contactID, &$values, $grantStatus) {
$value = array();
if (CRM_Utils_Array::value('is_auto_email', $values)) {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
if (isset($email)) {
......
......@@ -61,6 +61,12 @@ class CRM_Grant_BAO_Query {
$query->_tables['grant_status'] = $query->_whereTables['grant_status'] = 1;
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
}
if (CRM_Utils_Array::value('status_weight', $query->_returnProperties)) {
$query->_select['status_weight'] = 'v.weight as status_weight';
$query->_element['status_weight'] = 1;
$query->_tables['status_weight'] = 1;
}
if (CRM_Utils_Array::value('grant_type_id', $query->_returnProperties)) {
$query->_select['grant_type_id'] = 'grant_type.id as grant_type_id';
......@@ -81,12 +87,26 @@ class CRM_Grant_BAO_Query {
$query->_element['grant_note'] = 1;
$query->_tables['grant_note'] = 1;
}
if (CRM_Utils_Array::value('course_conference_type_21', $query->_returnProperties)) {
$query->_select['course_type'] = "civicrm_value_course_conference_details_6.course_conference_type_21 as course_type";
$query->_element['course_type'] = 1;
$query->_tables['course_type'] = 1;
}
if (CRM_Utils_Array::value('course_conference_name_24', $query->_returnProperties)) {
$query->_select['course_name'] = "civicrm_value_course_conference_details_6.course_conference_name_24 as course_name";
$query->_element['course_name'] = 1;
$query->_tables['course_name'] = 1;
}
$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->_select['grant_payment_created'] = 'civicrm_payment.payment_created_date as grant_payment_created';
$query->_element['grant_type_id'] = 1;
$query->_element['grant_status_id'] = 1;
$query->_tables['civicrm_grant'] = 1;
......@@ -270,12 +290,23 @@ class CRM_Grant_BAO_Query {
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 ) ";
}
$from .= "$side JOIN civicrm_entity_payment AS temp1 ON (civicrm_grant.id = temp1.entity_id AND temp1.entity_table = 'civicrm_grant')
$side JOIN (SELECT payment_id AS payment_id, entity_id AS entity_id FROM civicrm_entity_payment ORDER BY payment_id DESC) AS temp2 ON temp1.entity_id = temp2.entity_id
$side JOIN civicrm_payment ON (temp2.payment_id = civicrm_payment.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;
case 'status_weight':
$from .= " $side JOIN civicrm_option_value v ON (civicrm_grant.status_id = v.value AND v.option_group_id=21)";
break;
case 'course_name':
$from .= " $side JOIN civicrm_value_course_conference_details_6 ON ( civicrm_grant.id = civicrm_value_course_conference_details_6.entity_id )";
break;
}
return $from;
}
......@@ -302,8 +333,12 @@ class CRM_Grant_BAO_Query {
'grant_id' => 1,
'grant_type' => 1,
'grant_status' => 1,
'status_weight' => 1,
'grant_amount_requested' => 1,
'grant_application_received_date' => 1,
'grant_payment_created' => 1,
'course_conference_type_74' => 1,
'course_conference_name_77' => 1,
'grant_report_received' => 1,
'grant_money_transfer_date' => 1,
'grant_note' => 1,
......
This diff is collapsed.
......@@ -74,7 +74,10 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
'grant_amount_total',
'grant_amount_requested',
'grant_amount_granted',
'grant_application_received_date',
'grant_application_received_date',
'grant_payment_created',
'course_type',
'course_name',
'grant_report_received',
'grant_money_transfer_date',
);
......@@ -156,7 +159,7 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
// submitted form values
$this->_queryParams = &$queryParams;
$this->_grantClause = $grantClause;
$this->_single = $single;
$this->_limit = $limit;
$this->_context = $context;
......@@ -275,6 +278,13 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
foreach ($sort->_vars as $key => $value) {
if ($value['name'] == "status_weight" && 1 == $key) {
$sort = trim($sort->orderBy());
$sort .= ', grant_application_received_date DESC';
break;
}
}
$result = $this->_query->searchQuery($offset, $rowCount, $sort,
FALSE, FALSE,
FALSE, FALSE,
......@@ -331,7 +341,16 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
if(empty($prev)) {
$prev = end($contactGrants);
}
if (isset($result->course_type)) {
if (!empty($result->course_type)) {
if ($result->course_type != 'select_or_other') {
$result->course_type = CRM_Core_DAO::singleValueQuery("SELECT civicrm_option_value.label as course_type FROM civicrm_option_value LEFT JOIN civicrm_option_group ON civicrm_option_group.id = civicrm_option_value.option_group_id WHERE civicrm_option_value.value = {$result->course_type} AND civicrm_option_group.name = 'course_conference_type_20120606094128'");
}
else {
$result->course_type = 'Other';
}
}
}
// the columns we are interested in
foreach (self::$_properties as $property) {
......@@ -389,13 +408,15 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
*/
public function &getColumnHeaders($action = NULL, $output = NULL) {
if (!isset(self::$_columnHeaders)) {
self::$_columnHeaders = array(
$statusHeader = array(
array('name' => ts('Status'),
'sort' => 'grant_status',
'direction' => CRM_Utils_Sort::DONTCARE,
'sort' => 'status_weight',
'direction' => CRM_Utils_Sort::ASCENDING,
),
);
self::$_columnHeaders = array(
array(
'name' => ts('Type'),
'name' => ts('Program Name'),
'sort' => 'grant_type_id',
'direction' => CRM_Utils_Sort::DONTCARE,
),
......@@ -412,16 +433,21 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
array(
'name' => ts('Application Received'),
'sort' => 'grant_application_received_date',
'direction' => CRM_Utils_Sort::DONTCARE,
'direction' => CRM_Utils_Sort::DESCENDING,
),
array(
'name' => ts('Report Received'),
'sort' => 'grant_report_received',
'name' => ts('Payment Created'),
'sort' => 'grant_payment_created',
'direction' => CRM_Utils_Sort::DONTCARE,
),
array(
'name' => ts('Course Name'),
'sort' => 'course_conference_name_77',
'direction' => CRM_Utils_Sort::DONTCARE,
),
array(
'name' => ts('Money Transferred'),
'sort' => 'money_transfer_date',
'name' => ts('Course Type'),
'sort' => 'course_conference_type_74',
'direction' => CRM_Utils_Sort::DONTCARE,
),
array('desc' => ts('Actions')),
......@@ -433,10 +459,13 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
array(
'name' => ts('Name'),
'sort' => 'sort_name',
'direction' => CRM_Utils_Sort::ASCENDING,
'direction' => CRM_Utils_Sort::DONTCARE,
),
);
self::$_columnHeaders = array_merge($pre, self::$_columnHeaders);
self::$_columnHeaders = array_merge($pre, $statusHeader, self::$_columnHeaders);
}
else {
self::$_columnHeaders = array_merge($statusHeader, self::$_columnHeaders);
}
}
return self::$_columnHeaders;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment