Merge pull request #312 from nlegoff/silex_report

[3.8] Refactor Report into silex controllers
This commit is contained in:
Romain Neutron
2013-02-15 06:59:12 -08:00
49 changed files with 3601 additions and 2386 deletions

View File

@@ -45,6 +45,8 @@ rewrite ^/user/notifications/.*$ /index.php last;
rewrite ^/download/.*$ /index.php last; rewrite ^/download/.*$ /index.php last;
rewrite ^/session/.*$ /index.php last; rewrite ^/session/.*$ /index.php last;
rewrite ^/report/.*$ /index.php last;
rewrite ^/client/.*$ /index.php last; rewrite ^/client/.*$ /index.php last;
rewrite ^/client/baskets.*$ /index.php last; rewrite ^/client/baskets.*$ /index.php last;

View File

@@ -56,6 +56,10 @@ use Alchemy\Phrasea\Controller\Prod\TOU;
use Alchemy\Phrasea\Controller\Prod\Upload; use Alchemy\Phrasea\Controller\Prod\Upload;
use Alchemy\Phrasea\Controller\Prod\UsrLists; use Alchemy\Phrasea\Controller\Prod\UsrLists;
use Alchemy\Phrasea\Controller\Prod\WorkZone; use Alchemy\Phrasea\Controller\Prod\WorkZone;
use Alchemy\Phrasea\Controller\Report\Activity as ReportActivity;
use Alchemy\Phrasea\Controller\Report\Informations as ReportInformations;
use Alchemy\Phrasea\Controller\Report\Export as ReportExport;
use Alchemy\Phrasea\Controller\Report\Root as ReportRoot;
use Alchemy\Phrasea\Controller\Root\Account; use Alchemy\Phrasea\Controller\Root\Account;
use Alchemy\Phrasea\Controller\Root\Developers; use Alchemy\Phrasea\Controller\Root\Developers;
use Alchemy\Phrasea\Controller\Root\Login; use Alchemy\Phrasea\Controller\Root\Login;
@@ -649,6 +653,11 @@ class Application extends SilexApplication
$this->mount('/download/', new DoDownload()); $this->mount('/download/', new DoDownload());
$this->mount('/session/', new Session()); $this->mount('/session/', new Session());
$this->mount('/report/', new ReportRoot());
$this->mount('/report/activity', new ReportActivity());
$this->mount('/report/informations', new ReportInformations());
$this->mount('/report/export', new ReportExport());
} }
private function reinitUser() private function reinitUser()

View File

@@ -0,0 +1,829 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Controller\Report;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
class Activity implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = $app['controllers_factory'];
$controllers->before(function() use ($app) {
$app['firewall']->requireAuthentication();
$app['firewall']->requireAccessToModule('report');
});
$controllers->post('/users/connexions', $this->call('doReportConnexionsByUsers'))
->bind('report_activity_users_connexions');
$controllers->post('/users/downloads', $this->call('doReportDownloadsByUsers'))
->bind('report_activity_users_downloads');;
$controllers->post('/questions/best-of', $this->call('doReportBestOfQuestions'))
->bind('report_activity_questions_bestof');
$controllers->post('/questions/no-best-of', $this->call('doReportNoBestOfQuestions'))
->bind('report_activity_questions_nobestof');
$controllers->post('/instance/hours', $this->call('doReportSiteActiviyPerHours'))
->bind('report_activity_instance_hours');
$controllers->post('/instance/days', $this->call('doReportSiteActiviyPerDays'))
->bind('report_activity_instance_days');
$controllers->post('/documents/pushed', $this->call('doReportPushedDocuments'))
->bind('report_activity_documents_pushed');
$controllers->post('/documents/added', $this->call('doReportAddedDocuments'))
->bind('report_activity_documents_added');
$controllers->post('/documents/edited', $this->call('doReportEditedDocuments'))
->bind('report_activity_documents_edited');
$controllers->post('/documents/validated', $this->call('doReportValidatedDocuments'))
->bind('report_activity_documents_validated');
return $controllers;
}
/**
* Display connexions report group by user
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportConnexionsByUsers(Application $app, Request $request)
{
$activity = new \module_report_activity(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$activity->setConfig(false);
$activity->setBound("user", true);
//set Limit
if ($activity->getEnableLimit()
&& ('' !== $page = $request->request->get('page', ''))
&& ('' !== $limit = $request->request->get('limit', ''))) {
$activity->setLimit($page, $limit);
} else {
$activity->setLimit(false, false);
}
if ($request->request->get('printcsv') == 'on') {
$activity->setHasLimit(false);
$activity->getConnexionBase(false, $request->request->get('on', 'user'));
try {
$csv = \format::arr_to_csv($activity->getResult(), $activity->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
} else {
$report = $activity->getConnexionBase(false, $request->request->get('on', 'user'));
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => false,
'title' => false
));
}
}
/**
* Display download report group by user
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportDownloadsByUsers(Application $app, Request $request)
{
$conf = array(
'user' => array(_('report:: utilisateur'), 0, 1, 0, 0),
'nbdoc' => array(_('report:: nombre de documents'), 0, 0, 0, 0),
'poiddoc' => array(_('report:: poids des documents'), 0, 0, 0, 0),
'nbprev' => array(_('report:: nombre de preview'), 0, 0, 0, 0),
'poidprev' => array(_('report:: poids des previews'), 0, 0, 0, 0)
);
$activity = new \module_report_activity(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$activity->setConfig(false);
//set Limit
if ($activity->getEnableLimit()
&& ('' !== $page = $request->request->get('page', ''))
&& ('' !== $limit = $request->request->get('limit', ''))) {
$activity->setLimit($page, $limit);
} else {
$activity->setLimit(false, false);
}
$report = $activity->getDetailDownload($conf, $request->request->get('on'));
if ($request->request->get('printcsv') == 'on') {
$activity->setHasLimit(false);
try {
$csv = \format::arr_to_csv($activity->getResult(), $activity->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
} else {
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => false,
'title' => false
));
}
}
/**
* Display the most asked question
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportBestOfQuestions(Application $app, Request $request)
{
$conf = array(
'search' => array(_('report:: question'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'nb_rep' => array(_('report:: nombre de reponses'), 0, 0, 0, 0)
);
$activity = new \module_report_activity(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$activity->setLimit(1, $request->request->get('limit', 20));
$activity->setTop(20);
$activity->setConfig(false);
if ($request->request->get('printcsv') == 'on') {
$activity->setHasLimit(false);
$activity->setPrettyString(false);
$activity->getTopQuestion($conf);
try {
$csv = \format::arr_to_csv($activity->getResult(), $activity->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
} else {
$report = $activity->getTopQuestion($conf);
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => false,
'title' => false
));
}
}
/**
* Display report about questions that return no result
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportNoBestOfQuestions(Application $app, Request $request)
{
$conf = array(
'search' => array(_('report:: question'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'nb_rep' => array(_('report:: nombre de reponses'), 0, 0, 0, 0)
);
$activity = new \module_report_activity(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
//set Limit
if ($activity->getEnableLimit()
&& ('' !== $page = $request->request->get('page', ''))
&& ('' !== $limit = $request->request->get('limit', ''))) {
$activity->setLimit($page, $limit);
} else {
$activity->setLimit(false, false);
}
$activity->setConfig(false);
if ($request->request->get('printcsv') == 'on') {
$activity->setHasLimit(false);
$activity->setPrettyString(false);
$activity->getTopQuestion($conf, true);
try {
$csv = \format::arr_to_csv($activity->getResult(), $activity->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
} else {
$report = $activity->getTopQuestion($conf, true);
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => false,
'title' => false
));
}
}
/**
* Display an overview of connexion among hours of the da
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportSiteActiviyPerHours(Application $app, Request $request)
{
$activity = new \module_report_activity(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$activity->setConfig(false);
$report = $activity->getActivityPerHours();
if ($request->request->get('printcsv') == 'on') {
$activity->setHasLimit(false);
$activity->setPrettyString(false);
try {
$csv = \format::arr_to_csv($activity->getResult(), $activity->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
} else {
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => true,
'is_doc' => false
)),
'display_nav' => false,
'title' => false
));
}
}
/**
* Display an overview of downloaded document grouped by day
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportSiteActiviyPerDays(Application $app, Request $request)
{
$conf = array(
'ddate' => array(_('report:: jour'), 0, 0, 0, 0),
'total' => array(_('report:: total des telechargements'), 0, 0, 0, 0),
'preview' => array(_('report:: preview'), 0, 0, 0, 0),
'document' => array(_('report:: document original'), 0, 0, 0, 0)
);
$activity = new \module_report_activity(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
//set Limit
if ($activity->getEnableLimit()
&& ('' !== $page = $request->request->get('page', ''))
&& ('' !== $limit = $request->request->get('limit', ''))) {
$activity->setLimit($page, $limit);
} else {
$activity->setLimit(false, false);
}
$activity->setConfig(false);
$report = $activity->getDownloadByBaseByDay($conf);
if ($request->request->get('printcsv') == 'on') {
$activity->setHasLimit(false);
$activity->setPrettyString(false);
try {
$csv = \format::arr_to_csv($activity->getResult(), $activity->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
} else {
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => false,
'title' => false
));
}
}
/**
* Display report about pushed documents
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportPushedDocuments(Application $app, Request $request)
{
$conf = array(
'user' => array('', 1, 0, 1, 1),
'getter' => array("Destinataire", 1, 0, 1, 1),
'date' => array('', 1, 0, 1, 1),
'record_id' => array('', 1, 1, 1, 1),
'file' => array('', 1, 0, 1, 1),
'mime' => array('', 1, 0, 1, 1),
);
$activity = new \module_report_push(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$activity->setConfig(false);
if ($request->request->get('printcsv') == 'on') {
$activity->setHasLimit(false);
$activity->setPrettyString(false);
try {
$csv = \format::arr_to_csv($activity->getResult(), $activity->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
}
$report = $this->doReport($app, $request, $activity, $conf);
if ($report instanceof Response) {
return $report;
}
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => $report['display_nav'], // do we display the prev and next button ?
'next' => $report['next_page'], //Number of the next page
'prev' => $report['previous_page'], //Number of the previoous page
'page' => $report['page'], //The current page
'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters
'col' => $report['active_column'], //all the columns where a filter is applied
'limit' => $report['nb_record']
));
}
/**
* Display report about added documents
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportAddedDocuments(Application $app, Request $request)
{
$conf = array(
'user' => array('', 1, 0, 1, 1),
'date' => array('', 1, 0, 1, 1),
'record_id' => array('', 1, 1, 1, 1),
'file' => array('', 1, 0, 1, 1),
'mime' => array('', 1, 0, 1, 1),
);
$activity = new \module_report_add(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$activity->setConfig(false);
if ($request->request->get('printcsv') == 'on') {
$activity->setHasLimit(false);
$activity->setPrettyString(false);
try {
$csv = \format::arr_to_csv($activity->getResult(), $activity->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
}
$report = $this->doReport($app, $request, $activity, $conf);
if ($report instanceof Response) {
return $report;
}
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => $report['display_nav'], // do we display the prev and next button ?
'next' => $report['next_page'], //Number of the next page
'prev' => $report['previous_page'], //Number of the previoous page
'page' => $report['page'], //The current page
'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters
'col' => $report['active_column'], //all the columns where a filter is applied
'limit' => $report['nb_record']
));
}
/**
* Display report about edited documents
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportEditedDocuments(Application $app, Request $request)
{
$conf = array(
'user' => array('', 1, 0, 1, 1),
'date' => array('', 1, 0, 1, 1),
'record_id' => array('', 1, 1, 1, 1),
'file' => array('', 1, 0, 1, 1),
'mime' => array('', 1, 0, 1, 1),
);
$activity = new \module_report_edit(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$activity->setConfig(false);
if ($request->request->get('printcsv') == 'on') {
$activity->setHasLimit(false);
$activity->setPrettyString(false);
try {
$csv = \format::arr_to_csv($activity->getResult(), $activity->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
}
$report = $this->doReport($app, $request, $activity, $conf);
if ($report instanceof Response) {
return $report;
}
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => $report['display_nav'], // do we display the prev and next button ?
'next' => $report['next_page'], //Number of the next page
'prev' => $report['previous_page'], //Number of the previoous page
'page' => $report['page'], //The current page
'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters
'col' => $report['active_column'], //all the columns where a filter is applied
'limit' => $report['nb_record']
));
}
/**
* Display report about validated documents
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportValidatedDocuments(Application $app, Request $request)
{
$conf = array(
'user' => array('', 1, 0, 1, 1),
'getter' => array("Destinataire", 1, 0, 1, 1),
'date' => array('', 1, 0, 1, 1),
'record_id' => array('', 1, 1, 1, 1),
'file' => array('', 1, 0, 1, 1),
'mime' => array('', 1, 0, 1, 1),
);
$activity = new \module_report_validate(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$activity->setConfig(false);
if ($request->request->get('printcsv') == 'on') {
$activity->setHasLimit(false);
$activity->setPrettyString(false);
try {
$csv = \format::arr_to_csv($activity->getResult(), $activity->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
}
$report = $this->doReport($app, $request, $activity, $conf);
if ($report instanceof Response) {
return $report;
}
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => $report['display_nav'], // do we display the prev and next button ?
'next' => $report['next_page'], //Number of the next page
'prev' => $report['previous_page'], //Number of the previoous page
'page' => $report['page'], //The current page
'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters
'col' => $report['active_column'], //all the columns where a filter is applied
'limit' => $report['nb_record']
));
}
/**
* Set Report configuration according to request parameters
*
* @param Application $app An application instance
* @param Request $request A request instance
* @param \module_report $report A report instance
* @param Array $conf A report column configuration
* @param Boolean $what Whether to group on a particular field or not
* @return Array
*/
private function doReport(Application $app, Request $request, \module_report $report, $conf, $what = false)
{
if ($app['phraseanet.registry']->get('GV_anonymousReport') == true) {
if (isset($conf['user'])) {
unset($conf['user']);
}
if (isset($conf['ip'])) {
unset($conf['ip']);
}
}
//save initial conf
$base_conf = $conf;
//format conf according user preferences
if ('' !== $columnsList = $request->request->get('list_column', '')) {
$new_conf = $conf;
$columns = explode(",", $columnsList);
foreach (array_keys($conf) as $col) {
if (!in_array($col, $columns)) {
unset($new_conf[$col]);
}
}
$conf = $new_conf;
}
//display content of a table column when user click on it
if ($request->request->get('conf') == 'on') {
return $app->json(array('liste' => $app['twig']->render('report/listColumn.html.twig', array(
'conf' => $base_conf
)), "title" => _("configuration")));
}
//set order
if (('' !== $order = $request->request->get('order', '')) && ('' !== $field = $request->request->get('champ', ''))) {
$report->setOrder($field, $order);
}
//work on filters
$mapColumnTitleToSqlField = $report->getTransQueryString();
$currentfilter = array();
if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) {
$currentfilter = @unserialize(urldecode($serializedFilter));
}
$filter = new \module_report_filter($app, $currentfilter, $mapColumnTitleToSqlField);
if ('' !== $filterColumn = $request->request->get('filter_column', '')) {
$field = current(explode(' ', $filterColumn));
$value = $request->request->get('filter_value', '');
if ($request->request->get('liste') == 'on') {
return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array(
'result' => $report->colFilter($field),
'field' => $field
)), "title" => sprintf(_('filtrer les resultats sur la colonne %s'), $field)));
}
if ($field === $value) {
$filter->removeFilter($field);
} else {
$filter->addFilter($field, '=', $value);
}
}
//set new request filter if user asking for them
if ($request->request->get('precise') == 1) {
$filter->addFilter('xml', 'LIKE', $request->request->get('word', ''));
} elseif ($request->request->get('precise') == 2) {
$filter->addFilter('record_id', '=', $request->request->get('word', ''));
}
//set filters to current report
$report->setFilter($filter->getTabFilter());
$report->setActiveColumn($filter->getActiveColumn());
$report->setPostingFilter($filter->getPostingFilter());
// display a new arraywhere results are group
if ('' !== $groupby = $request->request->get('groupby', '')) {
$report->setConfig(false);
$groupby = current(explode(' ', $groupby));
$reportArray = $report->buildReport(false, $groupby);
if (count($reportArray['allChamps']) > 0 && count($reportArray['display']) > 0) {
$groupField = isset($reportArray['display'][$reportArray['allChamps'][0]]['title']) ? $reportArray['display'][$reportArray['allChamps'][0]]['title'] : '';
} else {
$groupField = isset($conf[strtolower($groupby)]['title']) ? $conf[strtolower($groupby)]['title'] : '';
}
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => true,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => false,
'title' => _(sprintf('Groupement des resultats sur le champ %s', $groupField))
));
}
//set Limit
if ($report->getEnableLimit()
&& ('' !== $page = $request->request->get('page', ''))
&& ('' !== $limit = $request->request->get('limit', ''))) {
$report->setLimit($page, $limit);
} else {
$report->setLimit(false, false);
}
//time to build our report
if (false === $what) {
$reportArray = $report->buildReport($conf);
} else {
$reportArray = $report->buildReport($conf, $what, $request->request->get('tbl', false));
}
return $reportArray;
}
/**
* Prefix the method to call with the controller class name
*
* @param string $method The method to call
* @return string
*/
private function call($method)
{
return sprintf('%s::%s', __CLASS__, $method);
}
}

View File

@@ -0,0 +1,81 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Controller\Report;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
class Export implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = $app['controllers_factory'];
$controllers->before(function() use ($app) {
$app['firewall']->requireAuthentication();
$app['firewall']->requireAccessToModule('report');
});
$controllers->post('/csv', $this->call('exportCSV'))
->bind('report_export_csv');
return $controllers;
}
/**
* Export data to a csv file
*
* @param Application $app
* @param Request $request
* @return Response
*/
public function exportCSV(Application $app, Request $request)
{
$name = $request->request->get('name', 'export');
if (null === $data = $request->request->get('csv')) {
$app->abort(400);
}
$filename = mb_strtolower('report_' . $name . '_' . date('dmY') . '.csv');
$data = preg_replace('/[ \t\r\f]+/', '', $data);
$response = new Response($data, 200, array(
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
'Last-Modified' => gmdate('D, d M Y H:i:s'). ' GMT',
'Cache-Control' => 'no-store, no-cache, must-revalidate',
'Cache-Control' => 'post-check=0, pre-check=0',
'Pragma' => 'no-cache',
'Content-Type' => 'text/csv',
'Content-Length' => strlen($data),
'Cache-Control' => 'max-age=3600, must-revalidate',
'Content-Disposition' => 'max-age=3600, must-revalidate',
));
$response->headers->set('Content-Disposition', $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename));
return $response;
}
/**
* Prefix the method to call with the controller class name
*
* @param string $method The method to call
* @return string
*/
private function call($method)
{
return sprintf('%s::%s', __CLASS__, $method);
}
}

View File

@@ -0,0 +1,525 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Controller\Report;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
class Informations implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = $app['controllers_factory'];
$controllers->before(function() use ($app) {
$app['firewall']->requireAuthentication();
$app['firewall']->requireAccessToModule('report');
});
$controllers->post('/user', $this->call('doReportInformationsUser'))
->bind('report_infomations_user');
$controllers->post('/browser', $this->call('doReportInformationsBrowser'))
->bind('report_infomations_browser');
$controllers->post('/document', $this->call('doReportInformationsDocument'))
->bind('report_infomations_document');
return $controllers;
}
/**
* Display informations about a user
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportInformationsUser(Application $app, Request $request)
{
$conf = array(
'config' => array(
'photo' => array(_('report:: document'), 0, 0, 0, 0),
'record_id' => array(_('report:: record id'), 0, 0, 0, 0),
'date' => array(_('report:: date'), 0, 0, 0, 0),
'type' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0),
'titre' => array(_('report:: titre'), 0, 0, 0, 0),
'taille' => array(_('report:: poids'), 0, 0, 0, 0)
),
'conf' => array(
'identifiant' => array(_('report:: identifiant'), 0, 0, 0, 0),
'nom' => array(_('report:: nom'), 0, 0, 0, 0),
'mail' => array(_('report:: email'), 0, 0, 0, 0),
'adresse' => array(_('report:: adresse'), 0, 0, 0, 0),
'tel' => array(_('report:: telephone'), 0, 0, 0, 0)
),
'config_cnx' => array(
'ddate' => array(_('report:: date'), 0, 0, 0, 0),
'appli' => array(_('report:: modules'), 0, 0, 0, 0),
),
'config_dl' => array(
'ddate' => array(_('report:: date'), 0, 0, 0, 0),
'record_id' => array(_('report:: record id'), 0, 1, 0, 0),
'final' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0),
'coll_id' => array(_('report:: collections'), 0, 0, 0, 0),
'comment' => array(_('report:: commentaire'), 0, 0, 0, 0),
),
'config_ask' => array(
'search' => array(_('report:: question'), 0, 0, 0, 0),
'ddate' => array(_('report:: date'), 0, 0, 0, 0)
)
);
$report = null;
$html = $html_info = '';
$from = $request->request->get('from', '');
$on = $request->request->get('on', '');
$selectValue = $request->request->get('user', '');
if ('' === $selectValue) {
$app->abort(400);
}
if ('' !== $on && $app['phraseanet.registry']->get('GV_anonymousReport') == true) {
$conf['conf'] = array(
$on => array($on, 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0)
);
}
if ($from == 'CNXU' || $from == 'CNX') {
$report = new \module_report_connexion(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection'
));
$conf_array = $conf['config_cnx'];
$title = _('report:: historique des connexions');
} elseif ($from == 'USR' || $from == 'GEN') {
$report = new \module_report_download(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$conf_array = $conf['config_dl'];
$title = _('report:: historique des telechargements');
} elseif ($from == 'ASK') {
$report = new \module_report_question(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$conf_array = $conf['config_ask'];
$title = _('report:: historique des questions');
}
if ($report) {
$mapColumnTitleToSqlField = $report->getTransQueryString();
$currentfilter = array();
if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) {
$currentfilter = @unserialize(urldecode($serializedFilter));
}
$filter = new \module_report_filter($app, $currentfilter, $mapColumnTitleToSqlField);
if ('' !== $filterColumn = $request->request->get('filter_column', '')) {
$field = current(explode(' ', $filterColumn));
$value = $request->request->get('filter_value', '');
if ($request->request->get('liste') == 'on') {
return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array(
'result' => $report->colFilter($field),
'field' => $field
)), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)));
}
if ($field === $value) {
$filter->removeFilter($field);
} else {
$filter->addFilter($field, '=', $value);
}
}
if ('' !== $selectValue && '' !== $from) {
$filter->addfilter('usrid', '=', $selectValue);
} elseif ('' !== $on && '' !== $selectValue) {
$filter->addfilter($on, '=', $selectValue);
}
if ($report instanceof \module_report_download) {
$report->setIsInformative(true);
}
$report->setFilter($filter->getTabFilter());
$report->setOrder('ddate', 'DESC');
$report->setConfig(false);
$report->setTitle($title);
$report->setHasLimit(false);
$reportArray = $report->buildReport($conf_array);
if ($request->request->get('printcsv') == 'on') {
$report->setPrettyString(false);
try {
$csv = \format::arr_to_csv($report->getResult(), $report->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
}
$html = $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray,
'is_infouser' => $report instanceof \module_report_download,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
));
}
$info = new \module_report_nav(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$info->setPeriode('');
$info->setCsv(false);
$infoArray = $info->buildTabGrpInfo(
null !== $report ? $report->getReq() : '',
null !== $report ? $report->getParams() : array(),
$selectValue,
$conf['conf'],
$on
);
if (false == $app['phraseanet.registry']->get('GV_anonymousReport')) {
$html_info = $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($infoArray['report']) ? $infoArray['report'] : $infoArray,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
));
$title = ('' === $on && isset($infoArray['result'])) ? $infoArray['result'][0]['identifiant'] : $selectValue;
} else {
$title = $selectValue;
}
return $app->json(array(
'rs' => sprintf('%s%s', $html_info, $html),
'display_nav' => false,
'title' => $title
));
}
/**
* Display a browser version
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportinformationsBrowser(Application $app, Request $request)
{
$conf = array(
'version' => array(_('report::version '), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0)
);
$info = new \module_report_nav(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$info->setCsv(false);
$info->setConfig(false);
if ('' === $browser = $request->request->get('user', '')) {
$app->abort(400);
}
$reportArray = $info->buildTabInfoNav($conf, $browser);
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => false,
'title' => $browser
));
}
/**
* Display informations about a document
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportInformationsDocument(Application $app, Request $request)
{
$config = array(
'photo' => array(_('report:: document'), 0, 0, 0, 0),
'record_id' => array(_('report:: record id'), 0, 0, 0, 0),
'date' => array(_('report:: date'), 0, 0, 0, 0),
'type' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0),
'titre' => array(_('report:: titre'), 0, 0, 0, 0),
'taille' => array(_('report:: poids'), 0, 0, 0, 0)
);
$config_dl = array(
'ddate' => array(_('report:: date'), 0, 0, 0, 0),
'user' => array(_('report:: utilisateurs'), 0, 0, 0, 0),
'final' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0),
'coll_id' => array(_('report:: collections'), 0, 0, 0, 0),
'comment' => array(_('report:: commentaire'), 0, 0, 0, 0),
'fonction' => array(_('report:: fonction'), 0, 0, 0, 0),
'activite' => array(_('report:: activite'), 0, 0, 0, 0),
'pays' => array(_('report:: pays'), 0, 0, 0, 0),
'societe' => array(_('report:: societe'), 0, 0, 0, 0)
);
//format conf according user preferences
if ('' !== $columnsList = $request->request->get('list_column', '')) {
$new_conf = $config_dl;
$columns = explode(',', $columnsList);
foreach (array_keys($config_dl) as $col) {
if (!in_array($col, $columns)) {
unset($new_conf[$col]);
}
}
$config_dl = $new_conf;
}
try {
$record = new \record_adapter(
$app,
$request->request->get('sbasid'),
$request->request->get('rid')
);
} catch (\Exception $e) {
$app->abort(404);
}
$what = new \module_report_nav(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$what->setPeriode('');
$what->setCsv(false);
$what->setPrint(false);
$reportArray = $what->buildTabUserWhat(
$record->get_base_id(),
$record->get_record_id(),
$config
);
$title = $what->getTitle();
$html = $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
));
$from = $request->request->get('from', '');
if ('TOOL' === $from) {
$what->setTitle('');
return $app->json(array(
'rs' => $html,
'display_nav' => false,
'title' => $title
));
}
if ('DASH' === $from) {
$download = new \module_report_download(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$mapColumnTitleToSqlField = $download->getTransQueryString();
$currentfilter = array();
if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) {
$currentfilter = @unserialize(urldecode($serializedFilter));
}
$filter = new \module_report_filter($app, $currentfilter, $mapColumnTitleToSqlField);
if ('' !== $filterColumn = $request->request->get('filter_column', '')) {
$field = current(explode(' ', $filterColumn));
$value = $request->request->get('filter_value', '');
if ($request->request->get('liste') == 'on') {
return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array(
'result' => $download->colFilter($field),
'field' => $field
)), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)));
}
if ($field === $value) {
$filter->removeFilter($field);
} else {
$filter->addFilter($field, '=', $value);
}
}
$filter->addfilter('record_id', '=', $record->get_record_id());
$download->setFilter($filter->getTabFilter());
$download->setOrder('ddate', 'DESC');
$download->setTitle(_('report:: historique des telechargements'));
$download->setConfig(false);
$reportArray = $download->buildReport($config_dl);
if ($request->request->get('printcsv') == 'on') {
$download->setPrettyString(false);
try {
$csv = \format::arr_to_csv($download->getResult(), $download->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
}
$html = $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
));
return $app->json(array(
'rs' => $html,
'display_nav' => false,
'title' => $title
));
}
if ($app['phraseanet.registry']->get('GV_anonymousReport') == false && $from !== 'DOC' && $from !== 'DASH' && $from !== 'GEN' && $from !== 'PUSHDOC') {
$conf = array(
'identifiant' => array(_('report:: identifiant'), 0, 0, 0, 0),
'nom' => array(_('report:: nom'), 0, 0, 0, 0),
'mail' => array(_('report:: email'), 0, 0, 0, 0),
'adresse' => array(_('report:: adresse'), 0, 0, 0, 0),
'tel' => array(_('report:: telephone'), 0, 0, 0, 0)
);
$info = new \module_report_nav(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$info->setPeriode('');
$info->setConfig(false);
$info->setTitle(_('report:: utilisateur'));
$reportArray = $info->buildTabGrpInfo(false, array(), $request->request->get('user'), $conf, false);
if ($request->request->get('printcsv') == 'on') {
$download->setPrettyString(false);
try {
$csv = \format::arr_to_csv($download->getResult(), $download->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
}
$html = $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
));
return $app->json(array(
'rs' => $html,
'display_nav' => false,
'title' => $title
));
}
return $app->json(array(
'rs' => $html,
'display_nav' => false,
'title' => $title
));
}
/**
* Prefix the method to call with the controller class name
*
* @param string $method The method to call
* @return string
*/
private function call($method)
{
return sprintf('%s::%s', __CLASS__, $method);
}
}

View File

@@ -0,0 +1,649 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Controller\Report;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
class Root implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = $app['controllers_factory'];
$controllers->before(function() use ($app) {
$app['firewall']->requireAuthentication();
$app['firewall']->requireAccessToModule('report');
});
$controllers->get('/', function(Application $app) {
return $app->redirect($app->path('report_dashboard'));
})->bind('report');
$controllers->get('/dashboard', $this->call('getDashboard'))
->bind('report_dashboard');
$controllers->post('/init', $this->call('initReport'))
->bind('report_init');
$controllers->post('/connexions', $this->call('doReportConnexions'))
->bind('report_connexions');
$controllers->post('/questions', $this->call('doReportQuestions'))
->bind('report_questions');
$controllers->post('/downloads', $this->call('doReportDownloads'))
->bind('report_downloads');
$controllers->post('/documents', $this->call('doReportDocuments'))
->bind('report_documents');
$controllers->post('/clients', $this->call('doReportClients'))
->bind('report_clients');
return $controllers;
}
/**
* Display dashboard informations
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function getDashboard(Application $app, Request $request)
{
$dashboard = new \module_report_dashboard($app, $app['phraseanet.user']);
if ('json' !== $request->getRequestFormat()) {
\User_Adapter::updateClientInfos($app, 4);
$dashboard->execute();
return $app['twig']->render('report/report_layout_child.html.twig', array(
'ajax_dash' => true,
'dashboard' => $dashboard,
'home_title' => $app['phraseanet.registry']->get('GV_homeTitle'),
'module' => 'report',
'module_name' => 'Report',
'anonymous' => $app['phraseanet.registry']->get('GV_anonymousReport'),
'g_anal' => $app['phraseanet.registry']->get('GV_googleAnalytics'),
'ajax' => false,
'ajax_chart' => false
));
}
$dmin = $request->request->get('dmin');
$dmax = $request->request->get('dmax');
if ($dmin && $dmax) {
$dashboard->setDate($dmin, $dmax);
}
$dashboard->execute();
return $app->json(array('html' => $app['twig']->render('report/ajax_dashboard_content_child.html.twig', array(
'dashboard' => $dashboard
))));
}
/**
* Gets available collections where current user can see report and
* format date
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function initReport(Application $app, Request $request)
{
$popbases = $request->request->get('popbases', array());
if ('' === $dmin = $request->request->get('dmin', '')) {
$dmin = '01-' . date('m') . '-' . date('Y');
}
if ('' === $dmax = $request->request->get('dmax', '')) {
$dmax = date('d') . '-' . date('m') . '-' . date('Y');
}
$dmin = \DateTime::createFromFormat('d-m-Y H:i:s', sprintf('%s 00:00:00', $dmin));
$dmax = \DateTime::createFromFormat('d-m-Y H:i:s', sprintf('%s 23:59:59', $dmax));
//get user's sbas & collections selection from popbases
$selection = array();
$liste = $id_sbas = '';
$i = 0;
foreach (array_fill_keys($popbases, 0) as $key => $val) {
$exp = explode('_', $key);
if ($exp[0] != $id_sbas && $i != 0) {
$selection[$id_sbas]['liste'] = $liste;
$liste = '';
}
$selection[$exp[0]][] = $exp[1];
$liste .= (empty($liste) ? '' : ',') . $exp[1];
$id_sbas = $exp[0];
$i ++;
}
//fill the last entry
$selection[$id_sbas]['liste'] = $liste;
return $app['twig']->render('report/ajax_report_content.html.twig', array(
'selection' => $selection,
'anonymous' => $app['phraseanet.registry']->get('GV_anonymousReport'),
'ajax' => true,
'dmin' => $dmin->format('Y-m-d H:i:s'),
'dmax' => $dmax->format('Y-m-d H:i:s'),
));
}
/**
* Display instance connexion report
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportConnexions(Application $app, Request $request)
{
$cnx = new \module_report_connexion(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$conf = array(
'user' => array(_('phraseanet::utilisateurs'), 1, 1, 1, 1),
'ddate' => array(_('report:: date'), 1, 0, 1, 1),
'ip' => array(_('report:: IP'), 1, 0, 0, 0),
'appli' => array(_('report:: modules'), 1, 0, 0, 0),
'fonction' => array(_('report::fonction'), 1, 1, 1, 1),
'activite' => array(_('report::activite'), 1, 1, 1, 1),
'pays' => array(_('report::pays'), 1, 1, 1, 1),
'societe' => array(_('report::societe'), 1, 1, 1, 1)
);
if ($request->request->get('printcsv') == 'on') {
$cnx->setHasLimit(false);
$cnx->setPrettyString(false);
try {
$csv = \format::arr_to_csv($cnx->getResult(), $cnx->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
}
$report = $this->doReport($app, $request, $cnx, $conf);
if ($report instanceof Response) {
return $report;
}
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => $report['display_nav'], // do we display the prev and next button ?
'next' => $report['next_page'], //Number of the next page
'prev' => $report['previous_page'], //Number of the previoous page
'page' => $report['page'], //The current page
'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters
'col' => $report['active_column'], //all the columns where a filter is applied
'limit' => $report['nb_record']
));
}
/**
* Display instance questions report
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportQuestions(Application $app, Request $request)
{
$questions = new \module_report_question(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$conf = array(
'user' => array(_('report:: utilisateur'), 1, 1, 1, 1),
'search' => array(_('report:: question'), 1, 0, 1, 1),
'ddate' => array(_('report:: date'), 1, 0, 1, 1),
'fonction' => array(_('report:: fonction'), 1, 1, 1, 1),
'activite' => array(_('report:: activite'), 1, 1, 1, 1),
'pays' => array(_('report:: pays'), 1, 1, 1, 1),
'societe' => array(_('report:: societe'), 1, 1, 1, 1)
);
if ($request->request->get('printcsv') == 'on') {
$questions->setHasLimit(false);
$questions->setPrettyString(false);
try {
$csv = \format::arr_to_csv($questions->getResult(), $questions->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
}
$report = $this->doReport($app, $request, $questions, $conf);
if ($report instanceof Response) {
return $report;
}
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => $report['display_nav'], // do we display the prev and next button ?
'next' => $report['next_page'], //Number of the next page
'prev' => $report['previous_page'], //Number of the previoous page
'page' => $report['page'], //The current page
'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters
'col' => $report['active_column'], //all the columns where a filter is applied
'limit' => $report['nb_record']
));
}
/**
* Display instance download report
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportDownloads(Application $app, Request $request)
{
$download = new \module_report_download(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$conf_pref = array();
foreach (\module_report::getPreff($app, $request->request->get('sbasid')) as $field) {
$conf_pref[strtolower($field)] = array($field, 0, 0, 0, 0);
}
$conf = array_merge(array(
'user' => array(_('report:: utilisateurs'), 1, 1, 1, 1),
'ddate' => array(_('report:: date'), 1, 0, 1, 1),
'record_id' => array(_('report:: record id'), 1, 1, 1, 1),
'final' => array(_('phrseanet:: sous definition'), 1, 0, 1, 1),
'coll_id' => array(_('report:: collections'), 1, 0, 1, 1),
'comment' => array(_('report:: commentaire'), 1, 0, 0, 0),
'fonction' => array(_('report:: fonction'), 1, 1, 1, 1),
'activite' => array(_('report:: activite'), 1, 1, 1, 1),
'pays' => array(_('report:: pays'), 1, 1, 1, 1),
'societe' => array(_('report:: societe'), 1, 1, 1, 1)
), $conf_pref);
if ($request->request->get('printcsv') == 'on') {
$download->setHasLimit(false);
$download->setPrettyString(false);
try {
$csv = \format::arr_to_csv($download->getResult(), $download->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
}
$report = $this->doReport($app, $request, $download, $conf);
if ($report instanceof Response) {
return $report;
}
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => $report['display_nav'], // do we display the prev and next button ?
'next' => $report['next_page'], //Number of the next page
'prev' => $report['previous_page'], //Number of the previoous page
'page' => $report['page'], //The current page
'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters
'col' => $report['active_column'], //all the columns where a filter is applied
'limit' => $report['nb_record']
));
}
/**
* Display instance document report
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportDocuments(Application $app, Request $request)
{
$document = new \module_report_download(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$conf_pref = array();
foreach (\module_report::getPreff($app, $request->request->get('sbasid')) as $field) {
$conf_pref[strtolower($field)] = array($field, 0, 0, 0, 0);
}
$conf = array_merge(array(
'telechargement' => array(_('report:: telechargements'), 1, 0, 0, 0),
'record_id' => array(_('report:: record id'), 1, 1, 1, 0),
'final' => array(_('phraseanet:: sous definition'), 1, 0, 1, 1),
'file' => array(_('report:: fichier'), 1, 0, 0, 1),
'mime' => array(_('report:: type'), 1, 0, 1, 1),
'size' => array(_('report:: taille'), 1, 0, 1, 1)
), $conf_pref);
if ($request->request->get('printcsv') == 'on') {
$document->setHasLimit(false);
$document->setPrettyString(false);
try {
$csv = \format::arr_to_csv($document->getResult(), $document->getDisplay());
} catch (\Exception $e) {
$csv = '';
}
return $app->json(array('rs' => $csv));
}
$report = $this->doReport($app, $request, $document, $conf, 'record_id');
if ($report instanceof Response) {
return $report;
}
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => true
)),
'display_nav' => $report['display_nav'], // do we display the prev and next button ?
'next' => $report['next_page'], //Number of the next page
'prev' => $report['previous_page'], //Number of the previoous page
'page' => $report['page'], //The current page
'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters
'col' => $report['active_column'], //all the columns where a filter is applied
'limit' => $report['nb_record']
));
}
/**
* Display informations about client (browser, resolution etc ...)
*
* @param Application $app
* @param Request $request
* @return JsonResponse
*/
public function doReportClients(Application $app, Request $request)
{
$nav = new \module_report_nav(
$app,
$request->request->get('dmin'),
$request->request->get('dmax'),
$request->request->get('sbasid'),
$request->request->get('collection')
);
$conf_nav = array(
'nav' => array(_('report:: navigateur'), 0, 1, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0)
);
$conf_combo = array(
'combo' => array(_('report:: navigateurs et plateforme'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0)
);
$conf_os = array(
'os' => array(_('report:: plateforme'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0)
);
$conf_res = array(
'res' => array(_('report:: resolution'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0)
);
$conf_mod = array(
'appli' => array(_('report:: module'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0)
);
$report = array(
'nav' => $nav->buildTabNav($conf_nav),
'os' => $nav->buildTabOs($conf_os),
'res' => $nav->buildTabRes($conf_res),
'mod' => $nav->buildTabModule($conf_mod),
'combo' => $nav->buildTabCombo($conf_combo)
);
if ($request->request->get('printcsv') == 'on') {
return $app->json(array(
'nav' => \format::arr_to_csv($report['nav']['result'], $conf_nav),
'os' => \format::arr_to_csv($report['os']['result'], $conf_os),
'res' => \format::arr_to_csv($report['res']['result'], $conf_res),
'mod' => \format::arr_to_csv($report['mod']['result'], $conf_mod),
'combo' => \format::arr_to_csv($report['combo']['result'], $conf_combo)
));
}
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false,
'is_nav' => true,
'is_groupby' => false,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => false,
'title' => false
));
}
/**
* Set Report configuration according to request parameters
*
* @param Application $app An application instance
* @param Request $request A request instance
* @param \module_report $report A report instance
* @param Array $conf A report column configuration
* @param Boolean $what Whether to group on a particular field or not
* @return Array
*/
private function doReport(Application $app, Request $request, \module_report $report, $conf, $what = false)
{
if ($app['phraseanet.registry']->get('GV_anonymousReport') == true) {
if (isset($conf['user'])) {
unset($conf['user']);
}
if (isset($conf['ip'])) {
unset($conf['ip']);
}
}
//save initial conf
$base_conf = $conf;
//format conf according user preferences
if ('' !== $columnsList = $request->request->get('list_column', '')) {
$new_conf = $conf;
$columns = explode(',', $columnsList);
foreach (array_keys($conf) as $col) {
if (!in_array($col, $columns)) {
unset($new_conf[$col]);
}
}
$conf = $new_conf;
}
//display content of a table column when user click on it
if ($request->request->get('conf') == 'on') {
return $app->json(array('liste' => $app['twig']->render('report/listColumn.html.twig', array(
'conf' => $base_conf
)), 'title' => _('configuration')));
}
//set order
if (('' !== $order = $request->request->get('order', '')) && ('' !== $field = $request->request->get('champ', ''))) {
$report->setOrder($field, $order);
}
//work on filters
$mapColumnTitleToSqlField = $report->getTransQueryString();
$currentfilter = array();
if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) {
$currentfilter = @unserialize(urldecode($serializedFilter));
}
$filter = new \module_report_filter($app, $currentfilter, $mapColumnTitleToSqlField);
if ('' !== $filterColumn = $request->request->get('filter_column', '')) {
$field = current(explode(' ', $filterColumn));
$value = $request->request->get('filter_value', '');
if ($request->request->get('liste') == 'on') {
return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array(
'result' => $report->colFilter($field),
'field' => $field
)), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)));
}
if ($field === $value) {
$filter->removeFilter($field);
} else {
$filter->addFilter($field, '=', $value);
}
}
//set new request filter if user asking for them
if ($request->request->get('precise') == 1) {
$filter->addFilter('xml', 'LIKE', $request->request->get('word', ''));
} elseif ($request->request->get('precise') == 2) {
$filter->addFilter('record_id', '=', $request->request->get('word', ''));
}
//set filters to current report
$report->setFilter($filter->getTabFilter());
$report->setActiveColumn($filter->getActiveColumn());
$report->setPostingFilter($filter->getPostingFilter());
// display a new arraywhere results are group
if ('' !== $groupby = $request->request->get('groupby', '')) {
$report->setConfig(false);
$groupby = current(explode(' ', $groupby));
$reportArray = $report->buildReport(false, $groupby);
if (count($reportArray['allChamps']) > 0 && count($reportArray['display']) > 0) {
$groupField = isset($reportArray['display'][$reportArray['allChamps'][0]]['title']) ? $reportArray['display'][$reportArray['allChamps'][0]]['title'] : '';
} else {
$groupField = isset($conf[strtolower($groupby)]['title']) ? $conf[strtolower($groupby)]['title'] : '';
}
return $app->json(array(
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array(
'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => true,
'is_plot' => false,
'is_doc' => false
)),
'display_nav' => false,
'title' => _(sprintf('Groupement des resultats sur le champ %s', $groupField))
));
}
//set Limit
if ($report->getEnableLimit()
&& ('' !== $page = $request->request->get('page', ''))
&& ('' !== $limit = $request->request->get('limit', ''))) {
$report->setLimit($page, $limit);
} else {
$report->setLimit(false, false);
}
//time to build our report
if (false === $what) {
$reportArray = $report->buildReport($conf);
} else {
$reportArray = $report->buildReport($conf, $what, $request->request->get('tbl', false));
}
return $reportArray;
}
/**
* Prefix the method to call with the controller class name
*
* @param string $method The method to call
* @return string
*/
private function call($method)
{
return sprintf('%s::%s', __CLASS__, $method);
}
}

View File

@@ -252,8 +252,11 @@ class module_report
$this->sbas_id = $sbas_id; $this->sbas_id = $sbas_id;
$this->list_coll_id = $collist; $this->list_coll_id = $collist;
$this->user_id = $this->app['phraseanet.user']->get_id(); $this->user_id = $this->app['phraseanet.user']->get_id();
$this->periode = $this->app['date-formatter']->getPrettyString(new DateTime($d1)) $this->periode = sprintf(
. ' - ' . $this->app['date-formatter']->getPrettyString(new DateTime($d2)); '%s - %s ',
$this->app['date-formatter']->getPrettyString(new \DateTime($d1)),
$this->app['date-formatter']->getPrettyString(new \DateTime($d2))
);
$this->dbname = phrasea::sbas_names($sbas_id, $app); $this->dbname = phrasea::sbas_names($sbas_id, $app);
$this->cor = $this->setCor(); $this->cor = $this->setCor();
$this->jour = $this->setDay(); $this->jour = $this->setDay();

View File

@@ -415,13 +415,6 @@ class module_report_nav extends module_report
$filter_id_apbox = $filter_id_datbox = array(); $filter_id_apbox = $filter_id_datbox = array();
$conn = $this->app['phraseanet.appbox']->get_connection(); $conn = $this->app['phraseanet.appbox']->get_connection();
$datefilter = array();
if ($this->dmin && $this->dmax) {
$params = array(':dmin' => $this->dmin, ':dmax' => $this->dmax);
$datefilter = "date > :dmin AND date < :dmax";
}
$this->title = sprintf(_('report:: Information sur les utilisateurs correspondant a %s'), $val); $this->title = sprintf(_('report:: Information sur les utilisateurs correspondant a %s'), $val);
if ($on) { if ($on) {
@@ -446,7 +439,7 @@ class module_report_nav extends module_report
usr_mail as mail, usr_mail as mail,
adresse, tel adresse, tel
FROM usr FROM usr
WHERE $on = :value AND (" . $filter_id_apbox . ")"; WHERE $on = :value " . (('' !== $filter_id_apbox) ? "AND (" . $filter_id_apbox . ")" : '');
} else { } else {
$sql = ' $sql = '
SELECT SELECT
@@ -548,19 +541,19 @@ class module_report_nav extends module_report
_('report:: Information sur le navigateur %s'), $navigator); _('report:: Information sur le navigateur %s'), $navigator);
$sqlBuilder = new module_report_sql($this->app, $this); $sqlBuilder = new module_report_sql($this->app, $this);
$filter = $sqlBuilder->getFilters(); $filter = $sqlBuilder->getFilters();
$params = array(':browser' => $navigator);
$report_filter = $filter->getReportFilter(); $report_filter = $filter->getReportFilter();
$params = array_merge($report_filter['params'], array(':browser' => $navigator));
$sql = " $sql = "
SELECT DISTINCT(version), COUNT(version) as nb SELECT DISTINCT(tt.version), COUNT(tt.version) as nb
FROM ( FROM (
SELECT DISTINCT (log.id) SELECT DISTINCT (log.id), version
FROM log FORCE INDEX (date_site, nav, version) FROM log FORCE INDEX (date_site, nav, version)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id) INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
WHERE ". $report_filter['sql'] . "
WHERE nav = :browser WHERE nav = :browser
AND ". $report_filter['sql'] . "
) AS tt ) AS tt
GROUP BY tt.version GROUP BY version
ORDER BY nb DESC"; ORDER BY nb DESC";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);

View File

@@ -38,6 +38,8 @@ class module_report_sqlaction extends module_report_sql implements module_report
public function buildSql() public function buildSql()
{ {
$customFieldMap = array();
$filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false); $filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false);
$this->params = array_merge(array(':action' => $this->action), $filter['params']); $this->params = array_merge(array(':action' => $this->action), $filter['params']);
@@ -53,12 +55,22 @@ class module_report_sqlaction extends module_report_sql implements module_report
WHERE (" . $filter['sql'] . ") AND (d.action = :action) WHERE (" . $filter['sql'] . ") AND (d.action = :action)
) AS tt"; ) AS tt";
$customFieldMap = array(
'log.usrid' => 'tt.usrid',
'log.user' => 'tt.user',
'd.final' => 'getter',
'd.record_id' => 'tt.record_id',
'd.date' => 'tt.date',
'record.mime' => 'tt.mime',
'file' => 'tt.file',
);
$stmt = $this->getConnBas()->prepare($this->sql); $stmt = $this->getConnBas()->prepare($this->sql);
$stmt->execute($this->params); $stmt->execute($this->params);
$this->total = $stmt->rowCount(); $this->total = $stmt->rowCount();
$stmt->closeCursor(); $stmt->closeCursor();
$this->sql .= $this->filter->getOrderFilter() ? : ''; $this->sql .= $this->filter->getOrderFilter($customFieldMap) ? : '';
$this->sql .= $this->filter->getLimitFilter() ? : ''; $this->sql .= $this->filter->getLimitFilter() ? : '';
} else { } else {
$this->sql = " $this->sql = "

View File

@@ -25,6 +25,8 @@ class module_report_sqldownload extends module_report_sql implements module_repo
public function buildSql() public function buildSql()
{ {
$customFieldMap = array();
$filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false); $filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false);
$this->params = array_merge(array(), $filter['params']); $this->params = array_merge(array(), $filter['params']);
@@ -54,6 +56,16 @@ class module_report_sqldownload extends module_report_sql implements module_repo
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id) INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
INNER JOIN record ON (log_docs.record_id = record.record_id) INNER JOIN record ON (log_docs.record_id = record.record_id)
INNER JOIN subdef ON (log_docs.record_id = subdef.record_id)'; INNER JOIN subdef ON (log_docs.record_id = subdef.record_id)';
$customFieldMap = array(
$field => $name,
'log_docs.comment' => 'tt.comment',
'subdef.size' => 'tt.size',
'subdef.file' => 'tt.file',
'subdef.mime' => 'tt.mime',
'log_docs.final' => 'tt.final',
);
} elseif ($this->on == 'DOC') { } elseif ($this->on == 'DOC') {
$this->sql = ' $this->sql = '
SELECT ' . $name . ', SUM(1) AS telechargement SELECT ' . $name . ', SUM(1) AS telechargement
@@ -88,7 +100,12 @@ class module_report_sqldownload extends module_report_sql implements module_repo
$this->total = $stmt->rowCount(); $this->total = $stmt->rowCount();
$stmt->closeCursor(); $stmt->closeCursor();
$this->sql .= $this->filter->getOrderFilter() ? : ''; if (count($customFieldMap) > 0) {
$this->sql .= $this->filter->getOrderFilter($customFieldMap) ? : '';
} else {
$this->sql .= $this->filter->getOrderFilter() ? : '';
}
$this->sql .= $this->filter->getLimitFilter() ? : ''; $this->sql .= $this->filter->getLimitFilter() ? : '';
return $this; return $this;

View File

@@ -17,6 +17,7 @@ class module_report_sqlfilter
private $filter; private $filter;
private $cor_query = array(); private $cor_query = array();
private $app; private $app;
private $report;
public function __construct(Application $app, module_report $report) public function __construct(Application $app, module_report $report)
{ {
@@ -27,6 +28,8 @@ class module_report_sqlfilter
$this->cor_query = $report->getTransQueryString(); $this->cor_query = $report->getTransQueryString();
$this->buildFilter($report); $this->buildFilter($report);
$this->report = $report;
} }
public static function constructDateFilter($dmin, $dmax) public static function constructDateFilter($dmin, $dmax)
@@ -123,9 +126,13 @@ class module_report_sqlfilter
return $this->filter['limit']; return $this->filter['limit'];
} }
public function getOrderFilter() public function getOrderFilter($customFieldMap = null)
{ {
return $this->filter['order']; if (null === $customFieldMap) {
return $this->filter['order'];
}
return $this->overrideOrderFilter($customFieldMap);
} }
private function dateFilter(module_report $report) private function dateFilter(module_report $report)
@@ -259,4 +266,19 @@ class module_report_sqlfilter
return; return;
} }
private function overrideOrderFilter($customFieldMap)
{
if (sizeof($this->report->getOrder()) > 0) {
if (!isset($customFieldMap[$this->cor_query[$this->report->getOrder('champ')]])) {
return false;
}
return " ORDER BY "
. $customFieldMap[$this->cor_query[$this->report->getOrder('champ')]]
. ' ' . $this->report->getOrder('order');
}
return false;
}
} }

View File

@@ -58,7 +58,7 @@
{# MODULE #} {# MODULE #}
{% if app['phraseanet.user'].ACL.has_access_to_module('report') %} {% if app['phraseanet.user'].ACL.has_access_to_module('report') %}
<li> <li>
<a target="_blank" href="/report/"> <a target="_blank" href="{{ app.path('report_dashboard') }}">
<span class="{% if module == "report" %}selected{% endif %}"> <span class="{% if module == "report" %}selected{% endif %}">
{% trans 'admin::monitor: module report' %} {% trans 'admin::monitor: module report' %}
</span> </span>

View File

@@ -27,9 +27,9 @@
<script type="text/javascript"> <script type="text/javascript">
$('#dialog .bound').each( function () { $('#dialog .bound').each( function () {
var riid = $(this).html(); var riid = $(this).html();
var new_a = $(this).html('<img style="float:right;margin-right:5px;" src="./images/loupe2.png" />'); var new_a = $(this).html('<img style="float:right;margin-right:5px;" src="/skins/report/img/loupe2.png" />');
$(this).before(riid); $(this).before(riid);
$(this).attr('rel', './tab.php').cluetip({ $(this).attr('rel', '{{ path('report_infomations_document') }}').cluetip({
width: 600, width: 600,
ajaxCache: true, ajaxCache: true,
arrows: true, arrows: true,
@@ -37,12 +37,11 @@
type : 'POST', type : 'POST',
dataType: 'json', dataType: 'json',
data : ({ data : ({
tbl : 'what',
rid : riid, rid : riid,
sbasid : '{{ param.sbasid }}', sbasid : '{{ app['request'].get('sbasid') }}',
collection : '{{ param.collection }}', collection : '{{ app['request'].get('collection') }}',
dmin : '{{ param.dmin }}', dmin : '{{ app['request'].get('dmin') }}',
dmax : '{{ param.dmax }}', dmax : '{{ app['request'].get('dmax') }}',
from : 'TOOL' from : 'TOOL'
}) })
}, },

View File

@@ -3,12 +3,12 @@
<div class="horizontal-scroller"> <div class="horizontal-scroller">
<ul class="tabb"> <ul class="tabb">
{% for key in selection|keys %} {% for key in selection|keys %}
<li class ="number_{{ key }}"><a href="#tab-{{ key }}-{{ param.tbl }}">{{ key|sbas_names(app)}}</a></li> <li class ="number_{{ key }}"><a href="#tab-{{ key }}-{{ app['request'].get('tbl') }}">{{ key|sbas_names(app)}}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
{% for key, value in selection %} {% for key, value in selection %}
<div id="tab-{{ key }}-{{ param.tbl }}"> <div id="tab-{{ key }}-{{ app['request'].get('tbl') }}">
<div class="load"> <div class="load">
{% block ajax_data_content %}{% endblock %} {% block ajax_data_content %}{% endblock %}
</div> </div>
@@ -28,14 +28,15 @@
<input type="button" name="go" value ="ok" class="submiter" /> <input type="button" name="go" value ="ok" class="submiter" />
</div> </div>
</fieldset> </fieldset>
<input type="hidden" name="tbl" value ="{{ param['tbl'] }}"/> <input type="hidden" name="tbl" value ="{{ app['request'].get('tbl') }}"/>
<input type="hidden" name="dmin" value ="{{ param['dmin'] }}"/> <input type="hidden" name="action" value ="{{ app['request'].get('action') }}"/>
<input type="hidden" name="dmax" value ="{{ param['dmax'] }}"/> <input type="hidden" name="dmin" value ="{{ dmin }}"/>
<input type="hidden" name="dmax" value ="{{ dmax }}"/>
<input type="hidden" name="sbasid" value ="{{ key }}"/> <input type="hidden" name="sbasid" value ="{{ key }}"/>
<input type="hidden" name="collection" value ="{{ value.liste }}"/> <input type="hidden" name="collection" value ="{{ value.liste }}"/>
<input type="hidden" name="user" value =""/> <input type="hidden" name="user" value =""/>
<input type="hidden" name="word" value ="{{ param['tbl'] == 'DOC' ? param['preciseWord'] : '' }}"/> <input type="hidden" name="word" value ="{{ app['request'].get('tbl') == 'DOC' ? app['request'].get('preciseWord') : '' }}"/>
<input type="hidden" name="precise" value ="{{ param['tbl'] == 'DOC' ? param['precise'] : '' }}"/> <input type="hidden" name="precise" value ="{{ app['request'].get('tbl') == 'DOC' ? app['request'].get('precise') : '' }}"/>
<input type="hidden" name="order" value =""/> <input type="hidden" name="order" value =""/>
<input type="hidden" name="champ" value =""/> <input type="hidden" name="champ" value =""/>
<input type="hidden" name="rid" value =""/> <input type="hidden" name="rid" value =""/>
@@ -51,11 +52,11 @@
<input type="hidden" name="fonction" value =""/> <input type="hidden" name="fonction" value =""/>
<input type="hidden" name="activite" value =""/> <input type="hidden" name="activite" value =""/>
{% if anonymous %} {% if anonymous %}
<input type="hidden" name="on" value ="{{ param['on'] }}"/> <input type="hidden" name="on" value ="{{ app['request'].get('on') }}"/>
{% else %} {% else %}
<input type="hidden" name="on" value =""/> <input type="hidden" name="on" value =""/>
{% endif %} {% endif %}
<input type="hidden" name="docwhat" value ="{{ param['tbl'] == 'WDOC' ? param['docwhat'] : '' }}"/> <input type="hidden" name="docwhat" value ="{{ app['request'].get('tbl') == 'WDOC' ? app['request'].get('docwhat') : '' }}"/>
<input type="hidden" name="from" value =""/> <input type="hidden" name="from" value =""/>
<input type="hidden" name="printcsv" value ="off"/> <input type="hidden" name="printcsv" value ="off"/>
</form> </form>

View File

@@ -6,7 +6,7 @@
{% endblock stylesheet %} {% endblock stylesheet %}
{% block icon %} {% block icon %}
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> <link rel="shortcut icon" type="image/x-icon" href="/skins/report/img/favicon.ico" />
{% endblock icon%} {% endblock icon%}
{% block javascript %} {% block javascript %}

View File

@@ -12,13 +12,13 @@
<div class="left titleleft"> <div class="left titleleft">
<div class="title left">{{ result.title }}</div> <div class="title left">{{ result.title }}</div>
{% if result.config %} {% if result.config %}
<a href="#" class="config left"><img title="{% trans 'report :: configurer le tableau' %}" src="images/config.png"/></a> <a href="#" class="config left"><img title="{% trans 'report :: configurer le tableau' %}" src="/skins/report/img/config.png"/></a>
{% endif %} {% endif %}
{% if result.print %} {% if result.print %}
<a href="#" class="jqprint left"><img title="{% trans 'report :: imprimer le tableau' %}" src="images/print.png"/></a> <a href="#" class="jqprint left"><img title="{% trans 'report :: imprimer le tableau' %}" src="/skins/report/img/print.png"/></a>
{% endif %} {% endif %}
{% if result.csv %} {% if result.csv %}
<form class="form_csv left" method="POST" action="export_csv.php" target="iframe" > <form class="form_csv left" method="POST" action="{{ path('report_export_csv') }}" target="iframe" >
<input type="submit" name ="submit" value=""/> <input type="submit" name ="submit" value=""/>
<input style="display:none;" type="submit" name="doit"/> <input style="display:none;" type="submit" name="doit"/>
<input type="hidden" name="name" value="{{ result.title }}" size="68"/> <input type="hidden" name="name" value="{{ result.title }}" size="68"/>
@@ -42,8 +42,8 @@
<th class="{{ key }}" scope="col" > <th class="{{ key }}" scope="col" >
{% if value.sort == 1 %} {% if value.sort == 1 %}
<div class="orderby"> <div class="orderby">
<img title="{% trans "Trier" %}" style="float:left;top:0;left:0;" class="asc" src="images/arrow_up.png" /> <img title="{% trans "Trier" %}" style="float:left;top:0;left:0;" class="asc" src="/skins/report/img/arrow_up.png" />
<img title="{% trans "Trier" %}" style="float:left;top:0;left:0;" class="desc" src="images/arrow_down.png" /> <img title="{% trans "Trier" %}" style="float:left;top:0;left:0;" class="desc" src="/skins/report/img/arrow_down.png" />
{% endif %} {% endif %}
<div class="title_th" style="clear:both;color:black;">{{ value.title }}</div> <div class="title_th" style="clear:both;color:black;">{{ value.title }}</div>
@@ -106,7 +106,7 @@
<div class="report-table center" style="margin-top:50px;" > <div class="report-table center" style="margin-top:50px;" >
<b>{{ result.title }}</b> <b>{{ result.title }}</b>
<br /> <br />
<img src="images/noresults.png" /> <img src="/skins/report/img/noresults.png" />
<br /> <br />
<i>{% trans "report :: aucun resultat trouve" %}</i><br /> <i>{% trans "report :: aucun resultat trouve" %}</i><br />
</div> </div>

View File

@@ -4,11 +4,11 @@
<div class="columnjson_title">{% trans "Cochez les cases correspondantes aux colonnes que vous desirez voire apparaitre dans le report" %} </div> <br /> <div class="columnjson_title">{% trans "Cochez les cases correspondantes aux colonnes que vous desirez voire apparaitre dans le report" %} </div> <br />
<div> <div>
<div class="columnjson_link_box"> <div class="columnjson_link_box">
<a class="columnjson_link" href='#' id='on'><img src ='./images/checkbox_checked.png' />{% trans "cocher tout" %}</a> <a class="columnjson_link" href='#' id='on'><img src ='/skins/report/img/checkbox_checked.png' />{% trans "cocher tout" %}</a>
</div> </div>
&nbsp;&nbsp; &nbsp;&nbsp;
<div class="columnjson_link_box"> <div class="columnjson_link_box">
<a class="columnjson_link" href='#' id='off'><img src ='./images/checkbox_unchecked.png' />{% trans "tout decocher" %}</a> <a class="columnjson_link" href='#' id='off'><img src ='/skins/report/img/checkbox_unchecked.png' />{% trans "tout decocher" %}</a>
</div> </div>
</div> </div>
<br /> <br />

View File

@@ -52,12 +52,12 @@
<div class="form_titre">{% trans "report:: 3 - Type de report" %} </div> <div class="form_titre">{% trans "report:: 3 - Type de report" %} </div>
{% if not anonymous %} {% if not anonymous %}
<div> <div>
<input name="tbl" type="radio" value="CNXU" id="CNXU-input" class="formsubmiter" /> <input name="tbl" type="radio" value="CNXU" data-action="{{ path('report_activity_users_connexions') }}" id="CNXU-input" class="formsubmiter" />
<label for="CNXU-input">{% trans "report:: (connexions) Par utilisateurs" %}</label> <label for="CNXU-input">{% trans "report:: (connexions) Par utilisateurs" %}</label>
</div> </div>
{% else %} {% else %}
<div> <div>
<input name="tbl" type="radio" value="CNXU" id="CNXU-input" class="formsubmiter" /> <input name="tbl" type="radio" value="CNXU" data-action="{{ path('report_activity_users_connexions') }}" id="CNXU-input" class="formsubmiter" />
<label for="CNXU-input">{% trans "report:: Grouper par" %}</label> <label for="CNXU-input">{% trans "report:: Grouper par" %}</label>
<select class="options" style="display:inline;display:none;" id="list-select" name="on" > <select class="options" style="display:inline;display:none;" id="list-select" name="on" >
<option selected ="selected" value="fonction" class="formsubmiter">{% trans "report:: fonction" %}</option> <option selected ="selected" value="fonction" class="formsubmiter">{% trans "report:: fonction" %}</option>
@@ -68,11 +68,11 @@
</div> </div>
{% endif %} {% endif %}
<div> <div>
<input name="tbl" type="radio" value="CNX" id="CNX-input" class="formsubmiter" /> <input name="tbl" type="radio" value="CNX" data-action="{{ path('report_connexions') }}" id="CNX-input" class="formsubmiter" />
<label for="CNX-input">{% trans "report:: (connexions) Globales" %}</label> <label for="CNX-input">{% trans "report:: (connexions) Globales" %}</label>
</div> </div>
<div> <div>
<input name="tbl" type="radio" value="CNXB" id="CNXB-input" class="formsubmiter" /> <input name="tbl" type="radio" value="CNXB" data-action="{{ path('report_clients') }}" id="CNXB-input" class="formsubmiter" />
<label for="CNXB-input">{% trans "report:: (connexions) OS et navigateurs" %}</label> <label for="CNXB-input">{% trans "report:: (connexions) OS et navigateurs" %}</label>
</div> </div>
</div> </div>
@@ -98,7 +98,7 @@
<div class="form_titre">{%trans "report:: 3 - Type de report" %}</div> <div class="form_titre">{%trans "report:: 3 - Type de report" %}</div>
{% if anonymous %} {% if anonymous %}
<div> <div>
<input name="tbl" type="radio" value="USR" id="USR-dl" class="formsubmiter" /> <input name="tbl" type="radio" value="USR" data-action="{{ path('report_activity_users_downloads') }}" id="USR-dl" class="formsubmiter" />
<label for="USR-dl">{% trans "report:: Grouper par" %}</label> <label for="USR-dl">{% trans "report:: Grouper par" %}</label>
<select class="options" style="display:inline;display:none;" id="list-select2" name="on" > <select class="options" style="display:inline;display:none;" id="list-select2" name="on" >
<option selected ="selected" value="fonction" class="formsubmiter">{% trans "report:: fonction" %}</option> <option selected ="selected" value="fonction" class="formsubmiter">{% trans "report:: fonction" %}</option>
@@ -109,20 +109,20 @@
</div> </div>
{% else %} {% else %}
<div> <div>
<input name="tbl" type="radio" value="USR" id="USR-input" class="formsubmiter" /> <input name="tbl" type="radio" value="USR" data-action="{{ path('report_activity_users_downloads') }}" id="USR-input" class="formsubmiter" />
<label for="USR-input">{% trans "report:: par utilisateurs" %}</label> <label for="USR-input">{% trans "report:: par utilisateurs" %}</label>
</div> </div>
{% endif %} {% endif %}
<div> <div>
<input name="tbl" type="radio" value="GEN" id="GEN-input" class="formsubmiter" /> <input name="tbl" type="radio" value="GEN" data-action="{{ path('report_downloads') }}" id="GEN-input" class="formsubmiter" />
<label for="GEN-input">{% trans "report:: (telechargement) Global" %}</label> <label for="GEN-input">{% trans "report:: (telechargement) Global" %}</label>
</div> </div>
<div> <div>
<input name="tbl" type="radio" value="DAY" id="DAY-input" class="formsubmiter" /> <input name="tbl" type="radio" value="DAY" data-action="{{ path('report_activity_instance_days') }}" id="DAY-input" class="formsubmiter" />
<label for="DAY-input">{% trans "report:: (telechargement) Par jours base par base" %}</label> <label for="DAY-input">{% trans "report:: (telechargement) Par jours base par base" %}</label>
</div> </div>
<div> <div>
<input name="tbl" type="radio" value="DOC" id="DOC-input" class="formsubmiter" /> <input name="tbl" type="radio" value="DOC" data-action="{{ path('report_documents') }}" id="DOC-input" class="formsubmiter" />
<label for="DOC-input">{% trans "report:: (telechargement) Par documents sur la base" %}</label> <label for="DOC-input">{% trans "report:: (telechargement) Par documents sur la base" %}</label>
<select class="options" id="precise" name="precise" style="display:none;"> <select class="options" id="precise" name="precise" style="display:none;">
<option value="0">{% trans "report::aucune precision" %}</option> <option value="0">{% trans "report::aucune precision" %}</option>
@@ -156,29 +156,29 @@
<input name="on" type="hidden" value="" checked="checked"/> <input name="on" type="hidden" value="" checked="checked"/>
{% endif %} {% endif %}
<div> <div>
<input name="tbl" type="radio" value="ASK" id="ASK-input" class="formsubmiter" /> <input name="tbl" type="radio" value="ASK" data-action="{{ path('report_questions') }}" id="ASK-input" class="formsubmiter" />
<label for="ASK-input">{% trans "report:: toutes les questions" %}</label> <label for="ASK-input">{% trans "report:: toutes les questions" %}</label>
</div> </div>
<div> <div>
<input name="tbl" type="radio" value="BESTOF" id="BESTOF-input" class="formsubmiter" /> <input name="tbl" type="radio" value="BESTOF" data-action="{{ path('report_activity_questions_bestof') }}" id="BESTOF-input" class="formsubmiter" />
<label for="BESTOF-input">{% trans "report:: Les questions les plus posees" %}</label> <label for="BESTOF-input">{% trans "report:: Les questions les plus posees" %}</label>
</div> </div>
<div> <div>
<input name="tbl" type="radio" value="NOBESTOF" id="NOBESTOF-input" class="formsubmiter" /> <input name="tbl" type="radio" value="NOBESTOF" data-action="{{ path('report_activity_questions_nobestof') }}" id="NOBESTOF-input" class="formsubmiter" />
<label for="NOBESTOF-input">{% trans "report:: questions sans reponses" %}</label> <label for="NOBESTOF-input">{% trans "report:: questions sans reponses" %}</label>
</div> </div>
<div> <div>
<input name="tbl" type="radio" value="SITEACTIVITY" id="SITEACTIVITY-input" class="formsubmiter" /> <input name="tbl" type="radio" value="SITEACTIVITY" data-action="{{ path('report_activity_questions_nobestof') }}" id="SITEACTIVITY-input" class="formsubmiter" />
<label for="SITEACTIVITY-input">{% trans "report:: activite du site" %}</label> <label for="SITEACTIVITY-input">{% trans "report:: activite du site" %}</label>
</div> </div>
<div> <div>
<input name="tbl" type="radio" value="WDOC" id="WDOC" class="formsubmiter" /> <input name="tbl" type="radio" value="WDOC" data-action="{{ path('report_activity_documents_pushed') }}" id="WDOC" class="formsubmiter" />
<label for="WDOC">{% trans "report:: document" %}</label> <label for="WDOC">{% trans "report:: document" %}</label>
<select class="options" style="display:inline;display:none;" id="list-select3" name="docwhat" > <select class="options" style="display:inline;display:none;" id="list-select3" name="docwhat" >
<option selected ="selected" value="PUSHDOC" class="formsubmiter">{% trans "report:: pushe" %}</option> <option selected ="selected" value="PUSHDOC" data-action="{{ path('report_activity_documents_pushed') }}" class="formsubmiter">{% trans "report:: pushe" %}</option>
<option value="ADDDOC" class="formsubmiter">{% trans "report:: ajoute" %}</option> <option value="ADDDOC" data-action="{{ path('report_activity_documents_added') }}" class="formsubmiter">{% trans "report:: ajoute" %}</option>
<option value="EDIDOC" class="formsubmiter">{% trans "report:: edite" %}</option> <option value="EDIDOC" data-action="{{ path('report_activity_documents_edited') }}" class="formsubmiter">{% trans "report:: edite" %}</option>
<option value="VALIDATEDOC" class="formsubmiter">{% trans "report:: valide" %}</option> <option value="VALIDOC" data-action="{{ path('report_activity_documents_validated') }}" class="formsubmiter">{% trans "report:: valide" %}</option>
</select> </select>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,581 @@
<?php
namespace Alchemy\Tests\Phrasea\Controller\Report;
class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
private $dmin;
private $dmax;
public function __construct()
{
$this->dmax = new \DateTime('now');
$this->dmin = new \DateTime('-1 month');
}
public function testDoReportConnexionsByUsers()
{
self::$DI['client']->request('POST', '/report/activity/users/connexions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'page' => 1,
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportConnexionsByUsersCSV()
{
self::$DI['client']->request('POST', '/report/activity/users/connexions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'page' => 1,
'limit' => 10,
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDownloadsByUsers()
{
self::$DI['client']->request('POST', '/report/activity/users/downloads', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'page' => 1,
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDownloadsByUsersCSV()
{
self::$DI['client']->request('POST', '/report/activity/users/downloads', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'page' => 1,
'limit' => 10,
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportBestOfQuestions()
{
self::$DI['client']->request('POST', '/report/activity/questions/best-of', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportBestOfQuestionsCSV()
{
self::$DI['client']->request('POST', '/report/activity/questions/best-of', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'limit' => 10,
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportNoBestOfQuestions()
{
self::$DI['client']->request('POST', '/report/activity/questions/no-best-of', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportNoBestOfQuestionsCSV()
{
self::$DI['client']->request('POST', '/report/activity/questions/no-best-of', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'limit' => 10,
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportSiteActiviyPerHours()
{
self::$DI['client']->request('POST', '/report/activity/instance/hours', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportSiteActiviyPerHoursCSV()
{
self::$DI['client']->request('POST', '/report/activity/instance/hours', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportSiteActiviyPerDays()
{
self::$DI['client']->request('POST', '/report/activity/instance/days', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportSiteActiviyPerDaysCSV()
{
self::$DI['client']->request('POST', '/report/activity/instance/days', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportPushedDocuments()
{
self::$DI['client']->request('POST', '/report/activity/documents/pushed', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'order' => 'ASC',
'champ' => 'user',
'page' => 1,
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportPushedDocumentsPrintCSV()
{
self::$DI['client']->request('POST', '/report/activity/documents/pushed', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportPushedDocumentsFilterColumns()
{
self::$DI['client']->request('POST', '/report/activity/documents/pushed', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'list_column' => 'user ddate',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportPushedDocumentsFilterResultOnOneColumn()
{
self::$DI['client']->request('POST', '/report/activity/documents/pushed', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'filter_column' => 'user',
'filter_value' => 'admin',
'liste' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportPushedDocumentsFilterConf()
{
self::$DI['client']->request('POST', '/report/activity/documents/pushed', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'conf' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportPushedDocumentsGroupBy()
{
self::$DI['client']->request('POST', '/report/activity/documents/pushed', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'groupby' => 'user',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportAddedDocuments()
{
self::$DI['client']->request('POST', '/report/activity/documents/added', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'order' => 'ASC',
'champ' => 'user',
'page' => 1,
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportAddedDocumentsPrintCSV()
{
self::$DI['client']->request('POST', '/report/activity/documents/added', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportAddedDocumentsFilterColumns()
{
self::$DI['client']->request('POST', '/report/activity/documents/added', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'list_column' => 'user ddate',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportAddedDocumentsFilterResultOnOneColumn()
{
self::$DI['client']->request('POST', '/report/activity/documents/added', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'filter_column' => 'user',
'filter_value' => 'admin',
'liste' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportAddedDocumentsFilterConf()
{
self::$DI['client']->request('POST', '/report/activity/documents/added', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'conf' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportAddedDocumentsGroupBy()
{
self::$DI['client']->request('POST', '/report/activity/documents/added', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'groupby' => 'user',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportEditedDocuments()
{
self::$DI['client']->request('POST', '/report/activity/documents/edited', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'order' => 'ASC',
'champ' => 'user',
'page' => 1,
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportEditedDocumentsPrintCSV()
{
self::$DI['client']->request('POST', '/report/activity/documents/edited', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportEditedDocumentsFilterColumns()
{
self::$DI['client']->request('POST', '/report/activity/documents/edited', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'list_column' => 'user ddate',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportEditedDocumentsFilterResultOnOneColumn()
{
self::$DI['client']->request('POST', '/report/activity/documents/edited', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'filter_column' => 'user',
'filter_value' => 'admin',
'liste' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportEditedDocumentsFilterConf()
{
self::$DI['client']->request('POST', '/report/activity/documents/edited', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'conf' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportEditedDocumentsGroupBy()
{
self::$DI['client']->request('POST', '/report/activity/documents/edited', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'groupby' => 'user',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportValidatedDocuments()
{
self::$DI['client']->request('POST', '/report/activity/documents/validated', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'order' => 'ASC',
'champ' => 'user',
'page' => 1,
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportValidatedDocumentsPrintCSV()
{
self::$DI['client']->request('POST', '/report/activity/documents/validated', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportValidatedDocumentsFilterColumns()
{
self::$DI['client']->request('POST', '/report/activity/documents/validated', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'list_column' => 'user ddate',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportValidatedDocumentsFilterResultOnOneColumn()
{
self::$DI['client']->request('POST', '/report/activity/documents/validated', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'filter_column' => 'user',
'filter_value' => 'admin',
'liste' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportValidatedDocumentsFilterConf()
{
self::$DI['client']->request('POST', '/report/activity/documents/validated', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'conf' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportValidatedDocumentsGroupBy()
{
self::$DI['client']->request('POST', '/report/activity/documents/validated', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'groupby' => 'user',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Alchemy\Tests\Phrasea\Controller\Report;
class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
public function testExportCSV()
{
$data = 'Year,Make,Model
1997,Ford,E350
2000,Mercury,Cougar';
self::$DI['client']->request('POST', '/report/export/csv', array(
'csv' => $data,
'name' => 'test',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
$this->assertRegexp('/attachment/', $response->headers->get('content-disposition'));
$this->assertRegexp('/report_test/', $response->headers->get('content-disposition'));
}
}

View File

@@ -0,0 +1,309 @@
<?php
namespace Alchemy\Tests\Phrasea\Controller\Report;
class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
private $dmin;
private $dmax;
public function __construct()
{
$this->dmax = new \DateTime('now');
$this->dmin = new \DateTime('-1 month');
}
public function testDoReportUserBadRequest()
{
self::$DI['client']->request('POST', '/report/informations/user', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertFalse($response->isOk());
$this->assertEquals(400, $response->getStatusCode());
}
public function testDoReportUser()
{
self::$DI['client']->request('POST', '/report/informations/user', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'user' => self::$DI['user']->get_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportUserFromConnexion()
{
self::$DI['client']->request('POST', '/report/informations/user', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'user' => self::$DI['user']->get_id(),
'from' => 'CNX',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportUserFromQuestion()
{
self::$DI['client']->request('POST', '/report/informations/user', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'from' => 'ASK',
'user' => self::$DI['user']->get_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportUserFromDownload()
{
self::$DI['client']->request('POST', '/report/informations/user', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'from' => 'GEN',
'user' => self::$DI['user']->get_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportUserFromConnexionCSV()
{
self::$DI['client']->request('POST', '/report/informations/user', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'from' => 'CNX',
'printcsv' => 'on',
'user' => self::$DI['user']->get_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportUserFromQuestionCSV()
{
self::$DI['client']->request('POST', '/report/informations/user', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'from' => 'ASK',
'printcsv' => 'on',
'user' => self::$DI['user']->get_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportUserFromDownloadCSV()
{
self::$DI['client']->request('POST', '/report/informations/user', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'from' => 'GEN',
'printcsv' => 'on',
'user' => self::$DI['user']->get_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportUserFromDownloadOnCustomField()
{
self::$DI['client']->request('POST', '/report/informations/user', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'from' => 'GEN',
'on' => 'usr_mail',
'user' => self::$DI['user']->get_email()
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportUserFromConnexionOnCustomField()
{
self::$DI['client']->request('POST', '/report/informations/user', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'from' => 'CNX',
'on' => 'usr_mail',
'user' => self::$DI['user']->get_email()
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportUserFromQuestionOnCustomField()
{
self::$DI['client']->request('POST', '/report/informations/user', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'from' => 'ASK',
'on' => 'usr_mail',
'user' => self::$DI['user']->get_email()
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportInformationsBrowserBadRequest()
{
self::$DI['client']->request('POST', '/report/informations/browser', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertFalse($response->isOk());
$this->assertEquals(400, $response->getStatusCode());
}
public function testDoReportInfomationsBrowser()
{
self::$DI['client']->request('POST', '/report/informations/browser', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'user' => 'chrome',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportInfomationsDocumentsNotFound()
{
self::$DI['client']->request('POST', '/report/informations/document', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'sbasid' => 0,
'rid' => 0,
));
$response = self::$DI['client']->getResponse();
$this->assertFalse($response->isOk());
$this->assertEquals(404, $response->getStatusCode());
}
public function testDoReportInfomationsDocuments()
{
self::$DI['client']->request('POST', '/report/informations/document', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'sbasid' => self::$DI['record_1']->get_sbas_id(),
'rid' => self::$DI['record_1']->get_record_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportInfomationsDocumentsFromTool()
{
self::$DI['client']->request('POST', '/report/informations/document', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'sbasid' => self::$DI['record_1']->get_sbas_id(),
'rid' => self::$DI['record_1']->get_record_id(),
'from' => 'TOOL'
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportInfomationsDocumentsFromDashboard()
{
self::$DI['client']->request('POST', '/report/informations/document', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'sbasid' => self::$DI['record_1']->get_sbas_id(),
'rid' => self::$DI['record_1']->get_record_id(),
'from' => 'DASH'
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportInfomationsDocumentsFromOther()
{
self::$DI['client']->request('POST', '/report/informations/document', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'sbasid' => self::$DI['record_1']->get_sbas_id(),
'rid' => self::$DI['record_1']->get_record_id(),
'user' => self::$DI['user']->get_id()
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
}

View File

@@ -0,0 +1,461 @@
<?php
namespace Alchemy\Tests\Phrasea\Controller\Report;
class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
private $dmin;
private $dmax;
public function __construct()
{
$this->dmax = new \DateTime('now');
$this->dmin = new \DateTime('-1 month');
}
public function testRouteDashboard()
{
$auth = new \Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
self::$DI['client']->request('GET', '/report/dashboard');
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testRouteDashboardJson()
{
$auth = new \Session_Authentication_None(self::$DI['user']);
self::$DI['app']->openAccount($auth);
$this->XMLHTTPRequest('GET', '/report/dashboard', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmin->format('Y-m-d H:i:s'),
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testRouteInitReport()
{
self::$DI['client']->request('POST', '/report/init', array('popbases' => array('1_1')));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportConnexions()
{
self::$DI['client']->request('POST', '/report/connexions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'order' => 'ASC',
'champ' => 'user',
'page' => 1,
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportConnexionsPrintCSV()
{
self::$DI['client']->request('POST', '/report/connexions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportConnexionsFilterColumns()
{
self::$DI['client']->request('POST', '/report/connexions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'list_column' => 'user ddate',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportConnexionsFilterResultOnOneColumn()
{
self::$DI['client']->request('POST', '/report/connexions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'filter_column' => 'user',
'filter_value' => 'admin',
'liste' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportConnexionsFilterConf()
{
self::$DI['client']->request('POST', '/report/connexions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'conf' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportConnexionsGroupBy()
{
self::$DI['client']->request('POST', '/report/connexions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'groupby' => 'user',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportQuestions()
{
self::$DI['client']->request('POST', '/report/questions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'order' => 'ASC',
'champ' => 'user',
'page' => 1,
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportQuestionsPrintCSV()
{
self::$DI['client']->request('POST', '/report/questions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportQuestionsFilterColumns()
{
self::$DI['client']->request('POST', '/report/questions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'list_column' => 'user ddate',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportQuestionsFilterResultOnOneColumn()
{
self::$DI['client']->request('POST', '/report/questions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'filter_column' => 'user',
'filter_value' => 'admin',
'liste' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportQuestionsFilterConf()
{
self::$DI['client']->request('POST', '/report/questions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'conf' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportQuestionsGroupBy()
{
self::$DI['client']->request('POST', '/report/questions', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'groupby' => 'user',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDownloads()
{
self::$DI['client']->request('POST', '/report/downloads', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'order' => 'ASC',
'champ' => 'user',
'page' => 1,
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDownloadsPrintCSV()
{
self::$DI['client']->request('POST', '/report/downloads', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDownloadsFilterColumns()
{
self::$DI['client']->request('POST', '/report/downloads', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'list_column' => 'user ddate',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDownloadsFilterResultOnOneColumn()
{
self::$DI['client']->request('POST', '/report/downloads', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'filter_column' => 'user',
'filter_value' => 'admin',
'liste' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDownloadsFilterConf()
{
self::$DI['client']->request('POST', '/report/downloads', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'conf' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDownloadsGroupBy()
{
self::$DI['client']->request('POST', '/report/downloads', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'groupby' => 'user',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDocuments()
{
self::$DI['client']->request('POST', '/report/documents', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'order' => 'ASC',
'champ' => 'final',
'tbl' => 'DOC',
'page' => 1,
'limit' => 10,
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDocumentsPrintCSV()
{
self::$DI['client']->request('POST', '/report/documents', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDocumentsFilterColumns()
{
self::$DI['client']->request('POST', '/report/documents', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'list_column' => 'file mime',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDocumentsFilterResultOnOneColumn()
{
self::$DI['client']->request('POST', '/report/documents', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'filter_column' => 'mime',
'filter_value' => 'pdf',
'liste' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDocumentsFilterConf()
{
self::$DI['client']->request('POST', '/report/documents', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'conf' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportDocumentsGroupBy()
{
self::$DI['client']->request('POST', '/report/documents', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'groupby' => 'mime',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportClients()
{
self::$DI['client']->request('POST', '/report/clients', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
public function testDoReportClientPrintCSV()
{
self::$DI['client']->request('POST', '/report/clients', array(
'dmin' => $this->dmin->format('Y-m-d H:i:s'),
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(),
'printcsv' => 'on',
));
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
}
}

View File

@@ -46,6 +46,8 @@
RewriteRule ^download/.*$ /index.php [L] RewriteRule ^download/.*$ /index.php [L]
RewriteRule ^session/.*$ /index.php [L] RewriteRule ^session/.*$ /index.php [L]
RewriteRule ^report/.*$ /index.php [L]
RewriteRule ^client/.*$ /index.php [L] RewriteRule ^client/.*$ /index.php [L]
RewriteRule ^client/baskets.*$ /index.php [L] RewriteRule ^client/baskets.*$ /index.php [L]

View File

@@ -1,55 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
require_once __DIR__ . "/../../vendor/autoload.php";
$app = new Application();
/**
* @todo Remove this in next refactor
*/
$event = new GetResponseEvent($app, Request::createFromGlobals(), HttpKernelInterface::MASTER_REQUEST);
$app->addLocale($event);
$app->initSession($event);
$request = http_request::getInstance();
$parm = $request->get_parms('id');
$id = $parm['id'];
$dashboard = new module_report_dashboard($app, $app['phraseanet.user']->get_id());
$var = array(
'rs' => $dashboard->dashboard['activity_day'][$id],
'legendDay' => $dashboard->legendDay,
"sbas_id" => $id,
'ajax_chart' => true
);
$twig = $app['twig'];
$html = $twig->render('report/chart.html.twig', $var);
$t = array("rs" => $html);
echo json_encode($t);

View File

@@ -1,64 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
require_once __DIR__ . "/../../vendor/autoload.php";
$app = new Application();
/**
* @todo Remove this in next refactor
*/
$event = new GetResponseEvent($app, Request::createFromGlobals(), HttpKernelInterface::MASTER_REQUEST);
$app->addLocale($event);
$app->initSession($event);
if ( ! $app['phraseanet.user']->ACL()->has_right('report'))
phrasea::headers(403);
$sbasid = isset($_POST['sbasid']) ? $_POST['sbasid'] : null;
$dmin = isset($_POST['dmin']) ? $_POST['dmin'] : false;
$dmax = isset($_POST['dmax']) ? $_POST['dmax'] : false;
///////Construct dashboard
try {
$dashboard = new module_report_dashboard($app, $app['phraseanet.user'], $sbasid);
if ($dmin && $dmax) {
$dashboard->setDate($dmin, $dmax);
}
$dashboard->execute();
} catch (Exception $e) {
echo 'Exception reçue : ', $e->getMessage(), "\n";
}
$twig = $app['twig'];
$html = $twig->render(
"report/ajax_dashboard_content_child.html.twig", array(
'dashboard' => $dashboard
)
);
$t = array('html' => $html);
echo p4string::jsonencode($t);

View File

@@ -1,89 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
require_once __DIR__ . "/../../vendor/autoload.php";
$request = http_request::getInstance();
$parm = $request->get_parms(
"dmin"
, "dmax"
, "baslst"
, "popbases"
, "tbl"
, "precise"
, "preciseWord"
, "preciseUser"
, "page"
, "limit"
, "fonction"
, "pays"
, "societe"
, "activite"
, "on"
);
extract($parm);
/* Initialise les dates par defaults min au 1er jour du mois courant et max a la date courante */
if ($parm['dmin'] == "")
$parm['dmin'] = "01-" . date("m") . "-" . date("Y");
if ($parm['dmax'] == "")
$parm['dmax'] = date("d") . "-" . date("m") . "-" . date("Y");
$td = explode("-", $parm['dmin']);
$parm['dmin'] = date('Y-m-d H:i:s', mktime(0, 0, 0, $td[1], $td[0], $td[2]));
$td = explode("-", $parm['dmax']);
$parm['dmax'] = date('Y-m-d H:i:s', mktime(23, 59, 59, $td[1], $td[0], $td[2]));
//get user's sbas & collections selection from popbases
$selection = array();
$popbases = array_fill_keys($popbases, 0);
$liste = '';
$i = 0;
$id_sbas = "";
foreach ($popbases as $key => $val) {
$exp = explode("_", $key);
if ($exp[0] != $id_sbas && $i != 0) {
$selection[$id_sbas]['liste'] = $liste;
$liste = '';
}
$selection[$exp[0]][] = $exp[1];
$liste .= ( empty($liste) ? '' : ',') . $exp[1];
$id_sbas = $exp[0];
$i ++;
}
//fill the last entry
$selection[$id_sbas]['liste'] = $liste;
$app = new Application();
/**
* @todo Remove this in next refactor
*/
$event = new GetResponseEvent($app, Request::createFromGlobals(), HttpKernelInterface::MASTER_REQUEST);
$app->addLocale($event);
$app->initSession($event);
$twig = $app['twig'];
echo $twig->render('liste_base.twig', array('selection' => $selection, 'param' => $parm));

View File

@@ -1,749 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
require_once __DIR__ . "/../../vendor/autoload.php";
/* get all the post parameters from report.php's form */
$request = http_request::getInstance();
$parm = $request->get_parms("dmin", // date minimal of the reporting
"dmax", // date maximal of the reporting
"page", // current page of the reporting
"limit", // numbers of result by page displayed in the reporting
"tbl", // action requested
"collection", // list of collection which concerns the reporting
"user", // id of user which concern the reporting
"precise", // 1 = precision on content of the doc we're lookin for; 2 = precison on id of the document we're looking for
"order", // order result of the reporting
"champ", // precise the field we want order
"word", // precise the word we're lookin for in our documents
"sbasid", // the report relates to this base iD
"rid", // precise the id of the document we are looking for
"filter_column", // name of the colonne we want applied the filter
"filter_value", // value of the filter
"liste", // default = off, if on, apply the new filter
"liste_filter", // memorize the current(s) applied filters
"conf", // default = off, if on, apply the new configuration
"list_column", // contain the list of the column the user wants to see
"groupby", // name of the column that the user wants group
"societe", // the name of the selectionned firm
"fonction", // the name of the selectionned function
"activite", // the name of the selectionned activity
"pays", // the name of the selectionned country
"on", // this field contain the name of the column the user wants display the download by
"top", // this field contains the number of the top questions he wants to see
"from"
);
$app = new Application();
/**
* @todo Remove this in next refactor
*/
$event = new GetResponseEvent($app, Request::createFromGlobals(), HttpKernelInterface::MASTER_REQUEST);
$app->addLocale($event);
$app->initSession($event);
$twig = $app['twig'];
$conf_info_usr = array(
'config' => array(
'photo' => array(_('report:: document'), 0, 0, 0, 0),
'record_id' => array(_('report:: record id'), 0, 0, 0, 0),
'date' => array(_('report:: date'), 0, 0, 0, 0),
'type' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0),
'titre' => array(_('report:: titre'), 0, 0, 0, 0),
'taille' => array(_('report:: poids'), 0, 0, 0, 0)
),
'conf' => array(
'identifiant' => array(_('report:: identifiant'), 0, 0, 0, 0),
'nom' => array(_('report:: nom'), 0, 0, 0, 0),
'mail' => array(_('report:: email'), 0, 0, 0, 0),
'adresse' => array(_('report:: adresse'), 0, 0, 0, 0),
'tel' => array(_('report:: telephone'), 0, 0, 0, 0)
),
'config_cnx' => array(
'ddate' => array(_('report:: date'), 0, 0, 0, 0),
'ip' => array(_('report:: IP'), 0, 0, 0, 0),
'appli' => array(_('report:: modules'), 0, 0, 0, 0),
),
'config_dl' => array(
'ddate' => array(_('report:: date'), 0, 0, 0, 0),
'record_id' => array(_('report:: record id'), 0, 1, 0, 0),
'final' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0),
'coll_id' => array(_('report:: collections'), 0, 0, 0, 0),
'comment' => array(_('report:: commentaire'), 0, 0, 0, 0),
),
'config_ask' => array(
'search' => array(_('report:: question'), 0, 0, 0, 0),
'ddate' => array(_('report:: date'), 0, 0, 0, 0)
)
);
#############################################################################################################################
function getFilterField($param)
{
$filter_column = explode(' ', $param['filter_column']);
$column = $filter_column[0];
return $column;
}
function doOrder($obj, $param)
{
( ! empty($param['order']) && ! empty($param['champ'])) ? $obj->setOrder($param['champ'], $param['order']) : "";
}
function doLimit($obj, $param)
{
( ! empty($param['page']) && ! empty($param['limit'])) ? $obj->setLimit($param['page'], $param['limit']) : "";
}
function doFilter(Application $app, $obj, $param, $twig)
{
$cor = $obj->getTransQueryString();
$currentfilter = unserializeFilter($param['liste_filter']);
$filter = new module_report_filter($app, $currentfilter, $cor);
if ( ! empty($param['filter_column'])) {
$field = getFilterField($param);
$value = $param['filter_value'];
if ($param['liste'] == "on") {
$tab = $obj->colFilter($field);
displayColValue($tab, $field, $twig);
}
if ($field == $value)
$filter->removeFilter($field);
else
$filter->addFilter($field, '=', $value);
}
return $filter;
}
function passFilter($filter, $obj)
{
$tab_filter = $filter->getTabFilter();
$obj->setFilter($tab_filter);
}
function doPreff(Application $app, $conf, $param)
{
$pref = module_report::getPreff($app, $param['sbasid']);
foreach ($pref as $key => $field)
$conf_pref[$field] = array($field, 0, 0, 0, 0);
$conf = array_merge($conf, $conf_pref);
return $conf;
}
function doReport(Application $app, $obj, $param, $conf, $twig, $what = false)
{
$conf = doUserConf($app, $conf, $param);
displayListColumn($conf, $param, $twig);
doOrder($obj, $param);
$filter = doFilter($app, $obj, $param, $twig);
passFilter($filter, $obj);
$posting_filter = $filter->getPostingFilter();
$active_column = $filter->getActiveColumn();
if ($param['precise'] == 1)
$dl->addfilter('xml', 'LIKE', $param['word']);
elseif ($param['precise'] == 2)
$dl->addfilter('record_id', '=', $param['word']);
groupBy($obj, $param, $twig);
doLimit($obj, $param);
if ( ! $what)
$tab = $obj->buildTab($conf);
else
$tab = $obj->buildTab($conf, $what, $param['tbl']);
return (array('rs' => $tab, 'filter' => $posting_filter, 'column' => $active_column));
}
function doHtml($report, $param, $twig, $template, $type = false)
{
$var = array(
'result' => (isset($report['rs'])) ? $report['rs'] : $report,
'report' => $report,
'currentfilter' => isset($report['filter']) ? $report['filter'] : "",
'param' => $param,
'is_infouser' => false,
'is_nav' => false,
'is_groupby' => false,
'is_plot' => false,
'meta' => true
);
if ($type) {
switch ($type) {
case "user" :
$var['is_infouser'] = true;
break;
case "nav" :
$var['is_nav'] = true;
break;
case "group" :
$var['is_groupby'] = true;
break;
case "plot" :
$var['is_plot'] = true;
break;
}
}
return ($twig->render($template, $var));
}
function sendReport($html, $report = false, $title = false, $display_nav = false)
{
if ($report) {
$t = array(
'rs' => $html,
'next' => intval($report['rs']['next_page']), //Number of the next page
'prev' => intval($report['rs']['previous_page']), //Number of the previoous page
'page' => intval($report['rs']['page']), //The current page
'limit' => $report['rs']['nb_record']
);
} else {
$t = array(
'rs' => $html,
'display_nav' => $display_nav,
'title' => $title
);
}
echo json_encode($t);
}
function getBasId($param)
{
try {
$record = new record_adapter(new Application(), $param['sbasid'], $param['rid']);
return $record->get_base_id();
} catch (Exception $e) {
}
return false;
}
function unserializeFilter($serialized_filter)
{
$tab_filter = array();
if ( ! empty($serialized_filter)) {
$tab_filter = @unserialize(urldecode($serialized_filter));
}
return $tab_filter;
}
function doUserConf(Application $app, $conf, $param)
{
if ($app['phraseanet.registry']->get('GV_anonymousReport') == true) {
if (isset($conf['user']))
unset($conf['user']);
if (isset($conf['ip']))
unset($conf['ip']);
}
if ( ! empty($param['list_column'])) {
$new_conf = array();
$new_conf = $conf;
$x = explode(",", $param['list_column']);
foreach ($conf as $key => $value) {
if ( ! in_array($key, $x))
unset($new_conf[$key]);
}
return $new_conf;
}
else {
return $conf;
}
}
function displayListColumn($conf, $param, $twig)
{
if ($param['conf'] == "on") {
$html = $twig->render('report/listColumn.html.twig', array(
'conf' => $conf,
'param' => $param,
));
$t = array('liste' => $html, "title" => _("configuration"));
echo json_encode($t);
exit();
}
}
function groupBy($obj, $param, $twig, $on = false)
{
//Contains the name of the column where the group by is applied
( ! empty($param['groupby']) ? $groupby = explode(' ', $param['groupby']) : $groupby = false);
//If users ask for group by, display the good array, result is encoded in Json , exit the function.
if ($groupby) {
$report = $obj->buildTab(false, $groupby[0], $on);
$html = doHtml($report, $param, $twig, 'report/report.html.twig', 'group');
$title = "Groupement des resultats sur le champ " . $report['display'][$report['allChamps'][0]]['title'];
sendReport($html, false, $title);
exit();
}
}
function displayColValue($tab, $column, $twig, $on = false)
{
$test = $twig->render('report/colFilter.html.twig', array(
'result' => $tab,
'field' => $column
));
$t = array('diag' => $test, "title" => sprintf(_("filtrer les resultats sur la colonne %s"), $column));
echo json_encode($t);
exit();
}
function getHistory(Application $app, $obj, $param, $twig, $conf, $dl = false, $title)
{
$filter = doFilter($app, $obj, $param, $twig);
if ( ! empty($param['user']) && empty($param['on']))
$filter->addfilter('usrid', '=', $param['user']);
elseif ( ! empty($param['on']) && ! empty($param['user']))
$filter->addfilter($param['on'], '=', $param['user']);
if ($dl)
$filter->addfilter("(log_docs.final = 'document'", "OR", "log_docs.final = 'preview')");
passFilter($filter, $obj);
$obj->setOrder('ddate', 'DESC');
$report = $obj->buildTab($conf);
$report['title'] = $title;
$report['config'] = 0;
$html = doHtml($report, $param, $twig, 'report.twig');
$request = $obj->req;
return(array('html' => $html, 'req' => $request));
}
################################################ACTION FUNCTIONS#######################################################
function cnx(Application $app, $param, $twig)
{
$cnx = new module_report_connexion($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$conf = array(
'user' => array(_('phraseanet::utilisateurs'), 1, 1, 1, 1),
'ddate' => array(_('report:: date'), 1, 0, 1, 1),
'ip' => array(_('report:: IP'), 1, 0, 0, 0),
'appli' => array(_('report:: modules'), 1, 0, 0, 0)
);
$report = doReport($app, $cnx, $param, $conf, $twig);
$html = doHtml($report, $param, $twig, 'report/report.html.twig');
sendReport($html, $report);
}
/* generate all the html string to display all the valid download in <table></table>, the result is encoded in json */
function gen(Application $app, $param, $twig)
{
$dl = new module_report_download($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$conf = array(
'user' => array(_('report:: utilisateurs'), 1, 1, 1, 1),
'ddate' => array(_('report:: date'), 1, 0, 1, 1),
'record_id' => array(_('report:: record id'), 1, 1, 1, 1),
'final' => array(_('phrseanet:: sous definition'), 1, 0, 1, 1),
'coll_id' => array(_('report:: collections'), 1, 0, 1, 1)
);
//$conf = doPreff($conf, $param);
$report = doReport($app, $dl, $param, $conf, $twig);
$html = doHtml($report, $param, $twig, 'report/report.html.twig');
sendReport($html, $report);
}
/* generate all the html string to display all the valid question in <table></table>, the result is encoded in json */
function ask(Application $app, $param, $twig)
{
$ask = new module_report_question($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$conf = array(
'user' => array(_('report:: utilisateur'), 1, 1, 1, 1),
'search' => array(_('report:: question'), 1, 0, 1, 1),
'ddate' => array(_('report:: date'), 1, 0, 1, 1)
);
$report = doReport($app, $ask, $param, $conf, $twig);
$html = doHtml($report, $param, $twig, 'report/report.html.twig');
sendReport($html, $report);
}
/* generate the html code to display the download by doc (records or string in xml description), the result is encoded in json */
function doc(Application $app, $param, $twig)
{
$conf = array(
'telechargement' => array(_('report:: telechargements'), 1, 0, 0, 0),
'record_id' => array(_('report:: record id'), 1, 1, 1, 0),
'final' => array(_('phrseanet:: sous definition'), 1, 0, 1, 1),
'file' => array(_('report:: fichier'), 1, 0, 0, 1),
'mime' => array(_('report:: type'), 1, 0, 1, 1),
'size' => array(_('report:: taille'), 1, 0, 1, 1)
);
$dl = new module_report_download($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$conf = doPreff($app, $conf, $param);
$report = doReport($app, $dl, $param, $conf, $twig, 'record_id');
$html = doHtml($report, $param, $twig, 'report/report.html.twig');
sendReport($html, $report);
}
/* generate the html string to display the result from different report (see below) in <table></table>, the result is encoded in json */
function cnxb(Application $app, $param, $twig)
{
$nav = new module_report_nav($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$conf_nav = array('nav' => array(_('report:: navigateur'), 0, 1, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0)
);
$conf_combo = array('combo' => array(_('report:: navigateurs et plateforme'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0)
);
$conf_os = array('os' => array(_('report:: plateforme'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0)
);
$conf_res = array('res' => array(_('report:: resolution'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0)
);
$conf_mod = array('appli' => array(_('report:: module'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0)
);
$report = array(
'nav' => $nav->buildTabNav($conf_nav),
'os' => $nav->buildTabOs($conf_os),
'res' => $nav->buildTabRes($conf_res),
'mod' => $nav->buildTabModule($conf_mod),
'combo' => $nav->buildTabCombo($conf_combo)
);
$html = doHtml($report, $param, $twig, 'report/report.html.twig', 'nav');
sendReport($html);
}
/* generate the html string to display the number of connexion by user in <table></table>, the result is encoded in json */
function cnxu(Application $app, $param, $twig)
{
$conf = array(
$param['on'] => array("", 0, 0, 0, 0),
'connexion' => array(_('report::Connexions'), 0, 0, 0, 0)
);
$connex = new module_report_activity($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
doLimit($connex, $param);
$report = $connex->getConnexionBase(false, $param['on']);
isset($report['display']['user']) ? $report['display']['user']['title'] = _('phraseanet::utilisateurs') : "";
isset($report['display']['user']) ? $report['display']['user']['bound'] = 1 : "";
$html = doHtml($report, $param, $twig, 'report/report.html.twig');
sendReport($html);
}
/* generate all the html string to display the top 20 question by databox in <table></table>, the result is encoded in json */
function bestOf(Application $app, $param, $twig)
{
$conf = array(
'search' => array(_('report:: question'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'nb_rep' => array(_('report:: nombre de reponses'), 0, 0, 0, 0)
);
$activity = new module_report_activity($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$activity->setLimit(1, $param['limit']);
$activity->nb_top = $param['limit'];
$report = $activity->getTopQuestion($conf);
$html = doHtml($report, $param, $twig, 'report/report.html.twig');
sendReport($html);
}
/* generate all the html string to display all the resot of questions <table></table>, the result is encoded in json */
function noBestOf(Application $app, $param, $twig)
{
$conf = array('search' => array(_('report:: question'), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0),
'nb_rep' => array(_('report:: nombre de reponses'), 0, 0, 0, 0)
);
$activity = new module_report_activity($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
doLimit($activity, $param);
$report = $activity->getTopQuestion($conf, true);
$html = doHtml($report, $param, $twig, 'report/report.html.twig');
sendReport($html);
}
/* generate all the html string to display the users connexions activity by hour in <table></table>, the result is encoded in json */
function tableSiteActivityPerHours(Application $app, $param, $twig)
{
$activity = new module_report_activity($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$report = $activity->getActivityPerHours();
$html = doHtml($report, $param, $twig, 'report/report.html.twig', 'plot');
sendReport($html);
}
/* generate all the html string to display all number of download day by day in <table></table>, the result is encoded in json */
function day(Application $app, $param, $twig)
{
$conf = array('ddate' => array(_('report:: jour'), 0, 0, 0, 0),
'total' => array(_('report:: total des telechargements'), 0, 0, 0, 0),
'preview' => array(_('report:: preview'), 0, 0, 0, 0),
'document' => array(_('report:: document original'), 0, 0, 0, 0)
);
$activity = new module_report_activity($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$activiy->list_coll_id = $param['collection'];
doLimit($activity, $param);
$report = $activity->getDownloadByBaseByDay($conf);
$html = doHtml($report, $param, $twig, 'report/report.html.twig');
sendReport($html);
}
/* generate all the html string to display all the details of download user by user in <table></table>, the result is encoded in json */
function usr(Application $app, $param, $twig)
{
$conf = array('user' => array(_('report:: utilisateur'), 0, 1, 0, 0),
'nbdoc' => array(_('report:: nombre de documents'), 0, 0, 0, 0),
'poiddoc' => array(_('report:: poids des documents'), 0, 0, 0, 0),
'nbprev' => array(_('report:: nombre de preview'), 0, 0, 0, 0),
'poidprev' => array(_('report:: poids des previews'), 0, 0, 0, 0)
);
$activity = new module_report_activity($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
doLimit($activity, $param);
empty($param['on']) ? $on = "user" : $on = $param['on']; //by default always report on user
$report = $activity->getDetailDownload($conf, $on);
$html = doHtml($report, $param, $twig, 'report/report.html.twig');
sendReport($html);
}
/* Display basic informations about an user */
function infoUsr(Application $app, $param, $twig, $conf)
{
if ($app['phraseanet.registry']->get('GV_anonymousReport') == true) {
$conf = array(
$param['on'] => array($param['on'], 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0)
);
}
empty($param['on']) ? $param['on'] = false : "";
$request = "";
$params = array();
$html = "";
$html_info = "";
$is_dl = false;
if ($param['from'] == 'CNXU' || $param['from'] == 'CNX') {
$histo = new module_report_connexion($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$conf_array = $conf['config_cnx'];
$title = _("report:: historique des connexions");
} elseif ($param['from'] == "USR" || $param['from'] == "GEN") {
$histo = new module_report_download($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$conf_array = $conf['config_dl'];
$is_dl = true;
$title = _("report:: historique des telechargements");
} elseif ($param['from'] == "ASK") {
$histo = new module_report_question($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$conf_array = $conf['config_ask'];
$title = _("report:: historique des questions");
}
if (isset($histo)) {
$rs = getHistory($app, $histo, $param, $twig, $conf_array, $is_dl, $title);
$html = $rs['html'];
$request = $rs['req'];
$params = $rs['params'];
}
$info = new module_report_nav($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$report = $info->buildTabGrpInfo($request, $params, $param['user'], $conf['conf'], $param['on']);
$report['periode'] = ""; //delete the periode
if ($app['phraseanet.registry']->get('GV_anonymousReport') == false) {
$html_info .= doHtml($report, $param, $twig, 'report/report.html.twig');
(empty($param['on']) && isset($report['result'])) ? $title = $report['result'][0]['identifiant'] : $title = $param['user'];
}
else
$title = $param['user'];
sendReport($html_info . $html, false, $title);
}
/* Display some basics informations about a Document */
function what(Application $app, $param, $twig)
{
$config = array(
'photo' => array(_('report:: document'), 0, 0, 0, 0),
'record_id' => array(_('report:: record id'), 0, 0, 0, 0),
'date' => array(_('report:: date'), 0, 0, 0, 0),
'type' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0),
'titre' => array(_('report:: titre'), 0, 0, 0, 0),
'taille' => array(_('report:: poids'), 0, 0, 0, 0)
);
$config_dl = array(
'ddate' => array(_('report:: date'), 0, 0, 0, 0),
'user' => array(_('report:: utilisateurs'), 0, 0, 0, 0),
'final' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0),
'coll_id' => array(_('report:: collections'), 0, 0, 0, 0),
'comment' => array(_('report:: commentaire'), 0, 0, 0, 0)
);
$config_dl = doUserConf($app, $config_dl, $param);
$html = "";
$basid = getBasId($param);
$what = new module_report_nav($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$report = $what->buildTabUserWhat($basid, $param['rid'], $config);
$report['periode'] = "";
if ($param['from'] == 'TOOL')
$report['title'] = "";
$title = $report['result'][0]["titre"];
$html = doHtml($report, $param, $twig, 'report/info.html.twig');
if ($param['from'] == 'TOOL')
sendReport($html);
if ($param['from'] != 'DASH') {
$histo = new module_report_download($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$filter = doFilter($app, $histo, $param, $twig);
if ( ! empty($param['rid']))
$filter->addfilter('record_id', '=', $param['rid']);
passFilter($filter, $histo);
$histo->setOrder('ddate', 'DESC');
$report = $histo->buildTab($config_dl);
$report['title'] = _("report:: historique des telechargements");
$report['config'] = 0;
$html .= doHtml($report, $param, $twig, 'report/report.html.twig');
}
if ($app['phraseanet.registry']->get('GV_anonymousReport') == false && $param['from'] != 'DOC' && $param['from'] != 'DASH' && $param['from'] != "GEN") {
$conf = array(
'identifiant' => array(_('report:: identifiant'), 0, 0, 0, 0),
'nom' => array(_('report:: nom'), 0, 0, 0, 0),
'mail' => array(_('report:: email'), 0, 0, 0, 0),
'adresse' => array(_('report:: adresse'), 0, 0, 0, 0),
'tel' => array(_('report:: telephone'), 0, 0, 0, 0)
);
$info = new module_report_nav($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$report = $info->buildTabGrpInfo(false, array(), $param['user'], $conf, false);
$report['periode'] = "";
$report['config'] = 0;
$report['title'] = _('report:: utilisateur');
$html .= doHtml($report, $param, $twig, 'report/report.html.twig');
}
sendReport($html, false, $title);
}
/* Display image when click in the dashboard */
function infoNav(Application $app, $param, $twig)
{
$conf = array(
'version' => array(_('report::version '), 0, 0, 0, 0),
'nb' => array(_('report:: nombre'), 0, 0, 0, 0)
);
$infonav = new module_report_nav($app, $param['dmin'], $param['dmax'], $param['sbasid'], $param['collection']);
$report = $infonav->buildTabInfoNav($conf, $param['user']);
$html = doHtml($report, $param, $twig, 'report/report.html.twig');
sendReport($html, false, $param['user']);
}
################################################SWITCH ACTIONS##############################################################
switch ($param['tbl']) {
case "CNX":
cnx($app, $param, $twig);
break;
case "CNXU":
cnxu($app, $param, $twig);
break;
case "CNXB":
cnxb($app, $param, $twig);
break;
case "GEN":
gen($app, $param, $twig);
break;
case "DAY":
day($app, $param, $twig);
break;
case "DOC":
doc($app, $param, $twig);
break;
case "BESTOF":
bestOf($app, $param, $twig);
break;
case "NOBESTOF":
noBestOf($app, $param, $twig);
break;
case "SITEACTIVITY":
tableSiteActivityPerHours($app, $param, $twig);
break;
case "USR":
usr($app, $param, $twig);
break;
case "ASK":
ask($app, $param, $twig);
break;
case "infouser":
infoUsr($app, $param, $twig, $conf_info_usr);
break;
case "what":
what($app, $param, $twig);
break;
case "infonav":
infoNav($app, $param, $twig);
break;
}
?>

View File

@@ -1,66 +0,0 @@
<?php
require_once(__DIR__ . "/../../../lib/classes/graphik/Graph.php");
require_once(__DIR__ . "/../../../lib/classes/graphik/LinePlot.php");
require_once(__DIR__ . "/../../../lib/classes/http/request.php");
$request = http_request::getInstance();
$parm = $request->get_parms("value", 'legend', 'absc');
$values = unserialize(urldecode($parm['value']));
$legend = unserialize(urldecode($parm['legend']));
$absc = $parm['absc'];
$graph = new Graph(800, 300);
$graph->setAntiAliasing(FALSE);
$graph->border->hide();
if (isset($values["Heures"]))
unset($values["Heures"]);
for ($i = 0; $i < sizeof($values); $i++)
{
if ($values[$i] < 1)
$values[$i] = (float) ($values[$i]);
else
$values[$i] = (int) ($values[$i]);
}
$x = $values;
$y = $legend;
$plot = new LinePlot($x);
$plot->grid->hide(true);
$plot->setSpace(4, 4, 10, 0);
$plot->setPadding(40, 15, 30, 50);
$plot->mark->setType(Mark::SQUARE);
$plot->mark->setSize(4);
$plot->mark->setFill(new Blue);
$plot->mark->border->show();
$plot->setColor(new Color(85, 85, 85));
$plot->setFillColor(new Color(180, 180, 180, 75));
$plot->label->set($x);
$plot->label->move(0, -10);
$plot->label->setFont(new Tuffy(6));
$plot->label->setAlign(NULL, Label::MIDDLE);
$plot->xAxis->setLabelText($y);
$plot->xAxis->label->setAngle(90);
$plot->xAxis->label->setFont(new Tuffy(7));
$plot->yAxis->title->set("Nombre de connexions");
$plot->yAxis->title->setFont(new TuffyBold(10));
$plot->yAxis->title->move(-10, 0);
$plot->yAxis->setTitleAlignment(Label::TOP);
$plot->xAxis->title->set($absc);
$plot->xAxis->title->setFont(new TuffyBold(10));
$plot->xAxis->title->move(0, 10);
$plot->xAxis->setTitleAlignment(Label::RIGHT);
$graph->add($plot);
$graph->draw();
?>

View File

@@ -1,47 +0,0 @@
<?php
require_once(__DIR__ . "/../../../lib/classes/graphik/Graph.php");
require_once(__DIR__ . "/../../../lib/classes/graphik/Pie.php");
require_once(__DIR__ . "/../../../lib/classes/http/request.php");
$request = http_request::getInstance();
$parm = $request->get_parms("value", 'legend', 'title');
$values = unserialize(urldecode($parm['value']));
$legend = unserialize(urldecode($parm['legend']));
$title = unserialize(urldecode($parm['title']));
$graph = new Graph(400, 400);
$graph->setAntiAliasing(FALSE);
$graph->border->hide();
$graph->title->set($title);
$graph->title->setFont(new TuffyBold(9));
$graph->title->setColor(new Color(255, 141, 28));
$plot = new Pie($values, Pie::EARTH);
$graph->setBackgroundColor(
new Color(246, 242, 241)
);
$plot->setCenter(0.5, 0.4);
$plot->setSize(0.5, 0.5);
$plot->set3D(12);
$plot->setBorderColor(new black);
$plot->explode(array(0 => 10, 1 => 10, 2 => 10, 3 => 15, 4 => 15, 5 => 20, 6 => 20, 7 => 20, 8 => 20, 9 => 20));
$plot->setStartAngle(234);
$plot->legend->setModel(Legend::MODEL_BOTTOM);
$plot->setLegend($legend);
$plot->setLabelPosition(8);
$plot->label->setPadding(3, 3, 3, 3);
$plot->setAbsSize(200, 200);
$plot->label->setFont(new Tuffy(9));
$plot->legend->setPosition(0.5, 1.15);
$plot->legend->setColumns(2);
$graph->add($plot);
$graph->draw();
?>

View File

@@ -1,39 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
require_once __DIR__ . "/../../vendor/autoload.php";
$request = http_request::getInstance();
$parm = $request->get_parms('name', 'csv');
function trimUltime($str)
{
$str = preg_replace('/[ \t\r\f]+/', '', $str);
return $str;
}
$parm['name'] ? $name = '_' . $parm['name'] : $name = "";
$name = preg_replace('/\s+/', '_', $name);
$filename = mb_strtolower('report' . $name . '_' . date('dmY') . '.csv');
$content = "";
if ($parm['csv']) {
$content = trimUltime($parm['csv']);
set_export::stream_data($content, $filename, "text/csv");
}
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -1,60 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
require_once __DIR__ . "/../../vendor/autoload.php";
$app = new Application();
/**
* @todo Remove this in next refactor
*/
$event = new GetResponseEvent($app, Request::createFromGlobals(), HttpKernelInterface::MASTER_REQUEST);
$app->addLocale($event);
$app->initSession($event);
require($app['phraseanet.registry']->get('GV_RootPath') . 'lib/classes/deprecated/countries.php');
phrasea::headers();
User_Adapter::updateClientInfos($app, 4);
///////Construct dashboard
$dashboard = new module_report_dashboard($app, $app['phraseanet.user']);
$dashboard->execute();
$var = array(
'ajax_dash' => true,
'dashboard' => $dashboard,
'home_title' => $app['phraseanet.registry']->get('GV_homeTitle'),
'module' => "report",
"module_name" => "Report",
'anonymous' => $app['phraseanet.registry']->get('GV_anonymousReport'),
'g_anal' => $app['phraseanet.registry']->get('GV_googleAnalytics'),
'ajax' => false,
'ajax_chart' => false
);
$twig = $app['twig'];
echo $twig->render('report/report_layout_child.html.twig', $var);

View File

@@ -170,6 +170,9 @@ function submiterAction(domSubmiter)
var container = domSubmiter.closest('.inside-container'); var container = domSubmiter.closest('.inside-container');
data = form.serializeArray(); data = form.serializeArray();
data[data.length] = {name: "action", value: domSubmiter.data('action')};
//check if a base is selected, pop an alert message if not //check if a base is selected, pop an alert message if not
if(!isOneBaseSelected(form)) if(!isOneBaseSelected(form))
{ {
@@ -186,8 +189,8 @@ function submiterAction(domSubmiter)
request = $.ajax({ request = $.ajax({
type: "POST", type: "POST",
url: "./report.php", url: "/report/init",
data:form.serializeArray(), data:data,
beforeSend:function(){ beforeSend:function(){
container.find('.content').empty(); container.find('.content').empty();
container.find('.answers').addClass('onload'); container.find('.answers').addClass('onload');
@@ -311,7 +314,7 @@ function tableLinkAction(domLink)
{ {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "./tab.php", url: "/report/informations/document",
dataType : "json", dataType : "json",
data: ({ data: ({
tbl : "what", tbl : "what",
@@ -332,7 +335,7 @@ function tableLinkAction(domLink)
{ {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "./tab.php", url: "/report/informations/user",
dataType : "json", dataType : "json",
data: ({ data: ({
tbl : "infouser", tbl : "infouser",
@@ -397,7 +400,7 @@ function changeDash(sbasid)
$.ajax({ $.ajax({
type:"POST", type:"POST",
dataType:"json", dataType:"json",
url:"ajax_info_dashboard.php", url:"/report/dashboard",
data:{ data:{
sbasid: sbasid, sbasid: sbasid,
dmin:dmin, dmin:dmin,
@@ -627,7 +630,7 @@ function who()
//load content //load content
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "./tab.php", url: form.find("input[name=action]").val(),
dataType: "json", dataType: "json",
data:form.serializeArray(), data:form.serializeArray(),
success: function(data){ success: function(data){
@@ -649,7 +652,7 @@ function group()
form.find("input[name=groupby]").val(col); form.find("input[name=groupby]").val(col);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "./tab.php", url: form.find("input[name=action]").val(),
dataType: "json", dataType: "json",
data:form.serializeArray(), data:form.serializeArray(),
success: function(data){ success: function(data){
@@ -675,7 +678,7 @@ function what()
form.find("input[name=user]").val(usrid); form.find("input[name=user]").val(usrid);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "./tab.php", url: "/report/informations/document",
dataType: "json", dataType: "json",
data: form.serializeArray(), data: form.serializeArray(),
success: function(data){ success: function(data){
@@ -789,7 +792,7 @@ function dofilter(submit, form, f_val)
form.find("input[name=liste]").val("on"); form.find("input[name=liste]").val("on");
$.ajax({ $.ajax({
type : "POST", type : "POST",
url : "./tab.php", url : form.find("input[name=action]").val(),
dataType : "json", dataType : "json",
data : form.serializeArray(), data : form.serializeArray(),
success : function(data){ success : function(data){
@@ -806,7 +809,7 @@ function conf(submit, form, f_val)
form.find("input[name=conf]").val("on"); form.find("input[name=conf]").val("on");
$.ajax({ $.ajax({
type : "POST", type : "POST",
url : "./tab.php", url : form.find("input[name=action]").val(),
dataType : "json", dataType : "json",
data : form.serializeArray(), data : form.serializeArray(),
success : function(data){ success : function(data){
@@ -881,7 +884,7 @@ function csv()
var query = $.ajax({ var query = $.ajax({
type : "POST", type : "POST",
url : "./tab.php", url : $form.find("input[name=action]").val(),
dataType : "json", dataType : "json",
data : $form.serializeArray(), data : $form.serializeArray(),
beforeSend:function(){ beforeSend:function(){
@@ -1032,6 +1035,7 @@ function go(submit, form, f_val, data)
{ {
$(".submiter").bind("click", function(){ $(".submiter").bind("click", function(){
form.find("input[name=liste_filter]").attr("value", data.filter); form.find("input[name=liste_filter]").attr("value", data.filter);
form.find("input[name=action]").attr("value", $(this).data('action'));
f_val = form.serialize(true); f_val = form.serialize(true);
update_tab(submit, form, f_val); update_tab(submit, form, f_val);
}); });
@@ -1051,9 +1055,10 @@ function update_tab(submit, form, f_val)
form.find("input[name=liste_filter]").attr("value", array_val["liste_filter"]); form.find("input[name=liste_filter]").attr("value", array_val["liste_filter"]);
var datas = form.serializeArray(); var datas = form.serializeArray();
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "./tab.php", url: form.find("input[name=action]").val(),
dataType: "json", dataType: "json",
data:datas, data:datas,
beforeSend:function(){ beforeSend:function(){

View File

@@ -1,99 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
require_once __DIR__ . "/../../vendor/autoload.php";
$app = new Application();
/**
* @todo Remove this in next refactor
*/
$event = new GetResponseEvent($app, Request::createFromGlobals(), HttpKernelInterface::MASTER_REQUEST);
$app->addLocale($event);
$app->initSession($event);
$request = http_request::getInstance();
$parm = $request->get_parms(
"dmin"
, "dmax"
, "baslst"
, "popbases"
, "tbl"
, "precise"
, "preciseWord"
, "preciseUser"
, "page"
, "limit"
, "fonction"
, "pays"
, "societe"
, "activite"
, "on"
, "docwhat"
);
extract($parm);
/* Initialise les dates par defaults min au 1er jour du mois courant et max a la date courante */
if ($parm['dmin'] == "")
$parm['dmin'] = "01-" . date("m") . "-" . date("Y");
if ($parm['dmax'] == "")
$parm['dmax'] = date("d") . "-" . date("m") . "-" . date("Y");
$td = explode("-", $parm['dmin']);
$parm['dmin'] = date('Y-m-d H:i:s', mktime(0, 0, 0, $td[1], $td[0], $td[2]));
$td = explode("-", $parm['dmax']);
$parm['dmax'] = date('Y-m-d H:i:s', mktime(23, 59, 59, $td[1], $td[0], $td[2]));
//get user's sbas & collections selection from popbases
$selection = array();
$popbases = array_fill_keys($popbases, 0);
$liste = '';
$i = 0;
$id_sbas = "";
foreach ($popbases as $key => $val) {
$exp = explode("_", $key);
if ($exp[0] != $id_sbas && $i != 0) {
$selection[$id_sbas]['liste'] = $liste;
$liste = '';
}
$selection[$exp[0]][] = $exp[1];
$liste .= ( empty($liste) ? '' : ',') . $exp[1];
$id_sbas = $exp[0];
$i ++;
}
//fill the last entry
$selection[$id_sbas]['liste'] = $liste;
$twig = $app['twig'];
echo $twig->render(
'report/ajax_report_content.html.twig', array(
'selection' => $selection,
'param' => $parm,
'anonymous' => $app['phraseanet.registry']->get('GV_anonymousReport'),
'ajax' => true
)
);

File diff suppressed because it is too large Load Diff

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 992 B

After

Width:  |  Height:  |  Size: 992 B

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 185 B