}
}
+ /**
+ * @param bool $freeze
+ *
+ * @return array
+ */
function setDefaultValues($freeze = TRUE) {
$freezeGroup = array();
return $this->_defaults;
}
+ /**
+ * @param $group
+ * @param $grpFieldName
+ *
+ * @return bool
+ */
function getElementFromGroup($group, $grpFieldName) {
$eleObj = $this->getElement($group);
foreach ($eleObj->_elements as $index => $obj) {
if (count($operations) <= 1) {
$element->freeze();
}
- $select = $this->addElement('select', "{$fieldName}_value", NULL,
- $field['options'], array(
- 'size' => 4,
- 'style' => 'min-width:250px',
- )
- );
- $select->setMultiple(TRUE);
+ $this->addElement('select', "{$fieldName}_value", NULL, $field['options'], array(
+ 'style' => 'min-width:250px',
+ 'class' => 'crm-select2',
+ 'multiple' => TRUE,
+ 'placeholder' => ts('- select -'),
+ ));
}
break;
}
}
}
+
+ $stateCountryMap[] = array(
+ 'country' => 'country_id_value',
+ 'state_province' => 'state_province_id_value',
+ 'county' => 'county_id_value'
+ );
+ CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
+
$this->assign('filters', $filters);
}
if (CRM_Core_Permission::check('administer Reports') && $this->_add2groupSupported) {
$this->addElement('select', 'groups', ts('Group'),
- array('' => ts('- select group -')) + CRM_Core_PseudoConstant::staticGroup()
+ array('' => ts('Add Contacts to Group')) + CRM_Core_PseudoConstant::nestedGroup(),
+ array('class' => 'crm-select2 crm-action-menu action-icon-plus huge')
);
$this->assign('group', TRUE);
}
- $label = ts('Add These Contacts to Group');
- $this->addElement('submit', $this->_groupButtonName, $label, array('onclick' => 'return checkGroup();'));
+ $this->addElement('submit', $this->_groupButtonName, '', array('style' => 'display: none;'));
$this->addChartOptions();
$this->addButtons(array(
// a formrule function to ensure that fields selected in group_by
// (if any) should only be the ones present in display/select fields criteria;
// note: works if and only if any custom field selected in group_by.
+ /**
+ * @param $fields
+ * @param array $ignoreFields
+ *
+ * @return array
+ */
function customDataFormRule($fields, $ignoreFields = array( )) {
$errors = array();
if (!empty($this->_customGroupExtends) && $this->_customGroupGroupBy && !empty($fields['group_bys'])) {
// Note: $fieldName param allows inheriting class to build operationPairs
// specific to a field.
+ /**
+ * @param string $type
+ * @param null $fieldName
+ *
+ * @return array
+ */
function getOperationPair($type = "string", $fieldName = NULL) {
// FIXME: At some point we should move these key-val pairs
// to option_group and option_value table.
'title' => ts('Group'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'group' => TRUE,
- 'options' => CRM_Core_PseudoConstant::group(),
+ 'options' => CRM_Core_PseudoConstant::nestedGroup(),
),
);
if (empty($this->_columns['civicrm_group']['dao'])) {
}
}
+ /**
+ * @param string $operator
+ *
+ * @return string
+ */
function getSQLOperator($operator = "like") {
switch ($operator) {
case 'eq':
}
}
+ /**
+ * @param $field
+ * @param $op
+ * @param $value
+ * @param $min
+ * @param $max
+ *
+ * @return null|string
+ */
function whereClause(&$field, $op,
$value, $min, $max
) {
// entries.
$clause = $this->whereTagClause($field, $value, $op);
}
-
+ elseif (!empty($field['membership_org']) && $clause) {
+ $clause = $this->whereMembershipOrgClause($field, $value, $op);
+ }
+ elseif (!empty($field['membership_type']) && $clause) {
+ $clause = $this->whereMembershipTypeClause($field, $value, $op);
+ }
return $clause;
}
+ /**
+ * @param $fieldName
+ * @param $relative
+ * @param $from
+ * @param $to
+ * @param null $type
+ * @param null $fromTime
+ * @param null $toTime
+ *
+ * @return null|string
+ */
function dateClause($fieldName,
$relative, $from, $to, $type = NULL, $fromTime = NULL, $toTime = NULL
) {
return NULL;
}
+ /**
+ * @param $relative
+ * @param $from
+ * @param $to
+ * @param null $fromtime
+ * @param null $totime
+ *
+ * @return array
+ */
function getFromTo($relative, $from, $to, $fromtime = NULL, $totime = NULL) {
if (empty($totime)) {
$totime = '235959';
return array($from, $to);
}
+ /**
+ * @param $rows
+ */
function alterDisplay(&$rows) {
// custom code to alter rows
}
+ /**
+ * @param $rows
+ */
function alterCustomDataDisplay(&$rows) {
// custom code to alter rows having custom values
if (empty($this->_customGroupExtends)) {
}
}
+ /**
+ * @param $value
+ * @param $customField
+ * @param $fieldValueMap
+ *
+ * @return float|string
+ */
function formatCustomValues($value, $customField, $fieldValueMap) {
if (CRM_Utils_System::isNull($value)) {
return;
return $retValue;
}
+ /**
+ * @param $rows
+ */
function removeDuplicates(&$rows) {
if (empty($this->_noRepeats)) {
return;
}
}
+ /**
+ * @param $row
+ * @param $fields
+ * @param bool $subtotal
+ */
function fixSubTotalDisplay(&$row, $fields, $subtotal = TRUE) {
foreach ($row as $colName => $colVal) {
if (in_array($colName, $fields)) {
}
}
+ /**
+ * @param $rows
+ *
+ * @return bool
+ */
function grandTotal(&$rows) {
if (!$this->_rollup || ($this->_rollup == '') ||
($this->_limit && count($rows) >= self::ROW_COUNT_LIMIT)
return TRUE;
}
+ /**
+ * @param $rows
+ * @param bool $pager
+ */
function formatDisplay(&$rows, $pager = TRUE) {
// set pager based on if any limit was applied in the query.
if ($pager) {
$this->alterCustomDataDisplay($rows);
}
+ /**
+ * @param $rows
+ */
function buildChart(&$rows) {
// override this method for building charts.
}
$this->_select = "SELECT " . implode(', ', $select) . " ";
}
+ /**
+ * @param $tableName
+ * @param $tableKey
+ * @param $fieldName
+ * @param $field
+ *
+ * @return bool
+ */
function selectClause(&$tableName, $tableKey, &$fieldName, &$field) {
return FALSE;
}
}
+ /**
+ * @param bool $applyLimit
+ *
+ * @return string
+ */
function buildQuery($applyLimit = TRUE) {
$this->select();
$this->from();
$this->assign('sections', $this->_sections);
}
+ /**
+ * @return array
+ */
function unselectedSectionColumns() {
$selectColumns = array();
foreach ($this->_columns as $tableName => $table) {
}
}
+ /**
+ * @param $sql
+ * @param $rows
+ */
function buildRows($sql, &$rows) {
$dao = CRM_Core_DAO::executeQuery($sql);
if (!is_array($rows)) {
// use this method to modify $this->_columnHeaders
}
+ /**
+ * @param $rows
+ */
function doTemplateAssignment(&$rows) {
$this->assign_by_ref('columnHeaders', $this->_columnHeaders);
$this->assign_by_ref('rows', $rows);
}
// override this method to build your own statistics
+ /**
+ * @param $rows
+ *
+ * @return array
+ */
function statistics(&$rows) {
$statistics = array();
return $statistics;
}
+ /**
+ * @param $statistics
+ * @param $count
+ */
function countStat(&$statistics, $count) {
$statistics['counts']['rowCount'] = array('title' => ts('Row(s) Listed'),
'value' => $count,
}
}
+ /**
+ * @param $statistics
+ */
function groupByStat(&$statistics) {
if (!empty($this->_params['group_bys']) &&
is_array($this->_params['group_bys']) &&
}
}
+ /**
+ * @param $statistics
+ */
function filterStat(&$statistics) {
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('filters', $table)) {
}
}
+ /**
+ * @param null $rows
+ */
function endPostProcess(&$rows = NULL) {
if ( $this->_storeResultSet ) {
$this->_resultSet = $rows;
$this->_storeResultSet = TRUE;
}
+ /**
+ * @return bool
+ */
function getResultSet() {
return $this->_resultSet;
}
* Get Template file name - use default form template if a specific one has not been set up for this report
*
*/
+ /**
+ * Use the form name to create the tpl file name
+ *
+ * @return string
+ * @access public
+ */
+ /**
+ * @return string
+ */
function getTemplateFileName(){
$defaultTpl = parent::getTemplateFileName();
$template = CRM_Core_Smarty::singleton();
*
* Although this function is super-short it is useful to keep separate so it can be over-ridden by report classes.
*/
+ /**
+ * @return string
+ */
function compileContent(){
$templateFile = $this->getHookedTemplateFileName();
return $this->_formValues['report_header'] . CRM_Core_Form::$_template->fetch($templateFile) . $this->_formValues['report_footer'];
$this->endPostProcess($rows);
}
+ /**
+ * @param int $rowCount
+ */
function limit($rowCount = self::ROW_COUNT_LIMIT) {
// lets do the pager if in html mode
$this->_limit = NULL;
}
}
+ /**
+ * @param int $rowCount
+ */
function setPager($rowCount = self::ROW_COUNT_LIMIT) {
// CRM-14115, over-ride row count if rowCount is specified in URL
}
}
+ /**
+ * @param $field
+ * @param $value
+ * @param $op
+ *
+ * @return string
+ */
function whereGroupClause($field, $value, $op) {
$smartGroupQuery = "";
{$smartGroupQuery} ) ";
}
+ /**
+ * @param $field
+ * @param $value
+ * @param $op
+ *
+ * @return string
+ */
function whereTagClause($field, $value, $op) {
// not using left join in query because if any contact
// belongs to more than one tag, results duplicate
WHERE entity_table = 'civicrm_contact' AND {$clause} ) ";
}
+ function whereMembershipOrgClause($field, $value, $op) {
+ $sqlOp = $this->getSQLOperator($op);
+ if (!is_array($value)) {
+ $value = array($value);
+ }
+
+ $tmp_membership_org_sql_list = implode(', ', $value);
+ return " {$this->_aliases['civicrm_contact']}.id {$sqlOp} (
+ SELECT DISTINCT mem.contact_id
+ FROM civicrm_membership mem
+ LEFT JOIN civicrm_membership_status mem_status ON mem.status_id = mem_status.id
+ LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id
+ WHERE mt.member_of_contact_id IN (".$tmp_membership_org_sql_list.")
+ AND mt.is_active = '1'
+ AND mem_status.is_current_member = '1'
+ AND mem_status.is_active = '1' ) ";
+ }
+
+ function whereMembershipTypeClause($field, $value, $op) {
+ $sqlOp = $this->getSQLOperator($op);
+ if (!is_array($value)) {
+ $value = array($value);
+ }
+
+ $tmp_membership_sql_list = implode(', ', $value);
+ return " {$this->_aliases['civicrm_contact']}.id {$sqlOp} (
+ SELECT DISTINCT mem.contact_id
+ FROM civicrm_membership mem
+ LEFT JOIN civicrm_membership_status mem_status ON mem.status_id = mem_status.id
+ LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id
+ WHERE mem.membership_type_id IN (".$tmp_membership_sql_list.")
+ AND mt.is_active = '1'
+ AND mem_status.is_current_member = '1'
+ AND mem_status.is_active = '1' ) ";
+ }
+
+ /**
+ * @param string $tableAlias
+ */
function buildACLClause($tableAlias = 'contact_a') {
list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
}
+ /**
+ * @param bool $addFields
+ * @param array $permCustomGroupIds
+ */
function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = array()) {
if (empty($this->_customGroupExtends)) {
return;
}
}
+ /**
+ * @param $prop
+ *
+ * @return bool
+ */
function isFieldSelected($prop) {
if (empty($prop)) {
return FALSE;
array('title' => ts('Postal Code Suffix'),
'default' => CRM_Utils_Array::value('postal_code_suffix', $defaults, FALSE),
),
- 'county_id' =>
- array('title' => ts('County'),
- 'default' => CRM_Utils_Array::value('county_id', $defaults, FALSE),
- ),
+ 'country_id' =>
+ array('title' => ts('Country'),
+ 'default' => CRM_Utils_Array::value('country_id', $defaults, FALSE),
+ ),
'state_province_id' =>
array('title' => ts('State/Province'),
'default' => CRM_Utils_Array::value('state_province_id', $defaults, FALSE),
),
- 'country_id' =>
- array('title' => ts('Country'),
- 'default' => CRM_Utils_Array::value('country_id', $defaults, FALSE),
- ),
+ 'county_id' =>
+ array('title' => ts('County'),
+ 'default' => CRM_Utils_Array::value('county_id', $defaults, FALSE),
+ ),
),
'grouping' => 'location-fields',
),
'operator' => 'like',
'name' => 'city',
),
- 'county_id' => array(
- 'name' => 'county_id',
- 'title' => ts('County'),
+ 'country_id' => array(
+ 'name' => 'country_id',
+ 'title' => ts('Country'),
'type' => CRM_Utils_Type::T_INT,
'operatorType' =>
- CRM_Report_Form::OP_MULTISELECT,
+ CRM_Report_Form::OP_MULTISELECT,
'options' =>
- CRM_Core_PseudoConstant::county(),
+ CRM_Core_PseudoConstant::country(),
),
'state_province_id' => array(
'name' => 'state_province_id',
'title' => ts('State/Province'),
'type' => CRM_Utils_Type::T_INT,
'operatorType' =>
- CRM_Report_Form::OP_MULTISELECT,
+ CRM_Report_Form::OP_MULTISELECT,
'options' =>
- CRM_Core_PseudoConstant::stateProvince(),
+ CRM_Core_PseudoConstant::stateProvince(),
),
- 'country_id' => array(
- 'name' => 'country_id',
- 'title' => ts('Country'),
+ 'county_id' => array(
+ 'name' => 'county_id',
+ 'title' => ts('County'),
'type' => CRM_Utils_Type::T_INT,
'operatorType' =>
CRM_Report_Form::OP_MULTISELECT,
'options' =>
- CRM_Core_PseudoConstant::country(),
+ CRM_Core_PseudoConstant::county(),
),
);
}
/*
* Do AlterDisplay processing on Address Fields
*/
+ /**
+ * @param $row
+ * @param $rows
+ * @param $rowNum
+ * @param $baseUrl
+ * @param $urltxt
+ *
+ * @return bool
+ */
function alterDisplayAddressFields(&$row, &$rows, &$rowNum, $baseUrl, $urltxt) {
$criteriaQueryParams = CRM_Report_Utils_Report::getPreviewCriteriaQueryParams($this->_defaults, $this->_params);
$entryFound = FALSE;
/*
* Adjusts dates passed in to YEAR() for fiscal year.
*/
+ /**
+ * @param $fieldName
+ *
+ * @return string
+ */
function fiscalYearOffset($fieldName) {
$config = CRM_Core_Config::singleton();
$fy = $config->fiscalYearStart;
}
+ /**
+ * @param $groupID
+ */
function add2group($groupID) {
if (is_numeric($groupID) && isset($this->_aliases['civicrm_contact'])) {
$select = "SELECT DISTINCT {$this->_aliases['civicrm_contact']}.id AS addtogroup_contact_id, ";