Skip to content
Snippets Groups Projects
Commit 0f532b26 authored by Mayur Jadhav's avatar Mayur Jadhav
Browse files

Worked on RG-174

parent fb85c9b8
No related branches found
No related tags found
No related merge requests found
......@@ -33,9 +33,6 @@
* $Id$
*
*/
define('CONFERENCE_DETAILS_TABLE', 'civicrm_value_nei_course_conference_details_16');
define('COURSE_TYPE', 'course_conference_type_74');
define('COURSE_NAME', 'course_conference_name_77');
class CRM_Grant_BAO_Query {
static function &getFields() {
$fields = array();
......@@ -103,14 +100,14 @@ class CRM_Grant_BAO_Query {
$query->_tables['grant_note'] = 1;
}
if (CRM_Utils_Array::value(COURSE_TYPE, $query->_returnProperties)) {
$query->_select['course_type'] = CONFERENCE_DETAILS_TABLE.'.'.COURSE_TYPE.' as course_type';
if (CRM_Utils_Array::value(COURSE_CONFERENCE_TYPE_COLUMN, $query->_returnProperties)) {
$query->_select['course_type'] = COURSE_CONFERENCE_DETAILS.'.'.COURSE_CONFERENCE_TYPE_COLUMN.' as course_type';
$query->_element['course_type'] = 1;
$query->_tables['course_type'] = 1;
}
if (CRM_Utils_Array::value(COURSE_NAME, $query->_returnProperties)) {
$query->_select['course_name'] = CONFERENCE_DETAILS_TABLE.'.'.COURSE_NAME.' as course_name';
if (CRM_Utils_Array::value(COURSE_CONFERENCE_NAME_COLUMN, $query->_returnProperties)) {
$query->_select['course_name'] = COURSE_CONFERENCE_DETAILS.'.'.COURSE_CONFERENCE_NAME_COLUMN.' as course_name';
$query->_element['course_name'] = 1;
$query->_tables['course_name'] = 1;
}
......@@ -320,7 +317,7 @@ $side JOIN civicrm_payment ON (temp2.payment_id = civicrm_payment.id)";
break;
case 'course_name':
$from .= ' '.$side.' JOIN '.CONFERENCE_DETAILS_TABLE.' ON ( civicrm_grant.id = '.CONFERENCE_DETAILS_TABLE.'.entity_id )';
$from .= ' '.$side.' JOIN '.COURSE_CONFERENCE_DETAILS.' ON ( civicrm_grant.id = '.COURSE_CONFERENCE_DETAILS.'.entity_id )';
break;
case 'grant_program':
......@@ -356,8 +353,8 @@ $side JOIN civicrm_payment ON (temp2.payment_id = civicrm_payment.id)";
'grant_amount_requested' => 1,
'grant_application_received_date' => 1,
'grant_payment_created' => 1,
COURSE_TYPE => 1,
COURSE_NAME => 1,
COURSE_CONFERENCE_TYPE_COLUMN => 1,
COURSE_CONFERENCE_NAME_COLUMN => 1,
'grant_report_received' => 1,
'grant_money_transfer_date' => 1,
'grant_note' => 1,
......
<?php
require_once 'grantprograms.civix.php';
require_once 'grantprograms_data_define.php';
//define pay grants
define('PAY_GRANTS', 5);
//define delete grants
define('DELETE_GRANTS', 1);
//RG-116 hide other fields
define('EMPLOYMENT', 62);
define('EMPLOYMENT_OTHER', 63);
define('POSITION', 66);
define('POSITION_OTHER', 67);
define('EMPLOYMENT_SETTING', 68);
define('EMPLOYMENT_SETTING_OTHER', 69);
define('INITIATIVE', 72);
define('INITIATIVE_OTHER', 73);
define('COURSE', 74);
define('COURSE_OTHER', 75);
//define custom groups
define('NEI_EMPLOYMENT', 'NEI_Employment_Information');
define('NEI_GENERAL', 'NEI_General_information');
define('NEI_CONFERENCE', 'NEI_Course_conference_details');
/**
* Implementation of hook_civicrm_config
*/
......@@ -42,9 +23,9 @@ function grantprograms_civicrm_xmlMenu(&$files) {
*/
function grantprograms_civicrm_install() {
_grantprograms_civix_civicrm_install();
$smarty = CRM_Core_Smarty::singleton();
$config = CRM_Core_Config::singleton();
grantprograms_define($config->extensionsDir);
$data = $smarty->fetch($config->extensionsDir . DIRECTORY_SEPARATOR . 'biz.jmaconsulting.grantprograms/sql/civicrm_msg_template.tpl');
file_put_contents($config->uploadDir . "civicrm_data.sql", $data);
CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $config->uploadDir . "civicrm_data.sql");
......@@ -55,6 +36,8 @@ function grantprograms_civicrm_install() {
* Implementation of hook_civicrm_uninstall
*/
function grantprograms_civicrm_uninstall() {
$config = CRM_Core_Config::singleton();
unlink($config->extensionsDir.'biz.jmaconsulting.grantprograms/grantprograms_data_define.php');
return _grantprograms_civix_civicrm_uninstall();
}
......@@ -281,16 +264,16 @@ function grantprograms_civicrm_buildForm($formName, &$form) {
$ccId = CRM_Core_DAO::singleValueQuery($query3);
}
$form->assign('employment', 'custom_'.EMPLOYMENT.'_'.$empId);
$form->assign('employment', 'custom_'.EMPLOYED_INDICATE.'_'.$empId);
$form->assign('employment_other', 'custom_'.EMPLOYMENT_OTHER.'_'.$empId);
$form->assign('position', 'custom_'.POSITION.'_'.$empId);
$form->assign('position_other', 'custom_'.POSITION_OTHER.'_'.$empId);
$form->assign('employment_setting', 'custom_'.EMPLOYMENT_SETTING.'_'.$empId);
$form->assign('employment_setting_other', 'custom_'.EMPLOYMENT_SETTING_OTHER.'_'.$empId);
$form->assign('init', 'custom_'.INITIATIVE.'_'.$genId);
$form->assign('init', 'custom_'.NEI_HEAR_ABOUT.'_'.$genId);
$form->assign('init_other', 'custom_'.INITIATIVE_OTHER.'_'.$genId);
$form->assign('course', 'custom_'.COURSE.'_'.$ccId);
$form->assign('course_other', 'custom_'.COURSE_OTHER.'_'.$ccId);
$form->assign('course', 'custom_'.COURSE_CONFERENCE_TYPE.'_'.$ccId);
$form->assign('course_other', 'custom_'.COURSE_CONFERENCE_TYPE_OTHER.'_'.$ccId);
CRM_Core_Region::instance('page-body')->add(array(
'template' => 'CRM/Grant/Form/GrantExtra.tpl',
));
......@@ -920,6 +903,7 @@ function grantprograms_getOptionValueLabel($optioGroupID, $value) {
$query = "SELECT label FROM civicrm_option_value WHERE option_group_id = {$optioGroupID} AND value = '{$value}' ";
return CRM_Core_DAO::singleValueQuery($query);
}
function grantprograms_getCustomFieldData($id) {
$customFieldData = array();
$query = "SELECT html_type, option_group_id FROM civicrm_custom_field WHERE id = {$id} ";
......@@ -930,3 +914,60 @@ function grantprograms_getCustomFieldData($id) {
}
return $customFieldData;
}
function grantprograms_define($extensionsDir) {
$file = fopen($extensionsDir .'biz.jmaconsulting.grantprograms/grantprograms_data_define.php', 'w' );
fwrite($file, "<?php\n\n//define custom table Names.\ndefine('COURSE_CONFERENCE_DETAILS', 'civicrm_value_nei_course_conference_details');\ndefine('EMPLOYMENT_INFORMATION', 'civicrm_value_nei_employment_information');\ndefine('GENERAL_INFORMATION', 'civicrm_value_nei_general_information');\ndefine('NEI_ID_TABLE', 'civicrm_value_nei_id');\n\n");
fwrite($file, "//define custom group Names.\ndefine('NEI_EMPLOYMENT', 'NEI_Employment_Information');\ndefine('NEI_GENERAL', 'NEI_General_information');\ndefine('NEI_CONFERENCE', 'NEI_Course_conference_details');\n\n");
fwrite($file, "//define custom groups Ids.\n");
$tables = array(
'civicrm_value_nei_employment_information' => 'COURSE_CONFERENCE_DETAILS_ID',
'civicrm_value_nei_general_information' => 'EMPLOYMENT_INFORMATION_ID',
'civicrm_value_nei_course_conference_details' => 'GENERAL_INFORMATION_ID',
'civicrm_value_nei_id' => 'NEI_ID',
);
foreach ($tables as $tableKey => $tableValue) {
fwrite($file, "define('".$tableValue."', '".CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $tableKey, 'id' ,'table_name')."');\n");
}
fwrite($file, "\n//define custom field Ids and Columns.\n");
$customFields = array(
'predominant_clinical_area_of_pra' => 'NEI_PRACTICE_AREA',
'nei_employment_status' => 'NEI_EMPLOYMENT_STATUS',
'if_you_are_not_employed_indicate' => 'EMPLOYED_INDICATE',
'other' => 'EMPLOYMENT_OTHER',
'employer_name' => 'EMPLOYER_NAME',
'province_of_employment' => 'PROVINCES_OF_EMPLOYMENT',
'position' => 'POSITION',
'select_or_other' => 'POSITION_OTHER',
'employment_setting' => 'EMPLOYMENT_SETTING',
'employment_setting_other' => 'EMPLOYMENT_SETTING_OTHER',
'work_phone' => 'WORK_PHONE',
'work_phone_extension' => 'WORK_PHONE_EXTENSION',
'how_did_you_hear_about_this_init' => 'NEI_HEAR_ABOUT',
'other_initiative' => 'INITIATIVE_OTHER',
'course_conference_type' => 'COURSE_CONFERENCE_TYPE',
'course_conference_type_other' => 'COURSE_CONFERENCE_TYPE_OTHER',
'course_conference_code' => 'COURSE_CONFERENCE_CODE',
'course_conference_name' => 'COURSE_CONFERENCE_NAME',
'course_conference_provider' => 'COURSE_CONFERENCE_PROVDER',
'how_will_this_course_enhance_the' => 'NEI_COURSE_ENHANCEMENT',
'proof_of_completion' => 'PROOF_OF_COMPELTION',
'proof_of_payment' => 'PROOF_OF_PAYMENT',
'type_of_course_provider' => 'COURSE_PROVIDER_TYPE',
'start_date' => 'START_DATE',
'end_date' => 'END_DATE',
'college_of_nurses_of_ontario_reg' => 'NEI_CNO_REGISTRATION_ID',
'social_insurance_number' => 'NEI_CIN',
);
foreach ($customFields as $tableKey => $tableValue) {
fwrite($file, "define('".$tableValue."', '".CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $tableKey, 'id' ,'column_name')."');\n");
fwrite($file, "define('".$tableValue."_COLUMN', '".$tableKey."');\n");
}
fwrite($file, "\ndefine('PAY_GRANTS', 5);\ndefine('DELETE_GRANTS', 1);\n\n?>");
fclose($file);
return;
}
\ No newline at end of file
<?php
// placeholder which ensures custom group and custom fields and custom tables.
?>
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment