PHP code example of mothership-ec / cog-mothership-reports
1. Go to this page and download the library: Download mothership-ec/cog-mothership-reports library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mothership-ec / cog-mothership-reports example snippets
public function registerReports($services)
{
$services['user.user_summary'] = $services->factory(function($c) {
return new User\Report\UserSummary(
$c['db.query.builder.factory'],
$c['routing.generator']
);
});
$services['user.reports'] = function($c) {
$reports = new ReportCollection;
$reports
->add($c['user.user_summary'])
;
return $reports;
};
}
public function getCharts()
{
$data = $this->_dataTransform($this->_getQuery()->run(), "json");
$columns = $this->_parseColumns($this->getColumns());
foreach ($this->_charts as $chart) {
$chart->setColumns($columns);
$chart->setData($data);
}
return $this->_charts;
}
protected function _getQuery()
{
$queryBuilder = $this->_builderFactory->getQueryBuilder();
$queryBuilder
->select('user.user_id AS "ID"')
->select('created_at AS "Created"')
->select('CONCAT(surname,", ",forename) AS "User"')
->select('email AS "Email"')
->from('user')
->orderBy('surname')
;
return $queryBuilder->getQuery();
}