From 509510616b060e448eebf966fdd908c90757c64d Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 25 Feb 2015 19:34:02 +1300 Subject: [PATCH] CRM-15941 separate parts of the report 'criteria' form This puts them in regions & allows them to be overridden on a more granular level --- CRM/Report/Form.php | 42 +++ templates/CRM/Report/Form/Criteria.tpl | 271 +++--------------- .../Report/Form/Criteria/FieldSelection.tpl | 57 ++++ .../CRM/Report/Form/Criteria/Filters.tpl | 78 +++++ .../CRM/Report/Form/Criteria/GroupBy.tpl | 47 +++ .../CRM/Report/Form/Criteria/OrderBy.tpl | 93 ++++++ .../Report/Form/Criteria/ReportOptions.tpl | 44 +++ 7 files changed, 399 insertions(+), 233 deletions(-) create mode 100644 templates/CRM/Report/Form/Criteria/FieldSelection.tpl create mode 100644 templates/CRM/Report/Form/Criteria/Filters.tpl create mode 100644 templates/CRM/Report/Form/Criteria/GroupBy.tpl create mode 100644 templates/CRM/Report/Form/Criteria/OrderBy.tpl create mode 100644 templates/CRM/Report/Form/Criteria/ReportOptions.tpl diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 877e3b2f8f..77f7c0e28d 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -168,6 +168,13 @@ class CRM_Report_Form extends CRM_Core_Form { public $_drilldownReport = array(); + /** + * Tabs to display on report. + * + * @var array + */ + protected $tabs = array(); + /** * An attribute for checkbox/radio form field layout * @@ -986,9 +993,16 @@ class CRM_Report_Form extends CRM_Core_Form { $this->addCheckBox("fields", ts('Select Columns'), $options, NULL, NULL, NULL, NULL, $this->_fourColumnAttribute, TRUE ); + $this->tabs[] = 'FieldSelection'; + // Note this assignment is only really required in buildForm. It is being 'over-called' + // to reduce risk of being missed due to overridden functions. + $this->assign('tabs', $this->tabs); $this->assign('colGroups', $colGroups); } + /** + * Add filters to report. + */ public function addFilters() { $filters = array(); $count = 1; @@ -1100,9 +1114,16 @@ class CRM_Report_Form extends CRM_Core_Form { } } } + $this->tabs[] = 'Filters'; + // Note this assignment is only really required in buildForm. It is being 'over-called' + // to reduce risk of being missed due to overridden functions. + $this->assign('tabs', $this->tabs); $this->assign('filters', $filters); } + /* + * Add options defined in $this->_options to the report. + */ public function addOptions() { if (!empty($this->_options)) { // FIXME: For now lets build all elements as checkboxes. @@ -1122,9 +1143,16 @@ class CRM_Report_Form extends CRM_Core_Form { } } } + $this->tabs[] = 'OrderBy'; + // Note this assignment is only really required in buildForm. It is being 'over-called' + // to reduce risk of being missed due to overridden functions. + $this->assign('tabs', $this->tabs); $this->assign('otherOptions', $this->_options); } + /** + * Add chart options to the report. + */ public function addChartOptions() { if (!empty($this->_charts)) { $this->addElement('select', "charts", ts('Chart'), $this->_charts); @@ -1133,6 +1161,9 @@ class CRM_Report_Form extends CRM_Core_Form { } } + /** + * Add group by options to the report. + */ public function addGroupBys() { $options = $freqElements = array(); @@ -1152,6 +1183,10 @@ class CRM_Report_Form extends CRM_Core_Form { NULL, NULL, NULL, $this->_fourColumnAttribute ); $this->assign('groupByElements', $options); + $this->tabs[] = 'GroupBy'; + // Note this assignment is only really required in buildForm. It is being 'over-called' + // to reduce risk of being missed due to overridden functions. + $this->assign('tabs', $this->tabs); foreach ($freqElements as $name) { $this->addElement('select', "group_bys_freq[$name]", @@ -1190,6 +1225,10 @@ class CRM_Report_Form extends CRM_Core_Form { asort($options); $this->assign('orderByOptions', $options); + $this->tabs[] = 'OrderBy.tpl'; + // Note this assignment is only really required in buildForm. It is being 'over-called' + // to reduce risk of being missed due to overridden functions. + $this->assign('tabs', $this->tabs); if (!empty($options)) { $options = array( @@ -1278,6 +1317,9 @@ class CRM_Report_Form extends CRM_Core_Form { ))) { $this->addFormRule(array(get_class($this), 'formRule'), $this); } + // Note this assignment is only really required in buildForm. It is being 'over-called' + // to reduce risk of being missed due to overridden functions. + $this->assign('tabs', $this->tabs); } /** diff --git a/templates/CRM/Report/Form/Criteria.tpl b/templates/CRM/Report/Form/Criteria.tpl index 4051bf2464..7ebb5ad8f5 100644 --- a/templates/CRM/Report/Form/Criteria.tpl +++ b/templates/CRM/Report/Form/Criteria.tpl @@ -24,245 +24,51 @@ +--------------------------------------------------------------------+ *} {* Report form criteria section *} -{if $colGroups} -
- {foreach from=$colGroups item=grpFields key=dnc} - {assign var="count" value="0"} - {* Wrap custom field sets in collapsed accordion pane. *} - {if $grpFields.group_title} - - {/if} - {/foreach} -
-{/if} -{if $groupByElements} -
- {assign var="count" value="0"} - - - {foreach from=$groupByElements item=gbElem key=dnc} - {assign var="count" value=`$count+1`} - - {if $count is div by 4} - - {/if} - {/foreach} - {if $count is not div by 4} - - {/if} - -
- {$form.group_bys[$gbElem].html} - {if $form.group_bys_freq[$gbElem].html}:
-   {$form.group_bys_freq[$gbElem].label} {$form.group_bys_freq[$gbElem].html} - {/if} -
-
-{/if} +{foreach from=$tabs item=tab} + $region = {"report-tab"|cat:$tab} + $fileName = {"Criteria/"|cat:$tab|cat:".tpl"} + {crmRegion name=$region} + {include file=$fileName} + {/crmRegion} +{/foreach} -{if $orderByOptions} -
- - - - - - - - - - {section name=rowLoop start=1 loop=6} - {assign var=index value=$smarty.section.rowLoop.index} - - - - - - - - {/section} -
  {ts}Column{/ts} {ts}Order{/ts} {ts}Section Header / Group By{/ts} {ts}Page Break{/ts}
- {if $index GT 1} - {ts}hide field or section{/ts} - {/if} - {$form.order_bys.$index.column.html} {$form.order_bys.$index.order.html} {$form.order_bys.$index.section.html} {$form.order_bys.$index.pageBreak.html}
- - -
-{/if} - -{if $otherOptions} -
- - {assign var="optionCount" value=0} - - {foreach from=$otherOptions item=optionField key=optionName} - {assign var="optionCount" value=`$optionCount+1`} - - {if $optionCount is div by 2} - - {/if} - {/foreach} - {if $optionCount is not div by 2} - - {/if} - -
{if $form.$optionName.label}{$form.$optionName.label} {/if}{$form.$optionName.html}
-
-{/if} - -{if $filters} -
- - {assign var="counter" value=1} - {foreach from=$filters item=table key=tableName} - {assign var="filterCount" value=$table|@count} - {* Wrap custom field sets in collapsed accordion pane. *} - {if $colGroups.$tableName.group_title and $filterCount gte 1} - {* we should close table that contains other filter elements before we start building custom group accordian *} - {if $counter eq 1} -
- {assign var="counter" value=0} - {/if} - - {assign var=closed value=1"} {*-- ie table tags are closed-- *} - {else} - {assign var=closed value=0"} {*-- ie table tags are not closed-- *} - {/if} - - {/foreach} - {if $closed eq 0 }{/if} -
- {/if} - - {literal} +{literal} {/literal} - diff --git a/templates/CRM/Report/Form/Criteria/FieldSelection.tpl b/templates/CRM/Report/Form/Criteria/FieldSelection.tpl new file mode 100644 index 0000000000..4775750252 --- /dev/null +++ b/templates/CRM/Report/Form/Criteria/FieldSelection.tpl @@ -0,0 +1,57 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.6 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2014 | + +--------------------------------------------------------------------+ + | 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 | + +--------------------------------------------------------------------+ +*} + +
+ {foreach from=$colGroups item=grpFields key=dnc} + {assign var="count" value="0"} + {* Wrap custom field sets in collapsed accordion pane. *} + {if $grpFields.group_title} + + {/if} + {/foreach} +
diff --git a/templates/CRM/Report/Form/Criteria/Filters.tpl b/templates/CRM/Report/Form/Criteria/Filters.tpl new file mode 100644 index 0000000000..2b99f1c9c0 --- /dev/null +++ b/templates/CRM/Report/Form/Criteria/Filters.tpl @@ -0,0 +1,78 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.6 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2014 | + +--------------------------------------------------------------------+ + | 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 | + +--------------------------------------------------------------------+ +*} + +
+ + {assign var="counter" value=1} + {foreach from=$filters item=table key=tableName} + {assign var="filterCount" value=$table|@count} + {* Wrap custom field sets in collapsed accordion pane. *} + {if $colGroups.$tableName.group_title and $filterCount gte 1} + {* we should close table that contains other filter elements before we start building custom group accordian *} + {if $counter eq 1} +
+ {assign var="counter" value=0} + {/if} + + {assign var=closed value="1"} {*-- ie table tags are closed-- *} + {else} + {assign var=closed value="0"} {*-- ie table tags are not closed-- *} + {/if} + + {/foreach} + {if $closed eq 0 }{/if} +
diff --git a/templates/CRM/Report/Form/Criteria/GroupBy.tpl b/templates/CRM/Report/Form/Criteria/GroupBy.tpl new file mode 100644 index 0000000000..e247e29391 --- /dev/null +++ b/templates/CRM/Report/Form/Criteria/GroupBy.tpl @@ -0,0 +1,47 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.6 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2014 | + +--------------------------------------------------------------------+ + | 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 | + +--------------------------------------------------------------------+ +*} +
+ {assign var="count" value="0"} + + + {foreach from=$groupByElements item=gbElem key=dnc} + {assign var="count" value=`$count+1`} + + {if $count is div by 4} + + {/if} + {/foreach} + {if $count is not div by 4} + + {/if} + +
+ {$form.group_bys[$gbElem].html} + {if $form.group_bys_freq[$gbElem].html}:
+   {$form.group_bys_freq[$gbElem].label} {$form.group_bys_freq[$gbElem].html} + {/if} +
+
diff --git a/templates/CRM/Report/Form/Criteria/OrderBy.tpl b/templates/CRM/Report/Form/Criteria/OrderBy.tpl new file mode 100644 index 0000000000..3be45c17c9 --- /dev/null +++ b/templates/CRM/Report/Form/Criteria/OrderBy.tpl @@ -0,0 +1,93 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.6 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2014 | + +--------------------------------------------------------------------+ + | 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 | + +--------------------------------------------------------------------+ +*} + + +
+ + + + + + + + + + {section name=rowLoop start=1 loop=6} + {assign var=index value=$smarty.section.rowLoop.index} + + + + + + + + {/section} +
  {ts}Column{/ts} {ts}Order{/ts} {ts}Section Header / Group By{/ts} {ts}Page Break{/ts}
+ {if $index GT 1} + {ts}hide field or section{/ts} + {/if} + {$form.order_bys.$index.column.html} {$form.order_bys.$index.order.html} {$form.order_bys.$index.section.html} {$form.order_bys.$index.pageBreak.html}
+ + +
diff --git a/templates/CRM/Report/Form/Criteria/ReportOptions.tpl b/templates/CRM/Report/Form/Criteria/ReportOptions.tpl new file mode 100644 index 0000000000..1f7cdd5afc --- /dev/null +++ b/templates/CRM/Report/Form/Criteria/ReportOptions.tpl @@ -0,0 +1,44 @@ +{* ++--------------------------------------------------------------------+ +| CiviCRM version 4.6 | ++--------------------------------------------------------------------+ +| Copyright CiviCRM LLC (c) 2004-2014 | ++--------------------------------------------------------------------+ +| 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 | ++--------------------------------------------------------------------+ +*} +{if $otherOptions} +
+ + {assign var="optionCount" value=0} + + {foreach from=$otherOptions item=optionField key=optionName} + {assign var="optionCount" value=`$optionCount+1`} + + {if $optionCount is div by 2} + + {/if} + {/foreach} + {if $optionCount is not div by 2} + + {/if} + +
{if $form.$optionName.label}{$form.$optionName.label} {/if}{$form.$optionName.html}
+
+{/if} -- 2.25.1