Loading...
 

 Note

This page is to document “what Tiki ‘’should’’ do”. For feature documentation (what Tiki does), please see corresponding page on doc site

Report

New feature in Tiki9

Tiki Report is a new way of creating and extracting data from Tiki in version 9 (trunk at time of writing). They consist of an abstract way of assembling each phase needed to create reports.

You create a Report Definition in which you define an input method, that returns what is possible in your report, and then an output method, that is your desired report criteria based on user input. The report user interface is automatically generated based off of the input method.

The aim with Reports is to eventually have saveable, reusable reports, that generate live data for use in a dashboard or spreadsheet.

Bugs & Wishes

Open and Pending

Wishlist

Closed


Things to keep in mind

  • Files in lib/core/Report folder are used for report building
  • Files in /lib/core/Report/Definition/ are those used to define first what reports can be generated and then their output, unless further developing how reports are generated
    • These files are automatically listed, they probably need feature detection

How to create a definition

  • Definitions are an abstract on what can be created from your report


Basic Generic Definition (copy to /lib/core/Report/Definition or name “Generic.php”):

class Report_Definition_Generic
{	
	function input()
	{//here we tell report what we can build with out report
		return array("values"=>array(),"options"=>array());
	}

	function output($values = array())
	{//here we assemble report based off of
		return $myGenericReportObject->assemble($values);
	}
}


Example for Tracker Definition:

<?php
class Report_Definition_Tracker
{	
	function input() {
		global $tikilib;
		$trackers = array();
		foreach($tikilib->table('tiki_trackers')->fetchAll(array('trackerId','name')) as $column) {
			$trackers[] = array(
				"name"=> $column['name'] . ' - ' . $column['trackerId'],
				"value"=> $column['trackerId'],
			);
		}
		
		$trackerFields = array();
		foreach($tikilib->table('tiki_tracker_fields')->fetchAll(array('trackerId', 'fieldId', 'name')) as $column) {
			$trackerFields[] = array(
				"name"=> $column['name'] . ' - ' . $column['fieldId'],
				"value"=> $column['fieldId'],
				"dependancy"=> $column['trackerId'],
			);
		}

		/*
			type:
				single (if value, turns into list, if no value, is textbox)
				multi (needs value, is checkbox)
				date	(simple date range)
				singeOneToOne (
				
		*/
		return array(
			"values"=> array(
				"trackers"=>		$trackers,
				"trackerFields"=>	$trackerFields,
				"trackerItemStatus"=>array("o", "p", "c"),
			),
			"options"=> array(
				array(
					"label"=> 		tr("Tracker"),
					"name"=> 		"tracker",
					"type"=> 		"single",
					"values"=> 		"trackers",
					"repeats"=>		false,
					"required"=>	true,
					"options" =>	array(
						array(
							"label"=> 		tr("Start"),
							"name"=> 		"start",
							"type"=> 		"date",
							"repeats"=>		false,
							"required"=>	false,
						),
						array(
							"label"=> 		tr("End"),
							"name"=> 		"end",
							"type"=> 		"date",
							"repeats"=>		false,
							"required"=>	false,
						),
						array(
							"label"=> 		tr("Item Id"),
							"name"=> 		"itemId",
							"type"=> 		"single",
							"repeats"=>		false,
							"required"=>	false,
						),
						array(
							"label"=> 		tr("Status"),
							"name"=> 		"status",
							"type"=> 		"multi",
							"values"=> 		"trackerItemStatus",
							"repeats"=>		false,
							"required"=>	false,
						),
						array(
							"label"=> 		tr("Search"),
							"relationLabel"=>tr(" for "),
							"name"=> 		"search",
							"type"=> 		"singleOneToOne",
							"dependancy"=>	array("tracker"),
							"values"=> 		array("trackerFields"),
							"repeats"=>		true,
							"required"=>	false,
						),
						array(
							"label"=> 		tr("Fields"),
							"name"=> 		"fields",
							"type"=> 		"multi",
							"dependancy"=>	"tracker",
							"values"=> 		"trackerFields",
							"repeats"=>		false,
							"required"=>	false,
						),
					),
				),
			),
		);
	}
	
	function output($values = array())
	{
		global $tikilib;
		$tracker = $values['tracker'];
		
		$qry = TikiLib::lib('trkqry')->tracker($tracker['value'])
			->start($tracker['start']['value'])
			->end($tracker['end']['value'])
			->itemId($tracker['itemId']['value'])
			->excludeDetails();
		
		if (!empty($tracker['status'])) {
			$allStatus = '';
			foreach($tracker['status'] as $status) {
				if (!empty($status['value'])) $allStatus .= $status['value'];
			}
			
			$qry->status($allStatus);
		}
		
		if (!empty($tracker['search'])) {
			$fieldIds = array();
			$search = array();
			
			for($i = 0; $i < count($tracker['search']); $i++) {
				if (!empty($tracker['search'][$i]) && $tracker['search'][$i + 1]) {
					$fieldIds[] = $tracker['search']['value'][$i];
					$search[] = $tracker['search']['value'][$i + 1];
				}
				$i++			; //searches are in groups of 2
			}
			
			if (!empty($fieldIds) && !empty($search)) {
				$qry
					->fields($fieldIds)
					->equals($search);
			}
		}
		
		$result = $qry->query(); 
		
		if (!empty($tracker['fields'])) {
			$newResult = array();
			foreach($result as $itemKey => $item) {
				$newResult[$itemKey] = array();
				foreach($tracker['fields'] as $field) {
					$newResult[$itemKey][$field['value']] = $result[$itemKey][$field['value']]; 
				}
			}
			
			$result = $newResult;
			unset($newResult);
		}
		
		return $result;
	}
}

Array value from input has 2 possible keys values(optional) & options(required)

Creating report values

each key in values is a sub-array with the following keys:
name - User Interface Name, please use tr() when possible
value - selectable and returned value
dependancy - parent value dependancy (optional)

Creating reportable options

Options consist of the following variables and are nestable:

  • label - What it will be called on the user interface, please use tr() when possible
  • name - The array name what it will be returned as
  • type - How it is going to be treated on the user interface
    • Acceptable types: single, date, multi, singleOneToOne
  • values - will link with values key at user interface
    • If type set to single, will give select (drop down list of options)
  • repeats - not yet working
  • required - not yet working
  • options - nested option(s)

Example 1

  • Create a new wiki page, for example, wikiReport
  • Paste this simple text into it:
{report}
  • Save the wiki page.
  • Click the pencil edit icon to edit the page you just saved.
  • A report plugin configuration panel will pop up.
  • Perhaps select the Report Type “Tracker”. Select one of your trackers and a couple of fields from that tracker.
  • Complete that panel and save it.
  • On your wikiReport page, you should now see a table, non-editable, of your tracker data.

Example 2

  • This process is still under construction...
  • Create a file on your webserver:
    lib/core/Report/Definition/TestReport.php
  • Paste into that file the ~150+ lines of code from the “Example for Tracker Definition” above.
  • Save that file.
  • Follow Example 1 immediately above, but instead of selecting Report Type “Tracker”, you will see your new report design “TestReport” in the Report Type drop down list.



Related:

alias

Keywords

The following is a list of keywords that should serve as hubs for navigation within the Tiki development and should correspond to documentation keywords.

Each feature in Tiki has a wiki page which regroups all the bugs, requests for enhancements, etc. It is somewhat a form of wiki-based project management. You can also express your interest in a feature by adding it to your profile. You can also try out the Dynamic filter.

Accessibility (WAI & 508)
Accounting 7.x
Administration
Ajax 2.x
Articles & Submissions
Backlinks
Banner
Batch 6.x
BigBlueButton audio/video/chat/screensharing (5.x)
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Comment
Communication Center
Consistency
Contacts Address book
Contact us
Content template
Contribution 2.x
Cookie
Copyright
Credits 6.x
Custom Home (and Group Home Page)
Database MySQL - MyISAM
Database MySQL - InnoDB
Date and Time
Debugger Console
Directory (of hyperlinks)
Documentation link from Tiki to doc.tiki.org (Help System)
Docs 8.x
DogFood
Draw 7.x
Dynamic Content
Preferences
Dynamic Variable
External Authentication
FAQ
Featured links
Feeds (RSS)
File Gallery
Forum
Friendship Network (Community)
Group
Help
History
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
jQuery
Kaltura video management
Karma
Live Support
Logs (system & action)
Lost edit protection
Mail-in
Map
Menu
Meta Tag
Missing features
Visual Mapping 3.x
Mobile Tiki and Voice Tiki
Mods
Modules
MultiTiki
MyTiki
Newsletter
Notepad
OS independence (Non-Linux, Windows/IIS, Mac, BSD)
Organic Groups (Self-managed Teams)
Payment 5.x
Performance Speed / Load / Compression / Cache
Permission
Poll
Profiles
Quiz
Rating
Realname
Report
Revision Approval
Score
Search engine optimization (SEO)
Search
Security
Semantic links 3.x
Share
Shopping Cart 5.x
Shoutbox
Site Identity
Slideshow
Smarty Template
Social Networking
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Staging and Approval
Stats
Survey
Syntax Highlighter (Codemirror)
Tablesorter
Tags 2.x
Task
Tell a Friend, alert + Social Bookmarking
Terms and Conditions
Theme
TikiTests 2.x
Timesheet
Token Access
Toolbar (Quicktags)
Tours
Trackers
TRIM
User Administration
User Files
User Menu
Watch
WebHelp
Webmail and Groupmail
WebServices 3.x
Wiki 3D
Wiki History, page rename, etc
Wiki plugins extends basic syntax
Wiki syntax text area, parser, etc
Wiki structure (book and table of content)
Workspace and perspectives 4.x
WYSIWTSN 4.x
WYSIWYCA
WYSIWYG 2.x
XMLRPC




Useful Tools